@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
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ Main menu:
|
|
|
19
19
|
1. `Install agent skills`
|
|
20
20
|
2. `Install project docs`
|
|
21
21
|
3. `Install libs for AI`
|
|
22
|
-
4. `
|
|
22
|
+
4. `Install mcp`
|
|
23
|
+
5. `Cancel`
|
|
23
24
|
|
|
24
25
|
Controls:
|
|
25
26
|
|
|
@@ -33,3 +34,17 @@ Controls:
|
|
|
33
34
|
|
|
34
35
|
`Install project docs`
|
|
35
36
|
- copies the contents inside the selected docs folder into the current working directory
|
|
37
|
+
|
|
38
|
+
`Install libs for AI`
|
|
39
|
+
- opens a guided workflow with tabs for `Libraries`, `Agents`, `OS`, `Scope`, `Mode`, and `Review`
|
|
40
|
+
- supports `rtk-ai/rtk`, `rtk-ai/icm`, and `affaan-m/ECC`
|
|
41
|
+
- runs the current upstream install flow for each selected library and prints safety notes when an upstream flow is broader than the selected agent or scope
|
|
42
|
+
- for `ECC`, clones the upstream repo into a temporary directory and runs the documented repo-based setup flow for the selected agent, with warnings about the documented Claude plugin overlap
|
|
43
|
+
|
|
44
|
+
`Install mcp`
|
|
45
|
+
- opens a guided workflow with tabs for `Select MCP`, `Agent`, `Mode`, and `Review`
|
|
46
|
+
- supports `Ant Design`, `GitLab`, `GitHub`, `Figma`, and `Shadcn`
|
|
47
|
+
- supports selecting `Codex`, `Claude`, or both in the same run
|
|
48
|
+
- supports `Install` and `Uninstall`
|
|
49
|
+
- builds commands from current official MCP setup docs, executes the selected plan, and prints any extra configuration still required after install
|
|
50
|
+
- in `Uninstall`, runs a safety preflight so removals target only the expected scope/config and warn when similarly named entries exist elsewhere
|
package/dist/src/bin/ai-tools.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { runCli } from "../cli.js";
|
|
3
3
|
function isCancellationMessage(message) {
|
|
4
4
|
return message === "Installation cancelled."
|
|
5
|
-
|| message === "Installation cancelled because existing targets would be overwritten."
|
|
5
|
+
|| message === "Installation cancelled because existing targets would be overwritten."
|
|
6
|
+
|| message === "MCP workflow cancelled.";
|
|
6
7
|
}
|
|
7
8
|
runCli().catch((error) => {
|
|
8
9
|
const message = error instanceof Error ? error.message : String(error);
|
package/dist/src/cli.js
CHANGED
|
@@ -5,9 +5,11 @@ import { createGitHubClient } from "./lib/github.js";
|
|
|
5
5
|
import { detectExistingTargets, installPlannedItems, installProjectDocsItems, planInstallations, planProjectDocsInstallations, resolveInstallRoot, resolveProjectDocsRoot } from "./lib/install.js";
|
|
6
6
|
import { loadProjectDocsCatalog } from "./lib/project-docs-catalog.js";
|
|
7
7
|
import { loadSelectionCatalog, resolveSelectionItems } from "./lib/selection-catalog.js";
|
|
8
|
+
import { buildMcpInstallPlan, createMcpUninstallBackups, executeMcpInstallPlan, inspectMcpUninstallSafety, verifyMcpUninstallExecutionSafety } from "./lib/mcp.js";
|
|
8
9
|
import { blessedConfirm } from "./lib/tui-utils.js";
|
|
9
10
|
import { runAiLibsWizard } from "./lib/tui-ai-libs.js";
|
|
10
11
|
import { runEntryMenu } from "./lib/tui-entry-menu.js";
|
|
12
|
+
import { runMcpWizard } from "./lib/tui-mcp.js";
|
|
11
13
|
import { runProjectDocsWizard } from "./lib/tui-project-docs.js";
|
|
12
14
|
import { runTabbedWizard } from "./lib/tui-wizard.js";
|
|
13
15
|
const ANSI = {
|
|
@@ -145,6 +147,14 @@ function printLibInstallSelectionSummary(plan) {
|
|
|
145
147
|
["Host OS", plan.hostOs ?? "unsupported"]
|
|
146
148
|
]);
|
|
147
149
|
}
|
|
150
|
+
function printMcpInstallSelectionSummary(plan) {
|
|
151
|
+
printLabeledRows("Selected items", [
|
|
152
|
+
["Mode", plan.mode],
|
|
153
|
+
["Agents", plan.agents.length ? plan.agents.join(", ") : "none"],
|
|
154
|
+
["MCPs", plan.servers.length ? plan.servers.join(", ") : "none"],
|
|
155
|
+
["OS", plan.os === "mac" ? "MacOS" : "Linux"]
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
148
158
|
export async function runCli() {
|
|
149
159
|
while (true) {
|
|
150
160
|
const entryAction = await runEntryMenu();
|
|
@@ -164,8 +174,8 @@ export async function runCli() {
|
|
|
164
174
|
libraries: libsResult.libraries
|
|
165
175
|
});
|
|
166
176
|
printSectionHeader("Install libs for AI", libsResult.mode === "install"
|
|
167
|
-
? "Preparing upstream RTK and
|
|
168
|
-
: "Preparing safe RTK and
|
|
177
|
+
? "Preparing upstream RTK, ICM, and ECC installers."
|
|
178
|
+
: "Preparing safe RTK, ICM, and ECC removal steps.");
|
|
169
179
|
printLibInstallSelectionSummary(plan);
|
|
170
180
|
if (plan.notes.length > 0) {
|
|
171
181
|
printBulletPanel("Notes", plan.notes, "warning");
|
|
@@ -184,6 +194,88 @@ export async function runCli() {
|
|
|
184
194
|
printBulletPanel(`Install complete (${plan.steps.length})`, plan.steps.map((step) => step.title), "success");
|
|
185
195
|
return;
|
|
186
196
|
}
|
|
197
|
+
if (entryAction === "install-mcp") {
|
|
198
|
+
const mcpResult = await runMcpWizard();
|
|
199
|
+
if ("backToMenu" in mcpResult) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const plan = buildMcpInstallPlan({
|
|
203
|
+
mode: mcpResult.mode,
|
|
204
|
+
agents: mcpResult.agents,
|
|
205
|
+
servers: mcpResult.servers,
|
|
206
|
+
os: mcpResult.os
|
|
207
|
+
});
|
|
208
|
+
const uninstallSafety = plan.mode === "uninstall"
|
|
209
|
+
? await inspectMcpUninstallSafety({
|
|
210
|
+
cwd: process.cwd(),
|
|
211
|
+
plan
|
|
212
|
+
})
|
|
213
|
+
: null;
|
|
214
|
+
const effectiveServers = uninstallSafety
|
|
215
|
+
? [...new Set(uninstallSafety.effectiveSteps.map((s) => s.server))]
|
|
216
|
+
: plan.servers;
|
|
217
|
+
const effectivePlan = uninstallSafety
|
|
218
|
+
? {
|
|
219
|
+
...buildMcpInstallPlan({
|
|
220
|
+
mode: plan.mode,
|
|
221
|
+
agents: plan.agents,
|
|
222
|
+
servers: effectiveServers,
|
|
223
|
+
os: plan.os
|
|
224
|
+
}),
|
|
225
|
+
steps: uninstallSafety.effectiveSteps
|
|
226
|
+
}
|
|
227
|
+
: plan;
|
|
228
|
+
printSectionHeader("Install mcp", plan.mode === "install"
|
|
229
|
+
? "Preparing MCP registration commands from current official setup docs."
|
|
230
|
+
: "Preparing MCP removal commands from current official setup docs.");
|
|
231
|
+
printMcpInstallSelectionSummary(effectivePlan);
|
|
232
|
+
if (effectivePlan.notes.length > 0) {
|
|
233
|
+
printBulletPanel("Notes", effectivePlan.notes, "warning");
|
|
234
|
+
}
|
|
235
|
+
if (effectivePlan.postInstallConfig.length > 0) {
|
|
236
|
+
printBulletPanel("Required configuration after install", effectivePlan.postInstallConfig, "warning");
|
|
237
|
+
}
|
|
238
|
+
if (uninstallSafety?.safeNotes.length) {
|
|
239
|
+
printBulletPanel("Uninstall safety check", uninstallSafety.safeNotes, "warning");
|
|
240
|
+
}
|
|
241
|
+
if (uninstallSafety?.skippedSteps.length) {
|
|
242
|
+
printBulletPanel("Skipped uninstall steps", uninstallSafety.skippedSteps.map((item) => item.reason), "warning");
|
|
243
|
+
}
|
|
244
|
+
printBulletPanel(`Execution plan (${effectivePlan.steps.length})`, effectivePlan.steps.map((step) => `${step.title}: ${step.command}`), "muted");
|
|
245
|
+
if (effectivePlan.sources.length > 0) {
|
|
246
|
+
printBulletPanel("Sources", effectivePlan.sources.map((source) => `${source.label}: ${source.url}`), "muted");
|
|
247
|
+
}
|
|
248
|
+
printStatusLine(effectivePlan.mode === "install" ? "install" : "uninstall", effectivePlan.mode === "install"
|
|
249
|
+
? "Running selected MCP setup commands..."
|
|
250
|
+
: "Running selected MCP removal commands...");
|
|
251
|
+
if (uninstallSafety?.effectiveSteps.length) {
|
|
252
|
+
const backupPaths = await createMcpUninstallBackups({
|
|
253
|
+
cwd: process.cwd(),
|
|
254
|
+
steps: uninstallSafety.effectiveSteps
|
|
255
|
+
});
|
|
256
|
+
if (backupPaths.length > 0) {
|
|
257
|
+
printBulletPanel("Config backups created", backupPaths, "warning");
|
|
258
|
+
}
|
|
259
|
+
await verifyMcpUninstallExecutionSafety({
|
|
260
|
+
cwd: process.cwd(),
|
|
261
|
+
originalPlan: plan,
|
|
262
|
+
expectedSteps: uninstallSafety.effectiveSteps
|
|
263
|
+
});
|
|
264
|
+
printStatusLine("verify", "Final uninstall verification passed.", "warning");
|
|
265
|
+
}
|
|
266
|
+
await executeMcpInstallPlan({
|
|
267
|
+
cwd: process.cwd(),
|
|
268
|
+
plan: effectivePlan,
|
|
269
|
+
onProgress(step) {
|
|
270
|
+
printStatusLine("run", `${step.title} -> ${step.command}`, "muted");
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
printBulletPanel(`${effectivePlan.mode === "install" ? "Install" : "Uninstall"} complete (${effectivePlan.steps.length})`, effectivePlan.steps.map((step) => step.title), "success");
|
|
274
|
+
if (effectivePlan.postInstallConfig.length > 0) {
|
|
275
|
+
printBulletPanel("Next configuration steps", effectivePlan.postInstallConfig, "warning");
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
187
279
|
if (entryAction === "install-project-docs") {
|
|
188
280
|
const config = await loadPackageConfig();
|
|
189
281
|
const projectDocsCatalog = await loadProjectDocsCatalog(config);
|
package/dist/src/lib/ai-libs.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { rm, stat, writeFile
|
|
1
|
+
import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
const ICM_INSTALL_COMMAND = "curl -fsSL https://raw.githubusercontent.com/rtk-ai/icm/main/install.sh | sh";
|
|
6
6
|
const RTK_INSTALL_COMMAND = "curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh";
|
|
7
|
+
const ECC_REPO_URL = "https://github.com/affaan-m/ECC.git";
|
|
8
|
+
const ECC_TEMP_DIR_PREFIX = "ai-tools-ecc-";
|
|
7
9
|
const ICM_MARKER_START = "<!-- icm:start -->";
|
|
8
10
|
const ICM_MARKER_END = "<!-- icm:end -->";
|
|
9
11
|
export function detectSupportedHostOs(platform = process.platform) {
|
|
@@ -165,6 +167,32 @@ function buildIcmUninstallSteps(scope) {
|
|
|
165
167
|
}
|
|
166
168
|
return [];
|
|
167
169
|
}
|
|
170
|
+
function buildEccInstallSteps(agents) {
|
|
171
|
+
const steps = [];
|
|
172
|
+
if (agents.includes("claude")) {
|
|
173
|
+
steps.push({
|
|
174
|
+
id: "ecc-install-claude",
|
|
175
|
+
library: "ecc",
|
|
176
|
+
phase: "install",
|
|
177
|
+
title: "Set up ECC for Claude",
|
|
178
|
+
description: "Clone the upstream ECC repo into a temporary directory, install its dependencies, and run the documented full manual Claude setup.",
|
|
179
|
+
command: "temporary clone of affaan-m/ECC -> npm install -> bash ./install.sh --profile full",
|
|
180
|
+
runner: "setup-ecc-claude"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (agents.includes("codex")) {
|
|
184
|
+
steps.push({
|
|
185
|
+
id: "ecc-install-codex",
|
|
186
|
+
library: "ecc",
|
|
187
|
+
phase: "configure",
|
|
188
|
+
title: "Set up ECC for Codex",
|
|
189
|
+
description: "Clone the upstream ECC repo into a temporary directory, install its dependencies, and run the documented Codex sync script.",
|
|
190
|
+
command: "temporary clone of affaan-m/ECC -> npm install -> bash ./scripts/sync-ecc-to-codex.sh",
|
|
191
|
+
runner: "setup-ecc-codex"
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return steps;
|
|
195
|
+
}
|
|
168
196
|
export function buildLibInstallPlan(input) {
|
|
169
197
|
const agents = uniq(input.agents);
|
|
170
198
|
const libraries = uniq(input.libraries);
|
|
@@ -209,9 +237,22 @@ export function buildLibInstallPlan(input) {
|
|
|
209
237
|
notes.push("ICM local uninstall only strips ICM-managed blocks from project files in the current directory and leaves global ICM config untouched.");
|
|
210
238
|
}
|
|
211
239
|
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (library === "ecc") {
|
|
243
|
+
if (input.mode === "install") {
|
|
244
|
+
steps.push(...buildEccInstallSteps(agents));
|
|
245
|
+
notes.push("ECC install in this CLI clones the upstream repo into a temporary directory and runs the documented repo-based setup flow for each selected agent. It is user-level and not constrained to the selected scope.");
|
|
246
|
+
notes.push("If ECC is already installed in Claude via the upstream plugin path, do not run the full installer again here. Upstream warns that stacking both methods can duplicate skills, commands, and hooks.");
|
|
247
|
+
notes.push("For Codex, this CLI uses the upstream repo-based sync flow (`npm install && bash scripts/sync-ecc-to-codex.sh`) instead of `npx ecc-install`, because the package name and installer binary are published separately (`ecc-universal` vs `ecc-install`).");
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
notes.push("Automatic ECC uninstall is not supported in this CLI. Upstream documents repo-root lifecycle commands such as `node scripts/uninstall.js --dry-run` followed by `node scripts/uninstall.js` for manual cleanup.");
|
|
251
|
+
notes.push("If ECC was installed through the Claude plugin path, remove the plugin first and then delete only the specific ECC rule folders you copied manually.");
|
|
252
|
+
}
|
|
212
253
|
}
|
|
213
254
|
}
|
|
214
|
-
if (input.mode === "install") {
|
|
255
|
+
if (input.mode === "install" && libraries.some((library) => library === "rtk" || library === "icm")) {
|
|
215
256
|
notes.unshift("Binary install still uses the upstream installer and writes to the user's bin directory even when scope is local.");
|
|
216
257
|
}
|
|
217
258
|
if (hostOs && hostOs !== input.os) {
|
|
@@ -245,9 +286,32 @@ export async function executeLibInstallPlan(input) {
|
|
|
245
286
|
await cleanupIcmLocalBlocks(input.cwd);
|
|
246
287
|
continue;
|
|
247
288
|
}
|
|
289
|
+
if (step.runner === "setup-ecc-claude") {
|
|
290
|
+
await runEccRepoSetup("claude", input.cwd);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (step.runner === "setup-ecc-codex") {
|
|
294
|
+
await runEccRepoSetup("codex", input.cwd);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
248
297
|
await runShellCommand(step.command, input.cwd);
|
|
249
298
|
}
|
|
250
299
|
}
|
|
300
|
+
async function runEccRepoSetup(target, cwd) {
|
|
301
|
+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), ECC_TEMP_DIR_PREFIX));
|
|
302
|
+
try {
|
|
303
|
+
await runShellCommand(`git clone --depth 1 ${ECC_REPO_URL} "${tempRoot}"`, cwd);
|
|
304
|
+
await runShellCommand("npm install", tempRoot);
|
|
305
|
+
if (target === "claude") {
|
|
306
|
+
await runShellCommand("bash ./install.sh --profile full", tempRoot);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
await runShellCommand("bash ./scripts/sync-ecc-to-codex.sh", tempRoot);
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
251
315
|
async function removeBinaryAtPath(targetPath) {
|
|
252
316
|
try {
|
|
253
317
|
const info = await stat(targetPath);
|