billion-context-pi 0.1.36 → 0.1.38

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
@@ -135,48 +135,9 @@ Blocks: 3 active (3.7K summary, 15.2K original compressed)
135
135
 
136
136
  ## Configuration
137
137
 
138
- billion-context-pi works out of the box with no configuration. Three optional keys can be set in a JSON config file.
139
-
140
- ### Config file
141
-
142
- Create `~/.pi/acp.json` (global) and/or `<project>/.pi/acp.json` (project-local, overrides global):
143
-
144
- ```json
145
- {
146
- "debug": false,
147
- "autoUpdate": true,
148
- "modelContextLimit": 200000,
149
- "delegate": true,
150
- "toolBashDefaultTimeout": 60,
151
- "toolOutputMaxBytes": 200000,
152
- "maxContextLimit": "75%",
153
- "emergencyThresholdPercent": "95%",
154
- "nudgeGrowthTokens": 50000
155
- }
156
- ```
138
+ billion-context-pi works out of the box with no configuration it reads your model's context window automatically and applies sensible defaults.
157
139
 
158
- | Key | Default | Description |
159
- |-----|---------|-------------|
160
- | `debug` | `false` | Enable verbose **debug-level** events in the log. The always-on log (lifecycle events, errors, warnings) is written regardless; `debug` only adds extra diagnostics. Also enabled by env `ACP_DEBUG=1`. |
161
- | `autoUpdate` | `true` | On Pi startup, check npm for a newer version and auto-install it (throttled to one check per 3 minutes). Disable to avoid all startup network calls. |
162
- | `modelContextLimit` | *(auto)* | Override the context limit (in tokens). Defaults to the model's `contextWindow`. |
163
- | `delegate` | `true` | Enable the `acp_delegate` tools (delegate/wait/cancel) and their system-prompt section. Set `false` to skip registering them (e.g. you use a different sub-agent extension, or run headless where async injection adds no value). |
164
- | `toolBashDefaultTimeout` | `60` | Seconds injected into the `bash` tool when the model omits `timeout`. Pi has **no** default of its own, so without this a forgotten timeout can hang for thousands of seconds. On timeout the model is guided to re-run with a larger `timeout`. `0` restores Pi's unbounded behavior. |
165
- | `toolOutputMaxBytes` | `200000` | Hard byte cap on tool result text (~5000 lines at ~40 B/line; applied via the `tool_result` hook). Stops runaway output that Pi's own 50KB/2000-line cap can't catch (e.g. tools Pi doesn't cap). When it fires the model is told how to see the full output — for `bash` the full output is in its temp file (`BashToolDetails.fullOutputPath`); set lower (e.g. `8192`) for a tighter context budget, or `0` to disable. |
166
- | `maxContextLimit` | `"75%"` | Context usage threshold that triggers **forced compression** nudges (bypasses growth-gate + cadence). Accepts a ratio (`0.75`) or percent string (`"75%"`). Lower = compress earlier / more aggressively. Maps to kernel `nudge.maxContextLimitPct`. |
167
- | `emergencyThresholdPercent` | `"95%"` | Context usage threshold that triggers **emergency truncation** of large tool outputs to keep the session alive. Accepts a ratio (`0.95`) or percent string (`"95%"`). Must be ≥ `maxContextLimit`. Maps to kernel `nudge.emergencyThresholdPct` + `truncate.threshold`. |
168
- | `nudgeGrowthTokens` | `50000` | Token growth step for soft compression nudges. A nudge fires roughly every time this many tokens become compressible. Lower = compress more often; higher = compress less often. Maps to kernel `nudge.growthFloor` + `nudge.growthCap`. |
169
-
170
- > **Only these nine keys are read from `acp.json`.** Other tuning knobs (`preserveRecentMessages`, `protectedTools`) are code-level and not user-overridable. The three nudge thresholds (`maxContextLimit`, `emergencyThresholdPercent`, `nudgeGrowthTokens`) form a three-tier escalation: growth-driven soft nudges → forced nudges at `maxContextLimit` → emergency truncation at `emergencyThresholdPercent`.
171
-
172
- ### Environment variables
173
-
174
- | Variable | Effect |
175
- |----------|--------|
176
- | `ACP_AUTO_UPDATE` | Set to `0` / `false` / `no` / `off` (case-insensitive) to disable auto-update, overriding the config. |
177
- | `ACP_MODEL_CONTEXT_LIMIT` | Override the context limit. Takes precedence over the config value. |
178
- | `ACP_DEBUG` | Set to `1` or `true` to enable debug-level logging (always-on events are written regardless). |
179
- | `ACP_LOG_FILE` | Override the log file path (default `~/.pi/acp.log`). |
140
+ Behavior is tuned via an optional `acp.json` config file (`~/.pi/acp.json` for global defaults, `<project>/.pi/acp.json` for per-project overrides) plus a few environment variables. For the complete reference — every key, type, default, and the precedence order — see **[CONFIGURATION.md](./CONFIGURATION.md)** ([中文](./CONFIGURATION.zh-CN.md)).
180
141
 
181
142
  ### Logging
182
143
 
package/README.zh-CN.md CHANGED
@@ -134,48 +134,9 @@ Blocks: 3 active (3.7K summary, 15.2K original compressed)
134
134
 
135
135
  ## 配置
136
136
 
137
- billion-context-pi 开箱即用,无需任何配置。可以在 JSON 配置文件中设置三个可选 key。
138
-
139
- ### 配置文件
140
-
141
- 创建 `~/.pi/acp.json`(全局)和/或 `<项目>/.pi/acp.json`(项目级,覆盖全局):
142
-
143
- ```json
144
- {
145
- "debug": false,
146
- "autoUpdate": true,
147
- "modelContextLimit": 200000,
148
- "delegate": true,
149
- "toolBashDefaultTimeout": 60,
150
- "toolOutputMaxBytes": 200000,
151
- "maxContextLimit": "75%",
152
- "emergencyThresholdPercent": "95%",
153
- "nudgeGrowthTokens": 50000
154
- }
155
- ```
156
-
157
- | Key | 默认值 | 说明 |
158
- |-----|--------|------|
159
- | `debug` | `false` | 启用诊断日志(`error`/`warn`/`info` 始终写入 `~/.pi/acp.log`,此开关仅额外打开详细 `debug` 事件)。也可用环境变量 `ACP_DEBUG=1` 启用。 |
160
- | `autoUpdate` | `true` | Pi 启动时检查 npm 是否有更新版本并自动安装(限频:每 3 分钟最多一次检查)。禁用以避免所有启动时的网络请求。 |
161
- | `modelContextLimit` | *(自动)* | 覆盖上下文上限(token 数)。默认为模型的 `contextWindow`。 |
162
- | `delegate` | `true` | 启用 `acp_delegate` 工具(delegate/wait/cancel)及其系统提示词段落。设为 `false` 则不注册这些工具(例如你用了别的子代理扩展,或跑 headless 场景异步注入没有意义)。 |
163
- | `toolBashDefaultTimeout` | `60` | 当模型未指定 `timeout` 时注入 `bash` 工具的超时秒数。Pi **本身没有默认超时**,不加这个,一次遗漏的超时可能挂起几千秒。超时后会提示模型用更大的 `timeout` 重跑。设为 `0` 恢复 Pi 的无界行为。 |
164
- | `toolOutputMaxBytes` | `200000` | 工具结果文本硬上限(字节,约 5000 行 @ ~40 字节/行,通过 `tool_result` hook 应用)。用于兜住 Pi 自身 50KB/2000 行截断管不到的输出(例如 Pi 未加限制的工具)。触发截断时会告诉模型如何查看完整输出——对 `bash`,完整输出在其临时文件(`BashToolDetails.fullOutputPath`)中;设更小(如 `8192`)可更省上下文,设 `0` 关闭。 |
165
- | `maxContextLimit` | `"75%"` | 上下文使用率达到此值时触发**强制压缩** nudge(绕过增长门控 + 频率限制)。支持比例(`0.75`)或百分比字符串(`"75%"`)。调小 → 更早/更激进压缩。映射到内核 `nudge.maxContextLimitPct`。 |
166
- | `emergencyThresholdPercent` | `"95%"` | 上下文使用率达到此值时触发**紧急截断**,硬截断大块工具输出以保住会话。支持比例(`0.95`)或百分比字符串(`"95%"`)。必须 ≥ `maxContextLimit`。映射到内核 `nudge.emergencyThresholdPct` + `truncate.threshold`。 |
167
- | `nudgeGrowthTokens` | `50000` | 软压缩 nudge 的增长步长(token)。大约每积累这么多可压缩 token 就触发一次 nudge。调小 → 压得更频繁;调大 → 压得更少。映射到内核 `nudge.growthFloor` + `nudge.growthCap`。 |
168
-
169
- > **只有这九个 key 会被 `acp.json` 读取。** 其他调优参数(`preserveRecentMessages`、`protectedTools`)是代码级的,不向用户开放。三个 nudge 阈值(`maxContextLimit`、`emergencyThresholdPercent`、`nudgeGrowthTokens`)构成三级触发:增长驱动的软 nudge → `maxContextLimit` 强制 nudge → `emergencyThresholdPercent` 紧急截断。
137
+ billion-context-pi 开箱即用,无需任何配置——它会自动读取模型的上下文窗口并应用合理的默认值。
170
138
 
171
- ### 环境变量
172
-
173
- | 变量 | 作用 |
174
- |------|------|
175
- | `ACP_AUTO_UPDATE` | 设为 `0` / `false` / `no` / `off`(不区分大小写)以禁用自动更新,覆盖配置值。 |
176
- | `ACP_MODEL_CONTEXT_LIMIT` | 覆盖上下文上限。优先级高于配置值。 |
177
- | `ACP_DEBUG` | 设为 `1` 或 `true` 启用 debug 日志(`error`/`warn`/`info` 始终写入,无需此开关)。 |
178
- | `ACP_LOG_FILE` | 覆盖日志文件路径(默认 `~/.pi/acp.log`)。 |
139
+ 行为通过可选的 `acp.json` 配置文件(`~/.pi/acp.json` 为全局默认,`<项目>/.pi/acp.json` 为项目级覆盖)以及若干环境变量来调优。完整参考——每个 key、类型、默认值与优先级顺序——请查阅 **[CONFIGURATION.zh-CN.md](./CONFIGURATION.zh-CN.md)** ([English](./CONFIGURATION.md))。
179
140
 
180
141
  ### 日志
181
142
 
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Config } from "acp-kernel";
1
+ import { type Config, type Prompts } from "acp-kernel";
2
2
  /** Delegate sub-agent configuration. */
