@adhdev/daemon-core 0.9.38 → 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/commands/chat-commands.d.ts +2 -0
- package/dist/index.js +83 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -67
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +11 -0
- package/src/cli-adapters/provider-cli-parse.ts +25 -15
- package/src/commands/chat-commands.ts +65 -56
- package/src/providers/cli-provider-instance.ts +6 -3
package/dist/index.mjs
CHANGED
|
@@ -1790,9 +1790,7 @@ function hydrateCliParsedMessages(parsedMessages, options) {
|
|
|
1790
1790
|
};
|
|
1791
1791
|
});
|
|
1792
1792
|
}
|
|
1793
|
-
function chooseMoreComparableCliMessage(left, right) {
|
|
1794
|
-
const leftComparable = normalizeComparableMessageContent(left.content || "");
|
|
1795
|
-
const rightComparable = normalizeComparableMessageContent(right.content || "");
|
|
1793
|
+
function chooseMoreComparableCliMessage(left, right, leftComparable = normalizeComparableMessageContent(left.content || ""), rightComparable = normalizeComparableMessageContent(right.content || "")) {
|
|
1796
1794
|
if (leftComparable && leftComparable === rightComparable) {
|
|
1797
1795
|
const leftNewlines = String(left.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
1798
1796
|
const rightNewlines = String(right.content || "").split(/\r\n|\n|\r/g).length - 1;
|
|
@@ -1807,24 +1805,32 @@ function dedupeConsecutiveComparableCliMessages(messages) {
|
|
|
1807
1805
|
...message,
|
|
1808
1806
|
content: typeof message.content === "string" ? message.content : String(message.content || "")
|
|
1809
1807
|
};
|
|
1808
|
+
const currentComparable = normalizeComparableMessageContent(current.content || "");
|
|
1810
1809
|
const previous = deduped[deduped.length - 1];
|
|
1811
1810
|
if (!previous) {
|
|
1812
|
-
deduped.push(current);
|
|
1811
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
1813
1812
|
continue;
|
|
1814
1813
|
}
|
|
1815
|
-
const
|
|
1816
|
-
const
|
|
1817
|
-
const
|
|
1818
|
-
const
|
|
1819
|
-
const sameSender = (previous.senderName || "") === (current.senderName || "");
|
|
1820
|
-
const comparableMatch = previousComparable && previousComparable === currentComparable;
|
|
1814
|
+
const sameRole = previous.message.role === current.role;
|
|
1815
|
+
const sameKind = (previous.message.kind || "standard") === (current.kind || "standard");
|
|
1816
|
+
const sameSender = (previous.message.senderName || "") === (current.senderName || "");
|
|
1817
|
+
const comparableMatch = previous.comparable && previous.comparable === currentComparable;
|
|
1821
1818
|
if (sameRole && sameKind && sameSender && comparableMatch) {
|
|
1822
|
-
|
|
1819
|
+
const selected = chooseMoreComparableCliMessage(
|
|
1820
|
+
previous.message,
|
|
1821
|
+
current,
|
|
1822
|
+
previous.comparable,
|
|
1823
|
+
currentComparable
|
|
1824
|
+
);
|
|
1825
|
+
deduped[deduped.length - 1] = {
|
|
1826
|
+
message: selected,
|
|
1827
|
+
comparable: selected === current ? currentComparable : previous.comparable
|
|
1828
|
+
};
|
|
1823
1829
|
continue;
|
|
1824
1830
|
}
|
|
1825
|
-
deduped.push(current);
|
|
1831
|
+
deduped.push({ message: current, comparable: currentComparable });
|
|
1826
1832
|
}
|
|
1827
|
-
return deduped;
|
|
1833
|
+
return deduped.map((entry) => entry.message);
|
|
1828
1834
|
}
|
|
1829
1835
|
function normalizeCliParsedMessages(parsedMessages, options) {
|
|
1830
1836
|
return dedupeConsecutiveComparableCliMessages(hydrateCliParsedMessages(parsedMessages, options).map((message) => ({
|
|
@@ -2848,6 +2854,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
2848
2854
|
}
|
|
2849
2855
|
this.resolveStartupState("settled");
|
|
2850
2856
|
if (this.startupParseGate) return;
|
|
2857
|
+
if (!this.isWaitingForResponse && !this.currentTurnScope && !this.activeModal && !this.parseErrorMessage) {
|
|
2858
|
+
const tail = this.settledBuffer || this.recentOutputBuffer;
|
|
2859
|
+
const modal2 = this.runParseApproval(tail);
|
|
2860
|
+
const lightweightStatus = this.cliScripts?.detectStatus ? this.runDetectStatus(tail) : null;
|
|
2861
|
+
if (!modal2 && lightweightStatus === "idle" && this.currentStatus === "idle") {
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2851
2865
|
const session = this.runParseSession();
|
|
2852
2866
|
if (!session) return;
|
|
2853
2867
|
const { status, messages, modal, parsedStatus } = session;
|
|
@@ -10462,68 +10476,66 @@ function normalizeReadChatMessages(payload) {
|
|
|
10462
10476
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
10463
10477
|
return normalizeChatMessages(messages);
|
|
10464
10478
|
}
|
|
10465
|
-
function
|
|
10466
|
-
|
|
10479
|
+
function normalizeReadChatReplayTextContent(content) {
|
|
10480
|
+
return flattenContent(content || "").replace(/\s+/g, " ").trim();
|
|
10481
|
+
}
|
|
10482
|
+
function getReadChatReplayCollapseInfo(message) {
|
|
10483
|
+
if (!message) return null;
|
|
10467
10484
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
10468
10485
|
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
10469
10486
|
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
10470
|
-
const
|
|
10471
|
-
return
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10487
|
+
const collapsible = role === "assistant" || role === "system";
|
|
10488
|
+
if (!collapsible) return { role, kind, senderName, content: "", signature: "", collapsible };
|
|
10489
|
+
const content = normalizeReadChatReplayTextContent(message.content);
|
|
10490
|
+
return {
|
|
10491
|
+
role,
|
|
10492
|
+
kind,
|
|
10493
|
+
senderName,
|
|
10494
|
+
content,
|
|
10495
|
+
signature: `${role}:${kind}:${senderName}:${content}`,
|
|
10496
|
+
collapsible
|
|
10497
|
+
};
|
|
10480
10498
|
}
|
|
10481
|
-
function
|
|
10482
|
-
if (!
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
if (
|
|
10486
|
-
if (
|
|
10487
|
-
const content = normalizeReadChatReplayText(message);
|
|
10488
|
-
if (content.length < 160) return false;
|
|
10489
|
-
if (/^(bash|shell|terminal) command\b/i.test(content)) return false;
|
|
10499
|
+
function isStableReadChatAssistantAnswerInfo(info) {
|
|
10500
|
+
if (!info) return false;
|
|
10501
|
+
if (info.role !== "assistant") return false;
|
|
10502
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10503
|
+
if (info.content.length < 160) return false;
|
|
10504
|
+
if (/^(bash|shell|terminal) command\b/i.test(info.content)) return false;
|
|
10490
10505
|
return true;
|
|
10491
10506
|
}
|
|
10492
|
-
function
|
|
10493
|
-
if (!
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
if (kind && kind !== "standard") return false;
|
|
10498
|
-
const content = normalizeReadChatReplayText(message);
|
|
10499
|
-
const stableContent = normalizeReadChatReplayText(stableAnswer);
|
|
10507
|
+
function isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableContent) {
|
|
10508
|
+
if (!info || !stableContent) return false;
|
|
10509
|
+
if (info.role !== "assistant") return false;
|
|
10510
|
+
if (info.kind && info.kind !== "standard") return false;
|
|
10511
|
+
const content = info.content;
|
|
10500
10512
|
if (content.length < 80 || stableContent.length < 80) return false;
|
|
10501
10513
|
return content === stableContent || content.startsWith(stableContent) || stableContent.startsWith(content);
|
|
10502
10514
|
}
|
|
10503
10515
|
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
10504
10516
|
const collapsed = [];
|
|
10505
10517
|
const replaySignaturesInCurrentTurn = /* @__PURE__ */ new Set();
|
|
10506
|
-
let
|
|
10518
|
+
let stableAssistantAnswerContentInCurrentTurn = "";
|
|
10519
|
+
let previousReplaySignature = "";
|
|
10507
10520
|
for (const message of messages) {
|
|
10508
|
-
const
|
|
10509
|
-
if (role === "user") {
|
|
10521
|
+
const info = getReadChatReplayCollapseInfo(message);
|
|
10522
|
+
if (info?.role === "user") {
|
|
10510
10523
|
replaySignaturesInCurrentTurn.clear();
|
|
10511
|
-
|
|
10524
|
+
stableAssistantAnswerContentInCurrentTurn = "";
|
|
10525
|
+
previousReplaySignature = "";
|
|
10512
10526
|
}
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
if (previousSignature === signature) continue;
|
|
10518
|
-
if (replaySignaturesInCurrentTurn.has(signature)) continue;
|
|
10519
|
-
if (isReplayedAssistantAnswerAfterStableAnswer(message, stableAssistantAnswerInCurrentTurn)) continue;
|
|
10527
|
+
if (info?.collapsible && info.signature) {
|
|
10528
|
+
if (previousReplaySignature === info.signature) continue;
|
|
10529
|
+
if (replaySignaturesInCurrentTurn.has(info.signature)) continue;
|
|
10530
|
+
if (isReplayedAssistantAnswerAfterStableAnswerInfo(info, stableAssistantAnswerContentInCurrentTurn)) continue;
|
|
10520
10531
|
}
|
|
10521
10532
|
collapsed.push(message);
|
|
10522
|
-
|
|
10523
|
-
|
|
10533
|
+
previousReplaySignature = info?.collapsible ? info.signature : "";
|
|
10534
|
+
if (info?.collapsible && info.signature) {
|
|
10535
|
+
replaySignaturesInCurrentTurn.add(info.signature);
|
|
10524
10536
|
}
|
|
10525
|
-
if (
|
|
10526
|
-
|
|
10537
|
+
if (isStableReadChatAssistantAnswerInfo(info)) {
|
|
10538
|
+
stableAssistantAnswerContentInCurrentTurn = info?.content || "";
|
|
10527
10539
|
}
|
|
10528
10540
|
}
|
|
10529
10541
|
return collapsed;
|
|
@@ -10603,13 +10615,17 @@ function computeReadChatSync(messages, cursor) {
|
|
|
10603
10615
|
};
|
|
10604
10616
|
}
|
|
10605
10617
|
if (cursor.tailLimit > 0 && knownSignature === lastMessageSignature) {
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10618
|
+
const requestedTailCount = Math.min(totalMessages, cursor.tailLimit);
|
|
10619
|
+
if (knownMessageCount >= requestedTailCount) {
|
|
10620
|
+
return {
|
|
10621
|
+
syncMode: "noop",
|
|
10622
|
+
replaceFrom: totalMessages,
|
|
10623
|
+
messages: [],
|
|
10624
|
+
totalMessages,
|
|
10625
|
+
lastMessageSignature
|
|
10626
|
+
};
|
|
10627
|
+
}
|
|
10628
|
+
return buildBoundedTailSync(messages, cursor);
|
|
10613
10629
|
}
|
|
10614
10630
|
if (knownMessageCount < totalMessages) {
|
|
10615
10631
|
const anchorSignature = getChatMessageSignature(messages[knownMessageCount - 1]);
|
|
@@ -13543,8 +13559,8 @@ var CliProviderInstance = class {
|
|
|
13543
13559
|
}
|
|
13544
13560
|
detectStatusTransition() {
|
|
13545
13561
|
const now = Date.now();
|
|
13546
|
-
const adapterStatus = this.adapter.getStatus();
|
|
13547
|
-
const parsedStatus =
|
|
13562
|
+
const adapterStatus = this.adapter.getStatus({ allowParse: false });
|
|
13563
|
+
const parsedStatus = null;
|
|
13548
13564
|
const rawStatus = adapterStatus.status;
|
|
13549
13565
|
const autoApproveActive = rawStatus === "waiting_approval" && this.shouldAutoApprove();
|
|
13550
13566
|
if (autoApproveActive && !this.autoApproveBusy) {
|
|
@@ -13637,7 +13653,7 @@ var CliProviderInstance = class {
|
|
|
13637
13653
|
this.completedDebouncePending = { chatTitle, duration, timestamp: now };
|
|
13638
13654
|
this.completedDebounceTimer = setTimeout(() => {
|
|
13639
13655
|
if (this.completedDebouncePending) {
|
|
13640
|
-
const latestStatus = this.adapter.getStatus();
|
|
13656
|
+
const latestStatus = this.adapter.getStatus({ allowParse: false });
|
|
13641
13657
|
const latestAutoApproveActive = latestStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
13642
13658
|
const latestVisibleStatus = latestAutoApproveActive ? "generating" : latestStatus.status;
|
|
13643
13659
|
if (latestVisibleStatus !== "idle") {
|