@adhdev/daemon-standalone 0.8.6 → 0.8.8

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
@@ -28611,6 +28611,9 @@ var require_dist2 = __commonJS({
28611
28611
  function normalizeScreenSnapshot(text) {
28612
28612
  return sanitizeTerminalText(String(text || "")).replace(/\s+/g, " ").trim();
28613
28613
  }
28614
+ function normalizeComparableMessageContent(text) {
28615
+ return String(text || "").replace(/\s+/g, " ").trim();
28616
+ }
28614
28617
  function parsePatternEntry(x) {
28615
28618
  if (x instanceof RegExp) return x;
28616
28619
  if (x && typeof x === "object" && typeof x.source === "string") {
@@ -28796,11 +28799,44 @@ var require_dist2 = __commonJS({
28796
28799
  this.structuredMessages = [...this.committedMessages];
28797
28800
  }
28798
28801
  normalizeParsedMessages(parsedMessages) {
28799
- return parsedMessages.filter((message) => message && (message.role === "user" || message.role === "assistant")).map((message) => ({
28800
- role: message.role,
28801
- content: typeof message.content === "string" ? message.content : String(message.content || ""),
28802
- timestamp: typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : Date.now()
28803
- }));
28802
+ const referenceMessages = [...this.committedMessages];
28803
+ const usedReferenceIndexes = /* @__PURE__ */ new Set();
28804
+ const now = Date.now();
28805
+ const findReferenceTimestamp = (role, content, parsedIndex) => {
28806
+ const normalizedContent = normalizeComparableMessageContent(content);
28807
+ if (!normalizedContent) return void 0;
28808
+ const sameIndex = referenceMessages[parsedIndex];
28809
+ if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && normalizeComparableMessageContent(sameIndex.content) === normalizedContent && typeof sameIndex.timestamp === "number" && Number.isFinite(sameIndex.timestamp)) {
28810
+ usedReferenceIndexes.add(parsedIndex);
28811
+ return sameIndex.timestamp;
28812
+ }
28813
+ for (let i = 0; i < referenceMessages.length; i++) {
28814
+ if (usedReferenceIndexes.has(i)) continue;
28815
+ const candidate = referenceMessages[i];
28816
+ if (!candidate || candidate.role !== role) continue;
28817
+ const candidateContent = normalizeComparableMessageContent(candidate.content);
28818
+ if (!candidateContent) continue;
28819
+ const exactMatch = candidateContent === normalizedContent;
28820
+ const fuzzyMatch = candidateContent.includes(normalizedContent) || normalizedContent.includes(candidateContent);
28821
+ if (!exactMatch && !fuzzyMatch) continue;
28822
+ if (typeof candidate.timestamp === "number" && Number.isFinite(candidate.timestamp)) {
28823
+ usedReferenceIndexes.add(i);
28824
+ return candidate.timestamp;
28825
+ }
28826
+ }
28827
+ return void 0;
28828
+ };
28829
+ return parsedMessages.filter((message) => message && (message.role === "user" || message.role === "assistant")).map((message, index) => {
28830
+ const role = message.role;
28831
+ const content = typeof message.content === "string" ? message.content : String(message.content || "");
28832
+ const parsedTimestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : void 0;
28833
+ const referenceTimestamp = parsedTimestamp ?? findReferenceTimestamp(role, content, index);
28834
+ return {
28835
+ role,
28836
+ content,
28837
+ timestamp: referenceTimestamp ?? now
28838
+ };
28839
+ });
28804
28840
  }
28805
28841
  sliceFromOffset(text, start) {
28806
28842
  if (!text) return "";
@@ -28958,11 +28994,15 @@ var require_dist2 = __commonJS({
28958
28994
  let shellCmd;
28959
28995
  let shellArgs;
28960
28996
  const useShellUnix = !isWin && (!!spawnConfig.shell || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
28961
- const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
28997
+ const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
28998
+ const useShell = isWin ? !!spawnConfig.shell || isCmdShim : useShellUnix;
28962
28999
  if (useShell) {
28963
29000
  if (!spawnConfig.shell && !isWin) {
28964
29001
  LOG2.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
28965
29002
  }
29003
+ if (isCmdShim) {
29004
+ LOG2.info("CLI", `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
29005
+ }
28966
29006
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
28967
29007
  if (isWin) {
28968
29008
  shellArgs = ["/c", binaryPath, ...allArgs];