@cortexkit/aft-pi 0.19.2 → 0.19.4

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":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAYH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAQlE,OAAO,EACL,aAAa,EAGd,MAAM,aAAa,CAAC;AAoFrB,iBAAe,iCAAiC,CAAC,OAAO,EAAE;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhB;AAQD;;;;;;;;GAQG;AACH,iBAAS,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,GAAG;IACrE,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAA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IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAiEA;AAED;;;;GAIG;AACH,yBAA+B,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA4X9D;AAED,eAAO,MAAM,QAAQ;;;CAA4D,CAAC"}
package/dist/index.js CHANGED
@@ -30475,7 +30475,7 @@ var require_src2 = __commonJS((exports, module) => {
30475
30475
 
30476
30476
  // src/index.ts
30477
30477
  import { createRequire as createRequire3 } from "node:module";
30478
- import { homedir as homedir8 } from "node:os";
30478
+ import { homedir as homedir9 } from "node:os";
30479
30479
  import { join as join12 } from "node:path";
30480
30480
 
30481
30481
  // ../aft-bridge/dist/active-logger.js
@@ -30507,9 +30507,15 @@ function error(message, meta) {
30507
30507
  console.error(`[aft-bridge] ERROR: ${message}`);
30508
30508
  }
30509
30509
  }
30510
+ function sessionLog(sessionId, message) {
30511
+ log(message, sessionId ? { sessionId } : undefined);
30512
+ }
30510
30513
  function sessionWarn(sessionId, message) {
30511
30514
  warn(message, sessionId ? { sessionId } : undefined);
30512
30515
  }
30516
+ function sessionError(sessionId, message) {
30517
+ error(message, sessionId ? { sessionId } : undefined);
30518
+ }
30513
30519
  // ../aft-bridge/dist/bridge.js
30514
30520
  import { spawn } from "node:child_process";
30515
30521
  import { homedir } from "node:os";
@@ -30637,8 +30643,8 @@ class BinaryBridge {
30637
30643
  if (Object.hasOwn(params, "id")) {
30638
30644
  throw new Error("params cannot contain reserved key 'id'");
30639
30645
  }
30640
- this.ensureSpawned();
30641
30646
  const requestSessionId = typeof params.session_id === "string" && params.session_id.length > 0 ? params.session_id : undefined;
30647
+ this.ensureSpawned(requestSessionId);
30642
30648
  if (requestSessionId && options?.configureWarningClient !== undefined) {
30643
30649
  this.configureWarningClients.set(requestSessionId, options.configureWarningClient);
30644
30650
  }
@@ -30701,7 +30707,7 @@ class BinaryBridge {
30701
30707
  }
30702
30708
  reject(new Error(`${this.errorPrefix} Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms`));
30703
30709
  if (!keepBridgeOnTimeout) {
30704
- this.handleTimeout();
30710
+ this.handleTimeout(requestSessionId);
30705
30711
  }
30706
30712
  }, effectiveTimeoutMs);
30707
30713
  this.pending.set(id, { resolve, reject, timer, onProgress: options?.onProgress });
@@ -30796,13 +30802,17 @@ class BinaryBridge {
30796
30802
  warn(`Version check failed: ${err.message}`);
30797
30803
  }
30798
30804
  }
