@tarquinen/opencode-dcp 1.2.1 → 1.2.3
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/dist/lib/messages/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject.js +10 -21
- package/dist/lib/messages/inject.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +1 -2
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +29 -38
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/discard-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/discard-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/{discard-tool-spec.txt → discard-tool-spec.js} +8 -8
- package/dist/lib/prompts/discard-tool-spec.js.map +1 -0
- package/dist/lib/prompts/extract-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/extract-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/{extract-tool-spec.txt → extract-tool-spec.js} +7 -6
- package/dist/lib/prompts/extract-tool-spec.js.map +1 -0
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +25 -4
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/nudge/both.d.ts +2 -0
- package/dist/lib/prompts/nudge/both.d.ts.map +1 -0
- package/dist/lib/prompts/nudge/{nudge-both.txt → both.js} +6 -5
- package/dist/lib/prompts/nudge/both.js.map +1 -0
- package/dist/lib/prompts/nudge/discard.d.ts +2 -0
- package/dist/lib/prompts/nudge/discard.d.ts.map +1 -0
- package/dist/lib/prompts/nudge/{nudge-discard.txt → discard.js} +5 -4
- package/dist/lib/prompts/nudge/discard.js.map +1 -0
- package/dist/lib/prompts/nudge/extract.d.ts +2 -0
- package/dist/lib/prompts/nudge/extract.d.ts.map +1 -0
- package/dist/lib/prompts/nudge/{nudge-extract.txt → extract.js} +4 -3
- package/dist/lib/prompts/nudge/extract.js.map +1 -0
- package/dist/lib/prompts/system/both.d.ts +2 -0
- package/dist/lib/prompts/system/both.d.ts.map +1 -0
- package/dist/lib/prompts/system/{system-prompt-both.txt → both.js} +14 -13
- package/dist/lib/prompts/system/both.js.map +1 -0
- package/dist/lib/prompts/system/discard.d.ts +2 -0
- package/dist/lib/prompts/system/discard.d.ts.map +1 -0
- package/dist/lib/prompts/system/{system-prompt-discard.txt → discard.js} +6 -5
- package/dist/lib/prompts/system/discard.js.map +1 -0
- package/dist/lib/prompts/system/extract.d.ts +2 -0
- package/dist/lib/prompts/system/extract.d.ts.map +1 -0
- package/dist/lib/prompts/system/{system-prompt-extract.txt → extract.js} +6 -5
- package/dist/lib/prompts/system/extract.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../../lib/messages/inject.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":"inject.d.ts","sourceRoot":"","sources":["../../../lib/messages/inject.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;AAkG7C,eAAO,MAAM,sBAAsB,GAC/B,OAAO,YAAY,EACnB,QAAQ,YAAY,EACpB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,KACtB,IA+CF,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadPrompt } from "../prompts";
|
|
2
|
-
import { extractParameterKey, buildToolIdList,
|
|
2
|
+
import { extractParameterKey, buildToolIdList, createSyntheticAssistantMessage, isIgnoredUserMessage, } from "./utils";
|
|
3
3
|
import { getFilePathFromParameters, isProtectedFilePath } from "../protected-file-patterns";
|
|
4
4
|
import { getLastUserMessage } from "../shared-utils";
|
|
5
5
|
const getNudgeString = (config) => {
|
|
@@ -99,27 +99,16 @@ export const insertPruneToolContext = (state, config, logger, messages) => {
|
|
|
99
99
|
if (!lastUserMessage) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const isAnthropic = modelID.includes("claude");
|
|
110
|
-
if (isGitHubCopilot) {
|
|
111
|
-
const lastMessage = messages[messages.length - 1];
|
|
112
|
-
if (lastMessage?.info?.role === "user" && !isIgnoredUserMessage(lastMessage)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Anthropic extended thinking models require a thinking block at the start of its turn
|
|
117
|
-
if (isAnthropic) {
|
|
118
|
-
if (!hasReasoningInCurrentAssistantTurn(messages)) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
102
|
+
// Never inject immediately following a user message - wait until assistant has started its turn
|
|
103
|
+
// This avoids interfering with model reasoning/thinking phases
|
|
104
|
+
// TODO: This can be skipped if there is a good way to check if the model has reasoning,
|
|
105
|
+
// can't find a good way to do this yet
|
|
106
|
+
const lastMessage = messages[messages.length - 1];
|
|
107
|
+
if (lastMessage?.info?.role === "user" && !isIgnoredUserMessage(lastMessage)) {
|
|
108
|
+
return;
|
|
121
109
|
}
|
|
110
|
+
const userInfo = lastUserMessage.info;
|
|
122
111
|
const variant = state.variant ?? userInfo.variant;
|
|
123
|
-
messages.push(
|
|
112
|
+
messages.push(createSyntheticAssistantMessage(lastUserMessage, prunableToolsContent, variant));
|
|
124
113
|
};
|
|
125
114
|
//# sourceMappingURL=inject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../lib/messages/inject.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../lib/messages/inject.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EACH,mBAAmB,EACnB,eAAe,EACf,+BAA+B,EAC/B,oBAAoB,GACvB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,cAAc,GAAG,CAAC,MAAoB,EAAU,EAAE;IACpD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IAEnD,IAAI,cAAc,IAAI,cAAc,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC,kBAAkB,CAAC,CAAA;IACzC,CAAC;SAAM,IAAI,cAAc,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAA;IAC5C,CAAC;SAAM,IAAI,cAAc,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAA;IAC5C,CAAC;IACD,OAAO,EAAE,CAAA;AACb,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC;;EAErD,OAAO;kBACS,CAAA;AAElB,MAAM,kBAAkB,GAAG,CAAC,MAAoB,EAAU,EAAE;IACxD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,MAAM,cAAc,GAAG,MAAM,CAAC,KAA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-
export declare const
|
|
3
|
+
export declare const createSyntheticAssistantMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
|
|
4
4
|
/**
|
|
5
5
|
* Extracts a human-readable key from tool metadata for display purposes.
|
|
6
6
|
*/
|
|
7
7
|
export declare const extractParameterKey: (tool: string, parameters: any) => string;
|
|
8
8
|
export declare function buildToolIdList(state: SessionState, messages: WithParts[], logger: Logger): string[];
|
|
9
9
|
export declare const isIgnoredUserMessage: (message: WithParts) => boolean;
|
|
10
|
-
export declare const hasReasoningInCurrentAssistantTurn: (messages: WithParts[]) => boolean;
|
|
11
10
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAYvD,eAAO,MAAM,+BAA+B,GACxC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,UAAU,MAAM,KACjB,SAkDF,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,CAeV;AAED,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,KAAG,OAYzD,CAAA"}
|
|
@@ -2,28 +2,37 @@ import { isMessageCompacted } from "../shared-utils";
|
|
|
2
2
|
const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
|
|
3
3
|
const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
|
|
4
4
|
const SYNTHETIC_CALL_ID = "call_01234567890123456789012345";
|
|
5
|
-
|
|
5
|
+
const isGeminiModel = (modelID) => {
|
|
6
|
+
const lowerModelID = modelID.toLowerCase();
|
|
7
|
+
return lowerModelID.includes("gemini");
|
|
8
|
+
};
|
|
9
|
+
export const createSyntheticAssistantMessage = (baseMessage, content, variant) => {
|
|
6
10
|
const userInfo = baseMessage.info;
|
|
7
11
|
const now = Date.now();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
root: "/",
|
|
21
|
-
},
|
|
22
|
-
time: { created: now, completed: now },
|
|
23
|
-
cost: 0,
|
|
24
|
-
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
25
|
-
...(variant !== undefined && { variant }),
|
|
12
|
+
const baseInfo = {
|
|
13
|
+
id: SYNTHETIC_MESSAGE_ID,
|
|
14
|
+
sessionID: userInfo.sessionID,
|
|
15
|
+
role: "assistant",
|
|
16
|
+
agent: userInfo.agent || "code",
|
|
17
|
+
parentID: userInfo.id,
|
|
18
|
+
modelID: userInfo.model.modelID,
|
|
19
|
+
providerID: userInfo.model.providerID,
|
|
20
|
+
mode: "default",
|
|
21
|
+
path: {
|
|
22
|
+
cwd: "/",
|
|
23
|
+
root: "/",
|
|
26
24
|
},
|
|
25
|
+
time: { created: now, completed: now },
|
|
26
|
+
cost: 0,
|
|
27
|
+
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
28
|
+
...(variant !== undefined && { variant }),
|
|
29
|
+
};
|
|
30
|
+
// For Gemini models, add thoughtSignature bypass to avoid validation errors
|
|
31
|
+
const toolPartMetadata = isGeminiModel(userInfo.model.modelID)
|
|
32
|
+
? { google: { thoughtSignature: "skip_thought_signature_validator" } }
|
|
33
|
+
: undefined;
|
|
34
|
+
return {
|
|
35
|
+
info: baseInfo,
|
|
27
36
|
parts: [
|
|
28
37
|
{
|
|
29
38
|
id: SYNTHETIC_PART_ID,
|
|
@@ -40,6 +49,7 @@ export const createSyntheticAssistantMessageWithToolPart = (baseMessage, content
|
|
|
40
49
|
metadata: {},
|
|
41
50
|
time: { start: now, end: now },
|
|
42
51
|
},
|
|
52
|
+
...(toolPartMetadata && { metadata: toolPartMetadata }),
|
|
43
53
|
},
|
|
44
54
|
],
|
|
45
55
|
};
|
|
@@ -180,23 +190,4 @@ export const isIgnoredUserMessage = (message) => {
|
|
|
180
190
|
}
|
|
181
191
|
return true;
|
|
182
192
|
};
|
|
183
|
-
export const hasReasoningInCurrentAssistantTurn = (messages) => {
|
|
184
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
185
|
-
const message = messages[i];
|
|
186
|
-
if (message.info?.role === "user") {
|
|
187
|
-
if (isIgnoredUserMessage(message)) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
if (message.info?.role === "assistant" && message.parts) {
|
|
193
|
-
for (const part of message.parts) {
|
|
194
|
-
if (part.type === "reasoning") {
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return false;
|
|
201
|
-
};
|
|
202
193
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,oBAAoB,GAAG,gCAAgC,CAAA;AAC7D,MAAM,iBAAiB,GAAG,gCAA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,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAkB,EAAW,EAAE;IAChE,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAE,IAAY,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DISCARD_TOOL_SPEC = "Discards tool outputs from context to manage conversation size and reduce noise.\n\n## IMPORTANT: The Prunable List\nA `<prunable-tools>` list is provided to you showing available tool outputs you can discard when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to discard.\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:** Use `extract` instead to preserve key findings.\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## Format\n\n- `ids`: Array where the first element is the reason, followed by numeric IDs from the `<prunable-tools>` list\n\nReasons: `noise` | `completion`\n\n## Example\n\n<example_noise>\nAssistant: [Reads 'wrong_file.ts']\nThis file isn't relevant to the auth system. I'll remove it to clear the context.\n[Uses discard with ids: [\"noise\", \"5\"]]\n</example_noise>\n\n<example_completion>\nAssistant: [Runs tests, they pass]\nThe tests passed and I don't need to preserve any details. I'll clean up now.\n[Uses discard with ids: [\"completion\", \"20\", \"21\"]]\n</example_completion>";
|
|
2
|
+
//# sourceMappingURL=discard-tool-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discard-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,q1DAuCR,CAAA"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
Discards tool outputs from context to manage conversation size and reduce noise.
|
|
1
|
+
export const DISCARD_TOOL_SPEC = `Discards tool outputs from context to manage conversation size and reduce noise.
|
|
2
2
|
|
|
3
3
|
## IMPORTANT: The Prunable List
|
|
4
|
-
A
|
|
4
|
+
A \`<prunable-tools>\` list is provided to you showing available tool outputs you can discard when there are tools available for pruning. Each line has the format \`ID: tool, parameter\` (e.g., \`20: read, /path/to/file.ts\`). You MUST only use numeric IDs that appear in this list to select which tools to discard.
|
|
5
5
|
|
|
6
6
|
## When to Use This Tool
|
|
7
7
|
|
|
8
|
-
Use
|
|
8
|
+
Use \`discard\` for removing tool content that is no longer needed
|
|
9
9
|
|
|
10
10
|
- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
|
|
11
11
|
- **Task Completion:** Work is complete and there's no valuable information worth preserving.
|
|
12
12
|
|
|
13
13
|
## When NOT to Use This Tool
|
|
14
14
|
|
|
15
|
-
- **If the output contains useful information:** Use
|
|
15
|
+
- **If the output contains useful information:** Use \`extract\` instead to preserve key findings.
|
|
16
16
|
- **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.
|
|
17
17
|
|
|
18
18
|
## Best Practices
|
|
@@ -21,9 +21,9 @@ Use `discard` for removing tool content that is no longer needed
|
|
|
21
21
|
|
|
22
22
|
## Format
|
|
23
23
|
|
|
24
|
-
-
|
|
24
|
+
- \`ids\`: Array where the first element is the reason, followed by numeric IDs from the \`<prunable-tools>\` list
|
|
25
25
|
|
|
26
|
-
Reasons:
|
|
26
|
+
Reasons: \`noise\` | \`completion\`
|
|
27
27
|
|
|
28
28
|
## Example
|
|
29
29
|
|
|
@@ -37,5 +37,5 @@ This file isn't relevant to the auth system. I'll remove it to clear the context
|
|
|
37
37
|
Assistant: [Runs tests, they pass]
|
|
38
38
|
The tests passed and I don't need to preserve any details. I'll clean up now.
|
|
39
39
|
[Uses discard with ids: ["completion", "20", "21"]]
|
|
40
|
-
</example_completion
|
|
41
|
-
|
|
40
|
+
</example_completion>`;
|
|
41
|
+
//# sourceMappingURL=discard-tool-spec.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAuCX,CAAA"}
|
|
@@ -0,0 +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## IMPORTANT: The Prunable List\nA `<prunable-tools>` list is provided to you showing available tool outputs you can extract from when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to extract.\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\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- `ids`: Array of numeric IDs as strings from the `<prunable-tools>` list\n- `distillation`: Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)\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>\nAssistant: [Reads auth service and user types]\nI'll preserve the key details before extracting.\n[Uses extract with:\n ids: [\"10\", \"11\"],\n distillation: [\n \"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds. Tokens must be 128+ chars.\",\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
|
+
//# sourceMappingURL=extract-tool-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,kkFA8Cd,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.
|
|
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
3
|
## IMPORTANT: The Prunable List
|
|
4
|
-
A
|
|
4
|
+
A \`<prunable-tools>\` list is provided to you showing available tool outputs you can extract from when there are tools available for pruning. Each line has the format \`ID: tool, parameter\` (e.g., \`20: read, /path/to/file.ts\`). You MUST only use numeric IDs that appear in this list to select which tools to extract.
|
|
5
5
|
|
|
6
6
|
## When to Use This Tool
|
|
7
7
|
|
|
8
|
-
Use
|
|
8
|
+
Use \`extract\` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:
|
|
9
9
|
|
|
10
10
|
- **Task Completion:** You completed a unit of work and want to preserve key findings.
|
|
11
11
|
- **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.
|
|
@@ -22,8 +22,8 @@ Use `extract` when you have gathered useful information that you want to **prese
|
|
|
22
22
|
|
|
23
23
|
## Format
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
25
|
+
- \`ids\`: Array of numeric IDs as strings from the \`<prunable-tools>\` list
|
|
26
|
+
- \`distillation\`: Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)
|
|
27
27
|
|
|
28
28
|
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
29
|
|
|
@@ -44,4 +44,5 @@ I'll preserve the key details before extracting.
|
|
|
44
44
|
<example_keep>
|
|
45
45
|
Assistant: [Reads 'auth.ts' to understand the login flow]
|
|
46
46
|
I'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.
|
|
47
|
-
</example_keep
|
|
47
|
+
</example_keep>`;
|
|
48
|
+
//# sourceMappingURL=extract-tool-spec.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8CjB,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":"AAyBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAW9E"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
// Tool specs
|
|
2
|
+
import { DISCARD_TOOL_SPEC } from "./discard-tool-spec";
|
|
3
|
+
import { EXTRACT_TOOL_SPEC } from "./extract-tool-spec";
|
|
4
|
+
// System prompts
|
|
5
|
+
import { SYSTEM_PROMPT_BOTH } from "./system/both";
|
|
6
|
+
import { SYSTEM_PROMPT_DISCARD } from "./system/discard";
|
|
7
|
+
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
|
+
const PROMPTS = {
|
|
13
|
+
"discard-tool-spec": DISCARD_TOOL_SPEC,
|
|
14
|
+
"extract-tool-spec": EXTRACT_TOOL_SPEC,
|
|
15
|
+
"system/system-prompt-both": SYSTEM_PROMPT_BOTH,
|
|
16
|
+
"system/system-prompt-discard": SYSTEM_PROMPT_DISCARD,
|
|
17
|
+
"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
|
+
};
|
|
3
22
|
export function loadPrompt(name, vars) {
|
|
4
|
-
|
|
5
|
-
|
|
23
|
+
let content = PROMPTS[name];
|
|
24
|
+
if (!content) {
|
|
25
|
+
throw new Error(`Prompt not found: ${name}`);
|
|
26
|
+
}
|
|
6
27
|
if (vars) {
|
|
7
28
|
for (const [key, value] of Object.entries(vars)) {
|
|
8
29
|
content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,iBAAiB;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,gBAAgB;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,OAAO,GAA2B;IACpC,mBAAmB,EAAE,iBAAiB;IACtC,mBAAmB,EAAE,iBAAiB;IACtC,2BAA2B,EAAE,kBAAkB;IAC/C,8BAA8B,EAAE,qBAAqB;IACrD,8BAA8B,EAAE,qBAAqB;IACrD,kBAAkB,EAAE,UAAU;IAC9B,qBAAqB,EAAE,aAAa;IACpC,qBAAqB,EAAE,aAAa;CACvC,CAAA;AAED,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAA6B;IAClE,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,IAAI,EAAE,CAAC;QACP,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;QAC3E,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const NUDGE_BOTH = "<instruction name=context_management_required>\n**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.\n\n**Immediate Actions Required:**\n1. **Task Completion:** If a sub-task is complete, decide: use `discard` if no valuable context to preserve (default), or use `extract` if insights are worth keeping.\n2. **Noise Removal:** If you read files or ran commands that yielded no value, use `discard` to remove them.\n3. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use `extract` to distill the insights and remove the raw entry.\n\n**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.\n</instruction>";
|
|
2
|
+
//# sourceMappingURL=both.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"both.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/both.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,s2BASR,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export const NUDGE_BOTH = `<instruction name=context_management_required>
|
|
2
2
|
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
3
|
|
|
4
4
|
**Immediate Actions Required:**
|
|
5
|
-
1. **Task Completion:** If a sub-task is complete, decide: use
|
|
6
|
-
2. **Noise Removal:** If you read files or ran commands that yielded no value, use
|
|
7
|
-
3. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use
|
|
5
|
+
1. **Task Completion:** If a sub-task is complete, decide: use \`discard\` if no valuable context to preserve (default), or use \`extract\` if insights are worth keeping.
|
|
6
|
+
2. **Noise Removal:** If you read files or ran commands that yielded no value, use \`discard\` to remove them.
|
|
7
|
+
3. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use \`extract\` to distill the insights and remove the raw entry.
|
|
8
8
|
|
|
9
9
|
**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
|
|
10
|
-
</instruction
|
|
10
|
+
</instruction>`;
|
|
11
|
+
//# sourceMappingURL=both.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"both.js","sourceRoot":"","sources":["../../../../lib/prompts/nudge/both.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;eASX,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const NUDGE_DISCARD = "<instruction name=context_management_required>\n**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.\n\n**Immediate Actions Required:**\n1. **Task Completion:** If a sub-task is complete, use the `discard` tool to remove the tools used.\n2. **Noise Removal:** If you read files or ran commands that yielded no value, use the `discard` tool to remove them.\n\n**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must discard unneeded tool outputs.\n</instruction>";
|
|
2
|
+
//# sourceMappingURL=discard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discard.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/discard.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,0oBAQX,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
export const NUDGE_DISCARD = `<instruction name=context_management_required>
|
|
2
2
|
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
3
|
|
|
4
4
|
**Immediate Actions Required:**
|
|
5
|
-
1. **Task Completion:** If a sub-task is complete, use the
|
|
6
|
-
2. **Noise Removal:** If you read files or ran commands that yielded no value, use the
|
|
5
|
+
1. **Task Completion:** If a sub-task is complete, use the \`discard\` tool to remove the tools used.
|
|
6
|
+
2. **Noise Removal:** If you read files or ran commands that yielded no value, use the \`discard\` tool to remove them.
|
|
7
7
|
|
|
8
8
|
**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must discard unneeded tool outputs.
|
|
9
|
-
</instruction
|
|
9
|
+
</instruction>`;
|
|
10
|
+
//# sourceMappingURL=discard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discard.js","sourceRoot":"","sources":["../../../../lib/prompts/nudge/discard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;eAQd,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const NUDGE_EXTRACT = "<instruction name=context_management_required>\n**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.\n\n**Immediate Actions Required:**\n1. **Task Completion:** If you have completed work, extract key findings from the tools used. Scale distillation depth to the value of the content.\n2. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use the `extract` tool with high-fidelity distillation to preserve the insights and remove the raw entry.\n\n**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must extract valuable findings from tool outputs.\n</instruction>";
|
|
2
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,gyBAQX,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
export const NUDGE_EXTRACT = `<instruction name=context_management_required>
|
|
2
2
|
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
3
|
|
|
4
4
|
**Immediate Actions Required:**
|
|
5
5
|
1. **Task Completion:** If you have completed work, extract key findings from the tools used. Scale distillation depth to the value of the content.
|
|
6
|
-
2. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use the
|
|
6
|
+
2. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use the \`extract\` tool with high-fidelity distillation to preserve the insights and remove the raw entry.
|
|
7
7
|
|
|
8
8
|
**Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must extract valuable findings from tool outputs.
|
|
9
|
-
</instruction
|
|
9
|
+
</instruction>`;
|
|
10
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../lib/prompts/nudge/extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;eAQd,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const SYSTEM_PROMPT_BOTH = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` and `extract` tools. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to prune.\n\nTWO TOOLS FOR CONTEXT MANAGEMENT\n- `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.\n- `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.\n\nCHOOSING THE RIGHT TOOL\nAsk: \"Do I need to preserve any information from this output?\"\n- **No** \u2192 `discard` (default for cleanup)\n- **Yes** \u2192 `extract` (preserves distilled knowledge)\n- **Uncertain** \u2192 `extract` (safer, preserves signal)\n\nCommon scenarios:\n- Task complete, no valuable context \u2192 `discard`\n- Task complete, insights worth remembering \u2192 `extract`\n- Noise, irrelevant, or superseded outputs \u2192 `discard`\n- Valuable context needed later but raw output too large \u2192 `extract`\n\nPRUNE METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.\n\nYou WILL evaluate pruning when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (pruning removes the large input content)\n\nYou MUST NOT prune when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nPruning that forces you to re-call the same tool later is a net loss. Only prune when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.\nFAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `discard` and `extract` tools also return a confirmation message listing what was pruned.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the prune encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the prune encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to prune\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to prune\")\n- NEVER acknowledge discard/extract tool output (e.g., \"I've pruned 3 tools\", \"Context pruning complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
|
|
2
|
+
//# sourceMappingURL=both.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"both.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,mvHAyDZ,CAAA"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
export const SYSTEM_PROMPT_BOTH = `<system-reminder>
|
|
2
2
|
<instruction name=context_management_protocol policy_level=critical>
|
|
3
3
|
|
|
4
4
|
ENVIRONMENT
|
|
5
|
-
You are operating in a context-constrained environment and thus must proactively manage your context window using the
|
|
5
|
+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` and \`extract\` tools. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to prune.
|
|
6
6
|
|
|
7
7
|
TWO TOOLS FOR CONTEXT MANAGEMENT
|
|
8
|
-
-
|
|
9
|
-
-
|
|
8
|
+
- \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
|
|
9
|
+
- \`extract\`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
|
|
10
10
|
|
|
11
11
|
CHOOSING THE RIGHT TOOL
|
|
12
12
|
Ask: "Do I need to preserve any information from this output?"
|
|
13
|
-
- **No** →
|
|
14
|
-
- **Yes** →
|
|
15
|
-
- **Uncertain** →
|
|
13
|
+
- **No** → \`discard\` (default for cleanup)
|
|
14
|
+
- **Yes** → \`extract\` (preserves distilled knowledge)
|
|
15
|
+
- **Uncertain** → \`extract\` (safer, preserves signal)
|
|
16
16
|
|
|
17
17
|
Common scenarios:
|
|
18
|
-
- Task complete, no valuable context →
|
|
19
|
-
- Task complete, insights worth remembering →
|
|
20
|
-
- Noise, irrelevant, or superseded outputs →
|
|
21
|
-
- Valuable context needed later but raw output too large →
|
|
18
|
+
- Task complete, no valuable context → \`discard\`
|
|
19
|
+
- Task complete, insights worth remembering → \`extract\`
|
|
20
|
+
- Noise, irrelevant, or superseded outputs → \`discard\`
|
|
21
|
+
- Valuable context needed later but raw output too large → \`extract\`
|
|
22
22
|
|
|
23
23
|
PRUNE METHODICALLY - BATCH YOUR ACTIONS
|
|
24
24
|
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.
|
|
@@ -42,7 +42,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
|
|
|
42
42
|
</instruction>
|
|
43
43
|
|
|
44
44
|
<instruction name=injected_context_handling policy_level=critical>
|
|
45
|
-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The
|
|
45
|
+
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`discard\` and \`extract\` tools also return a confirmation message listing what was pruned.
|
|
46
46
|
|
|
47
47
|
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
48
48
|
- NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.
|
|
@@ -55,4 +55,5 @@ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
|
55
55
|
|
|
56
56
|
The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
|
|
57
57
|
</instruction>
|
|
58
|
-
</system-reminder
|
|
58
|
+
</system-reminder>`;
|
|
59
|
+
//# sourceMappingURL=both.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"both.js","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAyDf,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const SYSTEM_PROMPT_DISCARD = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to discard.\n\nCONTEXT MANAGEMENT TOOL\n- `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.\n\nDISCARD METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise. Evaluate what SHOULD be discarded before jumping the gun.\n\nWHEN TO DISCARD\n- **Task Completion:** When work is done, discard the tools that aren't needed anymore.\n- **Noise Removal:** If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.\n\nYou WILL evaluate discarding when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (discarding removes the large input content)\n\nYou MUST NOT discard when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nDiscarding that forces you to re-call the same tool later is a net loss. Only discard when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact discards that significantly reduce context size.\nFAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY discard what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `discard` tool also returns a confirmation message listing what was discarded.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the discard encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the discard encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to discard\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to discard\")\n- NEVER acknowledge discard tool output (e.g., \"I've discarded 3 tools\", \"Context cleanup complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
|
|
2
|
+
//# sourceMappingURL=discard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discard.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,4yGAgDf,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export const SYSTEM_PROMPT_DISCARD = `<system-reminder>
|
|
2
2
|
<instruction name=context_management_protocol policy_level=critical>
|
|
3
3
|
|
|
4
4
|
ENVIRONMENT
|
|
5
|
-
You are operating in a context-constrained environment and thus must proactively manage your context window using the
|
|
5
|
+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to discard.
|
|
6
6
|
|
|
7
7
|
CONTEXT MANAGEMENT TOOL
|
|
8
|
-
-
|
|
8
|
+
- \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
|
|
9
9
|
|
|
10
10
|
DISCARD METHODICALLY - BATCH YOUR ACTIONS
|
|
11
11
|
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise. Evaluate what SHOULD be discarded before jumping the gun.
|
|
@@ -33,7 +33,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
|
|
|
33
33
|
</instruction>
|
|
34
34
|
|
|
35
35
|
<instruction name=injected_context_handling policy_level=critical>
|
|
36
|
-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The
|
|
36
|
+
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`discard\` tool also returns a confirmation message listing what was discarded.
|
|
37
37
|
|
|
38
38
|
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
39
39
|
- NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears.
|
|
@@ -46,4 +46,5 @@ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
|
46
46
|
|
|
47
47
|
The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
|
|
48
48
|
</instruction>
|
|
49
|
-
</system-reminder
|
|
49
|
+
</system-reminder>`;
|
|
50
|
+
//# sourceMappingURL=discard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discard.js","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgDlB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const SYSTEM_PROMPT_EXTRACT = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `extract` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to extract.\n\nCONTEXT MANAGEMENT TOOL\n- `extract`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.\n\nEXTRACT METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output. Evaluate what SHOULD be extracted before jumping the gun.\n\nWHEN TO EXTRACT\n- **Task Completion:** When work is done, extract key findings from the tools used. Scale distillation depth to the value of the content.\n- **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.\n\nYou WILL evaluate extracting when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (extracting removes the large input content)\n\nYou MUST NOT extract when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nExtracting that forces you to re-call the same tool later is a net loss. Only extract when you're confident the raw information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact extractions that significantly reduce context size.\nFAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY extract what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `extract` tool also returns a confirmation message listing what was extracted.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the extract encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the extract encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to extract\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to extract\")\n- NEVER acknowledge extract tool output (e.g., \"I've extracted 3 tools\", \"Context cleanup complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
|
|
2
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,wnHAgDf,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export const SYSTEM_PROMPT_EXTRACT = `<system-reminder>
|
|
2
2
|
<instruction name=context_management_protocol policy_level=critical>
|
|
3
3
|
|
|
4
4
|
ENVIRONMENT
|
|
5
|
-
You are operating in a context-constrained environment and thus must proactively manage your context window using the
|
|
5
|
+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`extract\` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to extract.
|
|
6
6
|
|
|
7
7
|
CONTEXT MANAGEMENT TOOL
|
|
8
|
-
-
|
|
8
|
+
- \`extract\`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.
|
|
9
9
|
|
|
10
10
|
EXTRACT METHODICALLY - BATCH YOUR ACTIONS
|
|
11
11
|
Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output. Evaluate what SHOULD be extracted before jumping the gun.
|
|
@@ -33,7 +33,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
|
|
|
33
33
|
</instruction>
|
|
34
34
|
|
|
35
35
|
<instruction name=injected_context_handling policy_level=critical>
|
|
36
|
-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The
|
|
36
|
+
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`extract\` tool also returns a confirmation message listing what was extracted.
|
|
37
37
|
|
|
38
38
|
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
39
39
|
- NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears.
|
|
@@ -46,4 +46,5 @@ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
|
|
|
46
46
|
|
|
47
47
|
The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
|
|
48
48
|
</instruction>
|
|
49
|
-
</system-reminder
|
|
49
|
+
</system-reminder>`;
|
|
50
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgDlB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@tarquinen/opencode-dcp",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"clean": "rm -rf dist",
|
|
11
|
-
"build": "npm run clean && tsc
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
12
|
"postbuild": "rm -rf dist/logs",
|
|
13
13
|
"prepublishOnly": "npm run build",
|
|
14
14
|
"dev": "opencode plugin dev",
|