@orion-agents/orion-code 0.4.5 → 0.4.6
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/CHANGELOG.md +7 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/commands/context-commands.js +16 -28
- package/dist/commands/context-tool-command-handlers.d.ts +2 -3
- package/dist/commands/context-tool-command-handlers.js +2 -20
- package/dist/commands/registry.js +24 -61
- package/dist/commands/retired-commands.d.ts +2 -0
- package/dist/commands/retired-commands.js +24 -0
- package/dist/commands/session-command-handlers.d.ts +3 -2
- package/dist/commands/session-command-handlers.js +41 -42
- package/dist/commands/session-commands.js +21 -0
- package/dist/commands/system-commands.js +2 -27
- package/dist/commands/tool-commands.js +0 -10
- package/dist/commands/types.d.ts +6 -4
- package/dist/commands/workflow-commands.js +0 -24
- package/dist/framework/query.js +1 -1
- package/dist/harness/context-harness.d.ts +1 -1
- package/dist/harness/context-harness.js +1 -1
- package/dist/harness/stop-controller.js +1 -1
- package/dist/runtime/agent-runtime-controller.d.ts +4 -2
- package/dist/runtime/agent-runtime-controller.js +115 -30
- package/dist/runtime/orion-session-runner.js +3 -5
- package/dist/runtime/product-bootstrap.js +24 -11
- package/dist/runtime/ui-events.d.ts +4 -1
- package/dist/runtime/ui-view-model.js +7 -3
- package/dist/skills/builtin/security-check/SKILL.md +2 -2
- package/dist/skills/builtin/test-gen/SKILL.md +2 -2
- package/dist/terminal-ui/launch.js +1 -1
- package/dist/tui-ui/launch.js +4 -1
- package/dist/tui-ui/layout.d.ts +2 -2
- package/dist/tui-ui/layout.js +59 -47
- package/dist/tui-ui/pickers.d.ts +3 -1
- package/dist/tui-ui/pickers.js +17 -11
- package/dist/tui-ui/runner.d.ts +1 -1
- package/dist/tui-ui/runner.js +61 -68
- package/dist/tui-ui/state.d.ts +4 -0
- package/dist/tui-ui/state.js +33 -2
- package/docs/cli-guide.md +20 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/tui-ui/layout.js
CHANGED
|
@@ -20,6 +20,7 @@ const MIN_WIDTH = 24;
|
|
|
20
20
|
const MIN_HEIGHT = 8;
|
|
21
21
|
const PROMPT_BORDER_ROWS = 2;
|
|
22
22
|
const MAX_TIMELINE_ROWS = 6;
|
|
23
|
+
const MAX_COMPOSER_PICKER_ROWS = 6;
|
|
23
24
|
const STATUS_ROWS = 1;
|
|
24
25
|
const ACTIVITY_SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧'];
|
|
25
26
|
/**
|
|
@@ -55,15 +56,16 @@ function activeSubtaskTimelineEntries(state) {
|
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Measure the cursor-owned live block. Idle TUI state stays compact like an
|
|
58
|
-
* ordinary shell prompt
|
|
59
|
-
*
|
|
59
|
+
* ordinary shell prompt. Composer pickers draw into this same block, so opening
|
|
60
|
+
* one does not allocate terminal rows or advance native scrollback.
|
|
60
61
|
*/
|
|
61
62
|
function measureTuiLiveFrameHeight(state, width, maxHeight, options = {}) {
|
|
62
63
|
const safeWidth = Math.max(MIN_WIDTH, Math.floor(width));
|
|
63
64
|
const transcriptWidth = resolveTranscriptWidth(safeWidth, options.transcriptWidth);
|
|
64
65
|
const safeMaxHeight = Math.max(MIN_HEIGHT, Math.floor(maxHeight));
|
|
65
|
-
if (state.overlay)
|
|
66
|
+
if (state.overlay && state.overlay.type !== 'commands' && state.overlay.type !== 'files') {
|
|
66
67
|
return safeMaxHeight;
|
|
68
|
+
}
|
|
67
69
|
const budget = computeBudget(safeMaxHeight, state);
|
|
68
70
|
const fixedRows = safeMaxHeight - budget.transcriptRows;
|
|
69
71
|
const transcriptRows = state.transcript
|
|
@@ -88,8 +90,7 @@ function renderTuiUiFrame(state, options) {
|
|
|
88
90
|
renderTimeline(frame, state, timelineTop, budget.timelineRows, options.theme);
|
|
89
91
|
renderStatus(frame, state, statusRow, options);
|
|
90
92
|
renderPrompt(frame, state, promptTop, width, budget.promptLineCount, options.theme);
|
|
91
|
-
|
|
92
|
-
renderOverlay(frame, state, activityRow);
|
|
93
|
+
renderOverlay(frame, state.overlay, activityRow, timelineTop, options.theme ?? style_1.DEFAULT_THEME);
|
|
93
94
|
if (budget.activityRows)
|
|
94
95
|
renderActivity(frame, state, activityRow, options);
|
|
95
96
|
return frame;
|
|
@@ -118,7 +119,7 @@ function renderTuiLiveFrame(state, options) {
|
|
|
118
119
|
renderTimeline(frame, state, timelineTop, budget.timelineRows, options.theme);
|
|
119
120
|
renderStatus(frame, state, statusRow, options);
|
|
120
121
|
renderPrompt(frame, state, promptTop, width, budget.promptLineCount, options.theme);
|
|
121
|
-
renderOverlay(frame, state, activityRow);
|
|
122
|
+
renderOverlay(frame, state.overlay, activityRow, timelineTop, options.theme ?? style_1.DEFAULT_THEME);
|
|
122
123
|
if (budget.activityRows)
|
|
123
124
|
renderActivity(frame, state, activityRow, options);
|
|
124
125
|
return frame;
|
|
@@ -332,14 +333,17 @@ function promptLineViewport(value, cursor, width) {
|
|
|
332
333
|
cursorCells,
|
|
333
334
|
};
|
|
334
335
|
}
|
|
335
|
-
function renderOverlay(frame,
|
|
336
|
-
if (!
|
|
336
|
+
function renderOverlay(frame, overlay, maxRows, transcriptRows, theme) {
|
|
337
|
+
if (!overlay || maxRows <= 0)
|
|
338
|
+
return;
|
|
339
|
+
if (overlay.type === 'commands' || overlay.type === 'files') {
|
|
340
|
+
renderComposerPicker(frame, overlay, transcriptRows, theme);
|
|
337
341
|
return;
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
}
|
|
343
|
+
if (overlay.type === 'sessions') {
|
|
340
344
|
const request = overlay.request;
|
|
341
345
|
const visibleCount = Math.max(0, Math.min(maxRows - 1, request.maxVisibleItems ?? maxRows - 1, request.sessions.length));
|
|
342
|
-
const start = sessionPickerStartIndex(
|
|
346
|
+
const start = sessionPickerStartIndex(overlay.selectedIndex, visibleCount, request.sessions.length);
|
|
343
347
|
const visibleSessions = request.sessions.slice(start, start + visibleCount);
|
|
344
348
|
const rows = [
|
|
345
349
|
`Sessions: ${request.title} (${overlay.selectedIndex + 1}/${request.sessions.length})`,
|
|
@@ -362,12 +366,11 @@ function renderOverlay(frame, state, maxRows) {
|
|
|
362
366
|
}
|
|
363
367
|
return;
|
|
364
368
|
}
|
|
365
|
-
if (
|
|
366
|
-
const overlay = state.overlay;
|
|
369
|
+
if (overlay.type === 'model') {
|
|
367
370
|
const request = overlay.request;
|
|
368
371
|
const pickerState = (0, ui_view_model_1.createModelPickerState)({ ...request, visibleStart: 0 });
|
|
369
372
|
const visibleCount = Math.max(0, Math.min(maxRows - 1, request.maxVisibleItems ?? maxRows - 1, request.models.length));
|
|
370
|
-
const start = sessionPickerStartIndex(
|
|
373
|
+
const start = sessionPickerStartIndex(overlay.selectedIndex, visibleCount, request.models.length);
|
|
371
374
|
const visibleModels = request.models.slice(start, start + visibleCount);
|
|
372
375
|
const rows = [
|
|
373
376
|
`Models: ${request.title ?? 'Switch Model'} (${overlay.selectedIndex + 1}/${request.models.length})`,
|
|
@@ -391,8 +394,7 @@ function renderOverlay(frame, state, maxRows) {
|
|
|
391
394
|
}
|
|
392
395
|
return;
|
|
393
396
|
}
|
|
394
|
-
if (
|
|
395
|
-
const overlay = state.overlay;
|
|
397
|
+
if (overlay.type === 'edit') {
|
|
396
398
|
const req = overlay.request;
|
|
397
399
|
const visibleCount = Math.max(0, Math.min(maxRows - 1, 10, req.candidates.length));
|
|
398
400
|
const start = pickerStartIndex(overlay.selectedIndex, visibleCount, req.candidates.length);
|
|
@@ -420,36 +422,7 @@ function renderOverlay(frame, state, maxRows) {
|
|
|
420
422
|
}
|
|
421
423
|
return;
|
|
422
424
|
}
|
|
423
|
-
if (
|
|
424
|
-
const overlay = state.overlay;
|
|
425
|
-
const visibleCount = Math.max(0, Math.min(maxRows - 2, 10, overlay.items.length || 1));
|
|
426
|
-
const start = pickerStartIndex(overlay.selectedIndex, visibleCount, overlay.items.length);
|
|
427
|
-
const visibleItems = overlay.items.slice(start, start + visibleCount);
|
|
428
|
-
const title = overlay.type === 'commands'
|
|
429
|
-
? `Commands${overlay.query ? ` "${overlay.query}"` : ''}`
|
|
430
|
-
: `Files${overlay.query ? ` "${overlay.query}"` : ''}`;
|
|
431
|
-
const rows = [
|
|
432
|
-
`${title} (${overlay.items.length} match${overlay.items.length === 1 ? '' : 'es'})`,
|
|
433
|
-
...(overlay.items.length === 0
|
|
434
|
-
? [' No matching items']
|
|
435
|
-
: visibleItems.map((item, offset) => {
|
|
436
|
-
const index = start + offset;
|
|
437
|
-
const marker = index === overlay.selectedIndex ? '›' : ' ';
|
|
438
|
-
const description = item.description ? ` ${item.description}` : '';
|
|
439
|
-
return `${marker} ${item.label}${description}`;
|
|
440
|
-
})),
|
|
441
|
-
].map(row => truncateCells(row, frame.width));
|
|
442
|
-
rows.slice(0, maxRows).forEach((line, index) => {
|
|
443
|
-
(0, frame_1.writeFrameText)(frame, index, 0, line);
|
|
444
|
-
});
|
|
445
|
-
// Clear any remaining transcript rows below overlay content
|
|
446
|
-
for (let i = rows.length; i < maxRows; i++) {
|
|
447
|
-
(0, frame_1.writeFrameText)(frame, i, 0, '');
|
|
448
|
-
}
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
if (state.overlay.type === 'permission') {
|
|
452
|
-
const overlay = state.overlay;
|
|
425
|
+
if (overlay.type === 'permission') {
|
|
453
426
|
const picker = (0, ui_view_model_1.createPermissionDecisionPickerState)(overlay.request);
|
|
454
427
|
const rows = [
|
|
455
428
|
`Tool Permission: ${overlay.request.name}`,
|
|
@@ -468,7 +441,7 @@ function renderOverlay(frame, state, maxRows) {
|
|
|
468
441
|
}
|
|
469
442
|
return;
|
|
470
443
|
}
|
|
471
|
-
if (
|
|
444
|
+
if (overlay.type === 'shortcuts') {
|
|
472
445
|
const rows = [
|
|
473
446
|
'Orion Pixel · Shortcuts',
|
|
474
447
|
'/ commands @ files ? help Ctrl+O tools',
|
|
@@ -482,6 +455,45 @@ function renderOverlay(frame, state, maxRows) {
|
|
|
482
455
|
});
|
|
483
456
|
}
|
|
484
457
|
}
|
|
458
|
+
function renderComposerPicker(frame, overlay, endRow, theme) {
|
|
459
|
+
const availableRows = Math.min(endRow, MAX_COMPOSER_PICKER_ROWS);
|
|
460
|
+
if (availableRows <= 0)
|
|
461
|
+
return;
|
|
462
|
+
const rows = [];
|
|
463
|
+
if (overlay.type === 'files' && availableRows > 1) {
|
|
464
|
+
const query = singleLine(overlay.query);
|
|
465
|
+
rows.push({ text: query ? `Files "${query}"` : 'Files' });
|
|
466
|
+
}
|
|
467
|
+
const count = Math.min(availableRows - rows.length, overlay.items.length);
|
|
468
|
+
const start = pickerStartIndex(overlay.selectedIndex, count, overlay.items.length);
|
|
469
|
+
const items = overlay.items.slice(start, start + count);
|
|
470
|
+
const labelWidth = Math.min(18, frame.width - 4);
|
|
471
|
+
for (const [index, item] of items.entries()) {
|
|
472
|
+
const selected = start + index === overlay.selectedIndex;
|
|
473
|
+
const marker = selected ? '›' : ' ';
|
|
474
|
+
const label = singleLine(item.label);
|
|
475
|
+
const description = item.description ? singleLine(item.description) : '';
|
|
476
|
+
const text = overlay.type === 'commands' &&
|
|
477
|
+
frame.width >= 40 &&
|
|
478
|
+
description &&
|
|
479
|
+
(0, string_width_1.default)(label) <= labelWidth
|
|
480
|
+
? `${marker} ${label}${' '.repeat(labelWidth - (0, string_width_1.default)(label) + 2)}${description}`
|
|
481
|
+
: `${marker} ${label}`;
|
|
482
|
+
rows.push({ text, selected });
|
|
483
|
+
}
|
|
484
|
+
if (!items.length) {
|
|
485
|
+
rows.push({
|
|
486
|
+
text: overlay.type === 'commands' ? ' No matching commands' : ' No matching files',
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
rows.forEach(({ text, selected }, index) => {
|
|
490
|
+
const row = endRow - rows.length + index;
|
|
491
|
+
const style = selected ? theme.pickerSelected : undefined;
|
|
492
|
+
// Overwrite the entire row, including continuation cells from wide characters.
|
|
493
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ' '.repeat(frame.width), style);
|
|
494
|
+
(0, frame_1.writeFrameText)(frame, row, 0, ellipsizeCells(text, frame.width), style);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
485
497
|
function sessionPickerStartIndex(selectedIndex, visibleCount, total) {
|
|
486
498
|
return pickerStartIndex(selectedIndex, visibleCount, total);
|
|
487
499
|
}
|
package/dist/tui-ui/pickers.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export interface TuiFileQuery {
|
|
|
7
7
|
base: string;
|
|
8
8
|
query: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/** Only the first slash token belongs to the root command picker. */
|
|
11
|
+
export declare function getCommandToken(input: string): string | undefined;
|
|
12
|
+
export declare function visibleCommandItems(query: string): TuiPickerItem[];
|
|
11
13
|
export declare function getFileQuery(input: string): TuiFileQuery | null;
|
|
12
14
|
export declare function visibleFileItems(cwd: string, input: string): TuiPickerItem[];
|
|
13
15
|
//# sourceMappingURL=pickers.d.ts.map
|
package/dist/tui-ui/pickers.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCommandToken = getCommandToken;
|
|
3
4
|
exports.visibleCommandItems = visibleCommandItems;
|
|
4
5
|
exports.getFileQuery = getFileQuery;
|
|
5
6
|
exports.visibleFileItems = visibleFileItems;
|
|
6
7
|
const commands_1 = require("../commands");
|
|
7
8
|
const ui_view_model_1 = require("../runtime/ui-view-model");
|
|
8
9
|
const file_glob_1 = require("../services/file-glob");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
/** Only the first slash token belongs to the root command picker. */
|
|
11
|
+
function getCommandToken(input) {
|
|
12
|
+
return /^\/[A-Za-z0-9-]*(?=\s|$)/u.exec(input)?.[0];
|
|
13
|
+
}
|
|
14
|
+
function visibleCommandItems(query) {
|
|
15
|
+
const prefix = query.toLowerCase();
|
|
16
|
+
const exact = (0, commands_1.findCommand)(prefix);
|
|
17
|
+
const commands = (0, commands_1.getVisibleCommands)('tui').filter(command => [command.name, ...(command.aliases ?? [])].some(name => name.toLowerCase().startsWith(prefix)));
|
|
18
|
+
if (exact && commands.includes(exact)) {
|
|
19
|
+
commands.splice(commands.indexOf(exact), 1);
|
|
20
|
+
commands.unshift(exact);
|
|
21
|
+
}
|
|
22
|
+
return commands.map(command => ({
|
|
23
|
+
value: command.name,
|
|
24
|
+
label: `/${command.name}`,
|
|
25
|
+
description: command.description,
|
|
20
26
|
}));
|
|
21
27
|
}
|
|
22
28
|
function getFileQuery(input) {
|
package/dist/tui-ui/runner.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare class TuiRunner {
|
|
|
65
65
|
private historySearchQuery;
|
|
66
66
|
private historySearchIndex;
|
|
67
67
|
private historySearchMatch;
|
|
68
|
+
private dismissedCommandToken?;
|
|
68
69
|
private animationFrame;
|
|
69
70
|
private animationTimer;
|
|
70
71
|
private surfaceFailed;
|
|
@@ -157,7 +158,6 @@ export declare class TuiRunner {
|
|
|
157
158
|
private updatePrompt;
|
|
158
159
|
private syncPromptOverlay;
|
|
159
160
|
private completeCommand;
|
|
160
|
-
private hasRecognizedCommandArguments;
|
|
161
161
|
private completeFile;
|
|
162
162
|
private answerPermission;
|
|
163
163
|
/** Restore any temporary Inspector terminal ownership before shutdown. */
|
package/dist/tui-ui/runner.js
CHANGED
|
@@ -568,19 +568,16 @@ class TuiRunner {
|
|
|
568
568
|
this.completeCommand(overlay.items[overlay.selectedIndex], false);
|
|
569
569
|
return;
|
|
570
570
|
case 'enter':
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
this.dispatch({ type: 'closeOverlay' });
|
|
578
|
-
this.submitPrompt();
|
|
579
|
-
return;
|
|
571
|
+
if (value.trim() !== '/' || overlay.selectedIndex !== 0) {
|
|
572
|
+
const selected = overlay.items[overlay.selectedIndex];
|
|
573
|
+
if (selected)
|
|
574
|
+
this.completeCommand(selected, true);
|
|
575
|
+
else
|
|
576
|
+
this.submitPrompt();
|
|
580
577
|
}
|
|
581
|
-
this.completeCommand(overlay.items[overlay.selectedIndex], true);
|
|
582
578
|
return;
|
|
583
579
|
case 'escape':
|
|
580
|
+
this.dismissedCommandToken = (0, pickers_1.getCommandToken)(value);
|
|
584
581
|
this.dispatch({ type: 'closeOverlay' });
|
|
585
582
|
return;
|
|
586
583
|
}
|
|
@@ -700,10 +697,10 @@ class TuiRunner {
|
|
|
700
697
|
this.updatePrompt(deleteAfterCursor(value, cursor));
|
|
701
698
|
return;
|
|
702
699
|
case 'left':
|
|
703
|
-
this.
|
|
700
|
+
this.updatePrompt({ value, cursor: previousBoundary(value, cursor) });
|
|
704
701
|
return;
|
|
705
702
|
case 'right':
|
|
706
|
-
this.
|
|
703
|
+
this.updatePrompt({ value, cursor: nextBoundary(value, cursor) });
|
|
707
704
|
return;
|
|
708
705
|
case 'home':
|
|
709
706
|
this.moveCursorLineHome();
|
|
@@ -712,7 +709,7 @@ class TuiRunner {
|
|
|
712
709
|
this.moveCursorLineEnd();
|
|
713
710
|
return;
|
|
714
711
|
case 'ctrl+u':
|
|
715
|
-
this.
|
|
712
|
+
this.updatePrompt({ value: '', cursor: 0 });
|
|
716
713
|
this.dispatch({ type: 'closeOverlay' });
|
|
717
714
|
return;
|
|
718
715
|
case 'ctrl+w':
|
|
@@ -727,16 +724,15 @@ class TuiRunner {
|
|
|
727
724
|
this.options.onInterrupt?.();
|
|
728
725
|
return;
|
|
729
726
|
case 'tab':
|
|
727
|
+
if ((0, pickers_1.getCommandToken)(value)) {
|
|
728
|
+
this.syncPromptOverlay(value, cursor, true);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
730
731
|
if (this.state.processing && value.trim()) {
|
|
731
732
|
this.queuePrompt();
|
|
732
733
|
return;
|
|
733
734
|
}
|
|
734
|
-
|
|
735
|
-
this.syncPromptOverlay(value);
|
|
736
|
-
}
|
|
737
|
-
else if ((0, pickers_1.getFileQuery)(value)) {
|
|
738
|
-
this.syncPromptOverlay(value);
|
|
739
|
-
}
|
|
735
|
+
this.syncPromptOverlay(value, cursor);
|
|
740
736
|
return;
|
|
741
737
|
case 'up':
|
|
742
738
|
this.moveCursorUpOrHistory();
|
|
@@ -752,14 +748,14 @@ class TuiRunner {
|
|
|
752
748
|
}
|
|
753
749
|
queuePrompt() {
|
|
754
750
|
const input = this.state.prompt.value.trim();
|
|
755
|
-
if (!input)
|
|
751
|
+
if (!input || (0, pickers_1.getCommandToken)(input))
|
|
756
752
|
return;
|
|
757
753
|
try {
|
|
758
754
|
const queued = this.options.onQueueSubmit?.(input);
|
|
759
755
|
if (queued === false)
|
|
760
756
|
return;
|
|
761
757
|
this.history = (0, history_1.pushHistoryEntry)(this.history, input);
|
|
762
|
-
this.
|
|
758
|
+
this.updatePrompt({ value: '', cursor: 0 });
|
|
763
759
|
this.dispatch({ type: 'closeOverlay' });
|
|
764
760
|
if (queued instanceof Promise)
|
|
765
761
|
void queued.catch(() => this.reportSubmitFailure());
|
|
@@ -788,7 +784,7 @@ class TuiRunner {
|
|
|
788
784
|
const match = matches[this.historySearchIndex % matches.length];
|
|
789
785
|
this.historySearchIndex += 1;
|
|
790
786
|
this.historySearchMatch = match;
|
|
791
|
-
this.
|
|
787
|
+
this.updatePrompt({ value: match, cursor: match.length });
|
|
792
788
|
this.dispatch({
|
|
793
789
|
type: 'setStatus',
|
|
794
790
|
message: `History ${((this.historySearchIndex - 1) % matches.length) + 1}/${matches.length}`,
|
|
@@ -808,7 +804,7 @@ class TuiRunner {
|
|
|
808
804
|
await (0, promises_1.writeFile)(filePath, original, { encoding: 'utf8', mode: 0o600 });
|
|
809
805
|
await this.options.onOpenExternalEditor(filePath);
|
|
810
806
|
const next = await (0, promises_1.readFile)(filePath, 'utf8');
|
|
811
|
-
this.
|
|
807
|
+
this.updatePrompt({ value: next, cursor: next.length });
|
|
812
808
|
}
|
|
813
809
|
finally {
|
|
814
810
|
await (0, promises_1.rm)(directory, { recursive: true, force: true });
|
|
@@ -852,7 +848,7 @@ class TuiRunner {
|
|
|
852
848
|
const { value, cursor } = this.state.prompt;
|
|
853
849
|
const { line, col } = lineColOfCursor(value, cursor);
|
|
854
850
|
if (line > 0) {
|
|
855
|
-
this.
|
|
851
|
+
this.updatePrompt({ value, cursor: cursorOfLineCol(value, line - 1, col) });
|
|
856
852
|
}
|
|
857
853
|
else {
|
|
858
854
|
this.historyBack();
|
|
@@ -869,7 +865,7 @@ class TuiRunner {
|
|
|
869
865
|
const lines = value.split('\n');
|
|
870
866
|
const { line, col } = lineColOfCursor(value, cursor);
|
|
871
867
|
if (line < lines.length - 1) {
|
|
872
|
-
this.
|
|
868
|
+
this.updatePrompt({ value, cursor: cursorOfLineCol(value, line + 1, col) });
|
|
873
869
|
}
|
|
874
870
|
else {
|
|
875
871
|
this.historyForward();
|
|
@@ -877,21 +873,16 @@ class TuiRunner {
|
|
|
877
873
|
}
|
|
878
874
|
/** Home: move to the start of the current visual line (not whole buffer). */
|
|
879
875
|
moveCursorLineHome() {
|
|
880
|
-
if (this.state.overlay)
|
|
881
|
-
return;
|
|
882
876
|
const { value, cursor } = this.state.prompt;
|
|
883
877
|
const { line } = lineColOfCursor(value, cursor);
|
|
884
|
-
this.
|
|
878
|
+
this.updatePrompt({ value, cursor: cursorOfLineCol(value, line, 0) });
|
|
885
879
|
}
|
|
886
880
|
/** End: move to the end of the current visual line (not whole buffer). */
|
|
887
881
|
moveCursorLineEnd() {
|
|
888
|
-
if (this.state.overlay)
|
|
889
|
-
return;
|
|
890
882
|
const { value, cursor } = this.state.prompt;
|
|
891
883
|
const { line } = lineColOfCursor(value, cursor);
|
|
892
884
|
const lines = value.split('\n');
|
|
893
|
-
this.
|
|
894
|
-
type: 'setPrompt',
|
|
885
|
+
this.updatePrompt({
|
|
895
886
|
value,
|
|
896
887
|
cursor: cursorOfLineCol(value, line, lines[line].length),
|
|
897
888
|
});
|
|
@@ -900,11 +891,16 @@ class TuiRunner {
|
|
|
900
891
|
const { value: input, cursor } = this.state.prompt;
|
|
901
892
|
if (!input.trim() && !options.allowEmpty)
|
|
902
893
|
return;
|
|
903
|
-
|
|
894
|
+
if (input.trim() === '/') {
|
|
895
|
+
this.syncPromptOverlay(input, cursor, true);
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
this.updatePrompt({ value: '', cursor: 0 });
|
|
904
899
|
try {
|
|
905
900
|
const submission = this.handleLocalCommand(input) || this.options.onSubmit?.(input);
|
|
906
901
|
if (submission === false) {
|
|
907
|
-
this.
|
|
902
|
+
this.dismissedCommandToken = (0, pickers_1.getCommandToken)(input);
|
|
903
|
+
this.updatePrompt({ value: input, cursor });
|
|
908
904
|
return;
|
|
909
905
|
}
|
|
910
906
|
this.history = (0, history_1.pushHistoryEntry)(this.history, input);
|
|
@@ -921,10 +917,6 @@ class TuiRunner {
|
|
|
921
917
|
}
|
|
922
918
|
handleLocalCommand(input) {
|
|
923
919
|
const command = input.trim();
|
|
924
|
-
if (command === '/redraw') {
|
|
925
|
-
this.forceOwnedRedraw();
|
|
926
|
-
return true;
|
|
927
|
-
}
|
|
928
920
|
if (command === '/queue') {
|
|
929
921
|
const items = this.state.followupQueue.items;
|
|
930
922
|
this.dispatch({
|
|
@@ -956,7 +948,7 @@ class TuiRunner {
|
|
|
956
948
|
});
|
|
957
949
|
return true;
|
|
958
950
|
}
|
|
959
|
-
if (
|
|
951
|
+
if (/^\/tool-output(?:\s|$)/u.test(command)) {
|
|
960
952
|
this.dispatch({
|
|
961
953
|
type: 'setStatus',
|
|
962
954
|
message: 'Usage: /tool-output adaptive|collapsed|full',
|
|
@@ -977,21 +969,30 @@ class TuiRunner {
|
|
|
977
969
|
}
|
|
978
970
|
updatePrompt(next) {
|
|
979
971
|
this.dispatch({ type: 'setPrompt', value: next.value, cursor: next.cursor });
|
|
980
|
-
this.syncPromptOverlay(next.value);
|
|
972
|
+
this.syncPromptOverlay(next.value, next.cursor);
|
|
981
973
|
}
|
|
982
|
-
syncPromptOverlay(value) {
|
|
983
|
-
|
|
984
|
-
|
|
974
|
+
syncPromptOverlay(value, cursor, reopen = false) {
|
|
975
|
+
const token = (0, pickers_1.getCommandToken)(value);
|
|
976
|
+
if (reopen || token !== this.dismissedCommandToken)
|
|
977
|
+
this.dismissedCommandToken = undefined;
|
|
978
|
+
const overlay = this.state.overlay;
|
|
979
|
+
if (overlay?.type === 'shortcuts') {
|
|
980
|
+
if (value.trim())
|
|
981
|
+
this.dispatch({ type: 'closeOverlay' });
|
|
982
|
+
}
|
|
983
|
+
else if (overlay && overlay.type !== 'commands' && overlay.type !== 'files') {
|
|
984
|
+
return;
|
|
985
985
|
}
|
|
986
|
-
if (
|
|
986
|
+
if (token && cursor > 0 && cursor <= token.length && token !== this.dismissedCommandToken) {
|
|
987
|
+
const query = token.slice(1);
|
|
987
988
|
this.dispatch({
|
|
988
989
|
type: 'showCommandPalette',
|
|
989
|
-
query
|
|
990
|
-
items:
|
|
990
|
+
query,
|
|
991
|
+
items: (0, pickers_1.visibleCommandItems)(query),
|
|
991
992
|
});
|
|
992
993
|
return;
|
|
993
994
|
}
|
|
994
|
-
const fileQuery = (0, pickers_1.getFileQuery)(value);
|
|
995
|
+
const fileQuery = cursor === value.length ? (0, pickers_1.getFileQuery)(value) : null;
|
|
995
996
|
if (fileQuery) {
|
|
996
997
|
this.dispatch({
|
|
997
998
|
type: 'showFilePicker',
|
|
@@ -1006,27 +1007,22 @@ class TuiRunner {
|
|
|
1006
1007
|
}
|
|
1007
1008
|
}
|
|
1008
1009
|
completeCommand(item, submitImmediately) {
|
|
1009
|
-
|
|
1010
|
+
const { value } = this.state.prompt;
|
|
1011
|
+
const token = (0, pickers_1.getCommandToken)(value);
|
|
1012
|
+
if (!item || !token)
|
|
1010
1013
|
return;
|
|
1011
|
-
const command = (0, commands_1.
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const promptAlreadyMatchesCommand = this.state.prompt.value.trim() === `/${item.value}`;
|
|
1016
|
-
const nextValue = promptAlreadyMatchesCommand ? `/${item.value}` : value;
|
|
1014
|
+
const command = (0, commands_1.findCommand)(item.value);
|
|
1015
|
+
const tail = value.slice(token.length);
|
|
1016
|
+
const separator = !submitImmediately && !tail && command?.argumentHint ? ' ' : '';
|
|
1017
|
+
this.dismissedCommandToken = item.label;
|
|
1017
1018
|
this.dispatch({ type: 'closeOverlay' });
|
|
1018
|
-
this.dispatch({
|
|
1019
|
-
|
|
1019
|
+
this.dispatch({
|
|
1020
|
+
type: 'setPrompt',
|
|
1021
|
+
value: item.label + separator + tail,
|
|
1022
|
+
cursor: item.label.length + separator.length,
|
|
1023
|
+
});
|
|
1024
|
+
if (submitImmediately)
|
|
1020
1025
|
this.submitPrompt();
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
hasRecognizedCommandArguments() {
|
|
1024
|
-
const prompt = this.state.prompt.value.trim();
|
|
1025
|
-
const match = prompt.match(/^\/([^\s]+)\s+\S/u);
|
|
1026
|
-
if (!match)
|
|
1027
|
-
return false;
|
|
1028
|
-
const name = match[1].toLowerCase();
|
|
1029
|
-
return (0, commands_1.findCommand)(name) !== undefined;
|
|
1030
1026
|
}
|
|
1031
1027
|
completeFile(item) {
|
|
1032
1028
|
if (!item)
|
|
@@ -1421,9 +1417,6 @@ function insertAtCursor(value, cursor, text) {
|
|
|
1421
1417
|
cursor: safeCursor + text.length,
|
|
1422
1418
|
};
|
|
1423
1419
|
}
|
|
1424
|
-
function visibleTuiCommandItems(input) {
|
|
1425
|
-
return (0, pickers_1.visibleCommandItems)(input);
|
|
1426
|
-
}
|
|
1427
1420
|
function safeFileName(value) {
|
|
1428
1421
|
return value.replace(/[^a-zA-Z0-9._-]+/gu, '-').replace(/^-+|-+$/gu, '') || 'tool';
|
|
1429
1422
|
}
|
package/dist/tui-ui/state.d.ts
CHANGED
package/dist/tui-ui/state.js
CHANGED
|
@@ -185,6 +185,24 @@ function tuiUiReducer(state, action) {
|
|
|
185
185
|
recentToolDetails: mergeRecentToolDetails([], action.entries.flatMap(toolDetailsFromTranscriptEntry)),
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
+
case 'startSession':
|
|
189
|
+
return {
|
|
190
|
+
...state,
|
|
191
|
+
overlay: null,
|
|
192
|
+
goal: null,
|
|
193
|
+
research: null,
|
|
194
|
+
researchEvents: [],
|
|
195
|
+
subtaskTimeline: [],
|
|
196
|
+
statusMessage: '',
|
|
197
|
+
statusState: {
|
|
198
|
+
...exports.initialTuiUiState.statusState,
|
|
199
|
+
snapshot: (0, ui_view_model_1.createStatusSnapshot)({
|
|
200
|
+
renderer: 'tui',
|
|
201
|
+
model: action.model,
|
|
202
|
+
sessionId: action.sessionId,
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
};
|
|
188
206
|
case 'clearTranscript':
|
|
189
207
|
return {
|
|
190
208
|
...state,
|
|
@@ -345,16 +363,21 @@ function tuiUiReducer(state, action) {
|
|
|
345
363
|
}
|
|
346
364
|
case 'followupQueueChanged':
|
|
347
365
|
return { ...state, followupQueue: action.snapshot };
|
|
348
|
-
case 'showCommandPalette':
|
|
366
|
+
case 'showCommandPalette': {
|
|
367
|
+
const previous = state.overlay;
|
|
368
|
+
const previousValue = previous?.type === 'commands' && previous.query === action.query
|
|
369
|
+
? previous.items[previous.selectedIndex]?.value
|
|
370
|
+
: undefined;
|
|
349
371
|
return {
|
|
350
372
|
...state,
|
|
351
373
|
overlay: {
|
|
352
374
|
type: 'commands',
|
|
353
375
|
query: action.query,
|
|
354
376
|
items: action.items,
|
|
355
|
-
selectedIndex:
|
|
377
|
+
selectedIndex: Math.max(0, action.items.findIndex(item => item.value === previousValue)),
|
|
356
378
|
},
|
|
357
379
|
};
|
|
380
|
+
}
|
|
358
381
|
case 'showFilePicker':
|
|
359
382
|
return {
|
|
360
383
|
...state,
|
|
@@ -573,6 +596,14 @@ function createTuiUiEventSink(dispatch, options = {}) {
|
|
|
573
596
|
toolFinished: event => dispatch({ type: 'toolFinished', event }),
|
|
574
597
|
sessionRestored: (event) => {
|
|
575
598
|
const view = (0, ui_view_model_1.createSessionRestoredView)(event);
|
|
599
|
+
if (event.reason === 'new') {
|
|
600
|
+
dispatch({ type: 'startSession', sessionId: event.sessionId, model: event.model });
|
|
601
|
+
dispatch({
|
|
602
|
+
type: 'appendTranscript',
|
|
603
|
+
entry: { id: idFactory(), role: 'status', title: 'new', content: view.headline },
|
|
604
|
+
});
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
576
607
|
const lines = [view.headline];
|
|
577
608
|
if (view.summary)
|
|
578
609
|
lines.push(`Summary: ${view.summary}`);
|
package/docs/cli-guide.md
CHANGED
|
@@ -43,10 +43,29 @@ orion doctor
|
|
|
43
43
|
`orion commit` 是只读提交计划,不是执行本地提交。阶段完成不隐含授权 push、发布或删除。
|
|
44
44
|
模型切换、权限、工具和会话帮助以安装版本内 `/help` 为准。
|
|
45
45
|
|
|
46
|
-
多步骤修改会在首次写入前建立清单。`/
|
|
46
|
+
多步骤修改会在首次写入前建立清单。`/context explain` 可查看当前步骤、已验证的回执、失败次数和剩余工作。
|
|
47
47
|
审批 PLAN 时,`## Execution checklist` 下的未勾选项可直接进入同一执行清单。实际改动和检查的回执决定
|
|
48
48
|
步骤能否完成。输入“先把第一步做完,其他之后再说”可以限制当前任务的范围,输入“继续”恢复已延期的步骤。
|
|
49
49
|
|
|
50
|
+
## TUI 命令与会话
|
|
51
|
+
|
|
52
|
+
从 v0.4.6 起,在输入框开头键入 `/` 可查看命令。候选根据命令名和别名筛选,并贴近输入框显示。
|
|
53
|
+
用方向键选中候选,Tab 补全命令名并保留已经输入的参数,Enter 执行。Esc 关闭候选并保留草稿。
|
|
54
|
+
光标进入参数区后,可以继续编辑并直接提交。
|
|
55
|
+
|
|
56
|
+
- `/new` 创建独立会话,`/resume` 可回到原会话。进行中的回合结束后即可切换。
|
|
57
|
+
- `/rename <name>` 重命名当前会话,`/session rename` 仍支持指定其他会话。
|
|
58
|
+
- `/quit` 退出,`/memories` 查看本地记忆状态。旧拼写 `/exit` 和 `/memory` 仍可输入。
|
|
59
|
+
|
|
60
|
+
| 旧入口 | 当前入口 |
|
|
61
|
+
| -------------------------- | ------------------------------ |
|
|
62
|
+
| `/clear`、`/context clear` | `/new` |
|
|
63
|
+
| `/redraw` | Ctrl+L |
|
|
64
|
+
| `/harness` | `/context explain` |
|
|
65
|
+
| `/safety` | `/doctor` |
|
|
66
|
+
| `/security`、`/audit` | `/skill security-check <task>` |
|
|
67
|
+
| `/test-gen`、`/tests` | `/skill test-gen <task>` |
|
|
68
|
+
|
|
50
69
|
## 非交互任务与 JSONL 事件
|
|
51
70
|
|
|
52
71
|
```bash
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-agents/orion-code",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@orion-agents/orion-code",
|
|
9
|
-
"version": "0.4.
|
|
9
|
+
"version": "0.4.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "2.12.0",
|