@adhdev/daemon-standalone 0.9.82-rc.293 → 0.9.82-rc.294

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
@@ -29983,10 +29983,10 @@ var require_dist3 = __commonJS({
29983
29983
  }
29984
29984
  function getDaemonBuildInfo() {
29985
29985
  if (cached2) return cached2;
29986
- const commit = readInjected(true ? "88f97abcc85d83fe5d5313b229d32a7d76b1208a" : void 0) ?? "unknown";
29987
- const commitShort = readInjected(true ? "88f97abc" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29988
- const version2 = readInjected(true ? "0.9.82-rc.293" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29989
- const builtAt = readInjected(true ? "2026-06-16T11:14:20.929Z" : void 0);
29986
+ const commit = readInjected(true ? "6ee0e52b0b7347870577ebe598054d87127078fe" : void 0) ?? "unknown";
29987
+ const commitShort = readInjected(true ? "6ee0e52b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29988
+ const version2 = readInjected(true ? "0.9.82-rc.294" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29989
+ const builtAt = readInjected(true ? "2026-06-16T12:16:10.838Z" : void 0);
29990
29990
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
29991
29991
  return cached2;
29992
29992
  }
@@ -31725,6 +31725,7 @@ ${rules.join("\n")}`;
31725
31725
  - **Verify via git, not source.** Use \`mesh_git_status\` to confirm side effects. Treat agent summaries as self-reports, not verification.
31726
31726
  - **Limit parallelism.** Start with 1\u20132 tasks; scale only on success. Never duplicate a session because \`mesh_read_chat\` shows no final message while tool/terminal activity is ongoing. This caps *concurrent* load \u2014 it does not mean serialize independent work: when a new, independent request arrives and there is headroom under \`maxParallelTasks\`, dispatch it right away rather than waiting for an in-flight task or a user nudge (read-only diagnosis especially, since it has no merge cost).
31727
31727
  - **Check history first.** Call \`mesh_task_history\` at session start to avoid duplicate work and inform recovery. On failure, read task history before retrying.
31728
+ - **Sequence shared-base-moving merges.** Parallel dispatch is encouraged, but merging one worktree can advance another in-flight worktree's base \u2014 especially the oss submodule pointer \u2014 turning a clean fast-forward into a diverged rebase (patch-equivalence correctly blocks this). Before merging an in-flight worktree while siblings are also in flight, land in an intentional order, re-clone long-running worktrees from the advanced base, or expect to manually rebase + ff-only the laggards; merging an independent fix mid-flight can strand siblings into a rebase.
31728
31729
  - **Converge branches.** After worktree tasks: refine/fast-forward, or classify as \`pushed_feature_branch_needs_merge\` / \`blocked_review\` / \`cleanup_candidate\` / \`not_mergeable\`. Clean up with \`mesh_remove_node\`.
31729
31730
  - **Refinery is config-driven.** \`mesh_refine_node\` must run validation from \`.adhdev/refine.{json,yaml,yml}\` or \`repo-mesh.refine.*\`. Heuristics are scaffolding only.
31730
31731
  - **Submodule reachability = publish-needed.** \`submodule_reachability_failed\` \u2192 classify as \`blocked_review\`, request user approval to push to submodule main, then rerun \`mesh_refine_node\`.
@@ -51597,22 +51598,160 @@ ${cleanBody}`;
51597
51598
  if (!Number.isFinite(numericOffset) || !Number.isFinite(numericExclude)) return false;
51598
51599
  return true;
51599
51600
  }
51601
+ var REVERSE_TAIL_SMALL_FILE_BYTES = 64 * 1024;
51602
+ var REVERSE_TAIL_CHUNK_BYTES = 64 * 1024;
51603
+ var TAIL_LINES_RETAINED = BOUNDED_TAIL_MAX_LIMIT + 2 * BOUNDED_TAIL_SLACK;
51604
+ var INCREMENTAL_TAIL_CACHE_MAX_ENTRIES = 64;
51605
+ var incrementalTailCache = /* @__PURE__ */ new Map();
51606
+ function evictIncrementalTailCache() {
51607
+ while (incrementalTailCache.size > INCREMENTAL_TAIL_CACHE_MAX_ENTRIES) {
51608
+ const oldest = incrementalTailCache.keys().next().value;
51609
+ if (oldest === void 0) break;
51610
+ incrementalTailCache.delete(oldest);
51611
+ }
51612
+ }
51613
+ function splitBufferLines(buf) {
51614
+ const lines = [];
51615
+ let lineEnd = buf.length;
51616
+ let firstNewline = -1;
51617
+ for (let i = buf.length - 1; i >= 0; i--) {
51618
+ if (buf[i] !== 10) continue;
51619
+ if (i + 1 < lineEnd) {
51620
+ lines.push(buf.toString("utf-8", i + 1, lineEnd));
51621
+ }
51622
+ lineEnd = i;
51623
+ firstNewline = i;
51624
+ }
51625
+ lines.reverse();
51626
+ const head = firstNewline >= 0 ? buf.subarray(0, firstNewline) : buf;
51627
+ return { head, lines };
51628
+ }
51629
+ function readReverseTailLines(filePath, needed) {
51630
+ const fd = fs52.openSync(filePath, "r");
51631
+ try {
51632
+ const stat2 = fs52.fstatSync(fd);
51633
+ const size = stat2.size;
51634
+ let position = size;
51635
+ let carry = Buffer.alloc(0);
51636
+ const collected = [];
51637
+ while (position > 0 && collected.length < needed) {
51638
+ const chunkSize = Math.min(REVERSE_TAIL_CHUNK_BYTES, position);
51639
+ position -= chunkSize;
51640
+ const chunk = Buffer.alloc(chunkSize);
51641
+ fs52.readSync(fd, chunk, 0, chunkSize, position);
51642
+ const combined = carry.length ? Buffer.concat([chunk, carry]) : chunk;
51643
+ const { head, lines } = splitBufferLines(combined);
51644
+ carry = head;
51645
+ for (let i = lines.length - 1; i >= 0; i--) {
51646
+ collected.push(lines[i]);
51647
+ }
51648
+ }
51649
+ const reachedStart = position <= 0;
51650
+ if (reachedStart && carry.length) {
51651
+ collected.push(carry.toString("utf-8"));
51652
+ }
51653
+ collected.reverse();
51654
+ return { lines: collected, coversWholeFile: reachedStart, size, mtimeMs: stat2.mtimeMs };
51655
+ } finally {
51656
+ fs52.closeSync(fd);
51657
+ }
51658
+ }
51659
+ function readFileTailLines(filePath, needed) {
51660
+ let stat2;
51661
+ try {
51662
+ stat2 = fs52.statSync(filePath);
51663
+ } catch {
51664
+ return { lines: [], coversWholeFile: true };
51665
+ }
51666
+ const size = stat2.size;
51667
+ const mtimeMs = stat2.mtimeMs;
51668
+ if (size === 0) {
51669
+ incrementalTailCache.delete(filePath);
51670
+ return { lines: [], coversWholeFile: true };
51671
+ }
51672
+ const cached22 = incrementalTailCache.get(filePath);
51673
+ if (cached22) {
51674
+ if (cached22.size === size && cached22.mtimeMs === mtimeMs) {
51675
+ incrementalTailCache.delete(filePath);
51676
+ incrementalTailCache.set(filePath, cached22);
51677
+ if (cached22.coversWholeFile || cached22.lines.length >= needed) {
51678
+ return { lines: cached22.lines, coversWholeFile: cached22.coversWholeFile };
51679
+ }
51680
+ } else if (size > cached22.size) {
51681
+ const incremental = tryIncrementalTailGrowth(filePath, cached22, size, mtimeMs, needed);
51682
+ if (incremental) return { lines: incremental.lines, coversWholeFile: incremental.coversWholeFile };
51683
+ }
51684
+ incrementalTailCache.delete(filePath);
51685
+ }
51686
+ if (size <= REVERSE_TAIL_SMALL_FILE_BYTES) {
51687
+ let content;
51688
+ try {
51689
+ content = fs52.readFileSync(filePath, "utf-8");
51690
+ } catch {
51691
+ return { lines: [], coversWholeFile: true };
51692
+ }
51693
+ const lines = content.split("\n");
51694
+ if (lines.length && lines[lines.length - 1] === "") lines.pop();
51695
+ storeIncrementalTailCache(filePath, size, mtimeMs, lines, true);
51696
+ return { lines, coversWholeFile: true };
51697
+ }
51698
+ let result;
51699
+ try {
51700
+ result = readReverseTailLines(filePath, needed);
51701
+ } catch {
51702
+ return { lines: [], coversWholeFile: true };
51703
+ }
51704
+ storeIncrementalTailCache(filePath, result.size, result.mtimeMs, result.lines, result.coversWholeFile);
51705
+ return { lines: result.lines, coversWholeFile: result.coversWholeFile };
51706
+ }
51707
+ function tryIncrementalTailGrowth(filePath, cached22, size, mtimeMs, needed) {
51708
+ const fd = fs52.openSync(filePath, "r");
51709
+ try {
51710
+ if (cached22.size > 0) {
51711
+ const boundary = Buffer.alloc(1);
51712
+ fs52.readSync(fd, boundary, 0, 1, cached22.size - 1);
51713
+ if (boundary[0] !== 10) return null;
51714
+ }
51715
+ const appendedLength = size - cached22.size;
51716
+ const appended = Buffer.alloc(appendedLength);
51717
+ fs52.readSync(fd, appended, 0, appendedLength, cached22.size);
51718
+ const newLines = appended.toString("utf-8").split("\n");
51719
+ if (newLines.length && newLines[newLines.length - 1] === "") newLines.pop();
51720
+ const merged = cached22.lines.concat(newLines);
51721
+ const trimmed = merged.length > TAIL_LINES_RETAINED ? merged.slice(merged.length - TAIL_LINES_RETAINED) : merged;
51722
+ const coversWholeFile = cached22.coversWholeFile && trimmed.length === merged.length;
51723
+ storeIncrementalTailCache(filePath, size, mtimeMs, trimmed, coversWholeFile);
51724
+ if (coversWholeFile || trimmed.length >= needed) {
51725
+ return { lines: trimmed, coversWholeFile };
51726
+ }
51727
+ return { lines: trimmed, coversWholeFile };
51728
+ } catch {
51729
+ return null;
51730
+ } finally {
51731
+ fs52.closeSync(fd);
51732
+ }
51733
+ }
51734
+ function storeIncrementalTailCache(filePath, size, mtimeMs, lines, coversWholeFile) {
51735
+ const retained = lines.length > TAIL_LINES_RETAINED ? lines.slice(lines.length - TAIL_LINES_RETAINED) : lines;
51736
+ const covers = coversWholeFile && retained.length === lines.length;
51737
+ incrementalTailCache.delete(filePath);
51738
+ incrementalTailCache.set(filePath, { size, mtimeMs, lines: retained, coversWholeFile: covers });
51739
+ evictIncrementalTailCache();
51740
+ }
51600
51741
  function readBoundedTailRecords(agentType, dir, files, needed) {
51601
51742
  const collected = [];
51602
51743
  const seen = /* @__PURE__ */ new Set();
51603
51744
  let readAllFiles = true;
51604
51745
  for (let f = 0; f < files.length; f++) {
51605
51746
  const filePath = path12.join(dir, files[f]);
51606
- let content;
51607
- try {
51608
- content = fs52.readFileSync(filePath, "utf-8");
51609
- } catch {
51610
- continue;
51611
- }
51612
- const lines = content.trim().split("\n").filter(Boolean);
51747
+ const remaining = Math.max(0, needed - collected.length);
51748
+ const perFileNeeded = Math.min(needed, remaining + BOUNDED_TAIL_SLACK);
51749
+ const { lines, coversWholeFile } = readFileTailLines(filePath, perFileNeeded);
51613
51750
  for (let i = lines.length - 1; i >= 0; i--) {
51751
+ const line = lines[i];
51752
+ if (!line) continue;
51614
51753
  try {
51615
- const parsed = JSON.parse(lines[i]);
51754
+ const parsed = JSON.parse(line);
51616
51755
  const sanitizedMessage = sanitizeHistoryMessage(agentType, parsed);
51617
51756
  if (!sanitizedMessage) continue;
51618
51757
  const hash2 = buildHistoryMessageHash(agentType, sanitizedMessage);
@@ -51622,6 +51761,10 @@ ${cleanBody}`;
51622
51761
  } catch {
51623
51762
  }
51624
51763
  }
51764
+ if (!coversWholeFile) {
51765
+ readAllFiles = false;
51766
+ break;
51767
+ }
51625
51768
  if (collected.length >= needed && f < files.length - 1) {
51626
51769
  readAllFiles = false;
51627
51770
  break;
@@ -61492,12 +61635,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61492
61635
  }
61493
61636
  this.maybeClearResolvedClaudeTuiPrompt();
61494
61637
  this.maybeCaptureClaudeTuiPrompt();
61638
+ this.maybeUpgradeClaudeTuiMultiSelect();
61495
61639
  this.statusCallback?.();
61496
61640
  return;
61497
61641
  case "pty_data":
61498
61642
  this.detectInteractivePromptFromPtyChunk(ev.chunk);
61499
61643
  this.maybeClearResolvedClaudeTuiPrompt();
61500
61644
  this.maybeCaptureClaudeTuiPrompt();
61645
+ this.maybeUpgradeClaudeTuiMultiSelect();
61501
61646
  try {
61502
61647
  this.ptyDataCallback?.(ev.chunk);
61503
61648
  } catch {
@@ -61646,6 +61791,35 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61646
61791
  this.claudeTuiPromptCaptureInFlight = false;
61647
61792
  });
61648
61793
  }
61794
+ /**
61795
+ * The TUI prompt is captured on the FIRST frame that renders the
61796
+ * "Enter to select" footer. At that instant the option rows' checkbox
61797
+ * column may not have drawn yet, so `detectClaudeTuiMultiSelect` returns
61798
+ * false and the prompt is frozen as single-select — the dashboard then
61799
+ * renders radio buttons even though the picker is multi-select.
61800
+ *
61801
+ * While the same TUI prompt is still on screen, re-check the live snapshot:
61802
+ * if checkbox glyphs have since appeared, promote any single-select
61803
+ * question to multi-select and re-emit status. Promotion is one-way
61804
+ * (false→true only) — once a question is known multi-select we never demote
61805
+ * it, since the glyph column can scroll out of view on later frames.
61806
+ */
61807
+ maybeUpgradeClaudeTuiMultiSelect() {
61808
+ if (this.cliType !== "claude-cli" || this.interactivePromptTransport !== "tui" || !this.activeInteractivePrompt) return;
61809
+ const questions = this.activeInteractivePrompt.questions;
61810
+ if (questions.length !== 1) return;
61811
+ if (questions[0].multiSelect) return;
61812
+ let screenText = "";
61813
+ try {
61814
+ screenText = this.driver.snapshot();
61815
+ } catch {
61816
+ return;
61817
+ }
61818
+ if (!screenText.includes("Enter to select")) return;
61819
+ if (!detectClaudeTuiMultiSelect(screenText)) return;
61820
+ questions[0].multiSelect = true;
61821
+ this.statusCallback?.();
61822
+ }
61649
61823
  readClaudeTuiHeaders(screenText) {
61650
61824
  const navLine = screenText.split(/\r?\n/).find((line) => line.includes("\u2714 Submit") && /[☐☒]/.test(line));
61651
61825
  if (!navLine) return [];
@@ -61787,6 +61961,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61787
61961
  }
61788
61962
  return normalizedId;
61789
61963
  }
61964
+ var STATUS_HYDRATION_TAIL_LIMIT = 200;
61790
61965
  function isIdleStatus(value) {
61791
61966
  const status = typeof value === "string" ? value.trim().toLowerCase() : "";
61792
61967
  return !status || status === "idle" || status === "ready";
@@ -63449,12 +63624,14 @@ ${effect.notification.body || ""}`.trim();
63449
63624
  const newestMessageAt = parsedMessages.reduce((newest, message) => Math.max(newest, getMessageTime(message)), 0);
63450
63625
  return newestMessageAt === 0;
63451
63626
  }
63452
- syncCanonicalSavedHistoryIfNeeded() {
63627
+ syncCanonicalSavedHistoryIfNeeded(options = {}) {
63453
63628
  if (!this.providerSessionId) return false;
63454
63629
  const canonicalHistory = this.provider.nativeHistory;
63455
63630
  if (!canonicalHistory) return false;
63631
+ const limit = options.full ? Number.MAX_SAFE_INTEGER : STATUS_HYDRATION_TAIL_LIMIT;
63632
+ const windowTag = options.full ? "full" : `tail:${STATUS_HYDRATION_TAIL_LIMIT}`;
63456
63633
  if (isNativeSourceCanonicalHistory(canonicalHistory)) {
63457
- const cacheKey = [this.type, this.providerSessionId, this.workingDir].join("\0");
63634
+ const cacheKey = [this.type, this.providerSessionId, this.workingDir, windowTag].join("\0");
63458
63635
  const now = Date.now();
63459
63636
  if (cacheKey === this.lastNativeSourceCanonicalCacheKey && now - this.lastNativeSourceCanonicalCheckAt < 2e3) {
63460
63637
  return true;
@@ -63466,7 +63643,7 @@ ${effect.notification.body || ""}`.trim();
63466
63643
  historySessionId: this.providerSessionId,
63467
63644
  workspace: this.workingDir,
63468
63645
  offset: 0,
63469
- limit: Number.MAX_SAFE_INTEGER,
63646
+ limit,
63470
63647
  historyBehavior: this.provider.historyBehavior,
63471
63648
  scripts: this.provider.scripts
63472
63649
  });
@@ -63482,7 +63659,7 @@ ${effect.notification.body || ""}`.trim();
63482
63659
  return true;
63483
63660
  }
63484
63661
  try {
63485
- const cacheKey = [this.type, this.providerSessionId, this.workingDir, canonicalHistory.mode || "materialized-mirror"].join("\0");
63662
+ const cacheKey = [this.type, this.providerSessionId, this.workingDir, canonicalHistory.mode || "materialized-mirror", windowTag].join("\0");
63486
63663
  const now = Date.now();
63487
63664
  if (cacheKey === this.lastNativeSourceCanonicalCacheKey && now - this.lastNativeSourceCanonicalCheckAt < 2e3) {
63488
63665
  return true;
@@ -63492,7 +63669,7 @@ ${effect.notification.body || ""}`.trim();
63492
63669
  if (!materializeProviderNativeHistory(this.type, canonicalHistory, this.providerSessionId, this.workingDir, this.provider.scripts)) {
63493
63670
  return false;
63494
63671
  }
63495
- const restoredHistory = readChatHistory(this.type, 0, Number.MAX_SAFE_INTEGER, this.providerSessionId, 0, this.provider.historyBehavior);
63672
+ const restoredHistory = readChatHistory(this.type, 0, limit, this.providerSessionId, 0, this.provider.historyBehavior);
63496
63673
  this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
63497
63674
  role: message.role,
63498
63675
  content: message.content,
@@ -63507,7 +63684,7 @@ ${effect.notification.body || ""}`.trim();
63507
63684
  }
63508
63685
  restorePersistedHistoryFromCurrentSession() {
63509
63686
  if (!this.providerSessionId) return;
63510
- this.syncCanonicalSavedHistoryIfNeeded();
63687
+ this.syncCanonicalSavedHistoryIfNeeded({ full: true });
63511
63688
  const restoredHistory = isNativeSourceCanonicalHistory(this.provider.nativeHistory) ? readProviderChatHistory(this.type, {
63512
63689
  canonicalHistory: this.provider.nativeHistory,
63513
63690
  historySessionId: this.providerSessionId,