mudra-skills 1.0.3 → 1.0.4
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/bin/cli.js +131 -0
- package/package.json +2 -2
package/bin/cli.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
10
|
+
const SKILLS_DIR = path.join(homeDir, '.claude', 'skills');
|
|
11
|
+
|
|
12
|
+
const [,, command, ...args] = process.argv;
|
|
13
|
+
|
|
14
|
+
switch (command ?? 'add') {
|
|
15
|
+
case 'add': await add(args[0]); break;
|
|
16
|
+
case 'remove':
|
|
17
|
+
case 'rm': remove(args[0]); break;
|
|
18
|
+
case 'list':
|
|
19
|
+
case 'ls': list(); break;
|
|
20
|
+
default: printHelp(); break;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function add(source) {
|
|
24
|
+
let skillsSource;
|
|
25
|
+
let tmpDir;
|
|
26
|
+
|
|
27
|
+
if (!source) {
|
|
28
|
+
skillsSource = path.resolve(__dirname, '..', 'skills');
|
|
29
|
+
} else if (/^https?:\/\/|^git@/.test(source)) {
|
|
30
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mudra-skills-'));
|
|
31
|
+
console.log(`Fetching ${source}...`);
|
|
32
|
+
try {
|
|
33
|
+
execSync(`git clone --depth 1 "${source}" "${tmpDir}"`, { stdio: 'inherit' });
|
|
34
|
+
} catch {
|
|
35
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
36
|
+
console.error('git clone failed — is git installed and the URL reachable?');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const nested = path.join(tmpDir, 'skills');
|
|
40
|
+
skillsSource = fs.existsSync(nested) ? nested : tmpDir;
|
|
41
|
+
} else {
|
|
42
|
+
skillsSource = path.resolve(source);
|
|
43
|
+
if (!fs.existsSync(skillsSource)) {
|
|
44
|
+
console.error(`Path not found: ${skillsSource}`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
copySkills(skillsSource);
|
|
51
|
+
} finally {
|
|
52
|
+
if (tmpDir) fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function copySkills(skillsSource) {
|
|
57
|
+
if (!fs.existsSync(skillsSource)) {
|
|
58
|
+
console.error(`No skills directory found at: ${skillsSource}`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const entries = fs.readdirSync(skillsSource, { withFileTypes: true })
|
|
63
|
+
.filter(e => e.isDirectory() && !e.name.startsWith('.'));
|
|
64
|
+
|
|
65
|
+
if (entries.length === 0) {
|
|
66
|
+
console.error('No skill folders found.');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fs.mkdirSync(SKILLS_DIR, { recursive: true });
|
|
71
|
+
|
|
72
|
+
const installed = [];
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
const src = path.join(skillsSource, entry.name);
|
|
75
|
+
const skillFile = path.join(src, 'SKILL.md');
|
|
76
|
+
if (!fs.existsSync(skillFile)) continue;
|
|
77
|
+
|
|
78
|
+
const dest = path.join(SKILLS_DIR, entry.name);
|
|
79
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
80
|
+
execSync(`cp -r "${src}/." "${dest}"`);
|
|
81
|
+
installed.push(entry.name);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (installed.length === 0) {
|
|
85
|
+
console.error('No valid skills found (each skill needs a SKILL.md).');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(`Installed ${installed.length} skill(s) to ${SKILLS_DIR}`);
|
|
91
|
+
for (const name of installed) console.log(` ✓ ${name}`);
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log('Restart Claude Code (or run /reload-skills) to activate.');
|
|
94
|
+
console.log('');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function remove(skillName) {
|
|
98
|
+
if (!skillName) { console.error('Usage: mudra-skills remove <skill-name>'); process.exit(1); }
|
|
99
|
+
const target = path.join(SKILLS_DIR, skillName);
|
|
100
|
+
if (!fs.existsSync(target)) {
|
|
101
|
+
console.error(`Skill not found: ${skillName}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
105
|
+
console.log(`Removed skill: ${skillName}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function list() {
|
|
109
|
+
if (!fs.existsSync(SKILLS_DIR)) {
|
|
110
|
+
console.log('No skills installed yet.');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const skills = fs.readdirSync(SKILLS_DIR, { withFileTypes: true })
|
|
114
|
+
.filter(e => e.isDirectory() && !e.name.startsWith('.') && fs.existsSync(path.join(SKILLS_DIR, e.name, 'SKILL.md')));
|
|
115
|
+
|
|
116
|
+
if (skills.length === 0) {
|
|
117
|
+
console.log('No skills installed yet.');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
console.log(`Skills in ${SKILLS_DIR}:`);
|
|
121
|
+
for (const s of skills) console.log(` ${s.name}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function printHelp() {
|
|
125
|
+
console.log(`
|
|
126
|
+
Usage:
|
|
127
|
+
npx mudra-skills add [<github-url>] Install skills (default: bundled)
|
|
128
|
+
npx mudra-skills remove <name> Remove a skill
|
|
129
|
+
npx mudra-skills list List installed skills
|
|
130
|
+
`);
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mudra-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Claude Code skills for building Mudra Band apps — 2D, 3D/XR, or auto-classified",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"mudra-skills": "bin/
|
|
7
|
+
"mudra-skills": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Wearable Devices",
|