@adhdev/daemon-core 0.9.42 → 0.9.44
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-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/index.js +68 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -5
- 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 +80 -3
|
@@ -23,6 +23,7 @@ type SeedCliChatMessage = Omit<Partial<CliChatMessage>, 'role'> & {
|
|
|
23
23
|
content?: string;
|
|
24
24
|
};
|
|
25
25
|
export declare function appendBoundedText(current: string, chunk: string, maxChars: number): string;
|
|
26
|
+
export declare function sanitizeCliStandardMessageContent(content: unknown): string;
|
|
26
27
|
export declare class ProviderCliAdapter implements CliAdapter {
|
|
27
28
|
private extraArgs;
|
|
28
29
|
readonly cliType: string;
|
package/dist/index.js
CHANGED
|
@@ -2058,7 +2058,8 @@ var provider_cli_adapter_exports = {};
|
|
|
2058
2058
|
__export(provider_cli_adapter_exports, {
|
|
2059
2059
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
2060
2060
|
appendBoundedText: () => appendBoundedText,
|
|
2061
|
-
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
|
|
2061
|
+
normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime,
|
|
2062
|
+
sanitizeCliStandardMessageContent: () => sanitizeCliStandardMessageContent
|
|
2062
2063
|
});
|
|
2063
2064
|
function normalizeComparableTranscriptText(value) {
|
|
2064
2065
|
return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
|
|
@@ -2098,7 +2099,63 @@ function appendBoundedText(current, chunk, maxChars) {
|
|
|
2098
2099
|
if (current.length <= keepFromCurrent) return current + chunk;
|
|
2099
2100
|
return current.slice(-keepFromCurrent) + chunk;
|
|
2100
2101
|
}
|
|
2101
|
-
|
|
2102
|
+
function isLikelyCommittedActivityPrefixContinuation(line) {
|
|
2103
|
+
const trimmed = String(line || "").trim();
|
|
2104
|
+
if (!trimmed) return false;
|
|
2105
|
+
if (COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(trimmed)) return false;
|
|
2106
|
+
if (/\s/.test(trimmed)) return false;
|
|
2107
|
+
if (/[가-힣]/.test(trimmed)) return false;
|
|
2108
|
+
if (trimmed.length > 96) return false;
|
|
2109
|
+
return /^[A-Za-z0-9_./:@+%=-]+$/.test(trimmed);
|
|
2110
|
+
}
|
|
2111
|
+
function parseCommittedActivityPrefixBlock(lines, index) {
|
|
2112
|
+
const first = String(lines[index] || "").trim();
|
|
2113
|
+
if (!COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(first)) return null;
|
|
2114
|
+
const parts = [first];
|
|
2115
|
+
let nextIndex = index + 1;
|
|
2116
|
+
while (nextIndex < lines.length && isLikelyCommittedActivityPrefixContinuation(lines[nextIndex])) {
|
|
2117
|
+
parts.push(String(lines[nextIndex] || "").trim());
|
|
2118
|
+
nextIndex += 1;
|
|
2119
|
+
}
|
|
2120
|
+
return { label: parts.join(""), nextIndex };
|
|
2121
|
+
}
|
|
2122
|
+
function sanitizeCliStandardMessageContent(content) {
|
|
2123
|
+
const source = String(content || "").trim();
|
|
2124
|
+
if (!source) return "";
|
|
2125
|
+
const lines = source.split(/\r?\n/);
|
|
2126
|
+
if (lines.length < 4) return source;
|
|
2127
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2128
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
2129
|
+
const block = parseCommittedActivityPrefixBlock(lines, index);
|
|
2130
|
+
if (!block) continue;
|
|
2131
|
+
counts.set(block.label, (counts.get(block.label) || 0) + 1);
|
|
2132
|
+
index = block.nextIndex - 1;
|
|
2133
|
+
}
|
|
2134
|
+
const repeatedLabels = new Set(
|
|
2135
|
+
Array.from(counts.entries()).filter(([, count]) => count >= 3).map(([label]) => label)
|
|
2136
|
+
);
|
|
2137
|
+
if (repeatedLabels.size === 0) return source;
|
|
2138
|
+
const stripped = [];
|
|
2139
|
+
let removed = 0;
|
|
2140
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
2141
|
+
const block = parseCommittedActivityPrefixBlock(lines, index);
|
|
2142
|
+
if (block && repeatedLabels.has(block.label)) {
|
|
2143
|
+
removed += 1;
|
|
2144
|
+
index = block.nextIndex - 1;
|
|
2145
|
+
continue;
|
|
2146
|
+
}
|
|
2147
|
+
stripped.push(lines[index]);
|
|
2148
|
+
}
|
|
2149
|
+
const next = stripped.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
2150
|
+
return removed >= 3 && next.length >= 80 ? next : source;
|
|
2151
|
+
}
|
|
2152
|
+
function sanitizeCommittedMessageForDisplay(message) {
|
|
2153
|
+
if (!message || message.role !== "assistant" || (message.kind || "standard") !== "standard") return message;
|
|
2154
|
+
const content = sanitizeCliStandardMessageContent(message.content);
|
|
2155
|
+
if (content === message.content) return message;
|
|
2156
|
+
return { ...message, content };
|
|
2157
|
+
}
|
|
2158
|
+
var os10, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
|
|
2102
2159
|
var init_provider_cli_adapter = __esm({
|
|
2103
2160
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
2104
2161
|
"use strict";
|
|
@@ -2114,6 +2171,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2114
2171
|
init_provider_cli_config();
|
|
2115
2172
|
init_provider_cli_runtime();
|
|
2116
2173
|
init_provider_cli_shared();
|
|
2174
|
+
COMMITTED_ACTIVITY_PREFIX_BLOCK_RE = /^(?:📖|💻|🔎|📚|📋|✏️|📝|🔧|🛠️|⚙️)\s+(.+)$/;
|
|
2117
2175
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
2118
2176
|
constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
|
|
2119
2177
|
this.extraArgs = extraArgs;
|
|
@@ -2325,7 +2383,10 @@ var init_provider_cli_adapter = __esm({
|
|
|
2325
2383
|
const tailFirst = parseBaseMessages[0];
|
|
2326
2384
|
if (tailFirst && this.messagesComparable(parsedFirst, tailFirst)) {
|
|
2327
2385
|
const prefixLength = fullBaseMessages.length - parseBaseMessages.length;
|
|
2328
|
-
|
|
2386
|
+
const prefix = fullBaseMessages.slice(0, prefixLength);
|
|
2387
|
+
const shouldSanitizePrefix = !!this.currentTurnScope || this.currentStatus !== "idle" || !!this.activeModal;
|
|
2388
|
+
const nextPrefix = shouldSanitizePrefix ? prefix.map((message) => sanitizeCommittedMessageForDisplay(message)) : prefix;
|
|
2389
|
+
return [...nextPrefix, ...parsedMessages];
|
|
2329
2390
|
}
|
|
2330
2391
|
return [...fullBaseMessages, ...parsedMessages];
|
|
2331
2392
|
}
|
|
@@ -3524,10 +3585,12 @@ var init_provider_cli_adapter = __esm({
|
|
|
3524
3585
|
}
|
|
3525
3586
|
buildCommittedChatMessages() {
|
|
3526
3587
|
return this.committedMessages.map((message, index) => {
|
|
3527
|
-
const
|
|
3588
|
+
const rawContentValue = message.content;
|
|
3589
|
+
const rawContent = typeof rawContentValue === "string" ? rawContentValue : String(rawContentValue || "");
|
|
3590
|
+
const content = message.role === "assistant" && (message.kind || "standard") === "standard" ? sanitizeCliStandardMessageContent(rawContent) : rawContent;
|
|
3528
3591
|
return buildChatMessage({
|
|
3529
3592
|
role: message.role,
|
|
3530
|
-
content
|
|
3593
|
+
content,
|
|
3531
3594
|
timestamp: message.timestamp,
|
|
3532
3595
|
kind: message.kind,
|
|
3533
3596
|
meta: message.meta,
|