@royalcat/opencode-dcp-rc 0.0.0-stage → 4.0.1

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.
Files changed (215) hide show
  1. package/LICENSE +619 -0
  2. package/README.md +348 -2
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +8129 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/commands/compression-targets.d.ts +13 -0
  8. package/dist/lib/commands/compression-targets.d.ts.map +1 -0
  9. package/dist/lib/commands/context.d.ts +67 -0
  10. package/dist/lib/commands/context.d.ts.map +1 -0
  11. package/dist/lib/commands/decompress.d.ts +12 -0
  12. package/dist/lib/commands/decompress.d.ts.map +1 -0
  13. package/dist/lib/commands/help.d.ts +18 -0
  14. package/dist/lib/commands/help.d.ts.map +1 -0
  15. package/dist/lib/commands/index.d.ts +8 -0
  16. package/dist/lib/commands/index.d.ts.map +1 -0
  17. package/dist/lib/commands/manual.d.ts +23 -0
  18. package/dist/lib/commands/manual.d.ts.map +1 -0
  19. package/dist/lib/commands/recompress.d.ts +12 -0
  20. package/dist/lib/commands/recompress.d.ts.map +1 -0
  21. package/dist/lib/commands/stats.d.ts +27 -0
  22. package/dist/lib/commands/stats.d.ts.map +1 -0
  23. package/dist/lib/commands/sweep.d.ts +23 -0
  24. package/dist/lib/commands/sweep.d.ts.map +1 -0
  25. package/dist/lib/compress/index.d.ts +3 -0
  26. package/dist/lib/compress/index.d.ts.map +1 -0
  27. package/dist/lib/compress/pipeline.d.ts +29 -0
  28. package/dist/lib/compress/pipeline.d.ts.map +1 -0
  29. package/dist/lib/compress/protected-content.d.ts +6 -0
  30. package/dist/lib/compress/protected-content.d.ts.map +1 -0
  31. package/dist/lib/compress/rc.d.ts +15 -0
  32. package/dist/lib/compress/rc.d.ts.map +1 -0
  33. package/dist/lib/compress/search.d.ts +12 -0
  34. package/dist/lib/compress/search.d.ts.map +1 -0
  35. package/dist/lib/compress/state.d.ts +10 -0
  36. package/dist/lib/compress/state.d.ts.map +1 -0
  37. package/dist/lib/compress/summary.d.ts +68 -0
  38. package/dist/lib/compress/summary.d.ts.map +1 -0
  39. package/dist/lib/compress/timing.d.ts +18 -0
  40. package/dist/lib/compress/timing.d.ts.map +1 -0
  41. package/dist/lib/compress/types.d.ts +64 -0
  42. package/dist/lib/compress/types.d.ts.map +1 -0
  43. package/dist/lib/compress/usage.d.ts +45 -0
  44. package/dist/lib/compress/usage.d.ts.map +1 -0
  45. package/dist/lib/compress-permission.d.ts +4 -0
  46. package/dist/lib/compress-permission.d.ts.map +1 -0
  47. package/dist/lib/config.d.ts +83 -0
  48. package/dist/lib/config.d.ts.map +1 -0
  49. package/dist/lib/hooks.d.ts +22 -0
  50. package/dist/lib/hooks.d.ts.map +1 -0
  51. package/dist/lib/logger.d.ts +31 -0
  52. package/dist/lib/logger.d.ts.map +1 -0
  53. package/dist/lib/message-ids.d.ts +20 -0
  54. package/dist/lib/message-ids.d.ts.map +1 -0
  55. package/dist/lib/messages/index.d.ts +8 -0
  56. package/dist/lib/messages/index.d.ts.map +1 -0
  57. package/dist/lib/messages/inject/inject.d.ts +7 -0
  58. package/dist/lib/messages/inject/inject.d.ts.map +1 -0
  59. package/dist/lib/messages/inject/subagent-results.d.ts +4 -0
  60. package/dist/lib/messages/inject/subagent-results.d.ts.map +1 -0
  61. package/dist/lib/messages/inject/utils.d.ts +23 -0
  62. package/dist/lib/messages/inject/utils.d.ts.map +1 -0
  63. package/dist/lib/messages/prune.d.ts +4 -0
  64. package/dist/lib/messages/prune.d.ts.map +1 -0
  65. package/dist/lib/messages/query.d.ts +7 -0
  66. package/dist/lib/messages/query.d.ts.map +1 -0
  67. package/dist/lib/messages/reasoning-strip.d.ts +8 -0
  68. package/dist/lib/messages/reasoning-strip.d.ts.map +1 -0
  69. package/dist/lib/messages/shape.d.ts +5 -0
  70. package/dist/lib/messages/shape.d.ts.map +1 -0
  71. package/dist/lib/messages/sync.d.ts +4 -0
  72. package/dist/lib/messages/sync.d.ts.map +1 -0
  73. package/dist/lib/messages/utils.d.ts +27 -0
  74. package/dist/lib/messages/utils.d.ts.map +1 -0
  75. package/dist/lib/prompts/compress-rc.d.ts +4 -0
  76. package/dist/lib/prompts/compress-rc.d.ts.map +1 -0
  77. package/dist/lib/prompts/context-limit-nudge.d.ts +2 -0
  78. package/dist/lib/prompts/context-limit-nudge.d.ts.map +1 -0
  79. package/dist/lib/prompts/extensions/nudge.d.ts +4 -0
  80. package/dist/lib/prompts/extensions/nudge.d.ts.map +1 -0
  81. package/dist/lib/prompts/extensions/system.d.ts +4 -0
  82. package/dist/lib/prompts/extensions/system.d.ts.map +1 -0
  83. package/dist/lib/prompts/extensions/tool.d.ts +3 -0
  84. package/dist/lib/prompts/extensions/tool.d.ts.map +1 -0
  85. package/dist/lib/prompts/index.d.ts +4 -0
  86. package/dist/lib/prompts/index.d.ts.map +1 -0
  87. package/dist/lib/prompts/iteration-nudge.d.ts +2 -0
  88. package/dist/lib/prompts/iteration-nudge.d.ts.map +1 -0
  89. package/dist/lib/prompts/store.d.ts +26 -0
  90. package/dist/lib/prompts/store.d.ts.map +1 -0
  91. package/dist/lib/prompts/system.d.ts +4 -0
  92. package/dist/lib/prompts/system.d.ts.map +1 -0
  93. package/dist/lib/prompts/turn-nudge.d.ts +2 -0
  94. package/dist/lib/prompts/turn-nudge.d.ts.map +1 -0
  95. package/dist/lib/protected-patterns.d.ts +6 -0
  96. package/dist/lib/protected-patterns.d.ts.map +1 -0
  97. package/dist/lib/state/index.d.ts +5 -0
  98. package/dist/lib/state/index.d.ts.map +1 -0
  99. package/dist/lib/state/persistence.d.ts +47 -0
  100. package/dist/lib/state/persistence.d.ts.map +1 -0
  101. package/dist/lib/state/state.d.ts +9 -0
  102. package/dist/lib/state/state.d.ts.map +1 -0
  103. package/dist/lib/state/tool-cache.d.ts +13 -0
  104. package/dist/lib/state/tool-cache.d.ts.map +1 -0
  105. package/dist/lib/state/types.d.ts +105 -0
  106. package/dist/lib/state/types.d.ts.map +1 -0
  107. package/dist/lib/state/utils.d.ts +22 -0
  108. package/dist/lib/state/utils.d.ts.map +1 -0
  109. package/dist/lib/strategies/deduplication.d.ts +10 -0
  110. package/dist/lib/strategies/deduplication.d.ts.map +1 -0
  111. package/dist/lib/strategies/index.d.ts +3 -0
  112. package/dist/lib/strategies/index.d.ts.map +1 -0
  113. package/dist/lib/strategies/purge-errors.d.ts +13 -0
  114. package/dist/lib/strategies/purge-errors.d.ts.map +1 -0
  115. package/dist/lib/subagents/subagent-results.d.ts +5 -0
  116. package/dist/lib/subagents/subagent-results.d.ts.map +1 -0
  117. package/dist/lib/token-utils.d.ts +19 -0
  118. package/dist/lib/token-utils.d.ts.map +1 -0
  119. package/dist/lib/tui/dialogs.d.ts +29 -0
  120. package/dist/lib/tui/dialogs.d.ts.map +1 -0
  121. package/dist/lib/tui/format.d.ts +4 -0
  122. package/dist/lib/tui/format.d.ts.map +1 -0
  123. package/dist/lib/tui/types.d.ts +18 -0
  124. package/dist/lib/tui/types.d.ts.map +1 -0
  125. package/dist/lib/tui/ui.d.ts +48 -0
  126. package/dist/lib/tui/ui.d.ts.map +1 -0
  127. package/dist/lib/ui/notification.d.ts +17 -0
  128. package/dist/lib/ui/notification.d.ts.map +1 -0
  129. package/dist/lib/ui/utils.d.ts +10 -0
  130. package/dist/lib/ui/utils.d.ts.map +1 -0
  131. package/dist/lib/v2/index.d.ts +5 -0
  132. package/dist/lib/v2/index.d.ts.map +1 -0
  133. package/dist/lib/v2/messages.d.ts +13 -0
  134. package/dist/lib/v2/messages.d.ts.map +1 -0
  135. package/dist/lib/v2/rpc.d.ts +75 -0
  136. package/dist/lib/v2/rpc.d.ts.map +1 -0
  137. package/dist/lib/v2/theme.d.ts +55 -0
  138. package/dist/lib/v2/theme.d.ts.map +1 -0
  139. package/dist/lib/v2/tui.d.ts +4 -0
  140. package/dist/lib/v2/tui.d.ts.map +1 -0
  141. package/dist/lib/v2/usage.d.ts +44 -0
  142. package/dist/lib/v2/usage.d.ts.map +1 -0
  143. package/dist/tui.d.ts +7 -0
  144. package/dist/tui.d.ts.map +1 -0
  145. package/lib/commands/compression-targets.ts +54 -0
  146. package/lib/commands/context.ts +305 -0
  147. package/lib/commands/decompress.ts +273 -0
  148. package/lib/commands/help.ts +76 -0
  149. package/lib/commands/index.ts +11 -0
  150. package/lib/commands/manual.ts +126 -0
  151. package/lib/commands/recompress.ts +222 -0
  152. package/lib/commands/stats.ts +180 -0
  153. package/lib/commands/sweep.ts +266 -0
  154. package/lib/compress/index.ts +2 -0
  155. package/lib/compress/pipeline.ts +116 -0
  156. package/lib/compress/protected-content.ts +163 -0
  157. package/lib/compress/rc.ts +494 -0
  158. package/lib/compress/search.ts +277 -0
  159. package/lib/compress/state.ts +272 -0
  160. package/lib/compress/summary.ts +320 -0
  161. package/lib/compress/timing.ts +77 -0
  162. package/lib/compress/types.ts +70 -0
  163. package/lib/compress/usage.ts +168 -0
  164. package/lib/compress-permission.ts +9 -0
  165. package/lib/config.ts +995 -0
  166. package/lib/hooks.ts +205 -0
  167. package/lib/logger.ts +226 -0
  168. package/lib/message-ids.ts +181 -0
  169. package/lib/messages/index.ts +7 -0
  170. package/lib/messages/inject/inject.ts +215 -0
  171. package/lib/messages/inject/subagent-results.ts +84 -0
  172. package/lib/messages/inject/utils.ts +304 -0
  173. package/lib/messages/prune.ts +238 -0
  174. package/lib/messages/query.ts +71 -0
  175. package/lib/messages/reasoning-strip.ts +40 -0
  176. package/lib/messages/shape.ts +50 -0
  177. package/lib/messages/sync.ts +124 -0
  178. package/lib/messages/utils.ts +190 -0
  179. package/lib/prompts/compress-rc.ts +25 -0
  180. package/lib/prompts/context-limit-nudge.ts +18 -0
  181. package/lib/prompts/extensions/nudge.ts +34 -0
  182. package/lib/prompts/extensions/system.ts +32 -0
  183. package/lib/prompts/extensions/tool.ts +21 -0
  184. package/lib/prompts/index.ts +29 -0
  185. package/lib/prompts/iteration-nudge.ts +6 -0
  186. package/lib/prompts/store.ts +452 -0
  187. package/lib/prompts/system.ts +41 -0
  188. package/lib/prompts/turn-nudge.ts +10 -0
  189. package/lib/protected-patterns.ts +159 -0
  190. package/lib/state/index.ts +4 -0
  191. package/lib/state/persistence.ts +321 -0
  192. package/lib/state/state.ts +214 -0
  193. package/lib/state/tool-cache.ts +99 -0
  194. package/lib/state/types.ts +117 -0
  195. package/lib/state/utils.ts +345 -0
  196. package/lib/strategies/deduplication.ts +125 -0
  197. package/lib/strategies/index.ts +2 -0
  198. package/lib/strategies/purge-errors.ts +86 -0
  199. package/lib/subagents/subagent-results.ts +75 -0
  200. package/lib/token-utils.ts +164 -0
  201. package/lib/tui/dialogs.tsx +261 -0
  202. package/lib/tui/format.ts +25 -0
  203. package/lib/tui/types.ts +25 -0
  204. package/lib/tui/ui.tsx +245 -0
  205. package/lib/ui/notification.ts +347 -0
  206. package/lib/ui/utils.ts +304 -0
  207. package/lib/v2/index.ts +448 -0
  208. package/lib/v2/messages.ts +252 -0
  209. package/lib/v2/rpc.ts +60 -0
  210. package/lib/v2/theme.ts +67 -0
  211. package/lib/v2/tui.tsx +115 -0
  212. package/lib/v2/usage.ts +423 -0
  213. package/package.json +91 -5
  214. package/server.js +1 -0
  215. package/tui.tsx +7 -0
