@iceinvein/agent-skills 0.1.6 → 0.1.7

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/cli/index.js +41 -19
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -682,6 +682,14 @@ Select (comma-separated numbers, e.g. 1,3): `);
682
682
  // src/cli/index.ts
683
683
  import { mkdirSync as mkdirSync4 } from "fs";
684
684
  import { join as join7 } from "path";
685
+ import { homedir } from "os";
686
+ function resolveInstallDir(flags) {
687
+ if (flags.global !== undefined || flags.g !== undefined) {
688
+ return homedir();
689
+ }
690
+ return process.cwd();
691
+ }
692
+ var BOOLEAN_FLAGS = new Set(["global", "g"]);
685
693
  function parseArgs(argv) {
686
694
  if (argv.length === 0)
687
695
  return { command: "help", args: [], flags: {} };
@@ -689,11 +697,19 @@ function parseArgs(argv) {
689
697
  const args = [];
690
698
  const flags = {};
691
699
  for (let i = 1;i < argv.length; i++) {
692
- if (argv[i].startsWith("--") && i + 1 < argv.length) {
693
- flags[argv[i].slice(2)] = argv[i + 1];
694
- i++;
700
+ const arg = argv[i];
701
+ if (arg === "-g") {
702
+ flags.global = "true";
703
+ } else if (arg.startsWith("--")) {
704
+ const key = arg.slice(2);
705
+ if (BOOLEAN_FLAGS.has(key)) {
706
+ flags[key] = "true";
707
+ } else if (i + 1 < argv.length) {
708
+ flags[key] = argv[i + 1];
709
+ i++;
710
+ }
695
711
  } else {
696
- args.push(argv[i]);
712
+ args.push(arg);
697
713
  }
698
714
  }
699
715
  return { command, args, flags };
@@ -703,15 +719,15 @@ function printHelp() {
703
719
  @iceinvein/agent-skills \u2014 Install agent skills into AI coding tools
704
720
 
705
721
  Usage:
706
- agent-skills install <skill> [--tool <tool>] Install a skill
707
- agent-skills remove <skill> Remove a skill
708
- agent-skills update <skill> Update a skill
709
- agent-skills list List available skills
710
- agent-skills info <skill> Show skill details
711
-
712
- Tools: ${TOOL_NAMES2.join(", ")}
722
+ agent-skills install <skill> [--tool <tool>] [-g] Install a skill
723
+ agent-skills remove <skill> [-g] Remove a skill
724
+ agent-skills update <skill> [-g] Update a skill
725
+ agent-skills list List available skills
726
+ agent-skills info <skill> Show skill details
713
727
 
714
- If --tool is omitted, auto-detects tools in the current directory.
728
+ Flags:
729
+ --tool <tool> Install for a specific tool (${TOOL_NAMES2.join(", ")})
730
+ -g, --global Install to home directory (available in all projects)
715
731
  `);
716
732
  }
717
733
  function printInstalled(result, skipped) {
@@ -734,6 +750,10 @@ async function main() {
734
750
  console.error("Error: skill name required. Usage: agent-skills install <skill>");
735
751
  process.exit(1);
736
752
  }
753
+ const installDir = resolveInstallDir(flags);
754
+ const isGlobal = installDir === homedir();
755
+ if (isGlobal)
756
+ console.log(`Installing globally to ${installDir}`);
737
757
  console.log(`Fetching skill '${skillName}'...`);
738
758
  const manifestResult = await fetchSkillManifest(skillName);
739
759
  if (!manifestResult.ok) {
@@ -753,10 +773,10 @@ async function main() {
753
773
  }
754
774
  tools = [flags.tool];
755
775
  } else {
756
- tools = await detectTools(process.cwd());
776
+ tools = await detectTools(installDir);
757
777
  if (tools.length === 0) {
758
778
  const supportedTools = manifestResult.manifest.tools;
759
- const selected = await promptSelect("No tools detected in this directory. Which tools do you use?", supportedTools.map((t) => ({
779
+ const selected = await promptSelect(isGlobal ? "Which tools do you use?" : "No tools detected in this directory. Which tools do you use?", supportedTools.map((t) => ({
760
780
  label: { claude: "Claude Code", cursor: "Cursor", codex: "Codex", gemini: "Gemini CLI" }[t],
761
781
  value: t
762
782
  })));
@@ -768,20 +788,20 @@ async function main() {
768
788
  gemini: ".gemini"
769
789
  };
770
790
  if (dirs[tool]) {
771
- mkdirSync4(join7(process.cwd(), dirs[tool]), { recursive: true });
791
+ mkdirSync4(join7(installDir, dirs[tool]), { recursive: true });
772
792
  }
773
793
  }
774
794
  } else {
775
795
  console.log(`Detected tools: ${tools.join(", ")}`);
776
796
  }
777
797
  }
778
- const result = await installSkill(process.cwd(), manifestResult.manifest, filesResult, tools);
798
+ const result = await installSkill(installDir, manifestResult.manifest, filesResult, tools);
779
799
  if (!result.ok) {
780
800
  console.error(`Error: ${result.error}`);
781
801
  process.exit(1);
782
802
  }
783
803
  console.log(`
784
- \u2713 Installed '${skillName}' v${manifestResult.manifest.version}:`);
804
+ \u2713 Installed '${skillName}' v${manifestResult.manifest.version}${isGlobal ? " (global)" : ""}:`);
785
805
  printInstalled(result.installed, result.skipped);
786
806
  break;
787
807
  }
@@ -791,7 +811,8 @@ async function main() {
791
811
  console.error("Error: skill name required. Usage: agent-skills remove <skill>");
792
812
  process.exit(1);
793
813
  }
794
- const result = await removeSkill(process.cwd(), skillName);
814
+ const removeDir = resolveInstallDir(flags);
815
+ const result = await removeSkill(removeDir, skillName);
795
816
  if (!result.ok) {
796
817
  console.error(`Error: ${result.error}`);
797
818
  process.exit(1);
@@ -805,8 +826,9 @@ async function main() {
805
826
  console.error("Error: skill name required. Usage: agent-skills update <skill>");
806
827
  process.exit(1);
807
828
  }
829
+ const updateDir = resolveInstallDir(flags);
808
830
  console.log(`Updating '${skillName}'...`);
809
- const result = await updateSkill(process.cwd(), skillName);
831
+ const result = await updateSkill(updateDir, skillName);
810
832
  if (!result.ok) {
811
833
  console.error(`Error: ${result.error}`);
812
834
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iceinvein/agent-skills",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Install agent skills into AI coding tools",
5
5
  "author": "iceinvein",
6
6
  "license": "MIT",