wave-code 1.0.10 → 1.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 (242) hide show
  1. package/bin/wave-code.js +8 -2
  2. package/dist/bundle/wave.mjs +3207 -0
  3. package/package.json +24 -25
  4. package/src/commands/update.ts +2 -7
  5. package/src/components/App.tsx +3 -7
  6. package/src/components/BtwDisplay.tsx +10 -1
  7. package/src/components/ChatInterface.tsx +21 -52
  8. package/src/components/ConfirmationDetails.tsx +144 -37
  9. package/src/components/DiffDisplay.tsx +335 -301
  10. package/src/components/InputBox.tsx +3 -1
  11. package/src/components/LoadingIndicator.tsx +16 -2
  12. package/src/components/MessageBlockItem.tsx +2 -4
  13. package/src/components/MessageList.tsx +75 -14
  14. package/src/components/ReasoningDisplay.tsx +2 -4
  15. package/src/components/SessionSelector.tsx +82 -11
  16. package/src/components/StatusCommand.tsx +2 -9
  17. package/src/components/ToolDisplay.tsx +2 -4
  18. package/src/contexts/useChat.tsx +156 -335
  19. package/src/daemon/commands.ts +57 -27
  20. package/src/daemon/jsonRpcClient.ts +1 -1
  21. package/src/daemon/socketClient.ts +2 -2
  22. package/src/hooks/useInputManager.ts +1 -1
  23. package/src/index.ts +57 -10
  24. package/src/managers/inputReducer.ts +186 -104
  25. package/src/print-cli.ts +21 -17
  26. package/src/reducers/selectorReducer.ts +10 -0
  27. package/src/session-selector-cli.tsx +269 -28
  28. package/src/stdio/agentBridge.ts +22 -21
  29. package/src/stdio/daemonServer.ts +3 -1
  30. package/src/utils/clipboard.ts +21 -0
  31. package/src/utils/highlightUtils.ts +46 -1
  32. package/src/utils/readPackageJson.ts +29 -0
  33. package/src/utils/streamingText.ts +11 -0
  34. package/src/utils/worktree.ts +191 -43
  35. package/dist/cli.d.ts +0 -6
  36. package/dist/cli.js +0 -53
  37. package/dist/commands/plugin/disable.d.ts +0 -5
  38. package/dist/commands/plugin/disable.js +0 -15
  39. package/dist/commands/plugin/enable.d.ts +0 -5
  40. package/dist/commands/plugin/enable.js +0 -15
  41. package/dist/commands/plugin/install.d.ts +0 -5
  42. package/dist/commands/plugin/install.js +0 -21
  43. package/dist/commands/plugin/list.d.ts +0 -1
  44. package/dist/commands/plugin/list.js +0 -31
  45. package/dist/commands/plugin/marketplace.d.ts +0 -10
  46. package/dist/commands/plugin/marketplace.js +0 -90
  47. package/dist/commands/plugin/uninstall.d.ts +0 -3
  48. package/dist/commands/plugin/uninstall.js +0 -16
  49. package/dist/commands/plugin/update.d.ts +0 -3
  50. package/dist/commands/plugin/update.js +0 -15
  51. package/dist/commands/update.d.ts +0 -1
  52. package/dist/commands/update.js +0 -97
  53. package/dist/components/AgentsManager.d.ts +0 -7
  54. package/dist/components/AgentsManager.js +0 -109
  55. package/dist/components/App.d.ts +0 -9
  56. package/dist/components/App.js +0 -76
  57. package/dist/components/BackgroundTaskManager.d.ts +0 -5
  58. package/dist/components/BackgroundTaskManager.js +0 -99
  59. package/dist/components/BangDisplay.d.ts +0 -8
  60. package/dist/components/BangDisplay.js +0 -17
  61. package/dist/components/BtwDisplay.d.ts +0 -7
  62. package/dist/components/BtwDisplay.js +0 -19
  63. package/dist/components/ChatInterface.d.ts +0 -2
  64. package/dist/components/ChatInterface.js +0 -61
  65. package/dist/components/CommandSelector.d.ts +0 -10
  66. package/dist/components/CommandSelector.js +0 -66
  67. package/dist/components/CompactDisplay.d.ts +0 -8
  68. package/dist/components/CompactDisplay.js +0 -13
  69. package/dist/components/ConfirmationDetails.d.ts +0 -9
  70. package/dist/components/ConfirmationDetails.js +0 -45
  71. package/dist/components/ConfirmationSelector.d.ts +0 -13
  72. package/dist/components/ConfirmationSelector.js +0 -127
  73. package/dist/components/DiffDisplay.d.ts +0 -8
  74. package/dist/components/DiffDisplay.js +0 -201
  75. package/dist/components/DiscoverView.d.ts +0 -2
  76. package/dist/components/DiscoverView.js +0 -37
  77. package/dist/components/FileSelector.d.ts +0 -11
  78. package/dist/components/FileSelector.js +0 -50
  79. package/dist/components/HelpView.d.ts +0 -7
  80. package/dist/components/HelpView.js +0 -74
  81. package/dist/components/HistorySearch.d.ts +0 -8
  82. package/dist/components/HistorySearch.js +0 -66
  83. package/dist/components/InputBox.d.ts +0 -24
  84. package/dist/components/InputBox.js +0 -149
  85. package/dist/components/InstalledView.d.ts +0 -2
  86. package/dist/components/InstalledView.js +0 -45
  87. package/dist/components/LoadingIndicator.d.ts +0 -10
  88. package/dist/components/LoadingIndicator.js +0 -6
  89. package/dist/components/LoginCommand.d.ts +0 -5
  90. package/dist/components/LoginCommand.js +0 -153
  91. package/dist/components/Markdown.d.ts +0 -5
  92. package/dist/components/Markdown.js +0 -127
  93. package/dist/components/MarketplaceAddForm.d.ts +0 -2
  94. package/dist/components/MarketplaceAddForm.js +0 -55
  95. package/dist/components/MarketplaceDetail.d.ts +0 -2
  96. package/dist/components/MarketplaceDetail.js +0 -74
  97. package/dist/components/MarketplaceList.d.ts +0 -8
  98. package/dist/components/MarketplaceList.js +0 -17
  99. package/dist/components/MarketplaceView.d.ts +0 -2
  100. package/dist/components/MarketplaceView.js +0 -41
  101. package/dist/components/McpManager.d.ts +0 -9
  102. package/dist/components/McpManager.js +0 -88
  103. package/dist/components/MessageBlockItem.d.ts +0 -8
  104. package/dist/components/MessageBlockItem.js +0 -15
  105. package/dist/components/MessageList.d.ts +0 -10
  106. package/dist/components/MessageList.js +0 -80
  107. package/dist/components/ModelSelector.d.ts +0 -8
  108. package/dist/components/ModelSelector.js +0 -45
  109. package/dist/components/Notifications.d.ts +0 -7
  110. package/dist/components/Notifications.js +0 -9
  111. package/dist/components/PlanDisplay.d.ts +0 -7
  112. package/dist/components/PlanDisplay.js +0 -6
  113. package/dist/components/PluginDetail.d.ts +0 -2
  114. package/dist/components/PluginDetail.js +0 -87
  115. package/dist/components/PluginList.d.ts +0 -13
  116. package/dist/components/PluginList.js +0 -15
  117. package/dist/components/PluginManagerShell.d.ts +0 -6
  118. package/dist/components/PluginManagerShell.js +0 -92
  119. package/dist/components/PluginManagerTypes.d.ts +0 -35
  120. package/dist/components/PluginManagerTypes.js +0 -1
  121. package/dist/components/QueuedMessageList.d.ts +0 -2
  122. package/dist/components/QueuedMessageList.js +0 -18
  123. package/dist/components/ReasoningDisplay.d.ts +0 -8
  124. package/dist/components/ReasoningDisplay.js +0 -13
  125. package/dist/components/RewindCommand.d.ts +0 -12
  126. package/dist/components/RewindCommand.js +0 -78
  127. package/dist/components/SessionSelector.d.ts +0 -12
  128. package/dist/components/SessionSelector.js +0 -47
  129. package/dist/components/StatusCommand.d.ts +0 -5
  130. package/dist/components/StatusCommand.js +0 -28
  131. package/dist/components/StatusLine.d.ts +0 -6
  132. package/dist/components/StatusLine.js +0 -9
  133. package/dist/components/TaskList.d.ts +0 -5
  134. package/dist/components/TaskList.js +0 -197
  135. package/dist/components/TaskNotificationMessage.d.ts +0 -5
  136. package/dist/components/TaskNotificationMessage.js +0 -12
  137. package/dist/components/ToolDisplay.d.ts +0 -9
  138. package/dist/components/ToolDisplay.js +0 -55
  139. package/dist/components/WorkflowManager.d.ts +0 -5
  140. package/dist/components/WorkflowManager.js +0 -102
  141. package/dist/components/WorktreeExitPrompt.d.ts +0 -12
  142. package/dist/components/WorktreeExitPrompt.js +0 -35
  143. package/dist/constants/commands.d.ts +0 -2
  144. package/dist/constants/commands.js +0 -92
  145. package/dist/contexts/PluginManagerContext.d.ts +0 -3
  146. package/dist/contexts/PluginManagerContext.js +0 -9
  147. package/dist/contexts/useAppConfig.d.ts +0 -10
  148. package/dist/contexts/useAppConfig.js +0 -13
  149. package/dist/contexts/useChat.d.ts +0 -101
  150. package/dist/contexts/useChat.js +0 -993
  151. package/dist/contracts/status.d.ts +0 -7
  152. package/dist/contracts/status.js +0 -1
  153. package/dist/daemon/commands.d.ts +0 -49
  154. package/dist/daemon/commands.js +0 -341
  155. package/dist/daemon/jsonRpcClient.d.ts +0 -38
  156. package/dist/daemon/jsonRpcClient.js +0 -129
  157. package/dist/daemon/socketClient.d.ts +0 -13
  158. package/dist/daemon/socketClient.js +0 -26
  159. package/dist/daemon-cli.d.ts +0 -10
  160. package/dist/daemon-cli.js +0 -15
  161. package/dist/hooks/useInputManager.d.ts +0 -75
  162. package/dist/hooks/useInputManager.js +0 -583
  163. package/dist/hooks/usePluginManager.d.ts +0 -4
  164. package/dist/hooks/usePluginManager.js +0 -265
  165. package/dist/hooks/useTasks.d.ts +0 -1
  166. package/dist/hooks/useTasks.js +0 -5
  167. package/dist/index.d.ts +0 -4
  168. package/dist/index.js +0 -447
  169. package/dist/managers/inputHandlers.d.ts +0 -30
  170. package/dist/managers/inputHandlers.js +0 -625
  171. package/dist/managers/inputReducer.d.ts +0 -271
  172. package/dist/managers/inputReducer.js +0 -1121
  173. package/dist/plugin-manager-cli.d.ts +0 -5
  174. package/dist/plugin-manager-cli.js +0 -12
  175. package/dist/print-cli.d.ts +0 -10
  176. package/dist/print-cli.js +0 -209
  177. package/dist/reducers/agentsManagerReducer.d.ts +0 -26
  178. package/dist/reducers/agentsManagerReducer.js +0 -54
  179. package/dist/reducers/backgroundTaskManagerReducer.d.ts +0 -62
  180. package/dist/reducers/backgroundTaskManagerReducer.js +0 -106
  181. package/dist/reducers/confirmationReducer.d.ts +0 -37
  182. package/dist/reducers/confirmationReducer.js +0 -193
  183. package/dist/reducers/helpSelectorReducer.d.ts +0 -25
  184. package/dist/reducers/helpSelectorReducer.js +0 -52
  185. package/dist/reducers/marketplaceAddFormReducer.d.ts +0 -24
  186. package/dist/reducers/marketplaceAddFormReducer.js +0 -58
  187. package/dist/reducers/mcpManagerReducer.d.ts +0 -37
  188. package/dist/reducers/mcpManagerReducer.js +0 -74
  189. package/dist/reducers/pluginDetailReducer.d.ts +0 -32
  190. package/dist/reducers/pluginDetailReducer.js +0 -70
  191. package/dist/reducers/questionReducer.d.ts +0 -82
  192. package/dist/reducers/questionReducer.js +0 -375
  193. package/dist/reducers/rewindSelectorReducer.d.ts +0 -21
  194. package/dist/reducers/rewindSelectorReducer.js +0 -37
  195. package/dist/reducers/selectorReducer.d.ts +0 -23
  196. package/dist/reducers/selectorReducer.js +0 -42
  197. package/dist/reducers/workflowManagerReducer.d.ts +0 -40
  198. package/dist/reducers/workflowManagerReducer.js +0 -100
  199. package/dist/session-selector-cli.d.ts +0 -3
  200. package/dist/session-selector-cli.js +0 -25
  201. package/dist/stdio/agentBridge.d.ts +0 -139
  202. package/dist/stdio/agentBridge.js +0 -999
  203. package/dist/stdio/daemonServer.d.ts +0 -67
  204. package/dist/stdio/daemonServer.js +0 -191
  205. package/dist/stdio/index.d.ts +0 -5
  206. package/dist/stdio/index.js +0 -5
  207. package/dist/stdio/jsonRpcConnection.d.ts +0 -39
  208. package/dist/stdio/jsonRpcConnection.js +0 -135
  209. package/dist/stdio/protocol.d.ts +0 -41
  210. package/dist/stdio/protocol.js +0 -26
  211. package/dist/stdio/stdioServer.d.ts +0 -36
  212. package/dist/stdio/stdioServer.js +0 -51
  213. package/dist/stdio-cli.d.ts +0 -8
  214. package/dist/stdio-cli.js +0 -15
  215. package/dist/types.d.ts +0 -20
  216. package/dist/types.js +0 -1
  217. package/dist/utils/bracketedPaste.d.ts +0 -39
  218. package/dist/utils/bracketedPaste.js +0 -122
  219. package/dist/utils/clipboard.d.ts +0 -21
  220. package/dist/utils/clipboard.js +0 -347
  221. package/dist/utils/constants.d.ts +0 -16
  222. package/dist/utils/constants.js +0 -18
  223. package/dist/utils/highlightUtils.d.ts +0 -1
  224. package/dist/utils/highlightUtils.js +0 -93
  225. package/dist/utils/inputUtils.d.ts +0 -17
  226. package/dist/utils/inputUtils.js +0 -67
  227. package/dist/utils/logger.d.ts +0 -71
  228. package/dist/utils/logger.js +0 -259
  229. package/dist/utils/markdownTable.d.ts +0 -34
  230. package/dist/utils/markdownTable.js +0 -302
  231. package/dist/utils/rewindCheckpoints.d.ts +0 -8
  232. package/dist/utils/rewindCheckpoints.js +0 -17
  233. package/dist/utils/throttle.d.ts +0 -14
  234. package/dist/utils/throttle.js +0 -55
  235. package/dist/utils/toolParameterTransforms.d.ts +0 -18
  236. package/dist/utils/toolParameterTransforms.js +0 -73
  237. package/dist/utils/usageSummary.d.ts +0 -28
  238. package/dist/utils/usageSummary.js +0 -121
  239. package/dist/utils/version.d.ts +0 -1
  240. package/dist/utils/version.js +0 -4
  241. package/dist/utils/worktree.d.ts +0 -35
  242. package/dist/utils/worktree.js +0 -219
