Files
zero/internal/modelregistry/modes.go
euxaristiaandClaude Sonnet 5 97ef90d27a chore: remove code unreachable on every supported platform (#706)
* chore: remove code unreachable on every supported platform

The Security and code health job's advisory deadcode step reports 152
unreachable functions on main. Running the same check under GOOS=linux,
windows, and darwin shows 13 of those are false positives whose callers
live in windows build-tagged files, so only functions unreachable on all
three platforms are touched.

Functions with no references anywhere are deleted, including the
internal/reasoning package, which nothing imports. Functions that only
tests reference move into per-package export_test.go files so tests keep
their seams while the production binary sheds the code. Test call sites
of deleted convenience wrappers are ported to the live APIs (scoped tool
constructors, tools.DeferredSource, FinishReason checks).

Kept despite the report: cron.Store.Runs (only reader of runs.jsonl,
which production writes), and agenteval.TraceEventKeys and
MissingTraceEvents (used across packages by the trace contract test).

* docs(config): correct ValidateFile's errors.As claim

Message is a flattened string (.Error() already called on the parse
error), not a wrapped error, so callers can't recover the concrete
json error type via errors.As. Fix the comment to match.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* chore(trace,skills): drop obsolete Sink adapters and fix stale doc references

The dead-code pass removed the Emit methods but left Sink, NDJSONSink, and
TextSink exported with a contract nothing implements; remove the types with
their contract. Also remove the stray blank line at EOF of trace.go flagged
by gofmt, and update skills package docs and HOW_ZERO_WORKS.md to stop
directing callers to DiscoveryRoots/Duplicates, which are now test seams.

Co-Authored-By: Claude Fable 5 <[email protected]>

* chore: clean up remaining review nits on dead code removal

Replace a pointless fmt.Errorf(...%w...).Error() with fmt.Sprintf
using %v, since the wrapped error was discarded immediately anyway.
Remove a comment block that was duplicated verbatim.

* docs(skills): drop remaining references to test-only List/Get

Load and MergedSkills comments still named List/Get as production
entry points after they moved to export_test.go. Point callers at
Load and ListFromRoots instead.

* chore: remove now-unreferenced export_test.go seams

execSessionManager.len() and likelySandboxDenied/sandboxDenialKind had
no remaining callers after the sandbox unify-command-execution rebase;
the production code they wrapped for tests no longer exists.

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
2026-07-24 09:04:41 +08:00

95 lines
3.0 KiB
Go

package modelregistry
import "strings"
// Mode bundles a model selection, reasoning effort, agent-loop turn budget, and
// an optional tool filter behind a single short name. Modes are presets that let
// callers switch the whole agent profile (smart/deep/fast/...) with one flag or
// command instead of tuning --model/--reasoning-effort/--max-turns by hand.
//
// Model holds a registry id or alias (resolved through Resolve/ResolveWithFallback
// at apply time so deprecation fallbacks and fuzzy aliases stay honored). MaxTurns
// of 0 means "leave the configured/default turn budget untouched". Effort of ""
// means "let the model's effective default apply".
type Mode struct {
Name string
Description string
Model string
Effort ReasoningEffort
MaxTurns int
// EnabledTools / DisabledTools optionally narrow the tool surface for the
// mode. Empty slices leave the existing tool selection untouched.
EnabledTools []string
DisabledTools []string
}
// defaultModes is the canonical preset catalog. It is kept data-driven so the
// CLI flag, the TUI command, and tests all read from one source of truth. Models
// reference real registry ids (see catalog.go); efforts reference real
// ReasoningEffort values.
var defaultModes = []Mode{
{
Name: "smart",
Description: "Balanced daily driver for high-quality agent work.",
Model: "claude-sonnet-4.5",
Effort: ReasoningEffortMedium,
},
{
Name: "deep",
Description: "Hardest tasks: deep reasoning with a larger turn budget.",
Model: "claude-opus-4.1",
Effort: ReasoningEffortHigh,
MaxTurns: 160,
},
{
Name: "fast",
Description: "Low-latency support for quick edits and summaries.",
Model: "claude-haiku-4.5",
Effort: ReasoningEffortLow,
MaxTurns: 15,
},
{
Name: "large",
Description: "Long-context work over large inputs.",
Model: "gemini-2.5-pro",
Effort: ReasoningEffortMedium,
},
{
Name: "precise",
Description: "Careful, high-effort reasoning for exacting changes.",
Model: "claude-sonnet-4.5",
Effort: ReasoningEffortHigh,
},
}
// LookupMode returns the preset registered under name (case-insensitive,
// whitespace-trimmed). The second result reports whether a preset matched.
func LookupMode(name string) (Mode, bool) {
normalized := strings.ToLower(strings.TrimSpace(name))
if normalized == "" {
return Mode{}, false
}
for _, mode := range defaultModes {
if mode.Name == normalized {
return cloneMode(mode), true
}
}
return Mode{}, false
}
// ModeNames returns the preset names in declaration order, handy for usage and
// error messages that need to list the valid modes.
func ModeNames() []string {
names := make([]string, len(defaultModes))
for index, mode := range defaultModes {
names[index] = mode.Name
}
return names
}
func cloneMode(mode Mode) Mode {
mode.EnabledTools = append([]string{}, mode.EnabledTools...)
mode.DisabledTools = append([]string{}, mode.DisabledTools...)
return mode
}