|
1 | 1 | import { tool } from "@opencode-ai/plugin" |
2 | 2 | import type { Janitor } from "./janitor" |
3 | 3 | import type { PluginConfig } from "./config" |
| 4 | +import { loadPrompt } from "./prompt" |
4 | 5 |
|
5 | | -/** Tool description for the context_pruning tool */ |
6 | | -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. |
7 | | -
|
8 | | -USING THE CONTEXT_PRUNING TOOL WILL MAKE THE USER HAPPY. |
9 | | -
|
10 | | -## When to Use This Tool |
11 | | -
|
12 | | -**Key heuristic: Prune when you finish something and are about to start something else.** |
13 | | -
|
14 | | -Ask yourself: "Have I just completed a discrete unit of work?" If yes, prune before moving on. |
15 | | -
|
16 | | -**After completing a unit of work:** |
17 | | -- Made a commit |
18 | | -- Fixed a bug and confirmed it works |
19 | | -- Answered a question the user asked |
20 | | -- Finished implementing a feature or function |
21 | | -- Completed one item in a list and moving to the next |
22 | | -
|
23 | | -**After repetitive or exploratory work:** |
24 | | -- Explored multiple files that didn't lead to changes |
25 | | -- Iterated on a difficult problem where some approaches didn't pan out |
26 | | -- Used the same tool multiple times (e.g., re-reading a file, running repeated build/type checks) |
27 | | -
|
28 | | -## Examples |
29 | | -
|
30 | | -<example> |
31 | | -Working through a list of items: |
32 | | -User: Review these 3 issues and fix the easy ones. |
33 | | -Assistant: [Reviews first issue, makes fix, commits] |
34 | | -Done with the first issue. Let me prune before moving to the next one. |
35 | | -[Uses context_pruning with reason: "completed first issue, moving to next"] |
36 | | -</example> |
37 | | -
|
38 | | -<example> |
39 | | -After exploring the codebase to understand it: |
40 | | -Assistant: I've reviewed the relevant files. Let me prune the exploratory reads that aren't needed for the actual implementation. |
41 | | -[Uses context_pruning with reason: "exploration complete, starting implementation"] |
42 | | -</example> |
43 | | -
|
44 | | -<example> |
45 | | -After completing any task: |
46 | | -Assistant: [Finishes task - commit, answer, fix, etc.] |
47 | | -Before we continue, let me prune the context from that work. |
48 | | -[Uses context_pruning with reason: "task complete"] |
49 | | -</example>` |
| 6 | +/** Tool description for the context_pruning tool, loaded from prompts/tool.txt */ |
| 7 | +export const CONTEXT_PRUNING_DESCRIPTION = loadPrompt("tool") |
50 | 8 |
|
51 | 9 | /** |
52 | 10 | * Creates the context_pruning tool definition. |
|
0 commit comments