mudra-skills 1.0.2 → 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/bin/install.js +7 -13
- 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/bin/install.js
CHANGED
|
@@ -15,10 +15,10 @@ const MARKETPLACE = 'mudra-band';
|
|
|
15
15
|
const PLUGIN_NAME = 'mudra';
|
|
16
16
|
const PLUGIN_KEY = `${PLUGIN_NAME}@${MARKETPLACE}`;
|
|
17
17
|
|
|
18
|
-
// Install to
|
|
19
|
-
const
|
|
20
|
-
fs.mkdirSync(
|
|
21
|
-
execSync(`cp -r "${pluginSrc}/." "${
|
|
18
|
+
// Install to top-level plugins directory (Claude Code scans here directly)
|
|
19
|
+
const target = path.join(pluginsDir, PLUGIN_NAME);
|
|
20
|
+
fs.mkdirSync(target, { recursive: true });
|
|
21
|
+
execSync(`cp -r "${pluginSrc}/." "${target}"`);
|
|
22
22
|
|
|
23
23
|
// Register the marketplace in known_marketplaces.json if not already there
|
|
24
24
|
const marketplacesFile = path.join(pluginsDir, 'known_marketplaces.json');
|
|
@@ -38,7 +38,7 @@ if (!marketplaces[MARKETPLACE]) {
|
|
|
38
38
|
fs.writeFileSync(marketplacesFile, JSON.stringify(marketplaces, null, 2));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// Register the plugin in installed_plugins.json
|
|
41
|
+
// Register the plugin in installed_plugins.json with the correct marketplace key
|
|
42
42
|
const installedFile = path.join(pluginsDir, 'installed_plugins.json');
|
|
43
43
|
let installed = { version: 2, plugins: {} };
|
|
44
44
|
if (fs.existsSync(installedFile)) {
|
|
@@ -53,7 +53,7 @@ const previousInstall = installed.plugins[PLUGIN_KEY]?.[0];
|
|
|
53
53
|
installed.plugins[PLUGIN_KEY] = [
|
|
54
54
|
{
|
|
55
55
|
scope: 'user',
|
|
56
|
-
installPath:
|
|
56
|
+
installPath: target,
|
|
57
57
|
version,
|
|
58
58
|
installedAt: previousInstall?.installedAt ?? now,
|
|
59
59
|
lastUpdated: now,
|
|
@@ -62,12 +62,6 @@ installed.plugins[PLUGIN_KEY] = [
|
|
|
62
62
|
|
|
63
63
|
fs.writeFileSync(installedFile, JSON.stringify(installed, null, 2));
|
|
64
64
|
|
|
65
|
-
// Clean up the old direct-copy install location if it exists
|
|
66
|
-
const oldTarget = path.join(pluginsDir, 'mudra');
|
|
67
|
-
if (fs.existsSync(oldTarget)) {
|
|
68
|
-
fs.rmSync(oldTarget, { recursive: true, force: true });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
65
|
console.log('');
|
|
72
66
|
console.log('Mudra skills installed successfully!');
|
|
73
67
|
console.log('');
|
|
@@ -78,4 +72,4 @@ console.log(' /mudra:mudra-master — auto-classify and route');
|
|
|
78
72
|
console.log(' /mudra:mudra-preview — generate 2D app');
|
|
79
73
|
console.log(' /mudra:mudra-xr — generate 3D/XR app');
|
|
80
74
|
console.log('');
|
|
81
|
-
console.log(`Plugin location: ${
|
|
75
|
+
console.log(`Plugin location: ${target}`);
|
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",
|