@todoforai/cli 0.1.18 → 0.1.19

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.
Files changed (2) hide show
  1. package/dist/todoai.js +10 -19
  2. package/package.json +1 -1
package/dist/todoai.js CHANGED
@@ -44548,20 +44548,19 @@ function ensureBridgeCredentials(apiUrl) {
44548
44548
  const login = spawnSync("todoforai-bridge", bridgeLoginArgs(apiUrl), { stdio: "inherit" });
44549
44549
  return login.status === 0;
44550
44550
  }
44551
- function lastLogLine(logFile) {
44552
- try {
44553
- const lines = fs2.readFileSync(logFile, "utf-8").split(`
44554
- `).filter(Boolean);
44555
- return lines.length ? lines[lines.length - 1] : null;
44556
- } catch {
44557
- return null;
44558
- }
44551
+ function bridgeAlreadyRunning() {
44552
+ if (process.platform === "win32")
44553
+ return false;
44554
+ const r = spawnSync("pgrep", ["-f", "todoforai-bridge"], { encoding: "utf-8" });
44555
+ return r.status === 0 && (r.stdout || "").trim().length > 0;
44559
44556
  }
44560
44557
  function ensureBridgeRunning(apiUrl, _apiKey) {
44561
44558
  if (!hasBridge()) {
44562
44559
  console.error("\x1B[2mBridge not started: `todoforai-bridge` was not found on PATH. Install TODOforAI Bridge, or pass --no-bridge (or deprecated --no-edge) to silence this.\x1B[0m");
44563
44560
  return;
44564
44561
  }
44562
+ if (bridgeAlreadyRunning())
44563
+ return;
44565
44564
  if (!ensureBridgeCredentials(apiUrl)) {
44566
44565
  console.error("\x1B[33mBridge not started: `todoforai-bridge login` did not complete successfully.\x1B[0m");
44567
44566
  return;
@@ -44584,20 +44583,12 @@ function ensureBridgeRunning(apiUrl, _apiKey) {
44584
44583
  exitCode = code;
44585
44584
  });
44586
44585
  child.unref();
44587
- const pid = child.pid;
44588
- if (!pid)
44586
+ if (!child.pid)
44589
44587
  return;
44590
44588
  const shortLog = logFile.replace(os3.homedir(), "~");
44591
44589
  setTimeout(() => {
44592
- if (!exited) {
44593
- console.error(`\x1B[2mStarted bridge (pid ${pid}), logs: ${shortLog}\x1B[0m`);
44594
- return;
44595
- }
44596
- if (exitCode === 0) {
44597
- console.error(`\x1B[2mBridge exited cleanly. Logs: ${shortLog}\x1B[0m`);
44598
- } else {
44599
- const reason = lastLogLine(logFile);
44600
- console.error(`\x1B[33mBridge exited early (exit ${exitCode}): ${reason ?? `check logs: ${shortLog}`}\x1B[0m`);
44590
+ if (exited && exitCode !== 0) {
44591
+ console.error(`\x1B[2mBridge not running (exit ${exitCode}), see ${shortLog}\x1B[0m`);
44601
44592
  }
44602
44593
  }, 500);
44603
44594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/cli",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "todoforai-cli": "dist/todoai.js",