mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 02:36:01 -10:00
Bring in the finished Go rewrite (developed under the placeholder name "duo") as the v2 codebase. Code-only import — no upstream git history. Config- and plugin-driven coding agent: registry core, OpenAI-compatible providers, builtin tools, MCP (stdio + HTTP) plugins, permission + sandbox, custom slash commands, @-references, two-model collaboration. Renamed throughout: duo→reasonix, Duo→Reasonix, DUO→REASONIX — module path, imports, CLI name, cmd/ dirs, reasonix.toml, .reasonix/commands, and $REASONIX_* env prefixes. Kept the v2 MIT LICENSE (the Go project had none). Verified: go build ./... · go vet ./... · go test ./... all green; gofmt clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
// colorEnabled is decided once at startup: only colorize when writing to a real
|
|
// terminal and the user hasn't opted out via NO_COLOR (https://no-color.org) or
|
|
// a dumb TERM. Piped/redirected output and CI stay plain so scripts aren't broken.
|
|
var colorEnabled = detectColor()
|
|
|
|
func detectColor() bool {
|
|
if os.Getenv("NO_COLOR") != "" {
|
|
return false
|
|
}
|
|
if os.Getenv("TERM") == "dumb" {
|
|
return false
|
|
}
|
|
return term.IsTerminal(int(os.Stdout.Fd()))
|
|
}
|
|
|
|
const (
|
|
ansiReset = "\033[0m"
|
|
ansiBold = "\033[1m"
|
|
ansiDim = "\033[2m"
|
|
ansiGreen = "\033[32m"
|
|
ansiYellow = "\033[33m"
|
|
ansiReverse = "\033[7m"
|
|
// ansiAccent is reasonix's brand colour: a warm copper (xterm-256 #173) chosen
|
|
// to read on both dark and light terminals. It marks titles, prompts, and
|
|
// box borders so the eye finds the same hue every time.
|
|
ansiAccent = "\033[38;5;173m"
|
|
)
|
|
|
|
func sgr(code, s string) string {
|
|
if !colorEnabled {
|
|
return s
|
|
}
|
|
return code + s + ansiReset
|
|
}
|
|
|
|
func bold(s string) string { return sgr(ansiBold, s) }
|
|
func dim(s string) string { return sgr(ansiDim, s) }
|
|
func green(s string) string { return sgr(ansiGreen, s) }
|
|
func yellow(s string) string { return sgr(ansiYellow, s) }
|
|
func accent(s string) string { return sgr(ansiAccent, s) }
|
|
func reverse(s string) string { return sgr(ansiReverse, s) }
|