1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package cli
import (
"fmt"
"os"
"path/filepath"
"github.com/claudomator/claudomator/internal/storage"
"github.com/spf13/cobra"
)
func newInitCmd() *cobra.Command {
return &cobra.Command{
Use: "init",
Short: "Initialize Claudomator data directory",
RunE: func(cmd *cobra.Command, args []string) error {
return initClaudomator()
},
}
}
func initClaudomator() error {
if err := cfg.EnsureDirs(); err != nil {
return fmt.Errorf("creating directories: %w", err)
}
// Initialize database.
store, err := storage.Open(cfg.DBPath)
if err != nil {
return fmt.Errorf("initializing database: %w", err)
}
store.Close()
// Create example task file if it doesn't exist.
examplePath := filepath.Join(cfg.DataDir, "example-task.yaml")
if _, err := os.Stat(examplePath); os.IsNotExist(err) {
example := `name: "Example Task"
description: "A sample task to get started"
claude:
model: "sonnet"
instructions: |
Say hello and list the files in the current directory.
working_dir: "."
timeout: "5m"
tags:
- "example"
`
if err := os.WriteFile(examplePath, []byte(example), 0644); err != nil {
return fmt.Errorf("writing example: %w", err)
}
}
fmt.Printf("Claudomator initialized at %s\n", cfg.DataDir)
fmt.Printf(" Database: %s\n", cfg.DBPath)
fmt.Printf(" Logs: %s\n", cfg.LogDir)
fmt.Printf(" Example: %s\n", examplePath)
return nil
}
|