@bastani/atomic 0.9.5-alpha.6 → 0.9.5-alpha.8

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 (283) hide show
  1. package/CHANGELOG.md +35 -2
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/CHANGELOG.md +17 -0
  4. package/dist/builtin/intercom/README.md +27 -21
  5. package/dist/builtin/intercom/broker/broker.ts +3 -6
  6. package/dist/builtin/intercom/broker/paths.ts +42 -5
  7. package/dist/builtin/intercom/broker/spawn.ts +78 -10
  8. package/dist/builtin/intercom/config.ts +6 -3
  9. package/dist/builtin/intercom/contact-supervisor-tool.ts +6 -4
  10. package/dist/builtin/intercom/index-heavy.ts +1 -1
  11. package/dist/builtin/intercom/index.ts +162 -130
  12. package/dist/builtin/intercom/intercom-tool.ts +9 -3
  13. package/dist/builtin/intercom/package.json +10 -1
  14. package/dist/builtin/intercom/result-renderers.ts +1 -1
  15. package/dist/builtin/intercom/ui/compose.ts +2 -2
  16. package/dist/builtin/intercom/ui/inline-message.ts +2 -2
  17. package/dist/builtin/intercom/ui/session-list.ts +2 -2
  18. package/dist/builtin/mcp/package.json +1 -1
  19. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  20. package/dist/builtin/subagents/package.json +1 -1
  21. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +15 -48
  22. package/dist/builtin/subagents/src/tui/render-layout.ts +9 -0
  23. package/dist/builtin/subagents/src/tui/render-widget-graph.ts +27 -25
  24. package/dist/builtin/subagents/src/tui/render-widget.ts +46 -69
  25. package/dist/builtin/subagents/src/tui/render.ts +1 -1
  26. package/dist/builtin/web-access/package.json +1 -1
  27. package/dist/builtin/workflows/CHANGELOG.md +11 -0
  28. package/dist/builtin/workflows/README.md +3 -1
  29. package/dist/builtin/workflows/builtin/goal-artifacts.ts +3 -1
  30. package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -2
  31. package/dist/builtin/workflows/builtin/goal-reducer.ts +21 -0
  32. package/dist/builtin/workflows/builtin/goal-review.ts +60 -6
  33. package/dist/builtin/workflows/builtin/goal-runner.ts +32 -21
  34. package/dist/builtin/workflows/builtin/goal-types.ts +7 -1
  35. package/dist/builtin/workflows/builtin/ralph-core.ts +52 -4
  36. package/dist/builtin/workflows/builtin/ralph-review-gate.ts +10 -3
  37. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +23 -2
  38. package/dist/builtin/workflows/builtin/ralph-runner.ts +38 -16
  39. package/dist/builtin/workflows/builtin/review-convergence.ts +111 -0
  40. package/dist/builtin/workflows/package.json +1 -1
  41. package/dist/builtin/workflows/skills/create-spec/SKILL.md +2 -0
  42. package/dist/builtin/workflows/src/durable/child-primitive.ts +12 -8
  43. package/dist/builtin/workflows/src/durable/dbos-backend.ts +47 -2
  44. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +28 -0
  45. package/dist/builtin/workflows/src/durable/stage-primitive.ts +165 -27
  46. package/dist/builtin/workflows/src/durable/types.ts +14 -1
  47. package/dist/builtin/workflows/src/engine/run.ts +12 -13
  48. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +2 -0
  49. package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +13 -3
  50. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +1 -1
  51. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +18 -19
  52. package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +38 -0
  53. package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +18 -1
  54. package/dist/builtin/workflows/src/shared/persistence-restore.ts +23 -5
  55. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
  56. package/dist/bun/internal-intercom-broker.d.ts +6 -0
  57. package/dist/bun/internal-intercom-broker.d.ts.map +1 -0
  58. package/dist/bun/internal-intercom-broker.js +39 -0
  59. package/dist/bun/internal-intercom-broker.js.map +1 -0
  60. package/dist/bun/split-loader.d.ts +2 -0
  61. package/dist/bun/split-loader.d.ts.map +1 -0
  62. package/dist/bun/split-loader.js +50 -0
  63. package/dist/bun/split-loader.js.map +1 -0
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +6 -4
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-session-auto-compaction.d.ts +7 -7
  68. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  69. package/dist/core/agent-session-auto-compaction.js +62 -16
  70. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  71. package/dist/core/agent-session-events.d.ts.map +1 -1
  72. package/dist/core/agent-session-events.js +3 -1
  73. package/dist/core/agent-session-events.js.map +1 -1
  74. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  75. package/dist/core/agent-session-extension-bindings.js +1 -1
  76. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  77. package/dist/core/agent-session-methods.d.ts +10 -4
  78. package/dist/core/agent-session-methods.d.ts.map +1 -1
  79. package/dist/core/agent-session-methods.js.map +1 -1
  80. package/dist/core/agent-session-models.d.ts +2 -2
  81. package/dist/core/agent-session-models.d.ts.map +1 -1
  82. package/dist/core/agent-session-models.js.map +1 -1
  83. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  84. package/dist/core/agent-session-prompt.js +1 -0
  85. package/dist/core/agent-session-prompt.js.map +1 -1
  86. package/dist/core/agent-session-retry.d.ts +2 -0
  87. package/dist/core/agent-session-retry.d.ts.map +1 -1
  88. package/dist/core/agent-session-retry.js +152 -4
  89. package/dist/core/agent-session-retry.js.map +1 -1
  90. package/dist/core/agent-session-services.d.ts +1 -0
  91. package/dist/core/agent-session-services.d.ts.map +1 -1
  92. package/dist/core/agent-session-services.js +1 -0
  93. package/dist/core/agent-session-services.js.map +1 -1
  94. package/dist/core/agent-session-types.d.ts +15 -1
  95. package/dist/core/agent-session-types.d.ts.map +1 -1
  96. package/dist/core/agent-session-types.js.map +1 -1
  97. package/dist/core/agent-session.d.ts +4 -0
  98. package/dist/core/agent-session.d.ts.map +1 -1
  99. package/dist/core/agent-session.js +4 -0
  100. package/dist/core/agent-session.js.map +1 -1
  101. package/dist/core/builtin-packages.d.ts.map +1 -1
  102. package/dist/core/builtin-packages.js +8 -4
  103. package/dist/core/builtin-packages.js.map +1 -1
  104. package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
  105. package/dist/core/compaction/context-compaction-runner.js +36 -20
  106. package/dist/core/compaction/context-compaction-runner.js.map +1 -1
  107. package/dist/core/copilot-anthropic-sse-repair.d.ts +23 -0
  108. package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -0
  109. package/dist/core/copilot-anthropic-sse-repair.js +340 -0
  110. package/dist/core/copilot-anthropic-sse-repair.js.map +1 -0
  111. package/dist/core/copilot-gemini-reasoning.d.ts +16 -8
  112. package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
  113. package/dist/core/copilot-gemini-reasoning.js +27 -22
  114. package/dist/core/copilot-gemini-reasoning.js.map +1 -1
  115. package/dist/core/copilot-hosts.d.ts +12 -0
  116. package/dist/core/copilot-hosts.d.ts.map +1 -0
  117. package/dist/core/copilot-hosts.js +33 -0
  118. package/dist/core/copilot-hosts.js.map +1 -0
  119. package/dist/core/copilot-model-catalog.d.ts.map +1 -1
  120. package/dist/core/copilot-model-catalog.js +3 -2
  121. package/dist/core/copilot-model-catalog.js.map +1 -1
  122. package/dist/core/extensions/agent-events.d.ts +1 -1
  123. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  124. package/dist/core/extensions/agent-events.js.map +1 -1
  125. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  126. package/dist/core/extensions/loader-virtual-modules.js +8 -3
  127. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  128. package/dist/core/http-dispatcher.d.ts.map +1 -1
  129. package/dist/core/http-dispatcher.js +5 -5
  130. package/dist/core/http-dispatcher.js.map +1 -1
  131. package/dist/core/openai-responses-payload-sanitizer.d.ts +6 -0
  132. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -0
  133. package/dist/core/openai-responses-payload-sanitizer.js +59 -0
  134. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -0
  135. package/dist/core/package-manager-auto-resources.d.ts +2 -2
  136. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  137. package/dist/core/package-manager-auto-resources.js +32 -52
  138. package/dist/core/package-manager-auto-resources.js.map +1 -1
  139. package/dist/core/package-manager-resolver.d.ts.map +1 -1
  140. package/dist/core/package-manager-resolver.js +23 -14
  141. package/dist/core/package-manager-resolver.js.map +1 -1
  142. package/dist/core/package-manager-resource-collector.d.ts +3 -3
  143. package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
  144. package/dist/core/package-manager-resource-collector.js +76 -73
  145. package/dist/core/package-manager-resource-collector.js.map +1 -1
  146. package/dist/core/package-manager-resource-files.d.ts +9 -8
  147. package/dist/core/package-manager-resource-files.d.ts.map +1 -1
  148. package/dist/core/package-manager-resource-files.js +92 -81
  149. package/dist/core/package-manager-resource-files.js.map +1 -1
  150. package/dist/core/prompt-templates-async.d.ts +3 -0
  151. package/dist/core/prompt-templates-async.d.ts.map +1 -0
  152. package/dist/core/prompt-templates-async.js +118 -0
  153. package/dist/core/prompt-templates-async.js.map +1 -0
  154. package/dist/core/provider-context-usage.d.ts +11 -0
  155. package/dist/core/provider-context-usage.d.ts.map +1 -0
  156. package/dist/core/provider-context-usage.js +58 -0
  157. package/dist/core/provider-context-usage.js.map +1 -0
  158. package/dist/core/resource-loader-assets.d.ts +3 -3
  159. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  160. package/dist/core/resource-loader-assets.js +66 -83
  161. package/dist/core/resource-loader-assets.js.map +1 -1
  162. package/dist/core/resource-loader-core.d.ts +1 -1
  163. package/dist/core/resource-loader-core.d.ts.map +1 -1
  164. package/dist/core/resource-loader-core.js +5 -5
  165. package/dist/core/resource-loader-core.js.map +1 -1
  166. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  167. package/dist/core/resource-loader-reload.js +43 -7
  168. package/dist/core/resource-loader-reload.js.map +1 -1
  169. package/dist/core/resource-loader-types.d.ts +7 -1
  170. package/dist/core/resource-loader-types.d.ts.map +1 -1
  171. package/dist/core/resource-loader-types.js.map +1 -1
  172. package/dist/core/sdk-types.d.ts +2 -0
  173. package/dist/core/sdk-types.d.ts.map +1 -1
  174. package/dist/core/sdk-types.js.map +1 -1
  175. package/dist/core/sdk.d.ts.map +1 -1
  176. package/dist/core/sdk.js +7 -4
  177. package/dist/core/sdk.js.map +1 -1
  178. package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
  179. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  180. package/dist/core/settings-manager-basic-accessors.js +6 -0
  181. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  182. package/dist/core/settings-types.d.ts +1 -0
  183. package/dist/core/settings-types.d.ts.map +1 -1
  184. package/dist/core/settings-types.js.map +1 -1
  185. package/dist/core/skills-async.d.ts +3 -0
  186. package/dist/core/skills-async.d.ts.map +1 -0
  187. package/dist/core/skills-async.js +269 -0
  188. package/dist/core/skills-async.js.map +1 -0
  189. package/dist/index-extensions.d.ts +1 -1
  190. package/dist/index-extensions.d.ts.map +1 -1
  191. package/dist/index-extensions.js.map +1 -1
  192. package/dist/main-deferred-startup.d.ts +14 -0
  193. package/dist/main-deferred-startup.d.ts.map +1 -1
  194. package/dist/main-deferred-startup.js +23 -0
  195. package/dist/main-deferred-startup.js.map +1 -1
  196. package/dist/main-early-input.d.ts +41 -0
  197. package/dist/main-early-input.d.ts.map +1 -0
  198. package/dist/main-early-input.js +147 -0
  199. package/dist/main-early-input.js.map +1 -0
  200. package/dist/main.d.ts +0 -6
  201. package/dist/main.d.ts.map +1 -1
  202. package/dist/main.js +23 -17
  203. package/dist/main.js.map +1 -1
  204. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  205. package/dist/modes/interactive/components/chat-session-host-events.js +15 -0
  206. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  207. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  208. package/dist/modes/interactive/interactive-agent-events.js +34 -1
  209. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  210. package/dist/modes/interactive/interactive-deferred-startup.d.ts +6 -0
  211. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  212. package/dist/modes/interactive/interactive-deferred-startup.js +27 -13
  213. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  214. package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
  215. package/dist/modes/interactive/interactive-editor-actions.js +13 -13
  216. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  217. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  218. package/dist/modes/interactive/interactive-extension-runtime.js +16 -0
  219. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  220. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  221. package/dist/modes/interactive/interactive-input-handling.js +324 -178
  222. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  223. package/dist/modes/interactive/interactive-mode-base.d.ts +14 -0
  224. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  225. package/dist/modes/interactive/interactive-mode-base.js +41 -0
  226. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  227. package/dist/modes/interactive/interactive-mode-surface.d.ts +22 -6
  228. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  229. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  230. package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
  231. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  232. package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
  233. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  234. package/dist/modes/interactive/interactive-model-routing.js +3 -3
  235. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  236. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
  237. package/dist/modes/interactive/interactive-onboarding.js +1 -0
  238. package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
  239. package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
  240. package/dist/modes/interactive/interactive-process-lifecycle.js +43 -6
  241. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  242. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  243. package/dist/modes/interactive/interactive-render-chat.js +78 -9
  244. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  245. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  246. package/dist/modes/interactive/interactive-resource-disclosure.js +3 -2
  247. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  248. package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
  249. package/dist/modes/interactive/interactive-resource-rendering.js +10 -8
  250. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  251. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  252. package/dist/modes/interactive/interactive-session-runtime.js +1 -1
  253. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  254. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  255. package/dist/modes/interactive/interactive-startup.js +65 -53
  256. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  257. package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
  258. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  259. package/dist/modes/interactive/theme/theme-loading.js +3 -0
  260. package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
  261. package/dist/modes/interactive/theme/theme.d.ts +1 -1
  262. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  263. package/dist/modes/interactive/theme/theme.js +1 -1
  264. package/dist/modes/interactive/theme/theme.js.map +1 -1
  265. package/dist/utils/module-require.d.ts +11 -0
  266. package/dist/utils/module-require.d.ts.map +1 -1
  267. package/dist/utils/module-require.js +14 -1
  268. package/dist/utils/module-require.js.map +1 -1
  269. package/dist/utils/split-launcher.d.ts +38 -0
  270. package/dist/utils/split-launcher.d.ts.map +1 -0
  271. package/dist/utils/split-launcher.js +63 -0
  272. package/dist/utils/split-launcher.js.map +1 -0
  273. package/docs/compaction.md +7 -0
  274. package/docs/json.md +3 -1
  275. package/docs/keybindings.md +2 -2
  276. package/docs/providers.md +2 -1
  277. package/docs/rpc.md +3 -1
  278. package/docs/settings.md +28 -2
  279. package/docs/terminal-setup.md +4 -0
  280. package/docs/usage.md +3 -3
  281. package/docs/workflows.md +13 -3
  282. package/npm-shrinkwrap.json +513 -23
  283. package/package.json +5 -4
