billion-context-pi 0.0.3 → 0.0.5

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/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface AdapterConfig {
9
9
  modelContextLimit?: number;
10
10
  protectedTools?: string[];
11
11
  preserveRecentMessages?: number;
12
- /** Check npm for a newer pai-acp on startup and auto-install it. Default: true.
12
+ /** Check npm for a newer billion-context-pi on startup and auto-install it. Default: true.
13
13
  * Disable via `autoUpdate: false` or env `ACP_AUTO_UPDATE=0` to avoid all
14
14
  * network calls on startup. */
15
15
  autoUpdate?: boolean;
package/dist/index.js CHANGED
@@ -7532,7 +7532,7 @@ import { tmpdir as tmpdir2 } from "os";
7532
7532
  import { join as join4 } from "path";
7533
7533
 
7534
7534
  // src/fleet-widget.ts
7535
- var DELEGATE_WIDGET_KEY = "pai-acp-delegates";
7535
+ var DELEGATE_WIDGET_KEY = "billion-context-pi-delegates";
7536
7536
  var REFRESH_MS = 500;
7537
7537
  var MAX_TASK_LEN = 48;
7538
7538
  var ui;
@@ -8184,7 +8184,7 @@ async function statusReport(runtime, ctx) {
8184
8184
  const activeBlocksList = state.blocks.filter((b) => b.active);
8185
8185
  const totalBlocksList = state.blocks;
8186
8186
  const lines = [];
8187
- const versionStr = "0.0.3" ? `pai-acp@${"0.0.3"}` : "";
8187
+ const versionStr = "0.0.5" ? `billion-context-pi@${"0.0.5"}` : "";
8188
8188
  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
8189
  lines.push("\u2502 ACP Context Analysis \u2502");
8190
8190
  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,24 +8331,12 @@ import { readFile, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises"
8331
8331
  import { join as join5, dirname as dirname3 } from "path";
8332
8332
  import { fileURLToPath } from "url";
8333
8333
  import { execFile } from "child_process";
8334
- var LEGACY_NAME = "pai-acp";
8335
- var REGISTRY_BASE = "https://registry.npmjs.org";
8334
+ var PACKAGE_NAME = "billion-context-pi";
8335
+ var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
8336
8336
  var SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/;
8337
8337
  var CHECK_INTERVAL_MS = 3 * 60 * 1e3;
8338
- function throttleFilePath(name) {
8339
- return `${process.env.HOME ?? ""}/.pi/agent/.${name}-update-check`;
8340
- }
8341
- var THROTTLE_FILE = `${process.env.HOME ?? ""}/.pi/agent/.pai-acp-update-check`;
8338
+ var THROTTLE_FILE = `${process.env.HOME ?? ""}/.pi/agent/.billion-context-pi-update-check`;
8342
8339
  var updateInFlight = false;
8343
- var cachedPackageName;
8344
- async function getPackageName() {
8345
- if (cachedPackageName !== void 0) return cachedPackageName;
8346
- const dir = await findExtensionDir();
8347
- if (!dir) return void 0;
8348
- const pkg = await readPackageJson(join5(dir, "package.json"));
8349
- cachedPackageName = pkg?.name;
8350
- return cachedPackageName;
8351
- }
8352
8340
  function parseVersion(v) {
8353
8341
  return v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
8354
8342
  }
@@ -8361,18 +8349,18 @@ function isNewer(latest, current) {
8361
8349
  }
8362
8350
  return false;
8363
8351
  }
8364
- async function readLastCheck(name) {
8352
+ async function readLastCheck() {
8365
8353
  try {
8366
- const data = await readFile(throttleFilePath(name), "utf-8");
8354
+ const data = await readFile(THROTTLE_FILE, "utf-8");
8367
8355
  return parseInt(data.trim(), 10) || 0;
8368
8356
  } catch {
8369
8357
  return 0;
8370
8358
  }
8371
8359
  }
8372
- async function writeLastCheck(name, timestamp) {
8360
+ async function writeLastCheck(timestamp) {
8373
8361
  try {
8374
- await mkdir3(dirname3(throttleFilePath(name)), { recursive: true });
8375
- await writeFile3(throttleFilePath(name), String(timestamp), "utf-8");
8362
+ await mkdir3(dirname3(THROTTLE_FILE), { recursive: true });
8363
+ await writeFile3(THROTTLE_FILE, String(timestamp), "utf-8");
8376
8364
  } catch {
8377
8365
  }
8378
8366
  }
@@ -8396,7 +8384,7 @@ async function findExtensionDir() {
8396
8384
  let dir = dirname3(fileURLToPath(import.meta.url));
8397
8385
  for (; ; ) {
8398
8386
  const pkg = await readPackageJson(join5(dir, "package.json"));
8399
- if (pkg?.name === LEGACY_NAME || pkg?.name === "billion-context-pi") return dir;
8387
+ if (pkg?.name === PACKAGE_NAME) return dir;
8400
8388
  const parent = dirname3(dir);
8401
8389
  if (parent === dir) return void 0;
8402
8390
  dir = parent;
@@ -8409,12 +8397,10 @@ async function autoInstallLatest(latest) {
8409
8397
  const npmDir = findNpmRoot(extDir);
8410
8398
  if (!npmDir) return false;
8411
8399
  try {
8412
- const packageName = await getPackageName();
8413
- if (!packageName) return false;
8414
8400
  const code = await new Promise((resolve2) => {
8415
8401
  execFile(
8416
8402
  "npm",
8417
- ["install", `${packageName}@${latest}`, "--silent", "--no-audit", "--no-fund"],
8403
+ ["install", `${PACKAGE_NAME}@${latest}`, "--silent", "--no-audit", "--no-fund"],
8418
8404
  { cwd: npmDir, timeout: 6e4, shell: process.platform === "win32" },
8419
8405
  (err) => resolve2(err ? 1 : 0)
8420
8406
  );
@@ -8432,14 +8418,12 @@ async function checkForUpdate(autoUpdate, notify) {
8432
8418
  if (updateInFlight) return;
8433
8419
  updateInFlight = true;
8434
8420
  try {
8435
- const packageName = await getPackageName();
8436
- if (!packageName) return;
8437
8421
  const now = Date.now();
8438
- const lastCheck = await readLastCheck(packageName);
8422
+ const lastCheck = await readLastCheck();
8439
8423
  if (now - lastCheck < CHECK_INTERVAL_MS) return;
8440
- await writeLastCheck(packageName, now);
8424
+ await writeLastCheck(now);
8441
8425
  const runtimeVersion = await getRuntimeVersion();
8442
- const res = await fetch(`${REGISTRY_BASE}/${packageName}/latest`, {
8426
+ const res = await fetch(REGISTRY_URL, {
8443
8427
  signal: AbortSignal.timeout(5e3),
8444
8428
  headers: { Accept: "application/json" }
8445
8429
  });
@@ -8447,7 +8431,7 @@ async function checkForUpdate(autoUpdate, notify) {
8447
8431
  const data = await res.json();
8448
8432
  const latest = data.version;
8449
8433
  if (!latest) return;
8450
- const current = runtimeVersion ?? "0.0.3";
8434
+ const current = runtimeVersion ?? "0.0.5";
8451
8435
  debug.event("update-check", {
8452
8436
  current,
8453
8437
  latest,
@@ -8461,7 +8445,7 @@ async function checkForUpdate(autoUpdate, notify) {
8461
8445
  );
8462
8446
  } else if (!installed && notify) {
8463
8447
  notify(
8464
- `${packageName} ${latest} available (you have ${current}). Run: pi update --extension npm:${packageName}`
8448
+ `${PACKAGE_NAME} ${latest} available (you have ${current}). Run: pi update --extension npm:${PACKAGE_NAME}`
8465
8449
  );
8466
8450
  }
8467
8451
  }
@@ -8477,157 +8461,11 @@ async function getRuntimeVersion() {
8477
8461
  return pkg?.version;
8478
8462
  }
8479
8463
 
8480
- // src/rename-notice.ts
8481
- import { readFileSync, existsSync } from "fs";
8482
- import { join as join6, dirname as dirname4 } from "path";
8483
- import { fileURLToPath as fileURLToPath2 } from "url";
8484
- import { execFile as execFile2 } from "child_process";
8485
- var LEGACY_NAME2 = "pai-acp";
8486
- var NEW_NAME = "billion-context-pi";
8487
- var NEW_REF = `npm:${NEW_NAME}`;
8488
- var REGISTRY_URL = `https://registry.npmjs.org/${NEW_NAME}/latest`;
8489
- function findExtensionDirSync() {
8490
- let dir = dirname4(fileURLToPath2(import.meta.url));
8491
- for (; ; ) {
8492
- try {
8493
- const data = JSON.parse(readFileSync(join6(dir, "package.json"), "utf-8"));
8494
- if (data?.name === LEGACY_NAME2 || data?.name === NEW_NAME) return dir;
8495
- } catch {
8496
- }
8497
- const parent = dirname4(dir);
8498
- if (parent === dir) return void 0;
8499
- dir = parent;
8500
- }
8501
- }
8502
- function findNpmRootSync(extDir) {
8503
- let dir = dirname4(extDir);
8504
- for (; ; ) {
8505
- if (dir.endsWith("node_modules")) return dirname4(dir);
8506
- const parent = dirname4(dir);
8507
- if (parent === dir) return void 0;
8508
- dir = parent;
8509
- }
8510
- }
8511
- function isLegacyPackage() {
8512
- const dir = findExtensionDirSync();
8513
- if (!dir) return false;
8514
- try {
8515
- const data = JSON.parse(readFileSync(join6(dir, "package.json"), "utf-8"));
8516
- return data?.name === LEGACY_NAME2;
8517
- } catch {
8518
- return false;
8519
- }
8520
- }
8521
- function isNewPackageInstalled() {
8522
- const extDir = findExtensionDirSync();
8523
- if (!extDir) return false;
8524
- const npmDir = findNpmRootSync(extDir);
8525
- if (!npmDir) return false;
8526
- try {
8527
- const data = JSON.parse(
8528
- readFileSync(join6(npmDir, "node_modules", NEW_NAME, "package.json"), "utf-8")
8529
- );
8530
- return data?.name === NEW_NAME && existsSync(join6(npmDir, "node_modules", NEW_NAME, "dist", "index.js"));
8531
- } catch {
8532
- return false;
8533
- }
8534
- }
8535
- async function newPackageReady() {
8536
- try {
8537
- const res = await fetch(REGISTRY_URL, {
8538
- signal: AbortSignal.timeout(5e3),
8539
- headers: { Accept: "application/json" }
8540
- });
8541
- if (!res.ok) return false;
8542
- const data = await res.json();
8543
- const v = (data.version ?? "0.0.0").split(".").map((n) => parseInt(n, 10) || 0);
8544
- return (v[0] ?? 0) > 0 || (v[1] ?? 0) > 0 || (v[2] ?? 0) > 1;
8545
- } catch {
8546
- return false;
8547
- }
8548
- }
8549
- function runPi(args) {
8550
- const cliEntry = process.argv[1];
8551
- if (!cliEntry || !existsSync(cliEntry)) return Promise.resolve(1);
8552
- return new Promise((resolve2) => {
8553
- const child = execFile2(
8554
- process.execPath,
8555
- [cliEntry, ...args],
8556
- { timeout: 12e4, shell: process.platform === "win32" },
8557
- (err) => resolve2(err ? 1 : 0)
8558
- );
8559
- child.stdin?.end();
8560
- });
8561
- }
8562
- var GREEN = "\x1B[32m";
8563
- var CYAN = "\x1B[36m";
8564
- var RESET = "\x1B[0m";
8565
- function manualNotice() {
8566
- const body = [
8567
- "\u2192 pai-acp has been renamed to billion-context-pi",
8568
- "Your context tools are unchanged \u2014 same package, new name.",
8569
- "Once billion-context-pi is published, it will install automatically.",
8570
- "Your ~/.pi/acp.json config carries over."
8571
- ].join("\n");
8572
- return `${CYAN}${body}${RESET}`;
8573
- }
8574
- function installingNotice() {
8575
- return `${CYAN}Installing billion-context-pi\u2026${RESET}`;
8576
- }
8577
- function successNotice() {
8578
- const body = [
8579
- "\u2714 pai-acp \u2192 billion-context-pi (renamed, same tools).",
8580
- "billion-context-pi has been installed. Restart Pi to switch over.",
8581
- "Do NOT uninstall billion-context-pi \u2014 it is the replacement for pai-acp."
8582
- ].join("\n");
8583
- return `${GREEN}${body}${RESET}`;
8584
- }
8585
- function canUninstallNotice() {
8586
- const body = [
8587
- "\u2714 You are now running billion-context-pi (formerly pai-acp).",
8588
- "All your context tools (compress / decompress / search / delegate) are intact.",
8589
- "pai-acp is now inert and safe to remove: pi uninstall pai-acp"
8590
- ].join("\n");
8591
- return `${GREEN}${body}${RESET}`;
8592
- }
8593
- async function installNewPackage() {
8594
- return await runPi(["install", NEW_REF]) === 0;
8595
- }
8596
- var migrateInFlight = false;
8597
- async function checkRename(notify) {
8598
- const safeNotify = (msg) => {
8599
- try {
8600
- notify(msg);
8601
- } catch {
8602
- }
8603
- };
8604
- if (migrateInFlight) return;
8605
- migrateInFlight = true;
8606
- try {
8607
- if (isNewPackageInstalled()) {
8608
- safeNotify(canUninstallNotice());
8609
- return;
8610
- }
8611
- const ready = await newPackageReady();
8612
- if (!ready) {
8613
- safeNotify(manualNotice());
8614
- return;
8615
- }
8616
- safeNotify(installingNotice());
8617
- const ok = await installNewPackage();
8618
- safeNotify(ok ? successNotice() : manualNotice());
8619
- } catch {
8620
- safeNotify(manualNotice());
8621
- } finally {
8622
- migrateInFlight = false;
8623
- }
8624
- }
8625
-
8626
8464
  // src/setup-subagent-tools.ts
8627
8465
  import { readFile as readFile2, writeFile as writeFile4, stat, copyFile, rename } from "fs/promises";
8628
- import { existsSync as existsSync2 } from "fs";
8466
+ import { existsSync } from "fs";
8629
8467
  import { homedir } from "os";
8630
- import { join as join7 } from "path";
8468
+ import { join as join6 } from "path";
8631
8469
  var ACP_TOOLS = ["compress", "decompress", "search_context", "acp_status"];
8632
8470
  var BUILTIN_DEFAULT_TOOLS = {
8633
8471
  advisor: ["read", "grep", "find", "ls", "bash", "intercom"],
@@ -8643,8 +8481,8 @@ var BUILTIN_DEFAULT_TOOLS = {
8643
8481
  function resolveAgentDir() {
8644
8482
  const configured = process.env.PI_CODING_AGENT_DIR;
8645
8483
  if (configured === "~") return homedir();
8646
- if (configured?.startsWith("~/")) return join7(homedir(), configured.slice(2));
8647
- return configured || join7(homedir(), ".pi", "agent");
8484
+ if (configured?.startsWith("~/")) return join6(homedir(), configured.slice(2));
8485
+ return configured || join6(homedir(), ".pi", "agent");
8648
8486
  }
8649
8487
  function desiredTools(existing, name) {
8650
8488
  const base = Array.isArray(existing?.tools) && existing.tools.length > 0 ? [...existing.tools] : [...BUILTIN_DEFAULT_TOOLS[name] ?? []];
@@ -8654,7 +8492,7 @@ function desiredTools(existing, name) {
8654
8492
  return { tools: base, changed: true };
8655
8493
  }
8656
8494
  async function ensureSubagentAcpTools(settingsPath) {
8657
- const path4 = settingsPath ?? join7(resolveAgentDir(), "settings.json");
8495
+ const path4 = settingsPath ?? join6(resolveAgentDir(), "settings.json");
8658
8496
  let raw;
8659
8497
  let mtimeMs;
8660
8498
  try {
@@ -8689,7 +8527,7 @@ async function ensureSubagentAcpTools(settingsPath) {
8689
8527
  return { path: path4, action: "skipped", reason: "all builtin agents already have ACP tools" };
8690
8528
  }
8691
8529
  const backupPath = `${path4}.acp-bak`;
8692
- if (!existsSync2(backupPath)) {
8530
+ if (!existsSync(backupPath)) {
8693
8531
  try {
8694
8532
  await copyFile(path4, backupPath);
8695
8533
  } catch {
@@ -8755,8 +8593,8 @@ import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
8755
8593
  async function loadUserConfig(cwd) {
8756
8594
  const home = process.env.HOME ?? "";
8757
8595
  const merged = {};
8758
- for (const base of [join9(home, CONFIG_DIR_NAME), join9(cwd, CONFIG_DIR_NAME)]) {
8759
- const file = join9(base, "acp.json");
8596
+ for (const base of [join8(home, CONFIG_DIR_NAME), join8(cwd, CONFIG_DIR_NAME)]) {
8597
+ const file = join8(base, "acp.json");
8760
8598
  try {
8761
8599
  const raw = await fs3.readFile(file, "utf8");
8762
8600
  const parsed = JSON.parse(raw);
@@ -8769,7 +8607,7 @@ async function loadUserConfig(cwd) {
8769
8607
  }
8770
8608
  return merged;
8771
8609
  }
8772
- function join9(...parts) {
8610
+ function join8(...parts) {
8773
8611
  return path3.join(...parts);
8774
8612
  }
8775
8613
  var KNOWN = /* @__PURE__ */ new Set(["debug", "autoUpdate", "modelContextLimit", "delegate"]);
@@ -8795,14 +8633,6 @@ function applyUserConfig(adapter, user) {
8795
8633
  // src/index.ts
8796
8634
  function createAcpExtension(adapter = {}) {
8797
8635
  return (pi) => {
8798
- if (isLegacyPackage() && isNewPackageInstalled()) {
8799
- pi.on("session_start", async (_event, ctx) => {
8800
- if (ctx.hasUI) {
8801
- checkRename((m) => ctx.ui.notify(m));
8802
- }
8803
- });
8804
- return;
8805
- }
8806
8636
  const runtime = createRuntime(adapter);
8807
8637
  wireCompactionDisable(pi);
8808
8638
  wireSessionLifecycle(pi, runtime);
@@ -8839,9 +8669,6 @@ function wireSessionLifecycle(pi, runtime) {
8839
8669
  void checkForUpdate(runtime.adapter.autoUpdate ?? true, (msg) => {
8840
8670
  if (ctx.hasUI) ctx.ui.notify(msg);
8841
8671
  });
8842
- if (isLegacyPackage() && ctx.hasUI) {
8843
- void checkRename((msg) => ctx.ui.notify(msg));
8844
- }
8845
8672
  void runSetupAndNotify(ctx.hasUI ? (m) => ctx.ui.notify(m) : void 0);
8846
8673
  delegateStatusWidget.setContext(ctx, runningRunsSnapshot);
8847
8674
  });