@orion-agents/orion-code 0.4.5 → 0.4.7

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +7 -7
  3. package/README.zh-CN.md +7 -7
  4. package/dist/commands/context-commands.js +16 -28
  5. package/dist/commands/context-tool-command-handlers.d.ts +2 -3
  6. package/dist/commands/context-tool-command-handlers.js +2 -20
  7. package/dist/commands/registry.js +24 -61
  8. package/dist/commands/retired-commands.d.ts +2 -0
  9. package/dist/commands/retired-commands.js +24 -0
  10. package/dist/commands/session-command-handlers.d.ts +3 -2
  11. package/dist/commands/session-command-handlers.js +41 -42
  12. package/dist/commands/session-commands.js +21 -0
  13. package/dist/commands/system-commands.js +2 -27
  14. package/dist/commands/tool-commands.js +0 -10
  15. package/dist/commands/types.d.ts +6 -4
  16. package/dist/commands/workflow-commands.js +0 -24
  17. package/dist/framework/query.js +1 -1
  18. package/dist/framework/verification-command.d.ts +2 -0
  19. package/dist/framework/verification-command.js +16 -4
  20. package/dist/harness/assembler.d.ts +1 -0
  21. package/dist/harness/assembler.js +5 -2
  22. package/dist/harness/clarification.d.ts +3 -0
  23. package/dist/harness/clarification.js +56 -0
  24. package/dist/harness/context-harness.d.ts +1 -1
  25. package/dist/harness/context-harness.js +33 -5
  26. package/dist/harness/contract.js +36 -10
  27. package/dist/harness/drift-guard.js +12 -4
  28. package/dist/harness/goal-verification.d.ts +2 -0
  29. package/dist/harness/goal-verification.js +42 -0
  30. package/dist/harness/intent.js +10 -12
  31. package/dist/harness/state.js +15 -2
  32. package/dist/harness/stop-controller.js +1 -1
  33. package/dist/harness/task-checklist.js +1 -1
  34. package/dist/harness/verification.d.ts +2 -0
  35. package/dist/harness/verification.js +16 -5
  36. package/dist/runtime/agent-loop.js +49 -27
  37. package/dist/runtime/agent-runtime-controller.d.ts +4 -2
  38. package/dist/runtime/agent-runtime-controller.js +116 -31
  39. package/dist/runtime/orion-session-runner.js +3 -5
  40. package/dist/runtime/plan-review.d.ts +1 -0
  41. package/dist/runtime/plan-review.js +12 -7
  42. package/dist/runtime/product-bootstrap.js +24 -11
  43. package/dist/runtime/product-orion-runtime.js +1 -1
  44. package/dist/runtime/step-snapshot.d.ts +1 -0
  45. package/dist/runtime/step-snapshot.js +2 -1
  46. package/dist/runtime/task-context-recovery.js +15 -7
  47. package/dist/runtime/tool-gateway.js +1 -0
  48. package/dist/runtime/ui-events.d.ts +4 -1
  49. package/dist/runtime/ui-view-model.js +7 -3
  50. package/dist/skills/builtin/security-check/SKILL.md +2 -2
  51. package/dist/skills/builtin/test-gen/SKILL.md +2 -2
  52. package/dist/terminal-ui/launch.js +1 -1
  53. package/dist/tui-ui/launch.js +4 -1
  54. package/dist/tui-ui/layout.d.ts +2 -2
  55. package/dist/tui-ui/layout.js +59 -47
  56. package/dist/tui-ui/pickers.d.ts +3 -1
  57. package/dist/tui-ui/pickers.js +17 -11
  58. package/dist/tui-ui/runner.d.ts +1 -1
  59. package/dist/tui-ui/runner.js +61 -68
  60. package/dist/tui-ui/state.d.ts +4 -0
  61. package/dist/tui-ui/state.js +33 -2
  62. package/docs/cli-guide.md +24 -1
  63. package/npm-shrinkwrap.json +2 -2
  64. package/package.json +1 -1
