@cortexkit/aft 0.39.3 → 0.40.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.
@@ -1 +1 @@
1
- {"version":3,"file":"lsp.d.ts","sourceRoot":"","sources":["../../src/commands/lsp.ts"],"names":[],"mappings":"AAIA,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;AAMrE,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"}
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 LONG_RUNNING_COMMAND_TIMEOUT_MS, PASSIVE_COMMANDS, PASSIVE_COMMAND_TIMEOUT_MS = 5000;
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 clampSemanticTimeout(configOverrides, bridgeTimeoutMs) {
215
- const semantic = configOverrides.semantic;
216
- if (!semantic || typeof semantic !== "object" || Array.isArray(semantic)) {
217
- return configOverrides;
218
- }
219
- const timeoutMs = semantic.timeout_ms;
220
- if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs)) {
221
- return configOverrides;
222
- }
223
- const semanticTransportBudgetMs = Math.max(bridgeTimeoutMs, LONG_RUNNING_COMMAND_TIMEOUT_MS.semantic_search ?? 0);
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, SEMANTIC_TIMEOUT_SAFETY_MARGIN_MS = 5000, 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, BinaryBridge;
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();
@@ -256,6 +237,17 @@ var init_bridge = __esm(() => {
256
237
  this.name = "BridgeReplacedDuringVersionCheck";
257
238
  }
258
239
  };
