@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
|
@@ -9,6 +9,7 @@ import { type LoadedMcpTools } from './mcp.js';
|
|
|
9
9
|
import { createSubagentTool } from './subagentRunner.js';
|
|
10
10
|
import type { ContextFile } from '../config/contextFiles.js';
|
|
11
11
|
import type { PostMutationDiagnostics } from './tools/toolContext.js';
|
|
12
|
+
import type { PostMutationGraphAdvisory } from './tools/graphAdvisory.js';
|
|
12
13
|
export type ToolCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
|
|
13
14
|
/** Model type accepted by the subagent tool; derived so this module stays decoupled. */
|
|
14
15
|
export type RequestModel = NonNullable<Parameters<typeof createSubagentTool>[0]['model']>;
|
|
@@ -32,6 +33,8 @@ export interface AssembledRequestContext {
|
|
|
32
33
|
lspPool?: LspPool;
|
|
33
34
|
/** Bounded automatic diagnostics attached to successful file-mutation results. */
|
|
34
35
|
postMutationDiagnostics?: PostMutationDiagnostics;
|
|
36
|
+
/** Reverse-dependency graph advisory attached to successful file-mutation results. */
|
|
37
|
+
postMutationGraph?: PostMutationGraphAdvisory;
|
|
35
38
|
executionScope: TurnExecutionScope;
|
|
36
39
|
}
|
|
37
40
|
/**
|
|
@@ -17,6 +17,7 @@ import { buildSkillTools } from '../skills/skillTools.js';
|
|
|
17
17
|
import { isSkillEnabled } from '../config/skillSettings.js';
|
|
18
18
|
import { createSubagentTool } from './subagentRunner.js';
|
|
19
19
|
import { addCapabilityTools } from './capabilities.js';
|
|
20
|
+
import { createPostMutationGraphAdvisory } from './tools/graphAdvisory.js';
|
|
20
21
|
const ALWAYS_AVAILABLE_TOOLS = new Set(['listFiles', 'readFile', 'grep', 'replaceLines', 'writeFile', 'editFile', 'shell', 'writeTasks', 'readToolOutput', 'skill']);
|
|
21
22
|
/** Keep the common coding path lean while preserving explicitly relevant capabilities. */
|
|
22
23
|
function selectToolsForRequest(tools, request) {
|
|
@@ -25,13 +26,20 @@ function selectToolsForRequest(tools, request) {
|
|
|
25
26
|
const lower = request.toLowerCase();
|
|
26
27
|
const includeFetch = /https?:\/\/|\b(web|online|fetch|current docs?|api docs?|library docs?|research)\b/.test(lower);
|
|
27
28
|
const includeProcess = /\b(background|server|serve|daemon|watch(?:er)?|long-running|process|dev server)\b/.test(lower);
|
|
28
|
-
const includeSubagent = /\b(subagents?|agents?|fleet|parallel|delegate|orchestrat\w*|multi-agent|review|audit|compare)\b/.test(lower)
|
|
29
|
+
const includeSubagent = /\b(subagents?|agents?|fleet|parallel|delegate|orchestrat\w*|multi-agent|review|audit|compare)\b/.test(lower);
|
|
30
|
+
// Semantic-navigation tool groups only pay off for orientation/refactor requests;
|
|
31
|
+
// grep/readFile remain available for everything else.
|
|
32
|
+
const includeLsp = /\b(rename|refactor|move|symbols?|definitions?|references|usages?|impact|blast radius|navigate|navigation|semantic|callers?)\b/.test(lower);
|
|
33
|
+
const includeGraph = /\b(architecture|structure|where|how (?:does|do)|relationships?|dependenc\w*|affected|explore|understand|map|overview|graph|codebase|unfamiliar|orient\w*|large)\b/.test(lower);
|
|
34
|
+
const isConditionalBuiltin = (name) => ['fetch', 'process', 'subagent'].includes(name) || name.startsWith('lsp') || name.startsWith('graph');
|
|
29
35
|
return Object.fromEntries(Object.entries(tools).filter(([name]) => ALWAYS_AVAILABLE_TOOLS.has(name)
|
|
30
36
|
|| (name === 'fetch' && includeFetch)
|
|
31
37
|
|| (name === 'process' && includeProcess)
|
|
32
38
|
|| (name === 'subagent' && includeSubagent)
|
|
33
|
-
|
|
34
|
-
||
|
|
39
|
+
|| (name.startsWith('lsp') && includeLsp)
|
|
40
|
+
|| (name.startsWith('graph') && includeGraph)
|
|
41
|
+
// Configured MCP tools are explicit user capabilities and remain available.
|
|
42
|
+
|| !isConditionalBuiltin(name)));
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
45
|
* Assemble the system prompt and full tool set (built-in + LSP + subagent +
|
|
@@ -118,9 +126,10 @@ export async function assembleRequestContext(input) {
|
|
|
118
126
|
const mcpAvailable = Boolean(loadedMcp && Object.keys(loadedMcp.tools).length > 0);
|
|
119
127
|
const skillErrors = (skillRegistry.errors ?? []).map(error => `${error.source ? `${error.source}/` : ''}${error.directory}: ${error.message}`);
|
|
120
128
|
const model = input.modelRuntime?.config ? { provider: input.modelRuntime.config.providerName, name: input.modelRuntime.config.modelName } : undefined;
|
|
121
|
-
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp, mcpAvailable, model, availableTools: new Set(Object.keys(availableTools)) })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
129
|
+
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp && 'lspWorkspaceSymbols' in availableTools, mcpAvailable, model, availableTools: new Set(Object.keys(availableTools)) })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
122
130
|
return {
|
|
123
131
|
systemPrompt, availableTools, toolCategories, loadedMcp, lspPool, executionScope,
|
|
124
132
|
...(lspPool ? { postMutationDiagnostics: createPostMutationDiagnostics(installedLsp, lspPool) } : {}),
|
|
133
|
+
postMutationGraph: createPostMutationGraphAdvisory(),
|
|
125
134
|
};
|
|
126
135
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ModelMessage } from 'ai';
|
|
1
|
+
import { type ModelMessage, type Tool } from 'ai';
|
|
2
2
|
import { toolOnlyStepCount } from '../core/agent/turnPolicy.js';
|
|
3
3
|
import { type HazeToolContext } from './tools/toolContext.js';
|
|
4
4
|
import { type WorkerContextBundle } from './workerContext.js';
|
|
@@ -45,313 +45,7 @@ export declare function createSubagentTool(options: {
|
|
|
45
45
|
blockedReason?: string;
|
|
46
46
|
forceMode?: 'inspect';
|
|
47
47
|
session?: PromptSession;
|
|
48
|
-
}):
|
|
49
|
-
deferLoading?: boolean;
|
|
50
|
-
title?: string;
|
|
51
|
-
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
52
|
-
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
53
|
-
inputSchema: import("ai").FlexibleSchema<{
|
|
54
|
-
objective: string;
|
|
55
|
-
deliverable: string;
|
|
56
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
57
|
-
scope?: string[] | undefined;
|
|
58
|
-
acceptanceCriteria?: string[] | undefined;
|
|
59
|
-
}>;
|
|
60
|
-
contextSchema?: import("ai").FlexibleSchema<HazeToolContext> | undefined;
|
|
61
|
-
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
62
|
-
objective: string;
|
|
63
|
-
deliverable: string;
|
|
64
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
65
|
-
scope?: string[] | undefined;
|
|
66
|
-
acceptanceCriteria?: string[] | undefined;
|
|
67
|
-
}, NoInfer<HazeToolContext>> | undefined;
|
|
68
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
69
|
-
onInputDelta?: ((options: {
|
|
70
|
-
inputTextDelta: string;
|
|
71
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
72
|
-
onInputAvailable?: ((options: {
|
|
73
|
-
input: {
|
|
74
|
-
objective: string;
|
|
75
|
-
deliverable: string;
|
|
76
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
77
|
-
scope?: string[] | undefined;
|
|
78
|
-
acceptanceCriteria?: string[] | undefined;
|
|
79
|
-
};
|
|
80
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
81
|
-
toModelOutput?: ((options: {
|
|
82
|
-
toolCallId: string;
|
|
83
|
-
input: {
|
|
84
|
-
objective: string;
|
|
85
|
-
deliverable: string;
|
|
86
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
87
|
-
scope?: string[] | undefined;
|
|
88
|
-
acceptanceCriteria?: string[] | undefined;
|
|
89
|
-
};
|
|
90
|
-
output: NoInfer<SubagentExecutionResult>;
|
|
91
|
-
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
92
|
-
} & {
|
|
93
|
-
outputSchema?: import("ai").FlexibleSchema<SubagentExecutionResult> | undefined;
|
|
94
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
95
|
-
objective: string;
|
|
96
|
-
deliverable: string;
|
|
97
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
98
|
-
scope?: string[] | undefined;
|
|
99
|
-
acceptanceCriteria?: string[] | undefined;
|
|
100
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
101
|
-
} & {
|
|
102
|
-
description?: string | ((options: {
|
|
103
|
-
context: NoInfer<HazeToolContext>;
|
|
104
|
-
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
105
|
-
}) => string) | undefined;
|
|
106
|
-
strict?: boolean;
|
|
107
|
-
inputExamples?: {
|
|
108
|
-
input: NoInfer<{
|
|
109
|
-
objective: string;
|
|
110
|
-
deliverable: string;
|
|
111
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
112
|
-
scope?: string[] | undefined;
|
|
113
|
-
acceptanceCriteria?: string[] | undefined;
|
|
114
|
-
}>;
|
|
115
|
-
}[] | undefined;
|
|
116
|
-
id?: never;
|
|
117
|
-
isProviderExecuted?: never;
|
|
118
|
-
args?: never;
|
|
119
|
-
supportsDeferredResults?: never;
|
|
120
|
-
} & {
|
|
121
|
-
type?: undefined | "function";
|
|
122
|
-
} & {
|
|
123
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
124
|
-
objective: string;
|
|
125
|
-
deliverable: string;
|
|
126
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
127
|
-
scope?: string[] | undefined;
|
|
128
|
-
acceptanceCriteria?: string[] | undefined;
|
|
129
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
130
|
-
}) | ({
|
|
131
|
-
deferLoading?: boolean;
|
|
132
|
-
title?: string;
|
|
133
|
-
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
134
|
-
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
135
|
-
inputSchema: import("ai").FlexibleSchema<{
|
|
136
|
-
objective: string;
|
|
137
|
-
deliverable: string;
|
|
138
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
139
|
-
scope?: string[] | undefined;
|
|
140
|
-
acceptanceCriteria?: string[] | undefined;
|
|
141
|
-
}>;
|
|
142
|
-
contextSchema?: import("ai").FlexibleSchema<HazeToolContext> | undefined;
|
|
143
|
-
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
144
|
-
objective: string;
|
|
145
|
-
deliverable: string;
|
|
146
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
147
|
-
scope?: string[] | undefined;
|
|
148
|
-
acceptanceCriteria?: string[] | undefined;
|
|
149
|
-
}, NoInfer<HazeToolContext>> | undefined;
|
|
150
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
151
|
-
onInputDelta?: ((options: {
|
|
152
|
-
inputTextDelta: string;
|
|
153
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
154
|
-
onInputAvailable?: ((options: {
|
|
155
|
-
input: {
|
|
156
|
-
objective: string;
|
|
157
|
-
deliverable: string;
|
|
158
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
159
|
-
scope?: string[] | undefined;
|
|
160
|
-
acceptanceCriteria?: string[] | undefined;
|
|
161
|
-
};
|
|
162
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
163
|
-
toModelOutput?: ((options: {
|
|
164
|
-
toolCallId: string;
|
|
165
|
-
input: {
|
|
166
|
-
objective: string;
|
|
167
|
-
deliverable: string;
|
|
168
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
169
|
-
scope?: string[] | undefined;
|
|
170
|
-
acceptanceCriteria?: string[] | undefined;
|
|
171
|
-
};
|
|
172
|
-
output: NoInfer<SubagentExecutionResult>;
|
|
173
|
-
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
174
|
-
} & {
|
|
175
|
-
outputSchema?: import("ai").FlexibleSchema<SubagentExecutionResult> | undefined;
|
|
176
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
177
|
-
objective: string;
|
|
178
|
-
deliverable: string;
|
|
179
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
180
|
-
scope?: string[] | undefined;
|
|
181
|
-
acceptanceCriteria?: string[] | undefined;
|
|
182
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
183
|
-
} & {
|
|
184
|
-
description?: string | ((options: {
|
|
185
|
-
context: NoInfer<HazeToolContext>;
|
|
186
|
-
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
187
|
-
}) => string) | undefined;
|
|
188
|
-
strict?: boolean;
|
|
189
|
-
inputExamples?: {
|
|
190
|
-
input: NoInfer<{
|
|
191
|
-
objective: string;
|
|
192
|
-
deliverable: string;
|
|
193
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
194
|
-
scope?: string[] | undefined;
|
|
195
|
-
acceptanceCriteria?: string[] | undefined;
|
|
196
|
-
}>;
|
|
197
|
-
}[] | undefined;
|
|
198
|
-
id?: never;
|
|
199
|
-
isProviderExecuted?: never;
|
|
200
|
-
args?: never;
|
|
201
|
-
supportsDeferredResults?: never;
|
|
202
|
-
} & {
|
|
203
|
-
type: "dynamic";
|
|
204
|
-
} & {
|
|
205
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
206
|
-
objective: string;
|
|
207
|
-
deliverable: string;
|
|
208
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
209
|
-
scope?: string[] | undefined;
|
|
210
|
-
acceptanceCriteria?: string[] | undefined;
|
|
211
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
212
|
-
}) | ({
|
|
213
|
-
deferLoading?: boolean;
|
|
214
|
-
title?: string;
|
|
215
|
-
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
216
|
-
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
217
|
-
inputSchema: import("ai").FlexibleSchema<{
|
|
218
|
-
objective: string;
|
|
219
|
-
deliverable: string;
|
|
220
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
221
|
-
scope?: string[] | undefined;
|
|
222
|
-
acceptanceCriteria?: string[] | undefined;
|
|
223
|
-
}>;
|
|
224
|
-
contextSchema?: import("ai").FlexibleSchema<HazeToolContext> | undefined;
|
|
225
|
-
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
226
|
-
objective: string;
|
|
227
|
-
deliverable: string;
|
|
228
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
229
|
-
scope?: string[] | undefined;
|
|
230
|
-
acceptanceCriteria?: string[] | undefined;
|
|
231
|
-
}, NoInfer<HazeToolContext>> | undefined;
|
|
232
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
233
|
-
onInputDelta?: ((options: {
|
|
234
|
-
inputTextDelta: string;
|
|
235
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
236
|
-
onInputAvailable?: ((options: {
|
|
237
|
-
input: {
|
|
238
|
-
objective: string;
|
|
239
|
-
deliverable: string;
|
|
240
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
241
|
-
scope?: string[] | undefined;
|
|
242
|
-
acceptanceCriteria?: string[] | undefined;
|
|
243
|
-
};
|
|
244
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
245
|
-
toModelOutput?: ((options: {
|
|
246
|
-
toolCallId: string;
|
|
247
|
-
input: {
|
|
248
|
-
objective: string;
|
|
249
|
-
deliverable: string;
|
|
250
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
251
|
-
scope?: string[] | undefined;
|
|
252
|
-
acceptanceCriteria?: string[] | undefined;
|
|
253
|
-
};
|
|
254
|
-
output: NoInfer<SubagentExecutionResult>;
|
|
255
|
-
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
256
|
-
} & {
|
|
257
|
-
outputSchema?: import("ai").FlexibleSchema<SubagentExecutionResult> | undefined;
|
|
258
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
259
|
-
objective: string;
|
|
260
|
-
deliverable: string;
|
|
261
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
262
|
-
scope?: string[] | undefined;
|
|
263
|
-
acceptanceCriteria?: string[] | undefined;
|
|
264
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
265
|
-
} & {
|
|
266
|
-
type: "provider";
|
|
267
|
-
id: `${string}.${string}`;
|
|
268
|
-
args: Record<string, unknown>;
|
|
269
|
-
description?: never;
|
|
270
|
-
strict?: never;
|
|
271
|
-
inputExamples?: never;
|
|
272
|
-
} & {
|
|
273
|
-
isProviderExecuted: false;
|
|
274
|
-
supportsDeferredResults?: never;
|
|
275
|
-
} & {
|
|
276
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
277
|
-
objective: string;
|
|
278
|
-
deliverable: string;
|
|
279
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
280
|
-
scope?: string[] | undefined;
|
|
281
|
-
acceptanceCriteria?: string[] | undefined;
|
|
282
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
283
|
-
}) | ({
|
|
284
|
-
deferLoading?: boolean;
|
|
285
|
-
title?: string;
|
|
286
|
-
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
287
|
-
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
288
|
-
inputSchema: import("ai").FlexibleSchema<{
|
|
289
|
-
objective: string;
|
|
290
|
-
deliverable: string;
|
|
291
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
292
|
-
scope?: string[] | undefined;
|
|
293
|
-
acceptanceCriteria?: string[] | undefined;
|
|
294
|
-
}>;
|
|
295
|
-
contextSchema?: import("ai").FlexibleSchema<HazeToolContext> | undefined;
|
|
296
|
-
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
297
|
-
objective: string;
|
|
298
|
-
deliverable: string;
|
|
299
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
300
|
-
scope?: string[] | undefined;
|
|
301
|
-
acceptanceCriteria?: string[] | undefined;
|
|
302
|
-
}, NoInfer<HazeToolContext>> | undefined;
|
|
303
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
304
|
-
onInputDelta?: ((options: {
|
|
305
|
-
inputTextDelta: string;
|
|
306
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
307
|
-
onInputAvailable?: ((options: {
|
|
308
|
-
input: {
|
|
309
|
-
objective: string;
|
|
310
|
-
deliverable: string;
|
|
311
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
312
|
-
scope?: string[] | undefined;
|
|
313
|
-
acceptanceCriteria?: string[] | undefined;
|
|
314
|
-
};
|
|
315
|
-
} & import("ai").ToolExecutionOptions<NoInfer<HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
316
|
-
toModelOutput?: ((options: {
|
|
317
|
-
toolCallId: string;
|
|
318
|
-
input: {
|
|
319
|
-
objective: string;
|
|
320
|
-
deliverable: string;
|
|
321
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
322
|
-
scope?: string[] | undefined;
|
|
323
|
-
acceptanceCriteria?: string[] | undefined;
|
|
324
|
-
};
|
|
325
|
-
output: NoInfer<SubagentExecutionResult>;
|
|
326
|
-
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
327
|
-
} & {
|
|
328
|
-
outputSchema?: import("ai").FlexibleSchema<SubagentExecutionResult> | undefined;
|
|
329
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
330
|
-
objective: string;
|
|
331
|
-
deliverable: string;
|
|
332
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
333
|
-
scope?: string[] | undefined;
|
|
334
|
-
acceptanceCriteria?: string[] | undefined;
|
|
335
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
336
|
-
} & {
|
|
337
|
-
type: "provider";
|
|
338
|
-
id: `${string}.${string}`;
|
|
339
|
-
args: Record<string, unknown>;
|
|
340
|
-
description?: never;
|
|
341
|
-
strict?: never;
|
|
342
|
-
inputExamples?: never;
|
|
343
|
-
} & {
|
|
344
|
-
isProviderExecuted: true;
|
|
345
|
-
supportsDeferredResults?: boolean;
|
|
346
|
-
} & {
|
|
347
|
-
execute: import("ai").ToolExecuteFunction<{
|
|
348
|
-
objective: string;
|
|
349
|
-
deliverable: string;
|
|
350
|
-
mode: "inspect" | "research" | "implement" | "validate";
|
|
351
|
-
scope?: string[] | undefined;
|
|
352
|
-
acceptanceCriteria?: string[] | undefined;
|
|
353
|
-
}, SubagentExecutionResult, NoInfer<HazeToolContext>>;
|
|
354
|
-
});
|
|
48
|
+
}): Tool;
|
|
355
49
|
export declare const internals: {
|
|
356
50
|
toolSummary: typeof toolSummary;
|
|
357
51
|
toolOnlyStepCount: typeof toolOnlyStepCount;
|
package/dist/llm/systemPrompt.js
CHANGED
|
@@ -17,6 +17,9 @@ export function buildSystemPrompt(contextFiles = [], session, options = {}) {
|
|
|
17
17
|
const mcpToolRule = options.mcpAvailable
|
|
18
18
|
? '- MCP server tools (e.g. Context7 docs lookup) are available when configured via /mcp. They extend the toolset with external capabilities; use them when the user asks for up-to-date docs or library info those tools expose, instead of guessing from memory.\n'
|
|
19
19
|
: '';
|
|
20
|
+
const graphToolRule = options.availableTools?.has('graphQuery')
|
|
21
|
+
? '- Code-graph tools are your primary navigation surface: start with graphQuery before any grep/readFile exploration when you need architecture, orientation, relationships, "where does X live", or any unfamiliar/large codebase; use graphExplain for one symbol, graphPath to trace how two things connect, and graphAffected for change blast radius before risky edits. Do not run grep loops or read whole directories to discover structure the graph already maps — graphQuery first, grep only for exact-string lookups the graph cannot answer. If a graph tool answers graph_not_built, call graphRebuild once, then retry. Edges marked INFERRED are resolved leads, not facts. Graph output is advisory context, never validation evidence. A stale graph flag means files changed since it was built — graphRebuild refreshes it cheaply.\n'
|
|
22
|
+
: '';
|
|
20
23
|
const modelLine = options.model ? `\nActive model: ${options.model.provider}/${options.model.name}` : '';
|
|
21
24
|
const hasTool = (name) => options.availableTools?.has(name) ?? true;
|
|
22
25
|
const processRule = hasTool('process') ? ', inspect them with process/readToolOutput, and kill every process you start when done' : '';
|
|
@@ -39,10 +42,10 @@ export function buildSystemPrompt(contextFiles = [], session, options = {}) {
|
|
|
39
42
|
- ${SECRET_FILE_RULE}
|
|
40
43
|
|
|
41
44
|
## Tool use
|
|
42
|
-
${lspToolRule}${mcpToolRule}- ${UNTRUSTED_TOOL_OUTPUT_RULE}
|
|
43
|
-
- grep
|
|
44
|
-
- editFile
|
|
45
|
-
-
|
|
45
|
+
${lspToolRule}${mcpToolRule}${graphToolRule}- ${UNTRUSTED_TOOL_OUTPUT_RULE}
|
|
46
|
+
- grep finds text patterns and non-semantic matches; listFiles discovers structure; readFile returns bounded, paginated numbered lines.
|
|
47
|
+
- editFile applies unique replacements (batch same-file edits; re-read the file and use replaceLines when a match fails or is stale); replaceInFiles applies guarded cross-file replacements (dry-run first); writeFile creates files, overwrites only when explicitly requested, and chunks large content via append.
|
|
48
|
+
- shell runs inspection, scripts, and validation — set purpose=validation for custom checks so real exit results count as completion evidence; use background=true only when managed process tools are available${processRule}; readToolOutput retrieves omitted oversized output.
|
|
46
49
|
${fetchRule}${subagentRule}${coordinationRule ? `- ${coordinationRule}\n` : ''}
|
|
47
50
|
- Prefer targeted reads and checks. Do not repeat unchanged reads or failing validation without a relevant change. When several independent files are already known, read them together instead of discovering them one model step at a time.
|
|
48
51
|
- Ignored files require explicit need. Keep file mutations separate from validation commands when practical.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'ignore_check_unavailable' | 'secret_file_protected' | 'git_internals_protected' | 'multi_link_file_protected' | 'path_not_found' | 'not_a_file' | 'permission_denied' | 'outside_workspace' | 'binary_file' | 'existing_file_requires_overwrite' | 'write_chunk_too_large' | 'conflicting_write_modes' | 'append_target_missing' | 'invalid_line_range' | 'io_error' | 'file_too_large' | 'blocked_url' | 'background_limit' | 'background_not_allowed' | 'process_id_required' | 'process_not_found' | 'process_already_exited' | 'process_kill_failed' | 'output_expired' | 'aborted' | 'missing_executable' | 'scoped_instructions_discovered';
|
|
1
|
+
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'ignore_check_unavailable' | 'secret_file_protected' | 'git_internals_protected' | 'multi_link_file_protected' | 'path_not_found' | 'not_a_file' | 'permission_denied' | 'outside_workspace' | 'binary_file' | 'existing_file_requires_overwrite' | 'write_chunk_too_large' | 'conflicting_write_modes' | 'append_target_missing' | 'invalid_line_range' | 'io_error' | 'file_too_large' | 'blocked_url' | 'background_limit' | 'background_not_allowed' | 'process_id_required' | 'process_not_found' | 'process_already_exited' | 'process_kill_failed' | 'output_expired' | 'aborted' | 'missing_executable' | 'graph_not_built' | 'graph_unavailable' | 'scoped_instructions_discovered';
|
|
2
2
|
export type ToolDiffLine = {
|
|
3
3
|
type: 'add' | 'remove' | 'context';
|
|
4
4
|
oldLine?: number;
|