adhdev 0.9.39 → 0.9.40
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 +73 -65
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +73 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -7892,68 +7892,66 @@ function normalizeReadChatMessages(payload) {
|
|
|
7892
7892
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
7893
7893
|
return normalizeChatMessages(messages);
|
|
7894
7894
|
}
|
|
7895
|
-
function
|
|
7896
|
-
|
|
7895
|
+
function normalizeReadChatReplayTextContent(content) {
|
|
7896
|
+
return flattenContent(content || "").replace(/\s+/g, " ").trim();
|
|
7897
|
+
}
|
|
7898
|
+
function getReadChatReplayCollapseInfo(message) {
|
|
7899
|
+
if (!message) return null;
|
|
7897
7900
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
7898
7901
|
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
7899
7902
|
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
7900
|
-
const
|
|
7901
|
-
return
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7903
|
+
const collapsible = role === "assistant" || role === "system";
|
|
7904
|
+
if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
|
|
7905
|
+
const content = normalizeReadChatReplayTextContent(message.content);
|
|
7906
|
+
return {
|
|
7907
|
+
role,
|
|
7908
|
+
kind,
|
|
7909
|
+
senderName,
|
|
7910
|
+
content,
|
|
7911
|
+
signature: `${role}:${kind}:${senderName}:${content}`,
|
|
7912
|
+
collapsible
|
|
7913
|
+
};
|
|
7910
7914
|
}
|
|
7911
|
-
function
|
|
7912
|
-
if (!
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
if (
|
|
7916
|
-
if (
|
|
7917
|
-
const content = normalizeReadChatReplayText(message);
|
|
7918
|
-
if (content.length < 160) return false;
|
|
7919
|
-
if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
|
|
7915
|
+
function isStableReadChatAssistantAnswerInfo(info) {
|
|
7916
|
+
if (!info) return false;
|
|
7917
|
+
if (info.role !== "assistant") return false;
|
|
7918
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
7919
|
+
if (info.content.length < 160) return false;
|
|
7920
|
+
if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
|
|
7920
7921
|
return true;
|
|
7921
7922
|
}
|
|
7922
|
-
function
|
|
7923
|
-
if (!
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
if (kind && kind !== "standard") return false;
|
|
7928
|
-
const content = normalizeReadChatReplayText(message);
|
|
7929
|
-
const stableContent = normalizeReadChatReplayText(stableAnswer);
|
|
7923
|
+
function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
|
|
7924
|
+
if (!info || !stableContent) return false;
|
|
7925
|
+
if (info.role !== "assistant") return false;
|
|
7926
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
7927
|
+
const content = info.content;
|
|
7930
7928
|
if (content.length < 80 || stableContent.length < 80) return false;
|
|
7931
7929
|
return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
|
|
7932
7930
|
}
|
|
7933
7931
|
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
7934
7932
|
const collapsed = [];
|
|
7935
7933
|
const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
|
|
7936
|
-
let
|
|
7934
|
+
let stableAssistantAnswerContentInCurrentTurn = "";
|
|
7935
|
+
let previousReplaySignature = "";
|
|
7937
7936
|
for (const message of messages) {
|
|
7938
|
-
const
|
|
7939
|
-
if (role === "user") {
|
|
7937
|
+
const info = getReadChatReplayCollapseInfo(message);
|
|
7938
|
+
if (info?.role === "user") {
|
|
7940
7939
|
replaySignaturesInCurrentTurn.clear();
|
|
7941
|
-
|
|
7940
|
+
stableAssistantAnswerContentInCurrentTurn = "";
|
|
7941
|
+
previousReplaySignature = "";
|
|
7942
7942
|
}
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
if (previousSignature === signature) continue;
|
|
7948
|
-
if (replaySignaturesInCurrentTurn.has(signature)) continue;
|
|
7949
|
-
if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
|
|
7943
|
+
if (info?.collapsible && info.signature) {
|
|
7944
|
+
if (previousReplaySignature === info.signature) continue;
|
|
7945
|
+
if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
|
|
7946
|
+
if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
|
|
7950
7947
|
}
|
|
7951
7948
|
collapsed.push(message);
|
|
7952
|
-
|
|
7953
|
-
|
|
7949
|
+
previousReplaySignature = info?.collapsible ? info.signature : "";
|
|
7950
|
+
if (info?.collapsible && info.signature) {
|
|
7951
|
+
replaySignaturesInCurrentTurn.add(info.signature);
|
|
7954
7952
|
}
|
|
7955
|
-
if (
|
|
7956
|
-
|
|
7953
|
+
if (isStableReadChatAssistantAnswerInfo(info)) {
|
|
7954
|
+
stableAssistantAnswerContentInCurrentTurn = info?.content || "";
|
|
7957
7955
|
}
|
|
7958
7956
|
}
|
|
7959
7957
|
return collapsed;
|
|
@@ -8033,13 +8031,17 @@ function computeReadChatSync(messages, cursor) {
|
|
|
8033
8031
|
};
|
|
8034
8032
|
}
|
|
8035
8033
|
if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8034
|
+
const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
|
|
8035
|
+
if (knownMessageCount >= requestedTailCount) {
|
|
8036
|
+
return {
|
|
8037
|
+
syncMode: "noop",
|
|
8038
|
+
replaceFrom: totalMessages,
|
|
8039
|
+
messages: [],
|
|
8040
|
+
totalMessages,
|
|
8041
|
+
lastMessageSignature
|
|
8042
|
+
};
|
|
8043
|
+
}
|
|
8044
|
+
return buildBoundedTailSync(messages, cursor);
|
|
8043
8045
|
}
|
|
8044
8046
|
if (knownMessageCount < totalMessages) {
|
|
8045
8047
|
const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
|
|
@@ -12478,9 +12480,7 @@ function hydrateCliParsedMessages(parsedMessages, options) {
|
|
|
12478
12480
|
};
|
|
12479
12481
|
});
|
|
12480
12482
|
}
|
|
12481
|
-
function chooseMoreComparableCliMessage(left2, right2) {
|
|
12482
|
-
const leftComparable = normalizeComparableMessageContent(left2.content || "");
|
|
12483
|
-
const rightComparable = normalizeComparableMessageContent(right2.content || "");
|
|
12483
|
+
function chooseMoreComparableCliMessage(left2, right2, leftComparable = normalizeComparableMessageContent(left2.content || ""), rightComparable = normalizeComparableMessageContent(right2.content || "")) {
|
|
12484
12484
|
if (leftComparable && leftComparable === rightComparable) {
|
|
12485
12485
|
const leftNewlines = String(left2.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
12486
12486
|
const rightNewlines = String(right2.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
@@ -12495,24 +12495,32 @@ function dedupeConsecutiveComparableCliMessages(messages) {
|
|
|
12495
12495
|
...message,
|
|
12496
12496
|
content: typeof message.content === "string" ? message.content : String(message.content || "")
|
|
12497
12497
|
};
|
|
12498
|
+
const currentComparable = normalizeComparableMessageContent(current.content || "");
|
|
12498
12499
|
const previous = deduped[deduped.length - 1];
|
|
12499
12500
|
if (!previous) {
|
|
12500
|
-
deduped.push(current);
|
|
12501
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
12501
12502
|
continue;
|
|
12502
12503
|
}
|
|
12503
|
-
const
|
|
12504
|
-
const
|
|
12505
|
-
const
|
|
12506
|
-
const
|
|
12507
|
-
const sameSender = (previous.senderName || "") === (current.senderName || "");
|
|
12508
|
-
const comparableMatch = previousComparable && previousComparable === currentComparable;
|
|
12504
|
+
const sameRole = previous.message.role === current.role;
|
|
12505
|
+
const sameKind = (previous.message.kind || "standard") === (current.kind || "standard");
|
|
12506
|
+
const sameSender = (previous.message.senderName || "") === (current.senderName || "");
|
|
12507
|
+
const comparableMatch = previous.comparable && previous.comparable === currentComparable;
|
|
12509
12508
|
if (sameRole && sameKind && sameSender && comparableMatch) {
|
|
12510
|
-
|
|
12509
|
+
const selected = chooseMoreComparableCliMessage(
|
|
12510
|
+
previous.message,
|
|
12511
|
+
current,
|
|
12512
|
+
previous.comparable,
|
|
12513
|
+
currentComparable
|
|
12514
|
+
);
|
|
12515
|
+
deduped[deduped.length - 1] = {
|
|
12516
|
+
message: selected,
|
|
12517
|
+
comparable: selected === current ? currentComparable : previous.comparable
|
|
12518
|
+
};
|
|
12511
12519
|
continue;
|
|
12512
12520
|
}
|
|
12513
|
-
deduped.push(current);
|
|
12521
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
12514
12522
|
}
|
|
12515
|
-
return deduped;
|
|
12523
|
+
return deduped.map((entry) => entry.message);
|
|
12516
12524
|
}
|
|
12517
12525
|
function normalizeCliParsedMessages(parsedMessages, options) {
|
|
12518
12526
|
return dedupeConsecutiveComparableCliMessages(hydrateCliParsedMessages(parsedMessages, options).map((message) => ({
|
|
@@ -88312,7 +88320,7 @@ var init_adhdev_daemon = __esm({
|
|
|
88312
88320
|
init_version();
|
|
88313
88321
|
init_src();
|
|
88314
88322
|
init_runtime_defaults();
|
|
88315
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
88323
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.40" });
|
|
88316
88324
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
88317
88325
|
localHttpServer = null;
|
|
88318
88326
|
localWss = null;
|