@tarquinen/opencode-dcp 1.3.2-beta.0 → 1.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +619 -21
- package/README.md +17 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/context.js +8 -7
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/stats.d.ts.map +1 -1
- package/dist/lib/commands/stats.js +13 -8
- package/dist/lib/commands/stats.js.map +1 -1
- package/dist/lib/commands/sweep.d.ts.map +1 -1
- package/dist/lib/commands/sweep.js +10 -9
- package/dist/lib/commands/sweep.js.map +1 -1
- package/dist/lib/config.d.ts +3 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +47 -19
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts +8 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +10 -4
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/messages/inject.d.ts +2 -1
- package/dist/lib/messages/inject.d.ts.map +1 -1
- package/dist/lib/messages/inject.js +39 -31
- package/dist/lib/messages/inject.js.map +1 -1
- package/dist/lib/messages/prune.js +6 -6
- package/dist/lib/messages/prune.js.map +1 -1
- package/dist/lib/messages/utils.d.ts +20 -4
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +47 -42
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/_codegen/compress.generated.d.ts +2 -0
- package/dist/lib/prompts/_codegen/compress.generated.d.ts.map +1 -0
- package/dist/lib/prompts/_codegen/compress.generated.js +40 -0
- package/dist/lib/prompts/_codegen/compress.generated.js.map +1 -0
- package/dist/lib/prompts/_codegen/distill.generated.d.ts +2 -0
- package/dist/lib/prompts/_codegen/distill.generated.d.ts.map +1 -0
- package/dist/lib/prompts/_codegen/distill.generated.js +33 -0
- package/dist/lib/prompts/_codegen/distill.generated.js.map +1 -0
- package/dist/lib/prompts/{nudge.generated.d.ts → _codegen/nudge.generated.d.ts} +1 -1
- package/dist/lib/prompts/_codegen/nudge.generated.d.ts.map +1 -0
- package/dist/lib/prompts/{nudge.generated.js → _codegen/nudge.generated.js} +1 -1
- package/dist/lib/prompts/_codegen/nudge.generated.js.map +1 -0
- package/dist/lib/prompts/_codegen/prune.generated.d.ts +2 -0
- package/dist/lib/prompts/_codegen/prune.generated.d.ts.map +1 -0
- package/dist/lib/prompts/_codegen/prune.generated.js +23 -0
- package/dist/lib/prompts/_codegen/prune.generated.js.map +1 -0
- package/dist/lib/prompts/_codegen/system.generated.d.ts +2 -0
- package/dist/lib/prompts/_codegen/system.generated.d.ts.map +1 -0
- package/dist/lib/prompts/_codegen/system.generated.js +50 -0
- package/dist/lib/prompts/_codegen/system.generated.js.map +1 -0
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +5 -6
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/protected-file-patterns.d.ts +2 -2
- package/dist/lib/protected-file-patterns.d.ts.map +1 -1
- package/dist/lib/protected-file-patterns.js +34 -7
- package/dist/lib/protected-file-patterns.js.map +1 -1
- package/dist/lib/shared-utils.js +1 -1
- package/dist/lib/shared-utils.js.map +1 -1
- package/dist/lib/state/persistence.d.ts +8 -2
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +6 -1
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/state.js +8 -6
- 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 +6 -1
- package/dist/lib/state/tool-cache.js.map +1 -1
- package/dist/lib/state/types.d.ts +4 -2
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/state/utils.js +2 -2
- package/dist/lib/state/utils.js.map +1 -1
- package/dist/lib/strategies/deduplication.d.ts.map +1 -1
- package/dist/lib/strategies/deduplication.js +7 -6
- package/dist/lib/strategies/deduplication.js.map +1 -1
- package/dist/lib/strategies/purge-errors.d.ts.map +1 -1
- package/dist/lib/strategies/purge-errors.js +7 -6
- package/dist/lib/strategies/purge-errors.js.map +1 -1
- package/dist/lib/strategies/supersede-writes.d.ts.map +1 -1
- package/dist/lib/strategies/supersede-writes.js +10 -8
- package/dist/lib/strategies/supersede-writes.js.map +1 -1
- package/dist/lib/strategies/utils.d.ts +7 -0
- package/dist/lib/strategies/utils.d.ts.map +1 -1
- package/dist/lib/strategies/utils.js +58 -28
- package/dist/lib/strategies/utils.js.map +1 -1
- package/dist/lib/tools/compress.d.ts.map +1 -1
- package/dist/lib/tools/compress.js +35 -17
- package/dist/lib/tools/compress.js.map +1 -1
- package/dist/lib/tools/distill.d.ts.map +1 -1
- package/dist/lib/tools/distill.js +25 -25
- package/dist/lib/tools/distill.js.map +1 -1
- package/dist/lib/tools/prune-shared.d.ts.map +1 -1
- package/dist/lib/tools/prune-shared.js +7 -5
- package/dist/lib/tools/prune-shared.js.map +1 -1
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +63 -0
- package/dist/lib/ui/notification.js.map +1 -1
- package/package.json +3 -3
- package/dist/lib/prompts/compress-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/compress-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/compress-tool-spec.js +0 -58
- package/dist/lib/prompts/compress-tool-spec.js.map +0 -1
- package/dist/lib/prompts/distill-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/distill-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/distill-tool-spec.js +0 -48
- package/dist/lib/prompts/distill-tool-spec.js.map +0 -1
- package/dist/lib/prompts/nudge.generated.d.ts.map +0 -1
- package/dist/lib/prompts/nudge.generated.js.map +0 -1
- package/dist/lib/prompts/prune-tool-spec.d.ts +0 -2
- package/dist/lib/prompts/prune-tool-spec.d.ts.map +0 -1
- package/dist/lib/prompts/prune-tool-spec.js +0 -40
- package/dist/lib/prompts/prune-tool-spec.js.map +0 -1
- package/dist/lib/prompts/system.generated.d.ts +0 -2
- package/dist/lib/prompts/system.generated.d.ts.map +0 -1
- package/dist/lib/prompts/system.generated.js +0 -90
- package/dist/lib/prompts/system.generated.js.map +0 -1
|
@@ -10,31 +10,45 @@ export function createCompressTool(ctx) {
|
|
|
10
10
|
return tool({
|
|
11
11
|
description: COMPRESS_TOOL_DESCRIPTION,
|
|
12
12
|
args: {
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
.describe("
|
|
13
|
+
topic: tool.schema
|
|
14
|
+
.string()
|
|
15
|
+
.describe("Short label (3-5 words) for display - e.g., 'Auth System Exploration'"),
|
|
16
|
+
content: tool.schema
|
|
17
|
+
.object({
|
|
18
|
+
startString: tool.schema
|
|
19
|
+
.string()
|
|
20
|
+
.describe("Unique text from conversation marking the beginning of range"),
|
|
21
|
+
endString: tool.schema
|
|
22
|
+
.string()
|
|
23
|
+
.describe("Unique text marking the end of range"),
|
|
24
|
+
summary: tool.schema
|
|
25
|
+
.string()
|
|
26
|
+
.describe("Complete technical summary replacing all content in range"),
|
|
27
|
+
})
|
|
28
|
+
.describe("The compression details: boundaries and replacement summary"),
|
|
16
29
|
},
|
|
17
30
|
async execute(args, toolCtx) {
|
|
18
31
|
const { client, state, logger } = ctx;
|
|
19
32
|
const sessionId = toolCtx.sessionID;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
await toolCtx.ask({
|
|
34
|
+
permission: "compress",
|
|
35
|
+
patterns: ["*"],
|
|
36
|
+
always: ["*"],
|
|
37
|
+
metadata: {},
|
|
38
|
+
});
|
|
39
|
+
const { topic, content } = args;
|
|
40
|
+
const { startString, endString, summary } = content || {};
|
|
41
|
+
if (!topic || typeof topic !== "string") {
|
|
42
|
+
throw new Error("topic is required and must be a non-empty string");
|
|
25
43
|
}
|
|
26
|
-
const [startString, endString, topic, summary] = args.input;
|
|
27
44
|
if (!startString || typeof startString !== "string") {
|
|
28
|
-
throw new Error("startString is required and must be a non-empty string");
|
|
45
|
+
throw new Error("content.startString is required and must be a non-empty string");
|
|
29
46
|
}
|
|
30
47
|
if (!endString || typeof endString !== "string") {
|
|
31
|
-
throw new Error("endString is required and must be a non-empty string");
|
|
32
|
-
}
|
|
33
|
-
if (!topic || typeof topic !== "string") {
|
|
34
|
-
throw new Error("topic is required and must be a non-empty string");
|
|
48
|
+
throw new Error("content.endString is required and must be a non-empty string");
|
|
35
49
|
}
|
|
36
50
|
if (!summary || typeof summary !== "string") {
|
|
37
|
-
throw new Error("summary is required and must be a non-empty string");
|
|
51
|
+
throw new Error("content.summary is required and must be a non-empty string");
|
|
38
52
|
}
|
|
39
53
|
logger.info("Compress tool invoked");
|
|
40
54
|
// logger.info(
|
|
@@ -57,8 +71,12 @@ export function createCompressTool(ctx) {
|
|
|
57
71
|
}
|
|
58
72
|
const containedToolIds = collectToolIdsInRange(messages, startResult.messageIndex, endResult.messageIndex);
|
|
59
73
|
const containedMessageIds = collectMessageIdsInRange(messages, startResult.messageIndex, endResult.messageIndex);
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
for (const id of containedToolIds) {
|
|
75
|
+
state.prune.toolIds.add(id);
|
|
76
|
+
}
|
|
77
|
+
for (const id of containedMessageIds) {
|
|
78
|
+
state.prune.messageIds.add(id);
|
|
79
|
+
}
|
|
62
80
|
// Remove any existing summaries whose anchors are now inside this range
|
|
63
81
|
// This prevents duplicate injections when a larger compress subsumes a smaller one
|
|
64
82
|
const removedSummaries = state.compressSummaries.filter((s) => containedMessageIds.includes(s.anchorMessageId));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../lib/tools/compress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IA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,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,
|
|
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,CAmDhF"}
|
|
@@ -6,35 +6,35 @@ export function createDistillTool(ctx) {
|
|
|
6
6
|
return tool({
|
|
7
7
|
description: DISTILL_TOOL_DESCRIPTION,
|
|
8
8
|
args: {
|
|
9
|
-
|
|
10
|
-
.array(tool.schema.
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
targets: tool.schema
|
|
10
|
+
.array(tool.schema.object({
|
|
11
|
+
id: tool.schema
|
|
12
|
+
.string()
|
|
13
|
+
.describe("Numeric ID from the <prunable-tools> list"),
|
|
14
|
+
distillation: tool.schema
|
|
15
|
+
.string()
|
|
16
|
+
.describe("Complete technical distillation for this tool output"),
|
|
17
|
+
}))
|
|
18
|
+
.describe("Tool outputs to distill, each pairing an ID with its distillation"),
|
|
15
19
|
},
|
|
16
20
|
async execute(args, toolCtx) {
|
|
17
|
-
if (!args.
|
|
18
|
-
ctx.logger.debug("Distill tool called without
|
|
19
|
-
throw new Error("Missing
|
|
21
|
+
if (!args.targets || !Array.isArray(args.targets) || args.targets.length === 0) {
|
|
22
|
+
ctx.logger.debug("Distill tool called without targets: " + JSON.stringify(args));
|
|
23
|
+
throw new Error("Missing targets. Provide at least one { id, distillation } entry.");
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
for (const target of args.targets) {
|
|
26
|
+
if (!target.id || typeof target.id !== "string" || target.id.trim() === "") {
|
|
27
|
+
ctx.logger.debug("Distill target missing id: " + JSON.stringify(target));
|
|
28
|
+
throw new Error("Each target must have an id (numeric string from <prunable-tools>).");
|
|
29
|
+
}
|
|
30
|
+
if (!target.distillation || typeof target.distillation !== "string") {
|
|
31
|
+
ctx.logger.debug("Distill target missing distillation: " + JSON.stringify(target));
|
|
32
|
+
throw new Error("Each target must have a distillation string.");
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
ctx.logger.debug("Distill tool called without distillation: " + JSON.stringify(args));
|
|
29
|
-
throw new Error('Missing distillation. You must provide an array of strings (e.g., ["summary 1", "summary 2"]).');
|
|
30
|
-
}
|
|
31
|
-
if (!args.distillation.every((d) => typeof d === "string")) {
|
|
32
|
-
ctx.logger.debug("Distill tool called with non-string distillation: " + JSON.stringify(args));
|
|
33
|
-
throw new Error("Invalid distillation. All distillation entries must be strings.");
|
|
34
|
-
}
|
|
35
|
-
// ctx.logger.info("Distillation data received:")
|
|
36
|
-
// ctx.logger.info(JSON.stringify(args.distillation, null, 2))
|
|
37
|
-
return executePruneOperation(ctx, toolCtx, args.ids, "extraction", "Distill", args.distillation);
|
|
35
|
+
const ids = args.targets.map((t) => t.id);
|
|
36
|
+
const distillations = args.targets.map((t) => t.distillation);
|
|
37
|
+
return executePruneOperation(ctx, toolCtx, ids, "extraction", "Distill", distillations);
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
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,GAAq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AE,gBAAgB,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC9B,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"prune-shared.d.ts","sourceRoot":"","sources":["../../../lib/tools/prune-shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,OAAO,EAAE,WAAW,EAA2B,MAAM,oBAAoB,CAAA;AAQzE,wBAAsB,qBAAqB,CACvC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC9B,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,MAAM,CAAC,CA2IjB"}
|
|
@@ -5,7 +5,7 @@ import { formatPruningResultForTool } from "../ui/utils";
|
|
|
5
5
|
import { ensureSessionInitialized } from "../state";
|
|
6
6
|
import { saveSessionState } from "../state/persistence";
|
|
7
7
|
import { calculateTokensSaved, getCurrentParams } from "../strategies/utils";
|
|
8
|
-
import {
|
|
8
|
+
import { getFilePathsFromParameters, isProtected } from "../protected-file-patterns";
|
|
9
9
|
// Shared logic for executing prune operations.
|
|
10
10
|
export async function executePruneOperation(ctx, toolCtx, ids, reason, toolName, distillation) {
|
|
11
11
|
const { client, state, logger, config, workingDirectory } = ctx;
|
|
@@ -61,13 +61,13 @@ export async function executePruneOperation(ctx, toolCtx, ids, reason, toolName,
|
|
|
61
61
|
skippedIds.push(index.toString());
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
64
|
+
const filePaths = getFilePathsFromParameters(metadata.tool, metadata.parameters);
|
|
65
|
+
if (isProtected(filePaths, config.protectedFilePatterns)) {
|
|
66
66
|
logger.debug("Rejecting prune request - protected file path", {
|
|
67
67
|
index,
|
|
68
68
|
id,
|
|
69
69
|
tool: metadata.tool,
|
|
70
|
-
|
|
70
|
+
filePaths,
|
|
71
71
|
});
|
|
72
72
|
skippedIds.push(index.toString());
|
|
73
73
|
continue;
|
|
@@ -81,7 +81,9 @@ export async function executePruneOperation(ctx, toolCtx, ids, reason, toolName,
|
|
|
81
81
|
throw new Error(errorMsg);
|
|
82
82
|
}
|
|
83
83
|
const pruneToolIds = validNumericIds.map((index) => toolIdList[index]);
|
|
84
|
-
|
|
84
|
+
for (const id of pruneToolIds) {
|
|
85
|
+
state.prune.toolIds.add(id);
|
|
86
|
+
}
|
|
85
87
|
const toolMetadata = new Map();
|
|
86
88
|
for (const id of pruneToolIds) {
|
|
87
89
|
const toolParameters = state.toolParameters.get(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune-shared.js","sourceRoot":"","sources":["../../../lib/tools/prune-shared.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAe,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"prune-shared.js","sourceRoot":"","sources":["../../../lib/tools/prune-shared.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAA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IAED,KAAK,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAA;IAC7D,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,CAAC,CAAA;IACjC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAA;IAEtB,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;IAED,IAAI,MAAM,GAAG,0BAA0B,CAAC,YAAY,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAA;IACrF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,aAAa,UAAU,CAAC,MAAM,gEAAgE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IACnI,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../../lib/ui/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA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f,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
|
@@ -26,6 +26,35 @@ function buildDetailedMessage(state, reason, pruneToolIds, toolMetadata, working
|
|
|
26
26
|
}
|
|
27
27
|
return (message + formatExtracted(showDistillation ? distillation : undefined)).trim();
|
|
28
28
|
}
|
|
29
|
+
const TOAST_BODY_MAX_LINES = 12;
|
|
30
|
+
const TOAST_SUMMARY_MAX_CHARS = 600;
|
|
31
|
+
function truncateToastBody(body, maxLines = TOAST_BODY_MAX_LINES) {
|
|
32
|
+
const lines = body.split("\n");
|
|
33
|
+
if (lines.length <= maxLines) {
|
|
34
|
+
return body;
|
|
35
|
+
}
|
|
36
|
+
const kept = lines.slice(0, maxLines - 1);
|
|
37
|
+
const remaining = lines.length - maxLines + 1;
|
|
38
|
+
return kept.join("\n") + `\n... and ${remaining} more`;
|
|
39
|
+
}
|
|
40
|
+
function truncateToastSummary(summary, maxChars = TOAST_SUMMARY_MAX_CHARS) {
|
|
41
|
+
if (summary.length <= maxChars) {
|
|
42
|
+
return summary;
|
|
43
|
+
}
|
|
44
|
+
return summary.slice(0, maxChars - 3) + "...";
|
|
45
|
+
}
|
|
46
|
+
function truncateExtractedSection(message, maxChars = TOAST_SUMMARY_MAX_CHARS) {
|
|
47
|
+
const marker = "\n\n▣ Extracted";
|
|
48
|
+
const index = message.indexOf(marker);
|
|
49
|
+
if (index === -1) {
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
const extracted = message.slice(index);
|
|
53
|
+
if (extracted.length <= maxChars) {
|
|
54
|
+
return message;
|
|
55
|
+
}
|
|
56
|
+
return message.slice(0, index) + truncateToastSummary(extracted, maxChars);
|
|
57
|
+
}
|
|
29
58
|
export async function sendUnifiedNotification(client, logger, config, state, sessionId, pruneToolIds, toolMetadata, reason, params, workingDirectory, distillation) {
|
|
30
59
|
const hasPruned = pruneToolIds.length > 0;
|
|
31
60
|
if (!hasPruned) {
|
|
@@ -38,6 +67,20 @@ export async function sendUnifiedNotification(client, logger, config, state, ses
|
|
|
38
67
|
const message = config.pruneNotification === "minimal"
|
|
39
68
|
? buildMinimalMessage(state, reason, distillation, showDistillation)
|
|
40
69
|
: buildDetailedMessage(state, reason, pruneToolIds, toolMetadata, workingDirectory, distillation, showDistillation);
|
|
70
|
+
if (config.pruneNotificationType === "toast") {
|
|
71
|
+
let toastMessage = truncateExtractedSection(message);
|
|
72
|
+
toastMessage =
|
|
73
|
+
config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage);
|
|
74
|
+
await client.tui.showToast({
|
|
75
|
+
body: {
|
|
76
|
+
title: "DCP: Prune Notification",
|
|
77
|
+
message: toastMessage,
|
|
78
|
+
variant: "info",
|
|
79
|
+
duration: 5000,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
41
84
|
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
42
85
|
return true;
|
|
43
86
|
}
|
|
@@ -66,6 +109,26 @@ export async function sendCompressNotification(client, logger, config, state, se
|
|
|
66
109
|
message += `\n→ Compression: ${summary}`;
|
|
67
110
|
}
|
|
68
111
|
}
|
|
112
|
+
if (config.pruneNotificationType === "toast") {
|
|
113
|
+
let toastMessage = message;
|
|
114
|
+
if (config.tools.compress.showCompression) {
|
|
115
|
+
const truncatedSummary = truncateToastSummary(summary);
|
|
116
|
+
if (truncatedSummary !== summary) {
|
|
117
|
+
toastMessage = toastMessage.replace(`\n→ Compression: ${summary}`, `\n→ Compression: ${truncatedSummary}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
toastMessage =
|
|
121
|
+
config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage);
|
|
122
|
+
await client.tui.showToast({
|
|
123
|
+
body: {
|
|
124
|
+
title: "DCP: Compress Notification",
|
|
125
|
+
message: toastMessage,
|
|
126
|
+
variant: "info",
|
|
127
|
+
duration: 5000,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
69
132
|
await sendIgnoredMessage(client, sessionId, message, params, logger);
|
|
70
133
|
return true;
|
|
71
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../lib/ui/notification.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,SAAS,CAAA;AAKhB,MAAM,CAAC,MAAM,mBAAmB,GAAgC;IAC5D,UAAU,EAAE,eAAe;IAC3B,KAAK,EAAE,eAAe;IACtB,UAAU,EAAE,YAAY;CAC3B,CAAA;AAED,SAAS,mBAAmB,CACxB,KAAmB,EACnB,MAA+B,EAC/B,YAAkC,EAClC,gBAAyB;IAEzB,MAAM,eAAe,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAA;IAC7D,MAAM,eAAe,GACjB,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAClF,MAAM,YAAY,GAAG,MAAM,IAAI,eAAe,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/F,IAAI,OAAO,GACP,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAC9E,YAAY;QACZ,eAAe,CAAA;IAEnB,OAAO,OAAO,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AACjF,CAAC;AAED,SAAS,oBAAoB,CACzB,KAAmB,EACnB,MAA+B,EAC/B,YAAsB,EACtB,YAA6C,EAC7C,gBAAwB,EACxB,YAAkC,EAClC,gBAAyB;IAEzB,IAAI,O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AE,MAAM,EAAE,MAAM,CAAC,CAAA;IACpE,OAAO,IAAI,CAAA;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACpC,MAAW,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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@tarquinen/opencode-dcp",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0-beta.0",
|
|
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/Tarquinen/opencode-dynamic-context-pruning#readme",
|
|
39
39
|
"author": "tarquinen",
|
|
40
|
-
"license": "
|
|
40
|
+
"license": "AGPL-3.0-or-later",
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@opencode-ai/plugin": ">=0.13.7"
|
|
43
43
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"zod": "^4.3.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@opencode-ai/plugin": "^1.1.
|
|
52
|
+
"@opencode-ai/plugin": "^1.1.49",
|
|
53
53
|
"@types/node": "^25.1.0",
|
|
54
54
|
"prettier": "^3.8.1",
|
|
55
55
|
"tsx": "^4.21.0",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const COMPRESS_TOOL_SPEC = "Collapses a contiguous range of conversation into a single summary.\n\n## When to Use This Tool\n\nUse `compress` when you want to condense an entire sequence of work into a brief summary:\n\n- **Phase Completion:** You completed a phase (research, tool calls, implementation) and want to collapse the entire sequence into a summary.\n- **Exploration Done:** You explored multiple files or ran multiple commands and only need a summary of what you learned.\n- **Failed Attempts:** You tried several unsuccessful approaches and want to condense them into a brief note.\n- **Verbose Output:** A section of conversation has grown large but can be summarized without losing critical details.\n\n## When NOT to Use This Tool\n\n- **If you need specific details:** If you'll need exact code, file contents, or error messages from the range, keep them.\n- **For individual tool outputs:** Use `prune` or `distill` for single tool outputs. Compress targets conversation ranges.\n- **If it's recent content:** You may still need recent work for the current phase.\n\n## How It Works\n\n1. `startString` \u2014 A unique text string that marks the start of the range to compress\n2. `endString` \u2014 A unique text string that marks the end of the range to compress\n3. `topic` \u2014 A short label (3-5 words) describing the compressed content\n4. `summary` \u2014 The replacement text that will be inserted\n\nEverything between startString and endString (inclusive) is removed and replaced with your summary.\n\n**Important:** The compress will FAIL if `startString` or `endString` is not found in the conversation. The compress will also FAIL if either string is found multiple times. Provide a larger string with more surrounding context to uniquely identify the intended match.\n\n## Best Practices\n- **Choose unique strings:** Pick text that appears only once in the conversation.\n- **Write concise topics:** Examples: \"Auth System Exploration\", \"Token Logic Refactor\"\n- **Write comprehensive summaries:** Include key information like file names, function signatures, and important findings.\n- **Timing:** Best used after finishing a work phase, not during active exploration.\n\n## Format\n\n- `input`: Array with four elements: [startString, endString, topic, summary]\n\n## Example\n\n<example_compress>\nConversation: [Asked about auth] -> [Read 5 files] -> [Analyzed patterns] -> [Found \"JWT tokens with 24h expiry\"]\n\n[Uses compress with:\n input: [\n \"Asked about authentication\",\n \"JWT tokens with 24h expiry\",\n \"Auth System Exploration\",\n \"Auth: JWT 24h expiry, bcrypt passwords, refresh rotation. Files: auth.ts, tokens.ts, middleware/auth.ts\"\n ]\n]\n</example_compress>\n\n<example_keep>\nAssistant: [Just finished reading auth.ts]\nI've read the auth file and now need to make edits based on it. I'm keeping this in context rather than compressing.\n</example_keep>";
|
|
2
|
-
//# sourceMappingURL=compress-tool-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/compress-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,o2FAwDf,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export const COMPRESS_TOOL_SPEC = `Collapses a contiguous range of conversation into a single summary.
|
|
2
|
-
|
|
3
|
-
## When to Use This Tool
|
|
4
|
-
|
|
5
|
-
Use \`compress\` when you want to condense an entire sequence of work into a brief summary:
|
|
6
|
-
|
|
7
|
-
- **Phase Completion:** You completed a phase (research, tool calls, implementation) and want to collapse the entire sequence into a summary.
|
|
8
|
-
- **Exploration Done:** You explored multiple files or ran multiple commands and only need a summary of what you learned.
|
|
9
|
-
- **Failed Attempts:** You tried several unsuccessful approaches and want to condense them into a brief note.
|
|
10
|
-
- **Verbose Output:** A section of conversation has grown large but can be summarized without losing critical details.
|
|
11
|
-
|
|
12
|
-
## When NOT to Use This Tool
|
|
13
|
-
|
|
14
|
-
- **If you need specific details:** If you'll need exact code, file contents, or error messages from the range, keep them.
|
|
15
|
-
- **For individual tool outputs:** Use \`prune\` or \`distill\` for single tool outputs. Compress targets conversation ranges.
|
|
16
|
-
- **If it's recent content:** You may still need recent work for the current phase.
|
|
17
|
-
|
|
18
|
-
## How It Works
|
|
19
|
-
|
|
20
|
-
1. \`startString\` — A unique text string that marks the start of the range to compress
|
|
21
|
-
2. \`endString\` — A unique text string that marks the end of the range to compress
|
|
22
|
-
3. \`topic\` — A short label (3-5 words) describing the compressed content
|
|
23
|
-
4. \`summary\` — The replacement text that will be inserted
|
|
24
|
-
|
|
25
|
-
Everything between startString and endString (inclusive) is removed and replaced with your summary.
|
|
26
|
-
|
|
27
|
-
**Important:** The compress will FAIL if \`startString\` or \`endString\` is not found in the conversation. The compress will also FAIL if either string is found multiple times. Provide a larger string with more surrounding context to uniquely identify the intended match.
|
|
28
|
-
|
|
29
|
-
## Best Practices
|
|
30
|
-
- **Choose unique strings:** Pick text that appears only once in the conversation.
|
|
31
|
-
- **Write concise topics:** Examples: "Auth System Exploration", "Token Logic Refactor"
|
|
32
|
-
- **Write comprehensive summaries:** Include key information like file names, function signatures, and important findings.
|
|
33
|
-
- **Timing:** Best used after finishing a work phase, not during active exploration.
|
|
34
|
-
|
|
35
|
-
## Format
|
|
36
|
-
|
|
37
|
-
- \`input\`: Array with four elements: [startString, endString, topic, summary]
|
|
38
|
-
|
|
39
|
-
## Example
|
|
40
|
-
|
|
41
|
-
<example_compress>
|
|
42
|
-
Conversation: [Asked about auth] -> [Read 5 files] -> [Analyzed patterns] -> [Found "JWT tokens with 24h expiry"]
|
|
43
|
-
|
|
44
|
-
[Uses compress with:
|
|
45
|
-
input: [
|
|
46
|
-
"Asked about authentication",
|
|
47
|
-
"JWT tokens with 24h expiry",
|
|
48
|
-
"Auth System Exploration",
|
|
49
|
-
"Auth: JWT 24h expiry, bcrypt passwords, refresh rotation. Files: auth.ts, tokens.ts, middleware/auth.ts"
|
|
50
|
-
]
|
|
51
|
-
]
|
|
52
|
-
</example_compress>
|
|
53
|
-
|
|
54
|
-
<example_keep>
|
|
55
|
-
Assistant: [Just finished reading auth.ts]
|
|
56
|
-
I've read the auth file and now need to make edits based on it. I'm keeping this in context rather than compressing.
|
|
57
|
-
</example_keep>`;
|
|
58
|
-
//# sourceMappingURL=compress-tool-spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/compress-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAwDlB,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const DISTILL_TOOL_SPEC = "Distills key findings from tool outputs into preserved knowledge, then removes the raw outputs from context.\n\n## IMPORTANT: The Prunable List\nA `<prunable-tools>` list is provided to you showing available tool outputs you can distill from when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to distill.\n\n## When to Use This Tool\n\nUse `distill` when you have individual tool outputs with valuable information you want to **preserve in distilled form** before removing the raw content:\n\n- **Large Outputs:** The raw output is too large but contains valuable technical details worth keeping.\n- **Knowledge Preservation:** You have context that contains valuable information (signatures, logic, constraints) but also a lot of unnecessary detail.\n\n## When NOT to Use This Tool\n\n- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.\n- **If uncertain:** Prefer keeping over re-fetching.\n\n\n## Best Practices\n- **Strategic Batching:** Wait until you have several items or a few large outputs to distill, rather than doing tiny, frequent distillations. Aim for high-impact distillations that significantly reduce context size.\n- **Think ahead:** Before distilling, ask: \"Will I need the raw output for upcoming work?\" If you researched a file you'll later edit, do NOT distill it.\n\n## Format\n\n- `ids`: Array of numeric IDs as strings from the `<prunable-tools>` list\n- `distillation`: Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)\n\nEach distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed.\n\n## Example\n\n<example_distillation>\nAssistant: [Reads auth service and user types]\nI'll preserve the key details before distilling.\n[Uses distill with:\n ids: [\"10\", \"11\"],\n distillation: [\n \"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds. Tokens must be 128+ chars.\",\n \"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }\"\n ]\n]\n</example_distillation>\n\n<example_keep>\nAssistant: [Reads 'auth.ts' to understand the login flow]\nI've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than distilling.\n</example_keep>";
|
|
2
|
-
//# sourceMappingURL=distill-tool-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distill-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/distill-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,glFA8Cd,CAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const DISTILL_TOOL_SPEC = `Distills key findings from tool outputs into preserved knowledge, then removes the raw outputs from context.
|
|
2
|
-
|
|
3
|
-
## IMPORTANT: The Prunable List
|
|
4
|
-
A \`<prunable-tools>\` list is provided to you showing available tool outputs you can distill from when there are tools available for pruning. Each line has the format \`ID: tool, parameter\` (e.g., \`20: read, /path/to/file.ts\`). You MUST only use numeric IDs that appear in this list to select which tools to distill.
|
|
5
|
-
|
|
6
|
-
## When to Use This Tool
|
|
7
|
-
|
|
8
|
-
Use \`distill\` when you have individual tool outputs with valuable information you want to **preserve in distilled form** before removing the raw content:
|
|
9
|
-
|
|
10
|
-
- **Large Outputs:** The raw output is too large but contains valuable technical details worth keeping.
|
|
11
|
-
- **Knowledge Preservation:** You have context that contains valuable information (signatures, logic, constraints) but also a lot of unnecessary detail.
|
|
12
|
-
|
|
13
|
-
## When NOT to Use This Tool
|
|
14
|
-
|
|
15
|
-
- **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.
|
|
16
|
-
- **If uncertain:** Prefer keeping over re-fetching.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Best Practices
|
|
20
|
-
- **Strategic Batching:** Wait until you have several items or a few large outputs to distill, rather than doing tiny, frequent distillations. Aim for high-impact distillations that significantly reduce context size.
|
|
21
|
-
- **Think ahead:** Before distilling, ask: "Will I need the raw output for upcoming work?" If you researched a file you'll later edit, do NOT distill it.
|
|
22
|
-
|
|
23
|
-
## Format
|
|
24
|
-
|
|
25
|
-
- \`ids\`: Array of numeric IDs as strings from the \`<prunable-tools>\` list
|
|
26
|
-
- \`distillation\`: Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)
|
|
27
|
-
|
|
28
|
-
Each distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed.
|
|
29
|
-
|
|
30
|
-
## Example
|
|
31
|
-
|
|
32
|
-
<example_distillation>
|
|
33
|
-
Assistant: [Reads auth service and user types]
|
|
34
|
-
I'll preserve the key details before distilling.
|
|
35
|
-
[Uses distill with:
|
|
36
|
-
ids: ["10", "11"],
|
|
37
|
-
distillation: [
|
|
38
|
-
"auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds. Tokens must be 128+ chars.",
|
|
39
|
-
"user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }"
|
|
40
|
-
]
|
|
41
|
-
]
|
|
42
|
-
</example_distillation>
|
|
43
|
-
|
|
44
|
-
<example_keep>
|
|
45
|
-
Assistant: [Reads 'auth.ts' to understand the login flow]
|
|
46
|
-
I've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than distilling.
|
|
47
|
-
</example_keep>`;
|
|
48
|
-
//# sourceMappingURL=distill-tool-spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distill-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/distill-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8CjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nudge.generated.d.ts","sourceRoot":"","sources":["../../../lib/prompts/nudge.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,+6BAYjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nudge.generated.js","sourceRoot":"","sources":["../../../lib/prompts/nudge.generated.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,yDAAyD;AACzD,8DAA8D;AAE9D,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;CAYpB,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const PRUNE_TOOL_SPEC = "Prunes tool outputs from context to manage conversation size and reduce noise.\n\n## IMPORTANT: The Prunable List\nA `<prunable-tools>` list is provided to you showing available tool outputs you can prune when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to prune.\n\n## When to Use This Tool\n\nUse `prune` for removing individual tool outputs that are no longer needed:\n\n- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.\n- **Wrong Files:** You read or accessed something that turned out to be irrelevant.\n- **Outdated Info:** Outputs that have been superseded by newer information.\n\n## When NOT to Use This Tool\n\n- **If the output contains useful information:** Keep it in context rather than pruning.\n- **If you'll need the output later:** Don't prune files you plan to edit or context you'll need for implementation.\n\n## Best Practices\n- **Strategic Batching:** Don't prune single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact prunes.\n- **Think ahead:** Before pruning, ask: \"Will I need this output for upcoming work?\" If yes, keep it.\n\n## Format\n\n- `ids`: Array of numeric IDs as strings from the `<prunable-tools>` list\n\n## Example\n\n<example_noise>\nAssistant: [Reads 'wrong_file.ts']\nThis file isn't relevant to the auth system. I'll remove it to clear the context.\n[Uses prune with ids: [\"5\"]]\n</example_noise>\n\n<example_superseded>\nAssistant: [Reads config.ts, then reads updated config.ts after changes]\nThe first read is now outdated. I'll prune it and keep the updated version.\n[Uses prune with ids: [\"20\"]]\n</example_superseded>";
|
|
2
|
-
//# sourceMappingURL=prune-tool-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/prune-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,+zDAsCN,CAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export const PRUNE_TOOL_SPEC = `Prunes tool outputs from context to manage conversation size and reduce noise.
|
|
2
|
-
|
|
3
|
-
## IMPORTANT: The Prunable List
|
|
4
|
-
A \`<prunable-tools>\` list is provided to you showing available tool outputs you can prune when there are tools available for pruning. Each line has the format \`ID: tool, parameter\` (e.g., \`20: read, /path/to/file.ts\`). You MUST only use numeric IDs that appear in this list to select which tools to prune.
|
|
5
|
-
|
|
6
|
-
## When to Use This Tool
|
|
7
|
-
|
|
8
|
-
Use \`prune\` for removing individual tool outputs that are no longer needed:
|
|
9
|
-
|
|
10
|
-
- **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
|
|
11
|
-
- **Wrong Files:** You read or accessed something that turned out to be irrelevant.
|
|
12
|
-
- **Outdated Info:** Outputs that have been superseded by newer information.
|
|
13
|
-
|
|
14
|
-
## When NOT to Use This Tool
|
|
15
|
-
|
|
16
|
-
- **If the output contains useful information:** Keep it in context rather than pruning.
|
|
17
|
-
- **If you'll need the output later:** Don't prune files you plan to edit or context you'll need for implementation.
|
|
18
|
-
|
|
19
|
-
## Best Practices
|
|
20
|
-
- **Strategic Batching:** Don't prune single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact prunes.
|
|
21
|
-
- **Think ahead:** Before pruning, ask: "Will I need this output for upcoming work?" If yes, keep it.
|
|
22
|
-
|
|
23
|
-
## Format
|
|
24
|
-
|
|
25
|
-
- \`ids\`: Array of numeric IDs as strings from the \`<prunable-tools>\` list
|
|
26
|
-
|
|
27
|
-
## Example
|
|
28
|
-
|
|
29
|
-
<example_noise>
|
|
30
|
-
Assistant: [Reads 'wrong_file.ts']
|
|
31
|
-
This file isn't relevant to the auth system. I'll remove it to clear the context.
|
|
32
|
-
[Uses prune with ids: ["5"]]
|
|
33
|
-
</example_noise>
|
|
34
|
-
|
|
35
|
-
<example_superseded>
|
|
36
|
-
Assistant: [Reads config.ts, then reads updated config.ts after changes]
|
|
37
|
-
The first read is now outdated. I'll prune it and keep the updated version.
|
|
38
|
-
[Uses prune with ids: ["20"]]
|
|
39
|
-
</example_superseded>`;
|
|
40
|
-
//# sourceMappingURL=prune-tool-spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/prune-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAsCT,CAAA"}
|