@tarquinen/opencode-dcp 3.0.3 → 3.1.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/README.md +23 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/compression-targets.d.ts +13 -0
- package/dist/lib/commands/compression-targets.d.ts.map +1 -0
- package/dist/lib/commands/compression-targets.js +97 -0
- package/dist/lib/commands/compression-targets.js.map +1 -0
- package/dist/lib/commands/context.js +1 -1
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/decompress.d.ts.map +1 -1
- package/dist/lib/commands/decompress.js +43 -28
- package/dist/lib/commands/decompress.js.map +1 -1
- package/dist/lib/commands/manual.d.ts.map +1 -1
- package/dist/lib/commands/manual.js +6 -6
- package/dist/lib/commands/manual.js.map +1 -1
- package/dist/lib/commands/recompress.d.ts.map +1 -1
- package/dist/lib/commands/recompress.js +34 -31
- package/dist/lib/commands/recompress.js.map +1 -1
- package/dist/lib/compress/index.d.ts +4 -0
- package/dist/lib/compress/index.d.ts.map +1 -0
- package/dist/lib/compress/index.js +3 -0
- package/dist/lib/compress/index.js.map +1 -0
- package/dist/lib/compress/message-utils.d.ts +8 -0
- package/dist/lib/compress/message-utils.d.ts.map +1 -0
- package/dist/lib/compress/message-utils.js +123 -0
- package/dist/lib/compress/message-utils.js.map +1 -0
- package/dist/lib/compress/message.d.ts +4 -0
- package/dist/lib/compress/message.d.ts.map +1 -0
- package/dist/lib/compress/message.js +78 -0
- package/dist/lib/compress/message.js.map +1 -0
- package/dist/lib/compress/pipeline.d.ts +29 -0
- package/dist/lib/compress/pipeline.d.ts.map +1 -0
- package/dist/lib/compress/pipeline.js +40 -0
- package/dist/lib/compress/pipeline.js.map +1 -0
- package/dist/lib/compress/protected-content.d.ts +5 -0
- package/dist/lib/compress/protected-content.d.ts.map +1 -0
- package/dist/lib/compress/protected-content.js +106 -0
- package/dist/lib/compress/protected-content.js.map +1 -0
- package/dist/lib/compress/range-utils.d.ts +10 -0
- package/dist/lib/compress/range-utils.d.ts.map +1 -0
- package/dist/lib/compress/range-utils.js +199 -0
- package/dist/lib/compress/range-utils.js.map +1 -0
- package/dist/lib/compress/range.d.ts +4 -0
- package/dist/lib/compress/range.d.ts.map +1 -0
- package/dist/lib/compress/range.js +86 -0
- package/dist/lib/compress/range.js.map +1 -0
- package/dist/lib/compress/search.d.ts +11 -0
- package/dist/lib/compress/search.d.ts.map +1 -0
- package/dist/lib/compress/search.js +204 -0
- package/dist/lib/compress/search.js.map +1 -0
- package/dist/lib/compress/state.d.ts +8 -0
- package/dist/lib/compress/state.d.ts.map +1 -0
- package/dist/lib/compress/state.js +197 -0
- package/dist/lib/compress/state.js.map +1 -0
- package/dist/lib/compress/types.d.ts +92 -0
- package/dist/lib/compress/types.d.ts.map +1 -0
- package/dist/lib/{tools → compress}/types.js.map +1 -1
- package/dist/lib/config.d.ts +5 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +24 -30
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +6 -8
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/message-ids.d.ts +1 -1
- package/dist/lib/message-ids.d.ts.map +1 -1
- package/dist/lib/message-ids.js +19 -3
- package/dist/lib/message-ids.js.map +1 -1
- package/dist/lib/messages/inject/inject.d.ts +3 -2
- package/dist/lib/messages/inject/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject/inject.js +31 -10
- package/dist/lib/messages/inject/inject.js.map +1 -1
- package/dist/lib/messages/inject/utils.d.ts +2 -2
- package/dist/lib/messages/inject/utils.d.ts.map +1 -1
- package/dist/lib/messages/inject/utils.js +102 -42
- package/dist/lib/messages/inject/utils.js.map +1 -1
- package/dist/lib/messages/priority.d.ts +13 -0
- package/dist/lib/messages/priority.d.ts.map +1 -0
- package/dist/lib/messages/priority.js +65 -0
- package/dist/lib/messages/priority.js.map +1 -0
- package/dist/lib/messages/prune.js +6 -4
- package/dist/lib/messages/prune.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +9 -2
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +41 -9
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/compress-message.d.ts +2 -0
- package/dist/lib/prompts/compress-message.d.ts.map +1 -0
- package/dist/lib/prompts/compress-message.js +44 -0
- package/dist/lib/prompts/compress-message.js.map +1 -0
- package/dist/lib/prompts/compress-range.d.ts +2 -0
- package/dist/lib/prompts/compress-range.d.ts.map +1 -0
- package/dist/lib/prompts/{compress.js → compress-range.js} +5 -29
- package/dist/lib/prompts/compress-range.js.map +1 -0
- package/dist/lib/prompts/internal-overlays.d.ts +2 -2
- package/dist/lib/prompts/internal-overlays.d.ts.map +1 -1
- package/dist/lib/prompts/internal-overlays.js +17 -11
- package/dist/lib/prompts/internal-overlays.js.map +1 -1
- package/dist/lib/prompts/message-priority-guidance.d.ts +2 -0
- package/dist/lib/prompts/message-priority-guidance.d.ts.map +1 -0
- package/dist/lib/prompts/message-priority-guidance.js +9 -0
- package/dist/lib/prompts/message-priority-guidance.js.map +1 -0
- package/dist/lib/prompts/store.d.ts +3 -2
- package/dist/lib/prompts/store.d.ts.map +1 -1
- package/dist/lib/prompts/store.js +30 -18
- package/dist/lib/prompts/store.js.map +1 -1
- package/dist/lib/prompts/system.d.ts +1 -1
- package/dist/lib/prompts/system.d.ts.map +1 -1
- package/dist/lib/prompts/system.js +26 -9
- package/dist/lib/prompts/system.js.map +1 -1
- package/dist/lib/shared-utils.d.ts +1 -0
- package/dist/lib/shared-utils.d.ts.map +1 -1
- package/dist/lib/shared-utils.js +7 -0
- package/dist/lib/shared-utils.js.map +1 -1
- package/dist/lib/state/persistence.d.ts +1 -0
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +1 -0
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/types.d.ts +6 -0
- 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 +31 -9
- 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 -5
- package/dist/lib/strategies/utils.d.ts.map +1 -1
- package/dist/lib/strategies/utils.js +24 -28
- package/dist/lib/strategies/utils.js.map +1 -1
- package/dist/lib/ui/notification.d.ts +8 -1
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +66 -13
- package/dist/lib/ui/notification.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/prompts/compress.d.ts +0 -2
- package/dist/lib/prompts/compress.d.ts.map +0 -1
- package/dist/lib/prompts/compress.js.map +0 -1
- package/dist/lib/strategies/supersede-writes.d.ts +0 -13
- package/dist/lib/strategies/supersede-writes.d.ts.map +0 -1
- package/dist/lib/strategies/supersede-writes.js +0 -94
- package/dist/lib/strategies/supersede-writes.js.map +0 -1
- package/dist/lib/tools/compress.d.ts +0 -4
- package/dist/lib/tools/compress.d.ts.map +0 -1
- package/dist/lib/tools/compress.js +0 -110
- package/dist/lib/tools/compress.js.map +0 -1
- package/dist/lib/tools/index.d.ts +0 -3
- package/dist/lib/tools/index.d.ts.map +0 -1
- package/dist/lib/tools/index.js +0 -2
- package/dist/lib/tools/index.js.map +0 -1
- package/dist/lib/tools/types.d.ts +0 -13
- package/dist/lib/tools/types.d.ts.map +0 -1
- package/dist/lib/tools/utils.d.ts +0 -80
- package/dist/lib/tools/utils.d.ts.map +0 -1
- package/dist/lib/tools/utils.js +0 -694
- package/dist/lib/tools/utils.js.map +0 -1
- /package/dist/lib/{tools → compress}/types.js +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { countAllMessageTokens } from "../strategies/utils";
|
|
2
|
+
import { isMessageCompacted, messageHasCompress } from "../shared-utils";
|
|
3
|
+
import { isIgnoredUserMessage, isProtectedUserMessage } from "./utils";
|
|
4
|
+
const MEDIUM_PRIORITY_MIN_TOKENS = 500;
|
|
5
|
+
const HIGH_PRIORITY_MIN_TOKENS = 5000;
|
|
6
|
+
export function buildPriorityMap(config, state, messages) {
|
|
7
|
+
if (config.compress.mode !== "message") {
|
|
8
|
+
return new Map();
|
|
9
|
+
}
|
|
10
|
+
const priorities = new Map();
|
|
11
|
+
for (const message of messages) {
|
|
12
|
+
if (isIgnoredUserMessage(message)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (isProtectedUserMessage(config, message)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (isMessageCompacted(state, message)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const rawMessageId = message.info.id;
|
|
22
|
+
if (typeof rawMessageId !== "string" || rawMessageId.length === 0) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const ref = state.messageIds.byRawId.get(rawMessageId);
|
|
26
|
+
if (!ref) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const tokenCount = countAllMessageTokens(message);
|
|
30
|
+
priorities.set(rawMessageId, {
|
|
31
|
+
ref,
|
|
32
|
+
tokenCount,
|
|
33
|
+
priority: messageHasCompress(message) ? "high" : classifyMessagePriority(tokenCount),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return priorities;
|
|
37
|
+
}
|
|
38
|
+
export function classifyMessagePriority(tokenCount) {
|
|
39
|
+
if (tokenCount >= HIGH_PRIORITY_MIN_TOKENS) {
|
|
40
|
+
return "high";
|
|
41
|
+
}
|
|
42
|
+
if (tokenCount >= MEDIUM_PRIORITY_MIN_TOKENS) {
|
|
43
|
+
return "medium";
|
|
44
|
+
}
|
|
45
|
+
return "low";
|
|
46
|
+
}
|
|
47
|
+
export function listPriorityRefsBeforeIndex(messages, priorities, anchorIndex, priority) {
|
|
48
|
+
const refs = [];
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
const upperBound = Math.max(0, Math.min(anchorIndex, messages.length));
|
|
51
|
+
for (let index = 0; index < upperBound; index++) {
|
|
52
|
+
const rawMessageId = messages[index]?.info.id;
|
|
53
|
+
if (typeof rawMessageId !== "string") {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const entry = priorities.get(rawMessageId);
|
|
57
|
+
if (!entry || entry.priority !== priority || seen.has(entry.ref)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
seen.add(entry.ref);
|
|
61
|
+
refs.push(entry.ref);
|
|
62
|
+
}
|
|
63
|
+
return refs;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=priority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority.js","sourceRoot":"","sources":["../../../lib/messages/priority.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAExE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEtE,MAAM,0BAA0B,GAAG,GAAG,CAAA;AACtC,MAAM,wBAAwB,GAAG,IAAI,CAAA;AAYrC,MAAM,UAAU,gBAAgB,CAC5B,MAAoB,EACpB,KAAmB,EACnB,QAAqB;IAErB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,IAAI,GAAG,EAAE,CAAA;IACpB,CAAC;IACD,MAAM,UAAU,GAA2B,IAAI,GAAG,EAAE,CAAA;IAEpD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAA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IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAEtE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAA;QAC7C,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YACnC,SAAQ;QACZ,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAC1C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/D,SAAQ;QACZ,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isMessageCompacted, getLastUserMessage } from "../shared-utils";
|
|
2
|
-
import { createSyntheticUserMessage } from "./utils";
|
|
2
|
+
import { createSyntheticUserMessage, replaceBlockIdsWithBlocked } from "./utils";
|
|
3
3
|
const PRUNED_TOOL_OUTPUT_REPLACEMENT = "[Output removed to save context - information superseded or no longer needed]";
|
|
4
4
|
const PRUNED_TOOL_ERROR_INPUT_REPLACEMENT = "[input removed due to failed tool call]";
|
|
5
5
|
const PRUNED_QUESTION_INPUT_REPLACEMENT = "[questions removed - see output for user's answers]";
|
|
6
6
|
export const prune = (state, logger, config, messages) => {
|
|
7
|
-
filterCompressedRanges(state, logger, messages);
|
|
7
|
+
filterCompressedRanges(state, logger, config, messages);
|
|
8
8
|
// pruneFullTool(state, logger, messages)
|
|
9
9
|
pruneToolOutputs(state, logger, messages);
|
|
10
10
|
pruneToolInputs(state, logger, messages);
|
|
@@ -120,7 +120,7 @@ const pruneToolErrors = (state, logger, messages) => {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
const filterCompressedRanges = (state, logger, messages) => {
|
|
123
|
+
const filterCompressedRanges = (state, logger, config, messages) => {
|
|
124
124
|
if (state.prune.messages.byMessageId.size === 0 &&
|
|
125
125
|
state.prune.messages.activeByAnchorMessageId.size === 0) {
|
|
126
126
|
return;
|
|
@@ -147,7 +147,9 @@ const filterCompressedRanges = (state, logger, messages) => {
|
|
|
147
147
|
const userMessage = getLastUserMessage(messages, msgIndex);
|
|
148
148
|
if (userMessage) {
|
|
149
149
|
const userInfo = userMessage.info;
|
|
150
|
-
const summaryContent =
|
|
150
|
+
const summaryContent = config.compress.mode === "message"
|
|
151
|
+
? replaceBlockIdsWithBlocked(rawSummaryContent)
|
|
152
|
+
: rawSummaryContent;
|
|
151
153
|
const summarySeed = `${summary.blockId}:${summary.anchorMessageId}`;
|
|
152
154
|
result.push(createSyntheticUserMessage(userMessage, summaryContent, userInfo.variant, summarySeed));
|
|
153
155
|
logger.info("Injected compress summary", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,0BAA0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C;QAED,6BAA6B;QAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,kCAAkC;IAClC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAA;IACnB,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PluginConfig } from "../config";
|
|
1
2
|
import type { SessionState, WithParts } from "../state";
|
|
2
3
|
export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string, variant?: string, stableSeed?: string) => WithParts;
|
|
3
4
|
export declare const createSyntheticTextPart: (baseMessage: WithParts, content: string, stableSeed?: string) => {
|
|
@@ -11,10 +12,16 @@ type MessagePart = WithParts["parts"][number];
|
|
|
11
12
|
type ToolPart = Extract<MessagePart, {
|
|
12
13
|
type: "tool";
|
|
13
14
|
}>;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
type TextPart = Extract<MessagePart, {
|
|
16
|
+
type: "text";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const appendToTextPart: (part: TextPart, injection: string) => boolean;
|
|
19
|
+
export declare const appendToLastTextPart: (message: WithParts, injection: string) => boolean;
|
|
20
|
+
export declare const appendToToolPart: (part: ToolPart, tag: string) => boolean;
|
|
16
21
|
export declare function buildToolIdList(state: SessionState, messages: WithParts[]): string[];
|
|
17
22
|
export declare const isIgnoredUserMessage: (message: WithParts) => boolean;
|
|
23
|
+
export declare function isProtectedUserMessage(config: PluginConfig, message: WithParts): boolean;
|
|
24
|
+
export declare const replaceBlockIdsWithBlocked: (text: string) => string;
|
|
18
25
|
export declare const stripHallucinationsFromString: (text: string) => string;
|
|
19
26
|
export declare const stripHallucinations: (messages: WithParts[]) => void;
|
|
20
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"
|
|
1
|
+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AAA;AAED,eAAO,MAAM,6BAA6B,GAAI,MAAM,MAAM,KAAG,MAE5D,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,UAAU,SAAS,EAAE,KAAG,IAgB3D,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { isMessageCompacted } from "../shared-utils";
|
|
3
3
|
const SUMMARY_ID_HASH_LENGTH = 16;
|
|
4
|
-
const DCP_MESSAGE_ID_TAG_REGEX = /<dcp-message-id>(?:m\d+|b\d
|
|
5
|
-
const
|
|
4
|
+
const DCP_MESSAGE_ID_TAG_REGEX = /<dcp-message-id(?=[\s>])[^>]*>(?:m\d+|b\d+|BLOCKED)<\/dcp-message-id>/g;
|
|
5
|
+
const DCP_BLOCK_ID_TAG_REGEX = /(<dcp-message-id(?=[\s>])[^>]*>)b\d+(<\/dcp-message-id>)/g;
|
|
6
|
+
const DCP_SYSTEM_REMINDER_REGEX = /<dcp-system-reminder(?=[\s>])[^>]*>[\s\S]*?<\/dcp-system-reminder>/g;
|
|
6
7
|
const generateStableId = (prefix, seed) => {
|
|
7
8
|
const hash = createHash("sha256").update(seed).digest("hex").slice(0, SUMMARY_ID_HASH_LENGTH);
|
|
8
9
|
return `${prefix}_${hash}`;
|
|
@@ -46,28 +47,47 @@ export const createSyntheticTextPart = (baseMessage, content, stableSeed) => {
|
|
|
46
47
|
text: content,
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
export const
|
|
50
|
-
if (part.
|
|
50
|
+
export const appendToTextPart = (part, injection) => {
|
|
51
|
+
if (typeof part.text !== "string") {
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
const normalizedInjection = injection.replace(/^\n+/, "");
|
|
55
|
+
if (!normalizedInjection.trim()) {
|
|
54
56
|
return false;
|
|
55
57
|
}
|
|
56
|
-
if (part.
|
|
58
|
+
if (part.text.includes(normalizedInjection)) {
|
|
57
59
|
return true;
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
const baseText = part.text.replace(/\n*$/, "");
|
|
62
|
+
part.text = baseText.length > 0 ? `${baseText}\n\n${normalizedInjection}` : normalizedInjection;
|
|
60
63
|
return true;
|
|
61
64
|
};
|
|
62
|
-
|
|
65
|
+
const findLastTextPart = (message) => {
|
|
63
66
|
for (let i = message.parts.length - 1; i >= 0; i--) {
|
|
64
67
|
const part = message.parts[i];
|
|
65
|
-
if (part.type === "
|
|
68
|
+
if (part.type === "text") {
|
|
66
69
|
return part;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
return null;
|
|
70
73
|
};
|
|
74
|
+
export const appendToLastTextPart = (message, injection) => {
|
|
75
|
+
const textPart = findLastTextPart(message);
|
|
76
|
+
if (!textPart) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return appendToTextPart(textPart, injection);
|
|
80
|
+
};
|
|
81
|
+
export const appendToToolPart = (part, tag) => {
|
|
82
|
+
if (part.state?.status !== "completed" || typeof part.state.output !== "string") {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (part.state.output.includes(tag)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
part.state.output = `${part.state.output}${tag}`;
|
|
89
|
+
return true;
|
|
90
|
+
};
|
|
71
91
|
export function buildToolIdList(state, messages) {
|
|
72
92
|
const toolIds = [];
|
|
73
93
|
for (const msg of messages) {
|
|
@@ -87,6 +107,9 @@ export function buildToolIdList(state, messages) {
|
|
|
87
107
|
return toolIds;
|
|
88
108
|
}
|
|
89
109
|
export const isIgnoredUserMessage = (message) => {
|
|
110
|
+
if (message.info.role !== "user") {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
90
113
|
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
91
114
|
if (parts.length === 0) {
|
|
92
115
|
return true;
|
|
@@ -98,6 +121,15 @@ export const isIgnoredUserMessage = (message) => {
|
|
|
98
121
|
}
|
|
99
122
|
return true;
|
|
100
123
|
};
|
|
124
|
+
export function isProtectedUserMessage(config, message) {
|
|
125
|
+
return (config.compress.mode === "message" &&
|
|
126
|
+
config.compress.protectUserMessages &&
|
|
127
|
+
message.info.role === "user" &&
|
|
128
|
+
!isIgnoredUserMessage(message));
|
|
129
|
+
}
|
|
130
|
+
export const replaceBlockIdsWithBlocked = (text) => {
|
|
131
|
+
return text.replace(DCP_BLOCK_ID_TAG_REGEX, "$1BLOCKED$2");
|
|
132
|
+
};
|
|
101
133
|
export const stripHallucinationsFromString = (text) => {
|
|
102
134
|
return text.replace(DCP_SYSTEM_REMINDER_REGEX, "").replace(DCP_MESSAGE_ID_TAG_REGEX, "");
|
|
103
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,wBAAwB,GAC1B,wEAAwE,CAAA;AAC5E,MAAM,sBAAsB,GAAG,2DAA2D,CAAA;AAC1F,MAAM,yBAAyB,GAC3B,qEAAqE,CAAA;AAEzE,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAU,EAAE;IAC9D,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAA;IAC7F,OAAO,GAAG,MAAM,IAAI,IAAI,EAAE,CAAA;AAC9B,CAAC,CAAA;AAED,M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BAA0B,GAAG,CAAC,IAAY,EAAU,EAAE;IAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAA;AAC9D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,IAAY,EAAU,EAAE;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAA;AAC5F,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAqB,EAAQ,EAAE;IAC/D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACxD,CAAC;YAED,IACI,IAAI,CAAC,IAAI,KAAK,MAAM;gBACpB,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW;gBAClC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,EACvC,CAAC;gBACC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YACxE,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const COMPRESS_MESSAGE = "Collapse selected individual messages in the conversation into detailed summaries.\n\nTHE SUMMARY\nYour summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings, tool outcomes, and user intent details that matter... EVERYTHING that preserves the value of the selected message after the raw message is removed.\n\nUSER INTENT FIDELITY\nWhen a selected message contains user intent, preserve that intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.\nDirectly quote short user instructions when that best preserves exact meaning.\n\nYet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool output, and repetition. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.\n\nMESSAGE IDS\nYou specify individual raw messages by ID using the injected IDs visible in the conversation:\n\n- `mNNNN` IDs identify raw messages\n\nEach message has an ID inside XML metadata tags like `<dcp-message-id priority=\"high\">m0007</dcp-message-id>`.\nThe ID tag appears at the end of the message it belongs to \u2014 it identifies the message above it, not the one below it.\nTreat these tags as message metadata only, not as content to summarize. Use only the inner `mNNNN` value as the `messageId`.\nThe `priority` attribute indicates relative context cost. Prefer higher-priority closed messages before lower-priority ones.\nMessages marked as `<dcp-message-id>BLOCKED</dcp-message-id>` cannot be compressed.\n\nRules:\n\n- Pick each `messageId` directly from injected IDs visible in context.\n- Only use raw message IDs of the form `mNNNN`.\n- Ignore XML attributes such as `priority` when copying the ID; use only the inner `mNNNN` value.\n- Do NOT use compressed block IDs like `bN`.\n- Do not invent IDs. Use only IDs that are present in context.\n- Do not target prior compressed blocks or block summaries.\n\nBATCHING\nSelect MANY messages in a single tool call when they are independently safe to compress.\nEach entry should summarize exactly one message, and the tool can receive as many entries as needed in one batch.\nWhen several messages are equally safe to compress, prefer higher-priority messages first.\n\nBecause each message is compressed independently:\n\n- Do not describe ranges\n- Do not use start/end boundaries\n- Do not use compressed block placeholders\n- Do not reference prior compressed blocks with `(bN)`\n";
|
|
2
|
+
//# sourceMappingURL=compress-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-message.d.ts","sourceRoot":"","sources":["../../../lib/prompts/compress-message.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,4+EA0C5B,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const COMPRESS_MESSAGE = `Collapse selected individual messages in the conversation into detailed summaries.
|
|
2
|
+
|
|
3
|
+
THE SUMMARY
|
|
4
|
+
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings, tool outcomes, and user intent details that matter... EVERYTHING that preserves the value of the selected message after the raw message is removed.
|
|
5
|
+
|
|
6
|
+
USER INTENT FIDELITY
|
|
7
|
+
When a selected message contains user intent, preserve that intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
8
|
+
Directly quote short user instructions when that best preserves exact meaning.
|
|
9
|
+
|
|
10
|
+
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool output, and repetition. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
11
|
+
|
|
12
|
+
MESSAGE IDS
|
|
13
|
+
You specify individual raw messages by ID using the injected IDs visible in the conversation:
|
|
14
|
+
|
|
15
|
+
- \`mNNNN\` IDs identify raw messages
|
|
16
|
+
|
|
17
|
+
Each message has an ID inside XML metadata tags like \`<dcp-message-id priority="high">m0007</dcp-message-id>\`.
|
|
18
|
+
The ID tag appears at the end of the message it belongs to — it identifies the message above it, not the one below it.
|
|
19
|
+
Treat these tags as message metadata only, not as content to summarize. Use only the inner \`mNNNN\` value as the \`messageId\`.
|
|
20
|
+
The \`priority\` attribute indicates relative context cost. Prefer higher-priority closed messages before lower-priority ones.
|
|
21
|
+
Messages marked as \`<dcp-message-id>BLOCKED</dcp-message-id>\` cannot be compressed.
|
|
22
|
+
|
|
23
|
+
Rules:
|
|
24
|
+
|
|
25
|
+
- Pick each \`messageId\` directly from injected IDs visible in context.
|
|
26
|
+
- Only use raw message IDs of the form \`mNNNN\`.
|
|
27
|
+
- Ignore XML attributes such as \`priority\` when copying the ID; use only the inner \`mNNNN\` value.
|
|
28
|
+
- Do NOT use compressed block IDs like \`bN\`.
|
|
29
|
+
- Do not invent IDs. Use only IDs that are present in context.
|
|
30
|
+
- Do not target prior compressed blocks or block summaries.
|
|
31
|
+
|
|
32
|
+
BATCHING
|
|
33
|
+
Select MANY messages in a single tool call when they are independently safe to compress.
|
|
34
|
+
Each entry should summarize exactly one message, and the tool can receive as many entries as needed in one batch.
|
|
35
|
+
When several messages are equally safe to compress, prefer higher-priority messages first.
|
|
36
|
+
|
|
37
|
+
Because each message is compressed independently:
|
|
38
|
+
|
|
39
|
+
- Do not describe ranges
|
|
40
|
+
- Do not use start/end boundaries
|
|
41
|
+
- Do not use compressed block placeholders
|
|
42
|
+
- Do not reference prior compressed blocks with \`(bN)\`
|
|
43
|
+
`;
|
|
44
|
+
//# sourceMappingURL=compress-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-message.js","sourceRoot":"","sources":["../../../lib/prompts/compress-message.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0C/B,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const COMPRESS_RANGE = "Collapse a range in the conversation into a detailed summary.\n\nTHE SUMMARY\nYour 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.\n\nUSER INTENT FIDELITY\nWhen 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.\nDirectly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.\n\nYet 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.\n\nCOMPRESSED BLOCK PLACEHOLDERS\nWhen the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:\n\n- `(bN)`\n\nCompressed block sections in context are clearly marked with a header:\n\n- `[Compressed conversation section]`\n\nCompressed block IDs always use the `bN` form (never `mNNNN`) and are represented in the same XML metadata tag format.\n\nRules:\n\n- Include every required block placeholder exactly once.\n- Do not invent placeholders for blocks outside the selected range.\n- Treat `(bN)` placeholders as RESERVED TOKENS. Do not emit `(bN)` text anywhere except intentional placeholders.\n- If you need to mention a block in prose, use plain text like `compressed bN` (not as a placeholder).\n- Preflight check before finalizing: the set of `(bN)` placeholders in your summary must exactly match the required set, with no duplicates.\n\nThese placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.\n\nFLOW PRESERVATION WITH PLACEHOLDERS\nWhen you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.\n\n- Treat each placeholder as a stand-in for a full conversation segment, not as a short label.\n- Ensure transitions before and after each placeholder preserve chronology and causality.\n- Do not write text that depends on the placeholder staying literal (for example, \"as noted in `(b2)`\").\n- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.\n\nBOUNDARY IDS\nYou specify boundaries by ID using the injected IDs visible in the conversation:\n\n- `mNNNN` IDs identify raw messages\n- `bN` IDs identify previously compressed blocks\n\nEach message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`.\nThe ID tag appears at the end of the message it belongs to \u2014 it identifies the message above it, not the one below it.\nTreat these tags as boundary metadata only, not as tool result content.\n\nRules:\n\n- Pick `startId` and `endId` directly from injected IDs in context.\n- IDs must exist in the current visible context.\n- `startId` must appear before `endId`.\n- Do not invent IDs. Use only IDs that are present in context.\n\nBATCHING\nWhen multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the `content` array of a single tool call. Each entry should have its own `startId`, `endId`, and `summary`.\n";
|
|
2
|
+
//# sourceMappingURL=compress-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-range.d.ts","sourceRoot":"","sources":["../../../lib/prompts/compress-range.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,6+GA2D1B,CAAA"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export const
|
|
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.
|
|
1
|
+
export const COMPRESS_RANGE = `Collapse a range in the conversation into a detailed summary.
|
|
7
2
|
|
|
8
3
|
THE SUMMARY
|
|
9
4
|
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.
|
|
@@ -43,25 +38,6 @@ When you use compressed block placeholders, write the surrounding summary text s
|
|
|
43
38
|
- Do not write text that depends on the placeholder staying literal (for example, "as noted in \`(b2)\`").
|
|
44
39
|
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
|
|
45
40
|
|
|
46
|
-
THE WAYS OF COMPRESS
|
|
47
|
-
Compress when a range is genuinely closed and the raw conversation has served its purpose:
|
|
48
|
-
|
|
49
|
-
Research concluded and findings are clear
|
|
50
|
-
Implementation finished and verified
|
|
51
|
-
Exploration exhausted and patterns understood
|
|
52
|
-
|
|
53
|
-
Compress smaller ranges when:
|
|
54
|
-
You need to discard dead-end noise without waiting for a whole chapter to close
|
|
55
|
-
You need to preserve key findings from a narrow slice while freeing context quickly
|
|
56
|
-
You can bound a stale range cleanly with injected IDs
|
|
57
|
-
|
|
58
|
-
Do NOT compress when:
|
|
59
|
-
You may need exact code, error messages, or file contents from the range in the immediate next steps
|
|
60
|
-
Work in that area is still active or likely to resume immediately
|
|
61
|
-
You cannot identify reliable boundaries yet
|
|
62
|
-
|
|
63
|
-
Before compressing, ask: _"Is this range closed enough to become summary-only right now?"_ Compression is irreversible. The summary replaces everything in the range.
|
|
64
|
-
|
|
65
41
|
BOUNDARY IDS
|
|
66
42
|
You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
67
43
|
|
|
@@ -69,6 +45,7 @@ You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
|
69
45
|
- \`bN\` IDs identify previously compressed blocks
|
|
70
46
|
|
|
71
47
|
Each message has an ID inside XML metadata tags like \`<dcp-message-id>...</dcp-message-id>\`.
|
|
48
|
+
The ID tag appears at the end of the message it belongs to — it identifies the message above it, not the one below it.
|
|
72
49
|
Treat these tags as boundary metadata only, not as tool result content.
|
|
73
50
|
|
|
74
51
|
Rules:
|
|
@@ -76,10 +53,9 @@ Rules:
|
|
|
76
53
|
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
77
54
|
- IDs must exist in the current visible context.
|
|
78
55
|
- \`startId\` must appear before \`endId\`.
|
|
79
|
-
- Prefer boundaries that produce short, closed ranges.
|
|
80
56
|
- Do not invent IDs. Use only IDs that are present in context.
|
|
81
57
|
|
|
82
|
-
|
|
83
|
-
When multiple independent ranges are ready and their boundaries do not overlap,
|
|
58
|
+
BATCHING
|
|
59
|
+
When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
|
|
84
60
|
`;
|
|
85
|
-
//# sourceMappingURL=compress.js.map
|
|
61
|
+
//# sourceMappingURL=compress-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-range.js","sourceRoot":"","sources":["../../../lib/prompts/compress-range.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D7B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const MANUAL_MODE_SYSTEM_OVERLAY = "<dcp-system-reminder>\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\nIssue exactly ONE compress call per manual trigger. Do NOT launch multiple compress calls in parallel. Each trigger grants a single compression; after it completes, wait for the next trigger.\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</dcp-system-reminder>\n";
|
|
2
2
|
export declare const SUBAGENT_SYSTEM_OVERLAY = "<dcp-system-reminder>\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</dcp-system-reminder>\n";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const RANGE_FORMAT_OVERLAY = "\nTHE FORMAT OF COMPRESS\n\n```\n{\n topic: string, // Short label (3-5 words) - e.g., \"Auth System Exploration\"\n content: [ // One or more ranges to compress\n {\n startId: string, // Boundary ID at range start: mNNNN or bN\n endId: string, // Boundary ID at range end: mNNNN or bN\n summary: string // Complete technical summary replacing all content in range\n }\n ]\n}\n```";
|
|
4
|
+
export declare const MESSAGE_FORMAT_OVERLAY = "\nTHE FORMAT OF COMPRESS\n\n```\n{\n topic: string, // Short label (3-5 words) for the overall batch\n content: [ // One or more messages to compress independently\n {\n messageId: string, // Raw message ID only: mNNNN (ignore metadata attributes like priority)\n topic: string, // Short label (3-5 words) for this one message summary\n summary: string // Complete technical summary replacing that one message\n }\n ]\n}\n```";
|
|
5
5
|
//# sourceMappingURL=internal-overlays.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-overlays.d.ts","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,mrBAStC,CAAA;AAED,eAAO,MAAM,uBAAuB,8VAOnC,CAAA;AAED,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"internal-overlays.d.ts","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,mrBAStC,CAAA;AAED,eAAO,MAAM,uBAAuB,8VAOnC,CAAA;AAED,eAAO,MAAM,oBAAoB,gcAc1B,CAAA;AAEP,eAAO,MAAM,sBAAsB,2eAc5B,CAAA"}
|
|
@@ -16,28 +16,34 @@ It is the only user message intentionally not assigned a message ID, and therefo
|
|
|
16
16
|
All subsequent messages in the session will have IDs.
|
|
17
17
|
</dcp-system-reminder>
|
|
18
18
|
`;
|
|
19
|
-
export const
|
|
19
|
+
export const RANGE_FORMAT_OVERLAY = `
|
|
20
20
|
THE FORMAT OF COMPRESS
|
|
21
21
|
|
|
22
22
|
\`\`\`
|
|
23
23
|
{
|
|
24
24
|
topic: string, // Short label (3-5 words) - e.g., "Auth System Exploration"
|
|
25
|
-
content:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
content: [ // One or more ranges to compress
|
|
26
|
+
{
|
|
27
|
+
startId: string, // Boundary ID at range start: mNNNN or bN
|
|
28
|
+
endId: string, // Boundary ID at range end: mNNNN or bN
|
|
29
|
+
summary: string // Complete technical summary replacing all content in range
|
|
30
|
+
}
|
|
31
|
+
]
|
|
30
32
|
}
|
|
31
33
|
\`\`\``;
|
|
32
|
-
export const
|
|
34
|
+
export const MESSAGE_FORMAT_OVERLAY = `
|
|
33
35
|
THE FORMAT OF COMPRESS
|
|
34
36
|
|
|
35
37
|
\`\`\`
|
|
36
38
|
{
|
|
37
|
-
topic: string, // Short label (3-5 words)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
topic: string, // Short label (3-5 words) for the overall batch
|
|
40
|
+
content: [ // One or more messages to compress independently
|
|
41
|
+
{
|
|
42
|
+
messageId: string, // Raw message ID only: mNNNN (ignore metadata attributes like priority)
|
|
43
|
+
topic: string, // Short label (3-5 words) for this one message summary
|
|
44
|
+
summary: string // Complete technical summary replacing that one message
|
|
45
|
+
}
|
|
46
|
+
]
|
|
41
47
|
}
|
|
42
48
|
\`\`\``;
|
|
43
49
|
//# sourceMappingURL=internal-overlays.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-overlays.js","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;CASzC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAED,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"internal-overlays.js","sourceRoot":"","sources":["../../../lib/prompts/internal-overlays.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;CASzC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;OAc7B,CAAA;AAEP,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;OAc/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-priority-guidance.d.ts","sourceRoot":"","sources":["../../../lib/prompts/message-priority-guidance.ts"],"names":[],"mappings":"AAAA,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ3F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function renderMessagePriorityGuidance(priorityLabel, refs) {
|
|
2
|
+
const refList = refs.length > 0 ? refs.join(", ") : "none";
|
|
3
|
+
return [
|
|
4
|
+
"Message priority context:",
|
|
5
|
+
"- Higher-priority older messages consume more context and should be compressed before lower-priority ones when safely closed.",
|
|
6
|
+
`- ${priorityLabel}-priority message IDs before this point: ${refList}`,
|
|
7
|
+
].join("\n");
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=message-priority-guidance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-priority-guidance.js","sourceRoot":"","sources":["../../../lib/prompts/message-priority-guidance.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,6BAA6B,CAAC,aAAqB,EAAE,IAAc;IAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAE1D,OAAO;QACH,2BAA2B;QAC3B,+HAA+H;QAC/H,KAAK,aAAa,4CAA4C,OAAO,EAAE;KAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAChB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Logger } from "../logger";
|
|
2
|
-
export type PromptKey = "system" | "compress" | "context-limit-nudge" | "turn-nudge" | "iteration-nudge";
|
|
2
|
+
export type PromptKey = "system" | "compress-range" | "compress-message" | "context-limit-nudge" | "turn-nudge" | "iteration-nudge";
|
|
3
3
|
export interface RuntimePrompts {
|
|
4
4
|
system: string;
|
|
5
|
-
|
|
5
|
+
compressRange: string;
|
|
6
|
+
compressMessage: string;
|
|
6
7
|
contextLimitNudge: string;
|
|
7
8
|
turnNudge: string;
|
|
8
9
|
iterationNudge: string;
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../lib/prompts/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AASvC,MAAM,MAAM,SAAS,GACf,QAAQ,GACR,gBAAgB,GAChB,kBAAkB,GAClB,qBAAqB,GACrB,YAAY,GACZ,iBAAiB,CAAA;AA8BvB,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;CAC1B;AAqDD,eAAO,MAAM,WAAW,EAAE,SAAS,EAOlC,CAAA;AA8MD,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"}
|