@pigcloud/skills 1.0.9 → 1.0.11

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/bin/cli.js +37 -46
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -69,15 +69,21 @@ const TOOL_CONFIGS = {
69
69
  windsurf: { dir: '.', rootFile: '.windsurfrules', markers: ['.windsurfrules'] }
70
70
  };
71
71
 
72
- function colorize(code, text) {
73
- const value = String(text);
74
- if (!process.stdout.isTTY) return value;
75
- return `${code}${value}${COLORS.reset}`;
76
- }
77
-
78
- function normalizeSkillName(skill) {
79
- return String(skill || '').trim();
80
- }
72
+ function colorize(code, text) {
73
+ const value = String(text);
74
+ if (!process.stdout.isTTY) return value;
75
+ return `${code}${value}${COLORS.reset}`;
76
+ }
77
+
78
+ function commandAvailable(command) {
79
+ const { spawnSync } = require('child_process');
80
+ const result = spawnSync(command, ['--version'], { stdio: 'ignore' });
81
+ return !result.error && result.status === 0;
82
+ }
83
+
84
+ function normalizeSkillName(skill) {
85
+ return String(skill || '').trim();
86
+ }
81
87
 
82
88
  function normalizeToolName(tool) {
83
89
  if (!tool) return null;
@@ -462,27 +468,18 @@ function printHelp() {
462
468
  console.log(' pig-skills update [--tool codex]');
463
469
  }
464
470
 
465
- async function ensureRuntimeForInstall() {
466
- if (!commandAvailable('npm')) {
467
- throw new Error('npm is not available. Install Node.js LTS first, then rerun the command.');
468
- }
469
-
470
- return { installed: false, skipped: false, npmPath: 'npm' };
471
- }
472
-
473
- async function run() {
474
- const { options, positionals } = parseArgs(process.argv.slice(2));
475
- const command = positionals[0];
471
+ async function run() {
472
+ const { options, positionals } = parseArgs(process.argv.slice(2));
473
+ const command = positionals[0];
476
474
 
477
475
  if (!command) {
478
476
  printHelp();
479
477
  return;
480
478
  }
481
479
 
482
- if (command === 'init') {
483
- const skills = getSelectedSkills(options.skills, options.all || !options.skills);
484
- try {
485
- await ensureRuntimeForInstall();
480
+ if (command === 'init') {
481
+ const skills = getSelectedSkills(options.skills, options.all || !options.skills);
482
+ try {
486
483
  const tools = resolveRequestedTools(options.tool);
487
484
  await installSkillsForTools(skills, tools, getInstallRoot(), { resetCodexNamespace: true });
488
485
  console.log(chalk.green(`Installed ${skills.length} skills for ${tools.join(', ')}`));
@@ -493,10 +490,9 @@ async function run() {
493
490
  return;
494
491
  }
495
492
 
496
- if (command === 'auto') {
497
- const skills = getSelectedSkills(options.skills, options.all || !options.skills);
498
- try {
499
- await ensureRuntimeForInstall();
493
+ if (command === 'auto') {
494
+ const skills = getSelectedSkills(options.skills, options.all || !options.skills);
495
+ try {
500
496
  const tools = resolveRequestedTools('auto');
501
497
  await installSkillsForTools(skills, tools, getInstallRoot(), { resetCodexNamespace: true });
502
498
  console.log(chalk.green(`Auto-installed ${skills.length} skills for ${tools.join(', ')}`));
@@ -507,13 +503,12 @@ async function run() {
507
503
  return;
508
504
  }
509
505
 
510
- if (command === 'codex') {
511
- const skills = getSelectedSkills(options.skills, options.all || !options.skills);
512
- try {
513
- await ensureRuntimeForInstall();
506
+ if (command === 'codex') {
507
+ const skills = getSelectedSkills(options.skills, options.all || !options.skills);
508
+ try {
514
509
  await installSkills(skills, 'codex', getInstallRoot(), { resetCodexNamespace: true });
515
510
  console.log(chalk.green(`Synced ${skills.length} skills into Codex`));
516
- console.log(chalk.green(`Installed Codex command pack: ${COMMAND_PACK_NAME}`));
511
+ console.log(chalk.green(`Installed Codex command pack: ${COMMAND_PACK_NAME}`));
517
512
  } catch (error) {
518
513
  console.error(chalk.red(error.message));
519
514
  process.exitCode = 1;
@@ -547,19 +542,15 @@ async function run() {
547
542
  return;
548
543
  }
549
544
 
550
- if (command === 'bootstrap') {
551
- try {
552
- const result = await ensureRuntimeForInstall();
553
- if (result.skipped) {
554
- console.log(chalk.yellow('Runtime bootstrap skipped by PIG_SKILLS_SKIP_RUNTIME_BOOTSTRAP.'));
555
- } else if (result.installed) {
556
- console.log(chalk.green('Node.js/npm runtime is ready.'));
557
- } else {
558
- console.log(chalk.green('Node.js/npm runtime is already available.'));
559
- }
560
- } catch (error) {
561
- console.error(chalk.red(error.message));
562
- process.exitCode = 1;
545
+ if (command === 'bootstrap') {
546
+ try {
547
+ if (!commandAvailable('npm')) {
548
+ throw new Error('npm is not available. Install Node.js LTS first, then rerun the command.');
549
+ }
550
+ console.log(chalk.green('Node.js/npm runtime is already available.'));
551
+ } catch (error) {
552
+ console.error(chalk.red(error.message));
553
+ process.exitCode = 1;
563
554
  }
564
555
  return;
565
556
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pigcloud/skills",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "面向 Codex、Trae 和 Claude Code 的 AI 技能包,提供共享技能、规则约束、工作流路由和 Pig Cloud 专属覆盖层。",
5
5
  "author": "Pig Skills Maintainers",
6
6
  "license": "MIT",