@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +4 -4
  3. package/README.zh-CN.md +4 -4
  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/harness/context-harness.d.ts +1 -1
  19. package/dist/harness/context-harness.js +1 -1
  20. package/dist/harness/stop-controller.js +1 -1
  21. package/dist/runtime/agent-runtime-controller.d.ts +4 -2
  22. package/dist/runtime/agent-runtime-controller.js +115 -30
  23. package/dist/runtime/orion-session-runner.js +3 -5
  24. package/dist/runtime/product-bootstrap.js +24 -11
  25. package/dist/runtime/ui-events.d.ts +4 -1
  26. package/dist/runtime/ui-view-model.js +7 -3
  27. package/dist/skills/builtin/security-check/SKILL.md +2 -2
  28. package/dist/skills/builtin/test-gen/SKILL.md +2 -2
  29. package/dist/terminal-ui/launch.js +1 -1
  30. package/dist/tui-ui/launch.js +4 -1
  31. package/dist/tui-ui/layout.d.ts +2 -2
  32. package/dist/tui-ui/layout.js +59 -47
  33. package/dist/tui-ui/pickers.d.ts +3 -1
  34. package/dist/tui-ui/pickers.js +17 -11
  35. package/dist/tui-ui/runner.d.ts +1 -1
  36. package/dist/tui-ui/runner.js +61 -68
  37. package/dist/tui-ui/state.d.ts +4 -0
  38. package/dist/tui-ui/state.js +33 -2
  39. package/docs/cli-guide.md +20 -1
  40. package/npm-shrinkwrap.json +2 -2
  41. package/package.json +1 -1
@@ -4,7 +4,7 @@
4
4
  * 使用 `/` 前缀的命令系统,支持 Tab 补全、命令建议、参数定义。
5
5
  * 非 `/` 前缀的输入直接作为 chat 消息处理。
6
6
  */
7
- import type { Store } from '../framework/store';
7
+ import type { AppState, Store } from '../framework/store';
8
8
  import type { LLMService } from '../services/llm';
9
9
  import type { OrionCodeCLIConfig, UIRenderer } from '../services/config';
10
10
  import type { SessionMeta } from '../services/session-storage';