@@ -1,375 +0,0 @@
1
- function buildAnswerFromSavedState(q, s) {
2
- const opts = [...q.options, { label: "Other" }];
3
- let a = "";
4
- if (q.multiSelect) {
5
- const selectedLabels = Array.from(s.selectedOptionIndices)
6
- .filter((i) => i < q.options.length)
7
- .map((i) => q.options[i].label);
8
- const isOtherChecked = s.selectedOptionIndices.has(opts.length - 1);
9
- if (isOtherChecked && s.otherText.trim()) {
10
- selectedLabels.push(s.otherText.trim());
11
- }
12
- a = selectedLabels.join(", ");
13
- }
14
- else {
15
- if (s.selectedOptionIndex === opts.length - 1) {
16
- a = s.otherText.trim();
17
- }
18
- else {
19
- a = opts[s.selectedOptionIndex].label;
20
- }
21
- }
22
- return a;
23
- }
24
- export function questionReducer(state, action) {
25
- switch (action.type) {
26
- case "SELECT_OPTION":
27
- return { ...state, selectedOptionIndex: action.index };
28
- case "MOVE_OPTION_UP":
29
- return {
30
- ...state,
31
- selectedOptionIndex: Math.max(0, state.selectedOptionIndex - 1),
32
- };
33
- case "MOVE_OPTION_DOWN":
34
- return {
35
- ...state,
36
- selectedOptionIndex: Math.min(action.maxIndex, state.selectedOptionIndex + 1),
37
- };
38
- case "TOGGLE_MULTI_SELECT": {
39
- const nextIndices = new Set(state.selectedOptionIndices);
40
- if (nextIndices.has(state.selectedOptionIndex))
41
- nextIndices.delete(state.selectedOptionIndex);
42
- else
43
- nextIndices.add(state.selectedOptionIndex);
44
- return { ...state, selectedOptionIndices: nextIndices };
45
- }
46
- case "CYCLE_QUESTION": {
47
- const direction = action.shift ? -1 : 1;
48
- let nextIndex = state.currentQuestionIndex + direction;
49
- if (nextIndex < 0)
50
- nextIndex = action.questionCount - 1;
51
- if (nextIndex >= action.questionCount)
52
- nextIndex = 0;
53
- if (nextIndex === state.currentQuestionIndex)
54
- return state;
55
- const savedStates = {
56
- ...state.savedStates,
57
- [state.currentQuestionIndex]: {
58
- selectedOptionIndex: state.selectedOptionIndex,
59
- selectedOptionIndices: state.selectedOptionIndices,
60
- otherText: state.otherText,
61
- otherCursorPosition: state.otherCursorPosition,
62
- },
63
- };
64
- const nextState = savedStates[nextIndex] || {
65
- selectedOptionIndex: 0,
66
- selectedOptionIndices: new Set(),
67
- otherText: "",
68
- otherCursorPosition: 0,
69
- };
70
- return {
71
- ...state,
72
- currentQuestionIndex: nextIndex,
73
- ...nextState,
74
- savedStates,
75
- };
76
- }
77
- case "INSERT_OTHER": {
78
- if (state.selectedOptionIndex !== action.optionsLength - 1)
79
- return state;
80
- const sanitized = action.text.replace(/\r\n?|\n/g, " ");
81
- const newText = state.otherText.slice(0, state.otherCursorPosition) +
82
- sanitized +
83
- state.otherText.slice(state.otherCursorPosition);
84
- return {
85
- ...state,
86
- otherText: newText,
87
- otherCursorPosition: state.otherCursorPosition + sanitized.length,
88
- };
89
- }
90
- case "DELETE_OTHER":
91
- if (state.selectedOptionIndex !== action.optionsLength - 1)
92
- return state;
93
- if (state.otherCursorPosition > 0) {
94
- return {
95
- ...state,
96
- otherText: state.otherText.slice(0, state.otherCursorPosition - 1) +
97
- state.otherText.slice(state.otherCursorPosition),
98
- otherCursorPosition: state.otherCursorPosition - 1,
99
- };
100
- }
101
- return state;
102
- case "MOVE_OTHER_LEFT":
103
- if (state.selectedOptionIndex !== action.optionsLength - 1)
104
- return state;
105
- return {
106
- ...state,
107
- otherCursorPosition: Math.max(0, state.otherCursorPosition - 1),
108
- };
109
- case "MOVE_OTHER_RIGHT":
110
- if (state.selectedOptionIndex !== action.optionsLength - 1)
111
- return state;
112
- return {
113
- ...state,
114
- otherCursorPosition: Math.min(state.otherText.length, state.otherCursorPosition + 1),
115
- };
116
- case "CONFIRM_ANSWER": {
117
- const { currentQuestion: cq, options, isMultiSelect, questions } = action;
118
- const isOtherFocused = state.selectedOptionIndex === options.length - 1;
119
- let answer = "";
120
- if (isMultiSelect) {
121
- const selectedLabels = Array.from(state.selectedOptionIndices)
122
- .filter((i) => i < cq.options.length)
123
- .map((i) => cq.options[i].label);
124
- const isOtherChecked = state.selectedOptionIndices.has(options.length - 1);
125
- if (isOtherChecked && state.otherText.trim()) {
126
- selectedLabels.push(state.otherText.trim());
127
- }
128
- answer = selectedLabels.join(", ");
129
- }
130
- else {
131
- if (isOtherFocused) {
132
- answer = state.otherText.trim();
133
- }
134
- else {
135
- answer = options[state.selectedOptionIndex].label;
136
- }
137
- }
138
- if (!answer)
139
- return state;
140
- const newAnswers = {
141
- ...state.userAnswers,
142
- [cq.question]: answer,
143
- };
144
- if (state.currentQuestionIndex < questions.length - 1) {
145
- const nextIndex = state.currentQuestionIndex + 1;
146
- const savedStates = {
147
- ...state.savedStates,
148
- [state.currentQuestionIndex]: {
149
- selectedOptionIndex: state.selectedOptionIndex,
150
- selectedOptionIndices: state.selectedOptionIndices,
151
- otherText: state.otherText,
152
- otherCursorPosition: state.otherCursorPosition,
153
- },
154
- };
155
- const nextState = savedStates[nextIndex] || {
156
- selectedOptionIndex: 0,
157
- selectedOptionIndices: new Set(),
158
- otherText: "",
159
- otherCursorPosition: 0,
160
- };
161
- return {
162
- ...state,
163
- currentQuestionIndex: nextIndex,
164
- ...nextState,
165
- userAnswers: newAnswers,
166
- savedStates,
167
- };
168
- }
169
- else {
170
- const finalAnswers = { ...newAnswers };
171
- for (const [idxStr, s] of Object.entries(state.savedStates)) {
172
- const idx = parseInt(idxStr);
173
- const q = questions[idx];
174
- if (q && !finalAnswers[q.question]) {
175
- const a = buildAnswerFromSavedState(q, s);
176
- if (a)
177
- finalAnswers[q.question] = a;
178
- }
179
- }
180
- const allAnswered = questions.every((q) => finalAnswers[q.question]);
181
- if (!allAnswered)
182
- return state;
183
- return {
184
- ...state,
185
- userAnswers: finalAnswers,
186
- decision: {
187
- behavior: "allow",
188
- message: JSON.stringify(finalAnswers),
189
- },
190
- };
191
- }
192
- }
193
- case "CLEAR_DECISION":
194
- return { ...state, decision: null };
195
- case "HANDLE_KEY": {
196
- const { input, key, questions } = action;
197
- const currentQuestion = questions[state.currentQuestionIndex];
198
- if (!currentQuestion)
199
- return state;
200
- const options = [...currentQuestion.options, { label: "Other" }];
201
- const isMultiSelect = currentQuestion.multiSelect;
202
- if (key.return) {
203
- const isOtherFocused = state.selectedOptionIndex === options.length - 1;
204
- let answer = "";
205
- if (isMultiSelect) {
206
- const selectedLabels = Array.from(state.selectedOptionIndices)
207
- .filter((i) => i < currentQuestion.options.length)
208
- .map((i) => currentQuestion.options[i].label);
209
- const isOtherChecked = state.selectedOptionIndices.has(options.length - 1);
210
- if (isOtherChecked && state.otherText.trim()) {
211
- selectedLabels.push(state.otherText.trim());
212
- }
213
- answer = selectedLabels.join(", ");
214
- }
215
- else {
216
- if (isOtherFocused) {
217
- answer = state.otherText.trim();
218
- }
219
- else {
220
- answer = options[state.selectedOptionIndex].label;
221
- }
222
- }
223
- if (!answer)
224
- return state;
225
- const newAnswers = {
226
- ...state.userAnswers,
227
- [currentQuestion.question]: answer,
228
- };
229
- if (state.currentQuestionIndex < questions.length - 1) {
230
- const nextIndex = state.currentQuestionIndex + 1;
231
- const savedStates = {
232
- ...state.savedStates,
233
- [state.currentQuestionIndex]: {
234
- selectedOptionIndex: state.selectedOptionIndex,
235
- selectedOptionIndices: state.selectedOptionIndices,
236
- otherText: state.otherText,
237
- otherCursorPosition: state.otherCursorPosition,
238
- },
239
- };
240
- const nextState = savedStates[nextIndex] || {
241
- selectedOptionIndex: 0,
242
- selectedOptionIndices: new Set(),
243
- otherText: "",
244
- otherCursorPosition: 0,
245
- };
246
- return {
247
- ...state,
248
- currentQuestionIndex: nextIndex,
249
- ...nextState,
250
- userAnswers: newAnswers,
251
- savedStates,
252
- };
253
- }
254
- else {
255
- const finalAnswers = { ...newAnswers };
256
- for (const [idxStr, s] of Object.entries(state.savedStates)) {
257
- const idx = parseInt(idxStr);
258
- const q = questions[idx];
259
- if (q && !finalAnswers[q.question]) {
260
- const a = buildAnswerFromSavedState(q, s);
261
- if (a)
262
- finalAnswers[q.question] = a;
263
- }
264
- }
265
- const allAnswered = questions.every((q) => finalAnswers[q.question]);
266
- if (!allAnswered)
267
- return state;
268
- return {
269
- ...state,
270
- userAnswers: finalAnswers,
271
- decision: {
272
- behavior: "allow",
273
- message: JSON.stringify(finalAnswers),
274
- },
275
- };
276
- }
277
- }
278
- if (input === " ") {
279
- const isOtherFocused = state.selectedOptionIndex === options.length - 1;
280
- if (isMultiSelect &&
281
- (!isOtherFocused ||
282
- !state.selectedOptionIndices.has(state.selectedOptionIndex))) {
283
- const nextIndices = new Set(state.selectedOptionIndices);
284
- if (nextIndices.has(state.selectedOptionIndex))
285
- nextIndices.delete(state.selectedOptionIndex);
286
- else
287
- nextIndices.add(state.selectedOptionIndex);
288
- return { ...state, selectedOptionIndices: nextIndices };
289
- }
290
- }
291
- if (key.upArrow) {
292
- return {
293
- ...state,
294
- selectedOptionIndex: Math.max(0, state.selectedOptionIndex - 1),
295
- };
296
- }
297
- if (key.downArrow) {
298
- return {
299
- ...state,
300
- selectedOptionIndex: Math.min(options.length - 1, state.selectedOptionIndex + 1),
301
- };
302
- }
303
- if (key.tab) {
304
- const direction = key.shift ? -1 : 1;
305
- let nextIndex = state.currentQuestionIndex + direction;
306
- if (nextIndex < 0)
307
- nextIndex = questions.length - 1;
308
- if (nextIndex >= questions.length)
309
- nextIndex = 0;
310
- if (nextIndex === state.currentQuestionIndex)
311
- return state;
312
- const savedStates = {
313
- ...state.savedStates,
314
- [state.currentQuestionIndex]: {
315
- selectedOptionIndex: state.selectedOptionIndex,
316
- selectedOptionIndices: state.selectedOptionIndices,
317
- otherText: state.otherText,
318
- otherCursorPosition: state.otherCursorPosition,
319
- },
320
- };
321
- const nextState = savedStates[nextIndex] || {
322
- selectedOptionIndex: 0,
323
- selectedOptionIndices: new Set(),
324
- otherText: "",
325
- otherCursorPosition: 0,
326
- };
327
- return {
328
- ...state,
329
- currentQuestionIndex: nextIndex,
330
- ...nextState,
331
- savedStates,
332
- };
333
- }
334
- if (state.selectedOptionIndex === options.length - 1) {
335
- if (key.leftArrow) {
336
- return {
337
- ...state,
338
- otherCursorPosition: Math.max(0, state.otherCursorPosition - 1),
339
- };
340
- }
341
- if (key.rightArrow) {
342
- return {
343
- ...state,
344
- otherCursorPosition: Math.min(state.otherText.length, state.otherCursorPosition + 1),
345
- };
346
- }
347
- if (key.backspace || key.delete) {
348
- if (state.otherCursorPosition > 0) {
349
- return {
350
- ...state,
351
- otherText: state.otherText.slice(0, state.otherCursorPosition - 1) +
352
- state.otherText.slice(state.otherCursorPosition),
353
- otherCursorPosition: state.otherCursorPosition - 1,
354
- };
355
- }
356
- return state;
357
- }
358
- if (input && !key.ctrl && !key.meta) {
359
- const sanitized = input.replace(/\r\n?|\n/g, " ");
360
- const newText = state.otherText.slice(0, state.otherCursorPosition) +
361
- sanitized +
362
- state.otherText.slice(state.otherCursorPosition);
363
- return {
364
- ...state,
365
- otherText: newText,
366
- otherCursorPosition: state.otherCursorPosition + sanitized.length,
367
- };
368
- }
369
- }
370
- return state;
371
- }
372
- default:
373
- return state;
374
- }
375
- }
@@ -1,21 +0,0 @@
1
- import { Key } from "ink";
2
- export interface SelectorState {
3
- selectedIndex: number;
4
- pendingDecision: "select" | "cancel" | null;
5
- }
6
- export type SelectorAction = {
7
- type: "MOVE_UP";
8
- } | {
9
- type: "MOVE_DOWN";
10
- maxIndex: number;
11
- } | {
12
- type: "RESET_INDEX";
13
- index: number;
14
- } | {
15
- type: "HANDLE_KEY";
16
- key: Key;
17
- maxIndex: number;
18
- } | {
19
- type: "CLEAR_DECISION";
20
- };
21
- export declare function rewindSelectorReducer(state: SelectorState, action: SelectorAction): SelectorState;
@@ -1,37 +0,0 @@
1
- export function rewindSelectorReducer(state, action) {
2
- switch (action.type) {
3
- case "MOVE_UP":
4
- return { ...state, selectedIndex: Math.max(0, state.selectedIndex - 1) };
5
- case "MOVE_DOWN":
6
- return {
7
- ...state,
8
- selectedIndex: Math.min(action.maxIndex, state.selectedIndex + 1),
9
- };
10
- case "RESET_INDEX":
11
- return { ...state, selectedIndex: action.index };
12
- case "HANDLE_KEY":
13
- if (action.key.upArrow) {
14
- return {
15
- ...state,
16
- selectedIndex: Math.max(0, state.selectedIndex - 1),
17
- };
18
- }
19
- if (action.key.downArrow) {
20
- return {
21
- ...state,
22
- selectedIndex: Math.min(action.maxIndex, state.selectedIndex + 1),
23
- };
24
- }
25
- if (action.key.return) {
26
- return { ...state, pendingDecision: "select" };
27
- }
28
- if (action.key.escape) {
29
- return { ...state, pendingDecision: "cancel" };
30
- }
31
- return state;
32
- case "CLEAR_DECISION":
33
- return { ...state, pendingDecision: null };
34
- default:
35
- return state;
36
- }
37
- }
@@ -1,23 +0,0 @@
1
- import { Key } from "ink";
2
- export interface SelectorState<T = unknown> {
3
- selectedIndex: number;
4
- pendingDecision: "select" | "insert" | "cancel" | null;
5
- items: T[];
6
- }
7
- export type SelectorAction<T = unknown> = {
8
- type: "MOVE_UP";
9
- } | {
10
- type: "MOVE_DOWN";
11
- } | {
12
- type: "RESET_INDEX";
13
- } | {
14
- type: "SET_ITEMS";
15
- items: T[];
16
- } | {
17
- type: "HANDLE_KEY";
18
- key: Key;
19
- hasInsert: boolean;
20
- } | {
21
- type: "CLEAR_DECISION";
22
- };
23
- export declare function selectorReducer<T = unknown>(state: SelectorState<T>, action: SelectorAction<T>): SelectorState<T>;
@@ -1,42 +0,0 @@
1
- export function selectorReducer(state, action) {
2
- switch (action.type) {
3
- case "MOVE_UP":
4
- return { ...state, selectedIndex: Math.max(0, state.selectedIndex - 1) };
5
- case "MOVE_DOWN":
6
- return {
7
- ...state,
8
- selectedIndex: Math.min(state.items.length - 1, state.selectedIndex + 1),
9
- };
10
- case "RESET_INDEX":
11
- return { ...state, selectedIndex: 0 };
12
- case "SET_ITEMS":
13
- return { ...state, items: action.items, selectedIndex: 0 };
14
- case "HANDLE_KEY":
15
- if (action.key.upArrow) {
16
- return {
17
- ...state,
18
- selectedIndex: Math.max(0, state.selectedIndex - 1),
19
- };
20
- }
21
- if (action.key.downArrow) {
22
- return {
23
- ...state,
24
- selectedIndex: Math.min(state.items.length - 1, state.selectedIndex + 1),
25
- };
26
- }
27
- if (action.key.return) {
28
- return { ...state, pendingDecision: "select" };
29
- }
30
- if (action.key.tab && action.hasInsert) {
31
- return { ...state, pendingDecision: "insert" };
32
- }
33
- if (action.key.escape) {
34
- return { ...state, pendingDecision: "cancel" };
35
- }
36
- return state;
37
- case "CLEAR_DECISION":
38
- return { ...state, pendingDecision: null };
39
- default:
40
- return state;
41
- }
42
- }
@@ -1,40 +0,0 @@
1
- import { Key } from "ink";
2
- import type { WorkflowRun } from "wave-agent-sdk";
3
- export type PendingEffect = {
4
- type: "CANCEL";
5
- } | {
6
- type: "STOP_RUN";
7
- runId: string;
8
- };
9
- export interface WorkflowManagerState {
10
- runs: WorkflowRun[];
11
- selectedIndex: number;
12
- viewMode: "list" | "detail";
13
- detailRunId: string | null;
14
- pendingEffect: PendingEffect | null;
15
- }
16
- export type WorkflowManagerAction = {
17
- type: "SET_RUNS";
18
- runs: WorkflowRun[];
19
- } | {
20
- type: "SELECT_INDEX";
21
- index: number;
22
- } | {
23
- type: "MOVE_UP";
24
- } | {
25
- type: "MOVE_DOWN";
26
- } | {
27
- type: "SELECT_CURRENT";
28
- } | {
29
- type: "SET_VIEW_MODE";
30
- mode: "list" | "detail";
31
- } | {
32
- type: "RESET_DETAIL";
33
- } | {
34
- type: "HANDLE_KEY";
35
- input: string;
36
- key: Key;
37
- } | {
38
- type: "CLEAR_PENDING_EFFECT";
39
- };
40
- export declare function workflowManagerReducer(state: WorkflowManagerState, action: WorkflowManagerAction): WorkflowManagerState;
@@ -1,100 +0,0 @@
1
- export function workflowManagerReducer(state, action) {
2
- switch (action.type) {
3
- case "SET_RUNS":
4
- return { ...state, runs: action.runs };
5
- case "SELECT_INDEX":
6
- return { ...state, selectedIndex: action.index };
7
- case "MOVE_UP":
8
- return { ...state, selectedIndex: Math.max(0, state.selectedIndex - 1) };
9
- case "MOVE_DOWN":
10
- return {
11
- ...state,
12
- selectedIndex: Math.min(state.runs.length > 0 ? state.runs.length - 1 : 0, state.selectedIndex + 1),
13
- };
14
- case "SELECT_CURRENT":
15
- if (state.runs.length > 0 && state.selectedIndex < state.runs.length) {
16
- return {
17
- ...state,
18
- detailRunId: state.runs[state.selectedIndex].runId,
19
- viewMode: "detail",
20
- };
21
- }
22
- return state;
23
- case "SET_VIEW_MODE":
24
- return { ...state, viewMode: action.mode };
25
- case "RESET_DETAIL":
26
- return {
27
- ...state,
28
- viewMode: "list",
29
- detailRunId: null,
30
- };
31
- case "HANDLE_KEY": {
32
- const { input, key } = action;
33
- if (state.viewMode === "list") {
34
- if (key.return) {
35
- if (state.runs.length > 0 &&
36
- state.selectedIndex < state.runs.length) {
37
- return {
38
- ...state,
39
- detailRunId: state.runs[state.selectedIndex].runId,
40
- viewMode: "detail",
41
- };
42
- }
43
- return state;
44
- }
45
- if (key.escape) {
46
- return { ...state, pendingEffect: { type: "CANCEL" } };
47
- }
48
- if (key.upArrow) {
49
- return {
50
- ...state,
51
- selectedIndex: Math.max(0, state.selectedIndex - 1),
52
- };
53
- }
54
- if (key.downArrow) {
55
- return {
56
- ...state,
57
- selectedIndex: Math.min(state.runs.length > 0 ? state.runs.length - 1 : 0, state.selectedIndex + 1),
58
- };
59
- }
60
- if (input === "k") {
61
- if (state.runs.length > 0 &&
62
- state.selectedIndex < state.runs.length) {
63
- const selectedRun = state.runs[state.selectedIndex];
64
- if (selectedRun.status === "running") {
65
- return {
66
- ...state,
67
- pendingEffect: { type: "STOP_RUN", runId: selectedRun.runId },
68
- };
69
- }
70
- }
71
- return state;
72
- }
73
- }
74
- else if (state.viewMode === "detail") {
75
- if (key.escape) {
76
- return {
77
- ...state,
78
- viewMode: "list",
79
- detailRunId: null,
80
- };
81
- }
82
- if (input === "k" && state.detailRunId) {
83
- const run = state.runs.find((r) => r.runId === state.detailRunId);
84
- if (run && run.status === "running") {
85
- return {
86
- ...state,
87
- pendingEffect: { type: "STOP_RUN", runId: state.detailRunId },
88
- };
89
- }
90
- return state;
91
- }
92
- }
93
- return state;
94
- }
95
- case "CLEAR_PENDING_EFFECT":
96
- return { ...state, pendingEffect: null };
97
- default:
98
- return state;
99
- }
100
- }
@@ -1,3 +0,0 @@
1
- export declare function startSessionSelectorCli({ workdir, }?: {
2
- workdir?: string;
3
- }): Promise<string | null>;
@@ -1,25 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, Box } from "ink";
3
- import { listSessions, truncateContent } from "wave-agent-sdk";
4
- import { SessionSelector } from "./components/SessionSelector.js";
5
- export async function startSessionSelectorCli({ workdir, } = {}) {
6
- const currentWorkdir = workdir || process.cwd();
7
- const sessions = await listSessions(currentWorkdir);
8
- if (sessions.length === 0) {
9
- console.log(`No sessions found for workdir: ${currentWorkdir}`);
10
- return null;
11
- }
12
- const sessionsWithContent = sessions.map((s) => ({
13
- ...s,
14
- firstMessage: truncateContent(s.firstMessage || "No content", 80),
15
- }));
16
- return new Promise((resolve) => {
17
- const { unmount } = render(_jsx(Box, { padding: 1, children: _jsx(SessionSelector, { sessions: sessionsWithContent, onSelect: (sessionId) => {
18
- unmount();
19
- resolve(sessionId);
20
- }, onCancel: () => {
21
- unmount();
22
- resolve(null);
23
- } }) }));
24
- });
25
- }