Multi-agent audit + aggressive cleanup across server/web/coder/booterm, delivered behind a DEFER discipline so none of the in-flight files were touched. Removes dead code/deps/columns, dedups server + coder helpers, and splits the oversized modules (tools.ts, opencode-server.ts, sentinel-summaries, turn.ts, TerminalPane.tsx) behind stable contracts. Adds 78 parity/unit tests (server 587, coder 323); fixes two latent bugs (ChatPane queue keys, FileViewerOverlay blank-line parity). Intended tag: v2.7.12-audit-cleanup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { ALL_TOOLS, TOOLS_BY_NAME } from './registry.js';
|
|
|
|
// v1.13.15-tools: tiered tool loading. BOOCODE_TOOLS env var (`core` |
|
|
// `standard` | `all`) filters the agent's tool whitelist before LLM dispatch.
|
|
// Daily-driver token win on qwen3.6-35b-a3b — the 35B-A3B MoE benefits from
|
|
// any prompt-cache stability win (fewer tools = shorter, more stable tool
|
|
// schemas in the system prompt). Pattern lift from eyaltoledano/claude-task-
|
|
// master (MIT + Commons Clause — pattern only, no code lift).
|
|
//
|
|
// The env var is a CEILING. It only narrows; never expands an agent's
|
|
// declared whitelist. Default behavior (var unset) is unchanged: all tools.
|
|
export const CORE_TOOL_NAMES = [
|
|
'view_file',
|
|
'list_dir',
|
|
'grep',
|
|
'find_files',
|
|
] as const;
|
|
|
|
export const STANDARD_TOOL_NAMES = [
|
|
...CORE_TOOL_NAMES,
|
|
'web_search',
|
|
'web_fetch',
|
|
'git_status',
|
|
'get_codebase_overview',
|
|
'get_file_analysis',
|
|
'get_symbol_info',
|
|
'search_symbols',
|
|
'get_dependencies',
|
|
'watch_changes',
|
|
'get_semantic_neighborhoods',
|
|
'get_framework_analysis',
|
|
] as const;
|
|
|
|
// Module-load validation: every name in CORE / STANDARD must exist in
|
|
// TOOLS_BY_NAME. Catches typos and stale tier definitions before they reach
|
|
// production; server boot fails loudly rather than silently filtering valid
|
|
// tools out of agent whitelists.
|
|
for (const name of CORE_TOOL_NAMES) {
|
|
if (!TOOLS_BY_NAME[name]) {
|
|
throw new Error(`CORE_TOOL_NAMES references unknown tool: '${name}'`);
|
|
}
|
|
}
|
|
for (const name of STANDARD_TOOL_NAMES) {
|
|
if (!TOOLS_BY_NAME[name]) {
|
|
throw new Error(`STANDARD_TOOL_NAMES references unknown tool: '${name}'`);
|
|
}
|
|
}
|
|
|
|
export function resolveToolTier(tier: string | undefined): readonly string[] {
|
|
switch ((tier ?? 'all').toLowerCase()) {
|
|
case 'core':
|
|
return CORE_TOOL_NAMES;
|
|
case 'standard':
|
|
return STANDARD_TOOL_NAMES;
|
|
case 'all':
|
|
default:
|
|
return ALL_TOOLS.map((t) => t.name);
|
|
}
|
|
}
|