@sortedyuan/maybecode 0.3.2 → 0.5.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 (295) hide show
  1. package/README.md +166 -55
  2. package/README.zh-CN.md +267 -0
  3. package/dist/application.d.ts +40 -34
  4. package/dist/application.d.ts.map +1 -1
  5. package/dist/application.js +290 -170
  6. package/dist/application.js.map +1 -1
  7. package/dist/args.d.ts +2 -2
  8. package/dist/args.d.ts.map +1 -1
  9. package/dist/args.js +50 -27
  10. package/dist/args.js.map +1 -1
  11. package/dist/bin.js +82 -71
  12. package/dist/bin.js.map +4 -4
  13. package/dist/cli/chunk-3IORPKBL.js +3572 -0
  14. package/dist/cli/chunk-3IORPKBL.js.map +7 -0
  15. package/dist/cli/{chunk-LVTRXPDS.js → chunk-4B2Z6KW7.js} +1547 -1536
  16. package/dist/cli/chunk-4B2Z6KW7.js.map +7 -0
  17. package/dist/cli/{chunk-JT6VBKOM.js → chunk-4WG6JIJJ.js} +127 -33
  18. package/dist/cli/{chunk-JT6VBKOM.js.map → chunk-4WG6JIJJ.js.map} +3 -3
  19. package/dist/cli/{chunk-K5JWPNSY.js → chunk-5SLWALZK.js} +3521 -16164
  20. package/dist/cli/chunk-5SLWALZK.js.map +7 -0
  21. package/dist/cli/chunk-MNBYXL5Y.js +132 -0
  22. package/dist/cli/chunk-MNBYXL5Y.js.map +7 -0
  23. package/dist/cli/{chunk-F4XRPLUM.js → chunk-SLWLUEHQ.js} +226 -86
  24. package/dist/cli/chunk-SLWLUEHQ.js.map +7 -0
  25. package/dist/cli/chunk-UQDZ55LQ.js +199 -0
  26. package/dist/cli/chunk-UQDZ55LQ.js.map +7 -0
  27. package/dist/cli/{chunk-7ISOHFS7.js → chunk-WMSG5ZTR.js} +717 -388
  28. package/dist/cli/chunk-WMSG5ZTR.js.map +7 -0
  29. package/dist/cli/chunk-WVIRS76R.js +4057 -0
  30. package/dist/cli/chunk-WVIRS76R.js.map +7 -0
  31. package/dist/cli/{chunk-HOU5ITUK.js → chunk-XTEMRAQW.js} +1 -1
  32. package/dist/cli/chunk-XTEMRAQW.js.map +7 -0
  33. package/dist/cli/chunk-Z3BOPBVU.js +91 -0
  34. package/dist/cli/chunk-Z3BOPBVU.js.map +7 -0
  35. package/dist/cli/{configured-WHY3GGAJ.js → configured-ACNM6TRQ.js} +10 -9
  36. package/dist/cli/{file-type-R2T7TBHI.js → file-type-HLHPV7WC.js} +817 -13
  37. package/dist/cli/file-type-HLHPV7WC.js.map +7 -0
  38. package/dist/cli/mcp-auth-XD5U7WCV.js +74 -0
  39. package/dist/cli/mcp-auth-XD5U7WCV.js.map +7 -0
  40. package/dist/cli/onboarding-WQWCPYEO.js +530 -0
  41. package/dist/cli/onboarding-WQWCPYEO.js.map +7 -0
  42. package/dist/cli/onboarding-check-HRRI5OJ7.js +32 -0
  43. package/dist/cli/onboarding-check-HRRI5OJ7.js.map +7 -0
  44. package/dist/cli/{retained-tui-VJ3VX4R3.js → retained-tui-QF5VMYLC.js} +788 -332
  45. package/dist/cli/retained-tui-QF5VMYLC.js.map +7 -0
  46. package/dist/cli/{sixel-LWTCM76G.js → sixel-ISZ4FZ3U.js} +37 -37
  47. package/dist/cli/{sixel-LWTCM76G.js.map → sixel-ISZ4FZ3U.js.map} +1 -1
  48. package/dist/cli/{team-T7G7PPNN.js → team-O2I5BXHM.js} +7 -6
  49. package/dist/cli/{team-v2-JGBBQ7FR.js → team-v2-YYO2G7DJ.js} +816 -390
  50. package/dist/cli/team-v2-YYO2G7DJ.js.map +7 -0
  51. package/dist/cli/{web-server-FOMNPY7Q.js → web-server-SXMH6FGA.js} +55 -19
  52. package/dist/cli/web-server-SXMH6FGA.js.map +7 -0
  53. package/dist/cli/{web-ui-COB6PKC5.js → web-ui-UWQUFE4W.js} +7 -6
  54. package/dist/config-schema.json +337 -0
  55. package/dist/configured.d.ts +18 -11
  56. package/dist/configured.d.ts.map +1 -1
  57. package/dist/configured.js +213 -390
  58. package/dist/configured.js.map +1 -1
  59. package/dist/controller.d.ts +19 -18
  60. package/dist/controller.d.ts.map +1 -1
  61. package/dist/delegation-commands.d.ts +1 -1
  62. package/dist/delegation-commands.d.ts.map +1 -1
  63. package/dist/delegation-commands.js +8 -8
  64. package/dist/delegation-commands.js.map +1 -1
  65. package/dist/errors.d.ts +2 -1
  66. package/dist/errors.d.ts.map +1 -1
  67. package/dist/errors.js +2 -1
  68. package/dist/errors.js.map +1 -1
  69. package/dist/events.d.ts +8 -6
  70. package/dist/events.d.ts.map +1 -1
  71. package/dist/fork-picker.d.ts.map +1 -1
  72. package/dist/fork-picker.js +19 -5
  73. package/dist/fork-picker.js.map +1 -1
  74. package/dist/git-request.d.ts +6 -6
  75. package/dist/git-request.d.ts.map +1 -1
  76. package/dist/git-request.js +28 -15
  77. package/dist/git-request.js.map +1 -1
  78. package/dist/goal-commands.d.ts +1 -1
  79. package/dist/goal-commands.d.ts.map +1 -1
  80. package/dist/goal-commands.js +12 -5
  81. package/dist/goal-commands.js.map +1 -1
  82. package/dist/index.d.ts +5 -37
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +3 -36
  85. package/dist/index.js.map +1 -1
  86. package/dist/instructions.d.ts +2 -7
  87. package/dist/instructions.d.ts.map +1 -1
  88. package/dist/instructions.js +7 -15
  89. package/dist/instructions.js.map +1 -1
  90. package/dist/keymap.d.ts +2 -2
  91. package/dist/keymap.d.ts.map +1 -1
  92. package/dist/keymap.js +2 -2
  93. package/dist/keymap.js.map +1 -1
  94. package/dist/maybecode-config.schema.json +1765 -0
  95. package/dist/mcp-auth.d.ts +1 -1
  96. package/dist/mcp-auth.d.ts.map +1 -1
  97. package/dist/mcp-auth.js +11 -8
  98. package/dist/mcp-auth.js.map +1 -1
  99. package/dist/mcp-commands.d.ts.map +1 -1
  100. package/dist/mcp-commands.js +18 -4
  101. package/dist/mcp-commands.js.map +1 -1
  102. package/dist/mcp-interaction-ui.d.ts.map +1 -1
  103. package/dist/mcp-interaction-ui.js +11 -4
  104. package/dist/mcp-interaction-ui.js.map +1 -1
  105. package/dist/media-history.d.ts +1 -1
  106. package/dist/media-history.d.ts.map +1 -1
  107. package/dist/media-history.js +8 -2
  108. package/dist/media-history.js.map +1 -1
  109. package/dist/model-picker.d.ts.map +1 -1
  110. package/dist/model-picker.js +10 -11
  111. package/dist/model-picker.js.map +1 -1
  112. package/dist/model-transition.d.ts +11 -0
  113. package/dist/model-transition.d.ts.map +1 -0
  114. package/dist/model-transition.js +48 -0
  115. package/dist/model-transition.js.map +1 -0
  116. package/dist/model.d.ts +2 -2
  117. package/dist/model.d.ts.map +1 -1
  118. package/dist/model.js +8 -4
  119. package/dist/model.js.map +1 -1
  120. package/dist/onboarding-check.d.ts +3 -0
  121. package/dist/onboarding-check.d.ts.map +1 -0
  122. package/dist/onboarding-check.js +22 -0
  123. package/dist/onboarding-check.js.map +1 -0
  124. package/dist/onboarding.d.ts +6 -0
  125. package/dist/onboarding.d.ts.map +1 -0
  126. package/dist/onboarding.js +463 -0
  127. package/dist/onboarding.js.map +1 -0
  128. package/dist/plugins/application.d.ts +6 -4
  129. package/dist/plugins/application.d.ts.map +1 -1
  130. package/dist/plugins/application.js +106 -52
  131. package/dist/plugins/application.js.map +1 -1
  132. package/dist/plugins/instructions.d.ts +1 -1
  133. package/dist/plugins/instructions.d.ts.map +1 -1
  134. package/dist/plugins/instructions.js +24 -11
  135. package/dist/plugins/instructions.js.map +1 -1
  136. package/dist/plugins/resources.d.ts +2 -2
  137. package/dist/plugins/resources.d.ts.map +1 -1
  138. package/dist/plugins/resources.js +22 -12
  139. package/dist/plugins/resources.js.map +1 -1
  140. package/dist/policy.d.ts +1 -1
  141. package/dist/policy.d.ts.map +1 -1
  142. package/dist/policy.js +59 -11
  143. package/dist/policy.js.map +1 -1
  144. package/dist/run.d.ts +2 -0
  145. package/dist/run.d.ts.map +1 -1
  146. package/dist/run.js +38 -33
  147. package/dist/run.js.map +1 -1
  148. package/dist/runtime-instructions.d.ts +1 -1
  149. package/dist/runtime-instructions.d.ts.map +1 -1
  150. package/dist/runtime-instructions.js +15 -7
  151. package/dist/runtime-instructions.js.map +1 -1
  152. package/dist/session-navigation.d.ts +6 -0
  153. package/dist/session-navigation.d.ts.map +1 -0
  154. package/dist/session-navigation.js +64 -0
  155. package/dist/session-navigation.js.map +1 -0
  156. package/dist/session-picker.d.ts +1 -1
  157. package/dist/session-picker.d.ts.map +1 -1
  158. package/dist/session-picker.js +23 -32
  159. package/dist/session-picker.js.map +1 -1
  160. package/dist/settings.d.ts +718 -0
  161. package/dist/settings.d.ts.map +1 -0
  162. package/dist/settings.js +14 -0
  163. package/dist/settings.js.map +1 -0
  164. package/dist/skills.d.ts +1 -1
  165. package/dist/skills.d.ts.map +1 -1
  166. package/dist/skills.js +10 -12
  167. package/dist/skills.js.map +1 -1
  168. package/dist/slash-commands.d.ts +2 -2
  169. package/dist/slash-commands.d.ts.map +1 -1
  170. package/dist/slash-commands.js +149 -67
  171. package/dist/slash-commands.js.map +1 -1
  172. package/dist/team-execution.d.ts +10 -0
  173. package/dist/team-execution.d.ts.map +1 -0
  174. package/dist/team-execution.js +29 -0
  175. package/dist/team-execution.js.map +1 -0
  176. package/dist/team-patches.d.ts.map +1 -1
  177. package/dist/team-patches.js +149 -52
  178. package/dist/team-patches.js.map +1 -1
  179. package/dist/team-plan.d.ts +2 -2
  180. package/dist/team-plan.d.ts.map +1 -1
  181. package/dist/team-plan.js +115 -34
  182. package/dist/team-plan.js.map +1 -1
  183. package/dist/team-recovery.d.ts +1 -1
  184. package/dist/team-recovery.d.ts.map +1 -1
  185. package/dist/team-recovery.js +40 -10
  186. package/dist/team-recovery.js.map +1 -1
  187. package/dist/team-v2.d.ts.map +1 -1
  188. package/dist/team-v2.js +335 -104
  189. package/dist/team-v2.js.map +1 -1
  190. package/dist/team-verification.d.ts +4 -2
  191. package/dist/team-verification.d.ts.map +1 -1
  192. package/dist/team-verification.js +300 -97
  193. package/dist/team-verification.js.map +1 -1
  194. package/dist/team.d.ts +2 -2
  195. package/dist/team.d.ts.map +1 -1
  196. package/dist/team.js +172 -62
  197. package/dist/team.js.map +1 -1
  198. package/dist/terminal-web.d.ts +1 -0
  199. package/dist/terminal-web.d.ts.map +1 -1
  200. package/dist/terminal-web.js +28 -10
  201. package/dist/terminal-web.js.map +1 -1
  202. package/dist/ui/actions.d.ts.map +1 -1
  203. package/dist/ui/actions.js.map +1 -1
  204. package/dist/ui/retained-tui.d.ts.map +1 -1
  205. package/dist/ui/retained-tui.js +231 -173
  206. package/dist/ui/retained-tui.js.map +1 -1
  207. package/dist/ui/{prototype-view.d.ts → terminal-view.d.ts} +7 -7
  208. package/dist/ui/terminal-view.d.ts.map +1 -0
  209. package/dist/ui/{prototype-view.js → terminal-view.js} +185 -98
  210. package/dist/ui/terminal-view.js.map +1 -0
  211. package/dist/web-commands.d.ts.map +1 -1
  212. package/dist/web-commands.js +160 -57
  213. package/dist/web-commands.js.map +1 -1
  214. package/dist/web-extension.d.ts.map +1 -1
  215. package/dist/web-extension.js +14 -4
  216. package/dist/web-extension.js.map +1 -1
  217. package/dist/web-server.d.ts.map +1 -1
  218. package/dist/web-server.js +2 -1
  219. package/dist/web-server.js.map +1 -1
  220. package/dist/web-ui.d.ts.map +1 -1
  221. package/dist/web-ui.js +167 -40
  222. package/dist/web-ui.js.map +1 -1
  223. package/dist/workspace-configuration.d.ts +7 -0
  224. package/dist/workspace-configuration.d.ts.map +1 -0
  225. package/dist/workspace-configuration.js +134 -0
  226. package/dist/workspace-configuration.js.map +1 -0
  227. package/dist/workspace-state.d.ts +20 -0
  228. package/dist/workspace-state.d.ts.map +1 -0
  229. package/dist/workspace-state.js +2 -0
  230. package/dist/workspace-state.js.map +1 -0
  231. package/dist/workspace.d.ts +26 -43
  232. package/dist/workspace.d.ts.map +1 -1
  233. package/dist/workspace.js +261 -323
  234. package/dist/workspace.js.map +1 -1
  235. package/package.json +21 -31
  236. package/dist/cli/chunk-7ISOHFS7.js.map +0 -7
  237. package/dist/cli/chunk-F4XRPLUM.js.map +0 -7
  238. package/dist/cli/chunk-H7SNBFO4.js +0 -5522
  239. package/dist/cli/chunk-H7SNBFO4.js.map +0 -7
  240. package/dist/cli/chunk-HOU5ITUK.js.map +0 -7
  241. package/dist/cli/chunk-K5JWPNSY.js.map +0 -7
  242. package/dist/cli/chunk-LVTRXPDS.js.map +0 -7
  243. package/dist/cli/chunk-VAZMCNBB.js +0 -686
  244. package/dist/cli/chunk-VAZMCNBB.js.map +0 -7
  245. package/dist/cli/chunk-WOFEI42C.js +0 -7820
  246. package/dist/cli/chunk-WOFEI42C.js.map +0 -7
  247. package/dist/cli/file-type-R2T7TBHI.js.map +0 -7
  248. package/dist/cli/mcp-auth-UNRHSIKJ.js +0 -63
  249. package/dist/cli/mcp-auth-UNRHSIKJ.js.map +0 -7
  250. package/dist/cli/retained-tui-VJ3VX4R3.js.map +0 -7
  251. package/dist/cli/team-v2-JGBBQ7FR.js.map +0 -7
  252. package/dist/cli/tui-SA74DKMA.js +0 -1705
  253. package/dist/cli/tui-SA74DKMA.js.map +0 -7
  254. package/dist/cli/web-server-FOMNPY7Q.js.map +0 -7
  255. package/dist/delegation.d.ts +0 -2
  256. package/dist/delegation.d.ts.map +0 -1
  257. package/dist/delegation.js +0 -2
  258. package/dist/delegation.js.map +0 -1
  259. package/dist/history-memory.d.ts +0 -2
  260. package/dist/history-memory.d.ts.map +0 -1
  261. package/dist/history-memory.js +0 -2
  262. package/dist/history-memory.js.map +0 -1
  263. package/dist/subagent-budget.d.ts +0 -2
  264. package/dist/subagent-budget.d.ts.map +0 -1
  265. package/dist/subagent-budget.js +0 -2
  266. package/dist/subagent-budget.js.map +0 -1
  267. package/dist/subagent-files.d.ts +0 -2
  268. package/dist/subagent-files.d.ts.map +0 -1
  269. package/dist/subagent-files.js +0 -2
  270. package/dist/subagent-files.js.map +0 -1
  271. package/dist/subagent-host.d.ts +0 -2
  272. package/dist/subagent-host.d.ts.map +0 -1
  273. package/dist/subagent-host.js +0 -2
  274. package/dist/subagent-host.js.map +0 -1
  275. package/dist/subagent-instructions.d.ts +0 -2
  276. package/dist/subagent-instructions.d.ts.map +0 -1
  277. package/dist/subagent-instructions.js +0 -2
  278. package/dist/subagent-instructions.js.map +0 -1
  279. package/dist/subagents.d.ts +0 -2
  280. package/dist/subagents.d.ts.map +0 -1
  281. package/dist/subagents.js +0 -2
  282. package/dist/subagents.js.map +0 -1
  283. package/dist/summarizer.d.ts +0 -2
  284. package/dist/summarizer.d.ts.map +0 -1
  285. package/dist/summarizer.js +0 -2
  286. package/dist/summarizer.js.map +0 -1
  287. package/dist/tui.d.ts +0 -7
  288. package/dist/tui.d.ts.map +0 -1
  289. package/dist/tui.js +0 -1109
  290. package/dist/tui.js.map +0 -1
  291. package/dist/ui/prototype-view.d.ts.map +0 -1
  292. package/dist/ui/prototype-view.js.map +0 -1
  293. /package/dist/cli/{configured-WHY3GGAJ.js.map → configured-ACNM6TRQ.js.map} +0 -0
  294. /package/dist/cli/{team-T7G7PPNN.js.map → team-O2I5BXHM.js.map} +0 -0
  295. /package/dist/cli/{web-ui-COB6PKC5.js.map → web-ui-UWQUFE4W.js.map} +0 -0
