@causyne/agent 1.20.93 → 1.20.94
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 +28 -25
- package/src/agentLoop.ts +27 -24
- package/src/contextManager.js +2 -0
- package/src/historyPruner.js +16 -1
- package/src/historyPruner.ts +13 -1
- package/src/sandbox.js +18 -12
- package/src/tools/deferredMcpSearch.js +76 -38
- package/src/tools/deferredMcpSearch.ts +66 -28
- package/src/tools/readNativeSkill.js +34 -42
- package/src/tools/readNativeSkill.ts +38 -36
- package/src/tools/searchRelevance.js +70 -0
- package/src/tools/searchRelevance.ts +72 -0
- package/src/tools/toolSelfRepair.js +9 -4
- package/src/tools/toolSelfRepair.ts +9 -4
- package/src/tui/composerGeometry.js +45 -0
- package/src/tui/composerGeometry.ts +80 -0
- package/src/tui/homeView.js +10 -6
- package/src/tui/homeView.ts +10 -6
- package/src/tui/lineEditor.js +8 -0
- package/src/tui/prompt.js +9 -4
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Causyne composer geometry. This module owns column arithmetic, never I/O.
|
|
3
|
+
*
|
|
4
|
+
* `barBlock` consumes the left bar + gutter. A painted block is exactly
|
|
5
|
+
* `boxWidth` cells, but the editing surface must reserve a caret cell so a
|
|
6
|
+
* full row cannot position the terminal cursor in the clipped right margin.
|
|
7
|
+
*/
|
|
8
|
+
export interface ComposerGeometry {
|
|
9
|
+
boxWidth: number;
|
|
10
|
+
inset: number;
|
|
11
|
+
bodyWidth: number;
|
|
12
|
+
editorWidth: number;
|
|
13
|
+
maxCaretCol: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function composerGeometry(
|
|
17
|
+
requestedWidth: number,
|
|
18
|
+
barColumns: number,
|
|
19
|
+
gutterColumns: number
|
|
20
|
+
): ComposerGeometry {
|
|
21
|
+
const width = Number.isFinite(requestedWidth)
|
|
22
|
+
? Math.max(4, Math.trunc(requestedWidth))
|
|
23
|
+
: 80;
|
|
24
|
+
const boxWidth = width - 1; // never occupy the terminal's deferred-wrap cell
|
|
25
|
+
const glyph = Number.isFinite(barColumns) ? Math.max(0, Math.trunc(barColumns)) : 1;
|
|
26
|
+
const gutter = Number.isFinite(gutterColumns) ? Math.max(0, Math.trunc(gutterColumns)) : 1;
|
|
27
|
+
const inset = Math.min(glyph + gutter, Math.max(0, boxWidth - 2));
|
|
28
|
+
const bodyWidth = Math.max(1, boxWidth - inset);
|
|
29
|
+
const editorWidth = Math.max(1, bodyWidth - 1); // reserve a full cursor cell
|
|
30
|
+
return { boxWidth, inset, bodyWidth, editorWidth, maxCaretCol: boxWidth - 1 };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface FittedHomeContent {
|
|
34
|
+
/** Full banner, or none when the terminal cannot show it without clipping. */
|
|
35
|
+
logoRows: string[];
|
|
36
|
+
/** Composer rows kept as a contiguous window around the editing caret. */
|
|
37
|
+
promptRows: string[];
|
|
38
|
+
spacer: number;
|
|
39
|
+
caretRow: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* In a small terminal the editor is more important than the full brand banner.
|
|
44
|
+
* This helper never loses the caret or returns more rows than the Stage owns.
|
|
45
|
+
* The ordinary roomy Home composition is unchanged.
|
|
46
|
+
*/
|
|
47
|
+
export function fitHomeContent(
|
|
48
|
+
logoRows: readonly string[],
|
|
49
|
+
promptRows: readonly string[],
|
|
50
|
+
stageHeight: number,
|
|
51
|
+
caretRow: number,
|
|
52
|
+
requestedSpacer: number
|
|
53
|
+
): FittedHomeContent {
|
|
54
|
+
const available = Number.isFinite(stageHeight)
|
|
55
|
+
? Math.max(1, Math.trunc(stageHeight))
|
|
56
|
+
: 24;
|
|
57
|
+
const prompt = promptRows.length ? [...promptRows] : [''];
|
|
58
|
+
const caret = Number.isFinite(caretRow)
|
|
59
|
+
? Math.max(0, Math.min(prompt.length - 1, Math.trunc(caretRow)))
|
|
60
|
+
: 0;
|
|
61
|
+
const promptCount = Math.min(available, prompt.length);
|
|
62
|
+
const start = prompt.length > available
|
|
63
|
+
? Math.min(Math.max(0, caret - Math.floor(available / 2)), prompt.length - available)
|
|
64
|
+
: 0;
|
|
65
|
+
const visiblePrompt = prompt.slice(start, start + promptCount);
|
|
66
|
+
const remaining = available - visiblePrompt.length;
|
|
67
|
+
// A cropped rotor/wordmark looks broken. On cramped terminals, hide the
|
|
68
|
+
// banner as a whole rather than displaying an arbitrary bottom fragment.
|
|
69
|
+
const showLogo = logoRows.length > 0 && remaining >= logoRows.length;
|
|
70
|
+
const visibleLogo = showLogo ? [...logoRows] : [];
|
|
71
|
+
const spacer = showLogo
|
|
72
|
+
? Math.min(Math.max(0, Number.isFinite(requestedSpacer) ? Math.trunc(requestedSpacer) : 0), remaining - logoRows.length)
|
|
73
|
+
: 0;
|
|
74
|
+
return {
|
|
75
|
+
logoRows: visibleLogo,
|
|
76
|
+
promptRows: visiblePrompt,
|
|
77
|
+
spacer,
|
|
78
|
+
caretRow: Math.max(0, Math.min(visiblePrompt.length - 1, caret - start))
|
|
79
|
+
};
|
|
80
|
+
}
|
package/src/tui/homeView.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sessionBanner } from './banner.js';
|
|
2
2
|
import { centerRows } from './layout.js';
|
|
3
|
+
import { fitHomeContent } from './composerGeometry.js';
|
|
3
4
|
import { panelRows } from './overlay.js';
|
|
4
5
|
/** A modal before the first conversation belongs to the centered home view. */
|
|
5
6
|
export function isStartupDialog(surface) {
|
|
@@ -45,17 +46,20 @@ export function placeHome(info, promptRows, columns, height, caretRow, caretCol)
|
|
|
45
46
|
const available = Math.max(1, Math.floor(height));
|
|
46
47
|
const logo = centerRows(sessionBanner(info, columns, { height: available }), columns).rows;
|
|
47
48
|
const spacer = available >= 25 ? 2 : 1;
|
|
48
|
-
|
|
49
|
+
// When the window is short, preserve the composer and editing caret first.
|
|
50
|
+
// The logo yields height; it must never push a wrapped draft off-screen.
|
|
51
|
+
const fitted = fitHomeContent(logo, promptRows, available, caretRow, spacer);
|
|
52
|
+
const required = fitted.logoRows.length + fitted.spacer + fitted.promptRows.length;
|
|
49
53
|
const top = Math.max(0, Math.floor((available - required) / 2));
|
|
50
54
|
const rows = [
|
|
51
55
|
...Array(top).fill(''),
|
|
52
|
-
...
|
|
53
|
-
...Array(spacer).fill(''),
|
|
54
|
-
...promptRows
|
|
56
|
+
...fitted.logoRows,
|
|
57
|
+
...Array(fitted.spacer).fill(''),
|
|
58
|
+
...fitted.promptRows
|
|
55
59
|
];
|
|
56
60
|
return {
|
|
57
|
-
rows
|
|
58
|
-
caretRow:
|
|
61
|
+
rows,
|
|
62
|
+
caretRow: top + fitted.logoRows.length + fitted.spacer + fitted.caretRow,
|
|
59
63
|
caretCol: Math.max(0, Math.min(caretCol, columns - 2))
|
|
60
64
|
};
|
|
61
65
|
}
|
package/src/tui/homeView.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sessionBanner, type BannerInfo } from './banner.js';
|
|
2
2
|
import { centerRows } from './layout.js';
|
|
3
|
+
import { fitHomeContent } from './composerGeometry.js';
|
|
3
4
|
import { panelRows } from './overlay.js';
|
|
4
5
|
|
|
5
6
|
export interface PlacedView {
|
|
@@ -74,17 +75,20 @@ export function placeHome(
|
|
|
74
75
|
const available = Math.max(1, Math.floor(height));
|
|
75
76
|
const logo = centerRows(sessionBanner(info, columns, { height: available }), columns).rows;
|
|
76
77
|
const spacer = available >= 25 ? 2 : 1;
|
|
77
|
-
|
|
78
|
+
// When the window is short, preserve the composer and editing caret first.
|
|
79
|
+
// The logo yields height; it must never push a wrapped draft off-screen.
|
|
80
|
+
const fitted = fitHomeContent(logo, promptRows, available, caretRow, spacer);
|
|
81
|
+
const required = fitted.logoRows.length + fitted.spacer + fitted.promptRows.length;
|
|
78
82
|
const top = Math.max(0, Math.floor((available - required) / 2));
|
|
79
83
|
const rows = [
|
|
80
84
|
...Array<string>(top).fill(''),
|
|
81
|
-
...
|
|
82
|
-
...Array<string>(spacer).fill(''),
|
|
83
|
-
...promptRows
|
|
85
|
+
...fitted.logoRows,
|
|
86
|
+
...Array<string>(fitted.spacer).fill(''),
|
|
87
|
+
...fitted.promptRows
|
|
84
88
|
];
|
|
85
89
|
return {
|
|
86
|
-
rows
|
|
87
|
-
caretRow:
|
|
90
|
+
rows,
|
|
91
|
+
caretRow: top + fitted.logoRows.length + fitted.spacer + fitted.caretRow,
|
|
88
92
|
caretCol: Math.max(0, Math.min(caretCol, columns - 2))
|
|
89
93
|
};
|
|
90
94
|
}
|
package/src/tui/lineEditor.js
CHANGED
|
@@ -376,6 +376,14 @@ export class LineEditor {
|
|
|
376
376
|
while (pos <= line.length) {
|
|
377
377
|
if (pos === line.length) {
|
|
378
378
|
if (isCurrentLine && pos === this.col && !placed) {
|
|
379
|
+
// An exact-width final row has no cell after its last glyph.
|
|
380
|
+
// Move the caret onto an empty continuation row instead of
|
|
381
|
+
// positioning it outside the editing surface. Preserve text.
|
|
382
|
+
if (used >= budget && pos > 0) {
|
|
383
|
+
rows.push(row);
|
|
384
|
+
row = prefix;
|
|
385
|
+
used = 0;
|
|
386
|
+
}
|
|
379
387
|
cursorRow = rows.length;
|
|
380
388
|
cursorCol = prefixWidth + used;
|
|
381
389
|
placed = true;
|
package/src/tui/prompt.js
CHANGED
|
@@ -24,6 +24,7 @@ import { PromptHistory } from './history.js';
|
|
|
24
24
|
import { FileIndex, suggest, applyCompletion, detectTrigger, renderPicker, MAX_VISIBLE } from './completion.js';
|
|
25
25
|
import { paint, dim, bold, GLYPHS, terminalWidth, HAS_COLOR } from './theme.js';
|
|
26
26
|
import { barBlock, GUTTER } from './block.js';
|
|
27
|
+
import { composerGeometry } from './composerGeometry.js';
|
|
27
28
|
import { visibleWidth, truncate, wrapBlock, shortenHome, safeDisplay, stripAnsi } from './text.js';
|
|
28
29
|
import { pickExample, fitHints } from './banner.js';
|
|
29
30
|
import { panelRows } from './overlay.js';
|
|
@@ -1603,10 +1604,14 @@ export class ChatPrompt {
|
|
|
1603
1604
|
// surface you are writing INTO. Every row of the block is inset by the same
|
|
1604
1605
|
// gutter, so the caret column is a constant rather than a special case for
|
|
1605
1606
|
// row 0 — which is also one fewer thing for erase() to get wrong.
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
const
|
|
1607
|
+
// Reserve one editor cell for the caret. The left bar and gutter are
|
|
1608
|
+
// consumed by barBlock; the remaining full-width body is not all editable.
|
|
1609
|
+
// This prevents a full sentence from placing the cursor beyond the fill.
|
|
1610
|
+
const { boxWidth, inset, editorWidth } = composerGeometry(
|
|
1611
|
+
width, visibleWidth(GLYPHS.barHeavy || GLYPHS.bar), GUTTER
|
|
1612
|
+
);
|
|
1613
|
+
const inner = editorWidth;
|
|
1614
|
+
const layout = this.editor.render(editorWidth, '');
|
|
1610
1615
|
|
|
1611
1616
|
// Scroll the editor internally rather than growing without bound: keep a
|
|
1612
1617
|
// window of MAX_PROMPT_ROWS that always contains the caret.
|