返回 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 "reasonix/internal/plugin"
12 "reasonix/internal/skill/skillwatch"
13
14 // Blank imports wire compile-time built-ins into their registries.
15 _ "reasonix/internal/provider/anthropic"
16 _ "reasonix/internal/provider/openai"
17 _ "reasonix/internal/provider/responses"
18 _ "reasonix/internal/tool/builtin"
19 )
20
21 // Build identity injected via -ldflags (see Makefile). version remains the
22 // single-line contract for `reasonix --version`; gitCommit/buildTimeUTC feed
23 // `reasonix version --verbose` / `--json` without embedding config paths.
24 var (
25 version = "dev"
26 gitCommit = ""
27 buildTimeUTC = ""
28 )
29
30 // runCLI is the CLI entry; tests may stub it. Production routes through
31 // RunWithBuildInfo so ldflags metadata is available to version --verbose/--json.
32 var runCLI = func(args []string, buildVersion string) int {
33 return cli.RunWithBuildInfo(args, cli.BuildInfo{
34 Version: buildVersion,
35 GitCommit: gitCommit,
36 BuildTimeUTC: buildTimeUTC,
37 })
38 }
39
40 func main() {
41 // Internal watcher-helper entry: the host-shared skill watch service
42 // re-enters this executable so Windows directory watching never runs
43 // in-process. Dispatch before any application initialization.
44 if skillwatch.MaybeRunHelper() {
45 return
46 }
47 plugin.SetMCPClientVersion(version)
48 os.Exit(runWithCrashCapture(os.Args[1:], version))
49 }
50
51 func runWithCrashCapture(args []string, buildVersion string) (exitCode int) {
52 defer func() {
53 if recovered := recover(); recovered != nil {
54 _ = crashreport.CapturePanic(config.ReasonixHomeDir(), buildVersion, recovered, debug.Stack())
55 panic(recovered)
56 }
57 }()
58 return runCLI(args, buildVersion)
59 }
60
60 lines GO