@@ -189,7 +189,16 @@ async function createProductUiRuntime(options) {
189
189
  const setSession = (session) => {
190
190
  if (currentSession?.id !== session?.id) {
191
191
  compactCoordinator.cancelBackground('session_changed');
192
- store.setState({ backgroundCompact: undefined });
192
+ store.setState({
193
+ conversationHistory: [],
194
+ tokenUsage: null,
195
+ contextUsage: null,
196
+ backgroundCompact: undefined,
197
+ harnessState: undefined,
198
+ lastLoopStats: undefined,
199
+ currentPlan: null,
200
+ todos: [],
201
+ });
193
202
  }
194
203
  applySessionState(session);
195
204
  currentSession = session;
@@ -203,17 +212,20 @@ async function createProductUiRuntime(options) {
203
212
  overridesProjectEffort: currentSession.effortPreference !== undefined,
204
213
  };
205
214
  };
215
+ const createFreshSession = () => {
216
+ defaultModelSelector =
217
+ settingsCoordinator.describe().sections.defaults.model.effectiveValue ??
218
+ defaultModelSelector;
219
+ const created = (0, session_storage_1.createSession)(cwd, defaultModelSelector, options.sessionSource ? { source: options.sessionSource } : undefined);
220
+ (0, global_config_1.incrementSessionCount)();
221
+ return created;
222
+ };
206
223
  const ensureSession = () => {
207
- if (!currentSession) {
208
- defaultModelSelector =
209
- settingsCoordinator?.describe().sections.defaults.model.effectiveValue ??
210
- defaultModelSelector;
211
- const created = (0, session_storage_1.createSession)(cwd, defaultModelSelector, options.sessionSource ? { source: options.sessionSource } : undefined);
212
- (0, global_config_1.incrementSessionCount)();
213
- setSession(created);
214
- return created;
215
- }
216
- return currentSession;
224
+ if (currentSession)
225
+ return currentSession;
226
+ const created = createFreshSession();
227
+ setSession(created);
228
+ return created;
217
229
  };
218
230
  const getSession = () => currentSession;
219
231
  const prepareSettingsRuntime = (context) => {
@@ -437,6 +449,7 @@ async function createProductUiRuntime(options) {
437
449
  synchronizeSettings,
438
450
  bindSettingsRuntimeIdleProbe,
439
451
  isConfigured: (0, config_1.isConfigured)(config),
452
+ createFreshSession,
440
453
  ensureSession,
441
454
  setSession,
442
455
  getSession,
@@ -121,7 +121,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
121
121
  if (context.mode === 'build' && !composition.taskContext.hasTaskTodos()) {
122
122
  const projection = store.loadProjection();
123
123
  const review = projection.planReview;
124
- if (review?.status === 'approved' && context.input === (0, plan_review_1.planReviewTurnInput)(review)) {
124
+ if (review?.status === 'approved' && (0, plan_review_1.isPlanReviewTurnInput)(review, context.input)) {
125
125
  const plan = (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review).plan;
126
126
  const steps = planExecutionChecklist(plan);
127
127
  if (steps.length)
@@ -141,6 +141,7 @@ export interface BoundToolExecutionRequestV1 {
141
141
  readonly context: ToolContext;
142
142
  readonly enforcement: 'full' | 'partial' | 'none';
143
143
  readonly abortSignal?: AbortSignal;
144
+ readonly verificationCommand?: string;
144
145
  }
145
146
  export interface WorkspaceMutationCoordinatorV1 {
146
147
  runWorkspaceMutation<T>(input: {
@@ -153,7 +153,8 @@ class ExecutionService {
153
153
  // test-generated files have been written and before committing its receipt.
154
154
  const verificationWorkspace = descriptor?.executorId === 'builtin:exec_command:v1' &&
155
155
  typeof request.args.command === 'string' &&
156
- (0, verification_command_1.classifyDirectVerificationCommand)(request.args.command)
156
+ ((0, verification_command_1.classifyDirectVerificationCommand)(request.args.command) ||
157
+ request.verificationCommand === request.args.command)
157
158
  ? this.captureVerificationWorkspace?.()
158
159
  : undefined;
159
160
  return {
@@ -39,11 +39,17 @@ function createTaskRecoveryBinder(taskContext, previousCommitDigest, progressAtA
39
39
  };
40
40
  checkpoint = { digest: (0, canonical_1.digestRuntimeValue)(seed), epoch: state.taskEpoch ?? 1 };
41
41
  }
42
- const command = name === 'exec_command' &&
43
- typeof args.command === 'string' &&
44
- (0, verification_command_1.classifyDirectVerificationCommand)(args.command) &&
45
- (0, redaction_1.redactTraceText)(args.command) === args.command
46
- ? args.command
42
+ const invocation = name === 'exec_command' && typeof args.command === 'string' ? args.command : undefined;
43
+ const commandCwd = typeof args.cwd === 'string' ? (0, common_1.normalizeToolPath)(args.cwd) : '.';
44
+ const contract = taskContext.getContract();
45
+ const command = invocation &&
46
+ (0, redaction_1.redactTraceText)(invocation) === invocation &&
47
+ ((0, verification_command_1.classifyDirectVerificationCommand)(invocation) ||
48
+ ((0, verification_command_1.classifyVerificationSelector)(invocation) === 'generic' &&
49
+ contract?.criteria?.some(criterion => (0, verification_1.requiredVerificationKinds)(criterion.statement).includes('generic') &&
50
+ (0, verification_1.requestedLocalChecks)(criterion.statement).some(check => check.kind === 'generic' &&
51
+ (0, verification_1.matchesRequestedCheckInvocation)(invocation, (0, path_1.resolve)(cwd, commandCwd), check, contract.allowedScope.cwd)))))
52
+ ? invocation
47
53
  : undefined;
48
54
  const path = typeof args.path === 'string'
49
55
  ? (0, verification_1.workspaceArtifactPath)(cwd, (0, common_1.normalizeToolPath)(args.path))
@@ -62,7 +68,7 @@ function createTaskRecoveryBinder(taskContext, previousCommitDigest, progressAtA
62
68
  args: {
63
69
  path,
64
70
  command,
65
- cwd: command && typeof args.cwd === 'string' ? (0, common_1.normalizeToolPath)(args.cwd) : undefined,
71
+ cwd: command && typeof args.cwd === 'string' ? commandCwd : undefined,
66
72
  },
67
73
  };
68
74
  };
@@ -80,7 +86,9 @@ function projectTaskToolEvidence(receipt, args, cwd) {
80
86
  const command = receipt.toolName === 'exec_command' && typeof args.command === 'string'
81
87
  ? args.command
82
88
  : undefined;
83
- const kind = command && (0, verification_command_1.classifyDirectVerificationCommand)(command);
89
+ const kind = command &&
90
+ ((0, verification_command_1.classifyDirectVerificationCommand)(command) ??
91
+ (receipt.verificationWorkspace !== undefined && (0, verification_command_1.classifyVerificationSelector)(command)));
84
92
  const verification = command && kind
85
93
  ? {
86
94
  kind,
@@ -180,6 +180,7 @@ class ToolGateway {
180
180
  context: invocation.context,
181
181
  enforcement: sandbox.enforcement,
182
182
  abortSignal: invocation.abortSignal,
183
+ verificationCommand: invocation.taskRecovery?.args.command,
183
184
  });
184
185
  }
185
186
  catch (error) {
@@ -225,6 +225,7 @@ export interface RuntimeToolFinishedEvent {
225
225
  batchIndex?: number;
226
226
  }
227
227
  export interface RuntimeSessionRestoredEvent {
228
+ reason?: 'new';
228
229
  sessionId: string;
229
230
  projectPath: string;
230
231
  model: string;
@@ -286,6 +287,8 @@ export interface RuntimeSettingsMutationV1 {
286
287
  readonly operations: readonly SettingsOperationV1[];
287
288
  }
288
289
  export interface OrionCodeUiRuntime extends RuntimeSessionAccessors {
290
+ /** Allocate an independent Session using the workspace default without switching owners. */
291
+ createFreshSession?: () => SessionMeta;
289
292
  cwd: string;
290
293
  version: string;
291
294
  config: OrionCodeCLIConfig;
@@ -304,7 +307,7 @@ export interface OrionCodeUiRuntime extends RuntimeSessionAccessors {
304
307
  /** Defaults to true; Web snapshots history and opts out of replaying it through live events. */
305
308
  readonly replayHistoryOnRestore?: boolean;
306
309
  }) => AgentRuntimeRunnerV1;
307
- /** Read-only v0.2 runtime diagnostics for `/harness explain`; never activates lazy providers. */
310
+ /** Read-only v0.2 runtime diagnostics for `/context explain`; never activates lazy providers. */
308
311
  getHarnessDiagnostics?: () => Promise<OrionRuntimeDiagnosticsV1 | undefined>;
309
312
  /** Descriptor-only Skill catalog for trusted product surfaces; never loads Skill bodies. */
310
313
  inspectSkills?: () => Promise<readonly SkillDescriptorV1[]>;
@@ -380,6 +380,12 @@ function createSessionRestoredView(event) {
380
380
  const summary = event.summary ? normalizeSingleLineText(event.summary) : undefined;
381
381
  const hasDetailedCounts = typeof event.transcriptMessages === 'number';
382
382
  const total = typeof event.messageCount === 'number' ? `/${event.messageCount}` : '';
383
+ const counts = hasDetailedCounts
384
+ ? `${event.restoredMessages} model-context / ${event.transcriptMessages} transcript messages`
385
+ : `${event.restoredMessages}${total} messages`;
386
+ const headline = event.reason === 'new'
387
+ ? `New session ${shortId}`
388
+ : `Resumed session ${shortId} · restored ${counts}`;
383
389
  const view = {
384
390
  sessionId: event.sessionId,
385
391
  shortId,
@@ -388,9 +394,7 @@ function createSessionRestoredView(event) {
388
394
  restoredMessages: event.restoredMessages,
389
395
  messageCount: event.messageCount,
390
396
  summary: summary || undefined,
391
- headline: hasDetailedCounts
392
- ? `Resumed session ${shortId} · restored ${event.restoredMessages} model-context / ${event.transcriptMessages} transcript messages`
393
- : `Resumed session ${shortId} · restored ${event.restoredMessages}${total} messages`,
397
+ headline,
394
398
  };
395
399
  if (event.summaryGeneratedAt !== undefined)
396
400
  view.summaryGeneratedAt = event.summaryGeneratedAt;
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: security-check
3
3
  description: Scan code for security vulnerabilities
4
- trigger: /security
4
+ trigger: /skill security-check
5
5
  tools:
6
6
  - read_file
7
7
  - glob
@@ -17,7 +17,7 @@ Identify potential security vulnerabilities in code.
17
17
 
18
18
  ## Usage
19
19
 
20
- Trigger: `/security [path]`
20
+ Run `/skill security-check <task>` with the code or dependencies to review.
21
21
 
22
22
  ## Security Patterns to Check
23
23
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: test-gen
3
3
  description: Generate test cases for existing code
4
- trigger: /test-gen
4
+ trigger: /skill test-gen
5
5
  tools:
6
6
  - read_file
7
7
  - write_file
@@ -17,7 +17,7 @@ Generate test cases for existing functions and modules.
17
17
 
18
18
  ## Usage
19
19
 
20
- Trigger: `/test-gen [path]` or `/test-gen [function]`
20
+ Run `/skill test-gen <task>` with the file, function, or behavior to test.
21
21
 
22
22
  ## Test Generation Strategy
23
23
 
@@ -661,7 +661,7 @@ class TerminalEventSink {
661
661
  sessionRestored(event) {
662
662
  this.append({
663
663
  role: 'status',
664
- title: 'resume',
664
+ title: event.reason === 'new' ? 'new' : 'resume',
665
665
  content: formatTerminalSessionRestored(event),
666
666
  });
667
667
  }
@@ -324,7 +324,10 @@ async function launchTuiUI(runtime, options = {}) {
324
324
  if (result.type === 'exit_requested') {
325
325
  void stop();
326
326
  }
327
- if (result.type === 'followup_queue_full' || result.type === 'followup_queue_rejected') {
327
+ if (result.type === 'followup_queue_full' ||
328
+ result.type === 'followup_queue_rejected' ||
329
+ result.type === 'command_rejected_busy' ||
330
+ result.type === 'command_ignored') {
328
331
  return false;
329
332
  }
330
333
  };
@@ -42,8 +42,8 @@ export interface TuiLayoutBudget {
42
42
  }
43
43
  /**
44
44
  * Measure the cursor-owned live block. Idle TUI state stays compact like an
45
- * ordinary shell prompt; streaming transcript and overlays grow the block only
46
- * as needed, up to the surface's viewport-derived limit.
45
+ * ordinary shell prompt. Composer pickers draw into this same block, so opening
46
+ * one does not allocate terminal rows or advance native scrollback.
47
47
  */
48
48
  export declare function measureTuiLiveFrameHeight(state: TuiUiState, width: number, maxHeight: number, options?: TuiTranscriptLayoutOptions): number;
49
49
  export declare function renderTuiUiFrame(state: TuiUiState, options: TuiLayoutOptions): TuiFrame;
@@ -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; streaming transcript and overlays grow the block only
59
- * as needed, up to the surface's viewport-derived limit.
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
- // Overlay covers the region above status (transcript + timeline).
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, state, maxRows) {
336
- if (!state.overlay || maxRows <= 0)
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
- if (state.overlay.type === 'sessions') {
339
- const overlay = state.overlay;
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(state.overlay.selectedIndex, visibleCount, request.sessions.length);
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 (state.overlay.type === 'model') {
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(state.overlay.selectedIndex, visibleCount, request.models.length);
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 (state.overlay.type === 'edit') {
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 (state.overlay.type === 'commands' || state.overlay.type === 'files') {
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 (state.overlay.type === 'shortcuts') {
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
  }
@@ -7,7 +7,9 @@ export interface TuiFileQuery {
7
7
  base: string;
8
8
  query: string;
9
9
  }
10
- export declare function visibleCommandItems(input: string): TuiPickerItem[];
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
@@ -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
- function visibleCommandItems(input) {
10
- const commandToken = input.match(/^\/([^\s]*)/u)?.[1] ?? '';
11
- return (0, ui_view_model_1.createCommandPickerState)({
12
- input: `/${commandToken}`,
13
- commands: (0, commands_1.getVisibleCommands)('tui'),
14
- maxVisibleItems: 10,
15
- categoryLabel: commands_1.getCommandCategoryLabel,
16
- }).visibleItems.map(item => ({
17
- value: item.value,
18
- label: item.label,
19
- description: item.description,
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) {
@@ -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. */