rolecraft 0.1.0
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/LICENSE +21 -0
- package/README.md +124 -0
- package/bin/rolecraft.js +98 -0
- package/bin/rolecraft.test.js +174 -0
- package/package.json +45 -0
- package/src/commands/install.js +55 -0
- package/src/commands/install.test.js +90 -0
- package/src/commands/list.js +26 -0
- package/src/commands/list.test.js +92 -0
- package/src/commands/remove.js +33 -0
- package/src/commands/remove.test.js +81 -0
- package/src/utils/installer.js +75 -0
- package/src/utils/installer.test.js +100 -0
- package/src/utils/lockfile.js +57 -0
- package/src/utils/lockfile.test.js +69 -0
- package/src/utils/resolver.js +151 -0
- package/src/utils/resolver.test.js +228 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Samet ÇELİKBIÇAK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="assets/rolecraft_logo.png" alt="Logo" width="256" height="256">
|
|
3
|
+
|
|
4
|
+
# RoleCraft — Simple Skill Installer for AI
|
|
5
|
+
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
**Zero-dependency** CLI to install AI agent skills as roles & behaviors from any source. No marketplace, no registry, no signup — just point it at a local folder or a GitHub repo and it works.
|
|
9
|
+
|
|
10
|
+
Works with **opencode**, **claude-code**, **cursor**, and all spec-compliant agents.
|
|
11
|
+
|
|
12
|
+
## Why rolecraft?
|
|
13
|
+
|
|
14
|
+
| Feature | rolecraft | `npx add-skill` | `@agentskill.sh/cli` |
|
|
15
|
+
| --------------------------------- | ---------------- | --------------- | -------------------- |
|
|
16
|
+
| Zero dependencies | ✅ | ✅ | ❌ (2) |
|
|
17
|
+
| Local path install | ✅ **1st class** | ❌ GitHub only | ❌ marketplace only |
|
|
18
|
+
| GitHub repo install | ✅ | ✅ | ❌ |
|
|
19
|
+
| Offline capable | ✅ | ❌ | ❌ |
|
|
20
|
+
| agentskill.sh lockfile compatible | ✅ | ✅ | ✅ |
|
|
21
|
+
| Project-level install | ✅ | ✅ | ✅ |
|
|
22
|
+
| File size | ~3 KB | ~500 KB+ | ~84 KB |
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g rolecraft
|
|
28
|
+
# or
|
|
29
|
+
npx rolecraft install <source>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
rolecraft install ./path/to/my-skill # install from local folder
|
|
36
|
+
rolecraft install sametcelikbicak/task-decomposer # install from GitHub
|
|
37
|
+
rolecraft list # list installed skills
|
|
38
|
+
rolecraft remove <slug> # remove a skill
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Install scope
|
|
42
|
+
|
|
43
|
+
When you run `rolecraft install <source>` without flags, it asks where to install:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Where do you want to install this skill?
|
|
47
|
+
1) Global (~/.agents/skills/) [default]
|
|
48
|
+
2) Project (./.agents/skills/)
|
|
49
|
+
3) Both
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Use flags to skip the prompt:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
rolecraft install ./my-skill --global # ~/.agents/skills/
|
|
56
|
+
rolecraft install ./my-skill --project # ./.agents/skills/
|
|
57
|
+
rolecraft install ./my-skill --claude # also ~/.claude/skills/
|
|
58
|
+
rolecraft install ./my-skill --all # all locations
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Source types
|
|
62
|
+
|
|
63
|
+
**Local path** — any directory containing `SKILL.md`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
rolecraft install ./my-skill
|
|
67
|
+
rolecraft install ~/projects/my-skill
|
|
68
|
+
rolecraft install /absolute/path/to/skill
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**GitHub repo** — shorthand `owner/repo`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
rolecraft install sametcelikbicak/task-decomposer
|
|
75
|
+
rolecraft install sametcelikbicak/coverage-guard
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The CLI clones with `--depth 1`, finds `SKILL.md` recursively, installs it, and cleans up.
|
|
79
|
+
|
|
80
|
+
## What it does
|
|
81
|
+
|
|
82
|
+
1. Reads `SKILL.md` from the source and parses metadata (slug, name, owner)
|
|
83
|
+
2. Copies all files alongside `SKILL.md` (references, configs, assets) to the target directory
|
|
84
|
+
3. Updates `~/.agents/.skill-lock.json` so agents can discover the skill
|
|
85
|
+
4. Compatible with skills installed by `@agentskill.sh/cli`, `add-skill`, or manual installs
|
|
86
|
+
|
|
87
|
+
## How agents discover skills
|
|
88
|
+
|
|
89
|
+
| Agent | Directory |
|
|
90
|
+
| ----------- | ------------------------------------------ |
|
|
91
|
+
| opencode | `~/.agents/skills/` or `./.agents/skills/` |
|
|
92
|
+
| claude-code | `~/.claude/skills/` or `./.claude/skills/` |
|
|
93
|
+
| cursor | `~/.cursor/skills/` or `./.cursor/skills/` |
|
|
94
|
+
|
|
95
|
+
## Commands
|
|
96
|
+
|
|
97
|
+
| Command | Description |
|
|
98
|
+
| ---------------------------- | --------------------------------- |
|
|
99
|
+
| `rolecraft install <source>` | Install a skill (local or GitHub) |
|
|
100
|
+
| `rolecraft list` | Show all installed skills |
|
|
101
|
+
| `rolecraft remove <slug>` | Uninstall a skill |
|
|
102
|
+
| `rolecraft help` | Show this help |
|
|
103
|
+
|
|
104
|
+
## Project structure
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
rolecraft/
|
|
108
|
+
├── bin/rolecraft.js # CLI entry point
|
|
109
|
+
├── src/
|
|
110
|
+
│ ├── commands/
|
|
111
|
+
│ │ ├── install.js # install logic + interactive scope
|
|
112
|
+
│ │ ├── list.js # list installed skills
|
|
113
|
+
│ │ └── remove.js # remove skill + lockfile cleanup
|
|
114
|
+
│ └── utils/
|
|
115
|
+
│ ├── resolver.js # source resolver (local / GitHub)
|
|
116
|
+
│ ├── installer.js # copy files to target dirs
|
|
117
|
+
│ └── lockfile.js # read/write .skill-lock.json
|
|
118
|
+
├── package.json
|
|
119
|
+
└── README.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
package/bin/rolecraft.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { installCommand } from '../src/commands/install.js'
|
|
4
|
+
import { listCommand } from '../src/commands/list.js'
|
|
5
|
+
import { removeCommand } from '../src/commands/remove.js'
|
|
6
|
+
|
|
7
|
+
function usage() {
|
|
8
|
+
console.log(`
|
|
9
|
+
rolecraft — Install AI agent skills like roles & behaviors
|
|
10
|
+
|
|
11
|
+
Zero dependencies, no marketplace required.
|
|
12
|
+
Works with opencode, claude-code, cursor, and all spec-compliant agents.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
rolecraft install <source> Install a skill (local path or owner/repo)
|
|
16
|
+
rolecraft list List installed skills
|
|
17
|
+
rolecraft remove <slug> Remove a skill
|
|
18
|
+
rolecraft help Show this help
|
|
19
|
+
|
|
20
|
+
Options for install:
|
|
21
|
+
--global Install to ~/.agents/skills/ (default)
|
|
22
|
+
--claude Also install to ~/.claude/skills/
|
|
23
|
+
--project Install to ./.agents/skills/
|
|
24
|
+
--all Install to all locations
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
rolecraft install ./my-skill
|
|
28
|
+
rolecraft install sametcelikbicak/task-decomposer
|
|
29
|
+
rolecraft install ./skills/my-skill --claude
|
|
30
|
+
rolecraft list
|
|
31
|
+
rolecraft remove task-decomposer
|
|
32
|
+
`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function main() {
|
|
36
|
+
const [,, cmd, ...args] = process.argv
|
|
37
|
+
switch (cmd) {
|
|
38
|
+
case 'install': {
|
|
39
|
+
const source = args[0]
|
|
40
|
+
if (!source) {
|
|
41
|
+
console.error('Usage: rolecraft install <source>')
|
|
42
|
+
console.error('Source can be a local path (./, /, ~) or a GitHub ref (owner/repo)')
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const flags = args.slice(1)
|
|
47
|
+
const hasAnyFlag = flags.some(f => ['--global', '--project', '--claude', '--all'].includes(f))
|
|
48
|
+
const options = hasAnyFlag ? {
|
|
49
|
+
global: flags.includes('--global') || flags.includes('--all'),
|
|
50
|
+
claude: flags.includes('--claude') || flags.includes('--all'),
|
|
51
|
+
project: flags.includes('--project') || flags.includes('--all'),
|
|
52
|
+
} : {}
|
|
53
|
+
|
|
54
|
+
await installCommand(source, options)
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case 'list':
|
|
59
|
+
await listCommand()
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
case 'remove': {
|
|
63
|
+
const slug = args[0]
|
|
64
|
+
if (!slug) {
|
|
65
|
+
console.error('Usage: rolecraft remove <slug>')
|
|
66
|
+
process.exit(1)
|
|
67
|
+
}
|
|
68
|
+
await removeCommand(slug)
|
|
69
|
+
break
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
case 'help':
|
|
73
|
+
case '--help':
|
|
74
|
+
case '-h':
|
|
75
|
+
default:
|
|
76
|
+
usage()
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
import { fileURLToPath } from 'node:url'
|
|
82
|
+
import { realpathSync } from 'node:fs'
|
|
83
|
+
|
|
84
|
+
export async function run() {
|
|
85
|
+
try {
|
|
86
|
+
await main()
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error(`Error: ${err.message}`)
|
|
89
|
+
process.exit(1)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const isEntryPoint = process.argv[1]
|
|
94
|
+
&& realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))
|
|
95
|
+
|
|
96
|
+
if (isEntryPoint) {
|
|
97
|
+
run()
|
|
98
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { mkdtempSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { mkdir, rm } from 'node:fs/promises'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
|
|
8
|
+
let tempDir, rolecraftModule, origArgv, origExit
|
|
9
|
+
|
|
10
|
+
before(async () => {
|
|
11
|
+
tempDir = mkdtempSync(join(tmpdir(), 'rolecraft-cli-test-'))
|
|
12
|
+
process.env.HOME = tempDir
|
|
13
|
+
await mkdir(join(tempDir, '.agents'), { recursive: true })
|
|
14
|
+
|
|
15
|
+
origArgv = process.argv
|
|
16
|
+
origExit = process.exit
|
|
17
|
+
rolecraftModule = await import('./rolecraft.js')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
after(async () => {
|
|
21
|
+
process.exit = origExit
|
|
22
|
+
process.argv = origArgv
|
|
23
|
+
await rm(tempDir, { recursive: true, force: true })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function capture(name, obj = console) {
|
|
27
|
+
const logs = []
|
|
28
|
+
const orig = obj[name]
|
|
29
|
+
obj[name] = (...args) => {
|
|
30
|
+
if (args.length) logs.push(String(args[0]))
|
|
31
|
+
}
|
|
32
|
+
return { logs, restore: () => { obj[name] = orig } }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function mockExit() {
|
|
36
|
+
const orig = process.exit
|
|
37
|
+
process.exit = (code) => { throw new Error(`exit:${code}`) }
|
|
38
|
+
return () => { process.exit = orig }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('rolecraft CLI', () => {
|
|
42
|
+
it('shows usage for help command', async () => {
|
|
43
|
+
process.argv = ['node', 'rolecraft', 'help']
|
|
44
|
+
const { logs, restore } = capture('log')
|
|
45
|
+
|
|
46
|
+
await rolecraftModule.main()
|
|
47
|
+
|
|
48
|
+
assert.ok(logs.some(l => l.includes('rolecraft')))
|
|
49
|
+
restore()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('shows usage for --help flag', async () => {
|
|
53
|
+
process.argv = ['node', 'rolecraft', '--help']
|
|
54
|
+
const { logs, restore } = capture('log')
|
|
55
|
+
|
|
56
|
+
await rolecraftModule.main()
|
|
57
|
+
|
|
58
|
+
assert.ok(logs.some(l => l.includes('rolecraft')))
|
|
59
|
+
restore()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('shows usage for unknown command', async () => {
|
|
63
|
+
process.argv = ['node', 'rolecraft', 'unknown']
|
|
64
|
+
const { logs, restore } = capture('log')
|
|
65
|
+
|
|
66
|
+
await rolecraftModule.main()
|
|
67
|
+
|
|
68
|
+
assert.ok(logs.some(l => l.includes('rolecraft')))
|
|
69
|
+
restore()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('errors when install has no source', async () => {
|
|
73
|
+
process.argv = ['node', 'rolecraft', 'install']
|
|
74
|
+
const { logs: errors, restore: restoreErr } = capture('error')
|
|
75
|
+
const restoreExit = mockExit()
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await rolecraftModule.main()
|
|
79
|
+
} catch (e) {
|
|
80
|
+
assert.ok(e.message.includes('exit:1'))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
assert.ok(errors.some(e => e.includes('Usage: rolecraft install <source>')))
|
|
84
|
+
restoreErr()
|
|
85
|
+
restoreExit()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('runs install with --global flag', async () => {
|
|
89
|
+
const skillDir = join(tempDir, 'my-cli-skill')
|
|
90
|
+
mkdirSync(skillDir, { recursive: true })
|
|
91
|
+
writeFileSync(join(skillDir, 'SKILL.md'), '# slug: cli/cli-skill\nname: cli-skill\nContent')
|
|
92
|
+
|
|
93
|
+
process.argv = ['node', 'rolecraft', 'install', skillDir, '--global']
|
|
94
|
+
const { logs, restore } = capture('log')
|
|
95
|
+
|
|
96
|
+
await rolecraftModule.main()
|
|
97
|
+
|
|
98
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
99
|
+
restore()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('errors when remove has no slug', async () => {
|
|
103
|
+
process.argv = ['node', 'rolecraft', 'remove']
|
|
104
|
+
const { logs: errors, restore: restoreErr } = capture('error')
|
|
105
|
+
const restoreExit = mockExit()
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
await rolecraftModule.main()
|
|
109
|
+
} catch (e) {
|
|
110
|
+
assert.ok(e.message.includes('exit:1'))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
assert.ok(errors.some(e => e.includes('Usage: rolecraft remove <slug>')))
|
|
114
|
+
restoreErr()
|
|
115
|
+
restoreExit()
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('dispatches list command without errors', async () => {
|
|
119
|
+
process.argv = ['node', 'rolecraft', 'list']
|
|
120
|
+
|
|
121
|
+
await rolecraftModule.main()
|
|
122
|
+
|
|
123
|
+
assert.ok(true)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('runs remove command with existing skill', async () => {
|
|
127
|
+
const skillDir = join(tempDir, 'removable-skill')
|
|
128
|
+
mkdirSync(skillDir, { recursive: true })
|
|
129
|
+
writeFileSync(join(skillDir, 'SKILL.md'), '# slug: test/removable\nname: removable\nContent')
|
|
130
|
+
|
|
131
|
+
process.argv = ['node', 'rolecraft', 'install', skillDir, '--global']
|
|
132
|
+
await rolecraftModule.main()
|
|
133
|
+
|
|
134
|
+
process.argv = ['node', 'rolecraft', 'remove', 'test/removable']
|
|
135
|
+
const { logs, restore } = capture('log')
|
|
136
|
+
|
|
137
|
+
await rolecraftModule.main()
|
|
138
|
+
|
|
139
|
+
assert.ok(logs.some(l => l.includes('Removed')))
|
|
140
|
+
restore()
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('runs remove command with nonexistent skill', async () => {
|
|
144
|
+
process.argv = ['node', 'rolecraft', 'remove', 'nonexistent']
|
|
145
|
+
const { logs: errors, restore: restoreErr } = capture('error')
|
|
146
|
+
const restoreExit = mockExit()
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
await rolecraftModule.main()
|
|
150
|
+
} catch (e) {
|
|
151
|
+
assert.ok(e.message.includes('exit:1'))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
assert.ok(errors.some(e => e.includes('not found')))
|
|
155
|
+
restoreErr()
|
|
156
|
+
restoreExit()
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('run() catches errors', async () => {
|
|
160
|
+
process.argv = ['node', 'rolecraft', 'install']
|
|
161
|
+
const { logs: errors, restore: restoreErr } = capture('error')
|
|
162
|
+
const restoreExit = mockExit()
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
await rolecraftModule.run()
|
|
166
|
+
} catch (e) {
|
|
167
|
+
assert.ok(e.message.includes('exit:1'))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
assert.ok(errors.some(e => e.includes('Usage: rolecraft install <source>')))
|
|
171
|
+
restoreErr()
|
|
172
|
+
restoreExit()
|
|
173
|
+
})
|
|
174
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rolecraft",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Install AI agent skills as roles & behaviors directly from any source — zero-dependency CLI for opencode, claude-code, cursor, and more",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"rolecraft": "bin/rolecraft.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"preferGlobal": true,
|
|
14
|
+
"keywords": [
|
|
15
|
+
"skill",
|
|
16
|
+
"skills",
|
|
17
|
+
"role",
|
|
18
|
+
"cli",
|
|
19
|
+
"agent",
|
|
20
|
+
"ai",
|
|
21
|
+
"rolecraft",
|
|
22
|
+
"opencode",
|
|
23
|
+
"claude-code",
|
|
24
|
+
"cursor",
|
|
25
|
+
"agentskill",
|
|
26
|
+
"zero-dependency"
|
|
27
|
+
],
|
|
28
|
+
"author": "Samet ÇELİKBIÇAK",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/sametcelikbicak/rolecraft.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/sametcelikbicak/rolecraft/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/sametcelikbicak/rolecraft#readme",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"test": "node --test",
|
|
40
|
+
"test:coverage": "node --experimental-test-coverage --test"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline'
|
|
2
|
+
import { stdin as input, stdout as output } from 'node:process'
|
|
3
|
+
import { resolveSource } from '../utils/resolver.js'
|
|
4
|
+
import { installSkill } from '../utils/installer.js'
|
|
5
|
+
|
|
6
|
+
function askQuestion(query) {
|
|
7
|
+
const rl = createInterface({ input, output })
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
rl.question(query, answer => {
|
|
10
|
+
rl.close()
|
|
11
|
+
resolve(answer.trim().toLowerCase())
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function askScope() {
|
|
17
|
+
console.log('\nWhere do you want to install this skill?\n')
|
|
18
|
+
console.log(' 1) Global (~/.agents/skills/) [default]')
|
|
19
|
+
console.log(' 2) Project (./.agents/skills/)')
|
|
20
|
+
console.log(' 3) Both\n')
|
|
21
|
+
|
|
22
|
+
const answer = await askQuestion('Choice [1/2/3] (default: 1): ')
|
|
23
|
+
|
|
24
|
+
switch (answer) {
|
|
25
|
+
case '2': return { global: false, project: true, claude: false }
|
|
26
|
+
case '3': return { global: true, project: true, claude: false }
|
|
27
|
+
default: return { global: true, project: false, claude: false }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function installCommand(source, options) {
|
|
32
|
+
const hasScopeFlags = options.global || options.project || options.claude
|
|
33
|
+
const scope = hasScopeFlags ? options : await askScope()
|
|
34
|
+
|
|
35
|
+
console.log(`\n🔍 Resolving skill from: ${source}`)
|
|
36
|
+
const resolved = await resolveSource(source)
|
|
37
|
+
|
|
38
|
+
console.log(`\n📦 Found skill: ${resolved.name}`)
|
|
39
|
+
console.log(` Slug: ${resolved.slug}`)
|
|
40
|
+
console.log(` Owner: ${resolved.owner}`)
|
|
41
|
+
console.log(` Files: ${resolved.files.join(', ')}`)
|
|
42
|
+
console.log()
|
|
43
|
+
|
|
44
|
+
const targets = []
|
|
45
|
+
if (scope.global) targets.push('agents')
|
|
46
|
+
if (scope.claude) targets.push('claude')
|
|
47
|
+
if (scope.project) targets.push('project')
|
|
48
|
+
|
|
49
|
+
const results = await installSkill(resolved, targets)
|
|
50
|
+
|
|
51
|
+
console.log('✅ Installed successfully:\n')
|
|
52
|
+
for (const r of results) {
|
|
53
|
+
console.log(` ${r.label} → ${r.path}`)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { mkdtempSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { mkdir, rm } from 'node:fs/promises'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
|
|
8
|
+
let tempDir, installModule
|
|
9
|
+
|
|
10
|
+
before(async () => {
|
|
11
|
+
tempDir = mkdtempSync(join(tmpdir(), 'rolecraft-install-cmd-test-'))
|
|
12
|
+
process.env.HOME = tempDir
|
|
13
|
+
|
|
14
|
+
const skillDir = join(tempDir, 'test-skill')
|
|
15
|
+
mkdirSync(skillDir, { recursive: true })
|
|
16
|
+
writeFileSync(join(skillDir, 'SKILL.md'), '# slug: ns/test-cmd\nname: test-cmd\n# owner: tester\nContent')
|
|
17
|
+
writeFileSync(join(skillDir, 'extra.js'), 'x')
|
|
18
|
+
|
|
19
|
+
await mkdir(join(tempDir, '.agents'), { recursive: true })
|
|
20
|
+
|
|
21
|
+
installModule = await import('./install.js')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
after(async () => {
|
|
25
|
+
await rm(tempDir, { recursive: true, force: true })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
function capture(name) {
|
|
29
|
+
const orig = console[name]
|
|
30
|
+
const logs = []
|
|
31
|
+
console[name] = (...args) => {
|
|
32
|
+
if (args.length) logs.push(String(args[0]))
|
|
33
|
+
}
|
|
34
|
+
return { logs, restore: () => { console[name] = orig } }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('install command', () => {
|
|
38
|
+
it('installs with --global flag', async () => {
|
|
39
|
+
const { logs, restore } = capture('log')
|
|
40
|
+
|
|
41
|
+
await installModule.installCommand(join(tempDir, 'test-skill'), { global: true })
|
|
42
|
+
|
|
43
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
44
|
+
restore()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('installs with --project flag', async () => {
|
|
48
|
+
const origCwd = process.cwd
|
|
49
|
+
process.cwd = () => tempDir
|
|
50
|
+
const { logs, restore } = capture('log')
|
|
51
|
+
|
|
52
|
+
await installModule.installCommand(join(tempDir, 'test-skill'), { project: true })
|
|
53
|
+
|
|
54
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
55
|
+
restore()
|
|
56
|
+
process.cwd = origCwd
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('installs with --claude flag', async () => {
|
|
60
|
+
const { logs, restore } = capture('log')
|
|
61
|
+
|
|
62
|
+
await installModule.installCommand(join(tempDir, 'test-skill'), { claude: true })
|
|
63
|
+
|
|
64
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
65
|
+
restore()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('installs with default scope (global) when no flags given', async () => {
|
|
69
|
+
const { logs, restore } = capture('log')
|
|
70
|
+
|
|
71
|
+
await installModule.installCommand(join(tempDir, 'test-skill'), {})
|
|
72
|
+
|
|
73
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
74
|
+
restore()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('installs with --all scope', async () => {
|
|
78
|
+
const origCwd = process.cwd
|
|
79
|
+
process.cwd = () => tempDir
|
|
80
|
+
const { logs, restore } = capture('log')
|
|
81
|
+
|
|
82
|
+
await installModule.installCommand(join(tempDir, 'test-skill'), {
|
|
83
|
+
global: true, project: true, claude: true,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
assert.ok(logs.some(l => l.includes('Installed')))
|
|
87
|
+
restore()
|
|
88
|
+
process.cwd = origCwd
|
|
89
|
+
})
|
|
90
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readLock } from '../utils/lockfile.js'
|
|
2
|
+
|
|
3
|
+
export async function listCommand() {
|
|
4
|
+
const lock = await readLock()
|
|
5
|
+
const skills = Object.entries(lock.skills)
|
|
6
|
+
|
|
7
|
+
if (skills.length === 0) {
|
|
8
|
+
console.log('No skills installed.')
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
console.log('Installed skills:\n')
|
|
13
|
+
for (const [slug, entry] of skills) {
|
|
14
|
+
const date = entry.installedAt
|
|
15
|
+
? new Date(entry.installedAt).toLocaleDateString()
|
|
16
|
+
: 'unknown'
|
|
17
|
+
console.log(` ${slug}`)
|
|
18
|
+
console.log(` ├─ Installed: ${date}`)
|
|
19
|
+
if (entry.source) console.log(` ├─ Source: ${entry.source}`)
|
|
20
|
+
if (entry.sourceType) console.log(` └─ Type: ${entry.sourceType}`)
|
|
21
|
+
console.log()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const count = skills.length
|
|
25
|
+
console.log(`${count} skill(s) total.`)
|
|
26
|
+
}
|