@buiducnhat/agent-skills 0.4.2 → 0.4.3
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/index.js +41 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs, { existsSync, lstatSync, mkdtempSync, readdirSync } from "node:fs";
|
|
4
|
+
import os, { tmpdir } from "node:os";
|
|
4
5
|
import path, { dirname, join } from "node:path";
|
|
5
6
|
import N, { stdin, stdout } from "node:process";
|
|
6
7
|
import * as k from "node:readline";
|
|
@@ -8,7 +9,6 @@ import ot from "node:readline";
|
|
|
8
9
|
import { ReadStream } from "node:tty";
|
|
9
10
|
import { stripVTControlCharacters } from "node:util";
|
|
10
11
|
import { execSync, spawn } from "node:child_process";
|
|
11
|
-
import { tmpdir } from "node:os";
|
|
12
12
|
|
|
13
13
|
//#region \0rolldown/runtime.js
|
|
14
14
|
var __create = Object.create;
|
|
@@ -2217,7 +2217,7 @@ function injectRules(projectDir, agents, agentsContent) {
|
|
|
2217
2217
|
|
|
2218
2218
|
//#endregion
|
|
2219
2219
|
//#region src/skills.ts
|
|
2220
|
-
async function runSkillsAdd(projectDir, agents, copy = false) {
|
|
2220
|
+
async function runSkillsAdd(projectDir, agents, copy = false, global = false) {
|
|
2221
2221
|
const args = agents.length === 0 ? [
|
|
2222
2222
|
"skills",
|
|
2223
2223
|
"add",
|
|
@@ -2236,6 +2236,7 @@ async function runSkillsAdd(projectDir, agents, copy = false) {
|
|
|
2236
2236
|
"-y"
|
|
2237
2237
|
];
|
|
2238
2238
|
if (copy) args.push("--copy");
|
|
2239
|
+
if (global) args.push("-g");
|
|
2239
2240
|
return new Promise((resolve) => {
|
|
2240
2241
|
const child = spawn("npx", args, {
|
|
2241
2242
|
cwd: projectDir,
|
|
@@ -2257,7 +2258,8 @@ function parseArgs(argv) {
|
|
|
2257
2258
|
nonInteractive: false,
|
|
2258
2259
|
help: false,
|
|
2259
2260
|
version: false,
|
|
2260
|
-
copy: false
|
|
2261
|
+
copy: false,
|
|
2262
|
+
global: false
|
|
2261
2263
|
};
|
|
2262
2264
|
for (let i = 0; i < argv.length; i++) switch (argv[i]) {
|
|
2263
2265
|
case "--non-interactive":
|
|
@@ -2274,6 +2276,10 @@ function parseArgs(argv) {
|
|
|
2274
2276
|
case "--copy":
|
|
2275
2277
|
args.copy = true;
|
|
2276
2278
|
break;
|
|
2279
|
+
case "--global":
|
|
2280
|
+
case "-g":
|
|
2281
|
+
args.global = true;
|
|
2282
|
+
break;
|
|
2277
2283
|
}
|
|
2278
2284
|
return args;
|
|
2279
2285
|
}
|
|
@@ -2316,7 +2322,12 @@ function printHelp() {
|
|
|
2316
2322
|
|
|
2317
2323
|
Options:
|
|
2318
2324
|
--non-interactive Skip interactive prompts (installs all skills to all agents)
|
|
2319
|
-
--copy Copy skill files instead of symlinking
|
|
2325
|
+
--copy Copy skill files instead of symlinking. Use this
|
|
2326
|
+
when your environment doesn’t support symlinks or you
|
|
2327
|
+
prefer independent copies; symlinks are recommended so
|
|
2328
|
+
updates propagate automatically.
|
|
2329
|
+
-g, --global Install skills to user home directory (~/<agent>/skills/)
|
|
2330
|
+
instead of the current project directory.
|
|
2320
2331
|
-h, --help Show this help message
|
|
2321
2332
|
-v, --version Show version
|
|
2322
2333
|
|
|
@@ -2324,6 +2335,8 @@ function printHelp() {
|
|
|
2324
2335
|
npx @buiducnhat/agent-skills
|
|
2325
2336
|
npx @buiducnhat/agent-skills --non-interactive
|
|
2326
2337
|
npx @buiducnhat/agent-skills --copy
|
|
2338
|
+
npx @buiducnhat/agent-skills --global
|
|
2339
|
+
npx @buiducnhat/agent-skills --global --non-interactive
|
|
2327
2340
|
`);
|
|
2328
2341
|
}
|
|
2329
2342
|
function printSummary(agents, results) {
|
|
@@ -2363,21 +2376,23 @@ async function main() {
|
|
|
2363
2376
|
}
|
|
2364
2377
|
We(import_picocolors.default.bold(import_picocolors.default.cyan(" Agent Skills Installer ")));
|
|
2365
2378
|
const cwd = process.cwd();
|
|
2379
|
+
const baseDir = args.global ? os.homedir() : cwd;
|
|
2380
|
+
if (args.global) R.info(`Global mode: installing to ${import_picocolors.default.cyan(os.homedir())}`);
|
|
2366
2381
|
let selectedAgents;
|
|
2367
2382
|
if (args.nonInteractive) {
|
|
2368
2383
|
R.step("Installing skills to all agents (non-interactive)...");
|
|
2369
|
-
if (!(await runSkillsAdd(cwd, [], args.copy)).success) {
|
|
2384
|
+
if (!(await runSkillsAdd(cwd, [], args.copy, args.global)).success) {
|
|
2370
2385
|
Ne(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' --all -y"));
|
|
2371
2386
|
process.exit(1);
|
|
2372
2387
|
}
|
|
2373
|
-
selectedAgents = detectAgentsFromFilesystem(
|
|
2388
|
+
selectedAgents = detectAgentsFromFilesystem(baseDir);
|
|
2374
2389
|
if (selectedAgents.length === 0) {
|
|
2375
2390
|
R.warn("No agents detected from filesystem. Skills may have been installed but rules injection was skipped.");
|
|
2376
2391
|
Le(import_picocolors.default.yellow("Done. No agent rules files were updated."));
|
|
2377
2392
|
process.exit(0);
|
|
2378
2393
|
}
|
|
2379
2394
|
} else {
|
|
2380
|
-
const preSelected = detectAgentsFromFilesystem(
|
|
2395
|
+
const preSelected = detectAgentsFromFilesystem(baseDir);
|
|
2381
2396
|
const selection = await je({
|
|
2382
2397
|
message: "Select agents to install skills for:",
|
|
2383
2398
|
options: SUPPORTED_AGENTS.map((a) => ({
|
|
@@ -2396,8 +2411,24 @@ async function main() {
|
|
|
2396
2411
|
Le(import_picocolors.default.yellow("No agents selected. Nothing to install."));
|
|
2397
2412
|
process.exit(0);
|
|
2398
2413
|
}
|
|
2414
|
+
const installMode = await Je({
|
|
2415
|
+
message: "How should the skills be installed?",
|
|
2416
|
+
options: [{
|
|
2417
|
+
label: "Symlink (recommended)",
|
|
2418
|
+
value: "symlink"
|
|
2419
|
+
}, {
|
|
2420
|
+
label: "Copy",
|
|
2421
|
+
value: "copy"
|
|
2422
|
+
}],
|
|
2423
|
+
initialValue: args.copy ? "copy" : "symlink"
|
|
2424
|
+
});
|
|
2425
|
+
if (Ct$1(installMode)) {
|
|
2426
|
+
Ne("Installation cancelled.");
|
|
2427
|
+
process.exit(0);
|
|
2428
|
+
}
|
|
2429
|
+
const copyFlag = installMode === "copy";
|
|
2399
2430
|
R.step("Installing skills via skills CLI...");
|
|
2400
|
-
if (!(await runSkillsAdd(cwd, selectedAgents, args.
|
|
2431
|
+
if (!(await runSkillsAdd(cwd, selectedAgents, copyFlag, args.global)).success) {
|
|
2401
2432
|
Ne(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' -a <agent> -y"));
|
|
2402
2433
|
process.exit(1);
|
|
2403
2434
|
}
|
|
@@ -2407,8 +2438,8 @@ async function main() {
|
|
|
2407
2438
|
try {
|
|
2408
2439
|
tempDir = await fetchTemplates();
|
|
2409
2440
|
const agentsContent = fs.readFileSync(path.join(tempDir, "templates", "AGENTS.md"), "utf-8");
|
|
2410
|
-
const results = injectRules(
|
|
2411
|
-
copyClaudeTemplate(tempDir,
|
|
2441
|
+
const results = injectRules(baseDir, selectedAgents, agentsContent);
|
|
2442
|
+
copyClaudeTemplate(tempDir, baseDir);
|
|
2412
2443
|
printSummary(selectedAgents, results);
|
|
2413
2444
|
Le(import_picocolors.default.green("Done! Your AI agent skills are ready."));
|
|
2414
2445
|
} catch (err) {
|