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/index.js
CHANGED
|
@@ -7372,68 +7372,66 @@ function normalizeReadChatMessages(payload) {
|
|
|
7372
7372
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
7373
7373
|
return normalizeChatMessages(messages);
|
|
7374
7374
|
}
|
|
7375
|
-
function
|
|
7376
|
-
|
|
7375
|
+
function normalizeReadChatReplayTextContent(content) {
|
|
7376
|
+
return flattenContent(content || "").replace(/\s+/g, " ").trim();
|
|
7377
|
+
}
|
|
7378
|
+
function getReadChatReplayCollapseInfo(message) {
|
|
7379
|
+
if (!message) return null;
|
|
7377
7380
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
7378
7381
|
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
7379
7382
|
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
7380
|
-
const
|
|
7381
|
-
return
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7383
|
+
const collapsible = role === "assistant" || role === "system";
|
|
7384
|
+
if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
|
|
7385
|
+
const content = normalizeReadChatReplayTextContent(message.content);
|
|
7386
|
+
return {
|
|
7387
|
+
role,
|
|
7388
|
+
kind,
|
|
7389
|
+
senderName,
|
|
7390
|
+
content,
|
|
7391
|
+
signature: `${role}:${kind}:${senderName}:${content}`,
|
|
7392
|
+
collapsible
|
|
7393
|
+
};
|
|
7390
7394
|
}
|
|
7391
|
-
function
|
|
7392
|
-
if (!
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
if (
|
|
7396
|
-
if (
|
|
7397
|
-
const content = normalizeReadChatReplayText(message);
|
|
7398
|
-
if (content.length < 160) return false;
|
|
7399
|
-
if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
|
|
7395
|
+
function isStableReadChatAssistantAnswerInfo(info) {
|
|
7396
|
+
if (!info) return false;
|
|
7397
|
+
if (info.role !== "assistant") return false;
|
|
7398
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
7399
|
+
if (info.content.length < 160) return false;
|
|
7400
|
+
if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
|
|
7400
7401
|
return true;
|
|
7401
7402
|
}
|
|
7402
|
-
function
|
|
7403
|
-
if (!
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
if (kind && kind !== "standard") return false;
|
|
7408
|
-
const content = normalizeReadChatReplayText(message);
|
|
7409
|
-
const stableContent = normalizeReadChatReplayText(stableAnswer);
|
|
7403
|
+
function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
|
|
7404
|
+
if (!info || !stableContent) return false;
|
|
7405
|
+
if (info.role !== "assistant") return false;
|
|
7406
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
7407
|
+
const content = info.content;
|
|
7410
7408
|
if (content.length < 80 || stableContent.length < 80) return false;
|
|
7411
7409
|
return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
|
|
7412
7410
|
}
|
|
7413
7411
|
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
7414
7412
|
const collapsed = [];
|
|
7415
7413
|
const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
|
|
7416
|
-
let
|
|
7414
|
+
let stableAssistantAnswerContentInCurrentTurn = "";
|
|
7415
|
+
let previousReplaySignature = "";
|
|
7417
7416
|
for (const message of messages) {
|
|
7418
|
-
const
|
|
7419
|
-
if (role === "user") {
|
|
7417
|
+
const info = getReadChatReplayCollapseInfo(message);
|
|
7418
|
+
if (info?.role === "user") {
|
|
7420
7419
|
replaySignaturesInCurrentTurn.clear();
|
|
7421
|
-
|
|
7420
|
+
stableAssistantAnswerContentInCurrentTurn = "";
|
|
7421
|
+
previousReplaySignature = "";
|
|
7422
7422
|
}
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
if (previousSignature === signature) continue;
|
|
7428
|
-
if (replaySignaturesInCurrentTurn.has(signature)) continue;
|
|
7429
|
-
if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
|
|
7423
|
+
if (info?.collapsible && info.signature) {
|
|
7424
|
+
if (previousReplaySignature === info.signature) continue;
|
|
7425
|
+
if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
|
|
7426
|
+
if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
|
|
7430
7427
|
}
|
|
7431
7428
|
collapsed.push(message);
|
|
7432
|
-
|
|
7433
|
-
|
|
7429
|
+
previousReplaySignature = info?.collapsible ? info.signature : "";
|
|
7430
|
+
if (info?.collapsible && info.signature) {
|
|
7431
|
+
replaySignaturesInCurrentTurn.add(info.signature);
|
|
7434
7432
|
}
|
|
7435
|
-
if (
|
|
7436
|
-
|
|
7433
|
+
if (isStableReadChatAssistantAnswerInfo(info)) {
|
|
7434
|
+
stableAssistantAnswerContentInCurrentTurn = info?.content || "";
|
|
7437
7435
|
}
|
|
7438
7436
|
}
|
|
7439
7437
|
return collapsed;
|
|
@@ -7513,13 +7511,17 @@ function computeReadChatSync(messages, cursor) {
|
|
|
7513
7511
|
};
|
|
7514
7512
|
}
|
|
7515
7513
|
if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7514
|
+
const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
|
|
7515
|
+
if (knownMessageCount >= requestedTailCount) {
|
|
7516
|
+
return {
|
|
7517
|
+
syncMode: "noop",
|
|
7518
|
+
replaceFrom: totalMessages,
|
|
7519
|
+
messages: [],
|
|
7520
|
+
totalMessages,
|
|
7521
|
+
lastMessageSignature
|
|
7522
|
+
};
|
|
7523
|
+
}
|
|
7524
|
+
return buildBoundedTailSync(messages, cursor);
|
|
7523
7525
|
}
|
|
7524
7526
|
if (knownMessageCount < totalMessages) {
|
|
7525
7527
|
const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
|
|
@@ -11522,9 +11524,7 @@ function hydrateCliParsedMessages(parsedMessages, options) {
|
|
|
11522
11524
|
};
|
|
11523
11525
|
});
|
|
11524
11526
|
}
|
|
11525
|
-
function chooseMoreComparableCliMessage(left2, right2) {
|
|
11526
|
-
const leftComparable = normalizeComparableMessageContent(left2.content || "");
|
|
11527
|
-
const rightComparable = normalizeComparableMessageContent(right2.content || "");
|
|
11527
|
+
function chooseMoreComparableCliMessage(left2, right2, leftComparable = normalizeComparableMessageContent(left2.content || ""), rightComparable = normalizeComparableMessageContent(right2.content || "")) {
|
|
11528
11528
|
if (leftComparable && leftComparable === rightComparable) {
|
|
11529
11529
|
const leftNewlines = String(left2.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
11530
11530
|
const rightNewlines = String(right2.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
@@ -11539,24 +11539,32 @@ function dedupeConsecutiveComparableCliMessages(messages) {
|
|
|
11539
11539
|
...message,
|
|
11540
11540
|
content: typeof message.content === "string" ? message.content : String(message.content || "")
|
|
11541
11541
|
};
|
|
11542
|
+
const currentComparable = normalizeComparableMessageContent(current.content || "");
|
|
11542
11543
|
const previous = deduped[deduped.length - 1];
|
|
11543
11544
|
if (!previous) {
|
|
11544
|
-
deduped.push(current);
|
|
11545
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
11545
11546
|
continue;
|
|
11546
11547
|
}
|
|
11547
|
-
const
|
|
11548
|
-
const
|
|
11549
|
-
const
|
|
11550
|
-
const
|
|
11551
|
-
const sameSender = (previous.senderName || "") === (current.senderName || "");
|
|
11552
|
-
const comparableMatch = previousComparable && previousComparable === currentComparable;
|
|
11548
|
+
const sameRole = previous.message.role === current.role;
|
|
11549
|
+
const sameKind = (previous.message.kind || "standard") === (current.kind || "standard");
|
|
11550
|
+
const sameSender = (previous.message.senderName || "") === (current.senderName || "");
|
|
11551
|
+
const comparableMatch = previous.comparable && previous.comparable === currentComparable;
|
|
11553
11552
|
if (sameRole && sameKind && sameSender && comparableMatch) {
|
|
11554
|
-
|
|
11553
|
+
const selected = chooseMoreComparableCliMessage(
|
|
11554
|
+
previous.message,
|
|
11555
|
+
current,
|
|
11556
|
+
previous.comparable,
|
|
11557
|
+
currentComparable
|
|
11558
|
+
);
|
|
11559
|
+
deduped[deduped.length - 1] = {
|
|
11560
|
+
message: selected,
|
|
11561
|
+
comparable: selected === current ? currentComparable : previous.comparable
|
|
11562
|
+
};
|
|
11555
11563
|
continue;
|
|
11556
11564
|
}
|
|
11557
|
-
deduped.push(current);
|
|
11565
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
11558
11566
|
}
|
|
11559
|
-
return deduped;
|
|
11567
|
+
return deduped.map((entry) => entry.message);
|
|
11560
11568
|
}
|
|
11561
11569
|
function normalizeCliParsedMessages(parsedMessages, options) {
|
|
11562
11570
|
return dedupeConsecutiveComparableCliMessages(hydrateCliParsedMessages(parsedMessages, options).map((message) => ({
|
|
@@ -56592,7 +56600,7 @@ var init_adhdev_daemon = __esm({
|
|
|
56592
56600
|
init_version();
|
|
56593
56601
|
init_src();
|
|
56594
56602
|
init_runtime_defaults();
|
|
56595
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
56603
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.40" });
|
|
56596
56604
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
56597
56605
|
localHttpServer = null;
|
|
56598
56606
|
localWss = null;
|