chat-recall 0.5.28 → 0.5.29

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
@@ -13266,9 +13266,9 @@ function doResolve(realPath) {
13266
13266
  const bot = resolveBotWorktree(realPath);
13267
13267
  if (bot)
13268
13268
  return bot;
13269
- const git = resolveGit(realPath);
13270
- if (git)
13271
- return git;
13269
+ const git2 = resolveGit(realPath);
13270
+ if (git2)
13271
+ return git2;
13272
13272
  const ws = resolveAutoWorkspace(realPath, cfg.autoWorkspaceMinRepos ?? DEFAULT_AUTO_WORKSPACE_MIN_REPOS);
13273
13273
  if (ws)
13274
13274
  return ws;
@@ -13337,9 +13337,9 @@ function resolveGit(realPath) {
13337
13337
  const toplevel = findGitToplevel(realPath);
13338
13338
  if (!toplevel)
13339
13339
  return null;
13340
- const remote = getGitRemote(toplevel);
13341
- if (remote) {
13342
- const parsed = parseGitRemote(remote);
13340
+ const probe = getGitRemote(toplevel);
13341
+ if (probe.kind === "remote") {
13342
+ const parsed = parseGitRemote(probe.url);
13343
13343
  if (parsed) {
13344
13344
  return {
13345
13345
  id: `git:${parsed.host}/${parsed.owner}/${parsed.repo}`,
@@ -13348,6 +13348,9 @@ function resolveGit(realPath) {
13348
13348
  };
13349
13349
  }
13350
13350
  }
13351
+ if (probe.kind === "failed") {
13352
+ console.error(`[project] could not read git remotes in ${toplevel} \u2014 filing it as a local-only repo for now, which is probably wrong: ${probe.reason}`);
13353
+ }
13351
13354
  const hash = createHash6("sha1").update(toplevel).digest("hex").slice(0, 12);
13352
13355
  return {
13353
13356
  id: `git-local:${hash}`,
@@ -13366,23 +13369,39 @@ function findGitToplevel(realPath) {
13366
13369
  }
13367
13370
  return null;
13368
13371
  }
13372
+ function git(toplevel, args) {
13373
+ return execSync(`git ${args}`, {
13374
+ cwd: toplevel,
13375
+ stdio: ["ignore", "pipe", "ignore"],
13376
+ encoding: "utf-8",
13377
+ timeout: GIT_TIMEOUT_MS
13378
+ });
13379
+ }
13380
+ function probeGitRemote(toplevel) {
13381
+ let names;
13382
+ try {
13383
+ names = git(toplevel, "remote").split("\n").map((n) => n.trim()).filter(Boolean);
13384
+ } catch (err) {
13385
+ return { kind: "failed", reason: err instanceof Error ? err.message : String(err) };
13386
+ }
13387
+ if (names.length === 0)
13388
+ return { kind: "none" };
13389
+ const pick = names.includes("origin") ? "origin" : names[0];
13390
+ try {
13391
+ const url = git(toplevel, `remote get-url ${pick}`).trim();
13392
+ return url ? { kind: "remote", url } : { kind: "none" };
13393
+ } catch (err) {
13394
+ return { kind: "failed", reason: err instanceof Error ? err.message : String(err) };
13395
+ }
13396
+ }
13369
13397
  function getGitRemote(toplevel) {
13370
13398
  const cached = gitCache.get(toplevel);
13371
13399
  if (cached)
13372
- return cached.remote;
13373
- let remote = null;
13374
- try {
13375
- remote = execSync("git remote get-url origin", {
13376
- cwd: toplevel,
13377
- stdio: ["ignore", "pipe", "ignore"],
13378
- encoding: "utf-8",
13379
- timeout: 2e3
13380
- }).trim() || null;
13381
- } catch {
13382
- remote = null;
13383
- }
13384
- gitCache.set(toplevel, { remote });
13385
- return remote;
13400
+ return cached;
13401
+ const probe = probeGitRemote(toplevel);
13402
+ if (probe.kind !== "failed")
13403
+ gitCache.set(toplevel, probe);
13404
+ return probe;
13386
13405
  }
13387
13406
  function parseGitRemote(url) {
13388
13407
  const trimmed = url.trim().replace(/\.git$/, "");
@@ -13512,7 +13531,7 @@ function globToRegex(glob) {
13512
13531
  function escapeRe(s) {
13513
13532
  return s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
13514
13533
  }
13515
- var DEFAULT_AUTO_WORKSPACE_MIN_REPOS, BOT_WORKTREE_MARKERS, resolveCache, gitCache, workspaceCache, wsIdCache, cachedConfig, AUTO_WORKSPACE_MAX_DEPTH;
13534
+ var DEFAULT_AUTO_WORKSPACE_MIN_REPOS, BOT_WORKTREE_MARKERS, resolveCache, gitCache, workspaceCache, wsIdCache, cachedConfig, GIT_TIMEOUT_MS, AUTO_WORKSPACE_MAX_DEPTH;
13516
13535
  var init_project_resolver = __esm({
13517
13536
  "../engine/dist/core/project-resolver.js"() {
13518
13537
  "use strict";
@@ -13524,6 +13543,7 @@ var init_project_resolver = __esm({
13524
13543
  workspaceCache = /* @__PURE__ */ new Map();
13525
13544
  wsIdCache = /* @__PURE__ */ new Map();
13526
13545
  cachedConfig = null;
13546
+ GIT_TIMEOUT_MS = 1e4;
13527
13547
  AUTO_WORKSPACE_MAX_DEPTH = 2;
13528
13548
  }
13529
13549
  });
@@ -19730,7 +19750,7 @@ var init_http = __esm({
19730
19750
  CLI_VERSION = JSON.parse(readFileSync33(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
19731
19751
  } catch {
19732
19752
  try {
19733
- if (true) CLI_VERSION = "0.5.28";
19753
+ if (true) CLI_VERSION = "0.5.29";
19734
19754
  } catch {
19735
19755
  }
19736
19756
  }
@@ -20242,7 +20262,7 @@ var init_telemetry = __esm({
20242
20262
  init_sync_client();
20243
20263
  cliVersion2 = () => {
20244
20264
  try {
20245
- return true ? "0.5.28" : "dev";
20265
+ return true ? "0.5.29" : "dev";
20246
20266
  } catch {
20247
20267
  return "dev";
20248
20268
  }
@@ -22250,7 +22270,7 @@ var init_sync_client = __esm({
22250
22270
  ownVersion = JSON.parse(readFileSync37(join44(dir, "../package.json"), "utf-8")).version || ownVersion;
22251
22271
  } catch {
22252
22272
  try {
22253
- if (true) ownVersion = "0.5.28";
22273
+ if (true) ownVersion = "0.5.29";
22254
22274
  } catch {
22255
22275
  }
22256
22276
  }
@@ -22479,11 +22499,17 @@ function writeFileMkdir(path, body) {
22479
22499
  mkdirSync10(dirname20(path), { recursive: true });
22480
22500
  writeFileSync11(path, body);
22481
22501
  }
22502
+ function readJsonObject(path) {
22503
+ const raw = readFileSync39(path, "utf-8");
22504
+ if (raw.trim() === "")
22505
+ return {};
22506
+ return JSON.parse(raw);
22507
+ }
22482
22508
  function registerMcpServersJson(target, path, spec) {
22483
22509
  let cfg = {};
22484
22510
  if (existsSync44(path)) {
22485
22511
  try {
22486
- cfg = JSON.parse(readFileSync39(path, "utf-8"));
22512
+ cfg = readJsonObject(path);
22487
22513
  } catch (err) {
22488
22514
  return { id: target.id, label: target.label, path, state: "unparseable", error: String(err) };
22489
22515
  }
@@ -22512,7 +22538,7 @@ function registerOpencodeJson(path, spec) {
22512
22538
  let cfg = {};
22513
22539
  if (existsSync44(path)) {
22514
22540
  try {
22515
- cfg = JSON.parse(readFileSync39(path, "utf-8"));
22541
+ cfg = readJsonObject(path);
22516
22542
  } catch (err) {
22517
22543
  return { id, label, path, state: "unparseable", error: String(err) };
22518
22544
  }
@@ -26001,7 +26027,7 @@ var init_intent_drain = __esm({
26001
26027
  ownVersion2 = JSON.parse(readFileSync46(join55(dir, "../package.json"), "utf-8")).version || ownVersion2;
26002
26028
  } catch {
26003
26029
  try {
26004
- if (true) ownVersion2 = "0.5.28";
26030
+ if (true) ownVersion2 = "0.5.29";
26005
26031
  } catch {
26006
26032
  }
26007
26033
  }
@@ -27872,7 +27898,9 @@ program.command("init").description("Set up chat-recall: connect to your server,
27872
27898
  if (ok.length) {
27873
27899
  }
27874
27900
  for (const r of bad) {
27875
- rep.warn(`${chalk.yellow(`${r.label} config left alone \u2014 the file does not parse`)} ${chalk.dim(r.path)}`);
27901
+ const why = (r.error ?? "").replace(/^SyntaxError:\s*/, "").split("\n")[0];
27902
+ rep.warn(`${chalk.yellow(`${r.label} config left alone \u2014 ${why || "the file does not parse"}`)} ${chalk.dim(r.path)}`);
27903
+ rep.warn(`${chalk.dim(` fix that file, then: chat-recall init (nothing else needs redoing)`)}`);
27876
27904
  }
27877
27905
  if (process.env.CHAT_RECALL_VERBOSE) {
27878
27906
  }
@@ -27981,12 +28009,12 @@ program.command("init").description("Set up chat-recall: connect to your server,
27981
28009
  }
27982
28010
  }
27983
28011
  if (deadTarget) {
27984
- console.log(chalk.bold("6. Skipping first sync \u2014 the saved server is not serving chat-recall"));
28012
+ console.log(chalk.bold("Skipping first sync \u2014 the saved server is not serving chat-recall"));
27985
28013
  console.log(` ${chalk.dim(`Re-point with the two commands above, then run ${chalk.bold("chat-recall sync")}.`)}`);
27986
28014
  } else if (!options.skipSync && firstTarget()) {
27987
28015
  const { watchFirstSync: watchFirstSync2, spawnDetachedSync: spawnDetachedSync2, handOffLine: handOffLine2, progressLine: renderProgress } = await Promise.resolve().then(() => (init_init_progress(), init_progress_exports));
27988
28016
  const { readCollectorHealth: readCollectorHealth2 } = await Promise.resolve().then(() => (init_collector_health(), collector_health_exports));
27989
- const label = (text) => `${chalk.bold("6. Indexing")} ${text}`;
28017
+ const label = (text) => `${chalk.bold("Indexing")} ${text}`;
27990
28018
  const tty = process.stdout.isTTY === true;
27991
28019
  const outcome = await watchFirstSync2({
27992
28020
  startWorker: () => spawnDetachedSync2(),
@@ -28007,11 +28035,11 @@ program.command("init").description("Set up chat-recall: connect to your server,
28007
28035
  console.log(label(chalk.green(renderProgress(outcome.snapshot))));
28008
28036
  } else {
28009
28037
  console.log(label(chalk.dim(handOffLine2(outcome.snapshot))));
28010
- console.log(` ${chalk.dim("watch it with: " + chalk.bold("chat-recall status"))}`);
28038
+ console.log(` ${chalk.dim("watch it with: " + chalk.bold("chat-recall status"))}`);
28011
28039
  }
28012
28040
  const failed = Object.entries(readCollectorHealth2()?.targets ?? {}).filter(([, t]) => (t.failures ?? 0) > 0 && t.lastError);
28013
28041
  for (const [server, t] of failed) {
28014
- console.log(` ${chalk.yellow("sync error")} ${chalk.dim(server)}: ${t.lastError}`);
28042
+ console.log(` ${chalk.yellow("sync error")} ${chalk.dim(server)}: ${t.lastError}`);
28015
28043
  }
28016
28044
  } else if (!options.skipSync) {
28017
28045
  } else {