@v11g/agents-rock 1.0.1 → 1.0.2
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/README.md +58 -14
- package/package.json +7 -3
- package/plugins/solution-architect/skills/analyze-requirements/README.md +1 -1
- package/src/cli/agents.mjs +10 -10
- package/src/cli/args.mjs +22 -3
- package/src/cli/flow.mjs +85 -0
- package/src/cli/install.mjs +7 -8
- package/src/cli/main.mjs +30 -72
- package/src/cli/prompts.mjs +84 -0
- package/src/cli/report.mjs +26 -0
- package/src/cli/scope.mjs +34 -0
- package/src/cli/targets.mjs +45 -0
- package/src/cli/uninstall.mjs +9 -10
- package/src/cli/picker.mjs +0 -78
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ A Claude Code plugin marketplace.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
/plugin marketplace add git@github.com:
|
|
8
|
+
/plugin marketplace add git@github.com:v11g/agents-rock.git
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
(HTTPS equivalent: `https://github.com/
|
|
11
|
+
(HTTPS equivalent: `https://github.com/v11g/agents-rock.git`)
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
/plugin install <plugin>@agents-rock
|
|
@@ -20,24 +20,68 @@ Replace `<plugin>` with any plugin from the table below, e.g.
|
|
|
20
20
|
### Install via npx (Claude Code + Codex)
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
-
npx @v11g/agents-rock
|
|
24
|
-
npx @v11g/agents-rock -p <plugin> -a claude
|
|
25
|
-
npx @v11g/agents-rock -p <plugin> -a codex
|
|
26
|
-
npx @v11g/agents-rock -p <plugin> -a claude -a codex # both agents
|
|
27
|
-
npx @v11g/agents-rock uninstall -p <plugin>
|
|
23
|
+
npx @v11g/agents-rock # interactive: pick plugins, agents, scope
|
|
24
|
+
npx @v11g/agents-rock -p <plugin> -a claude --project # this project, Claude Code
|
|
25
|
+
npx @v11g/agents-rock -p <plugin> -a codex --global # your home dir, Codex
|
|
26
|
+
npx @v11g/agents-rock -p <plugin> -a claude -a codex -g # both agents, home dir
|
|
27
|
+
npx @v11g/agents-rock uninstall -p <plugin> --project # remove from this project, all agents
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
`-p <plugin>` installs
|
|
30
|
+
`-p <plugin>` installs every skill that plugin ships.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
Run with no options and you get prompts for plugins, agents, and scope, then a
|
|
33
|
+
summary to confirm before anything is written. Nothing is written until you
|
|
34
|
+
confirm.
|
|
35
|
+
|
|
36
|
+
#### Scope
|
|
37
|
+
|
|
38
|
+
| Flag | Where skills land | Good for |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `--project` | the detected project root | skills committed alongside one repo |
|
|
41
|
+
| `--global` / `-g` | your home directory | skills you want in every project |
|
|
42
|
+
|
|
43
|
+
`--project` walks up from the current directory looking for `.git`, then for
|
|
44
|
+
`package.json`, `pyproject.toml`, `go.mod`, or `Cargo.toml`. When the root it
|
|
45
|
+
finds is not the directory you are standing in, it shows you both and asks which
|
|
46
|
+
to use — so running the installer from `packages/web/src` does not quietly
|
|
47
|
+
create a skills directory there. Use `--dir <path>` to name the directory
|
|
48
|
+
yourself and skip detection.
|
|
49
|
+
|
|
50
|
+
`--global` honors `CLAUDE_CONFIG_DIR` and `CODEX_HOME` if you have relocated
|
|
51
|
+
either agent's config.
|
|
52
|
+
|
|
53
|
+
#### Layout
|
|
54
|
+
|
|
55
|
+
Both scopes use the same shape — one canonical copy, symlinked per agent:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
project scope user scope
|
|
59
|
+
<root>/.agents/skills/<skill> ~/.agents/skills/<skill> canonical copy
|
|
60
|
+
<root>/.claude/skills/<skill> -> ~/.claude/skills/<skill> symlink
|
|
61
|
+
<root>/.codex/skills/<skill> -> ~/.codex/skills/<skill> symlink
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Editing the canonical copy updates every agent. On systems that refuse symlinks
|
|
65
|
+
the installer falls back to a junction, then to a plain copy, and warns that
|
|
66
|
+
updates will no longer propagate.
|
|
67
|
+
|
|
68
|
+
#### Other flags
|
|
69
|
+
|
|
70
|
+
| Flag | Effect |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `-y`, `--yes` | Skip confirmations; assumes `--project` |
|
|
73
|
+
| `-f`, `--force` | Overwrite or remove collisions |
|
|
74
|
+
| `-h`, `--help` | Full flag list |
|
|
75
|
+
|
|
76
|
+
Flags let the installer run unattended. Without a terminal it never guesses:
|
|
77
|
+
missing `--plugin`, `--agent`, or a scope flag is an error naming the flag,
|
|
78
|
+
rather than a hang.
|
|
35
79
|
|
|
36
80
|
## Plugins
|
|
37
81
|
|
|
38
|
-
| Plugin | Description
|
|
39
|
-
| -------------------- |
|
|
40
|
-
| `solution-architect` | Solution-architecture toolkit: interview-driven architecture documentation with interactive diagrams and provenance-tagged facts, AI-aware project estimation, and client-ready proposals.
|
|
82
|
+
| Plugin | Description | Version |
|
|
83
|
+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
84
|
+
| `solution-architect` | Solution-architecture toolkit: interview-driven architecture documentation with interactive diagrams and provenance-tagged facts, AI-aware project estimation, and client-ready proposals. | 1.0.0 |
|
|
41
85
|
| `lmk` | Terminal-native visual explainer: explains the current topic with cheap diagrams (flowcharts, sequences, timelines, tables) rendered directly in the terminal via a bundled Mermaid renderer. | 0.1.0 |
|
|
42
86
|
|
|
43
87
|
## Skills
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v11g/agents-rock",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/
|
|
25
|
+
"url": "https://github.com/v11g/agents-rock.git"
|
|
26
26
|
},
|
|
27
|
-
"license": "MIT"
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@clack/prompts": "^1.7.0",
|
|
30
|
+
"picocolors": "^1.1.1"
|
|
31
|
+
}
|
|
28
32
|
}
|
package/src/cli/agents.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Per-agent home directory plus the env var that relocates it. Both are only
|
|
3
|
+
* consulted for user scope; project scope always nests inside the project root.
|
|
4
|
+
*/
|
|
5
|
+
export const AGENT_HOMES = {
|
|
6
|
+
claude: { dir: '.claude', env: 'CLAUDE_CONFIG_DIR' },
|
|
7
|
+
codex: { dir: '.codex', env: 'CODEX_HOME' },
|
|
8
|
+
};
|
|
2
9
|
|
|
3
|
-
export const
|
|
4
|
-
export const ALL_AGENTS = Object.keys(AGENT_DIRS);
|
|
10
|
+
export const ALL_AGENTS = Object.keys(AGENT_HOMES);
|
|
5
11
|
|
|
6
|
-
export
|
|
7
|
-
return path.join(cwd, AGENT_DIRS[agent], 'skills');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function canonicalSkillsDir(cwd) {
|
|
11
|
-
return path.join(cwd, '.agents', 'skills');
|
|
12
|
-
}
|
|
12
|
+
export const AGENT_LABELS = { claude: 'Claude Code', codex: 'Codex' };
|
package/src/cli/args.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
|
+
import { ALL_AGENTS } from './agents.mjs';
|
|
2
3
|
|
|
3
4
|
export class UsageError extends Error {}
|
|
4
5
|
|
|
5
|
-
export const VALID_AGENTS = ['claude', 'codex'];
|
|
6
6
|
const COMMANDS = new Set(['install', 'uninstall']);
|
|
7
7
|
|
|
8
8
|
const OPTIONS = {
|
|
9
9
|
plugin: { type: 'string', multiple: true, short: 'p' },
|
|
10
10
|
agent: { type: 'string', multiple: true, short: 'a' },
|
|
11
|
+
global: { type: 'boolean', short: 'g' },
|
|
12
|
+
project: { type: 'boolean' },
|
|
13
|
+
dir: { type: 'string' },
|
|
14
|
+
yes: { type: 'boolean', short: 'y' },
|
|
11
15
|
force: { type: 'boolean', short: 'f' },
|
|
12
16
|
help: { type: 'boolean', short: 'h' },
|
|
13
17
|
version: { type: 'boolean', short: 'v' },
|
|
@@ -23,6 +27,9 @@ export function parseCliArgs(argv) {
|
|
|
23
27
|
command,
|
|
24
28
|
plugins: values.plugin ?? [],
|
|
25
29
|
agents: values.agent ?? [],
|
|
30
|
+
scope: resolveScope(values),
|
|
31
|
+
dir: values.dir ?? null,
|
|
32
|
+
yes: values.yes ?? false,
|
|
26
33
|
force: values.force ?? false,
|
|
27
34
|
help: values.help ?? false,
|
|
28
35
|
version: values.version ?? false,
|
|
@@ -37,10 +44,22 @@ function tryParse(argv) {
|
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
function resolveScope(values) {
|
|
48
|
+
if (values.global && values.project) {
|
|
49
|
+
throw new UsageError('Pass either --global or --project, not both.');
|
|
50
|
+
}
|
|
51
|
+
if (values.global && values.dir) {
|
|
52
|
+
throw new UsageError('--dir names a project directory, so it cannot be used with --global.');
|
|
53
|
+
}
|
|
54
|
+
if (values.global) return 'user';
|
|
55
|
+
if (values.project || values.dir) return 'project';
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
function validateAgents(agents) {
|
|
41
60
|
for (const agent of agents) {
|
|
42
|
-
if (!
|
|
43
|
-
throw new UsageError(`Unknown agent: ${agent}. Valid agents: ${
|
|
61
|
+
if (!ALL_AGENTS.includes(agent)) {
|
|
62
|
+
throw new UsageError(`Unknown agent: ${agent}. Valid agents: ${ALL_AGENTS.join(', ')}`);
|
|
44
63
|
}
|
|
45
64
|
}
|
|
46
65
|
}
|
package/src/cli/flow.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { UsageError } from './args.mjs';
|
|
4
|
+
import { ALL_AGENTS } from './agents.mjs';
|
|
5
|
+
import { findProjectRoot } from './scope.mjs';
|
|
6
|
+
import { resolveTargets } from './targets.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Turn flags plus prompt answers into a fully resolved install plan.
|
|
10
|
+
* Returns null when the user cancels or declines, so callers exit cleanly.
|
|
11
|
+
*/
|
|
12
|
+
export async function buildPlan({ args, registry, prompts, ctx }) {
|
|
13
|
+
const input = withDefaults({ args, registry, prompts, ctx });
|
|
14
|
+
const plugins = await selectPlugins(input);
|
|
15
|
+
if (!plugins) return null;
|
|
16
|
+
const agents = await selectAgents(input);
|
|
17
|
+
if (!agents) return null;
|
|
18
|
+
const scope = await selectScope(input);
|
|
19
|
+
if (!scope) return null;
|
|
20
|
+
const root = scope === 'project' ? await selectRoot(input) : null;
|
|
21
|
+
if (scope === 'project' && !root) return null;
|
|
22
|
+
return confirmPlan(input, { plugins, agents, scope, root });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function withDefaults({ args, registry, prompts, ctx }) {
|
|
26
|
+
const full = { cwd: ctx.cwd, stopAt: ctx.stopAt, isTTY: ctx.isTTY ?? false,
|
|
27
|
+
home: ctx.home ?? homedir(), env: ctx.env ?? process.env };
|
|
28
|
+
return { args, registry, prompts, ctx: full, interactive: full.isTTY && !args.yes };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function confirmPlan({ args, prompts, ctx }, selection) {
|
|
32
|
+
const { scope, root } = selection;
|
|
33
|
+
const targets = resolveTargets({ scope, root, home: ctx.home, env: ctx.env });
|
|
34
|
+
const plan = { ...selection, targets, command: args.command, force: args.force };
|
|
35
|
+
prompts.showSummary(plan);
|
|
36
|
+
if (args.yes || !ctx.isTTY) return plan;
|
|
37
|
+
return (await prompts.confirmInstall(plan)) ? plan : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function selectPlugins({ args, registry, prompts, interactive }) {
|
|
41
|
+
if (args.plugins.length) return args.plugins.map((name) => findPlugin(registry, name));
|
|
42
|
+
if (!interactive) {
|
|
43
|
+
throw new UsageError('Missing --plugin. Pass --plugin <name>, or run in a terminal to pick.');
|
|
44
|
+
}
|
|
45
|
+
const picked = await prompts.pickPlugins(registry);
|
|
46
|
+
return picked?.length ? picked.map((name) => findPlugin(registry, name)) : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function selectAgents({ args, prompts, interactive }) {
|
|
50
|
+
if (args.agents.length) return args.agents;
|
|
51
|
+
if (args.command === 'uninstall') return ALL_AGENTS;
|
|
52
|
+
if (!interactive) {
|
|
53
|
+
throw new UsageError(`Missing --agent. Pass --agent ${ALL_AGENTS.join('|')}, or run in a terminal to pick.`);
|
|
54
|
+
}
|
|
55
|
+
const picked = await prompts.pickAgents(ALL_AGENTS);
|
|
56
|
+
return picked?.length ? picked : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function selectScope({ args, prompts, interactive }) {
|
|
60
|
+
if (args.scope) return args.scope;
|
|
61
|
+
if (args.dir || args.yes) return 'project';
|
|
62
|
+
if (!interactive) {
|
|
63
|
+
throw new UsageError('Missing install scope. Pass --global for your home dir or --project for this project.');
|
|
64
|
+
}
|
|
65
|
+
return prompts.pickScope();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function selectRoot({ args, prompts, ctx, interactive }) {
|
|
69
|
+
if (args.dir) return path.resolve(args.dir);
|
|
70
|
+
const found = findProjectRoot(ctx.cwd, ctx.stopAt);
|
|
71
|
+
if (!interactive) return found?.root ?? ctx.cwd;
|
|
72
|
+
if (found?.root === ctx.cwd) return ctx.cwd;
|
|
73
|
+
return prompts.confirmRoot({
|
|
74
|
+
detected: found?.root ?? null,
|
|
75
|
+
marker: found?.marker ?? null,
|
|
76
|
+
cwd: ctx.cwd,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function findPlugin(registry, name) {
|
|
81
|
+
const plugin = registry.find((entry) => entry.name === name);
|
|
82
|
+
if (plugin) return plugin;
|
|
83
|
+
const names = registry.map((entry) => entry.name).join(', ');
|
|
84
|
+
throw new UsageError(`Unknown plugin: ${name}. Available: ${names}`);
|
|
85
|
+
}
|
package/src/cli/install.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { cpSync, existsSync, lstatSync, mkdirSync, readlinkSync, rmSync, symlinkSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { listSkills } from './registry.mjs';
|
|
4
|
-
import { agentSkillsDir, canonicalSkillsDir } from './agents.mjs';
|
|
5
4
|
|
|
6
|
-
export function installPlugin({ pluginDir,
|
|
5
|
+
export function installPlugin({ pluginDir, targets, agents, force = false }) {
|
|
7
6
|
const result = { installed: [], skipped: [], reused: [] };
|
|
8
7
|
for (const skill of listSkills(pluginDir)) {
|
|
9
|
-
const canonical = copyCanonical({ skill,
|
|
8
|
+
const canonical = copyCanonical({ skill, targets, force, result });
|
|
10
9
|
for (const agent of agents) {
|
|
11
|
-
linkAgent({ skill: skill.name, canonical, agent,
|
|
10
|
+
linkAgent({ skill: skill.name, canonical, agent, targets, force, result });
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
return result;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
function copyCanonical({ skill,
|
|
18
|
-
const dest = path.join(
|
|
16
|
+
function copyCanonical({ skill, targets, force, result }) {
|
|
17
|
+
const dest = path.join(targets.canonical, skill.name);
|
|
19
18
|
if (existsSync(dest) && !force) {
|
|
20
19
|
result.reused.push({ skill: skill.name, path: dest });
|
|
21
20
|
return dest;
|
|
@@ -26,8 +25,8 @@ function copyCanonical({ skill, cwd, force, result }) {
|
|
|
26
25
|
return dest;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
function linkAgent({ skill, canonical, agent,
|
|
30
|
-
const linkPath = path.join(
|
|
28
|
+
function linkAgent({ skill, canonical, agent, targets, force, result }) {
|
|
29
|
+
const linkPath = path.join(targets.agentDirs[agent], skill);
|
|
31
30
|
const status = inspectLink(linkPath, canonical);
|
|
32
31
|
if (status === 'correct') return result.installed.push({ skill, agent, mode: 'linked' });
|
|
33
32
|
if (status === 'occupied' && !force) {
|
package/src/cli/main.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { parseCliArgs
|
|
5
|
+
import { parseCliArgs } from './args.mjs';
|
|
5
6
|
import { loadRegistry } from './registry.mjs';
|
|
6
|
-
import {
|
|
7
|
+
import { buildPlan } from './flow.mjs';
|
|
8
|
+
import { createPrompts } from './prompts.mjs';
|
|
7
9
|
import { installPlugin } from './install.mjs';
|
|
8
10
|
import { uninstallPlugin } from './uninstall.mjs';
|
|
9
|
-
import {
|
|
11
|
+
import { printResult } from './report.mjs';
|
|
10
12
|
|
|
11
13
|
const PACKAGE_ROOT = fileURLToPath(new URL('../..', import.meta.url));
|
|
12
14
|
|
|
@@ -25,92 +27,48 @@ async function run(argv) {
|
|
|
25
27
|
if (args.help) return printHelp();
|
|
26
28
|
if (args.version) return printVersion();
|
|
27
29
|
const registry = loadRegistry(path.join(PACKAGE_ROOT, 'plugins'));
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function resolvePlugins(args, registry) {
|
|
35
|
-
const names = registry.map((p) => p.name);
|
|
36
|
-
for (const name of args.plugins) {
|
|
37
|
-
if (!names.includes(name)) {
|
|
38
|
-
throw new UsageError(`Unknown plugin: ${name}. Available: ${names.join(', ')}`);
|
|
39
|
-
}
|
|
30
|
+
const plan = await buildPlan({ args, registry, prompts: createPrompts(), ctx: processCtx() });
|
|
31
|
+
if (!plan) {
|
|
32
|
+
console.log('Cancelled.');
|
|
33
|
+
return 0;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
requireInteractive();
|
|
43
|
-
const picked = await runPicker({
|
|
44
|
-
title: 'Select plugins:',
|
|
45
|
-
items: registry.map((p) => ({ value: p.name, label: p.name, hint: p.description })),
|
|
46
|
-
});
|
|
47
|
-
if (picked === null) throw new UsageError('Cancelled.');
|
|
48
|
-
return picked.map((n) => registry.find((p) => p.name === n));
|
|
35
|
+
return execute(plan);
|
|
49
36
|
}
|
|
50
37
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
if (picked === null) throw new UsageError('Cancelled.');
|
|
60
|
-
return picked;
|
|
38
|
+
function processCtx() {
|
|
39
|
+
return {
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
home: homedir(),
|
|
42
|
+
env: process.env,
|
|
43
|
+
isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
44
|
+
};
|
|
61
45
|
}
|
|
62
46
|
|
|
63
|
-
function
|
|
64
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
65
|
-
throw new UsageError('Missing --plugin/--agent; interactive mode requires a TTY.');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function execute({ args, plugins, agents }) {
|
|
47
|
+
function execute(plan) {
|
|
70
48
|
let skippedTotal = 0;
|
|
71
|
-
for (const plugin of plugins) {
|
|
72
|
-
const opts = {
|
|
73
|
-
|
|
74
|
-
|
|
49
|
+
for (const plugin of plan.plugins) {
|
|
50
|
+
const opts = {
|
|
51
|
+
pluginDir: plugin.dir, targets: plan.targets, agents: plan.agents, force: plan.force,
|
|
52
|
+
};
|
|
53
|
+
const result = plan.command === 'install' ? installPlugin(opts) : uninstallPlugin(opts);
|
|
54
|
+
skippedTotal += printResult(plugin.name, result);
|
|
75
55
|
}
|
|
76
56
|
return skippedTotal > 0 ? 1 : 0;
|
|
77
57
|
}
|
|
78
58
|
|
|
79
|
-
function printSummary(pluginName, result) {
|
|
80
|
-
for (const item of result.reused ?? []) {
|
|
81
|
-
console.log(`↻ ${item.skill} (canonical exists, reused)`);
|
|
82
|
-
}
|
|
83
|
-
for (const item of result.installed ?? []) {
|
|
84
|
-
console.log(`✔ ${pluginName}: ${item.skill} → ${item.agent} (${item.mode})`);
|
|
85
|
-
warnIfCopyFallback(item);
|
|
86
|
-
}
|
|
87
|
-
for (const item of result.removed ?? []) {
|
|
88
|
-
console.log(`✔ ${pluginName}: removed ${item.skill} ← ${item.agent}`);
|
|
89
|
-
}
|
|
90
|
-
for (const skill of result.canonicalRemoved ?? []) {
|
|
91
|
-
console.log(`✔ ${pluginName}: removed canonical ${skill}`);
|
|
92
|
-
}
|
|
93
|
-
for (const item of result.skipped ?? []) {
|
|
94
|
-
console.error(`✖ skipped ${item.path} — ${item.reason}`);
|
|
95
|
-
}
|
|
96
|
-
return (result.skipped ?? []).length;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function warnIfCopyFallback(item) {
|
|
100
|
-
if (item.mode !== 'copy') return;
|
|
101
|
-
console.error(
|
|
102
|
-
`⚠ ${item.skill} → ${item.agent} installed as plain copy — updates to .agents/skills will not propagate`,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
59
|
function printHelp() {
|
|
107
60
|
console.log(`Usage: agents-rock [install|uninstall] [options]
|
|
108
61
|
|
|
109
|
-
Install plugin skills for Claude Code and Codex
|
|
62
|
+
Install plugin skills for Claude Code and Codex. Run with no options for an
|
|
63
|
+
interactive picker; pass flags to run unattended.
|
|
110
64
|
|
|
111
65
|
Options:
|
|
112
66
|
-p, --plugin <name> Plugin to install/uninstall (repeatable)
|
|
113
67
|
-a, --agent <name> Target agent: claude, codex (repeatable)
|
|
68
|
+
-g, --global User scope: install under your home directory
|
|
69
|
+
--project Project scope: install under the detected project root
|
|
70
|
+
--dir <path> Project scope into <path>, skipping root detection
|
|
71
|
+
-y, --yes Skip confirmations (assumes --project)
|
|
114
72
|
-f, --force Overwrite/remove collisions
|
|
115
73
|
-h, --help Show help
|
|
116
74
|
-v, --version Show version`);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as clack from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { AGENT_LABELS } from './agents.mjs';
|
|
4
|
+
|
|
5
|
+
const HINT_WIDTH = 64;
|
|
6
|
+
const clip = (text) => (text.length > HINT_WIDTH ? `${text.slice(0, HINT_WIDTH - 1)}…` : text);
|
|
7
|
+
|
|
8
|
+
/** Interactive shell around @clack/prompts. Holds no decisions — flow.mjs owns those. */
|
|
9
|
+
export function createPrompts() {
|
|
10
|
+
return { pickPlugins, pickAgents, pickScope, confirmRoot, showSummary, confirmInstall };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function pickPlugins(registry) {
|
|
14
|
+
return unwrap(await clack.multiselect({
|
|
15
|
+
message: 'Which plugins do you want?',
|
|
16
|
+
options: registry.map((plugin) => ({
|
|
17
|
+
value: plugin.name, label: plugin.name, hint: clip(plugin.description ?? ''),
|
|
18
|
+
})),
|
|
19
|
+
required: true,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function pickAgents(agents) {
|
|
24
|
+
return unwrap(await clack.multiselect({
|
|
25
|
+
message: 'Which agents should get them?',
|
|
26
|
+
options: agents.map((agent) => ({ value: agent, label: AGENT_LABELS[agent] ?? agent })),
|
|
27
|
+
initialValues: agents,
|
|
28
|
+
required: true,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function pickScope() {
|
|
33
|
+
return unwrap(await clack.select({
|
|
34
|
+
message: 'Installation scope',
|
|
35
|
+
options: [
|
|
36
|
+
{ value: 'project', label: 'Project', hint: 'this project only, committed with your repo' },
|
|
37
|
+
{ value: 'user', label: 'User', hint: 'your home dir, available in every project' },
|
|
38
|
+
],
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function confirmRoot({ detected, marker, cwd }) {
|
|
43
|
+
if (!detected) {
|
|
44
|
+
const ok = unwrap(await clack.confirm({
|
|
45
|
+
message: `No project root found above ${pc.cyan(cwd)}. Install here anyway?`,
|
|
46
|
+
}));
|
|
47
|
+
return ok ? cwd : null;
|
|
48
|
+
}
|
|
49
|
+
return unwrap(await clack.select({
|
|
50
|
+
message: 'Install into which directory?',
|
|
51
|
+
options: [
|
|
52
|
+
{ value: detected, label: detected, hint: `project root — found ${marker}` },
|
|
53
|
+
{ value: cwd, label: cwd, hint: 'current directory' },
|
|
54
|
+
],
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function showSummary(plan) {
|
|
59
|
+
clack.note(summaryLines(plan).join('\n'), verb(plan) + ' summary');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function confirmInstall(plan) {
|
|
63
|
+
return unwrap(await clack.confirm({ message: `Proceed with ${verb(plan).toLowerCase()}?` }));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function summaryLines(plan) {
|
|
67
|
+
const agents = plan.agents.map((agent) => AGENT_LABELS[agent] ?? agent).join(', ');
|
|
68
|
+
const scope = plan.scope === 'user' ? 'user (home dir)' : `project (${plan.root})`;
|
|
69
|
+
return [
|
|
70
|
+
`${pc.dim('scope: ')}${scope}`,
|
|
71
|
+
`${pc.dim('agents:')} ${agents}`,
|
|
72
|
+
`${pc.dim('skills:')} ${pc.cyan(plan.targets.canonical)}`,
|
|
73
|
+
...plan.plugins.map((plugin) => ` ${plugin.name}`),
|
|
74
|
+
...plan.agents.map((agent) => `${pc.dim('link: ')} ${plan.targets.agentDirs[agent]}`),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function verb(plan) {
|
|
79
|
+
return plan.command === 'uninstall' ? 'Uninstall' : 'Install';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function unwrap(value) {
|
|
83
|
+
return clack.isCancel(value) ? null : value;
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function printResult(pluginName, result) {
|
|
2
|
+
for (const item of result.reused ?? []) {
|
|
3
|
+
console.log(`↻ ${item.skill} (canonical exists, reused)`);
|
|
4
|
+
}
|
|
5
|
+
for (const item of result.installed ?? []) {
|
|
6
|
+
console.log(`✔ ${pluginName}: ${item.skill} → ${item.agent} (${item.mode})`);
|
|
7
|
+
warnIfCopyFallback(item);
|
|
8
|
+
}
|
|
9
|
+
for (const item of result.removed ?? []) {
|
|
10
|
+
console.log(`✔ ${pluginName}: removed ${item.skill} ← ${item.agent}`);
|
|
11
|
+
}
|
|
12
|
+
for (const skill of result.canonicalRemoved ?? []) {
|
|
13
|
+
console.log(`✔ ${pluginName}: removed canonical ${skill}`);
|
|
14
|
+
}
|
|
15
|
+
for (const item of result.skipped ?? []) {
|
|
16
|
+
console.error(`✖ skipped ${item.path} — ${item.reason}`);
|
|
17
|
+
}
|
|
18
|
+
return (result.skipped ?? []).length;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function warnIfCopyFallback(item) {
|
|
22
|
+
if (item.mode !== 'copy') return;
|
|
23
|
+
console.error(
|
|
24
|
+
`⚠ ${item.skill} → ${item.agent} installed as plain copy — updates to the canonical skill will not propagate`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const REPO_MARKERS = ['.git'];
|
|
5
|
+
const MANIFEST_MARKERS = ['package.json', 'pyproject.toml', 'go.mod', 'Cargo.toml'];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Walk up from `cwd` looking for a project root. A repo marker anywhere up the
|
|
9
|
+
* tree outranks a nearer manifest, so a monorepo package resolves to the repo.
|
|
10
|
+
* Returns `{ root, marker }`, or null when nothing is found by `stopAt`.
|
|
11
|
+
*/
|
|
12
|
+
export function findProjectRoot(cwd, stopAt = path.parse(path.resolve(cwd)).root) {
|
|
13
|
+
return search(cwd, stopAt, REPO_MARKERS) ?? search(cwd, stopAt, MANIFEST_MARKERS);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function search(cwd, stopAt, markers) {
|
|
17
|
+
for (const dir of ancestors(cwd, stopAt)) {
|
|
18
|
+
const marker = markers.find((name) => existsSync(path.join(dir, name)));
|
|
19
|
+
if (marker) return { root: dir, marker };
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function* ancestors(cwd, stopAt) {
|
|
25
|
+
const boundary = path.resolve(stopAt);
|
|
26
|
+
let dir = path.resolve(cwd);
|
|
27
|
+
while (dir !== boundary) {
|
|
28
|
+
yield dir;
|
|
29
|
+
const parent = path.dirname(dir);
|
|
30
|
+
if (parent === dir) return;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
yield boundary;
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { UsageError } from './args.mjs';
|
|
4
|
+
import { AGENT_HOMES, ALL_AGENTS } from './agents.mjs';
|
|
5
|
+
|
|
6
|
+
const CANONICAL = ['.agents', 'skills'];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolve every path an install writes to. Both scopes share one shape —
|
|
10
|
+
* a canonical skills dir plus one skills dir per agent — so install and
|
|
11
|
+
* uninstall stay scope-agnostic.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveTargets({ scope, root, home = homedir(), env = process.env }) {
|
|
14
|
+
if (scope === 'project') return projectTargets(requireRoot(root));
|
|
15
|
+
if (scope === 'user') return userTargets(home, env);
|
|
16
|
+
throw new UsageError(`Unknown scope: ${scope}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function requireRoot(root) {
|
|
20
|
+
if (!root) throw new UsageError('Project scope needs a project root.');
|
|
21
|
+
return root;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function projectTargets(root) {
|
|
25
|
+
return {
|
|
26
|
+
canonical: path.join(root, ...CANONICAL),
|
|
27
|
+
agentDirs: mapAgents((agent) => path.join(root, AGENT_HOMES[agent].dir, 'skills')),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function userTargets(home, env) {
|
|
32
|
+
return {
|
|
33
|
+
canonical: path.join(home, ...CANONICAL),
|
|
34
|
+
agentDirs: mapAgents((agent) => path.join(agentHome(agent, home, env), 'skills')),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function agentHome(agent, home, env) {
|
|
39
|
+
const { dir, env: key } = AGENT_HOMES[agent];
|
|
40
|
+
return env[key]?.trim() || path.join(home, dir);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function mapAgents(dirFor) {
|
|
44
|
+
return Object.fromEntries(ALL_AGENTS.map((agent) => [agent, dirFor(agent)]));
|
|
45
|
+
}
|
package/src/cli/uninstall.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { existsSync, lstatSync, rmSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { listSkills } from './registry.mjs';
|
|
4
|
-
import { agentSkillsDir, canonicalSkillsDir, ALL_AGENTS } from './agents.mjs';
|
|
5
4
|
|
|
6
|
-
export function uninstallPlugin({ pluginDir,
|
|
5
|
+
export function uninstallPlugin({ pluginDir, targets, agents, force = false }) {
|
|
7
6
|
const result = { removed: [], canonicalRemoved: [], skipped: [] };
|
|
8
7
|
for (const skill of listSkills(pluginDir)) {
|
|
9
8
|
for (const agent of agents) {
|
|
10
|
-
removeAgentEntry({ skill: skill.name, agent,
|
|
9
|
+
removeAgentEntry({ skill: skill.name, agent, targets, force, result });
|
|
11
10
|
}
|
|
12
|
-
maybeRemoveCanonical(skill.name,
|
|
11
|
+
maybeRemoveCanonical(skill.name, targets, result);
|
|
13
12
|
}
|
|
14
13
|
return result;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
function removeAgentEntry({ skill, agent,
|
|
18
|
-
const linkPath = path.join(
|
|
16
|
+
function removeAgentEntry({ skill, agent, targets, force, result }) {
|
|
17
|
+
const linkPath = path.join(targets.agentDirs[agent], skill);
|
|
19
18
|
let stat;
|
|
20
19
|
try { stat = lstatSync(linkPath); } catch { return; }
|
|
21
20
|
if (!stat.isSymbolicLink() && !force) {
|
|
@@ -25,13 +24,13 @@ function removeAgentEntry({ skill, agent, cwd, force, result }) {
|
|
|
25
24
|
result.removed.push({ skill, agent });
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
function maybeRemoveCanonical(skill,
|
|
29
|
-
const stillReferenced =
|
|
30
|
-
try { return Boolean(lstatSync(path.join(
|
|
27
|
+
function maybeRemoveCanonical(skill, targets, result) {
|
|
28
|
+
const stillReferenced = Object.values(targets.agentDirs).some((dir) => {
|
|
29
|
+
try { return Boolean(lstatSync(path.join(dir, skill))); }
|
|
31
30
|
catch { return false; }
|
|
32
31
|
});
|
|
33
32
|
if (stillReferenced) return;
|
|
34
|
-
const canonical = path.join(
|
|
33
|
+
const canonical = path.join(targets.canonical, skill);
|
|
35
34
|
if (!existsSync(canonical)) return;
|
|
36
35
|
rmSync(canonical, { recursive: true, force: true });
|
|
37
36
|
result.canonicalRemoved.push(skill);
|
package/src/cli/picker.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import readline from 'node:readline';
|
|
2
|
-
|
|
3
|
-
export function createPickerState(items) {
|
|
4
|
-
return { items, cursor: 0, selected: new Set() };
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function reduceKey(state, key) {
|
|
8
|
-
if (key === 'up') return { ...state, cursor: Math.max(0, state.cursor - 1) };
|
|
9
|
-
if (key === 'down') {
|
|
10
|
-
return { ...state, cursor: Math.min(state.items.length - 1, state.cursor + 1) };
|
|
11
|
-
}
|
|
12
|
-
if (key === 'space') return toggle(state);
|
|
13
|
-
return state;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function toggle(state) {
|
|
17
|
-
const selected = new Set(state.selected);
|
|
18
|
-
const value = state.items[state.cursor].value;
|
|
19
|
-
if (selected.has(value)) selected.delete(value);
|
|
20
|
-
else selected.add(value);
|
|
21
|
-
return { ...state, selected };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function renderPicker(state, title) {
|
|
25
|
-
const rows = state.items.map((item, i) => {
|
|
26
|
-
const cursor = i === state.cursor ? '>' : ' ';
|
|
27
|
-
const mark = state.selected.has(item.value) ? '[x]' : '[ ]';
|
|
28
|
-
const hint = item.hint ? ` ${item.hint}` : '';
|
|
29
|
-
return `${cursor} ${mark} ${item.label}${hint}`;
|
|
30
|
-
});
|
|
31
|
-
return [title, ...rows, '(space: toggle, enter: confirm, ctrl-c: cancel)'].join('\n');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function runPicker({ title, items }) {
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
const session = { state: createPickerState(items), title, rendered: 0 };
|
|
37
|
-
readline.emitKeypressEvents(process.stdin);
|
|
38
|
-
process.stdin.setRawMode(true);
|
|
39
|
-
process.stdin.resume();
|
|
40
|
-
const onKey = makeKeyHandler(session, (value) => {
|
|
41
|
-
teardown(onKey);
|
|
42
|
-
resolve(value);
|
|
43
|
-
});
|
|
44
|
-
process.stdin.on('keypress', onKey);
|
|
45
|
-
draw(session);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function makeKeyHandler(session, finish) {
|
|
50
|
-
return (str, key) => {
|
|
51
|
-
try {
|
|
52
|
-
if (key.ctrl && key.name === 'c') return finish(null);
|
|
53
|
-
if (key.name === 'return') return finish([...session.state.selected]);
|
|
54
|
-
session.state = reduceKey(session.state, keyName(key));
|
|
55
|
-
draw(session);
|
|
56
|
-
} catch {
|
|
57
|
-
finish(null);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function keyName(key) {
|
|
63
|
-
if (key.name === 'up' || key.name === 'down' || key.name === 'space') return key.name;
|
|
64
|
-
return '';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function draw(session) {
|
|
68
|
-
if (session.rendered > 0) process.stdout.write(`\x1b[${session.rendered}A\x1b[J`);
|
|
69
|
-
const text = renderPicker(session.state, session.title);
|
|
70
|
-
session.rendered = text.split('\n').length;
|
|
71
|
-
process.stdout.write(text + '\n');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function teardown(onKey) {
|
|
75
|
-
process.stdin.setRawMode(false);
|
|
76
|
-
process.stdin.pause();
|
|
77
|
-
process.stdin.removeListener('keypress', onKey);
|
|
78
|
-
}
|