@minhluudev/ai-tools 1.0.22 → 1.0.25
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 +5 -31
- package/dist/src/bin/ai-tools.js +1 -2
- package/dist/src/cli.js +1 -221
- package/dist/src/lib/agent-selection.js +60 -0
- package/dist/src/lib/catalog.js +4 -1
- package/dist/src/lib/config.js +0 -2
- package/dist/src/lib/install.js +45 -79
- package/dist/src/lib/selection-catalog.js +6 -2
- package/dist/src/lib/tui-entry-menu.js +0 -24
- package/dist/src/lib/tui-skills.js +4 -2
- package/dist/src/lib/tui-wizard.js +14 -24
- package/package.json +7 -7
- package/selection-catalog.json +31 -66
- package/dist/src/lib/ai-libs.js +0 -417
- package/dist/src/lib/mcp.js +0 -665
- package/dist/src/lib/plugins.js +0 -155
- package/dist/src/lib/project-docs-catalog.js +0 -45
- package/dist/src/lib/tui-ai-libs.js +0 -539
- package/dist/src/lib/tui-mcp.js +0 -514
- package/dist/src/lib/tui-plugins.js +0 -408
- package/dist/src/lib/tui-project-docs.js +0 -303
- package/project-docs-catalog.json +0 -19
package/dist/src/lib/tui-mcp.js
DELETED
|
@@ -1,514 +0,0 @@
|
|
|
1
|
-
import { buildMcpInstallPlan } from "./mcp.js";
|
|
2
|
-
import { canRun, createTabbedLayout, DEBOUNCE_MOVE_MS, DEBOUNCE_SELECT_MS, renderBannerHeader, renderKeycaps, renderListRow, renderListContent, 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
|
-
index
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return renderListRow({
|
|
203
|
-
active: isCursorRow,
|
|
204
|
-
selected: isItemSelected(item, state),
|
|
205
|
-
label: item.label,
|
|
206
|
-
index
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function renderReviewSummary(state) {
|
|
210
|
-
const selectedServers = selectionArray(state.selectedServers);
|
|
211
|
-
const selectedAgents = selectionArray(state.selectedAgents);
|
|
212
|
-
const sep = `{cyan-fg}${"─".repeat(50)}{/cyan-fg}`;
|
|
213
|
-
const none = "{gray-fg}none{/gray-fg}";
|
|
214
|
-
const lines = [
|
|
215
|
-
`{bold}{white-fg}◈ Summary{/white-fg}{/bold}`,
|
|
216
|
-
sep,
|
|
217
|
-
`{cyan-fg}◆ MCPs{/cyan-fg} ${selectedServers.length ? selectedServers.join(", ") : none}`,
|
|
218
|
-
`{cyan-fg}◆ Agents{/cyan-fg} ${selectedAgents.length ? selectedAgents.join(", ") : none}`,
|
|
219
|
-
`{cyan-fg}◆ Mode{/cyan-fg} ${state.selectedMode}`,
|
|
220
|
-
`{cyan-fg}◆ OS{/cyan-fg} ${state.selectedOs === "mac" ? "MacOS" : "Linux"}`
|
|
221
|
-
];
|
|
222
|
-
if (selectedServers.length > 0 && selectedAgents.length > 0) {
|
|
223
|
-
const plan = buildMcpInstallPlan({
|
|
224
|
-
mode: state.selectedMode,
|
|
225
|
-
agents: selectedAgents,
|
|
226
|
-
servers: selectedServers,
|
|
227
|
-
os: state.selectedOs
|
|
228
|
-
});
|
|
229
|
-
lines.push("", sep, `{bold}{white-fg}⊕ Planned steps{/white-fg}{/bold}`);
|
|
230
|
-
for (const step of plan.steps) {
|
|
231
|
-
lines.push(` {gray-fg}▶{/gray-fg} ${step.title} {gray-fg}${step.command}{/gray-fg}`);
|
|
232
|
-
}
|
|
233
|
-
if (plan.notes.length > 0) {
|
|
234
|
-
lines.push("", `{bold}{white-fg}◎ Notes{/white-fg}{/bold}`);
|
|
235
|
-
for (const note of plan.notes) {
|
|
236
|
-
lines.push(` {gray-fg}·{/gray-fg} ${note}`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (plan.postInstallConfig.length > 0) {
|
|
240
|
-
lines.push("", `{bold}{white-fg}◎ After install{/white-fg}{/bold}`);
|
|
241
|
-
for (const item of plan.postInstallConfig) {
|
|
242
|
-
lines.push(` {gray-fg}·{/gray-fg} ${item}`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (plan.sources.length > 0) {
|
|
246
|
-
lines.push("", `{bold}{white-fg}◎ Sources{/white-fg}{/bold}`);
|
|
247
|
-
for (const source of plan.sources) {
|
|
248
|
-
lines.push(` {gray-fg}·{/gray-fg} ${source.label} {gray-fg}${source.url}{/gray-fg}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (state.notice) {
|
|
253
|
-
lines.push("", `{yellow-fg}${state.notice}{/yellow-fg}`);
|
|
254
|
-
}
|
|
255
|
-
return lines.join("\n");
|
|
256
|
-
}
|
|
257
|
-
function renderDetailBody(state) {
|
|
258
|
-
if (state.activeTab === "review") {
|
|
259
|
-
return renderReviewSummary(state);
|
|
260
|
-
}
|
|
261
|
-
const items = currentTabItems(state);
|
|
262
|
-
const current = items[state.listCursor[state.activeTab]];
|
|
263
|
-
const lines = [];
|
|
264
|
-
if (state.notice) {
|
|
265
|
-
lines.push(`{yellow-fg}${state.notice}{/yellow-fg}`, "");
|
|
266
|
-
}
|
|
267
|
-
if (current) {
|
|
268
|
-
const selectedCount = items.filter((item) => isItemSelected(item, state)).length;
|
|
269
|
-
lines.push(`{cyan-fg}◆ ${selectedCount} of ${items.length} selected{/cyan-fg}`, `{gray-fg}${"─".repeat(40)}{/gray-fg}`, `{bold}{white-fg}${current.label}{/white-fg}{/bold}`, `{gray-fg}${current.description}{/gray-fg}`);
|
|
270
|
-
}
|
|
271
|
-
return lines.join("\n");
|
|
272
|
-
}
|
|
273
|
-
function renderFooter(state) {
|
|
274
|
-
if (state.activeTab === "review") {
|
|
275
|
-
return renderKeycaps([
|
|
276
|
-
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
277
|
-
{ key: "UP/DOWN", label: "move" },
|
|
278
|
-
{ key: "ENTER", label: "confirm action" },
|
|
279
|
-
{ key: "Q", label: "quit" }
|
|
280
|
-
]);
|
|
281
|
-
}
|
|
282
|
-
return renderKeycaps([
|
|
283
|
-
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
284
|
-
{ key: "UP/DOWN", label: "move" },
|
|
285
|
-
{ key: "SPACE", label: "toggle" },
|
|
286
|
-
{ key: "A", label: "toggle all" },
|
|
287
|
-
{ key: "Q", label: "quit" }
|
|
288
|
-
]);
|
|
289
|
-
}
|
|
290
|
-
function setNotice(state, message) {
|
|
291
|
-
state.notice = message;
|
|
292
|
-
}
|
|
293
|
-
function moveTab(state, delta) {
|
|
294
|
-
const index = TAB_ORDER.indexOf(state.activeTab);
|
|
295
|
-
const nextIndex = (index + delta + TAB_ORDER.length) % TAB_ORDER.length;
|
|
296
|
-
state.activeTab = TAB_ORDER[nextIndex];
|
|
297
|
-
state.notice = "";
|
|
298
|
-
}
|
|
299
|
-
function moveCursor(state, delta) {
|
|
300
|
-
const items = currentTabItems(state);
|
|
301
|
-
if (items.length === 0) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
const current = state.listCursor[state.activeTab];
|
|
305
|
-
const next = (current + delta + items.length) % items.length;
|
|
306
|
-
state.listCursor[state.activeTab] = next;
|
|
307
|
-
if (state.activeTab === "review") {
|
|
308
|
-
state.reviewAction = items[next]?.id;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function toggleCurrentItem(state) {
|
|
312
|
-
if (state.activeTab === "review") {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const items = currentTabItems(state);
|
|
316
|
-
const current = items[state.listCursor[state.activeTab]];
|
|
317
|
-
if (!current) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
toggleItem(current, state);
|
|
321
|
-
}
|
|
322
|
-
function validateBeforeConfirm(state) {
|
|
323
|
-
if (state.selectedServers.size === 0) {
|
|
324
|
-
return "Select at least one MCP server before confirming.";
|
|
325
|
-
}
|
|
326
|
-
if (state.selectedAgents.size === 0) {
|
|
327
|
-
return "Select at least one agent before confirming.";
|
|
328
|
-
}
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
function syncListSelection(listBox, state) {
|
|
332
|
-
const items = currentTabItems(state);
|
|
333
|
-
const maxIndex = Math.max(items.length - 1, 0);
|
|
334
|
-
const cursor = Math.min(state.listCursor[state.activeTab], maxIndex);
|
|
335
|
-
state.listCursor[state.activeTab] = cursor;
|
|
336
|
-
const rendered = items.map((item, index) => formatListItem(item, state, index === cursor, index));
|
|
337
|
-
renderListContent(listBox, rendered, 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
|
-
}
|