adhdev 0.9.13 → 0.9.15

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/index.js CHANGED
@@ -12541,6 +12541,11 @@ __export(provider_cli_adapter_exports, {
12541
12541
  function normalizeComparableTranscriptText(value) {
12542
12542
  return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
12543
12543
  }
12544
+ function hasVisibleInterruptPrompt(text) {
12545
+ return /\bEnter\s+to\s+interrupt\b(?:\s*,?\s*Ctrl\s*(?:\+|-)?\s*C\s+to\s+cancel)?/i.test(
12546
+ sanitizeTerminalText(text || "")
12547
+ );
12548
+ }
12544
12549
  function parsedTranscriptIsRicherThanCommitted(parsedMessages, committedMessages) {
12545
12550
  if (!Array.isArray(parsedMessages) || !Array.isArray(committedMessages)) return false;
12546
12551
  if (parsedMessages.length > committedMessages.length) return true;
@@ -13860,7 +13865,7 @@ var init_provider_cli_adapter = __esm({
13860
13865
  };
13861
13866
  }
13862
13867
  const hasVisibleAssistantMessage = Array.isArray(result?.messages) && result.messages.some((message) => message?.role === "assistant" && typeof message?.content === "string" && message.content.trim());
13863
- const shouldClampStaleGeneratingToIdle = result?.status === "generating" && this.currentStatus === "idle" && !this.currentTurnScope && !result?.activeModal && hasVisibleAssistantMessage;
13868
+ const shouldClampStaleGeneratingToIdle = result?.status === "generating" && this.currentStatus === "idle" && !this.currentTurnScope && !result?.activeModal && hasVisibleAssistantMessage && !hasVisibleInterruptPrompt(screenText);
13864
13869
  if (shouldClampStaleGeneratingToIdle) {
13865
13870
  result = {
13866
13871
  ...result,
@@ -38719,10 +38724,14 @@ var init_router = __esm({
38719
38724
  currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
38720
38725
  } catch {
38721
38726
  }
38722
- if (currentInstalled === latest) {
38727
+ const runningVersion = typeof this.deps.statusVersion === "string" ? this.deps.statusVersion.trim().replace(/^v/, "") : null;
38728
+ if (currentInstalled === latest && runningVersion === latest) {
38723
38729
  LOG.info("Upgrade", `Already on latest version v${latest}; skipping install`);
38724
38730
  return { success: true, upgraded: false, alreadyLatest: true, version: latest };
38725
38731
  }
38732
+ if (currentInstalled === latest && runningVersion && runningVersion !== latest) {
38733
+ LOG.info("Upgrade", `Installed package is v${latest}, but running daemon is v${runningVersion}; scheduling restart`);
38734
+ }
38726
38735
  spawnDetachedDaemonUpgradeHelper({
38727
38736
  packageName: pkgName,
38728
38737
  targetVersion: latest,
@@ -87136,21 +87145,65 @@ function isAdhdevProcess(pid) {
87136
87145
  return true;
87137
87146
  }
87138
87147
  }
87139
- function getDaemonPid(ref = {}) {
87140
- const pidFile = getDaemonPidFile(ref);
87148
+ function getDaemonHealthPid(ref = {}) {
87149
+ const port = resolveDaemonPort(ref);
87141
87150
  try {
87142
- if (!fs23.existsSync(pidFile)) return null;
87143
- const pid = parseInt(fs23.readFileSync(pidFile, "utf-8").trim(), 10);
87151
+ const { execFileSync: execFileSync5 } = require("child_process");
87152
+ const probe = `
87153
+ const http = require('http');
87154
+ const req = http.get('http://127.0.0.1:${port}/health', { timeout: 1500 }, (res) => {
87155
+ let body = '';
87156
+ res.setEncoding('utf8');
87157
+ res.on('data', (chunk) => { body += chunk; });
87158
+ res.on('end', () => {
87159
+ if (res.statusCode !== 200) return;
87160
+ try {
87161
+ const json = JSON.parse(body || '{}');
87162
+ if (Number.isFinite(json.pid)) process.stdout.write(String(json.pid));
87163
+ } catch {}
87164
+ });
87165
+ });
87166
+ req.on('error', () => {});
87167
+ req.on('timeout', () => { req.destroy(); });
87168
+ `;
87169
+ const result = execFileSync5(process.execPath, ["-e", probe], {
87170
+ encoding: "utf-8",
87171
+ timeout: 3e3,
87172
+ stdio: ["ignore", "pipe", "ignore"]
87173
+ }).trim();
87174
+ const pid = parseInt(result, 10);
87144
87175
  return Number.isFinite(pid) ? pid : null;
87145
87176
  } catch {
87146
87177
  return null;
87147
87178
  }
87148
87179
  }
87180
+ function getDaemonPid(ref = {}) {
87181
+ const pidFile = getDaemonPidFile(ref);
87182
+ try {
87183
+ if (fs23.existsSync(pidFile)) {
87184
+ const pid = parseInt(fs23.readFileSync(pidFile, "utf-8").trim(), 10);
87185
+ if (Number.isFinite(pid)) return pid;
87186
+ }
87187
+ } catch {
87188
+ }
87189
+ return getDaemonHealthPid(ref);
87190
+ }
87149
87191
  function stopDaemon(ref = {}) {
87150
87192
  const pidFile = getDaemonPidFile(ref);
87193
+ let pid = null;
87194
+ try {
87195
+ if (fs23.existsSync(pidFile)) {
87196
+ const pidFromFile = parseInt(fs23.readFileSync(pidFile, "utf-8").trim(), 10);
87197
+ if (Number.isFinite(pidFromFile)) pid = pidFromFile;
87198
+ }
87199
+ } catch {
87200
+ removeDaemonPid(ref);
87201
+ }
87202
+ if (pid === null) {
87203
+ pid = getDaemonHealthPid(ref);
87204
+ }
87205
+ if (pid === null) return false;
87151
87206
  try {
87152
- if (!fs23.existsSync(pidFile)) return false;
87153
- const pid = parseInt(fs23.readFileSync(pidFile, "utf-8").trim());
87154
87207
  process.kill(pid, "SIGTERM");
87155
87208
  removeDaemonPid(ref);
87156
87209
  return true;
@@ -87180,7 +87233,7 @@ var init_adhdev_daemon = __esm({
87180
87233
  init_version();
87181
87234
  init_src();
87182
87235
  init_runtime_defaults();
87183
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.13" });
87236
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.15" });
87184
87237
  AdhdevDaemon = class _AdhdevDaemon {
87185
87238
  localHttpServer = null;
87186
87239
  localWss = null;