Repository navigation
Expand file tree
/
Copy pathcli.go
More file actions
58 lines (53 loc) · 2.41 KB
/
Copy pathcli.go
File metadata and controls
58 lines (53 loc) · 2.41 KB
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 main
import (
"cmp"
"flag"
"fmt"
"os"
"strings"
"time"
"github.com/sadfun/agentci/providers"
)
type options struct {
yes bool
dir, base, head string
full bool
only string
provider, model, effort string
jobs int
timeout time.Duration
verbose, json, github bool
}
func runCLI(args []string) error {
if len(args) > 0 && args[0] == "init" {
return runInit()
}
var o options
fs := flag.NewFlagSet("agentci", flag.ExitOnError)
fs.BoolVar(&o.yes, "y", false, "install the agent CLI without asking when it is missing")
fs.StringVar(&o.dir, "C", ".", "repository directory")
fs.StringVar(&o.base, "base", "", "git ref to diff against (default: $AGENTCI_BASE, origin/$GITHUB_BASE_REF, origin/main, ..., HEAD~1)")
fs.StringVar(&o.head, "head", "HEAD", "git ref containing the changes under review")
fs.BoolVar(&o.full, "full", false, "review the whole repository instead of a diff")
fs.StringVar(&o.only, "only", "", "run just the rule with this name or file name")
fs.StringVar(&o.provider, "provider", cmp.Or(os.Getenv("AGENTCI_PROVIDER"), "codex"),
"agent CLI to run rules with: "+strings.Join(providers.Names(), "|")+" (default: $AGENTCI_PROVIDER or codex)")
fs.StringVar(&o.model, "model", "", "default model for rules that set none (default: the provider's own config)")
fs.StringVar(&o.effort, "effort", "", "default reasoning effort for rules that set none: low|medium|high|xhigh")
fs.IntVar(&o.jobs, "j", 1, "number of rules to run in parallel")
fs.DurationVar(&o.timeout, "timeout", 15*time.Minute, "default per-rule timeout")
fs.BoolVar(&o.verbose, "v", false, "stream the agent transcript to stderr")
fs.BoolVar(&o.json, "json", false, "print the report as one JSON object on stdout instead of text")
fs.BoolVar(&o.github, "github", true, "in GitHub Actions: one check per rule with the findings as annotations, plus the job summary (uses GITHUB_TOKEN)")
fs.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: agentci [flags]\n agentci init\n\n"+
"Runs each %s/*.md rule through an AI coding agent and exits 1 if any rule fails.\n"+
"Results go to stdout, one finding per line as file:line: message (rule); progress goes to stderr.\n\n", rulesDir)
fs.PrintDefaults()
}
fs.Parse(args)
if fs.NArg() > 0 {
return fmt.Errorf("unexpected arguments: %s", strings.Join(fs.Args(), " "))
}
return run(o)
}