@buildautomaton/cli 0.1.30 → 0.1.31

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/index.js CHANGED
@@ -23962,7 +23962,7 @@ function installBridgeProcessResilience() {
23962
23962
  }
23963
23963
 
23964
23964
  // src/cli-version.ts
23965
- var CLI_VERSION = "0.1.30".length > 0 ? "0.1.30" : "0.0.0-dev";
23965
+ var CLI_VERSION = "0.1.31".length > 0 ? "0.1.31" : "0.0.0-dev";
23966
23966
 
23967
23967
  // src/connection/heartbeat/constants.ts
23968
23968
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -25317,6 +25317,13 @@ function migrateCliSqlite(db) {
25317
25317
 
25318
25318
  // src/sqlite/cli-database.ts
25319
25319
  var { Database: SqliteDatabase } = sqliteWasm;
25320
+ function applyCliSqliteMemoryPragmas(db) {
25321
+ try {
25322
+ db.run("PRAGMA cache_size = -8192");
25323
+ db.run("PRAGMA temp_store = FILE");
25324
+ } catch {
25325
+ }
25326
+ }
25320
25327
  var openDatabases = /* @__PURE__ */ new Map();
25321
25328
  var processExitCloseRegistered = false;
25322
25329
  function registerProcessExitSqliteClose() {
@@ -25353,6 +25360,7 @@ function getCliDatabase(options) {
25353
25360
  ensureCliSqliteParentDir(sqlitePath);
25354
25361
  const db = new SqliteDatabase(sqlitePath);
25355
25362
  try {
25363
+ applyCliSqliteMemoryPragmas(db);
25356
25364
  migrateCliSqlite(db);
25357
25365
  importCliSqliteLegacyDiskData(db, options?.logLegacyMigration);
25358
25366
  } catch (e) {
@@ -31710,6 +31718,28 @@ function sendGitHeadVsWorkspaceForToolPaths(mergedPaths, sentPaths, send, sessio
31710
31718
  }
31711
31719
  }
31712
31720
 
31721
+ // src/agents/acp/hooks/bridge-on-session-update/send-session-info-title-update.ts
31722
+ function extractSessionInfoTitle(params) {
31723
+ if (!params || typeof params !== "object") return null;
31724
+ const p = params;
31725
+ const title = typeof p.title === "string" ? p.title.trim() : "";
31726
+ return title ? title : null;
31727
+ }
31728
+ function sendSessionInfoTitleUpdate(params) {
31729
+ const title = extractSessionInfoTitle(params.payload);
31730
+ if (!title || !params.runId || !params.send) return;
31731
+ try {
31732
+ params.send({
31733
+ type: "session_title_update",
31734
+ ...params.sessionId ? { sessionId: params.sessionId } : {},
31735
+ runId: params.runId,
31736
+ title
31737
+ });
31738
+ } catch (err) {
31739
+ params.log(`[Bridge service] Session title update send failed: ${errorMessage(err)}`);
31740
+ }
31741
+ }
31742
+
31713
31743
  // src/agents/acp/hooks/bridge-on-session-update/create-bridge-on-session-update.ts
31714
31744
  function createBridgeOnSessionUpdate(opts) {
31715
31745
  const { routing, getSendSessionUpdate, log: log2, sessionParentPath } = opts;
@@ -31725,6 +31755,10 @@ function createBridgeOnSessionUpdate(opts) {
31725
31755
  if (updateKind === "config_option_update") {
31726
31756
  return;
31727
31757
  }
31758
+ if (updateKind === "session_info_update") {
31759
+ sendSessionInfoTitleUpdate({ payload: params, runId, sessionId, send, log: log2 });
31760
+ return;
31761
+ }
31728
31762
  const isCompletedToolCallUpdate = updateKind === "tool_call_update" && isCompletedToolStatus(p.status);
31729
31763
  const toolName = p.toolCall?.name ?? p.tool_call?.name ?? "";
31730
31764
  const isToolUpdate = updateKind === "tool_call" || updateKind === "tool_call_update" || typeof toolName === "string" && toolName.length > 0;
@@ -33458,37 +33492,33 @@ function yieldToEventLoop() {
33458
33492
  // src/files/index/walk-workspace-tree.ts
33459
33493
  import fs24 from "node:fs";
33460
33494
  import path27 from "node:path";
33461
- async function walkWorkspaceTreeAsync(dir, baseDir, out, state) {
33495
+ function shouldSkipWorkspaceWalkEntry(name) {
33496
+ return name.startsWith(".");
33497
+ }
33498
+ function walkWorkspaceTreeSync(dir, baseDir, onFile) {
33462
33499
  let names;
33463
33500
  try {
33464
- names = await fs24.promises.readdir(dir);
33501
+ names = fs24.readdirSync(dir);
33465
33502
  } catch {
33466
33503
  return;
33467
33504
  }
33468
33505
  for (const name of names) {
33469
- if (name.startsWith(".")) continue;
33470
- if (state.n > 0 && state.n % INDEX_WORK_YIELD_EVERY === 0) {
33471
- await yieldToEventLoop();
33472
- }
33473
- state.n++;
33506
+ if (shouldSkipWorkspaceWalkEntry(name)) continue;
33474
33507
  const full = path27.join(dir, name);
33475
33508
  let stat2;
33476
33509
  try {
33477
- stat2 = await fs24.promises.stat(full);
33510
+ stat2 = fs24.statSync(full);
33478
33511
  } catch {
33479
33512
  continue;
33480
33513
  }
33481
33514
  const relative5 = path27.relative(baseDir, full).replace(/\\/g, "/");
33482
33515
  if (stat2.isDirectory()) {
33483
- await walkWorkspaceTreeAsync(full, baseDir, out, state);
33516
+ walkWorkspaceTreeSync(full, baseDir, onFile);
33484
33517
  } else if (stat2.isFile()) {
33485
- out.push(relative5);
33518
+ onFile(relative5);
33486
33519
  }
33487
33520
  }
33488
33521
  }
33489
- function createWalkYieldState() {
33490
- return { n: 0 };
33491
- }
33492
33522
 
33493
33523
  // src/files/index/file-index-sqlite-lock.ts
33494
33524
  import fs25 from "node:fs";
@@ -33521,20 +33551,29 @@ function withFileIndexSqliteLock(fn) {
33521
33551
  }
33522
33552
 
33523
33553
  // src/files/index/build-file-index.ts
33524
- function sortPaths(paths) {
33525
- paths.sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" }));
33526
- }
33527
- function persistPathsToSqlite(resolved, paths) {
33554
+ var FILE_INDEX_INSERT_BUFFER = 2048;
33555
+ function persistFileIndexForResolvedCwd(resolved) {
33528
33556
  const db = getCliDatabase();
33529
33557
  const h = getCwdHashForFileIndex(resolved);
33558
+ const buf = [];
33559
+ let pathCount = 0;
33530
33560
  db.run("BEGIN IMMEDIATE");
33531
33561
  try {
33532
33562
  db.run("DELETE FROM file_index_path WHERE cwd_hash = ?", [h]);
33533
33563
  const ins = db.prepare("INSERT INTO file_index_path (cwd_hash, path) VALUES (?, ?)");
33534
33564
  try {
33535
- for (const rel of paths) {
33536
- ins.run([h, rel]);
33537
- }
33565
+ const flushBuf = () => {
33566
+ for (const rel of buf) {
33567
+ ins.run([h, rel]);
33568
+ }
33569
+ pathCount += buf.length;
33570
+ buf.length = 0;
33571
+ };
33572
+ walkWorkspaceTreeSync(resolved, resolved, (rel) => {
33573
+ buf.push(rel);
33574
+ if (buf.length >= FILE_INDEX_INSERT_BUFFER) flushBuf();
33575
+ });
33576
+ flushBuf();
33538
33577
  } finally {
33539
33578
  ins.finalize();
33540
33579
  }
@@ -33546,22 +33585,26 @@ function persistPathsToSqlite(resolved, paths) {
33546
33585
  }
33547
33586
  throw e;
33548
33587
  }
33588
+ return pathCount;
33549
33589
  }
33550
33590
  async function buildFileIndexAsync(cwd) {
33551
33591
  return withFileIndexSqliteLock(async () => {
33552
33592
  const resolved = path28.resolve(cwd);
33553
- const paths = [];
33554
- await walkWorkspaceTreeAsync(resolved, resolved, paths, createWalkYieldState());
33555
33593
  await yieldToEventLoop();
33556
- sortPaths(paths);
33557
- persistPathsToSqlite(resolved, paths);
33558
- return { pathCount: paths.length };
33594
+ const pathCount = persistFileIndexForResolvedCwd(resolved);
33595
+ await yieldToEventLoop();
33596
+ return { pathCount };
33559
33597
  });
33560
33598
  }
33561
33599
 
33562
33600
  // src/files/index/ensure-file-index.ts
33563
33601
  import path29 from "node:path";
33564
33602
 
33603
+ // src/files/index/file-index-dependency-path.ts
33604
+ function sqliteExprBridgeFileIndexDependencyRank() {
33605
+ return `CASE WHEN lower(path) = 'node_modules' OR lower(path) LIKE 'node_modules/%' OR lower(path) LIKE '%/node_modules/%' OR lower(path) = 'bower_components' OR lower(path) LIKE 'bower_components/%' OR lower(path) LIKE '%/bower_components/%' THEN 1 ELSE 0 END`;
33606
+ }
33607
+
33565
33608
  // src/files/index/search-file-index.ts
33566
33609
  function escapeLikePattern(fragment) {
33567
33610
  return fragment.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
@@ -33586,8 +33629,9 @@ function searchBridgeFilePaths(resolvedCwd, query, limit = 100) {
33586
33629
  const h = getCwdHashForFileIndex(resolvedCwd);
33587
33630
  const pattern = `%${escapeLikePattern(q)}%`;
33588
33631
  const lim = Math.max(0, Math.min(1e4, Math.floor(limit)));
33632
+ const depRank = sqliteExprBridgeFileIndexDependencyRank();
33589
33633
  const rows = db.all(
33590
- `SELECT path FROM file_index_path WHERE cwd_hash = ? AND lower(path) LIKE ? ESCAPE '\\' LIMIT ?`,
33634
+ `SELECT path FROM file_index_path WHERE cwd_hash = ? AND lower(path) LIKE ? ESCAPE '\\' ORDER BY ${depRank}, path LIMIT ?`,
33591
33635
  [h, pattern, lim]
33592
33636
  );
33593
33637
  return rows.map((r) => String(r.path));
@@ -33612,7 +33656,6 @@ async function ensureFileIndexAsync(cwd) {
33612
33656
  var DEBOUNCE_MS = 900;
33613
33657
  function shouldIgnoreRelative(rel) {
33614
33658
  const n = rel.replace(/\\/g, "/");
33615
- if (n.includes("/node_modules/") || n.startsWith("node_modules/")) return true;
33616
33659
  if (n.includes("/.git/") || n === ".git" || n.startsWith(".git/")) return true;
33617
33660
  if (n.includes("/.buildautomaton/") || n.startsWith(".buildautomaton/")) return true;
33618
33661
  return false;