@cortexkit/aft 0.20.1 → 0.22.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
|
@@ -9871,6 +9871,15 @@ var init_setup = __esm(() => {
|
|
|
9871
9871
|
|
|
9872
9872
|
// src/lib/aft-bridge.ts
|
|
9873
9873
|
import { spawn } from "node:child_process";
|
|
9874
|
+
function isResponseForRequest(parsed, expectedIds) {
|
|
9875
|
+
if (!parsed || typeof parsed !== "object")
|
|
9876
|
+
return false;
|
|
9877
|
+
const obj = parsed;
|
|
9878
|
+
const id = obj.id;
|
|
9879
|
+
if (typeof id !== "string")
|
|
9880
|
+
return false;
|
|
9881
|
+
return expectedIds.has(id);
|
|
9882
|
+
}
|
|
9874
9883
|
async function sendAftRequests(binaryPath, requests) {
|
|
9875
9884
|
return new Promise((resolve2, reject) => {
|
|
9876
9885
|
const child = spawn(binaryPath, [], {
|
|
@@ -9888,6 +9897,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9888
9897
|
child.kill();
|
|
9889
9898
|
fn();
|
|
9890
9899
|
};
|
|
9900
|
+
const expectedIds = new Set(requests.map((req) => req.id));
|
|
9891
9901
|
const handleLine = (line) => {
|
|
9892
9902
|
if (!line)
|
|
9893
9903
|
return;
|
|
@@ -9895,14 +9905,20 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9895
9905
|
noiseLines.push(line);
|
|
9896
9906
|
return;
|
|
9897
9907
|
}
|
|
9908
|
+
let parsed;
|
|
9898
9909
|
try {
|
|
9899
|
-
|
|
9900
|
-
responses.push(parsed);
|
|
9901
|
-
if (responses.length === requests.length) {
|
|
9902
|
-
finish(() => resolve2(responses));
|
|
9903
|
-
}
|
|
9910
|
+
parsed = JSON.parse(line);
|
|
9904
9911
|
} catch {
|
|
9905
9912
|
noiseLines.push(line);
|
|
9913
|
+
return;
|
|
9914
|
+
}
|
|
9915
|
+
if (!isResponseForRequest(parsed, expectedIds)) {
|
|
9916
|
+
return;
|
|
9917
|
+
}
|
|
9918
|
+
const response = parsed;
|
|
9919
|
+
responses.push(response);
|
|
9920
|
+
if (responses.length === requests.length) {
|
|
9921
|
+
finish(() => resolve2(responses));
|
|
9906
9922
|
}
|
|
9907
9923
|
};
|
|
9908
9924
|
child.stdout.setEncoding("utf-8");
|
|
@@ -10248,9 +10264,7 @@ function resolveCustomServers(servers) {
|
|
|
10248
10264
|
};
|
|
10249
10265
|
}).filter((server) => typeof server.binary === "string" && server.binary.length > 0);
|
|
10250
10266
|
}
|
|
10251
|
-
function inferLspPathsExtra(
|
|
10252
|
-
if (lsp.auto_install === false)
|
|
10253
|
-
return [];
|
|
10267
|
+
function inferLspPathsExtra(_lsp) {
|
|
10254
10268
|
const paths = new Set;
|
|
10255
10269
|
for (const entry of childDirs(getAftLspPackagesDir())) {
|
|
10256
10270
|
paths.add(join6(entry, "node_modules", ".bin"));
|
|
@@ -10319,12 +10333,262 @@ var init_lsp = __esm(() => {
|
|
|
10319
10333
|
init_self_version();
|
|
10320
10334
|
});
|
|
10321
10335
|
|
|
10336
|
+
// src/commands/doctor-filters.ts
|
|
10337
|
+
var exports_doctor_filters = {};
|
|
10338
|
+
__export(exports_doctor_filters, {
|
|
10339
|
+
runDoctorFilters: () => runDoctorFilters,
|
|
10340
|
+
renderTrustedProjects: () => renderTrustedProjects,
|
|
10341
|
+
renderFilterShow: () => renderFilterShow,
|
|
10342
|
+
renderFilterList: () => renderFilterList,
|
|
10343
|
+
printDoctorFiltersHelp: () => printDoctorFiltersHelp
|
|
10344
|
+
});
|
|
10345
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
10346
|
+
import { homedir as homedir5 } from "node:os";
|
|
10347
|
+
import { relative, resolve as resolve3 } from "node:path";
|
|
10348
|
+
function printDoctorFiltersHelp() {
|
|
10349
|
+
console.log("Usage: aft doctor filters [--show <name>] [trust|untrust]");
|
|
10350
|
+
console.log("");
|
|
10351
|
+
console.log("Inspect declarative TOML compression filters.");
|
|
10352
|
+
console.log("");
|
|
10353
|
+
console.log("Commands:");
|
|
10354
|
+
console.log(" aft doctor filters List built-in, user, and project filters");
|
|
10355
|
+
console.log(" aft doctor filters --show <name> Show resolved TOML for a filter");
|
|
10356
|
+
console.log(" aft doctor filters trust Trust current project's .aft/filters");
|
|
10357
|
+
console.log(" aft doctor filters trust --list List trusted filter project paths");
|
|
10358
|
+
console.log(" aft doctor filters untrust Remove trusted project paths");
|
|
10359
|
+
}
|
|
10360
|
+
async function runDoctorFilters(options) {
|
|
10361
|
+
const mode = parseMode(options.argv);
|
|
10362
|
+
if (mode.kind === "help") {
|
|
10363
|
+
printDoctorFiltersHelp();
|
|
10364
|
+
return 0;
|
|
10365
|
+
}
|
|
10366
|
+
const resolveAdapters = options.resolveAdapters ?? resolveAdaptersForCommand;
|
|
10367
|
+
const adapters = await resolveAdapters(options.argv, {
|
|
10368
|
+
allowMulti: false,
|
|
10369
|
+
verb: "inspect filters for"
|
|
10370
|
+
});
|
|
10371
|
+
const adapter = adapters[0];
|
|
10372
|
+
if (!adapter) {
|
|
10373
|
+
O2.error("No harness selected.");
|
|
10374
|
+
return 1;
|
|
10375
|
+
}
|
|
10376
|
+
const findBinary = options.findBinary ?? findAftBinary;
|
|
10377
|
+
const binary = findBinary(getSelfVersion());
|
|
10378
|
+
if (!binary) {
|
|
10379
|
+
O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
10380
|
+
return 1;
|
|
10381
|
+
}
|
|
10382
|
+
const projectRoot = resolve3(process.cwd());
|
|
10383
|
+
const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
|
|
10384
|
+
if (!list.success) {
|
|
10385
|
+
O2.error(list.message ?? list.code ?? "list_filters failed");
|
|
10386
|
+
return 1;
|
|
10387
|
+
}
|
|
10388
|
+
list.project_dir_exists = list.project_dir ? existsSync7(list.project_dir) : false;
|
|
10389
|
+
if (mode.kind === "list") {
|
|
10390
|
+
console.log(renderFilterList(list, projectRoot));
|
|
10391
|
+
return 0;
|
|
10392
|
+
}
|
|
10393
|
+
if (mode.kind === "show") {
|
|
10394
|
+
const rendered = renderFilterShow(list, mode.name, projectRoot);
|
|
10395
|
+
if (!rendered) {
|
|
10396
|
+
O2.error(`Filter not found: ${mode.name}`);
|
|
10397
|
+
return 1;
|
|
10398
|
+
}
|
|
10399
|
+
console.log(rendered);
|
|
10400
|
+
return 0;
|
|
10401
|
+
}
|
|
10402
|
+
if (mode.kind === "trust") {
|
|
10403
|
+
if (mode.list) {
|
|
10404
|
+
console.log(renderTrustedProjects(list.trusted_projects ?? []));
|
|
10405
|
+
return 0;
|
|
10406
|
+
}
|
|
10407
|
+
return runTrustFlow(binary, list, adapter, projectRoot, options);
|
|
10408
|
+
}
|
|
10409
|
+
return runUntrustFlow(binary, list, adapter, projectRoot, options);
|
|
10410
|
+
}
|
|
10411
|
+
async function listFilters(binary, adapter, projectRoot, sendRequests) {
|
|
10412
|
+
const responses = await sendRequests(binary, [
|
|
10413
|
+
buildConfigureRequest(adapter, projectRoot),
|
|
10414
|
+
{ id: "doctor-filters-list", command: "list_filters" }
|
|
10415
|
+
]);
|
|
10416
|
+
const configure = responses[0];
|
|
10417
|
+
if (configure && !configure.success)
|
|
10418
|
+
return configure;
|
|
10419
|
+
return responses[1] ?? {
|
|
10420
|
+
success: false,
|
|
10421
|
+
message: "aft exited before list_filters"
|
|
10422
|
+
};
|
|
10423
|
+
}
|
|
10424
|
+
function buildConfigureRequest(adapter, projectRoot) {
|
|
10425
|
+
return {
|
|
10426
|
+
id: "doctor-filters-configure",
|
|
10427
|
+
command: "configure",
|
|
10428
|
+
project_root: projectRoot,
|
|
10429
|
+
storage_dir: adapter.getStorageDir()
|
|
10430
|
+
};
|
|
10431
|
+
}
|
|
10432
|
+
async function runTrustFlow(binary, list, adapter, projectRoot, options) {
|
|
10433
|
+
const filters = (list.filters ?? []).filter((filter) => filter.source.startsWith("project") && filter.trusted === false);
|
|
10434
|
+
if (filters.length === 0) {
|
|
10435
|
+
console.log(`No untrusted project filters in ${projectRoot}.`);
|
|
10436
|
+
return 0;
|
|
10437
|
+
}
|
|
10438
|
+
const prompt = options.selectMany ?? selectMany;
|
|
10439
|
+
const selected = await prompt("Trust project filters?", filters.map((filter) => ({
|
|
10440
|
+
label: filter.error ? `${filter.name} (invalid: ${filter.error})` : filter.name,
|
|
10441
|
+
value: filter.name,
|
|
10442
|
+
hint: formatSourcePath(filter.source_path, projectRoot)
|
|
10443
|
+
})), filters.map((filter) => filter.name), false);
|
|
10444
|
+
if (selected.length === 0) {
|
|
10445
|
+
console.log("Trusted 0 project(s). Restart AFT (or reconfigure) for filters to take effect.");
|
|
10446
|
+
return 0;
|
|
10447
|
+
}
|
|
10448
|
+
const sendRequests = options.sendRequests ?? sendAftRequests;
|
|
10449
|
+
const responses = await sendRequests(binary, [
|
|
10450
|
+
buildConfigureRequest(adapter, projectRoot),
|
|
10451
|
+
{ id: "doctor-filters-trust", command: "trust_filter_project", project_root: projectRoot }
|
|
10452
|
+
]);
|
|
10453
|
+
const trust = responses[responses.length - 1];
|
|
10454
|
+
if (!trust?.success) {
|
|
10455
|
+
O2.error(trust?.message ?? trust?.code ?? "trust_filter_project failed");
|
|
10456
|
+
return 1;
|
|
10457
|
+
}
|
|
10458
|
+
console.log("Trusted 1 project(s). Restart AFT (or reconfigure) for filters to take effect.");
|
|
10459
|
+
return 0;
|
|
10460
|
+
}
|
|
10461
|
+
async function runUntrustFlow(binary, list, adapter, projectRoot, options) {
|
|
10462
|
+
const trusted = list.trusted_projects ?? [];
|
|
10463
|
+
if (trusted.length === 0) {
|
|
10464
|
+
console.log("No trusted filter projects.");
|
|
10465
|
+
return 0;
|
|
10466
|
+
}
|
|
10467
|
+
const prompt = options.selectMany ?? selectMany;
|
|
10468
|
+
const selected = await prompt("Untrust filter projects?", trusted.map((path) => ({ label: path, value: path })), undefined, false);
|
|
10469
|
+
if (selected.length === 0) {
|
|
10470
|
+
console.log("Untrusted 0 project(s).");
|
|
10471
|
+
return 0;
|
|
10472
|
+
}
|
|
10473
|
+
const requests = [buildConfigureRequest(adapter, projectRoot)];
|
|
10474
|
+
for (const path of selected) {
|
|
10475
|
+
requests.push({
|
|
10476
|
+
id: `doctor-filters-untrust-${requests.length}`,
|
|
10477
|
+
command: "untrust_filter_project",
|
|
10478
|
+
project_root: path
|
|
10479
|
+
});
|
|
10480
|
+
}
|
|
10481
|
+
const responses = await (options.sendRequests ?? sendAftRequests)(binary, requests);
|
|
10482
|
+
const failures = responses.slice(1).filter((response) => !response.success);
|
|
10483
|
+
if (failures.length > 0) {
|
|
10484
|
+
O2.error(failures[0]?.message ?? failures[0]?.code ?? "untrust_filter_project failed");
|
|
10485
|
+
return 1;
|
|
10486
|
+
}
|
|
10487
|
+
console.log(`Untrusted ${selected.length} project(s). Restart AFT (or reconfigure) for filters to take effect.`);
|
|
10488
|
+
return 0;
|
|
10489
|
+
}
|
|
10490
|
+
function renderFilterList(response, projectRoot = process.cwd()) {
|
|
10491
|
+
const filters = response.filters ?? [];
|
|
10492
|
+
const lines = ["TOML compression filters", ""];
|
|
10493
|
+
pushSection(lines, "Built-in", filters.filter((filter) => filter.source === "builtin" || filter.source === "builtin_invalid"));
|
|
10494
|
+
lines.push("");
|
|
10495
|
+
pushSection(lines, `User (${formatHome(response.user_dir ?? "")}`, filters.filter((filter) => filter.source === "user" || filter.source === "user_invalid"), true);
|
|
10496
|
+
const projectFilters = filters.filter((filter) => filter.source === "project" || filter.source === "project_invalid");
|
|
10497
|
+
if (response.project_dir_exists || projectFilters.length > 0) {
|
|
10498
|
+
lines.push("");
|
|
10499
|
+
pushSection(lines, `Project (${formatProjectPath(response.project_dir ?? "", projectRoot)}`, projectFilters, true);
|
|
10500
|
+
}
|
|
10501
|
+
return lines.join(`
|
|
10502
|
+
`);
|
|
10503
|
+
}
|
|
10504
|
+
function pushSection(lines, title, filters, titleHasOpenParen = false) {
|
|
10505
|
+
lines.push(titleHasOpenParen ? `${title}, ${filters.length}):` : `${title} (${filters.length}):`);
|
|
10506
|
+
if (filters.length === 0) {
|
|
10507
|
+
lines.push(" (empty)");
|
|
10508
|
+
return;
|
|
10509
|
+
}
|
|
10510
|
+
for (const filter of filters) {
|
|
10511
|
+
const description = filter.error ? `invalid — ${filter.error}` : truncate(filter.description ?? "");
|
|
10512
|
+
const trust = filter.source.startsWith("project") && filter.trusted === false ? filter.error ? " (untrusted)" : " (untrusted — run `aft doctor filters trust` to enable)" : "";
|
|
10513
|
+
lines.push(` ${filter.name.padEnd(20)} ${description}${trust}`.trimEnd());
|
|
10514
|
+
}
|
|
10515
|
+
}
|
|
10516
|
+
function renderFilterShow(response, name, projectRoot = process.cwd()) {
|
|
10517
|
+
const filter = (response.filters ?? []).find((entry) => entry.name === name || entry.matches.includes(name));
|
|
10518
|
+
if (!filter)
|
|
10519
|
+
return null;
|
|
10520
|
+
const lines = [`Filter: ${filter.name}`];
|
|
10521
|
+
if (filter.source === "builtin") {
|
|
10522
|
+
lines.push("Source: built-in");
|
|
10523
|
+
} else if (filter.source.startsWith("user")) {
|
|
10524
|
+
lines.push(`Source: user (${formatHome(filter.source_path ?? "")})`);
|
|
10525
|
+
} else if (filter.source.startsWith("project")) {
|
|
10526
|
+
lines.push(`Source: project (${formatProjectPath(filter.source_path ?? "", projectRoot)})`);
|
|
10527
|
+
lines.push(`Trust: ${filter.trusted ? "trusted" : "untrusted"}`);
|
|
10528
|
+
} else {
|
|
10529
|
+
lines.push(`Source: ${filter.source}`);
|
|
10530
|
+
}
|
|
10531
|
+
if (filter.error)
|
|
10532
|
+
lines.push(`Error: ${filter.error}`);
|
|
10533
|
+
lines.push("", filter.content.trimEnd());
|
|
10534
|
+
return lines.join(`
|
|
10535
|
+
`);
|
|
10536
|
+
}
|
|
10537
|
+
function renderTrustedProjects(paths) {
|
|
10538
|
+
return paths.length === 0 ? "(none)" : paths.join(`
|
|
10539
|
+
`);
|
|
10540
|
+
}
|
|
10541
|
+
function parseMode(argv) {
|
|
10542
|
+
if (argv.includes("--help") || argv.includes("-h"))
|
|
10543
|
+
return { kind: "help" };
|
|
10544
|
+
const showIndex = argv.indexOf("--show");
|
|
10545
|
+
if (showIndex >= 0)
|
|
10546
|
+
return { kind: "show", name: argv[showIndex + 1] ?? "" };
|
|
10547
|
+
const positional = argv.filter((arg, index) => {
|
|
10548
|
+
if (arg === "--harness")
|
|
10549
|
+
return false;
|
|
10550
|
+
if (index > 0 && argv[index - 1] === "--harness")
|
|
10551
|
+
return false;
|
|
10552
|
+
return !arg.startsWith("--");
|
|
10553
|
+
});
|
|
10554
|
+
if (positional[0] === "trust")
|
|
10555
|
+
return { kind: "trust", list: argv.includes("--list") };
|
|
10556
|
+
if (positional[0] === "untrust")
|
|
10557
|
+
return { kind: "untrust" };
|
|
10558
|
+
return { kind: "list" };
|
|
10559
|
+
}
|
|
10560
|
+
function truncate(value) {
|
|
10561
|
+
return value.length <= 80 ? value : `${value.slice(0, 77)}…`;
|
|
10562
|
+
}
|
|
10563
|
+
function formatHome(path) {
|
|
10564
|
+
const home = homedir5();
|
|
10565
|
+
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
10566
|
+
}
|
|
10567
|
+
function formatProjectPath(path, projectRoot) {
|
|
10568
|
+
if (!path)
|
|
10569
|
+
return "";
|
|
10570
|
+
const rel = relative(projectRoot, path);
|
|
10571
|
+
return rel.startsWith("..") || rel === "" ? path : `./${rel}`;
|
|
10572
|
+
}
|
|
10573
|
+
function formatSourcePath(path, projectRoot) {
|
|
10574
|
+
if (!path)
|
|
10575
|
+
return;
|
|
10576
|
+
return formatProjectPath(path, projectRoot);
|
|
10577
|
+
}
|
|
10578
|
+
var init_doctor_filters = __esm(() => {
|
|
10579
|
+
init_aft_bridge();
|
|
10580
|
+
init_binary_probe();
|
|
10581
|
+
init_harness_select();
|
|
10582
|
+
init_prompts();
|
|
10583
|
+
init_self_version();
|
|
10584
|
+
});
|
|
10585
|
+
|
|
10322
10586
|
// src/lib/binary-cache.ts
|
|
10323
|
-
import { existsSync as
|
|
10587
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
10324
10588
|
import { join as join7 } from "node:path";
|
|
10325
10589
|
function getBinaryCacheInfo(activeVersion) {
|
|
10326
10590
|
const path = getAftBinaryCacheDir();
|
|
10327
|
-
if (!
|
|
10591
|
+
if (!existsSync8(path)) {
|
|
10328
10592
|
return {
|
|
10329
10593
|
versions: [],
|
|
10330
10594
|
activeVersion: null,
|
|
@@ -10354,10 +10618,10 @@ var init_binary_cache = __esm(() => {
|
|
|
10354
10618
|
});
|
|
10355
10619
|
|
|
10356
10620
|
// src/lib/lsp-cache.ts
|
|
10357
|
-
import { existsSync as
|
|
10621
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4, rmSync as rmSync2, statSync as statSync5 } from "node:fs";
|
|
10358
10622
|
import { join as join8 } from "node:path";
|
|
10359
10623
|
function inspectDir(path) {
|
|
10360
|
-
if (!
|
|
10624
|
+
if (!existsSync9(path)) {
|
|
10361
10625
|
return { entries: [], totalSize: 0 };
|
|
10362
10626
|
}
|
|
10363
10627
|
const entries = [];
|
|
@@ -10427,7 +10691,7 @@ var init_lsp_cache = __esm(() => {
|
|
|
10427
10691
|
});
|
|
10428
10692
|
|
|
10429
10693
|
// src/lib/onnx.ts
|
|
10430
|
-
import { existsSync as
|
|
10694
|
+
import { existsSync as existsSync10, readdirSync as readdirSync5, readlinkSync, realpathSync, statSync as statSync6 } from "node:fs";
|
|
10431
10695
|
import { join as join9 } from "node:path";
|
|
10432
10696
|
function getOnnxLibraryName() {
|
|
10433
10697
|
if (process.platform === "darwin")
|
|
@@ -10461,17 +10725,17 @@ function findSystemOnnxRuntime() {
|
|
|
10461
10725
|
const libName = getOnnxLibraryName();
|
|
10462
10726
|
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
10727
|
for (const path of searchPaths) {
|
|
10464
|
-
if (
|
|
10728
|
+
if (existsSync10(join9(path, libName)))
|
|
10465
10729
|
return path;
|
|
10466
10730
|
}
|
|
10467
10731
|
return null;
|
|
10468
10732
|
}
|
|
10469
10733
|
function findCachedOnnxRuntime(storageDir) {
|
|
10470
10734
|
const ortDir = join9(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
|
|
10471
|
-
return
|
|
10735
|
+
return existsSync10(join9(ortDir, getOnnxLibraryName())) ? ortDir : null;
|
|
10472
10736
|
}
|
|
10473
10737
|
function detectOrtVersion(libDir) {
|
|
10474
|
-
if (!
|
|
10738
|
+
if (!existsSync10(libDir))
|
|
10475
10739
|
return null;
|
|
10476
10740
|
const libName = getOnnxLibraryName();
|
|
10477
10741
|
try {
|
|
@@ -10484,7 +10748,7 @@ function detectOrtVersion(libDir) {
|
|
|
10484
10748
|
return match[1];
|
|
10485
10749
|
}
|
|
10486
10750
|
const base = join9(libDir, libName);
|
|
10487
|
-
if (
|
|
10751
|
+
if (existsSync10(base)) {
|
|
10488
10752
|
try {
|
|
10489
10753
|
const real = realpathSync(base);
|
|
10490
10754
|
const suffix = real.match(/\.(\d+\.\d+\.\d+)$/);
|
|
@@ -10514,13 +10778,13 @@ var ONNX_RUNTIME_VERSION = "1.24.4", REQUIRED_ORT_MAJOR = 1, REQUIRED_ORT_MIN_MI
|
|
|
10514
10778
|
var init_onnx = () => {};
|
|
10515
10779
|
|
|
10516
10780
|
// src/lib/sanitize.ts
|
|
10517
|
-
import { homedir as
|
|
10781
|
+
import { homedir as homedir6, userInfo } from "node:os";
|
|
10518
10782
|
function escapeRegex(value) {
|
|
10519
10783
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10520
10784
|
}
|
|
10521
10785
|
function sanitizeContent(content) {
|
|
10522
10786
|
const username = userInfo().username;
|
|
10523
|
-
const home =
|
|
10787
|
+
const home = homedir6();
|
|
10524
10788
|
let sanitized = content;
|
|
10525
10789
|
if (home) {
|
|
10526
10790
|
sanitized = sanitized.replace(new RegExp(escapeRegex(home), "g"), "~");
|
|
@@ -10549,7 +10813,7 @@ function sanitizeValue(value) {
|
|
|
10549
10813
|
var init_sanitize = () => {};
|
|
10550
10814
|
|
|
10551
10815
|
// src/lib/diagnostics.ts
|
|
10552
|
-
import { existsSync as
|
|
10816
|
+
import { existsSync as existsSync11, readFileSync as readFileSync4, statSync as statSync7 } from "node:fs";
|
|
10553
10817
|
async function collectDiagnostics(adapters) {
|
|
10554
10818
|
const cliVersion = getSelfVersion();
|
|
10555
10819
|
const binaryVersion = probeBinaryVersion(cliVersion);
|
|
@@ -10589,14 +10853,14 @@ async function diagnoseHarness(adapter) {
|
|
|
10589
10853
|
pluginRegistered: adapter.hasPluginEntry(),
|
|
10590
10854
|
configPaths,
|
|
10591
10855
|
aftConfig: {
|
|
10592
|
-
exists:
|
|
10856
|
+
exists: existsSync11(configPaths.aftConfig),
|
|
10593
10857
|
...aftConfigRead.error ? { parseError: aftConfigRead.error } : {},
|
|
10594
10858
|
flags: aftFlags
|
|
10595
10859
|
},
|
|
10596
10860
|
pluginCache: adapter.getPluginCacheInfo(),
|
|
10597
10861
|
storageDir: {
|
|
10598
10862
|
path: storage,
|
|
10599
|
-
exists:
|
|
10863
|
+
exists: existsSync11(storage),
|
|
10600
10864
|
sizesByKey: describeStorage
|
|
10601
10865
|
},
|
|
10602
10866
|
onnxRuntime: {
|
|
@@ -10613,8 +10877,8 @@ async function diagnoseHarness(adapter) {
|
|
|
10613
10877
|
},
|
|
10614
10878
|
logFile: {
|
|
10615
10879
|
path: logPath,
|
|
10616
|
-
exists:
|
|
10617
|
-
sizeKb:
|
|
10880
|
+
exists: existsSync11(logPath),
|
|
10881
|
+
sizeKb: existsSync11(logPath) ? Math.round(statSync7(logPath).size / 1024) : 0
|
|
10618
10882
|
}
|
|
10619
10883
|
};
|
|
10620
10884
|
}
|
|
@@ -10674,7 +10938,7 @@ function renderDiagnosticsMarkdown(report) {
|
|
|
10674
10938
|
`);
|
|
10675
10939
|
}
|
|
10676
10940
|
function tailLogFile(path, lines) {
|
|
10677
|
-
if (!
|
|
10941
|
+
if (!existsSync11(path))
|
|
10678
10942
|
return "";
|
|
10679
10943
|
try {
|
|
10680
10944
|
const raw = readFileSync4(path, "utf-8");
|
|
@@ -10732,7 +10996,7 @@ function createGitHubIssue(repo, title, body) {
|
|
|
10732
10996
|
var init_github = () => {};
|
|
10733
10997
|
|
|
10734
10998
|
// src/lib/onnx-fix.ts
|
|
10735
|
-
import { existsSync as
|
|
10999
|
+
import { existsSync as existsSync12, rmSync as rmSync3 } from "node:fs";
|
|
10736
11000
|
import { join as join10 } from "node:path";
|
|
10737
11001
|
function findOnnxFixCandidates(report) {
|
|
10738
11002
|
const candidates = [];
|
|
@@ -10750,7 +11014,7 @@ function findOnnxFixCandidates(report) {
|
|
|
10750
11014
|
harness,
|
|
10751
11015
|
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
11016
|
storageOnnxDir,
|
|
10753
|
-
storageOnnxBytes:
|
|
11017
|
+
storageOnnxBytes: existsSync12(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10754
11018
|
});
|
|
10755
11019
|
continue;
|
|
10756
11020
|
}
|
|
@@ -10759,7 +11023,7 @@ function findOnnxFixCandidates(report) {
|
|
|
10759
11023
|
harness,
|
|
10760
11024
|
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
11025
|
storageOnnxDir,
|
|
10762
|
-
storageOnnxBytes:
|
|
11026
|
+
storageOnnxBytes: existsSync12(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10763
11027
|
});
|
|
10764
11028
|
}
|
|
10765
11029
|
}
|
|
@@ -10789,7 +11053,7 @@ async function runOnnxFix(adapters, report, options = {}) {
|
|
|
10789
11053
|
const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
|
|
10790
11054
|
const rmFn = options.rmFn ?? rmSync3;
|
|
10791
11055
|
for (const c2 of candidates) {
|
|
10792
|
-
if (!
|
|
11056
|
+
if (!existsSync12(c2.storageOnnxDir)) {
|
|
10793
11057
|
O2.success(`${c2.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
|
|
10794
11058
|
continue;
|
|
10795
11059
|
}
|
|
@@ -10823,7 +11087,7 @@ __export(exports_doctor, {
|
|
|
10823
11087
|
DOCTOR_FORCE_CLEAR_TARGETS: () => DOCTOR_FORCE_CLEAR_TARGETS,
|
|
10824
11088
|
DOCTOR_CLEAR_TARGET_OPTIONS: () => DOCTOR_CLEAR_TARGET_OPTIONS
|
|
10825
11089
|
});
|
|
10826
|
-
import { existsSync as
|
|
11090
|
+
import { existsSync as existsSync13, rmSync as rmSync4, statSync as statSync8, writeFileSync as writeFileSync2 } from "node:fs";
|
|
10827
11091
|
import { join as join11 } from "node:path";
|
|
10828
11092
|
async function runDoctor(options) {
|
|
10829
11093
|
if (options.issue) {
|
|
@@ -10965,7 +11229,7 @@ function clearOldBinaries() {
|
|
|
10965
11229
|
errors: [],
|
|
10966
11230
|
keptVersion: keepTag
|
|
10967
11231
|
};
|
|
10968
|
-
if (!
|
|
11232
|
+
if (!existsSync13(info.path)) {
|
|
10969
11233
|
O2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
10970
11234
|
return result;
|
|
10971
11235
|
}
|
|
@@ -11203,6 +11467,10 @@ async function main() {
|
|
|
11203
11467
|
const { runLspDoctor: runLspDoctor2 } = await Promise.resolve().then(() => (init_lsp(), exports_lsp));
|
|
11204
11468
|
return runLspDoctor2({ argv: args.slice(1) });
|
|
11205
11469
|
}
|
|
11470
|
+
if (args[0] === "filters") {
|
|
11471
|
+
const { runDoctorFilters: runDoctorFilters2 } = await Promise.resolve().then(() => (init_doctor_filters(), exports_doctor_filters));
|
|
11472
|
+
return runDoctorFilters2({ argv: args.slice(1) });
|
|
11473
|
+
}
|
|
11206
11474
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), exports_doctor));
|
|
11207
11475
|
const force = args.includes("--force");
|
|
11208
11476
|
const clear = args.includes("--clear");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aft-bridge.d.ts","sourceRoot":"","sources":["../../src/lib/aft-bridge.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"aft-bridge.d.ts","sourceRoot":"","sources":["../../src/lib/aft-bridge.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAwBD,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,WAAW,CAAC,CAKtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,UAAU,EAAE,GACrB,OAAO,CAAC,WAAW,EAAE,CAAC,CAsFxB"}
|
package/package.json
CHANGED