@@ -32,9 +32,13 @@ export interface CommandContext {
32
32
  sessionId?: string;
33
33
  /** Lazily create or return the active session. */
34
34
  ensureSession?: () => SessionMeta;
35
+ /** Start an independent durable session and activate its runtime. */
36
+ startNewSession?: () => Promise<SessionMeta>;
35
37
  /** Switch the active session after /resume. */
36
38
  setSession?: (session: SessionMeta) => void;
37
- /** Rebind the product runtime and replay the selected durable Thread after /resume. */
39
+ /** Activate a verified Session/Thread and its read-side projection as one transition. */
40
+ activateSessionRuntime?: (session: SessionMeta, activation: ThreadSessionRuntimeActivationV1 | undefined, projection: Pick<AppState, 'conversationHistory' | 'harnessState'>) => Promise<void>;
41
+ /** Rebind an external runtime after selecting a Session. */
38
42
  restoreSessionRuntime?: (activation?: ThreadSessionRuntimeActivationV1) => Promise<void>;
39
43
  /** Notify renderer-independent runtime protocol consumers after /resume. */
40
44
  sessionRestored?: (event: RuntimeSessionRestoredEvent) => void;
@@ -52,8 +56,6 @@ export interface CommandContext {
52
56
  writeOutput?: (text: string) => void;
53
57
  /** Write one line while preserving the live input frame, when supported by the UI. */
54
58
  writeLine?: (text?: string) => void;
55
- /** Ask the active renderer to clear its viewport without deleting session data. */
56
- clearView?: () => void;
57
59
  /** Ask the active renderer to begin graceful shutdown. */
58
60
  requestShutdown?: (reason?: string) => void;
59
61
  /** Active renderer adapter identity, including non-config renderers such as print mode. */
@@ -74,30 +74,6 @@ exports.WORKFLOW_COMMANDS = [
74
74
  risk: 'read-only',
75
75
  execute: (_ctx, args) => (0, workflow_command_handlers_1.continueAsSlashChat)('research', args),
76
76
  },
77
- {
78
- name: 'security',
79
- aliases: ['audit'],
80
- description: 'Review code or dependencies for security risks',
81
- argumentHint: '[scope]',
82
- category: 'workflow',
83
- priority: 20,
84
- type: 'chat',
85
- execution: 'agent-workflow',
86
- risk: 'read-only',
87
- execute: (_ctx, args) => (0, workflow_command_handlers_1.continueAsSlashChat)('security', args),
88
- },
89
- {
90
- name: 'test-gen',
91
- aliases: ['tests'],
92
- description: 'Generate or improve tests for a target area',
93
- argumentHint: '[scope]',
94
- category: 'workflow',
95
- priority: 30,
96
- type: 'chat',
97
- execution: 'agent-workflow',
98
- risk: 'state-write',
99
- execute: (_ctx, args) => (0, workflow_command_handlers_1.continueAsSlashChat)('test-gen', args),
100
- },
101
77
  {
102
78
  name: 'todos',
103
79
  aliases: ['todo'],
@@ -863,7 +863,7 @@ async function* query(params) {
863
863
  status: planStop.code === 'task_step_blocked' ? 'blocked' : 'stopped',
864
864
  reason: { code: planStop.code, message: planStop.message },
865
865
  nextActions: [
866
- { kind: 'inspect', label: 'Inspect the current checklist', command: '/harness explain' },
866
+ { kind: 'inspect', label: 'Inspect the current checklist', command: '/context explain' },
867
867
  { kind: 'continue', label: 'Continue the current task', command: '继续' },
868
868
  ],
869
869
  };
@@ -100,7 +100,7 @@ export declare class HarnessKernel {
100
100
  getContract(): HarnessState['contract'];
101
101
  getIntentHistory(): IntentUpdate[];
102
102
  /**
103
- * Generate a structured diagnostic summary for /harness explain
103
+ * Generate a structured diagnostic summary for /context explain
104
104
  */
105
105
  explain(): {
106
106
  contract: HarnessState['contract'];
@@ -872,7 +872,7 @@ class HarnessKernel {
872
872
  return this.intentHistory;
873
873
  }
874
874
  /**
875
- * Generate a structured diagnostic summary for /harness explain
875
+ * Generate a structured diagnostic summary for /context explain
876
876
  */
877
877
  explain() {
878
878
  this.refreshEvidenceIndex();
@@ -52,7 +52,7 @@ class StopController {
52
52
  {
53
53
  kind: 'inspect',
54
54
  label: 'Inspect missing criterion evidence',
55
- command: '/harness explain',
55
+ command: '/context explain',
56
56
  },
57
57
  ],
58
58
  resources: {},
@@ -74,6 +74,7 @@ export declare class AgentRuntimeController {
74
74
  private readonly agentModeLifecycle;
75
75
  private readonly pendingPermissions;
76
76
  private activeRun;
77
+ private sessionChange?;
77
78
  private activeReview?;
78
79
  private pendingAgentMode;
79
80
  private readonly goalControlRuns;
@@ -111,8 +112,6 @@ export declare class AgentRuntimeController {
111
112
  };
112
113
  /** Goal controls remain available while a turn is active only when they can stop or inspect it. */
113
114
  canInterceptTargetCommand(input: string, duringActiveTurn: boolean): boolean;
114
- /** v0.1.1: emit clear_view event through the renderer protocol. */
115
- emitClearView(): void;
116
115
  /** v0.1.1: emit shutdown_requested event through the renderer protocol. */
117
116
  emitShutdownRequested(reason?: string): void;
118
117
  setVerificationState(state: 'pending' | 'running' | 'passed' | 'failed' | 'gated'): void;
@@ -129,9 +128,12 @@ export declare class AgentRuntimeController {
129
128
  private nextPendingFollowup;
130
129
  private manageFollowupQueue;
131
130
  submit(input: string): AgentRuntimeSubmitResult;
131
+ private rejectDuringSessionChange;
132
132
  private emitImmediateCommandSnapshot;
133
133
  private runTrackedReview;
134
134
  private runCommand;
135
+ private activateSessionRuntime;
136
+ private startNewSession;
135
137
  private createCommandContext;
136
138
  private submitTurnRequest;
137
139
  interrupt(): AgentRuntimeInterruptResult;
@@ -4,6 +4,7 @@ exports.AgentRuntimeController = exports.FollowupQueueConflictError = void 0;
4
4
  const async_hooks_1 = require("async_hooks");
5
5
  const commands_1 = require("../commands");
6
6
  const parser_1 = require("../commands/parser");
7
+ const retired_commands_1 = require("../commands/retired-commands");
7
8
  const target_command_1 = require("../commands/target-command");
8
9
  const agent_runtime_protocol_1 = require("./agent-runtime-protocol");
9
10
  const agent_status_1 = require("./agent-status");
@@ -11,6 +12,7 @@ const ui_events_1 = require("./ui-events");
11
12
  const turn_controller_1 = require("./turn-controller");
12
13
  const agent_mode_1 = require("../framework/agent-mode");
13
14
  const redaction_1 = require("../services/redaction");
15
+ const session_storage_1 = require("../services/session-storage");
14
16
  const style_1 = require("../tui-core/style");
15
17
  const followup_queue_store_1 = require("./followup-queue-store");
16
18
  const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
@@ -23,10 +25,6 @@ class FollowupQueueConflictError extends Error {
23
25
  }
24
26
  }
25
27
  exports.FollowupQueueConflictError = FollowupQueueConflictError;
26
- function isExitInput(input) {
27
- const parsed = (0, parser_1.parseInput)(input.trim());
28
- return parsed.isCommand && ['exit', 'quit', 'q'].includes(parsed.name);
29
- }
30
28
  function submittedEntry(input) {
31
29
  const parsed = (0, parser_1.parseInput)(input.trim());
32
30
  return {
@@ -180,6 +178,9 @@ class AgentRuntimeController {
180
178
  }
181
179
  /** Thin /goal control surface; GoalRuntimeCoordinatorV2 owns every mutation. */
182
180
  handleTargetInput(rawInput) {
181
+ if (this.sessionChange) {
182
+ return { handled: true, runtimeResult: this.rejectDuringSessionChange() };
183
+ }
183
184
  const parsed = (0, target_command_1.parseTargetCommand)(rawInput);
184
185
  if (!parsed.ok) {
185
186
  this.emitAppend({
@@ -209,10 +210,6 @@ class AgentRuntimeController {
209
210
  return true;
210
211
  return ['status', 'pause', 'clear'].includes(parsed.input.action);
211
212
  }
212
- /** v0.1.1: emit clear_view event through the renderer protocol. */
213
- emitClearView() {
214
- this.eventSink.emit({ type: 'clear_view' });
215
- }
216
213
  /** v0.1.1: emit shutdown_requested event through the renderer protocol. */
217
214
  emitShutdownRequested(reason) {
218
215
  this.runner.interrupt?.(reason ?? 'shutdown requested');
@@ -234,7 +231,9 @@ class AgentRuntimeController {
234
231
  case 'queue_followup':
235
232
  return this.queueFollowup(input.text, input.resolvedText);
236
233
  case 'manage_followup_queue':
237
- return this.manageFollowupQueue(input.action, input.itemId);
234
+ return this.sessionChange
235
+ ? this.rejectDuringSessionChange()
236
+ : this.manageFollowupQueue(input.action, input.itemId);
238
237
  case 'select_session':
239
238
  return this.submit(resumeSessionInput(input.sessionId, input.allProjects));
240
239
  case 'permission_decision':
@@ -247,13 +246,15 @@ class AgentRuntimeController {
247
246
  case 'goal_control':
248
247
  return this.startGoalControl(input);
249
248
  case 'cycle_agent_mode':
250
- return this.cycleAgentMode();
249
+ return this.sessionChange ? this.rejectDuringSessionChange() : this.cycleAgentMode();
251
250
  case 'set_agent_mode':
252
251
  return this.setAgentMode(input.mode);
253
252
  }
254
253
  }
255
254
  /** Set an exact mode immediately while idle, or at the next logical-request boundary. */
256
255
  setAgentMode(mode) {
256
+ if (this.sessionChange)
257
+ return this.rejectDuringSessionChange();
257
258
  const deferred = this.turnController.hasActiveTurn();
258
259
  if (!deferred) {
259
260
  this.pendingAgentMode = null;
@@ -413,30 +414,37 @@ class AgentRuntimeController {
413
414
  const submitted = input.trim();
414
415
  if (!submitted)
415
416
  return { type: 'empty' };
416
- if (isExitInput(submitted)) {
417
+ const parsedInput = (0, parser_1.parseInput)(submitted);
418
+ const command = parsedInput.canonicalName ? (0, commands_1.findCommand)(parsedInput.canonicalName) : undefined;
419
+ if (command?.name === 'quit') {
417
420
  this.emitShutdownRequested('user request');
418
421
  return { type: 'exit_requested' };
419
422
  }
423
+ if (parsedInput.isCommand) {
424
+ const retired = (0, retired_commands_1.retiredCommandNotice)(parsedInput.name, parsedInput.args);
425
+ if (retired || !command) {
426
+ const message = retired ?? `Unknown command /${parsedInput.name}. Use /help to list supported commands.`;
427
+ this.emitAppend({
428
+ role: 'error',
429
+ title: retired ? 'retired command' : 'unknown command',
430
+ content: message,
431
+ });
432
+ this.emitStatus(message);
433
+ return { type: 'command_handled' };
434
+ }
435
+ }
436
+ if (this.sessionChange)
437
+ return this.rejectDuringSessionChange(command);
420
438
  if ((0, target_command_1.isTargetCommand)(submitted)) {
421
439
  return this.handleTargetInput(submitted).runtimeResult;
422
440
  }
423
- const parsedInput = (0, parser_1.parseInput)(submitted);
424
- if (parsedInput.isCommand && parsedInput.name === 'clear') {
425
- this.emitClearView();
426
- this.emitStatus('View cleared. Conversation context is preserved.');
427
- return { type: 'command_handled' };
428
- }
429
- if (parsedInput.isCommand && !(0, commands_1.findCommand)(parsedInput.name)) {
430
- const message = `Unknown command /${parsedInput.name}. Use /help to list supported commands.`;
431
- this.emitAppend({ role: 'error', title: 'unknown command', content: message });
432
- this.emitStatus(message);
433
- return { type: 'command_handled' };
434
- }
435
- if (parsedInput.isCommand) {
436
- const command = (0, commands_1.findCommand)(parsedInput.name);
441
+ if (command) {
437
442
  const isReview = command.name === 'review';
438
- if (isReview && (this.activeRun || this.goalControlRuns.size > 0 || this.goalRuntimeActive)) {
439
- this.emitStatus('/review rejected: an agent operation is active.');
443
+ const changesSession = ['new', 'rename', 'resume'].includes(command.name) ||
444
+ (command.name === 'session' && /^rename(?:\s|$)/u.test(parsedInput.args));
445
+ if ((isReview || changesSession) &&
446
+ (this.activeRun || this.goalControlRuns.size > 0 || this.goalRuntimeActive || this.stopping)) {
447
+ this.emitStatus(`/${command.name} rejected: an agent operation is active.`);
440
448
  return { type: 'command_rejected_busy', commandId: command.id };
441
449
  }
442
450
  if (this.hasActiveTurn()) {
@@ -458,11 +466,15 @@ class AgentRuntimeController {
458
466
  this.emitStatus(`Queued /${command.name}; it will apply after the active logical request.`);
459
467
  return { type: 'command_queued', commandId: command.id };
460
468
  }
469
+ if (changesSession)
470
+ this.sessionChange = command.name;
461
471
  const run = (isReview
462
472
  ? this.runTrackedReview(command, parsedInput.args)
463
473
  : this.runCommand(command, parsedInput.args))
464
474
  .catch(error => this.handleCommandError(command, error))
465
475
  .finally(() => {
476
+ if (changesSession)
477
+ this.sessionChange = undefined;
466
478
  if (this.activeRun === run)
467
479
  this.activeRun = null;
468
480
  });
@@ -495,6 +507,12 @@ class AgentRuntimeController {
495
507
  };
496
508
  return this.submitTurnRequest(request);
497
509
  }
510
+ rejectDuringSessionChange(command) {
511
+ this.emitStatus(`Wait for /${this.sessionChange} to finish changing the session.`);
512
+ return command
513
+ ? { type: 'command_rejected_busy', commandId: command.id }
514
+ : { type: 'command_ignored' };
515
+ }
498
516
  emitImmediateCommandSnapshot(name) {
499
517
  const snapshot = this.options.runtime.store.getSnapshot?.() ?? {
500
518
  currentModel: this.options.runtime.config.model ?? 'unknown',
@@ -615,7 +633,70 @@ class AgentRuntimeController {
615
633
  });
616
634
  }
617
635
  }
636
+ async activateSessionRuntime(selected, activation, projection) {
637
+ const { runtime } = this.options;
638
+ const previous = runtime.getSession();
639
+ const snapshot = runtime.store.getSnapshot();
640
+ const previousGoalActive = this.goalRuntimeActive;
641
+ try {
642
+ runtime.setSession(selected);
643
+ if (projection)
644
+ runtime.store.setState(projection);
645
+ await this.runner.restoreSession?.(activation);
646
+ }
647
+ catch (error) {
648
+ runtime.setSession(previous);
649
+ this.goalRuntimeActive = previousGoalActive;
650
+ runtime.store.setState({
651
+ conversationHistory: snapshot.conversationHistory,
652
+ tokenUsage: snapshot.tokenUsage,
653
+ contextUsage: snapshot.contextUsage,
654
+ harnessState: snapshot.harnessState,
655
+ lastLoopStats: snapshot.lastLoopStats,
656
+ currentPlan: snapshot.currentPlan,
657
+ todos: snapshot.todos,
658
+ agentMode: snapshot.agentMode,
659
+ planMode: snapshot.planMode,
660
+ planReturnMode: snapshot.planReturnMode,
661
+ });
662
+ if (previous) {
663
+ try {
664
+ (0, session_storage_1.resumeSession)(previous.id);
665
+ await this.runner.restoreSession?.();
666
+ }
667
+ catch (restoreError) {
668
+ const startFailure = error instanceof Error ? error.message : String(error);
669
+ const rollbackFailure = restoreError instanceof Error ? restoreError.message : String(restoreError);
670
+ throw new Error(`Could not switch sessions (${startFailure}) or reopen the previous runtime (${rollbackFailure}).`);
671
+ }
672
+ }
673
+ throw error;
674
+ }
675
+ }
676
+ async startNewSession(createSession) {
677
+ if (this.stopping)
678
+ throw new Error('The runtime is shutting down.');
679
+ const created = createSession();
680
+ await this.activateSessionRuntime(created);
681
+ this.queuedCommands.length = 0;
682
+ this.turnController.clearExitIntent();
683
+ this.agentModeLifecycle.setMode('interactive');
684
+ this.eventSink.emit({ type: 'transcript_replace', entries: [] });
685
+ this.eventSink.emit({
686
+ type: 'session_restored',
687
+ event: {
688
+ reason: 'new',
689
+ sessionId: created.id,
690
+ projectPath: created.projectPath,
691
+ model: created.model,
692
+ restoredMessages: 0,
693
+ messageCount: 0,
694
+ },
695
+ });
696
+ return created;
697
+ }
618
698
  createCommandContext(abortSignal) {
699
+ const createFreshSession = this.options.runtime.createFreshSession;
619
700
  const renderer = this.options.uiRenderer ?? this.options.runtime.config.ui?.renderer ?? 'terminal';
620
701
  return {
621
702
  cwd: this.options.runtime.cwd,
@@ -628,9 +709,12 @@ class AgentRuntimeController {
628
709
  sessionComposerControls: this.options.runtime.sessionComposerControls,
629
710
  sessionId: this.options.runtime.getSession()?.id,
630
711
  ensureSession: this.options.runtime.ensureSession,
712
+ startNewSession: createFreshSession
713
+ ? () => this.startNewSession(createFreshSession)
714
+ : undefined,
631
715
  setSession: session => this.options.runtime.setSession(session),
632
- restoreSessionRuntime: this.runner.restoreSession
633
- ? activation => this.runner.restoreSession(activation)
716
+ activateSessionRuntime: this.runner.restoreSession
717
+ ? (session, activation, projection) => this.activateSessionRuntime(session, activation, projection)
634
718
  : undefined,
635
719
  sessionRestored: event => this.eventSink.emit({ type: 'session_restored', event }),
636
720
  ...((renderer === 'terminal' || renderer === 'tui') && {
@@ -645,7 +729,6 @@ class AgentRuntimeController {
645
729
  if (text?.trim())
646
730
  this.emitAppend({ role: 'system', content: text });
647
731
  },
648
- clearView: () => this.emitClearView(),
649
732
  requestShutdown: reason => this.emitShutdownRequested(reason),
650
733
  uiRenderer: renderer,
651
734
  uiCapabilities: (0, ui_events_1.resolveUiRendererCapabilities)(this.options.uiCapabilities, renderer),
@@ -1065,6 +1148,8 @@ class AgentRuntimeController {
1065
1148
  });
1066
1149
  }
1067
1150
  startGoalControl(control) {
1151
+ if (this.sessionChange)
1152
+ return this.rejectDuringSessionChange();
1068
1153
  const goalControl = normalizeGoalRuntimeControl(control);
1069
1154
  if (!this.runner.controlGoal) {
1070
1155
  const message = 'Goal runtime is unavailable for the active product session.';
@@ -73,11 +73,9 @@ class OrionSessionRunnerV1 {
73
73
  if (this.transition === transition)
74
74
  this.transition = undefined;
75
75
  }
76
- // A typed activation denotes an actual Session selection and is followed
77
- // by a bounded transcript replacement from the command surface. A same-
78
- // Session runtime rebind (for example after Settings changes) has no such
79
- // replacement and must preserve the current renderer window.
80
- if (activation || this.options.replayHistoryOnRestore !== false) {
76
+ // Interactive commands publish their bounded replacement only after the
77
+ // new owner starts. A runner that replays from the beginning owns its view.
78
+ if (this.options.replayHistoryOnRestore !== false) {
81
79
  this.options.eventSink.clearTranscript();
82
80
  }
83
81
  active.adapter.flush();
@@ -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,
@@ -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;