@lexwdex-org/opencode-dcp 4.0.0 → 5.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.
- package/README.en.md +5 -17
- package/README.md +5 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -270
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +0 -6
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/dtc/digest.d.ts.map +1 -1
- package/dist/lib/dtc/engine.d.ts +10 -0
- package/dist/lib/dtc/engine.d.ts.map +1 -1
- package/dist/lib/dtc/state.d.ts +4 -1
- package/dist/lib/dtc/state.d.ts.map +1 -1
- package/dist/lib/dtc/types.d.ts +1 -0
- package/dist/lib/dtc/types.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +11 -19
- package/dist/lib/hooks.d.ts.map +1 -1
- package/package.json +2 -3
- package/dist/lib/prompts/compaction.d.ts +0 -4
- package/dist/lib/prompts/compaction.d.ts.map +0 -1
- package/dist/lib/prompts/store.d.ts +0 -17
- package/dist/lib/prompts/store.d.ts.map +0 -1
package/README.en.md
CHANGED
|
@@ -21,7 +21,7 @@ The host fires `experimental.chat.messages.transform` before every model request
|
|
|
21
21
|
|
|
22
22
|
- **T tail zone**: the last `dtc.tailTurns` (default 4) conversation turns are **never folded**.
|
|
23
23
|
- **C current-task zone**: turns since the latest topic boundary (lexical drift detection); only oversized tool outputs are head+tail truncated, task details survive.
|
|
24
|
-
- **M middle zone**: long texts keep their first line; tool outputs get the host's native fold marker (rendered by the host as its own `[Old tool result content cleared]`); reasoning is emptied.
|
|
24
|
+
- **M middle zone**: long texts keep their first line; tool outputs get the host's native fold marker (rendered by the host as its own `[Old tool result content cleared]`); **tool arguments reduce to a target skeleton** (only filePath / command first line and friends — `oldString`/`newString`/`content` payloads are dropped); **failed attempts (error parts) fold to a short first line** — three edits on one file with two failures collapse to three recognizable call skeletons plus two single-line errors, with the final state owned by disk and the current-task zone; reasoning is emptied.
|
|
25
25
|
- **D distant zone**: whole turns collapse into one mechanical digest line (intent / actions / files touched / outcome / error count) and tool inputs are cleared — hard facts live on in the digest.
|
|
26
26
|
|
|
27
27
|
**Dynamic budget**: below `lowWatermarkRatio` of the context window (default 50%) **nothing is folded at all** — short sessions pay zero cost. Above it, folding escalates D→M→C from the far end until the estimate fits `targetRatio` (default 70%). The window size is learned per session from the `chat.params` hook; until it is known the engine fails open (no folding).
|
|
@@ -38,7 +38,7 @@ The host fires `experimental.chat.messages.transform` before every model request
|
|
|
38
38
|
- **The `dcp_prune` model tool**: returns instantly. Marks a topic boundary (the current-task zone restarts at the next turn) and raises this session's minimum fold level to M — old-task content folds from the next request onward. Never interrupts the running turn.
|
|
39
39
|
- **`/dcp fold`**: manual variant; raises the minimum fold level to the deepest tier.
|
|
40
40
|
- **`/dcp status`**: shows turns, token estimate, context window, and the manual fold level for the session.
|
|
41
|
-
- **The host's own compaction** (`/compact`, context-overflow fallback):
|
|
41
|
+
- **The host's own compaction** (`/compact`, context-overflow fallback): **100% native behavior** — the host's anchored-summary prompt and its own previous-checkpoint rolling merge stay fully in charge; DCP replaces nothing. DCP contributes exactly two things: it raises the host's tail-protection defaults to 4 turns / 32000 tokens (`compaction.tail_turns` / `preserve_recent_tokens`; explicit user config always wins), and DTC skips the compaction input via a one-shot flag so the summarizer sees full-fidelity content.
|
|
42
42
|
|
|
43
43
|
## Install
|
|
44
44
|
|
|
@@ -60,13 +60,9 @@ DCP reads these layers in order; later layers override earlier ones:
|
|
|
60
60
|
"enabled": true,
|
|
61
61
|
"autoUpdate": true,
|
|
62
62
|
"debug": false,
|
|
63
|
-
"language": "en",
|
|
64
63
|
"commands": {
|
|
65
64
|
"enabled": true,
|
|
66
65
|
},
|
|
67
|
-
"experimental": {
|
|
68
|
-
"customPrompts": false,
|
|
69
|
-
},
|
|
70
66
|
"dtc": {
|
|
71
67
|
"enabled": true,
|
|
72
68
|
"tailTurns": 4,
|
|
@@ -83,7 +79,6 @@ DCP reads these layers in order; later layers override earlier ones:
|
|
|
83
79
|
|
|
84
80
|
| Key | Description |
|
|
85
81
|
| ------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
86
|
-
| `language` | Bundled compaction prompt language: `zh` (default) / `en`; custom overrides always win |
|
|
87
82
|
| `dtc.enabled` | Master switch for dynamic tiered request-time compression |
|
|
88
83
|
| `dtc.tailTurns` | Turns at the end that are never folded (default 4) |
|
|
89
84
|
| `dtc.lowWatermarkRatio` | No folding below window × ratio (default 0.5) |
|
|
@@ -92,18 +87,11 @@ DCP reads these layers in order; later layers override earlier ones:
|
|
|
92
87
|
| `dtc.toolOutputKeepChars` | Head+tail characters kept for oversized current-zone tool outputs (default 4000) |
|
|
93
88
|
| `tool.enabled` | Register the model-invokable `dcp_prune` tool (instant boundary mark, never interrupts) |
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
`~/.config/opencode/dcp-prompts/defaults/compaction.md` to any override location:
|
|
97
|
-
|
|
98
|
-
- Project: `.opencode/dcp-prompts/overrides/compaction.md`
|
|
99
|
-
- Custom config dir: `$OPENCODE_CONFIG_DIR/dcp-prompts/overrides/compaction.md`
|
|
100
|
-
- Global: `~/.config/opencode/dcp-prompts/overrides/compaction.md`
|
|
101
|
-
|
|
102
|
-
## Migrating from 3.x
|
|
90
|
+
## Migrating from 3.x / 4.0
|
|
103
91
|
|
|
104
|
-
The 3.x `summarize` and `autoPrune` config blocks are gone (DCP no longer calls native summarize and has no heuristic triggers);
|
|
92
|
+
The 3.x `summarize` and `autoPrune` config blocks are gone (DCP no longer calls native summarize and has no heuristic triggers); since 5.0 `language` and `experimental.customPrompts` are gone as well — DCP no longer replaces the host's compaction prompt, so the `dcp-prompts` override machinery retired with it. Such keys produce a migration warning and are ignored. `autoPrune.driftThreshold` migrates automatically to `dtc.driftThreshold`. Older `compress`, `manualMode`, `strategies`, `turnProtection` keys remain removed.
|
|
105
93
|
|
|
106
|
-
Behavior change: compression no longer produces a visible "checkpoint turn" and needs no at-rest boundaries or continuation machinery — context folds automatically inside each request, invisible to the session and its state machine. Semantic checkpoints are
|
|
94
|
+
Behavior change: compression no longer produces a visible "checkpoint turn" and needs no at-rest boundaries or continuation machinery — context folds automatically inside each request, invisible to the session and its state machine. Semantic checkpoints are fully handed back to the host's native compaction (manual `/compact` or the overflow fallback): native prompt, native rolling merge — DCP only contributes the tail-protection defaults and full-fidelity protection of the summarizer input.
|
|
107
95
|
|
|
108
96
|
## Development
|
|
109
97
|
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ DCP 以**动态分级请求期压缩(DTC)**管理 OpenCode 会话上下文
|
|
|
21
21
|
|
|
22
22
|
- **T 尾部保护区**:最后 `dtc.tailTurns`(默认 4)轮对话**完全不折叠**。
|
|
23
23
|
- **C 当前任务区**:自最近话题边界(词面漂移检测)以来的轮次,只把超长 tool 输出做首尾截断,任务细节不丢。
|
|
24
|
-
- **M 中距离区**:长文本保留首行;tool 输出打宿主原生折叠标记(渲染为宿主自己的 `[Old tool result content cleared]
|
|
24
|
+
- **M 中距离区**:长文本保留首行;tool 输出打宿主原生折叠标记(渲染为宿主自己的 `[Old tool result content cleared]`);**tool 参数规约为目标骨架**(仅留 filePath/command 首行等,`oldString`/`newString`/`content` 等载荷全部丢弃);**失败尝试(error part)折为短首行**——同一文件连改 3 次错 2 次,折叠后只剩 3 个可辨识调用骨架 + 2 条单行错误,最终状态以磁盘与当前任务区为准;推理内容清空。
|
|
25
25
|
- **D 远距离区**:整轮塌缩为一行机械摘要(意图 / 动作 / 涉及文件 / 结果 / 错误数),tool 参数一并清空——硬事实保留在摘要里。
|
|
26
26
|
|
|
27
27
|
**动态预算**:估算低于上下文窗口的 `lowWatermarkRatio`(默认 50%)时**完全不折叠**,短会话零开销;超出则按 D→M→C 从远到近逐级加深,直到估算落回 `targetRatio`(默认 70%)以内。窗口大小由 `chat.params` 钩子按会话自动学习,未知时 fail-open 不折叠。
|
|
@@ -38,7 +38,7 @@ DCP 以**动态分级请求期压缩(DTC)**管理 OpenCode 会话上下文
|
|
|
38
38
|
- **模型调用 `dcp_prune` 工具**:瞬时返回。标记话题边界(当前任务区从下一轮重算)并把本会话折叠下限提到 M 级——旧任务内容从下一次请求起被折叠。绝不打断当前工作。
|
|
39
39
|
- **`/dcp fold`**:手动版本,直接把折叠下限提到最深档。
|
|
40
40
|
- **`/dcp status`**:查看当前会话的轮数、token 估算、窗口与降级档位。
|
|
41
|
-
- **宿主自身的 compaction**(`/compact
|
|
41
|
+
- **宿主自身的 compaction**(`/compact`、上下文溢出兜底):**100% 原生行为**——原生 anchored-summary 提示词、原生上一份检查点滚动合并,DCP 不做任何替换。DCP 只做两件事:把宿主尾部保护默认提升到 4 轮 / 32000 tokens(`compaction.tail_turns` / `preserve_recent_tokens`,用户显式配置优先);压缩输入经过 transform 钩子时 DTC 一次性跳过,保证摘要器看到全保真内容。
|
|
42
42
|
|
|
43
43
|
## 安装
|
|
44
44
|
|
|
@@ -60,13 +60,9 @@ DCP 依次读取以下配置,后面的层覆盖前面的层:
|
|
|
60
60
|
"enabled": true,
|
|
61
61
|
"autoUpdate": true,
|
|
62
62
|
"debug": false,
|
|
63
|
-
"language": "zh",
|
|
64
63
|
"commands": {
|
|
65
64
|
"enabled": true,
|
|
66
65
|
},
|
|
67
|
-
"experimental": {
|
|
68
|
-
"customPrompts": false,
|
|
69
|
-
},
|
|
70
66
|
"dtc": {
|
|
71
67
|
"enabled": true,
|
|
72
68
|
"tailTurns": 4,
|
|
@@ -83,7 +79,6 @@ DCP 依次读取以下配置,后面的层覆盖前面的层:
|
|
|
83
79
|
|
|
84
80
|
| 键 | 说明 |
|
|
85
81
|
| ------------------------- | ------------------------------------------------------------------------ |
|
|
86
|
-
| `language` | 内置压缩提示词语言:`zh`(默认)/ `en`;自定义覆盖文件优先于该配置 |
|
|
87
82
|
| `dtc.enabled` | 动态分级请求期压缩总开关 |
|
|
88
83
|
| `dtc.tailTurns` | 尾部保护轮数:最后 N 轮完全不折叠(默认 4) |
|
|
89
84
|
| `dtc.lowWatermarkRatio` | 估算低于窗口 × 该比例时完全不折叠(默认 0.5) |
|
|
@@ -92,18 +87,11 @@ DCP 依次读取以下配置,后面的层覆盖前面的层:
|
|
|
92
87
|
| `dtc.toolOutputKeepChars` | 当前任务区超长 tool 输出的首尾截断保留字符数(默认 4000) |
|
|
93
88
|
| `tool.enabled` | 注册模型可调用的 `dcp_prune` 工具(瞬时标记话题边界,绝不打断工作) |
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
`~/.config/opencode/dcp-prompts/defaults/compaction.md` 复制到以下任一覆盖位置:
|
|
97
|
-
|
|
98
|
-
- 项目:`.opencode/dcp-prompts/overrides/compaction.md`
|
|
99
|
-
- 自定义配置目录:`$OPENCODE_CONFIG_DIR/dcp-prompts/overrides/compaction.md`
|
|
100
|
-
- 全局:`~/.config/opencode/dcp-prompts/overrides/compaction.md`
|
|
101
|
-
|
|
102
|
-
## 从 3.x 迁移
|
|
90
|
+
## 从 3.x / 4.0 迁移
|
|
103
91
|
|
|
104
|
-
3.x 的 `summarize`、`autoPrune` 配置块已删除(DCP 不再调用原生 summarize
|
|
92
|
+
3.x 的 `summarize`、`autoPrune` 配置块已删除(DCP 不再调用原生 summarize,也不再有启发式触发器);5.0 起 `language` 与 `experimental.customPrompts` 也已删除——DCP 不再替换宿主压缩提示词,`dcp-prompts` 覆盖机制随之退役。这些键会显示迁移警告并被忽略。`autoPrune.driftThreshold` 自动迁移为 `dtc.driftThreshold`。更早的 `compress`、`manualMode`、`strategies`、`turnProtection` 等键维持删除状态。
|
|
105
93
|
|
|
106
|
-
行为变化:压缩不再产生可见的"检查点回合"
|
|
94
|
+
行为变化:压缩不再产生可见的"检查点回合",也不再需要任何静息边界或续跑机制——上下文折叠在每次请求内自动完成,会话与状态机零感知。语义检查点完全交还宿主原生 compaction(手动 `/compact` 或溢出兜底):原生提示词、原生滚动合并,DCP 仅贡献尾部保护默认值与摘要输入的全保真保护。
|
|
107
95
|
|
|
108
96
|
## 开发验证
|
|
109
97
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAejD,QAAA,MAAM,MAAM,EAAE,MAiDK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
|