@tarquinen/opencode-dcp 2.1.6 → 2.2.0-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 +30 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -29
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/context.js +36 -8
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/help.d.ts.map +1 -1
- package/dist/lib/commands/help.js +2 -6
- package/dist/lib/commands/help.js.map +1 -1
- package/dist/lib/commands/manual.d.ts +1 -3
- package/dist/lib/commands/manual.d.ts.map +1 -1
- package/dist/lib/commands/manual.js +4 -43
- package/dist/lib/commands/manual.js.map +1 -1
- package/dist/lib/commands/sweep.js +1 -1
- package/dist/lib/commands/sweep.js.map +1 -1
- package/dist/lib/compress-logger.d.ts +15 -0
- package/dist/lib/compress-logger.d.ts.map +1 -0
- package/dist/lib/compress-logger.js +132 -0
- package/dist/lib/compress-logger.js.map +1 -0
- package/dist/lib/config.d.ts +5 -20
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +172 -346
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts +7 -0
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +23 -16
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +6 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/messages/index.d.ts +2 -2
- package/dist/lib/messages/index.d.ts.map +1 -1
- package/dist/lib/messages/index.js +2 -2
- package/dist/lib/messages/index.js.map +1 -1
- package/dist/lib/messages/inject/inject.d.ts +6 -0
- package/dist/lib/messages/inject/inject.d.ts.map +1 -0
- package/dist/lib/messages/inject/inject.js +99 -0
- package/dist/lib/messages/inject/inject.js.map +1 -0
- package/dist/lib/messages/inject/utils.d.ts +20 -0
- package/dist/lib/messages/inject/utils.d.ts.map +1 -0
- package/dist/lib/messages/inject/utils.js +137 -0
- package/dist/lib/messages/inject/utils.js.map +1 -0
- package/dist/lib/messages/prune.js +7 -7
- package/dist/lib/messages/prune.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +16 -28
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +40 -133
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/_codegen/system.generated.d.ts +1 -1
- package/dist/lib/prompts/_codegen/system.generated.d.ts.map +1 -1
- package/dist/lib/prompts/_codegen/system.generated.js +36 -32
- package/dist/lib/prompts/_codegen/system.generated.js.map +1 -1
- package/dist/lib/prompts/compress.d.ts +2 -0
- package/dist/lib/prompts/compress.d.ts.map +1 -0
- package/dist/lib/prompts/compress.js +122 -0
- package/dist/lib/prompts/compress.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +6 -10
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +17 -40
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/iteration-nudge.d.ts +2 -0
- package/dist/lib/prompts/iteration-nudge.d.ts.map +1 -0
- package/dist/lib/prompts/iteration-nudge.js +9 -0
- package/dist/lib/prompts/iteration-nudge.js.map +1 -0
- package/dist/lib/prompts/nudge.d.ts +2 -0
- package/dist/lib/prompts/nudge.d.ts.map +1 -0
- package/dist/lib/prompts/nudge.js +40 -0
- package/dist/lib/prompts/nudge.js.map +1 -0
- package/dist/lib/prompts/turn-nudge.d.ts +2 -0
- package/dist/lib/prompts/turn-nudge.d.ts.map +1 -0
- package/dist/lib/prompts/turn-nudge.js +12 -0
- package/dist/lib/prompts/turn-nudge.js.map +1 -0
- package/dist/lib/state/persistence.d.ts +6 -0
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +58 -38
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/state.js +20 -5
- package/dist/lib/state/state.js.map +1 -1
- package/dist/lib/state/tool-cache.d.ts.map +1 -1
- package/dist/lib/state/tool-cache.js +3 -17
- package/dist/lib/state/tool-cache.js.map +1 -1
- package/dist/lib/state/types.d.ts +7 -2
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/state/utils.d.ts +1 -0
- package/dist/lib/state/utils.d.ts.map +1 -1
- package/dist/lib/state/utils.js +33 -6
- package/dist/lib/state/utils.js.map +1 -1
- package/dist/lib/strategies/index.d.ts +0 -1
- package/dist/lib/strategies/index.d.ts.map +1 -1
- package/dist/lib/strategies/index.js +0 -1
- package/dist/lib/strategies/index.js.map +1 -1
- package/dist/lib/strategies/utils.d.ts +1 -0
- package/dist/lib/strategies/utils.d.ts.map +1 -1
- package/dist/lib/strategies/utils.js +15 -0
- package/dist/lib/strategies/utils.js.map +1 -1
- package/dist/lib/tools/compress-utils.d.ts +7 -4
- package/dist/lib/tools/compress-utils.d.ts.map +1 -1
- package/dist/lib/tools/compress-utils.js +34 -25
- package/dist/lib/tools/compress-utils.js.map +1 -1
- package/dist/lib/tools/compress.d.ts +2 -2
- package/dist/lib/tools/compress.d.ts.map +1 -1
- package/dist/lib/tools/compress.js +21 -58
- package/dist/lib/tools/compress.js.map +1 -1
- package/dist/lib/tools/index.d.ts +1 -3
- package/dist/lib/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/index.js +0 -2
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/types.d.ts +1 -1
- package/dist/lib/tools/types.d.ts.map +1 -1
- package/dist/lib/ui/notification.d.ts +2 -2
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +31 -28
- package/dist/lib/ui/notification.js.map +1 -1
- package/dist/lib/ui/utils.d.ts +3 -4
- package/dist/lib/ui/utils.d.ts.map +1 -1
- package/dist/lib/ui/utils.js +165 -24
- package/dist/lib/ui/utils.js.map +1 -1
- package/package.json +2 -1
- package/dist/lib/messages/inject.d.ts +0 -14
- package/dist/lib/messages/inject.d.ts.map +0 -1
- package/dist/lib/messages/inject.js +0 -266
- package/dist/lib/messages/inject.js.map +0 -1
- package/dist/lib/prompts/_codegen/compress-nudge.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/compress-nudge.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/compress-nudge.generated.js +0 -15
- package/dist/lib/prompts/_codegen/compress-nudge.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/compress.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/compress.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/compress.generated.js +0 -66
- package/dist/lib/prompts/_codegen/compress.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/distill.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/distill.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/distill.generated.js +0 -33
- package/dist/lib/prompts/_codegen/distill.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/nudge.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/nudge.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/nudge.generated.js +0 -17
- package/dist/lib/prompts/_codegen/nudge.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/prune.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/prune.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/prune.generated.js +0 -23
- package/dist/lib/prompts/_codegen/prune.generated.js.map +0 -1
- package/dist/lib/tools/distill.d.ts +0 -4
- package/dist/lib/tools/distill.d.ts.map +0 -1
- package/dist/lib/tools/distill.js +0 -41
- package/dist/lib/tools/distill.js.map +0 -1
- package/dist/lib/tools/prune-shared.d.ts +0 -6
- package/dist/lib/tools/prune-shared.d.ts.map +0 -1
- package/dist/lib/tools/prune-shared.js +0 -113
- package/dist/lib/tools/prune-shared.js.map +0 -1
- package/dist/lib/tools/prune.d.ts +0 -4
- package/dist/lib/tools/prune.d.ts.map +0 -1
- package/dist/lib/tools/prune.js +0 -28
- package/dist/lib/tools/prune.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const COMPRESS = `Your only tool for context management, use it to collapse a range in the conversation into a detailed summary
|
|
2
|
+
|
|
3
|
+
THE PHILOSOPHY OF COMPRESS
|
|
4
|
+
\`compress\` transforms verbose conversation sequences into dense, high-fidelity summaries. This is not cleanup - it is crystallization. Your summary becomes the authoritative record of what transpired.
|
|
5
|
+
|
|
6
|
+
Think of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.
|
|
7
|
+
|
|
8
|
+
One method, many safe ranges:
|
|
9
|
+
|
|
10
|
+
- short, closed ranges for disposable noise
|
|
11
|
+
- short, closed ranges for resolved investigative slices
|
|
12
|
+
- short, closed ranges for completed implementation chunks
|
|
13
|
+
|
|
14
|
+
Default to multiple short, bounded compressions. Prefer several safe range compressions over one large sweep whenever independent ranges are available.
|
|
15
|
+
|
|
16
|
+
CADENCE, SIGNALS, AND LATENCY
|
|
17
|
+
Use \`compress\` during work whenever a slice is summary-safe; do not wait for the user to send another message.
|
|
18
|
+
|
|
19
|
+
- no fixed threshold forces compression
|
|
20
|
+
- prioritize closedness and independence over raw range size
|
|
21
|
+
- qualitative signals still matter most (stale exploration, noisy tool bursts, resolved branches)
|
|
22
|
+
|
|
23
|
+
PREFER smaller, regular compressions OVER infrequent large compressions for better latency and better summary fidelity.
|
|
24
|
+
|
|
25
|
+
THE SUMMARY
|
|
26
|
+
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
|
|
27
|
+
|
|
28
|
+
USER INTENT FIDELITY
|
|
29
|
+
When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
30
|
+
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
|
|
31
|
+
|
|
32
|
+
COMPRESSED BLOCK PLACEHOLDERS
|
|
33
|
+
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
|
|
34
|
+
|
|
35
|
+
- \`(bN)\`
|
|
36
|
+
|
|
37
|
+
Compressed block sections in context are clearly marked with a header:
|
|
38
|
+
|
|
39
|
+
- \`[Compressed conversation section]\`
|
|
40
|
+
|
|
41
|
+
Compressed block IDs always use the \`bN\` form (never \`mNNNN\`) and are represented in the same XML metadata tag format.
|
|
42
|
+
|
|
43
|
+
Rules:
|
|
44
|
+
|
|
45
|
+
- Include every required block placeholder exactly once.
|
|
46
|
+
- Do not invent placeholders for blocks outside the selected range.
|
|
47
|
+
- Treat \`(bN)\` placeholders as RESERVED TOKENS. Do not emit \`(bN)\` text anywhere except intentional placeholders.
|
|
48
|
+
- If you need to mention a block in prose, use plain text like \`compressed bN\` (not as a placeholder).
|
|
49
|
+
- Preflight check before finalizing: the set of \`(bN)\` placeholders in your summary must exactly match the required set, with no duplicates.
|
|
50
|
+
|
|
51
|
+
These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
|
|
52
|
+
|
|
53
|
+
FLOW PRESERVATION WITH PLACEHOLDERS
|
|
54
|
+
When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
|
|
55
|
+
|
|
56
|
+
- Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
|
|
57
|
+
- Ensure transitions before and after each placeholder preserve chronology and causality.
|
|
58
|
+
- Do not write text that depends on the placeholder staying literal (for example, "as noted in (b2)").
|
|
59
|
+
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
|
|
60
|
+
|
|
61
|
+
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
62
|
+
|
|
63
|
+
THE WAYS OF COMPRESS
|
|
64
|
+
Compress when a range is genuinely closed and the raw conversation has served its purpose:
|
|
65
|
+
|
|
66
|
+
Research concluded and findings are clear
|
|
67
|
+
Implementation finished and verified
|
|
68
|
+
Exploration exhausted and patterns understood
|
|
69
|
+
|
|
70
|
+
Compress smaller ranges when:
|
|
71
|
+
You need to discard dead-end noise without waiting for a whole chapter to close
|
|
72
|
+
You need to preserve key findings from a narrow slice while freeing context quickly
|
|
73
|
+
You can bound a stale range cleanly with injected IDs
|
|
74
|
+
|
|
75
|
+
Do NOT compress when:
|
|
76
|
+
You may need exact code, error messages, or file contents from the range in the immediate next steps
|
|
77
|
+
Work in that area is still active or likely to resume immediately
|
|
78
|
+
You cannot identify reliable boundaries yet
|
|
79
|
+
|
|
80
|
+
Before compressing, ask: _"Is this range closed enough to become summary-only right now?"_ Compression is irreversible. The summary replaces everything in the range.
|
|
81
|
+
|
|
82
|
+
BOUNDARY IDS
|
|
83
|
+
You specify boundaries by ID
|
|
84
|
+
|
|
85
|
+
Use the injected IDs visible in the conversation:
|
|
86
|
+
|
|
87
|
+
- \`mNNNN\` IDs identify raw messages
|
|
88
|
+
- \`bN\` IDs identify previously compressed blocks
|
|
89
|
+
|
|
90
|
+
Rules:
|
|
91
|
+
|
|
92
|
+
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
93
|
+
- IDs must exist in the current visible context.
|
|
94
|
+
- \`startId\` must appear before \`endId\`.
|
|
95
|
+
- Prefer boundaries that produce short, closed ranges.
|
|
96
|
+
|
|
97
|
+
ID SOURCES
|
|
98
|
+
|
|
99
|
+
- There is always an ID available for each message in XML tags like \`<dcp-message-id>...</dcp-message-id>\`.
|
|
100
|
+
- Compressed blocks are addressable by \`bN\` IDs.
|
|
101
|
+
|
|
102
|
+
Treat \`<dcp-message-id>...</dcp-message-id>\` as metadata only. It is not part of the tool result semantics.
|
|
103
|
+
|
|
104
|
+
Do not invent IDs. Use only IDs that are present in context.
|
|
105
|
+
|
|
106
|
+
PARALLEL COMPRESS EXECUTION
|
|
107
|
+
When multiple independent ranges are ready and their boundaries do not overlap, launch MULTIPLE \`compress\` calls in parallel in a single response. This is the PREFERRED pattern over a single large-range compression when the work can be safely split. Run compression sequentially only when ranges overlap or when a later range depends on the result of an earlier compression.
|
|
108
|
+
|
|
109
|
+
THE FORMAT OF COMPRESS
|
|
110
|
+
|
|
111
|
+
\`\`\`
|
|
112
|
+
{
|
|
113
|
+
topic: string, // Short label (3-5 words) - e.g., "Auth System Exploration"
|
|
114
|
+
content: {
|
|
115
|
+
startId: string, // Boundary ID at range start: mNNNN or bN
|
|
116
|
+
endId: string, // Boundary ID at range end: mNNNN or bN
|
|
117
|
+
summary: string // Complete technical summary replacing all content in range
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
\`\`\`
|
|
121
|
+
`;
|
|
122
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../lib/prompts/compress.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwHvB,CAAA"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function renderSystemPrompt(flags: ToolFlags): string;
|
|
8
|
-
export declare function renderNudge(flags: ToolFlags): string;
|
|
9
|
-
export declare function renderCompressNudge(): string;
|
|
10
|
-
export declare function loadPrompt(name: string, vars?: Record<string, string>): string;
|
|
1
|
+
import { COMPRESS } from "./compress";
|
|
2
|
+
export { COMPRESS as COMPRESS_TOOL_SPEC };
|
|
3
|
+
export declare function renderSystemPrompt(manual?: boolean): string;
|
|
4
|
+
export declare const CONTEXT_LIMIT_NUDGE: string;
|
|
5
|
+
export declare const TURN_NUDGE_PROMPT: string;
|
|
6
|
+
export declare const ITERATION_NUDGE_PROMPT: string;
|
|
11
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAA;AAEzC,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAU3D;AAWD,eAAO,MAAM,mBAAmB,QAAuD,CAAA;AACvF,eAAO,MAAM,iBAAiB,QAA+C,CAAA;AAC7E,eAAO,MAAM,sBAAsB,QAAyD,CAAA"}
|
|
@@ -1,47 +1,24 @@
|
|
|
1
|
-
// Generated prompts (from .md files via scripts/generate-prompts.ts)
|
|
2
1
|
import { SYSTEM as SYSTEM_PROMPT } from "./_codegen/system.generated";
|
|
3
|
-
import { NUDGE } from "./
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
let result = template;
|
|
11
|
-
// Strip comments: // ... //
|
|
2
|
+
import { NUDGE } from "./nudge";
|
|
3
|
+
import { COMPRESS } from "./compress";
|
|
4
|
+
import { TURN_NUDGE } from "./turn-nudge";
|
|
5
|
+
import { ITERATION_NUDGE } from "./iteration-nudge";
|
|
6
|
+
export { COMPRESS as COMPRESS_TOOL_SPEC };
|
|
7
|
+
export function renderSystemPrompt(manual) {
|
|
8
|
+
let result = SYSTEM_PROMPT;
|
|
12
9
|
result = result.replace(/\/\/.*?\/\//g, "");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
result = result.replace(regex, (_, content) => (flags[tool] ? content : ""));
|
|
10
|
+
if (!manual) {
|
|
11
|
+
const regex = new RegExp(`<manual>[\\s\\S]*?</manual>`, "g");
|
|
12
|
+
result = result.replace(regex, "");
|
|
17
13
|
}
|
|
18
|
-
// Collapse multiple blank/whitespace-only lines to single blank line
|
|
19
14
|
return result.replace(/\n([ \t]*\n)+/g, "\n\n").trim();
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return processConditionals(NUDGE, flags);
|
|
26
|
-
}
|
|
27
|
-
export function renderCompressNudge() {
|
|
28
|
-
return COMPRESS_NUDGE;
|
|
29
|
-
}
|
|
30
|
-
const PROMPTS = {
|
|
31
|
-
"prune-tool-spec": PRUNE_TOOL_SPEC,
|
|
32
|
-
"distill-tool-spec": DISTILL_TOOL_SPEC,
|
|
33
|
-
"compress-tool-spec": COMPRESS_TOOL_SPEC,
|
|
34
|
-
};
|
|
35
|
-
export function loadPrompt(name, vars) {
|
|
36
|
-
let content = PROMPTS[name];
|
|
37
|
-
if (!content) {
|
|
38
|
-
throw new Error(`Prompt not found: ${name}`);
|
|
39
|
-
}
|
|
40
|
-
if (vars) {
|
|
41
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
42
|
-
content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return content;
|
|
16
|
+
function extractInstruction(content, name) {
|
|
17
|
+
const regex = new RegExp(`<instruction\\s+name=(?:"${name}"|${name})[^>]*>[\\s\\S]*?<\\/instruction>`, "i");
|
|
18
|
+
const match = content.match(regex);
|
|
19
|
+
return match ? match[0] : content;
|
|
46
20
|
}
|
|
21
|
+
export const CONTEXT_LIMIT_NUDGE = extractInstruction(NUDGE, "context_buildup_warning");
|
|
22
|
+
export const TURN_NUDGE_PROMPT = extractInstruction(TURN_NUDGE, "turn_nudge");
|
|
23
|
+
export const ITERATION_NUDGE_PROMPT = extractInstruction(ITERATION_NUDGE, "iteration_nudge");
|
|
47
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAA;AAEzC,MAAM,UAAU,kBAAkB,CAAC,MAAgB;IAC/C,IAAI,MAAM,GAAG,aAAa,CAAA;IAC1B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QAC5D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;AAC1D,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,IAAI,MAAM,CACpB,4BAA4B,IAAI,KAAK,IAAI,mCAAmC,EAC5E,GAAG,CACN,CAAA;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;AACrC,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAA;AACvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const ITERATION_NUDGE = "<instruction name=iteration_nudge>\nYou've been iterating for a while after the last user message.\n\nIf there is a closed portion that is unlikely to be referenced immediately (for example, finished research before implementation), use the compress tool on it now.\n\nPrefer multiple short, closed ranges over one large range when several independent slices are ready.\n</instruction>\n";
|
|
2
|
+
//# sourceMappingURL=iteration-nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration-nudge.d.ts","sourceRoot":"","sources":["../../../lib/prompts/iteration-nudge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,wYAO3B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const ITERATION_NUDGE = `<instruction name=iteration_nudge>
|
|
2
|
+
You've been iterating for a while after the last user message.
|
|
3
|
+
|
|
4
|
+
If there is a closed portion that is unlikely to be referenced immediately (for example, finished research before implementation), use the compress tool on it now.
|
|
5
|
+
|
|
6
|
+
Prefer multiple short, closed ranges over one large range when several independent slices are ready.
|
|
7
|
+
</instruction>
|
|
8
|
+
`;
|
|
9
|
+
//# sourceMappingURL=iteration-nudge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration-nudge.js","sourceRoot":"","sources":["../../../lib/prompts/iteration-nudge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;CAO9B,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const NUDGE = "<instruction name=context_management_required>\nCRITICAL CONTEXT WARNING\nYour context window is filling with tool outputs. Strict adherence to context hygiene is required.\n\nPROTOCOL\nYou should prioritize context management, 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\nIMMEDIATE ACTION REQUIRED\nKNOWLEDGE PRESERVATION: If holding valuable raw data you POTENTIALLY will need in your task, compress the smallest closed range that preserves those findings. Write a high-fidelity summary so no key technical insight is lost.\n\nNOISE REMOVAL: If you read files or ran commands that yielded no value, compress those dead-end ranges into explicit noise summaries and move on.\n\nPHASE COMPLETION: If a chapter is complete, compress the entire sequence into a detailed technical summary with unambiguous outcomes.\n</instruction>\n\n<instruction name=context_buildup_warning>\nCRITICAL WARNING: CONTEXT BUILD-UP\n\nThe context window is filling-up. You've reached a point where performance may increasingly degrade. Active context management is now strategically relevant. Mind your context footprint as the conversation grows\n\nYOU MUST COMPRESS NOW TO AVOID CONTEXT ROT. THIS IS CRITICAL. Do not delay context management any further.\n\nDOOOOO IT!!!\n\nAvoid unnecessary context build-up with targeted uses of the `compress` tool. Start with low hanging fruits and clearly identified ranges that can be compressed with minimal risk of losing critical information. Look BACK on the conversation history and avoid compressing the newest ranges until you have exhausted older ones\n\nRANGE STRATEGY (MANDATORY)\nPrefer multiple short, closed range compressions.\nWhen multiple independent stale ranges are ready, batch those short compressions in parallel.\nDo not jump to a single broad range when the same cleanup can be done safely with several bounded ranges.\n\nIf you are performing a critical atomic operation, do not interrupt it, but make sure to perform context management rapidly\n\nUse injected boundary IDs for compression (`mNNNN` for messages, `bN` for compressed blocks). Pick IDs that are visible in context and ensure `startId` appears before `endId`.\n\nEnsure your summaries are inclusive of all parts of the range.\nIf the compressed range includes user messages, preserve user intent exactly. Prefer direct quotes for short user messages to avoid semantic drift.\n</instruction>\n";
|
|
2
|
+
//# sourceMappingURL=nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nudge.d.ts","sourceRoot":"","sources":["../../../lib/prompts/nudge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,y8EAsCjB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const NUDGE = `<instruction name=context_management_required>
|
|
2
|
+
CRITICAL CONTEXT WARNING
|
|
3
|
+
Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
|
|
4
|
+
|
|
5
|
+
PROTOCOL
|
|
6
|
+
You should prioritize context management, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
|
|
7
|
+
|
|
8
|
+
IMMEDIATE ACTION REQUIRED
|
|
9
|
+
KNOWLEDGE PRESERVATION: If holding valuable raw data you POTENTIALLY will need in your task, compress the smallest closed range that preserves those findings. Write a high-fidelity summary so no key technical insight is lost.
|
|
10
|
+
|
|
11
|
+
NOISE REMOVAL: If you read files or ran commands that yielded no value, compress those dead-end ranges into explicit noise summaries and move on.
|
|
12
|
+
|
|
13
|
+
PHASE COMPLETION: If a chapter is complete, compress the entire sequence into a detailed technical summary with unambiguous outcomes.
|
|
14
|
+
</instruction>
|
|
15
|
+
|
|
16
|
+
<instruction name=context_buildup_warning>
|
|
17
|
+
CRITICAL WARNING: CONTEXT BUILD-UP
|
|
18
|
+
|
|
19
|
+
The context window is filling-up. You've reached a point where performance may increasingly degrade. Active context management is now strategically relevant. Mind your context footprint as the conversation grows
|
|
20
|
+
|
|
21
|
+
YOU MUST COMPRESS NOW TO AVOID CONTEXT ROT. THIS IS CRITICAL. Do not delay context management any further.
|
|
22
|
+
|
|
23
|
+
DOOOOO IT!!!
|
|
24
|
+
|
|
25
|
+
Avoid unnecessary context build-up with targeted uses of the \`compress\` tool. Start with low hanging fruits and clearly identified ranges that can be compressed with minimal risk of losing critical information. Look BACK on the conversation history and avoid compressing the newest ranges until you have exhausted older ones
|
|
26
|
+
|
|
27
|
+
RANGE STRATEGY (MANDATORY)
|
|
28
|
+
Prefer multiple short, closed range compressions.
|
|
29
|
+
When multiple independent stale ranges are ready, batch those short compressions in parallel.
|
|
30
|
+
Do not jump to a single broad range when the same cleanup can be done safely with several bounded ranges.
|
|
31
|
+
|
|
32
|
+
If you are performing a critical atomic operation, do not interrupt it, but make sure to perform context management rapidly
|
|
33
|
+
|
|
34
|
+
Use injected boundary IDs for compression (\`mNNNN\` for messages, \`bN\` for compressed blocks). Pick IDs that are visible in context and ensure \`startId\` appears before \`endId\`.
|
|
35
|
+
|
|
36
|
+
Ensure your summaries are inclusive of all parts of the range.
|
|
37
|
+
If the compressed range includes user messages, preserve user intent exactly. Prefer direct quotes for short user messages to avoid semantic drift.
|
|
38
|
+
</instruction>
|
|
39
|
+
`;
|
|
40
|
+
//# sourceMappingURL=nudge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nudge.js","sourceRoot":"","sources":["../../../lib/prompts/nudge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCpB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const TURN_NUDGE = "<instruction name=turn_nudge>\nReview the user request above against the work that just finished.\n\nIf this request shifts direction, use the compress tool on earlier ranges that are now less relevant.\nIf any range is cleanly closed and not needed to answer this request, compress it.\nIf you determine a compression of previous content makes sense, do so first before completing the request above.\n\nPrefer small, closed-range compressions over one broad compression.\nKeep active context needed for this request uncompressed.\n</instruction>\n";
|
|
2
|
+
//# sourceMappingURL=turn-nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-nudge.d.ts","sourceRoot":"","sources":["../../../lib/prompts/turn-nudge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,yiBAUtB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const TURN_NUDGE = `<instruction name=turn_nudge>
|
|
2
|
+
Review the user request above against the work that just finished.
|
|
3
|
+
|
|
4
|
+
If this request shifts direction, use the compress tool on earlier ranges that are now less relevant.
|
|
5
|
+
If any range is cleanly closed and not needed to answer this request, compress it.
|
|
6
|
+
If you determine a compression of previous content makes sense, do so first before completing the request above.
|
|
7
|
+
|
|
8
|
+
Prefer small, closed-range compressions over one broad compression.
|
|
9
|
+
Keep active context needed for this request uncompressed.
|
|
10
|
+
</instruction>
|
|
11
|
+
`;
|
|
12
|
+
//# sourceMappingURL=turn-nudge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-nudge.js","sourceRoot":"","sources":["../../../lib/prompts/turn-nudge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;CAUzB,CAAA"}
|
|
@@ -12,10 +12,16 @@ export interface PersistedPrune {
|
|
|
12
12
|
toolIds?: string[];
|
|
13
13
|
messageIds?: string[];
|
|
14
14
|
}
|
|
15
|
+
export interface PersistedNudges {
|
|
16
|
+
contextLimitAnchors: string[];
|
|
17
|
+
turnNudgeAnchors?: string[];
|
|
18
|
+
iterationNudgeAnchors?: string[];
|
|
19
|
+
}
|
|
15
20
|
export interface PersistedSessionState {
|
|
16
21
|
sessionName?: string;
|
|
17
22
|
prune: PersistedPrune;
|
|
18
23
|
compressSummaries: CompressSummary[];
|
|
24
|
+
nudges: PersistedNudges;
|
|
19
25
|
stats: SessionStats;
|
|
20
26
|
lastUpdated: string;
|
|
21
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../lib/state/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,oCAAoC;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A;CACnC;AAED,MAAM,WAAW,qBAAqB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,cAAc,CAAA;IACrB,iBAAiB,EAAE,eAAe,EAAE,CAAA;IACpC,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,YAAY,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACtB;AAoBD,wBAAsB,gBAAgB,CAClC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAsCf;AAED,wBAAsB,gBAAgB,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CA4GvC;AAED,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA2ClF"}
|
|
@@ -29,6 +29,11 @@ export async function saveSessionState(sessionState, logger, sessionName) {
|
|
|
29
29
|
messages: Object.fromEntries(sessionState.prune.messages),
|
|
30
30
|
},
|
|
31
31
|
compressSummaries: sessionState.compressSummaries,
|
|
32
|
+
nudges: {
|
|
33
|
+
contextLimitAnchors: Array.from(sessionState.nudges.contextLimitAnchors),
|
|
34
|
+
turnNudgeAnchors: Array.from(sessionState.nudges.turnNudgeAnchors),
|
|
35
|
+
iterationNudgeAnchors: Array.from(sessionState.nudges.iterationNudgeAnchors),
|
|
36
|
+
},
|
|
32
37
|
stats: sessionState.stats,
|
|
33
38
|
lastUpdated: new Date().toISOString(),
|
|
34
39
|
};
|
|
@@ -57,59 +62,74 @@ export async function loadSessionState(sessionId, logger) {
|
|
|
57
62
|
const state = JSON.parse(content);
|
|
58
63
|
const hasNewFormat = state?.prune?.tools && typeof state.prune.tools === "object";
|
|
59
64
|
const hasLegacyFormat = Array.isArray(state?.prune?.toolIds);
|
|
60
|
-
|
|
65
|
+
const hasNudgeFormat = state?.nudges && typeof state.nudges === "object";
|
|
66
|
+
if (!state ||
|
|
67
|
+
!state.prune ||
|
|
68
|
+
(!hasNewFormat && !hasLegacyFormat) ||
|
|
69
|
+
!state.stats ||
|
|
70
|
+
!hasNudgeFormat) {
|
|
61
71
|
logger.warn("Invalid session state file, ignoring", {
|
|
62
72
|
sessionId: sessionId,
|
|
63
73
|
});
|
|
64
74
|
return null;
|
|
65
75
|
}
|
|
66
76
|
if (Array.isArray(state.compressSummaries)) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
typeof entry.summary !== "string") {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const blockId = typeof entry.blockId === "number" && Number.isInteger(entry.blockId)
|
|
77
|
-
? entry.blockId
|
|
78
|
-
: nextBlockId;
|
|
79
|
-
migratedSummaries.push({
|
|
80
|
-
blockId,
|
|
81
|
-
anchorMessageId: entry.anchorMessageId,
|
|
82
|
-
summary: entry.summary,
|
|
83
|
-
});
|
|
84
|
-
nextBlockId = Math.max(nextBlockId, blockId + 1);
|
|
85
|
-
}
|
|
86
|
-
if (migratedSummaries.length !== state.compressSummaries.length) {
|
|
77
|
+
const validSummaries = state.compressSummaries.filter((s) => s !== null &&
|
|
78
|
+
typeof s === "object" &&
|
|
79
|
+
typeof s.blockId === "number" &&
|
|
80
|
+
typeof s.anchorMessageId === "string" &&
|
|
81
|
+
typeof s.summary === "string");
|
|
82
|
+
if (validSummaries.length !== state.compressSummaries.length) {
|
|
87
83
|
logger.warn("Filtered out malformed compressSummaries entries", {
|
|
88
84
|
sessionId: sessionId,
|
|
89
85
|
original: state.compressSummaries.length,
|
|
90
|
-
valid:
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const seenBlockIds = new Set();
|
|
94
|
-
const dedupedSummaries = migratedSummaries.filter((summary) => {
|
|
95
|
-
if (seenBlockIds.has(summary.blockId)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
seenBlockIds.add(summary.blockId);
|
|
99
|
-
return true;
|
|
100
|
-
});
|
|
101
|
-
if (dedupedSummaries.length !== migratedSummaries.length) {
|
|
102
|
-
logger.warn("Removed duplicate compress block IDs", {
|
|
103
|
-
sessionId: sessionId,
|
|
104
|
-
original: migratedSummaries.length,
|
|
105
|
-
valid: dedupedSummaries.length,
|
|
86
|
+
valid: validSummaries.length,
|
|
106
87
|
});
|
|
107
88
|
}
|
|
108
|
-
state.compressSummaries =
|
|
89
|
+
state.compressSummaries = validSummaries;
|
|
109
90
|
}
|
|
110
91
|
else {
|
|
111
92
|
state.compressSummaries = [];
|
|
112
93
|
}
|
|
94
|
+
const rawContextLimitAnchors = Array.isArray(state.nudges.contextLimitAnchors)
|
|
95
|
+
? state.nudges.contextLimitAnchors
|
|
96
|
+
: [];
|
|
97
|
+
const validAnchors = rawContextLimitAnchors.filter((entry) => typeof entry === "string");
|
|
98
|
+
const dedupedAnchors = [...new Set(validAnchors)];
|
|
99
|
+
if (validAnchors.length !== rawContextLimitAnchors.length) {
|
|
100
|
+
logger.warn("Filtered out malformed contextLimitAnchors entries", {
|
|
101
|
+
sessionId: sessionId,
|
|
102
|
+
original: rawContextLimitAnchors.length,
|
|
103
|
+
valid: validAnchors.length,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
state.nudges.contextLimitAnchors = dedupedAnchors;
|
|
107
|
+
const rawTurnNudgeAnchors = Array.isArray(state.nudges.turnNudgeAnchors)
|
|
108
|
+
? state.nudges.turnNudgeAnchors
|
|
109
|
+
: [];
|
|
110
|
+
const validSoftAnchors = rawTurnNudgeAnchors.filter((entry) => typeof entry === "string");
|
|
111
|
+
const dedupedSoftAnchors = [...new Set(validSoftAnchors)];
|
|
112
|
+
if (validSoftAnchors.length !== rawTurnNudgeAnchors.length) {
|
|
113
|
+
logger.warn("Filtered out malformed turnNudgeAnchors entries", {
|
|
114
|
+
sessionId: sessionId,
|
|
115
|
+
original: rawTurnNudgeAnchors.length,
|
|
116
|
+
valid: validSoftAnchors.length,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
state.nudges.turnNudgeAnchors = dedupedSoftAnchors;
|
|
120
|
+
const rawIterationNudgeAnchors = Array.isArray(state.nudges.iterationNudgeAnchors)
|
|
121
|
+
? state.nudges.iterationNudgeAnchors
|
|
122
|
+
: [];
|
|
123
|
+
const validIterationAnchors = rawIterationNudgeAnchors.filter((entry) => typeof entry === "string");
|
|
124
|
+
const dedupedIterationAnchors = [...new Set(validIterationAnchors)];
|
|
125
|
+
if (validIterationAnchors.length !== rawIterationNudgeAnchors.length) {
|
|
126
|
+
logger.warn("Filtered out malformed iterationNudgeAnchors entries", {
|
|
127
|
+
sessionId: sessionId,
|
|
128
|
+
original: rawIterationNudgeAnchors.length,
|
|
129
|
+
valid: validIterationAnchors.length,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
state.nudges.iterationNudgeAnchors = dedupedIterationAnchors;
|
|
113
133
|
logger.info("Loaded session state from disk", {
|
|
114
134
|
sessionId: sessionId,
|
|
115
135
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../lib/state/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../lib/state/persistence.ts"],"names":[],"mappings":"AAAA;;;;GA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,MAAM,CAAC,aAAa,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ;wBACxC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM;wBAC1C,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,CAAA;oBAC3C,MAAM,CAAC,YAAY,EAAE,CAAA;gBACzB,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACL,qBAAqB;YACzB,CAAC;QACL,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../lib/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../lib/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAYvC,eAAO,MAAM,YAAY,GACrB,QAAQ,GAAG,EACX,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,EACrB,mBAAmB,OAAO,KAC3B,OAAO,CAAC,IAAI,CAwCd,CAAA;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAiCjD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CA+B3D;AAED,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EAAE,EACrB,iBAAiB,EAAE,OAAO,GAC3B,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
package/dist/lib/state/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadSessionState, saveSessionState } from "./persistence";
|
|
2
|
-
import { isSubAgentSession, findLastCompactionTimestamp, countTurns, resetOnCompaction, loadPruneMap, } from "./utils";
|
|
2
|
+
import { isSubAgentSession, findLastCompactionTimestamp, countTurns, resetOnCompaction, loadPruneMap, collectTurnNudgeAnchors, } from "./utils";
|
|
3
3
|
import { getLastUserMessage } from "../shared-utils";
|
|
4
4
|
export const checkSession = async (client, state, logger, messages, manualModeDefault) => {
|
|
5
5
|
const lastUserMessage = getLastUserMessage(messages);
|
|
@@ -42,6 +42,11 @@ export function createSessionState() {
|
|
|
42
42
|
messages: new Map(),
|
|
43
43
|
},
|
|
44
44
|
compressSummaries: [],
|
|
45
|
+
nudges: {
|
|
46
|
+
contextLimitAnchors: new Set(),
|
|
47
|
+
turnNudgeAnchors: new Set(),
|
|
48
|
+
iterationNudgeAnchors: new Set(),
|
|
49
|
+
},
|
|
45
50
|
stats: {
|
|
46
51
|
pruneTokenCounter: 0,
|
|
47
52
|
totalPruneTokens: 0,
|
|
@@ -53,12 +58,11 @@ export function createSessionState() {
|
|
|
53
58
|
byRef: new Map(),
|
|
54
59
|
nextRef: 0,
|
|
55
60
|
},
|
|
56
|
-
nudgeCounter: 0,
|
|
57
|
-
lastToolPrune: false,
|
|
58
61
|
lastCompaction: 0,
|
|
59
62
|
currentTurn: 0,
|
|
60
63
|
variant: undefined,
|
|
61
64
|
modelContextLimit: undefined,
|
|
65
|
+
systemPromptTokens: undefined,
|
|
62
66
|
};
|
|
63
67
|
}
|
|
64
68
|
export function resetSessionState(state) {
|
|
@@ -71,6 +75,11 @@ export function resetSessionState(state) {
|
|
|
71
75
|
messages: new Map(),
|
|
72
76
|
};
|
|
73
77
|
state.compressSummaries = [];
|
|
78
|
+
state.nudges = {
|
|
79
|
+
contextLimitAnchors: new Set(),
|
|
80
|
+
turnNudgeAnchors: new Set(),
|
|
81
|
+
iterationNudgeAnchors: new Set(),
|
|
82
|
+
};
|
|
74
83
|
state.stats = {
|
|
75
84
|
pruneTokenCounter: 0,
|
|
76
85
|
totalPruneTokens: 0,
|
|
@@ -82,12 +91,11 @@ export function resetSessionState(state) {
|
|
|
82
91
|
byRef: new Map(),
|
|
83
92
|
nextRef: 0,
|
|
84
93
|
};
|
|
85
|
-
state.nudgeCounter = 0;
|
|
86
|
-
state.lastToolPrune = false;
|
|
87
94
|
state.lastCompaction = 0;
|
|
88
95
|
state.currentTurn = 0;
|
|
89
96
|
state.variant = undefined;
|
|
90
97
|
state.modelContextLimit = undefined;
|
|
98
|
+
state.systemPromptTokens = undefined;
|
|
91
99
|
}
|
|
92
100
|
export async function ensureSessionInitialized(client, state, sessionId, logger, messages, manualModeDefault) {
|
|
93
101
|
if (state.sessionId === sessionId) {
|
|
@@ -103,6 +111,7 @@ export async function ensureSessionInitialized(client, state, sessionId, logger,
|
|
|
103
111
|
// logger.info("isSubAgent = " + isSubAgent)
|
|
104
112
|
state.lastCompaction = findLastCompactionTimestamp(messages);
|
|
105
113
|
state.currentTurn = countTurns(state, messages);
|
|
114
|
+
state.nudges.turnNudgeAnchors = collectTurnNudgeAnchors(messages);
|
|
106
115
|
const persisted = await loadSessionState(sessionId, logger);
|
|
107
116
|
if (persisted === null) {
|
|
108
117
|
return;
|
|
@@ -110,6 +119,12 @@ export async function ensureSessionInitialized(client, state, sessionId, logger,
|
|
|
110
119
|
state.prune.tools = loadPruneMap(persisted.prune.tools, persisted.prune.toolIds);
|
|
111
120
|
state.prune.messages = loadPruneMap(persisted.prune.messages, persisted.prune.messageIds);
|
|
112
121
|
state.compressSummaries = persisted.compressSummaries || [];
|
|
122
|
+
state.nudges.contextLimitAnchors = new Set(persisted.nudges.contextLimitAnchors || []);
|
|
123
|
+
state.nudges.turnNudgeAnchors = new Set([
|
|
124
|
+
...state.nudges.turnNudgeAnchors,
|
|
125
|
+
...(persisted.nudges.turnNudgeAnchors || []),
|
|
126
|
+
]);
|
|
127
|
+
state.nudges.iterationNudgeAnchors = new Set(persisted.nudges.iterationNudgeAnchors || []);
|
|
113
128
|
state.stats = {
|
|
114
129
|
pruneTokenCounter: persisted.stats?.pruneTokenCounter || 0,
|
|
115
130
|
totalPruneTokens: persisted.stats?.totalPruneTokens || 0,
|