返回 DeepSeek-Reasonix
main.go
根目录 / cmd / reasonix / main.go
1 // Command reasonix is a config- and plugin-driven coding agent CLI.
2 package main
3
4 import (
5 "os"
6 "runtime/debug"
7
8 "reasonix/internal/cli"
9 "reasonix/internal/config"
10 "reasonix/internal/crashreport"
11
12 // Blank imports wire compile-time built-ins into their registries.
13 _ "reasonix/internal/provider/anthropic"
14 _ "reasonix/internal/provider/openai"
15 _ "reasonix/internal/provider/responses"
16 _ "reasonix/internal/tool/builtin"
17 )
18
19 // Build identity injected via -ldflags (see Makefile). version remains the
20 // single-line contract for `reasonix --version`; gitCommit/buildTimeUTC feed
21 // `reasonix version --verbose` / `--json` without embedding config paths.
22 var (
23 version = "dev"
24 gitCommit = ""
25 buildTimeUTC = ""
26 )
27
28 // runCLI is the CLI entry; tests may stub it. Production routes through
29 // RunWithBuildInfo so ldflags metadata is available to version --verbose/--json.
30 var runCLI = func(args []string, buildVersion string) int {
31 return cli.RunWithBuildInfo(args, cli.BuildInfo{
32 Version: buildVersion,
33 GitCommit: gitCommit,
34 BuildTimeUTC: buildTimeUTC,
35 })
36 }
37
38 func main() {
39 os.Exit(runWithCrashCapture(os.Args[1:], version))
40 }
41
42 func runWithCrashCapture(args []string, buildVersion string) (exitCode int) {
43 defer func() {
44 if recovered := recover(); recovered != nil {
45 _ = crashreport.CapturePanic(config.ReasonixHomeDir(), buildVersion, recovered, debug.Stack())
46 panic(recovered)
47 }
48 }()
49 return runCLI(args, buildVersion)
50 }
51
51 lines GO