@cortexkit/aft 0.20.0 → 0.21.0
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.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sendAftRequests } from "../lib/aft-bridge.js";
|
|
2
|
+
import { findAftBinary } from "../lib/binary-probe.js";
|
|
3
|
+
import { resolveAdaptersForCommand } from "../lib/harness-select.js";
|
|
4
|
+
import { selectMany } from "../lib/prompts.js";
|
|
5
|
+
export interface DoctorFiltersOptions {
|
|
6
|
+
argv: string[];
|
|
7
|
+
sendRequests?: typeof sendAftRequests;
|
|
8
|
+
findBinary?: typeof findAftBinary;
|
|
9
|
+
resolveAdapters?: typeof resolveAdaptersForCommand;
|
|
10
|
+
selectMany?: typeof selectMany;
|
|
11
|
+
}
|
|
12
|
+
export interface FilterEntry {
|
|
13
|
+
name: string;
|
|
14
|
+
source: "builtin" | "user" | "project" | "builtin_invalid" | "user_invalid" | "project_invalid" | string;
|
|
15
|
+
source_path: string | null;
|
|
16
|
+
matches: string[];
|
|
17
|
+
description: string | null;
|
|
18
|
+
content: string;
|
|
19
|
+
trusted: boolean | null;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ListFiltersResponse {
|
|
23
|
+
success: boolean;
|
|
24
|
+
code?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
filters?: FilterEntry[];
|
|
27
|
+
user_dir?: string | null;
|
|
28
|
+
project_dir?: string | null;
|
|
29
|
+
trusted_projects?: string[];
|
|
30
|
+
project_dir_exists?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function printDoctorFiltersHelp(): void;
|
|
33
|
+
export declare function runDoctorFilters(options: DoctorFiltersOptions): Promise<number>;
|
|
34
|
+
export declare function renderFilterList(response: ListFiltersResponse, projectRoot?: string): string;
|
|
35
|
+
export declare function renderFilterShow(response: ListFiltersResponse, name: string, projectRoot?: string): string | null;
|
|
36
|
+
export declare function renderTrustedProjects(paths: string[]): string;
|
|
37
|
+
//# sourceMappingURL=doctor-filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-filters.d.ts","sourceRoot":"","sources":["../../src/commands/doctor-filters.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAO,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,eAAe,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,aAAa,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,yBAAyB,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EACF,SAAS,GACT,MAAM,GACN,SAAS,GACT,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AASD,wBAAgB,sBAAsB,IAAI,IAAI,CAW7C;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6DrF;AAmHD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,mBAAmB,EAC7B,WAAW,SAAgB,GAC1B,MAAM,CA4BR;AA2BD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAE,MAAM,EACZ,WAAW,SAAgB,GAC1B,MAAM,GAAG,IAAI,CAmBf;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7D"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,QAAA,MAAM,OAAO,QAAkB,CAAC;AAChC,QAAA,MAAM,IAAI,UAAwB,CAAC;AAEnC,iBAAS,SAAS,IAAI,IAAI,CAyBzB;AAED,iBAAe,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,QAAA,MAAM,OAAO,QAAkB,CAAC;AAChC,QAAA,MAAM,IAAI,UAAwB,CAAC;AAEnC,iBAAS,SAAS,IAAI,IAAI,CAyBzB;AAED,iBAAe,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAuBrC"}
|
package/dist/index.js
CHANGED
|
@@ -10319,12 +10319,262 @@ var init_lsp = __esm(() => {
|
|
|
10319
10319
|
init_self_version();
|
|
10320
10320
|
});
|
|
10321
10321
|
|
|
10322
|
+
// src/commands/doctor-filters.ts
|
|
10323
|
+
var exports_doctor_filters = {};
|
|
10324
|
+
__export(exports_doctor_filters, {
|
|
10325
|
+
runDoctorFilters: () => runDoctorFilters,
|
|
10326
|
+
renderTrustedProjects: () => renderTrustedProjects,
|
|
10327
|
+
renderFilterShow: () => renderFilterShow,
|
|
10328
|
+
renderFilterList: () => renderFilterList,
|
|
10329
|
+
printDoctorFiltersHelp: () => printDoctorFiltersHelp
|
|
10330
|
+
});
|
|
10331
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
10332
|
+
import { homedir as homedir5 } from "node:os";
|
|
10333
|
+
import { relative, resolve as resolve3 } from "node:path";
|
|
10334
|
+
function printDoctorFiltersHelp() {
|
|
10335
|
+
console.log("Usage: aft doctor filters [--show <name>] [trust|untrust]");
|
|
10336
|
+
console.log("");
|
|
10337
|
+
console.log("Inspect declarative TOML compression filters.");
|
|
10338
|
+
console.log("");
|
|
10339
|
+
console.log("Commands:");
|
|
10340
|
+
console.log(" aft doctor filters List built-in, user, and project filters");
|
|
10341
|
+
console.log(" aft doctor filters --show <name> Show resolved TOML for a filter");
|
|
10342
|
+
console.log(" aft doctor filters trust Trust current project's .aft/filters");
|
|
10343
|
+
console.log(" aft doctor filters trust --list List trusted filter project paths");
|
|
10344
|
+
console.log(" aft doctor filters untrust Remove trusted project paths");
|
|
10345
|
+
}
|
|
10346
|
+
async function runDoctorFilters(options) {
|
|
10347
|
+
const mode = parseMode(options.argv);
|
|
10348
|
+
if (mode.kind === "help") {
|
|
10349
|
+
printDoctorFiltersHelp();
|
|
10350
|
+
return 0;
|
|
10351
|
+
}
|
|
10352
|
+
const resolveAdapters = options.resolveAdapters ?? resolveAdaptersForCommand;
|
|
10353
|
+
const adapters = await resolveAdapters(options.argv, {
|
|
10354
|
+
allowMulti: false,
|
|
10355
|
+
verb: "inspect filters for"
|
|
10356
|
+
});
|
|
10357
|
+
const adapter = adapters[0];
|
|
10358
|
+
if (!adapter) {
|
|
10359
|
+
O2.error("No harness selected.");
|
|
10360
|
+
return 1;
|
|
10361
|
+
}
|
|
10362
|
+
const findBinary = options.findBinary ?? findAftBinary;
|
|
10363
|
+
const binary = findBinary(getSelfVersion());
|
|
10364
|
+
if (!binary) {
|
|
10365
|
+
O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
10366
|
+
return 1;
|
|
10367
|
+
}
|
|
10368
|
+
const projectRoot = resolve3(process.cwd());
|
|
10369
|
+
const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
|
|
10370
|
+
if (!list.success) {
|
|
10371
|
+
O2.error(list.message ?? list.code ?? "list_filters failed");
|
|
10372
|
+
return 1;
|
|
10373
|
+
}
|
|
10374
|
+
list.project_dir_exists = list.project_dir ? existsSync7(list.project_dir) : false;
|
|
10375
|
+
if (mode.kind === "list") {
|
|
10376
|
+
console.log(renderFilterList(list, projectRoot));
|
|
10377
|
+
return 0;
|
|
10378
|
+
}
|
|
10379
|
+
if (mode.kind === "show") {
|
|
10380
|
+
const rendered = renderFilterShow(list, mode.name, projectRoot);
|
|
10381
|
+
if (!rendered) {
|
|
10382
|
+
O2.error(`Filter not found: ${mode.name}`);
|
|
10383
|
+
return 1;
|
|
10384
|
+
}
|
|
10385
|
+
console.log(rendered);
|
|
10386
|
+
return 0;
|
|
10387
|
+
}
|
|
10388
|
+
if (mode.kind === "trust") {
|
|
10389
|
+
if (mode.list) {
|
|
10390
|
+
console.log(renderTrustedProjects(list.trusted_projects ?? []));
|
|
10391
|
+
return 0;
|
|
10392
|
+
}
|
|
10393
|
+
return runTrustFlow(binary, list, adapter, projectRoot, options);
|
|
10394
|
+
}
|
|
10395
|
+
return runUntrustFlow(binary, list, adapter, projectRoot, options);
|
|
10396
|
+
}
|
|
10397
|
+
async function listFilters(binary, adapter, projectRoot, sendRequests) {
|
|
10398
|
+
const responses = await sendRequests(binary, [
|
|
10399
|
+
buildConfigureRequest(adapter, projectRoot),
|
|
10400
|
+
{ id: "doctor-filters-list", command: "list_filters" }
|
|
10401
|
+
]);
|
|
10402
|
+
const configure = responses[0];
|
|
10403
|
+
if (configure && !configure.success)
|
|
10404
|
+
return configure;
|
|
10405
|
+
return responses[1] ?? {
|
|
10406
|
+
success: false,
|
|
10407
|
+
message: "aft exited before list_filters"
|
|
10408
|
+
};
|
|
10409
|
+
}
|
|
10410
|
+
function buildConfigureRequest(adapter, projectRoot) {
|
|
10411
|
+
return {
|
|
10412
|
+
id: "doctor-filters-configure",
|
|
10413
|
+
command: "configure",
|
|
10414
|
+
project_root: projectRoot,
|
|
10415
|
+
storage_dir: adapter.getStorageDir()
|
|
10416
|
+
};
|
|
10417
|
+
}
|
|
10418
|
+
async function runTrustFlow(binary, list, adapter, projectRoot, options) {
|
|
10419
|
+
const filters = (list.filters ?? []).filter((filter) => filter.source.startsWith("project") && filter.trusted === false);
|
|
10420
|
+
if (filters.length === 0) {
|
|
10421
|
+
console.log(`No untrusted project filters in ${projectRoot}.`);
|
|
10422
|
+
return 0;
|
|
10423
|
+
}
|
|
10424
|
+
const prompt = options.selectMany ?? selectMany;
|
|
10425
|
+
const selected = await prompt("Trust project filters?", filters.map((filter) => ({
|
|
10426
|
+
label: filter.error ? `${filter.name} (invalid: ${filter.error})` : filter.name,
|
|
10427
|
+
value: filter.name,
|
|
10428
|
+
hint: formatSourcePath(filter.source_path, projectRoot)
|
|
10429
|
+
})), filters.map((filter) => filter.name), false);
|
|
10430
|
+
if (selected.length === 0) {
|
|
10431
|
+
console.log("Trusted 0 project(s). Restart AFT (or reconfigure) for filters to take effect.");
|
|
10432
|
+
return 0;
|
|
10433
|
+
}
|
|
10434
|
+
const sendRequests = options.sendRequests ?? sendAftRequests;
|
|
10435
|
+
const responses = await sendRequests(binary, [
|
|
10436
|
+
buildConfigureRequest(adapter, projectRoot),
|
|
10437
|
+
{ id: "doctor-filters-trust", command: "trust_filter_project", project_root: projectRoot }
|
|
10438
|
+
]);
|
|
10439
|
+
const trust = responses[responses.length - 1];
|
|
10440
|
+
if (!trust?.success) {
|
|
10441
|
+
O2.error(trust?.message ?? trust?.code ?? "trust_filter_project failed");
|
|
10442
|
+
return 1;
|
|
10443
|
+
}
|
|
10444
|
+
console.log("Trusted 1 project(s). Restart AFT (or reconfigure) for filters to take effect.");
|
|
10445
|
+
return 0;
|
|
10446
|
+
}
|
|
10447
|
+
async function runUntrustFlow(binary, list, adapter, projectRoot, options) {
|
|
10448
|
+
const trusted = list.trusted_projects ?? [];
|
|
10449
|
+
if (trusted.length === 0) {
|
|
10450
|
+
console.log("No trusted filter projects.");
|
|
10451
|
+
return 0;
|
|
10452
|
+
}
|
|
10453
|
+
const prompt = options.selectMany ?? selectMany;
|
|
10454
|
+
const selected = await prompt("Untrust filter projects?", trusted.map((path) => ({ label: path, value: path })), undefined, false);
|
|
10455
|
+
if (selected.length === 0) {
|
|
10456
|
+
console.log("Untrusted 0 project(s).");
|
|
10457
|
+
return 0;
|
|
10458
|
+
}
|
|
10459
|
+
const requests = [buildConfigureRequest(adapter, projectRoot)];
|
|
10460
|
+
for (const path of selected) {
|
|
10461
|
+
requests.push({
|
|
10462
|
+
id: `doctor-filters-untrust-${requests.length}`,
|
|
10463
|
+
command: "untrust_filter_project",
|
|
10464
|
+
project_root: path
|
|
10465
|
+
});
|
|
10466
|
+
}
|
|
10467
|
+
const responses = await (options.sendRequests ?? sendAftRequests)(binary, requests);
|
|
10468
|
+
const failures = responses.slice(1).filter((response) => !response.success);
|
|
10469
|
+
if (failures.length > 0) {
|
|
10470
|
+
O2.error(failures[0]?.message ?? failures[0]?.code ?? "untrust_filter_project failed");
|
|
10471
|
+
return 1;
|
|
10472
|
+
}
|
|
10473
|
+
console.log(`Untrusted ${selected.length} project(s). Restart AFT (or reconfigure) for filters to take effect.`);
|
|
10474
|
+
return 0;
|
|
10475
|
+
}
|
|
10476
|
+
function renderFilterList(response, projectRoot = process.cwd()) {
|
|
10477
|
+
const filters = response.filters ?? [];
|
|
10478
|
+
const lines = ["TOML compression filters", ""];
|
|
10479
|
+
pushSection(lines, "Built-in", filters.filter((filter) => filter.source === "builtin" || filter.source === "builtin_invalid"));
|
|
10480
|
+
lines.push("");
|
|
10481
|
+
pushSection(lines, `User (${formatHome(response.user_dir ?? "")}`, filters.filter((filter) => filter.source === "user" || filter.source === "user_invalid"), true);
|
|
10482
|
+
const projectFilters = filters.filter((filter) => filter.source === "project" || filter.source === "project_invalid");
|
|
10483
|
+
if (response.project_dir_exists || projectFilters.length > 0) {
|
|
10484
|
+
lines.push("");
|
|
10485
|
+
pushSection(lines, `Project (${formatProjectPath(response.project_dir ?? "", projectRoot)}`, projectFilters, true);
|
|
10486
|
+
}
|
|
10487
|
+
return lines.join(`
|
|
10488
|
+
`);
|
|
10489
|
+
}
|
|
10490
|
+
function pushSection(lines, title, filters, titleHasOpenParen = false) {
|
|
10491
|
+
lines.push(titleHasOpenParen ? `${title}, ${filters.length}):` : `${title} (${filters.length}):`);
|
|
10492
|
+
if (filters.length === 0) {
|
|
10493
|
+
lines.push(" (empty)");
|
|
10494
|
+
return;
|
|
10495
|
+
}
|
|
10496
|
+
for (const filter of filters) {
|
|
10497
|
+
const description = filter.error ? `invalid — ${filter.error}` : truncate(filter.description ?? "");
|
|
10498
|
+
const trust = filter.source.startsWith("project") && filter.trusted === false ? filter.error ? " (untrusted)" : " (untrusted — run `aft doctor filters trust` to enable)" : "";
|
|
10499
|
+
lines.push(` ${filter.name.padEnd(20)} ${description}${trust}`.trimEnd());
|
|
10500
|
+
}
|
|
10501
|
+
}
|
|
10502
|
+
function renderFilterShow(response, name, projectRoot = process.cwd()) {
|
|
10503
|
+
const filter = (response.filters ?? []).find((entry) => entry.name === name || entry.matches.includes(name));
|
|
10504
|
+
if (!filter)
|
|
10505
|
+
return null;
|
|
10506
|
+
const lines = [`Filter: ${filter.name}`];
|
|
10507
|
+
if (filter.source === "builtin") {
|
|
10508
|
+
lines.push("Source: built-in");
|
|
10509
|
+
} else if (filter.source.startsWith("user")) {
|
|
10510
|
+
lines.push(`Source: user (${formatHome(filter.source_path ?? "")})`);
|
|
10511
|
+
} else if (filter.source.startsWith("project")) {
|
|
10512
|
+
lines.push(`Source: project (${formatProjectPath(filter.source_path ?? "", projectRoot)})`);
|
|
10513
|
+
lines.push(`Trust: ${filter.trusted ? "trusted" : "untrusted"}`);
|
|
10514
|
+
} else {
|
|
10515
|
+
lines.push(`Source: ${filter.source}`);
|
|
10516
|
+
}
|
|
10517
|
+
if (filter.error)
|
|
10518
|
+
lines.push(`Error: ${filter.error}`);
|
|
10519
|
+
lines.push("", filter.content.trimEnd());
|
|
10520
|
+
return lines.join(`
|
|
10521
|
+
`);
|
|
10522
|
+
}
|
|
10523
|
+
function renderTrustedProjects(paths) {
|
|
10524
|
+
return paths.length === 0 ? "(none)" : paths.join(`
|
|
10525
|
+
`);
|
|
10526
|
+
}
|
|
10527
|
+
function parseMode(argv) {
|
|
10528
|
+
if (argv.includes("--help") || argv.includes("-h"))
|
|
10529
|
+
return { kind: "help" };
|
|
10530
|
+
const showIndex = argv.indexOf("--show");
|
|
10531
|
+
if (showIndex >= 0)
|
|
10532
|
+
return { kind: "show", name: argv[showIndex + 1] ?? "" };
|
|
10533
|
+
const positional = argv.filter((arg, index) => {
|
|
10534
|
+
if (arg === "--harness")
|
|
10535
|
+
return false;
|
|
10536
|
+
if (index > 0 && argv[index - 1] === "--harness")
|
|
10537
|
+
return false;
|
|
10538
|
+
return !arg.startsWith("--");
|
|
10539
|
+
});
|
|
10540
|
+
if (positional[0] === "trust")
|
|
10541
|
+
return { kind: "trust", list: argv.includes("--list") };
|
|
10542
|
+
if (positional[0] === "untrust")
|
|
10543
|
+
return { kind: "untrust" };
|
|
10544
|
+
return { kind: "list" };
|
|
10545
|
+
}
|
|
10546
|
+
function truncate(value) {
|
|
10547
|
+
return value.length <= 80 ? value : `${value.slice(0, 77)}…`;
|
|
10548
|
+
}
|
|
10549
|
+
function formatHome(path) {
|
|
10550
|
+
const home = homedir5();
|
|
10551
|
+
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
10552
|
+
}
|
|
10553
|
+
function formatProjectPath(path, projectRoot) {
|
|
10554
|
+
if (!path)
|
|
10555
|
+
return "";
|
|
10556
|
+
const rel = relative(projectRoot, path);
|
|
10557
|
+
return rel.startsWith("..") || rel === "" ? path : `./${rel}`;
|
|
10558
|
+
}
|
|
10559
|
+
function formatSourcePath(path, projectRoot) {
|
|
10560
|
+
if (!path)
|
|
10561
|
+
return;
|
|
10562
|
+
return formatProjectPath(path, projectRoot);
|
|
10563
|
+
}
|
|
10564
|
+
var init_doctor_filters = __esm(() => {
|
|
10565
|
+
init_aft_bridge();
|
|
10566
|
+
init_binary_probe();
|
|
10567
|
+
init_harness_select();
|
|
10568
|
+
init_prompts();
|
|
10569
|
+
init_self_version();
|
|
10570
|
+
});
|
|
10571
|
+
|
|
10322
10572
|
// src/lib/binary-cache.ts
|
|
10323
|
-
import { existsSync as
|
|
10573
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
10324
10574
|
import { join as join7 } from "node:path";
|
|
10325
10575
|
function getBinaryCacheInfo(activeVersion) {
|
|
10326
10576
|
const path = getAftBinaryCacheDir();
|
|
10327
|
-
if (!
|
|
10577
|
+
if (!existsSync8(path)) {
|
|
10328
10578
|
return {
|
|
10329
10579
|
versions: [],
|
|
10330
10580
|
activeVersion: null,
|
|
@@ -10354,10 +10604,10 @@ var init_binary_cache = __esm(() => {
|
|
|
10354
10604
|
});
|
|
10355
10605
|
|
|
10356
10606
|
// src/lib/lsp-cache.ts
|
|
10357
|
-
import { existsSync as
|
|
10607
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4, rmSync as rmSync2, statSync as statSync5 } from "node:fs";
|
|
10358
10608
|
import { join as join8 } from "node:path";
|
|
10359
10609
|
function inspectDir(path) {
|
|
10360
|
-
if (!
|
|
10610
|
+
if (!existsSync9(path)) {
|
|
10361
10611
|
return { entries: [], totalSize: 0 };
|
|
10362
10612
|
}
|
|
10363
10613
|
const entries = [];
|
|
@@ -10427,7 +10677,7 @@ var init_lsp_cache = __esm(() => {
|
|
|
10427
10677
|
});
|
|
10428
10678
|
|
|
10429
10679
|
// src/lib/onnx.ts
|
|
10430
|
-
import { existsSync as
|
|
10680
|
+
import { existsSync as existsSync10, readdirSync as readdirSync5, readlinkSync, realpathSync, statSync as statSync6 } from "node:fs";
|
|
10431
10681
|
import { join as join9 } from "node:path";
|
|
10432
10682
|
function getOnnxLibraryName() {
|
|
10433
10683
|
if (process.platform === "darwin")
|
|
@@ -10461,17 +10711,17 @@ function findSystemOnnxRuntime() {
|
|
|
10461
10711
|
const libName = getOnnxLibraryName();
|
|
10462
10712
|
const searchPaths = process.platform === "darwin" ? ["/opt/homebrew/lib", "/usr/local/lib"] : process.platform === "linux" ? ["/usr/lib", "/usr/lib/x86_64-linux-gnu", "/usr/lib/aarch64-linux-gnu", "/usr/local/lib"] : [];
|
|
10463
10713
|
for (const path of searchPaths) {
|
|
10464
|
-
if (
|
|
10714
|
+
if (existsSync10(join9(path, libName)))
|
|
10465
10715
|
return path;
|
|
10466
10716
|
}
|
|
10467
10717
|
return null;
|
|
10468
10718
|
}
|
|
10469
10719
|
function findCachedOnnxRuntime(storageDir) {
|
|
10470
10720
|
const ortDir = join9(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
|
|
10471
|
-
return
|
|
10721
|
+
return existsSync10(join9(ortDir, getOnnxLibraryName())) ? ortDir : null;
|
|
10472
10722
|
}
|
|
10473
10723
|
function detectOrtVersion(libDir) {
|
|
10474
|
-
if (!
|
|
10724
|
+
if (!existsSync10(libDir))
|
|
10475
10725
|
return null;
|
|
10476
10726
|
const libName = getOnnxLibraryName();
|
|
10477
10727
|
try {
|
|
@@ -10484,7 +10734,7 @@ function detectOrtVersion(libDir) {
|
|
|
10484
10734
|
return match[1];
|
|
10485
10735
|
}
|
|
10486
10736
|
const base = join9(libDir, libName);
|
|
10487
|
-
if (
|
|
10737
|
+
if (existsSync10(base)) {
|
|
10488
10738
|
try {
|
|
10489
10739
|
const real = realpathSync(base);
|
|
10490
10740
|
const suffix = real.match(/\.(\d+\.\d+\.\d+)$/);
|
|
@@ -10514,13 +10764,13 @@ var ONNX_RUNTIME_VERSION = "1.24.4", REQUIRED_ORT_MAJOR = 1, REQUIRED_ORT_MIN_MI
|
|
|
10514
10764
|
var init_onnx = () => {};
|
|
10515
10765
|
|
|
10516
10766
|
// src/lib/sanitize.ts
|
|
10517
|
-
import { homedir as
|
|
10767
|
+
import { homedir as homedir6, userInfo } from "node:os";
|
|
10518
10768
|
function escapeRegex(value) {
|
|
10519
10769
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10520
10770
|
}
|
|
10521
10771
|
function sanitizeContent(content) {
|
|
10522
10772
|
const username = userInfo().username;
|
|
10523
|
-
const home =
|
|
10773
|
+
const home = homedir6();
|
|
10524
10774
|
let sanitized = content;
|
|
10525
10775
|
if (home) {
|
|
10526
10776
|
sanitized = sanitized.replace(new RegExp(escapeRegex(home), "g"), "~");
|
|
@@ -10549,7 +10799,7 @@ function sanitizeValue(value) {
|
|
|
10549
10799
|
var init_sanitize = () => {};
|
|
10550
10800
|
|
|
10551
10801
|
// src/lib/diagnostics.ts
|
|
10552
|
-
import { existsSync as
|
|
10802
|
+
import { existsSync as existsSync11, readFileSync as readFileSync4, statSync as statSync7 } from "node:fs";
|
|
10553
10803
|
async function collectDiagnostics(adapters) {
|
|
10554
10804
|
const cliVersion = getSelfVersion();
|
|
10555
10805
|
const binaryVersion = probeBinaryVersion(cliVersion);
|
|
@@ -10589,14 +10839,14 @@ async function diagnoseHarness(adapter) {
|
|
|
10589
10839
|
pluginRegistered: adapter.hasPluginEntry(),
|
|
10590
10840
|
configPaths,
|
|
10591
10841
|
aftConfig: {
|
|
10592
|
-
exists:
|
|
10842
|
+
exists: existsSync11(configPaths.aftConfig),
|
|
10593
10843
|
...aftConfigRead.error ? { parseError: aftConfigRead.error } : {},
|
|
10594
10844
|
flags: aftFlags
|
|
10595
10845
|
},
|
|
10596
10846
|
pluginCache: adapter.getPluginCacheInfo(),
|
|
10597
10847
|
storageDir: {
|
|
10598
10848
|
path: storage,
|
|
10599
|
-
exists:
|
|
10849
|
+
exists: existsSync11(storage),
|
|
10600
10850
|
sizesByKey: describeStorage
|
|
10601
10851
|
},
|
|
10602
10852
|
onnxRuntime: {
|
|
@@ -10613,8 +10863,8 @@ async function diagnoseHarness(adapter) {
|
|
|
10613
10863
|
},
|
|
10614
10864
|
logFile: {
|
|
10615
10865
|
path: logPath,
|
|
10616
|
-
exists:
|
|
10617
|
-
sizeKb:
|
|
10866
|
+
exists: existsSync11(logPath),
|
|
10867
|
+
sizeKb: existsSync11(logPath) ? Math.round(statSync7(logPath).size / 1024) : 0
|
|
10618
10868
|
}
|
|
10619
10869
|
};
|
|
10620
10870
|
}
|
|
@@ -10674,7 +10924,7 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
10674
10924
|
`);
|
|
10675
10925
|
}
|
|
10676
10926
|
function tailLogFile(path, lines) {
|
|
10677
|
-
if (!
|
|
10927
|
+
if (!existsSync11(path))
|
|
10678
10928
|
return "";
|
|
10679
10929
|
try {
|
|
10680
10930
|
const raw = readFileSync4(path, "utf-8");
|
|
@@ -10732,7 +10982,7 @@ function createGitHubIssue(repo, title, body) {
|
|
|
10732
10982
|
var init_github = () => {};
|
|
10733
10983
|
|
|
10734
10984
|
// src/lib/onnx-fix.ts
|
|
10735
|
-
import { existsSync as
|
|
10985
|
+
import { existsSync as existsSync12, rmSync as rmSync3 } from "node:fs";
|
|
10736
10986
|
import { join as join10 } from "node:path";
|
|
10737
10987
|
function findOnnxFixCandidates(report) {
|
|
10738
10988
|
const candidates = [];
|
|
@@ -10750,7 +11000,7 @@ function findOnnxFixCandidates(report) {
|
|
|
10750
11000
|
harness,
|
|
10751
11001
|
reason: `cached ONNX Runtime at ${harness.onnxRuntime.cachedPath} is v${harness.onnxRuntime.cachedVersion}, but AFT requires ${harness.onnxRuntime.requirement}. Clearing forces a fresh download on next start.`,
|
|
10752
11002
|
storageOnnxDir,
|
|
10753
|
-
storageOnnxBytes:
|
|
11003
|
+
storageOnnxBytes: existsSync12(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10754
11004
|
});
|
|
10755
11005
|
continue;
|
|
10756
11006
|
}
|
|
@@ -10759,7 +11009,7 @@ function findOnnxFixCandidates(report) {
|
|
|
10759
11009
|
harness,
|
|
10760
11010
|
reason: `system ONNX Runtime at ${harness.onnxRuntime.systemPath} is v${harness.onnxRuntime.systemVersion}, but AFT requires ${harness.onnxRuntime.requirement}, and no AFT-managed install is present. AFT v0.19.5+ skips incompatible system installs and auto-downloads v1.24 on next start; clearing any stale state here ensures a clean slate.`,
|
|
10761
11011
|
storageOnnxDir,
|
|
10762
|
-
storageOnnxBytes:
|
|
11012
|
+
storageOnnxBytes: existsSync12(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10763
11013
|
});
|
|
10764
11014
|
}
|
|
10765
11015
|
}
|
|
@@ -10789,7 +11039,7 @@ async function runOnnxFix(adapters, report, options = {}) {
|
|
|
10789
11039
|
const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
|
|
10790
11040
|
const rmFn = options.rmFn ?? rmSync3;
|
|
10791
11041
|
for (const c2 of candidates) {
|
|
10792
|
-
if (!
|
|
11042
|
+
if (!existsSync12(c2.storageOnnxDir)) {
|
|
10793
11043
|
O2.success(`${c2.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
|
|
10794
11044
|
continue;
|
|
10795
11045
|
}
|
|
@@ -10823,7 +11073,7 @@ __export(exports_doctor, {
|
|
|
10823
11073
|
DOCTOR_FORCE_CLEAR_TARGETS: () => DOCTOR_FORCE_CLEAR_TARGETS,
|
|
10824
11074
|
DOCTOR_CLEAR_TARGET_OPTIONS: () => DOCTOR_CLEAR_TARGET_OPTIONS
|
|
10825
11075
|
});
|
|
10826
|
-
import { existsSync as
|
|
11076
|
+
import { existsSync as existsSync13, rmSync as rmSync4, statSync as statSync8, writeFileSync as writeFileSync2 } from "node:fs";
|
|
10827
11077
|
import { join as join11 } from "node:path";
|
|
10828
11078
|
async function runDoctor(options) {
|
|
10829
11079
|
if (options.issue) {
|
|
@@ -10965,7 +11215,7 @@ function clearOldBinaries() {
|
|
|
10965
11215
|
errors: [],
|
|
10966
11216
|
keptVersion: keepTag
|
|
10967
11217
|
};
|
|
10968
|
-
if (!
|
|
11218
|
+
if (!existsSync13(info.path)) {
|
|
10969
11219
|
O2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
10970
11220
|
return result;
|
|
10971
11221
|
}
|
|
@@ -11203,6 +11453,10 @@ async function main() {
|
|
|
11203
11453
|
const { runLspDoctor: runLspDoctor2 } = await Promise.resolve().then(() => (init_lsp(), exports_lsp));
|
|
11204
11454
|
return runLspDoctor2({ argv: args.slice(1) });
|
|
11205
11455
|
}
|
|
11456
|
+
if (args[0] === "filters") {
|
|
11457
|
+
const { runDoctorFilters: runDoctorFilters2 } = await Promise.resolve().then(() => (init_doctor_filters(), exports_doctor_filters));
|
|
11458
|
+
return runDoctorFilters2({ argv: args.slice(1) });
|
|
11459
|
+
}
|
|
11206
11460
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), exports_doctor));
|
|
11207
11461
|
const force = args.includes("--force");
|
|
11208
11462
|
const clear = args.includes("--clear");
|
package/package.json
CHANGED