@tarquinen/opencode-dcp 1.3.0-beta.1 → 1.3.1-beta.2
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 +12 -11
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/context.js +36 -23
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/config.d.ts +7 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +47 -46
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +8 -29
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/messages/inject.d.ts +7 -0
- package/dist/lib/messages/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject.js +67 -62
- package/dist/lib/messages/inject.js.map +1 -1
- package/dist/lib/messages/prune.js +7 -7
- package/dist/lib/messages/prune.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +22 -2
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +46 -12
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/compress-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/compress-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/compress-tool-spec.js +58 -0
- package/dist/lib/prompts/compress-tool-spec.js.map +1 -0
- package/dist/lib/prompts/distill-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/distill-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/distill-tool-spec.js +48 -0
- package/dist/lib/prompts/distill-tool-spec.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +7 -0
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +28 -36
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/nudge.generated.d.ts +2 -0
- package/dist/lib/prompts/nudge.generated.d.ts.map +1 -0
- package/dist/lib/prompts/nudge.generated.js +17 -0
- package/dist/lib/prompts/nudge.generated.js.map +1 -0
- package/dist/lib/prompts/prune-tool-spec.d.ts +2 -0
- package/dist/lib/prompts/prune-tool-spec.d.ts.map +1 -0
- package/dist/lib/prompts/prune-tool-spec.js +40 -0
- package/dist/lib/prompts/prune-tool-spec.js.map +1 -0
- package/dist/lib/prompts/system.generated.d.ts +2 -0
- package/dist/lib/prompts/system.generated.d.ts.map +1 -0
- package/dist/lib/prompts/system.generated.js +90 -0
- package/dist/lib/prompts/system.generated.js.map +1 -0
- package/dist/lib/state/persistence.d.ts +2 -2
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +1 -1
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/state.js +3 -3
- 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 +2 -5
- package/dist/lib/state/tool-cache.js.map +1 -1
- package/dist/lib/state/types.d.ts +2 -2
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/state/utils.js +1 -1
- package/dist/lib/state/utils.js.map +1 -1
- package/dist/lib/strategies/index.d.ts +1 -1
- package/dist/lib/strategies/index.d.ts.map +1 -1
- package/dist/lib/strategies/index.js +1 -1
- package/dist/lib/strategies/index.js.map +1 -1
- package/dist/lib/tools/compress.d.ts +4 -0
- package/dist/lib/tools/compress.d.ts.map +1 -0
- package/dist/lib/tools/{squash.js → compress.js} +22 -22
- package/dist/lib/tools/compress.js.map +1 -0
- package/dist/lib/tools/{discard.d.ts → distill.d.ts} +2 -2
- package/dist/lib/tools/distill.d.ts.map +1 -0
- package/dist/lib/tools/{extract.js → distill.js} +12 -7
- package/dist/lib/tools/{extract.js.map → distill.js.map} +1 -1
- package/dist/lib/tools/index.d.ts +3 -3
- package/dist/lib/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/index.js +3 -3
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/prune.d.ts +4 -0
- package/dist/lib/tools/prune.d.ts.map +1 -0
- package/dist/lib/tools/{discard.js → prune.js} +6 -6
- package/dist/lib/tools/prune.js.map +1 -0
- package/dist/lib/tools/utils.d.ts +3 -3
- package/dist/lib/tools/utils.d.ts.map +1 -1
- package/dist/lib/tools/utils.js +7 -7
- package/dist/lib/tools/utils.js.map +1 -1
- 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 +7 -7
- package/dist/lib/ui/notification.js.map +1 -1
- package/package.json +6 -4
- package/dist/lib/prompts/discard-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/discard-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/discard-tool-spec.js +0 -18
- package/dist/lib/prompts/discard-tool-spec.js.map +0 -1
- package/dist/lib/prompts/extract-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/extract-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/extract-tool-spec.js +0 -23
- package/dist/lib/prompts/extract-tool-spec.js.map +0 -1
- package/dist/lib/prompts/nudge/all.d.ts +0 -2
- package/dist/lib/prompts/nudge/all.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/all.js +0 -9
- package/dist/lib/prompts/nudge/all.js.map +0 -1
- package/dist/lib/prompts/nudge/discard-extract.d.ts +0 -2
- package/dist/lib/prompts/nudge/discard-extract.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/discard-extract.js +0 -8
- package/dist/lib/prompts/nudge/discard-extract.js.map +0 -1
- package/dist/lib/prompts/nudge/discard-squash.d.ts +0 -2
- package/dist/lib/prompts/nudge/discard-squash.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/discard-squash.js +0 -8
- package/dist/lib/prompts/nudge/discard-squash.js.map +0 -1
- package/dist/lib/prompts/nudge/discard.d.ts +0 -2
- package/dist/lib/prompts/nudge/discard.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/discard.js +0 -8
- package/dist/lib/prompts/nudge/discard.js.map +0 -1
- package/dist/lib/prompts/nudge/extract-squash.d.ts +0 -2
- package/dist/lib/prompts/nudge/extract-squash.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/extract-squash.js +0 -8
- package/dist/lib/prompts/nudge/extract-squash.js.map +0 -1
- package/dist/lib/prompts/nudge/extract.d.ts +0 -2
- package/dist/lib/prompts/nudge/extract.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/extract.js +0 -8
- package/dist/lib/prompts/nudge/extract.js.map +0 -1
- package/dist/lib/prompts/nudge/squash.d.ts +0 -2
- package/dist/lib/prompts/nudge/squash.d.ts.map +0 -1
- package/dist/lib/prompts/nudge/squash.js +0 -8
- package/dist/lib/prompts/nudge/squash.js.map +0 -1
- package/dist/lib/prompts/squash-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/squash-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/squash-tool-spec.js +0 -33
- package/dist/lib/prompts/squash-tool-spec.js.map +0 -1
- package/dist/lib/prompts/system/all.d.ts +0 -2
- package/dist/lib/prompts/system/all.d.ts.map +0 -1
- package/dist/lib/prompts/system/all.js +0 -26
- package/dist/lib/prompts/system/all.js.map +0 -1
- package/dist/lib/prompts/system/discard-extract.d.ts +0 -2
- package/dist/lib/prompts/system/discard-extract.d.ts.map +0 -1
- package/dist/lib/prompts/system/discard-extract.js +0 -26
- package/dist/lib/prompts/system/discard-extract.js.map +0 -1
- package/dist/lib/prompts/system/discard-squash.d.ts +0 -2
- package/dist/lib/prompts/system/discard-squash.d.ts.map +0 -1
- package/dist/lib/prompts/system/discard-squash.js +0 -25
- package/dist/lib/prompts/system/discard-squash.js.map +0 -1
- package/dist/lib/prompts/system/discard.d.ts +0 -2
- package/dist/lib/prompts/system/discard.d.ts.map +0 -1
- package/dist/lib/prompts/system/discard.js +0 -27
- package/dist/lib/prompts/system/discard.js.map +0 -1
- package/dist/lib/prompts/system/extract-squash.d.ts +0 -2
- package/dist/lib/prompts/system/extract-squash.d.ts.map +0 -1
- package/dist/lib/prompts/system/extract-squash.js +0 -25
- package/dist/lib/prompts/system/extract-squash.js.map +0 -1
- package/dist/lib/prompts/system/extract.d.ts +0 -2
- package/dist/lib/prompts/system/extract.d.ts.map +0 -1
- package/dist/lib/prompts/system/extract.js +0 -27
- package/dist/lib/prompts/system/extract.js.map +0 -1
- package/dist/lib/prompts/system/squash.d.ts +0 -2
- package/dist/lib/prompts/system/squash.d.ts.map +0 -1
- package/dist/lib/prompts/system/squash.js +0 -27
- package/dist/lib/prompts/system/squash.js.map +0 -1
- package/dist/lib/tools/discard.d.ts.map +0 -1
- package/dist/lib/tools/discard.js.map +0 -1
- package/dist/lib/tools/extract.d.ts +0 -4
- package/dist/lib/tools/extract.d.ts.map +0 -1
- package/dist/lib/tools/squash.d.ts +0 -4
- package/dist/lib/tools/squash.d.ts.map +0 -1
- package/dist/lib/tools/squash.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../../lib/tools/compress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAe/C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAyIjF"}
|
|
@@ -4,22 +4,22 @@ import { saveSessionState } from "../state/persistence";
|
|
|
4
4
|
import { loadPrompt } from "../prompts";
|
|
5
5
|
import { estimateTokensBatch, getCurrentParams } from "../strategies/utils";
|
|
6
6
|
import { collectContentInRange, findStringInMessages, collectToolIdsInRange, collectMessageIdsInRange, } from "./utils";
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
export function
|
|
7
|
+
import { sendCompressNotification } from "../ui/notification";
|
|
8
|
+
const COMPRESS_TOOL_DESCRIPTION = loadPrompt("compress-tool-spec");
|
|
9
|
+
export function createCompressTool(ctx) {
|
|
10
10
|
return tool({
|
|
11
|
-
description:
|
|
11
|
+
description: COMPRESS_TOOL_DESCRIPTION,
|
|
12
12
|
args: {
|
|
13
13
|
input: tool.schema
|
|
14
14
|
.array(tool.schema.string())
|
|
15
15
|
.length(4)
|
|
16
|
-
.describe("[startString, endString, topic, summary] - 4 required strings: (1) startString: unique text from conversation marking range start, (2) endString: unique text marking range end, (3) topic: short 3-5 word label for UI, (4) summary: comprehensive text replacing all
|
|
16
|
+
.describe("[startString, endString, topic, summary] - 4 required strings: (1) startString: unique text from conversation marking range start, (2) endString: unique text marking range end, (3) topic: short 3-5 word label for UI, (4) summary: comprehensive text replacing all compressed content"),
|
|
17
17
|
},
|
|
18
18
|
async execute(args, toolCtx) {
|
|
19
19
|
const { client, state, logger } = ctx;
|
|
20
20
|
const sessionId = toolCtx.sessionID;
|
|
21
21
|
const [startString, endString, topic, summary] = args.input;
|
|
22
|
-
logger.info("
|
|
22
|
+
logger.info("Compress tool invoked");
|
|
23
23
|
// logger.info(
|
|
24
24
|
// JSON.stringify({
|
|
25
25
|
// startString: startString?.substring(0, 50) + "...",
|
|
@@ -33,8 +33,8 @@ export function createSquashTool(ctx) {
|
|
|
33
33
|
});
|
|
34
34
|
const messages = messagesResponse.data || messagesResponse;
|
|
35
35
|
await ensureSessionInitialized(client, state, sessionId, logger, messages);
|
|
36
|
-
const startResult = findStringInMessages(messages, startString, logger, state.
|
|
37
|
-
const endResult = findStringInMessages(messages, endString, logger, state.
|
|
36
|
+
const startResult = findStringInMessages(messages, startString, logger, state.compressSummaries, "startString");
|
|
37
|
+
const endResult = findStringInMessages(messages, endString, logger, state.compressSummaries, "endString");
|
|
38
38
|
if (startResult.messageIndex > endResult.messageIndex) {
|
|
39
39
|
throw new Error(`startString appears after endString in the conversation. Start must come before end.`);
|
|
40
40
|
}
|
|
@@ -43,39 +43,39 @@ export function createSquashTool(ctx) {
|
|
|
43
43
|
state.prune.toolIds.push(...containedToolIds);
|
|
44
44
|
state.prune.messageIds.push(...containedMessageIds);
|
|
45
45
|
// Remove any existing summaries whose anchors are now inside this range
|
|
46
|
-
// This prevents duplicate injections when a larger
|
|
47
|
-
const removedSummaries = state.
|
|
46
|
+
// This prevents duplicate injections when a larger compress subsumes a smaller one
|
|
47
|
+
const removedSummaries = state.compressSummaries.filter((s) => containedMessageIds.includes(s.anchorMessageId));
|
|
48
48
|
if (removedSummaries.length > 0) {
|
|
49
|
-
// logger.info("Removing subsumed
|
|
49
|
+
// logger.info("Removing subsumed compress summaries", {
|
|
50
50
|
// count: removedSummaries.length,
|
|
51
51
|
// anchorIds: removedSummaries.map((s) => s.anchorMessageId),
|
|
52
52
|
// })
|
|
53
|
-
state.
|
|
53
|
+
state.compressSummaries = state.compressSummaries.filter((s) => !containedMessageIds.includes(s.anchorMessageId));
|
|
54
54
|
}
|
|
55
|
-
const
|
|
55
|
+
const compressSummary = {
|
|
56
56
|
anchorMessageId: startResult.messageId,
|
|
57
57
|
summary: summary,
|
|
58
58
|
};
|
|
59
|
-
state.
|
|
59
|
+
state.compressSummaries.push(compressSummary);
|
|
60
60
|
const contentsToTokenize = collectContentInRange(messages, startResult.messageIndex, endResult.messageIndex);
|
|
61
|
-
const
|
|
62
|
-
state.stats.pruneTokenCounter +=
|
|
61
|
+
const estimatedCompressedTokens = estimateTokensBatch(contentsToTokenize);
|
|
62
|
+
state.stats.pruneTokenCounter += estimatedCompressedTokens;
|
|
63
63
|
const currentParams = getCurrentParams(state, messages, logger);
|
|
64
|
-
await
|
|
64
|
+
await sendCompressNotification(client, logger, ctx.config, state, sessionId, containedToolIds, containedMessageIds, topic, summary, startResult, endResult, messages.length, currentParams);
|
|
65
65
|
state.stats.totalPruneTokens += state.stats.pruneTokenCounter;
|
|
66
66
|
state.stats.pruneTokenCounter = 0;
|
|
67
67
|
state.nudgeCounter = 0;
|
|
68
|
-
// logger.info("
|
|
68
|
+
// logger.info("Compress range created", {
|
|
69
69
|
// startMessageId: startResult.messageId,
|
|
70
70
|
// endMessageId: endResult.messageId,
|
|
71
71
|
// toolIdsRemoved: containedToolIds.length,
|
|
72
72
|
// messagesInRange: containedMessageIds.length,
|
|
73
|
-
// estimatedTokens:
|
|
73
|
+
// estimatedTokens: estimatedCompressedTokens,
|
|
74
74
|
// })
|
|
75
75
|
saveSessionState(state, logger).catch((err) => logger.error("Failed to persist state", { error: err.message }));
|
|
76
|
-
const
|
|
77
|
-
return `
|
|
76
|
+
const messagesCompressed = endResult.messageIndex - startResult.messageIndex + 1;
|
|
77
|
+
return `Compressed ${messagesCompressed} messages (${containedToolIds.length} tool calls) into summary. The content will be replaced with your summary.`;
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
//# sourceMappingURL=
|
|
81
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../lib/tools/compress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAG1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,EACH,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,MAAM,yBAAyB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;AAElE,MAAM,UAAU,kBAAkB,CAAC,GAAqB;IACpD,OAAO,IAAI,CAAC;QACR,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE;YACF,KAAK,EAAE,IAAI,CAAC,MA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yB,CAAA;YAE1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC/D,MAAM,wBAAwB,CAC1B,MAAM,EACN,MAAM,EACN,GAAG,CAAC,MAAM,EACV,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,QAAQ,CAAC,MAAM,EACf,aAAa,CAChB,CAAA;YAED,KAAK,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAA;YAC7D,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,CAAC,CAAA;YACjC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAA;YAEtB,0CAA0C;YAC1C,6CAA6C;YAC7C,yCAAyC;YACzC,+CAA+C;YAC/C,mDAAmD;YACnD,kDAAkD;YAClD,KAAK;YAEL,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAC1C,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAClE,CAAA;YAED,MAAM,kBAAkB,GAAG,SAAS,CAAC,YAAY,GAAG,WAAW,CAAC,YAAY,GAAG,CAAC,CAAA;YAChF,OAAO,cAAc,kBAAkB,cAAc,gBAAgB,CAAC,MAAM,4EAA4E,CAAA;QAC5J,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
2
|
import type { PruneToolContext } from "./types";
|
|
3
|
-
export declare function
|
|
4
|
-
//# sourceMappingURL=
|
|
3
|
+
export declare function createDistillTool(ctx: PruneToolContext): ReturnType<typeof tool>;
|
|
4
|
+
//# sourceMappingURL=distill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distill.d.ts","sourceRoot":"","sources":["../../../lib/tools/distill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAiDhF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
2
|
import { executePruneOperation } from "./prune-shared";
|
|
3
3
|
import { loadPrompt } from "../prompts";
|
|
4
|
-
const
|
|
5
|
-
export function
|
|
4
|
+
const DISTILL_TOOL_DESCRIPTION = loadPrompt("distill-tool-spec");
|
|
5
|
+
export function createDistillTool(ctx) {
|
|
6
6
|
return tool({
|
|
7
|
-
description:
|
|
7
|
+
description: DISTILL_TOOL_DESCRIPTION,
|
|
8
8
|
args: {
|
|
9
9
|
ids: tool.schema
|
|
10
10
|
.array(tool.schema.string())
|
|
11
11
|
.min(1)
|
|
12
|
-
.describe("Numeric IDs as strings to
|
|
12
|
+
.describe("Numeric IDs as strings to distill from the <prunable-tools> list"),
|
|
13
13
|
distillation: tool.schema
|
|
14
14
|
.array(tool.schema.string())
|
|
15
15
|
.min(1)
|
|
@@ -17,14 +17,19 @@ export function createExtractTool(ctx) {
|
|
|
17
17
|
},
|
|
18
18
|
async execute(args, toolCtx) {
|
|
19
19
|
if (!args.distillation || args.distillation.length === 0) {
|
|
20
|
-
ctx.logger.debug("
|
|
20
|
+
ctx.logger.debug("Distill tool called without distillation: " + JSON.stringify(args));
|
|
21
21
|
throw new Error("Missing distillation. You must provide a distillation string for each ID.");
|
|
22
22
|
}
|
|
23
|
+
if (!Array.isArray(args.distillation)) {
|
|
24
|
+
ctx.logger.debug("Distill tool called with non-array distillation: " + JSON.stringify(args));
|
|
25
|
+
throw new Error(`Invalid distillation format: expected an array of strings, got ${typeof args.distillation}. ` +
|
|
26
|
+
`Example: distillation: ["summary for id 0", "summary for id 1"]`);
|
|
27
|
+
}
|
|
23
28
|
// Log the distillation for debugging/analysis
|
|
24
29
|
ctx.logger.info("Distillation data received:");
|
|
25
30
|
ctx.logger.info(JSON.stringify(args.distillation, null, 2));
|
|
26
|
-
return executePruneOperation(ctx, toolCtx, args.ids, "extraction", "
|
|
31
|
+
return executePruneOperation(ctx, toolCtx, args.ids, "extraction", "Distill", args.distillation);
|
|
27
32
|
},
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=distill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"distill.js","sourceRoot":"","sources":["../../../lib/tools/distill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,wBAAwB,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;AAEhE,MAAM,UAAU,iBAAiB,CAAC,GAAqB;IACnD,OAAO,IAAI,CAAC;QACR,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE;YACF,GAAG,EAAE,IAAI,CAAC,MAAM;iBACX,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,kEAAkE,CAAC;YACjF,YAAY,EAAE,IAAI,CAAC,MAAM;iBACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CACL,mGAAmG,CACtG;SACR;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO;YACvB,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvD,GAAG,CAAC,MAAM,CAAC,KAAK,CACZ,4CAA4C,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CACtE,CAAA;gBACD,MAAM,IAAI,KAAK,CACX,2EAA2E,CAC9E,CAAA;YACL,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CACZ,mDAAmD,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAC7E,CAAA;gBACD,MAAM,IAAI,KAAK,CACX,kEAAkE,OAAO,IAAI,CAAC,YAAY,IAAI;oBAC1F,iEAAiE,CACxE,CAAA;YACL,CAAC;YAED,8CAA8C;YAC9C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;YAC9C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;YAE3D,OAAO,qBAAqB,CACxB,GAAG,EACH,OAAO,EACP,IAAI,CAAC,GAAG,EACR,YAA2B,EAC3B,SAAS,EACT,IAAI,CAAC,YAAY,CACpB,CAAA;QACL,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { PruneToolContext } from "./types";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { createPruneTool } from "./prune";
|
|
3
|
+
export { createDistillTool } from "./distill";
|
|
4
|
+
export { createCompressTool } from "./compress";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/lib/tools/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { createPruneTool } from "./prune";
|
|
2
|
+
export { createDistillTool } from "./distill";
|
|
3
|
+
export { createCompressTool } from "./compress";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../lib/tools/prune.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAgB9E"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
2
|
import { executePruneOperation } from "./prune-shared";
|
|
3
3
|
import { loadPrompt } from "../prompts";
|
|
4
|
-
const
|
|
5
|
-
export function
|
|
4
|
+
const PRUNE_TOOL_DESCRIPTION = loadPrompt("prune-tool-spec");
|
|
5
|
+
export function createPruneTool(ctx) {
|
|
6
6
|
return tool({
|
|
7
|
-
description:
|
|
7
|
+
description: PRUNE_TOOL_DESCRIPTION,
|
|
8
8
|
args: {
|
|
9
9
|
ids: tool.schema
|
|
10
10
|
.array(tool.schema.string())
|
|
11
11
|
.min(1)
|
|
12
|
-
.describe("Numeric IDs as strings from the <prunable-tools> list to
|
|
12
|
+
.describe("Numeric IDs as strings from the <prunable-tools> list to prune"),
|
|
13
13
|
},
|
|
14
14
|
async execute(args, toolCtx) {
|
|
15
15
|
const numericIds = args.ids;
|
|
16
16
|
const reason = "noise";
|
|
17
|
-
return executePruneOperation(ctx, toolCtx, numericIds, reason, "
|
|
17
|
+
return executePruneOperation(ctx, toolCtx, numericIds, reason, "Prune");
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=prune.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/tools/prune.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,sBAAsB,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;AAE5D,MAAM,UAAU,eAAe,CAAC,GAAqB;IACjD,OAAO,IAAI,CAAC;QACR,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE;YACF,GAAG,EAAE,IAAI,CAAC,MAAM;iBACX,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,gEAAgE,CAAC;SAClF;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO;YACvB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAA;YAC3B,MAAM,MAAM,GAAG,OAAO,CAAA;YAEtB,OAAO,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC3E,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { WithParts,
|
|
1
|
+
import type { WithParts, CompressSummary } from "../state";
|
|
2
2
|
import type { Logger } from "../logger";
|
|
3
3
|
/**
|
|
4
4
|
* Searches messages for a string and returns the message ID where it's found.
|
|
5
5
|
* Searches in text parts, tool outputs, tool inputs, and other textual content.
|
|
6
|
-
* Also searches through existing
|
|
6
|
+
* Also searches through existing compress summaries to enable chained compression.
|
|
7
7
|
* Throws an error if the string is not found or found more than once.
|
|
8
8
|
*/
|
|
9
|
-
export declare function findStringInMessages(messages: WithParts[], searchString: string, logger: Logger,
|
|
9
|
+
export declare function findStringInMessages(messages: WithParts[], searchString: string, logger: Logger, compressSummaries: CompressSummary[] | undefined, stringType: "startString" | "endString"): {
|
|
10
10
|
messageId: string;
|
|
11
11
|
messageIndex: number;
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/tools/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/tools/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,SAAS,EAAE,EACrB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,eAAe,EAAE,YAAK,EACzC,UAAU,EAAE,aAAa,GAAG,WAAW,GACxC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA2D7C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,SAAS,EAAE,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACjB,MAAM,EAAE,CAiBV;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,QAAQ,EAAE,SAAS,EAAE,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACjB,MAAM,EAAE,CAWV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,SAAS,EAAE,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACjB,MAAM,EAAE,CAkCV"}
|
package/dist/lib/tools/utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Searches messages for a string and returns the message ID where it's found.
|
|
3
3
|
* Searches in text parts, tool outputs, tool inputs, and other textual content.
|
|
4
|
-
* Also searches through existing
|
|
4
|
+
* Also searches through existing compress summaries to enable chained compression.
|
|
5
5
|
* Throws an error if the string is not found or found more than once.
|
|
6
6
|
*/
|
|
7
|
-
export function findStringInMessages(messages, searchString, logger,
|
|
7
|
+
export function findStringInMessages(messages, searchString, logger, compressSummaries = [], stringType) {
|
|
8
8
|
const matches = [];
|
|
9
|
-
// First, search through existing
|
|
10
|
-
// This allows referencing text from previous
|
|
11
|
-
for (const summary of
|
|
9
|
+
// First, search through existing compress summaries
|
|
10
|
+
// This allows referencing text from previous compress operations
|
|
11
|
+
for (const summary of compressSummaries) {
|
|
12
12
|
if (summary.summary.includes(searchString)) {
|
|
13
13
|
const anchorIndex = messages.findIndex((m) => m.info.id === summary.anchorMessageId);
|
|
14
14
|
if (anchorIndex !== -1) {
|
|
@@ -45,10 +45,10 @@ export function findStringInMessages(messages, searchString, logger, squashSumma
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (matches.length === 0) {
|
|
48
|
-
throw new Error(
|
|
48
|
+
throw new Error(`${stringType} not found in conversation. Make sure the string exists and is spelled exactly as it appears.`);
|
|
49
49
|
}
|
|
50
50
|
if (matches.length > 1) {
|
|
51
|
-
throw new Error(`
|
|
51
|
+
throw new Error(`Found multiple matches for ${stringType}. Provide more surrounding context to uniquely identify the intended match.`);
|
|
52
52
|
}
|
|
53
53
|
return matches[0];
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/tools/utils.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAChC,QAAqB,EACrB,YAAoB,EACpB,MAAc,EACd,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/tools/utils.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAChC,QAAqB,EACrB,YAAoB,EACpB,MAAc,EACd,oBAAuC,EAAE,EACzC,UAAuC;IAEvC,MAAM,OAAO,GAAkD,EAAE,CAAA;IAEjE,oDAAoD;IACpD,iEAAiE;IACjE,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,C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AC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC5B,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAY,CAAA;gBACnC,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;oBACnB,QAAQ,CAAC,IAAI,CACT,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ;wBAC/B,CAAC,CAAC,SAAS,CAAC,KAAK;wBACjB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CACxC,CAAA;gBACL,CAAC;gBACD,IAAI,SAAS,EAAE,MAAM,KAAK,WAAW,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;oBACzD,QAAQ,CAAC,IAAI,CACT,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ;wBAChC,CAAC,CAAC,SAAS,CAAC,MAAM;wBAClB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CACzC,CAAA;gBACL,CAAC;qBAAM,IAAI,SAAS,EAAE,MAAM,KAAK,OAAO,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;oBAC3D,QAAQ,CAAC,IAAI,CACT,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ;wBAC/B,CAAC,CAAC,SAAS,CAAC,KAAK;wBACjB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CACxC,CAAA;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC"}
|
|
@@ -5,6 +5,6 @@ import { PluginConfig } from "../config";
|
|
|
5
5
|
export type PruneReason = "completion" | "noise" | "extraction";
|
|
6
6
|
export declare const PRUNE_REASON_LABELS: Record<PruneReason, string>;
|
|
7
7
|
export declare function sendUnifiedNotification(client: any, logger: Logger, config: PluginConfig, state: SessionState, sessionId: string, pruneToolIds: string[], toolMetadata: Map<string, ToolParameterEntry>, reason: PruneReason | undefined, params: any, workingDirectory: string, distillation?: string[]): Promise<boolean>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function sendCompressNotification(client: any, logger: Logger, config: PluginConfig, state: SessionState, sessionId: string, toolIds: string[], messageIds: string[], topic: string, summary: string, startResult: any, endResult: any, totalMessages: number, params: any): Promise<boolean>;
|
|
9
9
|
export declare function sendIgnoredMessage(client: any, sessionID: string, text: string, params: any, logger: Logger): Promise<void>;
|
|
10
10
|
//# sourceMappingURL=notification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../../lib/ui/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAS5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,YAAY,CAAA;AAC/D,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAI3D,CAAA;AA+CD,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7C,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,MAAM,EAAE,GAAG,EACX,gBAAgB,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,wBAAsB,
|
|
1
|
+
{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AAG,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
|
@@ -6,7 +6,7 @@ export const PRUNE_REASON_LABELS = {
|
|
|
6
6
|
};
|
|
7
7
|
function buildMinimalMessage(state, reason, distillation, showDistillation) {
|
|
8
8
|
const extractedTokens = countDistillationTokens(distillation);
|
|
9
|
-
const extractedSuffix = extractedTokens > 0 ? ` (
|
|
9
|
+
const extractedSuffix = extractedTokens > 0 ? ` (distilled ${formatTokenCount(extractedTokens)})` : "";
|
|
10
10
|
const reasonSuffix = reason && extractedTokens === 0 ? ` — ${PRUNE_REASON_LABELS[reason]}` : "";
|
|
11
11
|
let message = formatStatsHeader(state.stats.totalPruneTokens, state.stats.pruneTokenCounter) +
|
|
12
12
|
reasonSuffix +
|
|
@@ -18,7 +18,7 @@ function buildDetailedMessage(state, reason, pruneToolIds, toolMetadata, working
|
|
|
18
18
|
if (pruneToolIds.length > 0) {
|
|
19
19
|
const pruneTokenCounterStr = `~${formatTokenCount(state.stats.pruneTokenCounter)}`;
|
|
20
20
|
const extractedTokens = countDistillationTokens(distillation);
|
|
21
|
-
const extractedSuffix = extractedTokens > 0 ? `,
|
|
21
|
+
const extractedSuffix = extractedTokens > 0 ? `, distilled ${formatTokenCount(extractedTokens)}` : "";
|
|
22
22
|
const reasonLabel = reason && extractedTokens === 0 ? ` — ${PRUNE_REASON_LABELS[reason]}` : "";
|
|
23
23
|
message += `\n\n▣ Pruning (${pruneTokenCounterStr}${extractedSuffix})${reasonLabel}`;
|
|
24
24
|
const itemLines = formatPrunedItemsList(pruneToolIds, toolMetadata, workingDirectory);
|
|
@@ -34,14 +34,14 @@ export async function sendUnifiedNotification(client, logger, config, state, ses
|
|
|
34
34
|
if (config.pruneNotification === "off") {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
const showDistillation = config.tools.
|
|
37
|
+
const showDistillation = config.tools.distill.showDistillation;
|
|
38
38
|
const message = config.pruneNotification === "minimal"
|
|
39
39
|
? buildMinimalMessage(state, reason, distillation, showDistillation)
|
|
40
40
|
: buildDetailedMessage(state, reason, pruneToolIds, toolMetadata, workingDirectory, distillation, showDistillation);
|
|
41
41
|
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
|
-
export async function
|
|
44
|
+
export async function sendCompressNotification(client, logger, config, state, sessionId, toolIds, messageIds, topic, summary, startResult, endResult, totalMessages, params) {
|
|
45
45
|
if (config.pruneNotification === "off") {
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
@@ -53,7 +53,7 @@ export async function sendSquashNotification(client, logger, config, state, sess
|
|
|
53
53
|
message = formatStatsHeader(state.stats.totalPruneTokens, state.stats.pruneTokenCounter);
|
|
54
54
|
const pruneTokenCounterStr = `~${formatTokenCount(state.stats.pruneTokenCounter)}`;
|
|
55
55
|
const progressBar = formatProgressBar(totalMessages, startResult.messageIndex, endResult.messageIndex, 25);
|
|
56
|
-
message += `\n\n▣
|
|
56
|
+
message += `\n\n▣ Compressing (${pruneTokenCounterStr}) ${progressBar}`;
|
|
57
57
|
message += `\n→ Topic: ${topic}`;
|
|
58
58
|
message += `\n→ Items: ${messageIds.length} messages`;
|
|
59
59
|
if (toolIds.length > 0) {
|
|
@@ -62,8 +62,8 @@ export async function sendSquashNotification(client, logger, config, state, sess
|
|
|
62
62
|
else {
|
|
63
63
|
message += ` condensed`;
|
|
64
64
|
}
|
|
65
|
-
if (config.tools.
|
|
66
|
-
message += `\n→
|
|
65
|
+
if (config.tools.compress.showCompression) {
|
|
66
|
+
message += `\n→ Compression: ${summary}`;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../lib/ui/notification.ts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,EACX,SAAiB,EACjB,IAAY,EACZ,MAAW,EACX,MAAc;IAEd,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAA;IACvC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,SAAS,CAAA;IAC3C,MAAM,KAAK,GACP,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO;QAC/B,CAAC,CAAC;YACI,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B;QACH,CAAC,CAAC,SAAS,CAAA;IAEnB,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YACxB,IAAI,EAAE;gBACF,EAAE,EAAE,SAAS;aAChB;YACD,IAAI,EAAE;gBACF,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,OAAO;gBAChB,KAAK,EAAE;oBACH;wBACI,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI;wBACV,OAAO,EAAE,IAAI;qBAChB;iBACJ;aACJ;SACJ,CAAC,CAAA;IACN,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACzE,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@tarquinen/opencode-dcp",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1-beta.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"clean": "rm -rf dist",
|
|
11
|
+
"generate:prompts": "tsx scripts/generate-prompts.ts",
|
|
12
|
+
"prebuild": "npm run generate:prompts",
|
|
11
13
|
"build": "npm run clean && tsc",
|
|
12
|
-
"postbuild": "rm -rf dist/logs",
|
|
13
14
|
"prepublishOnly": "npm run build",
|
|
14
15
|
"dev": "opencode plugin dev",
|
|
15
|
-
"typecheck": "tsc --noEmit",
|
|
16
|
+
"typecheck": "npm run generate:prompts && tsc --noEmit",
|
|
16
17
|
"test": "node --import tsx --test tests/*.test.ts",
|
|
17
18
|
"format": "prettier --write .",
|
|
18
|
-
"format:check": "prettier --check ."
|
|
19
|
+
"format:check": "prettier --check .",
|
|
20
|
+
"dcp": "tsx scripts/print.ts"
|
|
19
21
|
},
|
|
20
22
|
"keywords": [
|
|
21
23
|
"opencode",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const DISCARD_TOOL_SPEC = "**Purpose:** Discard tool outputs from context to manage size and reduce noise.\n**IDs:** Use numeric IDs from `<prunable-tools>` (format: `ID: tool, parameter`).\n**Use When:**\n- Noise \u2192 irrelevant, unhelpful, or superseded outputs\n**Do NOT Use When:**\n- Output contains useful information\n- Output needed later (files to edit, implementation context)\n**Best Practices:**\n- Batch multiple items; avoid single small outputs (unless pure noise)\n- Criterion: \"Needed for upcoming task?\" \u2192 keep it\n**Format:**\n- `ids`: string[] \u2014 numeric IDs from prunable list\n**Example:**\nNoise removal:\n ids: [\"5\"]\n Context: Read wrong_file.ts \u2014 not relevant to auth system\n";
|
|
2
|
-
//# sourceMappingURL=discard-tool-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discard-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,ksBAgB7B,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const DISCARD_TOOL_SPEC = `**Purpose:** Discard tool outputs from context to manage size and reduce noise.
|
|
2
|
-
**IDs:** Use numeric IDs from \`<prunable-tools>\` (format: \`ID: tool, parameter\`).
|
|
3
|
-
**Use When:**
|
|
4
|
-
- Noise → irrelevant, unhelpful, or superseded outputs
|
|
5
|
-
**Do NOT Use When:**
|
|
6
|
-
- Output contains useful information
|
|
7
|
-
- Output needed later (files to edit, implementation context)
|
|
8
|
-
**Best Practices:**
|
|
9
|
-
- Batch multiple items; avoid single small outputs (unless pure noise)
|
|
10
|
-
- Criterion: "Needed for upcoming task?" → keep it
|
|
11
|
-
**Format:**
|
|
12
|
-
- \`ids\`: string[] — numeric IDs from prunable list
|
|
13
|
-
**Example:**
|
|
14
|
-
Noise removal:
|
|
15
|
-
ids: ["5"]
|
|
16
|
-
Context: Read wrong_file.ts — not relevant to auth system
|
|
17
|
-
`;
|
|
18
|
-
//# sourceMappingURL=discard-tool-spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discard-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/discard-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;CAgBhC,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const EXTRACT_TOOL_SPEC = "**Purpose:** Extract key findings from tool outputs into distilled knowledge; remove raw outputs from context.\n**IDs:** Use numeric IDs from `<prunable-tools>` (format: `ID: tool, parameter`).\n**Use When:**\n- Task complete \u2192 preserve findings\n- Distill context \u2192 keep specifics, drop noise\n**Do NOT Use When:**\n- Need exact syntax (edits/grep) \u2192 keep raw output\n- Planning modifications \u2192 keep read output\n**Best Practices:**\n- Batch multiple items; avoid frequent small extractions\n- Preserve raw output if editing/modifying later\n**Format:**\n- `ids`: string[] \u2014 numeric IDs from prunable list\n- `distillation`: string[] \u2014 positional mapping (distillation[i] for ids[i])\n- Detail level: signatures, logic, constraints, values\n**Example:**\n `ids`: [\"10\", \"11\"]\n `distillation`: [\n \"auth.ts: validateToken(token: string)\u2192User|null. Cache 5min TTL then OIDC. bcrypt 12 rounds. Tokens \u2265128 chars.\",\n \"user.ts: interface User {id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended'}\"\n ]\n";
|
|
2
|
-
//# sourceMappingURL=extract-tool-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,8lCAqB7B,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const EXTRACT_TOOL_SPEC = `**Purpose:** Extract key findings from tool outputs into distilled knowledge; remove raw outputs from context.
|
|
2
|
-
**IDs:** Use numeric IDs from \`<prunable-tools>\` (format: \`ID: tool, parameter\`).
|
|
3
|
-
**Use When:**
|
|
4
|
-
- Task complete → preserve findings
|
|
5
|
-
- Distill context → keep specifics, drop noise
|
|
6
|
-
**Do NOT Use When:**
|
|
7
|
-
- Need exact syntax (edits/grep) → keep raw output
|
|
8
|
-
- Planning modifications → keep read output
|
|
9
|
-
**Best Practices:**
|
|
10
|
-
- Batch multiple items; avoid frequent small extractions
|
|
11
|
-
- Preserve raw output if editing/modifying later
|
|
12
|
-
**Format:**
|
|
13
|
-
- \`ids\`: string[] — numeric IDs from prunable list
|
|
14
|
-
- \`distillation\`: string[] — positional mapping (distillation[i] for ids[i])
|
|
15
|
-
- Detail level: signatures, logic, constraints, values
|
|
16
|
-
**Example:**
|
|
17
|
-
\`ids\`: ["10", "11"]
|
|
18
|
-
\`distillation\`: [
|
|
19
|
-
"auth.ts: validateToken(token: string)→User|null. Cache 5min TTL then OIDC. bcrypt 12 rounds. Tokens ≥128 chars.",
|
|
20
|
-
"user.ts: interface User {id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended'}"
|
|
21
|
-
]
|
|
22
|
-
`;
|
|
23
|
-
//# sourceMappingURL=extract-tool-spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/extract-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const NUDGE_ALL = "<instruction name=context_management_required>\n**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.\n**Actions:**\n1. Task done \u2192 use `squash` to condense entire sequence into summary\n2. Noise \u2192 files/commands with no value, use `discard`\n3. Knowledge \u2192 valuable raw data to reference later, use `extract` to distill insights\n**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.\n</instruction>";
|
|
2
|
-
//# sourceMappingURL=all.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/all.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,0fAOP,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const NUDGE_ALL = `<instruction name=context_management_required>
|
|
2
|
-
**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.
|
|
3
|
-
**Actions:**
|
|
4
|
-
1. Task done → use \`squash\` to condense entire sequence into summary
|
|
5
|
-
2. Noise → files/commands with no value, use \`discard\`
|
|
6
|
-
3. Knowledge → valuable raw data to reference later, use \`extract\` to distill insights
|
|
7
|
-
**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.
|
|
8
|
-
</instruction>`;
|
|
9
|
-
//# sourceMappingURL=all.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../../../lib/prompts/nudge/all.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;eAOV,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const NUDGE_DISCARD_EXTRACT = "<instruction name=context_management_required>\n**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.\n**Actions:**\n1. Noise \u2192 files/commands with no value, use `discard`\n2. Knowledge \u2192 valuable raw data to reference later, use `extract` to distill insights\n**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.\n</instruction>";
|
|
2
|
-
//# sourceMappingURL=discard-extract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discard-extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/discard-extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,+aAMnB,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const NUDGE_DISCARD_EXTRACT = `<instruction name=context_management_required>
|
|
2
|
-
**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.
|
|
3
|
-
**Actions:**
|
|
4
|
-
1. Noise → files/commands with no value, use \`discard\`
|
|
5
|
-
2. Knowledge → valuable raw data to reference later, use \`extract\` to distill insights
|
|
6
|
-
**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.
|
|
7
|
-
</instruction>`;
|
|
8
|
-
//# sourceMappingURL=discard-extract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discard-extract.js","sourceRoot":"","sources":["../../../../lib/prompts/nudge/discard-extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;eAMtB,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const NUDGE_DISCARD_SQUASH = "<instruction name=context_management_required>\n**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.\n**Actions:**\n1. Task done \u2192 sub-task/phase complete, use `squash` to condense into summary\n2. Noise \u2192 files/commands with no value, use `discard`\n**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.\n</instruction>";
|
|
2
|
-
//# sourceMappingURL=discard-squash.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discard-squash.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/nudge/discard-squash.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,saAMlB,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const NUDGE_DISCARD_SQUASH = `<instruction name=context_management_required>
|
|
2
|
-
**CONTEXT WARNING:** Context filling with tool outputs. Context hygiene required.
|
|
3
|
-
**Actions:**
|
|
4
|
-
1. Task done → sub-task/phase complete, use \`squash\` to condense into summary
|
|
5
|
-
2. Noise → files/commands with no value, use \`discard\`
|
|
6
|
-
**Protocol:** Prioritize cleanup. Don't interrupt atomic ops. After immediate step, perform context management.
|
|
7
|
-
</instruction>`;
|
|
8
|
-
//# sourceMappingURL=discard-squash.js.map
|