summaryrefslogtreecommitdiff
path: root/internal/config/config.go
blob: a66524a1ee3e138aa5baa29a09245e1ef50049e1 (plain)
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
package config

import (
	"os"
	"path/filepath"
)

type Config struct {
	DataDir          string `toml:"data_dir"`
	DBPath           string `toml:"-"`
	LogDir           string `toml:"-"`
	ClaudeBinaryPath string `toml:"claude_binary_path"`
	GeminiBinaryPath string `toml:"gemini_binary_path"`
	MaxConcurrent    int    `toml:"max_concurrent"`
	DefaultTimeout   string `toml:"default_timeout"`
	ServerAddr       string `toml:"server_addr"`
	WebhookURL       string `toml:"webhook_url"`
}

func Default() *Config {
	home, _ := os.UserHomeDir()
	dataDir := filepath.Join(home, ".claudomator")
	return &Config{
		DataDir:          dataDir,
		DBPath:           filepath.Join(dataDir, "claudomator.db"),
		LogDir:           filepath.Join(dataDir, "executions"),
		ClaudeBinaryPath: "claude",
		GeminiBinaryPath: "gemini",
		MaxConcurrent:    3,
		DefaultTimeout:   "15m",
		ServerAddr:       ":8484",
	}
}

// EnsureDirs creates the data directory structure.
func (c *Config) EnsureDirs() error {
	for _, dir := range []string{c.DataDir, c.LogDir} {
		if err := os.MkdirAll(dir, 0700); err != nil {
			return err
		}
	}
	return nil
}