@@ -1,10 +1,11 @@
1
+ import { omitUndefined } from "@sortedyuan/may/core";
1
2
  import { Column, Dialog, Editor, EditorHistory, FocusManager, Panel, ScrollView, SelectList, Text, sanitizeTerminalText, styleText, SessionForkPicker, WorkspaceDiffViewer, workspaceGitLabel, } from "@sortedyuan/tui";
2
- import { TranscriptView, } from "@sortedyuan/tui/transcript";
3
+ import { TranscriptView } from "@sortedyuan/tui/transcript";
3
4
  import { createMaybeCodeKeymap, MAYBECODE_EDITOR_KEYBINDINGS } from "../keymap.js";
4
5
  import { MAYBECODE_DARK_THEME } from "./theme.js";
5
6
  import { MaybeCodeUiActionRegistry } from "./actions.js";
6
7
  /** Retained MaybeCode view shared by the experimental terminal frontend. */
7
- export class MaybeCodePrototypeView {
8
+ export class MaybeCodeTerminalView {
8
9
  options;
9
10
  focus = new FocusManager();
10
11
  keymap;
@@ -34,13 +35,13 @@ export class MaybeCodePrototypeView {
34
35
  layout = new Column([]);
35
36
  editorSize = { width: 1, height: 1 };
36
37
  editorRegion = {
37
- render: size => {
38
+ render: (size) => {
38
39
  this.editorSize = size;
39
40
  return new Panel(this.editor, {
40
41
  borderStyle: this.focus.focusedId === "editor" ? this.theme.borderAccent : this.theme.border,
41
42
  }).render(size);
42
43
  },
43
- handlePointer: event => {
44
+ handlePointer: (event) => {
44
45
  if (event.type === "down") {
45
46
  if (event.button !== 0)
46
47
  return false;
@@ -54,8 +55,8 @@ export class MaybeCodePrototypeView {
54
55
  },
55
56
  };
56
57
  transcriptRegion = {
57
- render: size => this.transcript.render(size),
58
- handlePointer: event => {
58
+ render: (size) => this.transcript.render(size),
59
+ handlePointer: (event) => {
59
60
  if (event.type === "down") {
60
61
  if (event.button !== 0)
61
62
  return false;
@@ -74,7 +75,7 @@ export class MaybeCodePrototypeView {
74
75
  baseView = {
75
76
  render: (size) => this.renderBase(size),
76
77
  handleKey: (stroke) => this.handleBaseKey(stroke),
77
- handlePointer: event => this.layout.handlePointer(event),
78
+ handlePointer: (event) => this.layout.handlePointer(event),
78
79
  };
79
80
  constructor(options) {
80
81
  this.options = options;
@@ -88,34 +89,36 @@ export class MaybeCodePrototypeView {
88
89
  assistantLabel: "MaybeCode",
89
90
  selectedToolDetailsHint: "Enter details",
90
91
  toolDetailsHint: `${this.shortcutHint("app.tools.toggle")} all`,
91
- ...(options.toolRenderers === undefined ? {} : { toolRenderers: options.toolRenderers }),
92
+ ...omitUndefined({ toolRenderers: options.toolRenderers }),
92
93
  });
93
94
  this.transcript = new ScrollView(this.transcriptView, {
94
95
  followEnd: true,
95
96
  onInvalidate: () => options.onInvalidate?.(),
96
97
  });
97
98
  this.inputHistory = options.inputHistory ?? new EditorHistory();
98
- this.uiActions = options.uiActions ?? new MaybeCodeUiActionRegistry()
99
- .register({
100
- id: "tools.toggle",
101
- command: "/details",
102
- description: "Toggle all tool execution details",
103
- run: () => {
104
- this.preserveSelectedToolPosition();
105
- const visible = this.transcriptView.toggleToolDetails();
106
- return `Tool details ${visible ? "shown" : "hidden"}`;
107
- },
108
- })
109
- .register({
110
- id: "thinking.toggle",
111
- command: "/thinking",
112
- description: "Toggle reasoning block visibility",
113
- run: () => {
114
- this.preserveSelectedToolPosition();
115
- const visible = this.transcriptView.toggleReasoning();
116
- return `Thinking ${visible ? "shown" : "hidden"}`;
117
- },
118
- });
99
+ this.uiActions =
100
+ options.uiActions ??
101
+ new MaybeCodeUiActionRegistry()
102
+ .register({
103
+ id: "tools.toggle",
104
+ command: "/details",
105
+ description: "Toggle all tool execution details",
106
+ run: () => {
107
+ this.preserveSelectedToolPosition();
108
+ const visible = this.transcriptView.toggleToolDetails();
109
+ return `Tool details ${visible ? "shown" : "hidden"}`;
110
+ },
111
+ })
112
+ .register({
113
+ id: "thinking.toggle",
114
+ command: "/thinking",
115
+ description: "Toggle reasoning block visibility",
116
+ run: () => {
117
+ this.preserveSelectedToolPosition();
118
+ const visible = this.transcriptView.toggleReasoning();
119
+ return `Thinking ${visible ? "shown" : "hidden"}`;
120
+ },
121
+ });
119
122
  this.editor = new Editor({
120
123
  ...this.editorOptions(),
121
124
  history: this.inputHistory,
@@ -168,13 +171,20 @@ export class MaybeCodePrototypeView {
168
171
  editorOptions() {
169
172
  return {
170
173
  keybindings: MAYBECODE_EDITOR_KEYBINDINGS,
171
- ...(this.options.clipboard === undefined ? {} : { clipboard: this.options.clipboard }),
174
+ ...omitUndefined({ clipboard: this.options.clipboard }),
172
175
  onInvalidate: () => this.options.onInvalidate?.(),
173
- onError: error => this.setStatus(`Error: ${error instanceof Error ? error.message : String(error)}`),
176
+ onError: (error) => this.setStatus(`Error: ${error instanceof Error ? error.message : String(error)}`),
174
177
  };
175
178
  }
176
179
  shortcutHint(action) {
177
- return this.keymap.keysForAction(action)[0]?.split(" ").map(key => key.split("+").map(part => part.length === 1 ? part.toUpperCase() : part[0].toUpperCase() + part.slice(1)).join("+")).join(" ") ?? "";
180
+ return (this.keymap
181
+ .keysForAction(action)[0]
182
+ ?.split(" ")
183
+ .map((key) => key
184
+ .split("+")
185
+ .map((part) => (part.length === 1 ? part.toUpperCase() : part[0].toUpperCase() + part.slice(1)))
186
+ .join("+"))
187
+ .join(" ") ?? "");
178
188
  }
179
189
  resetInputContext() {
180
190
  this.keymap.reset();
@@ -210,7 +220,9 @@ export class MaybeCodePrototypeView {
210
220
  return new Promise((resolve) => {
211
221
  let settled = false;
212
222
  const abort = () => pending.finish();
213
- const pending = { prompt, finish: (value) => {
223
+ const pending = {
224
+ prompt,
225
+ finish: (value) => {
214
226
  if (settled)
215
227
  return;
216
228
  settled = true;
@@ -225,7 +237,8 @@ export class MaybeCodePrototypeView {
225
237
  }
226
238
  resolve(value);
227
239
  this.options.onInvalidate?.();
228
- } };
240
+ },
241
+ };
229
242
  this.mcpQuestions.push(pending);
230
243
  signal.addEventListener("abort", abort, { once: true });
231
244
  this.openCurrentApproval();
@@ -304,9 +317,7 @@ export class MaybeCodePrototypeView {
304
317
  });
305
318
  }
306
319
  requestReasoningEffortSelection(state) {
307
- if (state.status !== "known" ||
308
- this.dialog !== undefined ||
309
- this.resolveEffortDialog !== undefined) {
320
+ if (state.status !== "known" || this.dialog !== undefined || this.resolveEffortDialog !== undefined) {
310
321
  return state.status === "known"
311
322
  ? Promise.reject(new Error("Another dialog is already open"))
312
323
  : Promise.resolve(undefined);
@@ -352,10 +363,22 @@ export class MaybeCodePrototypeView {
352
363
  requestForkSelection(points, currentSessionId) {
353
364
  if (this.dialog)
354
365
  return Promise.reject(new Error("Another dialog is already open"));
355
- return new Promise(resolve => {
366
+ return new Promise((resolve) => {
356
367
  this.resolveVersionDialog = resolve;
357
- const picker = new SessionForkPicker(points, { currentSessionId, theme: this.theme, onComplete: selection => this.completeVersionDialog(selection) });
358
- this.dialog = new Dialog(this.baseView, picker, { open: true, title: "Session 分支", width: 100, height: 25, dismissOnEscape: false, borderStyle: this.theme.borderAccent, titleStyle: this.theme.accent });
368
+ const picker = new SessionForkPicker(points, {
369
+ currentSessionId,
370
+ theme: this.theme,
371
+ onComplete: (selection) => this.completeVersionDialog(selection),
372
+ });
373
+ this.dialog = new Dialog(this.baseView, picker, {
374
+ open: true,
375
+ title: "Session 分支",
376
+ width: 100,
377
+ height: 25,
378
+ dismissOnEscape: false,
379
+ borderStyle: this.theme.borderAccent,
380
+ titleStyle: this.theme.accent,
381
+ });
359
382
  this.dialogKind = "fork";
360
383
  this.synchronizeDialog();
361
384
  this.options.onInvalidate?.();
@@ -364,10 +387,23 @@ export class MaybeCodePrototypeView {
364
387
  requestChanges(diff, operations = {}) {
365
388
  if (this.dialog)
366
389
  return Promise.reject(new Error("Another dialog is already open"));
367
- return new Promise(resolve => {
390
+ return new Promise((resolve) => {
368
391
  this.resolveVersionDialog = () => resolve();
369
- const viewer = new WorkspaceDiffViewer(diff, { theme: this.theme, onClose: () => this.completeVersionDialog(), ...operations, onInvalidate: () => this.options.onInvalidate?.() });
370
- this.dialog = new Dialog(this.baseView, viewer, { open: true, title: "文件变化", width: 110, height: 30, dismissOnEscape: false, borderStyle: this.theme.borderAccent, titleStyle: this.theme.accent });
392
+ const viewer = new WorkspaceDiffViewer(diff, {
393
+ theme: this.theme,
394
+ onClose: () => this.completeVersionDialog(),
395
+ ...operations,
396
+ onInvalidate: () => this.options.onInvalidate?.(),
397
+ });
398
+ this.dialog = new Dialog(this.baseView, viewer, {
399
+ open: true,
400
+ title: "文件变化",
401
+ width: 110,
402
+ height: 30,
403
+ dismissOnEscape: false,
404
+ borderStyle: this.theme.borderAccent,
405
+ titleStyle: this.theme.accent,
406
+ });
371
407
  this.dialogKind = "changes";
372
408
  this.synchronizeDialog();
373
409
  this.options.onInvalidate?.();
@@ -418,9 +454,7 @@ export class MaybeCodePrototypeView {
418
454
  }
419
455
  }
420
456
  renderBase(size) {
421
- const suggestionHeight = this.suggestionsVisible
422
- ? Math.min(7, this.suggestions.length + 2)
423
- : 0;
457
+ const suggestionHeight = this.suggestionsVisible ? Math.min(7, this.suggestions.length + 2) : 0;
424
458
  this.layout.setItems([
425
459
  {
426
460
  height: 3,
@@ -429,14 +463,16 @@ export class MaybeCodePrototypeView {
429
463
  { flex: 1, minHeight: 1, component: this.transcriptRegion },
430
464
  ...(suggestionHeight === 0
431
465
  ? []
432
- : [{
466
+ : [
467
+ {
433
468
  height: suggestionHeight,
434
469
  component: new Panel(this.suggestionList, {
435
470
  title: " Commands ",
436
471
  borderStyle: this.theme.border,
437
472
  titleStyle: this.theme.accent,
438
473
  }),
439
- }]),
474
+ },
475
+ ]),
440
476
  {
441
477
  height: 4,
442
478
  component: this.editorRegion,
@@ -454,14 +490,16 @@ export class MaybeCodePrototypeView {
454
490
  this.transcript.scrollBy(stroke.key === "wheelup" ? -3 : 3);
455
491
  return true;
456
492
  }
457
- if (this.focus.focusedId === "editor" && this.editor.hasSelection &&
458
- stroke.ctrl && stroke.key === "c" && this.editor.handleKey(stroke)) {
493
+ if (this.focus.focusedId === "editor" &&
494
+ this.editor.hasSelection &&
495
+ stroke.ctrl &&
496
+ stroke.key === "c" &&
497
+ this.editor.handleKey(stroke)) {
459
498
  this.keymap.reset();
460
499
  this.clearShortcutHint();
461
500
  return true;
462
501
  }
463
- const shortcut = this.keymap.resolve(stroke, this.transcriptView.hasSelection
464
- ? ["global", "transcript.selection"] : ["global"]);
502
+ const shortcut = this.keymap.resolve(stroke, this.transcriptView.hasSelection ? ["global", "transcript.selection"] : ["global"]);
465
503
  if (shortcut.type === "pending") {
466
504
  this.statusBeforeShortcut ??= this.status;
467
505
  this.status = `Shortcut: ${shortcut.completions.join(" / ")}`;
@@ -476,7 +514,7 @@ export class MaybeCodePrototypeView {
476
514
  this.setStatus("Error: Clipboard is unavailable");
477
515
  }
478
516
  else {
479
- this.pendingClipboard = this.options.clipboard.writeText(text).then(() => this.setStatus("Copied"), error => this.setStatus(`Error: ${error instanceof Error ? error.message : String(error)}`));
517
+ this.pendingClipboard = this.options.clipboard.writeText(text).then(() => this.setStatus("Copied"), (error) => this.setStatus(`Error: ${error instanceof Error ? error.message : String(error)}`));
480
518
  }
481
519
  return true;
482
520
  }
@@ -520,21 +558,34 @@ export class MaybeCodePrototypeView {
520
558
  this.hideSuggestions();
521
559
  return true;
522
560
  }
523
- if (this.suggestionsVisible && isSuggestionNavigation(stroke.key) &&
524
- stroke.key !== "home" && stroke.key !== "end" && !stroke.shift && !stroke.ctrl && !stroke.alt) {
561
+ if (this.suggestionsVisible &&
562
+ isSuggestionNavigation(stroke.key) &&
563
+ stroke.key !== "home" &&
564
+ stroke.key !== "end" &&
565
+ !stroke.shift &&
566
+ !stroke.ctrl &&
567
+ !stroke.alt) {
525
568
  return this.suggestionList.handleKey(stroke);
526
569
  }
527
570
  if (stroke.key === "tab" && !stroke.shift) {
528
571
  this.completeSuggestion(false);
529
572
  return true;
530
573
  }
531
- if (stroke.key === "enter" && this.suggestionsVisible && !stroke.shift && !stroke.ctrl && !stroke.alt && !stroke.meta) {
574
+ if (stroke.key === "enter" &&
575
+ this.suggestionsVisible &&
576
+ !stroke.shift &&
577
+ !stroke.ctrl &&
578
+ !stroke.alt &&
579
+ !stroke.meta) {
532
580
  this.completeSuggestion(true);
533
581
  return true;
534
582
  }
535
583
  }
536
- const transcriptInteraction = stroke.key === "j" || stroke.key === "k" ||
537
- stroke.key === "enter" || stroke.key === "space" || stroke.text === " ";
584
+ const transcriptInteraction = stroke.key === "j" ||
585
+ stroke.key === "k" ||
586
+ stroke.key === "enter" ||
587
+ stroke.key === "space" ||
588
+ stroke.text === " ";
538
589
  const togglesSelectedTool = this.focus.focusedId === "transcript" &&
539
590
  (stroke.key === "enter" || stroke.key === "space" || stroke.text === " ");
540
591
  if (togglesSelectedTool)
@@ -558,7 +609,9 @@ export class MaybeCodePrototypeView {
558
609
  this.hideSuggestions();
559
610
  this.setStatus("Running");
560
611
  const epoch = this.submissionEpoch;
561
- const submit = () => this.disposed || epoch !== this.submissionEpoch ? undefined : this.resolveSubmission(value, completeCommand, epoch);
612
+ const submit = () => this.disposed || epoch !== this.submissionEpoch
613
+ ? undefined
614
+ : this.resolveSubmission(value, completeCommand, epoch);
562
615
  const previous = this.submissionTail;
563
616
  const pending = (previous ? previous.then(submit) : Promise.resolve(submit()))
564
617
  .then((status) => {
@@ -570,7 +623,8 @@ export class MaybeCodePrototypeView {
570
623
  if (this.editor.value === "")
571
624
  this.editor.setValue(value);
572
625
  this.setStatus(`Error: ${error instanceof Error ? error.message : String(error)}`);
573
- }).finally(() => {
626
+ })
627
+ .finally(() => {
574
628
  if (this.submissionTail === pending)
575
629
  this.submissionTail = undefined;
576
630
  });
@@ -614,9 +668,7 @@ export class MaybeCodePrototypeView {
614
668
  this.suggestionList.setItems(suggestions.map((suggestion) => ({
615
669
  value: suggestion,
616
670
  label: suggestion.label,
617
- ...(suggestion.description === undefined
618
- ? {}
619
- : { description: suggestion.description }),
671
+ ...(suggestion.description === undefined ? {} : { description: suggestion.description }),
620
672
  })));
621
673
  this.suggestionsVisible = suggestions.length > 0;
622
674
  this.options.onInvalidate?.();
@@ -656,8 +708,13 @@ export class MaybeCodePrototypeView {
656
708
  const question = this.mcpQuestions[0];
657
709
  if (question !== undefined) {
658
710
  this.dialog = new Dialog(this.baseView, new McpInputPrompt(question.prompt, question.finish, this.editorOptions(), this.options.keymap), {
659
- open: true, title: "MCP user interaction — untrusted server", width: 92, height: 24,
660
- dismissOnEscape: false, borderStyle: this.theme.warning, titleStyle: this.theme.warning,
711
+ open: true,
712
+ title: "MCP user interaction — untrusted server",
713
+ width: 92,
714
+ height: 24,
715
+ dismissOnEscape: false,
716
+ borderStyle: this.theme.warning,
717
+ titleStyle: this.theme.warning,
661
718
  });
662
719
  this.dialogKind = "mcp";
663
720
  this.synchronizeDialog();
@@ -727,11 +784,10 @@ class ModelPrompt {
727
784
  const currentIndex = models.findIndex((model) => model.name === currentProfile);
728
785
  this.list = new SelectList(models.map((model) => ({
729
786
  value: model,
730
- label: `${model.name === currentProfile ? "* " : ""}${model.name}` +
731
- `${model.isDefault ? " [default]" : ""}`,
787
+ label: `${model.name === currentProfile ? "* " : ""}${model.name}` + `${model.isDefault ? " [default]" : ""}`,
732
788
  description: `${model.provider}/${model.model} · ${model.adapter}`,
733
789
  })), {
734
- onSelect: item => this.complete({ type: "switch", profile: item.value.name }),
790
+ onSelect: (item) => this.complete({ type: "switch", profile: item.value.name }),
735
791
  onCancel: () => this.complete(undefined),
736
792
  selectedIndex: Math.max(0, currentIndex),
737
793
  selectedStyle: theme.selected,
@@ -751,7 +807,9 @@ class ModelPrompt {
751
807
  ]);
752
808
  return this.layout.render(size);
753
809
  }
754
- handlePointer(event) { return this.layout.handlePointer(event); }
810
+ handlePointer(event) {
811
+ return this.layout.handlePointer(event);
812
+ }
755
813
  handleKey(stroke) {
756
814
  const result = this.keymap.resolve(stroke, ["select", "modelPicker"]);
757
815
  if (result.type === "pending")
@@ -777,9 +835,7 @@ class EffortPrompt {
777
835
  this.complete = complete;
778
836
  this.keymap = createMaybeCodeKeymap(keymapOptions);
779
837
  const efforts = ["default", ...state.efforts];
780
- const currentIndex = state.overridden
781
- ? efforts.indexOf(state.effectiveEffort ?? "")
782
- : 0;
838
+ const currentIndex = state.overridden ? efforts.indexOf(state.effectiveEffort ?? "") : 0;
783
839
  this.list = new SelectList(efforts.map((effort) => ({
784
840
  value: effort,
785
841
  label: `${effort === efforts[currentIndex] ? "* " : ""}${effort}`,
@@ -787,7 +843,7 @@ class EffortPrompt {
787
843
  ? `Clear override · default ${state.defaultEffort ?? "is provider-defined"}`
788
844
  : `Capability source: ${state.source}`,
789
845
  })), {
790
- onSelect: item => this.complete(item.value),
846
+ onSelect: (item) => this.complete(item.value),
791
847
  onCancel: () => this.complete(undefined),
792
848
  selectedIndex: Math.max(0, currentIndex),
793
849
  selectedStyle: theme.selected,
@@ -799,11 +855,16 @@ class EffortPrompt {
799
855
  render(size) {
800
856
  this.layout.setItems([
801
857
  { flex: 1, minHeight: 1, component: this.list },
802
- { height: 1, component: new Text(`${promptShortcut(this.keymap, "list.accept", "select")} select · ${promptShortcut(this.keymap, "list.cancel", "select")} close`) },
858
+ {
859
+ height: 1,
860
+ component: new Text(`${promptShortcut(this.keymap, "list.accept", "select")} select · ${promptShortcut(this.keymap, "list.cancel", "select")} close`),
861
+ },
803
862
  ]);
804
863
  return this.layout.render(size);
805
864
  }
806
- handlePointer(event) { return this.layout.handlePointer(event); }
865
+ handlePointer(event) {
866
+ return this.layout.handlePointer(event);
867
+ }
807
868
  handleKey(stroke) {
808
869
  const result = this.keymap.resolve(stroke, ["select"]);
809
870
  return result.type === "action" ? this.list.performAction(result.action) : result.type === "pending";
@@ -825,13 +886,21 @@ class ApprovalPrompt {
825
886
  { value: "allow", label: "Allow once", description: promptShortcut(this.keymap, "approval.allow", "approval") },
826
887
  ...(request.grantKey === undefined
827
888
  ? []
828
- : [{
889
+ : [
890
+ {
829
891
  value: "allow-session",
830
892
  label: "Allow matching calls for this session",
831
893
  description: promptShortcut(this.keymap, "approval.allowSession", "approval"),
832
- }]),
833
- { value: "deny", label: "Deny", description: `${promptShortcut(this.keymap, "approval.deny", "approval")} / ${promptShortcut(this.keymap, "list.cancel", "select")}` },
834
- ...(request.persistent ? [{ value: "allow-persistent", label: "保存允许规则", description: request.persistent.description }] : []),
894
+ },
895
+ ]),
896
+ {
897
+ value: "deny",
898
+ label: "Deny",
899
+ description: `${promptShortcut(this.keymap, "approval.deny", "approval")} / ${promptShortcut(this.keymap, "list.cancel", "select")}`,
900
+ },
901
+ ...(request.persistent
902
+ ? [{ value: "allow-persistent", label: "保存允许规则", description: request.persistent.description }]
903
+ : []),
835
904
  ], {
836
905
  onSelect: (item) => this.decide(item.value),
837
906
  onCancel: () => this.decide("deny"),
@@ -856,7 +925,9 @@ class ApprovalPrompt {
856
925
  ]);
857
926
  return this.layout.render(size);
858
927
  }
859
- handlePointer(event) { return this.layout.handlePointer(event); }
928
+ handlePointer(event) {
929
+ return this.layout.handlePointer(event);
930
+ }
860
931
  handleKey(stroke) {
861
932
  const result = this.keymap.resolve(stroke, ["select", "approval"]);
862
933
  if (result.type === "pending")
@@ -891,8 +962,8 @@ class SessionPrompt {
891
962
  keymap;
892
963
  layout = new Column([], { gap: 1 });
893
964
  listRegion = {
894
- render: size => this.list.render(size),
895
- handlePointer: event => (this.mode === "browse" || this.mode === "search") && this.list.handlePointer(event),
965
+ render: (size) => this.list.render(size),
966
+ handlePointer: (event) => (this.mode === "browse" || this.mode === "search") && this.list.handlePointer(event),
896
967
  };
897
968
  constructor(sessions, currentSessionId, theme, complete, editorOptions, keymapOptions = {}) {
898
969
  this.sessions = sessions;
@@ -940,8 +1011,12 @@ class SessionPrompt {
940
1011
  ]);
941
1012
  return this.layout.render(size);
942
1013
  }
943
- handlePointer(event) { return this.layout.handlePointer(event); }
944
- dispose() { this.input.dispose(); }
1014
+ handlePointer(event) {
1015
+ return this.layout.handlePointer(event);
1016
+ }
1017
+ dispose() {
1018
+ this.input.dispose();
1019
+ }
945
1020
  handleKey(stroke) {
946
1021
  const contexts = this.mode === "browse"
947
1022
  ? ["select", "sessionPicker"]
@@ -969,14 +1044,19 @@ class SessionPrompt {
969
1044
  this.status = "Type to filter by id, title, or preview";
970
1045
  this.input.setValue("");
971
1046
  return true;
972
- case "search.finish": return this.resumeSelected();
973
- case "session.rename.start": return this.beginRename();
1047
+ case "search.finish":
1048
+ return this.resumeSelected();
1049
+ case "session.rename.start":
1050
+ return this.beginRename();
974
1051
  case "session.rename.accept":
975
1052
  this.input.performAction("editor.submit");
976
1053
  return true;
977
- case "session.delete.request": return this.beginDelete();
978
- case "session.delete.cancel": return this.setMode("browse");
979
- case "session.delete.accept": return this.deleteSelected();
1054
+ case "session.delete.request":
1055
+ return this.beginDelete();
1056
+ case "session.delete.cancel":
1057
+ return this.setMode("browse");
1058
+ case "session.delete.accept":
1059
+ return this.deleteSelected();
980
1060
  case "text.clear":
981
1061
  this.input.setValue("");
982
1062
  return true;
@@ -1085,8 +1165,7 @@ class HeaderView {
1085
1165
  const title = `${styleText("◆", this.theme.accent)} ` +
1086
1166
  `${styleText("MaybeCode", this.theme.accent)} ` +
1087
1167
  styleText(sanitizeTerminalText(this.model), this.theme.muted);
1088
- const workspace = `${styleText("workspace", this.theme.dim)} ` +
1089
- styleText(sanitizeTerminalText(this.workspace), this.theme.muted);
1168
+ const workspace = `${styleText("workspace", this.theme.dim)} ` + styleText(sanitizeTerminalText(this.workspace), this.theme.muted);
1090
1169
  const divider = styleText("─".repeat(size.width), this.theme.border);
1091
1170
  return new Text(`${title}\n${workspace}\n${divider}`, { wrap: false }).render(size);
1092
1171
  }
@@ -1120,7 +1199,8 @@ class FooterView {
1120
1199
  : /running|cancell/iu.test(this.status)
1121
1200
  ? this.theme.warning
1122
1201
  : this.theme.success;
1123
- const value = (this.gitLabel ? `${styleText(this.gitLabel, this.theme.accent)} ` : "") + (this.yolo ? `${styleText("YOLO · Auto-approve", this.theme.warning)} ` : "") +
1202
+ const value = (this.gitLabel ? `${styleText(this.gitLabel, this.theme.accent)} ` : "") +
1203
+ (this.yolo ? `${styleText("YOLO · Auto-approve", this.theme.warning)} ` : "") +
1124
1204
  `${styleText("●", statusStyle)} ${styleText(this.status, statusStyle)} ` +
1125
1205
  `${styleText(this.focus ?? "none", this.theme.muted)} ` +
1126
1206
  `${styleText(this.replyHint, this.theme.dim)} reply ` +
@@ -1149,8 +1229,7 @@ function truncate(value, maximum) {
1149
1229
  return value.length <= maximum ? value : `${value.slice(0, maximum - 1)}…`;
1150
1230
  }
1151
1231
  function isSuggestionNavigation(key) {
1152
- return key === "up" || key === "down" || key === "pageup" ||
1153
- key === "pagedown" || key === "home" || key === "end";
1232
+ return key === "up" || key === "down" || key === "pageup" || key === "pagedown" || key === "home" || key === "end";
1154
1233
  }
1155
1234
  function commonPrefix(input, values) {
1156
1235
  const candidates = values.filter((value) => value.startsWith(input));
@@ -1188,12 +1267,20 @@ class McpInputPrompt {
1188
1267
  this.layout.setItems([
1189
1268
  { flex: 1, minHeight: 1, component: this.body },
1190
1269
  { height: 4, component: this.editor },
1191
- { height: 1, component: new Text(`${promptShortcut(this.keymap, "request.pageUp", "mcpInput")}/${promptShortcut(this.keymap, "request.pageDown", "mcpInput")} review request | Enter continue | ${promptShortcut(this.keymap, "request.cancel", "mcpInput")} cancel`) },
1270
+ {
1271
+ height: 1,
1272
+ component: new Text(`${promptShortcut(this.keymap, "request.pageUp", "mcpInput")}/${promptShortcut(this.keymap, "request.pageDown", "mcpInput")} review request | Enter continue | ${promptShortcut(this.keymap, "request.cancel", "mcpInput")} cancel`),
1273
+ },
1192
1274
  ]);
1193
1275
  return this.layout.render(size);
1194
1276
  }
1195
- handlePointer(event) { return this.layout.handlePointer(event); }
1196
- dispose() { this.editor.dispose(); this.body.dispose(); }
1277
+ handlePointer(event) {
1278
+ return this.layout.handlePointer(event);
1279
+ }
1280
+ dispose() {
1281
+ this.editor.dispose();
1282
+ this.body.dispose();
1283
+ }
1197
1284
  handleKey(stroke) {
1198
1285
  const result = this.keymap.resolve(stroke, ["mcpInput"]);
1199
1286
  if (result.type === "pending")
@@ -1223,4 +1310,4 @@ class McpInputPrompt {
1223
1310
  function promptShortcut(keymap, action, context) {
1224
1311
  return keymap.keysForAction(action, context).join(" / ");
1225
1312
  }
1226
- //# sourceMappingURL=prototype-view.js.map
1313
+ //# sourceMappingURL=terminal-view.js.map