An AI-powered tool that generates human-readable summaries of git changes using tool calling with a self-hosted LLM
1package config
2
3import (
4 "flag"
5 "os"
6)
7
8// Config holds application configuration
9type Config struct {
10 LlamaURL string
11 Model string
12 ListenAddr string
13 RepoDir string
14 MaxDiffLen int
15 GitUser string
16 GitToken string
17 SSHKeyPath string
18 CacheDir string
19 MaxCachedRepos int
20}
21
22// LoadConfig parses flags and environment variables to build configuration
23func LoadConfig() Config {
24 config := Config{
25 LlamaURL: "http://localhost:8080",
26 Model: "qwen2.5-coder",
27 ListenAddr: ":8000",
28 RepoDir: "/tmp",
29 MaxDiffLen: 16000,
30 CacheDir: "/tmp/git-cache",
31 MaxCachedRepos: 50,
32 }
33
34 flag.StringVar(&config.LlamaURL, "llama-url", config.LlamaURL, "llama.cpp server URL")
35 flag.StringVar(&config.Model, "model", config.Model, "Model name to use")
36 flag.StringVar(&config.ListenAddr, "listen", config.ListenAddr, "Listen address")
37 flag.StringVar(&config.RepoDir, "repo-dir", config.RepoDir, "Directory for cloned repos")
38 flag.IntVar(&config.MaxDiffLen, "max-diff", config.MaxDiffLen, "Max diff length to send to LLM")
39 flag.StringVar(&config.GitUser, "git-user", "", "Git username for HTTPS auth")
40 flag.StringVar(&config.GitToken, "git-token", "", "Git token/password for HTTPS auth")
41 flag.StringVar(&config.SSHKeyPath, "ssh-key", "", "Path to SSH private key")
42 flag.StringVar(&config.CacheDir, "cache-dir", config.CacheDir, "Directory for cached repos")
43 flag.IntVar(&config.MaxCachedRepos, "max-cached-repos", config.MaxCachedRepos, "Max repos to cache (LRU eviction)")
44 flag.Parse()
45
46 // Environment variable overrides
47 if url := os.Getenv("LLAMA_URL"); url != "" {
48 config.LlamaURL = url
49 }
50 if model := os.Getenv("LLAMA_MODEL"); model != "" {
51 config.Model = model
52 }
53 if user := os.Getenv("GIT_USER"); user != "" {
54 config.GitUser = user
55 }
56 if token := os.Getenv("GIT_TOKEN"); token != "" {
57 config.GitToken = token
58 }
59 if key := os.Getenv("SSH_KEY_PATH"); key != "" {
60 config.SSHKeyPath = key
61 }
62 if dir := os.Getenv("CACHE_DIR"); dir != "" {
63 config.CacheDir = dir
64 }
65
66 return config
67}