billion-context-pi 0.1.67 → 0.1.68-pr.331.192

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
@@ -24,6 +24,12 @@ The model decides <em>when</em> and <em>what</em> to compress — not a hard lim
24
24
 
25
25
  > **Host support:** this plugin is for **Pi**. It does **not** support **OMP (oh-my-pi)** — on an OMP host it refuses to run. OMP users: use [billion-context](https://github.com/ranxianglei/billion-context) instead (`bili omp`, built-in plugin). Full client → package table: see [Which do I need?](#which-do-i-need); OMP details: [docs/omp.md](./docs/omp.md).
26
26
 
27
+ ## Community
28
+
29
+ Discussion, help, and updates on QQ — one group covers all three projects (`billion-context`, `billion-context-pi`, `opencode-acp`):
30
+
31
+ **QQ Group: 1056132097**
32
+
27
33
  ## Why?
28
34
 
29
35
  When conversations get long, the model runs out of context. Most tools hard-truncate — silently dropping earlier messages. **billion-context** gives the model a `compress` tool: the LLM decides **when** and **what** to compress into high-fidelity summaries, preserving critical details (file paths, decisions, error strings) while reclaiming context space.
package/README.zh-CN.md CHANGED
@@ -22,6 +22,12 @@
22
22
 
23
23
  > **宿主支持:** 本插件面向 **Pi**。它**不支持 OMP(oh-my-pi)** —— 在 OMP 宿主上会拒绝运行。OMP 用户请直接改用 [billion-context](https://github.com/ranxianglei/billion-context)(启动命令 bili omp);其他客户端的完整对照见[该选哪个?](#该选哪个)。OMP 详细说明:[docs/omp.zh-CN.md](./docs/omp.zh-CN.md)。
24
24
 
25
+ ## 社区
26
+
27
+ 交流、求助与更新都在 QQ——同一个群覆盖三个项目(`billion-context`、`billion-context-pi`、`opencode-acp`):
28
+
29
+ **QQ 群:1056132097**
30
+
25
31
  ## 为什么选择 billion-context
26
32
 
27
33
  当对话变长,模型的上下文会耗尽。多数工具采用硬截断 —— 静默丢弃早期消息。**billion-context** 把 `compress` 工具交给模型:由 LLM 决定**何时**压缩、压缩**什么**,将内容压缩成高保真摘要,在回收上下文空间的同时保留关键细节(文件路径、决策、错误字符串)。
@@ -0,0 +1,3 @@
1
+ export declare const COMPRESS_LOOP_SENTINEL = "[ACP:compress-loop]";
2
+ export declare const COMPRESS_LOOP_CORRECT_THRESHOLD = 2;
3
+ export declare function buildCompressLoopText(failures: number): string;
@@ -1,6 +1,8 @@
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
+ import { type CompressionBlock, type CompressionState } from "acp-kernel";
4
6
  declare const RangeSpec: Type.TObject<{
5
7
  startId: Type.TString;
6
8
  endId: Type.TString;
@@ -18,10 +20,14 @@ declare const CompressParams: Type.TObject<{
18
20
  summaryMaxChars: Type.TOptional<Type.TNumber>;
19
21
  }>;
20
22
  type CompressArgs = Static<typeof CompressParams>;
21
- export declare function makeCompressTool(runtime: AcpRuntime): ToolDefinition<typeof CompressParams>;
23
+ export declare function makeCompressTool(runtime: AcpRuntime, overrides?: ToolPromptOverrides): ToolDefinition<typeof CompressParams>;
22
24
  type RangeEntry = Static<typeof RangeSpec>;
23
25
  export declare function normalizeRanges(args: CompressArgs): RangeEntry[] | string;
24
26
  export declare function tailRepair(s: string): string | undefined;
27
+ /** Panel block count, or -1 for non-panels. Accepts BOTH the legacy
28
+ * "… B blocks)" form (0-block runs; historical transcripts replayed by
29
+ * index/floor-stale) and the #376 "… blocks: b3=m00044–m00097*, …" form. */
30
+ export declare function compressPanelBlocks(text: string): number;
25
31
  /** Success = completed run that created >= 1 block (partial range errors
26
32
  * still count: progress was made). A 0-block panel must NOT be success —
27
33
  * it would reset the retry counter while the emergency nudge re-fires,
@@ -31,4 +37,5 @@ export declare function isCompressSuccessText(text: string): boolean;
31
37
  * range skipped). Counted as a FAILED attempt by noteCompressOutcomes so
32
38
  * the retry cap applies. Non-panels ("No ranges provided.") stay neutral. */
33
39
  export declare function isCompressNoopText(text: string): boolean;
40
+ export declare function blockSpanLabel(block: CompressionBlock, state: CompressionState): string;
34
41
  export {};
@@ -0,0 +1 @@
1
+ export declare const CONFIG_DIR_NAME: string;
package/dist/config.d.ts CHANGED
@@ -2,6 +2,8 @@ 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";
5
7
  /** Per-role delegate defaults. Lets long-lived automation pin a cheaper or
6
8
  * more capable model and a thinking level per delegate role, so the main
7
9
  * agent doesn't have to fill them in on every `acp_delegate()` call. */
@@ -120,6 +122,13 @@ export interface CompressSettings {
120
122
  * tool calls — see CompressReasoningConfig in src/reasoning-drop.ts.
121
123
  * Merged field-wise (drop, threshold) across the three levels. */
122
124
  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;
123
132
  }
124
133
  /** Per-provider compression overrides. Carries the same tuning fields as the
125
134
  * global level, plus an optional per-model map keyed by model id. */
@@ -232,6 +241,14 @@ export interface AdapterConfig {
232
241
  * boolean shorthand (`false` disables) or an object. Default: enabled,
233
242
  * minRun=200. */
234
243
  degenerationGuard?: boolean | DegenerationGuardConfig;
244
+ /** Host multi-session turn-boundary policy (#364). Accepts a boolean
245
+ * shorthand (`true` → count host-injected custom_message entries as turn
246
+ * boundaries) or a HostSessionConfig object. Default: off — pi-native
247
+ * behavior where only genuine user-role messages start a turn, so existing
248
+ * single-session users' nudge cadence is unchanged. Enable for inline
249
+ * multi-session hosts (Prime RLM & co.) whose injected agent messages must
250
+ * delimit real turns. See docs/host-adapter.md. */
251
+ hostSession?: boolean | HostSessionConfig;
235
252
  /** Legacy flat alias for `delegate.displayUsage`. Kept for backward
236
253
  * compatibility with existing acp.json files. Prefer `delegate.displayUsage`. */
237
254
  displayUsage?: "merged" | "separate";
@@ -244,6 +261,21 @@ export interface AdapterConfig {
244
261
  * replacing the kernel's tuned compression rules may reduce summary quality
245
262
  * (lost paths/signatures/decisions → worse retrieval). */
246
263
  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;
247
279
  coreOverrides?: Partial<Config>;
248
280
  }
249
281
  export declare const DEFAULT_TOOL_BASH_TIMEOUT = 60;
@@ -267,6 +299,21 @@ export declare function resolveRepetitionGuard(adapter: AdapterConfig): {
267
299
  warn: number;
268
300
  abort: number;
269
301
  };
302
+ /** Host multi-session turn-boundary policy (#364). See TurnBoundaryPolicy in
303
+ * src/turn-boundary.ts for the semantics this resolves. */
304
+ export interface HostSessionConfig {
305
+ /** Count host-injected custom_message entries (agent_message) as turn
306
+ * boundaries. Default: false (pi-native behavior). */
307
+ countCustomMessages?: boolean;
308
+ }
309
+ export interface ResolvedHostSession {
310
+ countCustomMessages: boolean;
311
+ }
312
+ /** Resolve the host-session turn-boundary policy from the adapter, handling
313
+ * the boolean shorthand (`true` enables countCustomMessages). Invalid values
314
+ * fall back to the pi-native default (off) with a logged warning — they never
315
+ * fail the session. */
316
+ export declare function resolveHostSession(adapter: AdapterConfig): ResolvedHostSession;
270
317
  /** Per-field deepest-wins merge of the three compression levels (global →
271
318
  * provider → model). An undefined field at a deeper level does NOT clear a
272
319
  * value set at a shallower level — only a defined value overrides. */
@@ -1,11 +1,12 @@
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";
4
5
  declare const DecompressParams: Type.TObject<{
5
6
  blockId: Type.TString;
6
7
  full: Type.TOptional<Type.TBoolean>;
7
8
  toFile: Type.TOptional<Type.TString>;
8
9
  inline: Type.TOptional<Type.TBoolean>;
9
10
  }>;
10
- export declare function makeDecompressTool(runtime: AcpRuntime): ToolDefinition<typeof DecompressParams>;
11
+ export declare function makeDecompressTool(runtime: AcpRuntime, overrides?: ToolPromptOverrides): ToolDefinition<typeof DecompressParams>;
11
12
  export {};
@@ -0,0 +1,20 @@
1
+ export interface ExportOptions {
2
+ output?: string;
3
+ full?: boolean;
4
+ }
5
+ export interface SessionSummary {
6
+ id: string;
7
+ title?: string;
8
+ label?: string;
9
+ savedAt?: number;
10
+ contextTokens?: number;
11
+ blocks: number;
12
+ }
13
+ export declare function listSessions(sessionDir: string): Promise<SessionSummary[]>;
14
+ export declare function exportSession(selector: string | undefined, opts: ExportOptions, sessionDir: string): Promise<string>;
15
+ export declare function parseExportArgs(args: string): {
16
+ selector?: string;
17
+ full: boolean;
18
+ output?: string;
19
+ error?: string;
20
+ };
package/dist/host.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ /** Which session-entry source API the host exposes (same precedence as readContextEntries). */
3
+ export type EntrySourceKind = "buildContextEntries" | "getBranch";
4
+ export declare function entrySourceOf(sm: ExtensionContext["sessionManager"]): EntrySourceKind | null;
5
+ /**
6
+ * Whether the host declared itself a Pi-compatible fork via environment.
7
+ *
8
+ * The SessionManager shape alone cannot distinguish e.g. Prime from OMP — both are
9
+ * Pi forks exposing `getBranch()` but not `buildContextEntries()` — so an
10
+ * unsupported shape requires an explicit declaration before the adapter runs.
11
+ * Read at call time so hosts can set it per-launch. See docs/host-adapter.md.
12
+ */
13
+ export declare function isDeclaredForkHost(): boolean;
14
+ /** Unsupported host: not Pi-shaped and not declared as a fork. OMP stays blocked by default. */
15
+ export declare function isUnsupportedHost(sm: ExtensionContext["sessionManager"]): boolean;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
2
  import { type AdapterConfig } from "./config.js";
3
+ export { createRuntime } from "./runtime.js";
4
+ export type { AcpRuntime, SessionRef } from "./runtime.js";
5
+ export { deriveChildState } from "./state.js";
3
6
  export declare function createAcpExtension(adapter?: AdapterConfig): ExtensionFactory;
4
7
  declare const _default: ExtensionFactory;
5
8
  export default _default;