@tarquinen/opencode-dcp 2.2.7-beta0 → 2.2.8-beta0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/decompress.d.ts +12 -0
- package/dist/lib/commands/decompress.d.ts.map +1 -0
- package/dist/lib/commands/decompress.js +159 -0
- package/dist/lib/commands/decompress.js.map +1 -0
- package/dist/lib/commands/help.d.ts.map +1 -1
- package/dist/lib/commands/help.js +4 -0
- package/dist/lib/commands/help.js.map +1 -1
- package/dist/lib/commands/manual.d.ts.map +1 -1
- package/dist/lib/commands/manual.js +5 -3
- package/dist/lib/commands/manual.js.map +1 -1
- package/dist/lib/commands/recompress.d.ts +12 -0
- package/dist/lib/commands/recompress.d.ts.map +1 -0
- package/dist/lib/commands/recompress.js +137 -0
- package/dist/lib/commands/recompress.js.map +1 -0
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +13 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts +3 -2
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +23 -4
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/messages/inject/inject.d.ts +2 -1
- package/dist/lib/messages/inject/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject/inject.js +2 -2
- package/dist/lib/messages/inject/inject.js.map +1 -1
- package/dist/lib/messages/inject/utils.d.ts +3 -1
- package/dist/lib/messages/inject/utils.d.ts.map +1 -1
- package/dist/lib/messages/inject/utils.js +8 -14
- package/dist/lib/messages/inject/utils.js.map +1 -1
- package/dist/lib/messages/sync.d.ts.map +1 -1
- package/dist/lib/messages/sync.js +8 -0
- package/dist/lib/messages/sync.js.map +1 -1
- package/dist/lib/prompts/context-limit-nudge.d.ts +2 -0
- package/dist/lib/prompts/context-limit-nudge.d.ts.map +1 -0
- package/dist/lib/prompts/context-limit-nudge.js +25 -0
- package/dist/lib/prompts/context-limit-nudge.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +2 -1
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +24 -12
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/internal-overlays.d.ts +3 -0
- package/dist/lib/prompts/internal-overlays.d.ts.map +1 -0
- package/dist/lib/prompts/internal-overlays.js +17 -0
- package/dist/lib/prompts/internal-overlays.js.map +1 -0
- package/dist/lib/prompts/store.d.ts +25 -0
- package/dist/lib/prompts/store.d.ts.map +1 -0
- package/dist/lib/prompts/store.js +377 -0
- package/dist/lib/prompts/store.js.map +1 -0
- package/dist/lib/prompts/{_codegen/system.generated.d.ts → system.d.ts} +2 -2
- package/dist/lib/prompts/system.d.ts.map +1 -0
- package/dist/lib/prompts/{_codegen/system.generated.js → system.js} +1 -20
- package/dist/lib/prompts/system.js.map +1 -0
- package/dist/lib/state/types.d.ts +2 -0
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/state/utils.d.ts.map +1 -1
- package/dist/lib/state/utils.js +5 -0
- package/dist/lib/state/utils.js.map +1 -1
- package/dist/lib/tools/compress.d.ts.map +1 -1
- package/dist/lib/tools/compress.js +10 -7
- package/dist/lib/tools/compress.js.map +1 -1
- package/dist/lib/tools/types.d.ts +2 -0
- package/dist/lib/tools/types.d.ts.map +1 -1
- package/dist/lib/tools/{compress-utils.d.ts → utils.d.ts} +5 -2
- package/dist/lib/tools/utils.d.ts.map +1 -0
- package/dist/lib/tools/{compress-utils.js → utils.js} +61 -6
- package/dist/lib/tools/utils.js.map +1 -0
- package/dist/lib/ui/notification.d.ts +1 -1
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +19 -7
- package/dist/lib/ui/notification.js.map +1 -1
- package/dist/lib/ui/utils.d.ts +1 -1
- package/dist/lib/ui/utils.d.ts.map +1 -1
- package/dist/lib/ui/utils.js +17 -7
- package/dist/lib/ui/utils.js.map +1 -1
- package/package.json +2 -4
- package/dist/lib/prompts/_codegen/system.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/system.generated.js.map +0 -1
- package/dist/lib/prompts/nudge.d.ts +0 -2
- package/dist/lib/prompts/nudge.d.ts.map +0 -1
- package/dist/lib/prompts/nudge.js +0 -25
- package/dist/lib/prompts/nudge.js.map +0 -1
- package/dist/lib/tools/compress-utils.d.ts.map +0 -1
- package/dist/lib/tools/compress-utils.js.map +0 -1
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const regex = new RegExp(`<${tagName}>[\\s\\S]*?</${tagName}>`, "g");
|
|
4
|
-
return content.replace(regex, "");
|
|
1
|
+
function stripLegacyInlineComments(content) {
|
|
2
|
+
return content.replace(/^[ \t]*\/\/.*?\/\/[ \t]*$/gm, "");
|
|
5
3
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!manual) {
|
|
10
|
-
result = stripConditionalTag(result, "manual");
|
|
4
|
+
function injectIntoSystemReminder(systemPrompt, overlays) {
|
|
5
|
+
if (overlays.length === 0) {
|
|
6
|
+
return systemPrompt;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const closeTag = "</system-reminder>";
|
|
9
|
+
const closeTagIndex = systemPrompt.lastIndexOf(closeTag);
|
|
10
|
+
if (closeTagIndex === -1) {
|
|
11
|
+
return [systemPrompt, ...overlays].join("\n\n");
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
const beforeClose = systemPrompt.slice(0, closeTagIndex).trimEnd();
|
|
14
|
+
const afterClose = systemPrompt.slice(closeTagIndex);
|
|
15
|
+
return `${beforeClose}\n\n${overlays.join("\n\n")}\n\n${afterClose}`;
|
|
16
|
+
}
|
|
17
|
+
export function renderSystemPrompt(prompts, manual, subagent) {
|
|
18
|
+
const overlays = [];
|
|
19
|
+
if (manual) {
|
|
20
|
+
overlays.push(prompts.manualOverlay.trim());
|
|
21
|
+
}
|
|
22
|
+
if (subagent) {
|
|
23
|
+
overlays.push(prompts.subagentOverlay.trim());
|
|
24
|
+
}
|
|
25
|
+
const strippedSystem = stripLegacyInlineComments(prompts.system).trim();
|
|
26
|
+
const withOverlays = injectIntoSystemReminder(strippedSystem, overlays);
|
|
27
|
+
return withOverlays.replace(/\n([ \t]*\n)+/g, "\n\n").trim();
|
|
16
28
|
}
|
|
17
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAEA,SAAS,yBAAyB,CAAC,OAAe;IAC9C,OAAO,OAAO,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAA;AAC7D,CAAC;AAED,SAAS,wBAAwB,CAAC,YAAoB,EAAE,QAAkB;IACtE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,YAAY,CAAA;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,oBAAoB,CAAA;IACrC,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;IACxD,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,YAAY,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,OAAO,EAAE,CAAA;IAClE,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACpD,OAAO,GAAG,WAAW,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,UAAU,EAAE,CAAA;AACxE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAC9B,OAAuB,EACvB,MAAgB,EAChB,QAAkB;IAElB,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,IAAI,MAAM,EAAE,CAAC;QACT,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;IAC/C,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACX,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;IAED,MAAM,cAAc,GAAG,yBAAyB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IACvE,MAAM,YAAY,GAAG,wBAAwB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;IACvE,OAAO,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const MANUAL_MODE_SYSTEM_OVERLAY = "<instruction name=manual_mode policy_level=critical>\nManual mode is enabled. Do NOT use compress unless the user has explicitly triggered it through a manual marker.\n\nOnly use the compress tool after seeing `<compress triggered manually>` in the current user instruction context.\n\nAfter completing a manually triggered context-management action, STOP IMMEDIATELY. Do NOT continue with any task execution. End your response right after the tool use completes and wait for the next user input.\n</instruction>\n";
|
|
2
|
+
export declare const SUBAGENT_SYSTEM_OVERLAY = "<instruction name=subagent_prompt_safety policy_level=critical>\nYou are operating in a subagent environment.\n\nThe initial subagent instruction is imperative and must be followed exactly.\nIt is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.\nAll subsequent messages in the session will have IDs.\n</instruction>\n";
|
|
3
|
+
//# sourceMappingURL=internal-overlays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-overlays.d.ts","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,ugBAOtC,CAAA;AAED,eAAO,MAAM,uBAAuB,gYAOnC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const MANUAL_MODE_SYSTEM_OVERLAY = `<instruction name=manual_mode policy_level=critical>
|
|
2
|
+
Manual mode is enabled. Do NOT use compress unless the user has explicitly triggered it through a manual marker.
|
|
3
|
+
|
|
4
|
+
Only use the compress tool after seeing \`<compress triggered manually>\` in the current user instruction context.
|
|
5
|
+
|
|
6
|
+
After completing a manually triggered context-management action, STOP IMMEDIATELY. Do NOT continue with any task execution. End your response right after the tool use completes and wait for the next user input.
|
|
7
|
+
</instruction>
|
|
8
|
+
`;
|
|
9
|
+
export const SUBAGENT_SYSTEM_OVERLAY = `<instruction name=subagent_prompt_safety policy_level=critical>
|
|
10
|
+
You are operating in a subagent environment.
|
|
11
|
+
|
|
12
|
+
The initial subagent instruction is imperative and must be followed exactly.
|
|
13
|
+
It is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.
|
|
14
|
+
All subsequent messages in the session will have IDs.
|
|
15
|
+
</instruction>
|
|
16
|
+
`;
|
|
17
|
+
//# sourceMappingURL=internal-overlays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-overlays.js","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;CAOzC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;CAOtC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Logger } from "../logger";
|
|
2
|
+
export type PromptKey = "system" | "compress" | "context-limit-nudge" | "user-turn-nudge" | "assistant-turn-nudge" | "iteration-nudge";
|
|
3
|
+
export interface RuntimePrompts {
|
|
4
|
+
system: string;
|
|
5
|
+
compress: string;
|
|
6
|
+
contextLimitNudge: string;
|
|
7
|
+
userTurnNudge: string;
|
|
8
|
+
assistantTurnNudge: string;
|
|
9
|
+
iterationNudge: string;
|
|
10
|
+
manualOverlay: string;
|
|
11
|
+
subagentOverlay: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const PROMPT_KEYS: PromptKey[];
|
|
14
|
+
export declare class PromptStore {
|
|
15
|
+
private readonly logger;
|
|
16
|
+
private readonly paths;
|
|
17
|
+
private readonly customPromptsEnabled;
|
|
18
|
+
private runtimePrompts;
|
|
19
|
+
constructor(logger: Logger, workingDirectory: string, customPromptsEnabled?: boolean);
|
|
20
|
+
getRuntimePrompts(): RuntimePrompts;
|
|
21
|
+
reload(): void;
|
|
22
|
+
private getOverrideCandidates;
|
|
23
|
+
private ensureDefaultFiles;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../lib/prompts/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAQvC,MAAM,MAAM,SAAS,GACf,QAAQ,GACR,UAAU,GACV,qBAAqB,GACrB,iBAAiB,GACjB,sBAAsB,GACtB,iBAAiB,CAAA;AA+BvB,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,MAAM,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;CAC1B;AAyDD,eAAO,MAAM,WAAW,EAAE,SAAS,EAOlC,CAAA;AAkOD,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,cAAc,CAAgB;gBAE1B,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,UAAQ;IAYlF,iBAAiB,IAAI,cAAc;IAInC,MAAM,IAAI,IAAI;IAiDd,OAAO,CAAC,qBAAqB;IAsB7B,OAAO,CAAC,kBAAkB;CAkD7B"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from "fs";
|
|
2
|
+
import { join, dirname } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { SYSTEM as SYSTEM_PROMPT } from "./system";
|
|
5
|
+
import { COMPRESS as COMPRESS_PROMPT } from "./compress";
|
|
6
|
+
import { CONTEXT_LIMIT_NUDGE } from "./context-limit-nudge";
|
|
7
|
+
import { USER_TURN_NUDGE, ASSISTANT_TURN_NUDGE } from "./turn-nudge";
|
|
8
|
+
import { ITERATION_NUDGE } from "./iteration-nudge";
|
|
9
|
+
import { MANUAL_MODE_SYSTEM_OVERLAY, SUBAGENT_SYSTEM_OVERLAY } from "./internal-overlays";
|
|
10
|
+
const PROMPT_DEFINITIONS = [
|
|
11
|
+
{
|
|
12
|
+
key: "system",
|
|
13
|
+
fileName: "system.md",
|
|
14
|
+
label: "System",
|
|
15
|
+
description: "Core system-level DCP instruction block",
|
|
16
|
+
usage: "Injected into the model system prompt on every request",
|
|
17
|
+
runtimeField: "system",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "compress",
|
|
21
|
+
fileName: "compress.md",
|
|
22
|
+
label: "Compress",
|
|
23
|
+
description: "compress tool instructions and summary constraints",
|
|
24
|
+
usage: "Registered as the compress tool description",
|
|
25
|
+
runtimeField: "compress",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "context-limit-nudge",
|
|
29
|
+
fileName: "context-limit-nudge.md",
|
|
30
|
+
label: "Context Limit Nudge",
|
|
31
|
+
description: "High-priority nudge when context is over max threshold",
|
|
32
|
+
usage: "Injected when context usage is beyond configured max limits",
|
|
33
|
+
runtimeField: "contextLimitNudge",
|
|
34
|
+
instructionName: "context_buildup_warning",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: "user-turn-nudge",
|
|
38
|
+
fileName: "user-turn-nudge.md",
|
|
39
|
+
label: "User Turn Nudge",
|
|
40
|
+
description: "Strong turn nudge attached to user messages",
|
|
41
|
+
usage: "Used when nudge force is strong",
|
|
42
|
+
runtimeField: "userTurnNudge",
|
|
43
|
+
instructionName: "turn_nudge",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "assistant-turn-nudge",
|
|
47
|
+
fileName: "assistant-turn-nudge.md",
|
|
48
|
+
label: "Assistant Turn Nudge",
|
|
49
|
+
description: "Soft turn nudge attached to assistant messages",
|
|
50
|
+
usage: "Used when nudge force is soft",
|
|
51
|
+
runtimeField: "assistantTurnNudge",
|
|
52
|
+
instructionName: "turn_nudge",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "iteration-nudge",
|
|
56
|
+
fileName: "iteration-nudge.md",
|
|
57
|
+
label: "Iteration Nudge",
|
|
58
|
+
description: "Nudge after many iterations without user input",
|
|
59
|
+
usage: "Injected when iteration threshold is crossed",
|
|
60
|
+
runtimeField: "iterationNudge",
|
|
61
|
+
instructionName: "iteration_nudge",
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
export const PROMPT_KEYS = [
|
|
65
|
+
"system",
|
|
66
|
+
"compress",
|
|
67
|
+
"context-limit-nudge",
|
|
68
|
+
"user-turn-nudge",
|
|
69
|
+
"assistant-turn-nudge",
|
|
70
|
+
"iteration-nudge",
|
|
71
|
+
];
|
|
72
|
+
const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
73
|
+
const LEGACY_INLINE_COMMENT_LINE_REGEX = /^[ \t]*\/\/.*?\/\/[ \t]*$/gm;
|
|
74
|
+
const INSTRUCTION_TAG_REGEX = /^\s*<instruction\b[^>]*>[\s\S]*<\/instruction>\s*$/i;
|
|
75
|
+
const DEFAULTS_README_FILE = "README.md";
|
|
76
|
+
const BUNDLED_EDITABLE_PROMPTS = {
|
|
77
|
+
system: SYSTEM_PROMPT,
|
|
78
|
+
compress: COMPRESS_PROMPT,
|
|
79
|
+
contextLimitNudge: CONTEXT_LIMIT_NUDGE,
|
|
80
|
+
userTurnNudge: USER_TURN_NUDGE,
|
|
81
|
+
assistantTurnNudge: ASSISTANT_TURN_NUDGE,
|
|
82
|
+
iterationNudge: ITERATION_NUDGE,
|
|
83
|
+
};
|
|
84
|
+
const INTERNAL_PROMPT_OVERLAYS = {
|
|
85
|
+
manualOverlay: MANUAL_MODE_SYSTEM_OVERLAY,
|
|
86
|
+
subagentOverlay: SUBAGENT_SYSTEM_OVERLAY,
|
|
87
|
+
};
|
|
88
|
+
function createBundledRuntimePrompts() {
|
|
89
|
+
return {
|
|
90
|
+
system: BUNDLED_EDITABLE_PROMPTS.system,
|
|
91
|
+
compress: BUNDLED_EDITABLE_PROMPTS.compress,
|
|
92
|
+
contextLimitNudge: BUNDLED_EDITABLE_PROMPTS.contextLimitNudge,
|
|
93
|
+
userTurnNudge: BUNDLED_EDITABLE_PROMPTS.userTurnNudge,
|
|
94
|
+
assistantTurnNudge: BUNDLED_EDITABLE_PROMPTS.assistantTurnNudge,
|
|
95
|
+
iterationNudge: BUNDLED_EDITABLE_PROMPTS.iterationNudge,
|
|
96
|
+
manualOverlay: INTERNAL_PROMPT_OVERLAYS.manualOverlay,
|
|
97
|
+
subagentOverlay: INTERNAL_PROMPT_OVERLAYS.subagentOverlay,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function findOpencodeDir(startDir) {
|
|
101
|
+
let current = startDir;
|
|
102
|
+
while (current !== "/") {
|
|
103
|
+
const candidate = join(current, ".opencode");
|
|
104
|
+
if (existsSync(candidate)) {
|
|
105
|
+
try {
|
|
106
|
+
if (statSync(candidate).isDirectory()) {
|
|
107
|
+
return candidate;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// ignore inaccessible entries while walking upward
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const parent = dirname(current);
|
|
115
|
+
if (parent === current) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
current = parent;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function resolvePromptPaths(workingDirectory) {
|
|
123
|
+
const configHome = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
124
|
+
const globalRoot = join(configHome, "opencode", "dcp-prompts");
|
|
125
|
+
const defaultsDir = join(globalRoot, "defaults");
|
|
126
|
+
const globalOverridesDir = join(globalRoot, "overrides");
|
|
127
|
+
const configDirOverridesDir = process.env.OPENCODE_CONFIG_DIR
|
|
128
|
+
? join(process.env.OPENCODE_CONFIG_DIR, "dcp-prompts", "overrides")
|
|
129
|
+
: null;
|
|
130
|
+
const opencodeDir = findOpencodeDir(workingDirectory);
|
|
131
|
+
const projectOverridesDir = opencodeDir ? join(opencodeDir, "dcp-prompts", "overrides") : null;
|
|
132
|
+
return {
|
|
133
|
+
defaultsDir,
|
|
134
|
+
globalOverridesDir,
|
|
135
|
+
configDirOverridesDir,
|
|
136
|
+
projectOverridesDir,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function stripConditionalTag(content, tagName) {
|
|
140
|
+
const regex = new RegExp(`<${tagName}>[\\s\\S]*?<\/${tagName}>`, "gi");
|
|
141
|
+
return content.replace(regex, "");
|
|
142
|
+
}
|
|
143
|
+
function hasTagPairMismatch(content, tagName) {
|
|
144
|
+
const openRegex = new RegExp(`<${tagName}\\b[^>]*>`, "i");
|
|
145
|
+
const closeRegex = new RegExp(`<\/${tagName}>`, "i");
|
|
146
|
+
return openRegex.test(content) !== closeRegex.test(content);
|
|
147
|
+
}
|
|
148
|
+
function unwrapTagIfWrapped(content, tagName) {
|
|
149
|
+
const regex = new RegExp(`^\\s*<${tagName}\\b[^>]*>\\s*([\\s\\S]*?)\\s*<\\/${tagName}>\\s*$`, "i");
|
|
150
|
+
const match = content.match(regex);
|
|
151
|
+
if (!match) {
|
|
152
|
+
return content.trim();
|
|
153
|
+
}
|
|
154
|
+
return match[1].trim();
|
|
155
|
+
}
|
|
156
|
+
function unwrapInstructionIfWrapped(content) {
|
|
157
|
+
const trimmed = content.trim();
|
|
158
|
+
if (!INSTRUCTION_TAG_REGEX.test(trimmed)) {
|
|
159
|
+
return trimmed;
|
|
160
|
+
}
|
|
161
|
+
return trimmed
|
|
162
|
+
.replace(/^\s*<instruction\b[^>]*>\s*/i, "")
|
|
163
|
+
.replace(/\s*<\/instruction>\s*$/i, "")
|
|
164
|
+
.trim();
|
|
165
|
+
}
|
|
166
|
+
function stripPromptComments(content) {
|
|
167
|
+
return content
|
|
168
|
+
.replace(/^\uFEFF/, "")
|
|
169
|
+
.replace(/\r\n?/g, "\n")
|
|
170
|
+
.replace(HTML_COMMENT_REGEX, "")
|
|
171
|
+
.replace(LEGACY_INLINE_COMMENT_LINE_REGEX, "");
|
|
172
|
+
}
|
|
173
|
+
function toEditablePromptText(definition, rawContent) {
|
|
174
|
+
let normalized = stripPromptComments(rawContent).trim();
|
|
175
|
+
if (!normalized) {
|
|
176
|
+
return "";
|
|
177
|
+
}
|
|
178
|
+
if (definition.key === "system") {
|
|
179
|
+
normalized = stripConditionalTag(normalized, "manual");
|
|
180
|
+
normalized = stripConditionalTag(normalized, "subagent");
|
|
181
|
+
if (hasTagPairMismatch(normalized, "system-reminder")) {
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
normalized = unwrapTagIfWrapped(normalized, "system-reminder");
|
|
185
|
+
if (hasTagPairMismatch(normalized, "instruction")) {
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
normalized = unwrapInstructionIfWrapped(normalized);
|
|
189
|
+
return normalized.trim();
|
|
190
|
+
}
|
|
191
|
+
if (definition.instructionName) {
|
|
192
|
+
if (hasTagPairMismatch(normalized, "instruction")) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
normalized = unwrapInstructionIfWrapped(normalized);
|
|
196
|
+
}
|
|
197
|
+
return normalized.trim();
|
|
198
|
+
}
|
|
199
|
+
function wrapRuntimePromptContent(definition, editableText) {
|
|
200
|
+
const trimmed = editableText.trim();
|
|
201
|
+
if (!trimmed) {
|
|
202
|
+
return "";
|
|
203
|
+
}
|
|
204
|
+
if (definition.key === "system") {
|
|
205
|
+
return `<system-reminder>\n<instruction name=compress_tool attention_level=high>\n${trimmed}\n</instruction>\n</system-reminder>`;
|
|
206
|
+
}
|
|
207
|
+
if (definition.instructionName) {
|
|
208
|
+
return `<instruction name=${definition.instructionName}>\n${trimmed}\n</instruction>`;
|
|
209
|
+
}
|
|
210
|
+
return trimmed;
|
|
211
|
+
}
|
|
212
|
+
function buildDefaultPromptFileContent(bundledEditableText) {
|
|
213
|
+
return `${bundledEditableText.trim()}\n`;
|
|
214
|
+
}
|
|
215
|
+
function buildDefaultsReadmeContent() {
|
|
216
|
+
const lines = [];
|
|
217
|
+
lines.push("# DCP Prompt Defaults");
|
|
218
|
+
lines.push("");
|
|
219
|
+
lines.push("This directory stores the DCP prompts.");
|
|
220
|
+
lines.push("Each prompt file here should contain plain text only (no XML wrappers).");
|
|
221
|
+
lines.push("");
|
|
222
|
+
lines.push("## Creating Overrides");
|
|
223
|
+
lines.push("");
|
|
224
|
+
lines.push("1. Copy a prompt file from this directory into an overrides directory using the same filename.");
|
|
225
|
+
lines.push("2. Edit the copied file using plain text.");
|
|
226
|
+
lines.push("3. Restart OpenCode.");
|
|
227
|
+
lines.push("");
|
|
228
|
+
lines.push("To reset an override, delete the matching file from your overrides directory.");
|
|
229
|
+
lines.push("");
|
|
230
|
+
lines.push("Do not edit the default prompt files directly, they are just for reference, only files in the overrides directory are used.");
|
|
231
|
+
lines.push("");
|
|
232
|
+
lines.push("Override precedence (highest first):");
|
|
233
|
+
lines.push("1. `.opencode/dcp-prompts/overrides/` (project)");
|
|
234
|
+
lines.push("2. `$OPENCODE_CONFIG_DIR/dcp-prompts/overrides/` (config dir)");
|
|
235
|
+
lines.push("3. `~/.config/opencode/dcp-prompts/overrides/` (global)");
|
|
236
|
+
lines.push("");
|
|
237
|
+
lines.push("## Prompt Files");
|
|
238
|
+
lines.push("");
|
|
239
|
+
for (const definition of PROMPT_DEFINITIONS) {
|
|
240
|
+
lines.push(`- \`${definition.fileName}\``);
|
|
241
|
+
lines.push(` - Purpose: ${definition.description}.`);
|
|
242
|
+
lines.push(` - Runtime use: ${definition.usage}.`);
|
|
243
|
+
}
|
|
244
|
+
return `${lines.join("\n")}\n`;
|
|
245
|
+
}
|
|
246
|
+
function readFileIfExists(filePath) {
|
|
247
|
+
if (!existsSync(filePath)) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
return readFileSync(filePath, "utf-8");
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
export class PromptStore {
|
|
258
|
+
logger;
|
|
259
|
+
paths;
|
|
260
|
+
customPromptsEnabled;
|
|
261
|
+
runtimePrompts;
|
|
262
|
+
constructor(logger, workingDirectory, customPromptsEnabled = false) {
|
|
263
|
+
this.logger = logger;
|
|
264
|
+
this.paths = resolvePromptPaths(workingDirectory);
|
|
265
|
+
this.customPromptsEnabled = customPromptsEnabled;
|
|
266
|
+
this.runtimePrompts = createBundledRuntimePrompts();
|
|
267
|
+
if (this.customPromptsEnabled) {
|
|
268
|
+
this.ensureDefaultFiles();
|
|
269
|
+
}
|
|
270
|
+
this.reload();
|
|
271
|
+
}
|
|
272
|
+
getRuntimePrompts() {
|
|
273
|
+
return { ...this.runtimePrompts };
|
|
274
|
+
}
|
|
275
|
+
reload() {
|
|
276
|
+
const nextPrompts = createBundledRuntimePrompts();
|
|
277
|
+
if (!this.customPromptsEnabled) {
|
|
278
|
+
this.runtimePrompts = nextPrompts;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
for (const definition of PROMPT_DEFINITIONS) {
|
|
282
|
+
const bundledSource = BUNDLED_EDITABLE_PROMPTS[definition.runtimeField];
|
|
283
|
+
const bundledEditable = toEditablePromptText(definition, bundledSource);
|
|
284
|
+
const bundledRuntime = wrapRuntimePromptContent(definition, bundledEditable);
|
|
285
|
+
const fallbackValue = bundledRuntime || bundledSource.trim();
|
|
286
|
+
let effectiveValue = fallbackValue;
|
|
287
|
+
for (const candidate of this.getOverrideCandidates(definition.fileName)) {
|
|
288
|
+
const rawOverride = readFileIfExists(candidate.path);
|
|
289
|
+
if (rawOverride === null) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const editableOverride = toEditablePromptText(definition, rawOverride);
|
|
293
|
+
if (!editableOverride) {
|
|
294
|
+
this.logger.warn("Prompt override is empty or invalid after normalization", {
|
|
295
|
+
key: definition.key,
|
|
296
|
+
path: candidate.path,
|
|
297
|
+
});
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const wrappedOverride = wrapRuntimePromptContent(definition, editableOverride);
|
|
301
|
+
if (!wrappedOverride) {
|
|
302
|
+
this.logger.warn("Prompt override could not be wrapped for runtime", {
|
|
303
|
+
key: definition.key,
|
|
304
|
+
path: candidate.path,
|
|
305
|
+
});
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
effectiveValue = wrappedOverride;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
nextPrompts[definition.runtimeField] = effectiveValue;
|
|
312
|
+
}
|
|
313
|
+
this.runtimePrompts = nextPrompts;
|
|
314
|
+
}
|
|
315
|
+
getOverrideCandidates(fileName) {
|
|
316
|
+
const candidates = [];
|
|
317
|
+
if (this.paths.projectOverridesDir) {
|
|
318
|
+
candidates.push({
|
|
319
|
+
path: join(this.paths.projectOverridesDir, fileName),
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (this.paths.configDirOverridesDir) {
|
|
323
|
+
candidates.push({
|
|
324
|
+
path: join(this.paths.configDirOverridesDir, fileName),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
candidates.push({
|
|
328
|
+
path: join(this.paths.globalOverridesDir, fileName),
|
|
329
|
+
});
|
|
330
|
+
return candidates;
|
|
331
|
+
}
|
|
332
|
+
ensureDefaultFiles() {
|
|
333
|
+
try {
|
|
334
|
+
mkdirSync(this.paths.defaultsDir, { recursive: true });
|
|
335
|
+
mkdirSync(this.paths.globalOverridesDir, { recursive: true });
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
this.logger.warn("Failed to initialize prompt directories", {
|
|
339
|
+
defaultsDir: this.paths.defaultsDir,
|
|
340
|
+
globalOverridesDir: this.paths.globalOverridesDir,
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
for (const definition of PROMPT_DEFINITIONS) {
|
|
345
|
+
const bundledEditable = toEditablePromptText(definition, BUNDLED_EDITABLE_PROMPTS[definition.runtimeField]);
|
|
346
|
+
const managedContent = buildDefaultPromptFileContent(bundledEditable || BUNDLED_EDITABLE_PROMPTS[definition.runtimeField]);
|
|
347
|
+
const filePath = join(this.paths.defaultsDir, definition.fileName);
|
|
348
|
+
try {
|
|
349
|
+
const existing = readFileIfExists(filePath);
|
|
350
|
+
if (existing === managedContent) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
writeFileSync(filePath, managedContent, "utf-8");
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
this.logger.warn("Failed to write default prompt file", {
|
|
357
|
+
key: definition.key,
|
|
358
|
+
path: filePath,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const readmePath = join(this.paths.defaultsDir, DEFAULTS_README_FILE);
|
|
363
|
+
const readmeContent = buildDefaultsReadmeContent();
|
|
364
|
+
try {
|
|
365
|
+
const existing = readFileIfExists(readmePath);
|
|
366
|
+
if (existing !== readmeContent) {
|
|
367
|
+
writeFileSync(readmePath, readmeContent, "utf-8");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
this.logger.warn("Failed to write defaults README", {
|
|
372
|
+
path: readmePath,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../lib/prompts/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AACjF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAE5B,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAkDzF,MAAM,kBAAkB,GAAuB;IAC3C;QACI,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,yCAAyC;QACtD,KAAK,EAAE,wDAAwD;QAC/D,YAAY,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,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;gBAC7B,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACL,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;gBAChD,IAAI,EAAE,UAAU;aACnB,CAAC,CAAA;QACN,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SYSTEM = "<system-reminder>\n<instruction name=compress_tool attention_level=high>\nYou operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.\n\nThe ONLY tool you have for context management is `compress`. It replaces a contiguous portion of the conversation (inclusive) with a technical summary you produce.\n\nOPERATING STANCE\nPrefer short, closed, summary-safe ranges.\nWhen multiple independent stale ranges exist, prefer several short compressions (in parallel when possible) over one large-range compression.\n\nUse `compress` as steady housekeeping while you work.\n\nCADENCE, SIGNALS, AND LATENCY\n\n- No fixed threshold mandates compression\n- Prioritize closedness and independence over raw range size\n- Prefer smaller, regular compressions over infrequent massive compressions for better latency and summary quality\n- When multiple independent stale ranges are ready, batch compressions in parallel\n\nBOUNDARY MATCHING\n`compress` uses inclusive ID boundaries via `content.startId` and `content.endId`. IDs are injected in context as message refs (`mNNNN`) and compressed block refs (`bN`).\n\nEach message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`.\nTreat these tags as boundary metadata only, not as tool result content.\n\nOnly choose IDs currently visible in context. Do not invent IDs.\n\nRESPECT THE CHRONOLOGY OF THE RANGE\n`content.startId` MUST refer to an item above/before `content.endId`\n`content.endId` MUST refer to an item below/after `content.startId`\nAlways provide boundaries via the tool schema fields `content.startId` and `content.endId`.\n\nTHE SUMMARY STANDARD\nYour summary MUST be technical and specific enough to preserve FULL understanding of what transpired, such that NO ambiguity remains about what asked, found, planned, done, or decided - yet noise free\n\nWhen compressing ranges that include user messages, preserve user intent faithfully. Do not reinterpret or redirect the request. Directly quote short user messages when that is the most reliable way to preserve exact meaning.\n\nPreserve key details: file paths, symbols, signatures, constraints, decisions, outcomes, commands, etc.. in order to produce a high fidelity, authoritative technical record\n\nDO NOT COMPRESS IF\n\n- raw context is still relevant and needed for edits or precise references\n- the task in the target range is still actively in progress\n\nEvaluate conversation signal-to-noise REGULARLY. Use `compress` deliberately with quality-first summaries. Prefer multiple short, independent range compressions before considering broader ranges, and prioritize ranges intelligently to maintain a high-signal context window that supports your agency\n\nIt is of your responsibility to keep a sharp, high-quality context window for optimal performance\n</instruction>\n\n
|
|
2
|
-
//# sourceMappingURL=system.
|
|
1
|
+
export declare const SYSTEM = "<system-reminder>\n<instruction name=compress_tool attention_level=high>\nYou operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.\n\nThe ONLY tool you have for context management is `compress`. It replaces a contiguous portion of the conversation (inclusive) with a technical summary you produce.\n\nOPERATING STANCE\nPrefer short, closed, summary-safe ranges.\nWhen multiple independent stale ranges exist, prefer several short compressions (in parallel when possible) over one large-range compression.\n\nUse `compress` as steady housekeeping while you work.\n\nCADENCE, SIGNALS, AND LATENCY\n\n- No fixed threshold mandates compression\n- Prioritize closedness and independence over raw range size\n- Prefer smaller, regular compressions over infrequent massive compressions for better latency and summary quality\n- When multiple independent stale ranges are ready, batch compressions in parallel\n\nBOUNDARY MATCHING\n`compress` uses inclusive ID boundaries via `content.startId` and `content.endId`. IDs are injected in context as message refs (`mNNNN`) and compressed block refs (`bN`).\n\nEach message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`.\nTreat these tags as boundary metadata only, not as tool result content.\n\nOnly choose IDs currently visible in context. Do not invent IDs.\n\nRESPECT THE CHRONOLOGY OF THE RANGE\n`content.startId` MUST refer to an item above/before `content.endId`\n`content.endId` MUST refer to an item below/after `content.startId`\nAlways provide boundaries via the tool schema fields `content.startId` and `content.endId`.\n\nTHE SUMMARY STANDARD\nYour summary MUST be technical and specific enough to preserve FULL understanding of what transpired, such that NO ambiguity remains about what asked, found, planned, done, or decided - yet noise free\n\nWhen compressing ranges that include user messages, preserve user intent faithfully. Do not reinterpret or redirect the request. Directly quote short user messages when that is the most reliable way to preserve exact meaning.\n\nPreserve key details: file paths, symbols, signatures, constraints, decisions, outcomes, commands, etc.. in order to produce a high fidelity, authoritative technical record\n\nDO NOT COMPRESS IF\n\n- raw context is still relevant and needed for edits or precise references\n- the task in the target range is still actively in progress\n\nEvaluate conversation signal-to-noise REGULARLY. Use `compress` deliberately with quality-first summaries. Prefer multiple short, independent range compressions before considering broader ranges, and prioritize ranges intelligently to maintain a high-signal context window that supports your agency\n\nIt is of your responsibility to keep a sharp, high-quality context window for optimal performance\n</instruction>\n\n</system-reminder>\n";
|
|
2
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../lib/prompts/system.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,y6FAkDlB,CAAA"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
-
// Generated from system.md by scripts/generate-prompts.ts
|
|
3
|
-
// To modify, edit system.md and run `npm run generate:prompts`
|
|
4
1
|
export const SYSTEM = `<system-reminder>
|
|
5
2
|
<instruction name=compress_tool attention_level=high>
|
|
6
3
|
You operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.
|
|
@@ -50,22 +47,6 @@ Evaluate conversation signal-to-noise REGULARLY. Use \`compress\` deliberately w
|
|
|
50
47
|
It is of your responsibility to keep a sharp, high-quality context window for optimal performance
|
|
51
48
|
</instruction>
|
|
52
49
|
|
|
53
|
-
<manual><instruction name=manual_mode policy_level=critical>
|
|
54
|
-
Manual mode is enabled. Do NOT use compress unless the user has explicitly triggered it through a manual marker.
|
|
55
|
-
|
|
56
|
-
Only use the compress tool after seeing \`<compress triggered manually>\` in the current user instruction context.
|
|
57
|
-
|
|
58
|
-
After completing a manually triggered context-management action, STOP IMMEDIATELY. Do NOT continue with any task execution. End your response right after the tool use completes and wait for the next user input.
|
|
59
|
-
</instruction></manual>
|
|
60
|
-
|
|
61
|
-
<subagent><instruction name=subagent_prompt_safety policy_level=critical>
|
|
62
|
-
You are operating in a subagent environment.
|
|
63
|
-
|
|
64
|
-
The initial subagent instruction is imperative and must be followed exactly.
|
|
65
|
-
It is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.
|
|
66
|
-
All subsequent messages in the session will have IDs.
|
|
67
|
-
</instruction></subagent>
|
|
68
|
-
|
|
69
50
|
</system-reminder>
|
|
70
51
|
`;
|
|
71
|
-
//# sourceMappingURL=system.
|
|
52
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../../lib/prompts/system.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,IAAI,EAAE,CAAA;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAA;AAEtE,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,GAAG,CAAA;IACf,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,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AC,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU9E;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAQ7D;AAED,wBAAgB,sBAAsB,CAClC,SAAS,CAAC,EAAE,2BAA2B,GACxC,kBAAkB,CA0IpB;AAcD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CA0B1E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAS3D"}
|
package/dist/lib/state/utils.js
CHANGED
|
@@ -97,6 +97,11 @@ export function loadPruneMessagesState(persisted) {
|
|
|
97
97
|
state.blocksById.set(blockId, {
|
|
98
98
|
blockId,
|
|
99
99
|
active: block.active === true,
|
|
100
|
+
deactivatedByUser: block.deactivatedByUser === true,
|
|
101
|
+
compressedTokens: typeof block.compressedTokens === "number" &&
|
|
102
|
+
Number.isFinite(block.compressedTokens)
|
|
103
|
+
? Math.max(0, block.compressedTokens)
|
|
104
|
+
: 0,
|
|
100
105
|
topic: typeof block.topic === "string" ? block.topic : "",
|
|
101
106
|
startId: typeof block.startId === "string" ? block.startId : "",
|
|
102
107
|
endId: typeof block.endId === "string" ? block.endId : "",
|