package/README.md CHANGED
@@ -1,3 +1,349 @@
1
- # Temporary Holding Version
1
+ # @royalcat/opencode-dcp-rc
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A fork of [Dynamic Context Pruning](https://github.com/Tarquinen/opencode-dynamic-context-pruning)
4
+
5
+ ## Why this fork exists
6
+
7
+ Upstream DCP is solid engineering, but its developers have clearly focused on their
8
+ commercial product, [Sleev](https://sleev.ai), and the open plugin gets the
9
+ leftovers. The core idea — the model picks stale messages and the summaries are
10
+ generated locally through your existing provider — needs no account, device lease,
11
+ or telemetry pipeline. This fork ports that idea back into the plugin, keeps it
12
+ fully local and invisible, and stays open for anyone who wants better context
13
+ management in OpenCode.
14
+
15
+ **Design goal: the plugin stays invisible.** Injected system prompts, message-ID
16
+ tags, nudges, and summary replacement only ever exist in the outgoing model
17
+ request. The user's stored history is never rewritten, and the only
18
+ user-visible artifact is the `compress` tool call itself.
19
+
20
+ ## How it differs from upstream DCP
21
+
22
+ - **The model selects; the plugin compresses.** `compress` takes only message IDs,
23
+ block IDs, or inclusive ranges — for example
24
+ `{ "ids": ["m0004-m0008", "m0011"] }` — never summary text. The plugin produces
25
+ one summary per selection with a dedicated prompt through your existing provider,
26
+ so compression follows a fixed, repeatable format instead of depending on what
27
+ the chat model would write inside the tool call.
28
+
29
+ - **OpenCode V2 only.** No V1 support and no upstream `range`/`message` modes.
30
+
31
+ - **Invisible by design.** Hiding is the intended behavior, not a setting: injected
32
+ prompts, message IDs, and nudges exist only in the request copy sent to the
33
+ model, stored history is never rewritten, and the only visible artifact is the
34
+ `compress` tool call and its result.
35
+
36
+ - **Fork names.** Package `@royalcat/opencode-dcp-rc`, config `dcp-rc.jsonc` /
37
+ `dcp-rc.json`, and no self-update. Commands and prompt overrides keep upstream
38
+ names: `/dcp`, `/dcp-compress`, and `dcp-prompts/overrides/`.
39
+
40
+ ## Install
41
+
42
+ Requires OpenCode V2 (`@opencode/plugin` ^2.0.22; verified against 2.0.4).
43
+
44
+ ```bash
45
+ opencode plugin add @royalcat/opencode-dcp-rc@latest
46
+ ```
47
+
48
+ or reference the package in `opencode.json(c)`:
49
+
50
+ ```jsonc
51
+ {
52
+ "plugins": ["@royalcat/opencode-dcp-rc"],
53
+ }
54
+ ```
55
+
56
+ > **Note:** installing directly from the Git URL
57
+ > (`opencode plugin add https://github.com/royalcat/opencode-dcp-rc`) currently
58
+ > fails because of an
59
+ > [OpenCode bug](https://github.com/anomalyco/opencode/issues/49704) when
60
+ > installing git dependencies. Install from npm as above.
61
+
62
+ ### Local development
63
+
64
+ ```bash
65
+ npm install --legacy-peer-deps
66
+ npm run build
67
+ opencode plugin add /path/to/opencode-dcp-rc
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ `~/.config/opencode/dcp-rc.jsonc` (created on first run):
73
+
74
+ ```jsonc
75
+ {
76
+ "compress": {
77
+ "permission": "allow",
78
+ "minContextLimit": 50000,
79
+ "maxContextLimit": 100000,
80
+ },
81
+ "pruneNotification": "off",
82
+ }
83
+ ```
84
+
85
+ The rest of the upstream configuration (strategies, protection lists, manual
86
+ mode, subagents) still applies, except `compress.mode` and `autoUpdate`, which
87
+ the fork no longer uses. Compress prompt text can be overridden through
88
+ `dcp-prompts/overrides/` when `experimental.customPrompts` is enabled.
89
+
90
+ ## Status and limitations
91
+
92
+ - The hidden summary call uses the session's provider/model and consumes a normal
93
+ model request. Its system prompt is a prefix of the main request, so providers
94
+ with prefix caching can reuse it.
95
+ - If the host rejects nested generation, the `compress` call fails visibly and the
96
+ selection is left uncompressed so it can be retried.
97
+ - Forked from DCP v3.2.0. Upstream is AGPL-3.0-or-later; this fork keeps the
98
+ same license and attribution (see `LICENSE`).
99
+
100
+ ---
101
+
102
+ # Upstream README
103
+
104
+ > **Fork note:** The upstream documentation below is kept for attribution and
105
+ > history. This fork does not ship its `range`/`message` modes, V1 support, or
106
+ > auto-update behavior; see the fork section above for what this package does.
107
+
108
+ # Dynamic Context Pruning Plugin
109
+
110
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/dansmolsky)
111
+ [![npm version](https://img.shields.io/npm/v/@tarquinen/opencode-dcp.svg)](https://www.npmjs.com/package/@tarquinen/opencode-dcp)
112
+
113
+ Automatically reduces token usage in OpenCode by managing conversation context.
114
+
115
+ ![DCP in action](assets/images/dcp-demo9.png)
116
+
117
+ ## Installation
118
+
119
+ Install from the OpenCode V2 CLI:
120
+
121
+ ```bash
122
+ opencode plugin add @tarquinen/opencode-dcp@latest
123
+ ```
124
+
125
+ This installs the package and adds it to your global OpenCode config.
126
+
127
+ ## Project Status
128
+
129
+ Development on DCP has slowed because most new context-management work has moved to [Sleev](https://sleev.ai) and the `sleev` CLI.
130
+
131
+ Sleev builds on DCP's core ideas with more advanced context management and significantly better performance. It's a local proxy that already supports Claude Code, Codex, OpenCode, Pi, and Hermes, and can be extended to support any harness.
132
+
133
+ DCP remains available for OpenCode plugin users, but new features are landing in Sleev first. If you are starting fresh, we recommend trying Sleev:
134
+
135
+ ```bash
136
+ npm i -g sleev
137
+ sleev
138
+ ```
139
+
140
+ ## How It Works
141
+
142
+ DCP reduces context size through a compress tool and automatic cleanup. Your session history is never modified — DCP replaces pruned content with placeholders before sending requests to your LLM.
143
+
144
+ ### Compress
145
+
146
+ Compress is a tool exposed to your model that replaces closed, stale conversation content with high-fidelity technical summaries. You can think of this as a much smarter version of Opencode's compaction process. Instead of triggering statically when your session reaches its maximum context and on the entire coding session, Compress allows the model to pick when to activate based on task completion, and to only compress the specific messages that are no longer needed verbatim.
147
+
148
+ DCP supports two compression modes:
149
+
150
+ - `range` mode compresses contiguous spans of conversation into one or more summaries.
151
+ - `message` mode (experimental) compresses individual raw messages independently, letting the model manage context much more surgically.
152
+
153
+ In `range` mode, when a new compression overlaps an earlier one, the earlier summary is nested inside the new one so information is preserved through layers of compression rather than diluted away. In both modes, protected tool outputs (such as subagents and skills) and protected file patterns are kept in compression summaries, ensuring that the most important information is never lost. You can also enable `protectUserMessages` to preserve your messages verbatim during compression, though note that large prompts (e.g. copy-pasting log files in the prompt) will then never be compressed away.
154
+
155
+ ### Deduplication
156
+
157
+ Identifies repeated tool calls (same tool, same arguments) and keeps only the most recent output. Recalculated when the compress tool runs, so prompt cache is only impacted alongside compression.
158
+
159
+ ### Purge Errors
160
+
161
+ Prunes inputs from errored tool calls after a configurable number of turns. Error messages are preserved; only the potentially large input content is removed. Recalculated on compress tool use.
162
+
163
+ ## Configuration
164
+
165
+ DCP uses its own config file, searched in order:
166
+
167
+ 1. Global: `~/.config/opencode/dcp.jsonc` (or `dcp.json`), created automatically on first run
168
+ 2. Custom config directory: `$OPENCODE_CONFIG_DIR/dcp.jsonc` (or `dcp.json`), if `OPENCODE_CONFIG_DIR` is set
169
+ 3. Project: `.opencode/dcp.jsonc` (or `dcp.json`) in your project's `.opencode` directory
170
+
171
+ Each level overrides the previous, so project settings take priority over global. Restart OpenCode after making config changes.
172
+
173
+ > [!NOTE]
174
+ > If your model has a smaller context window, lower `compress.minContextLimit` and `compress.maxContextLimit` in your configuration to match the available context.
175
+
176
+ > [!IMPORTANT]
177
+ > Defaults are applied automatically. Expand this if you want to review or override settings.
178
+
179
+ <details>
180
+ <summary><strong>Default Configuration</strong> (click to expand)</summary>
181
+
182
+ ```jsonc
183
+ {
184
+ "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
185
+ // Enable or disable the plugin
186
+ "enabled": true,
187
+ // Automatically update npm-installed DCP when a newer npm latest is available.
188
+ // Version-locked plugin specs are not updated.
189
+ "autoUpdate": true,
190
+ // Enable debug logging to ~/.config/opencode/logs/dcp/
191
+ "debug": false,
192
+ // Notification display: "off", "minimal", or "detailed"
193
+ "pruneNotification": "detailed",
194
+ // Notification type: "chat" (in-conversation) or "toast" (system toast)
195
+ "pruneNotificationType": "chat",
196
+ // Slash commands configuration
197
+ "commands": {
198
+ "enabled": true,
199
+ // Additional tools to protect from pruning via commands (e.g., /dcp sweep)
200
+ "protectedTools": [],
201
+ },
202
+ // Manual mode: disables autonomous context management,
203
+ // tools only run when explicitly triggered via /dcp commands
204
+ "manualMode": {
205
+ "enabled": false,
206
+ // When true, automatic cleanup (deduplication, purgeErrors)
207
+ // still runs even in manual mode
208
+ "automaticStrategies": true,
209
+ },
210
+ // Protect from pruning for <turns> message turns past tool invocation
211
+ "turnProtection": {
212
+ "enabled": false,
213
+ "turns": 4,
214
+ },
215
+ // Experimental settings
216
+ "experimental": {
217
+ // Allow DCP processing in subagent sessions
218
+ "allowSubAgents": false,
219
+ // Enable user-editable prompt overrides under dcp-prompts directories
220
+ // When false (default), prompt override files/directories are ignored
221
+ "customPrompts": false,
222
+ },
223
+ // Protect file operations from pruning via glob patterns
224
+ // Patterns match tool parameters.filePath (e.g. read/write/edit)
225
+ "protectedFilePatterns": [],
226
+ // Unified context compression tool and behavior settings
227
+ "compress": {
228
+ // Compression mode: "range" (compress spans into block summaries)
229
+ // or experimental "message" (compress individual raw messages)
230
+ "mode": "range",
231
+ // Permission mode: "allow" (no prompt), "ask" (prompt), "deny" (tool not registered)
232
+ "permission": "allow",
233
+ // Show compression content in a chat notification
234
+ "showCompression": false,
235
+ // Let active summary tokens extend the effective maxContextLimit
236
+ "summaryBuffer": true,
237
+ // Soft upper threshold: above this, DCP keeps injecting strong
238
+ // compression nudges (based on nudgeFrequency), so compression is
239
+ // much more likely. Accepts: number or "X%" of model context window.
240
+ "maxContextLimit": 100000,
241
+ // Soft lower threshold for reminder nudges: below this, turn/iteration
242
+ // reminders are off (compression less likely). At/above this, reminders
243
+ // are on. Accepts: number or "X%" of model context window.
244
+ "minContextLimit": 50000,
245
+ // Optional per-model override for maxContextLimit by providerID/modelID.
246
+ // If present, this wins over the global maxContextLimit.
247
+ // Accepts: number or "X%".
248
+ // Example:
249
+ // "modelMaxLimits": {
250
+ // "provider/model": "80%"
251
+ // },
252
+ // Optional per-model override for minContextLimit.
253
+ // If present, this wins over the global minContextLimit.
254
+ // "modelMinLimits": {
255
+ // "provider/model": "25%"
256
+ // },
257
+ // How often the context-limit nudge fires (1 = every fetch, 5 = every 5th)
258
+ "nudgeFrequency": 5,
259
+ // Start adding compression reminders after this many
260
+ // messages have happened since the last user message
261
+ "iterationNudgeThreshold": 15,
262
+ // Controls how likely compression is after user messages
263
+ // ("strong" = more likely, "soft" = less likely)
264
+ "nudgeForce": "soft",
265
+ // Tool names whose completed outputs are appended to the compression
266
+ "protectedTools": [],
267
+ // Preserve text wrapped in <protect>...</protect> when compressed
268
+ "protectTags": false,
269
+ // Preserve your messages during compression.
270
+ // Warning: large copy-pasted prompts will never be compressed away
271
+ "protectUserMessages": false,
272
+ },
273
+ // Automatic pruning strategies
274
+ "strategies": {
275
+ // Remove duplicate tool calls (same tool with same arguments)
276
+ "deduplication": {
277
+ "enabled": true,
278
+ // Additional tools to protect from pruning
279
+ "protectedTools": [],
280
+ },
281
+ // Prune tool inputs for errored tools after X turns
282
+ "purgeErrors": {
283
+ "enabled": true,
284
+ // Number of turns before errored tool inputs are pruned
285
+ "turns": 4,
286
+ // Additional tools to protect from pruning
287
+ "protectedTools": [],
288
+ },
289
+ },
290
+ }
291
+ ```
292
+
293
+ </details>
294
+
295
+ ### Commands
296
+
297
+ DCP provides a TUI panel and one prompt-producing slash command:
298
+
299
+ - `/dcp` — Opens the DCP panel with context, stats, and manual-mode controls.
300
+ - `/dcp-compress [focus]` — Asks the model to run one compression pass. Optional focus text directs what content to compress, following the active `compress.mode`.
301
+
302
+ ### Prompt Overrides
303
+
304
+ DCP exposes the following editable prompts:
305
+
306
+ - `system`
307
+ - `compress-range`
308
+ - `compress-message`
309
+ - `context-limit-nudge`
310
+ - `turn-nudge`
311
+ - `iteration-nudge`
312
+
313
+ This feature is disabled by default. Set `experimental.customPrompts` to `true` in your DCP config to activate it.
314
+
315
+ When enabled, managed defaults are written to `~/.config/opencode/dcp-prompts/defaults/` as plain-text prompt files. A single `README.md` in that directory explains each prompt and how to create overrides.
316
+
317
+ To customize behavior, add a file with the same name under an overrides directory and edit it as plain text.
318
+
319
+ To reset an override, delete the matching file from your overrides directory.
320
+
321
+ ### Protected Tools
322
+
323
+ By default, these tools are always protected from pruning:
324
+ `task`, `skill`, `todowrite`, `todoread`, `compress`, `batch`, `plan_enter`, `plan_exit`, `write`, `edit`
325
+
326
+ The `protectedTools` arrays in `commands` and `strategies` add to this default list.
327
+
328
+ For the `compress` tool, `compress.protectedTools` ensures specific tool outputs are appended to the compressed summary. By default it includes `task`, `skill`, `todowrite`, and `todoread`.
329
+
330
+ ## Impact on Prompt Caching
331
+
332
+ LLM providers cache prompts based on exact prefix matching. When DCP prunes content, it changes messages, which invalidates cached prefixes from that point forward.
333
+
334
+ **Trade-off:** Pruning reduces context size but can increase cache misses. The cost
335
+ balance depends on your conversation, compression frequency, and provider pricing.
336
+
337
+ **No impact for:**
338
+
339
+ - **Request-based billing** — Some providers charge per request, not tokens.
340
+ - **Uniform token pricing** — Providers that bill cached and uncached tokens at the same rate.
341
+
342
+ ## Contributing
343
+
344
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, local installation,
345
+ and testing with the V1/V2 sandbox.
346
+
347
+ ## License
348
+
349
+ AGPL-3.0-or-later
@@ -0,0 +1,7 @@
1
+ import { setup } from "./lib/v2";
2
+ declare const _default: {
3
+ id: string;
4
+ setup: typeof setup;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;;;;;AAEhC,wBAGyB"}