Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 40 additions & 23 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"

"github.com/agenticgokit/agenticgokit/observability"
"github.com/fatih/color"
Expand Down Expand Up @@ -48,24 +50,24 @@ Examples:
agk init my-project

# Initialize with built-in template
agk init my-project --template single-agent
agk init my-project --template quickstart

# Initialize from a community template (registry)
agk init my-project --template rag-agent
agk init my-project --template <registry-template-name>

# Initialize from a GitHub repository
agk init my-project --template github.com/username/my-template

# Initialize from a specific version
agk init my-project --template github.com/username/my-template@v1.0.0

# Non-interactive initialization
agk init my-project --template single-agent --llm openai --agent-type single --force
# Non-interactive initialization
agk init my-project --template quickstart --llm openai --force

# Initialize in specific directory
agk init my-project --output ./projects

# List available templates
# List available templates
agk init --list`,
Args: func(cmd *cobra.Command, args []string) error {
// Allow zero args only when listing templates
Expand Down Expand Up @@ -226,33 +228,48 @@ func listTemplates() {
color.Cyan("\n📋 Available AgenticGoKit Templates\n")
color.Cyan("═══════════════════════════════════\n\n")

// Built-in templates
templates := scaffold.GetAllTemplates()
color.Cyan("Built-in:\n")
for i, tmpl := range templates {
// Template name and complexity
color.Green("%d. %s %s\n", i+1, tmpl.Name, tmpl.Complexity)

// Description
fmt.Printf(" %s\n", color.YellowString(tmpl.Description))

// Features
if len(tmpl.Features) > 0 {
fmt.Printf(" Features: %v\n", color.CyanString("%v", tmpl.Features))
}

// File count
fmt.Printf(" Files: %s\n", color.MagentaString("%d", tmpl.FileCount))

// Usage example
templateID := ""
switch tmpl.Name {
case "Quickstart":
templateID = "quickstart"
case "Workflow":
templateID = "workflow"
fmt.Printf(" Usage: %s\n", color.HiBlackString("agk init my-project --template %s", strings.ToLower(tmpl.Name)))
if i < len(templates)-1 {
fmt.Println()
}
fmt.Printf(" Usage: %s\n", color.HiBlackString("agk init my-project --template %s", templateID))
}

if i < len(templates)-1 {
// Registry templates
color.Cyan("\nRegistry:\n")
index, err := registry.FetchIndex(registry.DefaultRegistryURL)
if err != nil {
fmt.Printf(" %s\n", color.YellowString("Unable to fetch registry templates: %v", err))
fmt.Println()
return
}

if len(index.Templates) == 0 {
fmt.Printf(" %s\n", color.YellowString("No templates found in registry."))
fmt.Println()
return
}

registryNames := make([]string, 0, len(index.Templates))
for name := range index.Templates {
registryNames = append(registryNames, name)
}
sort.Strings(registryNames)
for i, name := range registryNames {
source := index.Templates[name]
color.Green("%d. %s\n", i+1, name)
fmt.Printf(" Source: %s\n", color.HiBlackString(source))
fmt.Printf(" Usage: %s\n", color.HiBlackString("agk init my-project --template %s", name))
if i < len(registryNames)-1 {
fmt.Println()
}
}
Expand Down Expand Up @@ -334,7 +351,7 @@ func init() {
// Define flags
initCmd.Flags().BoolVar(&initListTemplates, "list", false, "List available templates")
initCmd.Flags().StringVarP(&initTemplate, "template", "t", "quickstart",
"Template type: quickstart, workflow")
"Template name (built-in: quickstart, workflow; or a registry template)")
initCmd.Flags().StringVarP(&initOutputDir, "output", "o", ".", "Output directory for the project")
initCmd.Flags().BoolVarP(&initInteractive, "interactive", "i", false, "Enable interactive prompts")
initCmd.Flags().BoolVarP(&initForce, "force", "f", false, "Force overwrite existing files")
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.24.1
require (
github.com/BurntSushi/toml v1.5.0
github.com/Masterminds/sprig/v3 v3.3.0
github.com/TyphonHill/go-mermaid v1.0.0
github.com/agenticgokit/agenticgokit v0.5.5
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.10
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/TyphonHill/go-mermaid v1.0.0 h1:VtmgQwgZA+KNHJvG/O591ibBVuDkGhg2+F/olVXnXAs=
github.com/TyphonHill/go-mermaid v1.0.0/go.mod h1:BqMEbKnr2HHpZ4lJJvGjL47v6rZAUpJcOaE/db1Ppwc=
github.com/agenticgokit/agenticgokit v0.5.5 h1:f/+2EbiIImlUsK8RP23V3W1D5pFtS+EgH/vCAqzPEF4=
github.com/agenticgokit/agenticgokit v0.5.5/go.mod h1:0EwU951CZIGYwEOLnC5hJbC9lhNvM85FhrL6NTTDIZo=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
Expand Down
Loading
Loading