@onpoint-dev-tools/crewcoder-opentui 0.0.0-stage → 0.1.0

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 (325) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +262 -2
  3. package/THIRD_PARTY_NOTICES.md +51 -0
  4. package/dist/App.d.ts +16 -0
  5. package/dist/App.d.ts.map +1 -0
  6. package/dist/App.js +428 -0
  7. package/dist/App.js.map +1 -0
  8. package/dist/Root.d.ts +11 -0
  9. package/dist/Root.d.ts.map +1 -0
  10. package/dist/Root.js +13 -0
  11. package/dist/Root.js.map +1 -0
  12. package/dist/alert-model.d.ts +31 -0
  13. package/dist/alert-model.d.ts.map +1 -0
  14. package/dist/alert-model.js +34 -0
  15. package/dist/alert-model.js.map +1 -0
  16. package/dist/args.d.ts +13 -0
  17. package/dist/args.d.ts.map +1 -0
  18. package/dist/args.js +63 -0
  19. package/dist/args.js.map +1 -0
  20. package/dist/attachments.d.ts +29 -0
  21. package/dist/attachments.d.ts.map +1 -0
  22. package/dist/attachments.js +38 -0
  23. package/dist/attachments.js.map +1 -0
  24. package/dist/block-panels.d.ts +43 -0
  25. package/dist/block-panels.d.ts.map +1 -0
  26. package/dist/block-panels.js +210 -0
  27. package/dist/block-panels.js.map +1 -0
  28. package/dist/cli.d.ts +3 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +138 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/command-format.d.ts +18 -0
  33. package/dist/command-format.d.ts.map +1 -0
  34. package/dist/command-format.js +66 -0
  35. package/dist/command-format.js.map +1 -0
  36. package/dist/command-runner.d.ts +128 -0
  37. package/dist/command-runner.d.ts.map +1 -0
  38. package/dist/command-runner.js +571 -0
  39. package/dist/command-runner.js.map +1 -0
  40. package/dist/commands.d.ts +47 -0
  41. package/dist/commands.d.ts.map +1 -0
  42. package/dist/commands.js +108 -0
  43. package/dist/commands.js.map +1 -0
  44. package/dist/components/AttachmentRow.d.ts +11 -0
  45. package/dist/components/AttachmentRow.d.ts.map +1 -0
  46. package/dist/components/AttachmentRow.js +17 -0
  47. package/dist/components/AttachmentRow.js.map +1 -0
  48. package/dist/components/Composer.d.ts +23 -0
  49. package/dist/components/Composer.d.ts.map +1 -0
  50. package/dist/components/Composer.js +45 -0
  51. package/dist/components/Composer.js.map +1 -0
  52. package/dist/components/ExtensionQuestion.d.ts +18 -0
  53. package/dist/components/ExtensionQuestion.d.ts.map +1 -0
  54. package/dist/components/ExtensionQuestion.js +45 -0
  55. package/dist/components/ExtensionQuestion.js.map +1 -0
  56. package/dist/components/GoalForm.d.ts +18 -0
  57. package/dist/components/GoalForm.d.ts.map +1 -0
  58. package/dist/components/GoalForm.js +26 -0
  59. package/dist/components/GoalForm.js.map +1 -0
  60. package/dist/components/Home.d.ts +21 -0
  61. package/dist/components/Home.d.ts.map +1 -0
  62. package/dist/components/Home.js +48 -0
  63. package/dist/components/Home.js.map +1 -0
  64. package/dist/components/MentionList.d.ts +14 -0
  65. package/dist/components/MentionList.d.ts.map +1 -0
  66. package/dist/components/MentionList.js +24 -0
  67. package/dist/components/MentionList.js.map +1 -0
  68. package/dist/components/SearchBar.d.ts +19 -0
  69. package/dist/components/SearchBar.d.ts.map +1 -0
  70. package/dist/components/SearchBar.js +28 -0
  71. package/dist/components/SearchBar.js.map +1 -0
  72. package/dist/components/Sidebar.d.ts +19 -0
  73. package/dist/components/Sidebar.d.ts.map +1 -0
  74. package/dist/components/Sidebar.js +35 -0
  75. package/dist/components/Sidebar.js.map +1 -0
  76. package/dist/components/SummaryEditor.d.ts +16 -0
  77. package/dist/components/SummaryEditor.d.ts.map +1 -0
  78. package/dist/components/SummaryEditor.js +21 -0
  79. package/dist/components/SummaryEditor.js.map +1 -0
  80. package/dist/components/Transcript.d.ts +37 -0
  81. package/dist/components/Transcript.d.ts.map +1 -0
  82. package/dist/components/Transcript.js +314 -0
  83. package/dist/components/Transcript.js.map +1 -0
  84. package/dist/components/ui/alert.d.ts +9 -0
  85. package/dist/components/ui/alert.d.ts.map +1 -0
  86. package/dist/components/ui/alert.js +18 -0
  87. package/dist/components/ui/alert.js.map +1 -0
  88. package/dist/components/ui/command-palette.d.ts +15 -0
  89. package/dist/components/ui/command-palette.d.ts.map +1 -0
  90. package/dist/components/ui/command-palette.js +14 -0
  91. package/dist/components/ui/command-palette.js.map +1 -0
  92. package/dist/components/ui/confirm.d.ts +12 -0
  93. package/dist/components/ui/confirm.d.ts.map +1 -0
  94. package/dist/components/ui/confirm.js +16 -0
  95. package/dist/components/ui/confirm.js.map +1 -0
  96. package/dist/components/ui/select.d.ts +11 -0
  97. package/dist/components/ui/select.d.ts.map +1 -0
  98. package/dist/components/ui/select.js +29 -0
  99. package/dist/components/ui/select.js.map +1 -0
  100. package/dist/components/ui/spinner.d.ts +14 -0
  101. package/dist/components/ui/spinner.d.ts.map +1 -0
  102. package/dist/components/ui/spinner.js +17 -0
  103. package/dist/components/ui/spinner.js.map +1 -0
  104. package/dist/components/ui/tool-approval.d.ts +14 -0
  105. package/dist/components/ui/tool-approval.d.ts.map +1 -0
  106. package/dist/components/ui/tool-approval.js +37 -0
  107. package/dist/components/ui/tool-approval.js.map +1 -0
  108. package/dist/components/ui/tool-call.d.ts +12 -0
  109. package/dist/components/ui/tool-call.d.ts.map +1 -0
  110. package/dist/components/ui/tool-call.js +69 -0
  111. package/dist/components/ui/tool-call.js.map +1 -0
  112. package/dist/components/ui/types.d.ts +82 -0
  113. package/dist/components/ui/types.d.ts.map +1 -0
  114. package/dist/components/ui/types.js +2 -0
  115. package/dist/components/ui/types.js.map +1 -0
  116. package/dist/crewcoder-cli.d.ts +51 -0
  117. package/dist/crewcoder-cli.d.ts.map +1 -0
  118. package/dist/crewcoder-cli.js +26 -0
  119. package/dist/crewcoder-cli.js.map +1 -0
  120. package/dist/diff-anchors.d.ts +14 -0
  121. package/dist/diff-anchors.d.ts.map +1 -0
  122. package/dist/diff-anchors.js +43 -0
  123. package/dist/diff-anchors.js.map +1 -0
  124. package/dist/footer-layout.d.ts +49 -0
  125. package/dist/footer-layout.d.ts.map +1 -0
  126. package/dist/footer-layout.js +79 -0
  127. package/dist/footer-layout.js.map +1 -0
  128. package/dist/glyphs.d.ts +32 -0
  129. package/dist/glyphs.d.ts.map +1 -0
  130. package/dist/glyphs.js +35 -0
  131. package/dist/glyphs.js.map +1 -0
  132. package/dist/goal-form.d.ts +47 -0
  133. package/dist/goal-form.d.ts.map +1 -0
  134. package/dist/goal-form.js +59 -0
  135. package/dist/goal-form.js.map +1 -0
  136. package/dist/hooks/use-animation.d.ts +6 -0
  137. package/dist/hooks/use-animation.d.ts.map +1 -0
  138. package/dist/hooks/use-animation.js +52 -0
  139. package/dist/hooks/use-animation.js.map +1 -0
  140. package/dist/hooks/use-app-colors.d.ts +6 -0
  141. package/dist/hooks/use-app-colors.d.ts.map +1 -0
  142. package/dist/hooks/use-app-colors.js +6 -0
  143. package/dist/hooks/use-app-colors.js.map +1 -0
  144. package/dist/hooks/use-glyph-set.d.ts +8 -0
  145. package/dist/hooks/use-glyph-set.d.ts.map +1 -0
  146. package/dist/hooks/use-glyph-set.js +22 -0
  147. package/dist/hooks/use-glyph-set.js.map +1 -0
  148. package/dist/hooks/use-motion.d.ts +6 -0
  149. package/dist/hooks/use-motion.d.ts.map +1 -0
  150. package/dist/hooks/use-motion.js +8 -0
  151. package/dist/hooks/use-motion.js.map +1 -0
  152. package/dist/hooks/use-terminal-focus.d.ts +16 -0
  153. package/dist/hooks/use-terminal-focus.d.ts.map +1 -0
  154. package/dist/hooks/use-terminal-focus.js +30 -0
  155. package/dist/hooks/use-terminal-focus.js.map +1 -0
  156. package/dist/hooks/use-theme.d.ts +6 -0
  157. package/dist/hooks/use-theme.d.ts.map +1 -0
  158. package/dist/hooks/use-theme.js +11 -0
  159. package/dist/hooks/use-theme.js.map +1 -0
  160. package/dist/hunk.d.ts +27 -0
  161. package/dist/hunk.d.ts.map +1 -0
  162. package/dist/hunk.js +43 -0
  163. package/dist/hunk.js.map +1 -0
  164. package/dist/image-view.d.ts +33 -0
  165. package/dist/image-view.d.ts.map +1 -0
  166. package/dist/image-view.js +51 -0
  167. package/dist/image-view.js.map +1 -0
  168. package/dist/keybindings.d.ts +28 -0
  169. package/dist/keybindings.d.ts.map +1 -0
  170. package/dist/keybindings.js +105 -0
  171. package/dist/keybindings.js.map +1 -0
  172. package/dist/lib/terminal-themes/default.d.ts +3 -0
  173. package/dist/lib/terminal-themes/default.d.ts.map +1 -0
  174. package/dist/lib/terminal-themes/default.js +49 -0
  175. package/dist/lib/terminal-themes/default.js.map +1 -0
  176. package/dist/logo-pulse.d.ts +23 -0
  177. package/dist/logo-pulse.d.ts.map +1 -0
  178. package/dist/logo-pulse.js +30 -0
  179. package/dist/logo-pulse.js.map +1 -0
  180. package/dist/markdown-style.d.ts +47 -0
  181. package/dist/markdown-style.d.ts.map +1 -0
  182. package/dist/markdown-style.js +138 -0
  183. package/dist/markdown-style.js.map +1 -0
  184. package/dist/mentions.d.ts +57 -0
  185. package/dist/mentions.d.ts.map +1 -0
  186. package/dist/mentions.js +109 -0
  187. package/dist/mentions.js.map +1 -0
  188. package/dist/palette-model.d.ts +42 -0
  189. package/dist/palette-model.d.ts.map +1 -0
  190. package/dist/palette-model.js +77 -0
  191. package/dist/palette-model.js.map +1 -0
  192. package/dist/path-suggestions.d.ts +50 -0
  193. package/dist/path-suggestions.d.ts.map +1 -0
  194. package/dist/path-suggestions.js +99 -0
  195. package/dist/path-suggestions.js.map +1 -0
  196. package/dist/picker-flows.d.ts +78 -0
  197. package/dist/picker-flows.d.ts.map +1 -0
  198. package/dist/picker-flows.js +444 -0
  199. package/dist/picker-flows.js.map +1 -0
  200. package/dist/pickers.d.ts +34 -0
  201. package/dist/pickers.d.ts.map +1 -0
  202. package/dist/pickers.js +136 -0
  203. package/dist/pickers.js.map +1 -0
  204. package/dist/prompt-history.d.ts +32 -0
  205. package/dist/prompt-history.d.ts.map +1 -0
  206. package/dist/prompt-history.js +40 -0
  207. package/dist/prompt-history.js.map +1 -0
  208. package/dist/providers/app-theme-provider.d.ts +12 -0
  209. package/dist/providers/app-theme-provider.d.ts.map +1 -0
  210. package/dist/providers/app-theme-provider.js +14 -0
  211. package/dist/providers/app-theme-provider.js.map +1 -0
  212. package/dist/providers/theme-provider.d.ts +10 -0
  213. package/dist/providers/theme-provider.d.ts.map +1 -0
  214. package/dist/providers/theme-provider.js +57 -0
  215. package/dist/providers/theme-provider.js.map +1 -0
  216. package/dist/question-model.d.ts +71 -0
  217. package/dist/question-model.d.ts.map +1 -0
  218. package/dist/question-model.js +176 -0
  219. package/dist/question-model.js.map +1 -0
  220. package/dist/search-controller.d.ts +46 -0
  221. package/dist/search-controller.d.ts.map +1 -0
  222. package/dist/search-controller.js +89 -0
  223. package/dist/search-controller.js.map +1 -0
  224. package/dist/search-jump.d.ts +27 -0
  225. package/dist/search-jump.d.ts.map +1 -0
  226. package/dist/search-jump.js +65 -0
  227. package/dist/search-jump.js.map +1 -0
  228. package/dist/session-controller.d.ts +268 -0
  229. package/dist/session-controller.d.ts.map +1 -0
  230. package/dist/session-controller.js +941 -0
  231. package/dist/session-controller.js.map +1 -0
  232. package/dist/sidebar-model.d.ts +45 -0
  233. package/dist/sidebar-model.d.ts.map +1 -0
  234. package/dist/sidebar-model.js +223 -0
  235. package/dist/sidebar-model.js.map +1 -0
  236. package/dist/sidebar.d.ts +49 -0
  237. package/dist/sidebar.d.ts.map +1 -0
  238. package/dist/sidebar.js +106 -0
  239. package/dist/sidebar.js.map +1 -0
  240. package/dist/status-line.d.ts +32 -0
  241. package/dist/status-line.d.ts.map +1 -0
  242. package/dist/status-line.js +69 -0
  243. package/dist/status-line.js.map +1 -0
  244. package/dist/syntax/filetype.d.ts +12 -0
  245. package/dist/syntax/filetype.d.ts.map +1 -0
  246. package/dist/syntax/filetype.js +28 -0
  247. package/dist/syntax/filetype.js.map +1 -0
  248. package/dist/syntax/grammars.d.ts +42 -0
  249. package/dist/syntax/grammars.d.ts.map +1 -0
  250. package/dist/syntax/grammars.js +52 -0
  251. package/dist/syntax/grammars.js.map +1 -0
  252. package/dist/text-offset.d.ts +5 -0
  253. package/dist/text-offset.d.ts.map +1 -0
  254. package/dist/text-offset.js +38 -0
  255. package/dist/text-offset.js.map +1 -0
  256. package/dist/text-wrap.d.ts +12 -0
  257. package/dist/text-wrap.d.ts.map +1 -0
  258. package/dist/text-wrap.js +53 -0
  259. package/dist/text-wrap.js.map +1 -0
  260. package/dist/theme-controller.d.ts +77 -0
  261. package/dist/theme-controller.d.ts.map +1 -0
  262. package/dist/theme-controller.js +178 -0
  263. package/dist/theme-controller.js.map +1 -0
  264. package/dist/theme.d.ts +51 -0
  265. package/dist/theme.d.ts.map +1 -0
  266. package/dist/theme.js +86 -0
  267. package/dist/theme.js.map +1 -0
  268. package/dist/tmux-check.d.ts +35 -0
  269. package/dist/tmux-check.d.ts.map +1 -0
  270. package/dist/tmux-check.js +66 -0
  271. package/dist/tmux-check.js.map +1 -0
  272. package/dist/tmux.d.ts +69 -0
  273. package/dist/tmux.d.ts.map +1 -0
  274. package/dist/tmux.js +135 -0
  275. package/dist/tmux.js.map +1 -0
  276. package/dist/tool-diff.d.ts +51 -0
  277. package/dist/tool-diff.d.ts.map +1 -0
  278. package/dist/tool-diff.js +158 -0
  279. package/dist/tool-diff.js.map +1 -0
  280. package/dist/tool-presentation.d.ts +46 -0
  281. package/dist/tool-presentation.d.ts.map +1 -0
  282. package/dist/tool-presentation.js +148 -0
  283. package/dist/tool-presentation.js.map +1 -0
  284. package/dist/tool-renderer-view.d.ts +14 -0
  285. package/dist/tool-renderer-view.d.ts.map +1 -0
  286. package/dist/tool-renderer-view.js +10 -0
  287. package/dist/tool-renderer-view.js.map +1 -0
  288. package/dist/transcript-search.d.ts +54 -0
  289. package/dist/transcript-search.d.ts.map +1 -0
  290. package/dist/transcript-search.js +160 -0
  291. package/dist/transcript-search.js.map +1 -0
  292. package/dist/transcript.d.ts +59 -0
  293. package/dist/transcript.d.ts.map +1 -0
  294. package/dist/transcript.js +123 -0
  295. package/dist/transcript.js.map +1 -0
  296. package/dist/workflow-tools.d.ts +42 -0
  297. package/dist/workflow-tools.d.ts.map +1 -0
  298. package/dist/workflow-tools.js +89 -0
  299. package/dist/workflow-tools.js.map +1 -0
  300. package/examples/themes/ember.json +75 -0
  301. package/grammars/bash/LICENSE +21 -0
  302. package/grammars/bash/highlights.scm +56 -0
  303. package/grammars/bash/tree-sitter-bash.wasm +0 -0
  304. package/grammars/css/LICENSE +21 -0
  305. package/grammars/css/highlights.scm +76 -0
  306. package/grammars/css/tree-sitter-css.wasm +0 -0
  307. package/grammars/go/LICENSE +21 -0
  308. package/grammars/go/highlights.scm +123 -0
  309. package/grammars/go/tree-sitter-go.wasm +0 -0
  310. package/grammars/html/LICENSE +21 -0
  311. package/grammars/html/highlights.scm +13 -0
  312. package/grammars/html/tree-sitter-html.wasm +0 -0
  313. package/grammars/json/LICENSE +21 -0
  314. package/grammars/json/highlights.scm +16 -0
  315. package/grammars/json/tree-sitter-json.wasm +0 -0
  316. package/grammars/python/LICENSE +21 -0
  317. package/grammars/python/highlights.scm +137 -0
  318. package/grammars/python/tree-sitter-python.wasm +0 -0
  319. package/grammars/rust/LICENSE +21 -0
  320. package/grammars/rust/highlights.scm +161 -0
  321. package/grammars/rust/tree-sitter-rust.wasm +0 -0
  322. package/grammars/yaml/LICENSE +20 -0
  323. package/grammars/yaml/highlights.scm +79 -0
  324. package/grammars/yaml/tree-sitter-yaml.wasm +0 -0
  325. package/package.json +56 -5
