@denizokcu/haze 1.7.11 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +142 -102
- package/SECURITY.md +1 -1
- package/assets/graph-grammars/NOTICE.md +21 -0
- package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
- package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.js +4056 -0
- package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
- package/bin/haze.js +47 -19
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +1 -2
- package/dist/cli/chat/ChatHeader.d.ts +6 -0
- package/dist/cli/chat/ChatHeader.js +11 -0
- package/dist/cli/chat/ChatScreen.d.ts +16 -0
- package/dist/cli/chat/ChatScreen.js +399 -0
- package/dist/cli/chat/ChatScreenView.d.ts +68 -0
- package/dist/cli/chat/ChatScreenView.js +47 -0
- package/dist/cli/chat/LiveTail.d.ts +11 -0
- package/dist/cli/chat/LiveTail.js +26 -0
- package/dist/cli/chat/TaskBar.d.ts +3 -2
- package/dist/cli/chat/TaskBar.js +4 -0
- package/dist/cli/chat/agentTurnRunner.d.ts +12 -0
- package/dist/cli/chat/agentTurnRunner.js +177 -0
- package/dist/cli/chat/busyIndicator.js +9 -5
- package/dist/cli/chat/chatMetrics.d.ts +7 -0
- package/dist/cli/chat/chatMetrics.js +15 -1
- package/dist/cli/chat/chatViewModel.d.ts +85 -0
- package/dist/cli/chat/chatViewModel.js +66 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +0 -14
- package/dist/cli/chat/fileMentionSuggestions.js +4 -21
- package/dist/cli/chat/inputSuggestions.js +1 -0
- package/dist/cli/chat/liveTheme.d.ts +11 -0
- package/dist/cli/chat/liveTheme.js +26 -0
- package/dist/cli/chat/messageFinalize.d.ts +4 -0
- package/dist/cli/chat/messageFinalize.js +8 -0
- package/dist/cli/chat/messages.js +1 -1
- package/dist/cli/chat/pickerOpeners.d.ts +23 -0
- package/dist/cli/chat/pickerOpeners.js +36 -0
- package/dist/cli/chat/promptSessionState.d.ts +11 -0
- package/dist/cli/chat/promptSessionState.js +39 -0
- package/dist/cli/chat/renderMetrics.d.ts +8 -0
- package/dist/cli/chat/renderMetrics.js +14 -0
- package/dist/cli/chat/resizeGuard.d.ts +11 -0
- package/dist/cli/chat/resizeGuard.js +25 -0
- package/dist/cli/chat/screenDeps.d.ts +116 -0
- package/dist/cli/chat/screenDeps.js +1 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
- package/dist/cli/chat/sessionLifecycle.js +6 -2
- package/dist/cli/chat/sessionRecorder.js +4 -1
- package/dist/cli/chat/settingsSelection.d.ts +33 -0
- package/dist/cli/chat/settingsSelection.js +46 -0
- package/dist/cli/chat/skillNotices.d.ts +18 -0
- package/dist/cli/chat/skillNotices.js +26 -0
- package/dist/cli/chat/startupInfo.js +1 -1
- package/dist/cli/chat/startupSequence.d.ts +2 -0
- package/dist/cli/chat/startupSequence.js +6 -0
- package/dist/cli/chat/submitPipeline.d.ts +8 -0
- package/dist/cli/chat/submitPipeline.js +141 -0
- package/dist/cli/chat/terminalControl.js +1 -1
- package/dist/cli/chat/toolSummaries.d.ts +29 -0
- package/dist/cli/chat/toolSummaries.js +268 -0
- package/dist/cli/chat/turnState.d.ts +8 -0
- package/dist/cli/chat/turnState.js +1 -0
- package/dist/cli/chat/userCommandFlow.d.ts +21 -0
- package/dist/cli/chat/userCommandFlow.js +66 -0
- package/dist/cli/chat/userCommandRunner.d.ts +14 -0
- package/dist/cli/chat/userCommandRunner.js +56 -0
- package/dist/cli/chat/wizard/providerHandlers.js +19 -2
- package/dist/cli/chat/wizardTrail.d.ts +22 -0
- package/dist/cli/chat/wizardTrail.js +55 -0
- package/dist/cli/commands/chat.d.ts +1 -13
- package/dist/cli/commands/chat.js +10 -795
- package/dist/cli/commands/commandHelp.js +11 -6
- package/dist/cli/commands/commandSuggest.d.ts +2 -0
- package/dist/cli/commands/commandSuggest.js +35 -0
- package/dist/cli/commands/commands.js +12 -3
- package/dist/cli/commands/formatters.d.ts +1 -23
- package/dist/cli/commands/formatters.js +3 -224
- package/dist/cli/commands/graphCommand.d.ts +2 -0
- package/dist/cli/commands/graphCommand.js +60 -0
- package/dist/cli/commands/initCommand.js +14 -0
- package/dist/cli/commands/modelCommand.js +11 -7
- package/dist/cli/commands/reasoningCommand.js +3 -3
- package/dist/cli/commands/runCommand.js +6 -2
- package/dist/cli/commands/streaming/agentAttempt.js +11 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +8 -3
- package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
- package/dist/cli/commands/streaming/attemptSetup.js +34 -5
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
- package/dist/cli/commands/streaming/prepareStep.js +1 -0
- package/dist/cli/commands/streaming/stepProjection.d.ts +59 -0
- package/dist/cli/commands/streaming/stepProjection.js +54 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
- package/dist/cli/commands/streaming/streamLoop.js +34 -23
- package/dist/cli/commands/streaming/toolGroupRenderer.js +1 -1
- package/dist/cli/commands/streaming/toolPartHandlers.js +8 -2
- package/dist/cli/commands/streaming.d.ts +3 -1
- package/dist/cli/commands/streaming.js +5 -0
- package/dist/cli/commands/wizardFlow.d.ts +2 -0
- package/dist/cli/commands/wizardFlow.js +3 -0
- package/dist/cli/index.js +8 -4
- package/dist/cli/terminalTitle.js +9 -3
- package/dist/config/contextFiles.d.ts +2 -5
- package/dist/config/contextFiles.js +1 -1
- package/dist/config/inputHistory.js +2 -2
- package/dist/config/providerAuth.js +2 -2
- package/dist/config/providerModelFacts.js +5 -0
- package/dist/config/providerPresets.js +1 -1
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.js +9 -2
- package/dist/config/updateCheck.js +2 -2
- package/dist/core/agent/compaction.d.ts +1 -0
- package/dist/core/agent/compaction.js +3 -0
- package/dist/core/agent/completionController.d.ts +1 -1
- package/dist/core/agent/contextBudget.d.ts +1 -1
- package/dist/core/agent/goalPolicy.js +8 -2
- package/dist/core/agent/overflow.js +5 -0
- package/dist/core/agent/toolCapabilities.js +14 -0
- package/dist/core/agent/userCommands.d.ts +53 -0
- package/dist/core/agent/userCommands.js +116 -0
- package/dist/core/agent/workState.d.ts +3 -1
- package/dist/core/agent/workState.js +57 -26
- package/dist/core/contextFileTypes.d.ts +12 -0
- package/dist/core/contextFileTypes.js +1 -0
- package/dist/core/graph/analyze.d.ts +61 -0
- package/dist/core/graph/analyze.js +274 -0
- package/dist/core/graph/buildGraph.d.ts +44 -0
- package/dist/core/graph/buildGraph.js +290 -0
- package/dist/core/graph/digest.d.ts +2 -0
- package/dist/core/graph/digest.js +40 -0
- package/dist/core/graph/extract.d.ts +58 -0
- package/dist/core/graph/extract.js +394 -0
- package/dist/core/graph/model.d.ts +63 -0
- package/dist/core/graph/model.js +96 -0
- package/dist/core/graph/query.d.ts +69 -0
- package/dist/core/graph/query.js +391 -0
- package/dist/core/graph/store.d.ts +64 -0
- package/dist/core/graph/store.js +171 -0
- package/dist/core/limits.d.ts +2 -0
- package/dist/core/limits.js +2 -0
- package/dist/core/log/llmLog.js +2 -2
- package/dist/{config → core/persistence}/privateStorage.js +1 -1
- package/dist/core/process/runBoundedProcess.d.ts +7 -4
- package/dist/core/process/runBoundedProcess.js +22 -11
- package/dist/core/safety/redaction.d.ts +2 -0
- package/dist/core/safety/redaction.js +26 -5
- package/dist/core/safety/secretPaths.js +12 -3
- package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
- package/dist/core/safety/untrustedEnvelopes.js +17 -2
- package/dist/core/safety/urlGuard.js +2 -0
- package/dist/core/session/sessionStore.d.ts +8 -1
- package/dist/core/session/sessionStore.js +15 -4
- package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
- package/dist/core/shellOutput/types.d.ts +1 -1
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/tasks/taskStorage.js +11 -1
- package/dist/{llm → core}/toolResultTypes.d.ts +1 -1
- package/dist/core/validation/outputParser.d.ts +1 -1
- package/dist/core/validation/outputParser.js +16 -8
- package/dist/llm/hazeTools.d.ts +2 -12426
- package/dist/llm/hazeTools.js +4 -0
- package/dist/llm/lsp/pool.js +1 -1
- package/dist/llm/lsp/workspaceEdit.d.ts +1 -1
- package/dist/llm/lspTools.d.ts +3 -12622
- package/dist/llm/requestContext.d.ts +6 -0
- package/dist/llm/requestContext.js +28 -7
- package/dist/llm/subagentRunner.d.ts +2 -308
- package/dist/llm/systemPrompt.js +17 -7
- package/dist/llm/toolGroups.d.ts +534 -0
- package/dist/llm/toolGroups.js +57 -0
- package/dist/llm/tools/editMatch.d.ts +1 -1
- package/dist/llm/tools/failures.d.ts +1 -1
- package/dist/llm/tools/fetchTool.d.ts +2 -1221
- package/dist/llm/tools/fileToolShared.d.ts +1 -1
- package/dist/llm/tools/fileToolShared.js +1 -1
- package/dist/llm/tools/fileTools.d.ts +2 -7768
- package/dist/llm/tools/fileTools.js +1 -1
- package/dist/llm/tools/gitTools.d.ts +12 -0
- package/dist/llm/tools/gitTools.js +527 -0
- package/dist/llm/tools/graphAdvisory.d.ts +22 -0
- package/dist/llm/tools/graphAdvisory.js +68 -0
- package/dist/llm/tools/graphTools.d.ts +13 -0
- package/dist/llm/tools/graphTools.js +195 -0
- package/dist/llm/tools/processTool.d.ts +2 -1081
- package/dist/llm/tools/readRecovery.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.d.ts +1 -1
- package/dist/llm/tools/replaceInFiles.js +1 -1
- package/dist/llm/tools/shellTool.d.ts +2 -1513
- package/dist/llm/tools/storedOutputTool.d.ts +2 -355
- package/dist/llm/tools/taskTool.d.ts +2 -489
- package/dist/llm/tools/taskTool.js +4 -1
- package/dist/llm/tools/toolContext.js +29 -11
- package/dist/llm/tools/toolContextState.d.ts +4 -1
- package/dist/llm/tools/toolContextState.js +2 -1
- package/dist/llm/tools/workspaceFile.d.ts +2 -2
- package/dist/llm/tools/workspaceFile.js +10 -5
- package/dist/skills/SkillRegistry.js +1 -1
- package/dist/skills/builder/SkillBuilder.js +1 -1
- package/dist/skills/plugins/installer.js +1 -1
- package/dist/skills/plugins/runtime.js +1 -1
- package/dist/skills/skillTools.js +4 -1
- package/dist/ui/components/MarkdownText.d.ts +14 -0
- package/dist/ui/components/MarkdownText.js +77 -12
- package/dist/ui/components/NativeIndicators.js +5 -1
- package/dist/ui/components/StreamingMarkdownText.d.ts +3 -1
- package/dist/ui/components/StreamingMarkdownText.js +39 -11
- package/dist/ui/components/TextInput.d.ts +1 -2
- package/dist/ui/components/TextInput.js +79 -9
- package/dist/ui/components/WizardChoices.d.ts +1 -2
- package/dist/ui/components/useInputSuggestions.d.ts +1 -1
- package/dist/ui/components/useInputSuggestions.js +1 -1
- package/dist/ui/mentionDetection.d.ts +20 -0
- package/dist/ui/mentionDetection.js +24 -0
- package/dist/ui/terminalColors.d.ts +4 -4
- package/dist/ui/terminalColors.js +23 -6
- package/dist/ui/terminalSanitize.js +8 -3
- package/dist/ui/textGeometry.d.ts +2 -0
- package/dist/ui/textGeometry.js +6 -0
- package/dist/ui/themes/registry.js +33 -33
- package/dist/utils/openPath.js +7 -0
- package/package.json +22 -19
- /package/dist/{llm/tools → core/ignore}/gitIgnore.d.ts +0 -0
- /package/dist/{llm/tools → core/ignore}/gitIgnore.js +0 -0
- /package/dist/{config → core}/paths.d.ts +0 -0
- /package/dist/{config → core}/paths.js +0 -0
- /package/dist/{config → core/persistence}/privateStorage.d.ts +0 -0
- /package/dist/{llm → core}/toolResultTypes.js +0 -0
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
export const COMMAND_HELP_ENTRIES = [
|
|
2
2
|
{ usage: '/help', description: 'Show all available slash commands and what they do.' },
|
|
3
|
+
{ usage: '! <command>', description: 'Run a shell command directly (no model turn) and show its output; the result stays in the conversation for the model. 60s limit, Esc cancels.' },
|
|
4
|
+
{ usage: '\\! <text>', description: 'Send a message that starts with ! as a normal prompt (the backslash is removed).' },
|
|
3
5
|
{ usage: '/provider', description: 'Choose a provider, then use it, add/remove models, set API key, toggle image input, or remove it.' },
|
|
4
6
|
{ usage: '/model', description: 'Choose a model, or add models from a provider\'s models endpoint.' },
|
|
5
|
-
{ usage: '/model <name-or-provider:name>', description: 'Set a model
|
|
7
|
+
{ usage: '/model <name-or-provider:name>', description: 'Set a configured model, or register a new one explicitly as provider:model (a bare unknown name is rejected). Selecting a model also sets its provider.' },
|
|
6
8
|
{ usage: '/model list', description: 'List all configured models across providers.' },
|
|
7
9
|
{ usage: '/settings', description: 'Show the configured provider, model, API key status, LSP/MCP servers, skills, and loaded context files.' },
|
|
8
10
|
{ usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
|
|
9
11
|
{ usage: '/settings edit', description: 'Open ~/.haze/settings.json in $VISUAL/$EDITOR in a fullscreen terminal handoff; falls back to the OS default app when no editor is configured. Restart haze to apply external changes.' },
|
|
10
12
|
{ usage: '/themes', description: 'Choose a terminal theme from the built-in registry (light palettes and oh-my-zsh ports included); applies immediately.' },
|
|
11
13
|
{ usage: '/themes <name>', description: 'Set the theme directly, e.g. /themes robbyrussell. Saved to ~/.haze/settings.json; text already on screen keeps its old colors.' },
|
|
12
|
-
{ usage: '/reasoning', description: 'Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
13
|
-
{ usage: '/reasoning <level|unset|reset|status>', description: 'Set the reasoning effort for the active model for this session, send no parameter with unset, remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
14
|
-
{ usage: '/thinking', description: 'Alias for /reasoning. Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
15
|
-
{ usage: '/thinking <level|unset|reset|status>', description: 'Alias for /reasoning. Set the reasoning effort for the active model for this session, send no parameter with unset, remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
14
|
+
{ usage: '/reasoning', description: 'Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; off = none, unset sends no parameter (provider default), reset falls back to the saved/default level.' },
|
|
15
|
+
{ usage: '/reasoning <level|off|unset|reset|status>', description: 'Set the reasoning effort for the active model for this session (off = none), send no parameter with unset (provider default), remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
16
|
+
{ usage: '/thinking', description: 'Alias for /reasoning. Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; off = none, unset sends no parameter (provider default), reset falls back to the saved/default level.' },
|
|
17
|
+
{ usage: '/thinking <level|off|unset|reset|status>', description: 'Alias for /reasoning. Set the reasoning effort for the active model for this session (off = none), send no parameter with unset (provider default), remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
16
18
|
{ usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
|
|
17
19
|
{ usage: '/plugin', description: 'Open the plugin picker: install or inspect a local plugin/collection, or manage installed project plugins. /kit is an alias.' },
|
|
18
20
|
{ usage: '/plugin inspect|install <local-directory> [plugin-name]', description: 'Inspect or install a Claude/Agent Plugins package or a selected local marketplace plugin. Only skills are activated; review source first.' },
|
|
19
21
|
{ usage: '/plugin list|remove <name>', description: 'List project-installed plugins or remove one, preserving modified and seed files. /kit is an alias.' },
|
|
20
22
|
{ usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
|
|
21
23
|
{ usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
|
|
22
|
-
{ usage: '/init', description: 'Inspect the current workspace
|
|
24
|
+
{ usage: '/init', description: 'Inspect the current workspace, create or update AGENTS.md project instructions, and build/refresh the workspace code graph.' },
|
|
23
25
|
{ usage: '/context', description: 'Show a token breakdown of the current request: system prompt, project context, tools (incl. MCP), and chat messages.' },
|
|
24
26
|
{ usage: '/session', description: 'Show the current durable session file.' },
|
|
25
27
|
{ usage: '/resume [id]', description: 'Browse this workspace’s saved sessions, or resume an exact session id.' },
|
|
@@ -27,6 +29,9 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
27
29
|
{ usage: '/logs', description: 'List recent log files with sizes and dates.' },
|
|
28
30
|
{ usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
|
|
29
31
|
{ usage: '/mcp', description: 'Configure Model Context Protocol servers like Context7 (interactive picker).' },
|
|
32
|
+
{ usage: '/graph', description: 'Build or refresh the persistent workspace code graph (deterministic tree-sitter extraction, incremental after the first build) and show an orientation report: subsystems, hub symbols, import cycles.' },
|
|
33
|
+
{ usage: '/graph status', description: 'Show the current code graph state (nodes, edges, build time, staleness) without rebuilding. /graph force rebuilds from scratch.' },
|
|
34
|
+
{ usage: '/graph delete', description: 'Delete the persisted workspace code graph (rebuilt on the next /graph).' },
|
|
30
35
|
{ usage: '/logs <id>', description: 'Show summary of a specific log: entry counts by type, total tokens, tool calls.' },
|
|
31
36
|
{ usage: '/logs <id> view', description: 'Page the raw log JSONL through $PAGER in a fullscreen terminal handoff.' },
|
|
32
37
|
{ usage: '/editor', description: 'Compose a prompt in $EDITOR, then submit it as the next message.' },
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { COMMAND_HELP_ENTRIES } from './commandHelp.js';
|
|
2
|
+
/** Documented command names (the first token of each `/help` usage line) plus aliases that exist only as matchers. */
|
|
3
|
+
const COMMAND_NAMES = [...new Set([...COMMAND_HELP_ENTRIES.map(entry => entry.usage.split(/[\s<[]/)[0] ?? ''), '/kit'])];
|
|
4
|
+
/** Levenshtein distance between two strings. */
|
|
5
|
+
function editDistance(left, right) {
|
|
6
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
7
|
+
for (let leftIndex = 1; leftIndex <= left.length; leftIndex++) {
|
|
8
|
+
const current = [leftIndex];
|
|
9
|
+
for (let rightIndex = 1; rightIndex <= right.length; rightIndex++) {
|
|
10
|
+
const cost = left[leftIndex - 1] === right[rightIndex - 1] ? 0 : 1;
|
|
11
|
+
current[rightIndex] = Math.min(current[rightIndex - 1] + 1, previous[rightIndex] + 1, previous[rightIndex - 1] + cost);
|
|
12
|
+
}
|
|
13
|
+
previous = current;
|
|
14
|
+
}
|
|
15
|
+
return previous[right.length];
|
|
16
|
+
}
|
|
17
|
+
/** Closest known command (case-insensitive) by edit distance, within about one edit per three characters and at least two. */
|
|
18
|
+
function suggestCommand(value) {
|
|
19
|
+
const typed = value.trim().split(/\s+/)[0]?.toLowerCase();
|
|
20
|
+
if (!typed)
|
|
21
|
+
return undefined;
|
|
22
|
+
const maxDistance = Math.max(2, Math.floor(typed.length / 3));
|
|
23
|
+
let best;
|
|
24
|
+
for (const name of COMMAND_NAMES) {
|
|
25
|
+
const distance = editDistance(typed, name);
|
|
26
|
+
if (!best || distance < best.distance)
|
|
27
|
+
best = { name, distance };
|
|
28
|
+
}
|
|
29
|
+
return best && best.distance <= maxDistance ? best.name : undefined;
|
|
30
|
+
}
|
|
31
|
+
/** System message for an unrecognized slash command: the closest known command (when near) and a pointer to `/help`. */
|
|
32
|
+
export function unknownCommandMessage(value) {
|
|
33
|
+
const suggestion = suggestCommand(value);
|
|
34
|
+
return `Unknown command: ${value}.${suggestion ? ` Did you mean ${suggestion}?` : ''} Run /help for the list.`;
|
|
35
|
+
}
|
|
@@ -3,9 +3,11 @@ import { SETTINGS_FILE, writeSettings } from '../../config/settings.js';
|
|
|
3
3
|
import { openPath } from '../../utils/openPath.js';
|
|
4
4
|
import { clearTasks } from '../../core/tasks/taskStorage.js';
|
|
5
5
|
import { COMMAND_HELP_ENTRIES, formatCommandHelp } from './commandHelp.js';
|
|
6
|
+
import { unknownCommandMessage } from './commandSuggest.js';
|
|
6
7
|
import { handleFleetCommand } from './fleetCommand.js';
|
|
7
8
|
import { handleInitCommand } from './initCommand.js';
|
|
8
9
|
import { handleLogsCommand } from './logsCommand.js';
|
|
10
|
+
import { handleGraphCommand } from './graphCommand.js';
|
|
9
11
|
import { handleModelCommand } from './modelCommand.js';
|
|
10
12
|
import { handleReasoningCommand } from './reasoningCommand.js';
|
|
11
13
|
import { handleThemesCommand } from './themesCommand.js';
|
|
@@ -23,6 +25,10 @@ function exact(command) {
|
|
|
23
25
|
function exactOrArgs(command) {
|
|
24
26
|
return value => value === command ? { args: '' } : value.startsWith(`${command} `) ? { args: value.slice(command.length).trim() } : false;
|
|
25
27
|
}
|
|
28
|
+
async function clearChat(ctx) {
|
|
29
|
+
await ctx.clearConversation();
|
|
30
|
+
await clearTasks();
|
|
31
|
+
}
|
|
26
32
|
const SLASH_COMMANDS = [
|
|
27
33
|
{ match: value => value === '/exit' || value === '/quit' ? { args: '' } : false, run: () => 'exit' },
|
|
28
34
|
{ match: exact('/help'), run: (_args, ctx) => { ctx.addSystemMessage(formatCommandHelp(COMMAND_HELP_ENTRIES)); return HANDLED; } },
|
|
@@ -32,8 +38,10 @@ const SLASH_COMMANDS = [
|
|
|
32
38
|
await ctx.resumeSession(args || undefined);
|
|
33
39
|
else
|
|
34
40
|
ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
|
|
35
|
-
{ match: exact('/new'), run: async (_args, ctx) => { if (ctx.newSession)
|
|
41
|
+
{ match: exact('/new'), run: async (_args, ctx) => { if (ctx.newSession) {
|
|
42
|
+
await clearChat(ctx);
|
|
36
43
|
await ctx.newSession();
|
|
44
|
+
}
|
|
37
45
|
else
|
|
38
46
|
ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
|
|
39
47
|
{ match: exactOrArgs('/compact'), run: async (args, ctx) => {
|
|
@@ -45,7 +53,7 @@ const SLASH_COMMANDS = [
|
|
|
45
53
|
ctx.addSystemMessage('Compaction is unavailable.');
|
|
46
54
|
return HANDLED;
|
|
47
55
|
} },
|
|
48
|
-
{ match: exact('/clear'), run: async (_args, ctx) => { await ctx
|
|
56
|
+
{ match: exact('/clear'), run: async (_args, ctx) => { await clearChat(ctx); return HANDLED; } },
|
|
49
57
|
{ match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
|
|
50
58
|
{ match: exact('/editor'), run: async (_args, ctx) => {
|
|
51
59
|
if (!ctx.composeInEditor) {
|
|
@@ -87,6 +95,7 @@ const SLASH_COMMANDS = [
|
|
|
87
95
|
{ match: exactOrArgs('/reasoning'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
88
96
|
{ match: exactOrArgs('/thinking'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
89
97
|
{ match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
|
|
98
|
+
{ match: exactOrArgs('/graph'), run: async (args, ctx) => await handleGraphCommand(args, ctx) },
|
|
90
99
|
];
|
|
91
100
|
export async function handleSlashCommand(value, ctx) {
|
|
92
101
|
for (const command of SLASH_COMMANDS) {
|
|
@@ -98,7 +107,7 @@ export async function handleSlashCommand(value, ctx) {
|
|
|
98
107
|
if (modelResult)
|
|
99
108
|
return modelResult;
|
|
100
109
|
if (value.startsWith('/')) {
|
|
101
|
-
ctx.addSystemMessage(
|
|
110
|
+
ctx.addSystemMessage(unknownCommandMessage(value));
|
|
102
111
|
return 'handled';
|
|
103
112
|
}
|
|
104
113
|
return 'unhandled';
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* One-line summary of a tool call for the transcript rows. Wraps the raw
|
|
4
|
-
* builder: paths, patterns, and commands are model/repo-derived, so terminal
|
|
5
|
-
* control sequences are stripped at this sink (HZA-3).
|
|
6
|
-
*/
|
|
7
|
-
export declare function toolCallSummary(toolName: string, input: unknown): string;
|
|
8
|
-
/**
|
|
9
|
-
* One-line summary of a tool result for the transcript rows; same terminal
|
|
10
|
-
* control-sequence sink discipline as `toolCallSummary` (HZA-3).
|
|
11
|
-
*/
|
|
12
|
-
export declare function toolResultSummary(event: {
|
|
13
|
-
success: boolean;
|
|
14
|
-
output?: unknown;
|
|
15
|
-
error?: unknown;
|
|
16
|
-
}): string;
|
|
17
|
-
/**
|
|
18
|
-
* A short, human label for the live busy indicator while a tool is running,
|
|
19
|
-
* e.g. "Running npm test", "Reading src/foo.ts", "Searching".
|
|
20
|
-
* Lets the developer see *what* is happening, not just that something is.
|
|
21
|
-
*/
|
|
22
|
-
export declare function busyToolLabel(toolName: string, input: unknown): string;
|
|
1
|
+
export { busyToolLabel, compact, toolCallSummary, toolResultSummary } from '../chat/toolSummaries.js';
|
|
23
2
|
/** Compact transcript row for a user-attached image (F03); never dumps bytes. */
|
|
24
3
|
export declare function imageAttachmentLine(attachment: {
|
|
25
4
|
fileName: string;
|
|
@@ -52,4 +31,3 @@ export interface ContextReportData {
|
|
|
52
31
|
}
|
|
53
32
|
/** Render a detailed, /context-style token breakdown. Pure for testability. */
|
|
54
33
|
export declare function formatContextReport(data: ContextReportData): string;
|
|
55
|
-
export {};
|
|
@@ -1,228 +1,7 @@
|
|
|
1
1
|
import { formatBytes } from '../../utils/format.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (value instanceof Error) {
|
|
6
|
-
text = value.message;
|
|
7
|
-
}
|
|
8
|
-
else if (typeof value === 'string') {
|
|
9
|
-
text = value;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
text = JSON.stringify(value, (_key, nestedValue) => nestedValue instanceof Error ? nestedValue.message : nestedValue);
|
|
13
|
-
}
|
|
14
|
-
if (!text)
|
|
15
|
-
return value === null ? 'null' : value === undefined ? 'undefined' : '';
|
|
16
|
-
if (text === '{}')
|
|
17
|
-
return ''; // empty object: nothing useful to render; avoid "[object Object]"
|
|
18
|
-
return text.length > maxLength ? `${text.slice(0, maxLength)}…` : text;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* One-line summary of a tool call for the transcript rows. Wraps the raw
|
|
22
|
-
* builder: paths, patterns, and commands are model/repo-derived, so terminal
|
|
23
|
-
* control sequences are stripped at this sink (HZA-3).
|
|
24
|
-
*/
|
|
25
|
-
export function toolCallSummary(toolName, input) {
|
|
26
|
-
return stripTerminalControlSequences(toolCallSummaryText(toolName, input));
|
|
27
|
-
}
|
|
28
|
-
function toolCallSummaryText(toolName, input) {
|
|
29
|
-
const data = input;
|
|
30
|
-
if (toolName === 'shell' && typeof data?.command === 'string') {
|
|
31
|
-
const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
|
|
32
|
-
return `shell $ ${data.command}${mode}`;
|
|
33
|
-
}
|
|
34
|
-
if (toolName === 'process' && typeof data?.action === 'string')
|
|
35
|
-
return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
|
|
36
|
-
if (toolName === 'grep' && typeof data?.pattern === 'string') {
|
|
37
|
-
const path = typeof data.path === 'string' && data.path !== '.' ? ` in ${data.path}` : '';
|
|
38
|
-
const glob = typeof data.glob === 'string' ? ` (${data.glob})` : '';
|
|
39
|
-
return `grep "${data.pattern}"${path}${glob}`;
|
|
40
|
-
}
|
|
41
|
-
if (toolName === 'listFiles' && typeof data?.path === 'string')
|
|
42
|
-
return `listFiles ${data.path}`;
|
|
43
|
-
if ((toolName === 'readFile' || toolName === 'writeFile')) {
|
|
44
|
-
if (typeof data?.path === 'string')
|
|
45
|
-
return `${toolName} ${data.path}`;
|
|
46
|
-
if (data == null || (typeof data === 'object' && Object.keys(data).length === 0))
|
|
47
|
-
return toolName; // input not yet streamed (tool-input-start) or empty
|
|
48
|
-
}
|
|
49
|
-
if (toolName === 'editFile' && typeof data?.path === 'string') {
|
|
50
|
-
const edits = Array.isArray(data.edits) ? ` (${data.edits.length} edit${data.edits.length === 1 ? '' : 's'})` : '';
|
|
51
|
-
return `${toolName} ${data.path}${edits}`;
|
|
52
|
-
}
|
|
53
|
-
if (toolName === 'replaceInFiles' && typeof data?.needle === 'string')
|
|
54
|
-
return `replaceInFiles "${compact(data.needle, 60)}"${typeof data.path === 'string' && data.path !== '.' ? ` in ${data.path}` : ''}${data.dryRun === false ? '' : ' (dry run)'}`;
|
|
55
|
-
if (toolName === 'replaceLines' && typeof data?.path === 'string')
|
|
56
|
-
return `replaceLines ${data.path}:${data.startLine}-${data.endLine}`;
|
|
57
|
-
if ((toolName === 'editFile' || toolName === 'replaceInFiles' || toolName === 'replaceLines') && (data == null || (typeof data === 'object' && Object.keys(data).length === 0)))
|
|
58
|
-
return toolName;
|
|
59
|
-
if (toolName === 'subagent') {
|
|
60
|
-
const task = typeof data?.objective === 'string' ? data.objective : typeof data?.task === 'string' ? data.task : undefined;
|
|
61
|
-
if (task) {
|
|
62
|
-
const taskPreview = task.length > 60 ? `${task.slice(0, 60).trimEnd()}…` : task;
|
|
63
|
-
return `subagent "${taskPreview}"`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (toolName === 'writeTasks') {
|
|
67
|
-
const tasks = Array.isArray(data?.tasks) ? data.tasks : [];
|
|
68
|
-
return `writeTasks (${tasks.length} task${tasks.length === 1 ? '' : 's'})`;
|
|
69
|
-
}
|
|
70
|
-
if (toolName === 'lspWorkspaceSymbols' && typeof data?.query === 'string')
|
|
71
|
-
return `lspWorkspaceSymbols "${data.query}"`;
|
|
72
|
-
if (toolName === 'lspSymbols' && typeof data?.path === 'string')
|
|
73
|
-
return `lspSymbols ${data.path}`;
|
|
74
|
-
if ((toolName === 'lspFindSymbol' || toolName === 'lspRenameSymbol' || toolName === 'lspSafeDeleteSymbol' || toolName === 'lspDiagnosticsForSymbol') && typeof data?.namePath === 'string')
|
|
75
|
-
return `${toolName} ${typeof data.path === 'string' ? `${data.path}:` : ''}${data.namePath}`;
|
|
76
|
-
if (toolName === 'lspDiagnostics' && typeof data?.path === 'string')
|
|
77
|
-
return `lspDiagnostics ${data.path}`;
|
|
78
|
-
if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
|
|
79
|
-
return `${toolName} ${data.path}:${data.line}:${data.column}`;
|
|
80
|
-
return `${toolName} ${compact(input)}`;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* One-line summary of a tool result for the transcript rows; same terminal
|
|
84
|
-
* control-sequence sink discipline as `toolCallSummary` (HZA-3).
|
|
85
|
-
*/
|
|
86
|
-
export function toolResultSummary(event) {
|
|
87
|
-
return stripTerminalControlSequences(toolResultSummaryText(event));
|
|
88
|
-
}
|
|
89
|
-
function toolResultSummaryText(event) {
|
|
90
|
-
const output = event.output;
|
|
91
|
-
if (!event.success)
|
|
92
|
-
return `failed: ${compact(event.error ?? output?.error ?? event.output)}`;
|
|
93
|
-
if (output?.duplicateSkipped === true)
|
|
94
|
-
return 'skipped duplicate';
|
|
95
|
-
if (output?.background === true && typeof output.backgroundId === 'string') {
|
|
96
|
-
return `⏵ ${output.backgroundId} ${compact(output.command, 80)}${typeof output.pid === 'number' ? ` (pid ${output.pid})` : ''}`;
|
|
97
|
-
}
|
|
98
|
-
if (typeof output?.totalMatches === 'number') {
|
|
99
|
-
const count = output.totalMatches;
|
|
100
|
-
return count === 0 ? 'no matches' : `${output.matchCountIsLowerBound === true ? 'at least ' : ''}${count} match${count === 1 ? '' : 'es'}`;
|
|
101
|
-
}
|
|
102
|
-
if (typeof output?.validationSummary === 'object' && output.validationSummary != null && 'summaryText' in output.validationSummary) {
|
|
103
|
-
const summary = output.validationSummary;
|
|
104
|
-
const next = typeof summary.suggestedNextStep === 'string' ? `; next: ${summary.suggestedNextStep}` : '';
|
|
105
|
-
return `${String(summary.summaryText)}${next}`;
|
|
106
|
-
}
|
|
107
|
-
if (typeof output?.code === 'number') {
|
|
108
|
-
const risk = typeof output.classification?.riskLevel === 'string'
|
|
109
|
-
? ` (${output.classification.riskLevel})`
|
|
110
|
-
: '';
|
|
111
|
-
return `exited with code ${output.code}${risk}`;
|
|
112
|
-
}
|
|
113
|
-
const resultOutput = output ?? {};
|
|
114
|
-
const capsule = typeof resultOutput.capsule === 'object' && resultOutput.capsule != null ? resultOutput.capsule : undefined;
|
|
115
|
-
if (capsule && typeof capsule.termination === 'string' && typeof capsule.deliverable === 'string') {
|
|
116
|
-
const summary = capsule.deliverable.split('\n')[0] ?? '';
|
|
117
|
-
const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
|
|
118
|
-
const telemetry = typeof resultOutput.telemetry === 'object' && resultOutput.telemetry != null ? resultOutput.telemetry : undefined;
|
|
119
|
-
const calls = typeof telemetry?.toolCallCount === 'number' ? telemetry.toolCallCount : typeof resultOutput.toolCallCount === 'number' ? resultOutput.toolCallCount : 0;
|
|
120
|
-
const durationMs = typeof telemetry?.durationMs === 'number' ? telemetry.durationMs : resultOutput.durationMs;
|
|
121
|
-
const duration = typeof durationMs === 'number' ? ` in ${(durationMs / 1000).toFixed(1)}s` : '';
|
|
122
|
-
const meta = calls > 0 ? ` (${calls} call${calls === 1 ? '' : 's'}${duration})` : '';
|
|
123
|
-
return `${capsule.termination}${capsule.usable === false ? ' · unusable' : ''}${capsule.truncated === true ? ' · truncated' : ''}${meta}: ${preview}`;
|
|
124
|
-
}
|
|
125
|
-
if (typeof output?.status === 'string' && typeof output?.summary === 'string') {
|
|
126
|
-
const summary = output.summary.split('\n')[0] ?? '';
|
|
127
|
-
const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
|
|
128
|
-
const calls = typeof output.toolCallCount === 'number' ? output.toolCallCount : output.toolCalls?.length ?? 0;
|
|
129
|
-
const duration = typeof output.durationMs === 'number' ? ` in ${(output.durationMs / 1000).toFixed(1)}s` : '';
|
|
130
|
-
const meta = calls > 0 ? ` (${calls} call${calls === 1 ? '' : 's'}${duration})` : '';
|
|
131
|
-
return `${output.status}${meta}: ${preview}`;
|
|
132
|
-
}
|
|
133
|
-
if (typeof output?.server === 'string' && Array.isArray(output.symbols)) {
|
|
134
|
-
const count = output.symbols.length;
|
|
135
|
-
return `${count} symbol${count === 1 ? '' : 's'} from ${output.server}`;
|
|
136
|
-
}
|
|
137
|
-
if (typeof output?.server === 'string' && Array.isArray(output.locations)) {
|
|
138
|
-
const count = output.locations.length;
|
|
139
|
-
return `${count} location${count === 1 ? '' : 's'} from ${output.server}`;
|
|
140
|
-
}
|
|
141
|
-
if (typeof output?.ok === 'boolean') {
|
|
142
|
-
// writeTasks result
|
|
143
|
-
if (output.ok && typeof output.summary === 'string') {
|
|
144
|
-
return compact(output.summary, 120);
|
|
145
|
-
}
|
|
146
|
-
if (output.ok) {
|
|
147
|
-
if (output.noChange === true)
|
|
148
|
-
return 'No changes made';
|
|
149
|
-
if (typeof output.addedLines === 'number' || typeof output.removedLines === 'number') {
|
|
150
|
-
const added = typeof output.addedLines === 'number' ? output.addedLines : 0;
|
|
151
|
-
const removed = typeof output.removedLines === 'number' ? output.removedLines : 0;
|
|
152
|
-
return `Added ${added} line${added === 1 ? '' : 's'}, removed ${removed} line${removed === 1 ? '' : 's'}`;
|
|
153
|
-
}
|
|
154
|
-
return 'completed';
|
|
155
|
-
}
|
|
156
|
-
if (output.reasonCode === 'secret_file_protected' || output.reasonCode === 'git_internals_protected') {
|
|
157
|
-
// Protection events are visible but distinct from ordinary failures so
|
|
158
|
-
// the developer can audit them at a glance; never print file contents.
|
|
159
|
-
const protectedPath = typeof output.path === 'string' && output.path ? ` (${compact(output.path, 80)})` : '';
|
|
160
|
-
const kind = output.reasonCode === 'secret_file_protected' ? 'protected secret file' : 'protected git internals';
|
|
161
|
-
return `blocked: ${kind}${protectedPath}`;
|
|
162
|
-
}
|
|
163
|
-
const reason = typeof output.reasonCode === 'string' ? ` (${output.reasonCode})` : '';
|
|
164
|
-
return typeof output.error === 'string' ? `failed${reason}: ${compact(output.error)}` : `failed${reason}`;
|
|
165
|
-
}
|
|
166
|
-
return 'completed';
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The short head of a shell command for the busy label: the program plus its
|
|
170
|
-
* first non-flag argument ("git diff", "npm test") — enough to identify the
|
|
171
|
-
* action without echoing the full (possibly long or sensitive) command line.
|
|
172
|
-
*/
|
|
173
|
-
function commandHead(command) {
|
|
174
|
-
const parts = command.trim().split(/\s+/);
|
|
175
|
-
const head = [parts[0]];
|
|
176
|
-
for (const part of parts.slice(1)) {
|
|
177
|
-
if (part.startsWith('-'))
|
|
178
|
-
continue;
|
|
179
|
-
head.push(part);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
return compact(head.filter(Boolean).join(' '), 80);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* A short, human label for the live busy indicator while a tool is running,
|
|
186
|
-
* e.g. "Running npm test", "Reading src/foo.ts", "Searching".
|
|
187
|
-
* Lets the developer see *what* is happening, not just that something is.
|
|
188
|
-
*/
|
|
189
|
-
export function busyToolLabel(toolName, input) {
|
|
190
|
-
const data = input;
|
|
191
|
-
const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
|
|
192
|
-
switch (toolName) {
|
|
193
|
-
case 'shell':
|
|
194
|
-
if (data?.background === true)
|
|
195
|
-
return 'Starting background process';
|
|
196
|
-
return typeof data?.command === 'string' && data.command ? `Running ${commandHead(data.command)}` : 'Running command';
|
|
197
|
-
case 'process':
|
|
198
|
-
return 'Managing background process';
|
|
199
|
-
case 'grep':
|
|
200
|
-
return 'Searching';
|
|
201
|
-
case 'listFiles':
|
|
202
|
-
return 'Listing files';
|
|
203
|
-
case 'readFile':
|
|
204
|
-
return pathLabel ? `Reading ${pathLabel}` : 'Reading file';
|
|
205
|
-
case 'writeFile':
|
|
206
|
-
return pathLabel ? `Writing ${pathLabel}` : 'Writing file';
|
|
207
|
-
case 'editFile':
|
|
208
|
-
case 'replaceLines':
|
|
209
|
-
return pathLabel ? `Editing ${pathLabel}` : 'Editing file';
|
|
210
|
-
case 'fetch':
|
|
211
|
-
return 'Fetching URL';
|
|
212
|
-
case 'subagent':
|
|
213
|
-
return 'Running subagent';
|
|
214
|
-
case 'writeTasks':
|
|
215
|
-
return 'Updating tasks';
|
|
216
|
-
case 'skill':
|
|
217
|
-
return 'Loading skill';
|
|
218
|
-
default:
|
|
219
|
-
if (toolName.startsWith('lsp'))
|
|
220
|
-
return 'Querying LSP';
|
|
221
|
-
if (toolName.startsWith('mcp'))
|
|
222
|
-
return 'Running MCP tool';
|
|
223
|
-
return `Running ${toolName}`;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
2
|
+
// The one-line tool call/result/busy-label builders live in `chat/toolSummaries.ts`
|
|
3
|
+
// (ARCH-03) and are re-exported here for the transcript formatters' callers.
|
|
4
|
+
export { busyToolLabel, compact, toolCallSummary, toolResultSummary } from '../chat/toolSummaries.js';
|
|
226
5
|
/** Compact transcript row for a user-attached image (F03); never dumps bytes. */
|
|
227
6
|
export function imageAttachmentLine(attachment) {
|
|
228
7
|
return `🖼 ${attachment.fileName} (${formatBytes(attachment.bytes)})`;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/graph` — build or refresh the workspace code graph and print the
|
|
3
|
+
* orientation report (subsystems, hub symbols, import cycles).
|
|
4
|
+
*
|
|
5
|
+
* `/graph status` only reports the current graph state without rebuilding.
|
|
6
|
+
* `/graph force` rebuilds from scratch. `/graph delete` removes the persisted
|
|
7
|
+
* graph for this workspace. Deterministic tree-sitter extraction; no LLM cost.
|
|
8
|
+
*/
|
|
9
|
+
import { buildGraphIndex } from '../../core/graph/model.js';
|
|
10
|
+
import { deleteGraph, graphStatus, graphStoreFor } from '../../core/graph/store.js';
|
|
11
|
+
import { buildWorkspaceGraph } from '../../core/graph/buildGraph.js';
|
|
12
|
+
import { renderGraphReport } from '../../core/graph/analyze.js';
|
|
13
|
+
import { workspaceRoot } from '../../utils/path.js';
|
|
14
|
+
export async function handleGraphCommand(args, ctx) {
|
|
15
|
+
const store = graphStoreFor(workspaceRoot());
|
|
16
|
+
const arg = args.trim();
|
|
17
|
+
if (arg === 'status') {
|
|
18
|
+
const status = await graphStatus(store);
|
|
19
|
+
if (!status.exists) {
|
|
20
|
+
ctx.addSystemMessage('No code graph for this workspace yet. Run /graph to build one (deterministic, no LLM cost).');
|
|
21
|
+
return 'handled';
|
|
22
|
+
}
|
|
23
|
+
const builtAt = status.builtAt ? new Date(status.builtAt).toISOString().replace('T', ' ').slice(0, 16) : 'unknown';
|
|
24
|
+
ctx.addSystemMessage([
|
|
25
|
+
`Code graph: ${status.nodeCount} nodes · ${status.edgeCount} edges · ${status.fileCount} files`,
|
|
26
|
+
`Built at ${builtAt} (UTC)${status.stale ? ' · STALE: files changed since; run /graph to refresh' : ' · fresh'}`,
|
|
27
|
+
].join('\n'));
|
|
28
|
+
return 'handled';
|
|
29
|
+
}
|
|
30
|
+
if (arg === 'delete') {
|
|
31
|
+
const removed = await deleteGraph(store);
|
|
32
|
+
ctx.addSystemMessage(removed
|
|
33
|
+
? 'Deleted the code graph for this workspace. Run /graph to rebuild it.'
|
|
34
|
+
: 'No code graph for this workspace; nothing to delete.');
|
|
35
|
+
return 'handled';
|
|
36
|
+
}
|
|
37
|
+
const force = arg === 'force';
|
|
38
|
+
ctx.addSystemMessage(force ? 'Rebuilding the code graph from scratch…' : 'Building the code graph…');
|
|
39
|
+
try {
|
|
40
|
+
const result = await buildWorkspaceGraph({ force });
|
|
41
|
+
if (result.graph.nodes.length === 0) {
|
|
42
|
+
ctx.addSystemMessage('No supported source files found (js/ts/tsx/jsx). Nothing to map.');
|
|
43
|
+
return 'handled';
|
|
44
|
+
}
|
|
45
|
+
const report = renderGraphReport(buildGraphIndex(result.graph), {
|
|
46
|
+
graph: result.graph,
|
|
47
|
+
files: result.files,
|
|
48
|
+
parsedFiles: result.parsedFiles,
|
|
49
|
+
cachedFiles: result.cachedFiles,
|
|
50
|
+
durationMs: result.durationMs,
|
|
51
|
+
stale: false,
|
|
52
|
+
});
|
|
53
|
+
ctx.addSystemMessage(report);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
ctx.addSystemMessage(`Code graph build failed: ${message}`);
|
|
58
|
+
}
|
|
59
|
+
return 'handled';
|
|
60
|
+
}
|
|
@@ -3,6 +3,7 @@ import { pathExists } from '../../utils/fs.js';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { MAX_CONTEXT_FILE_CHARS } from '../../config/contextFiles.js';
|
|
5
5
|
import { buildInitPrompt } from '../../llm/initPrompt.js';
|
|
6
|
+
import { buildWorkspaceGraph } from '../../core/graph/buildGraph.js';
|
|
6
7
|
export async function handleInitCommand(ctx) {
|
|
7
8
|
await ctx.runAgentTurn(buildInitPrompt(), '/init');
|
|
8
9
|
await ctx.refreshContextFiles();
|
|
@@ -16,5 +17,18 @@ export async function handleInitCommand(ctx) {
|
|
|
16
17
|
: `AGENTS.md validation: ${chars.toLocaleString()} chars / ${lines} lines — within the ${MAX_CONTEXT_FILE_CHARS.toLocaleString()}-char context budget.`;
|
|
17
18
|
ctx.addSystemMessage(msg);
|
|
18
19
|
}
|
|
20
|
+
// /init also builds/refreshes the workspace code graph so graph tools work
|
|
21
|
+
// from the start; incremental, deterministic, no LLM cost. Failures never
|
|
22
|
+
// block /init — the model can rebuild later via graphRebuild or /graph.
|
|
23
|
+
try {
|
|
24
|
+
const graph = await buildWorkspaceGraph();
|
|
25
|
+
if (graph.graph.nodes.length > 0) {
|
|
26
|
+
ctx.addSystemMessage(`Code graph: ${graph.graph.nodes.length} nodes · ${graph.graph.edges.length} edges · ${graph.files} files (${(graph.durationMs / 1000).toFixed(1)}s, ${graph.cachedFiles} cached / ${graph.parsedFiles} parsed).`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31
|
+
ctx.addSystemMessage(`Code graph build skipped: ${message}`);
|
|
32
|
+
}
|
|
19
33
|
return 'handled';
|
|
20
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { configuredProviders, modelSelector, resolveModelSelector, upsertProvider } from '../../config/providers.js';
|
|
2
2
|
export async function handleModelCommand(value, ctx) {
|
|
3
3
|
if (value === '/model') {
|
|
4
4
|
ctx.setModelProviderFilter?.(undefined);
|
|
@@ -20,14 +20,18 @@ export async function handleModelCommand(value, ctx) {
|
|
|
20
20
|
return 'handled';
|
|
21
21
|
}
|
|
22
22
|
if (resolved.status === 'missing') {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// UX-10: a bare typo must not be silently registered and persisted — only
|
|
24
|
+
// an explicit `provider:model` selector registers a new model.
|
|
25
|
+
const colon = selector.indexOf(':');
|
|
26
|
+
const namedProvider = colon > 0 ? configuredProviders(ctx.settings).find(candidate => candidate.name === selector.slice(0, colon)) : undefined;
|
|
27
|
+
if (!namedProvider || colon === selector.length - 1) {
|
|
28
|
+
ctx.addSystemMessage(`Unknown model "${selector}". Pick one with /model, list all with /model list, or register a new one explicitly as /model provider:model.`);
|
|
26
29
|
return 'handled';
|
|
27
30
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
ctx.
|
|
31
|
+
const model = selector.slice(colon + 1);
|
|
32
|
+
const nextProvider = namedProvider.models.includes(model) ? namedProvider : { ...namedProvider, models: [...namedProvider.models, model] };
|
|
33
|
+
await ctx.updateSettings({ provider: namedProvider.name, model, providers: upsertProvider(ctx.settings, nextProvider) });
|
|
34
|
+
ctx.addSystemMessage(`Model set to ${model} on ${namedProvider.name}. Saved to ~/.haze/settings.json.`);
|
|
31
35
|
return 'handled';
|
|
32
36
|
}
|
|
33
37
|
await ctx.updateSettings({ provider: resolved.provider.name, model: resolved.model });
|
|
@@ -36,7 +36,7 @@ export function resolveReasoningCommand(args, input) {
|
|
|
36
36
|
if (!value)
|
|
37
37
|
return { action: 'open-picker' };
|
|
38
38
|
if (value === 'status') {
|
|
39
|
-
return { action: 'status', message: `Reasoning effort${scope}: ${describeChoice(input.current)}. Set with /reasoning <level> (this model, this session), /reasoning unset to send no reasoning parameter, or /reasoning reset to fall back to the saved/default level. Levels: ${LEVELS_LIST}.` };
|
|
39
|
+
return { action: 'status', message: `Reasoning effort${scope}: ${describeChoice(input.current)}. Set with /reasoning <level> (this model, this session), /reasoning unset to send no reasoning parameter, or /reasoning reset to fall back to the saved/default level. Levels: ${LEVELS_LIST} (off = none).` };
|
|
40
40
|
}
|
|
41
41
|
if (value === REASONING_RESET) {
|
|
42
42
|
const fallback = resolveReasoningChoice(undefined, input.stored);
|
|
@@ -69,7 +69,7 @@ export async function handleReasoningCommand(args, ctx) {
|
|
|
69
69
|
ctx.addSystemMessage(`No adjustable reasoning levels are known for ${selected.model}. Choose a supported model via /model or configure its reasoning levels; unset sends no parameter.`);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
ctx.addSystemMessage('Choose a reasoning effort level for the active model, for this session. unset sends no reasoning parameter (provider default); reset falls back to the saved or default level.');
|
|
72
|
+
ctx.addSystemMessage('Choose a reasoning effort level for the active model, for this session. off = none; unset sends no reasoning parameter (provider default); reset falls back to the saved or default level.');
|
|
73
73
|
}
|
|
74
74
|
return 'handled';
|
|
75
75
|
}
|
|
@@ -89,7 +89,7 @@ export async function handleReasoningCommand(args, ctx) {
|
|
|
89
89
|
}
|
|
90
90
|
if (value === 'status') {
|
|
91
91
|
const applied = current.level && levels.includes(current.level) ? describeChoice(current) : 'provider default (no parameter sent)';
|
|
92
|
-
ctx.addSystemMessage(`Reasoning effort for ${modelSelector}: ${applied}. ${levels.length ? `Supported levels: ${levels.join(', ')}.` : support === 'unknown' ? 'Reasoning support is unknown for this model.' : 'Reasoning effort is unsupported for this model.'}`);
|
|
92
|
+
ctx.addSystemMessage(`Reasoning effort for ${modelSelector}: ${applied}. ${levels.length ? `Supported levels: ${levels.join(', ')} (off = none); unset sends no parameter (provider default).` : support === 'unknown' ? 'Reasoning support is unknown for this model.' : 'Reasoning effort is unsupported for this model.'}`);
|
|
93
93
|
return 'handled';
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -13,6 +13,7 @@ import { FALLBACK_CONTEXT_WINDOW_TOKENS } from '../../core/agent/contextBudget.j
|
|
|
13
13
|
import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
14
14
|
import { MAX_TURN_DEADLINE_MS } from '../../core/agent/budgets.js';
|
|
15
15
|
import { NdjsonSink, queueNdjsonWrite } from './ndjsonSink.js';
|
|
16
|
+
import { stripTerminalControlSequences } from '../../ui/terminalSanitize.js';
|
|
16
17
|
function pinnedUsage(usage) {
|
|
17
18
|
// Normalize every field to a number: TokenUsage seeds most fields to 0 but
|
|
18
19
|
// inputTokens/outputTokens may be undefined until the first report. A uniform ?? 0
|
|
@@ -388,10 +389,13 @@ export async function runHeadless(options) {
|
|
|
388
389
|
}
|
|
389
390
|
}
|
|
390
391
|
else if (status === 'complete') {
|
|
391
|
-
|
|
392
|
+
// The model answer can quote control sequences from fetched pages or tool
|
|
393
|
+
// output; never let them reach the terminal (JSON modes escape them).
|
|
394
|
+
const text = stripTerminalControlSequences(result);
|
|
395
|
+
process.stdout.write(text + (text.endsWith('\n') ? '' : '\n'));
|
|
392
396
|
}
|
|
393
397
|
else {
|
|
394
|
-
process.stderr.write(`${result || `Turn ${status}.`}\n`);
|
|
398
|
+
process.stderr.write(`${stripTerminalControlSequences(result) || `Turn ${status}.`}\n`);
|
|
395
399
|
}
|
|
396
400
|
return status === 'complete' ? 0 : 1;
|
|
397
401
|
}
|
|
@@ -47,7 +47,7 @@ export async function runAgentAttempt(input) {
|
|
|
47
47
|
let stallGuard;
|
|
48
48
|
let setup;
|
|
49
49
|
try {
|
|
50
|
-
setup = await prepareAttempt({ value, contextFiles, callbacks, retryingExistingRequest, overflowShrinkFactor: input.overflowShrinkFactor, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnBudget, globalBudget, sliceBudget, goal, onContextFileRead: path => toolDisplay.addContextFileRead(path), usageAnchor });
|
|
50
|
+
setup = await prepareAttempt({ value, contextFiles, callbacks, retryingExistingRequest, overflowShrinkFactor: input.overflowShrinkFactor, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnState, turnBudget, globalBudget, sliceBudget, goal, onContextFileRead: path => toolDisplay.addContextFileRead(path), usageAnchor });
|
|
51
51
|
if (!setup)
|
|
52
52
|
return { status: 'failed' };
|
|
53
53
|
const attemptSetupResult = setup;
|
|
@@ -72,6 +72,16 @@ export async function runAgentAttempt(input) {
|
|
|
72
72
|
debugLog: callbacks.debugLog,
|
|
73
73
|
});
|
|
74
74
|
const stream = await runAttemptStream({ setup, callbacks, abortController, retryAttempt, recoverySlice: turnOptions.recoverySlice, turnState, turnBudget, globalBudget, goal, stallGuard, loopState, toolDisplay, salvage, usageAnchor });
|
|
75
|
+
// An abort that lands in the epoch-boundary window — most easily during
|
|
76
|
+
// mid-turn LLM compaction, whose internal abort is caught — exits the
|
|
77
|
+
// stream loop normally instead of throwing. Route it through the same
|
|
78
|
+
// cause-aware failure classification as a thrown abort, so the recorded
|
|
79
|
+
// cause (user / turn-deadline / idle stall) decides retry, pause, or
|
|
80
|
+
// aborted; a finalize on an aborted controller would otherwise trust the
|
|
81
|
+
// last finish shape and could report a cancelled goal as complete.
|
|
82
|
+
if (abortController.signal.aborted) {
|
|
83
|
+
return handleAttemptFailure({ value, callbacks, abortController, turnState, retryAttempt, progressSinceLastRetry: input.progressSinceLastRetry, overflowRetries: input.overflowRetries, abortCause, stallGuard, salvage, error: new Error('aborted between model steps'), maxRetries: attemptSetupResult.modelRetries, retryBaseDelayMs: attemptSetupResult.retryBaseDelayMs, idleTimeoutMs: attemptSetupResult.streamIdleTimeoutMs, goal, turnOptions });
|
|
84
|
+
}
|
|
75
85
|
return finalizeAttemptOutcome({ value, callbacks, abortController, turnOptions, turnState, turnBudget, goal, remainingTurnDeadlineMs, stream, retryAttempt, overflowRetries: input.overflowRetries });
|
|
76
86
|
}
|
|
77
87
|
catch (error) {
|
|
@@ -58,6 +58,7 @@ export function createQuarantinableCallbacks(callbacks) {
|
|
|
58
58
|
compactConversation: callbacks.compactConversation && whileLiveBoolean(callbacks.compactConversation),
|
|
59
59
|
recordCompaction: callbacks.recordCompaction && whileLive(callbacks.recordCompaction),
|
|
60
60
|
recordTokenUsage: callbacks.recordTokenUsage && whileLive(callbacks.recordTokenUsage),
|
|
61
|
+
recordContextUsage: callbacks.recordContextUsage && whileLive(callbacks.recordContextUsage),
|
|
61
62
|
setWorkState: callbacks.setWorkState && whileLive(callbacks.setWorkState),
|
|
62
63
|
onTasksChanged: callbacks.onTasksChanged && whileLive(callbacks.onTasksChanged),
|
|
63
64
|
get log() {
|