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