@cortexkit/aft 0.19.4 → 0.19.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/adapters/pi.d.ts.map +1 -1
- package/dist/adapters/types.d.ts +2 -2
- package/dist/commands/doctor.d.ts +28 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -19
- package/dist/lib/aft-bridge.d.ts +15 -0
- package/dist/lib/aft-bridge.d.ts.map +1 -1
- package/dist/lib/onnx-fix.d.ts +69 -0
- package/dist/lib/onnx-fix.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ Unified CLI for [Agent File Tools (AFT)](https://github.com/cortexkit/aft) — s
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
npx @cortexkit/aft setup # interactive setup for one or more harnesses
|
|
9
|
+
npx @cortexkit/aft doctor # check and fix configuration issues
|
|
10
|
+
npx @cortexkit/aft doctor --force # force clear plugin cache
|
|
11
|
+
npx @cortexkit/aft doctor --issue # collect diagnostics and open a GitHub issue
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
By default the CLI auto-detects which harnesses are installed on your system (OpenCode, Pi). When multiple are detected, it prompts you to choose. Use `--harness opencode` or `--harness pi` to target one explicitly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../src/adapters/pi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAuDpB,qBAAa,SAAU,YAAW,cAAc;IAC9C,QAAQ,CAAC,IAAI,EAAG,IAAI,CAAU;IAC9B,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,iBAAiB,uBAAe;IACzC,QAAQ,CAAC,sBAAsB,2BAAgB;IAE/C,WAAW,IAAI,OAAO;IAStB,cAAc,IAAI,MAAM,GAAG,IAAI;IAQ/B,iBAAiB,IAAI,kBAAkB;IAevC,cAAc,IAAI,OAAO;IAInB,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAmCrD,kBAAkB,IAAI,eAAe;IA6BrC,aAAa,IAAI,MAAM;IAKvB,UAAU,IAAI,MAAM;IAIpB,cAAc,IAAI,MAAM;IAIlB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;QAC/C,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,OAAO,CAAC;QAC5E,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../src/adapters/pi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAuDpB,qBAAa,SAAU,YAAW,cAAc;IAC9C,QAAQ,CAAC,IAAI,EAAG,IAAI,CAAU;IAC9B,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,iBAAiB,uBAAe;IACzC,QAAQ,CAAC,sBAAsB,2BAAgB;IAE/C,WAAW,IAAI,OAAO;IAStB,cAAc,IAAI,MAAM,GAAG,IAAI;IAQ/B,iBAAiB,IAAI,kBAAkB;IAevC,cAAc,IAAI,OAAO;IAInB,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAmCrD,kBAAkB,IAAI,eAAe;IA6BrC,aAAa,IAAI,MAAM;IAKvB,UAAU,IAAI,MAAM;IAIpB,cAAc,IAAI,MAAM;IAIlB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;QAC/C,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,OAAO,CAAC;QAC5E,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAUF,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAUlD"}
|
package/dist/adapters/types.d.ts
CHANGED
|
@@ -66,8 +66,8 @@ export interface HarnessAdapter {
|
|
|
66
66
|
getInstallHint(): string;
|
|
67
67
|
/**
|
|
68
68
|
* Harness-aware version of `doctor --force` cache clearing. OpenCode nukes
|
|
69
|
-
* its
|
|
70
|
-
* `pi install` itself.
|
|
69
|
+
* its npm/npx package cache (`~/.cache/opencode/packages/...`); Pi may be a
|
|
70
|
+
* no-op because Pi caches are managed by `pi install` itself.
|
|
71
71
|
*/
|
|
72
72
|
clearPluginCache(force: boolean): Promise<{
|
|
73
73
|
action: "cleared" | "up_to_date" | "not_found" | "not_applicable" | "error";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HarnessAdapter } from "../adapters/types.js";
|
|
2
2
|
import { type ClearResult } from "../lib/lsp-cache.js";
|
|
3
|
-
export type DoctorClearTarget = "plugin-cache" | "lsp-cache";
|
|
3
|
+
export type DoctorClearTarget = "plugin-cache" | "lsp-cache" | "binary-cache";
|
|
4
4
|
export declare const DOCTOR_CLEAR_TARGET_OPTIONS: {
|
|
5
5
|
label: string;
|
|
6
6
|
value: DoctorClearTarget;
|
|
@@ -8,6 +8,7 @@ export declare const DOCTOR_CLEAR_TARGET_OPTIONS: {
|
|
|
8
8
|
export declare const DOCTOR_FORCE_CLEAR_TARGETS: DoctorClearTarget[];
|
|
9
9
|
export interface DoctorOptions {
|
|
10
10
|
clear: boolean;
|
|
11
|
+
fix: boolean;
|
|
11
12
|
force: boolean;
|
|
12
13
|
issue: boolean;
|
|
13
14
|
argv: string[];
|
|
@@ -24,6 +25,11 @@ export interface CacheClearSummary {
|
|
|
24
25
|
totalBytes: number;
|
|
25
26
|
errors: number;
|
|
26
27
|
};
|
|
28
|
+
binaryCache?: {
|
|
29
|
+
cleared: number;
|
|
30
|
+
totalBytes: number;
|
|
31
|
+
errors: number;
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
export interface CacheClearOptions {
|
|
29
35
|
clearLspCaches?: () => ClearResult;
|
|
@@ -31,4 +37,25 @@ export interface CacheClearOptions {
|
|
|
31
37
|
}
|
|
32
38
|
export declare function runDoctor(options: DoctorOptions): Promise<number>;
|
|
33
39
|
export declare function clearDoctorCaches(adapters: HarnessAdapter[], targets: readonly DoctorClearTarget[], options?: CacheClearOptions): Promise<CacheClearSummary>;
|
|
40
|
+
/**
|
|
41
|
+
* Clear cached `aft` binaries except the version this CLI ships with.
|
|
42
|
+
*
|
|
43
|
+
* Each release of `@cortexkit/aft` bundles a matching binary version; the
|
|
44
|
+
* plugin downloads it on first use into `~/.cache/aft/bin/v<version>/aft`.
|
|
45
|
+
* Older versions are kept around for rollback and to handle the
|
|
46
|
+
* "old plugin instance still running" scenario, but they pile up over
|
|
47
|
+
* time and a single binary is ~30 MB on macOS / Linux. Clearing keeps
|
|
48
|
+
* the version that matches the running CLI so we don't yank the binary
|
|
49
|
+
* a live OpenCode/Pi process is currently executing from.
|
|
50
|
+
*/
|
|
51
|
+
export interface BinaryCacheClearResult {
|
|
52
|
+
cleared: number;
|
|
53
|
+
bytesReclaimed: number;
|
|
54
|
+
errors: {
|
|
55
|
+
path: string;
|
|
56
|
+
error: string;
|
|
57
|
+
}[];
|
|
58
|
+
keptVersion: string | null;
|
|
59
|
+
}
|
|
60
|
+
export declare function clearOldBinaries(): BinaryCacheClearResult;
|
|
34
61
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAMvE,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,WAAW,GAAG,cAAc,CAAC;AAE9E,eAAO,MAAM,2BAA2B,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,EAapF,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,iBAAiB,EAAqB,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,MAAM,WAAW,CAAC;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAoGvE;AA4BD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CAgD5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,IAAI,sBAAsB,CAsDzD"}
|
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,
|
|
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,CAmBrC"}
|
package/dist/index.js
CHANGED
|
@@ -9007,7 +9007,7 @@ var import_sisteransi, E, G, u, Y, C, O = (r) => ("columns" in r) && typeof r.co
|
|
|
9007
9007
|
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
9008
9008
|
}
|
|
9009
9009
|
}
|
|
9010
|
-
}, H, X, et, st, it, nt, at;
|
|
9010
|
+
}, H, Q, X, et, st, it, nt, at;
|
|
9011
9011
|
var init_dist3 = __esm(() => {
|
|
9012
9012
|
init_main();
|
|
9013
9013
|
import_sisteransi = __toESM(require_src3(), 1);
|
|
@@ -9082,6 +9082,23 @@ var init_dist3 = __esm(() => {
|
|
|
9082
9082
|
}
|
|
9083
9083
|
}
|
|
9084
9084
|
};
|
|
9085
|
+
Q = class Q extends p {
|
|
9086
|
+
get cursor() {
|
|
9087
|
+
return this.value ? 0 : 1;
|
|
9088
|
+
}
|
|
9089
|
+
get _value() {
|
|
9090
|
+
return this.cursor === 0;
|
|
9091
|
+
}
|
|
9092
|
+
constructor(t) {
|
|
9093
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
9094
|
+
this.value = this._value;
|
|
9095
|
+
}), this.on("confirm", (e) => {
|
|
9096
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = e, this.state = "submit", this.close();
|
|
9097
|
+
}), this.on("cursor", () => {
|
|
9098
|
+
this.value = !this.value;
|
|
9099
|
+
});
|
|
9100
|
+
}
|
|
9101
|
+
};
|
|
9085
9102
|
X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
9086
9103
|
et = class et extends p {
|
|
9087
9104
|
#e;
|
|
@@ -9435,6 +9452,32 @@ var import_sisteransi2, ee, w2 = (e, i) => ee ? e : i, _e, oe, ue, F2, le, d2, E
|
|
|
9435
9452
|
for (const x of b)
|
|
9436
9453
|
C2.push(x);
|
|
9437
9454
|
return g && C2.push(l), C2;
|
|
9455
|
+
}, ot2 = (e) => {
|
|
9456
|
+
const i = e.active ?? "Yes", s = e.inactive ?? "No";
|
|
9457
|
+
return new Q({ active: i, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
|
|
9458
|
+
const r = e.withGuide ?? u.withGuide, u2 = `${V2(this.state)} `, n = r ? `${t("gray", d2)} ` : "", o = R(e.output, e.message, n, u2), c2 = `${r ? `${t("gray", d2)}
|
|
9459
|
+
` : ""}${o}
|
|
9460
|
+
`, a = this.value ? i : s;
|
|
9461
|
+
switch (this.state) {
|
|
9462
|
+
case "submit": {
|
|
9463
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
9464
|
+
return `${c2}${l}${t("dim", a)}`;
|
|
9465
|
+
}
|
|
9466
|
+
case "cancel": {
|
|
9467
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
9468
|
+
return `${c2}${l}${t(["strikethrough", "dim"], a)}${r ? `
|
|
9469
|
+
${t("gray", d2)}` : ""}`;
|
|
9470
|
+
}
|
|
9471
|
+
default: {
|
|
9472
|
+
const l = r ? `${t("cyan", d2)} ` : "", $2 = r ? t("cyan", E2) : "";
|
|
9473
|
+
return `${c2}${l}${this.value ? `${t("green", z2)} ${i}` : `${t("dim", H2)} ${t("dim", i)}`}${e.vertical ? r ? `
|
|
9474
|
+
${t("cyan", d2)} ` : `
|
|
9475
|
+
` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
|
|
9476
|
+
${$2}
|
|
9477
|
+
`;
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
} }).prompt();
|
|
9438
9481
|
}, O2, mt = (e = "", i) => {
|
|
9439
9482
|
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
|
|
9440
9483
|
s.write(`${r}${e}
|
|
@@ -9658,6 +9701,14 @@ function handleCancel(value, message = "Cancelled.") {
|
|
|
9658
9701
|
process.exit(0);
|
|
9659
9702
|
}
|
|
9660
9703
|
}
|
|
9704
|
+
async function confirm(message, defaultYes = true) {
|
|
9705
|
+
const result = await ot2({
|
|
9706
|
+
message,
|
|
9707
|
+
initialValue: defaultYes
|
|
9708
|
+
});
|
|
9709
|
+
handleCancel(result);
|
|
9710
|
+
return result;
|
|
9711
|
+
}
|
|
9661
9712
|
async function selectOne(message, options) {
|
|
9662
9713
|
const clackOptions = options.map((option) => {
|
|
9663
9714
|
const hint = option.hint ?? (option.recommended ? "recommended" : undefined);
|
|
@@ -9800,7 +9851,7 @@ function printNextSteps(adapter) {
|
|
|
9800
9851
|
if (adapter.kind === "opencode") {
|
|
9801
9852
|
wt([
|
|
9802
9853
|
"Restart OpenCode (or reload your session) so the plugin loads.",
|
|
9803
|
-
"Verify with: `
|
|
9854
|
+
"Verify with: `npx @cortexkit/aft doctor`."
|
|
9804
9855
|
].join(`
|
|
9805
9856
|
`), "Next steps");
|
|
9806
9857
|
return;
|
|
@@ -9808,7 +9859,7 @@ function printNextSteps(adapter) {
|
|
|
9808
9859
|
if (adapter.kind === "pi") {
|
|
9809
9860
|
wt([
|
|
9810
9861
|
"Restart your Pi session so the extension registers.",
|
|
9811
|
-
"Verify with: `
|
|
9862
|
+
"Verify with: `npx @cortexkit/aft doctor`."
|
|
9812
9863
|
].join(`
|
|
9813
9864
|
`), "Next steps");
|
|
9814
9865
|
}
|
|
@@ -9826,6 +9877,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9826
9877
|
stdio: ["pipe", "pipe", "pipe"]
|
|
9827
9878
|
});
|
|
9828
9879
|
const responses = [];
|
|
9880
|
+
const noiseLines = [];
|
|
9829
9881
|
let stdout = "";
|
|
9830
9882
|
let stderr = "";
|
|
9831
9883
|
let settled = false;
|
|
@@ -9839,14 +9891,18 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9839
9891
|
const handleLine = (line) => {
|
|
9840
9892
|
if (!line)
|
|
9841
9893
|
return;
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
} catch (error) {
|
|
9845
|
-
finish(() => reject(error));
|
|
9894
|
+
if (!line.startsWith("{")) {
|
|
9895
|
+
noiseLines.push(line);
|
|
9846
9896
|
return;
|
|
9847
9897
|
}
|
|
9848
|
-
|
|
9849
|
-
|
|
9898
|
+
try {
|
|
9899
|
+
const parsed = JSON.parse(line);
|
|
9900
|
+
responses.push(parsed);
|
|
9901
|
+
if (responses.length === requests.length) {
|
|
9902
|
+
finish(() => resolve2(responses));
|
|
9903
|
+
}
|
|
9904
|
+
} catch {
|
|
9905
|
+
noiseLines.push(line);
|
|
9850
9906
|
}
|
|
9851
9907
|
};
|
|
9852
9908
|
child.stdout.setEncoding("utf-8");
|
|
@@ -9874,7 +9930,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9874
9930
|
child.on("exit", (code) => {
|
|
9875
9931
|
if (settled)
|
|
9876
9932
|
return;
|
|
9877
|
-
finish(() => reject(
|
|
9933
|
+
finish(() => reject(buildBridgeError({ binaryPath, code, stderr, noiseLines, responses })));
|
|
9878
9934
|
});
|
|
9879
9935
|
for (const request of requests) {
|
|
9880
9936
|
child.stdin.write(`${JSON.stringify(request)}
|
|
@@ -9883,6 +9939,34 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
9883
9939
|
child.stdin.end();
|
|
9884
9940
|
});
|
|
9885
9941
|
}
|
|
9942
|
+
function buildBridgeError(ctx) {
|
|
9943
|
+
const parts = [];
|
|
9944
|
+
parts.push(`aft exited before responding (binary: ${ctx.binaryPath}, exit code: ${ctx.code ?? "unknown"}).`);
|
|
9945
|
+
if (ctx.responses.length > 0) {
|
|
9946
|
+
parts.push(`Got ${ctx.responses.length} valid response(s) before exit.`);
|
|
9947
|
+
}
|
|
9948
|
+
if (ctx.noiseLines.length > 0) {
|
|
9949
|
+
parts.push(`
|
|
9950
|
+
The binary printed ${ctx.noiseLines.length} non-JSON line(s) to stdout — this usually means ` + "the resolved binary isn't an AFT release binary (wrapper script, panic output, or unrelated tool):");
|
|
9951
|
+
const sample = ctx.noiseLines.slice(0, MAX_NOISE_LINES_IN_ERROR).map((line) => ` | ${line}`);
|
|
9952
|
+
parts.push(sample.join(`
|
|
9953
|
+
`));
|
|
9954
|
+
if (ctx.noiseLines.length > MAX_NOISE_LINES_IN_ERROR) {
|
|
9955
|
+
parts.push(` | (… ${ctx.noiseLines.length - MAX_NOISE_LINES_IN_ERROR} more line(s) omitted)`);
|
|
9956
|
+
}
|
|
9957
|
+
parts.push(`
|
|
9958
|
+
Try: npx @cortexkit/aft doctor (full diagnostics) or check ~/.cache/aft/bin/ for the right binary.`);
|
|
9959
|
+
}
|
|
9960
|
+
const stderrTrimmed = ctx.stderr.trim();
|
|
9961
|
+
if (stderrTrimmed) {
|
|
9962
|
+
parts.push(`
|
|
9963
|
+
stderr:
|
|
9964
|
+
${stderrTrimmed}`);
|
|
9965
|
+
}
|
|
9966
|
+
return new Error(parts.join(`
|
|
9967
|
+
`));
|
|
9968
|
+
}
|
|
9969
|
+
var MAX_NOISE_LINES_IN_ERROR = 5;
|
|
9886
9970
|
var init_aft_bridge = () => {};
|
|
9887
9971
|
|
|
9888
9972
|
// src/lib/binary-probe.ts
|
|
@@ -10647,21 +10731,108 @@ function createGitHubIssue(repo, title, body) {
|
|
|
10647
10731
|
}
|
|
10648
10732
|
var init_github = () => {};
|
|
10649
10733
|
|
|
10734
|
+
// src/lib/onnx-fix.ts
|
|
10735
|
+
import { existsSync as existsSync11, rmSync as rmSync3 } from "node:fs";
|
|
10736
|
+
import { join as join10 } from "node:path";
|
|
10737
|
+
function findOnnxFixCandidates(report) {
|
|
10738
|
+
const candidates = [];
|
|
10739
|
+
for (const harness of report.harnesses) {
|
|
10740
|
+
if (!harness.onnxRuntime.required)
|
|
10741
|
+
continue;
|
|
10742
|
+
if (!harness.storageDir.exists)
|
|
10743
|
+
continue;
|
|
10744
|
+
const storageOnnxDir = join10(harness.storageDir.path, "onnxruntime");
|
|
10745
|
+
const systemTooOld = harness.onnxRuntime.systemPath !== null && harness.onnxRuntime.systemCompatible === false;
|
|
10746
|
+
const cachedTooOld = harness.onnxRuntime.cachedPath !== null && harness.onnxRuntime.cachedCompatible === false;
|
|
10747
|
+
const hasCompatibleCached = harness.onnxRuntime.cachedCompatible === true;
|
|
10748
|
+
if (cachedTooOld) {
|
|
10749
|
+
candidates.push({
|
|
10750
|
+
harness,
|
|
10751
|
+
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
|
+
storageOnnxDir,
|
|
10753
|
+
storageOnnxBytes: existsSync11(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10754
|
+
});
|
|
10755
|
+
continue;
|
|
10756
|
+
}
|
|
10757
|
+
if (systemTooOld && !hasCompatibleCached) {
|
|
10758
|
+
candidates.push({
|
|
10759
|
+
harness,
|
|
10760
|
+
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
|
+
storageOnnxDir,
|
|
10762
|
+
storageOnnxBytes: existsSync11(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
10763
|
+
});
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
return candidates;
|
|
10767
|
+
}
|
|
10768
|
+
async function runOnnxFix(adapters, report, options = {}) {
|
|
10769
|
+
const candidates = findOnnxFixCandidates(report);
|
|
10770
|
+
if (candidates.length === 0) {
|
|
10771
|
+
return null;
|
|
10772
|
+
}
|
|
10773
|
+
O2.warn(`Found ${candidates.length} ONNX Runtime issue(s) that --fix can address by clearing AFT-managed cache:`);
|
|
10774
|
+
for (const c2 of candidates) {
|
|
10775
|
+
O2.info(` • ${c2.harness.displayName}: ${c2.reason}`);
|
|
10776
|
+
if (c2.storageOnnxBytes > 0) {
|
|
10777
|
+
O2.info(` will delete: ${c2.storageOnnxDir} (${formatBytes(c2.storageOnnxBytes)})`);
|
|
10778
|
+
} else {
|
|
10779
|
+
O2.info(` no AFT-managed ONNX cache to delete; nothing to reclaim`);
|
|
10780
|
+
}
|
|
10781
|
+
}
|
|
10782
|
+
wt("This NEVER touches system paths like /usr/lib. It only deletes AFT's own ONNX download cache. " + "On next bridge start, AFT will re-download ONNX Runtime v1.24 and use that instead of the " + "incompatible system library.", "Safe operation");
|
|
10783
|
+
const confirmFn = options.confirmFn ?? confirm;
|
|
10784
|
+
const proceed = options.yes ? true : await confirmFn("Proceed with the fixes above?", true);
|
|
10785
|
+
if (!proceed) {
|
|
10786
|
+
O2.info("Skipped — no changes made.");
|
|
10787
|
+
return null;
|
|
10788
|
+
}
|
|
10789
|
+
const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
|
|
10790
|
+
const rmFn = options.rmFn ?? rmSync3;
|
|
10791
|
+
for (const c2 of candidates) {
|
|
10792
|
+
if (!existsSync11(c2.storageOnnxDir)) {
|
|
10793
|
+
O2.success(`${c2.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
|
|
10794
|
+
continue;
|
|
10795
|
+
}
|
|
10796
|
+
try {
|
|
10797
|
+
rmFn(c2.storageOnnxDir, { recursive: true, force: true });
|
|
10798
|
+
result.cleared += 1;
|
|
10799
|
+
result.bytesReclaimed += c2.storageOnnxBytes;
|
|
10800
|
+
O2.success(`${c2.harness.displayName}: cleared ${c2.storageOnnxDir} (reclaimed ${formatBytes(c2.storageOnnxBytes)})`);
|
|
10801
|
+
} catch (err) {
|
|
10802
|
+
const message = err.message ?? "unknown error";
|
|
10803
|
+
O2.error(`${c2.harness.displayName}: failed to clear ${c2.storageOnnxDir}: ${message}`);
|
|
10804
|
+
result.errors.push({ path: c2.storageOnnxDir, error: message });
|
|
10805
|
+
}
|
|
10806
|
+
}
|
|
10807
|
+
if (result.cleared > 0 || candidates.some((c2) => c2.storageOnnxBytes === 0)) {
|
|
10808
|
+
wt("Restart your AFT-using harness (OpenCode / Pi) to trigger a fresh ONNX Runtime download. " + "Watch the TUI sidebar — the Semantic Index status should move from 'failed' → 'building' → 'ready'.", "Next step");
|
|
10809
|
+
}
|
|
10810
|
+
return result;
|
|
10811
|
+
}
|
|
10812
|
+
var init_onnx_fix = __esm(() => {
|
|
10813
|
+
init_fs_util();
|
|
10814
|
+
init_prompts();
|
|
10815
|
+
});
|
|
10816
|
+
|
|
10650
10817
|
// src/commands/doctor.ts
|
|
10651
10818
|
var exports_doctor = {};
|
|
10652
10819
|
__export(exports_doctor, {
|
|
10653
10820
|
runDoctor: () => runDoctor,
|
|
10821
|
+
clearOldBinaries: () => clearOldBinaries,
|
|
10654
10822
|
clearDoctorCaches: () => clearDoctorCaches,
|
|
10655
10823
|
DOCTOR_FORCE_CLEAR_TARGETS: () => DOCTOR_FORCE_CLEAR_TARGETS,
|
|
10656
10824
|
DOCTOR_CLEAR_TARGET_OPTIONS: () => DOCTOR_CLEAR_TARGET_OPTIONS
|
|
10657
10825
|
});
|
|
10658
|
-
import { writeFileSync as writeFileSync2 } from "node:fs";
|
|
10659
|
-
import { join as
|
|
10826
|
+
import { existsSync as existsSync12, rmSync as rmSync4, statSync as statSync8, writeFileSync as writeFileSync2 } from "node:fs";
|
|
10827
|
+
import { join as join11 } from "node:path";
|
|
10660
10828
|
async function runDoctor(options) {
|
|
10661
10829
|
if (options.issue) {
|
|
10662
10830
|
return runIssueFlow(options.argv);
|
|
10663
10831
|
}
|
|
10664
10832
|
mt("AFT doctor");
|
|
10833
|
+
if (options.fix) {
|
|
10834
|
+
return runFixFlow(options.argv);
|
|
10835
|
+
}
|
|
10665
10836
|
if (options.clear) {
|
|
10666
10837
|
return runClearFlow(options.argv);
|
|
10667
10838
|
}
|
|
@@ -10771,8 +10942,80 @@ async function clearDoctorCaches(adapters, targets, options = {}) {
|
|
|
10771
10942
|
errors: cleanup.errors.length
|
|
10772
10943
|
};
|
|
10773
10944
|
}
|
|
10945
|
+
if (targets.includes("binary-cache")) {
|
|
10946
|
+
const result = clearOldBinaries();
|
|
10947
|
+
if (result.errors.length > 0) {
|
|
10948
|
+
summary.hadErrors = true;
|
|
10949
|
+
}
|
|
10950
|
+
summary.binaryCache = {
|
|
10951
|
+
cleared: result.cleared,
|
|
10952
|
+
totalBytes: result.bytesReclaimed,
|
|
10953
|
+
errors: result.errors.length
|
|
10954
|
+
};
|
|
10955
|
+
}
|
|
10774
10956
|
return summary;
|
|
10775
10957
|
}
|
|
10958
|
+
function clearOldBinaries() {
|
|
10959
|
+
const cliVersion = getSelfVersion();
|
|
10960
|
+
const keepTag = `v${cliVersion.replace(/^v/, "")}`;
|
|
10961
|
+
const info = getBinaryCacheInfo(cliVersion);
|
|
10962
|
+
const result = {
|
|
10963
|
+
cleared: 0,
|
|
10964
|
+
bytesReclaimed: 0,
|
|
10965
|
+
errors: [],
|
|
10966
|
+
keptVersion: keepTag
|
|
10967
|
+
};
|
|
10968
|
+
if (!existsSync12(info.path)) {
|
|
10969
|
+
O2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
10970
|
+
return result;
|
|
10971
|
+
}
|
|
10972
|
+
const stale = info.versions.filter((v) => v !== keepTag);
|
|
10973
|
+
if (stale.length === 0) {
|
|
10974
|
+
O2.info(`Binary cache: only the active version (${keepTag}) is present at ${info.path}; nothing to clear`);
|
|
10975
|
+
return result;
|
|
10976
|
+
}
|
|
10977
|
+
for (const version of stale) {
|
|
10978
|
+
const dir = join11(info.path, version);
|
|
10979
|
+
let bytes = 0;
|
|
10980
|
+
try {
|
|
10981
|
+
bytes = statSync8(dir).isDirectory() ? dirSize(dir) : 0;
|
|
10982
|
+
} catch {
|
|
10983
|
+
bytes = 0;
|
|
10984
|
+
}
|
|
10985
|
+
try {
|
|
10986
|
+
rmSync4(dir, { recursive: true, force: true });
|
|
10987
|
+
result.cleared += 1;
|
|
10988
|
+
result.bytesReclaimed += bytes;
|
|
10989
|
+
O2.success(`Binary cache: cleared ${dir} (reclaimed ${formatBytes(bytes)})`);
|
|
10990
|
+
} catch (err) {
|
|
10991
|
+
const message = err.message ?? "unknown error";
|
|
10992
|
+
O2.error(`Binary cache: failed to remove ${dir}: ${message}`);
|
|
10993
|
+
result.errors.push({ path: dir, error: message });
|
|
10994
|
+
}
|
|
10995
|
+
}
|
|
10996
|
+
if (result.cleared > 0) {
|
|
10997
|
+
O2.success(`Binary cache: kept ${keepTag}, removed ${result.cleared} old version(s), reclaimed ${formatBytes(result.bytesReclaimed)}`);
|
|
10998
|
+
}
|
|
10999
|
+
return result;
|
|
11000
|
+
}
|
|
11001
|
+
async function runFixFlow(argv) {
|
|
11002
|
+
const adapters = await resolveAdaptersForCommand(argv, {
|
|
11003
|
+
allowMulti: true,
|
|
11004
|
+
verb: "auto-fix issues for"
|
|
11005
|
+
});
|
|
11006
|
+
O2.info("Running diagnostics to identify auto-fixable issues…");
|
|
11007
|
+
const report = await collectDiagnostics(adapters);
|
|
11008
|
+
const onnxResult = await runOnnxFix(adapters, report);
|
|
11009
|
+
if (onnxResult === null) {
|
|
11010
|
+
O2.info("No auto-fixable issues detected.");
|
|
11011
|
+
wt("If you're still seeing 'Semantic Index: failed' in the TUI sidebar, run " + "`aft doctor` (without --fix) for a full diagnostic dump.", "Tip");
|
|
11012
|
+
gt("Done.");
|
|
11013
|
+
return 0;
|
|
11014
|
+
}
|
|
11015
|
+
const hadErrors = onnxResult.errors.length > 0;
|
|
11016
|
+
gt(hadErrors ? "Done — some fixes failed." : "Done.");
|
|
11017
|
+
return hadErrors ? 1 : 0;
|
|
11018
|
+
}
|
|
10776
11019
|
async function clearPluginCache(adapter, includeBytes) {
|
|
10777
11020
|
const info = adapter.getPluginCacheInfo();
|
|
10778
11021
|
const bytes = info.exists ? dirSize(info.path) : 0;
|
|
@@ -10870,7 +11113,7 @@ ${tail || "<no log output>"}
|
|
|
10870
11113
|
`);
|
|
10871
11114
|
const body = sanitizeContent(rawBody);
|
|
10872
11115
|
const title = `AFT issue: ${description.slice(0, 72)}`;
|
|
10873
|
-
const outPath =
|
|
11116
|
+
const outPath = join11(process.cwd(), `aft-issue-${Date.now()}.md`);
|
|
10874
11117
|
writeFileSync2(outPath, `${body}
|
|
10875
11118
|
`);
|
|
10876
11119
|
O2.success(`Wrote sanitized issue body to ${outPath}`);
|
|
@@ -10894,13 +11137,16 @@ ${tail || "<no log output>"}
|
|
|
10894
11137
|
}
|
|
10895
11138
|
var DOCTOR_CLEAR_TARGET_OPTIONS, DOCTOR_FORCE_CLEAR_TARGETS;
|
|
10896
11139
|
var init_doctor = __esm(() => {
|
|
11140
|
+
init_binary_cache();
|
|
10897
11141
|
init_diagnostics();
|
|
10898
11142
|
init_fs_util();
|
|
10899
11143
|
init_github();
|
|
10900
11144
|
init_harness_select();
|
|
10901
11145
|
init_lsp_cache();
|
|
11146
|
+
init_onnx_fix();
|
|
10902
11147
|
init_prompts();
|
|
10903
11148
|
init_sanitize();
|
|
11149
|
+
init_self_version();
|
|
10904
11150
|
DOCTOR_CLEAR_TARGET_OPTIONS = [
|
|
10905
11151
|
{
|
|
10906
11152
|
label: "Plugin npm cache (~/.cache/opencode/packages/@cortexkit/aft-opencode@latest, etc.)",
|
|
@@ -10909,6 +11155,10 @@ var init_doctor = __esm(() => {
|
|
|
10909
11155
|
{
|
|
10910
11156
|
label: "LSP install cache (~/.cache/aft/lsp-packages/, ~/.cache/aft/lsp-binaries/)",
|
|
10911
11157
|
value: "lsp-cache"
|
|
11158
|
+
},
|
|
11159
|
+
{
|
|
11160
|
+
label: "Old aft binaries (~/.cache/aft/bin/v* — keeps the version matching this CLI)",
|
|
11161
|
+
value: "binary-cache"
|
|
10912
11162
|
}
|
|
10913
11163
|
];
|
|
10914
11164
|
DOCTOR_FORCE_CLEAR_TARGETS = ["plugin-cache"];
|
|
@@ -10926,6 +11176,7 @@ function printHelp() {
|
|
|
10926
11176
|
console.log(" setup Interactive setup wizard");
|
|
10927
11177
|
console.log(" doctor Check and fix configuration issues");
|
|
10928
11178
|
console.log(" doctor lsp <file> Inspect LSP setup for one file");
|
|
11179
|
+
console.log(" doctor --fix Auto-fix common issues (e.g. ONNX Runtime mismatch)");
|
|
10929
11180
|
console.log(" doctor --clear Select caches to clear with an interactive prompt");
|
|
10930
11181
|
console.log(" doctor --issue Collect diagnostics and open a GitHub issue");
|
|
10931
11182
|
console.log("");
|
|
@@ -10935,11 +11186,11 @@ function printHelp() {
|
|
|
10935
11186
|
console.log(" (default: auto-detect, prompt if multiple detected)");
|
|
10936
11187
|
console.log("");
|
|
10937
11188
|
console.log(" Usage:");
|
|
10938
|
-
console.log("
|
|
10939
|
-
console.log("
|
|
10940
|
-
console.log("
|
|
10941
|
-
console.log("
|
|
10942
|
-
console.log("
|
|
11189
|
+
console.log(" npx @cortexkit/aft setup");
|
|
11190
|
+
console.log(" npx @cortexkit/aft doctor");
|
|
11191
|
+
console.log(" npx @cortexkit/aft doctor lsp ./src/main.py");
|
|
11192
|
+
console.log(" npx @cortexkit/aft doctor --clear");
|
|
11193
|
+
console.log(" npx @cortexkit/aft doctor --issue");
|
|
10943
11194
|
console.log("");
|
|
10944
11195
|
}
|
|
10945
11196
|
async function main() {
|
|
@@ -10955,8 +11206,9 @@ async function main() {
|
|
|
10955
11206
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), exports_doctor));
|
|
10956
11207
|
const force = args.includes("--force");
|
|
10957
11208
|
const clear = args.includes("--clear");
|
|
11209
|
+
const fix = args.includes("--fix");
|
|
10958
11210
|
const issue = args.includes("--issue");
|
|
10959
|
-
return runDoctor2({ clear, force, issue, argv: args });
|
|
11211
|
+
return runDoctor2({ clear, fix, force, issue, argv: args });
|
|
10960
11212
|
}
|
|
10961
11213
|
printHelp();
|
|
10962
11214
|
return command ? 1 : 0;
|
package/dist/lib/aft-bridge.d.ts
CHANGED
|
@@ -11,5 +11,20 @@ export interface AftResponse {
|
|
|
11
11
|
[key: string]: unknown;
|
|
12
12
|
}
|
|
13
13
|
export declare function sendAftRequest(binaryPath: string, request: AftRequest): Promise<AftResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Send NDJSON requests to a long-running `aft` binary and collect
|
|
16
|
+
* matching responses.
|
|
17
|
+
*
|
|
18
|
+
* The contract is forgiving by design: any stdout line that isn't valid
|
|
19
|
+
* JSON is treated as binary noise (panic message, banner from a wrapper
|
|
20
|
+
* script, log line that escaped to stdout, etc.) and remembered for
|
|
21
|
+
* diagnostics rather than crashing the caller. We only report failure
|
|
22
|
+
* when the binary exits without producing the expected number of valid
|
|
23
|
+
* responses — and when we do, the error message names the specific
|
|
24
|
+
* binary path, the noise we observed, and the stderr tail so the user
|
|
25
|
+
* gets actionable context (issue #29 was a raw `SyntaxError` stack from
|
|
26
|
+
* `JSON.parse` on the first leaked stdout line, with no hint what to
|
|
27
|
+
* try next).
|
|
28
|
+
*/
|
|
14
29
|
export declare function sendAftRequests(binaryPath: string, requests: AftRequest[]): Promise<AftResponse[]>;
|
|
15
30
|
//# sourceMappingURL=aft-bridge.d.ts.map
|
|
@@ -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;AAUD,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,CAuExB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONNX Runtime auto-fix logic for `aft doctor --fix`.
|
|
3
|
+
*
|
|
4
|
+
* The most common ONNX failure mode in production is: a distro ships an
|
|
5
|
+
* old `libonnxruntime.so` (Ubuntu 22.04 still has v1.9, etc.), AFT's
|
|
6
|
+
* resolver picks it up, the Rust pre-validator rejects it as too old,
|
|
7
|
+
* and semantic search shows "failed" forever in the TUI sidebar.
|
|
8
|
+
*
|
|
9
|
+
* The error message tells users to either:
|
|
10
|
+
* 1. `rm /usr/lib/.../libonnxruntime.so` — needs sudo, breaks anything
|
|
11
|
+
* else linking that library, irreversible.
|
|
12
|
+
* 2. Install ONNX 1.24 system-wide — manual, slow, distro-specific.
|
|
13
|
+
* 3. Run doctor — diagnostics only.
|
|
14
|
+
*
|
|
15
|
+
* None of those is automatable safely. But there's a fourth option AFT
|
|
16
|
+
* actually owns end-to-end: clear `<storage_dir>/onnxruntime/` and let
|
|
17
|
+
* the bridge re-download v1.24 on next start. That's what `--fix` does.
|
|
18
|
+
*
|
|
19
|
+
* Pair this with the resolver fix in `packages/aft-bridge/src/onnx-runtime.ts`
|
|
20
|
+
* (which now skips system installs below v1.20) and the user gets a working
|
|
21
|
+
* AFT-managed ONNX even when the system library is too old, with NO change
|
|
22
|
+
* to system files.
|
|
23
|
+
*/
|
|
24
|
+
import type { HarnessAdapter } from "../adapters/types.js";
|
|
25
|
+
import type { DiagnosticReport, HarnessDiagnostic } from "./diagnostics.js";
|
|
26
|
+
export interface OnnxFixCandidate {
|
|
27
|
+
harness: HarnessDiagnostic;
|
|
28
|
+
reason: string;
|
|
29
|
+
storageOnnxDir: string;
|
|
30
|
+
storageOnnxBytes: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Identify harnesses where AFT's ONNX resolution is broken and could be
|
|
34
|
+
* auto-fixed by clearing `<storage_dir>/onnxruntime/`. Each entry carries
|
|
35
|
+
* a human-readable reason so the prompt explains exactly what's wrong.
|
|
36
|
+
*/
|
|
37
|
+
export declare function findOnnxFixCandidates(report: DiagnosticReport): OnnxFixCandidate[];
|
|
38
|
+
export interface OnnxFixResult {
|
|
39
|
+
cleared: number;
|
|
40
|
+
bytesReclaimed: number;
|
|
41
|
+
errors: {
|
|
42
|
+
path: string;
|
|
43
|
+
error: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface OnnxFixOptions {
|
|
47
|
+
/** Skip the user prompt and act immediately (used by tests + scripted flows). */
|
|
48
|
+
yes?: boolean;
|
|
49
|
+
/** Inject a custom confirm impl for testing. */
|
|
50
|
+
confirmFn?: (message: string, defaultYes?: boolean) => Promise<boolean>;
|
|
51
|
+
/** Inject a custom rmSync impl for testing. */
|
|
52
|
+
rmFn?: (path: string, options: {
|
|
53
|
+
recursive: boolean;
|
|
54
|
+
force: boolean;
|
|
55
|
+
}) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Interactive ONNX fix flow. Returns the apply result (or null if no
|
|
59
|
+
* fixable issues were found, or the user declined).
|
|
60
|
+
*
|
|
61
|
+
* Safety contract:
|
|
62
|
+
* - Only deletes paths inside `<storage_dir>/onnxruntime/` (AFT-owned).
|
|
63
|
+
* - NEVER touches `/usr/lib/...`, `/opt/homebrew/lib/...`, or any other
|
|
64
|
+
* system path.
|
|
65
|
+
* - Asks consent before any deletion (unless `options.yes` is set).
|
|
66
|
+
* - Reports byte counts so the user knows what's being reclaimed.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runOnnxFix(adapters: HarnessAdapter[], report: DiagnosticReport, options?: OnnxFixOptions): Promise<OnnxFixResult | null>;
|
|
69
|
+
//# sourceMappingURL=onnx-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-fix.d.ts","sourceRoot":"","sources":["../../src/lib/onnx-fix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI5E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAyClF;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,gDAAgD;IAChD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxE,+CAA+C;IAC/C,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAChF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,cAAc,EAAE,EAC1B,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA6E/B"}
|
package/package.json
CHANGED