@v11g/agents-rock 1.0.1 → 1.0.3
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/business-analyst/.claude-plugin/plugin.json +9 -0
- package/plugins/business-analyst/skills/business-analyst/README.md +20 -0
- package/plugins/business-analyst/skills/business-analyst/SKILL.md +69 -0
- package/plugins/business-analyst/skills/business-analyst/references/ai-extension.md +37 -0
- package/plugins/business-analyst/skills/business-analyst/references/frameworks.md +53 -0
- package/plugins/business-analyst/skills/business-analyst/references/interview.md +89 -0
- package/plugins/business-analyst/skills/business-analyst/references/review.md +25 -0
- package/plugins/business-analyst/skills/business-analyst/references/writing.md +102 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/lib/checks.mjs +166 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/lib/schema.mjs +78 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/checks.test.mjs +188 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/e2e.test.mjs +17 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-fail.json +205 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.json +59 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/fixtures/requirements-pass.md +63 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/test/schema.test.mjs +41 -0
- package/plugins/business-analyst/skills/business-analyst/scripts/validate.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/README.md +1 -1
- package/plugins/solution-architect/skills/estimate/SKILL.md +13 -5
- package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +917 -0
- package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +430 -13
- package/plugins/solution-architect/skills/estimate/references/agentic-estimation.md +148 -0
- package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +10 -0
- package/plugins/solution-architect/skills/estimate/references/interview.md +20 -1
- package/plugins/solution-architect/skills/estimate/references/task-shapes.md +173 -0
- package/plugins/solution-architect/skills/estimate/references/writing.md +31 -0
- package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +5 -1
- package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +65 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/baselines.mjs +107 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +16 -7
- package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +14 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/measurements.mjs +59 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +28 -5
- package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +53 -22
- package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +52 -7
- package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -3
- package/plugins/solution-architect/skills/estimate/scripts/test/baselines.test.mjs +120 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +69 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +44 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +28 -1
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-fail.md +55 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-pass.md +54 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +45 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/measurements.jsonl +20 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/measurements.test.mjs +54 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +25 -1
- package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +48 -1
- package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +59 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +37 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +168 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/zip.mjs +41 -0
- package/plugins/solution-architect/skills/new-lead/SKILL.md +15 -10
- 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
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// The Feature breakdown's spreadsheet export: an internal-only button that
|
|
2
|
+
// clones the sample estimator workbook in the browser, fills tab 1 with the
|
|
3
|
+
// currently visible rows, and keeps every tier/price formula live in-cell.
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { mkdtempSync } from 'node:fs';
|
|
7
|
+
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
11
|
+
import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
|
|
12
|
+
import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
|
|
13
|
+
import { readZip } from './zip.mjs';
|
|
14
|
+
|
|
15
|
+
const skip = { skip: !findChrome() && 'no chrome on PATH' };
|
|
16
|
+
const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
|
|
17
|
+
|
|
18
|
+
function buildPage() {
|
|
19
|
+
const dir = mkdtempSync(join(tmpdir(), 'estimate-xlsx-'));
|
|
20
|
+
const scripts = new URL('..', import.meta.url).pathname;
|
|
21
|
+
const passMd = join(scripts, 'test/fixtures/estimation-pass.md');
|
|
22
|
+
execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', fixture, '--out', join(dir, 'estimation.json')]);
|
|
23
|
+
execFileSync('node', [join(scripts, 'render.mjs'), '--json', join(dir, 'estimation.json'), '--md', passMd, '--out', dir]);
|
|
24
|
+
return pathToFileURL(join(dir, 'estimate.html')).href;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function exportedFiles(page) {
|
|
28
|
+
const b64 = await page.eval('window.__buildWorkbook()');
|
|
29
|
+
return readZip(Buffer.from(b64, 'base64'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const sheet1 = (files) => files.get('xl/worksheets/sheet1.xml').toString('utf8');
|
|
33
|
+
const cell = (xml, ref) => new RegExp(`<c r="${ref}"[^>]*>(.*?)</c>`, 's').exec(xml)?.[1] ?? '';
|
|
34
|
+
const inlineText = (frag) => /<t[^>]*>([^<]*)<\/t>/.exec(frag)?.[1];
|
|
35
|
+
const cellNumber = (frag) => Number(/<v>([^<]*)<\/v>/.exec(frag)?.[1]);
|
|
36
|
+
const cellFormula = (frag) => /<f>([^<]*)<\/f>/.exec(frag)?.[1];
|
|
37
|
+
|
|
38
|
+
test('the breakdown filter bar carries an internal-only download button', skip, async () => {
|
|
39
|
+
const page = await openPage(buildPage());
|
|
40
|
+
try {
|
|
41
|
+
assert.ok(await page.eval(
|
|
42
|
+
`!!document.querySelector('#feature-table .bd-filters button[data-download][data-internal]')`),
|
|
43
|
+
'expected a data-download button marked data-internal in the filter bar');
|
|
44
|
+
} finally { page.close(); }
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('the export clones the sample workbook with its guide tabs intact', skip, async () => {
|
|
48
|
+
const page = await openPage(buildPage());
|
|
49
|
+
try {
|
|
50
|
+
const files = await exportedFiles(page);
|
|
51
|
+
for (const name of ['xl/worksheets/sheet1.xml', 'xl/worksheets/sheet2.xml',
|
|
52
|
+
'xl/worksheets/sheet3.xml', 'xl/styles.xml', '[Content_Types].xml']) {
|
|
53
|
+
assert.ok(files.has(name), `${name} missing from the exported archive`);
|
|
54
|
+
}
|
|
55
|
+
const workbook = files.get('xl/workbook.xml').toString('utf8');
|
|
56
|
+
assert.match(workbook, /Scoring Guide/);
|
|
57
|
+
assert.match(workbook, /Tier Reference/);
|
|
58
|
+
} finally { page.close(); }
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('rows land as inline strings ordered by milestone with derived 1-5 scores', skip, async () => {
|
|
62
|
+
const page = await openPage(buildPage());
|
|
63
|
+
try {
|
|
64
|
+
const xml = sheet1(await exportedFiles(page));
|
|
65
|
+
// M1 feature before M2 feature regardless of the table's hour sort
|
|
66
|
+
assert.equal(inlineText(cell(xml, 'A7')), 'User can book appointment');
|
|
67
|
+
assert.equal(inlineText(cell(xml, 'A8')), 'Email reminders');
|
|
68
|
+
for (const row of [7, 8]) {
|
|
69
|
+
for (const col of ['B', 'C', 'D', 'E', 'F']) {
|
|
70
|
+
const v = cellNumber(cell(xml, `${col}${row}`));
|
|
71
|
+
assert.ok(Number.isInteger(v) && v >= 1 && v <= 5, `${col}${row} must be 1-5, got ${v}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} finally { page.close(); }
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('tech and size scores follow the Scoring Guide definitions', skip, async () => {
|
|
78
|
+
const page = await openPage(buildPage());
|
|
79
|
+
try {
|
|
80
|
+
const xml = sheet1(await exportedFiles(page));
|
|
81
|
+
// TECH: hours-weighted category score (boilerplate 1.5, logic 3, novel 5).
|
|
82
|
+
// Booking mixes boilerplate(25.3h) + logic(44h) → 2.45 → 2; reminders is
|
|
83
|
+
// logic-only → 3.
|
|
84
|
+
assert.equal(cellNumber(cell(xml, 'B7')), 2);
|
|
85
|
+
assert.equal(cellNumber(cell(xml, 'B8')), 3);
|
|
86
|
+
// SIZE: absolute expected-hour bands [8, 24, 64, 128] per the guide's
|
|
87
|
+
// "<1 day → epic" scale. Booking ≈69h → 4; reminders ≈21h → 2.
|
|
88
|
+
assert.equal(cellNumber(cell(xml, 'C7')), 4);
|
|
89
|
+
assert.equal(cellNumber(cell(xml, 'C8')), 2);
|
|
90
|
+
} finally { page.close(); }
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('score math stays in the sheet: G-K are formulas, total row uses SUMIF', skip, async () => {
|
|
94
|
+
const page = await openPage(buildPage());
|
|
95
|
+
try {
|
|
96
|
+
const xml = sheet1(await exportedFiles(page));
|
|
97
|
+
assert.match(cellFormula(cell(xml, 'G7')) ?? '', /SUM\(B7:F7\)/);
|
|
98
|
+
assert.match(cellFormula(cell(xml, 'H7')) ?? '', /IF\(/);
|
|
99
|
+
for (const ref of ['I7', 'J7', 'K7']) {
|
|
100
|
+
assert.ok(cellFormula(cell(xml, ref)), `${ref} must hold a formula, not a baked value`);
|
|
101
|
+
}
|
|
102
|
+
assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL');
|
|
103
|
+
assert.match(cellFormula(cell(xml, 'G27')) ?? '', /SUMIF\(G7:G26/);
|
|
104
|
+
} finally { page.close(); }
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('milestone and container fill L/M under an autofiltered header', skip, async () => {
|
|
108
|
+
const page = await openPage(buildPage());
|
|
109
|
+
try {
|
|
110
|
+
const xml = sheet1(await exportedFiles(page));
|
|
111
|
+
assert.equal(inlineText(cell(xml, 'L6')), 'MILESTONE');
|
|
112
|
+
assert.equal(inlineText(cell(xml, 'M6')), 'CONTAINER');
|
|
113
|
+
assert.equal(inlineText(cell(xml, 'L7')), 'M1 - Booking core');
|
|
114
|
+
assert.equal(inlineText(cell(xml, 'M7')), 'Booking API');
|
|
115
|
+
assert.equal(inlineText(cell(xml, 'M8')), 'Notification Service');
|
|
116
|
+
assert.match(xml, /<autoFilter ref="A6:M26"\/>/);
|
|
117
|
+
} finally { page.close(); }
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('the export honours the active source filter', skip, async () => {
|
|
121
|
+
const page = await openPage(buildPage());
|
|
122
|
+
try {
|
|
123
|
+
await page.eval(`document.querySelector('#feature-table [data-prov="stated"]').click()`);
|
|
124
|
+
const xml = sheet1(await exportedFiles(page));
|
|
125
|
+
assert.match(xml, /User can book appointment/);
|
|
126
|
+
assert.doesNotMatch(xml, /Email reminders/);
|
|
127
|
+
assert.equal(inlineText(cell(xml, 'A27')), 'PROJECT TOTAL', 'total row must survive filtering');
|
|
128
|
+
} finally { page.close(); }
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const sheetTasks = (files) => files.get('xl/worksheets/sheet4.xml')?.toString('utf8') ?? '';
|
|
132
|
+
|
|
133
|
+
test('the export adds a registered Task Breakdown tab', skip, async () => {
|
|
134
|
+
const page = await openPage(buildPage());
|
|
135
|
+
try {
|
|
136
|
+
const files = await exportedFiles(page);
|
|
137
|
+
assert.ok(files.has('xl/worksheets/sheet4.xml'), 'sheet4.xml missing');
|
|
138
|
+
assert.match(files.get('xl/workbook.xml').toString('utf8'), /name="Task Breakdown"/);
|
|
139
|
+
assert.match(files.get('xl/_rels/workbook.xml.rels').toString('utf8'), /Target="worksheets\/sheet4\.xml"/);
|
|
140
|
+
assert.match(files.get('[Content_Types].xml').toString('utf8'), /PartName="\/xl\/worksheets\/sheet4\.xml"/);
|
|
141
|
+
} finally { page.close(); }
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('task rows carry the PERT formula in-cell and ride the feature filter', skip, async () => {
|
|
145
|
+
const page = await openPage(buildPage());
|
|
146
|
+
try {
|
|
147
|
+
await page.eval(`document.querySelector('#feature-table [data-prov="stated"]').click()`);
|
|
148
|
+
const xml = sheetTasks(await exportedFiles(page));
|
|
149
|
+
assert.equal(inlineText(cell(xml, 'A2')), 'User can book appointment');
|
|
150
|
+
assert.equal(inlineText(cell(xml, 'B2')), 'Booking CRUD API');
|
|
151
|
+
assert.deepEqual(['D2', 'E2', 'F2'].map((r) => cellNumber(cell(xml, r))), [16, 24, 40]);
|
|
152
|
+
assert.match(cellFormula(cell(xml, 'G2')) ?? '', /\(D2\+4\*E2\+F2\)\/6/);
|
|
153
|
+
assert.equal(inlineText(cell(xml, 'H2')), 'HIGH');
|
|
154
|
+
assert.equal(inlineText(cell(xml, 'K2')), 'Booking API');
|
|
155
|
+
assert.doesNotMatch(xml, /Scheduled reminder jobs/, 'filtered-out feature tasks must not export');
|
|
156
|
+
} finally { page.close(); }
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('the task tab is filterable and sortable: autofilter over a frozen header', skip, async () => {
|
|
160
|
+
const page = await openPage(buildPage());
|
|
161
|
+
try {
|
|
162
|
+
const xml = sheetTasks(await exportedFiles(page));
|
|
163
|
+
assert.equal(inlineText(cell(xml, 'A1')), 'FEATURE');
|
|
164
|
+
// 3 fixture tasks under rows 2-4
|
|
165
|
+
assert.match(xml, /<autoFilter ref="A1:K4"\/>/);
|
|
166
|
+
assert.match(xml, /<pane ySplit="1"[^>]*state="frozen"/);
|
|
167
|
+
} finally { page.close(); }
|
|
168
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Minimal zip reader for asserting on workbooks the page exports.
|
|
2
|
+
// Central-directory driven: find EOCD, walk entries, inflate each.
|
|
3
|
+
import { inflateRawSync } from 'node:zlib';
|
|
4
|
+
|
|
5
|
+
function eocdOffset(buf) {
|
|
6
|
+
for (let i = buf.length - 22; i >= 0; i--) {
|
|
7
|
+
if (buf.readUInt32LE(i) === 0x06054b50) return i;
|
|
8
|
+
}
|
|
9
|
+
throw new Error('no end-of-central-directory record');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function entryData(buf, cd) {
|
|
13
|
+
const method = buf.readUInt16LE(cd + 10);
|
|
14
|
+
const csize = buf.readUInt32LE(cd + 20);
|
|
15
|
+
const local = buf.readUInt32LE(cd + 42);
|
|
16
|
+
const nameLen = buf.readUInt16LE(local + 26);
|
|
17
|
+
const extraLen = buf.readUInt16LE(local + 28);
|
|
18
|
+
const start = local + 30 + nameLen + extraLen;
|
|
19
|
+
const raw = buf.subarray(start, start + csize);
|
|
20
|
+
if (method === 0) return Buffer.from(raw);
|
|
21
|
+
if (method === 8) return inflateRawSync(raw);
|
|
22
|
+
throw new Error(`unsupported compression method ${method}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Returns Map<path, Buffer> of every file in the archive.
|
|
26
|
+
export function readZip(buf) {
|
|
27
|
+
const eocd = eocdOffset(buf);
|
|
28
|
+
const count = buf.readUInt16LE(eocd + 10);
|
|
29
|
+
let cd = buf.readUInt32LE(eocd + 16);
|
|
30
|
+
const files = new Map();
|
|
31
|
+
for (let i = 0; i < count; i++) {
|
|
32
|
+
if (buf.readUInt32LE(cd) !== 0x02014b50) throw new Error('bad central directory');
|
|
33
|
+
const nameLen = buf.readUInt16LE(cd + 28);
|
|
34
|
+
const extraLen = buf.readUInt16LE(cd + 30);
|
|
35
|
+
const commentLen = buf.readUInt16LE(cd + 32);
|
|
36
|
+
const name = buf.toString('utf8', cd + 46, cd + 46 + nameLen);
|
|
37
|
+
files.set(name, entryData(buf, cd));
|
|
38
|
+
cd += 46 + nameLen + extraLen + commentLen;
|
|
39
|
+
}
|
|
40
|
+
return files;
|
|
41
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: new-lead
|
|
3
|
-
description: Set up a pre-sales lead workspace and walk the human through the
|
|
3
|
+
description: Set up a pre-sales lead workspace and walk the human through the solution-architect skills in order — business-analyst first when installed, then analyze-requirements, estimate, proposal — plus a local leads dashboard. Use when the user says "new lead", points at a folder under leads/, or asks to see their leads pipeline.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# new-lead
|
|
7
7
|
|
|
8
|
-
Prepare a lead's workspace, then run `/
|
|
9
|
-
`/proposal` in that order, stopping
|
|
10
|
-
produced. Also maintains the leads dashboard: a `leads.json` registry and a
|
|
8
|
+
Prepare a lead's workspace, then run `/business-analyst` (when installed),
|
|
9
|
+
`/analyze-requirements`, `/estimate` and `/proposal` in that order, stopping
|
|
10
|
+
between each so the human sees what was produced. Also maintains the leads dashboard: a `leads.json` registry and a
|
|
11
11
|
self-contained local server.
|
|
12
12
|
|
|
13
13
|
## Hard rules
|
|
@@ -45,10 +45,15 @@ self-contained local server.
|
|
|
45
45
|
- `/new-lead` with no argument → diff `readdir(<root>/leads)` against
|
|
46
46
|
`leads.json` and print the state table below; the human picks one.
|
|
47
47
|
4. **Adopt** (only when the folder has no registry entry) — see Adoption.
|
|
48
|
-
5. **Chain**:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
5. **Chain**: when the `business-analyst` skill is available, the chain is
|
|
49
|
+
`/business-analyst`, `/analyze-requirements`, `/estimate`, `/proposal`;
|
|
50
|
+
otherwise recommend installing the business-analyst plugin in one line
|
|
51
|
+
(requirements discovery before architecture) and run the three-step
|
|
52
|
+
chain. For each step — `cd` to the lead directory, invoke the skill,
|
|
53
|
+
and when it returns, report what it wrote and wait. Skip any step whose
|
|
54
|
+
artifact already exists unless the human asks for a re-run.
|
|
55
|
+
`requirements.json` is soft evidence for the later skills, never a
|
|
56
|
+
prerequisite.
|
|
52
57
|
6. **Sync the registry** after `/proposal` — see Registry sync.
|
|
53
58
|
7. **Wrap**: start the dashboard (`sh <root>/start.sh`) if it is not already
|
|
54
59
|
running, and report the URL.
|
|
@@ -58,8 +63,8 @@ self-contained local server.
|
|
|
58
63
|
| State | Condition | Offer |
|
|
59
64
|
| --- | --- | --- |
|
|
60
65
|
| new | folder present, no registry entry | adopt, then run the chain |
|
|
61
|
-
| WIP | entry present, one of `ARCHITECTURE.md` / `estimation.json` / `proposal.md` missing | resume at the first gap |
|
|
62
|
-
| done | entry present,
|
|
66
|
+
| WIP | entry present, one of `requirements.json` (checked only when the business-analyst skill is installed) / `ARCHITECTURE.md` / `estimation.json` / `proposal.md` missing | resume at the first gap |
|
|
67
|
+
| done | entry present, no artifact from the WIP row missing | nothing; re-run a named step on request |
|
|
63
68
|
| orphan | entry present, folder gone | report only — never delete |
|
|
64
69
|
|
|
65
70
|
## Adoption
|
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`);
|