billion-context-pi 0.0.3 → 0.0.4
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 +51 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8090,6 +8090,25 @@ function truncate2(s, n) {
|
|
|
8090
8090
|
}
|
|
8091
8091
|
|
|
8092
8092
|
// src/commands.ts
|
|
8093
|
+
import { readFileSync } from "fs";
|
|
8094
|
+
import { join as join5, dirname as dirname3 } from "path";
|
|
8095
|
+
import { fileURLToPath } from "url";
|
|
8096
|
+
function getDisplayName() {
|
|
8097
|
+
try {
|
|
8098
|
+
let dir = dirname3(fileURLToPath(import.meta.url));
|
|
8099
|
+
for (; ; ) {
|
|
8100
|
+
const pkg = JSON.parse(readFileSync(join5(dir, "package.json"), "utf-8"));
|
|
8101
|
+
if (pkg?.name === "pai-acp" || pkg?.name === "billion-context-pi") {
|
|
8102
|
+
return pkg.name;
|
|
8103
|
+
}
|
|
8104
|
+
const parent = dirname3(dir);
|
|
8105
|
+
if (parent === dir) break;
|
|
8106
|
+
dir = parent;
|
|
8107
|
+
}
|
|
8108
|
+
} catch {
|
|
8109
|
+
}
|
|
8110
|
+
return "pai-acp";
|
|
8111
|
+
}
|
|
8093
8112
|
function makeCommands(runtime) {
|
|
8094
8113
|
return [
|
|
8095
8114
|
{
|
|
@@ -8184,7 +8203,7 @@ async function statusReport(runtime, ctx) {
|
|
|
8184
8203
|
const activeBlocksList = state.blocks.filter((b) => b.active);
|
|
8185
8204
|
const totalBlocksList = state.blocks;
|
|
8186
8205
|
const lines = [];
|
|
8187
|
-
const versionStr = "0.0.
|
|
8206
|
+
const versionStr = "0.0.4" ? `${getDisplayName()}@${"0.0.4"}` : "";
|
|
8188
8207
|
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
8208
|
lines.push("\u2502 ACP Context Analysis \u2502");
|
|
8190
8209
|
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");
|
|
@@ -8328,8 +8347,8 @@ When a background delegate finishes, an automated completion notification is inj
|
|
|
8328
8347
|
|
|
8329
8348
|
// src/update.ts
|
|
8330
8349
|
import { readFile, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
8331
|
-
import { join as
|
|
8332
|
-
import { fileURLToPath } from "url";
|
|
8350
|
+
import { join as join6, dirname as dirname4 } from "path";
|
|
8351
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8333
8352
|
import { execFile } from "child_process";
|
|
8334
8353
|
var LEGACY_NAME = "pai-acp";
|
|
8335
8354
|
var REGISTRY_BASE = "https://registry.npmjs.org";
|
|
@@ -8345,7 +8364,7 @@ async function getPackageName() {
|
|
|
8345
8364
|
if (cachedPackageName !== void 0) return cachedPackageName;
|
|
8346
8365
|
const dir = await findExtensionDir();
|
|
8347
8366
|
if (!dir) return void 0;
|
|
8348
|
-
const pkg = await readPackageJson(
|
|
8367
|
+
const pkg = await readPackageJson(join6(dir, "package.json"));
|
|
8349
8368
|
cachedPackageName = pkg?.name;
|
|
8350
8369
|
return cachedPackageName;
|
|
8351
8370
|
}
|
|
@@ -8371,7 +8390,7 @@ async function readLastCheck(name) {
|
|
|
8371
8390
|
}
|
|
8372
8391
|
async function writeLastCheck(name, timestamp) {
|
|
8373
8392
|
try {
|
|
8374
|
-
await mkdir3(
|
|
8393
|
+
await mkdir3(dirname4(throttleFilePath(name)), { recursive: true });
|
|
8375
8394
|
await writeFile3(throttleFilePath(name), String(timestamp), "utf-8");
|
|
8376
8395
|
} catch {
|
|
8377
8396
|
}
|
|
@@ -8385,19 +8404,19 @@ async function readPackageJson(path4) {
|
|
|
8385
8404
|
}
|
|
8386
8405
|
}
|
|
8387
8406
|
function findNpmRoot(extDir) {
|
|
8388
|
-
let dir =
|
|
8407
|
+
let dir = dirname4(extDir);
|
|
8389
8408
|
while (dir !== "/" && dir !== ".") {
|
|
8390
|
-
if (dir.endsWith("node_modules")) return
|
|
8391
|
-
dir =
|
|
8409
|
+
if (dir.endsWith("node_modules")) return dirname4(dir);
|
|
8410
|
+
dir = dirname4(dir);
|
|
8392
8411
|
}
|
|
8393
8412
|
return void 0;
|
|
8394
8413
|
}
|
|
8395
8414
|
async function findExtensionDir() {
|
|
8396
|
-
let dir =
|
|
8415
|
+
let dir = dirname4(fileURLToPath2(import.meta.url));
|
|
8397
8416
|
for (; ; ) {
|
|
8398
|
-
const pkg = await readPackageJson(
|
|
8417
|
+
const pkg = await readPackageJson(join6(dir, "package.json"));
|
|
8399
8418
|
if (pkg?.name === LEGACY_NAME || pkg?.name === "billion-context-pi") return dir;
|
|
8400
|
-
const parent =
|
|
8419
|
+
const parent = dirname4(dir);
|
|
8401
8420
|
if (parent === dir) return void 0;
|
|
8402
8421
|
dir = parent;
|
|
8403
8422
|
}
|
|
@@ -8447,7 +8466,7 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8447
8466
|
const data = await res.json();
|
|
8448
8467
|
const latest = data.version;
|
|
8449
8468
|
if (!latest) return;
|
|
8450
|
-
const current = runtimeVersion ?? "0.0.
|
|
8469
|
+
const current = runtimeVersion ?? "0.0.4";
|
|
8451
8470
|
debug.event("update-check", {
|
|
8452
8471
|
current,
|
|
8453
8472
|
latest,
|
|
@@ -8473,37 +8492,37 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8473
8492
|
async function getRuntimeVersion() {
|
|
8474
8493
|
const extDir = await findExtensionDir();
|
|
8475
8494
|
if (!extDir) return void 0;
|
|
8476
|
-
const pkg = await readPackageJson(
|
|
8495
|
+
const pkg = await readPackageJson(join6(extDir, "package.json"));
|
|
8477
8496
|
return pkg?.version;
|
|
8478
8497
|
}
|
|
8479
8498
|
|
|
8480
8499
|
// src/rename-notice.ts
|
|
8481
|
-
import { readFileSync, existsSync } from "fs";
|
|
8482
|
-
import { join as
|
|
8483
|
-
import { fileURLToPath as
|
|
8500
|
+
import { readFileSync as readFileSync2, existsSync } from "fs";
|
|
8501
|
+
import { join as join7, dirname as dirname5 } from "path";
|
|
8502
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8484
8503
|
import { execFile as execFile2 } from "child_process";
|
|
8485
8504
|
var LEGACY_NAME2 = "pai-acp";
|
|
8486
8505
|
var NEW_NAME = "billion-context-pi";
|
|
8487
8506
|
var NEW_REF = `npm:${NEW_NAME}`;
|
|
8488
8507
|
var REGISTRY_URL = `https://registry.npmjs.org/${NEW_NAME}/latest`;
|
|
8489
8508
|
function findExtensionDirSync() {
|
|
8490
|
-
let dir =
|
|
8509
|
+
let dir = dirname5(fileURLToPath3(import.meta.url));
|
|
8491
8510
|
for (; ; ) {
|
|
8492
8511
|
try {
|
|
8493
|
-
const data = JSON.parse(
|
|
8512
|
+
const data = JSON.parse(readFileSync2(join7(dir, "package.json"), "utf-8"));
|
|
8494
8513
|
if (data?.name === LEGACY_NAME2 || data?.name === NEW_NAME) return dir;
|
|
8495
8514
|
} catch {
|
|
8496
8515
|
}
|
|
8497
|
-
const parent =
|
|
8516
|
+
const parent = dirname5(dir);
|
|
8498
8517
|
if (parent === dir) return void 0;
|
|
8499
8518
|
dir = parent;
|
|
8500
8519
|
}
|
|
8501
8520
|
}
|
|
8502
8521
|
function findNpmRootSync(extDir) {
|
|
8503
|
-
let dir =
|
|
8522
|
+
let dir = dirname5(extDir);
|
|
8504
8523
|
for (; ; ) {
|
|
8505
|
-
if (dir.endsWith("node_modules")) return
|
|
8506
|
-
const parent =
|
|
8524
|
+
if (dir.endsWith("node_modules")) return dirname5(dir);
|
|
8525
|
+
const parent = dirname5(dir);
|
|
8507
8526
|
if (parent === dir) return void 0;
|
|
8508
8527
|
dir = parent;
|
|
8509
8528
|
}
|
|
@@ -8512,7 +8531,7 @@ function isLegacyPackage() {
|
|
|
8512
8531
|
const dir = findExtensionDirSync();
|
|
8513
8532
|
if (!dir) return false;
|
|
8514
8533
|
try {
|
|
8515
|
-
const data = JSON.parse(
|
|
8534
|
+
const data = JSON.parse(readFileSync2(join7(dir, "package.json"), "utf-8"));
|
|
8516
8535
|
return data?.name === LEGACY_NAME2;
|
|
8517
8536
|
} catch {
|
|
8518
8537
|
return false;
|
|
@@ -8525,9 +8544,9 @@ function isNewPackageInstalled() {
|
|
|
8525
8544
|
if (!npmDir) return false;
|
|
8526
8545
|
try {
|
|
8527
8546
|
const data = JSON.parse(
|
|
8528
|
-
|
|
8547
|
+
readFileSync2(join7(npmDir, "node_modules", NEW_NAME, "package.json"), "utf-8")
|
|
8529
8548
|
);
|
|
8530
|
-
return data?.name === NEW_NAME && existsSync(
|
|
8549
|
+
return data?.name === NEW_NAME && existsSync(join7(npmDir, "node_modules", NEW_NAME, "dist", "index.js"));
|
|
8531
8550
|
} catch {
|
|
8532
8551
|
return false;
|
|
8533
8552
|
}
|
|
@@ -8627,7 +8646,7 @@ async function checkRename(notify) {
|
|
|
8627
8646
|
import { readFile as readFile2, writeFile as writeFile4, stat, copyFile, rename } from "fs/promises";
|
|
8628
8647
|
import { existsSync as existsSync2 } from "fs";
|
|
8629
8648
|
import { homedir } from "os";
|
|
8630
|
-
import { join as
|
|
8649
|
+
import { join as join8 } from "path";
|
|
8631
8650
|
var ACP_TOOLS = ["compress", "decompress", "search_context", "acp_status"];
|
|
8632
8651
|
var BUILTIN_DEFAULT_TOOLS = {
|
|
8633
8652
|
advisor: ["read", "grep", "find", "ls", "bash", "intercom"],
|
|
@@ -8643,8 +8662,8 @@ var BUILTIN_DEFAULT_TOOLS = {
|
|
|
8643
8662
|
function resolveAgentDir() {
|
|
8644
8663
|
const configured = process.env.PI_CODING_AGENT_DIR;
|
|
8645
8664
|
if (configured === "~") return homedir();
|
|
8646
|
-
if (configured?.startsWith("~/")) return
|
|
8647
|
-
return configured ||
|
|
8665
|
+
if (configured?.startsWith("~/")) return join8(homedir(), configured.slice(2));
|
|
8666
|
+
return configured || join8(homedir(), ".pi", "agent");
|
|
8648
8667
|
}
|
|
8649
8668
|
function desiredTools(existing, name) {
|
|
8650
8669
|
const base = Array.isArray(existing?.tools) && existing.tools.length > 0 ? [...existing.tools] : [...BUILTIN_DEFAULT_TOOLS[name] ?? []];
|
|
@@ -8654,7 +8673,7 @@ function desiredTools(existing, name) {
|
|
|
8654
8673
|
return { tools: base, changed: true };
|
|
8655
8674
|
}
|
|
8656
8675
|
async function ensureSubagentAcpTools(settingsPath) {
|
|
8657
|
-
const path4 = settingsPath ??
|
|
8676
|
+
const path4 = settingsPath ?? join8(resolveAgentDir(), "settings.json");
|
|
8658
8677
|
let raw;
|
|
8659
8678
|
let mtimeMs;
|
|
8660
8679
|
try {
|
|
@@ -8755,8 +8774,8 @@ import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
|
8755
8774
|
async function loadUserConfig(cwd) {
|
|
8756
8775
|
const home = process.env.HOME ?? "";
|
|
8757
8776
|
const merged = {};
|
|
8758
|
-
for (const base of [
|
|
8759
|
-
const file =
|
|
8777
|
+
for (const base of [join10(home, CONFIG_DIR_NAME), join10(cwd, CONFIG_DIR_NAME)]) {
|
|
8778
|
+
const file = join10(base, "acp.json");
|
|
8760
8779
|
try {
|
|
8761
8780
|
const raw = await fs3.readFile(file, "utf8");
|
|
8762
8781
|
const parsed = JSON.parse(raw);
|
|
@@ -8769,7 +8788,7 @@ async function loadUserConfig(cwd) {
|
|
|
8769
8788
|
}
|
|
8770
8789
|
return merged;
|
|
8771
8790
|
}
|
|
8772
|
-
function
|
|
8791
|
+
function join10(...parts) {
|
|
8773
8792
|
return path3.join(...parts);
|
|
8774
8793
|
}
|
|
8775
8794
|
var KNOWN = /* @__PURE__ */ new Set(["debug", "autoUpdate", "modelContextLimit", "delegate"]);
|