@denizokcu/haze 1.7.11 → 1.7.12
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 +18 -0
- package/README.md +113 -97
- 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/dist/buildInfo.json +3 -3
- package/dist/cli/chat/inputSuggestions.js +1 -0
- package/dist/cli/chat/sessionLifecycle.js +2 -1
- package/dist/cli/chat/sessionRecorder.js +4 -1
- package/dist/cli/chat/startupSequence.d.ts +2 -0
- package/dist/cli/chat/startupSequence.js +6 -0
- package/dist/cli/commands/chat.js +5 -2
- package/dist/cli/commands/commandHelp.js +4 -1
- package/dist/cli/commands/commands.js +2 -0
- package/dist/cli/commands/formatters.js +28 -0
- 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/streaming/agentAttempt.js +11 -1
- package/dist/cli/commands/streaming/attemptOutcome.js +1 -1
- package/dist/cli/commands/streaming/attemptSetup.d.ts +3 -0
- package/dist/cli/commands/streaming/attemptSetup.js +8 -3
- package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
- package/dist/cli/commands/streaming/prepareStep.js +1 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
- package/dist/cli/commands/streaming/streamLoop.js +3 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +7 -1
- package/dist/cli/commands/streaming.js +5 -0
- package/dist/core/agent/compaction.d.ts +1 -0
- package/dist/core/agent/compaction.js +3 -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/process/runBoundedProcess.js +12 -6
- package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
- package/dist/core/safety/untrustedEnvelopes.js +17 -2
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/tasks/taskStorage.js +11 -1
- package/dist/core/validation/outputParser.js +16 -8
- package/dist/llm/hazeTools.d.ts +2 -12426
- package/dist/llm/hazeTools.js +2 -0
- package/dist/llm/lspTools.d.ts +3 -12622
- package/dist/llm/requestContext.d.ts +3 -0
- package/dist/llm/requestContext.js +13 -4
- package/dist/llm/subagentRunner.d.ts +2 -308
- package/dist/llm/systemPrompt.js +7 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/fetchTool.d.ts +2 -1221
- package/dist/llm/tools/fileTools.d.ts +2 -7768
- 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/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/toolContext.js +24 -9
- package/dist/llm/tools/toolContextState.d.ts +3 -0
- package/dist/llm/tools/toolContextState.js +2 -1
- package/dist/skills/skillTools.js +4 -1
- package/package.json +18 -15
package/dist/buildInfo.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizokcu/haze",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"commit": "
|
|
5
|
-
"builtAt": "2026-11-
|
|
3
|
+
"version": "1.7.12",
|
|
4
|
+
"commit": "6caef47334dd48adc89a9b58379eb1f0c1135a02",
|
|
5
|
+
"builtAt": "2026-11-20T17:35:30.238Z"
|
|
6
6
|
}
|
|
@@ -20,6 +20,7 @@ const CHAT_COMMAND_SUGGESTIONS = [
|
|
|
20
20
|
{ value: '/session', description: 'Show current session path', kind: 'command' },
|
|
21
21
|
{ value: '/resume', description: 'Browse saved sessions for this workspace', kind: 'command' },
|
|
22
22
|
{ value: '/new', description: 'Start a new session', kind: 'command' },
|
|
23
|
+
{ value: '/graph', description: 'Build or refresh the workspace code graph (deterministic, incremental) and show an orientation report', kind: 'command' },
|
|
23
24
|
{ value: '/logs', description: 'List recent LLM logs, or summarize one by id (--debug runs only)', kind: 'command' },
|
|
24
25
|
{ value: '/compact ', description: 'Summarize older context and keep recent messages', kind: 'command' },
|
|
25
26
|
{ value: '/clear', description: 'Clear conversation history', kind: 'command' },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { streamText } from 'ai';
|
|
2
2
|
import { transitionProviderConversation } from '../../core/agent/providerTransition.js';
|
|
3
3
|
import { buildLlmCompactionPrompt, compactModelMessages, compactModelMessagesWithSummary, splitForCompaction } from '../../core/agent/compaction.js';
|
|
4
|
+
import { buildCodeGraphDigest } from '../../core/graph/digest.js';
|
|
4
5
|
import { FALLBACK_CONTEXT_WINDOW_TOKENS } from '../../core/agent/contextBudget.js';
|
|
5
6
|
import { COMPACTION_LLM_MAX_OUTPUT_TOKENS } from '../../core/agent/budgets.js';
|
|
6
7
|
import { clearToolOutputs } from '../../core/agent/toolOutputStore.js';
|
|
@@ -231,7 +232,7 @@ export function createSessionLifecycle(deps) {
|
|
|
231
232
|
const summarization = streamText({
|
|
232
233
|
model: runtime.model,
|
|
233
234
|
...providerSettings,
|
|
234
|
-
prompt: buildLlmCompactionPrompt({ older: split.older, instructions }),
|
|
235
|
+
prompt: buildLlmCompactionPrompt({ older: split.older, instructions, codeGraphDigest: await buildCodeGraphDigest() }),
|
|
235
236
|
abortSignal: AbortSignal.timeout(COMPACT_SUMMARY_TIMEOUT_MS),
|
|
236
237
|
});
|
|
237
238
|
const summaryText = (await summarization.text).trim();
|
|
@@ -8,7 +8,10 @@ export function createSessionRecorder(getSession) {
|
|
|
8
8
|
const session = getSession();
|
|
9
9
|
if (!session)
|
|
10
10
|
return;
|
|
11
|
-
|
|
11
|
+
// Per-call rejections are captured as the writer's sticky first error and
|
|
12
|
+
// surfaced once by flush()/error(); an unhandled rejection here would kill
|
|
13
|
+
// the process on Node >=22 (the sibling paths below do the same).
|
|
14
|
+
void writer.append({ session, entry }).catch(() => undefined);
|
|
12
15
|
};
|
|
13
16
|
// Full-history snapshot coalescing (RH-008). conversation_snapshot and
|
|
14
17
|
// work_state_snapshot entries are large and only the latest of each is ever
|
|
@@ -19,6 +19,8 @@ export interface StartupSequenceOptions {
|
|
|
19
19
|
/** Reloads the skill registry (also reports project-skill and error signatures). */
|
|
20
20
|
refreshSkills: () => Promise<unknown>;
|
|
21
21
|
addSystemMessage: (text: string) => void;
|
|
22
|
+
/** Notified only when the background graph build actually starts/finishes. */
|
|
23
|
+
onGraphActivity?: (building: boolean) => void;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* The chat screen's startup sequence, extracted so ChatScreen stays rendering
|
|
@@ -4,6 +4,7 @@ import { readContextFiles } from '../../config/contextFiles.js';
|
|
|
4
4
|
import { readSettings } from '../../config/settings.js';
|
|
5
5
|
import { checkForUpdate } from '../../config/updateCheck.js';
|
|
6
6
|
import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
|
|
7
|
+
import { ensureGraphInBackground } from '../../core/graph/buildGraph.js';
|
|
7
8
|
import { startupContextInfo, startupProviderInfo } from './startupInfo.js';
|
|
8
9
|
const execFile = promisify(execFileCallback);
|
|
9
10
|
/** Current git branch name for the workspace header, or undefined outside a repo/branch. */
|
|
@@ -56,4 +57,9 @@ export async function runStartupSequence(options) {
|
|
|
56
57
|
else if (!runtimeCapabilities().goalSupervisorAvailable) {
|
|
57
58
|
options.addSystemMessage('Warning: this haze build lacks the goal supervisor module; exhausting a turn step/tool budget may pause the goal instead of continuing automatically. Reinstall or relink haze (npm run dev:link in the checkout).');
|
|
58
59
|
}
|
|
60
|
+
// Keep the workspace code graph warm without blocking startup: a single
|
|
61
|
+
// background build on every startup — creating the graph when none exists
|
|
62
|
+
// yet, incrementally refreshing it afterwards. Failures are silent here;
|
|
63
|
+
// the graph tools surface `graph_not_built` with a hint.
|
|
64
|
+
void ensureGraphInBackground({ onActivity: options.onGraphActivity });
|
|
59
65
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useReducer, useRef, useState } from 'react';
|
|
3
3
|
import { Box, render, Static, Text, useApp, useWindowSize } from 'ink';
|
|
4
|
-
import { StatusNotice } from '../../ui/components/NativeIndicators.js';
|
|
4
|
+
import { ActivitySpinner, StatusNotice } from '../../ui/components/NativeIndicators.js';
|
|
5
5
|
import { BusyBar } from '../chat/BusyBar.js';
|
|
6
6
|
import { readContextFiles } from '../../config/contextFiles.js';
|
|
7
7
|
import { addInputHistoryItem, readInputHistory } from '../../config/inputHistory.js';
|
|
@@ -168,6 +168,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
168
168
|
const [pausedResume, setPausedResume] = useState(undefined);
|
|
169
169
|
const [skills, setSkills] = useState([]);
|
|
170
170
|
const [branchName, setBranchName] = useState();
|
|
171
|
+
const [graphBuilding, setGraphBuilding] = useState(false);
|
|
171
172
|
const shutdownRef = useRef(undefined);
|
|
172
173
|
if (!shutdownRef.current)
|
|
173
174
|
shutdownRef.current = createChatShutdown({
|
|
@@ -254,6 +255,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
254
255
|
initializeSession: () => sessionLifecycle.initializeSession(),
|
|
255
256
|
refreshSkills,
|
|
256
257
|
addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
|
|
258
|
+
onGraphActivity: setGraphBuilding,
|
|
257
259
|
}).catch(() => undefined);
|
|
258
260
|
readInputHistory().then(setInputHistory).catch(() => undefined);
|
|
259
261
|
loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
|
|
@@ -774,7 +776,8 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
774
776
|
queue: followUps.queued.length > 0 ? _jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Queued follow-ups: ", followUps.queued.length] }), followUps.queued.map((item, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: [index + 1, ". ", item] }, `${index}-${item}`))] }) : undefined,
|
|
775
777
|
tasks: visibleTasks.length > 0 ? _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: Math.max(1, terminalRows - 8) }) : undefined,
|
|
776
778
|
activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, detail: busyDetail, tip: showingTip ? TIPS[tipIndex] : undefined })
|
|
777
|
-
:
|
|
779
|
+
: graphBuilding ? _jsxs(Box, { overflow: "hidden", children: [_jsx(ActivitySpinner, {}), _jsx(Box, { flexShrink: 0, width: 1 }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: "Building code graph in the background\u2026" })] })
|
|
780
|
+
: pausedResume ? _jsxs(StatusNotice, { variant: "warning", children: ["Press R to resume \u00B7 unfinished goal paused", pausedResume.pauseReason ? ` (${pausedResume.pauseReason})` : ''] }) : undefined,
|
|
778
781
|
status: _jsxs(_Fragment, { children: [_jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsxs(Text, { color: theme.muted, wrap: "truncate-start", children: [activeModelName, reasoningSuffix] })] }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel })] }),
|
|
779
782
|
}, input: ({ width: inputWidth, inputRows, suggestionRows, onRowsChange }) => _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: inputWidth, inputRows: inputRows, suggestionRows: suggestionRows, onRowsChange: onRowsChange, getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
|
|
780
783
|
if (!tasksExpanded) {
|
|
@@ -19,7 +19,7 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
19
19
|
{ usage: '/plugin list|remove <name>', description: 'List project-installed plugins or remove one, preserving modified and seed files. /kit is an alias.' },
|
|
20
20
|
{ usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
|
|
21
21
|
{ 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
|
|
22
|
+
{ usage: '/init', description: 'Inspect the current workspace, create or update AGENTS.md project instructions, and build/refresh the workspace code graph.' },
|
|
23
23
|
{ usage: '/context', description: 'Show a token breakdown of the current request: system prompt, project context, tools (incl. MCP), and chat messages.' },
|
|
24
24
|
{ usage: '/session', description: 'Show the current durable session file.' },
|
|
25
25
|
{ usage: '/resume [id]', description: 'Browse this workspace’s saved sessions, or resume an exact session id.' },
|
|
@@ -27,6 +27,9 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
27
27
|
{ usage: '/logs', description: 'List recent log files with sizes and dates.' },
|
|
28
28
|
{ usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
|
|
29
29
|
{ usage: '/mcp', description: 'Configure Model Context Protocol servers like Context7 (interactive picker).' },
|
|
30
|
+
{ 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.' },
|
|
31
|
+
{ usage: '/graph status', description: 'Show the current code graph state (nodes, edges, build time, staleness) without rebuilding. /graph force rebuilds from scratch.' },
|
|
32
|
+
{ usage: '/graph delete', description: 'Delete the persisted workspace code graph (rebuilt on the next /graph).' },
|
|
30
33
|
{ usage: '/logs <id>', description: 'Show summary of a specific log: entry counts by type, total tokens, tool calls.' },
|
|
31
34
|
{ usage: '/logs <id> view', description: 'Page the raw log JSONL through $PAGER in a fullscreen terminal handoff.' },
|
|
32
35
|
{ usage: '/editor', description: 'Compose a prompt in $EDITOR, then submit it as the next message.' },
|
|
@@ -6,6 +6,7 @@ import { COMMAND_HELP_ENTRIES, formatCommandHelp } from './commandHelp.js';
|
|
|
6
6
|
import { handleFleetCommand } from './fleetCommand.js';
|
|
7
7
|
import { handleInitCommand } from './initCommand.js';
|
|
8
8
|
import { handleLogsCommand } from './logsCommand.js';
|
|
9
|
+
import { handleGraphCommand } from './graphCommand.js';
|
|
9
10
|
import { handleModelCommand } from './modelCommand.js';
|
|
10
11
|
import { handleReasoningCommand } from './reasoningCommand.js';
|
|
11
12
|
import { handleThemesCommand } from './themesCommand.js';
|
|
@@ -87,6 +88,7 @@ const SLASH_COMMANDS = [
|
|
|
87
88
|
{ match: exactOrArgs('/reasoning'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
88
89
|
{ match: exactOrArgs('/thinking'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
89
90
|
{ match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
|
|
91
|
+
{ match: exactOrArgs('/graph'), run: async (args, ctx) => await handleGraphCommand(args, ctx) },
|
|
90
92
|
];
|
|
91
93
|
export async function handleSlashCommand(value, ctx) {
|
|
92
94
|
for (const command of SLASH_COMMANDS) {
|
|
@@ -77,6 +77,14 @@ function toolCallSummaryText(toolName, input) {
|
|
|
77
77
|
return `lspDiagnostics ${data.path}`;
|
|
78
78
|
if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
|
|
79
79
|
return `${toolName} ${data.path}:${data.line}:${data.column}`;
|
|
80
|
+
if (toolName === 'graphQuery' && typeof data?.question === 'string')
|
|
81
|
+
return `map: query "${compact(data.question, 60)}"`;
|
|
82
|
+
if ((toolName === 'graphExplain' || toolName === 'graphAffected') && typeof data?.symbol === 'string')
|
|
83
|
+
return `map: ${toolName === 'graphExplain' ? 'explain' : 'affected'} ${data.symbol}`;
|
|
84
|
+
if (toolName === 'graphPath' && typeof data?.from === 'string' && typeof data?.to === 'string')
|
|
85
|
+
return `map: path ${data.from} -> ${data.to}`;
|
|
86
|
+
if (toolName === 'graphRebuild')
|
|
87
|
+
return 'map: rebuild';
|
|
80
88
|
return `${toolName} ${compact(input)}`;
|
|
81
89
|
}
|
|
82
90
|
/**
|
|
@@ -138,6 +146,19 @@ function toolResultSummaryText(event) {
|
|
|
138
146
|
const count = output.locations.length;
|
|
139
147
|
return `${count} location${count === 1 ? '' : 's'} from ${output.server}`;
|
|
140
148
|
}
|
|
149
|
+
if (typeof output?.answer === 'string' && typeof output?.graph === 'object') {
|
|
150
|
+
// graphQuery/graphPath answers
|
|
151
|
+
const stale = output.graph.stale === true ? ' · stale graph' : '';
|
|
152
|
+
const seeds = typeof output.seeds === 'number' ? `${output.seeds} seed${output.seeds === 1 ? '' : 's'}` : typeof output.hops === 'number' ? `${output.hops} hop${output.hops === 1 ? '' : 's'}` : '';
|
|
153
|
+
return `${seeds}${stale}: ${compact(output.answer, 120)}`;
|
|
154
|
+
}
|
|
155
|
+
if (Array.isArray(output?.affected) && typeof output.symbol === 'string') {
|
|
156
|
+
const count = output.affected.length;
|
|
157
|
+
return count === 0 ? `no reverse relationships for ${output.symbol}` : `${count} affected by ${output.symbol}`;
|
|
158
|
+
}
|
|
159
|
+
if (typeof output?.nodes === 'number' && typeof output?.edges === 'number' && output?.toolName === 'graphRebuild') {
|
|
160
|
+
return `graph built: ${output.nodes} nodes · ${output.edges} edges · ${output.files} files`;
|
|
161
|
+
}
|
|
141
162
|
if (typeof output?.ok === 'boolean') {
|
|
142
163
|
// writeTasks result
|
|
143
164
|
if (output.ok && typeof output.summary === 'string') {
|
|
@@ -213,6 +234,13 @@ export function busyToolLabel(toolName, input) {
|
|
|
213
234
|
return 'Running subagent';
|
|
214
235
|
case 'writeTasks':
|
|
215
236
|
return 'Updating tasks';
|
|
237
|
+
case 'graphQuery':
|
|
238
|
+
case 'graphExplain':
|
|
239
|
+
case 'graphPath':
|
|
240
|
+
case 'graphAffected':
|
|
241
|
+
return 'Querying code graph';
|
|
242
|
+
case 'graphRebuild':
|
|
243
|
+
return 'Building code graph';
|
|
216
244
|
case 'skill':
|
|
217
245
|
return 'Loading skill';
|
|
218
246
|
default:
|
|
@@ -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
|
}
|
|
@@ -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) {
|
|
@@ -70,7 +70,7 @@ export function finalizeAttemptOutcome(deps) {
|
|
|
70
70
|
const completionEvidence = { sawToolCall: stream.sawToolCall, assistantText: stream.assistantText, lastToolOk: stream.lastToolOk, lastFailedToolWasValidation: stream.lastFailedToolWasValidation, unresolvedToolInputError: stream.unresolvedToolInputError };
|
|
71
71
|
const readiness = assessCompletionReadiness(turnState, completionEvidence);
|
|
72
72
|
const classification = classifyTerminalOutcome(turnState, completionEvidence);
|
|
73
|
-
const turnStatus = terminalTurnStatus({ aborted:
|
|
73
|
+
const turnStatus = terminalTurnStatus({ aborted: abortController.signal.aborted, assistantText: stream.assistantText, sawToolCall: stream.sawToolCall, lastToolOk: stream.lastToolOk, lastFailedToolWasValidation: stream.lastFailedToolWasValidation, finishReason: stream.finishReason, budgetReached: turnState.budgetBoundary, unresolvedToolInputError: stream.unresolvedToolInputError, intent: turnState.intent, mutationCount: turnState.mutationCount, validationOutcome: turnState.validationOutcome, taskProgress: turnState.taskProgress, requiresTaskLedger: turnState.requiresTaskLedger, ...(turnState.redPair ? { redPair: turnState.redPair } : {}) });
|
|
74
74
|
if (stream.unresolvedMalformedToolName)
|
|
75
75
|
callbacks.addMessage({ role: 'system', text: `${stream.unresolvedMalformedToolName} did not execute because its generated input remained invalid or truncated${stream.unresolvedMalformedToolProblem ? ` — ${stream.unresolvedMalformedToolProblem}` : ''}. The requested work is incomplete.` });
|
|
76
76
|
// Non-error overflow recovery (Pillar 1.2/1.4): a silent overflow completed
|
|
@@ -3,6 +3,7 @@ import type { ContextFile } from '../../../config/contextFiles.js';
|
|
|
3
3
|
import { type ToolExecutionBudgetState, type TurnBudget } from '../../../core/agent/budgets.js';
|
|
4
4
|
import { type SessionGoal } from '../../../core/agent/goalPolicy.js';
|
|
5
5
|
import { calculateRequestTokenBudget, type ContextUsageAnchor } from '../../../core/agent/contextBudget.js';
|
|
6
|
+
import type { TurnExecutionState } from '../../../core/agent/completionController.js';
|
|
6
7
|
import { providerRequestSettings, type ModelRuntimeSelection } from '../../../llm/client.js';
|
|
7
8
|
import type { StoredReasoningSetting } from '../../../core/agent/reasoningPolicy.js';
|
|
8
9
|
import { type ToolCategory, type TurnExecutionScope } from '../../../llm/requestContext.js';
|
|
@@ -71,6 +72,8 @@ export interface AttemptSetupDeps {
|
|
|
71
72
|
executionScope?: TurnExecutionScope;
|
|
72
73
|
};
|
|
73
74
|
turnBudget: TurnBudget;
|
|
75
|
+
/** Turn-wide execution state; the attempt's step cap is clamped against its cumulative usage. */
|
|
76
|
+
turnState: TurnExecutionState;
|
|
74
77
|
globalBudget: ToolExecutionBudgetState;
|
|
75
78
|
/** Shared slice execution state (see AgentAttemptInput.sliceBudget). */
|
|
76
79
|
sliceBudget: ToolExecutionBudgetState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readSettings } from '../../../config/settings.js';
|
|
2
|
-
import { DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_RETRY_BASE_DELAY_MS, MAIN_STEP_LIMIT, MAIN_TOOL_CALL_LIMIT, SUBAGENT_TOOL_DEADLINE_MS, DEFAULT_TOOL_DEADLINE_MS, DEFAULT_MODEL_RETRIES, resolveStreamIdleTimeoutMs, usesPatientIdleWindow, withToolExecutionBudget } from '../../../core/agent/budgets.js';
|
|
2
|
+
import { DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_RETRY_BASE_DELAY_MS, MAIN_STEP_LIMIT, MAIN_TOOL_CALL_LIMIT, SUBAGENT_TOOL_DEADLINE_MS, DEFAULT_TOOL_DEADLINE_MS, DEFAULT_MODEL_RETRIES, resolveStreamIdleTimeoutMs, remainingSteps, usesPatientIdleWindow, withToolExecutionBudget } from '../../../core/agent/budgets.js';
|
|
3
3
|
import { agentEvent } from '../../../core/agent/events.js';
|
|
4
4
|
import { goalDirectionPrompt, isPlanOnlyRequest } from '../../../core/agent/goalPolicy.js';
|
|
5
5
|
import { projectPreflight } from '../../../core/agent/projectPreflight.js';
|
|
@@ -40,7 +40,7 @@ export function restrictToRescueTools(tools) {
|
|
|
40
40
|
* configured (the caller-reported failure path).
|
|
41
41
|
*/
|
|
42
42
|
export async function prepareAttempt(deps) {
|
|
43
|
-
const { value, contextFiles, callbacks, retryingExistingRequest, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnBudget, goal, globalBudget, sliceBudget, onContextFileRead, usageAnchor } = deps;
|
|
43
|
+
const { value, contextFiles, callbacks, retryingExistingRequest, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnState, turnBudget, goal, globalBudget, sliceBudget, onContextFileRead, usageAnchor } = deps;
|
|
44
44
|
// Single choke point: one fresh settings read per attempt, shared by model
|
|
45
45
|
// resolution and request assembly (CR-024, relaxed in Pillar 1.9 so a
|
|
46
46
|
// provider/model switch mid-goal applies from the next attempt — the first
|
|
@@ -146,9 +146,14 @@ export async function prepareAttempt(deps) {
|
|
|
146
146
|
mutationPolicy,
|
|
147
147
|
blessedPaths: turnOptions.blessedPaths,
|
|
148
148
|
postMutationDiagnostics: assembled.postMutationDiagnostics,
|
|
149
|
+
postMutationGraph: assembled.postMutationGraph,
|
|
149
150
|
};
|
|
150
151
|
const recoverySlice = turnOptions.recoverySlice;
|
|
151
|
-
|
|
152
|
+
// The turn-wide step budget never resets (matching the tool-call execution
|
|
153
|
+
// boundary): a provider retry must not re-arm the main step cap, so clamp
|
|
154
|
+
// this attempt's cap to what the turn has left. Recovery slices were
|
|
155
|
+
// already clamped at admission; Math.min keeps them unchanged.
|
|
156
|
+
const stepCap = Math.min(recoverySlice?.maxSteps ?? MAIN_STEP_LIMIT, remainingSteps(turnState.stepsUsed, turnBudget));
|
|
152
157
|
// Rescue exposes only mutation + validation-capable built-in tools so
|
|
153
158
|
// discovery cannot be reopened near the boundary. Length-continuation keeps
|
|
154
159
|
// the full tool set. When no built-in mutation/validation tool qualifies,
|
|
@@ -191,14 +191,16 @@ export async function runAgentGoal(options) {
|
|
|
191
191
|
const result = await runAgentTurn(request, continuing ? undefined : options.displayValue, contextFiles, callbacks, initialRetryAttempt, continuing, false, options.session, activeModelOverride, turnOptions, options.reasoningOverride);
|
|
192
192
|
initialRetryAttempt = 0;
|
|
193
193
|
cycle += 1;
|
|
194
|
-
if (cycle >= GOAL_MAX_CYCLES) {
|
|
195
|
-
return finish('failed', 'cycle-limit', checkpoint ? { kind: 'incomplete-goal', checkpoint } : undefined);
|
|
196
|
-
}
|
|
197
194
|
lastEvidence = result.evidence;
|
|
198
195
|
if (result.checkpoint)
|
|
199
196
|
checkpoint = result.checkpoint;
|
|
197
|
+
// Structured completion wins over the cycle bound: a goal that finishes
|
|
198
|
+
// on the limit cycle is a success, never a cycle-limit failure.
|
|
200
199
|
if (result.status === 'complete')
|
|
201
200
|
return finish('complete', 'completed');
|
|
201
|
+
if (cycle >= GOAL_MAX_CYCLES) {
|
|
202
|
+
return finish('failed', 'cycle-limit', checkpoint ? { kind: 'incomplete-goal', checkpoint } : undefined);
|
|
203
|
+
}
|
|
202
204
|
if (result.status === 'aborted') {
|
|
203
205
|
return result.abortReason === 'turn-deadline'
|
|
204
206
|
? finish('failed', 'goal-deadline', checkpoint ? { kind: 'incomplete-goal', checkpoint } : undefined)
|
|
@@ -40,6 +40,7 @@ export function createRepairToolCall(deps) {
|
|
|
40
40
|
loopState.pendingMalformedToolProblem = problem;
|
|
41
41
|
loopState.unresolvedMalformedToolName = toolCall.toolName;
|
|
42
42
|
loopState.unresolvedMalformedToolProblem = problem;
|
|
43
|
+
loopState.unresolvedMalformedAtStep = loopState.completedSteps;
|
|
43
44
|
}
|
|
44
45
|
// Truncated generated file content cannot be reconstructed safely here;
|
|
45
46
|
// let the next agent step retry under the bounded tool-choice constraint.
|
|
@@ -34,6 +34,8 @@ export interface AttemptLoopState {
|
|
|
34
34
|
unresolvedMalformedToolName: string | undefined;
|
|
35
35
|
/** Last known diagnosis for the unresolved malformed tool; rides the turn-end system note so later turns see the exact defect. */
|
|
36
36
|
unresolvedMalformedToolProblem: string | undefined;
|
|
37
|
+
/** Attempt-local completed-step count when the unresolved malformed call was recorded; a same-name success clears the flag only from a later step. */
|
|
38
|
+
unresolvedMalformedAtStep: number | undefined;
|
|
37
39
|
/** Per-attempt (not per-turn) recovery counter: a transient retry gets a fresh map. Bounded across the whole turn by MAIN_TOOL_CALL_LIMIT. */
|
|
38
40
|
malformedRecoveryAttempts: Map<string, number>;
|
|
39
41
|
toolResultState: ToolResultState;
|
|
@@ -5,6 +5,7 @@ import { auxiliaryRequestOptions } from '../../../core/providerContracts.js';
|
|
|
5
5
|
import { contextTokensFromUsage, estimateConversationTokens, estimateValueTokens } from '../../../core/agent/contextBudget.js';
|
|
6
6
|
import { stripSyntheticControls } from '../../../core/agent/requestAssembly.js';
|
|
7
7
|
import { buildLlmCompactionPrompt, chooseBoundaryCompactionMethod, compactModelMessages, compactModelMessagesWithSummary, extractExistingCompactionSummary } from '../../../core/agent/compaction.js';
|
|
8
|
+
import { buildCodeGraphDigest } from '../../../core/graph/digest.js';
|
|
8
9
|
import { isLengthStopOverflow, isSilentContextOverflow } from '../../../core/agent/overflow.js';
|
|
9
10
|
import { isValidationRerunToolCall } from '../../../core/agent/turnPolicy.js';
|
|
10
11
|
import { COMPACTION_LLM_MAX_OUTPUT_TOKENS, COMPACTION_LLM_MIN_OLDER_TOKENS } from '../../../core/agent/budgets.js';
|
|
@@ -35,6 +36,7 @@ export function createAttemptLoopState(previousAssistantText, contextFiles, call
|
|
|
35
36
|
pendingMalformedToolProblem: undefined,
|
|
36
37
|
unresolvedMalformedToolName: undefined,
|
|
37
38
|
unresolvedMalformedToolProblem: undefined,
|
|
39
|
+
unresolvedMalformedAtStep: undefined,
|
|
38
40
|
malformedRecoveryAttempts: new Map(),
|
|
39
41
|
toolResultState: initialToolResultState(),
|
|
40
42
|
inFlightTools: new Set(),
|
|
@@ -367,6 +369,7 @@ async function compactAtEpochBoundary(deps, providerMessages) {
|
|
|
367
369
|
older: split.older,
|
|
368
370
|
previousSummary: extractExistingCompactionSummary(providerMessages),
|
|
369
371
|
splitTurn: split.splitTurn,
|
|
372
|
+
codeGraphDigest: await buildCodeGraphDigest(),
|
|
370
373
|
});
|
|
371
374
|
const summarization = streamText({
|
|
372
375
|
model: setup.runtime.model,
|
|
@@ -58,9 +58,15 @@ export function handleToolResultPart(deps, part) {
|
|
|
58
58
|
// the completion gates; a failed edit/write stays a hard tool failure even
|
|
59
59
|
// when an earlier check also failed.
|
|
60
60
|
loopState.lastFailedToolWasValidation = !ok && toolName === 'shell' && validationSummaryFromOutput(part.output) != null;
|
|
61
|
-
|
|
61
|
+
// A successful same-name call clears the unresolved flag only when it ran
|
|
62
|
+
// in a *later* step: a successful sibling within the same parallel batch
|
|
63
|
+
// (same completed-step count) must not mask the malformed call's failure.
|
|
64
|
+
if (ok && part.toolName === loopState.unresolvedMalformedToolName
|
|
65
|
+
&& loopState.unresolvedMalformedAtStep != null
|
|
66
|
+
&& loopState.completedSteps > loopState.unresolvedMalformedAtStep) {
|
|
62
67
|
loopState.unresolvedMalformedToolName = undefined;
|
|
63
68
|
loopState.unresolvedMalformedToolProblem = undefined;
|
|
69
|
+
loopState.unresolvedMalformedAtStep = undefined;
|
|
64
70
|
}
|
|
65
71
|
const finish = { toolCall, success: ok, output: part.output, durationMs: Date.now() - startedAt };
|
|
66
72
|
const item = toolDisplay.ensureToolItem(toolCall);
|
|
@@ -131,6 +131,11 @@ export async function runAgentTurn(value, displayValue, contextFiles, callbacks,
|
|
|
131
131
|
await abortableDelay(result.retry.delayMs, abortController.signal);
|
|
132
132
|
if (abortController.signal.aborted) {
|
|
133
133
|
status = 'aborted';
|
|
134
|
+
// The abort landed during retry backoff, after the attempt result
|
|
135
|
+
// was classified: recover the cause from the shared holder so a
|
|
136
|
+
// turn-deadline abort reaches the supervisor as `turn-deadline`
|
|
137
|
+
// (goal-deadline checkpoint) instead of a plain user cancel.
|
|
138
|
+
abortReason = abortCause.kind === 'turn-deadline' ? 'turn-deadline' : 'user';
|
|
134
139
|
break;
|
|
135
140
|
}
|
|
136
141
|
continue;
|
|
@@ -80,6 +80,7 @@ export declare function buildLlmCompactionPrompt(input: {
|
|
|
80
80
|
maxChars?: number;
|
|
81
81
|
previousSummary?: string;
|
|
82
82
|
splitTurn?: boolean;
|
|
83
|
+
codeGraphDigest?: string;
|
|
83
84
|
}): string;
|
|
84
85
|
/**
|
|
85
86
|
* Assemble the compacted history around a model-written summary (F-09). Same
|
|
@@ -212,6 +212,9 @@ export function buildLlmCompactionPrompt(input) {
|
|
|
212
212
|
? `A previous compaction summary exists. Update it with the new messages: PRESERVE everything still relevant, ADD new progress/decisions/context, DROP only what the recent tail supersedes.\n\n<previous-summary>\n${input.previousSummary}\n</previous-summary>`
|
|
213
213
|
: undefined,
|
|
214
214
|
input.instructions ? `User compaction instructions: ${input.instructions}` : undefined,
|
|
215
|
+
input.codeGraphDigest
|
|
216
|
+
? `A deterministic code-graph digest of the workspace follows. When the summary mentions structure (modules, hubs, relationships), prefer referencing these named symbols/files instead of re-describing them in prose:\n${input.codeGraphDigest}`
|
|
217
|
+
: undefined,
|
|
215
218
|
`Write a dense summary in at most 60 lines. ${omitted > 0 ? `(${omitted} oldest message(s) already omitted from this transcript.)` : ''}`.trim(),
|
|
216
219
|
'',
|
|
217
220
|
'<older_conversation>',
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type CodeGraph, type GraphIndex } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic label propagation. Iteration order is node-id sorted and the
|
|
4
|
+
* min-label rule breaks ties, so the same graph always yields the same
|
|
5
|
+
* partition. Mutates `graph.nodes[].community` in place.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectCommunities(graph: CodeGraph): void;
|
|
8
|
+
export interface CommunitySummary {
|
|
9
|
+
community: number;
|
|
10
|
+
size: number;
|
|
11
|
+
/** Highest-degree members, files first: a one-line identity for the cluster. */
|
|
12
|
+
members: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
kind: string;
|
|
16
|
+
degree: number;
|
|
17
|
+
}>;
|
|
18
|
+
/** Most common top-level directories among member files. */
|
|
19
|
+
directories: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function communitySummaries(index: GraphIndex, limit?: number): CommunitySummary[];
|
|
22
|
+
/** Test-path heuristic shared by god-node ranking and query demotion. */
|
|
23
|
+
export declare function isTestPath(file: string): boolean;
|
|
24
|
+
export interface GodNode {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
file: string;
|
|
29
|
+
degree: number;
|
|
30
|
+
}
|
|
31
|
+
/** Top-degree symbol nodes (files excluded; test helpers demoted — they mirror, not shape, the architecture). */
|
|
32
|
+
export declare function godNodes(index: GraphIndex, limit?: number): GodNode[];
|
|
33
|
+
/** Tarjan strongly-connected components over file-level `imports` edges. */
|
|
34
|
+
export declare function importCycles(index: GraphIndex, limit?: number): string[][];
|
|
35
|
+
export interface AffectedEntry {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
kind: string;
|
|
39
|
+
file: string;
|
|
40
|
+
depth: number;
|
|
41
|
+
viaRelation: string;
|
|
42
|
+
confidence: string;
|
|
43
|
+
viaFile: string;
|
|
44
|
+
viaLine?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Reverse blast radius from a symbol: who calls/inherits/imports it, transitively.
|
|
48
|
+
* File-level `imports` edges are followed one hop (the file importing the
|
|
49
|
+
* changed symbol's file) so consumers surface even when call sites are dynamic.
|
|
50
|
+
*/
|
|
51
|
+
export declare function affectedBySymbol(index: GraphIndex, symbolId: string, maxDepth?: number, limit?: number): AffectedEntry[];
|
|
52
|
+
export interface GraphReportInput {
|
|
53
|
+
graph: CodeGraph;
|
|
54
|
+
files: number;
|
|
55
|
+
parsedFiles: number;
|
|
56
|
+
cachedFiles: number;
|
|
57
|
+
durationMs: number;
|
|
58
|
+
stale: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Human-readable orientation report for /graph: structure, hubs, risk areas. */
|
|
61
|
+
export declare function renderGraphReport(index: GraphIndex, input: GraphReportInput): string;
|