skilldotmd 0.1.0 → 0.1.1

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/package.json +2 -2
  2. package/src/index.js +45 -11
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "skilldotmd",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Teach your AI any library. Install skills for Claude Code, Cursor, Windsurf and more.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "skilldotmd": "src/index.js"
7
+ "skilldotmd": "./src/index.js"
8
8
  },
9
9
  "keywords": [
10
10
  "claude",
package/src/index.js CHANGED
@@ -3,11 +3,10 @@
3
3
  import { intro, outro, select, text, spinner } from "@clack/prompts"
4
4
  import { Command } from "commander"
5
5
  import pc from "picocolors"
6
- import { execSync } from "child_process"
7
6
  import fs from "fs"
8
7
  import path from "path"
9
8
 
10
- const VERSION = "0.1.0"
9
+ const VERSION = "0.2.0"
11
10
 
12
11
  const TOOLS = {
13
12
  claude: { label: "Claude Code", projectPath: ".claude/skills" },
@@ -34,6 +33,34 @@ function detectTool() {
34
33
  return null
35
34
  }
36
35
 
36
+ function parseSkillPath(input) {
37
+ const parts = input.split("/")
38
+ if (parts.length < 3) return null
39
+ const owner = parts[0]
40
+ const repo = parts[1]
41
+ const skillPath = parts.slice(2).join("/")
42
+ const skillName = parts[parts.length - 1]
43
+ return { owner, repo, skillPath, skillName }
44
+ }
45
+
46
+ async function downloadSkill(parsed) {
47
+ const branches = ["main", "master"]
48
+ for (const branch of branches) {
49
+ const url = `https://raw.githubusercontent.com/${parsed.owner}/${parsed.repo}/${branch}/${parsed.skillPath}/SKILL.md`
50
+ const res = await fetch(url)
51
+ if (res.ok) return await res.text()
52
+ }
53
+ throw new Error(`Skill not found at ${parsed.owner}/${parsed.repo}/${parsed.skillPath}`)
54
+ }
55
+
56
+ function installSkill(tool, skillName, content) {
57
+ const cwd = process.cwd()
58
+ const targetDir = path.join(cwd, TOOLS[tool].projectPath, skillName)
59
+ fs.mkdirSync(targetDir, { recursive: true })
60
+ fs.writeFileSync(path.join(targetDir, "SKILL.md"), content)
61
+ return targetDir
62
+ }
63
+
37
64
  const program = new Command()
38
65
 
39
66
  program
@@ -49,17 +76,23 @@ program
49
76
  printBanner()
50
77
  intro(pc.bold("Add a skill"))
51
78
 
52
- let skillPath = skill
79
+ let skillInput = skill
53
80
 
54
- if (!skillPath) {
55
- skillPath = await text({
81
+ if (!skillInput) {
82
+ skillInput = await text({
56
83
  message: "Which skill do you want to install?",
57
- placeholder: "imPiyushkashyap/SkillDotMD-Library/groq",
84
+ placeholder: "imPiyushkashyap/SkillDotMD-Library/generated/firecrawl",
58
85
  validate(value) {
59
86
  if (!value) return "Please enter a skill path"
60
87
  },
61
88
  })
62
- if (typeof skillPath === "symbol") process.exit(0)
89
+ if (typeof skillInput === "symbol") process.exit(0)
90
+ }
91
+
92
+ const parsed = parseSkillPath(skillInput)
93
+ if (!parsed) {
94
+ outro(pc.red("✗ Invalid skill path. Use: owner/repo/path/to/skill"))
95
+ process.exit(1)
63
96
  }
64
97
 
65
98
  let tool = options.for
@@ -78,13 +111,14 @@ program
78
111
  }
79
112
 
80
113
  const s = spinner()
81
- s.start(`Installing ${pc.cyan(skillPath)}`)
114
+ s.start(`Downloading ${pc.cyan(parsed.skillName)} skill`)
82
115
 
83
116
  try {
84
- execSync(`npx skills add ${skillPath}`, { stdio: "pipe" })
85
- s.stop(`${pc.green("✓")} Installed ${pc.cyan(skillPath)}`)
117
+ const content = await downloadSkill(parsed)
118
+ const installDir = installSkill(tool, parsed.skillName, content)
119
+ s.stop(`${pc.green("✓")} Installed ${pc.cyan(parsed.skillName)} to ${pc.dim(installDir)}`)
86
120
  } catch (err) {
87
- s.stop(`${pc.red("✗")} Failed to install skill`)
121
+ s.stop(`${pc.red("✗")} ${err.message}`)
88
122
  process.exit(1)
89
123
  }
90
124