@tarquinen/opencode-dcp 0.3.23 → 0.3.24

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 CHANGED
@@ -13,7 +13,7 @@ Add to your OpenCode config:
13
13
  ```jsonc
14
14
  // opencode.jsonc
15
15
  {
16
- "plugin": ["@tarquinen/opencode-dcp@0.3.23"]
16
+ "plugin": ["@tarquinen/opencode-dcp@0.3.24"]
17
17
  }
18
18
  ```
19
19
 
@@ -1,3 +1,3 @@
1
- export declare function loadPrompt(name: string): string;
1
+ export declare function loadPrompt(name: string, vars?: Record<string, string>): string;
2
2
  export declare function buildAnalysisPrompt(unprunedToolCallIds: string[], messages: any[], alreadyPrunedIds?: string[], protectedToolCallIds?: string[], reason?: string): string;
3
3
  //# sourceMappingURL=prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AA4GD,wBAAgB,mBAAmB,CAC/B,mBAAmB,EAAE,MAAM,EAAE,EAC7B,QAAQ,EAAE,GAAG,EAAE,EACf,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAC3B,oBAAoB,CAAC,EAAE,MAAM,EAAE,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,MAAM,CAuCR"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAS9E;AA4GD,wBAAgB,mBAAmB,CAC/B,mBAAmB,EAAE,MAAM,EAAE,EAC7B,QAAQ,EAAE,GAAG,EAAE,EACf,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAC3B,oBAAoB,CAAC,EAAE,MAAM,EAAE,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,MAAM,CAaR"}
@@ -1,8 +1,14 @@
1
1
  import { readFileSync } from "fs";
2
2
  import { join } from "path";
