@tuanhung303/opencode-dcp 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +249 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/commands/context.d.ts +49 -0
- package/dist/lib/commands/context.d.ts.map +1 -0
- package/dist/lib/commands/context.js +191 -0
- package/dist/lib/commands/context.js.map +1 -0
- package/dist/lib/commands/help.d.ts +15 -0
- package/dist/lib/commands/help.d.ts.map +1 -0
- package/dist/lib/commands/help.js +26 -0
- package/dist/lib/commands/help.js.map +1 -0
- package/dist/lib/commands/stats.d.ts +15 -0
- package/dist/lib/commands/stats.d.ts.map +1 -0
- package/dist/lib/commands/stats.js +44 -0
- package/dist/lib/commands/stats.js.map +1 -0
- package/dist/lib/commands/sweep.d.ts +23 -0
- package/dist/lib/commands/sweep.d.ts.map +1 -0
- package/dist/lib/commands/sweep.js +191 -0
- package/dist/lib/commands/sweep.js.map +1 -0
- package/dist/lib/config.d.ts +69 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +754 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/hooks.d.ts +17 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/hooks.js +121 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/logger.d.ts +31 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +189 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/messages/index.d.ts +3 -0
- package/dist/lib/messages/index.d.ts.map +1 -0
- package/dist/lib/messages/index.js +3 -0
- package/dist/lib/messages/index.js.map +1 -0
- package/dist/lib/messages/inject.d.ts +5 -0
- package/dist/lib/messages/inject.d.ts.map +1 -0
- package/dist/lib/messages/inject.js +127 -0
- package/dist/lib/messages/inject.js.map +1 -0
- package/dist/lib/messages/prune.d.ts +5 -0
- package/dist/lib/messages/prune.d.ts.map +1 -0
- package/dist/lib/messages/prune.js +86 -0
- package/dist/lib/messages/prune.js.map +1 -0
- package/dist/lib/messages/utils.d.ts +31 -0
- package/dist/lib/messages/utils.d.ts.map +1 -0
- package/dist/lib/messages/utils.js +228 -0
- package/dist/lib/messages/utils.js.map +1 -0
- 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.js +41 -0
- 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.js +48 -0
- package/dist/lib/prompts/extract-tool-spec.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +2 -0
- package/dist/lib/prompts/index.d.ts.map +1 -0
- package/dist/lib/prompts/index.js +34 -0
- package/dist/lib/prompts/index.js.map +1 -0
- 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/both.js +11 -0
- 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/discard.js +10 -0
- 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/extract.js +10 -0
- 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/both.js +61 -0
- 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/discard.js +52 -0
- 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/extract.js +52 -0
- package/dist/lib/prompts/system/extract.js.map +1 -0
- package/dist/lib/protected-file-patterns.d.ts +12 -0
- package/dist/lib/protected-file-patterns.d.ts.map +1 -0
- package/dist/lib/protected-file-patterns.js +69 -0
- package/dist/lib/protected-file-patterns.js.map +1 -0
- package/dist/lib/shared-utils.d.ts +4 -0
- package/dist/lib/shared-utils.d.ts.map +1 -0
- package/dist/lib/shared-utils.js +14 -0
- package/dist/lib/shared-utils.js.map +1 -0
- package/dist/lib/state/index.d.ts +4 -0
- package/dist/lib/state/index.d.ts.map +1 -0
- package/dist/lib/state/index.js +4 -0
- package/dist/lib/state/index.js.map +1 -0
- package/dist/lib/state/persistence.d.ts +22 -0
- package/dist/lib/state/persistence.d.ts.map +1 -0
- package/dist/lib/state/persistence.js +107 -0
- package/dist/lib/state/persistence.js.map +1 -0
- package/dist/lib/state/state.d.ts +8 -0
- package/dist/lib/state/state.d.ts.map +1 -0
- package/dist/lib/state/state.js +115 -0
- package/dist/lib/state/state.js.map +1 -0
- package/dist/lib/state/tool-cache.d.ts +13 -0
- package/dist/lib/state/tool-cache.d.ts.map +1 -0
- package/dist/lib/state/tool-cache.js +77 -0
- package/dist/lib/state/tool-cache.js.map +1 -0
- package/dist/lib/state/types.d.ts +33 -0
- package/dist/lib/state/types.d.ts.map +1 -0
- package/dist/lib/state/types.js +2 -0
- package/dist/lib/state/types.js.map +1 -0
- package/dist/lib/state/utils.d.ts +2 -0
- package/dist/lib/state/utils.d.ts.map +1 -0
- package/dist/lib/state/utils.js +10 -0
- package/dist/lib/state/utils.js.map +1 -0
- package/dist/lib/strategies/deduplication.d.ts +10 -0
- package/dist/lib/strategies/deduplication.d.ts.map +1 -0
- package/dist/lib/strategies/deduplication.js +94 -0
- package/dist/lib/strategies/deduplication.js.map +1 -0
- package/dist/lib/strategies/index.d.ts +7 -0
- package/dist/lib/strategies/index.d.ts.map +1 -0
- package/dist/lib/strategies/index.js +7 -0
- package/dist/lib/strategies/index.js.map +1 -0
- package/dist/lib/strategies/placeholder-compression.d.ts +5 -0
- package/dist/lib/strategies/placeholder-compression.d.ts.map +1 -0
- package/dist/lib/strategies/placeholder-compression.js +148 -0
- package/dist/lib/strategies/placeholder-compression.js.map +1 -0
- package/dist/lib/strategies/prune-thinking.d.ts +15 -0
- package/dist/lib/strategies/prune-thinking.d.ts.map +1 -0
- package/dist/lib/strategies/prune-thinking.js +79 -0
- package/dist/lib/strategies/prune-thinking.js.map +1 -0
- package/dist/lib/strategies/purge-errors.d.ts +13 -0
- package/dist/lib/strategies/purge-errors.d.ts.map +1 -0
- package/dist/lib/strategies/purge-errors.js +59 -0
- package/dist/lib/strategies/purge-errors.js.map +1 -0
- package/dist/lib/strategies/supersede-writes.d.ts +13 -0
- package/dist/lib/strategies/supersede-writes.d.ts.map +1 -0
- package/dist/lib/strategies/supersede-writes.js +84 -0
- package/dist/lib/strategies/supersede-writes.js.map +1 -0
- package/dist/lib/strategies/tools.d.ts +14 -0
- package/dist/lib/strategies/tools.d.ts.map +1 -0
- package/dist/lib/strategies/tools.js +135 -0
- package/dist/lib/strategies/tools.js.map +1 -0
- package/dist/lib/strategies/utils.d.ts +11 -0
- package/dist/lib/strategies/utils.d.ts.map +1 -0
- package/dist/lib/strategies/utils.js +75 -0
- package/dist/lib/strategies/utils.js.map +1 -0
- package/dist/lib/ui/notification.d.ts +9 -0
- package/dist/lib/ui/notification.d.ts.map +1 -0
- package/dist/lib/ui/notification.js +77 -0
- package/dist/lib/ui/notification.js.map +1 -0
- package/dist/lib/ui/utils.d.ts +10 -0
- package/dist/lib/ui/utils.d.ts.map +1 -0
- package/dist/lib/ui/utils.js +87 -0
- package/dist/lib/ui/utils.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isMessageCompacted } from "../shared-utils";
|
|
2
|
+
const PRUNED_TOOL_OUTPUT_REPLACEMENT = "[Output removed to save context - information superseded or no longer needed]";
|
|
3
|
+
const PRUNED_TOOL_ERROR_INPUT_REPLACEMENT = "[input removed due to failed tool call]";
|
|
4
|
+
const PRUNED_QUESTION_INPUT_REPLACEMENT = "[questions removed - see output for user's answers]";
|
|
5
|
+
export const prune = (state, logger, config, messages) => {
|
|
6
|
+
pruneToolOutputs(state, logger, messages);
|
|
7
|
+
pruneToolInputs(state, logger, messages);
|
|
8
|
+
pruneToolErrors(state, logger, messages);
|
|
9
|
+
};
|
|
10
|
+
const pruneToolOutputs = (state, logger, messages) => {
|
|
11
|
+
for (const msg of messages) {
|
|
12
|
+
if (isMessageCompacted(state, msg)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const parts = Array.isArray(msg.parts) ? msg.parts : [];
|
|
16
|
+
for (const part of parts) {
|
|
17
|
+
if (part.type !== "tool") {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (!state.prune.toolIds.includes(part.callID)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (part.state.status !== "completed") {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (part.tool === "question") {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
part.state.output = PRUNED_TOOL_OUTPUT_REPLACEMENT;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const pruneToolInputs = (state, logger, messages) => {
|
|
34
|
+
for (const msg of messages) {
|
|
35
|
+
if (isMessageCompacted(state, msg)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const parts = Array.isArray(msg.parts) ? msg.parts : [];
|
|
39
|
+
for (const part of parts) {
|
|
40
|
+
if (part.type !== "tool") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!state.prune.toolIds.includes(part.callID)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (part.state.status !== "completed") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (part.tool !== "question") {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (part.state.input?.questions !== undefined) {
|
|
53
|
+
part.state.input.questions = PRUNED_QUESTION_INPUT_REPLACEMENT;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const pruneToolErrors = (state, logger, messages) => {
|
|
59
|
+
for (const msg of messages) {
|
|
60
|
+
if (isMessageCompacted(state, msg)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const parts = Array.isArray(msg.parts) ? msg.parts : [];
|
|
64
|
+
for (const part of parts) {
|
|
65
|
+
if (part.type !== "tool") {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!state.prune.toolIds.includes(part.callID)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (part.state.status !== "error") {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// Prune all string inputs for errored tools
|
|
75
|
+
const input = part.state.input;
|
|
76
|
+
if (input && typeof input === "object") {
|
|
77
|
+
for (const key of Object.keys(input)) {
|
|
78
|
+
if (typeof input[key] === "string") {
|
|
79
|
+
input[key] = PRUNED_TOOL_ERROR_INPUT_REPLACEMENT;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=prune.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MA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jC,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Logger } from "../logger";
|
|
2
|
+
import type { SessionState, WithParts } from "../state";
|
|
3
|
+
export declare const isDeepSeekOrKimi: (providerID: string, modelID: string) => boolean;
|
|
4
|
+
export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
|
|
5
|
+
export declare const createSyntheticAssistantMessage: (baseMessage: WithParts, content: string, variant?: string) => WithParts;
|
|
6
|
+
export declare const createSyntheticToolPart: (baseMessage: WithParts, content: string) => {
|
|
7
|
+
id: string;
|
|
8
|
+
sessionID: string;
|
|
9
|
+
messageID: string;
|
|
10
|
+
type: "tool";
|
|
11
|
+
callID: string;
|
|
12
|
+
tool: string;
|
|
13
|
+
state: {
|
|
14
|
+
status: "completed";
|
|
15
|
+
input: {};
|
|
16
|
+
output: string;
|
|
17
|
+
title: string;
|
|
18
|
+
metadata: {};
|
|
19
|
+
time: {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Extracts a human-readable key from tool metadata for display purposes.
|
|
27
|
+
*/
|
|
28
|
+
export declare const extractParameterKey: (tool: string, parameters: any) => string;
|
|
29
|
+
export declare function buildToolIdList(state: SessionState, messages: WithParts[], logger: Logger): string[];
|
|
30
|
+
export declare const isIgnoredUserMessage: (message: WithParts) => boolean;
|
|
31
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +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;AAOvD,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"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { isMessageCompacted } from "../shared-utils";
|
|
2
|
+
const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
|
|
3
|
+
const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
|
|
4
|
+
const SYNTHETIC_CALL_ID = "call_01234567890123456789012345";
|
|
5
|
+
export const isDeepSeekOrKimi = (providerID, modelID) => {
|
|
6
|
+
const lowerProviderID = providerID.toLowerCase();
|
|
7
|
+
const lowerModelID = modelID.toLowerCase();
|
|
8
|
+
return (lowerProviderID.includes("deepseek") ||
|
|
9
|
+
lowerProviderID.includes("kimi") ||
|
|
10
|
+
lowerModelID.includes("deepseek") ||
|
|
11
|
+
lowerModelID.includes("kimi"));
|
|
12
|
+
};
|
|
13
|
+
export const createSyntheticUserMessage = (baseMessage, content, variant) => {
|
|
14
|
+
const userInfo = baseMessage.info;
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
return {
|
|
17
|
+
info: {
|
|
18
|
+
id: SYNTHETIC_MESSAGE_ID,
|
|
19
|
+
sessionID: userInfo.sessionID,
|
|
20
|
+
role: "user",
|
|
21
|
+
agent: userInfo.agent || "code",
|
|
22
|
+
model: userInfo.model,
|
|
23
|
+
time: { created: now },
|
|
24
|
+
...(variant !== undefined && { variant }),
|
|
25
|
+
},
|
|
26
|
+
parts: [
|
|
27
|
+
{
|
|
28
|
+
id: SYNTHETIC_PART_ID,
|
|
29
|
+
sessionID: userInfo.sessionID,
|
|
30
|
+
messageID: SYNTHETIC_MESSAGE_ID,
|
|
31
|
+
type: "text",
|
|
32
|
+
text: content,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export const createSyntheticAssistantMessage = (baseMessage, content, variant) => {
|
|
38
|
+
const userInfo = baseMessage.info;
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
return {
|
|
41
|
+
info: {
|
|
42
|
+
id: SYNTHETIC_MESSAGE_ID,
|
|
43
|
+
sessionID: userInfo.sessionID,
|
|
44
|
+
role: "assistant",
|
|
45
|
+
agent: userInfo.agent || "code",
|
|
46
|
+
parentID: userInfo.id,
|
|
47
|
+
modelID: userInfo.model.modelID,
|
|
48
|
+
providerID: userInfo.model.providerID,
|
|
49
|
+
mode: "default",
|
|
50
|
+
path: {
|
|
51
|
+
cwd: "/",
|
|
52
|
+
root: "/",
|
|
53
|
+
},
|
|
54
|
+
time: { created: now, completed: now },
|
|
55
|
+
cost: 0,
|
|
56
|
+
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
57
|
+
...(variant !== undefined && { variant }),
|
|
58
|
+
},
|
|
59
|
+
parts: [
|
|
60
|
+
{
|
|
61
|
+
id: SYNTHETIC_PART_ID,
|
|
62
|
+
sessionID: userInfo.sessionID,
|
|
63
|
+
messageID: SYNTHETIC_MESSAGE_ID,
|
|
64
|
+
type: "text",
|
|
65
|
+
text: content,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export const createSyntheticToolPart = (baseMessage, content) => {
|
|
71
|
+
const userInfo = baseMessage.info;
|
|
72
|
+
const now = Date.now();
|
|
73
|
+
return {
|
|
74
|
+
id: SYNTHETIC_PART_ID,
|
|
75
|
+
sessionID: userInfo.sessionID,
|
|
76
|
+
messageID: baseMessage.info.id,
|
|
77
|
+
type: "tool",
|
|
78
|
+
callID: SYNTHETIC_CALL_ID,
|
|
79
|
+
tool: "context_info",
|
|
80
|
+
state: {
|
|
81
|
+
status: "completed",
|
|
82
|
+
input: {},
|
|
83
|
+
output: content,
|
|
84
|
+
title: "Context Info",
|
|
85
|
+
metadata: {},
|
|
86
|
+
time: { start: now, end: now },
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Extracts a human-readable key from tool metadata for display purposes.
|
|
92
|
+
*/
|
|
93
|
+
export const extractParameterKey = (tool, parameters) => {
|
|
94
|
+
if (!parameters)
|
|
95
|
+
return "";
|
|
96
|
+
if (tool === "read" && parameters.filePath) {
|
|
97
|
+
const offset = parameters.offset;
|
|
98
|
+
const limit = parameters.limit;
|
|
99
|
+
if (offset !== undefined && limit !== undefined) {
|
|
100
|
+
return `${parameters.filePath} (lines ${offset}-${offset + limit})`;
|
|
101
|
+
}
|
|
102
|
+
if (offset !== undefined) {
|
|
103
|
+
return `${parameters.filePath} (lines ${offset}+)`;
|
|
104
|
+
}
|
|
105
|
+
if (limit !== undefined) {
|
|
106
|
+
return `${parameters.filePath} (lines 0-${limit})`;
|
|
107
|
+
}
|
|
108
|
+
return parameters.filePath;
|
|
109
|
+
}
|
|
110
|
+
if (tool === "write" && parameters.filePath) {
|
|
111
|
+
return parameters.filePath;
|
|
112
|
+
}
|
|
113
|
+
if (tool === "edit" && parameters.filePath) {
|
|
114
|
+
return parameters.filePath;
|
|
115
|
+
}
|
|
116
|
+
if (tool === "list") {
|
|
117
|
+
return parameters.path || "(current directory)";
|
|
118
|
+
}
|
|
119
|
+
if (tool === "glob") {
|
|
120
|
+
if (parameters.pattern) {
|
|
121
|
+
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
122
|
+
return `"${parameters.pattern}"${pathInfo}`;
|
|
123
|
+
}
|
|
124
|
+
return "(unknown pattern)";
|
|
125
|
+
}
|
|
126
|
+
if (tool === "grep") {
|
|
127
|
+
if (parameters.pattern) {
|
|
128
|
+
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
129
|
+
return `"${parameters.pattern}"${pathInfo}`;
|
|
130
|
+
}
|
|
131
|
+
return "(unknown pattern)";
|
|
132
|
+
}
|
|
133
|
+
if (tool === "bash") {
|
|
134
|
+
if (parameters.description)
|
|
135
|
+
return parameters.description;
|
|
136
|
+
if (parameters.command) {
|
|
137
|
+
return parameters.command.length > 50
|
|
138
|
+
? parameters.command.substring(0, 50) + "..."
|
|
139
|
+
: parameters.command;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (tool === "webfetch" && parameters.url) {
|
|
143
|
+
return parameters.url;
|
|
144
|
+
}
|
|
145
|
+
if (tool === "websearch" && parameters.query) {
|
|
146
|
+
return `"${parameters.query}"`;
|
|
147
|
+
}
|
|
148
|
+
if (tool === "codesearch" && parameters.query) {
|
|
149
|
+
return `"${parameters.query}"`;
|
|
150
|
+
}
|
|
151
|
+
if (tool === "todowrite") {
|
|
152
|
+
return `${parameters.todos?.length || 0} todos`;
|
|
153
|
+
}
|
|
154
|
+
if (tool === "todoread") {
|
|
155
|
+
return "read todo list";
|
|
156
|
+
}
|
|
157
|
+
if (tool === "task" && parameters.description) {
|
|
158
|
+
return parameters.description;
|
|
159
|
+
}
|
|
160
|
+
if (tool === "skill" && parameters.name) {
|
|
161
|
+
return parameters.name;
|
|
162
|
+
}
|
|
163
|
+
if (tool === "lsp") {
|
|
164
|
+
const op = parameters.operation || "lsp";
|
|
165
|
+
const path = parameters.filePath || "";
|
|
166
|
+
const line = parameters.line;
|
|
167
|
+
const char = parameters.character;
|
|
168
|
+
if (path && line !== undefined && char !== undefined) {
|
|
169
|
+
return `${op} ${path}:${line}:${char}`;
|
|
170
|
+
}
|
|
171
|
+
if (path) {
|
|
172
|
+
return `${op} ${path}`;
|
|
173
|
+
}
|
|
174
|
+
return op;
|
|
175
|
+
}
|
|
176
|
+
if (tool === "question") {
|
|
177
|
+
const questions = parameters.questions;
|
|
178
|
+
if (Array.isArray(questions) && questions.length > 0) {
|
|
179
|
+
const headers = questions
|
|
180
|
+
.map((q) => q.header || "")
|
|
181
|
+
.filter(Boolean)
|
|
182
|
+
.slice(0, 3);
|
|
183
|
+
const count = questions.length;
|
|
184
|
+
const plural = count > 1 ? "s" : "";
|
|
185
|
+
if (headers.length > 0) {
|
|
186
|
+
const suffix = count > 3 ? ` (+${count - 3} more)` : "";
|
|
187
|
+
return `${count} question${plural}: ${headers.join(", ")}${suffix}`;
|
|
188
|
+
}
|
|
189
|
+
return `${count} question${plural}`;
|
|
190
|
+
}
|
|
191
|
+
return "question";
|
|
192
|
+
}
|
|
193
|
+
const paramStr = JSON.stringify(parameters);
|
|
194
|
+
if (paramStr === "{}" || paramStr === "[]" || paramStr === "null") {
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
return paramStr.substring(0, 50);
|
|
198
|
+
};
|
|
199
|
+
export function buildToolIdList(state, messages, logger) {
|
|
200
|
+
const toolIds = [];
|
|
201
|
+
for (const msg of messages) {
|
|
202
|
+
if (isMessageCompacted(state, msg)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const parts = Array.isArray(msg.parts) ? msg.parts : [];
|
|
206
|
+
if (parts.length > 0) {
|
|
207
|
+
for (const part of parts) {
|
|
208
|
+
if (part.type === "tool" && part.callID && part.tool) {
|
|
209
|
+
toolIds.push(part.callID);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return toolIds;
|
|
215
|
+
}
|
|
216
|
+
export const isIgnoredUserMessage = (message) => {
|
|
217
|
+
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
218
|
+
if (parts.length === 0) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
for (const part of parts) {
|
|
222
|
+
if (!part.ignored) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","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AC,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"}
|
|
@@ -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:** 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## 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,g1DAuCR,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DISCARD_TOOL_SPEC = `Discards tool outputs from context to manage conversation size and reduce noise.
|
|
2
|
+
|
|
3
|
+
## IMPORTANT: The Prunable List
|
|
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
|
+
|
|
6
|
+
## When to Use This Tool
|
|
7
|
+
|
|
8
|
+
Use \`discard\` for removing tool content that is no longer needed
|
|
9
|
+
|
|
10
|
+
- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
|
|
11
|
+
- **Task Completion:** Work is complete and there's no valuable information worth preserving.
|
|
12
|
+
|
|
13
|
+
## When NOT to Use This Tool
|
|
14
|
+
|
|
15
|
+
- **If the output contains useful information:** Keep it in context rather than discarding.
|
|
16
|
+
- **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.
|
|
17
|
+
|
|
18
|
+
## Best Practices
|
|
19
|
+
- **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
|
+
- **Think ahead:** Before discarding, ask: "Will I need this output for an upcoming task?" If yes, keep it.
|
|
21
|
+
|
|
22
|
+
## Format
|
|
23
|
+
|
|
24
|
+
- \`ids\`: Array where the first element is the reason, followed by numeric IDs from the \`<prunable-tools>\` list
|
|
25
|
+
|
|
26
|
+
Reasons: \`noise\` | \`completion\`
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
<example_noise>
|
|
31
|
+
Assistant: [Reads 'wrong_file.ts']
|
|
32
|
+
This file isn't relevant to the auth system. I'll remove it to clear the context.
|
|
33
|
+
[Uses discard with ids: ["noise", "5"]]
|
|
34
|
+
</example_noise>
|
|
35
|
+
|
|
36
|
+
<example_completion>
|
|
37
|
+
Assistant: [Runs tests, they pass]
|
|
38
|
+
The tests passed and I don't need to preserve any details. I'll clean up now.
|
|
39
|
+
[Uses discard with ids: ["completion", "20", "21"]]
|
|
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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const EXTRACT_TOOL_SPEC = `Extracts key findings from tool outputs into distilled knowledge, then removes the raw outputs from context.
|
|
2
|
+
|
|
3
|
+
## IMPORTANT: The Prunable List
|
|
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
|
+
|
|
6
|
+
## When to Use This Tool
|
|
7
|
+
|
|
8
|
+
Use \`extract\` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:
|
|
9
|
+
|
|
10
|
+
- **Task Completion:** You completed a unit of work and want to preserve key findings.
|
|
11
|
+
- **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.
|
|
12
|
+
|
|
13
|
+
## When NOT to Use This Tool
|
|
14
|
+
|
|
15
|
+
- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.
|
|
16
|
+
- **If uncertain:** Prefer keeping over re-fetching.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Best Practices
|
|
20
|
+
- **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
|
+
- **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
|
+
## Format
|
|
24
|
+
|
|
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
|
+
|
|
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
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
<example_extraction>
|
|
33
|
+
Assistant: [Reads auth service and user types]
|
|
34
|
+
I'll preserve the key details before extracting.
|
|
35
|
+
[Uses extract with:
|
|
36
|
+
ids: ["10", "11"],
|
|
37
|
+
distillation: [
|
|
38
|
+
"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds. Tokens must be 128+ chars.",
|
|
39
|
+
"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }"
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
</example_extraction>
|
|
43
|
+
|
|
44
|
+
<example_keep>
|
|
45
|
+
Assistant: [Reads 'auth.ts' to understand the login flow]
|
|
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>`;
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
};
|
|
22
|
+
export function loadPrompt(name, vars) {
|
|
23
|
+
let content = PROMPTS[name];
|
|
24
|
+
if (!content) {
|
|
25
|
+
throw new Error(`Prompt not found: ${name}`);
|
|
26
|
+
}
|
|
27
|
+
if (vars) {
|
|
28
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
29
|
+
content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return content;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const NUDGE_BOTH = `<instruction name=context_management_required>
|
|
2
|
+
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
|
+
|
|
4
|
+
**Immediate Actions Required:**
|
|
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
|
+
|
|
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>`;
|
|
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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const NUDGE_DISCARD = `<instruction name=context_management_required>
|
|
2
|
+
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
|
+
|
|
4
|
+
**Immediate Actions Required:**
|
|
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
|
+
|
|
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>`;
|
|
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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const NUDGE_EXTRACT = `<instruction name=context_management_required>
|
|
2
|
+
**CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
3
|
+
|
|
4
|
+
**Immediate Actions Required:**
|
|
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 \`extract\` tool with high-fidelity distillation to preserve the insights and remove the raw entry.
|
|
7
|
+
|
|
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>`;
|
|
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. The environment calls the `context_info` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to prune.\n\nIMPORTANT: The `context_info` tool is only available to the environment - you do not have access to it and must not attempt to call it.\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 turn, the environment calls the `context_info` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.\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,0zHA2DZ,CAAA"}
|