3
3
  export interface DelegateConfig {
4
4
  /** Enable acp_delegate tools (delegate/wait/cancel) and their system-prompt
@@ -72,6 +72,15 @@ export interface AdapterConfig {
72
72
  /** Legacy flat alias for `delegate.displayUsage`. Kept for backward
73
73
  * compatibility with existing acp.json files. Prefer `delegate.displayUsage`. */
74
74
  displayUsage?: "merged" | "separate";
75
+ /** Override acp-kernel's load-bearing compression prompt rules (the 4
76
+ * Prompts fields). Each set field replaces the kernel default verbatim.
77
+ * Requires acknowledgePromptsRisk: true — without it, overrides are dropped
78
+ * (defaults used) and a warning is logged. Set via ~/.pi/acp.json. */
79
+ prompts?: Partial<Prompts>;
80
+ /** Must be true for `prompts` overrides to take effect. Acknowledges that
81
+ * replacing the kernel's tuned compression rules may reduce summary quality
82
+ * (lost paths/signatures/decisions → worse retrieval). */
83
+ acknowledgePromptsRisk?: boolean;
75
84
  coreOverrides?: Partial<Config>;
76
85
  }
77
86
  export declare const DEFAULT_TOOL_BASH_TIMEOUT = 60;
@@ -3,6 +3,11 @@ import { Type, type Static } from "typebox";
3
3
  import type { AgentToolResult, ExtensionAPI, ExtensionContext, ToolDefinition } from "@earendil-works/pi-coding-agent";
4
4
  import { type Usage } from "./delegate-events.js";
5
5
  export declare function delegateSpawnOptions(cwd: string, env: NodeJS.ProcessEnv): SpawnOptions;
6
+ /** Resolve the pi CLI entry for delegate child processes.
7
+ * argv[1] is only the pi CLI under a CLI host; embedded hosts (e.g. pi-web)
8
+ * run the SDK inside another node process, so probe instead. Non-pi hosts
9
+ * (omp) keep argv[1] untouched. */
10
+ export declare function resolvePiCliEntry(argv1: string, env?: NodeJS.ProcessEnv, piHost?: boolean): string;
6
11
  type RunStatus = "running" | "completed" | "failed" | "cancelled";
7
12
  interface DelegateRun {
8
13
  runId: string;