| 1 | package cmd |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "the-valley/flow/internal/config" |
| 7 | "the-valley/flow/internal/git" |
| 8 | "github.com/spf13/cobra" |
| 9 | ) |
| 10 | |
| 11 | var initCmd = &cobra.Command{ |
| 12 | Use: "init", |
| 13 | Short: "Initialize klaus config", |
| 14 | Long: `Scaffolds a .klaus/ directory with default config.json and prompt.md template. |
| 15 | |
| 16 | If run inside a git repository, creates .klaus/ in the repo root. |
| 17 | If run outside a git repository, creates ~/.klaus/config.json for global configuration.`, |
| 18 | RunE: func(cmd *cobra.Command, args []string) error { |
| 19 | root, _ := git.RepoRoot() |
| 20 | |
| 21 | if root != "" { |
| 22 | if err := config.Init(root); err != nil { |
| 23 | return err |
| 24 | } |
| 25 | fmt.Println("Initialized .klaus/ directory:") |
| 26 | fmt.Println(" .klaus/config.json โ configuration") |
| 27 | fmt.Println(" .klaus/prompt.md โ system prompt template") |
| 28 | } else { |
| 29 | if err := config.InitGlobal(); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | fmt.Println("Initialized global klaus config:") |
| 33 | fmt.Println(" ~/.klaus/config.json โ configuration") |
| 34 | } |
| 35 | return nil |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | func init() { |
| 40 | rootCmd.AddCommand(initCmd) |
| 41 | } |