@cortexkit/aft 0.39.4 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/lsp.d.ts.map +1 -1
- package/dist/index.js +181 -262
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lsp.d.ts","sourceRoot":"","sources":["../../src/commands/lsp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lsp.d.ts","sourceRoot":"","sources":["../../src/commands/lsp.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAKrE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,cAAc,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,eAAe,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,aAAa,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,yBAAyB,CAAC;CACpD;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,iBAAiB,GAAG,sBAAsB,GAAG,WAAW,GAAG,MAAM,CAAC;IAC1F,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAkBD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,MAAsB,GAClC,MAAM,CAoBR;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2D7E;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAmD3F"}
|
package/dist/index.js
CHANGED
|
@@ -110,18 +110,8 @@ var init_bash_hints = () => {};
|
|
|
110
110
|
function isPassiveCommand(command) {
|
|
111
111
|
return PASSIVE_COMMANDS.has(command);
|
|
112
112
|
}
|
|
113
|
-
var
|
|
113
|
+
var PASSIVE_COMMANDS, PASSIVE_COMMAND_TIMEOUT_MS = 5000;
|
|
114
114
|
var init_command_timeouts = __esm(() => {
|
|
115
|
-
LONG_RUNNING_COMMAND_TIMEOUT_MS = {
|
|
116
|
-
callers: 60000,
|
|
117
|
-
trace_to: 60000,
|
|
118
|
-
trace_to_symbol: 60000,
|
|
119
|
-
trace_data: 60000,
|
|
120
|
-
impact: 60000,
|
|
121
|
-
grep: 60000,
|
|
122
|
-
glob: 60000,
|
|
123
|
-
semantic_search: 60000
|
|
124
|
-
};
|
|
125
115
|
PASSIVE_COMMANDS = new Set(["status"]);
|
|
126
116
|
});
|
|
127
117
|
|
|
@@ -211,30 +201,21 @@ function compareSemver(a, b) {
|
|
|
211
201
|
}
|
|
212
202
|
return 0;
|
|
213
203
|
}
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const maxSemanticTimeoutMs = semanticTransportBudgetMs > SEMANTIC_TIMEOUT_SAFETY_MARGIN_MS ? semanticTransportBudgetMs - SEMANTIC_TIMEOUT_SAFETY_MARGIN_MS : Math.max(1, semanticTransportBudgetMs - 1);
|
|
225
|
-
if (timeoutMs <= maxSemanticTimeoutMs) {
|
|
226
|
-
return configOverrides;
|
|
227
|
-
}
|
|
228
|
-
warn(`semantic.timeout_ms=${timeoutMs} exceeds the semantic transport budget; clamping to ${maxSemanticTimeoutMs}ms (budget: ${semanticTransportBudgetMs}ms)`);
|
|
229
|
-
return {
|
|
230
|
-
...configOverrides,
|
|
231
|
-
semantic: {
|
|
232
|
-
...semantic,
|
|
233
|
-
timeout_ms: maxSemanticTimeoutMs
|
|
204
|
+
function coerceConfigureDroppedKeys(value) {
|
|
205
|
+
if (!Array.isArray(value))
|
|
206
|
+
return [];
|
|
207
|
+
const dropped = [];
|
|
208
|
+
for (const item of value) {
|
|
209
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
210
|
+
continue;
|
|
211
|
+
const record = item;
|
|
212
|
+
if (typeof record.key === "string" && typeof record.tier === "string" && typeof record.reason === "string") {
|
|
213
|
+
dropped.push({ key: record.key, tier: record.tier, reason: record.reason });
|
|
234
214
|
}
|
|
235
|
-
}
|
|
215
|
+
}
|
|
216
|
+
return dropped;
|
|
236
217
|
}
|
|
237
|
-
var DEFAULT_BRIDGE_TIMEOUT_MS = 30000, BRIDGE_HANG_TIMEOUT_THRESHOLD = 2,
|
|
218
|
+
var DEFAULT_BRIDGE_TIMEOUT_MS = 30000, BRIDGE_HANG_TIMEOUT_THRESHOLD = 2, MAX_STDOUT_BUFFER, STDOUT_BUFFER_COMPACT_THRESHOLD, TERMINAL_BASH_STATUSES, BENIGN_CPUINFO_PROC_CPUINFO_PARSE_FAILURE = "failed to parse processor information from /proc/cpuinfo", BridgeReplacedDuringVersionCheck, BridgeTransportTimeoutError, BinaryBridge;
|
|
238
219
|
var init_bridge = __esm(() => {
|
|
239
220
|
init_active_logger();
|
|
240
221
|
init_command_timeouts();
|
|
@@ -310,7 +291,7 @@ var init_bridge = __esm(() => {
|
|
|
310
291
|
this.timeoutMs = options?.timeoutMs ?? DEFAULT_BRIDGE_TIMEOUT_MS;
|
|
311
292
|
this.hangThreshold = options?.hangThreshold ?? BRIDGE_HANG_TIMEOUT_THRESHOLD;
|
|
312
293
|
this.maxRestarts = options?.maxRestarts ?? 3;
|
|
313
|
-
this.configOverrides =
|
|
294
|
+
this.configOverrides = configOverrides ?? {};
|
|
314
295
|
this.minVersion = options?.minVersion;
|
|
315
296
|
this.onVersionMismatch = options?.onVersionMismatch;
|
|
316
297
|
this.onConfigureWarnings = options?.onConfigureWarnings;
|
|
@@ -547,18 +528,24 @@ var init_bridge = __esm(() => {
|
|
|
547
528
|
}
|
|
548
529
|
}
|
|
549
530
|
async deliverConfigureWarnings(configResult, params, options) {
|
|
550
|
-
if (!this.onConfigureWarnings
|
|
531
|
+
if (!this.onConfigureWarnings)
|
|
551
532
|
return;
|
|
552
|
-
|
|
533
|
+
const warnings = Array.isArray(configResult.warnings) ? configResult.warnings : [];
|
|
534
|
+
const configDroppedKeys = coerceConfigureDroppedKeys(configResult.config_dropped_keys);
|
|
535
|
+
if (warnings.length === 0 && configDroppedKeys.length === 0)
|
|
553
536
|
return;
|
|
554
537
|
const sessionId = typeof params.session_id === "string" ? params.session_id : undefined;
|
|
538
|
+
const context = {
|
|
539
|
+
projectRoot: this.cwd,
|
|
540
|
+
sessionId,
|
|
541
|
+
client: options?.configureWarningClient ?? (sessionId ? this.configureWarningClients.get(sessionId) : undefined),
|
|
542
|
+
warnings
|
|
543
|
+
};
|
|
544
|
+
if (configDroppedKeys.length > 0) {
|
|
545
|
+
context.configDroppedKeys = configDroppedKeys;
|
|
546
|
+
}
|
|
555
547
|
try {
|
|
556
|
-
await this.onConfigureWarnings(
|
|
557
|
-
projectRoot: this.cwd,
|
|
558
|
-
sessionId,
|
|
559
|
-
client: options?.configureWarningClient ?? (sessionId ? this.configureWarningClients.get(sessionId) : undefined),
|
|
560
|
-
warnings: configResult.warnings
|
|
561
|
-
});
|
|
548
|
+
await this.onConfigureWarnings(context);
|
|
562
549
|
} catch (err) {
|
|
563
550
|
this.warnVia(`configure warning delivery failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
564
551
|
} finally {
|
|
@@ -1034,6 +1021,35 @@ var init_bridge = __esm(() => {
|
|
|
1034
1021
|
|
|
1035
1022
|
// ../aft-bridge/dist/callgraph-format.js
|
|
1036
1023
|
var init_callgraph_format = () => {};
|
|
1024
|
+
// ../aft-bridge/dist/config-tiers.js
|
|
1025
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
1026
|
+
import { resolve } from "node:path";
|
|
1027
|
+
function readConfigTiers(opts) {
|
|
1028
|
+
const tiers = [];
|
|
1029
|
+
try {
|
|
1030
|
+
if (existsSync(opts.userConfigPath)) {
|
|
1031
|
+
const doc = readFileSync(opts.userConfigPath, "utf-8");
|
|
1032
|
+
tiers.push({
|
|
1033
|
+
tier: "user",
|
|
1034
|
+
source: resolve(opts.userConfigPath),
|
|
1035
|
+
doc
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
} catch {}
|
|
1039
|
+
try {
|
|
1040
|
+
if (existsSync(opts.projectConfigPath)) {
|
|
1041
|
+
const doc = readFileSync(opts.projectConfigPath, "utf-8");
|
|
1042
|
+
tiers.push({
|
|
1043
|
+
tier: "project",
|
|
1044
|
+
source: resolve(opts.projectConfigPath),
|
|
1045
|
+
doc
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
} catch {}
|
|
1049
|
+
return tiers;
|
|
1050
|
+
}
|
|
1051
|
+
var init_config_tiers = () => {};
|
|
1052
|
+
|
|
1037
1053
|
// ../aft-bridge/dist/platform.js
|
|
1038
1054
|
var init_platform = () => {};
|
|
1039
1055
|
|
|
@@ -1049,7 +1065,7 @@ var init_downloader = __esm(() => {
|
|
|
1049
1065
|
var init_paths = () => {};
|
|
1050
1066
|
|
|
1051
1067
|
// ../aft-bridge/dist/resolver.js
|
|
1052
|
-
import { chmodSync, closeSync, copyFileSync, existsSync, mkdirSync, openSync, readSync, renameSync, unlinkSync } from "node:fs";
|
|
1068
|
+
import { chmodSync, closeSync, copyFileSync, existsSync as existsSync2, mkdirSync, openSync, readSync, renameSync, unlinkSync } from "node:fs";
|
|
1053
1069
|
function isNativeExecutable(binaryPath) {
|
|
1054
1070
|
let fd = null;
|
|
1055
1071
|
try {
|
|
@@ -1254,63 +1270,39 @@ var init_onnx_runtime = __esm(() => {
|
|
|
1254
1270
|
};
|
|
1255
1271
|
});
|
|
1256
1272
|
|
|
1257
|
-
// ../aft-bridge/dist/
|
|
1258
|
-
var NOISE_FILTERS, GREP_GUARD_FLAGS, XCODEBUILD_VALUE_FLAGS, XCODEBUILD_BUILD_ACTIONS, READS_FILE_OPERAND;
|
|
1259
|
-
var init_pipe_strip = __esm(() => {
|
|
1260
|
-
NOISE_FILTERS = new Set([
|
|
1261
|
-
"grep",
|
|
1262
|
-
"rg",
|
|
1263
|
-
"head",
|
|
1264
|
-
"tail",
|
|
1265
|
-
"cat",
|
|
1266
|
-
"less",
|
|
1267
|
-
"more",
|
|
1268
|
-
"sed",
|
|
1269
|
-
"awk",
|
|
1270
|
-
"cut",
|
|
1271
|
-
"sort",
|
|
1272
|
-
"uniq",
|
|
1273
|
-
"tr",
|
|
1274
|
-
"column",
|
|
1275
|
-
"fold"
|
|
1276
|
-
]);
|
|
1277
|
-
GREP_GUARD_FLAGS = new Set([
|
|
1278
|
-
"c",
|
|
1279
|
-
"count",
|
|
1280
|
-
"q",
|
|
1281
|
-
"quiet",
|
|
1282
|
-
"o",
|
|
1283
|
-
"only-matching",
|
|
1284
|
-
"l",
|
|
1285
|
-
"files-with-matches"
|
|
1286
|
-
]);
|
|
1287
|
-
XCODEBUILD_VALUE_FLAGS = new Set([
|
|
1288
|
-
"-scheme",
|
|
1289
|
-
"-target",
|
|
1290
|
-
"-project",
|
|
1291
|
-
"-workspace",
|
|
1292
|
-
"-configuration",
|
|
1293
|
-
"-sdk",
|
|
1294
|
-
"-destination",
|
|
1295
|
-
"-arch",
|
|
1296
|
-
"-derivedDataPath",
|
|
1297
|
-
"-resultBundlePath",
|
|
1298
|
-
"-xcconfig",
|
|
1299
|
-
"-toolchain"
|
|
1300
|
-
]);
|
|
1301
|
-
XCODEBUILD_BUILD_ACTIONS = new Set([
|
|
1302
|
-
"build",
|
|
1303
|
-
"test",
|
|
1304
|
-
"build-for-testing",
|
|
1305
|
-
"test-without-building",
|
|
1306
|
-
"analyze"
|
|
1307
|
-
]);
|
|
1308
|
-
READS_FILE_OPERAND = new Set(["cat", "tac", "nl", "less", "more"]);
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
// ../aft-bridge/dist/pool.js
|
|
1273
|
+
// ../aft-bridge/dist/project-identity.js
|
|
1312
1274
|
import { realpathSync } from "node:fs";
|
|
1275
|
+
import { resolve as resolve2 } from "node:path";
|
|
1276
|
+
function canonicalizeProjectRoot(dir) {
|
|
1277
|
+
const trimmed = dir.replace(/[/\\]+$/, "");
|
|
1278
|
+
let canonical;
|
|
1279
|
+
try {
|
|
1280
|
+
canonical = realpathSync(trimmed);
|
|
1281
|
+
} catch {
|
|
1282
|
+
canonical = resolve2(trimmed);
|
|
1283
|
+
}
|
|
1284
|
+
return normalizeWindowsRoot(canonical);
|
|
1285
|
+
}
|
|
1286
|
+
function normalizeWindowsRoot(p) {
|
|
1287
|
+
if (process.platform !== "win32")
|
|
1288
|
+
return p;
|
|
1289
|
+
let s = p;
|
|
1290
|
+
if (s.startsWith("\\\\?\\UNC\\")) {
|
|
1291
|
+
s = `\\\\${s.slice("\\\\?\\UNC\\".length)}`;
|
|
1292
|
+
} else if (s.startsWith("\\\\?\\")) {
|
|
1293
|
+
s = s.slice("\\\\?\\".length);
|
|
1294
|
+
}
|
|
1295
|
+
if (s.length >= 2 && s[1] === ":") {
|
|
1296
|
+
const drive = s.charCodeAt(0);
|
|
1297
|
+
if (drive >= 97 && drive <= 122) {
|
|
1298
|
+
s = s[0].toUpperCase() + s.slice(1);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return s;
|
|
1302
|
+
}
|
|
1303
|
+
var init_project_identity = () => {};
|
|
1313
1304
|
|
|
1305
|
+
// ../aft-bridge/dist/pool.js
|
|
1314
1306
|
class BridgePool {
|
|
1315
1307
|
bridges = new Map;
|
|
1316
1308
|
staleBridges = new Set;
|
|
@@ -1478,17 +1470,13 @@ class BridgePool {
|
|
|
1478
1470
|
}
|
|
1479
1471
|
}
|
|
1480
1472
|
function normalizeKey(projectRoot) {
|
|
1481
|
-
|
|
1482
|
-
try {
|
|
1483
|
-
return realpathSync(stripped);
|
|
1484
|
-
} catch {
|
|
1485
|
-
return stripped;
|
|
1486
|
-
}
|
|
1473
|
+
return canonicalizeProjectRoot(projectRoot);
|
|
1487
1474
|
}
|
|
1488
1475
|
var DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_MAX_POOL_SIZE = 8, CLEANUP_INTERVAL_MS;
|
|
1489
1476
|
var init_pool = __esm(() => {
|
|
1490
1477
|
init_active_logger();
|
|
1491
1478
|
init_bridge();
|
|
1479
|
+
init_project_identity();
|
|
1492
1480
|
DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
|
|
1493
1481
|
CLEANUP_INTERVAL_MS = 60 * 1000;
|
|
1494
1482
|
});
|
|
@@ -1499,14 +1487,15 @@ var init_dist = __esm(() => {
|
|
|
1499
1487
|
init_bridge();
|
|
1500
1488
|
init_callgraph_format();
|
|
1501
1489
|
init_command_timeouts();
|
|
1490
|
+
init_config_tiers();
|
|
1502
1491
|
init_downloader();
|
|
1503
1492
|
init_migration();
|
|
1504
1493
|
init_npm_resolver();
|
|
1505
1494
|
init_onnx_runtime();
|
|
1506
1495
|
init_paths();
|
|
1507
|
-
init_pipe_strip();
|
|
1508
1496
|
init_platform();
|
|
1509
1497
|
init_pool();
|
|
1498
|
+
init_project_identity();
|
|
1510
1499
|
init_resolver();
|
|
1511
1500
|
});
|
|
1512
1501
|
|
|
@@ -1575,7 +1564,7 @@ var init_paths2 = () => {};
|
|
|
1575
1564
|
|
|
1576
1565
|
// src/lib/binary-probe.ts
|
|
1577
1566
|
import { execSync, spawnSync } from "node:child_process";
|
|
1578
|
-
import { existsSync as
|
|
1567
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
1579
1568
|
import { createRequire } from "node:module";
|
|
1580
1569
|
import { homedir as homedir4 } from "node:os";
|
|
1581
1570
|
import { join as join4 } from "node:path";
|
|
@@ -1631,7 +1620,7 @@ function probeAftBinary(preferredVersion) {
|
|
|
1631
1620
|
const candidates = [];
|
|
1632
1621
|
for (const candidate of aftBinaryCandidates(preferredVersion)) {
|
|
1633
1622
|
try {
|
|
1634
|
-
if (!
|
|
1623
|
+
if (!existsSync3(candidate))
|
|
1635
1624
|
continue;
|
|
1636
1625
|
const result = spawnSync(candidate, ["--version"], {
|
|
1637
1626
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -1682,7 +1671,7 @@ function pushCandidate(candidates, candidate) {
|
|
|
1682
1671
|
function firstExisting(candidates) {
|
|
1683
1672
|
for (const candidate of candidates) {
|
|
1684
1673
|
try {
|
|
1685
|
-
if (!
|
|
1674
|
+
if (!existsSync3(candidate))
|
|
1686
1675
|
continue;
|
|
1687
1676
|
return candidate;
|
|
1688
1677
|
} catch {}
|
|
@@ -1739,10 +1728,10 @@ var init_binary_probe = __esm(async () => {
|
|
|
1739
1728
|
});
|
|
1740
1729
|
|
|
1741
1730
|
// src/lib/fs-util.ts
|
|
1742
|
-
import { existsSync as
|
|
1731
|
+
import { existsSync as existsSync4, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
1743
1732
|
import { join as join5 } from "node:path";
|
|
1744
1733
|
function dirSize(path) {
|
|
1745
|
-
if (!
|
|
1734
|
+
if (!existsSync4(path)) {
|
|
1746
1735
|
return 0;
|
|
1747
1736
|
}
|
|
1748
1737
|
const stat = statSync2(path);
|
|
@@ -9528,25 +9517,25 @@ var require_src2 = __commonJS((exports, module) => {
|
|
|
9528
9517
|
});
|
|
9529
9518
|
|
|
9530
9519
|
// src/lib/jsonc.ts
|
|
9531
|
-
import { existsSync as
|
|
9520
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
9532
9521
|
import { dirname as dirname2 } from "node:path";
|
|
9533
9522
|
function detectJsoncFile(configDir, baseName) {
|
|
9534
9523
|
const jsoncPath = `${configDir}/${baseName}.jsonc`;
|
|
9535
9524
|
const jsonPath = `${configDir}/${baseName}.json`;
|
|
9536
|
-
if (
|
|
9525
|
+
if (existsSync5(jsoncPath)) {
|
|
9537
9526
|
return { path: jsoncPath, format: "jsonc" };
|
|
9538
9527
|
}
|
|
9539
|
-
if (
|
|
9528
|
+
if (existsSync5(jsonPath)) {
|
|
9540
9529
|
return { path: jsonPath, format: "json" };
|
|
9541
9530
|
}
|
|
9542
9531
|
return { path: jsonPath, format: "none" };
|
|
9543
9532
|
}
|
|
9544
9533
|
function readJsoncFile(path) {
|
|
9545
|
-
if (!
|
|
9534
|
+
if (!existsSync5(path)) {
|
|
9546
9535
|
return { value: null };
|
|
9547
9536
|
}
|
|
9548
9537
|
try {
|
|
9549
|
-
const raw =
|
|
9538
|
+
const raw = readFileSync2(path, "utf-8");
|
|
9550
9539
|
const value = import_comment_json.parse(raw);
|
|
9551
9540
|
return { value };
|
|
9552
9541
|
} catch (error2) {
|
|
@@ -9563,7 +9552,7 @@ function writeJsoncFile(path, value, format = "json") {
|
|
|
9563
9552
|
`);
|
|
9564
9553
|
}
|
|
9565
9554
|
function ensureAftSchemaUrl(path, format) {
|
|
9566
|
-
const existed =
|
|
9555
|
+
const existed = existsSync5(path);
|
|
9567
9556
|
if (!existed) {
|
|
9568
9557
|
const writeFormat = format === "jsonc" ? "jsonc" : "json";
|
|
9569
9558
|
writeJsoncFile(path, { $schema: AFT_SCHEMA_URL }, writeFormat);
|
|
@@ -9616,14 +9605,14 @@ var init_self_version = () => {};
|
|
|
9616
9605
|
|
|
9617
9606
|
// src/adapters/opencode.ts
|
|
9618
9607
|
import { execSync as execSync2 } from "node:child_process";
|
|
9619
|
-
import { existsSync as
|
|
9608
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3, rmSync, statSync as statSync3 } from "node:fs";
|
|
9620
9609
|
import { homedir as homedir5 } from "node:os";
|
|
9621
|
-
import { dirname as dirname3, join as join6, parse, resolve } from "node:path";
|
|
9610
|
+
import { dirname as dirname3, join as join6, parse, resolve as resolve3 } from "node:path";
|
|
9622
9611
|
import { fileURLToPath } from "node:url";
|
|
9623
9612
|
function getOpenCodeConfigDir() {
|
|
9624
9613
|
const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
9625
9614
|
if (envDir)
|
|
9626
|
-
return
|
|
9615
|
+
return resolve3(envDir);
|
|
9627
9616
|
const xdg = process.env.XDG_CONFIG_HOME || join6(homedir5(), ".config");
|
|
9628
9617
|
return join6(xdg, "opencode");
|
|
9629
9618
|
}
|
|
@@ -9657,7 +9646,7 @@ function openCodeDesktopAppExists() {
|
|
|
9657
9646
|
}
|
|
9658
9647
|
return candidates.some((p) => {
|
|
9659
9648
|
try {
|
|
9660
|
-
return
|
|
9649
|
+
return existsSync6(p);
|
|
9661
9650
|
} catch {
|
|
9662
9651
|
return false;
|
|
9663
9652
|
}
|
|
@@ -9680,13 +9669,13 @@ function pathPointsToOurPlugin(entry) {
|
|
|
9680
9669
|
if (!fsPath)
|
|
9681
9670
|
return false;
|
|
9682
9671
|
try {
|
|
9683
|
-
if (!
|
|
9672
|
+
if (!existsSync6(fsPath))
|
|
9684
9673
|
return false;
|
|
9685
9674
|
let searchDir = statSync3(fsPath).isDirectory() ? fsPath : dirname3(fsPath);
|
|
9686
9675
|
let pkgJsonPath = null;
|
|
9687
9676
|
while (true) {
|
|
9688
9677
|
const candidate = join6(searchDir, "package.json");
|
|
9689
|
-
if (
|
|
9678
|
+
if (existsSync6(candidate)) {
|
|
9690
9679
|
pkgJsonPath = candidate;
|
|
9691
9680
|
break;
|
|
9692
9681
|
}
|
|
@@ -9697,7 +9686,7 @@ function pathPointsToOurPlugin(entry) {
|
|
|
9697
9686
|
}
|
|
9698
9687
|
if (!pkgJsonPath)
|
|
9699
9688
|
return false;
|
|
9700
|
-
const parsed = JSON.parse(
|
|
9689
|
+
const parsed = JSON.parse(readFileSync3(pkgJsonPath, "utf-8"));
|
|
9701
9690
|
return parsed.name === PLUGIN_NAME;
|
|
9702
9691
|
} catch {
|
|
9703
9692
|
return false;
|
|
@@ -9717,7 +9706,7 @@ class OpenCodeAdapter {
|
|
|
9717
9706
|
pluginPackageName = PLUGIN_NAME;
|
|
9718
9707
|
pluginEntryWithVersion = PLUGIN_ENTRY;
|
|
9719
9708
|
isInstalled() {
|
|
9720
|
-
if (
|
|
9709
|
+
if (existsSync6(getOpenCodeConfigDir()))
|
|
9721
9710
|
return true;
|
|
9722
9711
|
if (openCodeDesktopAppExists())
|
|
9723
9712
|
return true;
|
|
@@ -9802,8 +9791,8 @@ class OpenCodeAdapter {
|
|
|
9802
9791
|
let cached;
|
|
9803
9792
|
try {
|
|
9804
9793
|
const installedPkgPath = join6(path, "node_modules", "@cortexkit", "aft-opencode", "package.json");
|
|
9805
|
-
if (
|
|
9806
|
-
const pkg = JSON.parse(
|
|
9794
|
+
if (existsSync6(installedPkgPath)) {
|
|
9795
|
+
const pkg = JSON.parse(readFileSync3(installedPkgPath, "utf-8"));
|
|
9807
9796
|
cached = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
9808
9797
|
}
|
|
9809
9798
|
} catch {
|
|
@@ -9813,7 +9802,7 @@ class OpenCodeAdapter {
|
|
|
9813
9802
|
path,
|
|
9814
9803
|
cached,
|
|
9815
9804
|
latest: getSelfVersion(),
|
|
9816
|
-
exists:
|
|
9805
|
+
exists: existsSync6(path)
|
|
9817
9806
|
};
|
|
9818
9807
|
}
|
|
9819
9808
|
getStorageDir() {
|
|
@@ -9881,7 +9870,7 @@ var init_opencode = __esm(() => {
|
|
|
9881
9870
|
|
|
9882
9871
|
// src/adapters/pi.ts
|
|
9883
9872
|
import { execSync as execSync3, spawnSync as spawnSync2 } from "node:child_process";
|
|
9884
|
-
import { existsSync as
|
|
9873
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
9885
9874
|
import { homedir as homedir6 } from "node:os";
|
|
9886
9875
|
import { join as join7 } from "node:path";
|
|
9887
9876
|
function getPiAgentDir() {
|
|
@@ -9891,9 +9880,9 @@ function getPiAgentDir() {
|
|
|
9891
9880
|
}
|
|
9892
9881
|
function readPiExtensionIndex() {
|
|
9893
9882
|
const settingsPath = join7(getPiAgentDir(), "settings.json");
|
|
9894
|
-
if (
|
|
9883
|
+
if (existsSync7(settingsPath)) {
|
|
9895
9884
|
try {
|
|
9896
|
-
const raw =
|
|
9885
|
+
const raw = readFileSync4(settingsPath, "utf-8");
|
|
9897
9886
|
const trimmed = raw.replace(/^\uFEFF/, "");
|
|
9898
9887
|
const value = JSON.parse(trimmed);
|
|
9899
9888
|
const packages = value.packages;
|
|
@@ -9910,7 +9899,7 @@ function readPiExtensionIndex() {
|
|
|
9910
9899
|
join7(getPiAgentDir(), "config.jsonc")
|
|
9911
9900
|
];
|
|
9912
9901
|
for (const path of candidates) {
|
|
9913
|
-
if (!
|
|
9902
|
+
if (!existsSync7(path))
|
|
9914
9903
|
continue;
|
|
9915
9904
|
try {
|
|
9916
9905
|
const { value } = readJsoncFile(path);
|
|
@@ -9948,12 +9937,12 @@ function piEntryMatchesAft(entry) {
|
|
|
9948
9937
|
if (!resolved)
|
|
9949
9938
|
return false;
|
|
9950
9939
|
try {
|
|
9951
|
-
if (!
|
|
9940
|
+
if (!existsSync7(resolved))
|
|
9952
9941
|
return false;
|
|
9953
9942
|
const pkgPath = join7(resolved, "package.json");
|
|
9954
|
-
if (!
|
|
9943
|
+
if (!existsSync7(pkgPath))
|
|
9955
9944
|
return false;
|
|
9956
|
-
const pkg = JSON.parse(
|
|
9945
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
9957
9946
|
return pkg.name === PLUGIN_NAME2;
|
|
9958
9947
|
} catch {
|
|
9959
9948
|
return false;
|
|
@@ -10050,10 +10039,10 @@ class PiAdapter {
|
|
|
10050
10039
|
join7(getPiAgentDir(), "extensions", "node_modules", "@cortexkit", "aft-pi", "package.json")
|
|
10051
10040
|
];
|
|
10052
10041
|
for (const candidate of candidates) {
|
|
10053
|
-
if (!
|
|
10042
|
+
if (!existsSync7(candidate))
|
|
10054
10043
|
continue;
|
|
10055
10044
|
try {
|
|
10056
|
-
const pkg = JSON.parse(
|
|
10045
|
+
const pkg = JSON.parse(readFileSync4(candidate, "utf-8"));
|
|
10057
10046
|
const cached = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
10058
10047
|
return {
|
|
10059
10048
|
path: candidate,
|
|
@@ -11707,7 +11696,7 @@ function isResponseForRequest(parsed, expectedIds) {
|
|
|
11707
11696
|
return expectedIds.has(id);
|
|
11708
11697
|
}
|
|
11709
11698
|
async function sendAftRequests(binaryPath, requests) {
|
|
11710
|
-
return new Promise((
|
|
11699
|
+
return new Promise((resolve4, reject) => {
|
|
11711
11700
|
const child = spawn2(binaryPath, [], {
|
|
11712
11701
|
stdio: ["pipe", "pipe", "pipe"]
|
|
11713
11702
|
});
|
|
@@ -11744,7 +11733,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
11744
11733
|
const response = parsed;
|
|
11745
11734
|
responses.push(response);
|
|
11746
11735
|
if (responses.length === requests.length) {
|
|
11747
|
-
finish(() =>
|
|
11736
|
+
finish(() => resolve4(responses));
|
|
11748
11737
|
}
|
|
11749
11738
|
};
|
|
11750
11739
|
child.stdout.setEncoding("utf-8");
|
|
@@ -11819,25 +11808,25 @@ __export(exports_lsp, {
|
|
|
11819
11808
|
printLspDoctorHelp: () => printLspDoctorHelp,
|
|
11820
11809
|
findProjectRootForFile: () => findProjectRootForFile
|
|
11821
11810
|
});
|
|
11822
|
-
import { existsSync as
|
|
11823
|
-
import { dirname as dirname4, join as join8, resolve as
|
|
11811
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
11812
|
+
import { dirname as dirname4, join as join8, resolve as resolve4 } from "node:path";
|
|
11824
11813
|
function findProjectRootForFile(filePath, fallbackCwd = process.cwd()) {
|
|
11825
|
-
const resolvedFile =
|
|
11814
|
+
const resolvedFile = resolve4(fallbackCwd, filePath);
|
|
11826
11815
|
let dir = dirname4(resolvedFile);
|
|
11827
11816
|
try {
|
|
11828
|
-
if (
|
|
11817
|
+
if (existsSync8(resolvedFile) && statSync4(resolvedFile).isDirectory()) {
|
|
11829
11818
|
dir = resolvedFile;
|
|
11830
11819
|
}
|
|
11831
11820
|
} catch {
|
|
11832
11821
|
dir = dirname4(resolvedFile);
|
|
11833
11822
|
}
|
|
11834
11823
|
while (true) {
|
|
11835
|
-
if (PROJECT_ROOT_MARKERS.some((marker) =>
|
|
11824
|
+
if (PROJECT_ROOT_MARKERS.some((marker) => existsSync8(join8(dir, marker)))) {
|
|
11836
11825
|
return dir;
|
|
11837
11826
|
}
|
|
11838
11827
|
const parent = dirname4(dir);
|
|
11839
11828
|
if (parent === dir)
|
|
11840
|
-
return
|
|
11829
|
+
return resolve4(fallbackCwd);
|
|
11841
11830
|
dir = parent;
|
|
11842
11831
|
}
|
|
11843
11832
|
}
|
|
@@ -11868,7 +11857,7 @@ async function runLspDoctor(options) {
|
|
|
11868
11857
|
O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
11869
11858
|
return 1;
|
|
11870
11859
|
}
|
|
11871
|
-
const resolvedFile =
|
|
11860
|
+
const resolvedFile = resolve4(file);
|
|
11872
11861
|
const projectRoot = findProjectRootForFile(resolvedFile);
|
|
11873
11862
|
const config = buildConfigureParams(adapter, projectRoot);
|
|
11874
11863
|
const inspectRequest = {
|
|
@@ -11953,87 +11942,20 @@ function parseFileArg(argv) {
|
|
|
11953
11942
|
return null;
|
|
11954
11943
|
}
|
|
11955
11944
|
function buildConfigureParams(adapter, projectRoot) {
|
|
11956
|
-
const
|
|
11957
|
-
const
|
|
11958
|
-
const
|
|
11959
|
-
const
|
|
11960
|
-
const
|
|
11961
|
-
const lspConfig = resolveLspConfig(merged);
|
|
11945
|
+
const userConfigPath = adapter.detectConfigPaths().aftConfig;
|
|
11946
|
+
const dir = adapter.kind === "pi" ? ".pi" : ".opencode";
|
|
11947
|
+
const projectJsonc = join8(projectRoot, dir, "aft.jsonc");
|
|
11948
|
+
const projectJson = join8(projectRoot, dir, "aft.json");
|
|
11949
|
+
const projectConfigPath = existsSync8(projectJsonc) ? projectJsonc : projectJson;
|
|
11962
11950
|
return {
|
|
11963
11951
|
id: "doctor-lsp-configure",
|
|
11964
11952
|
command: "configure",
|
|
11965
11953
|
project_root: projectRoot,
|
|
11966
11954
|
harness: adapter.kind,
|
|
11967
|
-
|
|
11968
|
-
lsp_paths_extra: inferLspPathsExtra(
|
|
11955
|
+
config: readConfigTiers({ userConfigPath, projectConfigPath }),
|
|
11956
|
+
lsp_paths_extra: inferLspPathsExtra({})
|
|
11969
11957
|
};
|
|
11970
11958
|
}
|
|
11971
|
-
function readProjectConfig(kind, projectRoot) {
|
|
11972
|
-
const dir = kind === "pi" ? ".pi" : ".opencode";
|
|
11973
|
-
const jsonc = join8(projectRoot, dir, "aft.jsonc");
|
|
11974
|
-
const json = join8(projectRoot, dir, "aft.json");
|
|
11975
|
-
if (existsSync7(jsonc))
|
|
11976
|
-
return readJsoncFile(jsonc).value ?? {};
|
|
11977
|
-
if (existsSync7(json))
|
|
11978
|
-
return readJsoncFile(json).value ?? {};
|
|
11979
|
-
return {};
|
|
11980
|
-
}
|
|
11981
|
-
function mergeConfig(userConfig, projectConfig) {
|
|
11982
|
-
const userLsp = isRecord(userConfig.lsp) ? userConfig.lsp : {};
|
|
11983
|
-
const projectLsp = isRecord(projectConfig.lsp) ? projectConfig.lsp : {};
|
|
11984
|
-
return {
|
|
11985
|
-
...userConfig,
|
|
11986
|
-
...projectConfig,
|
|
11987
|
-
lsp: {
|
|
11988
|
-
...userLsp,
|
|
11989
|
-
...projectLsp,
|
|
11990
|
-
...isRecord(userLsp.servers) ? { servers: userLsp.servers } : {},
|
|
11991
|
-
...Array.isArray(userLsp.disabled) ? { disabled: userLsp.disabled } : {}
|
|
11992
|
-
}
|
|
11993
|
-
};
|
|
11994
|
-
}
|
|
11995
|
-
function resolveLspConfig(config) {
|
|
11996
|
-
const lsp = isRecord(config.lsp) ? config.lsp : {};
|
|
11997
|
-
const disabled = new Set;
|
|
11998
|
-
for (const entry of Array.isArray(lsp.disabled) ? lsp.disabled : []) {
|
|
11999
|
-
if (typeof entry === "string")
|
|
12000
|
-
disabled.add(entry.toLowerCase());
|
|
12001
|
-
}
|
|
12002
|
-
let experimentalTy = typeof config.experimental_lsp_ty === "boolean" ? config.experimental_lsp_ty : undefined;
|
|
12003
|
-
if (lsp.python === "ty") {
|
|
12004
|
-
experimentalTy = true;
|
|
12005
|
-
disabled.add("python");
|
|
12006
|
-
} else if (lsp.python === "pyright") {
|
|
12007
|
-
experimentalTy = false;
|
|
12008
|
-
disabled.add("ty");
|
|
12009
|
-
}
|
|
12010
|
-
const result = {};
|
|
12011
|
-
if (experimentalTy !== undefined)
|
|
12012
|
-
result.experimental_lsp_ty = experimentalTy;
|
|
12013
|
-
if (disabled.size > 0)
|
|
12014
|
-
result.disabled_lsp = [...disabled];
|
|
12015
|
-
const servers = resolveCustomServers(lsp.servers);
|
|
12016
|
-
if (servers.length > 0)
|
|
12017
|
-
result.lsp_servers = servers;
|
|
12018
|
-
return result;
|
|
12019
|
-
}
|
|
12020
|
-
function resolveCustomServers(servers) {
|
|
12021
|
-
if (!isRecord(servers))
|
|
12022
|
-
return [];
|
|
12023
|
-
return Object.entries(servers).filter(([, server]) => isRecord(server)).map(([id, server]) => {
|
|
12024
|
-
const entry = server;
|
|
12025
|
-
return {
|
|
12026
|
-
id,
|
|
12027
|
-
extensions: Array.isArray(entry.extensions) ? entry.extensions : [],
|
|
12028
|
-
binary: typeof entry.binary === "string" ? entry.binary : "",
|
|
12029
|
-
args: Array.isArray(entry.args) ? entry.args : [],
|
|
12030
|
-
root_markers: Array.isArray(entry.root_markers) ? entry.root_markers : [".git"],
|
|
12031
|
-
disabled: entry.disabled === true,
|
|
12032
|
-
...isRecord(entry.env) ? { env: entry.env } : {},
|
|
12033
|
-
...entry.initialization_options !== undefined ? { initialization_options: entry.initialization_options } : {}
|
|
12034
|
-
};
|
|
12035
|
-
}).filter((server) => typeof server.binary === "string" && server.binary.length > 0);
|
|
12036
|
-
}
|
|
12037
11959
|
function inferLspPathsExtra(_lsp) {
|
|
12038
11960
|
const paths = new Set;
|
|
12039
11961
|
for (const entry of childDirs(getAftLspPackagesDir())) {
|
|
@@ -12045,7 +11967,7 @@ function inferLspPathsExtra(_lsp) {
|
|
|
12045
11967
|
return [...paths];
|
|
12046
11968
|
}
|
|
12047
11969
|
function childDirs(path) {
|
|
12048
|
-
if (!
|
|
11970
|
+
if (!existsSync8(path))
|
|
12049
11971
|
return [];
|
|
12050
11972
|
try {
|
|
12051
11973
|
return readdirSync3(path).map((entry) => join8(path, entry)).filter((entry) => {
|
|
@@ -12090,14 +12012,11 @@ function installHint(binaryName) {
|
|
|
12090
12012
|
return "Install with `npm install -g pyright`.";
|
|
12091
12013
|
return `Install ${binaryName} and ensure it is on PATH or in lsp_paths_extra.`;
|
|
12092
12014
|
}
|
|
12093
|
-
function isRecord(value) {
|
|
12094
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12095
|
-
}
|
|
12096
12015
|
var PROJECT_ROOT_MARKERS;
|
|
12097
12016
|
var init_lsp = __esm(async () => {
|
|
12017
|
+
init_dist();
|
|
12098
12018
|
init_aft_bridge();
|
|
12099
12019
|
init_harness_select();
|
|
12100
|
-
init_jsonc();
|
|
12101
12020
|
init_paths2();
|
|
12102
12021
|
init_prompts();
|
|
12103
12022
|
init_self_version();
|
|
@@ -12128,9 +12047,9 @@ __export(exports_doctor_filters, {
|
|
|
12128
12047
|
renderFilterList: () => renderFilterList,
|
|
12129
12048
|
printDoctorFiltersHelp: () => printDoctorFiltersHelp
|
|
12130
12049
|
});
|
|
12131
|
-
import { existsSync as
|
|
12050
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
12132
12051
|
import { homedir as homedir7 } from "node:os";
|
|
12133
|
-
import { relative, resolve as
|
|
12052
|
+
import { relative, resolve as resolve5 } from "node:path";
|
|
12134
12053
|
function printDoctorFiltersHelp() {
|
|
12135
12054
|
console.log("Usage: aft doctor filters [--show <name>] [trust|untrust]");
|
|
12136
12055
|
console.log("");
|
|
@@ -12165,13 +12084,13 @@ async function runDoctorFilters(options) {
|
|
|
12165
12084
|
O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
12166
12085
|
return 1;
|
|
12167
12086
|
}
|
|
12168
|
-
const projectRoot =
|
|
12087
|
+
const projectRoot = resolve5(process.cwd());
|
|
12169
12088
|
const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
|
|
12170
12089
|
if (!list.success) {
|
|
12171
12090
|
O2.error(list.message ?? list.code ?? "list_filters failed");
|
|
12172
12091
|
return 1;
|
|
12173
12092
|
}
|
|
12174
|
-
list.project_dir_exists = list.project_dir ?
|
|
12093
|
+
list.project_dir_exists = list.project_dir ? existsSync9(list.project_dir) : false;
|
|
12175
12094
|
if (mode.kind === "list") {
|
|
12176
12095
|
console.log(renderFilterList(list, projectRoot));
|
|
12177
12096
|
return 0;
|
|
@@ -12370,11 +12289,11 @@ var init_doctor_filters = __esm(async () => {
|
|
|
12370
12289
|
});
|
|
12371
12290
|
|
|
12372
12291
|
// src/lib/binary-cache.ts
|
|
12373
|
-
import { existsSync as
|
|
12292
|
+
import { existsSync as existsSync10, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
|
|
12374
12293
|
import { join as join9 } from "node:path";
|
|
12375
12294
|
function getBinaryCacheInfo(activeVersion) {
|
|
12376
12295
|
const path = getAftBinaryCacheDir();
|
|
12377
|
-
if (!
|
|
12296
|
+
if (!existsSync10(path)) {
|
|
12378
12297
|
return {
|
|
12379
12298
|
versions: [],
|
|
12380
12299
|
activeVersion: null,
|
|
@@ -12482,7 +12401,7 @@ var init_sanitize = __esm(() => {
|
|
|
12482
12401
|
});
|
|
12483
12402
|
|
|
12484
12403
|
// src/lib/bridge-tool-failures.ts
|
|
12485
|
-
import { closeSync as closeSync2, existsSync as
|
|
12404
|
+
import { closeSync as closeSync2, existsSync as existsSync11, openSync as openSync2, readSync as readSync2, statSync as statSync6 } from "node:fs";
|
|
12486
12405
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
12487
12406
|
import { join as join10 } from "node:path";
|
|
12488
12407
|
function resolveBridgePluginLogPath() {
|
|
@@ -12490,7 +12409,7 @@ function resolveBridgePluginLogPath() {
|
|
|
12490
12409
|
return join10(tmpdir2(), isTestEnv ? "aft-plugin-test.log" : "aft-plugin.log");
|
|
12491
12410
|
}
|
|
12492
12411
|
function tailLogFileBytes(path, maxBytes) {
|
|
12493
|
-
if (!
|
|
12412
|
+
if (!existsSync11(path) || maxBytes <= 0)
|
|
12494
12413
|
return "";
|
|
12495
12414
|
let fd = null;
|
|
12496
12415
|
try {
|
|
@@ -12625,10 +12544,10 @@ var init_bridge_tool_failures = __esm(() => {
|
|
|
12625
12544
|
});
|
|
12626
12545
|
|
|
12627
12546
|
// src/lib/lsp-cache.ts
|
|
12628
|
-
import { existsSync as
|
|
12547
|
+
import { existsSync as existsSync12, readdirSync as readdirSync5, rmSync as rmSync2, statSync as statSync7 } from "node:fs";
|
|
12629
12548
|
import { join as join11 } from "node:path";
|
|
12630
12549
|
function inspectDir(path) {
|
|
12631
|
-
if (!
|
|
12550
|
+
if (!existsSync12(path)) {
|
|
12632
12551
|
return { entries: [], totalSize: 0 };
|
|
12633
12552
|
}
|
|
12634
12553
|
const entries = [];
|
|
@@ -12698,8 +12617,8 @@ var init_lsp_cache = __esm(() => {
|
|
|
12698
12617
|
});
|
|
12699
12618
|
|
|
12700
12619
|
// src/lib/onnx.ts
|
|
12701
|
-
import { existsSync as
|
|
12702
|
-
import { basename, isAbsolute as isAbsolute2, join as join12, resolve as
|
|
12620
|
+
import { existsSync as existsSync13, readdirSync as readdirSync6, readlinkSync, realpathSync as realpathSync3, statSync as statSync8 } from "node:fs";
|
|
12621
|
+
import { basename, isAbsolute as isAbsolute2, join as join12, resolve as resolve6, win32 } from "node:path";
|
|
12703
12622
|
function getOnnxLibraryName() {
|
|
12704
12623
|
if (process.platform === "darwin")
|
|
12705
12624
|
return "libonnxruntime.dylib";
|
|
@@ -12768,7 +12687,7 @@ function findSystemOnnxRuntime() {
|
|
|
12768
12687
|
if (!userProfile)
|
|
12769
12688
|
return nugetPaths;
|
|
12770
12689
|
const nugetPackageDir = join12(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
12771
|
-
if (!
|
|
12690
|
+
if (!existsSync13(nugetPackageDir))
|
|
12772
12691
|
return nugetPaths;
|
|
12773
12692
|
try {
|
|
12774
12693
|
for (const entry of readdirSync6(nugetPackageDir, { withFileTypes: true })) {
|
|
@@ -12786,7 +12705,7 @@ function findSystemOnnxRuntime() {
|
|
|
12786
12705
|
const seen = new Set;
|
|
12787
12706
|
const unknownVersionPaths = [];
|
|
12788
12707
|
for (const dir of searchPaths) {
|
|
12789
|
-
let key =
|
|
12708
|
+
let key = resolve6(dir).replace(/[/\\]+$/, "");
|
|
12790
12709
|
if (normalizeCase)
|
|
12791
12710
|
key = key.toLowerCase();
|
|
12792
12711
|
if (seen.has(key))
|
|
@@ -12808,10 +12727,10 @@ function findSystemOnnxRuntime() {
|
|
|
12808
12727
|
function findCachedOnnxRuntime(storageDir) {
|
|
12809
12728
|
const ortDir = join12(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
|
|
12810
12729
|
const libName = getOnnxLibraryName();
|
|
12811
|
-
if (
|
|
12730
|
+
if (existsSync13(join12(ortDir, libName)))
|
|
12812
12731
|
return ortDir;
|
|
12813
12732
|
const libSubdir = join12(ortDir, "lib");
|
|
12814
|
-
if (
|
|
12733
|
+
if (existsSync13(join12(libSubdir, libName)))
|
|
12815
12734
|
return libSubdir;
|
|
12816
12735
|
return null;
|
|
12817
12736
|
}
|
|
@@ -12832,7 +12751,7 @@ function parseOrtVersionFromDirectoryPath(value) {
|
|
|
12832
12751
|
return null;
|
|
12833
12752
|
}
|
|
12834
12753
|
function detectOrtVersion(libDir) {
|
|
12835
|
-
if (!
|
|
12754
|
+
if (!existsSync13(libDir))
|
|
12836
12755
|
return null;
|
|
12837
12756
|
const libName = getOnnxLibraryName();
|
|
12838
12757
|
try {
|
|
@@ -12848,7 +12767,7 @@ function detectOrtVersion(libDir) {
|
|
|
12848
12767
|
return version;
|
|
12849
12768
|
}
|
|
12850
12769
|
const base = join12(libDir, libName);
|
|
12851
|
-
if (
|
|
12770
|
+
if (existsSync13(base)) {
|
|
12852
12771
|
try {
|
|
12853
12772
|
const real = realpathSync3(base);
|
|
12854
12773
|
const version = parseOrtVersionFromPath(real) ?? parseOrtVersionFromDirectoryPath(real);
|
|
@@ -12883,7 +12802,7 @@ import {
|
|
|
12883
12802
|
accessSync,
|
|
12884
12803
|
closeSync as closeSync3,
|
|
12885
12804
|
constants,
|
|
12886
|
-
existsSync as
|
|
12805
|
+
existsSync as existsSync14,
|
|
12887
12806
|
openSync as openSync3,
|
|
12888
12807
|
readSync as readSync3,
|
|
12889
12808
|
statSync as statSync9
|
|
@@ -12915,7 +12834,7 @@ async function diagnoseHarness(adapter) {
|
|
|
12915
12834
|
const logPath = adapter.getLogFile();
|
|
12916
12835
|
const pluginCache = adapter.getPluginCacheInfo();
|
|
12917
12836
|
const storageAccessible = (() => {
|
|
12918
|
-
if (!
|
|
12837
|
+
if (!existsSync14(storage))
|
|
12919
12838
|
return false;
|
|
12920
12839
|
try {
|
|
12921
12840
|
accessSync(storage, constants.R_OK | constants.W_OK);
|
|
@@ -12938,14 +12857,14 @@ async function diagnoseHarness(adapter) {
|
|
|
12938
12857
|
pluginRegistered: adapter.hasPluginEntry(),
|
|
12939
12858
|
configPaths,
|
|
12940
12859
|
aftConfig: {
|
|
12941
|
-
exists:
|
|
12860
|
+
exists: existsSync14(configPaths.aftConfig),
|
|
12942
12861
|
...aftConfigRead.error ? { parseError: aftConfigRead.error } : {},
|
|
12943
12862
|
flags: aftFlags
|
|
12944
12863
|
},
|
|
12945
12864
|
pluginCache,
|
|
12946
12865
|
storageDir: {
|
|
12947
12866
|
path: storage,
|
|
12948
|
-
exists:
|
|
12867
|
+
exists: existsSync14(storage),
|
|
12949
12868
|
accessible: storageAccessible,
|
|
12950
12869
|
sizesByKey: describeStorage
|
|
12951
12870
|
},
|
|
@@ -12963,8 +12882,8 @@ async function diagnoseHarness(adapter) {
|
|
|
12963
12882
|
},
|
|
12964
12883
|
logFile: {
|
|
12965
12884
|
path: logPath,
|
|
12966
|
-
exists:
|
|
12967
|
-
sizeKb:
|
|
12885
|
+
exists: existsSync14(logPath),
|
|
12886
|
+
sizeKb: existsSync14(logPath) ? Math.round(statSync9(logPath).size / 1024) : 0
|
|
12968
12887
|
}
|
|
12969
12888
|
};
|
|
12970
12889
|
}
|
|
@@ -13158,7 +13077,7 @@ function formatDiagnosticIssuesSection(report) {
|
|
|
13158
13077
|
return lines;
|
|
13159
13078
|
}
|
|
13160
13079
|
function tailLogFile(path, lines) {
|
|
13161
|
-
if (!
|
|
13080
|
+
if (!existsSync14(path))
|
|
13162
13081
|
return "";
|
|
13163
13082
|
if (lines <= 0)
|
|
13164
13083
|
return "";
|
|
@@ -13344,7 +13263,7 @@ var init_issue_body = __esm(() => {
|
|
|
13344
13263
|
});
|
|
13345
13264
|
|
|
13346
13265
|
// src/lib/onnx-fix.ts
|
|
13347
|
-
import { existsSync as
|
|
13266
|
+
import { existsSync as existsSync15, rmSync as rmSync3 } from "node:fs";
|
|
13348
13267
|
import { join as join13 } from "node:path";
|
|
13349
13268
|
function findOnnxFixCandidates(report) {
|
|
13350
13269
|
const candidates = [];
|
|
@@ -13362,7 +13281,7 @@ function findOnnxFixCandidates(report) {
|
|
|
13362
13281
|
harness,
|
|
13363
13282
|
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.`,
|
|
13364
13283
|
storageOnnxDir,
|
|
13365
|
-
storageOnnxBytes:
|
|
13284
|
+
storageOnnxBytes: existsSync15(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
13366
13285
|
});
|
|
13367
13286
|
continue;
|
|
13368
13287
|
}
|
|
@@ -13371,7 +13290,7 @@ function findOnnxFixCandidates(report) {
|
|
|
13371
13290
|
harness,
|
|
13372
13291
|
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.`,
|
|
13373
13292
|
storageOnnxDir,
|
|
13374
|
-
storageOnnxBytes:
|
|
13293
|
+
storageOnnxBytes: existsSync15(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
13375
13294
|
});
|
|
13376
13295
|
}
|
|
13377
13296
|
}
|
|
@@ -13401,7 +13320,7 @@ async function runOnnxFix(adapters, report, options = {}) {
|
|
|
13401
13320
|
const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
|
|
13402
13321
|
const rmFn = options.rmFn ?? rmSync3;
|
|
13403
13322
|
for (const c2 of candidates) {
|
|
13404
|
-
if (!
|
|
13323
|
+
if (!existsSync15(c2.storageOnnxDir)) {
|
|
13405
13324
|
O2.success(`${c2.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
|
|
13406
13325
|
continue;
|
|
13407
13326
|
}
|
|
@@ -13427,7 +13346,7 @@ var init_onnx_fix = __esm(() => {
|
|
|
13427
13346
|
});
|
|
13428
13347
|
|
|
13429
13348
|
// src/lib/sessions.ts
|
|
13430
|
-
import { existsSync as
|
|
13349
|
+
import { existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync5, statSync as statSync10 } from "node:fs";
|
|
13431
13350
|
import { createRequire as createRequire3 } from "node:module";
|
|
13432
13351
|
import { homedir as homedir9 } from "node:os";
|
|
13433
13352
|
import { basename as basename2, join as join14 } from "node:path";
|
|
@@ -13460,7 +13379,7 @@ function mapOpenCodeSessionRows(rows) {
|
|
|
13460
13379
|
}
|
|
13461
13380
|
function listRecentOpenCodeSessions() {
|
|
13462
13381
|
const dbPath = join14(getXdgDataHome(), "opencode", "opencode.db");
|
|
13463
|
-
if (!
|
|
13382
|
+
if (!existsSync16(dbPath))
|
|
13464
13383
|
return [];
|
|
13465
13384
|
let db = null;
|
|
13466
13385
|
try {
|
|
@@ -13490,7 +13409,7 @@ function getHomeDir() {
|
|
|
13490
13409
|
}
|
|
13491
13410
|
function listPiSessionsFromDir(sessionsDir) {
|
|
13492
13411
|
try {
|
|
13493
|
-
if (!
|
|
13412
|
+
if (!existsSync16(sessionsDir))
|
|
13494
13413
|
return [];
|
|
13495
13414
|
const files = collectJsonlFiles(sessionsDir).map((filePath) => {
|
|
13496
13415
|
try {
|
|
@@ -13502,7 +13421,7 @@ function listPiSessionsFromDir(sessionsDir) {
|
|
|
13502
13421
|
}).filter((entry) => entry !== null).sort((a, b) => b.mtimeMs - a.mtimeMs).slice(0, MAX_RECENT_SESSIONS * 4);
|
|
13503
13422
|
const sessions = [];
|
|
13504
13423
|
for (const file of files) {
|
|
13505
|
-
const parsed = parsePiSessionJsonl(
|
|
13424
|
+
const parsed = parsePiSessionJsonl(readFileSync5(file.filePath, "utf8"), basename2(file.filePath));
|
|
13506
13425
|
if (!parsed)
|
|
13507
13426
|
continue;
|
|
13508
13427
|
sessions.push({ ...parsed, lastActivity: file.mtimeMs });
|
|
@@ -13628,10 +13547,10 @@ __export(exports_doctor, {
|
|
|
13628
13547
|
import { execFileSync } from "node:child_process";
|
|
13629
13548
|
import {
|
|
13630
13549
|
chmodSync as chmodSync2,
|
|
13631
|
-
existsSync as
|
|
13550
|
+
existsSync as existsSync17,
|
|
13632
13551
|
mkdirSync as mkdirSync3,
|
|
13633
13552
|
mkdtempSync,
|
|
13634
|
-
readFileSync as
|
|
13553
|
+
readFileSync as readFileSync6,
|
|
13635
13554
|
realpathSync as realpathSync4,
|
|
13636
13555
|
rmSync as rmSync4,
|
|
13637
13556
|
statSync as statSync11,
|
|
@@ -13792,7 +13711,7 @@ function clearOldBinaries() {
|
|
|
13792
13711
|
errors: [],
|
|
13793
13712
|
keptVersion: keepTag
|
|
13794
13713
|
};
|
|
13795
|
-
if (!
|
|
13714
|
+
if (!existsSync17(info.path)) {
|
|
13796
13715
|
O2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
13797
13716
|
return result;
|
|
13798
13717
|
}
|
|
@@ -14127,7 +14046,7 @@ function ensureStorageDirsForRegisteredPlugins(adapters) {
|
|
|
14127
14046
|
if (!adapter.isInstalled() || !adapter.hasPluginEntry())
|
|
14128
14047
|
continue;
|
|
14129
14048
|
const storageDir = adapter.getStorageDir();
|
|
14130
|
-
if (
|
|
14049
|
+
if (existsSync17(storageDir))
|
|
14131
14050
|
continue;
|
|
14132
14051
|
mkdirSync3(storageDir, { recursive: true });
|
|
14133
14052
|
summary.created += 1;
|
|
@@ -14255,7 +14174,7 @@ function readReviewedIssueFile(reviewFile) {
|
|
|
14255
14174
|
O2.error(`Review file path changed before filing; refusing to read ${reviewFile.path}.`);
|
|
14256
14175
|
return null;
|
|
14257
14176
|
}
|
|
14258
|
-
return
|
|
14177
|
+
return readFileSync6(reviewFile.path, "utf8");
|
|
14259
14178
|
} catch (err) {
|
|
14260
14179
|
O2.error(`Failed to read reviewed issue report: ${err instanceof Error ? err.message : String(err)}`);
|
|
14261
14180
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/aft",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Unified CLI for Agent File Tools (AFT) — setup, doctor, and diagnostics across supported agent harnesses (OpenCode, Pi)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@clack/prompts": "^1.2.0",
|
|
27
|
-
"@cortexkit/aft-bridge": "0.
|
|
27
|
+
"@cortexkit/aft-bridge": "0.40.1",
|
|
28
28
|
"comment-json": "^4.6.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|