3
- export function loadPrompt(name) {
3
+ export function loadPrompt(name, vars) {
4
4
  const filePath = join(__dirname, "prompts", `${name}.txt`);
5
- return readFileSync(filePath, "utf8").trim();
5
+ let content = readFileSync(filePath, "utf8").trim();
6
+ if (vars) {
7
+ for (const [key, value] of Object.entries(vars)) {
8
+ content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
9
+ }
10
+ }
11
+ return content;
6
12
  }
7
13
  function minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds) {
8
14
  const prunedIdsSet = alreadyPrunedIds ? new Set(alreadyPrunedIds.map(id => id.toLowerCase())) : new Set();
@@ -105,35 +111,10 @@ export function buildAnalysisPrompt(unprunedToolCallIds, messages, alreadyPruned
105
111
  const reasonContext = reason
106
112
  ? `\nContext: The AI has requested pruning with the following reason: "${reason}"\nUse this context to inform your decisions about what is most relevant to keep.`
107
113
  : '';
108
- return `You are a conversation analyzer that identifies obsolete tool outputs in a coding session.
109
- ${reasonContext}
110
- Your task: Analyze the session history and identify tool call IDs whose outputs are NO LONGER RELEVANT to the current conversation context.
111
-
112
- Guidelines for identifying obsolete tool calls:
113
- 1. Exploratory reads that didn't lead to actual edits or meaningful discussion AND were not explicitly requested to be retained
114
- 2. Tool outputs from debugging/fixing an error that has now been resolved
115
- 3. Failed or incorrect tool attempts that were immediately corrected (e.g., reading a file from the wrong path, then reading from the correct path)
116
-
117
- DO NOT prune:
118
- - Tool calls whose outputs are actively being discussed
119
- - Tool calls that produced errors still being debugged
120
- - Tool calls that are the MOST RECENT activity in the conversation (these may be intended for future use)
121
-
122
- IMPORTANT: Available tool call IDs for analysis: ${unprunedToolCallIds.join(", ")}
123
-
124
- The session history below may contain tool calls with IDs not in the available list above, these cannot be pruned. These are either:
125
- 1. Protected tools (marked with toolCallID "<protected>")
126
- 2. Already-pruned tools (marked with toolCallID "<already-pruned>")
127
-
128
- ONLY return IDs from the available list above.
129
-
130
- Session history (each tool call has a "toolCallID" field):
131
- ${messagesJson}
132
-
133
- You MUST respond with valid JSON matching this exact schema:
134
- {
135
- "pruned_tool_call_ids": ["id1", "id2", ...],
136
- "reasoning": "explanation of why these IDs were selected"
137
- }`;
114
+ return loadPrompt("pruning", {
115
+ reason_context: reasonContext,
116
+ available_tool_call_ids: unprunedToolCallIds.join(", "),
117
+ session_history: messagesJson
118
+ });
138
119
  }
139
120
  //# sourceMappingURL=prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,MAAM,UAAU,UAAU,CAAC,IAAY;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,MAAM,CAAC,CAAA;IAC1D,OAAO,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;AAChD,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAe,EAAE,gBAA2B,EAAE,oBAA+B;IACnG,MAAM,YAAY,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAA;IACzG,MAAM,eAAe,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAA;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tD,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;6BACpD,CAAA;wBACL,CAAC;6BACI,CAAC;4BACF,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;wBAC1B,CAAC;oBACL,CAAC;oBAED,OAAO,QAAQ,CAAA;gBACnB,CAAC;gBAED,OAAO,IAAI,CAAA;YACf,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,SAAS,CAAA;IACpB,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACZ,OAAO,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,MAAM,UAAU,mBAAmB,CAC/B,mBAA6B,EAC7B,QAAe,EACf,gBAA2B,EAC3B,oBAA+B,EAC/B,MAAe;IAEf,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;IAC5F,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAErF,MAAM,aAAa,GAAG,MAAM;QACxB,CAAC,CAAC,uEAAuE,MAAM,mFAAmF;QAClK,CAAC,CAAC,EAAE,CAAA;IAER,OAAO,UAAU,CAAC,SAAS,EAAE;QACzB,cAAc,EAAE,aAAa;QAC7B,uBAAuB,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;QACvD,eAAe,EAAE,YAAY;KAChC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,30 @@
1
+ You are a conversation analyzer that identifies obsolete tool outputs in a coding session.
2
+ {{reason_context}}
3
+ Your task: Analyze the session history and identify tool call IDs whose outputs are NO LONGER RELEVANT to the current conversation context.
4
+
5
+ Guidelines for identifying obsolete tool calls:
6
+ 1. Exploratory reads that didn't lead to actual edits or meaningful discussion AND were not explicitly requested to be retained
7
+ 2. Tool outputs from debugging/fixing an error that has now been resolved
8
+ 3. Failed or incorrect tool attempts that were immediately corrected (e.g., reading a file from the wrong path, then reading from the correct path)
9
+
10
+ DO NOT prune:
11
+ - Tool calls whose outputs are actively being discussed
12
+ - Tool calls that produced errors still being debugged
13
+ - Tool calls that are the MOST RECENT activity in the conversation (these may be intended for future use)
14
+
15
+ IMPORTANT: Available tool call IDs for analysis: {{available_tool_call_ids}}
16
+
17
+ The session history below may contain tool calls with IDs not in the available list above, these cannot be pruned. These are either:
18
+ 1. Protected tools (marked with toolCallID "<protected>")
19
+ 2. Already-pruned tools (marked with toolCallID "<already-pruned>")
20
+
21
+ ONLY return IDs from the available list above.
22
+
23
+ Session history (each tool call has a "toolCallID" field):
24
+ {{session_history}}
25
+
26
+ You MUST respond with valid JSON matching this exact schema:
27
+ {
28
+ "pruned_tool_call_ids": ["id1", "id2", ...],
29
+ "reasoning": "explanation of why these IDs were selected"
30
+ }
@@ -1,8 +1,8 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
2
  import type { Janitor } from "./janitor";
3
3
  import type { PluginConfig } from "./config";
4
- /** Tool description for the context_pruning tool */
5
- export declare const CONTEXT_PRUNING_DESCRIPTION = "Performs semantic pruning on session tool outputs that are no longer relevant to the current task. Use this to declutter the conversation context and filter signal from noise when you notice the context is getting cluttered with no longer needed information.\n\nUSING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY.\n\n## When to Use This Tool\n\n**Key heuristic: Prune when you finish something and are about to start something else.**\n\nAsk yourself: \"Have I just completed a discrete unit of work?\" If yes, prune before moving on.\n\n**After completing a unit of work:**\n- Made a commit\n- Fixed a bug and confirmed it works\n- Answered a question the user asked\n- Finished implementing a feature or function\n- Completed one item in a list and moving to the next\n\n**After repetitive or exploratory work:**\n- Explored multiple files that didn't lead to changes\n- Iterated on a difficult problem where some approaches didn't pan out\n- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks)\n\n## Examples\n\n<example>\nWorking through a list of items:\nUser: Review these 3 issues and fix the easy ones.\nAssistant: [Reviews first issue, makes fix, commits]\nDone with the first issue. Let me prune before moving to the next one.\n[Uses context_pruning with reason: \"completed first issue, moving to next\"]\n</example>\n\n<example>\nAfter exploring the codebase to understand it:\nAssistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation.\n[Uses context_pruning with reason: \"exploration complete, starting implementation\"]\n</example>\n\n<example>\nAfter completing any task:\nAssistant: [Finishes task - commit, answer, fix, etc.]\nBefore we continue, let me prune the context from that work.\n[Uses context_pruning with reason: \"task complete\"]\n</example>";
4
+ /** Tool description for the context_pruning tool, loaded from prompts/tool.txt */
5
+ export declare const CONTEXT_PRUNING_DESCRIPTION: string;
6
6
  /**
7
7
  * Creates the context_pruning tool definition.
8
8
  * Returns a tool definition that can be passed to the plugin's tool registry.
@@ -1 +1 @@
1
- {"version":3,"file":"pruning-tool.d.ts","sourceRoot":"","sources":["../../lib/pruning-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,oDAAoD;AACpD,eAAO,MAAM,2BAA2B,02DA2C7B,CAAA;AAEX;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAsBjG"}
1
+ {"version":3,"file":"pruning-tool.d.ts","sourceRoot":"","sources":["../../lib/pruning-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAG5C,kFAAkF;AAClF,eAAO,MAAM,2BAA2B,QAAqB,CAAA;AAE7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAsBjG"}
@@ -1,49 +1,7 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
- /** Tool description for the context_pruning tool */
3
- export const CONTEXT_PRUNING_DESCRIPTION = `Performs semantic pruning on session tool outputs that are no longer relevant to the current task. Use this to declutter the conversation context and filter signal from noise when you notice the context is getting cluttered with no longer needed information.
4
-
5
- USING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY.
6
-
7
- ## When to Use This Tool
8
-
9
- **Key heuristic: Prune when you finish something and are about to start something else.**
10
-
11
- Ask yourself: "Have I just completed a discrete unit of work?" If yes, prune before moving on.
12
-
13
- **After completing a unit of work:**
14
- - Made a commit
15
- - Fixed a bug and confirmed it works
16
- - Answered a question the user asked
17
- - Finished implementing a feature or function
18
- - Completed one item in a list and moving to the next
19
-
20
- **After repetitive or exploratory work:**
21
- - Explored multiple files that didn't lead to changes
22
- - Iterated on a difficult problem where some approaches didn't pan out
23
- - Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks)
24
-
25
- ## Examples
26
-
27
- <example>
28
- Working through a list of items:
29
- User: Review these 3 issues and fix the easy ones.
30
- Assistant: [Reviews first issue, makes fix, commits]
31
- Done with the first issue. Let me prune before moving to the next one.
32
- [Uses context_pruning with reason: "completed first issue, moving to next"]
33
- </example>
34
-
35
- <example>
36
- After exploring the codebase to understand it:
37
- Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation.
38
- [Uses context_pruning with reason: "exploration complete, starting implementation"]
39
- </example>
40
-
41
- <example>
42
- After completing any task:
43
- Assistant: [Finishes task - commit, answer, fix, etc.]
44
- Before we continue, let me prune the context from that work.
45
- [Uses context_pruning with reason: "task complete"]
46
- </example>`;
2
+ import { loadPrompt } from "./prompt";
3
+ /** Tool description for the context_pruning tool, loaded from prompts/tool.txt */
4
+ export const CONTEXT_PRUNING_DESCRIPTION = loadPrompt("tool");
47
5
  /**
48
6
  * Creates the context_pruning tool definition.
49
7
  * Returns a tool definition that can be passed to the plugin's tool registry.
@@ -1 +1 @@
1
- {"version":3,"file":"pruning-tool.js","sourceRoot":"","sources":["../../lib/pruning-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAI1C,oDAAoD;AACpD,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2ChC,CAAA;AAEX;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,MAAoB;IACpE,OAAO,IAAI,CAAC;QACR,WAAW,EAAE,2BAA2B;QACxC,IAAI,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAC5C,gFAAgF,CACnF;SACJ;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;YACnB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CACnC,GAAG,CAAC,SAAS,EACb,MAAM,CAAC,UAAU,CAAC,MAAM,EACxB,IAAI,CAAC,MAAM,CACd,CAAA;YAED,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;gBACtC,OAAO,mMAAmM,CAAA;YAC9M,CAAC;YAED,OAAO,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,GAAG,6IAA6I,CAAA;QACrM,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
1
+ {"version":3,"file":"pruning-tool.js","sourceRoot":"","sources":["../../lib/pruning-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;AAE7D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,MAAoB;IACpE,OAAO,IAAI,CAAC;QACR,WAAW,EAAE,2BAA2B;QACxC,IAAI,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAC5C,gFAAgF,CACnF;SACJ;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;YACnB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CACnC,GAAG,CAAC,SAAS,EACb,MAAM,CAAC,UAAU,CAAC,MAAM,EACxB,IAAI,CAAC,MAAM,CACd,CAAA;YAED,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;gBACtC,OAAO,mMAAmM,CAAA;YAC9M,CAAC;YAED,OAAO,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,GAAG,6IAA6I,CAAA;QACrM,CAAC;KACJ,CAAC,CAAA;AACN,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": "0.3.23",
4
+ "version": "0.3.24",
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",