@minhluudev/ai-tools 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/dist/src/bin/ai-tools.js +2 -1
- package/dist/src/cli.js +94 -2
- package/dist/src/lib/ai-libs.js +66 -2
- package/dist/src/lib/mcp.js +665 -0
- package/dist/src/lib/tui-ai-libs.js +10 -4
- package/dist/src/lib/tui-entry-menu.js +7 -1
- package/dist/src/lib/tui-mcp.js +514 -0
- package/package.json +1 -1
|
@@ -26,15 +26,21 @@ function currentTabItems(state) {
|
|
|
26
26
|
return [
|
|
27
27
|
{
|
|
28
28
|
id: "rtk",
|
|
29
|
-
label: "
|
|
29
|
+
label: "rtk-ai/rtk",
|
|
30
30
|
description: "Token-saving CLI proxy with agent-specific init for Codex and Claude.",
|
|
31
31
|
kind: "library"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
id: "icm",
|
|
35
|
-
label: "
|
|
35
|
+
label: "rtk-ai/icm",
|
|
36
36
|
description: "Persistent agent memory with MCP, CLI instructions, rules, and hooks.",
|
|
37
37
|
kind: "library"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "ecc",
|
|
41
|
+
label: "affaan-m/ECC",
|
|
42
|
+
description: "Run ECC's upstream full manual installer with notes about Codex sync and Claude plugin overlap.",
|
|
43
|
+
kind: "library"
|
|
38
44
|
}
|
|
39
45
|
];
|
|
40
46
|
}
|
|
@@ -380,7 +386,7 @@ export async function runAiLibsWizard() {
|
|
|
380
386
|
review: "Review selections"
|
|
381
387
|
}[state.activeTab];
|
|
382
388
|
const stepDescription = {
|
|
383
|
-
libraries: "Choose one or
|
|
389
|
+
libraries: "Choose one or more upstream AI libraries to install.",
|
|
384
390
|
agents: "Pick which agent integrations should be configured.",
|
|
385
391
|
os: "Choose the current host OS for sanity checking before install.",
|
|
386
392
|
scope: "Choose whether setup should target global config or project-local files.",
|
|
@@ -395,7 +401,7 @@ export async function runAiLibsWizard() {
|
|
|
395
401
|
mode: state.selectedMode,
|
|
396
402
|
review: state.notice || "Ready for confirmation"
|
|
397
403
|
}[state.activeTab];
|
|
398
|
-
headerBox.setContent(renderBannerHeader("Install libs for AI", "Run upstream installers and init commands for RTK and
|
|
404
|
+
headerBox.setContent(renderBannerHeader("Install libs for AI", "Run upstream installers and init commands for RTK, ICM, and ECC.", [
|
|
399
405
|
{ label: `${state.selectedLibraries.size} libraries`, tone: "accent" },
|
|
400
406
|
{ label: `${state.selectedAgents.size} agents`, tone: "success" },
|
|
401
407
|
{ label: state.selectedOs ?? "OS pending", tone: "muted" },
|
|
@@ -16,9 +16,15 @@ const MENU_ITEMS = [
|
|
|
16
16
|
{
|
|
17
17
|
id: "install-libs",
|
|
18
18
|
label: "Install libs for AI",
|
|
19
|
-
description: "Install RTK
|
|
19
|
+
description: "Install RTK, ICM, or ECC, then run the supported setup flow for Codex and Claude.",
|
|
20
20
|
meta: "Mac + Linux"
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
id: "install-mcp",
|
|
24
|
+
label: "Install mcp",
|
|
25
|
+
description: "Add or remove Ant Design, GitLab, GitHub, and Figma MCP servers for Codex or Claude.",
|
|
26
|
+
meta: "Codex + Claude"
|
|
27
|
+
},
|
|
22
28
|
{
|
|
23
29
|
id: "cancel",
|
|
24
30
|
label: "Cancel",
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { buildMcpInstallPlan } from "./mcp.js";
|
|
2
|
+
import { canRun, createTabbedLayout, DEBOUNCE_MOVE_MS, DEBOUNCE_SELECT_MS, renderBannerHeader, renderKeycaps, renderListRow, renderStepSummary, renderTabBar, selectionArray } from "./tui-utils.js";
|
|
3
|
+
const TAB_ORDER = ["servers", "agent", "mode", "os", "review"];
|
|
4
|
+
function buildInitialState() {
|
|
5
|
+
return {
|
|
6
|
+
activeTab: "servers",
|
|
7
|
+
selectedServers: new Set(),
|
|
8
|
+
selectedAgents: new Set(),
|
|
9
|
+
selectedMode: "install",
|
|
10
|
+
selectedOs: process.platform === "darwin" ? "mac" : "linux",
|
|
11
|
+
listCursor: {
|
|
12
|
+
servers: 0,
|
|
13
|
+
agent: 0,
|
|
14
|
+
mode: 0,
|
|
15
|
+
os: 0,
|
|
16
|
+
review: 0
|
|
17
|
+
},
|
|
18
|
+
reviewAction: "confirm",
|
|
19
|
+
notice: ""
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function currentTabItems(state) {
|
|
23
|
+
if (state.activeTab === "servers") {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
id: "antd",
|
|
27
|
+
label: "Ant Design",
|
|
28
|
+
description: "Official Ant Design MCP server exposed by `@ant-design/cli`.",
|
|
29
|
+
kind: "server"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "gitlab",
|
|
33
|
+
label: "GitLab",
|
|
34
|
+
description: "GitLab.com MCP endpoint with OAuth-based authorization.",
|
|
35
|
+
kind: "server"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "github",
|
|
39
|
+
label: "GitHub",
|
|
40
|
+
description: "GitHub's hosted MCP server using PAT-based access.",
|
|
41
|
+
kind: "server"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "figma",
|
|
45
|
+
label: "Figma",
|
|
46
|
+
description: "Figma's remote MCP server for design context and write-back workflows.",
|
|
47
|
+
kind: "server"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "shadcn",
|
|
51
|
+
label: "Shadcn",
|
|
52
|
+
description: "Shadcn/ui registry MCP server for browsing, searching, and installing components.",
|
|
53
|
+
kind: "server"
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
if (state.activeTab === "agent") {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
id: "codex",
|
|
61
|
+
label: "Codex",
|
|
62
|
+
description: "Configure the selected MCP servers for OpenAI Codex.",
|
|
63
|
+
kind: "agent"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "claude",
|
|
67
|
+
label: "Claude",
|
|
68
|
+
description: "Configure the selected MCP servers for Claude Code.",
|
|
69
|
+
kind: "agent"
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
if (state.activeTab === "mode") {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
id: "install",
|
|
77
|
+
label: "Install",
|
|
78
|
+
description: "Add or register the selected MCP servers in the chosen agent.",
|
|
79
|
+
kind: "mode"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "uninstall",
|
|
83
|
+
label: "Uninstall",
|
|
84
|
+
description: "Remove the selected MCP server entries from the chosen agent.",
|
|
85
|
+
kind: "mode"
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
if (state.activeTab === "os") {
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
id: "mac",
|
|
93
|
+
label: "MacOS",
|
|
94
|
+
description: "Apple macOS (darwin). Homebrew-based paths and macOS shell profiles apply.",
|
|
95
|
+
kind: "os"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "linux",
|
|
99
|
+
label: "Linux",
|
|
100
|
+
description: "Linux distributions. Standard XDG paths and bash/zsh shell profiles apply.",
|
|
101
|
+
kind: "os"
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
id: "confirm",
|
|
108
|
+
label: state.selectedMode === "install" ? "Confirm install" : "Confirm uninstall",
|
|
109
|
+
description: "Run the planned MCP commands.",
|
|
110
|
+
kind: "review"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "back",
|
|
114
|
+
label: "Back to main menu",
|
|
115
|
+
description: "Leave this workflow and return to the main menu.",
|
|
116
|
+
kind: "review"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "cancel",
|
|
120
|
+
label: "Cancel",
|
|
121
|
+
description: "Exit without changing MCP configuration.",
|
|
122
|
+
kind: "review"
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
function isItemSelected(item, state) {
|
|
127
|
+
if (item.kind === "server") {
|
|
128
|
+
return state.selectedServers.has(item.id);
|
|
129
|
+
}
|
|
130
|
+
if (item.kind === "agent") {
|
|
131
|
+
return state.selectedAgents.has(item.id);
|
|
132
|
+
}
|
|
133
|
+
if (item.kind === "mode") {
|
|
134
|
+
return state.selectedMode === item.id;
|
|
135
|
+
}
|
|
136
|
+
if (item.kind === "os") {
|
|
137
|
+
return state.selectedOs === item.id;
|
|
138
|
+
}
|
|
139
|
+
return state.reviewAction === item.id;
|
|
140
|
+
}
|
|
141
|
+
function toggleItem(item, state) {
|
|
142
|
+
if (item.kind === "server") {
|
|
143
|
+
const server = item.id;
|
|
144
|
+
if (state.selectedServers.has(server)) {
|
|
145
|
+
state.selectedServers.delete(server);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
state.selectedServers.add(server);
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (item.kind === "agent") {
|
|
153
|
+
const agent = item.id;
|
|
154
|
+
if (state.selectedAgents.has(agent)) {
|
|
155
|
+
state.selectedAgents.delete(agent);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
state.selectedAgents.add(agent);
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (item.kind === "mode") {
|
|
163
|
+
state.selectedMode = item.id;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (item.kind === "os") {
|
|
167
|
+
state.selectedOs = item.id;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
state.reviewAction = item.id;
|
|
171
|
+
}
|
|
172
|
+
function renderTabs(state) {
|
|
173
|
+
const counts = {
|
|
174
|
+
servers: state.selectedServers.size,
|
|
175
|
+
agent: state.selectedAgents.size,
|
|
176
|
+
mode: 1,
|
|
177
|
+
os: 1,
|
|
178
|
+
review: state.reviewAction === "confirm" ? 1 : 0
|
|
179
|
+
};
|
|
180
|
+
const TAB_LABELS = {
|
|
181
|
+
servers: "Select MCP",
|
|
182
|
+
agent: "Agent",
|
|
183
|
+
mode: "Mode",
|
|
184
|
+
os: "OS",
|
|
185
|
+
review: "Review"
|
|
186
|
+
};
|
|
187
|
+
return renderTabBar(TAB_ORDER.map((tab, index) => ({
|
|
188
|
+
label: `${index + 1}. ${TAB_LABELS[tab]}`,
|
|
189
|
+
meta: tab === "review" ? "ready" : `${counts[tab]} selected`,
|
|
190
|
+
active: state.activeTab === tab
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
193
|
+
function formatListItem(item, state, isCursorRow, index) {
|
|
194
|
+
if (item.kind === "review") {
|
|
195
|
+
return renderListRow({
|
|
196
|
+
active: isCursorRow,
|
|
197
|
+
selected: state.reviewAction === item.id,
|
|
198
|
+
label: item.label,
|
|
199
|
+
meta: item.description,
|
|
200
|
+
index
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return renderListRow({
|
|
204
|
+
active: isCursorRow,
|
|
205
|
+
selected: isItemSelected(item, state),
|
|
206
|
+
label: item.label,
|
|
207
|
+
meta: item.description,
|
|
208
|
+
index
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function renderReviewSummary(state) {
|
|
212
|
+
const selectedServers = selectionArray(state.selectedServers);
|
|
213
|
+
const selectedAgents = selectionArray(state.selectedAgents);
|
|
214
|
+
const lines = [
|
|
215
|
+
"{bold}Selections{/bold}",
|
|
216
|
+
`MCPs ${selectedServers.length ? selectedServers.join(", ") : "none"}`,
|
|
217
|
+
`Agents ${selectedAgents.length ? selectedAgents.join(", ") : "none"}`,
|
|
218
|
+
`Mode ${state.selectedMode}`,
|
|
219
|
+
`OS ${state.selectedOs === "mac" ? "MacOS" : "Linux"}`
|
|
220
|
+
];
|
|
221
|
+
if (selectedServers.length > 0 && selectedAgents.length > 0) {
|
|
222
|
+
const plan = buildMcpInstallPlan({
|
|
223
|
+
mode: state.selectedMode,
|
|
224
|
+
agents: selectedAgents,
|
|
225
|
+
servers: selectedServers,
|
|
226
|
+
os: state.selectedOs
|
|
227
|
+
});
|
|
228
|
+
lines.push("", "{bold}Planned steps{/bold}");
|
|
229
|
+
for (const step of plan.steps) {
|
|
230
|
+
lines.push(`- ${step.title}: ${step.command}`);
|
|
231
|
+
}
|
|
232
|
+
if (plan.notes.length > 0) {
|
|
233
|
+
lines.push("", "{bold}Notes{/bold}");
|
|
234
|
+
for (const note of plan.notes) {
|
|
235
|
+
lines.push(`- ${note}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (plan.postInstallConfig.length > 0) {
|
|
239
|
+
lines.push("", "{bold}After install{/bold}");
|
|
240
|
+
for (const item of plan.postInstallConfig) {
|
|
241
|
+
lines.push(`- ${item}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (plan.sources.length > 0) {
|
|
245
|
+
lines.push("", "{bold}Sources{/bold}");
|
|
246
|
+
for (const source of plan.sources) {
|
|
247
|
+
lines.push(`- ${source.label}: ${source.url}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (state.notice) {
|
|
252
|
+
lines.push("", `{yellow-fg}${state.notice}{/yellow-fg}`);
|
|
253
|
+
}
|
|
254
|
+
return lines.join("\n");
|
|
255
|
+
}
|
|
256
|
+
function renderDetailBody(state) {
|
|
257
|
+
if (state.activeTab === "review") {
|
|
258
|
+
return renderReviewSummary(state);
|
|
259
|
+
}
|
|
260
|
+
const items = currentTabItems(state);
|
|
261
|
+
const current = items[state.listCursor[state.activeTab]];
|
|
262
|
+
const lines = [];
|
|
263
|
+
if (state.notice) {
|
|
264
|
+
lines.push(`{yellow-fg}${state.notice}{/yellow-fg}`, "");
|
|
265
|
+
}
|
|
266
|
+
if (current) {
|
|
267
|
+
const selectedCount = items.filter((item) => isItemSelected(item, state)).length;
|
|
268
|
+
lines.push("{bold}Selected in this step{/bold}", `${selectedCount} of ${items.length}`, "", "{bold}About current item{/bold}", current.description);
|
|
269
|
+
}
|
|
270
|
+
return lines.join("\n");
|
|
271
|
+
}
|
|
272
|
+
function renderFooter(state) {
|
|
273
|
+
if (state.activeTab === "review") {
|
|
274
|
+
return renderKeycaps([
|
|
275
|
+
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
276
|
+
{ key: "UP/DOWN", label: "move" },
|
|
277
|
+
{ key: "ENTER", label: "confirm action" },
|
|
278
|
+
{ key: "Q", label: "quit" }
|
|
279
|
+
]);
|
|
280
|
+
}
|
|
281
|
+
return renderKeycaps([
|
|
282
|
+
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
283
|
+
{ key: "UP/DOWN", label: "move" },
|
|
284
|
+
{ key: "SPACE", label: "toggle" },
|
|
285
|
+
{ key: "A", label: "toggle all" },
|
|
286
|
+
{ key: "Q", label: "quit" }
|
|
287
|
+
]);
|
|
288
|
+
}
|
|
289
|
+
function setNotice(state, message) {
|
|
290
|
+
state.notice = message;
|
|
291
|
+
}
|
|
292
|
+
function moveTab(state, delta) {
|
|
293
|
+
const index = TAB_ORDER.indexOf(state.activeTab);
|
|
294
|
+
const nextIndex = (index + delta + TAB_ORDER.length) % TAB_ORDER.length;
|
|
295
|
+
state.activeTab = TAB_ORDER[nextIndex];
|
|
296
|
+
state.notice = "";
|
|
297
|
+
}
|
|
298
|
+
function moveCursor(state, delta) {
|
|
299
|
+
const items = currentTabItems(state);
|
|
300
|
+
if (items.length === 0) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const current = state.listCursor[state.activeTab];
|
|
304
|
+
const next = (current + delta + items.length) % items.length;
|
|
305
|
+
state.listCursor[state.activeTab] = next;
|
|
306
|
+
if (state.activeTab === "review") {
|
|
307
|
+
state.reviewAction = items[next]?.id;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function toggleCurrentItem(state) {
|
|
311
|
+
if (state.activeTab === "review") {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const items = currentTabItems(state);
|
|
315
|
+
const current = items[state.listCursor[state.activeTab]];
|
|
316
|
+
if (!current) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
toggleItem(current, state);
|
|
320
|
+
}
|
|
321
|
+
function validateBeforeConfirm(state) {
|
|
322
|
+
if (state.selectedServers.size === 0) {
|
|
323
|
+
return "Select at least one MCP server before confirming.";
|
|
324
|
+
}
|
|
325
|
+
if (state.selectedAgents.size === 0) {
|
|
326
|
+
return "Select at least one agent before confirming.";
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
function syncListSelection(listBox, state) {
|
|
331
|
+
const items = currentTabItems(state);
|
|
332
|
+
const maxIndex = Math.max(items.length - 1, 0);
|
|
333
|
+
const cursor = Math.min(state.listCursor[state.activeTab], maxIndex);
|
|
334
|
+
state.listCursor[state.activeTab] = cursor;
|
|
335
|
+
listBox.setItems(items.map((item, index) => formatListItem(item, state, index === cursor, index)));
|
|
336
|
+
listBox.select(cursor);
|
|
337
|
+
listBox.scrollTo(cursor);
|
|
338
|
+
}
|
|
339
|
+
export async function runMcpWizard() {
|
|
340
|
+
return new Promise((resolve, reject) => {
|
|
341
|
+
const state = buildInitialState();
|
|
342
|
+
let lastTabSwitchAt = 0;
|
|
343
|
+
let lastMoveAt = 0;
|
|
344
|
+
let lastToggleAt = 0;
|
|
345
|
+
const { screen, headerBox, tabsBox, titleBox, listBox, detailBox, footerBox } = createTabbedLayout();
|
|
346
|
+
function cleanup() {
|
|
347
|
+
screen.destroy();
|
|
348
|
+
}
|
|
349
|
+
function finishWithError(message) {
|
|
350
|
+
cleanup();
|
|
351
|
+
reject(new Error(message));
|
|
352
|
+
}
|
|
353
|
+
function finishSuccess() {
|
|
354
|
+
if (state.selectedAgents.size === 0) {
|
|
355
|
+
finishWithError("Missing agent selection.");
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
cleanup();
|
|
359
|
+
resolve({
|
|
360
|
+
servers: selectionArray(state.selectedServers),
|
|
361
|
+
agents: selectionArray(state.selectedAgents),
|
|
362
|
+
mode: state.selectedMode,
|
|
363
|
+
os: state.selectedOs
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function finishBackToMenu() {
|
|
367
|
+
cleanup();
|
|
368
|
+
resolve({
|
|
369
|
+
backToMenu: true
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function render() {
|
|
373
|
+
const currentStep = TAB_ORDER.indexOf(state.activeTab) + 1;
|
|
374
|
+
const stepTitle = {
|
|
375
|
+
servers: "Select MCP servers",
|
|
376
|
+
agent: "Select agent",
|
|
377
|
+
mode: "Select mode",
|
|
378
|
+
os: "Select OS",
|
|
379
|
+
review: "Review selections"
|
|
380
|
+
}[state.activeTab];
|
|
381
|
+
const stepDescription = {
|
|
382
|
+
servers: "Choose one or more MCP servers to register or remove.",
|
|
383
|
+
agent: "Choose one or both agent targets for the MCP configuration.",
|
|
384
|
+
mode: "Choose whether this workflow installs or uninstalls the selected MCP servers.",
|
|
385
|
+
os: "Choose the operating system where the MCP servers will be configured.",
|
|
386
|
+
review: "Verify the generated MCP commands and source links before execution."
|
|
387
|
+
}[state.activeTab];
|
|
388
|
+
const stepStatus = {
|
|
389
|
+
servers: `${state.selectedServers.size} selected`,
|
|
390
|
+
agent: `${state.selectedAgents.size} selected`,
|
|
391
|
+
mode: state.selectedMode,
|
|
392
|
+
os: state.selectedOs === "mac" ? "MacOS" : "Linux",
|
|
393
|
+
review: state.notice || "Ready for confirmation"
|
|
394
|
+
}[state.activeTab];
|
|
395
|
+
headerBox.setContent(renderBannerHeader("Install mcp", "Plan and run MCP add/remove commands based on current official docs.", [
|
|
396
|
+
{ label: `${state.selectedServers.size} MCPs`, tone: "accent" },
|
|
397
|
+
{ label: `${state.selectedAgents.size} agents`, tone: "success" },
|
|
398
|
+
{ label: state.selectedMode, tone: "muted" },
|
|
399
|
+
{ label: "Internet-verified", tone: "muted" }
|
|
400
|
+
]));
|
|
401
|
+
tabsBox.setContent(renderTabs(state));
|
|
402
|
+
titleBox.setContent(renderStepSummary({
|
|
403
|
+
step: `STEP ${currentStep}/${TAB_ORDER.length}`,
|
|
404
|
+
title: stepTitle,
|
|
405
|
+
description: stepDescription,
|
|
406
|
+
status: stepStatus
|
|
407
|
+
}));
|
|
408
|
+
syncListSelection(listBox, state);
|
|
409
|
+
detailBox.setContent(renderDetailBody(state));
|
|
410
|
+
footerBox.setContent(renderFooter(state));
|
|
411
|
+
screen.render();
|
|
412
|
+
}
|
|
413
|
+
function handleToggleOrConfirm() {
|
|
414
|
+
if (!canRun(lastToggleAt, DEBOUNCE_SELECT_MS)) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
lastToggleAt = Date.now();
|
|
418
|
+
if (state.activeTab === "review") {
|
|
419
|
+
if (state.reviewAction === "back") {
|
|
420
|
+
finishBackToMenu();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (state.reviewAction === "cancel") {
|
|
424
|
+
finishWithError("MCP workflow cancelled.");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const validationMessage = validateBeforeConfirm(state);
|
|
428
|
+
if (validationMessage) {
|
|
429
|
+
setNotice(state, validationMessage);
|
|
430
|
+
render();
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
finishSuccess();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
toggleCurrentItem(state);
|
|
437
|
+
render();
|
|
438
|
+
}
|
|
439
|
+
function toggleAllInCurrentTab() {
|
|
440
|
+
if (state.activeTab === "review") {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const items = currentTabItems(state);
|
|
444
|
+
if (items.length === 0) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (state.activeTab === "mode") {
|
|
448
|
+
const current = items[state.listCursor.mode];
|
|
449
|
+
if (current) {
|
|
450
|
+
state.selectedMode = current.id;
|
|
451
|
+
render();
|
|
452
|
+
}
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (state.activeTab === "os") {
|
|
456
|
+
const current = items[state.listCursor.os];
|
|
457
|
+
if (current) {
|
|
458
|
+
state.selectedOs = current.id;
|
|
459
|
+
render();
|
|
460
|
+
}
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const allSelected = items.every((item) => isItemSelected(item, state));
|
|
464
|
+
for (const item of items) {
|
|
465
|
+
if (allSelected === isItemSelected(item, state)) {
|
|
466
|
+
toggleItem(item, state);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
render();
|
|
470
|
+
}
|
|
471
|
+
screen.key(["left"], () => {
|
|
472
|
+
if (!canRun(lastTabSwitchAt, DEBOUNCE_SELECT_MS)) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
lastTabSwitchAt = Date.now();
|
|
476
|
+
moveTab(state, -1);
|
|
477
|
+
render();
|
|
478
|
+
});
|
|
479
|
+
screen.key(["right"], () => {
|
|
480
|
+
if (!canRun(lastTabSwitchAt, DEBOUNCE_SELECT_MS)) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
lastTabSwitchAt = Date.now();
|
|
484
|
+
moveTab(state, 1);
|
|
485
|
+
render();
|
|
486
|
+
});
|
|
487
|
+
screen.key(["up"], () => {
|
|
488
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS)) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
lastMoveAt = Date.now();
|
|
492
|
+
moveCursor(state, -1);
|
|
493
|
+
render();
|
|
494
|
+
});
|
|
495
|
+
screen.key(["down"], () => {
|
|
496
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS)) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
lastMoveAt = Date.now();
|
|
500
|
+
moveCursor(state, 1);
|
|
501
|
+
render();
|
|
502
|
+
});
|
|
503
|
+
screen.key(["space", "enter"], () => {
|
|
504
|
+
handleToggleOrConfirm();
|
|
505
|
+
});
|
|
506
|
+
screen.key(["a"], () => {
|
|
507
|
+
toggleAllInCurrentTab();
|
|
508
|
+
});
|
|
509
|
+
screen.key(["q", "C-c"], () => {
|
|
510
|
+
finishWithError("MCP workflow cancelled.");
|
|
511
|
+
});
|
|
512
|
+
render();
|
|
513
|
+
});
|
|
514
|
+
}
|