@@ -1,6 +1,51 @@
1
- import { InteractiveModeBase } from "./interactive-mode-base.js";
1
+ import { InteractiveModeBase, seedStartupInput } from "./interactive-mode-base.js";
2
2
  import { pasteClipboardImageToEditor } from "./interactive-mode-deps.js";
3
+ import { yieldToEventLoop } from "../../utils/event-loop.js";
4
+ InteractiveModeBase.prototype.runUserPromptTurn = async function (userInput) {
5
+ // Show the working spinner immediately on submit so there is no visible gap
6
+ // while prompt preflight runs before the agent emits `agent_start`.
7
+ this.showWorkingLoaderNow();
8
+ if (this.deferredStartupPending) {
9
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = true;
10
+ }
11
+ // Yield once so the freshly-mounted spinner paints before synchronous
12
+ // preflight work can block the event loop.
13
+ await yieldToEventLoop();
14
+ try {
15
+ await this.ensureDeferredStartupComplete();
16
+ await this.session.prompt(userInput);
17
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = false;
18
+ if (this.pendingLoadedResourcesDisclosure) {
19
+ this.pendingLoadedResourcesDisclosure = false;
20
+ this.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });
21
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);
22
+ }
23
+ }
24
+ catch (error) {
25
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = false;
26
+ this.discardDeferredRenderedUserInput(userInput);
27
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
28
+ this.showError(errorMessage);
29
+ }
30
+ finally {
31
+ // A submission that resolves without starting an agent turn (e.g. an
32
+ // extension slash-command) never emits `agent_end`, so clear the
33
+ // pre-shown spinner here when idle to avoid a lingering indicator.
34
+ if (!this.session.isStreaming) {
35
+ this.stopWorkingLoader();
36
+ }
37
+ }
38
+ };
3
39
  InteractiveModeBase.prototype.setupKeyHandlers = function () {
40
+ this.ui.addInputListener((data) => {
41
+ if (!this.keybindings.matches(data, "app.clear"))
42
+ return undefined;
43
+ if (this.ui.hasOverlay())
44
+ return undefined;
45
+ this.handleCtrlC();
46
+ this.ui.requestRender();
47
+ return { consume: true };
48
+ });
4
49
  // Set up handlers on defaultEditor - they use this.editor for text access
5
50
  // so they work correctly regardless of which editor is active
6
51
  this.defaultEditor.onEscape = () => {
@@ -71,205 +116,306 @@ InteractiveModeBase.prototype.handleClipboardImagePaste = async function () {
71
116
  showWarning: (message) => this.showWarning(message),
72
117
  });
73
118
  };
