@causyne/agent 1.20.62 → 1.20.65
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/README.md +2 -2
- package/package.json +1 -1
- package/src/acp/client.js +48 -0
- package/src/acp/client.ts +44 -0
- package/src/agentLoop.js +181 -11
- package/src/agentLoop.ts +184 -11
- package/src/approvalPolicy.js +19 -0
- package/src/approvalPolicy.ts +18 -0
- package/src/browser/causyneBrowser.js +34 -4
- package/src/browser/causyneBrowser.ts +32 -4
- package/src/cliMode.js +12 -28
- package/src/commands.js +33 -0
- package/src/decisionPolicy.js +18 -1
- package/src/decisionPolicy.ts +18 -1
- package/src/implementationPlan.js +26 -0
- package/src/implementationPlan.ts +25 -0
- package/src/observer/coldObserver.js +6 -1
- package/src/observer/coldObserver.ts +6 -1
- package/src/observer.js +24 -2
- package/src/observer.ts +24 -2
- package/src/providers/acp.js +2 -8
- package/src/providers/acp.ts +2 -8
- package/src/providers/antigravity.js +7 -10
- package/src/providers/antigravity.ts +7 -10
- package/src/smartToolsUse.js +1 -1
- package/src/smartToolsUse.ts +1 -1
- package/src/toolPacks.js +1 -1
- package/src/toolPacks.ts +1 -1
- package/src/tools/toolSelfRepair.js +51 -8
- package/src/tools/toolSelfRepair.ts +42 -9
- package/src/tui/CausyneRotor.js +234 -0
- package/src/tui/CausyneRotor.ts +280 -0
- package/src/tui/activityLayout.js +1 -1
- package/src/tui/activityLayout.ts +1 -1
- package/src/tui/chatRenderer.js +56 -7
- package/src/tui/chatboxClipboard.js +96 -10
- package/src/tui/chatboxClipboard.ts +121 -11
- package/src/tui/clipboardImage.js +308 -0
- package/src/tui/clipboardImage.ts +320 -0
- package/src/tui/codeStreamRenderer.js +89 -1
- package/src/tui/codeStreamRenderer.ts +109 -1
- package/src/tui/composerControls.js +2 -0
- package/src/tui/composerControls.ts +2 -0
- package/src/tui/dialogs.js +41 -6
- package/src/tui/engineSpinner.js +20 -0
- package/src/tui/engineSpinner.ts +46 -0
- package/src/tui/lineEditor.js +44 -12
- package/src/tui/messageInteraction.js +16 -5
- package/src/tui/messageInteraction.ts +14 -5
- package/src/tui/observerPicker.js +4 -8
- package/src/tui/observerPicker.ts +4 -8
- package/src/tui/prompt.js +80 -43
- package/src/tui/runningLight.js +213 -0
- package/src/tui/runningLight.ts +271 -0
- package/src/tui/sessionSidebar.js +7 -1
- package/src/tui/sessionSidebar.ts +7 -1
- package/src/tui/stage.js +4 -4
- package/src/tui/stageSurface.js +21 -14
- package/src/tui/statusLine.js +27 -4
- package/src/tui/statusLine.ts +27 -4
- package/src/tui/theme.js +5 -2
- package/src/tui/thinkingBox.js +41 -10
- package/src/tui/thinkingBox.ts +43 -10
- package/src/tui/turnRail.js +155 -24
- package/src/tui/turnRail.ts +170 -22
package/src/tui/turnRail.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface TurnRailLayout {
|
|
|
19
19
|
viewportHeight: number;
|
|
20
20
|
dotRows: Map<number, number>; // turnIndex -> screenY
|
|
21
21
|
rowToTurn: Map<number, number>; // screenY -> turnIndex
|
|
22
|
+
turns?: SessionTurn[];
|
|
23
|
+
cardRect?: { x: number; y: number; width: number; height: number; turnIndex: number } | null;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export function formatTurnTimestamp(ts: number): string {
|
|
@@ -100,7 +102,7 @@ export function collectSessionTurns(transcript: any, contentWidth = 80): Session
|
|
|
100
102
|
turnIndex,
|
|
101
103
|
totalTurns,
|
|
102
104
|
userPrompt: userPrompt.replace(/\s+/g, ' ').trim(),
|
|
103
|
-
assistantSummary: assistantSummary
|
|
105
|
+
assistantSummary: formatPreviewCardMarkdown(assistantSummary),
|
|
104
106
|
timestamp: frame.ts || Date.now(),
|
|
105
107
|
formattedDate: formatTurnTimestamp(frame.ts || Date.now()),
|
|
106
108
|
frameId: frame.id,
|
|
@@ -251,6 +253,65 @@ export function buildTurnRailCells(
|
|
|
251
253
|
return { cells, layout: { dotRows, rowToTurn } };
|
|
252
254
|
}
|
|
253
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Render and clean markdown for display within the Floating Turn Preview Card.
|
|
258
|
+
* Strips raw syntax markers (###, **, *, `, table delimiters) and renders
|
|
259
|
+
* clean, readable, professional text without leaking markdown source code.
|
|
260
|
+
*/
|
|
261
|
+
export function formatPreviewCardMarkdown(raw: string): string {
|
|
262
|
+
if (!raw) return '';
|
|
263
|
+
let text = String(raw);
|
|
264
|
+
|
|
265
|
+
// Strip code block fences
|
|
266
|
+
text = text.replace(/```[a-zA-Z0-9_-]*\n?/g, ' ');
|
|
267
|
+
|
|
268
|
+
// Strip headings: ### Heading -> Heading
|
|
269
|
+
text = text.replace(/(?:^|\n)\s*#{1,6}\s+/g, '\n');
|
|
270
|
+
|
|
271
|
+
// Strip blockquotes: > quote -> quote
|
|
272
|
+
text = text.replace(/(?:^|\n)\s*>\s?/g, '\n');
|
|
273
|
+
|
|
274
|
+
// Strip horizontal rules: --- or ***
|
|
275
|
+
text = text.replace(/(?:^|\n)\s*[-*_]{3,}\s*(?=\n|$)/g, '\n');
|
|
276
|
+
|
|
277
|
+
// Strip table separator lines: | :--- | :--- |
|
|
278
|
+
text = text.replace(/(?:^|\n)\s*\|?(\s*:?-+:?\s*\|)+\s*(?=\n|$)/g, '\n');
|
|
279
|
+
|
|
280
|
+
// Convert table row pipes: | a | b | -> a · b
|
|
281
|
+
text = text.replace(/(?:^|\n)\s*\|\s*(.+?)\s*\|\s*(?=\n|$)/g, (_m, content) => {
|
|
282
|
+
return '\n' + content.split(/\s*\|\s*/).filter(Boolean).join(' · ');
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Convert list bullets: - item, * item -> • item
|
|
286
|
+
text = text.replace(/(?:^|\n)\s*[-*+]\s+/g, '\n• ');
|
|
287
|
+
|
|
288
|
+
// Convert numbered lists: 1. item -> 1. item
|
|
289
|
+
text = text.replace(/(?:^|\n)\s*(\d+)\.\s+/g, '\n$1. ');
|
|
290
|
+
|
|
291
|
+
// Strip links: [label](url) -> label
|
|
292
|
+
text = text.replace(/\[([^\]\n]+)\]\([^\)\s]+\)/g, '$1');
|
|
293
|
+
|
|
294
|
+
// Strip images:  -> alt
|
|
295
|
+
text = text.replace(/!\[([^\]\n]*)\]\([^\)\s]+\)/g, '$1');
|
|
296
|
+
|
|
297
|
+
// Strip inline code backticks: `code` -> code
|
|
298
|
+
text = text.replace(/`([^`\n]+)`/g, '$1');
|
|
299
|
+
|
|
300
|
+
// Format bold and italic: ***text***, **text**, *text*, ___text___, __text__, _text_
|
|
301
|
+
text = text.replace(/\*\*\*([^*]+)\*\*\*/g, '$1');
|
|
302
|
+
text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
|
|
303
|
+
text = text.replace(/(?:^|[^*])\*([^*]+)\*(?!\*)/g, (m, inner) => m.startsWith('*') ? inner : `${m[0]}${inner}`);
|
|
304
|
+
text = text.replace(/___([^_]+)___/g, '$1');
|
|
305
|
+
text = text.replace(/__([^_]+)__/g, '$1');
|
|
306
|
+
text = text.replace(/(?:^|[^_])_([^_]+)_(?!_)/g, (m, inner) => m.startsWith('_') ? inner : `${m[0]}${inner}`);
|
|
307
|
+
|
|
308
|
+
// Strip strikethrough: ~~text~~ -> text
|
|
309
|
+
text = text.replace(/~~([^~]+)~~/g, '$1');
|
|
310
|
+
|
|
311
|
+
// Collapse multiple spaces/newlines cleanly into single space
|
|
312
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
313
|
+
}
|
|
314
|
+
|
|
254
315
|
/**
|
|
255
316
|
* Render the Floating Turn Preview Card popover.
|
|
256
317
|
* Exactly matches the UX/UI in Screen Recording 2026-10-30 at 02.42.17:
|
|
@@ -267,17 +328,18 @@ export function renderTurnPreviewCard(turn: SessionTurn, maxCardWidth = 50): str
|
|
|
267
328
|
const borderStyle = `${cardBg}\x1b[38;2;75;75;82m`;
|
|
268
329
|
const reset = '\x1b[0m';
|
|
269
330
|
|
|
270
|
-
// Format header: User Prompt (bold primary)
|
|
271
|
-
const rawPrompt = turn.userPrompt || 'User request';
|
|
272
|
-
const promptLines = wrapBlock(rawPrompt, innerWidth).slice(0, 2);
|
|
331
|
+
// Format header: User Prompt (bold primary) rendered cleanly without raw markdown, strictly flush-left with hang: 0
|
|
332
|
+
const rawPrompt = formatPreviewCardMarkdown(turn.userPrompt || 'User request');
|
|
333
|
+
const promptLines = wrapBlock(rawPrompt, innerWidth, { hang: 0 }).slice(0, 2);
|
|
273
334
|
if (promptLines.length === 2 && promptLines[1]) {
|
|
274
335
|
promptLines[1] = truncate(promptLines[1], innerWidth - 3, '...');
|
|
275
336
|
}
|
|
276
337
|
|
|
277
|
-
// Format body: Assistant Summary (muted secondary)
|
|
338
|
+
// Format body: Assistant Summary (muted secondary) rendered cleanly without raw markdown, strictly flush-left with hang: 0
|
|
278
339
|
let bodyLines: string[] = [];
|
|
279
340
|
if (turn.assistantSummary) {
|
|
280
|
-
|
|
341
|
+
const formattedSummary = formatPreviewCardMarkdown(turn.assistantSummary);
|
|
342
|
+
bodyLines = wrapBlock(formattedSummary, innerWidth, { hang: 0 }).slice(0, 3);
|
|
281
343
|
if (bodyLines.length === 3 && bodyLines[2]) {
|
|
282
344
|
bodyLines[2] = truncate(bodyLines[2], innerWidth - 3, '...');
|
|
283
345
|
}
|
|
@@ -335,10 +397,11 @@ export function overlayTurnPreviewCard(
|
|
|
335
397
|
if (cardRows.length === 0 || viewportRows.length === 0) return viewportRows;
|
|
336
398
|
|
|
337
399
|
const cardWidth = visibleWidth(cardRows[0] || '');
|
|
338
|
-
// Clamp card placement horizontally:
|
|
400
|
+
// Clamp card placement horizontally: flush-left with transcript baseline at column 3
|
|
401
|
+
const cardSpacing = 2; // railX + 2 gives x = 3, perfectly flush left with transcript content
|
|
339
402
|
let x = railX - cardWidth - 1;
|
|
340
|
-
if (x < 0 || (railX <= 4 && railX +
|
|
341
|
-
x = Math.max(0, Math.min(screenWidth - cardWidth - 1, railX +
|
|
403
|
+
if (x < 0 || (railX <= 4 && railX + cardSpacing + cardWidth <= screenWidth)) {
|
|
404
|
+
x = Math.max(0, Math.min(screenWidth - cardWidth - 1, railX + cardSpacing));
|
|
342
405
|
}
|
|
343
406
|
|
|
344
407
|
// Center vertically around anchorY
|
|
@@ -354,10 +417,39 @@ export function overlayTurnPreviewCard(
|
|
|
354
417
|
const baseRow = out[targetY] || '';
|
|
355
418
|
const cardRow = cardRows[i] || '';
|
|
356
419
|
|
|
357
|
-
// Composite cardRow onto baseRow at column x
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
420
|
+
// Composite cardRow onto baseRow at column x.
|
|
421
|
+
// To the left of the card, NEVER allow severed underlying characters (like '▸' or text) to leak!
|
|
422
|
+
// Maintain a perfectly clean, flush, symmetrical margin:
|
|
423
|
+
// Only preserve the rail dot (if present at railX) and whitespace padding up to column x.
|
|
424
|
+
let beforePart = '';
|
|
425
|
+
if (x <= 6 && railX <= 4) {
|
|
426
|
+
const plainBase = stripAnsi(baseRow);
|
|
427
|
+
const dotChar = plainBase[railX] || ' ';
|
|
428
|
+
const isDot = dotChar === '●' || dotChar === '•' || dotChar === '·' || dotChar === '[' || dotChar === ']';
|
|
429
|
+
let dotCell = ' ';
|
|
430
|
+
if (isDot) {
|
|
431
|
+
const sliceDot = sliceFromColumn(baseRow, railX);
|
|
432
|
+
dotCell = sliceDot ? truncate(sliceDot, 1, '') : dotChar;
|
|
433
|
+
}
|
|
434
|
+
const leadingSpace = ' '.repeat(Math.max(0, railX));
|
|
435
|
+
const trailingSpace = ' '.repeat(Math.max(0, x - railX - 1));
|
|
436
|
+
beforePart = `${leadingSpace}${dotCell}${trailingSpace}`;
|
|
437
|
+
} else {
|
|
438
|
+
beforePart = padEnd(truncate(baseRow, x, ''), x);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
let restOfRow = '';
|
|
442
|
+
if (x <= 6) {
|
|
443
|
+
// For left-placed turn cards, do not leave severed text tails sticking out
|
|
444
|
+
const totalRowWidth = Math.max(screenWidth, visibleWidth(baseRow));
|
|
445
|
+
const rightCell = sliceFromColumn(baseRow, totalRowWidth - 1);
|
|
446
|
+
const rightCellWidth = visibleWidth(rightCell);
|
|
447
|
+
const gap = Math.max(0, totalRowWidth - x - cardWidth - rightCellWidth);
|
|
448
|
+
restOfRow = `${' '.repeat(gap)}${rightCell}`;
|
|
449
|
+
} else {
|
|
450
|
+
restOfRow = sliceFromColumn(baseRow, x + cardWidth);
|
|
451
|
+
}
|
|
452
|
+
out[targetY] = `${beforePart}${cardRow}${restOfRow}`;
|
|
361
453
|
}
|
|
362
454
|
|
|
363
455
|
return out;
|
|
@@ -388,27 +480,72 @@ export function handleTurnRailMouse(
|
|
|
388
480
|
? (mouseX >= 0 && mouseX <= Math.max(3, layout.railX + 2))
|
|
389
481
|
: (mouseX >= layout.railX - 1 && mouseX <= layout.railX + 2);
|
|
390
482
|
|
|
391
|
-
if
|
|
483
|
+
// Check if currently showing a card and mouse is hovering over the card or bridge tunnel
|
|
484
|
+
const hasActiveCard = surface.hoveredTurnIndex !== null && surface.hoveredTurnIndex !== undefined;
|
|
485
|
+
let isCard = false;
|
|
486
|
+
let isBridge = false;
|
|
487
|
+
|
|
488
|
+
if (hasActiveCard) {
|
|
489
|
+
const cardRect = layout.cardRect;
|
|
490
|
+
if (cardRect && cardRect.turnIndex === surface.hoveredTurnIndex) {
|
|
491
|
+
isCard = mouseX >= cardRect.x && mouseX < cardRect.x + cardRect.width &&
|
|
492
|
+
relY >= cardRect.y && relY < cardRect.y + cardRect.height;
|
|
493
|
+
isBridge = layout.railX <= 4 &&
|
|
494
|
+
mouseX >= 0 && mouseX < cardRect.x &&
|
|
495
|
+
relY >= cardRect.y && relY < cardRect.y + cardRect.height;
|
|
496
|
+
} else {
|
|
497
|
+
const cardWidth = 52;
|
|
498
|
+
const cardX = layout.railX <= 4 ? layout.railX + 2 : Math.max(0, layout.railX - cardWidth - 1);
|
|
499
|
+
const anchorY = surface.hoveredTurnAnchorY ?? Math.floor(layout.viewportHeight / 2);
|
|
500
|
+
const cardHeight = 9;
|
|
501
|
+
const cardStartY = Math.max(0, Math.min(layout.viewportHeight - cardHeight, anchorY - Math.floor(cardHeight / 2)));
|
|
502
|
+
const cardEndY = cardStartY + cardHeight;
|
|
503
|
+
|
|
504
|
+
isCard = mouseX >= cardX && mouseX < cardX + cardWidth &&
|
|
505
|
+
relY >= cardStartY && relY < cardEndY;
|
|
506
|
+
isBridge = layout.railX <= 4 &&
|
|
507
|
+
mouseX >= 0 && mouseX < cardX &&
|
|
508
|
+
relY >= cardStartY && relY < cardEndY;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const inHoverZone = isRail || isCard || isBridge;
|
|
513
|
+
|
|
514
|
+
if (!inHoverZone || relY < 0 || relY >= layout.viewportHeight) {
|
|
392
515
|
surface.turnRailHoverSuppressed = false;
|
|
393
516
|
if (surface.hoveredTurnIndex !== null && surface.hoveredTurnIndex !== undefined) {
|
|
394
|
-
surface.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
517
|
+
if (!surface._turnCardLeaveTimer) {
|
|
518
|
+
surface._turnCardLeaveTimer = setTimeout(() => {
|
|
519
|
+
surface._turnCardLeaveTimer = null;
|
|
520
|
+
if (surface.hoveredTurnIndex !== null && surface.hoveredTurnIndex !== undefined) {
|
|
521
|
+
surface.hoveredTurnIndex = null;
|
|
522
|
+
surface.hoveredTurnAnchorY = null;
|
|
523
|
+
if (typeof host?.scheduleDraw === 'function') host.scheduleDraw();
|
|
524
|
+
else if (typeof host?.draw === 'function') host.draw();
|
|
525
|
+
}
|
|
526
|
+
}, 120);
|
|
527
|
+
}
|
|
398
528
|
}
|
|
399
529
|
return false;
|
|
400
530
|
}
|
|
401
531
|
|
|
532
|
+
// Inside hover zone - cancel any pending leave timer
|
|
533
|
+
if (surface._turnCardLeaveTimer) {
|
|
534
|
+
clearTimeout(surface._turnCardLeaveTimer);
|
|
535
|
+
surface._turnCardLeaveTimer = null;
|
|
536
|
+
}
|
|
537
|
+
|
|
402
538
|
// If hover is temporarily suppressed after a click, swallow rail mouse events until suppression ends
|
|
403
539
|
if (surface.turnRailHoverSuppressed) {
|
|
404
540
|
return true;
|
|
405
541
|
}
|
|
406
542
|
|
|
407
|
-
|
|
543
|
+
// Rail takes precedence when mouse is on the rail track
|
|
544
|
+
let turnNum = isRail ? layout.rowToTurn?.get(relY) : ((isCard || isBridge) ? surface.hoveredTurnIndex : undefined);
|
|
408
545
|
let anchorY = relY;
|
|
409
546
|
|
|
410
|
-
// If not an exact row hit, resolve closest dot within proximity
|
|
411
|
-
if (!turnNum && layout.dotRows && layout.dotRows.size > 0) {
|
|
547
|
+
// If on rail and not an exact row hit, resolve closest dot within proximity
|
|
548
|
+
if (!turnNum && isRail && layout.dotRows && layout.dotRows.size > 0) {
|
|
412
549
|
let minDistance = Infinity;
|
|
413
550
|
let closestTurn: number | undefined;
|
|
414
551
|
let closestRow: number | undefined;
|
|
@@ -422,7 +559,7 @@ export function handleTurnRailMouse(
|
|
|
422
559
|
}
|
|
423
560
|
}
|
|
424
561
|
|
|
425
|
-
if (minDistance <=
|
|
562
|
+
if (minDistance <= 1 && closestTurn !== undefined && closestRow !== undefined) {
|
|
426
563
|
turnNum = closestTurn;
|
|
427
564
|
anchorY = closestRow;
|
|
428
565
|
}
|
|
@@ -430,6 +567,17 @@ export function handleTurnRailMouse(
|
|
|
430
567
|
|
|
431
568
|
if (turnNum) {
|
|
432
569
|
if (isMouseMotion(event.sequence)) {
|
|
570
|
+
// While a turn is streaming, a hover card would sit on top of live output
|
|
571
|
+
// (thinking, code edits, tool frames). Clicking a dot still navigates.
|
|
572
|
+
if (host?.busy) {
|
|
573
|
+
if (surface.hoveredTurnIndex !== null && surface.hoveredTurnIndex !== undefined) {
|
|
574
|
+
surface.hoveredTurnIndex = null;
|
|
575
|
+
surface.hoveredTurnAnchorY = null;
|
|
576
|
+
if (typeof host?.scheduleDraw === 'function') host.scheduleDraw();
|
|
577
|
+
else if (typeof host?.draw === 'function') host.draw();
|
|
578
|
+
}
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
433
581
|
if (surface.hoveredTurnIndex !== turnNum) {
|
|
434
582
|
surface.hoveredTurnIndex = turnNum;
|
|
435
583
|
surface.hoveredTurnAnchorY = anchorY;
|