@tarquinen/opencode-dcp 2.1.7 → 2.2.0-beta0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -29
- package/dist/index.js.map +1 -1
- package/dist/lib/commands/context.d.ts.map +1 -1
- package/dist/lib/commands/context.js +36 -8
- package/dist/lib/commands/context.js.map +1 -1
- package/dist/lib/commands/help.d.ts.map +1 -1
- package/dist/lib/commands/help.js +2 -6
- package/dist/lib/commands/help.js.map +1 -1
- package/dist/lib/commands/manual.d.ts +1 -3
- package/dist/lib/commands/manual.d.ts.map +1 -1
- package/dist/lib/commands/manual.js +4 -43
- package/dist/lib/commands/manual.js.map +1 -1
- package/dist/lib/commands/sweep.d.ts.map +1 -1
- package/dist/lib/commands/sweep.js +2 -12
- package/dist/lib/commands/sweep.js.map +1 -1
- package/dist/lib/compress-logger.d.ts +15 -0
- package/dist/lib/compress-logger.d.ts.map +1 -0
- package/dist/lib/compress-logger.js +132 -0
- package/dist/lib/compress-logger.js.map +1 -0
- package/dist/lib/config.d.ts +5 -20
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +172 -348
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hooks.d.ts +7 -0
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +23 -17
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +6 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/messages/index.d.ts +2 -3
- package/dist/lib/messages/index.d.ts.map +1 -1
- package/dist/lib/messages/index.js +2 -3
- package/dist/lib/messages/index.js.map +1 -1
- package/dist/lib/messages/inject/inject.d.ts +6 -0
- package/dist/lib/messages/inject/inject.d.ts.map +1 -0
- package/dist/lib/messages/inject/inject.js +99 -0
- package/dist/lib/messages/inject/inject.js.map +1 -0
- package/dist/lib/messages/inject/utils.d.ts +20 -0
- package/dist/lib/messages/inject/utils.d.ts.map +1 -0
- package/dist/lib/messages/inject/utils.js +137 -0
- package/dist/lib/messages/inject/utils.js.map +1 -0
- package/dist/lib/messages/utils.d.ts +7 -11
- package/dist/lib/messages/utils.d.ts.map +1 -1
- package/dist/lib/messages/utils.js +33 -132
- package/dist/lib/messages/utils.js.map +1 -1
- package/dist/lib/prompts/_codegen/system.generated.d.ts +1 -1
- package/dist/lib/prompts/_codegen/system.generated.d.ts.map +1 -1
- package/dist/lib/prompts/_codegen/system.generated.js +36 -32
- package/dist/lib/prompts/_codegen/system.generated.js.map +1 -1
- package/dist/lib/prompts/compress.d.ts +2 -0
- package/dist/lib/prompts/compress.d.ts.map +1 -0
- package/dist/lib/prompts/compress.js +122 -0
- package/dist/lib/prompts/compress.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +6 -10
- package/dist/lib/prompts/index.d.ts.map +1 -1
- package/dist/lib/prompts/index.js +17 -40
- package/dist/lib/prompts/index.js.map +1 -1
- package/dist/lib/prompts/iteration-nudge.d.ts +2 -0
- package/dist/lib/prompts/iteration-nudge.d.ts.map +1 -0
- package/dist/lib/prompts/iteration-nudge.js +9 -0
- package/dist/lib/prompts/iteration-nudge.js.map +1 -0
- package/dist/lib/prompts/nudge.d.ts +2 -0
- package/dist/lib/prompts/nudge.d.ts.map +1 -0
- package/dist/lib/prompts/nudge.js +40 -0
- package/dist/lib/prompts/nudge.js.map +1 -0
- package/dist/lib/prompts/turn-nudge.d.ts +2 -0
- package/dist/lib/prompts/turn-nudge.d.ts.map +1 -0
- package/dist/lib/prompts/turn-nudge.js +12 -0
- package/dist/lib/prompts/turn-nudge.js.map +1 -0
- package/dist/lib/state/persistence.d.ts +7 -2
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/persistence.js +58 -39
- package/dist/lib/state/persistence.js.map +1 -1
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/state.js +20 -8
- package/dist/lib/state/state.js.map +1 -1
- package/dist/lib/state/tool-cache.d.ts.map +1 -1
- package/dist/lib/state/tool-cache.js +3 -17
- package/dist/lib/state/tool-cache.js.map +1 -1
- package/dist/lib/state/types.d.ts +7 -8
- package/dist/lib/state/types.d.ts.map +1 -1
- package/dist/lib/state/utils.d.ts +2 -2
- package/dist/lib/state/utils.d.ts.map +1 -1
- package/dist/lib/state/utils.js +29 -19
- 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 +0 -11
- package/dist/lib/strategies/deduplication.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/purge-errors.d.ts.map +1 -1
- package/dist/lib/strategies/purge-errors.js +0 -11
- 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 +0 -11
- package/dist/lib/strategies/supersede-writes.js.map +1 -1
- package/dist/lib/strategies/utils.d.ts +1 -0
- package/dist/lib/strategies/utils.d.ts.map +1 -1
- package/dist/lib/strategies/utils.js +15 -0
- package/dist/lib/strategies/utils.js.map +1 -1
- package/dist/lib/tools/compress-utils.d.ts +7 -4
- package/dist/lib/tools/compress-utils.d.ts.map +1 -1
- package/dist/lib/tools/compress-utils.js +34 -25
- package/dist/lib/tools/compress-utils.js.map +1 -1
- package/dist/lib/tools/compress.d.ts +2 -2
- package/dist/lib/tools/compress.d.ts.map +1 -1
- package/dist/lib/tools/compress.js +21 -58
- package/dist/lib/tools/compress.js.map +1 -1
- package/dist/lib/tools/index.d.ts +1 -3
- package/dist/lib/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/index.js +0 -2
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/types.d.ts +1 -1
- package/dist/lib/tools/types.d.ts.map +1 -1
- package/dist/lib/ui/notification.d.ts +2 -2
- package/dist/lib/ui/notification.d.ts.map +1 -1
- package/dist/lib/ui/notification.js +31 -28
- package/dist/lib/ui/notification.js.map +1 -1
- package/dist/lib/ui/utils.d.ts +3 -4
- package/dist/lib/ui/utils.d.ts.map +1 -1
- package/dist/lib/ui/utils.js +165 -24
- package/dist/lib/ui/utils.js.map +1 -1
- package/package.json +2 -1
- package/dist/lib/messages/inject.d.ts +0 -14
- package/dist/lib/messages/inject.d.ts.map +0 -1
- package/dist/lib/messages/inject.js +0 -266
- package/dist/lib/messages/inject.js.map +0 -1
- package/dist/lib/messages/sync.d.ts +0 -4
- package/dist/lib/messages/sync.d.ts.map +0 -1
- package/dist/lib/messages/sync.js +0 -29
- package/dist/lib/messages/sync.js.map +0 -1
- package/dist/lib/prompts/_codegen/compress-nudge.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/compress-nudge.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/compress-nudge.generated.js +0 -15
- package/dist/lib/prompts/_codegen/compress-nudge.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/compress.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/compress.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/compress.generated.js +0 -66
- package/dist/lib/prompts/_codegen/compress.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/distill.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/distill.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/distill.generated.js +0 -33
- package/dist/lib/prompts/_codegen/distill.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/nudge.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/nudge.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/nudge.generated.js +0 -17
- package/dist/lib/prompts/_codegen/nudge.generated.js.map +0 -1
- package/dist/lib/prompts/_codegen/prune.generated.d.ts +0 -2
- package/dist/lib/prompts/_codegen/prune.generated.d.ts.map +0 -1
- package/dist/lib/prompts/_codegen/prune.generated.js +0 -23
- package/dist/lib/prompts/_codegen/prune.generated.js.map +0 -1
- package/dist/lib/tools/distill.d.ts +0 -4
- package/dist/lib/tools/distill.d.ts.map +0 -1
- package/dist/lib/tools/distill.js +0 -41
- package/dist/lib/tools/distill.js.map +0 -1
- package/dist/lib/tools/prune-shared.d.ts +0 -8
- package/dist/lib/tools/prune-shared.d.ts.map +0 -1
- package/dist/lib/tools/prune-shared.js +0 -127
- package/dist/lib/tools/prune-shared.js.map +0 -1
- package/dist/lib/tools/prune.d.ts +0 -4
- package/dist/lib/tools/prune.d.ts.map +0 -1
- package/dist/lib/tools/prune.js +0 -28
- package/dist/lib/tools/prune.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const COMPRESS = "Use this tool to collapse a contiguous range of conversation into a preserved summary.\n\nTHE PHILOSOPHY OF COMPRESS\n`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.\n\nThink of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.\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\nWhen the selected range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.\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\nTHE WAYS OF COMPRESS\n`compress` when a chapter closes - when a phase of work is truly complete and the raw conversation has served its purpose:\n\nResearch concluded and findings are clear\nImplementation finished and verified\nExploration exhausted and patterns understood\n\nDo NOT compress when:\nYou may need exact code, error messages, or file contents from the range\nWork in that area is still active or may resume\nYou're mid-sprint on related functionality\n\nBefore compressing, ask: _\"Is this chapter closed?\"_ Compression is irreversible. The summary replaces everything in the range.\n\nBOUNDARY IDS\nYou specify boundaries by ID.\n\nUse the injected IDs visible in the conversation:\n\n- `mNNNN` IDs identify raw messages\n- `bN` IDs identify previously compressed blocks\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.\n\nCOMPRESSED BLOCK PLACEHOLDERS\nWhen the selected range includes previously compressed blocks, use placeholders in this exact format:\n\n- `(bN)`\n\nRules:\n\n- Include every required placeholder exactly once.\n- Do not include placeholders for blocks outside the selected range.\n- Treat `(bN)` placeholders as reserved tokens and only use them intentionally.\n- If needed in prose, refer to a block as plain text like `compressed b3` (not as a placeholder token).\n\nTHE FORMAT OF COMPRESS\n`topic`: Short label (3-5 words) for display - e.g., \"Auth System Exploration\"\n`content`: Object containing:\n`startId`: Boundary ID marking the beginning of the range (`mNNNN` or `bN`)\n`endId`: Boundary ID marking the end of the range (`mNNNN` or `bN`)\n`summary`: Complete technical summary replacing all content in the range\n";
|
|
2
|
-
//# sourceMappingURL=compress.generated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.generated.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/compress.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,8+FA6DpB,CAAA"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
-
// Generated from compress.md by scripts/generate-prompts.ts
|
|
3
|
-
// To modify, edit compress.md and run `npm run generate:prompts`
|
|
4
|
-
export const COMPRESS = `Use this tool to collapse a contiguous range of conversation into a preserved summary.
|
|
5
|
-
|
|
6
|
-
THE PHILOSOPHY OF COMPRESS
|
|
7
|
-
\`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.
|
|
8
|
-
|
|
9
|
-
Think of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.
|
|
10
|
-
|
|
11
|
-
THE SUMMARY
|
|
12
|
-
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.
|
|
13
|
-
|
|
14
|
-
When the selected range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
15
|
-
|
|
16
|
-
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
17
|
-
|
|
18
|
-
THE WAYS OF COMPRESS
|
|
19
|
-
\`compress\` when a chapter closes - when a phase of work is truly complete and the raw conversation has served its purpose:
|
|
20
|
-
|
|
21
|
-
Research concluded and findings are clear
|
|
22
|
-
Implementation finished and verified
|
|
23
|
-
Exploration exhausted and patterns understood
|
|
24
|
-
|
|
25
|
-
Do NOT compress when:
|
|
26
|
-
You may need exact code, error messages, or file contents from the range
|
|
27
|
-
Work in that area is still active or may resume
|
|
28
|
-
You're mid-sprint on related functionality
|
|
29
|
-
|
|
30
|
-
Before compressing, ask: _"Is this chapter closed?"_ Compression is irreversible. The summary replaces everything in the range.
|
|
31
|
-
|
|
32
|
-
BOUNDARY IDS
|
|
33
|
-
You specify boundaries by ID.
|
|
34
|
-
|
|
35
|
-
Use the injected IDs visible in the conversation:
|
|
36
|
-
|
|
37
|
-
- \`mNNNN\` IDs identify raw messages
|
|
38
|
-
- \`bN\` IDs identify previously compressed blocks
|
|
39
|
-
|
|
40
|
-
Rules:
|
|
41
|
-
|
|
42
|
-
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
43
|
-
- IDs must exist in the current visible context.
|
|
44
|
-
- \`startId\` must appear before \`endId\`.
|
|
45
|
-
- Do not invent IDs.
|
|
46
|
-
|
|
47
|
-
COMPRESSED BLOCK PLACEHOLDERS
|
|
48
|
-
When the selected range includes previously compressed blocks, use placeholders in this exact format:
|
|
49
|
-
|
|
50
|
-
- \`(bN)\`
|
|
51
|
-
|
|
52
|
-
Rules:
|
|
53
|
-
|
|
54
|
-
- Include every required placeholder exactly once.
|
|
55
|
-
- Do not include placeholders for blocks outside the selected range.
|
|
56
|
-
- Treat \`(bN)\` placeholders as reserved tokens and only use them intentionally.
|
|
57
|
-
- If needed in prose, refer to a block as plain text like \`compressed b3\` (not as a placeholder token).
|
|
58
|
-
|
|
59
|
-
THE FORMAT OF COMPRESS
|
|
60
|
-
\`topic\`: Short label (3-5 words) for display - e.g., "Auth System Exploration"
|
|
61
|
-
\`content\`: Object containing:
|
|
62
|
-
\`startId\`: Boundary ID marking the beginning of the range (\`mNNNN\` or \`bN\`)
|
|
63
|
-
\`endId\`: Boundary ID marking the end of the range (\`mNNNN\` or \`bN\`)
|
|
64
|
-
\`summary\`: Complete technical summary replacing all content in the range
|
|
65
|
-
`;
|
|
66
|
-
//# sourceMappingURL=compress.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compress.generated.js","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/compress.generated.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,4DAA4D;AAC5D,iEAAiE;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DvB,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const DISTILL = "Use this tool to distill relevant findings from a selection of raw tool outputs into preserved knowledge, in order to denoise key bits and parts of context.\n\nTHE PRUNABLE TOOLS LIST\nA <prunable-tools> will show in context when outputs are available for distillation (you don't need to look for it). Each entry follows the format `ID: tool, parameter (~token usage)` (e.g., `20: read, /path/to/file.ts (~1500 tokens)`). You MUST select outputs by their numeric ID. THESE ARE YOUR ONLY VALID TARGETS.\n\nTHE PHILOSOPHY OF DISTILLATION\n`distill` is your favored instrument for transforming raw tool outputs into preserved knowledge. This is not mere summarization; it is high-fidelity extraction that makes the original output obsolete.\n\nYour distillation must be COMPLETE. Capture function signatures, type definitions, business logic, constraints, configuration values... EVERYTHING essential. Think of it as creating a high signal technical substitute so faithful that re-fetching the original would yield no additional value. Be thorough; be comprehensive; leave no ambiguity, ensure that your distillation stands alone, and is designed for easy retrieval and comprehension.\n\nAIM FOR IMPACT. Distillation is most powerful when applied to outputs that contain signal buried in noise. A single line requires no distillation; a hundred lines of API documentation do. Make sure the distillation is meaningful.\n\nTHE WAYS OF DISTILL\n`distill` when you have extracted the essence from tool outputs and the raw form has served its purpose.\nHere are some examples:\nEXPLORATION: You've read extensively and grasp the architecture. The original file contents are no longer needed; your understanding, synthesized, is sufficient.\nPRESERVATION: Valuable technical details (signatures, logic, constraints) coexist with noise. Preserve the former; discard the latter.\n\nNot everything should be distilled. Prefer keeping raw outputs when:\nPRECISION MATTERS: You will edit the file, grep for exact strings, or need line-accurate references. Distillation sacrifices precision for essence.\nUNCERTAINTY REMAINS: If you might need to re-examine the original, defer. Distillation is irreversible; be certain before you commit.\n\nBefore distilling, ask yourself: _\"Will I need the raw output for upcoming work?\"_ If you plan to edit a file you just read, keep it intact. Distillation is for completed exploration, not active work.\n\nTHE FORMAT OF DISTILL\n`targets`: Array of objects, each containing:\n`id`: Numeric ID (as string) from the `<prunable-tools>` list\n`distillation`: Complete technical substitute for that tool output\n";
|
|
2
|
-
//# sourceMappingURL=distill.generated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distill.generated.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/distill.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,+kFA4BnB,CAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
-
// Generated from distill.md by scripts/generate-prompts.ts
|
|
3
|
-
// To modify, edit distill.md and run `npm run generate:prompts`
|
|
4
|
-
export const DISTILL = `Use this tool to distill relevant findings from a selection of raw tool outputs into preserved knowledge, in order to denoise key bits and parts of context.
|
|
5
|
-
|
|
6
|
-
THE PRUNABLE TOOLS LIST
|
|
7
|
-
A <prunable-tools> will show in context when outputs are available for distillation (you don't need to look for it). Each entry follows the format \`ID: tool, parameter (~token usage)\` (e.g., \`20: read, /path/to/file.ts (~1500 tokens)\`). You MUST select outputs by their numeric ID. THESE ARE YOUR ONLY VALID TARGETS.
|
|
8
|
-
|
|
9
|
-
THE PHILOSOPHY OF DISTILLATION
|
|
10
|
-
\`distill\` is your favored instrument for transforming raw tool outputs into preserved knowledge. This is not mere summarization; it is high-fidelity extraction that makes the original output obsolete.
|
|
11
|
-
|
|
12
|
-
Your distillation must be COMPLETE. Capture function signatures, type definitions, business logic, constraints, configuration values... EVERYTHING essential. Think of it as creating a high signal technical substitute so faithful that re-fetching the original would yield no additional value. Be thorough; be comprehensive; leave no ambiguity, ensure that your distillation stands alone, and is designed for easy retrieval and comprehension.
|
|
13
|
-
|
|
14
|
-
AIM FOR IMPACT. Distillation is most powerful when applied to outputs that contain signal buried in noise. A single line requires no distillation; a hundred lines of API documentation do. Make sure the distillation is meaningful.
|
|
15
|
-
|
|
16
|
-
THE WAYS OF DISTILL
|
|
17
|
-
\`distill\` when you have extracted the essence from tool outputs and the raw form has served its purpose.
|
|
18
|
-
Here are some examples:
|
|
19
|
-
EXPLORATION: You've read extensively and grasp the architecture. The original file contents are no longer needed; your understanding, synthesized, is sufficient.
|
|
20
|
-
PRESERVATION: Valuable technical details (signatures, logic, constraints) coexist with noise. Preserve the former; discard the latter.
|
|
21
|
-
|
|
22
|
-
Not everything should be distilled. Prefer keeping raw outputs when:
|
|
23
|
-
PRECISION MATTERS: You will edit the file, grep for exact strings, or need line-accurate references. Distillation sacrifices precision for essence.
|
|
24
|
-
UNCERTAINTY REMAINS: If you might need to re-examine the original, defer. Distillation is irreversible; be certain before you commit.
|
|
25
|
-
|
|
26
|
-
Before distilling, ask yourself: _"Will I need the raw output for upcoming work?"_ If you plan to edit a file you just read, keep it intact. Distillation is for completed exploration, not active work.
|
|
27
|
-
|
|
28
|
-
THE FORMAT OF DISTILL
|
|
29
|
-
\`targets\`: Array of objects, each containing:
|
|
30
|
-
\`id\`: Numeric ID (as string) from the \`<prunable-tools>\` list
|
|
31
|
-
\`distillation\`: Complete technical substitute for that tool output
|
|
32
|
-
`;
|
|
33
|
-
//# sourceMappingURL=distill.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distill.generated.js","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/distill.generated.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,2DAA2D;AAC3D,gEAAgE;AAEhE,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BtB,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const NUDGE = "<instruction name=context_management_required>\nCRITICAL CONTEXT WARNING\nYour context window is filling with tool. Strict adherence to context hygiene is required.\n\nPROTOCOL\nYou should prioritize context management, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.\n\nIMMEDIATE ACTION REQUIRED\n<distill>KNOWLEDGE PRESERVATION: If holding valuable raw data you POTENTIALLY will need in your task, use the `distill` tool. Produce a high-fidelity distillation to preserve insights - be thorough</distill>\n<compress>PHASE COMPLETION: If a phase is complete, use the `compress` tool to condense the entire sequence into a detailed summary</compress>\n<prune>NOISE REMOVAL: If you read files or ran commands that yielded no value, use the `prune` tool to remove them. If newer tools supersedes older ones, prune the old</prune>\n</instruction>\n";
|
|
2
|
-
//# sourceMappingURL=nudge.generated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nudge.generated.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/nudge.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,+6BAYjB,CAAA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
-
// Generated from nudge.md by scripts/generate-prompts.ts
|
|
3
|
-
// To modify, edit nudge.md and run `npm run generate:prompts`
|
|
4
|
-
export const NUDGE = `<instruction name=context_management_required>
|
|
5
|
-
CRITICAL CONTEXT WARNING
|
|
6
|
-
Your context window is filling with tool. Strict adherence to context hygiene is required.
|
|
7
|
-
|
|
8
|
-
PROTOCOL
|
|
9
|
-
You should prioritize context management, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
|
|
10
|
-
|
|
11
|
-
IMMEDIATE ACTION REQUIRED
|
|
12
|
-
<distill>KNOWLEDGE PRESERVATION: If holding valuable raw data you POTENTIALLY will need in your task, use the \`distill\` tool. Produce a high-fidelity distillation to preserve insights - be thorough</distill>
|
|
13
|
-
<compress>PHASE COMPLETION: If a phase is complete, use the \`compress\` tool to condense the entire sequence into a detailed summary</compress>
|
|
14
|
-
<prune>NOISE REMOVAL: If you read files or ran commands that yielded no value, use the \`prune\` tool to remove them. If newer tools supersedes older ones, prune the old</prune>
|
|
15
|
-
</instruction>
|
|
16
|
-
`;
|
|
17
|
-
//# sourceMappingURL=nudge.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nudge.generated.js","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/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 = "Use this tool to remove tool outputs from context entirely. No preservation - pure deletion.\n\nTHE PRUNABLE TOOLS LIST\nA `<prunable-tools>` section surfaces in context showing outputs eligible for removal. Each line reads `ID: tool, parameter (~token usage)` (e.g., `20: read, /path/to/file.ts (~1500 tokens)`). Reference outputs by their numeric ID - these are your ONLY valid targets for pruning.\n\nTHE WAYS OF PRUNE\n`prune` is surgical deletion - eliminating noise (irrelevant or unhelpful outputs), superseded information (older outputs replaced by newer data), or wrong targets (you accessed something that turned out to be irrelevant). Use it to keep your context lean and focused.\n\nBATCH WISELY! Pruning is most effective when consolidated. Don't prune a single tiny output - accumulate several candidates before acting.\n\nDo NOT prune when:\nNEEDED LATER: You plan to edit the file or reference this context for implementation.\nUNCERTAINTY: If you might need to re-examine the original, keep it.\n\nBefore pruning, ask: _\"Is this noise, or will it serve me?\"_ If the latter, keep it. Pruning that forces re-fetching is a net loss.\n\nTHE FORMAT OF PRUNE\n`ids`: Array of numeric IDs (as strings) from the `<prunable-tools>` list\n";
|
|
2
|
-
//# sourceMappingURL=prune.generated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune.generated.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/prune.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,quCAkBjB,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
-
// Generated from prune.md by scripts/generate-prompts.ts
|
|
3
|
-
// To modify, edit prune.md and run `npm run generate:prompts`
|
|
4
|
-
export const PRUNE = `Use this tool to remove tool outputs from context entirely. No preservation - pure deletion.
|
|
5
|
-
|
|
6
|
-
THE PRUNABLE TOOLS LIST
|
|
7
|
-
A \`<prunable-tools>\` section surfaces in context showing outputs eligible for removal. Each line reads \`ID: tool, parameter (~token usage)\` (e.g., \`20: read, /path/to/file.ts (~1500 tokens)\`). Reference outputs by their numeric ID - these are your ONLY valid targets for pruning.
|
|
8
|
-
|
|
9
|
-
THE WAYS OF PRUNE
|
|
10
|
-
\`prune\` is surgical deletion - eliminating noise (irrelevant or unhelpful outputs), superseded information (older outputs replaced by newer data), or wrong targets (you accessed something that turned out to be irrelevant). Use it to keep your context lean and focused.
|
|
11
|
-
|
|
12
|
-
BATCH WISELY! Pruning is most effective when consolidated. Don't prune a single tiny output - accumulate several candidates before acting.
|
|
13
|
-
|
|
14
|
-
Do NOT prune when:
|
|
15
|
-
NEEDED LATER: You plan to edit the file or reference this context for implementation.
|
|
16
|
-
UNCERTAINTY: If you might need to re-examine the original, keep it.
|
|
17
|
-
|
|
18
|
-
Before pruning, ask: _"Is this noise, or will it serve me?"_ If the latter, keep it. Pruning that forces re-fetching is a net loss.
|
|
19
|
-
|
|
20
|
-
THE FORMAT OF PRUNE
|
|
21
|
-
\`ids\`: Array of numeric IDs (as strings) from the \`<prunable-tools>\` list
|
|
22
|
-
`;
|
|
23
|
-
//# sourceMappingURL=prune.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune.generated.js","sourceRoot":"","sources":["../../../../lib/prompts/_codegen/prune.generated.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,yDAAyD;AACzD,8DAA8D;AAE9D,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;CAkBpB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAoDhF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { tool } from "@opencode-ai/plugin";
|
|
2
|
-
import { executePruneOperation } from "./prune-shared";
|
|
3
|
-
import { loadPrompt } from "../prompts";
|
|
4
|
-
const DISTILL_TOOL_DESCRIPTION = loadPrompt("distill-tool-spec");
|
|
5
|
-
export function createDistillTool(ctx) {
|
|
6
|
-
return tool({
|
|
7
|
-
description: DISTILL_TOOL_DESCRIPTION,
|
|
8
|
-
args: {
|
|
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"),
|
|
19
|
-
},
|
|
20
|
-
async execute(args, toolCtx) {
|
|
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.");
|
|
24
|
-
}
|
|
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
|
-
}
|
|
34
|
-
}
|
|
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", "distill", distillations);
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=distill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;oBACzE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;oBACxE,MAAM,IAAI,KAAK,CACX,qEAAqE,CACxE,CAAA;gBACL,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;oBAClE,GAAG,CAAC,MAAM,CAAC,KAAK,CACZ,uCAAuC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CACnE,CAAA;oBACD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;gBACnE,CAAC;YACL,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;YACzC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;YAE7D,OAAO,qBAAqB,CACxB,GAAG,EACH,OAAO,EACP,GAAG,EACH,YAA2B,EAC3B,SAAS,EACT,SAAS,EACT,aAAa,CAChB,CAAA;QACL,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PruneOriginSource } from "../state";
|
|
2
|
-
import type { PruneToolContext } from "./types";
|
|
3
|
-
import { PruneReason } from "../ui/notification";
|
|
4
|
-
export declare function executePruneOperation(ctx: PruneToolContext, toolCtx: {
|
|
5
|
-
sessionID: string;
|
|
6
|
-
messageID?: string;
|
|
7
|
-
}, ids: string[], reason: PruneReason, toolName: string, source: PruneOriginSource, distillation?: string[]): Promise<string>;
|
|
8
|
-
//# sourceMappingURL=prune-shared.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune-shared.d.ts","sourceRoot":"","sources":["../../../lib/tools/prune-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA+C,MAAM,UAAU,CAAA;AAG9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,EAAE,WAAW,EAA2B,MAAM,oBAAoB,CAAA;AASzE,wBAAsB,qBAAqB,CACvC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAClD,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,EACzB,YAAY,CAAC,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,MAAM,CAAC,CAyKjB"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { syncToolCache } from "../state/tool-cache";
|
|
2
|
-
import { sendUnifiedNotification } from "../ui/notification";
|
|
3
|
-
import { formatPruningResultForTool } from "../ui/utils";
|
|
4
|
-
import { ensureSessionInitialized } from "../state";
|
|
5
|
-
import { saveSessionState } from "../state/persistence";
|
|
6
|
-
import { getTotalToolTokens, getCurrentParams } from "../strategies/utils";
|
|
7
|
-
import { getFilePathsFromParameters, isProtected } from "../protected-file-patterns";
|
|
8
|
-
import { buildToolIdList } from "../messages/utils";
|
|
9
|
-
// Shared logic for executing prune operations.
|
|
10
|
-
export async function executePruneOperation(ctx, toolCtx, ids, reason, toolName, source, distillation) {
|
|
11
|
-
const { client, state, logger, config, workingDirectory } = ctx;
|
|
12
|
-
const sessionId = toolCtx.sessionID;
|
|
13
|
-
logger.info(`${toolName} tool invoked`);
|
|
14
|
-
logger.info(JSON.stringify(reason ? { ids, reason } : { ids }));
|
|
15
|
-
if (!ids || ids.length === 0) {
|
|
16
|
-
logger.debug(`${toolName} tool called but ids is empty or undefined`);
|
|
17
|
-
throw new Error(`No IDs provided. Check the <prunable-tools> list for available IDs to ${toolName.toLowerCase()}.`);
|
|
18
|
-
}
|
|
19
|
-
const numericToolIds = ids
|
|
20
|
-
.map((id) => parseInt(id, 10))
|
|
21
|
-
.filter((n) => !isNaN(n));
|
|
22
|
-
if (numericToolIds.length === 0) {
|
|
23
|
-
logger.debug(`No numeric tool IDs provided for ${toolName}: ` + JSON.stringify(ids));
|
|
24
|
-
throw new Error("No numeric IDs provided. Format: ids: [id1, id2, ...]");
|
|
25
|
-
}
|
|
26
|
-
// Fetch messages to calculate tokens and find current agent
|
|
27
|
-
const messagesResponse = await client.session.messages({
|
|
28
|
-
path: { id: sessionId },
|
|
29
|
-
});
|
|
30
|
-
const messages = messagesResponse.data || messagesResponse;
|
|
31
|
-
// These 3 are probably not needed as they should always be set in the message
|
|
32
|
-
// transform handler, but in case something causes state to reset, this is a safety net
|
|
33
|
-
await ensureSessionInitialized(ctx.client, state, sessionId, logger, messages, config.manualMode.enabled);
|
|
34
|
-
syncToolCache(state, config, logger, messages);
|
|
35
|
-
buildToolIdList(state, messages, logger);
|
|
36
|
-
const currentParams = getCurrentParams(state, messages, logger);
|
|
37
|
-
const toolIdList = state.toolIdList;
|
|
38
|
-
const validNumericIds = [];
|
|
39
|
-
const skippedIds = [];
|
|
40
|
-
// Validate and filter IDs
|
|
41
|
-
for (const index of numericToolIds) {
|
|
42
|
-
// Validate that index is within bounds
|
|
43
|
-
if (index < 0 || index >= toolIdList.length) {
|
|
44
|
-
logger.debug(`Rejecting prune request - index out of bounds: ${index}`);
|
|
45
|
-
skippedIds.push(index.toString());
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const id = toolIdList[index];
|
|
49
|
-
const metadata = state.toolParameters.get(id);
|
|
50
|
-
// Validate that all IDs exist in cache and aren't protected
|
|
51
|
-
// (rejects hallucinated IDs and turn-protected tools not shown in <prunable-tools>)
|
|
52
|
-
if (!metadata) {
|
|
53
|
-
logger.debug("Rejecting prune request - ID not in cache (turn-protected or hallucinated)", { index, id });
|
|
54
|
-
skippedIds.push(index.toString());
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const allProtectedTools = config.tools.settings.protectedTools;
|
|
58
|
-
if (allProtectedTools.includes(metadata.tool)) {
|
|
59
|
-
logger.debug("Rejecting prune request - protected tool", {
|
|
60
|
-
index,
|
|
61
|
-
id,
|
|
62
|
-
tool: metadata.tool,
|
|
63
|
-
});
|
|
64
|
-
skippedIds.push(index.toString());
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
const filePaths = getFilePathsFromParameters(metadata.tool, metadata.parameters);
|
|
68
|
-
if (isProtected(filePaths, config.protectedFilePatterns)) {
|
|
69
|
-
logger.debug("Rejecting prune request - protected file path", {
|
|
70
|
-
index,
|
|
71
|
-
id,
|
|
72
|
-
tool: metadata.tool,
|
|
73
|
-
filePaths,
|
|
74
|
-
});
|
|
75
|
-
skippedIds.push(index.toString());
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (state.prune.tools.has(id)) {
|
|
79
|
-
logger.debug("Rejecting prune request - already pruned", { index, id });
|
|
80
|
-
skippedIds.push(index.toString());
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
validNumericIds.push(index);
|
|
84
|
-
}
|
|
85
|
-
if (validNumericIds.length === 0) {
|
|
86
|
-
const errorMsg = skippedIds.length > 0
|
|
87
|
-
? `Invalid IDs provided: [${skippedIds.join(", ")}]. Only use numeric IDs from the <prunable-tools> list.`
|
|
88
|
-
: `No valid IDs provided to ${toolName.toLowerCase()}.`;
|
|
89
|
-
throw new Error(errorMsg);
|
|
90
|
-
}
|
|
91
|
-
const pruneToolIds = validNumericIds.map((index) => toolIdList[index]);
|
|
92
|
-
const originMessageId = typeof toolCtx.messageID === "string" && toolCtx.messageID.length > 0
|
|
93
|
-
? toolCtx.messageID
|
|
94
|
-
: "";
|
|
95
|
-
if (!originMessageId) {
|
|
96
|
-
logger.warn(`Missing tool message ID for ${toolName} prune origin tracking`);
|
|
97
|
-
}
|
|
98
|
-
for (const id of pruneToolIds) {
|
|
99
|
-
const entry = state.toolParameters.get(id);
|
|
100
|
-
state.prune.tools.set(id, entry?.tokenCount ?? 0);
|
|
101
|
-
if (originMessageId) {
|
|
102
|
-
state.prune.origins.set(id, { source, originMessageId });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const toolMetadata = new Map();
|
|
106
|
-
for (const id of pruneToolIds) {
|
|
107
|
-
const toolParameters = state.toolParameters.get(id);
|
|
108
|
-
if (toolParameters) {
|
|
109
|
-
toolMetadata.set(id, toolParameters);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
logger.debug("No metadata found for ID", { id });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
state.stats.pruneTokenCounter += getTotalToolTokens(state, pruneToolIds);
|
|
116
|
-
await sendUnifiedNotification(client, logger, config, state, sessionId, pruneToolIds, toolMetadata, reason, currentParams, workingDirectory, distillation);
|
|
117
|
-
state.stats.totalPruneTokens += state.stats.pruneTokenCounter;
|
|
118
|
-
state.stats.pruneTokenCounter = 0;
|
|
119
|
-
state.nudgeCounter = 0;
|
|
120
|
-
saveSessionState(state, logger).catch((err) => logger.error("Failed to persist state", { error: err.message }));
|
|
121
|
-
let result = formatPruningResultForTool(pruneToolIds, toolMetadata, workingDirectory);
|
|
122
|
-
if (skippedIds.length > 0) {
|
|
123
|
-
result += `\n\nNote: ${skippedIds.length} IDs were skipped (invalid, protected, already pruned, or missing metadata): ${skippedIds.join(", ")}`;
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=prune-shared.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prune-shared.js","sourceRoot":"","sources":["../../../lib/tools/prune-shared.ts"],"names":[],"mappings":"AAIA,OAAO,E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AAC,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,gFAAgF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IACnJ,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CA2B9E"}
|
package/dist/lib/tools/prune.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { tool } from "@opencode-ai/plugin";
|
|
2
|
-
import { executePruneOperation } from "./prune-shared";
|
|
3
|
-
import { loadPrompt } from "../prompts";
|
|
4
|
-
const PRUNE_TOOL_DESCRIPTION = loadPrompt("prune-tool-spec");
|
|
5
|
-
export function createPruneTool(ctx) {
|
|
6
|
-
return tool({
|
|
7
|
-
description: PRUNE_TOOL_DESCRIPTION,
|
|
8
|
-
args: {
|
|
9
|
-
ids: tool.schema
|
|
10
|
-
.array(tool.schema.string())
|
|
11
|
-
.describe("Numeric IDs as strings from the <prunable-tools> list to prune"),
|
|
12
|
-
},
|
|
13
|
-
async execute(args, toolCtx) {
|
|
14
|
-
if (!args.ids || !Array.isArray(args.ids) || args.ids.length === 0) {
|
|
15
|
-
ctx.logger.debug("Prune tool called without ids: " + JSON.stringify(args));
|
|
16
|
-
throw new Error("Missing ids. You must provide at least one ID to prune.");
|
|
17
|
-
}
|
|
18
|
-
if (!args.ids.every((id) => typeof id === "string" && id.trim() !== "")) {
|
|
19
|
-
ctx.logger.debug("Prune tool called with invalid ids: " + JSON.stringify(args));
|
|
20
|
-
throw new Error('Invalid ids. All IDs must be numeric strings (e.g., "1", "23") from the <prunable-tools> list.');
|
|
21
|
-
}
|
|
22
|
-
const numericIds = args.ids;
|
|
23
|
-
const reason = "noise";
|
|
24
|
-
return executePruneOperation(ctx, toolCtx, numericIds, reason, "Prune", "prune");
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=prune.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,CAAC,gEAAgE,CAAC;SAClF;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO;YACvB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjE,GAAG,C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