@buildautomaton/cli 0.1.70 → 0.1.71

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/cli.js CHANGED
@@ -7720,14 +7720,14 @@ var init_access = __esm({
7720
7720
 
7721
7721
  // src/sqlite/read-migration-sql.ts
7722
7722
  import { existsSync, readFileSync } from "node:fs";
7723
- import { dirname, join as join2 } from "node:path";
7723
+ import { dirname, join as join3 } from "node:path";
7724
7724
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7725
7725
  function readMigrationSql(filename, ...searchSubdirs) {
7726
7726
  const moduleDir = dirname(fileURLToPath2(import.meta.url));
7727
7727
  const candidates = searchSubdirs.flatMap((sub) => [
7728
- join2(moduleDir, sub, filename),
7729
- join2(moduleDir, "..", sub, filename),
7730
- join2(moduleDir, "..", "..", "dist", sub, filename)
7728
+ join3(moduleDir, sub, filename),
7729
+ join3(moduleDir, "..", sub, filename),
7730
+ join3(moduleDir, "..", "..", "dist", sub, filename)
7731
7731
  ]);
7732
7732
  const resolved = candidates.find((path84) => existsSync(path84));
7733
7733
  if (!resolved) {
@@ -10608,26 +10608,26 @@ var init_member_access = __esm({
10608
10608
 
10609
10609
  // src/code-nav/tree-sitter-assets-dir.ts
10610
10610
  import { existsSync as existsSync2 } from "node:fs";
10611
- import { dirname as dirname2, join as join3 } from "node:path";
10611
+ import { dirname as dirname2, join as join4 } from "node:path";
10612
10612
  import { fileURLToPath as fileURLToPath3 } from "node:url";
10613
10613
  function repoNodeModulesDir(fromDir) {
10614
- return join3(fromDir, "..", "..", "..", "node_modules");
10614
+ return join4(fromDir, "..", "..", "..", "node_modules");
10615
10615
  }
10616
10616
  function firstDirWithWebTreeSitterWasm(candidates) {
10617
10617
  for (const dir of candidates) {
10618
- if (existsSync2(join3(dir, "web-tree-sitter.wasm"))) return dir;
10618
+ if (existsSync2(join4(dir, "web-tree-sitter.wasm"))) return dir;
10619
10619
  }
10620
10620
  return null;
10621
10621
  }
10622
10622
  function getTreeSitterAssetsDir() {
10623
10623
  const moduleDir = dirname2(fileURLToPath3(import.meta.url));
10624
10624
  const fromModule = firstDirWithWebTreeSitterWasm([
10625
- join3(moduleDir, "tree-sitter"),
10626
- join3(moduleDir, "..", "tree-sitter"),
10627
- join3(moduleDir, "..", "..", "dist", "tree-sitter")
10625
+ join4(moduleDir, "tree-sitter"),
10626
+ join4(moduleDir, "..", "tree-sitter"),
10627
+ join4(moduleDir, "..", "..", "dist", "tree-sitter")
10628
10628
  ]);
10629
10629
  if (fromModule) return fromModule;
10630
- const fromNodeModules = firstDirWithWebTreeSitterWasm([join3(repoNodeModulesDir(moduleDir), "web-tree-sitter")]);
10630
+ const fromNodeModules = firstDirWithWebTreeSitterWasm([join4(repoNodeModulesDir(moduleDir), "web-tree-sitter")]);
10631
10631
  if (fromNodeModules) return fromNodeModules;
10632
10632
  throw new Error(
10633
10633
  "Missing web-tree-sitter.wasm. Run `pnpm build` in packages/cli to copy tree-sitter assets into dist/tree-sitter."
@@ -10641,7 +10641,7 @@ var init_tree_sitter_assets_dir = __esm({
10641
10641
 
10642
10642
  // src/code-nav/parser/tree-sitter-runtime.ts
10643
10643
  import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
10644
- import { dirname as dirname3, join as join4 } from "node:path";
10644
+ import { dirname as dirname3, join as join5 } from "node:path";
10645
10645
  import { fileURLToPath as fileURLToPath4 } from "node:url";
10646
10646
  import { Parser, Language, Query, LANGUAGE_VERSION, MIN_COMPATIBLE_VERSION } from "web-tree-sitter";
10647
10647
  function withTreeSitterRuntimeLock(fn) {
@@ -10656,7 +10656,7 @@ async function ensureParserInit() {
10656
10656
  if (!initPromise2) {
10657
10657
  const assetsDir = getTreeSitterAssetsDir();
10658
10658
  initPromise2 = Parser.init({
10659
- locateFile: (scriptName) => join4(assetsDir, scriptName)
10659
+ locateFile: (scriptName) => join5(assetsDir, scriptName)
10660
10660
  }).catch((e) => {
10661
10661
  initPromise2 = null;
10662
10662
  throw e;
@@ -10666,9 +10666,9 @@ async function ensureParserInit() {
10666
10666
  }
10667
10667
  function resolveWasmPath(assetsDir, wasmFile) {
10668
10668
  const candidates = [
10669
- join4(assetsDir, wasmFile),
10670
- join4(assetsDir, "..", "..", "dist", "tree-sitter", wasmFile),
10671
- join4(assetsDir, "..", "..", "..", "node_modules", wasmFile.replace(".wasm", ""), wasmFile)
10669
+ join5(assetsDir, wasmFile),
10670
+ join5(assetsDir, "..", "..", "dist", "tree-sitter", wasmFile),
10671
+ join5(assetsDir, "..", "..", "..", "node_modules", wasmFile.replace(".wasm", ""), wasmFile)
10672
10672
  ];
10673
10673
  const hit = candidates.find((p) => existsSync3(p));
10674
10674
  if (!hit) throw new Error(`Missing tree-sitter wasm: ${wasmFile}`);
@@ -10677,10 +10677,10 @@ function resolveWasmPath(assetsDir, wasmFile) {
10677
10677
  function resolveTagsPath(assetsDir, tagsQueryFile) {
10678
10678
  const pkgName = tagsQueryFile.split("/")[0] ?? "";
10679
10679
  const candidates = [
10680
- join4(CODE_NAV_QUERIES_ROOT, tagsQueryFile),
10681
- join4(assetsDir, tagsQueryFile),
10682
- join4(assetsDir, "..", "..", "dist", "tree-sitter", tagsQueryFile),
10683
- join4(assetsDir, "..", "..", "..", "node_modules", pkgName, "queries", "tags.scm")
10680
+ join5(CODE_NAV_QUERIES_ROOT, tagsQueryFile),
10681
+ join5(assetsDir, tagsQueryFile),
10682
+ join5(assetsDir, "..", "..", "dist", "tree-sitter", tagsQueryFile),
10683
+ join5(assetsDir, "..", "..", "..", "node_modules", pkgName, "queries", "tags.scm")
10684
10684
  ];
10685
10685
  const hit = candidates.find((p) => existsSync3(p));
10686
10686
  if (!hit) throw new Error(`Missing tags query: ${tagsQueryFile}`);
@@ -10718,7 +10718,7 @@ var init_tree_sitter_runtime = __esm({
10718
10718
  loadedByKey = /* @__PURE__ */ new Map();
10719
10719
  failedLanguageKeys = /* @__PURE__ */ new Set();
10720
10720
  runtimeChain = Promise.resolve();
10721
- CODE_NAV_QUERIES_ROOT = join4(dirname3(fileURLToPath4(import.meta.url)), "..", "queries");
10721
+ CODE_NAV_QUERIES_ROOT = join5(dirname3(fileURLToPath4(import.meta.url)), "..", "queries");
10722
10722
  }
10723
10723
  });
10724
10724
 
@@ -12289,7 +12289,7 @@ var init_in_process_bridge = __esm({
12289
12289
  });
12290
12290
 
12291
12291
  // src/code-nav/symbol-index/worker/lifecycle/state.ts
12292
- import { dirname as dirname4, join as join5 } from "node:path";
12292
+ import { dirname as dirname4, join as join6 } from "node:path";
12293
12293
  import { fileURLToPath as fileURLToPath5 } from "node:url";
12294
12294
  function getWorker() {
12295
12295
  return worker;
@@ -12308,7 +12308,7 @@ function shouldUseInProcessWorker() {
12308
12308
  }
12309
12309
  function resolveWorkerScriptPath() {
12310
12310
  const moduleDir = dirname4(fileURLToPath5(import.meta.url));
12311
- return join5(moduleDir, "..", "worker.js");
12311
+ return join6(moduleDir, "..", "worker.js");
12312
12312
  }
12313
12313
  function resetLifecycleStateForTests() {
12314
12314
  terminatePromise = null;
@@ -31064,7 +31064,7 @@ var {
31064
31064
  } = import_index.default;
31065
31065
 
31066
31066
  // src/cli-version.ts
31067
- var CLI_VERSION = "0.1.70".length > 0 ? "0.1.70" : "0.0.0-dev";
31067
+ var CLI_VERSION = "0.1.71".length > 0 ? "0.1.71" : "0.0.0-dev";
31068
31068
 
31069
31069
  // src/cli/defaults.ts
31070
31070
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -32816,6 +32816,46 @@ function runPendingAuth(options) {
32816
32816
  // src/run-bridge-connected.ts
32817
32817
  init_log();
32818
32818
 
32819
+ // src/agents/acp/clients/bridge-agent-path.ts
32820
+ import { execFileSync as execFileSync2 } from "node:child_process";
32821
+ import { homedir } from "node:os";
32822
+ import { join as join2 } from "node:path";
32823
+ function getBridgeAgentPathEntries(home = process.env.HOME ?? homedir()) {
32824
+ const entries = [
32825
+ join2(home, ".local", "bin"),
32826
+ join2(home, ".npm-global", "bin"),
32827
+ "/usr/local/bin"
32828
+ ];
32829
+ const prefix = process.env.NPM_CONFIG_PREFIX;
32830
+ if (prefix) entries.push(join2(prefix, "bin"));
32831
+ try {
32832
+ const npmBin = execFileSync2("npm", ["bin", "-g"], { encoding: "utf8", timeout: 2e3 }).trim();
32833
+ if (npmBin) entries.push(npmBin);
32834
+ } catch {
32835
+ }
32836
+ return entries;
32837
+ }
32838
+ function augmentPath(pathValue, extra) {
32839
+ const current = pathValue ?? "";
32840
+ const parts = current.split(":").filter(Boolean);
32841
+ const seen = new Set(parts);
32842
+ const prefix = [];
32843
+ for (const entry of extra) {
32844
+ if (!entry || seen.has(entry)) continue;
32845
+ seen.add(entry);
32846
+ prefix.push(entry);
32847
+ }
32848
+ if (prefix.length === 0) return current;
32849
+ return current ? `${prefix.join(":")}:${current}` : prefix.join(":");
32850
+ }
32851
+ function ensureBridgeAgentPathInProcessEnv() {
32852
+ const extra = getBridgeAgentPathEntries();
32853
+ process.env.PATH = augmentPath(process.env.PATH, extra);
32854
+ }
32855
+ function bridgeAgentPathEnv(base = process.env) {
32856
+ return { ...base, PATH: augmentPath(base.PATH, getBridgeAgentPathEntries()) };
32857
+ }
32858
+
32819
32859
  // src/files/watch-file-index.ts
32820
32860
  import path25 from "node:path";
32821
32861
 
@@ -34970,7 +35010,10 @@ async function execFileShutdownAware(file2, args, timeoutMs) {
34970
35010
  async function isCommandOnPath(command, timeoutMs = COMMAND_ON_PATH_PROBE_TIMEOUT_MS) {
34971
35011
  if (isCliImmediateShutdownRequested()) return false;
34972
35012
  try {
34973
- await execFileShutdownAware("which", [command], timeoutMs);
35013
+ await execFileAsync5("which", [command], {
35014
+ timeout: timeoutMs,
35015
+ env: bridgeAgentPathEnv()
35016
+ });
34974
35017
  return true;
34975
35018
  } catch {
34976
35019
  return false;
@@ -36685,15 +36728,15 @@ function resolveAgentCommand(preferredAgentType) {
36685
36728
  }
36686
36729
 
36687
36730
  // src/agents/acp/session-file-change-path-kind.ts
36688
- import { execFileSync as execFileSync4 } from "node:child_process";
36731
+ import { execFileSync as execFileSync5 } from "node:child_process";
36689
36732
  import { existsSync as existsSync4, statSync } from "node:fs";
36690
36733
 
36691
36734
  // src/git/get-git-repo-root-sync.ts
36692
- import { execFileSync as execFileSync2 } from "node:child_process";
36735
+ import { execFileSync as execFileSync3 } from "node:child_process";
36693
36736
  import * as path28 from "node:path";
36694
36737
  function getGitRepoRootSync(startDir) {
36695
36738
  try {
36696
- const out = execFileSync2("git", ["rev-parse", "--show-toplevel"], {
36739
+ const out = execFileSync3("git", ["rev-parse", "--show-toplevel"], {
36697
36740
  cwd: path28.resolve(startDir),
36698
36741
  encoding: "utf8",
36699
36742
  stdio: ["ignore", "pipe", "ignore"],
@@ -36706,7 +36749,7 @@ function getGitRepoRootSync(startDir) {
36706
36749
  }
36707
36750
 
36708
36751
  // src/agents/acp/workspace-files.ts
36709
- import { execFileSync as execFileSync3 } from "node:child_process";
36752
+ import { execFileSync as execFileSync4 } from "node:child_process";
36710
36753
  import { readFileSync as readFileSync4 } from "node:fs";
36711
36754
  import * as path29 from "node:path";
36712
36755
  function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
@@ -36767,7 +36810,7 @@ function readGitHeadBlob(sessionParentPath, displayPath) {
36767
36810
  const gitRoot = getGitRepoRootSync(sessionParentPath);
36768
36811
  const execCwd = gitRoot ?? sessionParentPath;
36769
36812
  try {
36770
- return execFileSync3("git", ["show", `HEAD:${displayPath}`], {
36813
+ return execFileSync4("git", ["show", `HEAD:${displayPath}`], {
36771
36814
  cwd: execCwd,
36772
36815
  encoding: "utf8",
36773
36816
  maxBuffer: 50 * 1024 * 1024
@@ -36783,7 +36826,7 @@ function gitHeadPathObjectType(sessionParentPath, displayPath) {
36783
36826
  const gitRoot = getGitRepoRootSync(sessionParentPath);
36784
36827
  if (!gitRoot) return null;
36785
36828
  try {
36786
- return execFileSync4("git", ["cat-file", "-t", `HEAD:${displayPath}`], {
36829
+ return execFileSync5("git", ["cat-file", "-t", `HEAD:${displayPath}`], {
36787
36830
  cwd: gitRoot,
36788
36831
  encoding: "utf8"
36789
36832
  }).trim();
@@ -37638,11 +37681,11 @@ init_cli_process_interrupt();
37638
37681
  var BRIDGE_MCP_SERVER_NAME2 = "buildautomaton-bridge";
37639
37682
 
37640
37683
  // src/mcp/resolve-bridge-mcp-server-path.ts
37641
- import { dirname as dirname7, join as join6 } from "node:path";
37684
+ import { dirname as dirname7, join as join7 } from "node:path";
37642
37685
  import { fileURLToPath as fileURLToPath7 } from "node:url";
37643
37686
  function resolveBridgeMcpServerScriptPath() {
37644
37687
  const cliDir = dirname7(fileURLToPath7(import.meta.url));
37645
- return join6(cliDir, "bridge-mcp-server.js");
37688
+ return join7(cliDir, "bridge-mcp-server.js");
37646
37689
  }
37647
37690
 
37648
37691
  // src/mcp/build-acp-mcp-servers.ts
@@ -52903,7 +52946,7 @@ import { execFile as execFile9 } from "node:child_process";
52903
52946
  import { promisify as promisify10 } from "node:util";
52904
52947
  var execFileAsync8 = promisify10(execFile9);
52905
52948
  async function runNpmGlobalInstall(packageName, env, timeoutMs = 3e5) {
52906
- await execFileAsync8("npm", ["install", "-g", packageName], { timeout: timeoutMs, env });
52949
+ await execFileAsync8("npm", ["install", "-g", packageName], { timeout: timeoutMs, env: bridgeAgentPathEnv(env) });
52907
52950
  }
52908
52951
 
52909
52952
  // src/agents/install/commands/claude-code.ts
@@ -52943,7 +52986,7 @@ var cursorCliInstallCommand = {
52943
52986
  ctx.onProgress?.("Installing Cursor CLI");
52944
52987
  await execFileAsync9("bash", ["-lc", "curl -fsSL https://cursor.com/install | bash"], {
52945
52988
  timeout: 3e5,
52946
- env: { ...ctx.env, CURSOR_API_KEY: ctx.authToken }
52989
+ env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken }
52947
52990
  });
52948
52991
  }
52949
52992
  };
@@ -52990,6 +53033,7 @@ async function installLocalAgentOnBridge(params) {
52990
53033
  const msg = e instanceof Error ? e.message : String(e);
52991
53034
  return { success: false, error: msg };
52992
53035
  }
53036
+ ensureBridgeAgentPathInProcessEnv();
52993
53037
  const found = await isCommandOnPath(command.detectCommand);
52994
53038
  if (!found) {
52995
53039
  return { success: false, error: `${command.detectCommand} not found on PATH after install` };
@@ -53036,6 +53080,9 @@ var handleInstallAgentMessage = (msg, deps) => {
53036
53080
  error: result.error
53037
53081
  });
53038
53082
  }
53083
+ if (result.success) {
53084
+ await deps.reportAutoDetectedAgents?.();
53085
+ }
53039
53086
  if (!result.success) {
53040
53087
  deps.log(`[Bridge service] Install agent failed: ${result.error ?? "unknown"}`);
53041
53088
  }
@@ -53721,6 +53768,7 @@ init_log();
53721
53768
  async function createBridgeConnection(options) {
53722
53769
  const { apiUrl, workspaceId, justAuthenticated, onAuthInvalid, persistTokens } = options;
53723
53770
  const logFn = options.log ?? log;
53771
+ ensureBridgeAgentPathInProcessEnv();
53724
53772
  await ensureBridgeConnectionDatabases(logFn);
53725
53773
  const { state, getWs } = createMainBridgeReconnectState();
53726
53774
  const runtime = await createBridgeConnectionRuntime(options, { state, getWs, logFn });