billion-context-pi 0.1.68-pr.411.207 → 0.1.68

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
@@ -10,16 +10,6 @@ The model decides <em>when</em> and <em>what</em> to compress — not a hard lim
10
10
 
11
11
  ---
12
12
 
13
- ## 📄 Paper / Preprint
14
-
15
- - **[Model-Driven Incremental Hierarchical Compression: Training-Free Multi-Generational Context Management for Long-Lived Coding Agents](./paper/model-driven-incremental-hierarchical-compression-training-free-multi-generational-context-management-for-long-lived-coding-agents.md)** (English, v0.2)
16
-
17
- > 📝 **The paper itself is open-sourced under the MIT License as part of the codebase (`paper/`). It is a living document — anyone may edit it; improvements are welcome via pull request.**
18
-
19
- A production-scale longitudinal study: 4.5 months, three hosts, 174,327 model calls, 18.76B cumulative input tokens (~24.7B across all hosts), zero window violations on 204,800-token models, marathon sessions of 8,584–12,049 calls.
20
-
21
- ---
22
-
23
13
  <p align="center">
24
14
  <a href="https://www.npmjs.com/package/billion-context-pi"><img src="https://img.shields.io/npm/v/billion-context-pi.svg?style=flat-square" alt="npm"></a>
25
15
  <a href="https://github.com/ranxianglei/billion-context-pi/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/billion-context-pi.svg?style=flat-square" alt="license"></a>
@@ -76,9 +66,10 @@ pi install npm:billion-context-pi
76
66
 
77
67
  That's it. The extension auto-loads on next Pi startup. No configuration needed — it reads your model's context window automatically.
78
68
 
