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.
- package/bin/wave-code.js +8 -2
- package/dist/bundle/wave.mjs +3207 -0
- package/package.json +24 -25
- package/src/commands/update.ts +2 -7
- package/src/components/App.tsx +3 -7
- package/src/components/BtwDisplay.tsx +10 -1
- package/src/components/ChatInterface.tsx +21 -52
- package/src/components/ConfirmationDetails.tsx +144 -37
- package/src/components/DiffDisplay.tsx +335 -301
- package/src/components/InputBox.tsx +3 -1
- package/src/components/LoadingIndicator.tsx +16 -2
- package/src/components/MessageBlockItem.tsx +2 -4
- package/src/components/MessageList.tsx +75 -14
- package/src/components/ReasoningDisplay.tsx +2 -4
- package/src/components/SessionSelector.tsx +82 -11
- package/src/components/StatusCommand.tsx +2 -9
- package/src/components/ToolDisplay.tsx +2 -4
- package/src/contexts/useChat.tsx +156 -335
- package/src/daemon/commands.ts +57 -27
- package/src/daemon/jsonRpcClient.ts +1 -1
- package/src/daemon/socketClient.ts +2 -2
- package/src/hooks/useInputManager.ts +1 -1
- package/src/index.ts +57 -10
- package/src/managers/inputReducer.ts +186 -104
- package/src/print-cli.ts +21 -17
- package/src/reducers/selectorReducer.ts +10 -0
- package/src/session-selector-cli.tsx +269 -28
- package/src/stdio/agentBridge.ts +22 -21
- package/src/stdio/daemonServer.ts +3 -1
- package/src/utils/clipboard.ts +21 -0
- package/src/utils/highlightUtils.ts +46 -1
- package/src/utils/readPackageJson.ts +29 -0
- package/src/utils/streamingText.ts +11 -0
- package/src/utils/worktree.ts +191 -43
- package/dist/cli.d.ts +0 -6
- package/dist/cli.js +0 -53
- package/dist/commands/plugin/disable.d.ts +0 -5
- package/dist/commands/plugin/disable.js +0 -15
- package/dist/commands/plugin/enable.d.ts +0 -5
- package/dist/commands/plugin/enable.js +0 -15
- package/dist/commands/plugin/install.d.ts +0 -5
- package/dist/commands/plugin/install.js +0 -21
- package/dist/commands/plugin/list.d.ts +0 -1
- package/dist/commands/plugin/list.js +0 -31
- package/dist/commands/plugin/marketplace.d.ts +0 -10
- package/dist/commands/plugin/marketplace.js +0 -90
- package/dist/commands/plugin/uninstall.d.ts +0 -3
- package/dist/commands/plugin/uninstall.js +0 -16
- package/dist/commands/plugin/update.d.ts +0 -3
- package/dist/commands/plugin/update.js +0 -15
- package/dist/commands/update.d.ts +0 -1
- package/dist/commands/update.js +0 -97
- package/dist/components/AgentsManager.d.ts +0 -7
- package/dist/components/AgentsManager.js +0 -109
- package/dist/components/App.d.ts +0 -9
- package/dist/components/App.js +0 -76
- package/dist/components/BackgroundTaskManager.d.ts +0 -5
- package/dist/components/BackgroundTaskManager.js +0 -99
- package/dist/components/BangDisplay.d.ts +0 -8
- package/dist/components/BangDisplay.js +0 -17
- package/dist/components/BtwDisplay.d.ts +0 -7
- package/dist/components/BtwDisplay.js +0 -19
- package/dist/components/ChatInterface.d.ts +0 -2
- package/dist/components/ChatInterface.js +0 -61
- package/dist/components/CommandSelector.d.ts +0 -10
- package/dist/components/CommandSelector.js +0 -66
- package/dist/components/CompactDisplay.d.ts +0 -8
- package/dist/components/CompactDisplay.js +0 -13
- package/dist/components/ConfirmationDetails.d.ts +0 -9
- package/dist/components/ConfirmationDetails.js +0 -45
- package/dist/components/ConfirmationSelector.d.ts +0 -13
- package/dist/components/ConfirmationSelector.js +0 -127
- package/dist/components/DiffDisplay.d.ts +0 -8
- package/dist/components/DiffDisplay.js +0 -201
- package/dist/components/DiscoverView.d.ts +0 -2
- package/dist/components/DiscoverView.js +0 -37
- package/dist/components/FileSelector.d.ts +0 -11
- package/dist/components/FileSelector.js +0 -50
- package/dist/components/HelpView.d.ts +0 -7
- package/dist/components/HelpView.js +0 -74
- package/dist/components/HistorySearch.d.ts +0 -8
- package/dist/components/HistorySearch.js +0 -66
- package/dist/components/InputBox.d.ts +0 -24
- package/dist/components/InputBox.js +0 -149
- package/dist/components/InstalledView.d.ts +0 -2
- package/dist/components/InstalledView.js +0 -45
- package/dist/components/LoadingIndicator.d.ts +0 -10
- package/dist/components/LoadingIndicator.js +0 -6
- package/dist/components/LoginCommand.d.ts +0 -5
- package/dist/components/LoginCommand.js +0 -153
- package/dist/components/Markdown.d.ts +0 -5
- package/dist/components/Markdown.js +0 -127
- package/dist/components/MarketplaceAddForm.d.ts +0 -2
- package/dist/components/MarketplaceAddForm.js +0 -55
- package/dist/components/MarketplaceDetail.d.ts +0 -2
- package/dist/components/MarketplaceDetail.js +0 -74
- package/dist/components/MarketplaceList.d.ts +0 -8
- package/dist/components/MarketplaceList.js +0 -17
- package/dist/components/MarketplaceView.d.ts +0 -2
- package/dist/components/MarketplaceView.js +0 -41
- package/dist/components/McpManager.d.ts +0 -9
- package/dist/components/McpManager.js +0 -88
- package/dist/components/MessageBlockItem.d.ts +0 -8
- package/dist/components/MessageBlockItem.js +0 -15
- package/dist/components/MessageList.d.ts +0 -10
- package/dist/components/MessageList.js +0 -80
- package/dist/components/ModelSelector.d.ts +0 -8
- package/dist/components/ModelSelector.js +0 -45
- package/dist/components/Notifications.d.ts +0 -7
- package/dist/components/Notifications.js +0 -9
- package/dist/components/PlanDisplay.d.ts +0 -7
- package/dist/components/PlanDisplay.js +0 -6
- package/dist/components/PluginDetail.d.ts +0 -2
- package/dist/components/PluginDetail.js +0 -87
- package/dist/components/PluginList.d.ts +0 -13
- package/dist/components/PluginList.js +0 -15
- package/dist/components/PluginManagerShell.d.ts +0 -6
- package/dist/components/PluginManagerShell.js +0 -92
- package/dist/components/PluginManagerTypes.d.ts +0 -35
- package/dist/components/PluginManagerTypes.js +0 -1
- package/dist/components/QueuedMessageList.d.ts +0 -2
- package/dist/components/QueuedMessageList.js +0 -18
- package/dist/components/ReasoningDisplay.d.ts +0 -8
- package/dist/components/ReasoningDisplay.js +0 -13
- package/dist/components/RewindCommand.d.ts +0 -12
- package/dist/components/RewindCommand.js +0 -78
- package/dist/components/SessionSelector.d.ts +0 -12
- package/dist/components/SessionSelector.js +0 -47
- package/dist/components/StatusCommand.d.ts +0 -5
- package/dist/components/StatusCommand.js +0 -28
- package/dist/components/StatusLine.d.ts +0 -6
- package/dist/components/StatusLine.js +0 -9
- package/dist/components/TaskList.d.ts +0 -5
- package/dist/components/TaskList.js +0 -197
- package/dist/components/TaskNotificationMessage.d.ts +0 -5
- package/dist/components/TaskNotificationMessage.js +0 -12
- package/dist/components/ToolDisplay.d.ts +0 -9
- package/dist/components/ToolDisplay.js +0 -55
- package/dist/components/WorkflowManager.d.ts +0 -5
- package/dist/components/WorkflowManager.js +0 -102
- package/dist/components/WorktreeExitPrompt.d.ts +0 -12
- package/dist/components/WorktreeExitPrompt.js +0 -35
- package/dist/constants/commands.d.ts +0 -2
- package/dist/constants/commands.js +0 -92
- package/dist/contexts/PluginManagerContext.d.ts +0 -3
- package/dist/contexts/PluginManagerContext.js +0 -9
- package/dist/contexts/useAppConfig.d.ts +0 -10
- package/dist/contexts/useAppConfig.js +0 -13
- package/dist/contexts/useChat.d.ts +0 -101
- package/dist/contexts/useChat.js +0 -993
- package/dist/contracts/status.d.ts +0 -7
- package/dist/contracts/status.js +0 -1
- package/dist/daemon/commands.d.ts +0 -49
- package/dist/daemon/commands.js +0 -341
- package/dist/daemon/jsonRpcClient.d.ts +0 -38
- package/dist/daemon/jsonRpcClient.js +0 -129
- package/dist/daemon/socketClient.d.ts +0 -13
- package/dist/daemon/socketClient.js +0 -26
- package/dist/daemon-cli.d.ts +0 -10
- package/dist/daemon-cli.js +0 -15
- package/dist/hooks/useInputManager.d.ts +0 -75
- package/dist/hooks/useInputManager.js +0 -583
- package/dist/hooks/usePluginManager.d.ts +0 -4
- package/dist/hooks/usePluginManager.js +0 -265
- package/dist/hooks/useTasks.d.ts +0 -1
- package/dist/hooks/useTasks.js +0 -5
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -447
- package/dist/managers/inputHandlers.d.ts +0 -30
- package/dist/managers/inputHandlers.js +0 -625
- package/dist/managers/inputReducer.d.ts +0 -271
- package/dist/managers/inputReducer.js +0 -1121
- package/dist/plugin-manager-cli.d.ts +0 -5
- package/dist/plugin-manager-cli.js +0 -12
- package/dist/print-cli.d.ts +0 -10
- package/dist/print-cli.js +0 -209
- package/dist/reducers/agentsManagerReducer.d.ts +0 -26
- package/dist/reducers/agentsManagerReducer.js +0 -54
- package/dist/reducers/backgroundTaskManagerReducer.d.ts +0 -62
- package/dist/reducers/backgroundTaskManagerReducer.js +0 -106
- package/dist/reducers/confirmationReducer.d.ts +0 -37
- package/dist/reducers/confirmationReducer.js +0 -193
- package/dist/reducers/helpSelectorReducer.d.ts +0 -25
- package/dist/reducers/helpSelectorReducer.js +0 -52
- package/dist/reducers/marketplaceAddFormReducer.d.ts +0 -24
- package/dist/reducers/marketplaceAddFormReducer.js +0 -58
- package/dist/reducers/mcpManagerReducer.d.ts +0 -37
- package/dist/reducers/mcpManagerReducer.js +0 -74
- package/dist/reducers/pluginDetailReducer.d.ts +0 -32
- package/dist/reducers/pluginDetailReducer.js +0 -70
- package/dist/reducers/questionReducer.d.ts +0 -82
- package/dist/reducers/questionReducer.js +0 -375
- package/dist/reducers/rewindSelectorReducer.d.ts +0 -21
- package/dist/reducers/rewindSelectorReducer.js +0 -37
- package/dist/reducers/selectorReducer.d.ts +0 -23
- package/dist/reducers/selectorReducer.js +0 -42
- package/dist/reducers/workflowManagerReducer.d.ts +0 -40
- package/dist/reducers/workflowManagerReducer.js +0 -100
- package/dist/session-selector-cli.d.ts +0 -3
- package/dist/session-selector-cli.js +0 -25
- package/dist/stdio/agentBridge.d.ts +0 -139
- package/dist/stdio/agentBridge.js +0 -999
- package/dist/stdio/daemonServer.d.ts +0 -67
- package/dist/stdio/daemonServer.js +0 -191
- package/dist/stdio/index.d.ts +0 -5
- package/dist/stdio/index.js +0 -5
- package/dist/stdio/jsonRpcConnection.d.ts +0 -39
- package/dist/stdio/jsonRpcConnection.js +0 -135
- package/dist/stdio/protocol.d.ts +0 -41
- package/dist/stdio/protocol.js +0 -26
- package/dist/stdio/stdioServer.d.ts +0 -36
- package/dist/stdio/stdioServer.js +0 -51
- package/dist/stdio-cli.d.ts +0 -8
- package/dist/stdio-cli.js +0 -15
- package/dist/types.d.ts +0 -20
- package/dist/types.js +0 -1
- package/dist/utils/bracketedPaste.d.ts +0 -39
- package/dist/utils/bracketedPaste.js +0 -122
- package/dist/utils/clipboard.d.ts +0 -21
- package/dist/utils/clipboard.js +0 -347
- package/dist/utils/constants.d.ts +0 -16
- package/dist/utils/constants.js +0 -18
- package/dist/utils/highlightUtils.d.ts +0 -1
- package/dist/utils/highlightUtils.js +0 -93
- package/dist/utils/inputUtils.d.ts +0 -17
- package/dist/utils/inputUtils.js +0 -67
- package/dist/utils/logger.d.ts +0 -71
- package/dist/utils/logger.js +0 -259
- package/dist/utils/markdownTable.d.ts +0 -34
- package/dist/utils/markdownTable.js +0 -302
- package/dist/utils/rewindCheckpoints.d.ts +0 -8
- package/dist/utils/rewindCheckpoints.js +0 -17
- package/dist/utils/throttle.d.ts +0 -14
- package/dist/utils/throttle.js +0 -55
- package/dist/utils/toolParameterTransforms.d.ts +0 -18
- package/dist/utils/toolParameterTransforms.js +0 -73
- package/dist/utils/usageSummary.d.ts +0 -28
- package/dist/utils/usageSummary.js +0 -121
- package/dist/utils/version.d.ts +0 -1
- package/dist/utils/version.js +0 -4
- package/dist/utils/worktree.d.ts +0 -35
- 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,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
|
-
}
|