74
- InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
75
- this.defaultEditor.onSubmit = async (text) => {
76
- text = text.trim();
77
- if (!text)
78
- return;
79
- // Handle commands
80
- if (text === "/settings") {
81
- this.showSettingsSelector();
82
- this.editor.setText("");
83
- return;
84
- }
85
- if (text === "/fast") {
86
- this.editor.setText("");
87
- this.showFastModeSelector();
88
- return;
89
- }
90
- if (text === "/scoped-models") {
91
- this.editor.setText("");
92
- await this.showModelsSelector();
93
- return;
94
- }
95
- if (text === "/model" || text.startsWith("/model ")) {
96
- const searchTerm = text.startsWith("/model ")
97
- ? text.slice(7).trim()
98
- : undefined;
99
- this.editor.setText("");
100
- await this.handleModelCommand(searchTerm);
101
- return;
102
- }
103
- if (text === "/export" || text.startsWith("/export ")) {
104
- await this.handleExportCommand(text);
105
- this.editor.setText("");
106
- return;
107
- }
108
- if (text === "/import" || text.startsWith("/import ")) {
109
- await this.handleImportCommand(text);
110
- this.editor.setText("");
111
- return;
112
- }
113
- if (text === "/share") {
114
- await this.handleShareCommand();
115
- this.editor.setText("");
116
- return;
117
- }
118
- if (text === "/copy") {
119
- await this.handleCopyCommand();
120
- this.editor.setText("");
121
- return;
122
- }
123
- if (text === "/name" || text.startsWith("/name ")) {
124
- this.handleNameCommand(text);
125
- this.editor.setText("");
126
- return;
127
- }
128
- if (text === "/session") {
129
- this.handleSessionCommand();
130
- this.editor.setText("");
131
- return;
132
- }
133
- if (text === "/changelog") {
134
- this.handleChangelogCommand();
135
- this.editor.setText("");
136
- return;
137
- }
138
- if (text === "/atomic" || text.startsWith("/atomic ")) {
139
- this.editor.setText("");
140
- await this.session.prompt(text);
141
- return;
142
- }
143
- if (text === "/hotkeys") {
144
- this.handleHotkeysCommand();
145
- this.editor.setText("");
146
- return;
147
- }
148
- if (text === "/fork") {
149
- this.showUserMessageSelector();
150
- this.editor.setText("");
151
- return;
152
- }
153
- if (text === "/clone") {
154
- this.editor.setText("");
155
- await this.handleCloneCommand();
156
- return;
157
- }
158
- if (text === "/tree") {
159
- this.showTreeSelector();
160
- this.editor.setText("");
161
- return;
162
- }
163
- if (text === "/trust") {
164
- this.showTrustSelector();
119
+ InteractiveModeBase.prototype.deliverStartupReplayPrompt = function (text) {
120
+ if (this.onInputCallback) {
121
+ if (!text.startsWith("/")) {
122
+ this.renderDeferredUserInput(text);
123
+ }
124
+ const callback = this.onInputCallback;
125
+ this.onInputCallback = undefined;
126
+ callback(text);
127
+ }
128
+ else {
129
+ this.pendingUserInputs.push(text);
130
+ }
131
+ };
132
+ InteractiveModeBase.prototype.recoverCookedStartupInput = function () {
133
+ if (this.startupCookedInputRecovered || this.pendingUserInputs.length > 0)
134
+ return true;
135
+ const text = this.editor.getText();
136
+ const cookedLines = text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
137
+ const isCommandLike = (line) => line !== undefined && (line.startsWith("/") || line.startsWith("!"));
138
+ const singleCommandLike = cookedLines.length === 1 && isCommandLike(cookedLines[0]);
139
+ if (cookedLines.length < 2 && !singleCommandLike)
140
+ return false;
141
+ this.startupCookedInputRecovered = true;
142
+ const activeInput = this.startupReplayActiveInput?.trim();
143
+ let draftText = "";
144
+ let submissions = cookedLines;
145
+ if (activeInput === undefined &&
146
+ cookedLines.length > 1 &&
147
+ !isCommandLike(cookedLines[cookedLines.length - 1]) &&
148
+ (!isCommandLike(cookedLines[0]) || cookedLines.length > 2)) {
149
+ draftText = cookedLines[cookedLines.length - 1] ?? "";
150
+ submissions = cookedLines.slice(0, -1);
151
+ }
152
+ else if (activeInput && cookedLines.length > 1 && !isCommandLike(cookedLines[cookedLines.length - 1])) {
153
+ draftText = cookedLines[cookedLines.length - 1] ?? "";
154
+ submissions = cookedLines.slice(0, -1);
155
+ }
156
+ if (submissions.length === 0)
157
+ return true;
158
+ if (activeInput) {
159
+ const queuedSubmissions = submissions[0] === activeInput ? submissions.slice(1) : submissions;
160
+ this.editor.setText(draftText);
161
+ this.startupReplayInputs.push(...queuedSubmissions);
162
+ return true;
163
+ }
164
+ this.editor.setText("");
165
+ seedStartupInput(this.pendingUserInputs, this.editor, { text: draftText, submissions }, this.startupReplayInputs, (draft) => {
166
+ this.startupDraftText = draft;
167
+ }, (active) => {
168
+ this.startupReplayActiveInput = active;
169
+ });
170
+ return true;
171
+ };
172
+ InteractiveModeBase.prototype.drainStartupReplayCommands = async function () {
173
+ while (this.pendingUserInputs.length === 0 && this.startupReplayActiveInput) {
174
+ const activeInput = this.startupReplayActiveInput;
175
+ await this.defaultEditor.onSubmit?.(activeInput);
176
+ if (this.editor.getText().trim() === activeInput.trim()) {
165
177
  this.editor.setText("");
166
- return;
167
178
  }
168
- if (text === "/login") {
169
- this.showOAuthSelector("login");
170
- this.editor.setText("");
179
+ if (this.startupReplayActiveInput?.trim() === activeInput.trim())
180
+ break;
181
+ }
182
+ };
183
+ InteractiveModeBase.prototype.advanceStartupInputReplay = function (submittedText) {
184
+ if (this.startupReplayActiveInput?.trim() !== submittedText.trim())
185
+ return;
186
+ this.startupReplayActiveInput = undefined;
187
+ while (this.startupReplayInputs.length > 0) {
188
+ const nextInput = this.startupReplayInputs.shift();
189
+ if (nextInput === undefined)
190
+ break;
191
+ const trimmed = nextInput.trimStart();
192
+ if (trimmed.startsWith("/") || trimmed.startsWith("!")) {
193
+ this.startupReplayActiveInput = nextInput.trim();
194
+ this.editor.setText(this.startupReplayActiveInput);
195
+ this.ui.requestRender();
171
196
  return;
172
197
  }
173
- if (text === "/logout") {
174
- this.showOAuthSelector("logout");
175
- this.editor.setText("");
198
+ this.deliverStartupReplayPrompt(nextInput);
199
+ }
200
+ if (this.startupDraftText !== undefined) {
201
+ this.editor.setText(this.startupDraftText);
202
+ this.startupDraftText = undefined;
203
+ this.ui.requestRender();
204
+ }
205
+ };
206
+ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
207
+ this.defaultEditor.onSubmit = async (text) => {
208
+ text = text.trim();
209
+ if (!text)
176
210
  return;
177
- }
178
- if (text === "/new") {
211
+ if (this.startupReplayActiveInput && this.startupReplayActiveInput.trim() !== text.trim()) {
212
+ this.startupReplayInputs.push(text);
213
+ this.editor.addToHistory?.(text);
179
214
  this.editor.setText("");
180
- await this.handleClearCommand();
181
215
  return;
182
216
  }
183
- if (/^\/compact(?:\s|$)/.test(text)) {
184
- this.editor.setText("");
185
- if (text !== "/compact") {
186
- this.showWarning("Usage: /compact");
217
+ try {
218
+ // Handle commands
219
+ if (text === "/settings") {
220
+ this.showSettingsSelector();
221
+ this.editor.setText("");
187
222
  return;
188
223
  }
189
- await this.handleCompactCommand();
190
- return;
191
- }
192
- if (text === "/reload") {
193
- this.editor.setText("");
194
- await this.handleReloadCommand();
195
- return;
196
- }
197
- if (text === "/debug") {
198
- this.handleDebugCommand();
199
- this.editor.setText("");
200
- return;
201
- }
202
- if (text === "/arminsayshi") {
203
- this.handleArminSaysHi();
204
- this.editor.setText("");
205
- return;
206
- }
207
- if (text === "/dementedelves") {
208
- this.handleDementedDelves();
209
- this.editor.setText("");
210
- return;
211
- }
212
- if (text === "/resume") {
213
- this.showSessionSelector();
214
- this.editor.setText("");
215
- return;
216
- }
217
- if (text === "/quit" || text === "/exit") {
218
- this.editor.setText("");
219
- await this.shutdown();
220
- return;
221
- }
222
- // Handle bash command (! for normal, !! for excluded from context)
223
- if (text.startsWith("!")) {
224
- const isExcluded = text.startsWith("!!");
225
- const command = isExcluded
226
- ? text.slice(2).trim()
227
- : text.slice(1).trim();
228
- if (command) {
229
- if (this.session.isBashRunning) {
230
- this.showWarning("A bash command is already running. esc cancel first.");
231
- this.editor.setText(text);
224
+ if (text === "/fast") {
225
+ this.editor.setText("");
226
+ this.showFastModeSelector();
227
+ return;
228
+ }
229
+ if (text === "/scoped-models") {
230
+ this.editor.setText("");
231
+ await this.showModelsSelector();
232
+ return;
233
+ }
234
+ if (text === "/model" || text.startsWith("/model ")) {
235
+ const searchTerm = text.startsWith("/model ")
236
+ ? text.slice(7).trim()
237
+ : undefined;
238
+ this.editor.setText("");
239
+ await this.handleModelCommand(searchTerm);
240
+ return;
241
+ }
242
+ if (text === "/export" || text.startsWith("/export ")) {
243
+ await this.handleExportCommand(text);
244
+ this.editor.setText("");
245
+ return;
246
+ }
247
+ if (text === "/import" || text.startsWith("/import ")) {
248
+ await this.handleImportCommand(text);
249
+ this.editor.setText("");
250
+ return;
251
+ }
252
+ if (text === "/share") {
253
+ await this.handleShareCommand();
254
+ this.editor.setText("");
255
+ return;
256
+ }
257
+ if (text === "/copy") {
258
+ await this.handleCopyCommand();
259
+ this.editor.setText("");
260
+ return;
261
+ }
262
+ if (text === "/name" || text.startsWith("/name ")) {
263
+ this.handleNameCommand(text);
264
+ this.editor.setText("");
265
+ return;
266
+ }
267
+ if (text === "/session") {
268
+ this.handleSessionCommand();
269
+ this.editor.setText("");
270
+ return;
271
+ }
272
+ if (text === "/changelog") {
273
+ this.handleChangelogCommand();
274
+ this.editor.setText("");
275
+ return;
276
+ }
277
+ if (text === "/atomic" || text.startsWith("/atomic ")) {
278
+ this.editor.setText("");
279
+ await this.session.prompt(text);
280
+ return;
281
+ }
282
+ if (text === "/hotkeys") {
283
+ this.handleHotkeysCommand();
284
+ this.editor.setText("");
285
+ return;
286
+ }
287
+ if (text === "/fork") {
288
+ this.showUserMessageSelector();
289
+ this.editor.setText("");
290
+ return;
291
+ }
292
+ if (text === "/clone") {
293
+ this.editor.setText("");
294
+ await this.handleCloneCommand();
295
+ return;
296
+ }
297
+ if (text === "/tree") {
298
+ this.showTreeSelector();
299
+ this.editor.setText("");
300
+ return;
301
+ }
302
+ if (text === "/trust") {
303
+ this.showTrustSelector();
304
+ this.editor.setText("");
305
+ return;
306
+ }
307
+ if (text === "/login") {
308
+ this.showOAuthSelector("login");
309
+ this.editor.setText("");
310
+ return;
311
+ }
312
+ if (text === "/logout") {
313
+ this.showOAuthSelector("logout");
314
+ this.editor.setText("");
315
+ return;
316
+ }
317
+ if (text === "/new") {
318
+ this.editor.setText("");
319
+ await this.handleClearCommand();
320
+ return;
321
+ }
322
+ if (/^\/compact(?:\s|$)/.test(text)) {
323
+ this.editor.setText("");
324
+ if (text !== "/compact") {
325
+ this.showWarning("Usage: /compact");
232
326
  return;
233
327
  }
234
- this.editor.addToHistory?.(text);
235
- await this.handleBashCommand(command, isExcluded);
236
- this.isBashMode = false;
237
- this.updateEditorBorderColor();
328
+ await this.handleCompactCommand();
238
329
  return;
239
330
  }
240
- }
241
- // Queue input during compaction (extension commands execute immediately)
242
- if (this.session.isCompacting) {
243
- if (this.isExtensionCommand(text)) {
331
+ if (text === "/reload") {
332
+ this.editor.setText("");
333
+ await this.handleReloadCommand();
334
+ return;
335
+ }
336
+ if (text === "/debug") {
337
+ this.handleDebugCommand();
338
+ this.editor.setText("");
339
+ return;
340
+ }
341
+ if (text === "/arminsayshi") {
342
+ this.handleArminSaysHi();
343
+ this.editor.setText("");
344
+ return;
345
+ }
346
+ if (text === "/dementedelves") {
347
+ this.handleDementedDelves();
348
+ this.editor.setText("");
349
+ return;
350
+ }
351
+ if (text === "/resume") {
352
+ this.showSessionSelector();
353
+ this.editor.setText("");
354
+ return;
355
+ }
356
+ if (text === "/quit" || text === "/exit") {
357
+ this.editor.setText("");
358
+ await this.shutdown();
359
+ return;
360
+ }
361
+ // Handle bash command (! for normal, !! for excluded from context)
362
+ if (text.startsWith("!")) {
363
+ const isExcluded = text.startsWith("!!");
364
+ const command = isExcluded
365
+ ? text.slice(2).trim()
366
+ : text.slice(1).trim();
367
+ if (command) {
368
+ if (this.session.isBashRunning) {
369
+ this.showWarning("A bash command is already running. esc cancel first.");
370
+ this.editor.setText(text);
371
+ return;
372
+ }
373
+ this.editor.addToHistory?.(text);
374
+ await this.handleBashCommand(command, isExcluded);
375
+ this.isBashMode = false;
376
+ this.updateEditorBorderColor();
377
+ return;
378
+ }
379
+ }
380
+ // Queue input during compaction (extension commands execute immediately)
381
+ if (this.session.isCompacting) {
382
+ if (this.isExtensionCommand(text)) {
383
+ this.editor.addToHistory?.(text);
384
+ this.editor.setText("");
385
+ await this.session.prompt(text);
386
+ }
387
+ else {
388
+ this.queueCompactionMessage(text, "steer");
389
+ }
390
+ return;
391
+ }
392
+ // If streaming, use prompt() with steer behavior
393
+ // This handles extension commands (execute immediately), prompt template expansion, and queueing
394
+ if (this.session.isStreaming) {
244
395
  this.editor.addToHistory?.(text);
245
396
  this.editor.setText("");
246
- await this.session.prompt(text);
397
+ await this.session.prompt(text, { streamingBehavior: "steer" });
398
+ this.updatePendingMessagesDisplay();
399
+ this.ui.requestRender();
400
+ return;
401
+ }
402
+ // Normal message submission
403
+ // First, move any pending bash components to chat
404
+ this.flushPendingBashComponents();
405
+ if (this.onInputCallback) {
406
+ if (!text.startsWith("/")) {
407
+ this.renderDeferredUserInput(text);
408
+ }
409
+ this.onInputCallback(text);
247
410
  }
248
411
  else {
249
- this.queueCompactionMessage(text, "steer");
412
+ this.pendingUserInputs.push(text);
250
413
  }
251
- return;
252
- }
253
- // If streaming, use prompt() with steer behavior
254
- // This handles extension commands (execute immediately), prompt template expansion, and queueing
255
- if (this.session.isStreaming) {
256
414
  this.editor.addToHistory?.(text);
257
- this.editor.setText("");
258
- await this.session.prompt(text, { streamingBehavior: "steer" });
259
- this.updatePendingMessagesDisplay();
260
- this.ui.requestRender();
261
- return;
262
- }
263
- // Normal message submission
264
- // First, move any pending bash components to chat
265
- this.flushPendingBashComponents();
266
- if (this.onInputCallback) {
267
- this.onInputCallback(text);
268
415
  }
269
- else {
270
- this.pendingUserInputs.push(text);
416
+ finally {
417
+ this.advanceStartupInputReplay?.(text);
271
418
  }
272
- this.editor.addToHistory?.(text);
273
419
  };
274
420
  };
275
421
  //# sourceMappingURL=interactive-input-handling.js.map