billion-context-dsh 0.2.1 → 0.2.3
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 +8 -7
- package/README.md +8 -7
- package/dist/index.d.ts +3 -1
- package/dist/index.js +378 -73
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +24 -3
- package/dist/region.d.ts +53 -0
- package/dist/tools.d.ts +8 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[English](./README.en.md) | [中文](./README.md)
|
|
4
4
|
|
|
5
5
|
> **⚠️ Beta notice — not for production use**
|
|
6
|
-
> This project (**v0.2.
|
|
6
|
+
> This project (**v0.2.3**) is a work-in-progress beta. The [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) itself is also in **public beta**. **Do not use either in engineering / production environments** — expect breaking changes and rough edges.
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<strong>Built with gratitude on top of these projects</strong> — please give them a ⭐:
|
|
@@ -41,10 +41,11 @@ When conversations get long, the model runs out of context. Most tools hard-trun
|
|
|
41
41
|
|
|
42
42
|
Unlike DSH's built-in auto-compaction (which replaces a range with an automatically generated summary), billion-context-dsh:
|
|
43
43
|
|
|
44
|
-
- **Model-driven** — the model writes the summary itself; there is no second LLM summarization call
|
|
44
|
+
- **Model-driven** — the model writes the summary itself; there is no second LLM summarization call
|
|
45
45
|
- **Advisory, never imperative** — automatic policy only *nudges*; the model decides whether and when to compress
|
|
46
46
|
- **Durable & recoverable** — a compressed range becomes a checkpoint node, the originals stay in the append-only session log; `decompress` restores them, `search_context` finds information inside blocks
|
|
47
|
-
- **
|
|
47
|
+
- **Long tasks hold steady** — every step builds on the results before it; key conclusions stay usable and compound, so very long tasks actually finish
|
|
48
|
+
- **Context stays lean** — every request rides on a small, distilled slice of context with only the key information; no bulk compression of large ranges, so details don't decay with it — and tokens stay low
|
|
48
49
|
|
|
49
50
|
This is the DeepSeek Harness port of [billion-context-pi](https://github.com/ranxianglei/billion-context-pi) (the Pi coding-agent adapter): the compression core ([acp-kernel](https://github.com/ranxianglei/acp-kernel)) is reused verbatim, and the adapter layer was rewritten against DSH's durable-surface model — see [docs](https://github.com/Tyan66666/billion-context-dsh/tree/main/docs) for the verified mapping.
|
|
50
51
|
|
|
@@ -129,7 +130,7 @@ DSH derives every model request from its append-only session log (the *surface*)
|
|
|
129
130
|
| nudge ("efficiency note — compress early and keep context lean") | injected at `agent/pre-step` by the kernel's pressure decision — efficiency note + context breakdown + compression rules, tone aligned with kernel/pi; never an order |
|
|
130
131
|
| `decompress` | read-only recovery of shadowed originals from the log |
|
|
131
132
|
| `search_context` | scores block summaries + originals rebuilt from the log |
|
|
132
|
-
| `acp_status` | block ledger + context
|
|
133
|
+
| `acp_status` | CONTEXT BREAKDOWN (tool/text/summaries shares of the visible total) + compressed-block ledger + nudge decision line; no context-window rows; scope/view/tool/sort/limit drilldown supported |
|
|
133
134
|
| block state | in-memory kernel state + **log-rebuilt ledger** (no sidecar files) |
|
|
134
135
|
| tiered distillation (T2/T3) | re-compressing a block's summary node distills that block (tier 2); distilling a tier-2 block yields tier 3. Tier + kernel block ids are persisted to the log, so kernel state rehydrates from the log after a restart and stays distillable |
|
|
135
136
|
|
|
@@ -146,9 +147,9 @@ A walkthrough of the ACP philosophy this project inherits — how active context
|
|
|
146
147
|
| Tool | What it does |
|
|
147
148
|
| --- | --- |
|
|
148
149
|
| `compress` | Replace a seq range with a dense summary you write (edges auto-balanced to tool-pair boundaries); re-compressing a block's summary node distills it (tier 2/3) |
|
|
149
|
-
| `decompress` | Restore a previously compressed block's original content (read-only) |
|
|
150
|
+
| `decompress` | Restore a previously compressed block's original content (read-only); accepts the `bN` ref shown by acp_status or a compaction id |
|
|
150
151
|
| `search_context` | Search compressed block summaries and originals by keyword |
|
|
151
|
-
| `acp_status` |
|
|
152
|
+
| `acp_status` | CONTEXT BREAKDOWN (tool/text/summaries shares of the visible total) + compressed-block ledger + nudge decision line; no context-window rows. Drilldown supported: `scope:"compressed"` per block, `scope:"uncompressed"` + `view:"messages"`/`"ranges"` per message/range, with `tool` filter, `sort` order and `limit` cap. Drilldown row refs are kernel ids (mN, size awareness only) — compress always uses the `Surface:` seqs |
|
|
152
153
|
| `/acp` | status / compress / decompress from the command bar |
|
|
153
154
|
|
|
154
155
|
## Upstream & credits
|
|
@@ -169,7 +170,7 @@ This project reuses `acp-kernel`'s compression core and `billion-context-pi`'s d
|
|
|
169
170
|
| Key | Default | Meaning |
|
|
170
171
|
|---|---|---|
|
|
171
172
|
| `modelContextLimit` | auto-detected (fallback `128000`) | Context window used for the kernel's pressure decisions; an explicit value wins and skips the probe |
|
|
172
|
-
| `autoModelContextLimit` | `true` | Probe the model's real window from the model API (`agent.ctx.llm.resolveModelInfo`); fall back to the default on failure, `
|
|
173
|
+
| `autoModelContextLimit` | `true` | Probe the model's real window from the model API (`agent.ctx.llm.resolveModelInfo`); fall back to the default on failure, the `/acp` command shows the window source (the `acp_status` model tool carries no window info) |
|
|
173
174
|
| `nudgeMinContextLimitPct` | kernel default `0.45` | Nudge window lower bound (usage fraction) — validation only; the growth-driven trigger has no percentage floor — same default as billion-context-pi |
|
|
174
175
|
| `nudgeMaxContextLimitPct` | engine default `0.70` (kernel/pi default `0.75`) | Over-limit line: above this the nudge fires regardless of growth — deliberately below the host compaction-basic 80% auto-compaction line so the forced nudge fires first; an explicit value wins |
|
|
175
176
|
| `nudgeEmergencyThresholdPct` | engine default `0.85` (kernel/pi default `0.95`) | Emergency nudge (bypasses the per-turn dedup) — lowered from `0.95`: at 95% the model has no room to act and the 80% auto-compaction line shadows it; an explicit value wins |
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[中文](./README.md) | [English](./README.en.md)
|
|
4
4
|
|
|
5
5
|
> **⚠️ 测试版声明——请勿用于生产环境**
|
|
6
|
-
> 本项目(**v0.2.
|
|
6
|
+
> 本项目(**v0.2.3**)仍处于开发中的测试版。[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 本身也处于**公开测试版**阶段。**请勿将两者用于工程化 / 生产环境**——预期会有破坏性变更与粗糙之处。
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<strong>衷心感谢以下项目——请给它们一个 ⭐:</strong>
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
|
|
42
42
|
与 DSH 内置的自动压缩(用自动生成的摘要替换一段范围)不同,billion-context-dsh:
|
|
43
43
|
|
|
44
|
-
- **模型驱动** —— 摘要由模型自己书写,没有第二次 LLM
|
|
44
|
+
- **模型驱动** —— 摘要由模型自己书写,没有第二次 LLM 摘要调用
|
|
45
45
|
- **只建议、不强令** —— 自动策略只 *nudge*(提醒),是否压缩、何时压缩由模型决定
|
|
46
46
|
- **持久且可恢复** —— 压缩范围成为 checkpoint 节点,原文保留在 append-only 会话日志中;`decompress` 可恢复,`search_context` 可在块内查找
|
|
47
|
-
-
|
|
47
|
+
- **长任务稳得住** —— 每一步都接着前面的成果走,关键结论持续可用、不断叠加,超长任务更容易跑完
|
|
48
|
+
- **上下文始终精简** —— 每次请求都只用少量、精炼的上下文,只保留关键信息;不做大段统一压缩,细节不随之衰失,token 消耗自然更低
|
|
48
49
|
|
|
49
50
|
这是 [billion-context-pi](https://github.com/ranxianglei/billion-context-pi)(Pi 编码代理适配器)在 DeepSeek Harness 上的移植:压缩内核([acp-kernel](https://github.com/ranxianglei/acp-kernel))原样复用,适配层针对 DSH 的 durable-surface 模型重写——经过验证的映射关系见 [docs](https://github.com/Tyan66666/billion-context-dsh/tree/main/docs)。
|
|
50
51
|
|
|
@@ -130,7 +131,7 @@ DSH 的每个模型请求都派生自其 append-only 会话日志(*surface*)
|
|
|
130
131
|
| nudge("效率提示——尽早压缩保持精简") | 由内核的压力决策在 `agent/pre-step` 注入——效率通知 + 上下文分解 + 压缩规则,语气对齐 kernel/pi;绝非命令 |
|
|
131
132
|
| `decompress` | 从日志只读恢复被遮蔽的原文 |
|
|
132
133
|
| `search_context` | 对从日志重建的块摘要与原文打分 |
|
|
133
|
-
| `acp_status` |
|
|
134
|
+
| `acp_status` | CONTEXT BREAKDOWN(tool/text/summaries 占可见总量)+ 压缩块账本 + nudge 决策行;不含上下文窗口;支持 scope/view/tool/sort/limit 钻取 |
|
|
134
135
|
| 块状态 | 内存内核状态 + **日志重建账本**(无旁车文件) |
|
|
135
136
|
| 分层蒸馏(T2/T3) | 再次压缩某块的摘要节点 = 蒸馏该块(tier 2),蒸馏 tier-2 块得 tier 3;tier 与内核块 id 持久化进日志,重启后内核状态从日志再水合、可继续蒸馏 |
|
|
136
137
|
|
|
@@ -147,9 +148,9 @@ DSH 的每个模型请求都派生自其 append-only 会话日志(*surface*)
|
|
|
147
148
|
| 工具 | 作用 |
|
|
148
149
|
| --- | --- |
|
|
149
150
|
| `compress` | 用你书写的紧凑摘要替换 seq 范围(边界自动平衡到 tool-call/result 配对点);对某块的摘要节点再次压缩 = 分层蒸馏(tier 2/3) |
|
|
150
|
-
| `decompress` |
|
|
151
|
+
| `decompress` | 恢复已压缩块的原始内容(只读);接受 acp_status 显示的 `bN` 或 compaction id |
|
|
151
152
|
| `search_context` | 按关键词搜索压缩块摘要与原文 |
|
|
152
|
-
| `acp_status` |
|
|
153
|
+
| `acp_status` | CONTEXT BREAKDOWN(tool/text/summaries 占可见总量)+ 压缩块账本 + nudge 决策行;不含上下文窗口。支持钻取:`scope:"compressed"` 逐块、`scope:"uncompressed"` + `view:"messages"`/`"ranges"` 逐消息/区间,`tool` 过滤、`sort` 排序、`limit` 截断。钻取行 ref 是内核 mN(仅供体量感知)——压缩始终用 `Surface:` 的 seq |
|
|
153
154
|
| `/acp` | 从命令栏执行 status / compress / decompress |
|
|
154
155
|
|
|
155
156
|
## 上游项目与致谢
|
|
@@ -170,7 +171,7 @@ DSH 的每个模型请求都派生自其 append-only 会话日志(*surface*)
|
|
|
170
171
|
| 键 | 默认值 | 含义 |
|
|
171
172
|
|---|---|---|
|
|
172
173
|
| `modelContextLimit` | 自动探测(回退 `128000`) | 用于内核压力决策的上下文窗口;显式配置时优先且跳过探测 |
|
|
173
|
-
| `autoModelContextLimit` | `true` | 从模型 API 自动探测真实窗口(`agent.ctx.llm.resolveModelInfo
|
|
174
|
+
| `autoModelContextLimit` | `true` | 从模型 API 自动探测真实窗口(`agent.ctx.llm.resolveModelInfo`);探测失败回退默认值,`/acp` 命令展示窗口来源(模型工具 `acp_status` 不含窗口信息) |
|
|
174
175
|
| `nudgeMinContextLimitPct` | 内核默认 `0.45` | Nudge 窗口下界(用量占比)——仅作配置校验,增长路径的触发没有百分比下限——与 billion-context-pi 相同的默认值 |
|
|
175
176
|
| `nudgeMaxContextLimitPct` | engine 默认 `0.70`(内核/pi 默认 `0.75`) | 过限线:超过此值则无论增长与否都触发 nudge——刻意低于宿主 compaction-basic 的 80% 自动压缩线,保证强制 nudge 先触发;显式配置优先 |
|
|
176
177
|
| `nudgeEmergencyThresholdPct` | engine 默认 `0.85`(内核/pi 默认 `0.95`) | 紧急 nudge(绕过每轮去重)——从 `0.95` 下调:95% 时模型已无操作空间且会被 80% 自动压缩线遮蔽;显式配置优先 |
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export { makeTools, type ToolEnvironment } from './tools.ts';
|
|
|
40
40
|
export { acpCommand } from './commands.ts';
|
|
41
41
|
export { buildNudge, resolveTokenCount, type NudgeEnvironment, type NudgeOutcome } from './nudge.ts';
|
|
42
42
|
export { DEFAULT_CONTEXT_WINDOW, detectContextWindow, windowSourceLabel, type AcpWindow, } from './window.ts';
|
|
43
|
-
export { AlreadyCompressedRangeError, rebuildBlockLedger, resolveSurfaceRange, runCompactionTransaction, shadowedSeqsOf, findOpenTurn, assertNoActiveCompaction, blockRegistry, blockRefForSummarySeq, compactionIdsOfKernelBlocks, summarySeqOfKernelBlock, expandShadowedSeqs, type AcpBlockLedgerEntry, type CompactionTransactionInput, type ResolvedSurfaceRange, } from './region.ts';
|
|
43
|
+
export { AlreadyCompressedRangeError, rebuildBlockLedger, resolveSurfaceRange, runCompactionTransaction, shadowedSeqsOf, findOpenTurn, assertNoActiveCompaction, blockRegistry, blockRefForSummarySeq, compactionIdsOfKernelBlocks, summarySeqOfKernelBlock, expandShadowedSeqs, hideCompressToolPair, stripOrphanedSurfaceToolMessages, type AcpBlockLedgerEntry, type CompactionTransactionInput, type ResolvedSurfaceRange, } from './region.ts';
|
|
44
44
|
export { eventsToCoreMessages, projectEvent, surfaceEventsOf, extractEventText } from './messages.ts';
|
|
45
45
|
export interface AcpConfig {
|
|
46
46
|
/**
|
|
@@ -108,6 +108,8 @@ export declare class AcpCompactionEngine extends CompactionEngine {
|
|
|
108
108
|
/** Resolved prompt templates (validated at construction — fail-fast on template typos). */
|
|
109
109
|
readonly prompts: ResolvedPrompts;
|
|
110
110
|
private readonly lastNudgeTurn;
|
|
111
|
+
/** Successful compress call ids awaiting their tool/result so the pair can be hidden. */
|
|
112
|
+
private readonly compressCallIdsToHide;
|
|
111
113
|
/** Per provider/model route the resolved window (probe failures cached too). */
|
|
112
114
|
private readonly windowCache;
|
|
113
115
|
constructor(ctx: Context, config?: Partial<AcpConfig>);
|