billion-context-pi 0.0.5 → 0.1.24
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 +9 -9
- package/README.zh-CN.md +8 -8
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# billion-context-pi
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | [中文](./README.zh-CN.md)
|
|
4
4
|
|
|
@@ -11,13 +11,13 @@ The model decides <em>when</em> and <em>what</em> to compress — not a hard lim
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
|
-
<a href="https://www.npmjs.com/package/
|
|
15
|
-
<a href="https://github.com/ranxianglei/
|
|
16
|
-
<a href="https://github.com/ranxianglei/
|
|
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>
|
|
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>
|
|
16
|
+
<a href="https://github.com/ranxianglei/billion-context-pi"><img src="https://img.shields.io/badge/GitHub-ranxianglei%2Fbillion--context--pi-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
20
|
-
<code>pi install npm:
|
|
20
|
+
<code>pi install npm:billion-context-pi</code>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
---
|
|
@@ -40,12 +40,12 @@ This means:
|
|
|
40
40
|
## Install
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
pi install npm:
|
|
43
|
+
pi install npm:billion-context-pi
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
That's it. The extension auto-loads on next Pi startup. No configuration needed — it reads your model's context window automatically.
|
|
47
47
|
|
|
48
|
-
> **Uninstall `pi-subagents` first (optional, recommended).**
|
|
48
|
+
> **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:
|
|
49
49
|
> ```bash
|
|
50
50
|
> pi remove npm:pi-subagents
|
|
51
51
|
> ```
|
|
@@ -101,7 +101,7 @@ Rich status display for the user:
|
|
|
101
101
|
╭─────────────────────────────────────────────╮
|
|
102
102
|
│ ACP Context Analysis │
|
|
103
103
|
╰─────────────────────────────────────────────╯
|
|
104
|
-
|
|
104
|
+
billion-context-pi@0.1.14
|
|
105
105
|
|
|
106
106
|
Context: 12% (120K / 1.0M)
|
|
107
107
|
Growth: +15K since last nudge
|
|
@@ -121,7 +121,7 @@ Blocks: 3 active (3.7K summary, 15.2K original compressed)
|
|
|
121
121
|
|
|
122
122
|
## Configuration
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
billion-context-pi works out of the box with no configuration. Three optional keys can be set in a JSON config file.
|
|
125
125
|
|
|
126
126
|
### Config file
|
|
127
127
|
|
package/README.zh-CN.md
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/
|
|
13
|
-
<a href="https://github.com/ranxianglei/
|
|
14
|
-
<a href="https://github.com/ranxianglei/
|
|
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>
|
|
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>
|
|
14
|
+
<a href="https://github.com/ranxianglei/billion-context-pi"><img src="https://img.shields.io/badge/GitHub-ranxianglei%2Fbillion--context--pi-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<p align="center">
|
|
18
|
-
<code>pi install npm:
|
|
18
|
+
<code>pi install npm:billion-context-pi</code>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
21
|
---
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
## 安装
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
pi install npm:
|
|
42
|
+
pi install npm:billion-context-pi
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
完成。扩展在下次 Pi 启动时自动加载。无需配置 —— 它会自动读取模型的上下文窗口。
|
|
46
46
|
|
|
47
|
-
> **建议先卸载 `pi-subagents`(可选,推荐)。**
|
|
47
|
+
> **建议先卸载 `pi-subagents`(可选,推荐)。** billion-context-pi 自带 `acp_delegate` 子代理工具(见下文),以极低的上下文成本(~600 tok vs ~7K tok/轮)替代 pi-subagents。如果你已安装 pi-subagents,卸载它以避免重复的委派工具:
|
|
48
48
|
> ```bash
|
|
49
49
|
> pi remove npm:pi-subagents
|
|
50
50
|
> ```
|
|
@@ -100,7 +100,7 @@ Pi 内置的自动压缩会被取消 —— ACP 是唯一的上下文管理者
|
|
|
100
100
|
╭─────────────────────────────────────────────╮
|
|
101
101
|
│ ACP Context Analysis │
|
|
102
102
|
╰─────────────────────────────────────────────╯
|
|
103
|
-
|
|
103
|
+
billion-context-pi@0.1.14
|
|
104
104
|
|
|
105
105
|
Context: 12% (120K / 1.0M)
|
|
106
106
|
Growth: +15K since last nudge
|
|
@@ -120,7 +120,7 @@ Blocks: 3 active (3.7K summary, 15.2K original compressed)
|
|
|
120
120
|
|
|
121
121
|
## 配置
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
billion-context-pi 开箱即用,无需任何配置。可以在 JSON 配置文件中设置三个可选 key。
|
|
124
124
|
|
|
125
125
|
### 配置文件
|
|
126
126
|
|
package/dist/index.js
CHANGED
|
@@ -7044,8 +7044,9 @@ __export(typebox_exports, {
|
|
|
7044
7044
|
// src/log.ts
|
|
7045
7045
|
import { promises as fs2 } from "fs";
|
|
7046
7046
|
import * as path2 from "path";
|
|
7047
|
+
import { homedir } from "os";
|
|
7047
7048
|
var ENV_DEBUG = process.env.ACP_DEBUG === "1" || process.env.ACP_DEBUG === "true";
|
|
7048
|
-
var LOG_FILE = process.env.ACP_LOG_FILE ?? path2.join(
|
|
7049
|
+
var LOG_FILE = process.env.ACP_LOG_FILE ?? path2.join(homedir(), ".pi", "acp-debug.log");
|
|
7049
7050
|
var runtimeDebug = null;
|
|
7050
7051
|
var initialized = false;
|
|
7051
7052
|
function setDebugEnabled(enabled) {
|
|
@@ -7206,8 +7207,8 @@ async function handleCompress(args, runtime, ctx, toolCallId) {
|
|
|
7206
7207
|
// src/decompress-tool.ts
|
|
7207
7208
|
import { writeFile, mkdir } from "fs/promises";
|
|
7208
7209
|
import { resolve, relative, isAbsolute, join as join3 } from "path";
|
|
7209
|
-
import { tmpdir } from "os";
|
|
7210
|
-
var AUTO_DIR = join3(
|
|
7210
|
+
import { tmpdir, homedir as homedir2 } from "os";
|
|
7211
|
+
var AUTO_DIR = join3(homedir2() || tmpdir(), ".cache", "pi", "acp-decompress");
|
|
7211
7212
|
var PREVIEW_CHARS = 600;
|
|
7212
7213
|
var MESSAGE_INLINE_THRESHOLD = 2e3;
|
|
7213
7214
|
var DecompressParams = typebox_exports.Object({
|
|
@@ -7237,11 +7238,11 @@ function makeDecompressTool(runtime) {
|
|
|
7237
7238
|
}
|
|
7238
7239
|
var ALLOWED_DIRS = [
|
|
7239
7240
|
tmpdir(),
|
|
7240
|
-
join3(
|
|
7241
|
-
join3(
|
|
7241
|
+
join3(homedir2(), ".cache", "opencode"),
|
|
7242
|
+
join3(homedir2(), ".cache", "pi")
|
|
7242
7243
|
];
|
|
7243
7244
|
function resolveToFilePath(targetPath) {
|
|
7244
|
-
const expanded = targetPath.startsWith("~/") ? join3(
|
|
7245
|
+
const expanded = targetPath.startsWith("~/") ? join3(homedir2(), targetPath.slice(2)) : targetPath;
|
|
7245
7246
|
const resolved = resolve(expanded);
|
|
7246
7247
|
const isAllowed = ALLOWED_DIRS.some((dir) => {
|
|
7247
7248
|
const rel = relative(dir, resolved);
|
|
@@ -8184,7 +8185,7 @@ async function statusReport(runtime, ctx) {
|
|
|
8184
8185
|
const activeBlocksList = state.blocks.filter((b) => b.active);
|
|
8185
8186
|
const totalBlocksList = state.blocks;
|
|
8186
8187
|
const lines = [];
|
|
8187
|
-
const versionStr = "0.
|
|
8188
|
+
const versionStr = "0.1.24" ? `billion-context-pi@${"0.1.24"}` : "";
|
|
8188
8189
|
lines.push("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E");
|
|
8189
8190
|
lines.push("\u2502 ACP Context Analysis \u2502");
|
|
8190
8191
|
lines.push("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");
|
|
@@ -8331,11 +8332,12 @@ import { readFile, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises"
|
|
|
8331
8332
|
import { join as join5, dirname as dirname3 } from "path";
|
|
8332
8333
|
import { fileURLToPath } from "url";
|
|
8333
8334
|
import { execFile } from "child_process";
|
|
8335
|
+
import { homedir as homedir3 } from "os";
|
|
8334
8336
|
var PACKAGE_NAME = "billion-context-pi";
|
|
8335
8337
|
var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
8336
8338
|
var SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/;
|
|
8337
8339
|
var CHECK_INTERVAL_MS = 3 * 60 * 1e3;
|
|
8338
|
-
var THROTTLE_FILE =
|
|
8340
|
+
var THROTTLE_FILE = join5(homedir3(), ".pi", "agent", ".billion-context-pi-update-check");
|
|
8339
8341
|
var updateInFlight = false;
|
|
8340
8342
|
function parseVersion(v) {
|
|
8341
8343
|
return v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -8431,7 +8433,7 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8431
8433
|
const data = await res.json();
|
|
8432
8434
|
const latest = data.version;
|
|
8433
8435
|
if (!latest) return;
|
|
8434
|
-
const current = runtimeVersion ?? "0.
|
|
8436
|
+
const current = runtimeVersion ?? "0.1.24";
|
|
8435
8437
|
debug.event("update-check", {
|
|
8436
8438
|
current,
|
|
8437
8439
|
latest,
|
|
@@ -8464,7 +8466,7 @@ async function getRuntimeVersion() {
|
|
|
8464
8466
|
// src/setup-subagent-tools.ts
|
|
8465
8467
|
import { readFile as readFile2, writeFile as writeFile4, stat, copyFile, rename } from "fs/promises";
|
|
8466
8468
|
import { existsSync } from "fs";
|
|
8467
|
-
import { homedir } from "os";
|
|
8469
|
+
import { homedir as homedir4 } from "os";
|
|
8468
8470
|
import { join as join6 } from "path";
|
|
8469
8471
|
var ACP_TOOLS = ["compress", "decompress", "search_context", "acp_status"];
|
|
8470
8472
|
var BUILTIN_DEFAULT_TOOLS = {
|
|
@@ -8480,9 +8482,9 @@ var BUILTIN_DEFAULT_TOOLS = {
|
|
|
8480
8482
|
};
|
|
8481
8483
|
function resolveAgentDir() {
|
|
8482
8484
|
const configured = process.env.PI_CODING_AGENT_DIR;
|
|
8483
|
-
if (configured === "~") return
|
|
8484
|
-
if (configured?.startsWith("~/")) return join6(
|
|
8485
|
-
return configured || join6(
|
|
8485
|
+
if (configured === "~") return homedir4();
|
|
8486
|
+
if (configured?.startsWith("~/")) return join6(homedir4(), configured.slice(2));
|
|
8487
|
+
return configured || join6(homedir4(), ".pi", "agent");
|
|
8486
8488
|
}
|
|
8487
8489
|
function desiredTools(existing, name) {
|
|
8488
8490
|
const base = Array.isArray(existing?.tools) && existing.tools.length > 0 ? [...existing.tools] : [...BUILTIN_DEFAULT_TOOLS[name] ?? []];
|
|
@@ -8589,9 +8591,10 @@ async function runSetupAndNotify(notify) {
|
|
|
8589
8591
|
// src/user-config.ts
|
|
8590
8592
|
import { promises as fs3 } from "fs";
|
|
8591
8593
|
import * as path3 from "path";
|
|
8594
|
+
import { homedir as homedir5 } from "os";
|
|
8592
8595
|
import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
8593
8596
|
async function loadUserConfig(cwd) {
|
|
8594
|
-
const home =
|
|
8597
|
+
const home = homedir5();
|
|
8595
8598
|
const merged = {};
|
|
8596
8599
|
for (const base of [join8(home, CONFIG_DIR_NAME), join8(cwd, CONFIG_DIR_NAME)]) {
|
|
8597
8600
|
const file = join8(base, "acp.json");
|