@iceinvein/agent-skills 0.1.5 → 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.
- package/dist/cli/index.js +90 -20
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -648,7 +648,48 @@ async function updateSkill(cwd, skillName) {
|
|
|
648
648
|
// src/cli/types.ts
|
|
649
649
|
var TOOL_NAMES2 = ["claude", "cursor", "codex", "gemini"];
|
|
650
650
|
|
|
651
|
+
// src/cli/prompt.ts
|
|
652
|
+
import { createInterface } from "node:readline";
|
|
653
|
+
var rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
654
|
+
function ask(question) {
|
|
655
|
+
return new Promise((resolve) => {
|
|
656
|
+
rl.question(question, (answer) => resolve(answer.trim()));
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
async function promptSelect(message, options) {
|
|
660
|
+
console.log(`
|
|
661
|
+
${message}
|
|
662
|
+
`);
|
|
663
|
+
for (let i = 0;i < options.length; i++) {
|
|
664
|
+
console.log(` ${i + 1}) ${options[i].label}`);
|
|
665
|
+
}
|
|
666
|
+
console.log(` ${options.length + 1}) All of the above`);
|
|
667
|
+
const answer = await ask(`
|
|
668
|
+
Select (comma-separated numbers, e.g. 1,3): `);
|
|
669
|
+
rl.close();
|
|
670
|
+
const nums = answer.split(",").map((s) => parseInt(s.trim(), 10));
|
|
671
|
+
if (nums.includes(options.length + 1)) {
|
|
672
|
+
return options.map((o) => o.value);
|
|
673
|
+
}
|
|
674
|
+
const selected = nums.filter((n) => n >= 1 && n <= options.length).map((n) => options[n - 1].value);
|
|
675
|
+
if (selected.length === 0) {
|
|
676
|
+
console.error("No valid selection. Exiting.");
|
|
677
|
+
process.exit(1);
|
|
678
|
+
}
|
|
679
|
+
return selected;
|
|
680
|
+
}
|
|
681
|
+
|
|
651
682
|
// src/cli/index.ts
|
|
683
|
+
import { mkdirSync as mkdirSync4 } from "fs";
|
|
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"]);
|
|
652
693
|
function parseArgs(argv) {
|
|
653
694
|
if (argv.length === 0)
|
|
654
695
|
return { command: "help", args: [], flags: {} };
|
|
@@ -656,11 +697,19 @@ function parseArgs(argv) {
|
|
|
656
697
|
const args = [];
|
|
657
698
|
const flags = {};
|
|
658
699
|
for (let i = 1;i < argv.length; i++) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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
|
+
}
|
|
662
711
|
} else {
|
|
663
|
-
args.push(
|
|
712
|
+
args.push(arg);
|
|
664
713
|
}
|
|
665
714
|
}
|
|
666
715
|
return { command, args, flags };
|
|
@@ -670,15 +719,15 @@ function printHelp() {
|
|
|
670
719
|
@iceinvein/agent-skills \u2014 Install agent skills into AI coding tools
|
|
671
720
|
|
|
672
721
|
Usage:
|
|
673
|
-
agent-skills install <skill> [--tool <tool>]
|
|
674
|
-
agent-skills remove <skill>
|
|
675
|
-
agent-skills update <skill>
|
|
676
|
-
agent-skills list
|
|
677
|
-
agent-skills info <skill>
|
|
678
|
-
|
|
679
|
-
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
|
|
680
727
|
|
|
681
|
-
|
|
728
|
+
Flags:
|
|
729
|
+
--tool <tool> Install for a specific tool (${TOOL_NAMES2.join(", ")})
|
|
730
|
+
-g, --global Install to home directory (available in all projects)
|
|
682
731
|
`);
|
|
683
732
|
}
|
|
684
733
|
function printInstalled(result, skipped) {
|
|
@@ -701,6 +750,10 @@ async function main() {
|
|
|
701
750
|
console.error("Error: skill name required. Usage: agent-skills install <skill>");
|
|
702
751
|
process.exit(1);
|
|
703
752
|
}
|
|
753
|
+
const installDir = resolveInstallDir(flags);
|
|
754
|
+
const isGlobal = installDir === homedir();
|
|
755
|
+
if (isGlobal)
|
|
756
|
+
console.log(`Installing globally to ${installDir}`);
|
|
704
757
|
console.log(`Fetching skill '${skillName}'...`);
|
|
705
758
|
const manifestResult = await fetchSkillManifest(skillName);
|
|
706
759
|
if (!manifestResult.ok) {
|
|
@@ -720,20 +773,35 @@ async function main() {
|
|
|
720
773
|
}
|
|
721
774
|
tools = [flags.tool];
|
|
722
775
|
} else {
|
|
723
|
-
tools = await detectTools(
|
|
776
|
+
tools = await detectTools(installDir);
|
|
724
777
|
if (tools.length === 0) {
|
|
725
|
-
|
|
726
|
-
|
|
778
|
+
const supportedTools = manifestResult.manifest.tools;
|
|
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) => ({
|
|
780
|
+
label: { claude: "Claude Code", cursor: "Cursor", codex: "Codex", gemini: "Gemini CLI" }[t],
|
|
781
|
+
value: t
|
|
782
|
+
})));
|
|
783
|
+
tools = selected;
|
|
784
|
+
for (const tool of tools) {
|
|
785
|
+
const dirs = {
|
|
786
|
+
claude: ".claude",
|
|
787
|
+
cursor: ".cursor",
|
|
788
|
+
gemini: ".gemini"
|
|
789
|
+
};
|
|
790
|
+
if (dirs[tool]) {
|
|
791
|
+
mkdirSync4(join7(installDir, dirs[tool]), { recursive: true });
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
} else {
|
|
795
|
+
console.log(`Detected tools: ${tools.join(", ")}`);
|
|
727
796
|
}
|
|
728
|
-
console.log(`Detected tools: ${tools.join(", ")}`);
|
|
729
797
|
}
|
|
730
|
-
const result = await installSkill(
|
|
798
|
+
const result = await installSkill(installDir, manifestResult.manifest, filesResult, tools);
|
|
731
799
|
if (!result.ok) {
|
|
732
800
|
console.error(`Error: ${result.error}`);
|
|
733
801
|
process.exit(1);
|
|
734
802
|
}
|
|
735
803
|
console.log(`
|
|
736
|
-
\u2713 Installed '${skillName}' v${manifestResult.manifest.version}:`);
|
|
804
|
+
\u2713 Installed '${skillName}' v${manifestResult.manifest.version}${isGlobal ? " (global)" : ""}:`);
|
|
737
805
|
printInstalled(result.installed, result.skipped);
|
|
738
806
|
break;
|
|
739
807
|
}
|
|
@@ -743,7 +811,8 @@ async function main() {
|
|
|
743
811
|
console.error("Error: skill name required. Usage: agent-skills remove <skill>");
|
|
744
812
|
process.exit(1);
|
|
745
813
|
}
|
|
746
|
-
const
|
|
814
|
+
const removeDir = resolveInstallDir(flags);
|
|
815
|
+
const result = await removeSkill(removeDir, skillName);
|
|
747
816
|
if (!result.ok) {
|
|
748
817
|
console.error(`Error: ${result.error}`);
|
|
749
818
|
process.exit(1);
|
|
@@ -757,8 +826,9 @@ async function main() {
|
|
|
757
826
|
console.error("Error: skill name required. Usage: agent-skills update <skill>");
|
|
758
827
|
process.exit(1);
|
|
759
828
|
}
|
|
829
|
+
const updateDir = resolveInstallDir(flags);
|
|
760
830
|
console.log(`Updating '${skillName}'...`);
|
|
761
|
-
const result = await updateSkill(
|
|
831
|
+
const result = await updateSkill(updateDir, skillName);
|
|
762
832
|
if (!result.ok) {
|
|
763
833
|
console.error(`Error: ${result.error}`);
|
|
764
834
|
process.exit(1);
|