billion-context-pi 0.0.4 → 0.0.6
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 +1 -1
- package/dist/index.js +47 -236
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/rename-notice.d.ts +0 -14
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
|
|
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
|
@@ -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);
|
|
@@ -7532,7 +7533,7 @@ import { tmpdir as tmpdir2 } from "os";
|
|
|
7532
7533
|
import { join as join4 } from "path";
|
|
7533
7534
|
|
|
7534
7535
|
// src/fleet-widget.ts
|
|
7535
|
-
var DELEGATE_WIDGET_KEY = "
|
|
7536
|
+
var DELEGATE_WIDGET_KEY = "billion-context-pi-delegates";
|
|
7536
7537
|
var REFRESH_MS = 500;
|
|
7537
7538
|
var MAX_TASK_LEN = 48;
|
|
7538
7539
|
var ui;
|
|
@@ -8090,25 +8091,6 @@ function truncate2(s, n) {
|
|
|
8090
8091
|
}
|
|
8091
8092
|
|
|
8092
8093
|
// 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
|
-
}
|
|
8112
8094
|
function makeCommands(runtime) {
|
|
8113
8095
|
return [
|
|
8114
8096
|
{
|
|
@@ -8203,7 +8185,7 @@ async function statusReport(runtime, ctx) {
|
|
|
8203
8185
|
const activeBlocksList = state.blocks.filter((b) => b.active);
|
|
8204
8186
|
const totalBlocksList = state.blocks;
|
|
8205
8187
|
const lines = [];
|
|
8206
|
-
const versionStr = "0.0.
|
|
8188
|
+
const versionStr = "0.0.6" ? `billion-context-pi@${"0.0.6"}` : "";
|
|
8207
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");
|
|
8208
8190
|
lines.push("\u2502 ACP Context Analysis \u2502");
|
|
8209
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");
|
|
@@ -8347,27 +8329,16 @@ When a background delegate finishes, an automated completion notification is inj
|
|
|
8347
8329
|
|
|
8348
8330
|
// src/update.ts
|
|
8349
8331
|
import { readFile, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
8350
|
-
import { join as
|
|
8351
|
-
import { fileURLToPath
|
|
8332
|
+
import { join as join5, dirname as dirname3 } from "path";
|
|
8333
|
+
import { fileURLToPath } from "url";
|
|
8352
8334
|
import { execFile } from "child_process";
|
|
8353
|
-
|
|
8354
|
-
var
|
|
8335
|
+
import { homedir as homedir3 } from "os";
|
|
8336
|
+
var PACKAGE_NAME = "billion-context-pi";
|
|
8337
|
+
var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
8355
8338
|
var SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/;
|
|
8356
8339
|
var CHECK_INTERVAL_MS = 3 * 60 * 1e3;
|
|
8357
|
-
|
|
8358
|
-
return `${process.env.HOME ?? ""}/.pi/agent/.${name}-update-check`;
|
|
8359
|
-
}
|
|
8360
|
-
var THROTTLE_FILE = `${process.env.HOME ?? ""}/.pi/agent/.pai-acp-update-check`;
|
|
8340
|
+
var THROTTLE_FILE = join5(homedir3(), ".pi", "agent", ".billion-context-pi-update-check");
|
|
8361
8341
|
var updateInFlight = false;
|
|
8362
|
-
var cachedPackageName;
|
|
8363
|
-
async function getPackageName() {
|
|
8364
|
-
if (cachedPackageName !== void 0) return cachedPackageName;
|
|
8365
|
-
const dir = await findExtensionDir();
|
|
8366
|
-
if (!dir) return void 0;
|
|
8367
|
-
const pkg = await readPackageJson(join6(dir, "package.json"));
|
|
8368
|
-
cachedPackageName = pkg?.name;
|
|
8369
|
-
return cachedPackageName;
|
|
8370
|
-
}
|
|
8371
8342
|
function parseVersion(v) {
|
|
8372
8343
|
return v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
|
|
8373
8344
|
}
|
|
@@ -8380,18 +8351,18 @@ function isNewer(latest, current) {
|
|
|
8380
8351
|
}
|
|
8381
8352
|
return false;
|
|
8382
8353
|
}
|
|
8383
|
-
async function readLastCheck(
|
|
8354
|
+
async function readLastCheck() {
|
|
8384
8355
|
try {
|
|
8385
|
-
const data = await readFile(
|
|
8356
|
+
const data = await readFile(THROTTLE_FILE, "utf-8");
|
|
8386
8357
|
return parseInt(data.trim(), 10) || 0;
|
|
8387
8358
|
} catch {
|
|
8388
8359
|
return 0;
|
|
8389
8360
|
}
|
|
8390
8361
|
}
|
|
8391
|
-
async function writeLastCheck(
|
|
8362
|
+
async function writeLastCheck(timestamp) {
|
|
8392
8363
|
try {
|
|
8393
|
-
await mkdir3(
|
|
8394
|
-
await writeFile3(
|
|
8364
|
+
await mkdir3(dirname3(THROTTLE_FILE), { recursive: true });
|
|
8365
|
+
await writeFile3(THROTTLE_FILE, String(timestamp), "utf-8");
|
|
8395
8366
|
} catch {
|
|
8396
8367
|
}
|
|
8397
8368
|
}
|
|
@@ -8404,19 +8375,19 @@ async function readPackageJson(path4) {
|
|
|
8404
8375
|
}
|
|
8405
8376
|
}
|
|
8406
8377
|
function findNpmRoot(extDir) {
|
|
8407
|
-
let dir =
|
|
8378
|
+
let dir = dirname3(extDir);
|
|
8408
8379
|
while (dir !== "/" && dir !== ".") {
|
|
8409
|
-
if (dir.endsWith("node_modules")) return
|
|
8410
|
-
dir =
|
|
8380
|
+
if (dir.endsWith("node_modules")) return dirname3(dir);
|
|
8381
|
+
dir = dirname3(dir);
|
|
8411
8382
|
}
|
|
8412
8383
|
return void 0;
|
|
8413
8384
|
}
|
|
8414
8385
|
async function findExtensionDir() {
|
|
8415
|
-
let dir =
|
|
8386
|
+
let dir = dirname3(fileURLToPath(import.meta.url));
|
|
8416
8387
|
for (; ; ) {
|
|
8417
|
-
const pkg = await readPackageJson(
|
|
8418
|
-
if (pkg?.name ===
|
|
8419
|
-
const parent =
|
|
8388
|
+
const pkg = await readPackageJson(join5(dir, "package.json"));
|
|
8389
|
+
if (pkg?.name === PACKAGE_NAME) return dir;
|
|
8390
|
+
const parent = dirname3(dir);
|
|
8420
8391
|
if (parent === dir) return void 0;
|
|
8421
8392
|
dir = parent;
|
|
8422
8393
|
}
|
|
@@ -8428,12 +8399,10 @@ async function autoInstallLatest(latest) {
|
|
|
8428
8399
|
const npmDir = findNpmRoot(extDir);
|
|
8429
8400
|
if (!npmDir) return false;
|
|
8430
8401
|
try {
|
|
8431
|
-
const packageName = await getPackageName();
|
|
8432
|
-
if (!packageName) return false;
|
|
8433
8402
|
const code = await new Promise((resolve2) => {
|
|
8434
8403
|
execFile(
|
|
8435
8404
|
"npm",
|
|
8436
|
-
["install", `${
|
|
8405
|
+
["install", `${PACKAGE_NAME}@${latest}`, "--silent", "--no-audit", "--no-fund"],
|
|
8437
8406
|
{ cwd: npmDir, timeout: 6e4, shell: process.platform === "win32" },
|
|
8438
8407
|
(err) => resolve2(err ? 1 : 0)
|
|
8439
8408
|
);
|
|
@@ -8451,14 +8420,12 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8451
8420
|
if (updateInFlight) return;
|
|
8452
8421
|
updateInFlight = true;
|
|
8453
8422
|
try {
|
|
8454
|
-
const packageName = await getPackageName();
|
|
8455
|
-
if (!packageName) return;
|
|
8456
8423
|
const now = Date.now();
|
|
8457
|
-
const lastCheck = await readLastCheck(
|
|
8424
|
+
const lastCheck = await readLastCheck();
|
|
8458
8425
|
if (now - lastCheck < CHECK_INTERVAL_MS) return;
|
|
8459
|
-
await writeLastCheck(
|
|
8426
|
+
await writeLastCheck(now);
|
|
8460
8427
|
const runtimeVersion = await getRuntimeVersion();
|
|
8461
|
-
const res = await fetch(
|
|
8428
|
+
const res = await fetch(REGISTRY_URL, {
|
|
8462
8429
|
signal: AbortSignal.timeout(5e3),
|
|
8463
8430
|
headers: { Accept: "application/json" }
|
|
8464
8431
|
});
|
|
@@ -8466,7 +8433,7 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8466
8433
|
const data = await res.json();
|
|
8467
8434
|
const latest = data.version;
|
|
8468
8435
|
if (!latest) return;
|
|
8469
|
-
const current = runtimeVersion ?? "0.0.
|
|
8436
|
+
const current = runtimeVersion ?? "0.0.6";
|
|
8470
8437
|
debug.event("update-check", {
|
|
8471
8438
|
current,
|
|
8472
8439
|
latest,
|
|
@@ -8480,7 +8447,7 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8480
8447
|
);
|
|
8481
8448
|
} else if (!installed && notify) {
|
|
8482
8449
|
notify(
|
|
8483
|
-
`${
|
|
8450
|
+
`${PACKAGE_NAME} ${latest} available (you have ${current}). Run: pi update --extension npm:${PACKAGE_NAME}`
|
|
8484
8451
|
);
|
|
8485
8452
|
}
|
|
8486
8453
|
}
|
|
@@ -8492,161 +8459,15 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
8492
8459
|
async function getRuntimeVersion() {
|
|
8493
8460
|
const extDir = await findExtensionDir();
|
|
8494
8461
|
if (!extDir) return void 0;
|
|
8495
|
-
const pkg = await readPackageJson(
|
|
8462
|
+
const pkg = await readPackageJson(join5(extDir, "package.json"));
|
|
8496
8463
|
return pkg?.version;
|
|
8497
8464
|
}
|
|
8498
8465
|
|
|
8499
|
-
// src/rename-notice.ts
|
|
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";
|
|
8503
|
-
import { execFile as execFile2 } from "child_process";
|
|
8504
|
-
var LEGACY_NAME2 = "pai-acp";
|
|
8505
|
-
var NEW_NAME = "billion-context-pi";
|
|
8506
|
-
var NEW_REF = `npm:${NEW_NAME}`;
|
|
8507
|
-
var REGISTRY_URL = `https://registry.npmjs.org/${NEW_NAME}/latest`;
|
|
8508
|
-
function findExtensionDirSync() {
|
|
8509
|
-
let dir = dirname5(fileURLToPath3(import.meta.url));
|
|
8510
|
-
for (; ; ) {
|
|
8511
|
-
try {
|
|
8512
|
-
const data = JSON.parse(readFileSync2(join7(dir, "package.json"), "utf-8"));
|
|
8513
|
-
if (data?.name === LEGACY_NAME2 || data?.name === NEW_NAME) return dir;
|
|
8514
|
-
} catch {
|
|
8515
|
-
}
|
|
8516
|
-
const parent = dirname5(dir);
|
|
8517
|
-
if (parent === dir) return void 0;
|
|
8518
|
-
dir = parent;
|
|
8519
|
-
}
|
|
8520
|
-
}
|
|
8521
|
-
function findNpmRootSync(extDir) {
|
|
8522
|
-
let dir = dirname5(extDir);
|
|
8523
|
-
for (; ; ) {
|
|
8524
|
-
if (dir.endsWith("node_modules")) return dirname5(dir);
|
|
8525
|
-
const parent = dirname5(dir);
|
|
8526
|
-
if (parent === dir) return void 0;
|
|
8527
|
-
dir = parent;
|
|
8528
|
-
}
|
|
8529
|
-
}
|
|
8530
|
-
function isLegacyPackage() {
|
|
8531
|
-
const dir = findExtensionDirSync();
|
|
8532
|
-
if (!dir) return false;
|
|
8533
|
-
try {
|
|
8534
|
-
const data = JSON.parse(readFileSync2(join7(dir, "package.json"), "utf-8"));
|
|
8535
|
-
return data?.name === LEGACY_NAME2;
|
|
8536
|
-
} catch {
|
|
8537
|
-
return false;
|
|
8538
|
-
}
|
|
8539
|
-
}
|
|
8540
|
-
function isNewPackageInstalled() {
|
|
8541
|
-
const extDir = findExtensionDirSync();
|
|
8542
|
-
if (!extDir) return false;
|
|
8543
|
-
const npmDir = findNpmRootSync(extDir);
|
|
8544
|
-
if (!npmDir) return false;
|
|
8545
|
-
try {
|
|
8546
|
-
const data = JSON.parse(
|
|
8547
|
-
readFileSync2(join7(npmDir, "node_modules", NEW_NAME, "package.json"), "utf-8")
|
|
8548
|
-
);
|
|
8549
|
-
return data?.name === NEW_NAME && existsSync(join7(npmDir, "node_modules", NEW_NAME, "dist", "index.js"));
|
|
8550
|
-
} catch {
|
|
8551
|
-
return false;
|
|
8552
|
-
}
|
|
8553
|
-
}
|
|
8554
|
-
async function newPackageReady() {
|
|
8555
|
-
try {
|
|
8556
|
-
const res = await fetch(REGISTRY_URL, {
|
|
8557
|
-
signal: AbortSignal.timeout(5e3),
|
|
8558
|
-
headers: { Accept: "application/json" }
|
|
8559
|
-
});
|
|
8560
|
-
if (!res.ok) return false;
|
|
8561
|
-
const data = await res.json();
|
|
8562
|
-
const v = (data.version ?? "0.0.0").split(".").map((n) => parseInt(n, 10) || 0);
|
|
8563
|
-
return (v[0] ?? 0) > 0 || (v[1] ?? 0) > 0 || (v[2] ?? 0) > 1;
|
|
8564
|
-
} catch {
|
|
8565
|
-
return false;
|
|
8566
|
-
}
|
|
8567
|
-
}
|
|
8568
|
-
function runPi(args) {
|
|
8569
|
-
const cliEntry = process.argv[1];
|
|
8570
|
-
if (!cliEntry || !existsSync(cliEntry)) return Promise.resolve(1);
|
|
8571
|
-
return new Promise((resolve2) => {
|
|
8572
|
-
const child = execFile2(
|
|
8573
|
-
process.execPath,
|
|
8574
|
-
[cliEntry, ...args],
|
|
8575
|
-
{ timeout: 12e4, shell: process.platform === "win32" },
|
|
8576
|
-
(err) => resolve2(err ? 1 : 0)
|
|
8577
|
-
);
|
|
8578
|
-
child.stdin?.end();
|
|
8579
|
-
});
|
|
8580
|
-
}
|
|
8581
|
-
var GREEN = "\x1B[32m";
|
|
8582
|
-
var CYAN = "\x1B[36m";
|
|
8583
|
-
var RESET = "\x1B[0m";
|
|
8584
|
-
function manualNotice() {
|
|
8585
|
-
const body = [
|
|
8586
|
-
"\u2192 pai-acp has been renamed to billion-context-pi",
|
|
8587
|
-
"Your context tools are unchanged \u2014 same package, new name.",
|
|
8588
|
-
"Once billion-context-pi is published, it will install automatically.",
|
|
8589
|
-
"Your ~/.pi/acp.json config carries over."
|
|
8590
|
-
].join("\n");
|
|
8591
|
-
return `${CYAN}${body}${RESET}`;
|
|
8592
|
-
}
|
|
8593
|
-
function installingNotice() {
|
|
8594
|
-
return `${CYAN}Installing billion-context-pi\u2026${RESET}`;
|
|
8595
|
-
}
|
|
8596
|
-
function successNotice() {
|
|
8597
|
-
const body = [
|
|
8598
|
-
"\u2714 pai-acp \u2192 billion-context-pi (renamed, same tools).",
|
|
8599
|
-
"billion-context-pi has been installed. Restart Pi to switch over.",
|
|
8600
|
-
"Do NOT uninstall billion-context-pi \u2014 it is the replacement for pai-acp."
|
|
8601
|
-
].join("\n");
|
|
8602
|
-
return `${GREEN}${body}${RESET}`;
|
|
8603
|
-
}
|
|
8604
|
-
function canUninstallNotice() {
|
|
8605
|
-
const body = [
|
|
8606
|
-
"\u2714 You are now running billion-context-pi (formerly pai-acp).",
|
|
8607
|
-
"All your context tools (compress / decompress / search / delegate) are intact.",
|
|
8608
|
-
"pai-acp is now inert and safe to remove: pi uninstall pai-acp"
|
|
8609
|
-
].join("\n");
|
|
8610
|
-
return `${GREEN}${body}${RESET}`;
|
|
8611
|
-
}
|
|
8612
|
-
async function installNewPackage() {
|
|
8613
|
-
return await runPi(["install", NEW_REF]) === 0;
|
|
8614
|
-
}
|
|
8615
|
-
var migrateInFlight = false;
|
|
8616
|
-
async function checkRename(notify) {
|
|
8617
|
-
const safeNotify = (msg) => {
|
|
8618
|
-
try {
|
|
8619
|
-
notify(msg);
|
|
8620
|
-
} catch {
|
|
8621
|
-
}
|
|
8622
|
-
};
|
|
8623
|
-
if (migrateInFlight) return;
|
|
8624
|
-
migrateInFlight = true;
|
|
8625
|
-
try {
|
|
8626
|
-
if (isNewPackageInstalled()) {
|
|
8627
|
-
safeNotify(canUninstallNotice());
|
|
8628
|
-
return;
|
|
8629
|
-
}
|
|
8630
|
-
const ready = await newPackageReady();
|
|
8631
|
-
if (!ready) {
|
|
8632
|
-
safeNotify(manualNotice());
|
|
8633
|
-
return;
|
|
8634
|
-
}
|
|
8635
|
-
safeNotify(installingNotice());
|
|
8636
|
-
const ok = await installNewPackage();
|
|
8637
|
-
safeNotify(ok ? successNotice() : manualNotice());
|
|
8638
|
-
} catch {
|
|
8639
|
-
safeNotify(manualNotice());
|
|
8640
|
-
} finally {
|
|
8641
|
-
migrateInFlight = false;
|
|
8642
|
-
}
|
|
8643
|
-
}
|
|
8644
|
-
|
|
8645
8466
|
// src/setup-subagent-tools.ts
|
|
8646
8467
|
import { readFile as readFile2, writeFile as writeFile4, stat, copyFile, rename } from "fs/promises";
|
|
8647
|
-
import { existsSync
|
|
8648
|
-
import { homedir } from "os";
|
|
8649
|
-
import { join as
|
|
8468
|
+
import { existsSync } from "fs";
|
|
8469
|
+
import { homedir as homedir4 } from "os";
|
|
8470
|
+
import { join as join6 } from "path";
|
|
8650
8471
|
var ACP_TOOLS = ["compress", "decompress", "search_context", "acp_status"];
|
|
8651
8472
|
var BUILTIN_DEFAULT_TOOLS = {
|
|
8652
8473
|
advisor: ["read", "grep", "find", "ls", "bash", "intercom"],
|
|
@@ -8661,9 +8482,9 @@ var BUILTIN_DEFAULT_TOOLS = {
|
|
|
8661
8482
|
};
|
|
8662
8483
|
function resolveAgentDir() {
|
|
8663
8484
|
const configured = process.env.PI_CODING_AGENT_DIR;
|
|
8664
|
-
if (configured === "~") return
|
|
8665
|
-
if (configured?.startsWith("~/")) return
|
|
8666
|
-
return configured ||
|
|
8485
|
+
if (configured === "~") return homedir4();
|
|
8486
|
+
if (configured?.startsWith("~/")) return join6(homedir4(), configured.slice(2));
|
|
8487
|
+
return configured || join6(homedir4(), ".pi", "agent");
|
|
8667
8488
|
}
|
|
8668
8489
|
function desiredTools(existing, name) {
|
|
8669
8490
|
const base = Array.isArray(existing?.tools) && existing.tools.length > 0 ? [...existing.tools] : [...BUILTIN_DEFAULT_TOOLS[name] ?? []];
|
|
@@ -8673,7 +8494,7 @@ function desiredTools(existing, name) {
|
|
|
8673
8494
|
return { tools: base, changed: true };
|
|
8674
8495
|
}
|
|
8675
8496
|
async function ensureSubagentAcpTools(settingsPath) {
|
|
8676
|
-
const path4 = settingsPath ??
|
|
8497
|
+
const path4 = settingsPath ?? join6(resolveAgentDir(), "settings.json");
|
|
8677
8498
|
let raw;
|
|
8678
8499
|
let mtimeMs;
|
|
8679
8500
|
try {
|
|
@@ -8708,7 +8529,7 @@ async function ensureSubagentAcpTools(settingsPath) {
|
|
|
8708
8529
|
return { path: path4, action: "skipped", reason: "all builtin agents already have ACP tools" };
|
|
8709
8530
|
}
|
|
8710
8531
|
const backupPath = `${path4}.acp-bak`;
|
|
8711
|
-
if (!
|
|
8532
|
+
if (!existsSync(backupPath)) {
|
|
8712
8533
|
try {
|
|
8713
8534
|
await copyFile(path4, backupPath);
|
|
8714
8535
|
} catch {
|
|
@@ -8770,12 +8591,13 @@ async function runSetupAndNotify(notify) {
|
|
|
8770
8591
|
// src/user-config.ts
|
|
8771
8592
|
import { promises as fs3 } from "fs";
|
|
8772
8593
|
import * as path3 from "path";
|
|
8594
|
+
import { homedir as homedir5 } from "os";
|
|
8773
8595
|
import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
8774
8596
|
async function loadUserConfig(cwd) {
|
|
8775
|
-
const home =
|
|
8597
|
+
const home = homedir5();
|
|
8776
8598
|
const merged = {};
|
|
8777
|
-
for (const base of [
|
|
8778
|
-
const file =
|
|
8599
|
+
for (const base of [join8(home, CONFIG_DIR_NAME), join8(cwd, CONFIG_DIR_NAME)]) {
|
|
8600
|
+
const file = join8(base, "acp.json");
|
|
8779
8601
|
try {
|
|
8780
8602
|
const raw = await fs3.readFile(file, "utf8");
|
|
8781
8603
|
const parsed = JSON.parse(raw);
|
|
@@ -8788,7 +8610,7 @@ async function loadUserConfig(cwd) {
|
|
|
8788
8610
|
}
|
|
8789
8611
|
return merged;
|
|
8790
8612
|
}
|
|
8791
|
-
function
|
|
8613
|
+
function join8(...parts) {
|
|
8792
8614
|
return path3.join(...parts);
|
|
8793
8615
|
}
|
|
8794
8616
|
var KNOWN = /* @__PURE__ */ new Set(["debug", "autoUpdate", "modelContextLimit", "delegate"]);
|
|
@@ -8814,14 +8636,6 @@ function applyUserConfig(adapter, user) {
|
|
|
8814
8636
|
// src/index.ts
|
|
8815
8637
|
function createAcpExtension(adapter = {}) {
|
|
8816
8638
|
return (pi) => {
|
|
8817
|
-
if (isLegacyPackage() && isNewPackageInstalled()) {
|
|
8818
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
8819
|
-
if (ctx.hasUI) {
|
|
8820
|
-
checkRename((m) => ctx.ui.notify(m));
|
|
8821
|
-
}
|
|
8822
|
-
});
|
|
8823
|
-
return;
|
|
8824
|
-
}
|
|
8825
8639
|
const runtime = createRuntime(adapter);
|
|
8826
8640
|
wireCompactionDisable(pi);
|
|
8827
8641
|
wireSessionLifecycle(pi, runtime);
|
|
@@ -8858,9 +8672,6 @@ function wireSessionLifecycle(pi, runtime) {
|
|
|
8858
8672
|
void checkForUpdate(runtime.adapter.autoUpdate ?? true, (msg) => {
|
|
8859
8673
|
if (ctx.hasUI) ctx.ui.notify(msg);
|
|
8860
8674
|
});
|
|
8861
|
-
if (isLegacyPackage() && ctx.hasUI) {
|
|
8862
|
-
void checkRename((msg) => ctx.ui.notify(msg));
|
|
8863
|
-
}
|
|
8864
8675
|
void runSetupAndNotify(ctx.hasUI ? (m) => ctx.ui.notify(m) : void 0);
|
|
8865
8676
|
delegateStatusWidget.setContext(ctx, runningRunsSnapshot);
|
|
8866
8677
|
});
|