@@ -0,0 +1,571 @@
1
+ import fs from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { isCrewCoderRemote, isCrewName } from "@onpoint-dev-tools/crewcoder-tui-core/bridge/crewcoder-process";
5
+ import { formatBudgetTokens, parseBudgetInput, parseCompactionResult, parseDecisionExplanation, parseGoalRecord, parseGoalStartInput, parseReviewSummary, tokenizeGoalCommand } from "@onpoint-dev-tools/crewcoder-tui-core/state/command-results";
6
+ import { effortLevelsForModel } from "@onpoint-dev-tools/crewcoder-tui-core/state/effort-levels";
7
+ import { normalizeTuiMode } from "@onpoint-dev-tools/crewcoder-tui-core/state/tui-store";
8
+ import { cliOutputAlert, goalsAlert, reviewSummaryAlert, whyAlert } from "./command-format.js";
9
+ import { BUDGET_MENU, CONFIG_TOGGLES, configToggleOn, MEMORY_MENU_EXTRAS, TASK_MENU_EXTRAS, toggleMenu } from "./commands.js";
10
+ import { cliJson, cliText, errorMessage } from "./crewcoder-cli.js";
11
+ import { HUNK_COMMAND, HUNK_INSTALL_HINT, hunkDiffArgs } from "./hunk.js";
12
+ import { goalDefaults } from "./goal-form.js";
13
+ import { MIN_SIDEBAR_TERMINAL_WIDTH } from "./sidebar-model.js";
14
+ const TASKS_ENV = "CREWCODER_TASKS_ENABLED";
15
+ /** Extension commands are typed as `/ext.<extension-id>.<command-id> [args]`. */
16
+ const EXTENSION_COMMAND_PREFIX = "/ext.";
17
+ /**
18
+ * Every slash command that is not a picker. Results are alerts (status,
19
+ * on/off, and text output); failures are error alerts. None of them sends a
20
+ * prompt to the agent except /approve-plan, which is a prompt by design.
21
+ */
22
+ export class CommandRunner {
23
+ host;
24
+ flows;
25
+ handlers;
26
+ constructor(host, flows) {
27
+ this.host = host;
28
+ this.flows = flows;
29
+ const followUp = (rest) => this.followUp(rest);
30
+ this.handlers = {
31
+ "/help": () => this.host.openCommandPalette(),
32
+ "/thinking": (rest) => this.configToggle("/thinking", rest),
33
+ "/identity": (rest) => this.configToggle("/identity", rest),
34
+ "/checkpoints": (rest) => this.configToggle("/checkpoints", rest),
35
+ "/compact": (rest) => this.compact(rest),
36
+ "/full-access": (rest) => this.fullAccess(rest),
37
+ "/memory": (rest) => this.memory(rest),
38
+ "/remember": (rest) => this.remember(rest),
39
+ "/set-budget": (rest) => this.setBudget(rest),
40
+ "/add-dir": (rest) => this.addDirectory(rest),
41
+ "/task": (rest) => this.task(rest),
42
+ "/extensions": () => this.cliAlert("Extensions", ["extension", "list"]),
43
+ "/plugins": () => this.plugins(),
44
+ "/teams": () => this.cliAlert("Teams", ["crew", "team", "list"]),
45
+ "/team": (rest) => this.team(rest),
46
+ "/crew": (rest) => this.crew(rest),
47
+ "/review-summary": () => this.reviewSummary(),
48
+ "/why": () => this.why(),
49
+ "/branch": (rest) => rest ? this.flows.branchById(rest) : this.branch(),
50
+ "/export": (rest) => this.exportSession(rest),
51
+ "/reload": () => this.reload(),
52
+ "/goal": (rest) => this.goal(rest),
53
+ "/clear": () => this.clear(),
54
+ "/repaint": () => this.repaint(),
55
+ "/redraw": () => this.repaint(),
56
+ "/quit": () => this.quit(),
57
+ "/find": (rest) => this.host.openSearch(rest.trim()),
58
+ "/diff": () => this.diff(),
59
+ "/sidebar": (rest) => this.setSidebar(rest),
60
+ "/file-changes": (rest) => this.fileChanges(rest),
61
+ "/approve": (rest) => this.host.resolveApproval(rest || undefined, true),
62
+ "/deny": (rest) => this.host.resolveApproval(rest || undefined, false),
63
+ "/approve-plan": () => this.approvePlan(),
64
+ "/follow-up": followUp,
65
+ "/followup": followUp
66
+ };
67
+ }
68
+ /** Run `name` with the raw text after it. Returns false for commands it does not own. */
69
+ run(name, rest) {
70
+ const handler = Object.hasOwn(this.handlers, name)
71
+ ? this.handlers[name]
72
+ : name.startsWith(EXTENSION_COMMAND_PREFIX) ? (text) => this.extensionCommand(name, text) : undefined;
73
+ if (!handler)
74
+ return false;
75
+ Promise.resolve()
76
+ .then(() => handler(rest.trim()))
77
+ .catch((error) => this.alert({ variant: "error", title: name, body: errorMessage(error) }))
78
+ .finally(() => this.host.changed());
79
+ return true;
80
+ }
81
+ /** Install an edited summary into a saved session (idle compaction preview). */
82
+ async applyEditedSummary(sessionId, summary) {
83
+ if (isCrewCoderRemote()) {
84
+ this.alert({ variant: "warning", title: "Not available in remote SSH mode", body: "Applying an edited summary needs a local file. Live previews and plain /compact work remotely." });
85
+ return;
86
+ }
87
+ const file = path.join(os.tmpdir(), `crewcoder-compact-${sessionId}-${Date.now()}.md`);
88
+ this.alert({ variant: "info", title: `Applying edited summary to ${sessionId}…` });
89
+ try {
90
+ await fs.writeFile(file, summary, "utf8");
91
+ await cliText(this.host.cli, ["session", "compact", sessionId, "--summary-file", file, "--json"]);
92
+ this.alert({ variant: "success", title: `Session ${sessionId} compacted with your summary` });
93
+ }
94
+ finally {
95
+ await fs.unlink(file).catch(() => undefined);
96
+ }
97
+ }
98
+ alert(alert) {
99
+ this.host.alert(alert);
100
+ }
101
+ get state() {
102
+ return this.host.state;
103
+ }
104
+ busy(action) {
105
+ if (!this.host.bridgeRunning && !this.state.running)
106
+ return false;
107
+ this.alert({ variant: "warning", title: `Wait for the current run to finish before ${action}`, body: "Use /stop to end it." });
108
+ return true;
109
+ }
110
+ savedSession(action) {
111
+ if (this.state.sessionId && this.state.sessionId !== "new")
112
+ return this.state.sessionId;
113
+ this.alert({ variant: "warning", title: `No saved session to ${action} yet`, body: "Send a prompt first." });
114
+ return undefined;
115
+ }
116
+ /**
117
+ * `/ext.<extension-id>.<command-id> [args]`: runs an extension's executable
118
+ * command through `crewcoder command run`, which enforces the extension's
119
+ * trust (as in the legacy UI). Its notifications come back as one alert;
120
+ * nothing is sent to the agent. `--` keeps typed arguments from being read as
121
+ * agent CLI options, and the CLI runs without a shell.
122
+ */
123
+ async extensionCommand(name, rest) {
124
+ const id = name.slice(1);
125
+ if (id.length <= EXTENSION_COMMAND_PREFIX.length - 1) {
126
+ this.usage("/ext.<extension-id>.<command-id> [args]. Run /commands to see extension commands.");
127
+ return;
128
+ }
129
+ await this.cliAlert(name, ["command", "run", id, "--", ...rest.split(/\s+/).filter(Boolean)]);
130
+ }
131
+ quit() {
132
+ const quit = this.host.quit;
133
+ if (!quit) {
134
+ this.alert({ variant: "warning", title: "/quit needs an interactive terminal", body: "Press Ctrl+C to exit." });
135
+ return;
136
+ }
137
+ quit();
138
+ }
139
+ /**
140
+ * Recovery for a garbled screen: something wrote to the terminal behind
141
+ * OpenTUI's back (a stray child process, a system message, a glitch after
142
+ * /diff). Silent on success; the redrawn screen is the result.
143
+ */
144
+ repaint() {
145
+ const repaint = this.host.repaint;
146
+ if (!repaint) {
147
+ this.alert({ variant: "warning", title: "/repaint needs an interactive terminal" });
148
+ return;
149
+ }
150
+ repaint();
151
+ }
152
+ /** Review this session's file changes in Hunk; the UI is suspended until Hunk exits. */
153
+ async diff() {
154
+ if (isCrewCoderRemote()) {
155
+ this.alert({ variant: "warning", title: "/diff is not available in remote SSH mode", body: "Hunk runs on this machine; the changes live on the remote host." });
156
+ return;
157
+ }
158
+ const run = this.host.runInTerminal;
159
+ if (!run) {
160
+ this.alert({ variant: "warning", title: "/diff needs an interactive terminal" });
161
+ return;
162
+ }
163
+ const result = await run(HUNK_COMMAND, hunkDiffArgs(this.state.changedFiles, this.state.cwd), this.state.cwd);
164
+ if (result.missing) {
165
+ this.alert({ variant: "error", title: "Hunk is not installed", body: HUNK_INSTALL_HINT });
166
+ }
167
+ else if (result.code !== 0) {
168
+ this.alert({ variant: "error", title: `hunk diff exited with ${result.code ?? "a signal"}`, body: result.stderr.trim() || undefined });
169
+ }
170
+ }
171
+ /** Bare `/sidebar` toggles; on/off/status are explicit. Display only: nothing is saved. */
172
+ setSidebar(value) {
173
+ const action = value.toLowerCase();
174
+ const sidebar = this.host.sidebar;
175
+ if (action === "status")
176
+ return this.alert({ variant: "info", title: `Sidebar is ${sidebar.open ? "open" : "closed"}` });
177
+ if (action && action !== "on" && action !== "off")
178
+ return this.usage("/sidebar on|off|status (bare /sidebar toggles)");
179
+ const open = action ? action === "on" : !sidebar.open;
180
+ if (open === sidebar.open)
181
+ return this.alert({ variant: "info", title: `Sidebar already ${open ? "open" : "closed"}` });
182
+ sidebar.setOpen(open);
183
+ if (sidebar.hiddenByWidth) {
184
+ this.alert({ variant: "warning", title: "Sidebar opened, but the terminal is too narrow", body: `It shows at ${MIN_SIDEBAR_TERMINAL_WIDTH} columns or wider.` });
185
+ }
186
+ }
187
+ /**
188
+ * Show or hide modified files in the sidebar. Tracking never stops, so
189
+ * turning it back on restores the list. Instance-local and kept across /new.
190
+ */
191
+ fileChanges(value) {
192
+ const action = value.toLowerCase();
193
+ const count = this.state.changedFiles.length;
194
+ if (action === "status") {
195
+ return this.alert({ variant: "info", title: `File changes display is ${this.state.showFileChanges ? "on" : "off"}`, body: `File tracking remains active (${count} changed).` });
196
+ }
197
+ if (action && action !== "on" && action !== "off")
198
+ return this.usage("/file-changes on|off|status (bare /file-changes toggles)");
199
+ this.state.showFileChanges = action ? action === "on" : !this.state.showFileChanges;
200
+ const hint = this.host.sidebar.open ? undefined : "The sidebar is closed; open it with /sidebar or Ctrl+B.";
201
+ this.alert({
202
+ variant: "success",
203
+ title: `File changes display turned ${this.state.showFileChanges ? "on" : "off"}`,
204
+ body: [`File tracking remains active (${count} changed).`, hint].filter(Boolean).join(" ")
205
+ });
206
+ }
207
+ usage(text) {
208
+ this.alert({ variant: "warning", title: "Usage", body: text });
209
+ }
210
+ async readConfig() {
211
+ return cliJson(this.host.cli, ["config", "show"], {});
212
+ }
213
+ async cliAlert(title, args, variant) {
214
+ const alert = cliOutputAlert(title, await this.host.cli.exec(args));
215
+ this.alert(variant && alert.variant !== "error" ? { ...alert, variant } : alert);
216
+ }
217
+ configToggle(name, value) {
218
+ const toggle = CONFIG_TOGGLES[name];
219
+ const action = value.toLowerCase();
220
+ if (!action) {
221
+ return this.host.openMenu(toggle.label, toggleMenu(name), async () => toggleMenu(name, configToggleOn(name, await this.readConfig())));
222
+ }
223
+ if (action === "status") {
224
+ return this.readConfig().then((config) => {
225
+ const on = configToggleOn(name, config);
226
+ const note = name === "/checkpoints" ? "Existing checkpoints are preserved." : undefined;
227
+ this.alert({ variant: "info", title: `${toggle.label}: ${on ? "on" : "off"}`, body: note });
228
+ });
229
+ }
230
+ if (action !== "on" && action !== "off")
231
+ return this.usage(`${name} on|off|status`);
232
+ if (name === "/checkpoints" && this.busy("changing checkpoints"))
233
+ return;
234
+ return cliText(this.host.cli, ["config", "set", toggle.key, action === "on" ? "true" : "false"]).then(() => {
235
+ if (name === "/thinking")
236
+ this.state.thinkingEnabled = action === "on";
237
+ if (name === "/identity")
238
+ this.state.workerIdentityEnabled = action === "on";
239
+ const note = name === "/checkpoints"
240
+ ? `Existing checkpoints are preserved${action === "off" ? "; future runs will not create new ones" : ""}.`
241
+ : name === "/identity" ? "Applies to future runs." : undefined;
242
+ this.alert({ variant: "success", title: `${toggle.label} turned ${action}`, body: note });
243
+ });
244
+ }
245
+ fullAccess(value) {
246
+ const action = value.toLowerCase();
247
+ if (!action)
248
+ return this.host.openMenu("Full access", toggleMenu("/full-access", this.state.fullAccess));
249
+ if (action === "status") {
250
+ return this.alert({ variant: this.state.fullAccess ? "warning" : "info", title: `Full access is ${this.state.fullAccess ? "on" : "off"} for this session` });
251
+ }
252
+ if (action !== "on" && action !== "off")
253
+ return this.usage("/full-access on|off|status");
254
+ this.state.fullAccess = action === "on";
255
+ this.alert(this.state.fullAccess
256
+ ? { variant: "warning", title: "Full access enabled", body: "Future tool calls in this session bypass approval prompts, including dangerous commands." }
257
+ : { variant: "success", title: "Full access disabled", body: "Future mutating and dangerous tool calls require approval." });
258
+ }
259
+ compact(value) {
260
+ const action = value.toLowerCase();
261
+ if (!action)
262
+ return this.compactNow();
263
+ if (action === "preview" || action === "edit")
264
+ return this.previewCompaction();
265
+ if (action === "auto")
266
+ return this.configToggle("/compact auto", "");
267
+ if (action === "on" || action === "off" || action === "status")
268
+ return this.configToggle("/compact auto", action);
269
+ if (action.startsWith("auto "))
270
+ return this.configToggle("/compact auto", action.slice(5));
271
+ return this.usage("/compact (now) · /compact preview · /compact on|off|status");
272
+ }
273
+ async compactNow() {
274
+ if (this.busy("compacting"))
275
+ return;
276
+ const sessionId = this.savedSession("compact");
277
+ if (!sessionId)
278
+ return;
279
+ this.alert({ variant: "info", title: `Compacting session ${sessionId}…` });
280
+ const result = parseCompactionResult(await cliText(this.host.cli, ["session", "compact", sessionId, ...this.modelArgs(), "--json"]));
281
+ if (!result.compacted)
282
+ return this.alert({ variant: "info", title: "Nothing to compact yet", body: "This session is still too small." });
283
+ const counts = result.originalMessageCount !== undefined && result.retainedMessageCount !== undefined
284
+ ? `${result.originalMessageCount} → ${result.retainedMessageCount} messages` : undefined;
285
+ this.alert({ variant: "success", title: `Session ${sessionId} compacted`, body: counts });
286
+ }
287
+ async previewCompaction() {
288
+ // Live run: the loop answers with a session_compaction_preview event, which opens the editor.
289
+ if (this.host.bridgeRunning) {
290
+ if (this.host.requestLiveCompactionPreview())
291
+ this.alert({ variant: "info", title: "Requested a compaction preview", body: "The editor opens when the summary is ready." });
292
+ else
293
+ this.alert({ variant: "error", title: "No active run to preview compaction for" });
294
+ return;
295
+ }
296
+ if (this.state.running)
297
+ return void this.busy("previewing compaction");
298
+ const sessionId = this.savedSession("preview");
299
+ if (!sessionId)
300
+ return;
301
+ this.alert({ variant: "info", title: "Preparing the compaction summary…" });
302
+ const preview = await cliJson(this.host.cli, ["session", "compact", sessionId, "--preview", ...this.modelArgs(), "--json"], {});
303
+ if (preview.preview !== true || typeof preview.summary !== "string") {
304
+ return this.alert({ variant: "info", title: "Nothing to preview yet", body: "This session is still too small to compact." });
305
+ }
306
+ this.host.openSummaryEditor({
307
+ summary: preview.summary,
308
+ context: { mode: "idle", sessionId },
309
+ source: typeof preview.source === "string" ? preview.source : undefined,
310
+ originalMessageCount: typeof preview.originalMessageCount === "number" ? preview.originalMessageCount : undefined,
311
+ retainedMessageCount: typeof preview.retainedMessageCount === "number" ? preview.retainedMessageCount : undefined
312
+ });
313
+ }
314
+ modelArgs() {
315
+ const args = ["--provider", this.state.provider];
316
+ if (this.state.model)
317
+ args.push("--model", this.state.model);
318
+ if (this.state.effort)
319
+ args.push("--effort", this.state.effort);
320
+ return args;
321
+ }
322
+ memory(value) {
323
+ const action = value.toLowerCase();
324
+ if (!action)
325
+ return this.host.openMenu("Project memory", toggleMenu("/memory", undefined, [...MEMORY_MENU_EXTRAS]));
326
+ if (action !== "on" && action !== "off" && action !== "status" && action !== "list")
327
+ return this.usage("/memory on|off|status|list");
328
+ return this.cliAlert(action === "list" ? "Remembered facts" : "Project memory", ["memory", action], action === "on" || action === "off" ? "success" : undefined);
329
+ }
330
+ remember(fact) {
331
+ if (!fact)
332
+ return this.host.setComposerDraft("/remember ");
333
+ return this.cliAlert("Remembered", ["remember", fact], "success");
334
+ }
335
+ setBudget(value) {
336
+ const normalized = value.toLowerCase();
337
+ if (!normalized)
338
+ return this.host.openMenu("Token budget", [...BUDGET_MENU]);
339
+ if (normalized === "status") {
340
+ return this.alert(this.state.tokenBudget
341
+ ? { variant: "info", title: `Token budget: ${formatBudgetTokens(this.state.tokenBudget)} tokens`, body: "Clear it with /set-budget off." }
342
+ : { variant: "info", title: "No token budget set", body: "This session is unbounded. Set one with /set-budget 200k." });
343
+ }
344
+ if (normalized === "off" || normalized === "none" || normalized === "0") {
345
+ this.state.tokenBudget = undefined;
346
+ this.state.usage = { ...this.state.usage, tokenBudget: undefined, budgetExceeded: undefined };
347
+ return this.alert({ variant: "success", title: "Token budget cleared", body: "This session is unbounded again." });
348
+ }
349
+ const parsed = parseBudgetInput(normalized);
350
+ if (parsed === undefined)
351
+ return this.usage("/set-budget 200k|1.5m|250000|off|status");
352
+ this.state.tokenBudget = parsed;
353
+ this.state.usage = { ...this.state.usage, tokenBudget: parsed };
354
+ this.alert({ variant: "success", title: `Token budget set to ${formatBudgetTokens(parsed)} tokens`, body: "Applies from your next message. A warning shows at 80%; the run stops at the limit." });
355
+ }
356
+ async addDirectory(directory) {
357
+ if (!directory) {
358
+ const dirs = this.state.externalDirectories;
359
+ return this.alert({ variant: "info", title: dirs.length ? "External directories" : "No external directories attached", body: dirs.length ? `${dirs.join("\n")}\n\nAdd another with /add-dir <path>.` : "Add one with /add-dir <path>." });
360
+ }
361
+ if (this.busy("changing external directories"))
362
+ return;
363
+ const sessionId = this.state.sessionId && this.state.sessionId !== "new" ? this.state.sessionId : undefined;
364
+ const parsed = await cliJson(this.host.cli, sessionId
365
+ ? ["session", "add-dir", sessionId, directory, "--json"]
366
+ : ["session", "validate-dir", directory, "--json"], null);
367
+ const added = Array.isArray(parsed)
368
+ ? parsed.filter((value) => typeof value === "string")
369
+ : parsed && typeof parsed === "object" && typeof parsed.path === "string"
370
+ ? [...this.state.externalDirectories, parsed.path]
371
+ : [];
372
+ this.state.externalDirectories = [...new Set(added)];
373
+ this.alert({ variant: "success", title: "External directory attached to this session", body: this.state.externalDirectories.at(-1) ?? directory });
374
+ }
375
+ task(value) {
376
+ const parts = value.split(/\s+/).filter(Boolean);
377
+ const action = parts[0]?.toLowerCase();
378
+ const override = process.env[TASKS_ENV];
379
+ if (!action) {
380
+ return this.host.openMenu("Tasks (this instance)", toggleMenu("/task", override === undefined ? undefined : override === "true", [...TASK_MENU_EXTRAS]));
381
+ }
382
+ if (action === "status") {
383
+ return this.alert({
384
+ variant: "info",
385
+ title: override === undefined ? "Tasks use the shared default" : `Tasks are ${override === "true" ? "on" : "off"} for this instance`,
386
+ body: override === undefined ? "Use /task on or /task off to override it for this instance only." : undefined
387
+ });
388
+ }
389
+ if (action === "on" || action === "off") {
390
+ // Instance-local: inherited by this process's agent children only; the shared config is untouched.
391
+ process.env[TASKS_ENV] = action === "on" ? "true" : "false";
392
+ return this.alert({ variant: "success", title: `Tasks turned ${action} for this instance`, body: "Other running instances and the shared default were not changed." });
393
+ }
394
+ return this.cliAlert("Tasks", ["task", ...parts]);
395
+ }
396
+ /** CrewCode app plugin templates: only meaningful with CrewCode integration on. */
397
+ plugins() {
398
+ if (this.state.integrationProfile !== "crewcode") {
399
+ return this.alert({ variant: "warning", title: "CrewCode integration is disabled for this project", body: "Enable it with /profile crewcode." });
400
+ }
401
+ return this.cliAlert("CrewCode plugin templates", ["plugin", "list-templates"]);
402
+ }
403
+ /** `/team <team> <task>`: a team declared in crewcoder.json, streamed live. */
404
+ team(value) {
405
+ const usage = "/team <team> <task> (use /teams to list teams)";
406
+ const match = /^(\S+)\s+([\s\S]+)$/.exec(value);
407
+ if (!match)
408
+ return this.usage(usage);
409
+ const [, team = "", task = ""] = match;
410
+ if (!isCrewName(team))
411
+ return this.usage(`${usage}\nTeam ids are letters, digits, and . _ - (not ${team}).`);
412
+ this.host.launchCrew({ kind: "team", team }, task.trim(), `/team ${team} ${task.trim()}`);
413
+ }
414
+ /** `/crew <worker1,worker2> <task>`: named workers in order, streamed live. */
415
+ crew(value) {
416
+ const usage = "/crew <worker1,worker2> <task> (use /workers to list workers)";
417
+ const match = /^(\S+)\s+([\s\S]+)$/.exec(value);
418
+ if (!match)
419
+ return this.usage(usage);
420
+ const [, list = "", task = ""] = match;
421
+ const workers = [...new Set(list.split(",").map((name) => name.trim()).filter(Boolean))];
422
+ const bad = workers.find((name) => !isCrewName(name));
423
+ if (!workers.length || bad !== undefined)
424
+ return this.usage(`${usage}\nWorker names are letters, digits, and . _ - (not ${bad ?? list}).`);
425
+ this.host.launchCrew({ kind: "workers", workers }, task.trim(), `/crew ${workers.join(",")} ${task.trim()}`);
426
+ }
427
+ async reviewSummary() {
428
+ this.alert(reviewSummaryAlert(parseReviewSummary(await cliText(this.host.cli, ["git", "review-summary", "--json"]))));
429
+ }
430
+ /** A one-shot `session why`, never a prompt in the session. */
431
+ async why() {
432
+ const sessionId = this.savedSession("explain");
433
+ if (!sessionId)
434
+ return;
435
+ this.alert({ variant: "info", title: "Asking the model to explain its last decision…" });
436
+ const decision = parseDecisionExplanation(await cliText(this.host.cli, ["session", "why", sessionId, "--json", ...this.modelArgs()]));
437
+ this.alert(decision ? whyAlert(decision) : { variant: "info", title: "Nothing to explain yet", body: "This session has no agent turn." });
438
+ }
439
+ /**
440
+ * Fork the current session in place. Refused mid-run: the copy would miss the
441
+ * rest of the turn (and any follow-ups), which keep going to the original.
442
+ */
443
+ async branch() {
444
+ if (this.busy("branching the session"))
445
+ return;
446
+ const source = this.savedSession("branch");
447
+ if (!source)
448
+ return;
449
+ const branched = await this.host.cli.branch(source);
450
+ this.state.sessionId = branched || source;
451
+ this.alert({ variant: "success", title: "Branched session", body: `${source} → ${this.state.sessionId}. New messages go to the branch.` });
452
+ }
453
+ async exportSession(outPath) {
454
+ const sessionId = this.savedSession("export");
455
+ if (!sessionId)
456
+ return;
457
+ const target = outPath || `${sessionId}.html`;
458
+ const stdout = await cliText(this.host.cli, ["session", "export", sessionId, "--html", "--out", target]);
459
+ this.alert({ variant: "success", title: "Session exported", body: stdout.trim() || target });
460
+ }
461
+ async reload() {
462
+ if (this.busy("reloading"))
463
+ return;
464
+ const [config, providers, profile] = await Promise.all([
465
+ this.readConfig(),
466
+ this.flows.reloadProviders(),
467
+ cliText(this.host.cli, ["profile", "show"]).then((text) => text.trim(), () => undefined),
468
+ this.host.loadExtensionRenderers()
469
+ ]);
470
+ const state = this.state;
471
+ if (profile === "crewcode" || profile === "standalone")
472
+ state.integrationProfile = profile;
473
+ if (typeof config.defaultMode === "string") {
474
+ state.mode = normalizeTuiMode(config.defaultMode);
475
+ if (state.mode === "plugin" && state.integrationProfile !== "crewcode")
476
+ state.mode = "general";
477
+ }
478
+ if (typeof config.defaultProvider === "string" && config.defaultProvider.trim())
479
+ state.provider = config.defaultProvider.trim();
480
+ if (typeof config.defaultModel === "string" && config.defaultModel.trim())
481
+ state.model = config.defaultModel.trim();
482
+ state.thinkingEnabled = config.thinkingEnabled !== false;
483
+ state.workerIdentityEnabled = config.workerIdentityEnabled === true;
484
+ const provider = providers.find((item) => item.id === state.provider) ?? providers[0];
485
+ if (provider) {
486
+ state.provider = provider.id;
487
+ if (provider.models.length && !provider.models.includes(state.model))
488
+ state.model = provider.defaultModel ?? provider.models[0] ?? state.model;
489
+ }
490
+ const levels = effortLevelsForModel(state.provider, state.model);
491
+ if (!levels.includes(state.effort))
492
+ state.effort = levels[0] ?? state.effort;
493
+ this.alert({ variant: "success", title: "Reloaded CrewCoder", body: `${providers.length} provider${providers.length === 1 ? "" : "s"} · profile ${state.integrationProfile} · ${state.provider}/${state.model}` });
494
+ }
495
+ async goal(input) {
496
+ if (!input)
497
+ return this.host.openGoalForm(goalDefaults(await this.readConfig()));
498
+ const parts = tokenizeGoalCommand(input);
499
+ const action = parts[0]?.toLowerCase();
500
+ const approval = this.state.fullAccess ? "full-access" : "review";
501
+ if (action === "status")
502
+ return this.goalArgs(["goal", "status", ...parts.slice(1), "--json"]);
503
+ if (action === "list")
504
+ return this.goalArgs(["goal", "list", "--json"]);
505
+ if (action === "logs") {
506
+ const stdout = await cliText(this.host.cli, ["goal", "logs", ...parts.slice(1, 2)]);
507
+ const lines = stdout.split("\n").filter(Boolean).slice(-30);
508
+ return this.alert({ variant: "info", title: "Recent goal events", body: lines.length ? lines.join("\n") : "No goal events recorded yet." });
509
+ }
510
+ if (action === "pause" || action === "clear" || action === "approve" || action === "deny") {
511
+ return this.goalArgs(["goal", action, ...parts.slice(1), "--json"]);
512
+ }
513
+ if (action === "resume")
514
+ return this.goalArgs(["goal", "resume", ...parts.slice(1), "--approval", approval, "--json"]);
515
+ return this.startGoal(parseGoalStartInput(action === "start" ? parts.slice(1) : parts));
516
+ }
517
+ /** Detached goals run in CrewCoder's supervisor; closing the TUI does not stop them. */
518
+ startGoal(start) {
519
+ const state = this.state;
520
+ const args = ["goal", "start", start.objective, "--provider", state.provider, "--model", state.model, "--mode", state.mode,
521
+ "--effort", state.effort, "--approval", state.fullAccess ? "full-access" : "review", "--json"];
522
+ if (start.maxTurns !== undefined)
523
+ args.push("--max-turns", String(start.maxTurns));
524
+ if (start.timeoutMinutes !== undefined)
525
+ args.push("--timeout-minutes", String(start.timeoutMinutes));
526
+ if (start.checkModel)
527
+ args.push("--check-model", start.checkModel);
528
+ else if (start.disableCheckModel)
529
+ args.push("--no-check-model");
530
+ if (state.tokenBudget)
531
+ args.push("--budget", String(state.tokenBudget));
532
+ if (state.systemPrompt)
533
+ args.push("--system-prompt", state.systemPrompt);
534
+ if (state.worker)
535
+ args.push("--worker", state.worker);
536
+ return this.goalArgs(args);
537
+ }
538
+ async goalArgs(args) {
539
+ const parsed = await cliJson(this.host.cli, args, null);
540
+ const records = Array.isArray(parsed) ? parsed : [parsed];
541
+ const goals = records.flatMap((record) => {
542
+ const goal = parseGoalRecord(JSON.stringify(record));
543
+ return goal ? [goal] : [];
544
+ });
545
+ this.alert(goalsAlert(goals.slice(0, 10)));
546
+ }
547
+ clear() {
548
+ if (this.busy("clearing the screen"))
549
+ return;
550
+ this.host.clearScreen();
551
+ }
552
+ approvePlan() {
553
+ // A CrewCoder-mode plan acceptance is a prompt, not a tool-call approval.
554
+ if (this.host.bridgeRunning) {
555
+ if (!this.host.queueFollowUp("/approve-plan"))
556
+ this.alert({ variant: "error", title: "Could not send /approve-plan to the active run" });
557
+ return;
558
+ }
559
+ this.host.startPrompt("/approve-plan");
560
+ }
561
+ followUp(message) {
562
+ if (!message)
563
+ return this.usage("/follow-up <message>");
564
+ if (!this.host.bridgeRunning) {
565
+ return this.alert({ variant: "warning", title: "No active run", body: "Send a normal message to start or resume the session." });
566
+ }
567
+ if (!this.host.queueFollowUp(message))
568
+ this.alert({ variant: "error", title: "Could not queue the follow-up for the active run" });
569
+ }
570
+ }
571
+ //# sourceMappingURL=command-runner.js.map