79
- > **Already using another sub-agent extension?** Pick one delegation toolset so the model doesn't waffle between two:
80
- > - **Use ACP's `acp_delegate` instead** (default, recommended) — uninstall the other one, e.g. `pi remove npm:pi-subagents`. It replaces pi-subagents at a fraction of the context cost (~600 tok vs ~7K tok/turn); see below.
81
- > - **Keep your own sub-agents** — set `"delegate": false` in `.pi/acp.json` (project) or `~/.pi/acp.json` (global): ACP then registers no `acp_delegate*` tools and injects no delegation prompt. See [Using your own sub-agents](#using-your-own-sub-agents).
69
+ > **Uninstall `pi-subagents` first (optional, recommended).** billion-context-pi ships its own `acp_delegate` sub-agent tool (see below) that replaces pi-subagents at a fraction of the context cost (~600 tok vs ~7K tok/turn). If you have pi-subagents installed, remove it to avoid duplicate delegation tools:
70
+ > ```bash
71
+ > pi remove npm:pi-subagents
72
+ > ```
82
73
 
83
74
  ## How it works
84
75
 
@@ -132,8 +123,6 @@ billion-context-pi is built for the **Pi** coding agent (`@earendil-works/pi-cod
132
123
  | `acp_delegate_wait` | Block until a delegate run finishes (returns its result; times out otherwise) |
133
124
  | `acp_delegate_cancel` | Cancel a running delegate by runId |
134
125
 
135
- The three `acp_delegate*` rows can be removed entirely with `"delegate": false` in `acp.json` — see [Using your own sub-agents](#using-your-own-sub-agents).
136
-
137
126
  ### acp_delegate — clean-context delegation
138
127
 
139
128
  Hand a self-contained task to a fresh pi process running in a clean context. Five built-in roles, each with a system prompt and a **soft tool guardrail**:
@@ -158,22 +147,6 @@ The full delegate result is saved to a file (`/tmp/acp-delegate/<runId>.out`); t
158
147
 
159
148
  In the **interactive TUI**, async runs also show a live status widget below the editor (agent, elapsed seconds, task preview), so you always know what's running and for how long. Disabled automatically in RPC/print/JSON.
160
149
 
161
- #### Using your own sub-agents
162
-
163
- If you keep your own sub-agent extension (pi-subagents, pi-lens, ...) and don't want ACP's delegation toolset on top of it, disable it:
164
-
165
- ```json
166
- { "delegate": false }
167
- ```
168
-
169
- in `.pi/acp.json` (project) or `~/.pi/acp.json` (global); project overrides global. `"delegate": false` is equivalent to `"delegate": { "enabled": false }` — the other keys (`displayUsage`, timeouts, ...) keep their defaults, they just go unused while disabled.
170
-
171
- What turns off: the three `acp_delegate*` tools, the `ctrl+alt+f` shortcut, and the `ACP_DELEGATE NOTIFICATIONS` system-prompt section. Everything else (compress / decompress / search_context / acp_status, pruning, nudges) is unaffected.
172
-
173
- Timing: tools are registered at session start, so the change takes effect on the **next session** (restart Pi or start a new session); the prompt section is re-resolved every turn and changes immediately within a session. Mid-session edits can therefore briefly desynchronize the two surfaces (enabling shows the prompt before the tools exist; disabling hides the prompt while the tools stay registered until restart).
174
-
175
- Related knobs: `delegatePrompt: null` removes only the prompt section and keeps the tools — the inverse of `"delegate": false`, which removes both. Don't use Pi's `--exclude-tools acp_delegate,...` as a substitute for `"delegate": false`: the denylist hides the tools, but the prompt section is driven by config only — the model would still be told about `acp_delegate_wait` etc. even though it cannot call them.
176
-
177
150
  ## `/acp` command
178
151
 
179
152
  Rich status display for the user:
package/README.zh-CN.md CHANGED
@@ -8,16 +8,6 @@
8
8
 
9
9
  ---
10
10
 
11
- ## 📄 论文 / 预印本
12
-
13
- - **[模型驱动的分层增量压缩:面向长寿命编码 Agent 的免训练多代上下文管理](./paper/模型驱动的分层增量压缩-免训练多代上下文管理.md)**(中文版,v0.2)
14
-
15
- > 📝 **论文本身与代码一同以 MIT 许可开源(位于 `paper/` 目录),是代码库的一部分 —— 这是一份活文档,任何人都可以编辑,欢迎提 PR 改进。**
16
-
17
- 生产规模纵向研究:四个半月、三宿主、174,327 次模型调用、187.6 亿累计输入 token(三宿主合计约 247 亿),204,800-token 窗口零违规,马拉松会话 8,584–12,049 次调用。
18
-
19
- ---
20
-
21
11
  <p align="center">
22
12
  <a href="https://www.npmjs.com/package/billion-context-pi"><img src="https://img.shields.io/npm/v/billion-context-pi.svg?style=flat-square" alt="npm"></a>
23
13
  <a href="https://github.com/ranxianglei/billion-context-pi/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/billion-context-pi.svg?style=flat-square" alt="license"></a>
@@ -75,9 +65,10 @@ pi install npm:billion-context-pi
75
65
 
76
66
  完成。扩展在下次 Pi 启动时自动加载。无需配置 —— 它会自动读取模型的上下文窗口。
77
67
 
78
- > **正在使用其他子代理扩展?** 选一套委派工具集,避免模型在两套之间摇摆:
79
- > - **改用 ACP 的 `acp_delegate`**(默认,推荐)— 卸载另一个,例如 `pi remove npm:pi-subagents`。它以极低的上下文成本(~600 tok vs ~7K tok/轮)替代 pi-subagents,见下文。
80
- > - **保留你自己的子代理** — 在 `.pi/acp.json`(项目级)或 `~/.pi/acp.json`(全局)中设 `"delegate": false`:ACP 不再注册任何 `acp_delegate*` 工具,也不注入委派提示段。见[使用你自己的子代理](#使用你自己的子代理)。
68
+ > **建议先卸载 `pi-subagents`(可选,推荐)。** billion-context-pi 自带 `acp_delegate` 子代理工具(见下文),以极低的上下文成本(~600 tok vs ~7K tok/轮)替代 pi-subagents。如果你已安装 pi-subagents,卸载它以避免重复的委派工具:
69
+ > ```bash
70
+ > pi remove npm:pi-subagents
71
+ > ```
81
72
 
82
73
  ## 工作原理
83
74
 
@@ -131,8 +122,6 @@ billion-context-pi 面向 **Pi** 编码代理(`@earendil-works/pi-coding-agent`)
131
122
  | `acp_delegate_wait` | 阻塞等待委派任务完成(返回结果,否则超时) |
132
123
  | `acp_delegate_cancel` | 按 runId 取消正在运行的委派任务 |
133
124
 
134
- 三行 `acp_delegate*` 工具可用 `acp.json` 中的 `"delegate": false` 整体移除——见[使用你自己的子代理](#使用你自己的子代理)。
135
-
136
125
  ### acp_delegate — 干净上下文委派
137
126
 
138
127
  把一个自包含的任务交给一个运行在干净上下文中的新 pi 进程。五个内置角色,各自有系统提示和**软工具护栏**:
@@ -156,22 +145,6 @@ Worker 运行在 Pi 的完整默认工具集上 - 不应用 `--tools` 白名单,
156
145
 
157
146
  在**交互 TUI** 中,异步运行还会在编辑器下方显示一个实时状态 widget(角色、已运行秒数、任务预览),让你随时知道什么在跑、跑了多久。RPC/print/JSON 模式自动禁用。
158
147
 
159
- #### 使用你自己的子代理
160
-
161
- 如果你保留自己的子代理扩展(pi-subagents、pi-lens 等),不想再叠加 ACP 的委派工具集,关掉它:
162
-
163
- ```json
164
- { "delegate": false }
165
- ```
166
-
167
- 写入 `.pi/acp.json`(项目级)或 `~/.pi/acp.json`(全局);项目级覆盖全局。`"delegate": false` 与 `"delegate": { "enabled": false }` 等价——其余键(`displayUsage`、超时等)保持默认值,只是禁用期间不生效。
168
-
169
- 关闭的具体面:`acp_delegate*` 三个工具、`ctrl+alt+f` 快捷键、系统提示中的 `ACP_DELEGATE NOTIFICATIONS` 段。其余功能(compress / decompress / search_context / acp_status、prune、nudge)不受影响。
170
-
171
- 生效时机:工具在会话开始时注册,改动在**下一个会话**生效(重启 Pi 或开新会话);提示段每回合重新解析,会在当前会话内立即变化。因此会话中途改配置时两个面可能短暂不同步(开启后提示先于工具出现;关闭后提示先消失而工具保留到重启)。
172
-
173
- 相关开关:`delegatePrompt: null` 只摘除提示段、保留工具——与 `"delegate": false` 全关正好相反。不要用 Pi 的 `--exclude-tools acp_delegate,...` 替代 `"delegate": false`:denylist 只让工具消失,提示段只由配置驱动——模型仍会被告知 `acp_delegate_wait` 等它调不到的工具。
174
-
175
148
  ## `/acp` 命令
176
149
 
177
150
  为用户提供丰富的状态显示:
@@ -1,7 +1,6 @@
1
1
  import { Type, type Static } from "typebox";
2
2
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
3
3
  import type { AcpRuntime } from "./runtime.js";
4
- import { type ToolPromptOverrides } from "./surface.js";
5
4
  import { type CompressionBlock, type CompressionState } from "acp-kernel";
6
5
  declare const RangeSpec: Type.TObject<{
7
6
  startId: Type.TString;
@@ -20,7 +19,7 @@ declare const CompressParams: Type.TObject<{
20
19
  summaryMaxChars: Type.TOptional<Type.TNumber>;
21
20
  }>;
22
21
  type CompressArgs = Static<typeof CompressParams>;
23
- export declare function makeCompressTool(runtime: AcpRuntime, overrides?: ToolPromptOverrides): ToolDefinition<typeof CompressParams>;
22
+ export declare function makeCompressTool(runtime: AcpRuntime): ToolDefinition<typeof CompressParams>;
24
23
  type RangeEntry = Static<typeof RangeSpec>;
25
24
  export declare function normalizeRanges(args: CompressArgs): RangeEntry[] | string;
26
25
  export declare function tailRepair(s: string): string | undefined;
package/dist/config.d.ts CHANGED
@@ -2,8 +2,6 @@ import { type Config, type Prompts } from "acp-kernel";
2
2
  import type { CompressReasoningConfig } from "./reasoning-drop.js";
3
3
  import type { DegenerationGuardConfig } from "./degeneration.js";
4
4
  import type { ThrottleRetryConfig } from "./throttle-retry.js";
5
- import type { PiPromptSections } from "./system-prompt.js";
6
- import type { NudgeSectionsConfig, ToolPromptsConfig } from "./surface.js";
7
5
  /** Per-role delegate defaults. Lets long-lived automation pin a cheaper or
8
6
  * more capable model and a thinking level per delegate role, so the main
9
7
  * agent doesn't have to fill them in on every `acp_delegate()` call. */
@@ -122,13 +120,6 @@ export interface CompressSettings {
122
120
  * tool calls — see CompressReasoningConfig in src/reasoning-drop.ts.
123
121
  * Merged field-wise (drop, threshold) across the three levels. */
124
122
  reasoning?: CompressReasoningConfig;
125
- /** Active prompt pack name (see CONFIGURATION.md “Prompt packs”). Base
126
- * level; override per provider/model via `providers`. "default" or unset =
127
- * built-in defaults. Resolved per request against the live model, so
128
- * switching models mid-session switches the pack. Packs ship text-level
129
- * overrides only; a pack's `toolPrompts` follow the base selection (tool
130
- * definitions freeze at extension load, before the model is known). */
131
- promptPack?: string;
132
123
  }
133
124
  /** Per-provider compression overrides. Carries the same tuning fields as the
134
125
  * global level, plus an optional per-model map keyed by model id. */
@@ -261,21 +252,6 @@ export interface AdapterConfig {
261
252
  * replacing the kernel's tuned compression rules may reduce summary quality
262
253
  * (lost paths/signatures/decisions → worse retrieval). */
263
254
  acknowledgePromptsRisk?: boolean;
264
- /** Override structural sections of the ACP system prompt (ACP TAGS, TOOLS,
265
- * WHEN TO COMPRESS, ...). Tri-state per section: string = replace, null =
266
- * remove, omitted = default. Not risk-gated — these are documentation
267
- * sections, not compression rules. Set via acp.json. */
268
- promptSections?: Partial<PiPromptSections>;
269
- /** Override guidance-class nudge texts (efficiencyNote, emergencyHeader,
270
- * t2Guidance, t3Guidance). Same tri-state semantics. Not risk-gated. */
271
- nudgeSections?: NudgeSectionsConfig;
272
- /** Override the four ACP tool definitions' LLM-facing text (description,
273
- * paramDescriptions, promptSnippet, promptGuidelines). Read synchronously
274
- * at extension load — tool defs are frozen at registration time. */
275
- toolPrompts?: ToolPromptsConfig;
276
- /** Replace (string) or remove (null) the ACP_DELEGATE_NOTIFICATIONS appendix
277
- * injected when the delegate tool is enabled. */
278
- delegatePrompt?: string | null;
279
255
  coreOverrides?: Partial<Config>;
280
256
  }
281
257
  export declare const DEFAULT_TOOL_BASH_TIMEOUT = 60;
@@ -1,12 +1,11 @@
1
1
  import { Type } from "typebox";
2
2
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
3
3
  import type { AcpRuntime } from "./runtime.js";
4
- import { type ToolPromptOverrides } from "./surface.js";
5
4
  declare const DecompressParams: Type.TObject<{
6
5
  blockId: Type.TString;
7
6
  full: Type.TOptional<Type.TBoolean>;
8
7
  toFile: Type.TOptional<Type.TString>;
9
8
  inline: Type.TOptional<Type.TBoolean>;
10
9
  }>;
11
- export declare function makeDecompressTool(runtime: AcpRuntime, overrides?: ToolPromptOverrides): ToolDefinition<typeof DecompressParams>;
10
+ export declare function makeDecompressTool(runtime: AcpRuntime): ToolDefinition<typeof DecompressParams>;
12
11
  export {};