@causyne/agent 1.20.60 → 1.20.63
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/agentCatalog.js +1 -1
- package/src/acp/agentCatalog.ts +1 -1
- package/src/acp/client.js +48 -0
- package/src/acp/client.ts +44 -0
- package/src/acp/peerProfiles.js +3 -3
- package/src/acp/peerProfiles.ts +3 -3
- package/src/agentLoop.js +239 -33
- package/src/agentLoop.ts +248 -36
- package/src/checkpoints.js +23 -5
- package/src/cliMode.js +13 -2
- package/src/commands.js +534 -78
- package/src/contextManager.d.ts +3 -0
- package/src/contextManager.js +78 -5
- package/src/cortex/autoCondenser.js +105 -145
- package/src/cortex/autoCondenser.ts +185 -0
- package/src/cortex/cortexEngine.js +179 -0
- package/src/cortex/cortexEngine.ts +209 -0
- package/src/cortex/provisioner.js +12 -14
- package/src/cortex/provisioner.ts +29 -0
- package/src/cortex/vectorDb.js +307 -386
- package/src/cortex/vectorDb.ts +473 -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/reporting.js +30 -7
- package/src/sessionJournal.js +13 -0
- package/src/sessionJournal.ts +13 -0
- package/src/smartToolsUse.js +1 -1
- package/src/smartToolsUse.ts +1 -1
- package/src/tokenTracker.js +22 -0
- package/src/tokenTracker.ts +28 -0
- 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 +62 -9
- 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/completion.js +34 -15
- package/src/tui/composerControls.js +5 -0
- package/src/tui/composerControls.ts +5 -0
- package/src/tui/dialogs.js +5 -2
- package/src/tui/engineSpinner.js +20 -0
- package/src/tui/engineSpinner.ts +46 -0
- package/src/tui/layout.js +1 -1
- package/src/tui/layout.ts +1 -1
- 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 +319 -0
- package/src/tui/observerPicker.ts +382 -0
- package/src/tui/prompt.js +247 -55
- 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 +27 -10
- 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/usageCard.js +178 -0
- package/src/tui/usageCard.ts +240 -0
- package/src/utils/paths.js +30 -1
- package/src/utils/paths.ts +32 -1
- package/src/cortex/autoCondenser.d.ts +0 -2
- package/src/cortex/vectorDb.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatRenderer } from './chatRenderer.js';
|
|
2
2
|
import { CODE_PANEL_LINES, codePreviewLineCount, defaultPreviewStart, renderCodeProgress } from './codeProgress.js';
|
|
3
|
-
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES } from './thinkingBox.js';
|
|
3
|
+
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES, renderThinkingFrame } from './thinkingBox.js';
|
|
4
|
+
import { formatElapsed } from './statusLine.js';
|
|
4
5
|
import { markerAt } from './messageInteraction.js';
|
|
5
6
|
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
6
7
|
function lastStart(event) {
|
|
@@ -12,7 +13,63 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
12
13
|
modelNote = '';
|
|
13
14
|
lastReasoning = '';
|
|
14
15
|
currentActivity = 'thinking';
|
|
16
|
+
streamingNowMs = 320;
|
|
17
|
+
streamingTick = undefined;
|
|
15
18
|
codePanels = new WeakMap();
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(options);
|
|
21
|
+
const status = this.status;
|
|
22
|
+
if (status) {
|
|
23
|
+
status.onTick = (nowMs, tick) => {
|
|
24
|
+
this.onStatusTick(nowMs, tick);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Synchronizes the active streaming thinking frame with the live status clock
|
|
30
|
+
* so the running-light shimmer advances smoothly across both surfaces.
|
|
31
|
+
*/
|
|
32
|
+
onStatusTick(nowMs, tick) {
|
|
33
|
+
this.streamingNowMs = nowMs;
|
|
34
|
+
this.streamingTick = tick;
|
|
35
|
+
const transcript = this.transcript;
|
|
36
|
+
if (!transcript || !Array.isArray(transcript.frames))
|
|
37
|
+
return;
|
|
38
|
+
const tail = transcript.frames.at(-1);
|
|
39
|
+
if (tail?.meta?.reasoning === true && tail.meta.streaming === true) {
|
|
40
|
+
if (nowMs > 0) {
|
|
41
|
+
tail.meta.durationText = formatElapsed(nowMs);
|
|
42
|
+
}
|
|
43
|
+
tail.rows = null;
|
|
44
|
+
tail.renderedWidth = -1;
|
|
45
|
+
transcript.cache = null;
|
|
46
|
+
transcript.revision++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
renderReasoning(content, options = {}) {
|
|
50
|
+
const width = this.measure();
|
|
51
|
+
const isStreaming = Boolean(options.streaming);
|
|
52
|
+
const resolvedTick = options.tick ?? this.streamingTick;
|
|
53
|
+
const rows = renderThinkingFrame(content, {
|
|
54
|
+
width,
|
|
55
|
+
streaming: isStreaming,
|
|
56
|
+
durationText: options.durationText ?? '',
|
|
57
|
+
collapsed: Boolean(options.collapsed),
|
|
58
|
+
startLine: Number(options.startLine) || 0,
|
|
59
|
+
...(options.activity !== undefined ? { activity: options.activity } : {}),
|
|
60
|
+
...(options.title !== undefined ? { title: options.title } : {}),
|
|
61
|
+
...(options.completedTitle !== undefined ? { completedTitle: options.completedTitle } : {}),
|
|
62
|
+
...(isStreaming ? { nowMs: options.nowMs ?? this.streamingNowMs } : {}),
|
|
63
|
+
...(isStreaming && resolvedTick !== undefined ? { tick: resolvedTick } : {})
|
|
64
|
+
});
|
|
65
|
+
if (rows.length === 0)
|
|
66
|
+
return;
|
|
67
|
+
this.write();
|
|
68
|
+
for (const row of rows) {
|
|
69
|
+
this.write(row);
|
|
70
|
+
}
|
|
71
|
+
this.write();
|
|
72
|
+
}
|
|
16
73
|
/** Scroll only the code beneath the pointer; leave the chat viewport alone. */
|
|
17
74
|
scrollCodePanel(key, surface) {
|
|
18
75
|
const wheel = key?.wheel;
|
|
@@ -128,6 +185,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
128
185
|
}
|
|
129
186
|
}
|
|
130
187
|
handle(message) {
|
|
188
|
+
const selfStatus = this;
|
|
131
189
|
if (message?.type === 'agent_activity') {
|
|
132
190
|
const rawActivity = String(message.activity || message.message || '').trim();
|
|
133
191
|
if (rawActivity) {
|
|
@@ -139,8 +197,18 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
139
197
|
activity: this.currentActivity,
|
|
140
198
|
title: rawActivity
|
|
141
199
|
});
|
|
200
|
+
if (selfStatus.quietStatus) {
|
|
201
|
+
selfStatus.currentStatus = rawActivity;
|
|
202
|
+
selfStatus.onStatusChange?.(rawActivity);
|
|
203
|
+
}
|
|
142
204
|
return true;
|
|
143
205
|
}
|
|
206
|
+
const handled = super.handle(message);
|
|
207
|
+
if (selfStatus.quietStatus) {
|
|
208
|
+
selfStatus.currentStatus = rawActivity;
|
|
209
|
+
selfStatus.onStatusChange?.(rawActivity);
|
|
210
|
+
}
|
|
211
|
+
return handled;
|
|
144
212
|
}
|
|
145
213
|
}
|
|
146
214
|
if (message?.type === 'notice' && message.nativeStep === true) {
|
|
@@ -165,6 +233,11 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
165
233
|
activity = 'planning';
|
|
166
234
|
}
|
|
167
235
|
this.currentActivity = activity;
|
|
236
|
+
if (selfStatus.quietStatus) {
|
|
237
|
+
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
238
|
+
selfStatus.currentStatus = statusLabel;
|
|
239
|
+
selfStatus.onStatusChange?.(statusLabel);
|
|
240
|
+
}
|
|
168
241
|
const currentContent = this.lastReasoning ? `${this.lastReasoning}\n${stepLine}` : stepLine;
|
|
169
242
|
this.lastReasoning = currentContent;
|
|
170
243
|
super.onAgentReasoning({
|
|
@@ -198,6 +271,7 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
198
271
|
}
|
|
199
272
|
return true;
|
|
200
273
|
}
|
|
274
|
+
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
201
275
|
const handled = super.handle({
|
|
202
276
|
...message,
|
|
203
277
|
activity: message.activity || this.currentActivity
|
|
@@ -205,6 +279,20 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
205
279
|
if (message.streaming === false) {
|
|
206
280
|
this.lastReasoning = '';
|
|
207
281
|
}
|
|
282
|
+
else if (selfStatus.quietStatus) {
|
|
283
|
+
const activeStatus = preservedStatus || `${this.currentActivity || 'thinking'}…`;
|
|
284
|
+
selfStatus.currentStatus = activeStatus;
|
|
285
|
+
selfStatus.onStatusChange?.(activeStatus);
|
|
286
|
+
}
|
|
287
|
+
return handled;
|
|
288
|
+
}
|
|
289
|
+
if (message?.type === 'usage_update' && selfStatus.quietStatus) {
|
|
290
|
+
const preservedStatus = selfStatus.currentStatus;
|
|
291
|
+
const handled = super.handle(message);
|
|
292
|
+
if (preservedStatus) {
|
|
293
|
+
selfStatus.currentStatus = preservedStatus;
|
|
294
|
+
selfStatus.onStatusChange?.(preservedStatus);
|
|
295
|
+
}
|
|
208
296
|
return handled;
|
|
209
297
|
}
|
|
210
298
|
if (['agent_message', 'budget_warning', 'step_start', 'task_complete', 'error', 'agent_plan'].includes(message?.type || '')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatRenderer } from './chatRenderer.js';
|
|
2
2
|
import { CODE_PANEL_LINES, codePreviewLineCount, defaultPreviewStart, renderCodeProgress, type CodeProgressEvent } from './codeProgress.js';
|
|
3
|
-
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES } from './thinkingBox.js';
|
|
3
|
+
import { calculateThinkingLineCount, DEFAULT_MAX_EXPANDED_LINES, renderThinkingFrame } from './thinkingBox.js';
|
|
4
|
+
import { formatElapsed, type StatusLine } from './statusLine.js';
|
|
4
5
|
import { markerAt } from './messageInteraction.js';
|
|
5
6
|
import { AdaptiveWheelDampener } from './scrollInteraction.js';
|
|
6
7
|
|
|
@@ -37,8 +38,80 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
37
38
|
private modelNote = '';
|
|
38
39
|
private lastReasoning = '';
|
|
39
40
|
private currentActivity = 'thinking';
|
|
41
|
+
private streamingNowMs = 320;
|
|
42
|
+
private streamingTick: number | undefined = undefined;
|
|
40
43
|
private readonly codePanels = new WeakMap<CodeFrame, CodePanelState>();
|
|
41
44
|
|
|
45
|
+
constructor(options?: Record<string, unknown>) {
|
|
46
|
+
super(options);
|
|
47
|
+
const status = (this as unknown as { status?: StatusLine }).status;
|
|
48
|
+
if (status) {
|
|
49
|
+
status.onTick = (nowMs: number, tick?: number) => {
|
|
50
|
+
this.onStatusTick(nowMs, tick);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Synchronizes the active streaming thinking frame with the live status clock
|
|
57
|
+
* so the running-light shimmer advances smoothly across both surfaces.
|
|
58
|
+
*/
|
|
59
|
+
onStatusTick(nowMs: number, tick?: number): void {
|
|
60
|
+
this.streamingNowMs = nowMs;
|
|
61
|
+
this.streamingTick = tick;
|
|
62
|
+
const transcript = this.transcript as unknown as CodeTranscript | null;
|
|
63
|
+
if (!transcript || !Array.isArray(transcript.frames)) return;
|
|
64
|
+
const tail = transcript.frames.at(-1);
|
|
65
|
+
if (tail?.meta?.reasoning === true && tail.meta.streaming === true) {
|
|
66
|
+
if (nowMs > 0) {
|
|
67
|
+
tail.meta.durationText = formatElapsed(nowMs);
|
|
68
|
+
}
|
|
69
|
+
tail.rows = null;
|
|
70
|
+
tail.renderedWidth = -1;
|
|
71
|
+
transcript.cache = null;
|
|
72
|
+
transcript.revision++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override renderReasoning(
|
|
77
|
+
content: string,
|
|
78
|
+
options: {
|
|
79
|
+
streaming?: boolean;
|
|
80
|
+
durationText?: string;
|
|
81
|
+
collapsed?: boolean;
|
|
82
|
+
startLine?: number;
|
|
83
|
+
activity?: string;
|
|
84
|
+
title?: string;
|
|
85
|
+
completedTitle?: string;
|
|
86
|
+
nowMs?: number;
|
|
87
|
+
tick?: number;
|
|
88
|
+
} = {}
|
|
89
|
+
): void {
|
|
90
|
+
const width = this.measure();
|
|
91
|
+
const isStreaming = Boolean(options.streaming);
|
|
92
|
+
const resolvedTick = options.tick ?? this.streamingTick;
|
|
93
|
+
const rows = renderThinkingFrame(content, {
|
|
94
|
+
width,
|
|
95
|
+
streaming: isStreaming,
|
|
96
|
+
durationText: options.durationText ?? '',
|
|
97
|
+
collapsed: Boolean(options.collapsed),
|
|
98
|
+
startLine: Number(options.startLine) || 0,
|
|
99
|
+
...(options.activity !== undefined ? { activity: options.activity } : {}),
|
|
100
|
+
...(options.title !== undefined ? { title: options.title } : {}),
|
|
101
|
+
...(options.completedTitle !== undefined ? { completedTitle: options.completedTitle } : {}),
|
|
102
|
+
...(isStreaming ? { nowMs: options.nowMs ?? this.streamingNowMs } : {}),
|
|
103
|
+
...(isStreaming && resolvedTick !== undefined ? { tick: resolvedTick } : {})
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (rows.length === 0) return;
|
|
107
|
+
|
|
108
|
+
this.write();
|
|
109
|
+
for (const row of rows) {
|
|
110
|
+
this.write(row);
|
|
111
|
+
}
|
|
112
|
+
this.write();
|
|
113
|
+
}
|
|
114
|
+
|
|
42
115
|
/** Scroll only the code beneath the pointer; leave the chat viewport alone. */
|
|
43
116
|
scrollCodePanel(key: CodeWheel, surface: CodeSurface | null): boolean {
|
|
44
117
|
const wheel = key?.wheel;
|
|
@@ -154,6 +227,12 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
154
227
|
}
|
|
155
228
|
|
|
156
229
|
override handle(message: RendererEvent): boolean {
|
|
230
|
+
const selfStatus = this as unknown as {
|
|
231
|
+
quietStatus?: boolean;
|
|
232
|
+
currentStatus?: string;
|
|
233
|
+
onStatusChange?: ((s: string) => void) | null;
|
|
234
|
+
};
|
|
235
|
+
|
|
157
236
|
if (message?.type === 'agent_activity') {
|
|
158
237
|
const rawActivity = String((message as any).activity || (message as any).message || '').trim();
|
|
159
238
|
if (rawActivity) {
|
|
@@ -165,8 +244,18 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
165
244
|
activity: this.currentActivity,
|
|
166
245
|
title: rawActivity
|
|
167
246
|
});
|
|
247
|
+
if (selfStatus.quietStatus) {
|
|
248
|
+
selfStatus.currentStatus = rawActivity;
|
|
249
|
+
selfStatus.onStatusChange?.(rawActivity);
|
|
250
|
+
}
|
|
168
251
|
return true;
|
|
169
252
|
}
|
|
253
|
+
const handled = super.handle(message);
|
|
254
|
+
if (selfStatus.quietStatus) {
|
|
255
|
+
selfStatus.currentStatus = rawActivity;
|
|
256
|
+
selfStatus.onStatusChange?.(rawActivity);
|
|
257
|
+
}
|
|
258
|
+
return handled;
|
|
170
259
|
}
|
|
171
260
|
}
|
|
172
261
|
|
|
@@ -188,6 +277,11 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
188
277
|
activity = 'planning';
|
|
189
278
|
}
|
|
190
279
|
this.currentActivity = activity;
|
|
280
|
+
if (selfStatus.quietStatus) {
|
|
281
|
+
const statusLabel = `${activity.charAt(0).toUpperCase() + activity.slice(1)}…`;
|
|
282
|
+
selfStatus.currentStatus = statusLabel;
|
|
283
|
+
selfStatus.onStatusChange?.(statusLabel);
|
|
284
|
+
}
|
|
191
285
|
|
|
192
286
|
const currentContent = this.lastReasoning ? `${this.lastReasoning}\n${stepLine}` : stepLine;
|
|
193
287
|
this.lastReasoning = currentContent;
|
|
@@ -223,12 +317,26 @@ export class CodeStreamRenderer extends ChatRenderer {
|
|
|
223
317
|
}
|
|
224
318
|
return true;
|
|
225
319
|
}
|
|
320
|
+
const preservedStatus = selfStatus.quietStatus ? selfStatus.currentStatus : '';
|
|
226
321
|
const handled = super.handle({
|
|
227
322
|
...message,
|
|
228
323
|
activity: (message as any).activity || this.currentActivity
|
|
229
324
|
});
|
|
230
325
|
if (message.streaming === false) {
|
|
231
326
|
this.lastReasoning = '';
|
|
327
|
+
} else if (selfStatus.quietStatus) {
|
|
328
|
+
const activeStatus = preservedStatus || `${this.currentActivity || 'thinking'}…`;
|
|
329
|
+
selfStatus.currentStatus = activeStatus;
|
|
330
|
+
selfStatus.onStatusChange?.(activeStatus);
|
|
331
|
+
}
|
|
332
|
+
return handled;
|
|
333
|
+
}
|
|
334
|
+
if (message?.type === 'usage_update' && selfStatus.quietStatus) {
|
|
335
|
+
const preservedStatus = selfStatus.currentStatus;
|
|
336
|
+
const handled = super.handle(message);
|
|
337
|
+
if (preservedStatus) {
|
|
338
|
+
selfStatus.currentStatus = preservedStatus;
|
|
339
|
+
selfStatus.onStatusChange?.(preservedStatus);
|
|
232
340
|
}
|
|
233
341
|
return handled;
|
|
234
342
|
}
|
package/src/tui/completion.js
CHANGED
|
@@ -106,6 +106,9 @@ function rank(items, query, limit = 50, focusDir = null) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (value >= 0) {
|
|
109
|
+
if (item.isCommand) {
|
|
110
|
+
value += 2000;
|
|
111
|
+
}
|
|
109
112
|
if (focusPrefix && val.toLowerCase().startsWith(focusPrefix)) {
|
|
110
113
|
value += 3000;
|
|
111
114
|
}
|
|
@@ -131,7 +134,7 @@ const ARGUMENT_LIMIT = 500;
|
|
|
131
134
|
// `/` commands
|
|
132
135
|
// ---------------------------------------------------------------------------
|
|
133
136
|
|
|
134
|
-
function commandItems() {
|
|
137
|
+
function commandItems(query = '') {
|
|
135
138
|
// Suggested/high-frequency commands prioritized at the top on a bare '/' (OpenCode architecture)
|
|
136
139
|
const SUGGESTED_ORDER = ['model', 'sessions', 'new', 'clear', 'continuum', 'help', 'status', 'setup', 'mcp'];
|
|
137
140
|
const allCommands = listCommands('terminal');
|
|
@@ -157,27 +160,43 @@ function commandItems() {
|
|
|
157
160
|
match: command.name,
|
|
158
161
|
aliases: Array.isArray(command.aliases) ? command.aliases.filter(isTerminalSafe) : [],
|
|
159
162
|
label: primaryLabel,
|
|
160
|
-
description: sanitize(command.description || '')
|
|
163
|
+
description: sanitize(command.description || ''),
|
|
164
|
+
isCommand: true
|
|
161
165
|
});
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
// On a bare '/' (no query entered), keep the menu purely focused on genuine slash commands.
|
|
170
|
+
// Skills belong in `/skills` and must never pollute the top-level palette.
|
|
171
|
+
if (!query) {
|
|
172
|
+
return commands;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// When a user explicitly searches for a skill keyword (e.g. `/docker`), offer matching skills,
|
|
176
|
+
// but commands always retain strict priority in ranking.
|
|
177
|
+
//
|
|
178
|
+
// Skills match only on a CONTIGUOUS piece of their own id, and only once the
|
|
179
|
+
// query is long enough to mean something. Loose subsequence matching over
|
|
180
|
+
// "id + domain" let `/p` and `/plu` pull 70+ unrelated skills into the
|
|
181
|
+
// command palette ("... 72 more"), burying the command being typed.
|
|
182
|
+
const needle = query.toLowerCase();
|
|
183
|
+
if (needle.length < SKILL_QUERY_MIN) return commands;
|
|
184
|
+
const skills = listSkillsForCompletion()
|
|
185
|
+
.filter((skill) => String(skill.id || '').toLowerCase().includes(needle))
|
|
186
|
+
.map((skill) => ({
|
|
187
|
+
value: `/skills ${skill.domain}/${skill.id}`,
|
|
188
|
+
match: skill.id,
|
|
189
|
+
label: `/${skill.id}`,
|
|
190
|
+
description: sanitize(skill.description || ''),
|
|
191
|
+
isCommand: false
|
|
192
|
+
}));
|
|
175
193
|
|
|
176
|
-
// Commands first: on a bare `/` every entry scores 0, and a stable sort then
|
|
177
|
-
// leaves the real commands above the library.
|
|
178
194
|
return commands.concat(skills);
|
|
179
195
|
}
|
|
180
196
|
|
|
197
|
+
// Below this many characters a query is still a command prefix, not a skill search.
|
|
198
|
+
const SKILL_QUERY_MIN = 3;
|
|
199
|
+
|
|
181
200
|
/**
|
|
182
201
|
* A command's own argument suggestions.
|
|
183
202
|
*
|
|
@@ -401,7 +420,7 @@ export function suggest(text, cursor, options = {}) {
|
|
|
401
420
|
if (!trigger) return null;
|
|
402
421
|
|
|
403
422
|
if (trigger.kind === 'command') {
|
|
404
|
-
const items = rank(commandItems(), trigger.query);
|
|
423
|
+
const items = rank(commandItems(trigger.query), trigger.query);
|
|
405
424
|
if (items.length === 0) return null;
|
|
406
425
|
return { ...trigger, items, total: items.total };
|
|
407
426
|
}
|
|
@@ -130,6 +130,11 @@ export function handlePromptEscape(prompt, formatInterruptedRow) {
|
|
|
130
130
|
prompt.scheduleDraw();
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
+
if (prompt.usageCard) {
|
|
134
|
+
prompt.usageCard = null;
|
|
135
|
+
prompt.scheduleDraw();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
133
138
|
if (prompt.completion) {
|
|
134
139
|
prompt.completion = null;
|
|
135
140
|
if (prompt.editor.getText().startsWith('/')) {
|
|
@@ -183,6 +183,11 @@ export function handlePromptEscape(
|
|
|
183
183
|
prompt.scheduleDraw();
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
+
if ((prompt as any).usageCard) {
|
|
187
|
+
(prompt as any).usageCard = null;
|
|
188
|
+
prompt.scheduleDraw();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
186
191
|
if (prompt.completion) {
|
|
187
192
|
prompt.completion = null;
|
|
188
193
|
if (prompt.editor.getText().startsWith('/')) {
|
package/src/tui/dialogs.js
CHANGED
|
@@ -77,8 +77,11 @@ export class SelectLayer extends Layer {
|
|
|
77
77
|
const item = this.list.current;
|
|
78
78
|
this.settled = true;
|
|
79
79
|
const result = this.onPick ? this.onPick(item) : null;
|
|
80
|
-
if (result === 'keep'
|
|
81
|
-
|
|
80
|
+
if (result === 'keep' || result === 'handled') {
|
|
81
|
+
this.settled = false;
|
|
82
|
+
return 'handled';
|
|
83
|
+
}
|
|
84
|
+
return 'close';
|
|
82
85
|
}
|
|
83
86
|
if (action === 'cancel') return 'close';
|
|
84
87
|
return action ? 'handled' : null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Spinner Adapter for CausyneRotor.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the terminal spinner interfaces directly to CausyneRotor.ts.
|
|
5
|
+
*/
|
|
6
|
+
export { renderCausyneRotor, startCausyneRotor, getRotorSpinnerFrames, getRotorSpinnerFrame, getAnimatedDots, formatAnimatedStatus, COLORS, } from './CausyneRotor.js';
|
|
7
|
+
import { getRotorSpinnerFrames, getRotorSpinnerFrame, } from './CausyneRotor.js';
|
|
8
|
+
export function detectSpinnerStyle() {
|
|
9
|
+
return 'turbine';
|
|
10
|
+
}
|
|
11
|
+
export function getEngineFrames(options = {}) {
|
|
12
|
+
const unicode = options.unicode !== false;
|
|
13
|
+
const color = options.color !== false && options.color !== 'none';
|
|
14
|
+
return getRotorSpinnerFrames(color, unicode);
|
|
15
|
+
}
|
|
16
|
+
export function getEngineFrame(tick, options = {}) {
|
|
17
|
+
const unicode = options.unicode !== false;
|
|
18
|
+
const color = options.color !== false && options.color !== 'none';
|
|
19
|
+
return getRotorSpinnerFrame(tick, color, unicode);
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Spinner Adapter for CausyneRotor.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the terminal spinner interfaces directly to CausyneRotor.ts.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
renderCausyneRotor,
|
|
9
|
+
startCausyneRotor,
|
|
10
|
+
getRotorSpinnerFrames,
|
|
11
|
+
getRotorSpinnerFrame,
|
|
12
|
+
getAnimatedDots,
|
|
13
|
+
formatAnimatedStatus,
|
|
14
|
+
COLORS,
|
|
15
|
+
type RotorMotion,
|
|
16
|
+
type RotorOptions,
|
|
17
|
+
} from './CausyneRotor.js';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
getRotorSpinnerFrames,
|
|
21
|
+
getRotorSpinnerFrame,
|
|
22
|
+
} from './CausyneRotor.js';
|
|
23
|
+
|
|
24
|
+
export type EngineSpinnerStyle = 'turbine' | 'iris' | 'reactor' | 'compact' | 'ascii';
|
|
25
|
+
|
|
26
|
+
export interface EngineSpinnerOptions {
|
|
27
|
+
style?: EngineSpinnerStyle | undefined;
|
|
28
|
+
unicode?: boolean | undefined;
|
|
29
|
+
color?: boolean | 'truecolor' | '256' | '16' | 'none' | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function detectSpinnerStyle(): EngineSpinnerStyle {
|
|
33
|
+
return 'turbine';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getEngineFrames(options: EngineSpinnerOptions = {}): readonly string[] {
|
|
37
|
+
const unicode = options.unicode !== false;
|
|
38
|
+
const color = options.color !== false && options.color !== 'none';
|
|
39
|
+
return getRotorSpinnerFrames(color, unicode);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getEngineFrame(tick: number, options: EngineSpinnerOptions = {}): string {
|
|
43
|
+
const unicode = options.unicode !== false;
|
|
44
|
+
const color = options.color !== false && options.color !== 'none';
|
|
45
|
+
return getRotorSpinnerFrame(tick, color, unicode);
|
|
46
|
+
}
|
package/src/tui/layout.js
CHANGED
|
@@ -15,7 +15,7 @@ export function centerRows(rows, columns) {
|
|
|
15
15
|
/** Conversation content starts at the left margin while Home stays centered. */
|
|
16
16
|
export function sessionRows(rows, columns) {
|
|
17
17
|
const available = Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 80;
|
|
18
|
-
const inset = Math.min(
|
|
18
|
+
const inset = Math.min(3, Math.max(0, available - 3));
|
|
19
19
|
const prefix = ' '.repeat(inset);
|
|
20
20
|
return {
|
|
21
21
|
rows: rows.map(row => row ? prefix + truncate(row, Math.max(1, available - inset - 1), '') : ''),
|
package/src/tui/layout.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function centerRows(rows: string[], columns: number): { rows: string[]; i
|
|
|
18
18
|
/** Conversation content starts at the left margin while Home stays centered. */
|
|
19
19
|
export function sessionRows(rows: string[], columns: number): { rows: string[]; inset: number } {
|
|
20
20
|
const available = Number.isFinite(columns) ? Math.max(1, Math.floor(columns)) : 80;
|
|
21
|
-
const inset = Math.min(
|
|
21
|
+
const inset = Math.min(3, Math.max(0, available - 3));
|
|
22
22
|
const prefix = ' '.repeat(inset);
|
|
23
23
|
return {
|
|
24
24
|
rows: rows.map(row => row ? prefix + truncate(row, Math.max(1, available - inset - 1), '') : ''),
|
package/src/tui/lineEditor.js
CHANGED
|
@@ -366,38 +366,70 @@ export class LineEditor {
|
|
|
366
366
|
const prefixWidth = visibleWidth(prefix);
|
|
367
367
|
const budget = Math.max(1, usable - prefixWidth);
|
|
368
368
|
const line = this.lines[index];
|
|
369
|
+
const isCurrentLine = index === this.line;
|
|
369
370
|
|
|
370
371
|
let row = prefix;
|
|
371
372
|
let used = 0;
|
|
372
373
|
let placed = false;
|
|
373
374
|
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
let pos = 0;
|
|
376
|
+
while (pos <= line.length) {
|
|
377
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
376
378
|
cursorRow = rows.length;
|
|
377
379
|
cursorCol = prefixWidth + used;
|
|
378
380
|
placed = true;
|
|
379
381
|
}
|
|
380
|
-
if (
|
|
382
|
+
if (pos === line.length) break;
|
|
383
|
+
|
|
384
|
+
const isSpace = /\s/.test(line[pos]);
|
|
385
|
+
let nextPos = pos;
|
|
386
|
+
let tokenWidth = 0;
|
|
387
|
+
while (nextPos < line.length && (/\s/.test(line[nextPos]) === isSpace)) {
|
|
388
|
+
tokenWidth += visibleWidth(line[nextPos]);
|
|
389
|
+
nextPos++;
|
|
390
|
+
}
|
|
381
391
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (used + charWidth > budget) {
|
|
392
|
+
// If non-whitespace word exceeds remaining space on non-empty line: wrap to next line!
|
|
393
|
+
if (used > 0 && used + tokenWidth > budget && !isSpace) {
|
|
385
394
|
rows.push(row);
|
|
386
395
|
row = prefix;
|
|
387
396
|
used = 0;
|
|
388
|
-
|
|
389
|
-
if (placed && cursorRow === rows.length - 1 && cursorCol === prefixWidth + budget) {
|
|
397
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
390
398
|
cursorRow = rows.length;
|
|
391
399
|
cursorCol = prefixWidth;
|
|
400
|
+
placed = true;
|
|
392
401
|
}
|
|
393
402
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
403
|
+
|
|
404
|
+
while (pos < nextPos) {
|
|
405
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
406
|
+
cursorRow = rows.length;
|
|
407
|
+
cursorCol = prefixWidth + used;
|
|
408
|
+
placed = true;
|
|
409
|
+
}
|
|
410
|
+
const char = line[pos];
|
|
411
|
+
const charWidth = visibleWidth(char);
|
|
412
|
+
|
|
413
|
+
if (used + charWidth > budget && used > 0) {
|
|
414
|
+
rows.push(row);
|
|
415
|
+
row = prefix;
|
|
416
|
+
used = 0;
|
|
417
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
418
|
+
cursorRow = rows.length;
|
|
419
|
+
cursorCol = prefixWidth;
|
|
420
|
+
placed = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const isSelected = range ? isInsideRange(index, pos, range) : false;
|
|
425
|
+
row += isSelected ? `\x1b[7m${char}\x1b[27m` : char;
|
|
426
|
+
used += charWidth;
|
|
427
|
+
pos++;
|
|
428
|
+
}
|
|
397
429
|
}
|
|
398
430
|
|
|
399
431
|
rows.push(row);
|
|
400
|
-
if (
|
|
432
|
+
if (isCurrentLine && !placed) {
|
|
401
433
|
cursorRow = rows.length - 1;
|
|
402
434
|
cursorCol = prefixWidth + used;
|
|
403
435
|
}
|
|
@@ -224,11 +224,22 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
224
224
|
if (row < padding || row >= rows.length)
|
|
225
225
|
continue;
|
|
226
226
|
const existingRow = rows[row] ?? '';
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
let content = existingRow;
|
|
228
|
+
if (transcriptRow === firstContentRow) {
|
|
229
|
+
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
230
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
231
|
+
if (!alreadyHasMarker) {
|
|
232
|
+
if (existingRow.startsWith(' ')) {
|
|
233
|
+
content = ` ${paint('accent', '▸')} ${existingRow.slice(3)}`;
|
|
234
|
+
}
|
|
235
|
+
else if (existingRow.startsWith(' ')) {
|
|
236
|
+
content = ` ${paint('accent', '▸')}${existingRow.slice(2)}`;
|
|
237
|
+
}
|
|
238
|
+
else if (existingRow.startsWith(' ')) {
|
|
239
|
+
content = `${paint('accent', '▸')}${existingRow.slice(1)}`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
232
243
|
rows[row] = fill('surfaceHi', padEnd(content, contentWidth));
|
|
233
244
|
}
|
|
234
245
|
}
|
|
@@ -308,11 +308,20 @@ export function markHoveredMessage(
|
|
|
308
308
|
const row = transcriptRow - surface.viewport.scrollTop + padding;
|
|
309
309
|
if (row < padding || row >= rows.length) continue;
|
|
310
310
|
const existingRow = rows[row] ?? '';
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
311
|
+
let content = existingRow;
|
|
312
|
+
if (transcriptRow === firstContentRow) {
|
|
313
|
+
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
314
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
315
|
+
if (!alreadyHasMarker) {
|
|
316
|
+
if (existingRow.startsWith(' ')) {
|
|
317
|
+
content = ` ${paint('accent', '▸')} ${existingRow.slice(3)}`;
|
|
318
|
+
} else if (existingRow.startsWith(' ')) {
|
|
319
|
+
content = ` ${paint('accent', '▸')}${existingRow.slice(2)}`;
|
|
320
|
+
} else if (existingRow.startsWith(' ')) {
|
|
321
|
+
content = `${paint('accent', '▸')}${existingRow.slice(1)}`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
316
325
|
rows[row] = fill('surfaceHi', padEnd(content, contentWidth));
|
|
317
326
|
}
|
|
318
327
|
}
|