billion-context-pi 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -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.2" ? `pai-acp@${"0.0.2"}` : "";
8187
+ const versionStr = "0.0.3" ? `pai-acp@${"0.0.3"}` : "";
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,12 +8331,24 @@ 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 PACKAGE_NAME = "pai-acp";
8335
- var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
8334
+ var LEGACY_NAME = "pai-acp";
8335
+ var REGISTRY_BASE = "https://registry.npmjs.org";
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
+ }
8338
8341
  var THROTTLE_FILE = `${process.env.HOME ?? ""}/.pi/agent/.pai-acp-update-check`;
8339
8342
  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
+ }
8340
8352
  function parseVersion(v) {
8341
8353
  return v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
8342
8354
  }
@@ -8349,18 +8361,18 @@ function isNewer(latest, current) {
8349
8361
  }
8350
8362
  return false;
8351
8363
  }
8352
- async function readLastCheck() {
8364
+ async function readLastCheck(name) {
8353
8365
  try {
8354
- const data = await readFile(THROTTLE_FILE, "utf-8");
8366
+ const data = await readFile(throttleFilePath(name), "utf-8");
8355
8367
  return parseInt(data.trim(), 10) || 0;
8356
8368
  } catch {
8357
8369
  return 0;
8358
8370
  }
8359
8371
  }
8360
- async function writeLastCheck(timestamp) {
8372
+ async function writeLastCheck(name, timestamp) {
8361
8373
  try {
8362
- await mkdir3(dirname3(THROTTLE_FILE), { recursive: true });
8363
- await writeFile3(THROTTLE_FILE, String(timestamp), "utf-8");
8374
+ await mkdir3(dirname3(throttleFilePath(name)), { recursive: true });
8375
+ await writeFile3(throttleFilePath(name), String(timestamp), "utf-8");
8364
8376
  } catch {
8365
8377
  }
8366
8378
  }
@@ -8384,7 +8396,7 @@ async function findExtensionDir() {
8384
8396
  let dir = dirname3(fileURLToPath(import.meta.url));
8385
8397
  for (; ; ) {
8386
8398
  const pkg = await readPackageJson(join5(dir, "package.json"));
8387
- if (pkg?.name === PACKAGE_NAME) return dir;
8399
+ if (pkg?.name === LEGACY_NAME || pkg?.name === "billion-context-pi") return dir;
8388
8400
  const parent = dirname3(dir);
8389
8401
  if (parent === dir) return void 0;
8390
8402
  dir = parent;
@@ -8397,10 +8409,12 @@ async function autoInstallLatest(latest) {
8397
8409
  const npmDir = findNpmRoot(extDir);
8398
8410
  if (!npmDir) return false;
8399
8411
  try {
8412
+ const packageName = await getPackageName();
8413
+ if (!packageName) return false;
8400
8414
  const code = await new Promise((resolve2) => {
8401
8415
  execFile(
8402
8416
  "npm",
8403
- ["install", `${PACKAGE_NAME}@${latest}`, "--silent", "--no-audit", "--no-fund"],
8417
+ ["install", `${packageName}@${latest}`, "--silent", "--no-audit", "--no-fund"],
8404
8418
  { cwd: npmDir, timeout: 6e4, shell: process.platform === "win32" },
8405
8419
  (err) => resolve2(err ? 1 : 0)
8406
8420
  );
@@ -8418,12 +8432,14 @@ async function checkForUpdate(autoUpdate, notify) {
8418
8432
  if (updateInFlight) return;
8419
8433
  updateInFlight = true;
8420
8434
  try {
8435
+ const packageName = await getPackageName();
8436
+ if (!packageName) return;
8421
8437
  const now = Date.now();
8422
- const lastCheck = await readLastCheck();
8438
+ const lastCheck = await readLastCheck(packageName);
8423
8439
  if (now - lastCheck < CHECK_INTERVAL_MS) return;
8424
- await writeLastCheck(now);
8440
+ await writeLastCheck(packageName, now);
8425
8441
  const runtimeVersion = await getRuntimeVersion();
8426
- const res = await fetch(REGISTRY_URL, {
8442
+ const res = await fetch(`${REGISTRY_BASE}/${packageName}/latest`, {
8427
8443
  signal: AbortSignal.timeout(5e3),
8428
8444
  headers: { Accept: "application/json" }
8429
8445
  });
@@ -8431,7 +8447,7 @@ async function checkForUpdate(autoUpdate, notify) {
8431
8447
  const data = await res.json();
8432
8448
  const latest = data.version;
8433
8449
  if (!latest) return;
8434
- const current = runtimeVersion ?? "0.0.2";
8450
+ const current = runtimeVersion ?? "0.0.3";
8435
8451
  debug.event("update-check", {
8436
8452
  current,
8437
8453
  latest,
@@ -8445,7 +8461,7 @@ async function checkForUpdate(autoUpdate, notify) {
8445
8461
  );
8446
8462
  } else if (!installed && notify) {
8447
8463
  notify(
8448
- `${PACKAGE_NAME} ${latest} available (you have ${current}). Run: pi update --extension npm:${PACKAGE_NAME}`
8464
+ `${packageName} ${latest} available (you have ${current}). Run: pi update --extension npm:${packageName}`
8449
8465
  );
8450
8466
  }
8451
8467
  }
@@ -8466,16 +8482,16 @@ import { readFileSync, existsSync } from "fs";
8466
8482
  import { join as join6, dirname as dirname4 } from "path";
8467
8483
  import { fileURLToPath as fileURLToPath2 } from "url";
8468
8484
  import { execFile as execFile2 } from "child_process";
8469
- var LEGACY_NAME = "pai-acp";
8485
+ var LEGACY_NAME2 = "pai-acp";
8470
8486
  var NEW_NAME = "billion-context-pi";
8471
8487
  var NEW_REF = `npm:${NEW_NAME}`;
8472
- var REGISTRY_URL2 = `https://registry.npmjs.org/${NEW_NAME}/latest`;
8488
+ var REGISTRY_URL = `https://registry.npmjs.org/${NEW_NAME}/latest`;
8473
8489
  function findExtensionDirSync() {
8474
8490
  let dir = dirname4(fileURLToPath2(import.meta.url));
8475
8491
  for (; ; ) {
8476
8492
  try {
8477
8493
  const data = JSON.parse(readFileSync(join6(dir, "package.json"), "utf-8"));
8478
- if (data?.name === LEGACY_NAME || data?.name === NEW_NAME) return dir;
8494
+ if (data?.name === LEGACY_NAME2 || data?.name === NEW_NAME) return dir;
8479
8495
  } catch {
8480
8496
  }
8481
8497
  const parent = dirname4(dir);
@@ -8497,7 +8513,7 @@ function isLegacyPackage() {
8497
8513
  if (!dir) return false;
8498
8514
  try {
8499
8515
  const data = JSON.parse(readFileSync(join6(dir, "package.json"), "utf-8"));
8500
- return data?.name === LEGACY_NAME;
8516
+ return data?.name === LEGACY_NAME2;
8501
8517
  } catch {
8502
8518
  return false;
8503
8519
  }
@@ -8518,7 +8534,7 @@ function isNewPackageInstalled() {
8518
8534
  }
8519
8535
  async function newPackageReady() {
8520
8536
  try {
8521
- const res = await fetch(REGISTRY_URL2, {
8537
+ const res = await fetch(REGISTRY_URL, {
8522
8538
  signal: AbortSignal.timeout(5e3),
8523
8539
  headers: { Accept: "application/json" }
8524
8540
  });
@@ -8548,12 +8564,10 @@ var CYAN = "\x1B[36m";
8548
8564
  var RESET = "\x1B[0m";
8549
8565
  function manualNotice() {
8550
8566
  const body = [
8551
- "\u2192 pai-acp is now billion-context-pi",
8567
+ "\u2192 pai-acp has been renamed to billion-context-pi",
8552
8568
  "Your context tools are unchanged \u2014 same package, new name.",
8553
- "To switch:",
8554
- " pi install billion-context-pi",
8555
- " pi uninstall pai-acp",
8556
- "(Your ~/.pi/acp.json config carries over.)"
8569
+ "Once billion-context-pi is published, it will install automatically.",
8570
+ "Your ~/.pi/acp.json config carries over."
8557
8571
  ].join("\n");
8558
8572
  return `${CYAN}${body}${RESET}`;
8559
8573
  }
@@ -8561,15 +8575,20 @@ function installingNotice() {
8561
8575
  return `${CYAN}Installing billion-context-pi\u2026${RESET}`;
8562
8576
  }
8563
8577
  function successNotice() {
8564
- return `${GREEN}\u2714 billion-context-pi installed \u2014 restart Pi to switch.${RESET}`;
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}`;
8565
8584
  }
8566
8585
  function canUninstallNotice() {
8567
8586
  const body = [
8568
- `${GREEN}\u2714 billion-context-pi is active.${RESET}`,
8569
- `${CYAN}pai-acp is now inert. To clean up:${RESET}`,
8570
- ` ${CYAN}pi uninstall pai-acp${RESET}`
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"
8571
8590
  ].join("\n");
8572
- return body;
8591
+ return `${GREEN}${body}${RESET}`;
8573
8592
  }
8574
8593
  async function installNewPackage() {
8575
8594
  return await runPi(["install", NEW_REF]) === 0;