@causyne/agent 1.20.103 → 1.20.105
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/package.json +1 -1
- package/src/agentLoop.js +20 -20
- package/src/agentLoop.ts +18 -21
- package/src/launchIntent.js +76 -16
- package/src/launchIntent.ts +75 -16
- package/src/observer/evidence.js +2 -1
- package/src/observer/evidence.ts +2 -1
- package/src/observer.js +39 -4
- package/src/observer.ts +35 -5
- package/src/timeMachine.js +20 -8
- package/src/timeMachine.ts +20 -8
- package/src/tools/gitExec.js +64 -24
- package/src/tui/chatRenderer.js +14 -6
- package/src/tui/sessionSidebar.js +30 -17
- package/src/tui/sessionSidebar.ts +27 -16
- package/src/tui/stageSurface.js +66 -12
package/src/tui/stageSurface.js
CHANGED
|
@@ -60,6 +60,44 @@ const RAIL_BUDGET = RAIL_WIDTH + 1;
|
|
|
60
60
|
// The interactive turn rail takes three columns at the left of each row.
|
|
61
61
|
const TURN_RAIL_BUDGET = 3;
|
|
62
62
|
|
|
63
|
+
// Count a prefix of terminal control sequences with a deterministic scan.
|
|
64
|
+
// This preserves CSI, OSC (BEL/ST), and two-byte ESC codes without regex
|
|
65
|
+
// backtracking on long or malformed terminal output.
|
|
66
|
+
export function leadingAnsiControlEnd(row) {
|
|
67
|
+
if (typeof row !== 'string') return 0;
|
|
68
|
+
let index = 0;
|
|
69
|
+
while (row.charCodeAt(index) === 27) {
|
|
70
|
+
let cursor = index + 1;
|
|
71
|
+
const kind = row.charCodeAt(cursor);
|
|
72
|
+
if (kind === 91) { // ESC [
|
|
73
|
+
cursor++;
|
|
74
|
+
while (row.charCodeAt(cursor) >= 48 && row.charCodeAt(cursor) <= 63) cursor++;
|
|
75
|
+
while (row.charCodeAt(cursor) >= 32 && row.charCodeAt(cursor) <= 47) cursor++;
|
|
76
|
+
const final = row.charCodeAt(cursor);
|
|
77
|
+
if (final >= 64 && final <= 126) {
|
|
78
|
+
index = cursor + 1;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
} else if (kind === 93) { // ESC ] ... BEL or ESC backslash
|
|
82
|
+
cursor++;
|
|
83
|
+
while (cursor < row.length && row.charCodeAt(cursor) !== 7 && row.charCodeAt(cursor) !== 27) cursor++;
|
|
84
|
+
if (row.charCodeAt(cursor) === 7) {
|
|
85
|
+
index = cursor + 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (row.charCodeAt(cursor) === 27 && row.charCodeAt(cursor + 1) === 92) {
|
|
89
|
+
index = cursor + 2;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
} else if ((kind >= 64 && kind <= 90) || (kind >= 92 && kind <= 95)) {
|
|
93
|
+
index = cursor + 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
return index;
|
|
99
|
+
}
|
|
100
|
+
|
|
63
101
|
// Which marker wins when several frames fall in the same rail row. A proportional
|
|
64
102
|
// rail on a long session compresses dozens of frames per row, and what you want
|
|
65
103
|
// to see at a glance is the thing that went wrong or the thing you can roll back
|
|
@@ -207,13 +245,13 @@ export class StageSurface {
|
|
|
207
245
|
|
|
208
246
|
composeAvailableWidth() {
|
|
209
247
|
if (this.homeInfo) return this.width;
|
|
210
|
-
return sessionMainWidth(this.width);
|
|
248
|
+
return sessionMainWidth(this.width, false, this.env);
|
|
211
249
|
}
|
|
212
250
|
|
|
213
251
|
/** Home is compact; a session uses its full conversation column. */
|
|
214
252
|
composeWidth() {
|
|
215
253
|
if (this.homeInfo) return composerWidth(this.width);
|
|
216
|
-
const mainWidth = sessionMainWidth(this.width);
|
|
254
|
+
const mainWidth = sessionMainWidth(this.width, false, this.env);
|
|
217
255
|
return sessionComposerWidth(mainWidth);
|
|
218
256
|
}
|
|
219
257
|
|
|
@@ -375,7 +413,7 @@ export class StageSurface {
|
|
|
375
413
|
handleChange() {
|
|
376
414
|
if (!this.transcript.isEmpty()) this.opened = true;
|
|
377
415
|
const before = this.lastHeight;
|
|
378
|
-
const mainWidth = sessionMainWidth(this.width);
|
|
416
|
+
const mainWidth = sessionMainWidth(this.width, false, this.env);
|
|
379
417
|
const contentWidth = this.railEnabled(mainWidth)
|
|
380
418
|
? Math.max(20, mainWidth - RAIL_BUDGET - (hasSessionTurns(this.transcript) ? TURN_RAIL_BUDGET : 0))
|
|
381
419
|
: mainWidth;
|
|
@@ -428,8 +466,8 @@ export class StageSurface {
|
|
|
428
466
|
}
|
|
429
467
|
|
|
430
468
|
const width = this.width;
|
|
431
|
-
const sidebar = sidebarVisible(width);
|
|
432
|
-
const mainWidth = sessionMainWidth(width);
|
|
469
|
+
const sidebar = sidebarVisible(width, false, this.env);
|
|
470
|
+
const mainWidth = sessionMainWidth(width, false, this.env);
|
|
433
471
|
const rail = this.railEnabled(mainWidth);
|
|
434
472
|
const contentWidth = rail
|
|
435
473
|
? Math.max(20, mainWidth - RAIL_BUDGET - (hasSessionTurns(this.transcript) ? TURN_RAIL_BUDGET : 0))
|
|
@@ -478,6 +516,16 @@ export class StageSurface {
|
|
|
478
516
|
if (budget > 0) {
|
|
479
517
|
this.viewport.resize({ height: budget, width: contentWidth });
|
|
480
518
|
rows = alignTranscriptRows(this.viewport.rows(), contentRows);
|
|
519
|
+
// In follow mode, the viewport can land on the blank separator between
|
|
520
|
+
// two assistant frames after enough replies to fill the band. Show a
|
|
521
|
+
// subtle boundary marker in that same row instead of a visible void.
|
|
522
|
+
// Do not shift row indices: rails, hover targets and reading anchors
|
|
523
|
+
// are keyed to the original transcript row positions.
|
|
524
|
+
if (this.viewport.following && this.viewport.maxScrollTop() > 0
|
|
525
|
+
&& rows.length > 0 && stripAnsi(rows[0] || '').trim() === ''
|
|
526
|
+
&& rows.some(row => stripAnsi(row).trim() !== '')) {
|
|
527
|
+
rows[0] = paint('rule', ` ${GLYPHS.dot} `);
|
|
528
|
+
}
|
|
481
529
|
this.decorate(rows, contentWidth);
|
|
482
530
|
markHoveredMessage(rows, this, contentWidth);
|
|
483
531
|
if (rail) this.attachRail(rows, contentWidth);
|
|
@@ -627,12 +675,18 @@ export class StageSurface {
|
|
|
627
675
|
this.close();
|
|
628
676
|
return false;
|
|
629
677
|
}
|
|
630
|
-
//
|
|
631
|
-
|
|
678
|
+
// A width-only resize must not collapse and re-claim the whole session.
|
|
679
|
+
// Claiming fresh lines on every drag scrolls the transcript and leaves
|
|
680
|
+
// obsolete sidebar columns behind during the 160-column breakpoint.
|
|
681
|
+
// The existing rows are already reserved: repaint them in place with
|
|
682
|
+
// their new width, clearing trailing cells through Stage.paint().
|
|
683
|
+
if (!this.stage.reserved || next !== this.stage.maxHeight) {
|
|
684
|
+
this.stage.resize(next, 1);
|
|
685
|
+
}
|
|
632
686
|
this.stage.invalidate();
|
|
633
687
|
// Re-derive from the new geometry: growing the viewport lowers maxScrollTop,
|
|
634
688
|
// and leaving scrollTop above it would read as "the user scrolled away".
|
|
635
|
-
const mainWidth = sessionMainWidth(this.width);
|
|
689
|
+
const mainWidth = sessionMainWidth(this.width, false, this.env);
|
|
636
690
|
const contentWidth = this.railEnabled(mainWidth)
|
|
637
691
|
? Math.max(20, mainWidth - RAIL_BUDGET - (hasSessionTurns(this.transcript) ? TURN_RAIL_BUDGET : 0))
|
|
638
692
|
: mainWidth;
|
|
@@ -728,10 +782,10 @@ export class StageSurface {
|
|
|
728
782
|
let row = rows[i] || '';
|
|
729
783
|
if (hasTurns && railResult) {
|
|
730
784
|
const leftCell = railResult.cells[i] || ' ';
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
const leadEscapes =
|
|
734
|
-
row = `${leadEscapes} ${leftCell} ${row.slice(
|
|
785
|
+
const leadEnd = leadingAnsiControlEnd(row);
|
|
786
|
+
if (row.slice(leadEnd, leadEnd + 3) === ' ') {
|
|
787
|
+
const leadEscapes = row.slice(0, leadEnd);
|
|
788
|
+
row = `${leadEscapes} ${leftCell} ${row.slice(leadEnd + 3)}`;
|
|
735
789
|
} else if (stripAnsi(row).length === 0) {
|
|
736
790
|
row = leftCell !== ' ' ? ` ${leftCell} ` : '';
|
|
737
791
|
} else {
|