From 2e2b2187b957e9af78797a67ec5c6874615fae02 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 8 Feb 2026 21:35:45 -1000 Subject: Initial project: task model, executor, API server, CLI, storage, reporter Claudomator automation toolkit for Claude Code with: - Task model with YAML parsing, validation, state machine (49 tests, 0 races) - SQLite storage for tasks and executions - Executor pool with bounded concurrency, timeout, cancellation - REST API + WebSocket for mobile PWA integration - Webhook/multi-notifier system - CLI: init, run, serve, list, status commands - Console, JSON, HTML reporters with cost tracking Co-Authored-By: Claude Opus 4.6 --- internal/cli/init.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 internal/cli/init.go (limited to 'internal/cli/init.go') diff --git a/internal/cli/init.go b/internal/cli/init.go new file mode 100644 index 0000000..6660f9d --- /dev/null +++ b/internal/cli/init.go @@ -0,0 +1,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 +} -- cgit v1.2.3