@denizokcu/haze 0.8.0 → 0.10.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 +67 -17
- package/README.md +121 -64
- package/dist/cli/chat/chatMetrics.d.ts +17 -1
- package/dist/cli/chat/chatMetrics.js +22 -5
- package/dist/cli/chat/contextReport.d.ts +11 -0
- package/dist/cli/chat/contextReport.js +44 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
- package/dist/cli/chat/fileMentionSuggestions.js +91 -0
- package/dist/cli/chat/inputSuggestions.d.ts +5 -0
- package/dist/cli/chat/inputSuggestions.js +17 -3
- package/dist/cli/chat/sessionLifecycle.d.ts +58 -0
- package/dist/cli/chat/sessionLifecycle.js +155 -0
- package/dist/cli/chat/sessionRecorder.d.ts +3 -0
- package/dist/cli/chat/sessionRecorder.js +21 -8
- package/dist/cli/chat/startupInfo.d.ts +1 -0
- package/dist/cli/chat/startupInfo.js +11 -0
- package/dist/cli/chat/tips.d.ts +21 -0
- package/dist/cli/chat/tips.js +43 -0
- package/dist/cli/chat/wizardDispatch.d.ts +64 -0
- package/dist/cli/chat/wizardDispatch.js +645 -0
- package/dist/cli/commands/chat.d.ts +1 -0
- package/dist/cli/commands/chat.js +246 -779
- package/dist/cli/commands/chatModes.d.ts +1 -1
- package/dist/cli/commands/chatModes.js +7 -2
- package/dist/cli/commands/commandHelp.js +5 -3
- package/dist/cli/commands/commands.d.ts +4 -3
- package/dist/cli/commands/commands.js +12 -13
- package/dist/cli/commands/fleetCommand.d.ts +14 -0
- package/dist/cli/commands/fleetCommand.js +46 -0
- package/dist/cli/commands/formatters.d.ts +5 -0
- package/dist/cli/commands/formatters.js +36 -9
- package/dist/cli/commands/logsCommand.js +8 -28
- package/dist/cli/commands/mcpWizard.js +24 -2
- package/dist/cli/commands/modelCommand.js +1 -1
- package/dist/cli/commands/providerWizard.d.ts +1 -0
- package/dist/cli/commands/providerWizard.js +31 -5
- package/dist/cli/commands/runCommand.d.ts +1 -0
- package/dist/cli/commands/runCommand.js +32 -20
- package/dist/cli/commands/sessionPicker.d.ts +9 -0
- package/dist/cli/commands/sessionPicker.js +29 -0
- package/dist/cli/commands/settingsSummary.js +8 -4
- package/dist/cli/commands/skillConfirmRemove.js +4 -3
- package/dist/cli/commands/skillWizard.d.ts +2 -0
- package/dist/cli/commands/skillWizard.js +16 -6
- package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
- package/dist/cli/commands/streaming/idleTimer.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +4 -2
- package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
- package/dist/cli/commands/streaming/turnOutcome.js +13 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -4
- package/dist/cli/commands/streaming.d.ts +13 -1
- package/dist/cli/commands/streaming.js +104 -44
- package/dist/cli/commands/wizardActions.d.ts +6 -0
- package/dist/cli/commands/wizardActions.js +6 -0
- package/dist/cli/commands/wizardPrompts.js +1 -1
- package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
- package/dist/cli/commands/wizardSuggestions.js +62 -13
- package/dist/cli/commands/wizardTransition.d.ts +37 -0
- package/dist/cli/commands/wizardTransition.js +43 -0
- package/dist/cli/index.js +17 -3
- package/dist/cli/terminalTitle.d.ts +6 -0
- package/dist/cli/terminalTitle.js +36 -0
- package/dist/config/contextFiles.js +6 -3
- package/dist/config/endpointSecurity.d.ts +2 -0
- package/dist/config/endpointSecurity.js +28 -0
- package/dist/config/inputHistory.d.ts +3 -3
- package/dist/config/inputHistory.js +13 -17
- package/dist/config/modelDiscovery.d.ts +20 -0
- package/dist/config/modelDiscovery.js +51 -0
- package/dist/config/privateStorage.d.ts +6 -0
- package/dist/config/privateStorage.js +61 -0
- package/dist/config/providerPresets.d.ts +16 -4
- package/dist/config/providerPresets.js +263 -34
- package/dist/config/providers.d.ts +2 -0
- package/dist/config/providers.js +7 -0
- package/dist/config/settings.d.ts +22 -0
- package/dist/config/settings.js +33 -5
- package/dist/config/skillSettings.d.ts +6 -13
- package/dist/config/skillSettings.js +20 -19
- package/dist/config/updateCheck.js +4 -2
- package/dist/core/agent/budgets.d.ts +26 -0
- package/dist/core/agent/budgets.js +34 -0
- package/dist/core/agent/compaction.js +17 -3
- package/dist/core/agent/contextBudget.d.ts +8 -0
- package/dist/core/agent/contextBudget.js +29 -0
- package/dist/core/agent/errors.js +6 -2
- package/dist/core/agent/events.d.ts +12 -0
- package/dist/core/agent/toolOutputStore.d.ts +8 -0
- package/dist/core/agent/toolOutputStore.js +49 -11
- package/dist/core/agent/workState.d.ts +1 -1
- package/dist/core/agent/workState.js +0 -4
- package/dist/core/attachments/imageAttachments.d.ts +90 -0
- package/dist/core/attachments/imageAttachments.js +245 -0
- package/dist/core/attachments/readBlessings.d.ts +37 -0
- package/dist/core/attachments/readBlessings.js +79 -0
- package/dist/core/goal/completionPolicy.d.ts +0 -28
- package/dist/core/goal/completionPolicy.js +0 -88
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -13
- package/dist/core/io/boundedRead.d.ts +15 -0
- package/dist/core/io/boundedRead.js +144 -0
- package/dist/core/limits/byteBudgets.d.ts +18 -0
- package/dist/core/limits/byteBudgets.js +18 -0
- package/dist/core/limits/textBudgets.d.ts +23 -0
- package/dist/core/limits/textBudgets.js +23 -0
- package/dist/core/log/llmLog.d.ts +10 -0
- package/dist/core/log/llmLog.js +59 -13
- package/dist/core/persistence/orderedFileWriter.d.ts +11 -0
- package/dist/core/persistence/orderedFileWriter.js +29 -0
- package/dist/core/process/backgroundRegistry.d.ts +35 -0
- package/dist/core/process/backgroundRegistry.js +194 -0
- package/dist/core/process/runBoundedProcess.d.ts +30 -0
- package/dist/core/process/runBoundedProcess.js +116 -0
- package/dist/core/safety/urlGuard.d.ts +2 -1
- package/dist/core/safety/urlGuard.js +3 -2
- package/dist/core/session/sessionSlimming.js +47 -4
- package/dist/core/session/sessionStore.d.ts +37 -0
- package/dist/core/session/sessionStore.js +136 -27
- package/dist/core/subagent/contracts.d.ts +116 -0
- package/dist/core/subagent/contracts.js +54 -0
- package/dist/core/subagent/executionProfiles.d.ts +28 -0
- package/dist/core/subagent/executionProfiles.js +45 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +74 -0
- package/dist/core/subagent/subagentCoordinator.js +134 -0
- package/dist/core/subagent/subagentRunner.d.ts +211 -145
- package/dist/core/subagent/subagentRunner.js +228 -98
- package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
- package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
- package/dist/core/tasks/taskStorage.js +12 -1
- package/dist/llm/client.d.ts +20 -29
- package/dist/llm/client.js +33 -29
- package/dist/llm/hazeTools.d.ts +2396 -67
- package/dist/llm/hazeTools.js +50 -37
- package/dist/llm/lsp.d.ts +23 -3
- package/dist/llm/lsp.js +73 -16
- package/dist/llm/lspTools.d.ts +96 -48
- package/dist/llm/mcp.d.ts +1 -1
- package/dist/llm/mcp.js +65 -16
- package/dist/llm/requestContext.d.ts +23 -1
- package/dist/llm/requestContext.js +50 -7
- package/dist/llm/systemPrompt.d.ts +4 -1
- package/dist/llm/systemPrompt.js +14 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +1210 -16
- package/dist/llm/tools/bashTool.js +43 -60
- package/dist/llm/tools/fetchTool.d.ts +26 -26
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +2 -1
- package/dist/llm/tools/fileToolShared.js +5 -5
- package/dist/llm/tools/grepRunner.d.ts +20 -0
- package/dist/llm/tools/grepRunner.js +66 -0
- package/dist/llm/tools/outputCap.d.ts +2 -6
- package/dist/llm/tools/outputCap.js +2 -6
- package/dist/llm/tools/processTool.d.ts +1077 -0
- package/dist/llm/tools/processTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +8 -0
- package/dist/llm/tools/toolContext.js +22 -11
- package/dist/llm/tools/workspaceFile.d.ts +9 -1
- package/dist/llm/tools/workspaceFile.js +33 -4
- package/dist/llm/webFetch.js +24 -11
- package/dist/llm/workerContext.d.ts +18 -0
- package/dist/llm/workerContext.js +55 -0
- package/dist/skills/SkillLoader.d.ts +2 -2
- package/dist/skills/SkillLoader.js +17 -5
- package/dist/skills/SkillRegistry.d.ts +3 -2
- package/dist/skills/SkillRegistry.js +53 -10
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +23 -5
- package/dist/skills/skillTools.js +11 -4
- package/dist/skills/types.d.ts +11 -1
- package/dist/ui/components/TextInput.d.ts +5 -2
- package/dist/ui/components/TextInput.js +76 -8
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/fs.d.ts +0 -1
- package/dist/utils/fs.js +0 -4
- package/dist/utils/openPath.d.ts +2 -0
- package/dist/utils/openPath.js +9 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +9 -4
- package/package.json +1 -1
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import type { ToolSet } from 'ai';
|
|
2
2
|
import { type PromptSession } from './systemPrompt.js';
|
|
3
|
+
import { readSettings } from '../config/settings.js';
|
|
4
|
+
import { type ModelRuntimeSelection } from './client.js';
|
|
5
|
+
import { SubagentCoordinator, type CoordinatorEvent } from '../core/subagent/subagentCoordinator.js';
|
|
6
|
+
import { WorkspaceMutationPolicy } from '../core/subagent/workspaceMutationPolicy.js';
|
|
3
7
|
import { type LoadedMcpTools } from './mcp.js';
|
|
4
8
|
import { createSubagentTool } from '../core/subagent/subagentRunner.js';
|
|
5
9
|
import type { ContextFile } from '../config/contextFiles.js';
|
|
6
10
|
export type ToolCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
|
|
7
11
|
/** Model type accepted by the subagent tool; derived so this module stays decoupled. */
|
|
8
|
-
export type RequestModel = Parameters<typeof createSubagentTool>[0]['model']
|
|
12
|
+
export type RequestModel = NonNullable<Parameters<typeof createSubagentTool>[0]['model']>;
|
|
13
|
+
export interface SubagentOverrides {
|
|
14
|
+
profile?: string;
|
|
15
|
+
workerModel?: string;
|
|
16
|
+
maxConcurrency?: number;
|
|
17
|
+
forceMode?: 'inspect';
|
|
18
|
+
}
|
|
19
|
+
export interface TurnExecutionScope {
|
|
20
|
+
coordinator: SubagentCoordinator;
|
|
21
|
+
mutationPolicy: WorkspaceMutationPolicy;
|
|
22
|
+
}
|
|
9
23
|
export interface AssembledRequestContext {
|
|
10
24
|
systemPrompt: string;
|
|
11
25
|
availableTools: ToolSet;
|
|
12
26
|
/** Tool name -> coarse origin bucket, used by /context to group token estimates. */
|
|
13
27
|
toolCategories: Map<string, ToolCategory>;
|
|
14
28
|
loadedMcp?: LoadedMcpTools;
|
|
29
|
+
executionScope: TurnExecutionScope;
|
|
15
30
|
}
|
|
16
31
|
/**
|
|
17
32
|
* Assemble the system prompt and full tool set (built-in + LSP + subagent +
|
|
@@ -25,4 +40,11 @@ export declare function assembleRequestContext(input: {
|
|
|
25
40
|
contextFiles: ContextFile[];
|
|
26
41
|
session?: PromptSession;
|
|
27
42
|
model: RequestModel;
|
|
43
|
+
modelRuntime?: ModelRuntimeSelection;
|
|
44
|
+
subagentOverrides?: SubagentOverrides;
|
|
45
|
+
onSubagentEvent?: (event: CoordinatorEvent) => void;
|
|
46
|
+
abortSignal?: AbortSignal;
|
|
47
|
+
executionScope?: TurnExecutionScope;
|
|
48
|
+
/** Pre-read settings so a turn performs a single settings read (CR-024). */
|
|
49
|
+
settings?: Awaited<ReturnType<typeof readSettings>>;
|
|
28
50
|
}): Promise<AssembledRequestContext>;
|
|
@@ -2,6 +2,11 @@ import { hazeTools } from './hazeTools.js';
|
|
|
2
2
|
import { lspTools } from './lspTools.js';
|
|
3
3
|
import { buildSystemPrompt } from './systemPrompt.js';
|
|
4
4
|
import { readSettings } from '../config/settings.js';
|
|
5
|
+
import { resolveWorkerRuntime } from './client.js';
|
|
6
|
+
import { resolveExecutionProfile } from '../core/subagent/executionProfiles.js';
|
|
7
|
+
import { SubagentCoordinator } from '../core/subagent/subagentCoordinator.js';
|
|
8
|
+
import { WorkspaceMutationPolicy } from '../core/subagent/workspaceMutationPolicy.js';
|
|
9
|
+
import { fallbackProviderCapabilities, fallbackWorkerRuntime } from '../core/subagent/contracts.js';
|
|
5
10
|
import { installedLspServers } from '../config/lspSettings.js';
|
|
6
11
|
import { configuredMcpServers } from '../config/mcpSettings.js';
|
|
7
12
|
import { loadMcpTools } from './mcp.js';
|
|
@@ -19,23 +24,61 @@ import { addCapabilityTools } from './capabilities.js';
|
|
|
19
24
|
* close (`.close()`) once it is done with the assembled context.
|
|
20
25
|
*/
|
|
21
26
|
export async function assembleRequestContext(input) {
|
|
22
|
-
const settings = await readSettings();
|
|
27
|
+
const settings = input.settings ?? await readSettings();
|
|
23
28
|
const skillRegistry = await loadSkillRegistry();
|
|
24
|
-
const enabledSkills = new Map(
|
|
29
|
+
const enabledSkills = new Map(skillRegistry.skills);
|
|
30
|
+
if (skillRegistry.candidates) {
|
|
31
|
+
enabledSkills.clear();
|
|
32
|
+
for (const skill of skillRegistry.candidates) {
|
|
33
|
+
if (isSkillEnabled(settings, skill.name, skill.source) && !enabledSkills.has(skill.name))
|
|
34
|
+
enabledSkills.set(skill.name, skill);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (const [name, skill] of enabledSkills)
|
|
39
|
+
if (!isSkillEnabled(settings, name, skill.source))
|
|
40
|
+
enabledSkills.delete(name);
|
|
41
|
+
}
|
|
25
42
|
const hasInstalledLsp = (await installedLspServers(settings)).length > 0;
|
|
43
|
+
const profileName = input.subagentOverrides?.profile ?? settings.subagents?.defaultProfile;
|
|
44
|
+
const profile = resolveExecutionProfile(profileName, settings.subagents?.profiles, input.subagentOverrides?.maxConcurrency);
|
|
45
|
+
const executionScope = input.executionScope ?? {
|
|
46
|
+
mutationPolicy: new WorkspaceMutationPolicy(),
|
|
47
|
+
coordinator: new SubagentCoordinator(profile ?? resolveExecutionProfile(undefined, undefined), input.onSubagentEvent),
|
|
48
|
+
};
|
|
49
|
+
const { coordinator, mutationPolicy } = executionScope;
|
|
50
|
+
let blockedReason = profile ? undefined : `Unknown subagent profile ${profileName}. Configure subagents.profiles or select a built-in profile.`;
|
|
51
|
+
let workerRuntime;
|
|
52
|
+
if (input.modelRuntime) {
|
|
53
|
+
const resolution = await resolveWorkerRuntime({ active: input.modelRuntime, settings, selector: input.subagentOverrides?.workerModel ?? settings.subagents?.workerModel, cwd: input.session?.cwd });
|
|
54
|
+
if (resolution.status === 'found')
|
|
55
|
+
workerRuntime = resolution.runtime;
|
|
56
|
+
else
|
|
57
|
+
blockedReason = resolution.message;
|
|
58
|
+
}
|
|
59
|
+
else if (settings.subagents?.workerModel || input.subagentOverrides?.workerModel) {
|
|
60
|
+
blockedReason = 'An explicit worker model could not be resolved for this request. Configure it via /provider and retry.';
|
|
61
|
+
}
|
|
62
|
+
workerRuntime ??= {
|
|
63
|
+
...fallbackWorkerRuntime(input.model, input.modelRuntime?.selector, input.modelRuntime?.config.providerName),
|
|
64
|
+
capabilities: input.modelRuntime?.config.capabilities ?? fallbackProviderCapabilities(),
|
|
65
|
+
};
|
|
26
66
|
const toolCategories = new Map();
|
|
27
67
|
const availableTools = {};
|
|
28
68
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'builtin', tools: hazeTools } });
|
|
29
69
|
if (hasInstalledLsp)
|
|
30
70
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'lsp', tools: lspTools } });
|
|
31
|
-
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'subagent', tools: { subagent: createSubagentTool({
|
|
32
|
-
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'skill', tools: buildSkillTools({ skills: enabledSkills }) } });
|
|
71
|
+
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'subagent', tools: { subagent: createSubagentTool({ runtime: workerRuntime, profile: profile ?? undefined, coordinator, mutationPolicy, blockedReason, forceMode: input.subagentOverrides?.forceMode, session: input.session }) } } });
|
|
72
|
+
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'skill', tools: buildSkillTools({ skills: enabledSkills, errors: skillRegistry.errors ?? [] }) } });
|
|
33
73
|
const mcpServers = configuredMcpServers(settings).filter(server => server.enabled !== false);
|
|
34
|
-
const loadedMcp = mcpServers.length > 0
|
|
74
|
+
const loadedMcp = mcpServers.length > 0
|
|
75
|
+
? await loadMcpTools(mcpServers, new Set(Object.keys(availableTools)), ...(input.abortSignal ? [input.abortSignal] : []))
|
|
76
|
+
: undefined;
|
|
35
77
|
if (loadedMcp && Object.keys(loadedMcp.tools).length > 0) {
|
|
36
78
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'mcp', tools: loadedMcp.tools }, skipCollisions: true });
|
|
37
79
|
}
|
|
38
80
|
const mcpAvailable = Boolean(loadedMcp && Object.keys(loadedMcp.tools).length > 0);
|
|
39
|
-
const
|
|
40
|
-
|
|
81
|
+
const skillErrors = (skillRegistry.errors ?? []).map(error => `${error.source ? `${error.source}/` : ''}${error.directory}: ${error.message}`);
|
|
82
|
+
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp, mcpAvailable })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
83
|
+
return { systemPrompt, availableTools, toolCategories, loadedMcp, executionScope };
|
|
41
84
|
}
|
|
@@ -8,4 +8,7 @@ export declare function buildSystemPrompt(contextFiles?: ContextFile[], session?
|
|
|
8
8
|
lspAvailable?: boolean;
|
|
9
9
|
mcpAvailable?: boolean;
|
|
10
10
|
}): string;
|
|
11
|
-
export declare function buildSubagentPrompt(contextFiles?: ContextFile[], session?: PromptSession
|
|
11
|
+
export declare function buildSubagentPrompt(contextFiles?: ContextFile[], session?: PromptSession, mode?: 'inspect' | 'research' | 'implement' | 'validate', budget?: {
|
|
12
|
+
maxToolCalls: number;
|
|
13
|
+
maxSteps: number;
|
|
14
|
+
}): string;
|
package/dist/llm/systemPrompt.js
CHANGED
|
@@ -31,9 +31,9 @@ export function buildSystemPrompt(contextFiles = [], session, options = {}) {
|
|
|
31
31
|
## Tool use
|
|
32
32
|
${lspToolRule}${mcpToolRule}- grep locates text patterns and non-semantic matches. listFiles discovers structure. readFile returns bounded numbered lines with nextOffset for pagination.
|
|
33
33
|
- editFile performs unique replacements. If an edit fails, read that exact file again before retrying; use replaceLines when current line numbers are safer.
|
|
34
|
-
- writeFile creates files and only overwrites when explicitly requested. bash runs inspection, scripts, and validation. readToolOutput retrieves omitted oversized command output.
|
|
34
|
+
- writeFile creates files and only overwrites when explicitly requested. bash runs inspection, scripts, and validation; use background=true for dev servers/watchers, inspect them with process/readToolOutput, and kill every process you start when done. readToolOutput retrieves omitted oversized command output.
|
|
35
35
|
- fetch reads a public URL and returns readable content (markdown for docs, pretty JSON, or text); use it for current docs, API references, and error lookups instead of guessing from memory. Private/loopback/metadata hosts and non-http(s) schemes are blocked; oversize output is retrievable with readToolOutput.
|
|
36
|
-
- subagent is
|
|
36
|
+
- Use subagent as a context-isolation boundary. Delegate an independent, self-contained task when its private reads/searches/tool output will likely be much larger than the compact deliverable needed here; one substantial task is sufficient. Keep trivial, conversation-coupled, user-interactive, sequentially dependent, or uncertain shared-mutation work here. Give a precise objective, deliverable, mode, and path scope—never paste chat history or file contents. Submit genuinely independent tasks together and let runtime limits schedule them.
|
|
37
37
|
- skill loads one installed workflow by name. writeTasks is for substantial work, normally five or more steps; update it only at meaningful phase changes, blockers, or completion.
|
|
38
38
|
- Prefer targeted reads and checks. Do not repeat unchanged reads or failing validation without a relevant change.
|
|
39
39
|
- Ignored files require explicit need. Keep file mutations separate from validation commands when practical.
|
|
@@ -50,10 +50,20 @@ ${lspToolRule}${mcpToolRule}- grep locates text patterns and non-semantic matche
|
|
|
50
50
|
Current date: ${date}
|
|
51
51
|
Current working directory: ${cwd}`;
|
|
52
52
|
}
|
|
53
|
-
export function buildSubagentPrompt(contextFiles = [], session) {
|
|
53
|
+
export function buildSubagentPrompt(contextFiles = [], session, mode = 'implement', budget) {
|
|
54
54
|
const date = (session?.start ?? new Date()).toISOString().slice(0, 10);
|
|
55
55
|
const cwd = (session?.cwd ?? process.cwd()).replace(/\\/g, '/');
|
|
56
|
-
|
|
56
|
+
const modeRule = mode === 'inspect'
|
|
57
|
+
? 'Inspect only. You have no shell or mutation tools.'
|
|
58
|
+
: mode === 'research'
|
|
59
|
+
? 'Research and inspect only. You may fetch public sources; you cannot run shell commands or mutate files.'
|
|
60
|
+
: mode === 'validate'
|
|
61
|
+
? 'Inspect and run validation commands. Treat commands as potentially mutating; do not edit files directly.'
|
|
62
|
+
: 'Implement the bounded task, using targeted edits and relevant validation.';
|
|
63
|
+
const budgetRule = budget
|
|
64
|
+
? ` You have at most ${budget.maxToolCalls} tool calls across ${budget.maxSteps} steps. Sample strategically rather than reading the whole repository; stop gathering evidence early enough to synthesize. A concise partial deliverable with explicit coverage gaps is mandatory and better than exhausting the budget with no output.`
|
|
65
|
+
: '';
|
|
66
|
+
return `You are a disposable ${mode} subagent in a fresh private context. Complete only the JSON task capsule in your single user message; you have no parent/sibling chat history. ${modeRule}${budgetRule} Investigate freely, but return only the requested self-contained deliverable with evidence, changed paths, validation, blockers, and coverage gaps. Do not ask the user questions or narrate your process. Follow newly surfaced scoped project instructions before continuing; after a failed edit, reread the file before retrying.${projectContextSection(contextFiles)}
|
|
57
67
|
|
|
58
68
|
Current date: ${date}
|
|
59
69
|
Current working directory: ${cwd}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'existing_file_requires_overwrite' | 'invalid_line_range' | 'io_error' | 'blocked_url' | 'scoped_instructions_discovered';
|
|
1
|
+
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'existing_file_requires_overwrite' | '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' | 'scoped_instructions_discovered';
|
|
2
2
|
export type ToolDiffLine = {
|
|
3
3
|
type: 'add' | 'remove' | 'context';
|
|
4
4
|
oldLine?: number;
|