@adhdev/daemon-core 0.9.43 → 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
package/package.json
CHANGED
|
@@ -171,6 +171,74 @@ export function appendBoundedText(current: string, chunk: string, maxChars: numb
|
|
|
171
171
|
return current.slice(-keepFromCurrent) + chunk;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
const COMMITTED_ACTIVITY_PREFIX_BLOCK_RE = /^(?:📖|💻|🔎|📚|📋|✏️|📝|🔧|🛠️|⚙️)\s+(.+)$/;
|
|
175
|
+
|
|
176
|
+
function isLikelyCommittedActivityPrefixContinuation(line: string): boolean {
|
|
177
|
+
const trimmed = String(line || '').trim();
|
|
178
|
+
if (!trimmed) return false;
|
|
179
|
+
if (COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(trimmed)) return false;
|
|
180
|
+
if (/\s/.test(trimmed)) return false;
|
|
181
|
+
if (/[가-힣]/.test(trimmed)) return false;
|
|
182
|
+
if (trimmed.length > 96) return false;
|
|
183
|
+
return /^[A-Za-z0-9_./:@+%=-]+$/.test(trimmed);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function parseCommittedActivityPrefixBlock(lines: string[], index: number): { label: string; nextIndex: number } | null {
|
|
187
|
+
const first = String(lines[index] || '').trim();
|
|
188
|
+
if (!COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(first)) return null;
|
|
189
|
+
const parts = [first];
|
|
190
|
+
let nextIndex = index + 1;
|
|
191
|
+
while (nextIndex < lines.length && isLikelyCommittedActivityPrefixContinuation(lines[nextIndex])) {
|
|
192
|
+
parts.push(String(lines[nextIndex] || '').trim());
|
|
193
|
+
nextIndex += 1;
|
|
194
|
+
}
|
|
195
|
+
return { label: parts.join(''), nextIndex };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function sanitizeCliStandardMessageContent(content: unknown): string {
|
|
199
|
+
const source = String(content || '').trim();
|
|
200
|
+
if (!source) return '';
|
|
201
|
+
const lines = source.split(/\r?\n/);
|
|
202
|
+
if (lines.length < 4) return source;
|
|
203
|
+
|
|
204
|
+
const counts = new Map<string, number>();
|
|
205
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
206
|
+
const block = parseCommittedActivityPrefixBlock(lines, index);
|
|
207
|
+
if (!block) continue;
|
|
208
|
+
counts.set(block.label, (counts.get(block.label) || 0) + 1);
|
|
209
|
+
index = block.nextIndex - 1;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const repeatedLabels = new Set(
|
|
213
|
+
Array.from(counts.entries())
|
|
214
|
+
.filter(([, count]) => count >= 3)
|
|
215
|
+
.map(([label]) => label),
|
|
216
|
+
);
|
|
217
|
+
if (repeatedLabels.size === 0) return source;
|
|
218
|
+
|
|
219
|
+
const stripped: string[] = [];
|
|
220
|
+
let removed = 0;
|
|
221
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
222
|
+
const block = parseCommittedActivityPrefixBlock(lines, index);
|
|
223
|
+
if (block && repeatedLabels.has(block.label)) {
|
|
224
|
+
removed += 1;
|
|
225
|
+
index = block.nextIndex - 1;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
stripped.push(lines[index]);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const next = stripped.join('\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
232
|
+
return removed >= 3 && next.length >= 80 ? next : source;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function sanitizeCommittedMessageForDisplay<T extends { role?: string; kind?: string; content?: unknown }>(message: T): T {
|
|
236
|
+
if (!message || message.role !== 'assistant' || (message.kind || 'standard') !== 'standard') return message;
|
|
237
|
+
const content = sanitizeCliStandardMessageContent(message.content);
|
|
238
|
+
if (content === message.content) return message;
|
|
239
|
+
return { ...message, content };
|
|
240
|
+
}
|
|
241
|
+
|
|
174
242
|
// ─── Adapter ────────────────────────────────────────
|
|
175
243
|
|
|
176
244
|
export class ProviderCliAdapter implements CliAdapter {
|
|
@@ -400,7 +468,12 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
400
468
|
const tailFirst = parseBaseMessages[0];
|
|
401
469
|
if (tailFirst && this.messagesComparable(parsedFirst, tailFirst)) {
|
|
402
470
|
const prefixLength = fullBaseMessages.length - parseBaseMessages.length;
|
|
403
|
-
|
|
471
|
+
const prefix = fullBaseMessages.slice(0, prefixLength);
|
|
472
|
+
const shouldSanitizePrefix = !!this.currentTurnScope || this.currentStatus !== 'idle' || !!this.activeModal;
|
|
473
|
+
const nextPrefix = shouldSanitizePrefix
|
|
474
|
+
? prefix.map((message) => sanitizeCommittedMessageForDisplay(message))
|
|
475
|
+
: prefix;
|
|
476
|
+
return [...nextPrefix, ...parsedMessages];
|
|
404
477
|
}
|
|
405
478
|
|
|
406
479
|
return [...fullBaseMessages, ...parsedMessages];
|
|
@@ -1808,10 +1881,14 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1808
1881
|
|
|
1809
1882
|
private buildCommittedChatMessages(): any[] {
|
|
1810
1883
|
return this.committedMessages.map((message, index) => {
|
|
1811
|
-
const
|
|
1884
|
+
const rawContentValue = message.content;
|
|
1885
|
+
const rawContent = typeof rawContentValue === 'string' ? rawContentValue : String(rawContentValue || '');
|
|
1886
|
+
const content = message.role === 'assistant' && (message.kind || 'standard') === 'standard'
|
|
1887
|
+
? sanitizeCliStandardMessageContent(rawContent)
|
|
1888
|
+
: rawContent;
|
|
1812
1889
|
return buildChatMessage({
|
|
1813
1890
|
role: message.role,
|
|
1814
|
-
content
|
|
1891
|
+
content,
|
|
1815
1892
|
timestamp: message.timestamp,
|
|
1816
1893
|
kind: message.kind,
|
|
1817
1894
|
meta: message.meta,
|