@cortexkit/aft-pi 0.35.0 → 0.35.2
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
|
@@ -7709,9 +7709,9 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
7709
7709
|
value
|
|
7710
7710
|
} = comment;
|
|
7711
7711
|
const line_breaks_before = blank_lines > 0 ? blank_lines + (inline ? 0 : 1) : null;
|
|
7712
|
-
const
|
|
7712
|
+
const delimiter2 = line_breaks_before > 0 ? repeat_line_breaks(line_breaks_before, deeper_gap) : inline ? SPACE : i === 0 && symbol_tag === PREFIX_BEFORE_ALL && deeper_gap === EMPTY ? EMPTY : LF + deeper_gap;
|
|
7713
7713
|
const is_line_comment = type === "LineComment";
|
|
7714
|
-
str +=
|
|
7714
|
+
str += delimiter2 + comment_stringify(value, is_line_comment);
|
|
7715
7715
|
blank_lines = 0;
|
|
7716
7716
|
last_comment = comment;
|
|
7717
7717
|
});
|
|
@@ -7728,10 +7728,10 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
7728
7728
|
replacer = null;
|
|
7729
7729
|
indent = EMPTY;
|
|
7730
7730
|
};
|
|
7731
|
-
var
|
|
7731
|
+
var join9 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two)), gap) : EMPTY;
|
|
7732
7732
|
var join_content = (inside, value, gap) => {
|
|
7733
7733
|
const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
|
|
7734
|
-
return
|
|
7734
|
+
return join9(comment, inside, gap);
|
|
7735
7735
|
};
|
|
7736
7736
|
var stringify_string = (holder, key, value) => {
|
|
7737
7737
|
const raw = get_raw_string_literal(holder, key);
|
|
@@ -7753,13 +7753,13 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
7753
7753
|
if (i !== 0) {
|
|
7754
7754
|
inside += COMMA;
|
|
7755
7755
|
}
|
|
7756
|
-
const before =
|
|
7756
|
+
const before = join9(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
|
|
7757
7757
|
inside += before || LF + deeper_gap;
|
|
7758
7758
|
inside += stringify(i, value, deeper_gap) || STR_NULL;
|
|
7759
7759
|
inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
|
|
7760
7760
|
after_comma = process_comments(value, AFTER(i), deeper_gap);
|
|
7761
7761
|
}
|
|
7762
|
-
inside +=
|
|
7762
|
+
inside += join9(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
|
|
7763
7763
|
return BRACKET_OPEN + join_content(inside, value, gap) + BRACKET_CLOSE;
|
|
7764
7764
|
};
|
|
7765
7765
|
var object_stringify = (value, gap) => {
|
|
@@ -7780,13 +7780,13 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
7780
7780
|
inside += COMMA;
|
|
7781
7781
|
}
|
|
7782
7782
|
first = false;
|
|
7783
|
-
const before =
|
|
7783
|
+
const before = join9(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
|
|
7784
7784
|
inside += before || LF + deeper_gap;
|
|
7785
7785
|
inside += quote(key) + process_comments(value, AFTER_PROP(key), deeper_gap) + COLON + process_comments(value, AFTER_COLON(key), deeper_gap) + SPACE + sv + process_comments(value, AFTER_VALUE(key), deeper_gap);
|
|
7786
7786
|
after_comma = process_comments(value, AFTER(key), deeper_gap);
|
|
7787
7787
|
};
|
|
7788
7788
|
keys.forEach(iteratee);
|
|
7789
|
-
inside +=
|
|
7789
|
+
inside += join9(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
|
|
7790
7790
|
return CURLY_BRACKET_OPEN + join_content(inside, value, gap) + CURLY_BRACKET_CLOSE;
|
|
7791
7791
|
};
|
|
7792
7792
|
function stringify(key, holder, gap) {
|
|
@@ -12816,6 +12816,35 @@ async function fetchLatestTag() {
|
|
|
12816
12816
|
clearTimeout(timeout);
|
|
12817
12817
|
}
|
|
12818
12818
|
}
|
|
12819
|
+
// ../aft-bridge/dist/edit-summary.js
|
|
12820
|
+
function formatEditSummary(data) {
|
|
12821
|
+
if (data.rolled_back === true) {
|
|
12822
|
+
return "Edit rolled back: the change produced invalid syntax, so the file was left unchanged.";
|
|
12823
|
+
}
|
|
12824
|
+
if (typeof data.files_modified === "number") {
|
|
12825
|
+
const n = data.files_modified;
|
|
12826
|
+
return `Applied edits to ${n} file${n === 1 ? "" : "s"}.`;
|
|
12827
|
+
}
|
|
12828
|
+
const additions = data.diff?.additions ?? 0;
|
|
12829
|
+
const deletions = data.diff?.deletions ?? 0;
|
|
12830
|
+
const counts = `+${additions}/-${deletions}`;
|
|
12831
|
+
if (data.created === true) {
|
|
12832
|
+
let s2 = `Created file (${counts}).`;
|
|
12833
|
+
if (data.formatted)
|
|
12834
|
+
s2 += " Auto-formatted.";
|
|
12835
|
+
return s2;
|
|
12836
|
+
}
|
|
12837
|
+
let detail = counts;
|
|
12838
|
+
if (typeof data.edits_applied === "number" && data.edits_applied > 1) {
|
|
12839
|
+
detail = `${counts}, ${data.edits_applied} edits`;
|
|
12840
|
+
} else if (typeof data.replacements === "number" && data.replacements > 1) {
|
|
12841
|
+
detail = `${counts}, ${data.replacements} replacements`;
|
|
12842
|
+
}
|
|
12843
|
+
let s = `Edited (${detail}).`;
|
|
12844
|
+
if (data.formatted)
|
|
12845
|
+
s += " Auto-formatted.";
|
|
12846
|
+
return s;
|
|
12847
|
+
}
|
|
12819
12848
|
// ../aft-bridge/dist/format.js
|
|
12820
12849
|
function compressionSavingsPercent(original, compressed) {
|
|
12821
12850
|
if (original <= 0)
|
|
@@ -12823,6 +12852,20 @@ function compressionSavingsPercent(original, compressed) {
|
|
|
12823
12852
|
const saved = Math.max(0, original - compressed);
|
|
12824
12853
|
return Math.round(saved / original * 100);
|
|
12825
12854
|
}
|
|
12855
|
+
// ../aft-bridge/dist/jsonc.js
|
|
12856
|
+
function stripJsoncSymbols(value) {
|
|
12857
|
+
if (Array.isArray(value)) {
|
|
12858
|
+
return value.map((item) => stripJsoncSymbols(item));
|
|
12859
|
+
}
|
|
12860
|
+
if (value !== null && typeof value === "object") {
|
|
12861
|
+
const out = {};
|
|
12862
|
+
for (const [key, val] of Object.entries(value)) {
|
|
12863
|
+
out[key] = stripJsoncSymbols(val);
|
|
12864
|
+
}
|
|
12865
|
+
return out;
|
|
12866
|
+
}
|
|
12867
|
+
return value;
|
|
12868
|
+
}
|
|
12826
12869
|
// ../aft-bridge/dist/migration.js
|
|
12827
12870
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
12828
12871
|
import { existsSync as existsSync4, mkdirSync as mkdirSync4 } from "node:fs";
|
|
@@ -12881,7 +12924,7 @@ function markAnnouncementSeen(storageRoot, harness, currentVersion) {
|
|
|
12881
12924
|
|
|
12882
12925
|
// ../aft-bridge/dist/resolver.js
|
|
12883
12926
|
import { execSync } from "node:child_process";
|
|
12884
|
-
import { chmodSync as chmodSync2, copyFileSync as copyFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync3, renameSync as renameSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
12927
|
+
import { chmodSync as chmodSync2, closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync3, openSync as openSync2, readSync, renameSync as renameSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
12885
12928
|
import { createRequire as createRequire2 } from "node:module";
|
|
12886
12929
|
import { homedir as homedir3 } from "node:os";
|
|
12887
12930
|
import { join as join4 } from "node:path";
|
|
@@ -12962,6 +13005,37 @@ function probeBinaryCandidate(binaryPath, source, expectedVersion) {
|
|
|
12962
13005
|
function parsePathLookupOutput(output) {
|
|
12963
13006
|
return output.split(/\r?\n/).map((candidate) => candidate.trim()).filter(Boolean);
|
|
12964
13007
|
}
|
|
13008
|
+
function isNativeExecutable(binaryPath) {
|
|
13009
|
+
let fd = null;
|
|
13010
|
+
try {
|
|
13011
|
+
fd = openSync2(binaryPath, "r");
|
|
13012
|
+
const buf = Buffer.alloc(4);
|
|
13013
|
+
const read = readSync(fd, buf, 0, 4, 0);
|
|
13014
|
+
if (read < 2)
|
|
13015
|
+
return false;
|
|
13016
|
+
const b0 = buf[0];
|
|
13017
|
+
const b1 = buf[1];
|
|
13018
|
+
if (b0 === 35 && b1 === 33)
|
|
13019
|
+
return false;
|
|
13020
|
+
const m32 = buf.readUInt32BE(0);
|
|
13021
|
+
const machO = new Set([4277009102, 4277009103, 3472551422, 3489328638, 3405691582]);
|
|
13022
|
+
if (read >= 4 && machO.has(m32))
|
|
13023
|
+
return true;
|
|
13024
|
+
if (read >= 4 && m32 === 2135247942)
|
|
13025
|
+
return true;
|
|
13026
|
+
if (b0 === 77 && b1 === 90)
|
|
13027
|
+
return true;
|
|
13028
|
+
return false;
|
|
13029
|
+
} catch {
|
|
13030
|
+
return false;
|
|
13031
|
+
} finally {
|
|
13032
|
+
if (fd !== null) {
|
|
13033
|
+
try {
|
|
13034
|
+
closeSync2(fd);
|
|
13035
|
+
} catch {}
|
|
13036
|
+
}
|
|
13037
|
+
}
|
|
13038
|
+
}
|
|
12965
13039
|
function platformKey(platform = process.platform, arch = process.arch) {
|
|
12966
13040
|
const archMap = PLATFORM_ARCH_MAP[platform];
|
|
12967
13041
|
if (!archMap) {
|
|
@@ -13015,6 +13089,10 @@ function findBinarySync(expectedVersion) {
|
|
|
13015
13089
|
stdio: ["pipe", "pipe", "pipe"]
|
|
13016
13090
|
}).trim();
|
|
13017
13091
|
for (const candidate of parsePathLookupOutput(result)) {
|
|
13092
|
+
if (!isNativeExecutable(candidate)) {
|
|
13093
|
+
warn(`PATH binary at ${candidate} is not a native executable (script shim?); skipping`);
|
|
13094
|
+
continue;
|
|
13095
|
+
}
|
|
13018
13096
|
const usable = probeBinaryCandidate(candidate, "PATH", expectedVersion);
|
|
13019
13097
|
if (usable)
|
|
13020
13098
|
return usable;
|
|
@@ -13161,11 +13239,125 @@ async function ensureStorageMigrated(opts) {
|
|
|
13161
13239
|
const stdoutTail = tail(result.stdout);
|
|
13162
13240
|
throw new Error(`AFT storage migration failed (${detail}). ` + `Harness: ${opts.harness}. Legacy: ${legacyRoot}. Target: ${newRoot}. ` + `See log: ${logPath}. ` + `Plugin load aborted to prevent legacy/new state divergence.` + (stderrTail ? ` Stderr tail: ${stderrTail}` : "") + (stdoutTail ? ` Stdout tail: ${stdoutTail}` : ""));
|
|
13163
13241
|
}
|
|
13242
|
+
// ../aft-bridge/dist/npm-resolver.js
|
|
13243
|
+
import { readdirSync, statSync as statSync2 } from "node:fs";
|
|
13244
|
+
import { homedir as homedir5 } from "node:os";
|
|
13245
|
+
import { delimiter, dirname as dirname3, isAbsolute, join as join6 } from "node:path";
|
|
13246
|
+
function defaultDeps() {
|
|
13247
|
+
return {
|
|
13248
|
+
platform: process.platform,
|
|
13249
|
+
env: process.env,
|
|
13250
|
+
home: homedir5(),
|
|
13251
|
+
execPath: process.execPath
|
|
13252
|
+
};
|
|
13253
|
+
}
|
|
13254
|
+
function npmBinaryName(platform) {
|
|
13255
|
+
return platform === "win32" ? "npm.cmd" : "npm";
|
|
13256
|
+
}
|
|
13257
|
+
function isFile(p) {
|
|
13258
|
+
try {
|
|
13259
|
+
return statSync2(p).isFile();
|
|
13260
|
+
} catch {
|
|
13261
|
+
return false;
|
|
13262
|
+
}
|
|
13263
|
+
}
|
|
13264
|
+
function npmFromPath(deps) {
|
|
13265
|
+
const name = npmBinaryName(deps.platform);
|
|
13266
|
+
const raw = deps.env.PATH ?? deps.env.Path ?? "";
|
|
13267
|
+
for (const entry of raw.split(delimiter)) {
|
|
13268
|
+
const dir = entry.trim().replace(/^"|"$/g, "");
|
|
13269
|
+
if (!dir || !isAbsolute(dir))
|
|
13270
|
+
continue;
|
|
13271
|
+
if (isFile(join6(dir, name)))
|
|
13272
|
+
return dir;
|
|
13273
|
+
}
|
|
13274
|
+
return null;
|
|
13275
|
+
}
|
|
13276
|
+
function npmAdjacentToNode(deps) {
|
|
13277
|
+
const dir = dirname3(deps.execPath);
|
|
13278
|
+
return isFile(join6(dir, npmBinaryName(deps.platform))) ? dir : null;
|
|
13279
|
+
}
|
|
13280
|
+
function highestVersionedNodeBin(installsDir, name) {
|
|
13281
|
+
let entries;
|
|
13282
|
+
try {
|
|
13283
|
+
entries = readdirSync(installsDir);
|
|
13284
|
+
} catch {
|
|
13285
|
+
return null;
|
|
13286
|
+
}
|
|
13287
|
+
const candidates = entries.filter((v) => isFile(join6(installsDir, v, "bin", name))).sort((a, b) => compareVersionsDesc(a, b));
|
|
13288
|
+
return candidates.length > 0 ? join6(installsDir, candidates[0], "bin") : null;
|
|
13289
|
+
}
|
|
13290
|
+
function compareVersionsDesc(a, b) {
|
|
13291
|
+
const pa = a.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
|
|
13292
|
+
const pb = b.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
|
|
13293
|
+
for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
|
|
13294
|
+
const na = Number.isFinite(pa[i]) ? pa[i] : -1;
|
|
13295
|
+
const nb = Number.isFinite(pb[i]) ? pb[i] : -1;
|
|
13296
|
+
if (na !== nb)
|
|
13297
|
+
return nb - na;
|
|
13298
|
+
}
|
|
13299
|
+
return b.localeCompare(a);
|
|
13300
|
+
}
|
|
13301
|
+
function wellKnownNpmDirs(deps) {
|
|
13302
|
+
const { platform, env, home } = deps;
|
|
13303
|
+
const name = npmBinaryName(platform);
|
|
13304
|
+
const dirs = [];
|
|
13305
|
+
const push = (dir) => {
|
|
13306
|
+
if (dir && !dirs.includes(dir))
|
|
13307
|
+
dirs.push(dir);
|
|
13308
|
+
};
|
|
13309
|
+
if (platform === "win32") {
|
|
13310
|
+
const programFiles = env.ProgramFiles || "C:\\Program Files";
|
|
13311
|
+
const appData = env.APPDATA;
|
|
13312
|
+
const localAppData = env.LOCALAPPDATA;
|
|
13313
|
+
push(join6(programFiles, "nodejs"));
|
|
13314
|
+
if (appData)
|
|
13315
|
+
push(join6(appData, "npm"));
|
|
13316
|
+
if (localAppData)
|
|
13317
|
+
push(join6(localAppData, "Volta", "bin"));
|
|
13318
|
+
if (env.NVM_SYMLINK)
|
|
13319
|
+
push(env.NVM_SYMLINK);
|
|
13320
|
+
} else {
|
|
13321
|
+
if (env.NVM_BIN)
|
|
13322
|
+
push(env.NVM_BIN);
|
|
13323
|
+
push(highestVersionedNodeBin(join6(home, ".nvm", "versions", "node"), name));
|
|
13324
|
+
push(highestVersionedNodeBin(join6(home, ".local", "share", "mise", "installs", "node"), name));
|
|
13325
|
+
push(highestVersionedNodeBin(join6(home, ".asdf", "installs", "nodejs"), name));
|
|
13326
|
+
push(join6(home, ".volta", "bin"));
|
|
13327
|
+
push(join6(home, ".asdf", "shims"));
|
|
13328
|
+
const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin", join6(home, ".local", "bin")]);
|
|
13329
|
+
for (const dir of systemDirs)
|
|
13330
|
+
push(dir);
|
|
13331
|
+
}
|
|
13332
|
+
return dirs;
|
|
13333
|
+
}
|
|
13334
|
+
function resolveNpm(deps = defaultDeps()) {
|
|
13335
|
+
const name = npmBinaryName(deps.platform);
|
|
13336
|
+
const onPath = npmFromPath(deps);
|
|
13337
|
+
if (onPath)
|
|
13338
|
+
return { command: join6(onPath, name), binDir: onPath };
|
|
13339
|
+
const adjacent = npmAdjacentToNode(deps);
|
|
13340
|
+
if (adjacent)
|
|
13341
|
+
return { command: join6(adjacent, name), binDir: adjacent };
|
|
13342
|
+
for (const dir of wellKnownNpmDirs(deps)) {
|
|
13343
|
+
const candidate = join6(dir, name);
|
|
13344
|
+
if (isFile(candidate))
|
|
13345
|
+
return { command: candidate, binDir: dir };
|
|
13346
|
+
}
|
|
13347
|
+
return null;
|
|
13348
|
+
}
|
|
13349
|
+
function npmSpawnEnv(resolved, baseEnv = process.env) {
|
|
13350
|
+
if (!resolved.binDir)
|
|
13351
|
+
return { ...baseEnv };
|
|
13352
|
+
const existing = baseEnv.PATH ?? baseEnv.Path ?? "";
|
|
13353
|
+
const next = existing ? `${resolved.binDir}${delimiter}${existing}` : resolved.binDir;
|
|
13354
|
+
return { ...baseEnv, PATH: next };
|
|
13355
|
+
}
|
|
13164
13356
|
// ../aft-bridge/dist/onnx-runtime.js
|
|
13165
13357
|
import { execFileSync } from "node:child_process";
|
|
13166
13358
|
import { createHash as createHash2 } from "node:crypto";
|
|
13167
|
-
import { chmodSync as chmodSync3, closeSync as
|
|
13168
|
-
import { basename, dirname as
|
|
13359
|
+
import { chmodSync as chmodSync3, closeSync as closeSync3, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, openSync as openSync3, readdirSync as readdirSync2, readFileSync as readFileSync3, readlinkSync, realpathSync, rmSync as rmSync2, statSync as statSync3, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13360
|
+
import { basename, dirname as dirname4, isAbsolute as isAbsolute2, join as join7, relative, resolve, win32 } from "node:path";
|
|
13169
13361
|
import { Readable as Readable2 } from "node:stream";
|
|
13170
13362
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
13171
13363
|
var ORT_VERSION = "1.24.4";
|
|
@@ -13228,10 +13420,10 @@ function getManualInstallHint() {
|
|
|
13228
13420
|
}
|
|
13229
13421
|
async function ensureOnnxRuntime(storageDir) {
|
|
13230
13422
|
const info = getPlatformInfo();
|
|
13231
|
-
const ortVersionDir =
|
|
13423
|
+
const ortVersionDir = join7(storageDir, "onnxruntime", ORT_VERSION);
|
|
13232
13424
|
const libName = info?.libName ?? "libonnxruntime.dylib";
|
|
13233
13425
|
const resolvedOrtDir = resolveCachedOnnxRuntimeDir(ortVersionDir, libName);
|
|
13234
|
-
const libPath =
|
|
13426
|
+
const libPath = join7(resolvedOrtDir, libName);
|
|
13235
13427
|
if (existsSync5(libPath)) {
|
|
13236
13428
|
const meta = readOnnxInstalledMeta(ortVersionDir);
|
|
13237
13429
|
if (meta?.sha256) {
|
|
@@ -13261,9 +13453,9 @@ async function ensureOnnxRuntime(storageDir) {
|
|
|
13261
13453
|
warn(`ONNX Runtime auto-download not available for ${process.platform}/${process.arch}. Install manually: ${getManualInstallHint()}`);
|
|
13262
13454
|
return null;
|
|
13263
13455
|
}
|
|
13264
|
-
const onnxBaseDir =
|
|
13456
|
+
const onnxBaseDir = join7(storageDir, "onnxruntime");
|
|
13265
13457
|
mkdirSync5(onnxBaseDir, { recursive: true });
|
|
13266
|
-
const lockPath =
|
|
13458
|
+
const lockPath = join7(onnxBaseDir, ONNX_LOCK_FILE);
|
|
13267
13459
|
cleanupAbandonedStagingDirs(onnxBaseDir);
|
|
13268
13460
|
if (!acquireLock(lockPath)) {
|
|
13269
13461
|
warn(`ONNX Runtime install already in progress in another process (lock: ${lockPath}). Skipping.`);
|
|
@@ -13278,11 +13470,11 @@ async function ensureOnnxRuntime(storageDir) {
|
|
|
13278
13470
|
}
|
|
13279
13471
|
function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
13280
13472
|
try {
|
|
13281
|
-
const entries =
|
|
13473
|
+
const entries = readdirSync2(onnxBaseDir);
|
|
13282
13474
|
for (const entry of entries) {
|
|
13283
13475
|
if (!entry.startsWith(`${ORT_VERSION}.tmp.`))
|
|
13284
13476
|
continue;
|
|
13285
|
-
const stagingDir =
|
|
13477
|
+
const stagingDir = join7(onnxBaseDir, entry);
|
|
13286
13478
|
const parts = entry.split(".");
|
|
13287
13479
|
const pidStr = parts[parts.length - 2];
|
|
13288
13480
|
const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
|
|
@@ -13294,7 +13486,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
13294
13486
|
abandoned = true;
|
|
13295
13487
|
} else {
|
|
13296
13488
|
try {
|
|
13297
|
-
const ageMs = Date.now() -
|
|
13489
|
+
const ageMs = Date.now() - statSync3(stagingDir).mtimeMs;
|
|
13298
13490
|
abandoned = ageMs > STALE_LOCK_MS;
|
|
13299
13491
|
} catch {
|
|
13300
13492
|
abandoned = true;
|
|
@@ -13319,7 +13511,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
13319
13511
|
}
|
|
13320
13512
|
function cleanupIncompleteTargetIfUnowned(ortDir) {
|
|
13321
13513
|
try {
|
|
13322
|
-
if (existsSync5(ortDir) && !existsSync5(
|
|
13514
|
+
if (existsSync5(ortDir) && !existsSync5(join7(ortDir, ONNX_INSTALLED_META_FILE))) {
|
|
13323
13515
|
log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
|
|
13324
13516
|
rmSync2(ortDir, { recursive: true, force: true });
|
|
13325
13517
|
}
|
|
@@ -13348,11 +13540,11 @@ function parseOnnxVersionFromDirectoryPath(value) {
|
|
|
13348
13540
|
}
|
|
13349
13541
|
function isPathInsideRoot(root, candidate) {
|
|
13350
13542
|
const rel = relative(root, candidate);
|
|
13351
|
-
return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !
|
|
13543
|
+
return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute2(rel) && !win32.isAbsolute(rel);
|
|
13352
13544
|
}
|
|
13353
13545
|
function detectOnnxVersion(libDir, libName) {
|
|
13354
13546
|
try {
|
|
13355
|
-
const entries =
|
|
13547
|
+
const entries = readdirSync2(libDir);
|
|
13356
13548
|
const barePrefix = libName.replace(/\.(so|dylib|dll)$/, "");
|
|
13357
13549
|
const expectedPrefix = process.platform === "win32" ? barePrefix.toLowerCase() : barePrefix;
|
|
13358
13550
|
for (const entry of entries) {
|
|
@@ -13363,7 +13555,7 @@ function detectOnnxVersion(libDir, libName) {
|
|
|
13363
13555
|
if (version)
|
|
13364
13556
|
return version;
|
|
13365
13557
|
}
|
|
13366
|
-
const base =
|
|
13558
|
+
const base = join7(libDir, libName);
|
|
13367
13559
|
if (existsSync5(base)) {
|
|
13368
13560
|
try {
|
|
13369
13561
|
const real = realpathSync(base);
|
|
@@ -13395,16 +13587,16 @@ function pathEnvValue() {
|
|
|
13395
13587
|
return process.env.PATH ?? process.env.Path ?? process.env.path ?? "";
|
|
13396
13588
|
}
|
|
13397
13589
|
function pathEntriesForPlatform() {
|
|
13398
|
-
const
|
|
13399
|
-
return pathEnvValue().split(
|
|
13590
|
+
const delimiter2 = process.platform === "win32" ? ";" : ":";
|
|
13591
|
+
return pathEnvValue().split(delimiter2).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
|
|
13400
13592
|
if (!entry || entry === "." || entry.includes("\x00"))
|
|
13401
13593
|
return false;
|
|
13402
|
-
return
|
|
13594
|
+
return isAbsolute2(entry) || win32.isAbsolute(entry);
|
|
13403
13595
|
});
|
|
13404
13596
|
}
|
|
13405
13597
|
function directoryContainsLibrary(dir, libName) {
|
|
13406
13598
|
try {
|
|
13407
|
-
const entries =
|
|
13599
|
+
const entries = readdirSync2(dir);
|
|
13408
13600
|
if (process.platform === "win32") {
|
|
13409
13601
|
const expected = libName.toLowerCase();
|
|
13410
13602
|
return entries.some((entry) => entry.toLowerCase() === expected);
|
|
@@ -13415,10 +13607,10 @@ function directoryContainsLibrary(dir, libName) {
|
|
|
13415
13607
|
}
|
|
13416
13608
|
}
|
|
13417
13609
|
function resolveCachedOnnxRuntimeDir(ortVersionDir, libName) {
|
|
13418
|
-
if (existsSync5(
|
|
13610
|
+
if (existsSync5(join7(ortVersionDir, libName)))
|
|
13419
13611
|
return ortVersionDir;
|
|
13420
|
-
const libSubdir =
|
|
13421
|
-
if (existsSync5(
|
|
13612
|
+
const libSubdir = join7(ortVersionDir, "lib");
|
|
13613
|
+
if (existsSync5(join7(libSubdir, libName)))
|
|
13422
13614
|
return libSubdir;
|
|
13423
13615
|
return ortVersionDir;
|
|
13424
13616
|
}
|
|
@@ -13433,21 +13625,21 @@ function findSystemOnnxRuntime(libName) {
|
|
|
13433
13625
|
} else if (process.platform === "win32") {
|
|
13434
13626
|
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
13435
13627
|
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
13436
|
-
searchPaths.push(
|
|
13628
|
+
searchPaths.push(join7(programFiles, "onnxruntime", "lib"), join7(programFiles, "Microsoft ONNX Runtime", "lib"), join7(programFiles, "Microsoft Machine Learning", "lib"), join7(programFilesX86, "onnxruntime", "lib"), ...(() => {
|
|
13437
13629
|
const nugetPaths = [];
|
|
13438
13630
|
const userProfile = process.env.USERPROFILE ?? "";
|
|
13439
13631
|
if (!userProfile)
|
|
13440
13632
|
return nugetPaths;
|
|
13441
|
-
const nugetPackageDir =
|
|
13633
|
+
const nugetPackageDir = join7(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
13442
13634
|
if (!existsSync5(nugetPackageDir))
|
|
13443
13635
|
return nugetPaths;
|
|
13444
13636
|
try {
|
|
13445
|
-
for (const entry of
|
|
13637
|
+
for (const entry of readdirSync2(nugetPackageDir, { withFileTypes: true })) {
|
|
13446
13638
|
if (!entry.isDirectory())
|
|
13447
13639
|
continue;
|
|
13448
13640
|
if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
|
|
13449
13641
|
continue;
|
|
13450
|
-
nugetPaths.push(
|
|
13642
|
+
nugetPaths.push(join7(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join7(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
|
|
13451
13643
|
}
|
|
13452
13644
|
} catch (err) {
|
|
13453
13645
|
warn(`Failed to scan NuGet ONNX Runtime cache ${nugetPackageDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -13469,7 +13661,7 @@ function findSystemOnnxRuntime(libName) {
|
|
|
13469
13661
|
});
|
|
13470
13662
|
const unknownVersionPaths = [];
|
|
13471
13663
|
for (const dir of uniquePaths) {
|
|
13472
|
-
const libPath =
|
|
13664
|
+
const libPath = join7(dir, libName);
|
|
13473
13665
|
if (process.platform === "win32") {
|
|
13474
13666
|
if (!directoryContainsLibrary(dir, libName))
|
|
13475
13667
|
continue;
|
|
@@ -13505,7 +13697,7 @@ async function downloadFileWithCap(url, destPath) {
|
|
|
13505
13697
|
if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES2) {
|
|
13506
13698
|
throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES2}`);
|
|
13507
13699
|
}
|
|
13508
|
-
mkdirSync5(
|
|
13700
|
+
mkdirSync5(dirname4(destPath), { recursive: true });
|
|
13509
13701
|
let bytesWritten = 0;
|
|
13510
13702
|
const guard = new TransformStream({
|
|
13511
13703
|
transform(chunk, transformController) {
|
|
@@ -13533,21 +13725,21 @@ function validateExtractedTree(stagingRoot) {
|
|
|
13533
13725
|
const realRoot = realpathSync(stagingRoot);
|
|
13534
13726
|
let totalBytes = 0;
|
|
13535
13727
|
const walk = (dir) => {
|
|
13536
|
-
const entries =
|
|
13728
|
+
const entries = readdirSync2(dir);
|
|
13537
13729
|
for (const entry of entries) {
|
|
13538
|
-
const fullPath =
|
|
13730
|
+
const fullPath = join7(dir, entry);
|
|
13539
13731
|
const lst = lstatSync(fullPath);
|
|
13540
13732
|
if (lst.isSymbolicLink()) {
|
|
13541
13733
|
const linkTarget = readlinkSync(fullPath);
|
|
13542
|
-
const resolvedTarget = resolve(
|
|
13734
|
+
const resolvedTarget = resolve(dirname4(fullPath), linkTarget);
|
|
13543
13735
|
const rel2 = relative(realRoot, resolvedTarget);
|
|
13544
|
-
if (rel2.startsWith("..") ||
|
|
13736
|
+
if (rel2.startsWith("..") || isAbsolute2(rel2) || win32.isAbsolute(rel2)) {
|
|
13545
13737
|
throw new Error(`extracted symlink ${fullPath} points outside staging root: ${linkTarget}`);
|
|
13546
13738
|
}
|
|
13547
13739
|
continue;
|
|
13548
13740
|
}
|
|
13549
13741
|
const rel = relative(realRoot, fullPath);
|
|
13550
|
-
if (rel.startsWith("..") ||
|
|
13742
|
+
if (rel.startsWith("..") || isAbsolute2(rel) || win32.isAbsolute(rel)) {
|
|
13551
13743
|
throw new Error(`extracted entry ${fullPath} escapes staging root`);
|
|
13552
13744
|
}
|
|
13553
13745
|
if (lst.isDirectory()) {
|
|
@@ -13570,7 +13762,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
13570
13762
|
const tmpDir = `${targetDir}.tmp.${process.pid}.${Date.now().toString(36)}`;
|
|
13571
13763
|
try {
|
|
13572
13764
|
mkdirSync5(tmpDir, { recursive: true });
|
|
13573
|
-
const archivePath =
|
|
13765
|
+
const archivePath = join7(tmpDir, `onnxruntime.${info.archiveType}`);
|
|
13574
13766
|
await downloadFileWithCap(url, archivePath);
|
|
13575
13767
|
const archiveSha256 = sha256File(archivePath);
|
|
13576
13768
|
log(`ONNX Runtime archive sha256=${archiveSha256}`);
|
|
@@ -13586,16 +13778,16 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
13586
13778
|
unlinkSync3(archivePath);
|
|
13587
13779
|
} catch {}
|
|
13588
13780
|
validateExtractedTree(tmpDir);
|
|
13589
|
-
const extractedDir =
|
|
13781
|
+
const extractedDir = join7(tmpDir, info.assetName, "lib");
|
|
13590
13782
|
if (!existsSync5(extractedDir)) {
|
|
13591
13783
|
throw new Error(`Expected directory not found: ${extractedDir}`);
|
|
13592
13784
|
}
|
|
13593
13785
|
mkdirSync5(targetDir, { recursive: true });
|
|
13594
|
-
const libFiles =
|
|
13786
|
+
const libFiles = readdirSync2(extractedDir).filter((f) => f.startsWith("libonnxruntime") || f.startsWith("onnxruntime"));
|
|
13595
13787
|
const realFiles = [];
|
|
13596
13788
|
const symlinks = [];
|
|
13597
13789
|
for (const libFile of libFiles) {
|
|
13598
|
-
const src =
|
|
13790
|
+
const src = join7(extractedDir, libFile);
|
|
13599
13791
|
try {
|
|
13600
13792
|
const stat = lstatSync(src);
|
|
13601
13793
|
log(`ORT extract: ${libFile} — isSymlink=${stat.isSymbolicLink()}, isFile=${stat.isFile()}, size=${stat.size}`);
|
|
@@ -13610,7 +13802,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
13610
13802
|
}
|
|
13611
13803
|
}
|
|
13612
13804
|
copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks);
|
|
13613
|
-
const libPath =
|
|
13805
|
+
const libPath = join7(targetDir, info.libName);
|
|
13614
13806
|
let libHash = null;
|
|
13615
13807
|
try {
|
|
13616
13808
|
libHash = sha256File(libPath);
|
|
@@ -13635,8 +13827,8 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
13635
13827
|
function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile = copyFileSync3) {
|
|
13636
13828
|
const requiredLibs = new Set([info.libName]);
|
|
13637
13829
|
for (const libFile of realFiles) {
|
|
13638
|
-
const src =
|
|
13639
|
-
const dst =
|
|
13830
|
+
const src = join7(extractedDir, libFile);
|
|
13831
|
+
const dst = join7(targetDir, libFile);
|
|
13640
13832
|
try {
|
|
13641
13833
|
copyFile(src, dst);
|
|
13642
13834
|
if (process.platform !== "win32") {
|
|
@@ -13652,12 +13844,12 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
13652
13844
|
}
|
|
13653
13845
|
const targetRoot = realpathSync(targetDir);
|
|
13654
13846
|
for (const link of symlinks) {
|
|
13655
|
-
const dst =
|
|
13847
|
+
const dst = join7(targetDir, link.name);
|
|
13656
13848
|
try {
|
|
13657
13849
|
unlinkSync3(dst);
|
|
13658
13850
|
} catch {}
|
|
13659
|
-
const dstForContainment =
|
|
13660
|
-
const resolvedTarget = resolve(
|
|
13851
|
+
const dstForContainment = join7(targetRoot, link.name);
|
|
13852
|
+
const resolvedTarget = resolve(dirname4(dstForContainment), link.target);
|
|
13661
13853
|
if (!isPathInsideRoot(targetRoot, resolvedTarget)) {
|
|
13662
13854
|
const message = `ONNX Runtime symlink ${link.name} points outside install dir: ${link.target}`;
|
|
13663
13855
|
if (requiredLibs.has(link.name)) {
|
|
@@ -13677,7 +13869,7 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
13677
13869
|
log(`ORT extract: failed to symlink optional ${link.name}: ${symlinkErr}`);
|
|
13678
13870
|
}
|
|
13679
13871
|
}
|
|
13680
|
-
const requiredPath =
|
|
13872
|
+
const requiredPath = join7(targetDir, info.libName);
|
|
13681
13873
|
if (!existsSync5(requiredPath)) {
|
|
13682
13874
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
13683
13875
|
throw new Error(`Required ONNX Runtime library missing after install: ${requiredPath}`);
|
|
@@ -13704,15 +13896,15 @@ function writeOnnxInstalledMeta(installDir, version, sha256, archiveSha256) {
|
|
|
13704
13896
|
...sha256 ? { sha256 } : {},
|
|
13705
13897
|
archiveSha256
|
|
13706
13898
|
};
|
|
13707
|
-
writeFileSync2(
|
|
13899
|
+
writeFileSync2(join7(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
|
|
13708
13900
|
} catch (err) {
|
|
13709
13901
|
log(`[onnx] failed to write installed-meta in ${installDir}: ${err}`);
|
|
13710
13902
|
}
|
|
13711
13903
|
}
|
|
13712
13904
|
function readOnnxInstalledMeta(installDir) {
|
|
13713
|
-
const path =
|
|
13905
|
+
const path = join7(installDir, ONNX_INSTALLED_META_FILE);
|
|
13714
13906
|
try {
|
|
13715
|
-
if (!
|
|
13907
|
+
if (!statSync3(path).isFile())
|
|
13716
13908
|
return null;
|
|
13717
13909
|
const raw = readFileSync3(path, "utf8");
|
|
13718
13910
|
const parsed = JSON.parse(raw);
|
|
@@ -13736,13 +13928,13 @@ function sha256File(path) {
|
|
|
13736
13928
|
function acquireLock(lockPath) {
|
|
13737
13929
|
const tryClaim = () => {
|
|
13738
13930
|
try {
|
|
13739
|
-
const fd =
|
|
13931
|
+
const fd = openSync3(lockPath, "wx");
|
|
13740
13932
|
try {
|
|
13741
13933
|
writeFileSync2(fd, `${process.pid}
|
|
13742
13934
|
${new Date().toISOString()}
|
|
13743
13935
|
`);
|
|
13744
13936
|
} finally {
|
|
13745
|
-
|
|
13937
|
+
closeSync3(fd);
|
|
13746
13938
|
}
|
|
13747
13939
|
return true;
|
|
13748
13940
|
} catch (err) {
|
|
@@ -13763,7 +13955,7 @@ ${new Date().toISOString()}
|
|
|
13763
13955
|
const parsed = Number.parseInt(firstLine, 10);
|
|
13764
13956
|
if (Number.isFinite(parsed) && parsed > 0)
|
|
13765
13957
|
owningPid = parsed;
|
|
13766
|
-
lockMtimeMs =
|
|
13958
|
+
lockMtimeMs = statSync3(lockPath).mtimeMs;
|
|
13767
13959
|
} catch {
|
|
13768
13960
|
return tryClaim();
|
|
13769
13961
|
}
|
|
@@ -13848,13 +14040,13 @@ function isProcessAlive(pid) {
|
|
|
13848
14040
|
}
|
|
13849
14041
|
// ../aft-bridge/dist/pool.js
|
|
13850
14042
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
13851
|
-
import { homedir as
|
|
14043
|
+
import { homedir as homedir6 } from "node:os";
|
|
13852
14044
|
var DEFAULT_IDLE_TIMEOUT_MS = Infinity;
|
|
13853
14045
|
var DEFAULT_MAX_POOL_SIZE = 8;
|
|
13854
14046
|
var CLEANUP_INTERVAL_MS = 60 * 1000;
|
|
13855
14047
|
function canonicalHomeDir() {
|
|
13856
14048
|
try {
|
|
13857
|
-
const home =
|
|
14049
|
+
const home = homedir6();
|
|
13858
14050
|
if (!home)
|
|
13859
14051
|
return null;
|
|
13860
14052
|
try {
|
|
@@ -14774,7 +14966,7 @@ import {
|
|
|
14774
14966
|
// package.json
|
|
14775
14967
|
var package_default = {
|
|
14776
14968
|
name: "@cortexkit/aft-pi",
|
|
14777
|
-
version: "0.35.
|
|
14969
|
+
version: "0.35.2",
|
|
14778
14970
|
type: "module",
|
|
14779
14971
|
description: "Pi coding agent extension for Agent File Tools (AFT) — tree-sitter and LSP-powered code analysis",
|
|
14780
14972
|
main: "dist/index.js",
|
|
@@ -14797,7 +14989,7 @@ var package_default = {
|
|
|
14797
14989
|
"test:unit": "bun test src/__tests__ --path-ignore-patterns 'src/__tests__/e2e/**'"
|
|
14798
14990
|
},
|
|
14799
14991
|
dependencies: {
|
|
14800
|
-
"@cortexkit/aft-bridge": "0.35.
|
|
14992
|
+
"@cortexkit/aft-bridge": "0.35.2",
|
|
14801
14993
|
"@xterm/headless": "^5.5.0",
|
|
14802
14994
|
"comment-json": "^5.0.0",
|
|
14803
14995
|
diff: "^8.0.4",
|
|
@@ -14805,12 +14997,12 @@ var package_default = {
|
|
|
14805
14997
|
zod: "^4.1.8"
|
|
14806
14998
|
},
|
|
14807
14999
|
optionalDependencies: {
|
|
14808
|
-
"@cortexkit/aft-darwin-arm64": "0.35.
|
|
14809
|
-
"@cortexkit/aft-darwin-x64": "0.35.
|
|
14810
|
-
"@cortexkit/aft-linux-arm64": "0.35.
|
|
14811
|
-
"@cortexkit/aft-linux-x64": "0.35.
|
|
14812
|
-
"@cortexkit/aft-win32-arm64": "0.35.
|
|
14813
|
-
"@cortexkit/aft-win32-x64": "0.35.
|
|
15000
|
+
"@cortexkit/aft-darwin-arm64": "0.35.2",
|
|
15001
|
+
"@cortexkit/aft-darwin-x64": "0.35.2",
|
|
15002
|
+
"@cortexkit/aft-linux-arm64": "0.35.2",
|
|
15003
|
+
"@cortexkit/aft-linux-x64": "0.35.2",
|
|
15004
|
+
"@cortexkit/aft-win32-arm64": "0.35.2",
|
|
15005
|
+
"@cortexkit/aft-win32-x64": "0.35.2"
|
|
14814
15006
|
},
|
|
14815
15007
|
devDependencies: {
|
|
14816
15008
|
"@earendil-works/pi-coding-agent": "*",
|
|
@@ -15456,10 +15648,10 @@ function registerStatusCommand(pi, ctx) {
|
|
|
15456
15648
|
}
|
|
15457
15649
|
|
|
15458
15650
|
// src/config.ts
|
|
15459
|
-
var import_comment_json = __toESM(require_src2(), 1);
|
|
15460
15651
|
import { existsSync as existsSync6, readFileSync as readFileSync4, renameSync as renameSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
15461
|
-
import { homedir as
|
|
15462
|
-
import { join as
|
|
15652
|
+
import { homedir as homedir7 } from "node:os";
|
|
15653
|
+
import { join as join9 } from "node:path";
|
|
15654
|
+
var import_comment_json = __toESM(require_src2(), 1);
|
|
15463
15655
|
|
|
15464
15656
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
15465
15657
|
var exports_external = {};
|
|
@@ -17045,8 +17237,8 @@ function emoji() {
|
|
|
17045
17237
|
}
|
|
17046
17238
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
17047
17239
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
17048
|
-
var mac = (
|
|
17049
|
-
const escapedDelim = escapeRegex(
|
|
17240
|
+
var mac = (delimiter2) => {
|
|
17241
|
+
const escapedDelim = escapeRegex(delimiter2 ?? ":");
|
|
17050
17242
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
17051
17243
|
};
|
|
17052
17244
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -29396,14 +29588,15 @@ function loadConfigFromPath(configPath) {
|
|
|
29396
29588
|
return null;
|
|
29397
29589
|
}
|
|
29398
29590
|
migrateRawConfig(rawConfig, configPath, { log: log2, warn: warn2 });
|
|
29399
|
-
const
|
|
29591
|
+
const cleanConfig = stripJsoncSymbols(rawConfig);
|
|
29592
|
+
const result = AftConfigSchema.safeParse(cleanConfig);
|
|
29400
29593
|
if (result.success) {
|
|
29401
29594
|
log2(`Config loaded from ${configPath}`);
|
|
29402
29595
|
return result.data;
|
|
29403
29596
|
}
|
|
29404
29597
|
const errorMsg = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ");
|
|
29405
29598
|
warn2(`Config validation error in ${configPath}: ${errorMsg}`);
|
|
29406
|
-
return parseConfigPartially(
|
|
29599
|
+
return parseConfigPartially(cleanConfig);
|
|
29407
29600
|
} catch (err) {
|
|
29408
29601
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
29409
29602
|
error2(`Error loading config from ${configPath}: ${errorMsg}`);
|
|
@@ -29591,15 +29784,15 @@ function mergeConfigs(base, override) {
|
|
|
29591
29784
|
};
|
|
29592
29785
|
}
|
|
29593
29786
|
function getGlobalPiDir() {
|
|
29594
|
-
return
|
|
29787
|
+
return join9(homedir7(), ".pi", "agent");
|
|
29595
29788
|
}
|
|
29596
29789
|
function loadAftConfig(projectDirectory) {
|
|
29597
|
-
const userBasePath =
|
|
29790
|
+
const userBasePath = join9(getGlobalPiDir(), "aft");
|
|
29598
29791
|
migrateAftConfigFile(`${userBasePath}.jsonc`);
|
|
29599
29792
|
migrateAftConfigFile(`${userBasePath}.json`);
|
|
29600
29793
|
const userDetected = detectConfigFile(userBasePath);
|
|
29601
29794
|
const userConfigPath = userDetected.format !== "none" ? userDetected.path : `${userBasePath}.json`;
|
|
29602
|
-
const projectBasePath =
|
|
29795
|
+
const projectBasePath = join9(projectDirectory, ".pi", "aft");
|
|
29603
29796
|
migrateAftConfigFile(`${projectBasePath}.jsonc`);
|
|
29604
29797
|
migrateAftConfigFile(`${projectBasePath}.json`);
|
|
29605
29798
|
const projectDetected = detectConfigFile(projectBasePath);
|
|
@@ -29626,49 +29819,49 @@ function loadAftConfig(projectDirectory) {
|
|
|
29626
29819
|
// src/lsp-auto-install.ts
|
|
29627
29820
|
import { spawn as spawn2 } from "node:child_process";
|
|
29628
29821
|
import { createHash as createHash3 } from "node:crypto";
|
|
29629
|
-
import { createReadStream, mkdirSync as mkdirSync7, readFileSync as readFileSync7, renameSync as renameSync5, rmSync as rmSync3, statSync as
|
|
29630
|
-
import { join as
|
|
29822
|
+
import { createReadStream, mkdirSync as mkdirSync7, readFileSync as readFileSync7, renameSync as renameSync5, rmSync as rmSync3, statSync as statSync5 } from "node:fs";
|
|
29823
|
+
import { join as join12 } from "node:path";
|
|
29631
29824
|
|
|
29632
29825
|
// src/lsp-cache.ts
|
|
29633
29826
|
import {
|
|
29634
|
-
closeSync as
|
|
29827
|
+
closeSync as closeSync4,
|
|
29635
29828
|
mkdirSync as mkdirSync6,
|
|
29636
|
-
openSync as
|
|
29829
|
+
openSync as openSync4,
|
|
29637
29830
|
readFileSync as readFileSync5,
|
|
29638
|
-
statSync as
|
|
29831
|
+
statSync as statSync4,
|
|
29639
29832
|
unlinkSync as unlinkSync5,
|
|
29640
29833
|
writeFileSync as writeFileSync4
|
|
29641
29834
|
} from "node:fs";
|
|
29642
|
-
import { homedir as
|
|
29643
|
-
import { join as
|
|
29835
|
+
import { homedir as homedir8 } from "node:os";
|
|
29836
|
+
import { join as join10 } from "node:path";
|
|
29644
29837
|
function aftCacheBase() {
|
|
29645
29838
|
const override = process.env.AFT_CACHE_DIR;
|
|
29646
29839
|
if (override && override.length > 0)
|
|
29647
29840
|
return override;
|
|
29648
29841
|
if (process.platform === "win32") {
|
|
29649
29842
|
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
29650
|
-
const base2 = localAppData ||
|
|
29651
|
-
return
|
|
29843
|
+
const base2 = localAppData || join10(homedir8(), "AppData", "Local");
|
|
29844
|
+
return join10(base2, "aft");
|
|
29652
29845
|
}
|
|
29653
|
-
const base = process.env.XDG_CACHE_HOME ||
|
|
29654
|
-
return
|
|
29846
|
+
const base = process.env.XDG_CACHE_HOME || join10(homedir8(), ".cache");
|
|
29847
|
+
return join10(base, "aft");
|
|
29655
29848
|
}
|
|
29656
29849
|
function lspCacheRoot() {
|
|
29657
|
-
return
|
|
29850
|
+
return join10(aftCacheBase(), "lsp-packages");
|
|
29658
29851
|
}
|
|
29659
29852
|
function lspPackageDir(npmPackage) {
|
|
29660
|
-
return
|
|
29853
|
+
return join10(lspCacheRoot(), encodeURIComponent(npmPackage));
|
|
29661
29854
|
}
|
|
29662
29855
|
function lspBinaryPath(npmPackage, binary) {
|
|
29663
|
-
return
|
|
29856
|
+
return join10(lspPackageDir(npmPackage), "node_modules", ".bin", binary);
|
|
29664
29857
|
}
|
|
29665
29858
|
function lspBinDir(npmPackage) {
|
|
29666
|
-
return
|
|
29859
|
+
return join10(lspPackageDir(npmPackage), "node_modules", ".bin");
|
|
29667
29860
|
}
|
|
29668
29861
|
function isInstalled(npmPackage, binary) {
|
|
29669
29862
|
for (const candidate of lspBinaryCandidates(binary)) {
|
|
29670
29863
|
try {
|
|
29671
|
-
if (
|
|
29864
|
+
if (statSync4(join10(lspBinDir(npmPackage), candidate)).isFile())
|
|
29672
29865
|
return true;
|
|
29673
29866
|
} catch {}
|
|
29674
29867
|
}
|
|
@@ -29688,15 +29881,15 @@ function writeInstalledMetaIn(installDir, version2, sha256) {
|
|
|
29688
29881
|
installedAt: new Date().toISOString(),
|
|
29689
29882
|
...sha256 ? { sha256 } : {}
|
|
29690
29883
|
};
|
|
29691
|
-
writeFileSync4(
|
|
29884
|
+
writeFileSync4(join10(installDir, INSTALLED_META_FILE), JSON.stringify(meta3), "utf8");
|
|
29692
29885
|
} catch (err) {
|
|
29693
29886
|
log2(`[lsp-cache] failed to write installed-meta in ${installDir}: ${err}`);
|
|
29694
29887
|
}
|
|
29695
29888
|
}
|
|
29696
29889
|
function readInstalledMetaIn(installDir) {
|
|
29697
|
-
const path2 =
|
|
29890
|
+
const path2 = join10(installDir, INSTALLED_META_FILE);
|
|
29698
29891
|
try {
|
|
29699
|
-
if (!
|
|
29892
|
+
if (!statSync4(path2).isFile())
|
|
29700
29893
|
return null;
|
|
29701
29894
|
const raw = readFileSync5(path2, "utf8");
|
|
29702
29895
|
const parsed = JSON.parse(raw);
|
|
@@ -29718,7 +29911,7 @@ function readInstalledMeta(packageKey) {
|
|
|
29718
29911
|
return readInstalledMetaIn(lspPackageDir(packageKey));
|
|
29719
29912
|
}
|
|
29720
29913
|
function lockPath(npmPackage) {
|
|
29721
|
-
return
|
|
29914
|
+
return join10(lspPackageDir(npmPackage), ".aft-installing");
|
|
29722
29915
|
}
|
|
29723
29916
|
var STALE_LOCK_MS2 = 30 * 60 * 1000;
|
|
29724
29917
|
function acquireInstallLock(lockKey) {
|
|
@@ -29726,13 +29919,13 @@ function acquireInstallLock(lockKey) {
|
|
|
29726
29919
|
const lock = lockPath(lockKey);
|
|
29727
29920
|
const tryClaim = () => {
|
|
29728
29921
|
try {
|
|
29729
|
-
const fd =
|
|
29922
|
+
const fd = openSync4(lock, "wx");
|
|
29730
29923
|
try {
|
|
29731
29924
|
writeFileSync4(fd, `${process.pid}
|
|
29732
29925
|
${new Date().toISOString()}
|
|
29733
29926
|
`);
|
|
29734
29927
|
} finally {
|
|
29735
|
-
|
|
29928
|
+
closeSync4(fd);
|
|
29736
29929
|
}
|
|
29737
29930
|
return true;
|
|
29738
29931
|
} catch (err) {
|
|
@@ -29753,7 +29946,7 @@ ${new Date().toISOString()}
|
|
|
29753
29946
|
const parsed = Number.parseInt(firstLine, 10);
|
|
29754
29947
|
if (Number.isFinite(parsed) && parsed > 0)
|
|
29755
29948
|
owningPid = parsed;
|
|
29756
|
-
lockMtimeMs =
|
|
29949
|
+
lockMtimeMs = statSync4(lock).mtimeMs;
|
|
29757
29950
|
} catch {
|
|
29758
29951
|
return tryClaim();
|
|
29759
29952
|
}
|
|
@@ -29825,7 +30018,7 @@ async function withInstallLock(lockKey, task) {
|
|
|
29825
30018
|
}
|
|
29826
30019
|
var VERSION_CHECK_FILE = ".aft-version-check";
|
|
29827
30020
|
function readVersionCheck(npmPackage) {
|
|
29828
|
-
const file2 =
|
|
30021
|
+
const file2 = join10(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
|
|
29829
30022
|
try {
|
|
29830
30023
|
const raw = readFileSync5(file2, "utf8");
|
|
29831
30024
|
const parsed = JSON.parse(raw);
|
|
@@ -29842,7 +30035,7 @@ function readVersionCheck(npmPackage) {
|
|
|
29842
30035
|
}
|
|
29843
30036
|
function writeVersionCheck(npmPackage, latest) {
|
|
29844
30037
|
mkdirSync6(lspPackageDir(npmPackage), { recursive: true });
|
|
29845
|
-
const file2 =
|
|
30038
|
+
const file2 = join10(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
|
|
29846
30039
|
const record2 = {
|
|
29847
30040
|
last_checked: new Date().toISOString(),
|
|
29848
30041
|
latest_eligible: latest
|
|
@@ -30004,8 +30197,8 @@ var NPM_LSP_TABLE = [
|
|
|
30004
30197
|
];
|
|
30005
30198
|
|
|
30006
30199
|
// src/lsp-project-relevance.ts
|
|
30007
|
-
import { existsSync as existsSync7, readdirSync as
|
|
30008
|
-
import { join as
|
|
30200
|
+
import { existsSync as existsSync7, readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
30201
|
+
import { join as join11 } from "node:path";
|
|
30009
30202
|
var MAX_WALK_DIRS = 200;
|
|
30010
30203
|
var MAX_WALK_DEPTH = 4;
|
|
30011
30204
|
var NOISE_DIRS = new Set([
|
|
@@ -30022,7 +30215,7 @@ function hasRootMarker(projectRoot, rootMarkers) {
|
|
|
30022
30215
|
if (!rootMarkers)
|
|
30023
30216
|
return false;
|
|
30024
30217
|
for (const marker of rootMarkers) {
|
|
30025
|
-
if (existsSync7(
|
|
30218
|
+
if (existsSync7(join11(projectRoot, marker)))
|
|
30026
30219
|
return true;
|
|
30027
30220
|
}
|
|
30028
30221
|
return false;
|
|
@@ -30046,7 +30239,7 @@ function hasPackageJsonDep(projectRoot, depNames) {
|
|
|
30046
30239
|
}
|
|
30047
30240
|
function readPackageJson(projectRoot) {
|
|
30048
30241
|
try {
|
|
30049
|
-
const raw = readFileSync6(
|
|
30242
|
+
const raw = readFileSync6(join11(projectRoot, "package.json"), "utf8");
|
|
30050
30243
|
const parsed = JSON.parse(raw);
|
|
30051
30244
|
if (typeof parsed !== "object" || parsed === null)
|
|
30052
30245
|
return null;
|
|
@@ -30069,14 +30262,14 @@ function relevantExtensionsInProject(projectRoot, extToServer) {
|
|
|
30069
30262
|
visitedDirs += 1;
|
|
30070
30263
|
let entries;
|
|
30071
30264
|
try {
|
|
30072
|
-
entries =
|
|
30265
|
+
entries = readdirSync3(current.dir, { withFileTypes: true });
|
|
30073
30266
|
} catch {
|
|
30074
30267
|
continue;
|
|
30075
30268
|
}
|
|
30076
30269
|
for (const entry of entries) {
|
|
30077
30270
|
if (entry.isDirectory()) {
|
|
30078
30271
|
if (current.depth < MAX_WALK_DEPTH && !NOISE_DIRS.has(entry.name.toLowerCase())) {
|
|
30079
|
-
queue.push({ dir:
|
|
30272
|
+
queue.push({ dir: join11(current.dir, entry.name), depth: current.depth + 1 });
|
|
30080
30273
|
}
|
|
30081
30274
|
continue;
|
|
30082
30275
|
}
|
|
@@ -30210,10 +30403,16 @@ function runInstall(spec, version2, cwd, signal) {
|
|
|
30210
30403
|
resolve2(false);
|
|
30211
30404
|
return;
|
|
30212
30405
|
}
|
|
30213
|
-
const
|
|
30214
|
-
|
|
30406
|
+
const npm = resolveNpm();
|
|
30407
|
+
if (!npm) {
|
|
30408
|
+
warn2(`[lsp] npm not found on PATH or known locations; cannot install ${target}`);
|
|
30409
|
+
resolve2(false);
|
|
30410
|
+
return;
|
|
30411
|
+
}
|
|
30412
|
+
const child = spawn2(npm.command, ["install", "--no-save", "--ignore-scripts", "--silent", target], {
|
|
30215
30413
|
stdio: ["ignore", "pipe", "pipe"],
|
|
30216
|
-
cwd
|
|
30414
|
+
cwd,
|
|
30415
|
+
env: npmSpawnEnv(npm)
|
|
30217
30416
|
});
|
|
30218
30417
|
child.unref();
|
|
30219
30418
|
let stderrBuf = "";
|
|
@@ -30340,7 +30539,7 @@ function hashInstalledBinary(spec) {
|
|
|
30340
30539
|
let pathToHash = null;
|
|
30341
30540
|
for (const p of candidates) {
|
|
30342
30541
|
try {
|
|
30343
|
-
if (
|
|
30542
|
+
if (statSync5(p).isFile()) {
|
|
30344
30543
|
pathToHash = p;
|
|
30345
30544
|
break;
|
|
30346
30545
|
}
|
|
@@ -30366,7 +30565,7 @@ function installedBinaryPath(spec) {
|
|
|
30366
30565
|
] : [lspBinaryPath(spec.npm, spec.binary)];
|
|
30367
30566
|
for (const candidate of candidates) {
|
|
30368
30567
|
try {
|
|
30369
|
-
if (
|
|
30568
|
+
if (statSync5(candidate).isFile())
|
|
30370
30569
|
return candidate;
|
|
30371
30570
|
} catch {}
|
|
30372
30571
|
}
|
|
@@ -30377,10 +30576,10 @@ function sha256OfFileSync(path2) {
|
|
|
30377
30576
|
}
|
|
30378
30577
|
function quarantineCachedNpmInstall(spec, reason) {
|
|
30379
30578
|
const packageDir = lspPackageDir(spec.npm);
|
|
30380
|
-
const dest =
|
|
30579
|
+
const dest = join12(packageDir, "..", ".quarantine", encodeURIComponent(spec.npm), `${Date.now()}`);
|
|
30381
30580
|
warn2(`[lsp] tofu_mismatch ${spec.npm}: ${reason}; quarantining ${packageDir} -> ${dest}`);
|
|
30382
30581
|
try {
|
|
30383
|
-
mkdirSync7(
|
|
30582
|
+
mkdirSync7(join12(dest, ".."), { recursive: true });
|
|
30384
30583
|
rmSync3(dest, { recursive: true, force: true });
|
|
30385
30584
|
renameSync5(packageDir, dest);
|
|
30386
30585
|
} catch (err) {
|
|
@@ -30465,17 +30664,17 @@ import {
|
|
|
30465
30664
|
existsSync as existsSync8,
|
|
30466
30665
|
lstatSync as lstatSync2,
|
|
30467
30666
|
mkdirSync as mkdirSync8,
|
|
30468
|
-
readdirSync as
|
|
30667
|
+
readdirSync as readdirSync4,
|
|
30469
30668
|
readFileSync as readFileSync8,
|
|
30470
30669
|
readlinkSync as readlinkSync2,
|
|
30471
30670
|
realpathSync as realpathSync3,
|
|
30472
30671
|
renameSync as renameSync6,
|
|
30473
30672
|
rmSync as rmSync4,
|
|
30474
|
-
statSync as
|
|
30673
|
+
statSync as statSync6,
|
|
30475
30674
|
unlinkSync as unlinkSync6,
|
|
30476
30675
|
writeFileSync as writeFileSync5
|
|
30477
30676
|
} from "node:fs";
|
|
30478
|
-
import { dirname as
|
|
30677
|
+
import { dirname as dirname5, join as join13, relative as relative2, resolve as resolve2 } from "node:path";
|
|
30479
30678
|
import { Readable as Readable3 } from "node:stream";
|
|
30480
30679
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
30481
30680
|
|
|
@@ -30565,26 +30764,26 @@ function detectHostPlatform() {
|
|
|
30565
30764
|
|
|
30566
30765
|
// src/lsp-github-install.ts
|
|
30567
30766
|
function ghCacheRoot() {
|
|
30568
|
-
return
|
|
30767
|
+
return join13(aftCacheBase(), "lsp-binaries");
|
|
30569
30768
|
}
|
|
30570
30769
|
function ghPackageDir(spec) {
|
|
30571
|
-
return
|
|
30770
|
+
return join13(ghCacheRoot(), spec.id);
|
|
30572
30771
|
}
|
|
30573
30772
|
function ghBinDir(spec) {
|
|
30574
|
-
return
|
|
30773
|
+
return join13(ghPackageDir(spec), "bin");
|
|
30575
30774
|
}
|
|
30576
30775
|
function ghExtractDir(spec) {
|
|
30577
|
-
return
|
|
30776
|
+
return join13(ghPackageDir(spec), "extracted");
|
|
30578
30777
|
}
|
|
30579
30778
|
var INSTALLED_META_FILE2 = ".aft-installed";
|
|
30580
30779
|
function ghBinaryPath(spec, platform) {
|
|
30581
30780
|
const ext = platform === "win32" ? ".exe" : "";
|
|
30582
|
-
return
|
|
30781
|
+
return join13(ghBinDir(spec), `${spec.binary}${ext}`);
|
|
30583
30782
|
}
|
|
30584
30783
|
function isGithubInstalled(spec, platform) {
|
|
30585
30784
|
for (const candidate of ghBinaryCandidates(spec, platform)) {
|
|
30586
30785
|
try {
|
|
30587
|
-
if (
|
|
30786
|
+
if (statSync6(join13(ghBinDir(spec), candidate)).isFile())
|
|
30588
30787
|
return true;
|
|
30589
30788
|
} catch {}
|
|
30590
30789
|
}
|
|
@@ -30597,8 +30796,8 @@ function ghBinaryCandidates(spec, platform) {
|
|
|
30597
30796
|
}
|
|
30598
30797
|
function readGithubInstalledMetaIn(installDir) {
|
|
30599
30798
|
try {
|
|
30600
|
-
const path2 =
|
|
30601
|
-
if (!
|
|
30799
|
+
const path2 = join13(installDir, INSTALLED_META_FILE2);
|
|
30800
|
+
if (!statSync6(path2).isFile())
|
|
30602
30801
|
return null;
|
|
30603
30802
|
const parsed = JSON.parse(readFileSync8(path2, "utf8"));
|
|
30604
30803
|
if (typeof parsed.version !== "string" || parsed.version.length === 0)
|
|
@@ -30624,7 +30823,7 @@ function writeGithubInstalledMetaIn(installDir, version2, binarySha256, archiveS
|
|
|
30624
30823
|
binarySha256,
|
|
30625
30824
|
...archiveSha256 ? { archiveSha256 } : {}
|
|
30626
30825
|
};
|
|
30627
|
-
writeFileSync5(
|
|
30826
|
+
writeFileSync5(join13(installDir, INSTALLED_META_FILE2), JSON.stringify(meta3), "utf8");
|
|
30628
30827
|
} catch (err) {
|
|
30629
30828
|
warn2(`[lsp] failed to write github installed metadata in ${installDir}: ${err}`);
|
|
30630
30829
|
}
|
|
@@ -30817,7 +31016,7 @@ async function downloadFile(url2, destPath, fetchImpl, assetSize, signal) {
|
|
|
30817
31016
|
if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES3) {
|
|
30818
31017
|
throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES3}`);
|
|
30819
31018
|
}
|
|
30820
|
-
mkdirSync8(
|
|
31019
|
+
mkdirSync8(dirname5(destPath), { recursive: true });
|
|
30821
31020
|
let bytesWritten = 0;
|
|
30822
31021
|
const guard = new TransformStream({
|
|
30823
31022
|
transform(chunk, controller) {
|
|
@@ -30868,12 +31067,12 @@ function validateExtraction(stagingRoot) {
|
|
|
30868
31067
|
const walk = (dir) => {
|
|
30869
31068
|
let entries;
|
|
30870
31069
|
try {
|
|
30871
|
-
entries =
|
|
31070
|
+
entries = readdirSync4(dir);
|
|
30872
31071
|
} catch (err) {
|
|
30873
31072
|
throw new Error(`failed to read staging dir ${dir}: ${err}`);
|
|
30874
31073
|
}
|
|
30875
31074
|
for (const entry of entries) {
|
|
30876
|
-
const full =
|
|
31075
|
+
const full = join13(dir, entry);
|
|
30877
31076
|
let lst;
|
|
30878
31077
|
try {
|
|
30879
31078
|
lst = lstatSync2(full);
|
|
@@ -30961,10 +31160,10 @@ function extractArchiveSafely(archivePath, destDir, archiveType) {
|
|
|
30961
31160
|
}
|
|
30962
31161
|
function quarantineCachedGithubInstall(spec, reason) {
|
|
30963
31162
|
const packageDir = ghPackageDir(spec);
|
|
30964
|
-
const dest =
|
|
31163
|
+
const dest = join13(ghCacheRoot(), ".quarantine", encodeURIComponent(spec.id), `${Date.now()}`);
|
|
30965
31164
|
warn2(`[lsp] tofu_mismatch ${spec.id}: ${reason}; quarantining ${packageDir} -> ${dest}`);
|
|
30966
31165
|
try {
|
|
30967
|
-
mkdirSync8(
|
|
31166
|
+
mkdirSync8(dirname5(dest), { recursive: true });
|
|
30968
31167
|
rmSync4(dest, { recursive: true, force: true });
|
|
30969
31168
|
renameSync6(packageDir, dest);
|
|
30970
31169
|
} catch (err) {
|
|
@@ -30974,9 +31173,9 @@ function quarantineCachedGithubInstall(spec, reason) {
|
|
|
30974
31173
|
function validateCachedGithubInstall(spec, platform) {
|
|
30975
31174
|
const packageDir = ghPackageDir(spec);
|
|
30976
31175
|
const meta3 = readGithubInstalledMetaIn(packageDir);
|
|
30977
|
-
const binaryPath = ghBinaryCandidates(spec, platform).map((candidate) =>
|
|
31176
|
+
const binaryPath = ghBinaryCandidates(spec, platform).map((candidate) => join13(ghBinDir(spec), candidate)).find((candidate) => {
|
|
30978
31177
|
try {
|
|
30979
|
-
return
|
|
31178
|
+
return statSync6(candidate).isFile();
|
|
30980
31179
|
} catch {
|
|
30981
31180
|
return false;
|
|
30982
31181
|
}
|
|
@@ -31052,7 +31251,7 @@ async function downloadAndInstall(spec, tag, assets, platform, arch, fetchImpl,
|
|
|
31052
31251
|
}
|
|
31053
31252
|
const pkgDir = ghPackageDir(spec);
|
|
31054
31253
|
const extractDir = ghExtractDir(spec);
|
|
31055
|
-
const archivePath =
|
|
31254
|
+
const archivePath = join13(pkgDir, expected.name);
|
|
31056
31255
|
log2(`[lsp] downloading ${spec.id} ${tag} → ${matchingAsset.url}`);
|
|
31057
31256
|
try {
|
|
31058
31257
|
await downloadFile(matchingAsset.url, archivePath, fetchImpl, matchingAsset.size, signal);
|
|
@@ -31092,13 +31291,13 @@ async function downloadAndInstall(spec, tag, assets, platform, arch, fetchImpl,
|
|
|
31092
31291
|
unlinkSync6(archivePath);
|
|
31093
31292
|
} catch {}
|
|
31094
31293
|
}
|
|
31095
|
-
const innerBinaryPath =
|
|
31294
|
+
const innerBinaryPath = join13(extractDir, spec.binaryPathInArchive(platform, arch, version2));
|
|
31096
31295
|
if (!existsSync8(innerBinaryPath)) {
|
|
31097
31296
|
error2(`[lsp] ${spec.id}: extracted binary not found at ${innerBinaryPath}`);
|
|
31098
31297
|
return null;
|
|
31099
31298
|
}
|
|
31100
31299
|
const targetBinary = ghBinaryPath(spec, platform);
|
|
31101
|
-
mkdirSync8(
|
|
31300
|
+
mkdirSync8(dirname5(targetBinary), { recursive: true });
|
|
31102
31301
|
try {
|
|
31103
31302
|
copyFileSync4(innerBinaryPath, targetBinary);
|
|
31104
31303
|
if (platform !== "win32") {
|
|
@@ -31546,8 +31745,8 @@ import { Type as Type3 } from "typebox";
|
|
|
31546
31745
|
|
|
31547
31746
|
// src/tools/hoisted.ts
|
|
31548
31747
|
import { stat } from "node:fs/promises";
|
|
31549
|
-
import { homedir as
|
|
31550
|
-
import { isAbsolute as
|
|
31748
|
+
import { homedir as homedir9 } from "node:os";
|
|
31749
|
+
import { isAbsolute as isAbsolute3, relative as relative3, resolve as resolve3, sep } from "node:path";
|
|
31551
31750
|
import {
|
|
31552
31751
|
renderDiff
|
|
31553
31752
|
} from "@earendil-works/pi-coding-agent";
|
|
@@ -31663,15 +31862,15 @@ function diagnosticsOnEditDefault(ctx) {
|
|
|
31663
31862
|
}
|
|
31664
31863
|
function containsPath(parent, child) {
|
|
31665
31864
|
const rel = relative3(parent, child);
|
|
31666
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
31865
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
|
|
31667
31866
|
}
|
|
31668
31867
|
function expandTilde(path2) {
|
|
31669
31868
|
if (!path2 || !path2.startsWith("~"))
|
|
31670
31869
|
return path2;
|
|
31671
31870
|
if (path2 === "~")
|
|
31672
|
-
return
|
|
31871
|
+
return homedir9();
|
|
31673
31872
|
if (path2.startsWith(`~${sep}`) || path2.startsWith("~/")) {
|
|
31674
|
-
return resolve3(
|
|
31873
|
+
return resolve3(homedir9(), path2.slice(2));
|
|
31675
31874
|
}
|
|
31676
31875
|
return path2;
|
|
31677
31876
|
}
|
|
@@ -31686,7 +31885,7 @@ async function assertExternalDirectoryPermission(extCtx, target, action = "modif
|
|
|
31686
31885
|
if (!target)
|
|
31687
31886
|
return;
|
|
31688
31887
|
const expanded = expandTilde(target);
|
|
31689
|
-
const absoluteTarget =
|
|
31888
|
+
const absoluteTarget = isAbsolute3(expanded) ? expanded : resolve3(extCtx.cwd, expanded);
|
|
31690
31889
|
if (containsPath(extCtx.cwd, absoluteTarget))
|
|
31691
31890
|
return;
|
|
31692
31891
|
if (options.restrictToProjectRoot === false)
|
|
@@ -31807,7 +32006,7 @@ function registerHoistedTools(pi, ctx, surface) {
|
|
|
31807
32006
|
diagnostics: params.diagnostics ?? diagnosticsOnEditDefault(ctx),
|
|
31808
32007
|
include_diff_content: true
|
|
31809
32008
|
}, extCtx);
|
|
31810
|
-
return buildMutationResult(
|
|
32009
|
+
return buildMutationResult(response);
|
|
31811
32010
|
},
|
|
31812
32011
|
renderCall(args, theme, context) {
|
|
31813
32012
|
return renderMutationCall("write", args?.filePath, theme, context);
|
|
@@ -31843,7 +32042,7 @@ function registerHoistedTools(pi, ctx, surface) {
|
|
|
31843
32042
|
include_diff_content: true
|
|
31844
32043
|
};
|
|
31845
32044
|
const response2 = await callBridge(bridge, "edit_match", req2, extCtx);
|
|
31846
|
-
return buildMutationResult(
|
|
32045
|
+
return buildMutationResult(response2);
|
|
31847
32046
|
}
|
|
31848
32047
|
const req = {
|
|
31849
32048
|
file: params.filePath,
|
|
@@ -31858,7 +32057,7 @@ function registerHoistedTools(pi, ctx, surface) {
|
|
|
31858
32057
|
if (occurrence !== undefined)
|
|
31859
32058
|
req.occurrence = occurrence;
|
|
31860
32059
|
const response = await callBridge(bridge, "edit_match", req, extCtx);
|
|
31861
|
-
return buildMutationResult(
|
|
32060
|
+
return buildMutationResult(response);
|
|
31862
32061
|
},
|
|
31863
32062
|
renderCall(args, theme, context) {
|
|
31864
32063
|
return renderMutationCall("edit", args?.filePath, theme, context);
|
|
@@ -31899,7 +32098,7 @@ function registerHoistedTools(pi, ctx, surface) {
|
|
|
31899
32098
|
});
|
|
31900
32099
|
}
|
|
31901
32100
|
}
|
|
31902
|
-
function buildMutationResult(
|
|
32101
|
+
function buildMutationResult(response) {
|
|
31903
32102
|
const diffObj = response.diff;
|
|
31904
32103
|
const additions = diffObj?.additions ?? 0;
|
|
31905
32104
|
const deletions = diffObj?.deletions ?? 0;
|
|
@@ -31917,8 +32116,7 @@ function buildMutationResult(filePath, response) {
|
|
|
31917
32116
|
diffText = piDiff.diff;
|
|
31918
32117
|
firstChangedLine = piDiff.firstChangedLine;
|
|
31919
32118
|
}
|
|
31920
|
-
|
|
31921
|
-
let text = summaryHeader;
|
|
32119
|
+
let text = formatEditSummary(response);
|
|
31922
32120
|
if (noOp) {
|
|
31923
32121
|
text += `
|
|
31924
32122
|
|
|
@@ -32040,14 +32238,14 @@ ${summary}${suffix}`);
|
|
|
32040
32238
|
return container;
|
|
32041
32239
|
}
|
|
32042
32240
|
function shortenPath(path2) {
|
|
32043
|
-
const home =
|
|
32241
|
+
const home = homedir9();
|
|
32044
32242
|
if (path2.startsWith(home))
|
|
32045
32243
|
return `~${path2.slice(home.length)}`;
|
|
32046
32244
|
return path2;
|
|
32047
32245
|
}
|
|
32048
32246
|
async function resolvePathArg(cwd, path2) {
|
|
32049
32247
|
const expanded = expandTilde(path2);
|
|
32050
|
-
const abs =
|
|
32248
|
+
const abs = isAbsolute3(expanded) ? expanded : resolve3(cwd, expanded);
|
|
32051
32249
|
try {
|
|
32052
32250
|
await stat(abs);
|
|
32053
32251
|
return abs;
|
|
@@ -32101,7 +32299,7 @@ function formatReadFooter(agentSpecifiedRange, data) {
|
|
|
32101
32299
|
}
|
|
32102
32300
|
|
|
32103
32301
|
// src/tools/render-helpers.ts
|
|
32104
|
-
import { homedir as
|
|
32302
|
+
import { homedir as homedir10 } from "node:os";
|
|
32105
32303
|
import { renderDiff as renderDiff2 } from "@earendil-works/pi-coding-agent";
|
|
32106
32304
|
import { Container as Container2, Spacer as Spacer2, Text as Text2 } from "@earendil-works/pi-tui";
|
|
32107
32305
|
function reuseText2(last) {
|
|
@@ -32111,7 +32309,7 @@ function reuseContainer2(last) {
|
|
|
32111
32309
|
return last instanceof Container2 ? last : new Container2;
|
|
32112
32310
|
}
|
|
32113
32311
|
function shortenPath2(path2) {
|
|
32114
|
-
const home =
|
|
32312
|
+
const home = homedir10();
|
|
32115
32313
|
if (path2.startsWith(home))
|
|
32116
32314
|
return `~${path2.slice(home.length)}`;
|
|
32117
32315
|
return path2;
|
|
@@ -34738,6 +34936,14 @@ function semanticHonestyNote(response, theme) {
|
|
|
34738
34936
|
notes.push("partial/incomplete");
|
|
34739
34937
|
return notes.length > 0 ? theme.fg("warning", `Search status: ${notes.join("; ")}.`) : undefined;
|
|
34740
34938
|
}
|
|
34939
|
+
function extraAgentHonestyNote(response) {
|
|
34940
|
+
const notes = [];
|
|
34941
|
+
if (response.fully_degraded === true)
|
|
34942
|
+
notes.push("fully degraded");
|
|
34943
|
+
if (response.complete === false)
|
|
34944
|
+
notes.push("partial/incomplete");
|
|
34945
|
+
return notes.length > 0 ? `Search status: ${notes.join("; ")}.` : undefined;
|
|
34946
|
+
}
|
|
34741
34947
|
var SearchParams2 = Type13.Object({
|
|
34742
34948
|
query: Type13.String({
|
|
34743
34949
|
description: "Concept, regex, literal text, filename, or capability to find. Examples: 'fuzzy match with whitespace tolerance', '^export', 'Cargo.lock'."
|
|
@@ -34873,7 +35079,12 @@ function registerSemanticTool(pi, ctx) {
|
|
|
34873
35079
|
if (params.hint !== undefined)
|
|
34874
35080
|
req.hint = params.hint;
|
|
34875
35081
|
const response = await callBridge(bridge, "semantic_search", req, extCtx);
|
|
34876
|
-
|
|
35082
|
+
let agentText = response.text ?? "No results.";
|
|
35083
|
+
const extra = extraAgentHonestyNote(response);
|
|
35084
|
+
if (extra)
|
|
35085
|
+
agentText = `${agentText}
|
|
35086
|
+
${extra}`;
|
|
35087
|
+
return textResult(agentText, response);
|
|
34877
35088
|
},
|
|
34878
35089
|
renderCall(args, theme, context) {
|
|
34879
35090
|
return renderSemanticCall(args, theme, context);
|