unslopify 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +100 -2
- package/bin/unslopify.js +180 -0
- package/lib/install.mjs +197 -0
- package/lib/setup.mjs +29 -0
- package/lib/targets.mjs +128 -0
- package/package.json +43 -4
- package/skills/durable-instructions/LICENSE +21 -0
- package/skills/durable-instructions/README.md +49 -0
- package/skills/durable-instructions/SKILL.md +73 -0
- package/skills/durable-instructions/assets/durable-instructions-logo.svg +8 -0
- package/skills/durable-instructions/evals/evals.json +75 -0
- package/skills/durable-instructions/evals/validate_structure.py +67 -0
- package/skills/durable-instructions/references/authoring-patterns.md +98 -0
- package/skills/durable-instructions/references/evaluation.md +31 -0
- package/skills/durable-instructions/references/positive-framing.md +60 -0
- package/skills/durable-instructions/references/research-evidence.md +72 -0
- package/skills/no-ai-slop/LICENSE +21 -0
- package/skills/no-ai-slop/README.md +124 -0
- package/skills/no-ai-slop/SKILL.md +122 -0
- package/skills/no-ai-slop/SKILL_TREE.md +52 -0
- package/skills/no-ai-slop/assets/no-ai-slop-logo.svg +7 -0
- package/skills/no-ai-slop/evals/evals.json +40 -0
- package/skills/no-ai-slop/evals/fixtures/sloppy-landing.html +38 -0
- package/skills/no-ai-slop/references/expanded-slop-indicators.md +487 -0
- package/skills/no-ai-slop/references/impressive-ui-patterns.md +198 -0
- package/skills/no-ai-slop/references/reference-library.md +146 -0
- package/skills/no-ai-slop/references/rewrite-playbook.md +132 -0
- package/skills/no-ai-slop/references/slop-indicators.md +258 -0
- package/skills/no-ai-slop/scripts/scan_slop.py +255 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 suydev-agent-skills contributors
|
|
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
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# unslopify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One npm package that installs the `no-ai-slop` and `durable-instructions` skills into every agent on this machine. Both skills are bundled, so no network access is needed at install time.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g unslopify
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run it once without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx unslopify --dry-run
|
|
15
|
+
npx unslopify
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
After installing, restart your agents so they re-scan their skill directories.
|
|
19
|
+
|
|
20
|
+
## Troubleshooting
|
|
21
|
+
|
|
22
|
+
If `unslopify: command not found` after a successful global install:
|
|
23
|
+
|
|
24
|
+
1. Check the global bin is on your PATH: `npm prefix -g`, then look for `bin/unslopify` there.
|
|
25
|
+
2. Older installs of `suydev-agent-skills` left an `install-agent-skills` symlink. Remove it with `rm "$(npm prefix -g)/bin/install-agent-skills"` and reinstall.
|
|
26
|
+
3. Reinstall cleanly with `npm uninstall -g unslopify && npm install -g unslopify`.
|
|
27
|
+
|
|
28
|
+
## Guided setup
|
|
29
|
+
|
|
30
|
+
For an interactive walkthrough — detected agents, choice of targets, confirmation, and overwrite policy — run:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
unslopify setup
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
It asks which agents to target, whether to include project-local folders, whether to use the shared folder, and which locations to write to before anything changes. For scripts and CI, use the non-interactive `install` command instead. `setup` is unavailable when stdin is not a terminal; the CLI will tell you to use `install` in that case.
|
|
37
|
+
|
|
38
|
+
## What it does
|
|
39
|
+
|
|
40
|
+
By default the CLI detects agents by looking for their config directories, then installs into their personal skill folders. It always includes the vendor-neutral shared folder `~/.agents/skills/`, which most modern agents read.
|
|
41
|
+
|
|
42
|
+
| Agent | Personal folders written |
|
|
43
|
+
|---|---|
|
|
44
|
+
| Shared (Codex, Gemini, Cursor, Copilot, OpenCode, Amp, Windsurf) | `~/.agents/skills/` |
|
|
45
|
+
| Claude Code | `~/.claude/skills/` |
|
|
46
|
+
| OpenAI Codex | `~/.codex/skills/` |
|
|
47
|
+
| Cursor | `~/.cursor/skills/` |
|
|
48
|
+
| Gemini CLI | `~/.gemini/skills/` |
|
|
49
|
+
| GitHub Copilot / VS Code | `~/.copilot/skills/` |
|
|
50
|
+
| OpenCode | `~/.config/opencode/skills/` |
|
|
51
|
+
| Amp | `~/.config/agents/skills/`, `~/.config/amp/skills/` |
|
|
52
|
+
| Windsurf / Devin | `~/.config/devin/skills/` |
|
|
53
|
+
|
|
54
|
+
One physical copy per path: targets are de-duplicated. For example `~/.agents/skills/` is written once even though seven agents read it.
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
unslopify list # detected agents and resolved paths
|
|
60
|
+
unslopify --dry-run # preview without writing
|
|
61
|
+
unslopify --all # every known folder, detected or not
|
|
62
|
+
unslopify --agents claude,cursor,opencode
|
|
63
|
+
unslopify --project # also write .agents/skills, .claude/skills, etc. in cwd
|
|
64
|
+
unslopify --force # overwrite files that differ
|
|
65
|
+
unslopify --json # machine-readable report
|
|
66
|
+
unslopify uninstall --dry-run # preview removal
|
|
67
|
+
unslopify uninstall # remove bundled files only
|
|
68
|
+
unslopify uninstall --all # from every known folder
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`uninstall` removes only files that are byte-identical to the bundled skill. Any local edit or extra file in a skill folder stops removal for that folder, so your changes survive.
|
|
72
|
+
|
|
73
|
+
## Safety
|
|
74
|
+
|
|
75
|
+
- Existing files with the same content are left alone.
|
|
76
|
+
- Existing files with different content are **skipped** with a warning; nothing is overwritten without `--force`. That protects local edits such as a project-specific plugin manifest.
|
|
77
|
+
- Symlinked skill directories are skipped, never written through.
|
|
78
|
+
- No dependencies, no telemetry, no network calls during install. Node 18+ required.
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm test # node:test suite
|
|
84
|
+
npm run sync # recopy skills from ~/no-ai-slop and ~/durable-instructions
|
|
85
|
+
npm pack # sync + test + tarball
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`npm run sync` reads the two sibling repositories in your home directory; published tarballs already contain the synced skills. Source is at `https://github.com/Suydev/unslopify`.
|
|
89
|
+
|
|
90
|
+
Publishing happens two ways:
|
|
91
|
+
|
|
92
|
+
- Locally: `npm login && npm publish` from the package directory.
|
|
93
|
+
- Automatically: push to `main`; `.github/workflows/publish.yml` runs the tests and `npm publish --provenance`. This needs a repository secret named `NPM_TOKEN`, and each push must bump `version` in `package.json` or npm rejects the duplicate version.
|
|
94
|
+
|
|
95
|
+
## Why these paths
|
|
96
|
+
|
|
97
|
+
SKILL.md is an open format used by many agents; the standard defines the file, not the folder. Vendor-documented personal/project folders were checked on 2026-11-24: [Claude Code](https://code.claude.com/docs/en/skills), [OpenCode](https://docs.dev.opencode.ai/docs/skills), [Gemini CLI](https://geminicli.com/docs/cli/skills/), [Cursor](https://cursor.com/docs/skills), [GitHub Copilot](https://docs.github.com/en/copilot/concepts/customizations/agent-skills), [Windsurf](https://docs.windsurf.com/windsurf/cascade/skills), [Amp](https://ampcode.com/docs/customize/skills), and [this cross-agent path guide](https://claudeskills.page/guides/agent-skills-in-other-tools).
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT — the bundled skills keep their own MIT licenses.
|
package/bin/unslopify.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
':' //; exec node "$0" "$@"
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
import { AGENTS, detectAgents, resolveTargets } from '../lib/targets.mjs';
|
|
8
|
+
import { findSkills, installAll, uninstallAll } from '../lib/install.mjs';
|
|
9
|
+
import { askYesNo, parseSelection } from '../lib/setup.mjs';
|
|
10
|
+
|
|
11
|
+
const ROOT = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
12
|
+
const DEFAULT_SKILLS = path.join(ROOT, 'skills');
|
|
13
|
+
|
|
14
|
+
const HELP = `unslopify — install portable skills into every agent on this machine
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
unslopify setup [options] # guided setup with confirmation prompts
|
|
18
|
+
unslopify [install] [options]
|
|
19
|
+
unslopify uninstall [options]
|
|
20
|
+
unslopify list
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--all target every known agent directory
|
|
24
|
+
--agents a,b,c target specific agents: ${AGENTS.map((a) => a.id).join(',')}
|
|
25
|
+
--project also write project-local directories in the current folder
|
|
26
|
+
--force overwrite files that differ from the bundled skill
|
|
27
|
+
--dry-run show what would happen without writing
|
|
28
|
+
--no-universal skip the shared ~/.agents/skills directory
|
|
29
|
+
--json machine-readable report
|
|
30
|
+
--home DIR override home directory (testing)
|
|
31
|
+
--skills DIR override bundled skills directory (testing)
|
|
32
|
+
-h, --help show this help
|
|
33
|
+
|
|
34
|
+
Default: detected agents + the shared ~/.agents/skills directory, personal scope only.
|
|
35
|
+
Existing files that differ are skipped; never overwritten without --force.
|
|
36
|
+
Symlinked skill directories are left untouched.
|
|
37
|
+
Uninstall removes only files identical to the bundle; local edits are left untouched.
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
function parse(args) {
|
|
41
|
+
const options = {
|
|
42
|
+
command: 'install',
|
|
43
|
+
all: false,
|
|
44
|
+
agents: [],
|
|
45
|
+
project: false,
|
|
46
|
+
force: false,
|
|
47
|
+
dryRun: false,
|
|
48
|
+
universal: true,
|
|
49
|
+
json: false,
|
|
50
|
+
home: os.homedir(),
|
|
51
|
+
skillsDir: DEFAULT_SKILLS,
|
|
52
|
+
};
|
|
53
|
+
const rest = [];
|
|
54
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
55
|
+
const arg = args[i];
|
|
56
|
+
if (arg === 'install' || arg === 'list' || arg === 'uninstall' || arg === 'setup') {
|
|
57
|
+
options.command = arg;
|
|
58
|
+
} else if (arg === '--all') options.all = true;
|
|
59
|
+
else if (arg === '--agents') options.agents = (args[++i] ?? '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
60
|
+
else if (arg === '--project') options.project = true;
|
|
61
|
+
else if (arg === '--force') options.force = true;
|
|
62
|
+
else if (arg === '--dry-run') options.dryRun = true;
|
|
63
|
+
else if (arg === '--no-universal') options.universal = false;
|
|
64
|
+
else if (arg === '--json') options.json = true;
|
|
65
|
+
else if (arg === '--home') options.home = args[++i];
|
|
66
|
+
else if (arg === '--skills') options.skillsDir = args[++i];
|
|
67
|
+
else if (arg === '-h' || arg === '--help') options.command = 'help';
|
|
68
|
+
else rest.push(arg);
|
|
69
|
+
}
|
|
70
|
+
if (rest.length > 0) throw new Error(`unknown arguments: ${rest.join(', ')}`);
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function printReport(results, json) {
|
|
75
|
+
if (json) {
|
|
76
|
+
process.stdout.write(`${JSON.stringify(results, null, 2)}\n`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const icons = {
|
|
80
|
+
installed: '+',
|
|
81
|
+
updated: '~',
|
|
82
|
+
unchanged: '=',
|
|
83
|
+
skipped: '!',
|
|
84
|
+
absent: '.',
|
|
85
|
+
removed: '-',
|
|
86
|
+
'would-write': '?',
|
|
87
|
+
'would-remove': '?',
|
|
88
|
+
};
|
|
89
|
+
for (const result of results) {
|
|
90
|
+
const agents = result.agents.join(', ');
|
|
91
|
+
const suffix = result.reason ? ` — ${result.reason}` : '';
|
|
92
|
+
process.stdout.write(`${icons[result.status] ?? '?'} ${result.skill} -> ${result.path} [${agents}] ${result.status}${suffix}\n`);
|
|
93
|
+
}
|
|
94
|
+
const summary = results.reduce((acc, result) => {
|
|
95
|
+
acc[result.status] = (acc[result.status] ?? 0) + 1;
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
process.stdout.write(`\n${Object.entries(summary).map(([key, value]) => `${value} ${key}`).join(', ')}\n`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function runSetup(options) {
|
|
102
|
+
if (!process.stdin.isTTY) {
|
|
103
|
+
throw new Error('setup needs an interactive terminal; use "unslopify install" in scripts');
|
|
104
|
+
}
|
|
105
|
+
const detected = detectAgents({ home: options.home });
|
|
106
|
+
const readline = createInterface({ input: process.stdin, output: process.stdout });
|
|
107
|
+
try {
|
|
108
|
+
process.stdout.write('\nDetected agents:\n');
|
|
109
|
+
if (detected.length === 0) process.stdout.write(' none found\n');
|
|
110
|
+
for (const [index, id] of detected.entries()) {
|
|
111
|
+
const agent = AGENTS.find((entry) => entry.id === id);
|
|
112
|
+
process.stdout.write(` ${index + 1}) ${id} — ${agent.name}\n`);
|
|
113
|
+
}
|
|
114
|
+
const choice = await readline.question('\nWhich agents? (numbers or ids, comma-separated; Enter = all detected) ');
|
|
115
|
+
const agents = parseSelection(choice, detected);
|
|
116
|
+
const project = askYesNo(await readline.question('Also install project-local folders in this directory? [y/N] '), false);
|
|
117
|
+
const universal = askYesNo(await readline.question('Install into the shared ~/.agents/skills folder? [Y/n] '), true);
|
|
118
|
+
|
|
119
|
+
const targets = resolveTargets({
|
|
120
|
+
home: options.home,
|
|
121
|
+
agents,
|
|
122
|
+
project,
|
|
123
|
+
includeUniversal: universal,
|
|
124
|
+
});
|
|
125
|
+
process.stdout.write('\nPlanned locations:\n');
|
|
126
|
+
for (const target of targets) {
|
|
127
|
+
process.stdout.write(` ${target.path} [${target.agents.join(', ')}]\n`);
|
|
128
|
+
}
|
|
129
|
+
if (!askYesNo(await readline.question('\nInstall to these locations? [Y/n] '), true)) {
|
|
130
|
+
process.stdout.write('Cancelled.\n');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const force = askYesNo(await readline.question('Overwrite files that differ from the bundled skills? [y/N] '), false);
|
|
134
|
+
const results = await installAll({ skillsDir: options.skillsDir, targets, force });
|
|
135
|
+
printReport(results, false);
|
|
136
|
+
process.stdout.write('\nRestart your agents so they re-scan their skill directories.\n');
|
|
137
|
+
} finally {
|
|
138
|
+
readline.close();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const options = parse(process.argv.slice(2));
|
|
144
|
+
if (options.command === 'help') {
|
|
145
|
+
process.stdout.write(HELP);
|
|
146
|
+
} else if (options.command === 'setup') {
|
|
147
|
+
await runSetup(options);
|
|
148
|
+
} else {
|
|
149
|
+
const detected = detectAgents({ home: options.home });
|
|
150
|
+
const targets = resolveTargets({
|
|
151
|
+
home: options.home,
|
|
152
|
+
all: options.all,
|
|
153
|
+
agents: options.agents,
|
|
154
|
+
project: options.project,
|
|
155
|
+
includeUniversal: options.universal,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (options.command === 'list') {
|
|
159
|
+
const payload = { detected, targets };
|
|
160
|
+
process.stdout.write(options.json ? `${JSON.stringify(payload, null, 2)}\n` : `${detected.join(', ') || 'none'}\n${targets.map((t) => `${t.path} [${t.agents.join(', ')}]`).join('\n')}\n`);
|
|
161
|
+
} else {
|
|
162
|
+
if (!options.json) {
|
|
163
|
+
process.stdout.write(`Detected agents: ${detected.join(', ') || 'none'}\n`);
|
|
164
|
+
process.stdout.write(`Targets: ${targets.length}\n\n`);
|
|
165
|
+
}
|
|
166
|
+
const results = options.command === 'uninstall'
|
|
167
|
+
? await uninstallAll({ skillsDir: options.skillsDir, targets, dryRun: options.dryRun })
|
|
168
|
+
: await installAll({
|
|
169
|
+
skillsDir: options.skillsDir,
|
|
170
|
+
targets,
|
|
171
|
+
force: options.force,
|
|
172
|
+
dryRun: options.dryRun,
|
|
173
|
+
});
|
|
174
|
+
printReport(results, options.json);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
process.stderr.write(`error: ${error.message}\n`);
|
|
179
|
+
process.exitCode = 1;
|
|
180
|
+
}
|
package/lib/install.mjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { copyFile, lstat, mkdir, readdir, readFile, rmdir, unlink } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
async function listFiles(dir, base = dir) {
|
|
6
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
7
|
+
const files = [];
|
|
8
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
9
|
+
const absolute = path.join(dir, entry.name);
|
|
10
|
+
if (entry.isDirectory()) {
|
|
11
|
+
files.push(...await listFiles(absolute, base));
|
|
12
|
+
} else if (entry.isFile()) {
|
|
13
|
+
files.push({ absolute, relative: path.relative(base, absolute) });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return files;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function hash(absolute) {
|
|
20
|
+
return createHash('sha256').update(await readFile(absolute)).digest('hex');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function pathExists(absolute) {
|
|
24
|
+
try {
|
|
25
|
+
await lstat(absolute);
|
|
26
|
+
return true;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error.code === 'ENOENT') return false;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function isDirectory(absolute) {
|
|
34
|
+
try {
|
|
35
|
+
return (await lstat(absolute)).isDirectory();
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function isSymlink(absolute) {
|
|
42
|
+
try {
|
|
43
|
+
return (await lstat(absolute)).isSymbolicLink();
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function installSkill({ source, destination, force = false, dryRun = false }) {
|
|
50
|
+
const name = path.basename(source);
|
|
51
|
+
const result = { skill: name, path: destination, status: 'unchanged', written: [], conflicts: [] };
|
|
52
|
+
const existedBefore = await pathExists(destination);
|
|
53
|
+
|
|
54
|
+
if (await pathExists(destination)) {
|
|
55
|
+
if (await isSymlink(destination)) {
|
|
56
|
+
return { ...result, status: 'skipped', reason: 'destination is a symlink' };
|
|
57
|
+
}
|
|
58
|
+
if (!await isDirectory(destination)) {
|
|
59
|
+
return { ...result, status: 'skipped', reason: 'destination is not a directory' };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const files = await listFiles(source);
|
|
64
|
+
for (const file of files) {
|
|
65
|
+
const target = path.join(destination, file.relative);
|
|
66
|
+
let differs = true;
|
|
67
|
+
if (await pathExists(target)) {
|
|
68
|
+
differs = await hash(target) !== await hash(file.absolute);
|
|
69
|
+
if (differs && !force) {
|
|
70
|
+
result.conflicts.push(file.relative);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!differs) continue;
|
|
75
|
+
if (!dryRun) {
|
|
76
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
77
|
+
await copyFile(file.absolute, target);
|
|
78
|
+
}
|
|
79
|
+
result.written.push(file.relative);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (result.conflicts.length > 0 && !force) {
|
|
83
|
+
result.status = 'skipped';
|
|
84
|
+
result.reason = `existing files differ (${result.conflicts.join(', ')}); use --force`;
|
|
85
|
+
} else if (result.written.length > 0) {
|
|
86
|
+
result.status = dryRun ? 'would-write' : (existedBefore ? 'updated' : 'installed');
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function findSkills(skillsDir) {
|
|
92
|
+
const entries = await readdir(skillsDir, { withFileTypes: true });
|
|
93
|
+
const skills = [];
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
if (entry.isDirectory() && await pathExists(path.join(skillsDir, entry.name, 'SKILL.md'))) {
|
|
96
|
+
skills.push(path.join(skillsDir, entry.name));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return skills.sort();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function installAll({ skillsDir, targets, force = false, dryRun = false }) {
|
|
103
|
+
const sources = await findSkills(skillsDir);
|
|
104
|
+
if (sources.length === 0) throw new Error(`no bundled skills found in ${skillsDir}`);
|
|
105
|
+
const results = [];
|
|
106
|
+
for (const target of targets) {
|
|
107
|
+
for (const source of sources) {
|
|
108
|
+
const destination = path.join(target.path, path.basename(source));
|
|
109
|
+
const result = await installSkill({ source, destination, force, dryRun });
|
|
110
|
+
results.push({ ...result, target, agents: target.agents });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return results;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function removeEmptyDirs(dir) {
|
|
117
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
118
|
+
if (!entry.isDirectory()) continue;
|
|
119
|
+
const child = path.join(dir, entry.name);
|
|
120
|
+
await removeEmptyDirs(child);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await rmdir(dir);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (error.code !== 'ENOTEMPTY' && error.code !== 'EEXIST') throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function uninstallSkill({ source, destination, dryRun = false }) {
|
|
130
|
+
const name = path.basename(source);
|
|
131
|
+
const result = {
|
|
132
|
+
skill: name,
|
|
133
|
+
path: destination,
|
|
134
|
+
status: 'absent',
|
|
135
|
+
removed: [],
|
|
136
|
+
conflicts: [],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
if (!await pathExists(destination)) return result;
|
|
140
|
+
if (await isSymlink(destination)) {
|
|
141
|
+
return { ...result, status: 'skipped', reason: 'destination is a symlink' };
|
|
142
|
+
}
|
|
143
|
+
if (!await isDirectory(destination)) {
|
|
144
|
+
return { ...result, status: 'skipped', reason: 'destination is not a directory' };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const bundled = await listFiles(source);
|
|
148
|
+
const bundledNames = new Set(bundled.map((file) => file.relative));
|
|
149
|
+
const installed = await listFiles(destination);
|
|
150
|
+
|
|
151
|
+
for (const extra of installed) {
|
|
152
|
+
if (!bundledNames.has(extra.relative)) {
|
|
153
|
+
result.conflicts.push(`${extra.relative} (not in bundle)`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const file of bundled) {
|
|
157
|
+
const target = path.join(destination, file.relative);
|
|
158
|
+
if (!await pathExists(target)) continue;
|
|
159
|
+
if (await isSymlink(target) || await hash(target) !== await hash(file.absolute)) {
|
|
160
|
+
result.conflicts.push(file.relative);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
result.removed.push(file.relative);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (result.conflicts.length > 0) {
|
|
167
|
+
return {
|
|
168
|
+
...result,
|
|
169
|
+
removed: [],
|
|
170
|
+
status: 'skipped',
|
|
171
|
+
reason: `local files differ (${result.conflicts.join(', ')}); remove them manually`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (result.removed.length === 0) return result;
|
|
175
|
+
|
|
176
|
+
if (!dryRun) {
|
|
177
|
+
for (const relative of result.removed) {
|
|
178
|
+
await unlink(path.join(destination, relative));
|
|
179
|
+
}
|
|
180
|
+
await removeEmptyDirs(destination);
|
|
181
|
+
}
|
|
182
|
+
return { ...result, status: dryRun ? 'would-remove' : 'removed' };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export async function uninstallAll({ skillsDir, targets, dryRun = false }) {
|
|
186
|
+
const sources = await findSkills(skillsDir);
|
|
187
|
+
if (sources.length === 0) throw new Error(`no bundled skills found in ${skillsDir}`);
|
|
188
|
+
const results = [];
|
|
189
|
+
for (const target of targets) {
|
|
190
|
+
for (const source of sources) {
|
|
191
|
+
const destination = path.join(target.path, path.basename(source));
|
|
192
|
+
const result = await uninstallSkill({ source, destination, dryRun });
|
|
193
|
+
results.push({ ...result, target, agents: target.agents });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return results;
|
|
197
|
+
}
|
package/lib/setup.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { agentById } from './targets.mjs';
|
|
2
|
+
|
|
3
|
+
export function parseSelection(input, detected) {
|
|
4
|
+
const raw = (input ?? '').trim();
|
|
5
|
+
if (raw === '' || raw.toLowerCase() === 'all') return [...detected];
|
|
6
|
+
const ids = [];
|
|
7
|
+
for (const token of raw.split(/[\s,]+/).filter(Boolean)) {
|
|
8
|
+
if (/^\d+$/.test(token)) {
|
|
9
|
+
const index = Number(token) - 1;
|
|
10
|
+
if (index < 0 || index >= detected.length) {
|
|
11
|
+
throw new Error(`invalid choice: ${token}`);
|
|
12
|
+
}
|
|
13
|
+
ids.push(detected[index]);
|
|
14
|
+
} else {
|
|
15
|
+
const id = token.toLowerCase();
|
|
16
|
+
if (!agentById(id)) throw new Error(`unknown agent: ${token}`);
|
|
17
|
+
ids.push(id);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return [...new Set(ids)];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function askYesNo(input, defaultValue = false) {
|
|
24
|
+
const value = (input ?? '').trim().toLowerCase();
|
|
25
|
+
if (value === '') return defaultValue;
|
|
26
|
+
if (value === 'y' || value === 'yes') return true;
|
|
27
|
+
if (value === 'n' || value === 'no') return false;
|
|
28
|
+
throw new Error(`answer y or n (got: ${input})`);
|
|
29
|
+
}
|
package/lib/targets.mjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
export function expandHome(value, home = os.homedir()) {
|
|
6
|
+
return value === '~' || value.startsWith('~/')
|
|
7
|
+
? path.join(home, value.slice(2))
|
|
8
|
+
: value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const AGENTS = [
|
|
12
|
+
{
|
|
13
|
+
id: 'universal',
|
|
14
|
+
name: 'Shared Agent Skills (.agents)',
|
|
15
|
+
personal: ['~/.agents/skills'],
|
|
16
|
+
project: ['.agents/skills'],
|
|
17
|
+
markers: ['~/.agents'],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'claude',
|
|
21
|
+
name: 'Claude Code',
|
|
22
|
+
personal: ['~/.claude/skills'],
|
|
23
|
+
project: ['.claude/skills'],
|
|
24
|
+
markers: ['~/.claude'],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'codex',
|
|
28
|
+
name: 'OpenAI Codex',
|
|
29
|
+
personal: ['~/.agents/skills', '~/.codex/skills'],
|
|
30
|
+
project: ['.agents/skills', '.codex/skills'],
|
|
31
|
+
markers: ['~/.codex', '~/.agents'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'cursor',
|
|
35
|
+
name: 'Cursor',
|
|
36
|
+
personal: ['~/.agents/skills', '~/.cursor/skills', '~/.claude/skills', '~/.codex/skills'],
|
|
37
|
+
project: ['.agents/skills', '.cursor/skills', '.claude/skills', '.codex/skills'],
|
|
38
|
+
markers: ['~/.cursor'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'gemini',
|
|
42
|
+
name: 'Gemini CLI',
|
|
43
|
+
personal: ['~/.agents/skills', '~/.gemini/skills'],
|
|
44
|
+
project: ['.agents/skills', '.gemini/skills'],
|
|
45
|
+
markers: ['~/.gemini'],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'copilot',
|
|
49
|
+
name: 'GitHub Copilot / VS Code',
|
|
50
|
+
personal: ['~/.agents/skills', '~/.copilot/skills'],
|
|
51
|
+
project: ['.agents/skills', '.github/skills'],
|
|
52
|
+
markers: ['~/.copilot', '~/.vscode', '~/.config/Code', '~/.config/Code - OSS'],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'opencode',
|
|
56
|
+
name: 'OpenCode',
|
|
57
|
+
personal: ['~/.agents/skills', '~/.config/opencode/skills', '~/.claude/skills'],
|
|
58
|
+
project: ['.agents/skills', '.opencode/skills', '.claude/skills'],
|
|
59
|
+
markers: ['~/.config/opencode', '~/.opencode'],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'amp',
|
|
63
|
+
name: 'Amp',
|
|
64
|
+
personal: ['~/.config/agents/skills', '~/.agents/skills', '~/.config/amp/skills'],
|
|
65
|
+
project: ['.agents/skills'],
|
|
66
|
+
markers: ['~/.config/amp', '~/.config/agents', '~/.amp'],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'windsurf',
|
|
70
|
+
name: 'Windsurf / Devin',
|
|
71
|
+
personal: ['~/.agents/skills', '~/.config/devin/skills'],
|
|
72
|
+
project: ['.agents/skills', '.devin/skills', '.windsurf/skills'],
|
|
73
|
+
markers: ['~/.windsurf', '~/.config/devin', '~/.devin'],
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export function agentById(id) {
|
|
78
|
+
return AGENTS.find((entry) => entry.id === id);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function detectAgents({ home = os.homedir() } = {}) {
|
|
82
|
+
return AGENTS.filter((entry) =>
|
|
83
|
+
entry.markers.some((marker) => existsSync(expandHome(marker, home)))
|
|
84
|
+
).map((entry) => entry.id);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function resolveTargets({
|
|
88
|
+
home = os.homedir(),
|
|
89
|
+
projectDir = process.cwd(),
|
|
90
|
+
all = false,
|
|
91
|
+
agents = [],
|
|
92
|
+
project = false,
|
|
93
|
+
includeUniversal = true,
|
|
94
|
+
} = {}) {
|
|
95
|
+
let selected;
|
|
96
|
+
if (agents.length > 0) {
|
|
97
|
+
const unknown = agents.filter((id) => !agentById(id));
|
|
98
|
+
if (unknown.length > 0) {
|
|
99
|
+
throw new Error(`unknown agent(s): ${unknown.join(', ')}. Known: ${AGENTS.map((a) => a.id).join(', ')}`);
|
|
100
|
+
}
|
|
101
|
+
selected = [...agents];
|
|
102
|
+
} else if (all) {
|
|
103
|
+
selected = AGENTS.map((entry) => entry.id);
|
|
104
|
+
} else {
|
|
105
|
+
selected = detectAgents({ home });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (includeUniversal && !selected.includes('universal')) {
|
|
109
|
+
selected.push('universal');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const map = new Map();
|
|
113
|
+
for (const id of selected) {
|
|
114
|
+
const entry = agentById(id);
|
|
115
|
+
if (!entry) continue;
|
|
116
|
+
const paths = [...entry.personal];
|
|
117
|
+
if (project) paths.push(...entry.project);
|
|
118
|
+
for (const raw of paths) {
|
|
119
|
+
const absolute = raw.startsWith('~')
|
|
120
|
+
? expandHome(raw, home)
|
|
121
|
+
: path.resolve(projectDir, raw);
|
|
122
|
+
const existing = map.get(absolute) ?? { path: absolute, agents: [], scope: raw.startsWith('~') ? 'personal' : 'project' };
|
|
123
|
+
if (!existing.agents.includes(id)) existing.agents.push(id);
|
|
124
|
+
map.set(absolute, existing);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [...map.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
128
|
+
}
|