@adhdev/daemon-core 0.8.6 → 0.8.7

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
@@ -877,6 +877,9 @@ function promptLikelyVisible(screenText, promptSnippet) {
877
877
  function normalizeScreenSnapshot(text) {
878
878
  return sanitizeTerminalText(String(text || "")).replace(/\s+/g, " ").trim();
879
879
  }
880
+ function normalizeComparableMessageContent(text) {
881
+ return String(text || "").replace(/\s+/g, " ").trim();
882
+ }
880
883
  function parsePatternEntry(x) {
881
884
  if (x instanceof RegExp) return x;
882
885
  if (x && typeof x === "object" && typeof x.source === "string") {
@@ -1058,11 +1061,44 @@ var init_provider_cli_adapter = __esm({
1058
1061
  this.structuredMessages = [...this.committedMessages];
1059
1062
  }
1060
1063
  normalizeParsedMessages(parsedMessages) {
1061
- return parsedMessages.filter((message) => message && (message.role === "user" || message.role === "assistant")).map((message) => ({
1062
- role: message.role,
1063
- content: typeof message.content === "string" ? message.content : String(message.content || ""),
1064
- timestamp: typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : Date.now()
1065
- }));
1064
+ const referenceMessages = [...this.committedMessages];
1065
+ const usedReferenceIndexes = /* @__PURE__ */ new Set();
1066
+ const now = Date.now();
1067
+ const findReferenceTimestamp = (role, content, parsedIndex) => {
1068
+ const normalizedContent = normalizeComparableMessageContent(content);
1069
+ if (!normalizedContent) return void 0;
1070
+ const sameIndex = referenceMessages[parsedIndex];
1071
+ if (sameIndex && !usedReferenceIndexes.has(parsedIndex) && sameIndex.role === role && normalizeComparableMessageContent(sameIndex.content) === normalizedContent && typeof sameIndex.timestamp === "number" && Number.isFinite(sameIndex.timestamp)) {
1072
+ usedReferenceIndexes.add(parsedIndex);
1073
+ return sameIndex.timestamp;
1074
+ }
1075
+ for (let i = 0; i < referenceMessages.length; i++) {
1076
+ if (usedReferenceIndexes.has(i)) continue;
1077
+ const candidate = referenceMessages[i];
1078
+ if (!candidate || candidate.role !== role) continue;
1079
+ const candidateContent = normalizeComparableMessageContent(candidate.content);
1080
+ if (!candidateContent) continue;
1081
+ const exactMatch = candidateContent === normalizedContent;
1082
+ const fuzzyMatch = candidateContent.includes(normalizedContent) || normalizedContent.includes(candidateContent);
1083
+ if (!exactMatch && !fuzzyMatch) continue;
1084
+ if (typeof candidate.timestamp === "number" && Number.isFinite(candidate.timestamp)) {
1085
+ usedReferenceIndexes.add(i);
1086
+ return candidate.timestamp;
1087
+ }
1088
+ }
1089
+ return void 0;
1090
+ };
1091
+ return parsedMessages.filter((message) => message && (message.role === "user" || message.role === "assistant")).map((message, index) => {
1092
+ const role = message.role;
1093
+ const content = typeof message.content === "string" ? message.content : String(message.content || "");
1094
+ const parsedTimestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : void 0;
1095
+ const referenceTimestamp = parsedTimestamp ?? findReferenceTimestamp(role, content, index);
1096
+ return {
1097
+ role,
1098
+ content,
1099
+ timestamp: referenceTimestamp ?? now
1100
+ };
1101
+ });
1066
1102
  }
1067
1103
  sliceFromOffset(text, start) {
1068
1104
  if (!text) return "";
@@ -1220,11 +1256,15 @@ var init_provider_cli_adapter = __esm({
1220
1256
  let shellCmd;
1221
1257
  let shellArgs;
1222
1258
  const useShellUnix = !isWin && (!!spawnConfig.shell || !path7.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
1223
- const useShell = isWin ? !!spawnConfig.shell : useShellUnix;
1259
+ const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
1260
+ const useShell = isWin ? !!spawnConfig.shell || isCmdShim : useShellUnix;
1224
1261
  if (useShell) {
1225
1262
  if (!spawnConfig.shell && !isWin) {
1226
1263
  LOG.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
1227
1264
  }
1265
+ if (isCmdShim) {
1266
+ LOG.info("CLI", `[${this.cliType}] Using cmd.exe shell for .cmd/.bat shim: ${binaryPath}`);
1267
+ }
1228
1268
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
1229
1269
  if (isWin) {
1230
1270
  shellArgs = ["/c", binaryPath, ...allArgs];