@tuanhung303/opencode-acp 2.2.0 → 2.2.2
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/README.md +131 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/budget.d.ts +15 -0
- package/dist/lib/commands/budget.d.ts.map +1 -0
- package/dist/lib/commands/budget.js +120 -0
- package/dist/lib/commands/budget.js.map +1 -0
- package/dist/lib/commands/context.d.ts +1 -1
- package/dist/lib/commands/context.js +4 -4
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/help.d.ts.map +1 -1
- package/dist/lib/commands/help.js +2 -0
- package/dist/lib/commands/help.js.map +1 -1
- package/dist/lib/commands/protected.d.ts +17 -0
- package/dist/lib/commands/protected.d.ts.map +1 -0
- package/dist/lib/commands/protected.js +50 -0
- package/dist/lib/commands/protected.js.map +1 -0
- package/dist/lib/commands/stats.d.ts +1 -1
- package/dist/lib/commands/stats.d.ts.map +1 -1
- package/dist/lib/commands/stats.js +24 -4
- package/dist/lib/commands/stats.js.map +1 -1
- package/dist/lib/commands/sweep.d.ts.map +1 -1
- package/dist/lib/commands/sweep.js +5 -2
- package/dist/lib/commands/sweep.js.map +1 -1
- package/dist/lib/config-schema.d.ts +119 -0
- package/dist/lib/config-schema.d.ts.map +1 -0
- package/dist/lib/config-schema.js +97 -0
- package/dist/lib/config-schema.js.map +1 -0
- package/dist/lib/config.d.ts +7 -30
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +45 -483
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts +14 -0
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +120 -13
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/logger.d.ts +25 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +45 -4
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/messages/index.d.ts +1 -1
- package/dist/lib/messages/index.d.ts.map +1 -1
- package/dist/lib/messages/index.js +1 -1
- package/dist/lib/messages/index.js.map +1 -1
- package/dist/lib/messages/inject.d.ts +6 -1
- package/dist/lib/messages/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject.js +8 -125
- package/dist/lib/messages/inject.js.map +1 -1
- package/dist/lib/messages/prune.d.ts +8 -0
- package/dist/lib/messages/prune.d.ts.map +1 -1
- package/dist/lib/messages/prune.js +89 -2
- package/dist/lib/messages/prune.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +12 -0
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +34 -0
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/discard-tool-spec.d.ts +1 -1
- package/dist/lib/prompts/discard-tool-spec.d.ts.map +1 -1
- package/dist/lib/prompts/discard-tool-spec.js +30 -17
- package/dist/lib/prompts/discard-tool-spec.js.map +1 -1
- package/dist/lib/prompts/extract-tool-spec.d.ts +1 -1
- package/dist/lib/prompts/extract-tool-spec.d.ts.map +1 -1
- package/dist/lib/prompts/extract-tool-spec.js +19 -11
- package/dist/lib/prompts/extract-tool-spec.js.map +1 -1
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +2 -7
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/restore-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/restore-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/restore-tool-spec.js +37 -0
- package/dist/lib/prompts/restore-tool-spec.js.map +1 -0
- package/dist/lib/prompts/system/both.d.ts +1 -1
- package/dist/lib/prompts/system/both.d.ts.map +1 -1
- package/dist/lib/prompts/system/both.js +20 -16
- package/dist/lib/prompts/system/both.js.map +1 -1
- package/dist/lib/prompts/system/discard.d.ts +1 -1
- package/dist/lib/prompts/system/discard.d.ts.map +1 -1
- package/dist/lib/prompts/system/discard.js +19 -16
- package/dist/lib/prompts/system/discard.js.map +1 -1
- package/dist/lib/prompts/system/extract.d.ts +1 -1
- package/dist/lib/prompts/system/extract.d.ts.map +1 -1
- package/dist/lib/prompts/system/extract.js +19 -16
- package/dist/lib/prompts/system/extract.js.map +1 -1
- package/dist/lib/protected-file-patterns.js +1 -1
- package/dist/lib/protected-file-patterns.js.map +1 -1
- package/dist/lib/safe-execute.d.ts +20 -0
- package/dist/lib/safe-execute.d.ts.map +1 -0
- package/dist/lib/safe-execute.js +38 -0
- package/dist/lib/safe-execute.js.map +1 -0
- package/dist/lib/shared-utils.js +1 -1
- package/dist/lib/shared-utils.js.map +1 -1
- package/dist/lib/state/persistence.d.ts +6 -1
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +59 -1
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/state.js +54 -3
- package/dist/lib/state/state.js.map +1 -1
- package/dist/lib/state/tool-cache.d.ts +2 -0
- package/dist/lib/state/tool-cache.d.ts.map +1 -1
- package/dist/lib/state/tool-cache.js +34 -12
- package/dist/lib/state/tool-cache.js.map +1 -1
- package/dist/lib/state/types.d.ts +50 -5
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/strategies/deduplication.d.ts +1 -0
- package/dist/lib/strategies/deduplication.d.ts.map +1 -1
- package/dist/lib/strategies/deduplication.js +87 -3
- package/dist/lib/strategies/deduplication.js.map +1 -1
- package/dist/lib/strategies/index.d.ts +1 -5
- package/dist/lib/strategies/index.d.ts.map +1 -1
- package/dist/lib/strategies/index.js +1 -5
- package/dist/lib/strategies/index.js.map +1 -1
- package/dist/lib/strategies/purge-errors.d.ts.map +1 -1
- package/dist/lib/strategies/purge-errors.js +4 -1
- package/dist/lib/strategies/purge-errors.js.map +1 -1
- package/dist/lib/strategies/supersede-writes.d.ts.map +1 -1
- package/dist/lib/strategies/supersede-writes.js +7 -1
- package/dist/lib/strategies/supersede-writes.js.map +1 -1
- package/dist/lib/strategies/tools.d.ts +1 -0
- package/dist/lib/strategies/tools.d.ts.map +1 -1
- package/dist/lib/strategies/tools.js +215 -62
- package/dist/lib/strategies/tools.js.map +1 -1
- package/dist/lib/ui/notification.d.ts +5 -2
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +10 -6
- package/dist/lib/ui/notification.js.map +1 -1
- package/dist/lib/ui/utils.d.ts +3 -3
- package/dist/lib/ui/utils.d.ts.map +1 -1
- package/dist/lib/ui/utils.js +38 -12
- package/dist/lib/ui/utils.js.map +1 -1
- package/package.json +7 -12
- package/dist/lib/prompts/nudge/both.d.ts +0 -2
- package/dist/lib/prompts/nudge/both.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/both.js +0 -11
- package/dist/lib/prompts/nudge/both.js.map +0 -1
- package/dist/lib/prompts/nudge/discard.d.ts +0 -2
- package/dist/lib/prompts/nudge/discard.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/discard.js +0 -10
- package/dist/lib/prompts/nudge/discard.js.map +0 -1
- package/dist/lib/prompts/nudge/extract.d.ts +0 -2
- package/dist/lib/prompts/nudge/extract.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/extract.js +0 -10
- package/dist/lib/prompts/nudge/extract.js.map +0 -1
- package/dist/lib/strategies/head-tail-truncation.d.ts +0 -15
- package/dist/lib/strategies/head-tail-truncation.d.ts.map +0 -1
- package/dist/lib/strategies/head-tail-truncation.js +0 -144
- package/dist/lib/strategies/head-tail-truncation.js.map +0 -1
- package/dist/lib/strategies/placeholder-compression.d.ts +0 -5
- package/dist/lib/strategies/placeholder-compression.d.ts.map +0 -1
- package/dist/lib/strategies/placeholder-compression.js +0 -148
- package/dist/lib/strategies/placeholder-compression.js.map +0 -1
- package/dist/lib/strategies/prune-thinking.d.ts +0 -15
- package/dist/lib/strategies/prune-thinking.d.ts.map +0 -1
- package/dist/lib/strategies/prune-thinking.js +0 -79
- package/dist/lib/strategies/prune-thinking.js.map +0 -1
- package/dist/lib/strategies/read-consolidation.d.ts +0 -21
- package/dist/lib/strategies/read-consolidation.d.ts.map +0 -1
- package/dist/lib/strategies/read-consolidation.js +0 -155
- package/dist/lib/strategies/read-consolidation.js.map +0 -1
|
@@ -1,127 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return loadPrompt(`nudge/nudge-both`);
|
|
10
|
-
}
|
|
11
|
-
else if (discardEnabled) {
|
|
12
|
-
return loadPrompt(`nudge/nudge-discard`);
|
|
13
|
-
}
|
|
14
|
-
else if (extractEnabled) {
|
|
15
|
-
return loadPrompt(`nudge/nudge-extract`);
|
|
16
|
-
}
|
|
17
|
-
return "";
|
|
18
|
-
};
|
|
19
|
-
const wrapPrunableTools = (content) => `<prunable-tools>
|
|
20
|
-
The following tools have been invoked and are available for pruning. This list does not mandate immediate action. Consider your current goals and the resources you need before discarding valuable tool inputs or outputs. Consolidate your prunes for efficiency; it is rarely worth pruning a single tiny tool output. Keep the context free of noise.
|
|
21
|
-
${content}
|
|
22
|
-
</prunable-tools>`;
|
|
23
|
-
const getCooldownMessage = (config) => {
|
|
24
|
-
const discardEnabled = config.tools.discard.enabled;
|
|
25
|
-
const extractEnabled = config.tools.extract.enabled;
|
|
26
|
-
let toolName;
|
|
27
|
-
if (discardEnabled && extractEnabled) {
|
|
28
|
-
toolName = "discard or extract tools";
|
|
29
|
-
}
|
|
30
|
-
else if (discardEnabled) {
|
|
31
|
-
toolName = "discard tool";
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
toolName = "extract tool";
|
|
35
|
-
}
|
|
36
|
-
return `<prunable-tools>
|
|
37
|
-
Context management was just performed. Do not use the ${toolName} again. A fresh list will be available after your next tool use.
|
|
38
|
-
</prunable-tools>`;
|
|
39
|
-
};
|
|
40
|
-
const buildPrunableToolsList = (state, config, logger, messages) => {
|
|
41
|
-
const lines = [];
|
|
42
|
-
const toolIdList = buildToolIdList(state, messages, logger);
|
|
43
|
-
state.toolParameters.forEach((toolParameterEntry, toolCallId) => {
|
|
44
|
-
if (state.prune.toolIds.includes(toolCallId)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const allProtectedTools = config.tools.settings.protectedTools;
|
|
48
|
-
if (allProtectedTools.includes(toolParameterEntry.tool)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const filePath = getFilePathFromParameters(toolParameterEntry.parameters);
|
|
52
|
-
if (isProtectedFilePath(filePath, config.protectedFilePatterns)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const numericId = toolIdList.indexOf(toolCallId);
|
|
56
|
-
if (numericId === -1) {
|
|
57
|
-
logger.warn(`Tool in cache but not in toolIdList - possible stale entry`, {
|
|
58
|
-
toolCallId,
|
|
59
|
-
tool: toolParameterEntry.tool,
|
|
60
|
-
});
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const paramKey = extractParameterKey(toolParameterEntry.tool, toolParameterEntry.parameters);
|
|
64
|
-
const description = paramKey
|
|
65
|
-
? `${toolParameterEntry.tool}, ${paramKey}`
|
|
66
|
-
: toolParameterEntry.tool;
|
|
67
|
-
lines.push(`${numericId}: ${description}`);
|
|
68
|
-
logger.debug(`Prunable tool found - ID: ${numericId}, Tool: ${toolParameterEntry.tool}, Call ID: ${toolCallId}`);
|
|
69
|
-
});
|
|
70
|
-
if (lines.length === 0) {
|
|
71
|
-
return "";
|
|
72
|
-
}
|
|
73
|
-
return wrapPrunableTools(lines.join("\n"));
|
|
74
|
-
};
|
|
75
|
-
export const insertPruneToolContext = (state, config, logger, messages) => {
|
|
76
|
-
if (!config.tools.discard.enabled && !config.tools.extract.enabled) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
let prunableToolsContent;
|
|
80
|
-
if (state.lastToolPrune) {
|
|
81
|
-
logger.debug("Last tool was prune - injecting cooldown message");
|
|
82
|
-
prunableToolsContent = getCooldownMessage(config);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
const prunableToolsList = buildPrunableToolsList(state, config, logger, messages);
|
|
86
|
-
if (!prunableToolsList) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
logger.debug("prunable-tools: \n" + prunableToolsList);
|
|
90
|
-
let nudgeString = "";
|
|
91
|
-
if (config.tools.settings.nudgeEnabled &&
|
|
92
|
-
state.nudgeCounter >= config.tools.settings.nudgeFrequency) {
|
|
93
|
-
logger.info("Inserting prune nudge message");
|
|
94
|
-
nudgeString = "\n" + getNudgeString(config);
|
|
95
|
-
}
|
|
96
|
-
prunableToolsContent = prunableToolsList + nudgeString;
|
|
97
|
-
}
|
|
98
|
-
const lastUserMessage = getLastUserMessage(messages);
|
|
99
|
-
if (!lastUserMessage) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const userInfo = lastUserMessage.info;
|
|
103
|
-
const variant = state.variant ?? userInfo.variant;
|
|
104
|
-
let lastNonIgnoredMessage;
|
|
105
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
106
|
-
const msg = messages[i];
|
|
107
|
-
if (!(msg.info.role === "user" && isIgnoredUserMessage(msg))) {
|
|
108
|
-
lastNonIgnoredMessage = msg;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (!lastNonIgnoredMessage || lastNonIgnoredMessage.info.role === "user") {
|
|
113
|
-
messages.push(createSyntheticUserMessage(lastUserMessage, prunableToolsContent, variant));
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const providerID = userInfo.model?.providerID || "";
|
|
117
|
-
const modelID = userInfo.model?.modelID || "";
|
|
118
|
-
if (isDeepSeekOrKimi(providerID, modelID)) {
|
|
119
|
-
const toolPart = createSyntheticToolPart(lastNonIgnoredMessage, prunableToolsContent);
|
|
120
|
-
lastNonIgnoredMessage.parts.push(toolPart);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
messages.push(createSyntheticAssistantMessage(lastUserMessage, prunableToolsContent, variant));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated This function is no longer used. Hash-based discarding embeds
|
|
3
|
+
* hashes directly into tool outputs instead of injecting a prunable-tools list.
|
|
4
|
+
* Kept for backward compatibility but does nothing.
|
|
5
|
+
*/
|
|
6
|
+
export const insertPruneToolContext = (_state, _config, _logger, _messages) => {
|
|
7
|
+
// No-op: Hash-based discarding doesn't need list injection.
|
|
8
|
+
// Hashes are embedded directly into tool outputs via injectHashesIntoToolOutputs()
|
|
126
9
|
};
|
|
127
10
|
//# sourceMappingURL=inject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../lib/messages/inject.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../lib/messages/inject.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,MAAoB,EACpB,OAAqB,EACrB,OAAe,EACf,SAAsB,EAClB,EAAE;IACN,4DAA4D;IAC5D,mFAAmF;AACvF,CAAC,CAAA"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { SessionState, WithParts } from "../state";
|
|
2
2
|
import type { Logger } from "../logger";
|
|
3
3
|
import type { PluginConfig } from "../config";
|
|
4
|
+
/**
|
|
5
|
+
* Injects hash identifiers into tool outputs for hash-based discarding.
|
|
6
|
+
* Format: #x_xxxxx#\n<original output>
|
|
7
|
+
*
|
|
8
|
+
* This allows agents to reference tools by their stable hash when discarding,
|
|
9
|
+
* eliminating the need for a separate prunable-tools list.
|
|
10
|
+
*/
|
|
11
|
+
export declare const injectHashesIntoToolOutputs: (state: SessionState, config: PluginConfig, messages: WithParts[], logger: Logger) => void;
|
|
4
12
|
export declare const prune: (state: SessionState, logger: Logger, config: PluginConfig, messages: WithParts[]) => void;
|
|
5
13
|
//# sourceMappingURL=prune.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAM7C;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACpC,OAAO,YAAY,EACnB,QAAQ,YAAY,EACpB,UAAU,SAAS,EAAE,EACrB,QAAQ,MAAM,KACf,IA8CF,CAAA;AAoDD,eAAO,MAAM,KAAK,GACd,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,QAAQ,YAAY,EACpB,UAAU,SAAS,EAAE,KACtB,IAIF,CAAA"}
|
|
@@ -1,7 +1,94 @@
|
|
|
1
1
|
import { isMessageCompacted } from "../shared-utils";
|
|
2
|
-
const PRUNED_TOOL_OUTPUT_REPLACEMENT = "[Output removed to save context - information superseded or no longer needed]";
|
|
3
2
|
const PRUNED_TOOL_ERROR_INPUT_REPLACEMENT = "[input removed due to failed tool call]";
|
|
4
3
|
const PRUNED_QUESTION_INPUT_REPLACEMENT = "[questions removed - see output for user's answers]";
|
|
4
|
+
/**
|
|
5
|
+
* Injects hash identifiers into tool outputs for hash-based discarding.
|
|
6
|
+
* Format: #x_xxxxx#\n<original output>
|
|
7
|
+
*
|
|
8
|
+
* This allows agents to reference tools by their stable hash when discarding,
|
|
9
|
+
* eliminating the need for a separate prunable-tools list.
|
|
10
|
+
*/
|
|
11
|
+
export const injectHashesIntoToolOutputs = (state, config, messages, logger) => {
|
|
12
|
+
const protectedTools = config.tools.settings.protectedTools;
|
|
13
|
+
for (const msg of messages) {
|
|
14
|
+
if (isMessageCompacted(state, msg)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const parts = Array.isArray(msg.parts) ? msg.parts : [];
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
if (part.type !== "tool" || !part.callID) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
// Skip protected tools - they don't get hashes
|
|
23
|
+
if (protectedTools.includes(part.tool)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
// Skip if already pruned
|
|
27
|
+
if (state.prune.toolIds.includes(part.callID)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
// Only inject into completed tools that have output
|
|
31
|
+
if (part.state.status !== "completed") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const hash = state.callIdToHash.get(part.callID);
|
|
35
|
+
if (!hash) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// Skip if already has hash prefix
|
|
39
|
+
if (part.state.output?.startsWith("#")) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// Prepend hash to output
|
|
43
|
+
if (part.state.output) {
|
|
44
|
+
part.state.output = `${hash}\n${part.state.output}`;
|
|
45
|
+
logger.debug(`Injected hash ${hash} into ${part.tool} output`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Creates a compact breadcrumb string for pruned tool outputs.
|
|
52
|
+
* Format: [Output removed...] tool({param: "value"}) → status
|
|
53
|
+
*
|
|
54
|
+
* This preserves key metadata so the agent can understand what was pruned
|
|
55
|
+
* without needing to re-read the content.
|
|
56
|
+
*/
|
|
57
|
+
const createPrunedOutputBreadcrumb = (tool, input, status) => {
|
|
58
|
+
let paramsStr = "";
|
|
59
|
+
if (input && typeof input === "object") {
|
|
60
|
+
// Extract key parameters for common tools
|
|
61
|
+
const keyParams = {
|
|
62
|
+
read: ["filePath"],
|
|
63
|
+
write: ["filePath"],
|
|
64
|
+
edit: ["filePath"],
|
|
65
|
+
glob: ["pattern", "path"],
|
|
66
|
+
grep: ["pattern", "include", "path"],
|
|
67
|
+
bash: ["command", "description"],
|
|
68
|
+
webfetch: ["url"],
|
|
69
|
+
task: ["description"],
|
|
70
|
+
};
|
|
71
|
+
const relevantKeys = keyParams[tool] || Object.keys(input).slice(0, 2);
|
|
72
|
+
const params = [];
|
|
73
|
+
for (const key of relevantKeys) {
|
|
74
|
+
if (input[key] !== undefined) {
|
|
75
|
+
const value = input[key];
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
// Truncate long strings
|
|
78
|
+
const truncated = value.length > 50 ? value.slice(0, 47) + "..." : value;
|
|
79
|
+
params.push(`${key}: "${truncated}"`);
|
|
80
|
+
}
|
|
81
|
+
else if (typeof value === "number" || typeof value === "boolean") {
|
|
82
|
+
params.push(`${key}: ${value}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (params.length > 0) {
|
|
87
|
+
paramsStr = `{${params.join(", ")}}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return `[Output removed to save context - information superseded or no longer needed]\n${tool}(${paramsStr}) → ${status}`;
|
|
91
|
+
};
|
|
5
92
|
export const prune = (state, logger, config, messages) => {
|
|
6
93
|
pruneToolOutputs(state, logger, messages);
|
|
7
94
|
pruneToolInputs(state, logger, messages);
|
|
@@ -26,7 +113,7 @@ const pruneToolOutputs = (state, logger, messages) => {
|
|
|
26
113
|
if (part.tool === "question") {
|
|
27
114
|
continue;
|
|
28
115
|
}
|
|
29
|
-
part.state.output =
|
|
116
|
+
part.state.output = createPrunedOutputBreadcrumb(part.tool, part.state.input, part.state.status);
|
|
30
117
|
}
|
|
31
118
|
}
|
|
32
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,
|
|
1
|
+
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,mCAAmC,GAAG,yCAAyC,CAAA;AACrF,MAAM,iCAAiC,GAAG,qDAAqD,CAAA;AAE/F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACvC,KAAmB,EACnB,MAAoB,EACpB,QAAqB,EACrB,MAAc,EACV,EAAE;IACN,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAA;IAE3D,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YACjC,SAAQ;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACvC,SAAQ;YACZ,CAAC;YAED,+CAA+C;YAC/C,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,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,CAAC,EAAE,CAAC;YACjC,SAAQ;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACvB,SAAQ;YACZ,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC7C,SAAQ;YACZ,CAAC;YACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAChC,SAAQ;YACZ,CAAC;YAED,4CAA4C;YAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;YAC9B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnC,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;wBACjC,KAAK,CAAC,GAAG,CAAC,GAAG,mCAAmC,CAAA;oBACpD,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { Logger } from "../logger";
|
|
2
2
|
import type { SessionState, WithParts } from "../state";
|
|
3
|
+
/**
|
|
4
|
+
* Stable JSON stringify with sorted keys for deterministic hashing.
|
|
5
|
+
* Ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function stableStringify(obj: unknown): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generate a short, stable hash for a tool call.
|
|
10
|
+
* Format: #x_xxxxx# (e.g., #r_a1b2c#)
|
|
11
|
+
* - First char is tool prefix (first letter of tool name)
|
|
12
|
+
* - 5 hex chars from SHA256 hash of stable-stringified params
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateToolHash(tool: string, params: unknown): string;
|
|
3
15
|
export declare const isDeepSeekOrKimi: (providerID: string, modelID: string) => boolean;
|
|
4
16
|
export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
|
|
5
17
|
export declare const createSyntheticAssistantMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKvD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAqBpD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAKtE;AAID,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,EAAE,SAAS,MAAM,KAAG,OAStE,CAAA;AAED,eAAO,MAAM,0BAA0B,GACnC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,UAAU,MAAM,KACjB,SAwBF,CAAA;AAED,eAAO,MAAM,+BAA+B,GACxC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,UAAU,MAAM,KACjB,SAiCF,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,aAAa,SAAS,EAAE,SAAS,MAAM;;;;;;;;;;;;;;;;;;CAoB9E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,EAAE,YAAY,GAAG,KAAG,MAkHnE,CAAA;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,MAAM,GACf,MAAM,EAAE,CAgBV;AAED,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,KAAG,OAazD,CAAA"}
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
1
2
|
import { isMessageCompacted } from "../shared-utils";
|
|
2
3
|
const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
|
|
4
|
+
/**
|
|
5
|
+
* Stable JSON stringify with sorted keys for deterministic hashing.
|
|
6
|
+
* Ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
|
|
7
|
+
*/
|
|
8
|
+
export function stableStringify(obj) {
|
|
9
|
+
if (obj === null || obj === undefined) {
|
|
10
|
+
return JSON.stringify(obj);
|
|
11
|
+
}
|
|
12
|
+
if (typeof obj !== "object") {
|
|
13
|
+
return JSON.stringify(obj);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(obj)) {
|
|
16
|
+
return "[" + obj.map(stableStringify).join(",") + "]";
|
|
17
|
+
}
|
|
18
|
+
const keys = Object.keys(obj).sort();
|
|
19
|
+
return ("{" +
|
|
20
|
+
keys
|
|
21
|
+
.map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`)
|
|
22
|
+
.join(",") +
|
|
23
|
+
"}");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a short, stable hash for a tool call.
|
|
27
|
+
* Format: #x_xxxxx# (e.g., #r_a1b2c#)
|
|
28
|
+
* - First char is tool prefix (first letter of tool name)
|
|
29
|
+
* - 5 hex chars from SHA256 hash of stable-stringified params
|
|
30
|
+
*/
|
|
31
|
+
export function generateToolHash(tool, params) {
|
|
32
|
+
const prefix = (tool[0] ?? "x").toLowerCase();
|
|
33
|
+
const paramsStr = stableStringify(params);
|
|
34
|
+
const hash = createHash("sha256").update(paramsStr).digest("hex").substring(0, 5);
|
|
35
|
+
return `#${prefix}_${hash}#`;
|
|
36
|
+
}
|
|
3
37
|
const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
|
|
4
38
|
const SYNTHETIC_CALL_ID = "call_01234567890123456789012345";
|
|
5
39
|
export const isDeepSeekOrKimi = (providerID, modelID) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,oBAAoB,GAAG,gCAAgC,CAAA;AAE7D;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IACxC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACzD,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,OAAO,CACH,GAAG;QACH,IA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IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACnD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAC7B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAkB,EAAW,EAAE;IAChE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,CAAE,IAAY,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DISCARD_TOOL_SPEC = "Discards tool outputs from context to manage conversation size and reduce noise.\n\n##
|
|
1
|
+
export declare const DISCARD_TOOL_SPEC = "Discards tool outputs from context to manage conversation size and reduce noise.\n\n## How It Works\n\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to discard specific tool outputs when they are no longer needed.\n\n## When to Use This Tool\n\nUse `discard` for removing tool content that is no longer needed:\n\n- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.\n- **Task Completion:** Work is complete and there's no valuable information worth preserving.\n\n## When NOT to Use This Tool\n\n- **If the output contains useful information:** Keep it in context rather than discarding.\n- **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.\n\n## Best Practices\n- **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.\n- **Think ahead:** Before discarding, ask: \"Will I need this output for an upcoming task?\" If yes, keep it.\n\n## Parameters\n\n- `reason` (required): Why you're discarding. One of:\n - `noise` - Irrelevant or unhelpful output\n - `completion` - Task done, no longer needed\n - `superseded` - Newer output replaces this\n - `exploration` - Dead-end investigation\n - `duplicate` - Same content read multiple times\n\n- `hashes` (required): Array of hash strings from tool outputs (e.g., [\"#r_a1b2c#\", \"#g_d4e5f#\"])\n\n## Examples\n\n<example_single>\nTool output shows:\n#r_a1b2c#\n<file content...>\n\nTo discard: discard({hashes: [\"#r_a1b2c#\"], reason: \"noise\"})\n</example_single>\n\n<example_multiple>\nMultiple tools to discard after task completion:\ndiscard({hashes: [\"#r_a1b2c#\", \"#g_d4e5f#\", \"#b_12345#\"], reason: \"completion\"})\n</example_multiple>\n\n<example_exploration>\nAfter exploring files that weren't useful:\ndiscard({hashes: [\"#r_abc12#\", \"#r_def34#\"], reason: \"exploration\"})\n</example_exploration>";
|
|
2
2
|
//# sourceMappingURL=discard-tool-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discard-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"discard-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,0hEAoDP,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export const DISCARD_TOOL_SPEC = `Discards tool outputs from context to manage conversation size and reduce noise.
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
3
|
+
## How It Works
|
|
4
|
+
|
|
5
|
+
Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
|
|
6
|
+
Use these hashes to discard specific tool outputs when they are no longer needed.
|
|
5
7
|
|
|
6
8
|
## When to Use This Tool
|
|
7
9
|
|
|
8
|
-
Use \`discard\` for removing tool content that is no longer needed
|
|
10
|
+
Use \`discard\` for removing tool content that is no longer needed:
|
|
9
11
|
|
|
10
12
|
- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
|
|
11
13
|
- **Task Completion:** Work is complete and there's no valuable information worth preserving.
|
|
@@ -19,23 +21,34 @@ Use \`discard\` for removing tool content that is no longer needed
|
|
|
19
21
|
- **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.
|
|
20
22
|
- **Think ahead:** Before discarding, ask: "Will I need this output for an upcoming task?" If yes, keep it.
|
|
21
23
|
|
|
22
|
-
##
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
- \`reason\` (required): Why you're discarding. One of:
|
|
27
|
+
- \`noise\` - Irrelevant or unhelpful output
|
|
28
|
+
- \`completion\` - Task done, no longer needed
|
|
29
|
+
- \`superseded\` - Newer output replaces this
|
|
30
|
+
- \`exploration\` - Dead-end investigation
|
|
31
|
+
- \`duplicate\` - Same content read multiple times
|
|
32
|
+
|
|
33
|
+
- \`hashes\` (required): Array of hash strings from tool outputs (e.g., ["#r_a1b2c#", "#g_d4e5f#"])
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
## Examples
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
<example_single>
|
|
38
|
+
Tool output shows:
|
|
39
|
+
#r_a1b2c#
|
|
40
|
+
<file content...>
|
|
27
41
|
|
|
28
|
-
|
|
42
|
+
To discard: discard({hashes: ["#r_a1b2c#"], reason: "noise"})
|
|
43
|
+
</example_single>
|
|
29
44
|
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</example_noise>
|
|
45
|
+
<example_multiple>
|
|
46
|
+
Multiple tools to discard after task completion:
|
|
47
|
+
discard({hashes: ["#r_a1b2c#", "#g_d4e5f#", "#b_12345#"], reason: "completion"})
|
|
48
|
+
</example_multiple>
|
|
35
49
|
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</example_completion>`;
|
|
50
|
+
<example_exploration>
|
|
51
|
+
After exploring files that weren't useful:
|
|
52
|
+
discard({hashes: ["#r_abc12#", "#r_def34#"], reason: "exploration"})
|
|
53
|
+
</example_exploration>`;
|
|
41
54
|
//# sourceMappingURL=discard-tool-spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discard-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"discard-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAoDV,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const EXTRACT_TOOL_SPEC = "Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.\n\n##
|
|
1
|
+
export declare const EXTRACT_TOOL_SPEC = "Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.\n\n## How It Works\n\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to extract and distill specific tool outputs.\n\n## When to Use This Tool\n\nUse `extract` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:\n\n- **Task Completion:** You completed a unit of work and want to preserve key findings.\n- **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.\n\n## When NOT to Use This Tool\n\n- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.\n- **If uncertain:** Prefer keeping over re-fetching.\n\n## Best Practices\n- **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.\n- **Think ahead:** Before extracting, ask: \"Will I need the raw output for an upcoming task?\" If you researched a file you'll later edit, do NOT extract it.\n\n## Format\n\n- `hashes`: Array of hash strings from tool outputs (e.g., [\"#r_a1b2c#\", \"#r_d4e5f#\"])\n- `distillation`: Array of strings, one per hash (positional: distillation[0] is for hashes[0], etc.)\n- `preserve` (optional): Set to `true` to keep the original tool output after extraction. Default is `false` (prunes after extraction).\n\nEach distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed for your task.\n\n## Example\n\n<example_extraction>\nTool outputs show:\n#r_a1b2c#\n<auth.ts content...>\n\n#r_d4e5f#\n<user.ts content...>\n\nTo extract:\nextract({\n hashes: [\"#r_a1b2c#\", \"#r_d4e5f#\"],\n distillation: [\n \"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds.\",\n \"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }\"\n ]\n})\n</example_extraction>\n\n<example_keep>\nAssistant: [Reads 'auth.ts' to understand the login flow]\nI've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than extracting.\n</example_keep>";
|
|
2
2
|
//# sourceMappingURL=extract-tool-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"extract-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,2iFAsDd,CAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const EXTRACT_TOOL_SPEC = `Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
3
|
+
## How It Works
|
|
4
|
+
|
|
5
|
+
Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
|
|
6
|
+
Use these hashes to extract and distill specific tool outputs.
|
|
5
7
|
|
|
6
8
|
## When to Use This Tool
|
|
7
9
|
|
|
@@ -15,30 +17,36 @@ Use \`extract\` when you have gathered useful information that you want to **pre
|
|
|
15
17
|
- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.
|
|
16
18
|
- **If uncertain:** Prefer keeping over re-fetching.
|
|
17
19
|
|
|
18
|
-
|
|
19
20
|
## Best Practices
|
|
20
21
|
- **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.
|
|
21
22
|
- **Think ahead:** Before extracting, ask: "Will I need the raw output for an upcoming task?" If you researched a file you'll later edit, do NOT extract it.
|
|
22
23
|
|
|
23
24
|
## Format
|
|
24
25
|
|
|
25
|
-
- \`
|
|
26
|
-
- \`distillation\`: Array of strings, one per
|
|
26
|
+
- \`hashes\`: Array of hash strings from tool outputs (e.g., ["#r_a1b2c#", "#r_d4e5f#"])
|
|
27
|
+
- \`distillation\`: Array of strings, one per hash (positional: distillation[0] is for hashes[0], etc.)
|
|
28
|
+
- \`preserve\` (optional): Set to \`true\` to keep the original tool output after extraction. Default is \`false\` (prunes after extraction).
|
|
27
29
|
|
|
28
30
|
Each distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed for your task.
|
|
29
31
|
|
|
30
32
|
## Example
|
|
31
33
|
|
|
32
34
|
<example_extraction>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Tool outputs show:
|
|
36
|
+
#r_a1b2c#
|
|
37
|
+
<auth.ts content...>
|
|
38
|
+
|
|
39
|
+
#r_d4e5f#
|
|
40
|
+
<user.ts content...>
|
|
41
|
+
|
|
42
|
+
To extract:
|
|
43
|
+
extract({
|
|
44
|
+
hashes: ["#r_a1b2c#", "#r_d4e5f#"],
|
|
37
45
|
distillation: [
|
|
38
|
-
"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds.
|
|
46
|
+
"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds.",
|
|
39
47
|
"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }"
|
|
40
48
|
]
|
|
41
|
-
|
|
49
|
+
})
|
|
42
50
|
</example_extraction>
|
|
43
51
|
|
|
44
52
|
<example_keep>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"extract-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAsDjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAW9E"}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
// Tool specs
|
|
2
2
|
import { DISCARD_TOOL_SPEC } from "./discard-tool-spec";
|
|
3
3
|
import { EXTRACT_TOOL_SPEC } from "./extract-tool-spec";
|
|
4
|
+
import { RESTORE_TOOL_SPEC } from "./restore-tool-spec";
|
|
4
5
|
// System prompts
|
|
5
6
|
import { SYSTEM_PROMPT_BOTH } from "./system/both";
|
|
6
7
|
import { SYSTEM_PROMPT_DISCARD } from "./system/discard";
|
|
7
8
|
import { SYSTEM_PROMPT_EXTRACT } from "./system/extract";
|
|
8
|
-
// Nudge prompts
|
|
9
|
-
import { NUDGE_BOTH } from "./nudge/both";
|
|
10
|
-
import { NUDGE_DISCARD } from "./nudge/discard";
|
|
11
|
-
import { NUDGE_EXTRACT } from "./nudge/extract";
|
|
12
9
|
const PROMPTS = {
|
|
13
10
|
"discard-tool-spec": DISCARD_TOOL_SPEC,
|
|
14
11
|
"extract-tool-spec": EXTRACT_TOOL_SPEC,
|
|
12
|
+
"restore-tool-spec": RESTORE_TOOL_SPEC,
|
|
15
13
|
"system/system-prompt-both": SYSTEM_PROMPT_BOTH,
|
|
16
14
|
"system/system-prompt-discard": SYSTEM_PROMPT_DISCARD,
|
|
17
15
|
"system/system-prompt-extract": SYSTEM_PROMPT_EXTRACT,
|
|
18
|
-
"nudge/nudge-both": NUDGE_BOTH,
|
|
19
|
-
"nudge/nudge-discard": NUDGE_DISCARD,
|
|
20
|
-
"nudge/nudge-extract": NUDGE_EXTRACT,
|
|
21
16
|
};
|
|
22
17
|
export function loadPrompt(name, vars) {
|
|
23
18
|
let content = PROMPTS[name];
|