30799
- ensureSpawned() {
30805
+ ensureSpawned(triggeringSessionId) {
30800
30806
  if (this.isAlive())
30801
30807
  return;
30802
- this.spawnProcess();
30808
+ this.spawnProcess(triggeringSessionId);
30803
30809
  }
30804
- spawnProcess() {
30805
- log(`Spawning binary: ${this.binaryPath} (cwd: ${this.cwd})`);
30810
+ spawnProcess(triggeringSessionId) {
30811
+ if (triggeringSessionId) {
30812
+ sessionLog(triggeringSessionId, `Spawning binary: ${this.binaryPath} (cwd: ${this.cwd})`);
30813
+ } else {
30814
+ log(`Spawning binary: ${this.binaryPath} (cwd: ${this.cwd})`);
30815
+ }
30806
30816
  const semantic = this.configOverrides.semantic;
30807
30817
  const semanticBackend = (() => {
30808
30818
  if (semantic && typeof semantic === "object" && !Array.isArray(semantic)) {
@@ -30950,7 +30960,7 @@ class BinaryBridge {
30950
30960
  }
30951
30961
  }
30952
30962
  }
30953
- handleTimeout() {
30963
+ handleTimeout(triggeringSessionId) {
30954
30964
  if (this.process) {
30955
30965
  this.process.kill("SIGKILL");
30956
30966
  this.process = null;
@@ -30959,10 +30969,17 @@ class BinaryBridge {
30959
30969
  this.configured = false;
30960
30970
  const tail = this.formatStderrTail();
30961
30971
  this.stderrTail = [];
30972
+ const killedMsg = tail ? `Bridge killed after timeout.${tail}` : `Bridge killed after timeout (see ${getLogFilePath()})`;
30962
30973
  if (tail) {
30963
- error(`Bridge killed after timeout.${tail}`);
30974
+ if (triggeringSessionId) {
30975
+ sessionError(triggeringSessionId, killedMsg);
30976
+ } else {
30977
+ error(killedMsg);
30978
+ }
30979
+ } else if (triggeringSessionId) {
30980
+ sessionWarn(triggeringSessionId, killedMsg);
30964
30981
  } else {
30965
- warn(`Bridge killed after timeout (see ${getLogFilePath()})`);
30982
+ warn(killedMsg);
30966
30983
  }
30967
30984
  }
30968
30985
  handleCrash(cause) {
@@ -31644,10 +31661,40 @@ function isProcessAlive(pid) {
31644
31661
  }
31645
31662
  // ../aft-bridge/dist/pool.js
31646
31663
  import { realpathSync as realpathSync2 } from "node:fs";
31664
+ import { homedir as homedir3 } from "node:os";
31647
31665
  var DEFAULT_IDLE_TIMEOUT_MS = Infinity;
31648
31666
  var DEFAULT_MAX_POOL_SIZE = 8;
31649
31667
  var CLEANUP_INTERVAL_MS = 60 * 1000;
31650
31668
 
31669
+ class HomeProjectRootError extends Error {
31670
+ projectRoot;
31671
+ constructor(projectRoot) {
31672
+ super(`aft refuses to spawn a bridge with project_root=${projectRoot} (user home directory). ` + `Open OpenCode/Pi from a project subdirectory instead, or set the session's ` + `directory to a real project root.`);
31673
+ this.projectRoot = projectRoot;
31674
+ this.name = "HomeProjectRootError";
31675
+ }
31676
+ }
31677
+ function canonicalHomeDir() {
31678
+ try {
31679
+ const home = homedir3();
31680
+ if (!home)
31681
+ return null;
31682
+ try {
31683
+ return realpathSync2(home);
31684
+ } catch {
31685
+ return home.replace(/[/\\]+$/, "");
31686
+ }
31687
+ } catch {
31688
+ return null;
31689
+ }
31690
+ }
31691
+ function isHomeDirectoryRoot(normalizedKey) {
31692
+ const home = canonicalHomeDir();
31693
+ if (!home)
31694
+ return false;
31695
+ return normalizedKey === home;
31696
+ }
31697
+
31651
31698
  class BridgePool {
31652
31699
  bridges = new Map;
31653
31700
  binaryPath;
@@ -31684,6 +31731,9 @@ class BridgePool {
31684
31731
  }
31685
31732
  getBridge(projectRoot) {
31686
31733
  const key = normalizeKey(projectRoot);
31734
+ if (isHomeDirectoryRoot(key)) {
31735
+ throw new HomeProjectRootError(key);
31736
+ }
31687
31737
  const existing = this.bridges.get(key);
31688
31738
  if (existing) {
31689
31739
  existing.lastUsed = Date.now();
@@ -31762,7 +31812,7 @@ function normalizeKey(projectRoot) {
31762
31812
  import { execSync, spawnSync } from "node:child_process";
31763
31813
  import { chmodSync as chmodSync3, copyFileSync as copyFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync3, renameSync } from "node:fs";
31764
31814
  import { createRequire as createRequire2 } from "node:module";
31765
- import { homedir as homedir3 } from "node:os";
31815
+ import { homedir as homedir4 } from "node:os";
31766
31816
  import { join as join4 } from "node:path";
31767
31817
  function copyToVersionedCache(npmBinaryPath) {
31768
31818
  try {
@@ -31842,7 +31892,7 @@ function findBinarySync(expectedVersion) {
31842
31892
  if (result)
31843
31893
  return result;
31844
31894
  } catch {}
31845
- const cargoPath = join4(homedir3(), ".cargo", "bin", `aft${ext}`);
31895
+ const cargoPath = join4(homedir4(), ".cargo", "bin", `aft${ext}`);
31846
31896
  if (existsSync3(cargoPath))
31847
31897
  return cargoPath;
31848
31898
  return null;
@@ -32419,19 +32469,19 @@ function warn2(message, data) {
32419
32469
  function error2(message, data) {
32420
32470
  write("ERROR", message, data);
32421
32471
  }
32422
- function sessionLog(sessionId, message, data) {
32472
+ function sessionLog2(sessionId, message, data) {
32423
32473
  write("INFO", message, data, sessionId);
32424
32474
  }
32425
32475
  function sessionWarn2(sessionId, message, data) {
32426
32476
  write("WARN", message, data, sessionId);
32427
32477
  }
32428
- function sessionError(sessionId, message, data) {
32478
+ function sessionError2(sessionId, message, data) {
32429
32479
  write("ERROR", message, data, sessionId);
32430
32480
  }
32431
32481
  var bridgeLogger = {
32432
32482
  log(message, meta) {
32433
32483
  if (meta?.sessionId)
32434
- sessionLog(meta.sessionId, message);
32484
+ sessionLog2(meta.sessionId, message);
32435
32485
  else
32436
32486
  write("INFO", message);
32437
32487
  },
@@ -32443,7 +32493,7 @@ var bridgeLogger = {
32443
32493
  },
32444
32494
  error(message, meta) {
32445
32495
  if (meta?.sessionId)
32446
- sessionError(meta.sessionId, message);
32496
+ sessionError2(meta.sessionId, message);
32447
32497
  else
32448
32498
  write("ERROR", message);
32449
32499
  },
@@ -32907,7 +32957,7 @@ function registerStatusCommand(pi, ctx) {
32907
32957
  // src/config.ts
32908
32958
  var import_comment_json = __toESM(require_src2(), 1);
32909
32959
  import { existsSync as existsSync5, readFileSync as readFileSync3, renameSync as renameSync2, unlinkSync as unlinkSync4, writeFileSync as writeFileSync3 } from "node:fs";
32910
- import { homedir as homedir4 } from "node:os";
32960
+ import { homedir as homedir5 } from "node:os";
32911
32961
  import { join as join7 } from "node:path";
32912
32962
 
32913
32963
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
@@ -46854,7 +46904,7 @@ function mergeConfigs(base, override) {
46854
46904
  };
46855
46905
  }
46856
46906
  function getGlobalPiDir() {
46857
- return join7(homedir4(), ".pi", "agent");
46907
+ return join7(homedir5(), ".pi", "agent");
46858
46908
  }
46859
46909
  function loadAftConfig(projectDirectory) {
46860
46910
  const userBasePath = join7(getGlobalPiDir(), "aft");
@@ -46901,7 +46951,7 @@ import {
46901
46951
  unlinkSync as unlinkSync5,
46902
46952
  writeFileSync as writeFileSync4
46903
46953
  } from "node:fs";
46904
- import { homedir as homedir5 } from "node:os";
46954
+ import { homedir as homedir6 } from "node:os";
46905
46955
  import { join as join8 } from "node:path";
46906
46956
  function aftCacheBase() {
46907
46957
  const override = process.env.AFT_CACHE_DIR;
@@ -46909,10 +46959,10 @@ function aftCacheBase() {
46909
46959
  return override;
46910
46960
  if (process.platform === "win32") {
46911
46961
  const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
46912
- const base2 = localAppData || join8(homedir5(), "AppData", "Local");
46962
+ const base2 = localAppData || join8(homedir6(), "AppData", "Local");
46913
46963
  return join8(base2, "aft");
46914
46964
  }
46915
- const base = process.env.XDG_CACHE_HOME || join8(homedir5(), ".cache");
46965
+ const base = process.env.XDG_CACHE_HOME || join8(homedir6(), ".cache");
46916
46966
  return join8(base, "aft");
46917
46967
  }
46918
46968
  function lspCacheRoot() {
@@ -48314,7 +48364,7 @@ function sendIgnoredMessage(client, sessionId, text) {
48314
48364
  typedClient.ui.notify(text, "warning");
48315
48365
  return true;
48316
48366
  } catch (err) {
48317
- sessionLog(sessionId, `[aft-pi] notification send failed: ${err instanceof Error ? err.message : String(err)}`);
48367
+ sessionLog2(sessionId, `[aft-pi] notification send failed: ${err instanceof Error ? err.message : String(err)}`);
48318
48368
  return false;
48319
48369
  }
48320
48370
  }
@@ -48473,7 +48523,7 @@ import { StringEnum } from "@mariozechner/pi-ai";
48473
48523
  import { Type } from "@sinclair/typebox";
48474
48524
 
48475
48525
  // src/tools/render-helpers.ts
48476
- import { homedir as homedir6 } from "node:os";
48526
+ import { homedir as homedir7 } from "node:os";
48477
48527
  import { renderDiff } from "@mariozechner/pi-coding-agent";
48478
48528
  import { Container, Spacer, Text } from "@mariozechner/pi-tui";
48479
48529
  function reuseText(last) {
@@ -48483,7 +48533,7 @@ function reuseContainer(last) {
48483
48533
  return last instanceof Container ? last : new Container;
48484
48534
  }
48485
48535
  function shortenPath(path2) {
48486
- const home = homedir6();
48536
+ const home = homedir7();
48487
48537
  if (path2.startsWith(home))
48488
48538
  return `~${path2.slice(home.length)}`;
48489
48539
  return path2;
@@ -49312,7 +49362,7 @@ function registerFsTools(pi, ctx, surface) {
49312
49362
 
49313
49363
  // src/tools/hoisted.ts
49314
49364
  import { stat } from "node:fs/promises";
49315
- import { homedir as homedir7 } from "node:os";
49365
+ import { homedir as homedir8 } from "node:os";
49316
49366
  import { resolve as resolve3 } from "node:path";
49317
49367
  import {
49318
49368
  renderDiff as renderDiff2
@@ -49722,7 +49772,7 @@ ${summary}${suffix}`);
49722
49772
  return container;
49723
49773
  }
49724
49774
  function shortenPath2(path2) {
49725
- const home = homedir7();
49775
+ const home = homedir8();
49726
49776
  if (path2.startsWith(home))
49727
49777
  return `~${path2.slice(home.length)}`;
49728
49778
  return path2;
@@ -50988,7 +51038,7 @@ async function handleConfigureWarningsForSession(context) {
50988
51038
  }, validWarnings);
50989
51039
  }
50990
51040
  function resolveStorageDir() {
50991
- return join12(homedir8(), ".pi", "agent", "aft");
51041
+ return join12(homedir9(), ".pi", "agent", "aft");
50992
51042
  }
50993
51043
  function resolveToolSurface(config2) {
50994
51044
  const surface = config2.tool_surface ?? "recommended";
@@ -51195,7 +51245,12 @@ ${lines}
51195
51245
  }
51196
51246
  (async () => {
51197
51247
  try {
51198
- const bridge = pool.getBridge(process.cwd());
51248
+ const cwd = process.cwd();
51249
+ if (isHomeDirectoryRoot(cwd)) {
51250
+ log2(`Eager configure skipped: cwd=${cwd} is the user home directory. ` + `The first real tool call will warm the correct project bridge.`);
51251
+ return;
51252
+ }
51253
+ const bridge = pool.getBridge(cwd);
51199
51254
  await bridge.send("status", {});
51200
51255
  } catch (err) {
51201
51256
  log2(`eager configure failed: ${err instanceof Error ? err.message : String(err)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft-pi",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "type": "module",
5
5
  "description": "Pi coding agent extension for Agent File Tools (AFT) — tree-sitter and LSP-powered code analysis",
6
6
  "main": "dist/index.js",
@@ -22,18 +22,18 @@
22
22
  "prepublishOnly": "bun run build"
23
23
  },
24
24
  "dependencies": {
25
- "@cortexkit/aft-bridge": "0.19.2",
25
+ "@cortexkit/aft-bridge": "0.19.4",
26
26
  "@sinclair/typebox": "^0.34.33",
27
27
  "comment-json": "^5.0.0",
28
28
  "diff": "^8.0.4",
29
29
  "zod": "^4.1.8"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@cortexkit/aft-darwin-arm64": "0.19.2",
33
- "@cortexkit/aft-darwin-x64": "0.19.2",
34
- "@cortexkit/aft-linux-arm64": "0.19.2",
35
- "@cortexkit/aft-linux-x64": "0.19.2",
36
- "@cortexkit/aft-win32-x64": "0.19.2"
32
+ "@cortexkit/aft-darwin-arm64": "0.19.4",
33
+ "@cortexkit/aft-darwin-x64": "0.19.4",
34
+ "@cortexkit/aft-linux-arm64": "0.19.4",
35
+ "@cortexkit/aft-linux-x64": "0.19.4",
36
+ "@cortexkit/aft-win32-x64": "0.19.4"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@mariozechner/pi-coding-agent": "*",