@minhluudev/ai-tools 1.0.15 → 1.0.16
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/dist/src/cli.js +33 -0
- package/dist/src/lib/tui-entry-menu.js +7 -0
- package/dist/src/lib/tui-skills.js +322 -0
- package/package.json +1 -1
- package/selection-catalog.json +7 -0
package/dist/src/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as process from "node:process";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
2
3
|
import { buildLibInstallPlan, executeLibInstallPlan } from "./lib/ai-libs.js";
|
|
3
4
|
import { loadPackageConfig } from "./lib/config.js";
|
|
4
5
|
import { createGitHubClient } from "./lib/github.js";
|
|
@@ -8,6 +9,7 @@ import { loadSelectionCatalog, resolveSelectionItems } from "./lib/selection-cat
|
|
|
8
9
|
import { buildMcpInstallPlan, createMcpUninstallBackups, executeMcpInstallPlan, inspectMcpUninstallSafety, verifyMcpUninstallExecutionSafety } from "./lib/mcp.js";
|
|
9
10
|
import { buildPluginInstallPlan, executePluginInstallPlan } from "./lib/plugins.js";
|
|
10
11
|
import { blessedConfirm } from "./lib/tui-utils.js";
|
|
12
|
+
import { runSkillsWizard, resolveSkillsDir } from "./lib/tui-skills.js";
|
|
11
13
|
import { runAiLibsWizard } from "./lib/tui-ai-libs.js";
|
|
12
14
|
import { runEntryMenu } from "./lib/tui-entry-menu.js";
|
|
13
15
|
import { runMcpWizard } from "./lib/tui-mcp.js";
|
|
@@ -351,6 +353,37 @@ export async function runCli() {
|
|
|
351
353
|
printBulletPanel(`Install complete (${results.length})`, results.map((result) => `${result.id} -> ${result.targetPath}`), "success");
|
|
352
354
|
return;
|
|
353
355
|
}
|
|
356
|
+
if (entryAction === "manage-skills") {
|
|
357
|
+
const skillsResult = await runSkillsWizard();
|
|
358
|
+
if ("backToMenu" in skillsResult) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const { agent, skillsToDelete } = skillsResult;
|
|
362
|
+
const skillsDir = resolveSkillsDir(agent);
|
|
363
|
+
printSectionHeader("Manage skills", `Deleting ${skillsToDelete.length} skill(s) for ${agent}.`);
|
|
364
|
+
const deleted = [];
|
|
365
|
+
const failed = [];
|
|
366
|
+
for (const skillName of skillsToDelete) {
|
|
367
|
+
const skillPath = `${skillsDir}/${skillName}`;
|
|
368
|
+
try {
|
|
369
|
+
await rm(skillPath, { recursive: true, force: true });
|
|
370
|
+
deleted.push(skillName);
|
|
371
|
+
printStatusLine("delete", skillPath, "muted");
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
375
|
+
failed.push({ name: skillName, error: message });
|
|
376
|
+
printStatusLine("warn", `Failed to delete ${skillPath}: ${message}`, "warning");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (deleted.length > 0) {
|
|
380
|
+
printBulletPanel(`Deleted (${deleted.length})`, deleted, "success");
|
|
381
|
+
}
|
|
382
|
+
if (failed.length > 0) {
|
|
383
|
+
printBulletPanel(`Failed (${failed.length})`, failed.map((f) => `${f.name}: ${f.error}`), "warning");
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
354
387
|
// install-skills
|
|
355
388
|
const config = await loadPackageConfig();
|
|
356
389
|
const selectionCatalog = await loadSelectionCatalog(config);
|
|
@@ -31,6 +31,12 @@ const MENU_ITEMS = [
|
|
|
31
31
|
description: "Add or remove Ant Design, GitLab, GitHub, and Figma MCP servers for Codex or Claude.",
|
|
32
32
|
meta: "Codex + Claude"
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
id: "manage-skills",
|
|
36
|
+
label: "⊘ Manage skills",
|
|
37
|
+
description: "List and delete installed skills for Claude or Codex.",
|
|
38
|
+
meta: "Claude + Codex"
|
|
39
|
+
},
|
|
34
40
|
{
|
|
35
41
|
id: "cancel",
|
|
36
42
|
label: "✕ Cancel",
|
|
@@ -38,6 +44,7 @@ const MENU_ITEMS = [
|
|
|
38
44
|
meta: "Safe exit"
|
|
39
45
|
}
|
|
40
46
|
];
|
|
47
|
+
export const MENU_ITEMS_FOR_TEST = MENU_ITEMS;
|
|
41
48
|
function renderItem(item, isActive) {
|
|
42
49
|
return renderListRow({
|
|
43
50
|
active: isActive,
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { canRun, createTabbedLayout, DEBOUNCE_MOVE_MS, DEBOUNCE_SELECT_MS, renderBannerHeader, renderKeycaps, renderListContent, renderListRow, renderStepSummary, renderTabBar, selectionArray } from "./tui-utils.js";
|
|
5
|
+
const TAB_ORDER = ["agent", "skills", "review"];
|
|
6
|
+
const AGENT_DIR = {
|
|
7
|
+
claude: ".claude",
|
|
8
|
+
codex: ".codex"
|
|
9
|
+
};
|
|
10
|
+
export function resolveSkillsDir(agent) {
|
|
11
|
+
return path.join(os.homedir(), AGENT_DIR[agent], "skills");
|
|
12
|
+
}
|
|
13
|
+
export async function readInstalledSkills(skillsDir) {
|
|
14
|
+
try {
|
|
15
|
+
const entries = await readdir(skillsDir, { withFileTypes: true });
|
|
16
|
+
return entries
|
|
17
|
+
.filter((entry) => entry.isDirectory())
|
|
18
|
+
.map((entry) => entry.name);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function buildInitialState(availableSkills) {
|
|
25
|
+
return {
|
|
26
|
+
activeTab: "agent",
|
|
27
|
+
selectedAgent: "claude",
|
|
28
|
+
availableSkills,
|
|
29
|
+
selectedSkills: new Set(),
|
|
30
|
+
listCursor: { agent: 0, skills: 0, review: 0 },
|
|
31
|
+
reviewAction: "confirm",
|
|
32
|
+
notice: ""
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function agentItems() {
|
|
36
|
+
return [
|
|
37
|
+
{ id: "claude", label: "◇ Claude" },
|
|
38
|
+
{ id: "codex", label: "◇ Codex" }
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
function reviewItems() {
|
|
42
|
+
return [
|
|
43
|
+
{ id: "confirm", label: "✓ Confirm delete" },
|
|
44
|
+
{ id: "back", label: "← Back to main menu" },
|
|
45
|
+
{ id: "cancel", label: "✕ Cancel" }
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
function renderTabs(state) {
|
|
49
|
+
return renderTabBar(TAB_ORDER.map((tab, index) => ({
|
|
50
|
+
label: `${index + 1}. ${tab.charAt(0).toUpperCase() + tab.slice(1)}`,
|
|
51
|
+
meta: tab === "agent"
|
|
52
|
+
? state.selectedAgent
|
|
53
|
+
: tab === "skills"
|
|
54
|
+
? `${state.selectedSkills.size} selected`
|
|
55
|
+
: "ready",
|
|
56
|
+
active: state.activeTab === tab
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
function renderDetailBody(state) {
|
|
60
|
+
const lines = [];
|
|
61
|
+
if (state.notice) {
|
|
62
|
+
lines.push(`{yellow-fg}${state.notice}{/yellow-fg}`, "");
|
|
63
|
+
}
|
|
64
|
+
if (state.activeTab === "review") {
|
|
65
|
+
const selected = selectionArray(state.selectedSkills);
|
|
66
|
+
const sep = `{cyan-fg}${"─".repeat(50)}{/cyan-fg}`;
|
|
67
|
+
lines.push(`{bold}{white-fg}◈ Delete summary{/white-fg}{/bold}`, sep, `{cyan-fg}◆ Agent{/cyan-fg} ${state.selectedAgent}`, `{cyan-fg}◆ Skills{/cyan-fg} ${selected.length ? selected.join(", ") : "{gray-fg}none{/gray-fg}"}`, "", `{gray-fg}This will permanently remove the selected skill directories.{/gray-fg}`);
|
|
68
|
+
return lines.join("\n");
|
|
69
|
+
}
|
|
70
|
+
if (state.activeTab === "agent") {
|
|
71
|
+
lines.push(`{cyan-fg}◆ Select the agent whose skills you want to manage.{/cyan-fg}`);
|
|
72
|
+
return lines.join("\n");
|
|
73
|
+
}
|
|
74
|
+
const count = state.selectedSkills.size;
|
|
75
|
+
const total = state.availableSkills.length;
|
|
76
|
+
lines.push(`{cyan-fg}◆ ${count} of ${total} selected{/cyan-fg}`, `{gray-fg}${"─".repeat(40)}{/gray-fg}`, `{gray-fg}Skills for ${state.selectedAgent} in ${resolveSkillsDir(state.selectedAgent)}{/gray-fg}`);
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
function renderFooter(state) {
|
|
80
|
+
if (state.activeTab === "review") {
|
|
81
|
+
return renderKeycaps([
|
|
82
|
+
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
83
|
+
{ key: "UP/DOWN", label: "move" },
|
|
84
|
+
{ key: "ENTER", label: "confirm action" },
|
|
85
|
+
{ key: "Q", label: "quit" }
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
if (state.activeTab === "skills") {
|
|
89
|
+
return renderKeycaps([
|
|
90
|
+
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
91
|
+
{ key: "UP/DOWN", label: "move" },
|
|
92
|
+
{ key: "SPACE", label: "toggle" },
|
|
93
|
+
{ key: "A", label: "toggle all" },
|
|
94
|
+
{ key: "ENTER", label: "next" },
|
|
95
|
+
{ key: "Q", label: "quit" }
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
return renderKeycaps([
|
|
99
|
+
{ key: "LEFT/RIGHT", label: "switch tab" },
|
|
100
|
+
{ key: "UP/DOWN", label: "move" },
|
|
101
|
+
{ key: "SPACE", label: "select" },
|
|
102
|
+
{ key: "ENTER", label: "next" },
|
|
103
|
+
{ key: "Q", label: "quit" }
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
function moveTab(state, delta) {
|
|
107
|
+
const index = TAB_ORDER.indexOf(state.activeTab);
|
|
108
|
+
const nextIndex = (index + delta + TAB_ORDER.length) % TAB_ORDER.length;
|
|
109
|
+
state.activeTab = TAB_ORDER[nextIndex];
|
|
110
|
+
state.notice = "";
|
|
111
|
+
}
|
|
112
|
+
function moveCursor(state, delta) {
|
|
113
|
+
let length = 0;
|
|
114
|
+
if (state.activeTab === "agent")
|
|
115
|
+
length = agentItems().length;
|
|
116
|
+
else if (state.activeTab === "skills")
|
|
117
|
+
length = state.availableSkills.length;
|
|
118
|
+
else
|
|
119
|
+
length = reviewItems().length;
|
|
120
|
+
if (length === 0)
|
|
121
|
+
return;
|
|
122
|
+
const current = state.listCursor[state.activeTab];
|
|
123
|
+
const next = (current + delta + length) % length;
|
|
124
|
+
state.listCursor[state.activeTab] = next;
|
|
125
|
+
if (state.activeTab === "review") {
|
|
126
|
+
state.reviewAction = reviewItems()[next]?.id ?? "confirm";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function toggleCurrentItem(state) {
|
|
130
|
+
if (state.activeTab === "agent") {
|
|
131
|
+
const item = agentItems()[state.listCursor.agent];
|
|
132
|
+
if (item) {
|
|
133
|
+
state.selectedAgent = item.id;
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (state.activeTab === "skills") {
|
|
138
|
+
const skill = state.availableSkills[state.listCursor.skills];
|
|
139
|
+
if (!skill)
|
|
140
|
+
return;
|
|
141
|
+
if (state.selectedSkills.has(skill)) {
|
|
142
|
+
state.selectedSkills.delete(skill);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
state.selectedSkills.add(skill);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function toggleAllSkills(state) {
|
|
150
|
+
if (state.activeTab !== "skills")
|
|
151
|
+
return;
|
|
152
|
+
const allSelected = state.availableSkills.every((s) => state.selectedSkills.has(s));
|
|
153
|
+
state.selectedSkills.clear();
|
|
154
|
+
if (!allSelected) {
|
|
155
|
+
for (const s of state.availableSkills) {
|
|
156
|
+
state.selectedSkills.add(s);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function validateAndAdvance(state) {
|
|
161
|
+
if (state.activeTab === "agent") {
|
|
162
|
+
moveTab(state, 1);
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
if (state.activeTab === "skills") {
|
|
166
|
+
if (state.availableSkills.length === 0) {
|
|
167
|
+
state.notice = "No skills found. Install skills first.";
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (state.selectedSkills.size === 0) {
|
|
171
|
+
state.notice = "Select at least one skill to delete.";
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
moveTab(state, 1);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
function buildListItems(state) {
|
|
180
|
+
if (state.activeTab === "agent") {
|
|
181
|
+
return agentItems().map((item, index) => renderListRow({
|
|
182
|
+
active: index === state.listCursor.agent,
|
|
183
|
+
selected: state.selectedAgent === item.id,
|
|
184
|
+
label: item.label,
|
|
185
|
+
index
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
if (state.activeTab === "skills") {
|
|
189
|
+
if (state.availableSkills.length === 0) {
|
|
190
|
+
return [renderListRow({ active: false, label: "{gray-fg}No skills found{/gray-fg}" })];
|
|
191
|
+
}
|
|
192
|
+
return state.availableSkills.map((skill, index) => renderListRow({
|
|
193
|
+
active: index === state.listCursor.skills,
|
|
194
|
+
selected: state.selectedSkills.has(skill),
|
|
195
|
+
label: `◈ ${skill}`,
|
|
196
|
+
index
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
return reviewItems().map((item, index) => renderListRow({
|
|
200
|
+
active: index === state.listCursor.review,
|
|
201
|
+
selected: state.reviewAction === item.id,
|
|
202
|
+
label: item.label,
|
|
203
|
+
index
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
export async function runSkillsWizard() {
|
|
207
|
+
const initialSkills = await readInstalledSkills(resolveSkillsDir("claude"));
|
|
208
|
+
const state = buildInitialState(initialSkills);
|
|
209
|
+
const { screen, headerBox, tabsBox, titleBox, listBox, detailBox, footerBox } = createTabbedLayout();
|
|
210
|
+
let lastMoveAt = 0;
|
|
211
|
+
let lastSelectAt = 0;
|
|
212
|
+
return new Promise((resolve) => {
|
|
213
|
+
function cleanup() {
|
|
214
|
+
screen.destroy();
|
|
215
|
+
}
|
|
216
|
+
async function refreshSkills() {
|
|
217
|
+
const skills = await readInstalledSkills(resolveSkillsDir(state.selectedAgent));
|
|
218
|
+
state.availableSkills = skills;
|
|
219
|
+
state.selectedSkills.clear();
|
|
220
|
+
state.listCursor.skills = 0;
|
|
221
|
+
state.notice = "";
|
|
222
|
+
render();
|
|
223
|
+
}
|
|
224
|
+
function render() {
|
|
225
|
+
const items = buildListItems(state);
|
|
226
|
+
const cursor = state.listCursor[state.activeTab];
|
|
227
|
+
headerBox.setContent(renderBannerHeader("Manage skills", "List and delete installed skills for Claude or Codex.", [
|
|
228
|
+
{ label: state.selectedAgent, tone: "accent" },
|
|
229
|
+
{ label: `${state.selectedSkills.size} selected`, tone: "muted" },
|
|
230
|
+
{ label: "delete", tone: "warning" }
|
|
231
|
+
]));
|
|
232
|
+
tabsBox.setContent(renderTabs(state));
|
|
233
|
+
titleBox.setContent(renderStepSummary({
|
|
234
|
+
step: `${TAB_ORDER.indexOf(state.activeTab) + 1}/${TAB_ORDER.length}`,
|
|
235
|
+
title: state.activeTab === "review"
|
|
236
|
+
? "Review"
|
|
237
|
+
: state.activeTab.charAt(0).toUpperCase() + state.activeTab.slice(1),
|
|
238
|
+
description: "Choose agent, select skills to remove, then confirm."
|
|
239
|
+
}));
|
|
240
|
+
renderListContent(listBox, items, cursor);
|
|
241
|
+
detailBox.setContent(renderDetailBody(state));
|
|
242
|
+
footerBox.setContent(renderFooter(state));
|
|
243
|
+
screen.render();
|
|
244
|
+
}
|
|
245
|
+
screen.key(["left"], () => {
|
|
246
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS))
|
|
247
|
+
return;
|
|
248
|
+
lastMoveAt = Date.now();
|
|
249
|
+
moveTab(state, -1);
|
|
250
|
+
render();
|
|
251
|
+
});
|
|
252
|
+
screen.key(["right"], () => {
|
|
253
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS))
|
|
254
|
+
return;
|
|
255
|
+
lastMoveAt = Date.now();
|
|
256
|
+
moveTab(state, 1);
|
|
257
|
+
render();
|
|
258
|
+
});
|
|
259
|
+
screen.key(["up"], () => {
|
|
260
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS))
|
|
261
|
+
return;
|
|
262
|
+
lastMoveAt = Date.now();
|
|
263
|
+
moveCursor(state, -1);
|
|
264
|
+
render();
|
|
265
|
+
});
|
|
266
|
+
screen.key(["down"], () => {
|
|
267
|
+
if (!canRun(lastMoveAt, DEBOUNCE_MOVE_MS))
|
|
268
|
+
return;
|
|
269
|
+
lastMoveAt = Date.now();
|
|
270
|
+
moveCursor(state, 1);
|
|
271
|
+
render();
|
|
272
|
+
});
|
|
273
|
+
screen.key(["space"], () => {
|
|
274
|
+
if (!canRun(lastSelectAt, DEBOUNCE_SELECT_MS))
|
|
275
|
+
return;
|
|
276
|
+
lastSelectAt = Date.now();
|
|
277
|
+
toggleCurrentItem(state);
|
|
278
|
+
render();
|
|
279
|
+
});
|
|
280
|
+
screen.key(["a"], () => {
|
|
281
|
+
if (!canRun(lastSelectAt, DEBOUNCE_SELECT_MS))
|
|
282
|
+
return;
|
|
283
|
+
lastSelectAt = Date.now();
|
|
284
|
+
toggleAllSkills(state);
|
|
285
|
+
render();
|
|
286
|
+
});
|
|
287
|
+
screen.key(["enter"], () => {
|
|
288
|
+
if (!canRun(lastSelectAt, DEBOUNCE_SELECT_MS))
|
|
289
|
+
return;
|
|
290
|
+
lastSelectAt = Date.now();
|
|
291
|
+
if (state.activeTab !== "review") {
|
|
292
|
+
const prevAgent = state.selectedAgent;
|
|
293
|
+
if (state.activeTab === "agent") {
|
|
294
|
+
const item = agentItems()[state.listCursor.agent];
|
|
295
|
+
if (item)
|
|
296
|
+
state.selectedAgent = item.id;
|
|
297
|
+
}
|
|
298
|
+
const advanced = validateAndAdvance(state);
|
|
299
|
+
if (advanced && state.activeTab === "skills" && state.selectedAgent !== prevAgent) {
|
|
300
|
+
void refreshSkills();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
render();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
cleanup();
|
|
307
|
+
if (state.reviewAction === "back" || state.reviewAction === "cancel") {
|
|
308
|
+
resolve({ backToMenu: true });
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
resolve({
|
|
312
|
+
agent: state.selectedAgent,
|
|
313
|
+
skillsToDelete: selectionArray(state.selectedSkills)
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
screen.key(["q", "escape", "C-c"], () => {
|
|
317
|
+
cleanup();
|
|
318
|
+
resolve({ backToMenu: true });
|
|
319
|
+
});
|
|
320
|
+
render();
|
|
321
|
+
});
|
|
322
|
+
}
|
package/package.json
CHANGED
package/selection-catalog.json
CHANGED
|
@@ -70,6 +70,13 @@
|
|
|
70
70
|
"description": "Create or update structured task documents from Jira, Trello, Notion, Linear, GitHub Issues, or plain descriptions.",
|
|
71
71
|
"sourceBranch": "agent-skills",
|
|
72
72
|
"sourcePath": "make-task"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "generate-flow",
|
|
76
|
+
"label": "Generate Flow",
|
|
77
|
+
"description": "Trace a feature's data and logic end-to-end through source code layers — from trigger to persistence, event emission, response, or failure.",
|
|
78
|
+
"sourceBranch": "agent-skills",
|
|
79
|
+
"sourcePath": "generate-flow"
|
|
73
80
|
}
|
|
74
81
|
]
|
|
75
82
|
}
|