@buiducnhat/agent-skills 0.4.2 → 0.5.0

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -34
  2. 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;
@@ -2064,7 +2064,7 @@ const SUPPORTED_AGENTS = [
2064
2064
  const AGENT_SKILLS_DIRS = {
2065
2065
  ".adal": "adal",
2066
2066
  ".agent": "antigravity",
2067
- ".agents": "amp",
2067
+ ".agents": "opencode",
2068
2068
  ".augment": "augment",
2069
2069
  ".claude": "claude-code",
2070
2070
  ".codebuddy": "codebuddy",
@@ -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
  }
@@ -2285,29 +2291,6 @@ function detectAgentsFromFilesystem(projectDir) {
2285
2291
  }
2286
2292
  return detected;
2287
2293
  }
2288
- function copyDirectory(src, dest) {
2289
- fs.mkdirSync(dest, { recursive: true });
2290
- const entries = fs.readdirSync(src, { withFileTypes: true });
2291
- for (const entry of entries) {
2292
- const srcPath = path.join(src, entry.name);
2293
- const destPath = path.join(dest, entry.name);
2294
- if (entry.isDirectory()) copyDirectory(srcPath, destPath);
2295
- else fs.copyFileSync(srcPath, destPath);
2296
- }
2297
- }
2298
- function copyClaudeTemplate(tempDir, projectDir) {
2299
- const srcClaude = path.join(tempDir, "templates", ".claude");
2300
- const destClaude = path.join(projectDir, ".claude");
2301
- if (!fs.existsSync(srcClaude)) return;
2302
- fs.mkdirSync(destClaude, { recursive: true });
2303
- for (const entry of fs.readdirSync(srcClaude, { withFileTypes: true })) {
2304
- if (entry.name === "skills") continue;
2305
- const src = path.join(srcClaude, entry.name);
2306
- const dest = path.join(destClaude, entry.name);
2307
- if (entry.isDirectory()) copyDirectory(src, dest);
2308
- else fs.copyFileSync(src, dest);
2309
- }
2310
- }
2311
2294
  function printHelp() {
2312
2295
  console.log(`
2313
2296
  @buiducnhat/agent-skills - Install AI agent workflow skills for coding assistants
@@ -2316,7 +2299,12 @@ function printHelp() {
2316
2299
 
2317
2300
  Options:
2318
2301
  --non-interactive Skip interactive prompts (installs all skills to all agents)
2319
- --copy Copy skill files instead of symlinking
2302
+ --copy Copy skill files instead of symlinking. Use this
2303
+ when your environment doesn’t support symlinks or you
2304
+ prefer independent copies; symlinks are recommended so
2305
+ updates propagate automatically.
2306
+ -g, --global Install skills to user home directory (~/<agent>/skills/)
2307
+ instead of the current project directory.
2320
2308
  -h, --help Show this help message
2321
2309
  -v, --version Show version
2322
2310
 
@@ -2324,6 +2312,8 @@ function printHelp() {
2324
2312
  npx @buiducnhat/agent-skills
2325
2313
  npx @buiducnhat/agent-skills --non-interactive
2326
2314
  npx @buiducnhat/agent-skills --copy
2315
+ npx @buiducnhat/agent-skills --global
2316
+ npx @buiducnhat/agent-skills --global --non-interactive
2327
2317
  `);
2328
2318
  }
2329
2319
  function printSummary(agents, results) {
@@ -2363,21 +2353,23 @@ async function main() {
2363
2353
  }
2364
2354
  We(import_picocolors.default.bold(import_picocolors.default.cyan(" Agent Skills Installer ")));
2365
2355
  const cwd = process.cwd();
2356
+ const baseDir = args.global ? os.homedir() : cwd;
2357
+ if (args.global) R.info(`Global mode: installing to ${import_picocolors.default.cyan(os.homedir())}`);
2366
2358
  let selectedAgents;
2367
2359
  if (args.nonInteractive) {
2368
2360
  R.step("Installing skills to all agents (non-interactive)...");
2369
- if (!(await runSkillsAdd(cwd, [], args.copy)).success) {
2361
+ if (!(await runSkillsAdd(cwd, [], args.copy, args.global)).success) {
2370
2362
  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
2363
  process.exit(1);
2372
2364
  }
2373
- selectedAgents = detectAgentsFromFilesystem(cwd);
2365
+ selectedAgents = detectAgentsFromFilesystem(baseDir);
2374
2366
  if (selectedAgents.length === 0) {
2375
2367
  R.warn("No agents detected from filesystem. Skills may have been installed but rules injection was skipped.");
2376
2368
  Le(import_picocolors.default.yellow("Done. No agent rules files were updated."));
2377
2369
  process.exit(0);
2378
2370
  }
2379
2371
  } else {
2380
- const preSelected = detectAgentsFromFilesystem(cwd);
2372
+ const preSelected = detectAgentsFromFilesystem(baseDir);
2381
2373
  const selection = await je({
2382
2374
  message: "Select agents to install skills for:",
2383
2375
  options: SUPPORTED_AGENTS.map((a) => ({
@@ -2396,8 +2388,24 @@ async function main() {
2396
2388
  Le(import_picocolors.default.yellow("No agents selected. Nothing to install."));
2397
2389
  process.exit(0);
2398
2390
  }
2391
+ const installMode = await Je({
2392
+ message: "How should the skills be installed?",
2393
+ options: [{
2394
+ label: "Symlink (recommended)",
2395
+ value: "symlink"
2396
+ }, {
2397
+ label: "Copy",
2398
+ value: "copy"
2399
+ }],
2400
+ initialValue: args.copy ? "copy" : "symlink"
2401
+ });
2402
+ if (Ct$1(installMode)) {
2403
+ Ne("Installation cancelled.");
2404
+ process.exit(0);
2405
+ }
2406
+ const copyFlag = installMode === "copy";
2399
2407
  R.step("Installing skills via skills CLI...");
2400
- if (!(await runSkillsAdd(cwd, selectedAgents, args.copy)).success) {
2408
+ if (!(await runSkillsAdd(cwd, selectedAgents, copyFlag, args.global)).success) {
2401
2409
  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
2410
  process.exit(1);
2403
2411
  }
@@ -2407,8 +2415,7 @@ async function main() {
2407
2415
  try {
2408
2416
  tempDir = await fetchTemplates();
2409
2417
  const agentsContent = fs.readFileSync(path.join(tempDir, "templates", "AGENTS.md"), "utf-8");
2410
- const results = injectRules(cwd, selectedAgents, agentsContent);
2411
- copyClaudeTemplate(tempDir, cwd);
2418
+ const results = injectRules(baseDir, selectedAgents, agentsContent);
2412
2419
  printSummary(selectedAgents, results);
2413
2420
  Le(import_picocolors.default.green("Done! Your AI agent skills are ready."));
2414
2421
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buiducnhat/agent-skills",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Install AI agent workflow skills for coding assistants",
5
5
  "type": "module",
6
6
  "bin": {