240
+ BridgeTransportTimeoutError = class BridgeTransportTimeoutError extends Error {
241
+ command;
242
+ timeoutMs;
243
+ code = "transport_timeout";
244
+ constructor(command, timeoutMs, message) {
245
+ super(message);
246
+ this.command = command;
247
+ this.timeoutMs = timeoutMs;
248
+ this.name = "BridgeTransportTimeoutError";
249
+ }
250
+ };
259
251
  BinaryBridge = class BinaryBridge {
260
252
  static RESTART_RESET_MS = 5 * 60 * 1000;
261
253
  static STDERR_TAIL_MAX = 20;
@@ -299,7 +291,7 @@ var init_bridge = __esm(() => {
299
291
  this.timeoutMs = options?.timeoutMs ?? DEFAULT_BRIDGE_TIMEOUT_MS;
300
292
  this.hangThreshold = options?.hangThreshold ?? BRIDGE_HANG_TIMEOUT_THRESHOLD;
301
293
  this.maxRestarts = options?.maxRestarts ?? 3;
302
- this.configOverrides = clampSemanticTimeout(configOverrides ?? {}, this.timeoutMs);
294
+ this.configOverrides = configOverrides ?? {};
303
295
  this.minVersion = options?.minVersion;
304
296
  this.onVersionMismatch = options?.onVersionMismatch;
305
297
  this.onConfigureWarnings = options?.onConfigureWarnings;
@@ -483,7 +475,7 @@ var init_bridge = __esm(() => {
483
475
  } else {
484
476
  this.warnVia(timeoutMsg2);
485
477
  }
486
- entry.reject(new Error(`${this.errorPrefix} Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms`));
478
+ entry.reject(new BridgeTransportTimeoutError(command, effectiveTimeoutMs, `${this.errorPrefix} Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms`));
487
479
  return;
488
480
  }
489
481
  const childActiveSinceRequest = this.lastChildActivityAt > requestSentAt;
@@ -536,18 +528,24 @@ var init_bridge = __esm(() => {
536
528
  }
537
529
  }
538
530
  async deliverConfigureWarnings(configResult, params, options) {
539
- if (!this.onConfigureWarnings || !Array.isArray(configResult.warnings))
531
+ if (!this.onConfigureWarnings)
540
532
  return;
541
- if (configResult.warnings.length === 0)
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)
542
536
  return;
543
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
+ }
544
547
  try {
545
- await this.onConfigureWarnings({
546
- projectRoot: this.cwd,
547
- sessionId,
548
- client: options?.configureWarningClient ?? (sessionId ? this.configureWarningClients.get(sessionId) : undefined),
549
- warnings: configResult.warnings
550
- });
548
+ await this.onConfigureWarnings(context);
551
549
  } catch (err) {
552
550
  this.warnVia(`configure warning delivery failed: ${err instanceof Error ? err.message : String(err)}`);
553
551
  } finally {
@@ -1023,6 +1021,35 @@ var init_bridge = __esm(() => {
1023
1021
 
1024
1022
  // ../aft-bridge/dist/callgraph-format.js
1025
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
+
1026
1053
  // ../aft-bridge/dist/platform.js
1027
1054
  var init_platform = () => {};
1028
1055
 
@@ -1038,7 +1065,7 @@ var init_downloader = __esm(() => {
1038
1065
  var init_paths = () => {};
1039
1066
 
1040
1067
  // ../aft-bridge/dist/resolver.js
1041
- 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";
1042
1069
  function isNativeExecutable(binaryPath) {
1043
1070
  let fd = null;
1044
1071
  try {
@@ -1243,63 +1270,39 @@ var init_onnx_runtime = __esm(() => {
1243
1270
  };
1244
1271
  });
1245
1272
 
1246
- // ../aft-bridge/dist/pipe-strip.js
1247
- var NOISE_FILTERS, GREP_GUARD_FLAGS, XCODEBUILD_VALUE_FLAGS, XCODEBUILD_BUILD_ACTIONS, READS_FILE_OPERAND;
1248
- var init_pipe_strip = __esm(() => {
1249
- NOISE_FILTERS = new Set([
1250
- "grep",
1251
- "rg",
1252
- "head",
1253
- "tail",
1254
- "cat",
1255
- "less",
1256
- "more",
1257
- "sed",
1258
- "awk",
1259
- "cut",
1260
- "sort",
1261
- "uniq",
1262
- "tr",
1263
- "column",
1264
- "fold"
1265
- ]);
1266
- GREP_GUARD_FLAGS = new Set([
1267
- "c",
1268
- "count",
1269
- "q",
1270
- "quiet",
1271
- "o",
1272
- "only-matching",
1273
- "l",
1274
- "files-with-matches"
1275
- ]);
1276
- XCODEBUILD_VALUE_FLAGS = new Set([
1277
- "-scheme",
1278
- "-target",
1279
- "-project",
1280
- "-workspace",
1281
- "-configuration",
1282
- "-sdk",
1283
- "-destination",
1284
- "-arch",
1285
- "-derivedDataPath",
1286
- "-resultBundlePath",
1287
- "-xcconfig",
1288
- "-toolchain"
1289
- ]);
1290
- XCODEBUILD_BUILD_ACTIONS = new Set([
1291
- "build",
1292
- "test",
1293
- "build-for-testing",
1294
- "test-without-building",
1295
- "analyze"
1296
- ]);
1297
- READS_FILE_OPERAND = new Set(["cat", "tac", "nl", "less", "more"]);
1298
- });
1299
-
1300
- // ../aft-bridge/dist/pool.js
1273
+ // ../aft-bridge/dist/project-identity.js
1301
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 = () => {};
1302
1304
 
1305
+ // ../aft-bridge/dist/pool.js
1303
1306
  class BridgePool {
1304
1307
  bridges = new Map;
1305
1308
  staleBridges = new Set;
@@ -1467,17 +1470,13 @@ class BridgePool {
1467
1470
  }
1468
1471
  }
1469
1472
  function normalizeKey(projectRoot) {
1470
- const stripped = projectRoot.replace(/[/\\]+$/, "");
1471
- try {
1472
- return realpathSync(stripped);
1473
- } catch {
1474
- return stripped;
1475
- }
1473
+ return canonicalizeProjectRoot(projectRoot);
1476
1474
  }
1477
1475
  var DEFAULT_IDLE_TIMEOUT_MS, DEFAULT_MAX_POOL_SIZE = 8, CLEANUP_INTERVAL_MS;
1478
1476
  var init_pool = __esm(() => {
1479
1477
  init_active_logger();
1480
1478
  init_bridge();
1479
+ init_project_identity();
1481
1480
  DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
1482
1481
  CLEANUP_INTERVAL_MS = 60 * 1000;
1483
1482
  });
@@ -1488,14 +1487,15 @@ var init_dist = __esm(() => {
1488
1487
  init_bridge();
1489
1488
  init_callgraph_format();
1490
1489
  init_command_timeouts();
1490
+ init_config_tiers();
1491
1491
  init_downloader();
1492
1492
  init_migration();
1493
1493
  init_npm_resolver();
1494
1494
  init_onnx_runtime();
1495
1495
  init_paths();
1496
- init_pipe_strip();
1497
1496
  init_platform();
1498
1497
  init_pool();
1498
+ init_project_identity();
1499
1499
  init_resolver();
1500
1500
  });
1501
1501
 
@@ -1564,7 +1564,7 @@ var init_paths2 = () => {};
1564
1564
 
1565
1565
  // src/lib/binary-probe.ts
1566
1566
  import { execSync, spawnSync } from "node:child_process";
1567
- import { existsSync as existsSync2 } from "node:fs";
1567
+ import { existsSync as existsSync3 } from "node:fs";
1568
1568
  import { createRequire } from "node:module";
1569
1569
  import { homedir as homedir4 } from "node:os";
1570
1570
  import { join as join4 } from "node:path";
@@ -1620,7 +1620,7 @@ function probeAftBinary(preferredVersion) {
1620
1620
  const candidates = [];
1621
1621
  for (const candidate of aftBinaryCandidates(preferredVersion)) {
1622
1622
  try {
1623
- if (!existsSync2(candidate))
1623
+ if (!existsSync3(candidate))
1624
1624
  continue;
1625
1625
  const result = spawnSync(candidate, ["--version"], {
1626
1626
  stdio: ["ignore", "pipe", "pipe"],
@@ -1671,7 +1671,7 @@ function pushCandidate(candidates, candidate) {
1671
1671
  function firstExisting(candidates) {
1672
1672
  for (const candidate of candidates) {
1673
1673
  try {
1674
- if (!existsSync2(candidate))
1674
+ if (!existsSync3(candidate))
1675
1675
  continue;
1676
1676
  return candidate;
1677
1677
  } catch {}
@@ -1728,10 +1728,10 @@ var init_binary_probe = __esm(async () => {
1728
1728
  });
1729
1729
 
1730
1730
  // src/lib/fs-util.ts
1731
- import { existsSync as existsSync3, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
1731
+ import { existsSync as existsSync4, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
1732
1732
  import { join as join5 } from "node:path";
1733
1733
  function dirSize(path) {
1734
- if (!existsSync3(path)) {
1734
+ if (!existsSync4(path)) {
1735
1735
  return 0;
1736
1736
  }
1737
1737
  const stat = statSync2(path);
@@ -9517,25 +9517,25 @@ var require_src2 = __commonJS((exports, module) => {
9517
9517
  });
9518
9518
 
9519
9519
  // src/lib/jsonc.ts
9520
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "node:fs";
9520
+ import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "node:fs";
9521
9521
  import { dirname as dirname2 } from "node:path";
9522
9522
  function detectJsoncFile(configDir, baseName) {
9523
9523
  const jsoncPath = `${configDir}/${baseName}.jsonc`;
9524
9524
  const jsonPath = `${configDir}/${baseName}.json`;
9525
- if (existsSync4(jsoncPath)) {
9525
+ if (existsSync5(jsoncPath)) {
9526
9526
  return { path: jsoncPath, format: "jsonc" };
9527
9527
  }
9528
- if (existsSync4(jsonPath)) {
9528
+ if (existsSync5(jsonPath)) {
9529
9529
  return { path: jsonPath, format: "json" };
9530
9530
  }
9531
9531
  return { path: jsonPath, format: "none" };
9532
9532
  }
9533
9533
  function readJsoncFile(path) {
9534
- if (!existsSync4(path)) {
9534
+ if (!existsSync5(path)) {
9535
9535
  return { value: null };
9536
9536
  }
9537
9537
  try {
9538
- const raw = readFileSync(path, "utf-8");
9538
+ const raw = readFileSync2(path, "utf-8");
9539
9539
  const value = import_comment_json.parse(raw);
9540
9540
  return { value };
9541
9541
  } catch (error2) {
@@ -9552,7 +9552,7 @@ function writeJsoncFile(path, value, format = "json") {
9552
9552
  `);
9553
9553
  }
9554
9554
  function ensureAftSchemaUrl(path, format) {
9555
- const existed = existsSync4(path);
9555
+ const existed = existsSync5(path);
9556
9556
  if (!existed) {
9557
9557
  const writeFormat = format === "jsonc" ? "jsonc" : "json";
9558
9558
  writeJsoncFile(path, { $schema: AFT_SCHEMA_URL }, writeFormat);
@@ -9605,14 +9605,14 @@ var init_self_version = () => {};
9605
9605
 
9606
9606
  // src/adapters/opencode.ts
9607
9607
  import { execSync as execSync2 } from "node:child_process";
9608
- import { existsSync as existsSync5, readFileSync as readFileSync2, rmSync, statSync as statSync3 } from "node:fs";
9608
+ import { existsSync as existsSync6, readFileSync as readFileSync3, rmSync, statSync as statSync3 } from "node:fs";
9609
9609
  import { homedir as homedir5 } from "node:os";
9610
- 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";
9611
9611
  import { fileURLToPath } from "node:url";
9612
9612
  function getOpenCodeConfigDir() {
9613
9613
  const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
9614
9614
  if (envDir)
9615
- return resolve(envDir);
9615
+ return resolve3(envDir);
9616
9616
  const xdg = process.env.XDG_CONFIG_HOME || join6(homedir5(), ".config");
9617
9617
  return join6(xdg, "opencode");
9618
9618
  }
@@ -9646,7 +9646,7 @@ function openCodeDesktopAppExists() {
9646
9646
  }
9647
9647
  return candidates.some((p) => {
9648
9648
  try {
9649
- return existsSync5(p);
9649
+ return existsSync6(p);
9650
9650
  } catch {
9651
9651
  return false;
9652
9652
  }
@@ -9669,13 +9669,13 @@ function pathPointsToOurPlugin(entry) {
9669
9669
  if (!fsPath)
9670
9670
  return false;
9671
9671
  try {
9672
- if (!existsSync5(fsPath))
9672
+ if (!existsSync6(fsPath))
9673
9673
  return false;
9674
9674
  let searchDir = statSync3(fsPath).isDirectory() ? fsPath : dirname3(fsPath);
9675
9675
  let pkgJsonPath = null;
9676
9676
  while (true) {
9677
9677
  const candidate = join6(searchDir, "package.json");
9678
- if (existsSync5(candidate)) {
9678
+ if (existsSync6(candidate)) {
9679
9679
  pkgJsonPath = candidate;
9680
9680
  break;
9681
9681
  }
@@ -9686,7 +9686,7 @@ function pathPointsToOurPlugin(entry) {
9686
9686
  }
9687
9687
  if (!pkgJsonPath)
9688
9688
  return false;
9689
- const parsed = JSON.parse(readFileSync2(pkgJsonPath, "utf-8"));
9689
+ const parsed = JSON.parse(readFileSync3(pkgJsonPath, "utf-8"));
9690
9690
  return parsed.name === PLUGIN_NAME;
9691
9691
  } catch {
9692
9692
  return false;
@@ -9706,7 +9706,7 @@ class OpenCodeAdapter {
9706
9706
  pluginPackageName = PLUGIN_NAME;
9707
9707
  pluginEntryWithVersion = PLUGIN_ENTRY;
9708
9708
  isInstalled() {
9709
- if (existsSync5(getOpenCodeConfigDir()))
9709
+ if (existsSync6(getOpenCodeConfigDir()))
9710
9710
  return true;
9711
9711
  if (openCodeDesktopAppExists())
9712
9712
  return true;
@@ -9791,8 +9791,8 @@ class OpenCodeAdapter {
9791
9791
  let cached;
9792
9792
  try {
9793
9793
  const installedPkgPath = join6(path, "node_modules", "@cortexkit", "aft-opencode", "package.json");
9794
- if (existsSync5(installedPkgPath)) {
9795
- const pkg = JSON.parse(readFileSync2(installedPkgPath, "utf-8"));
9794
+ if (existsSync6(installedPkgPath)) {
9795
+ const pkg = JSON.parse(readFileSync3(installedPkgPath, "utf-8"));
9796
9796
  cached = typeof pkg.version === "string" ? pkg.version : undefined;
9797
9797
  }
9798
9798
  } catch {
@@ -9802,7 +9802,7 @@ class OpenCodeAdapter {
9802
9802
  path,
9803
9803
  cached,
9804
9804
  latest: getSelfVersion(),
9805
- exists: existsSync5(path)
9805
+ exists: existsSync6(path)
9806
9806
  };
9807
9807
  }
9808
9808
  getStorageDir() {
@@ -9870,7 +9870,7 @@ var init_opencode = __esm(() => {
9870
9870
 
9871
9871
  // src/adapters/pi.ts
9872
9872
  import { execSync as execSync3, spawnSync as spawnSync2 } from "node:child_process";
9873
- import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
9873
+ import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
9874
9874
  import { homedir as homedir6 } from "node:os";
9875
9875
  import { join as join7 } from "node:path";
9876
9876
  function getPiAgentDir() {
@@ -9880,9 +9880,9 @@ function getPiAgentDir() {
9880
9880
  }
9881
9881
  function readPiExtensionIndex() {
9882
9882
  const settingsPath = join7(getPiAgentDir(), "settings.json");
9883
- if (existsSync6(settingsPath)) {
9883
+ if (existsSync7(settingsPath)) {
9884
9884
  try {
9885
- const raw = readFileSync3(settingsPath, "utf-8");
9885
+ const raw = readFileSync4(settingsPath, "utf-8");
9886
9886
  const trimmed = raw.replace(/^\uFEFF/, "");
9887
9887
  const value = JSON.parse(trimmed);
9888
9888
  const packages = value.packages;
@@ -9899,7 +9899,7 @@ function readPiExtensionIndex() {
9899
9899
  join7(getPiAgentDir(), "config.jsonc")
9900
9900
  ];
9901
9901
  for (const path of candidates) {
9902
- if (!existsSync6(path))
9902
+ if (!existsSync7(path))
9903
9903
  continue;
9904
9904
  try {
9905
9905
  const { value } = readJsoncFile(path);
@@ -9937,12 +9937,12 @@ function piEntryMatchesAft(entry) {
9937
9937
  if (!resolved)
9938
9938
  return false;
9939
9939
  try {
9940
- if (!existsSync6(resolved))
9940
+ if (!existsSync7(resolved))
9941
9941
  return false;
9942
9942
  const pkgPath = join7(resolved, "package.json");
9943
- if (!existsSync6(pkgPath))
9943
+ if (!existsSync7(pkgPath))
9944
9944
  return false;
9945
- const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
9945
+ const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
9946
9946
  return pkg.name === PLUGIN_NAME2;
9947
9947
  } catch {
9948
9948
  return false;
@@ -10039,10 +10039,10 @@ class PiAdapter {
10039
10039
  join7(getPiAgentDir(), "extensions", "node_modules", "@cortexkit", "aft-pi", "package.json")
10040
10040
  ];
10041
10041
  for (const candidate of candidates) {
10042
- if (!existsSync6(candidate))
10042
+ if (!existsSync7(candidate))
10043
10043
  continue;
10044
10044
  try {
10045
- const pkg = JSON.parse(readFileSync3(candidate, "utf-8"));
10045
+ const pkg = JSON.parse(readFileSync4(candidate, "utf-8"));
10046
10046
  const cached = typeof pkg.version === "string" ? pkg.version : undefined;
10047
10047
  return {
10048
10048
  path: candidate,
@@ -11696,7 +11696,7 @@ function isResponseForRequest(parsed, expectedIds) {
11696
11696
  return expectedIds.has(id);
11697
11697
  }
11698
11698
  async function sendAftRequests(binaryPath, requests) {
11699
- return new Promise((resolve2, reject) => {
11699
+ return new Promise((resolve4, reject) => {
11700
11700
  const child = spawn2(binaryPath, [], {
11701
11701
  stdio: ["pipe", "pipe", "pipe"]
11702
11702
  });
@@ -11733,7 +11733,7 @@ async function sendAftRequests(binaryPath, requests) {
11733
11733
  const response = parsed;
11734
11734
  responses.push(response);
11735
11735
  if (responses.length === requests.length) {
11736
- finish(() => resolve2(responses));
11736
+ finish(() => resolve4(responses));
11737
11737
  }
11738
11738
  };
11739
11739
  child.stdout.setEncoding("utf-8");
@@ -11808,25 +11808,25 @@ __export(exports_lsp, {
11808
11808
  printLspDoctorHelp: () => printLspDoctorHelp,
11809
11809
  findProjectRootForFile: () => findProjectRootForFile
11810
11810
  });
11811
- import { existsSync as existsSync7, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
11812
- import { dirname as dirname4, join as join8, resolve as resolve2 } from "node:path";
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";
11813
11813
  function findProjectRootForFile(filePath, fallbackCwd = process.cwd()) {
11814
- const resolvedFile = resolve2(fallbackCwd, filePath);
11814
+ const resolvedFile = resolve4(fallbackCwd, filePath);
11815
11815
  let dir = dirname4(resolvedFile);
11816
11816
  try {
11817
- if (existsSync7(resolvedFile) && statSync4(resolvedFile).isDirectory()) {
11817
+ if (existsSync8(resolvedFile) && statSync4(resolvedFile).isDirectory()) {
11818
11818
  dir = resolvedFile;
11819
11819
  }
11820
11820
  } catch {
11821
11821
  dir = dirname4(resolvedFile);
11822
11822
  }
11823
11823
  while (true) {
11824
- if (PROJECT_ROOT_MARKERS.some((marker) => existsSync7(join8(dir, marker)))) {
11824
+ if (PROJECT_ROOT_MARKERS.some((marker) => existsSync8(join8(dir, marker)))) {
11825
11825
  return dir;
11826
11826
  }
11827
11827
  const parent = dirname4(dir);
11828
11828
  if (parent === dir)
11829
- return resolve2(fallbackCwd);
11829
+ return resolve4(fallbackCwd);
11830
11830
  dir = parent;
11831
11831
  }
11832
11832
  }
@@ -11857,7 +11857,7 @@ async function runLspDoctor(options) {
11857
11857
  O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
11858
11858
  return 1;
11859
11859
  }
11860
- const resolvedFile = resolve2(file);
11860
+ const resolvedFile = resolve4(file);
11861
11861
  const projectRoot = findProjectRootForFile(resolvedFile);
11862
11862
  const config = buildConfigureParams(adapter, projectRoot);
11863
11863
  const inspectRequest = {
@@ -11942,87 +11942,20 @@ function parseFileArg(argv) {
11942
11942
  return null;
11943
11943
  }
11944
11944
  function buildConfigureParams(adapter, projectRoot) {
11945
- const paths = adapter.detectConfigPaths();
11946
- const userConfig = readJsoncFile(paths.aftConfig).value ?? {};
11947
- const projectConfig = readProjectConfig(adapter.kind, projectRoot);
11948
- const merged = mergeConfig(userConfig, projectConfig);
11949
- const lsp = isRecord(merged.lsp) ? merged.lsp : {};
11950
- 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;
11951
11950
  return {
11952
11951
  id: "doctor-lsp-configure",
11953
11952
  command: "configure",
11954
11953
  project_root: projectRoot,
11955
11954
  harness: adapter.kind,
11956
- ...lspConfig,
11957
- lsp_paths_extra: inferLspPathsExtra(lsp)
11958
- };
11959
- }
11960
- function readProjectConfig(kind, projectRoot) {
11961
- const dir = kind === "pi" ? ".pi" : ".opencode";
11962
- const jsonc = join8(projectRoot, dir, "aft.jsonc");
11963
- const json = join8(projectRoot, dir, "aft.json");
11964
- if (existsSync7(jsonc))
11965
- return readJsoncFile(jsonc).value ?? {};
11966
- if (existsSync7(json))
11967
- return readJsoncFile(json).value ?? {};
11968
- return {};
11969
- }
11970
- function mergeConfig(userConfig, projectConfig) {
11971
- const userLsp = isRecord(userConfig.lsp) ? userConfig.lsp : {};
11972
- const projectLsp = isRecord(projectConfig.lsp) ? projectConfig.lsp : {};
11973
- return {
11974
- ...userConfig,
11975
- ...projectConfig,
11976
- lsp: {
11977
- ...userLsp,
11978
- ...projectLsp,
11979
- ...isRecord(userLsp.servers) ? { servers: userLsp.servers } : {},
11980
- ...Array.isArray(userLsp.disabled) ? { disabled: userLsp.disabled } : {}
11981
- }
11955
+ config: readConfigTiers({ userConfigPath, projectConfigPath }),
11956
+ lsp_paths_extra: inferLspPathsExtra({})
11982
11957
  };
11983
11958
  }
11984
- function resolveLspConfig(config) {
11985
- const lsp = isRecord(config.lsp) ? config.lsp : {};
11986
- const disabled = new Set;
11987
- for (const entry of Array.isArray(lsp.disabled) ? lsp.disabled : []) {
11988
- if (typeof entry === "string")
11989
- disabled.add(entry.toLowerCase());
11990
- }
11991
- let experimentalTy = typeof config.experimental_lsp_ty === "boolean" ? config.experimental_lsp_ty : undefined;
11992
- if (lsp.python === "ty") {
11993
- experimentalTy = true;
11994
- disabled.add("python");
11995
- } else if (lsp.python === "pyright") {
11996
- experimentalTy = false;
11997
- disabled.add("ty");
11998
- }
11999
- const result = {};
12000
- if (experimentalTy !== undefined)
12001
- result.experimental_lsp_ty = experimentalTy;
12002
- if (disabled.size > 0)
12003
- result.disabled_lsp = [...disabled];
12004
- const servers = resolveCustomServers(lsp.servers);
12005
- if (servers.length > 0)
12006
- result.lsp_servers = servers;
12007
- return result;
12008
- }
12009
- function resolveCustomServers(servers) {
12010
- if (!isRecord(servers))
12011
- return [];
12012
- return Object.entries(servers).filter(([, server]) => isRecord(server)).map(([id, server]) => {
12013
- const entry = server;
12014
- return {
12015
- id,
12016
- extensions: Array.isArray(entry.extensions) ? entry.extensions : [],
12017
- binary: typeof entry.binary === "string" ? entry.binary : "",
12018
- args: Array.isArray(entry.args) ? entry.args : [],
12019
- root_markers: Array.isArray(entry.root_markers) ? entry.root_markers : [".git"],
12020
- disabled: entry.disabled === true,
12021
- ...isRecord(entry.env) ? { env: entry.env } : {},
12022
- ...entry.initialization_options !== undefined ? { initialization_options: entry.initialization_options } : {}
12023
- };
12024
- }).filter((server) => typeof server.binary === "string" && server.binary.length > 0);
12025
- }
12026
11959
  function inferLspPathsExtra(_lsp) {
12027
11960
  const paths = new Set;
12028
11961
  for (const entry of childDirs(getAftLspPackagesDir())) {
@@ -12034,7 +11967,7 @@ function inferLspPathsExtra(_lsp) {
12034
11967
  return [...paths];
12035
11968
  }
12036
11969
  function childDirs(path) {
12037
- if (!existsSync7(path))
11970
+ if (!existsSync8(path))
12038
11971
  return [];
12039
11972
  try {
12040
11973
  return readdirSync3(path).map((entry) => join8(path, entry)).filter((entry) => {
@@ -12079,14 +12012,11 @@ function installHint(binaryName) {
12079
12012
  return "Install with `npm install -g pyright`.";
12080
12013
  return `Install ${binaryName} and ensure it is on PATH or in lsp_paths_extra.`;
12081
12014
  }
12082
- function isRecord(value) {
12083
- return typeof value === "object" && value !== null && !Array.isArray(value);
12084
- }
12085
12015
  var PROJECT_ROOT_MARKERS;
12086
12016
  var init_lsp = __esm(async () => {
12017
+ init_dist();
12087
12018
  init_aft_bridge();
12088
12019
  init_harness_select();
12089
- init_jsonc();
12090
12020
  init_paths2();
12091
12021
  init_prompts();
12092
12022
  init_self_version();
@@ -12117,9 +12047,9 @@ __export(exports_doctor_filters, {
12117
12047
  renderFilterList: () => renderFilterList,
12118
12048
  printDoctorFiltersHelp: () => printDoctorFiltersHelp
12119
12049
  });
12120
- import { existsSync as existsSync8 } from "node:fs";
12050
+ import { existsSync as existsSync9 } from "node:fs";
12121
12051
  import { homedir as homedir7 } from "node:os";
12122
- import { relative, resolve as resolve3 } from "node:path";
12052
+ import { relative, resolve as resolve5 } from "node:path";
12123
12053
  function printDoctorFiltersHelp() {
12124
12054
  console.log("Usage: aft doctor filters [--show <name>] [trust|untrust]");
12125
12055
  console.log("");
@@ -12154,13 +12084,13 @@ async function runDoctorFilters(options) {
12154
12084
  O2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
12155
12085
  return 1;
12156
12086
  }
12157
- const projectRoot = resolve3(process.cwd());
12087
+ const projectRoot = resolve5(process.cwd());
12158
12088
  const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
12159
12089
  if (!list.success) {
12160
12090
  O2.error(list.message ?? list.code ?? "list_filters failed");
12161
12091
  return 1;
12162
12092
  }
12163
- list.project_dir_exists = list.project_dir ? existsSync8(list.project_dir) : false;
12093
+ list.project_dir_exists = list.project_dir ? existsSync9(list.project_dir) : false;
12164
12094
  if (mode.kind === "list") {
12165
12095
  console.log(renderFilterList(list, projectRoot));
12166
12096
  return 0;
@@ -12359,11 +12289,11 @@ var init_doctor_filters = __esm(async () => {
12359
12289
  });
12360
12290
 
12361
12291
  // src/lib/binary-cache.ts
12362
- import { existsSync as existsSync9, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
12292
+ import { existsSync as existsSync10, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
12363
12293
  import { join as join9 } from "node:path";
12364
12294
  function getBinaryCacheInfo(activeVersion) {
12365
12295
  const path = getAftBinaryCacheDir();
12366
- if (!existsSync9(path)) {
12296
+ if (!existsSync10(path)) {
12367
12297
  return {
12368
12298
  versions: [],
12369
12299
  activeVersion: null,
@@ -12471,7 +12401,7 @@ var init_sanitize = __esm(() => {
12471
12401
  });
12472
12402
 
12473
12403
  // src/lib/bridge-tool-failures.ts
12474
- import { closeSync as closeSync2, existsSync as existsSync10, openSync as openSync2, readSync as readSync2, statSync as statSync6 } from "node:fs";
12404
+ import { closeSync as closeSync2, existsSync as existsSync11, openSync as openSync2, readSync as readSync2, statSync as statSync6 } from "node:fs";
12475
12405
  import { tmpdir as tmpdir2 } from "node:os";
12476
12406
  import { join as join10 } from "node:path";
12477
12407
  function resolveBridgePluginLogPath() {
@@ -12479,7 +12409,7 @@ function resolveBridgePluginLogPath() {
12479
12409
  return join10(tmpdir2(), isTestEnv ? "aft-plugin-test.log" : "aft-plugin.log");
12480
12410
  }
12481
12411
  function tailLogFileBytes(path, maxBytes) {
12482
- if (!existsSync10(path) || maxBytes <= 0)
12412
+ if (!existsSync11(path) || maxBytes <= 0)
12483
12413
  return "";
12484
12414
  let fd = null;
12485
12415
  try {
@@ -12614,10 +12544,10 @@ var init_bridge_tool_failures = __esm(() => {
12614
12544
  });
12615
12545
 
12616
12546
  // src/lib/lsp-cache.ts
12617
- import { existsSync as existsSync11, readdirSync as readdirSync5, rmSync as rmSync2, statSync as statSync7 } from "node:fs";
12547
+ import { existsSync as existsSync12, readdirSync as readdirSync5, rmSync as rmSync2, statSync as statSync7 } from "node:fs";
12618
12548
  import { join as join11 } from "node:path";
12619
12549
  function inspectDir(path) {
12620
- if (!existsSync11(path)) {
12550
+ if (!existsSync12(path)) {
12621
12551
  return { entries: [], totalSize: 0 };
12622
12552
  }
12623
12553
  const entries = [];
@@ -12687,8 +12617,8 @@ var init_lsp_cache = __esm(() => {
12687
12617
  });
12688
12618
 
12689
12619
  // src/lib/onnx.ts
12690
- import { existsSync as existsSync12, readdirSync as readdirSync6, readlinkSync, realpathSync as realpathSync3, statSync as statSync8 } from "node:fs";
12691
- import { basename, isAbsolute as isAbsolute2, join as join12, resolve as resolve4, win32 } from "node:path";
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";
12692
12622
  function getOnnxLibraryName() {
12693
12623
  if (process.platform === "darwin")
12694
12624
  return "libonnxruntime.dylib";
@@ -12757,7 +12687,7 @@ function findSystemOnnxRuntime() {
12757
12687
  if (!userProfile)
12758
12688
  return nugetPaths;
12759
12689
  const nugetPackageDir = join12(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
12760
- if (!existsSync12(nugetPackageDir))
12690
+ if (!existsSync13(nugetPackageDir))
12761
12691
  return nugetPaths;
12762
12692
  try {
12763
12693
  for (const entry of readdirSync6(nugetPackageDir, { withFileTypes: true })) {
@@ -12775,7 +12705,7 @@ function findSystemOnnxRuntime() {
12775
12705
  const seen = new Set;
12776
12706
  const unknownVersionPaths = [];
12777
12707
  for (const dir of searchPaths) {
12778
- let key = resolve4(dir).replace(/[/\\]+$/, "");
12708
+ let key = resolve6(dir).replace(/[/\\]+$/, "");
12779
12709
  if (normalizeCase)
12780
12710
  key = key.toLowerCase();
12781
12711
  if (seen.has(key))
@@ -12797,10 +12727,10 @@ function findSystemOnnxRuntime() {
12797
12727
  function findCachedOnnxRuntime(storageDir) {
12798
12728
  const ortDir = join12(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
12799
12729
  const libName = getOnnxLibraryName();
12800
- if (existsSync12(join12(ortDir, libName)))
12730
+ if (existsSync13(join12(ortDir, libName)))
12801
12731
  return ortDir;
12802
12732
  const libSubdir = join12(ortDir, "lib");
12803
- if (existsSync12(join12(libSubdir, libName)))
12733
+ if (existsSync13(join12(libSubdir, libName)))
12804
12734
  return libSubdir;
12805
12735
  return null;
12806
12736
  }
@@ -12821,7 +12751,7 @@ function parseOrtVersionFromDirectoryPath(value) {
12821
12751
  return null;
12822
12752
  }
12823
12753
  function detectOrtVersion(libDir) {
12824
- if (!existsSync12(libDir))
12754
+ if (!existsSync13(libDir))
12825
12755
  return null;
12826
12756
  const libName = getOnnxLibraryName();
12827
12757
  try {
@@ -12837,7 +12767,7 @@ function detectOrtVersion(libDir) {
12837
12767
  return version;
12838
12768
  }
12839
12769
  const base = join12(libDir, libName);
12840
- if (existsSync12(base)) {
12770
+ if (existsSync13(base)) {
12841
12771
  try {
12842
12772
  const real = realpathSync3(base);
12843
12773
  const version = parseOrtVersionFromPath(real) ?? parseOrtVersionFromDirectoryPath(real);
@@ -12872,7 +12802,7 @@ import {
12872
12802
  accessSync,
12873
12803
  closeSync as closeSync3,
12874
12804
  constants,
12875
- existsSync as existsSync13,
12805
+ existsSync as existsSync14,
12876
12806
  openSync as openSync3,
12877
12807
  readSync as readSync3,
12878
12808
  statSync as statSync9
@@ -12904,7 +12834,7 @@ async function diagnoseHarness(adapter) {
12904
12834
  const logPath = adapter.getLogFile();
12905
12835
  const pluginCache = adapter.getPluginCacheInfo();
12906
12836
  const storageAccessible = (() => {
12907
- if (!existsSync13(storage))
12837
+ if (!existsSync14(storage))
12908
12838
  return false;
12909
12839
  try {
12910
12840
  accessSync(storage, constants.R_OK | constants.W_OK);
@@ -12927,14 +12857,14 @@ async function diagnoseHarness(adapter) {
12927
12857
  pluginRegistered: adapter.hasPluginEntry(),
12928
12858
  configPaths,
12929
12859
  aftConfig: {
12930
- exists: existsSync13(configPaths.aftConfig),
12860
+ exists: existsSync14(configPaths.aftConfig),
12931
12861
  ...aftConfigRead.error ? { parseError: aftConfigRead.error } : {},
12932
12862
  flags: aftFlags
12933
12863
  },
12934
12864
  pluginCache,
12935
12865
  storageDir: {
12936
12866
  path: storage,
12937
- exists: existsSync13(storage),
12867
+ exists: existsSync14(storage),
12938
12868
  accessible: storageAccessible,
12939
12869
  sizesByKey: describeStorage
12940
12870
  },
@@ -12952,8 +12882,8 @@ async function diagnoseHarness(adapter) {
12952
12882
  },
12953
12883
  logFile: {
12954
12884
  path: logPath,
12955
- exists: existsSync13(logPath),
12956
- sizeKb: existsSync13(logPath) ? Math.round(statSync9(logPath).size / 1024) : 0
12885
+ exists: existsSync14(logPath),
12886
+ sizeKb: existsSync14(logPath) ? Math.round(statSync9(logPath).size / 1024) : 0
12957
12887
  }
12958
12888
  };
12959
12889
  }
@@ -13147,7 +13077,7 @@ function formatDiagnosticIssuesSection(report) {
13147
13077
  return lines;
13148
13078
  }
13149
13079
  function tailLogFile(path, lines) {
13150
- if (!existsSync13(path))
13080
+ if (!existsSync14(path))
13151
13081
  return "";
13152
13082
  if (lines <= 0)
13153
13083
  return "";
@@ -13333,7 +13263,7 @@ var init_issue_body = __esm(() => {
13333
13263
  });
13334
13264
 
13335
13265
  // src/lib/onnx-fix.ts
13336
- import { existsSync as existsSync14, rmSync as rmSync3 } from "node:fs";
13266
+ import { existsSync as existsSync15, rmSync as rmSync3 } from "node:fs";
13337
13267
  import { join as join13 } from "node:path";
13338
13268
  function findOnnxFixCandidates(report) {
13339
13269
  const candidates = [];
@@ -13351,7 +13281,7 @@ function findOnnxFixCandidates(report) {
13351
13281
  harness,
13352
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.`,
13353
13283
  storageOnnxDir,
13354
- storageOnnxBytes: existsSync14(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
13284
+ storageOnnxBytes: existsSync15(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
13355
13285
  });
13356
13286
  continue;
13357
13287
  }
@@ -13360,7 +13290,7 @@ function findOnnxFixCandidates(report) {
13360
13290
  harness,
13361
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.`,
13362
13292
  storageOnnxDir,
13363
- storageOnnxBytes: existsSync14(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
13293
+ storageOnnxBytes: existsSync15(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
13364
13294
  });
13365
13295
  }
13366
13296
  }
@@ -13390,7 +13320,7 @@ async function runOnnxFix(adapters, report, options = {}) {
13390
13320
  const result = { cleared: 0, bytesReclaimed: 0, errors: [] };
13391
13321
  const rmFn = options.rmFn ?? rmSync3;
13392
13322
  for (const c2 of candidates) {
13393
- if (!existsSync14(c2.storageOnnxDir)) {
13323
+ if (!existsSync15(c2.storageOnnxDir)) {
13394
13324
  O2.success(`${c2.harness.displayName}: no cached state to clear; restart your harness to trigger a fresh ONNX download`);
13395
13325
  continue;
13396
13326
  }
@@ -13416,7 +13346,7 @@ var init_onnx_fix = __esm(() => {
13416
13346
  });
13417
13347
 
13418
13348
  // src/lib/sessions.ts
13419
- import { existsSync as existsSync15, readdirSync as readdirSync7, readFileSync as readFileSync4, statSync as statSync10 } from "node:fs";
13349
+ import { existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync5, statSync as statSync10 } from "node:fs";
13420
13350
  import { createRequire as createRequire3 } from "node:module";
13421
13351
  import { homedir as homedir9 } from "node:os";
13422
13352
  import { basename as basename2, join as join14 } from "node:path";
@@ -13449,7 +13379,7 @@ function mapOpenCodeSessionRows(rows) {
13449
13379
  }
13450
13380
  function listRecentOpenCodeSessions() {
13451
13381
  const dbPath = join14(getXdgDataHome(), "opencode", "opencode.db");
13452
- if (!existsSync15(dbPath))
13382
+ if (!existsSync16(dbPath))
13453
13383
  return [];
13454
13384
  let db = null;
13455
13385
  try {
@@ -13479,7 +13409,7 @@ function getHomeDir() {
13479
13409
  }
13480
13410
  function listPiSessionsFromDir(sessionsDir) {
13481
13411
  try {
13482
- if (!existsSync15(sessionsDir))
13412
+ if (!existsSync16(sessionsDir))
13483
13413
  return [];
13484
13414
  const files = collectJsonlFiles(sessionsDir).map((filePath) => {
13485
13415
  try {
@@ -13491,7 +13421,7 @@ function listPiSessionsFromDir(sessionsDir) {
13491
13421
  }).filter((entry) => entry !== null).sort((a, b) => b.mtimeMs - a.mtimeMs).slice(0, MAX_RECENT_SESSIONS * 4);
13492
13422
  const sessions = [];
13493
13423
  for (const file of files) {
13494
- const parsed = parsePiSessionJsonl(readFileSync4(file.filePath, "utf8"), basename2(file.filePath));
13424
+ const parsed = parsePiSessionJsonl(readFileSync5(file.filePath, "utf8"), basename2(file.filePath));
13495
13425
  if (!parsed)
13496
13426
  continue;
13497
13427
  sessions.push({ ...parsed, lastActivity: file.mtimeMs });
@@ -13617,10 +13547,10 @@ __export(exports_doctor, {
13617
13547
  import { execFileSync } from "node:child_process";
13618
13548
  import {
13619
13549
  chmodSync as chmodSync2,
13620
- existsSync as existsSync16,
13550
+ existsSync as existsSync17,
13621
13551
  mkdirSync as mkdirSync3,
13622
13552
  mkdtempSync,
13623
- readFileSync as readFileSync5,
13553
+ readFileSync as readFileSync6,
13624
13554
  realpathSync as realpathSync4,
13625
13555
  rmSync as rmSync4,
13626
13556
  statSync as statSync11,
@@ -13781,7 +13711,7 @@ function clearOldBinaries() {
13781
13711
  errors: [],
13782
13712
  keptVersion: keepTag
13783
13713
  };
13784
- if (!existsSync16(info.path)) {
13714
+ if (!existsSync17(info.path)) {
13785
13715
  O2.info(`Binary cache: nothing to clear at ${info.path}`);
13786
13716
  return result;
13787
13717
  }
@@ -14116,7 +14046,7 @@ function ensureStorageDirsForRegisteredPlugins(adapters) {
14116
14046
  if (!adapter.isInstalled() || !adapter.hasPluginEntry())
14117
14047
  continue;
14118
14048
  const storageDir = adapter.getStorageDir();
14119
- if (existsSync16(storageDir))
14049
+ if (existsSync17(storageDir))
14120
14050
  continue;
14121
14051
  mkdirSync3(storageDir, { recursive: true });
14122
14052
  summary.created += 1;
@@ -14244,7 +14174,7 @@ function readReviewedIssueFile(reviewFile) {
14244
14174
  O2.error(`Review file path changed before filing; refusing to read ${reviewFile.path}.`);
14245
14175
  return null;
14246
14176
  }
14247
- return readFileSync5(reviewFile.path, "utf8");
14177
+ return readFileSync6(reviewFile.path, "utf8");
14248
14178
  } catch (err) {
14249
14179
  O2.error(`Failed to read reviewed issue report: ${err instanceof Error ? err.message : String(err)}`);
14250
14180
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft",
3
- "version": "0.39.3",
3
+ "version": "0.40.0",
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.39.3",
27
+ "@cortexkit/aft-bridge": "0.40.0",
28
28
  "comment-json": "^4.6.2"
29
29
  },
30
30
  "devDependencies": {