@v11g/agents-rock 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +65 -0
  2. package/bin/agents-rock.mjs +4 -0
  3. package/package.json +13 -0
  4. package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
  5. package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
  6. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
  7. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
  8. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  10. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  11. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  12. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  13. package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
  14. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
  15. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
  16. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
  17. package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
  18. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
  19. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
  20. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
  21. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
  22. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
  23. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
  26. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
  27. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
  28. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
  29. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
  30. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
  31. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
  32. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
  33. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
  34. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
  38. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
  39. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
  40. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
  41. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
  42. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
  43. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
  44. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
  45. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
  46. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
  47. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
  48. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
  49. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
  50. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
  51. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
  52. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
  53. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
  54. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
  55. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
  56. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
  57. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
  58. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
  59. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
  60. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
  61. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
  62. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
  63. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
  64. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
  65. package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
  66. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
  67. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
  68. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
  74. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
  75. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
  77. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
  78. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
  79. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
  112. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
  113. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
  114. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
  115. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
  116. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
  117. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
  118. package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
  119. package/plugins/solution-architect/skills/estimate/README.md +67 -0
  120. package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
  121. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
  122. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
  123. package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
  124. package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
  125. package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
  126. package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
  127. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
  128. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
  129. package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
  130. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
  131. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
  132. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
  133. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
  134. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
  135. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
  136. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
  137. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
  138. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
  139. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
  140. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
  141. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
  142. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
  143. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
  144. package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
  145. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
  146. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
  147. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
  149. package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
  150. package/plugins/solution-architect/skills/new-lead/README.md +48 -0
  151. package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
  152. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
  153. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
  154. package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
  155. package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
  156. package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
  157. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
  158. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
  159. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
  160. package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
  161. package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
  162. package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
  163. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
  164. package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
  165. package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
  166. package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
  167. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
  168. package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
  169. package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
  170. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
  171. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
  172. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
  173. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
  174. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
  175. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
  176. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
  177. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
  178. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
  179. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
  180. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
  181. package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
  182. package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
  183. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
  184. package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
  185. package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
  186. package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
  187. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
  188. package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
  189. package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
  190. package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
  191. package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
  192. package/plugins/solution-architect/skills/proposal/README.md +36 -0
  193. package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
  194. package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
  195. package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
  196. package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
  197. package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
  198. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
  203. package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
  204. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
  205. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
  206. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
  207. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
  209. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
  210. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
  211. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
  212. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
  213. package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
  214. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
  215. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
  216. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
  217. package/src/cli/agents.mjs +12 -0
  218. package/src/cli/args.mjs +46 -0
  219. package/src/cli/install.mjs +68 -0
  220. package/src/cli/main.mjs +124 -0
  221. package/src/cli/picker.mjs +78 -0
  222. package/src/cli/registry.mjs +26 -0
  223. package/src/cli/uninstall.mjs +38 -0
@@ -0,0 +1,51 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import { JARGON } from '../lib/jargon.mjs';
5
+
6
+ const doc = (p) => readFileSync(new URL(`../../${p}`, import.meta.url), 'utf8');
7
+ const REFS = ['references/interview.md', 'references/writing.md', 'references/review.md'];
8
+
9
+ test('no skill doc carries placeholders', () => {
10
+ for (const f of ['SKILL.md', 'README.md', ...REFS]) {
11
+ assert.doesNotMatch(doc(f), /\bTBD\b|\bTODO\b/, f);
12
+ }
13
+ });
14
+
15
+ test('SKILL.md names the pipeline, both hard prerequisites, and the review gate', () => {
16
+ const skill = doc('SKILL.md');
17
+ assert.match(skill, /^name: proposal$/m);
18
+ for (const needle of ['ARCHITECTURE.md', 'estimation.json', 'derive.mjs', 'validate.mjs',
19
+ 'render.mjs', 'serve.mjs', 'references/interview.md', 'references/writing.md',
20
+ 'references/review.md', 'mermaid', 'Human review']) {
21
+ assert.ok(skill.includes(needle), `SKILL.md missing: ${needle}`);
22
+ }
23
+ });
24
+
25
+ test('interview.md carries the prereq gate, tech levels, scenario pick, and profile scopes', () => {
26
+ const d = doc('references/interview.md');
27
+ for (const needle of ['non-tech', 'low-tech', 'technical', 'scenario',
28
+ 'valid', 'proposal-profile.json', '.claude/', 'stop']) {
29
+ assert.ok(d.includes(needle), `interview.md missing: ${needle}`);
30
+ }
31
+ });
32
+
33
+ test('writing.md states every validator rule family and the ten sections', () => {
34
+ const d = doc('references/writing.md');
35
+ for (const needle of ['Executive Summary', 'Background & Objectives', 'Proposed Solution',
36
+ 'Scope', 'Out of Scope & Assumptions', 'Delivery Approach', 'Investment & Timeline',
37
+ 'Team', 'About', 'Next Steps', 'valid_until', 'jargon_allow', 'proposal-figures.json',
38
+ 'Never write a number', 'rates']) {
39
+ assert.ok(d.includes(needle), `writing.md missing: ${needle}`);
40
+ }
41
+ for (const term of ['kubernetes', 'api']) {
42
+ assert.ok(JARGON.includes(term), `jargon list lost its anchor term: ${term}`);
43
+ }
44
+ });
45
+
46
+ test('review.md dispatches a fresh-eyes subagent with the five-point charter', () => {
47
+ const d = doc('references/review.md');
48
+ for (const needle of ['fresh', 'tech level', 'hype', 'leak', 'contradiction', 'one']) {
49
+ assert.ok(d.toLowerCase().includes(needle), `review.md missing: ${needle}`);
50
+ }
51
+ });
@@ -0,0 +1,30 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ const script = (p) => new URL(p, import.meta.url).pathname;
9
+
10
+ test('compute → derive → validate → render runs clean end to end', () => {
11
+ const dir = mkdtempSync(join(tmpdir(), 'proposal-e2e-'));
12
+ const json = join(dir, 'estimation.json');
13
+ execFileSync('node', [script('../../../estimate/scripts/compute.mjs'),
14
+ '--inputs', script('../../../estimate/scripts/test/fixtures/booking-inputs.json'), '--out', json]);
15
+ execFileSync('node', [script('../derive.mjs'),
16
+ '--estimation', json, '--scenario', '2eng-max5x', '--out', join(dir, 'proposal-figures.json')]);
17
+ execFileSync('node', [script('../validate.mjs'),
18
+ '--md', script('./fixtures/proposal-pass.md'), '--estimation', json]);
19
+ const bundle = join(dir, 'mermaid.js');
20
+ writeFileSync(bundle, 'globalThis.mermaid={initialize(){},run(){}};');
21
+ execFileSync('node', [script('../render.mjs'), '--md', script('./fixtures/proposal-pass.md'),
22
+ '--estimation', json, '--mermaid-bundle', bundle, '--out', dir]);
23
+ const html = readFileSync(join(dir, 'proposal.html'), 'utf8');
24
+ assert.match(html, /Proposal — Acme Corp/);
25
+ // The figures file is an authoring aid; the rendered numbers must
26
+ // nevertheless agree with it, because both derive from estimation.json.
27
+ const figures = JSON.parse(readFileSync(join(dir, 'proposal-figures.json'), 'utf8'));
28
+ assert.match(html, new RegExp(figures.cost.low.toLocaleString('en-US')));
29
+ assert.match(html, new RegExp(figures.cost.high.toLocaleString('en-US')));
30
+ });
@@ -0,0 +1,81 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync, mkdtempSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+ import { writeFileSync } from 'node:fs';
8
+ import { deriveFigures, formatMoney } from '../lib/figures.mjs';
9
+
10
+ // Hand-checkable synthetic estimation: spread ratios are lo 0.8 / hi 1.2.
11
+ const estimation = {
12
+ inputs: {
13
+ scenarios: [{
14
+ id: 's1', plan: 'max5x',
15
+ team: [{ seniority: 'senior', rate: 50 }, { seniority: 'mid', rate: 40 }],
16
+ }],
17
+ },
18
+ computed: {
19
+ features: {
20
+ a: { hours: 100, low: 80, high: 120 },
21
+ b: { hours: 100, low: 80, high: 120 },
22
+ },
23
+ scenarios: {
24
+ s1: {
25
+ months: 2, totalCost: 10000,
26
+ roadmap: [
27
+ { milestone: 'M1', startMonths: 0, endMonths: 1.5 },
28
+ { milestone: 'M2', startMonths: 1.5, endMonths: 2 },
29
+ ],
30
+ },
31
+ },
32
+ },
33
+ };
34
+
35
+ test('figures scale totals by the feature spread ratios', () => {
36
+ const f = deriveFigures(estimation, 's1');
37
+ assert.deepEqual(f.cost, { low: 8000, high: 12000 });
38
+ assert.deepEqual(f.months, { low: 1.6, high: 2.4 });
39
+ });
40
+
41
+ test('milestone splits follow the roadmap band shares', () => {
42
+ const f = deriveFigures(estimation, 's1');
43
+ assert.deepEqual(f.milestones, [
44
+ { name: 'M1', cost: { low: 6000, high: 9000 }, months: { low: 1.2, high: 1.8 } },
45
+ { name: 'M2', cost: { low: 2000, high: 3000 }, months: { low: 0.4, high: 0.6 } },
46
+ ]);
47
+ });
48
+
49
+ test('team lists seniorities only — rates never leave the estimate', () => {
50
+ const f = deriveFigures(estimation, 's1');
51
+ assert.deepEqual(f.team, ['senior', 'mid']);
52
+ assert.doesNotMatch(JSON.stringify(f), /rate|50|40/);
53
+ });
54
+
55
+ test('no roadmap means no milestones, not a crash', () => {
56
+ const noRoadmap = structuredClone(estimation);
57
+ delete noRoadmap.computed.scenarios.s1.roadmap;
58
+ assert.deepEqual(deriveFigures(noRoadmap, 's1').milestones, []);
59
+ });
60
+
61
+ test('unknown scenario throws with the id in the message', () => {
62
+ assert.throws(() => deriveFigures(estimation, 'nope'), /scenario "nope" not in estimation\.json/);
63
+ });
64
+
65
+ test('formatMoney uses en-US grouping with a dollar sign', () => {
66
+ assert.equal(formatMoney(8000), '$8,000');
67
+ assert.equal(formatMoney(1234500), '$1,234,500');
68
+ });
69
+
70
+ test('derive.mjs CLI writes the figures file and refuses unknown scenarios', () => {
71
+ const dir = mkdtempSync(join(tmpdir(), 'proposal-derive-'));
72
+ const est = join(dir, 'estimation.json');
73
+ writeFileSync(est, JSON.stringify(estimation));
74
+ const out = join(dir, 'proposal-figures.json');
75
+ const cli = new URL('../derive.mjs', import.meta.url).pathname;
76
+ execFileSync('node', [cli, '--estimation', est, '--scenario', 's1', '--out', out]);
77
+ const written = JSON.parse(readFileSync(out, 'utf8'));
78
+ assert.equal(written.cost.low, 8000);
79
+ assert.equal(written.milestones[0].name, 'M1');
80
+ assert.throws(() => execFileSync('node', [cli, '--estimation', est, '--scenario', 'nope', '--out', out]));
81
+ });
@@ -0,0 +1,22 @@
1
+ ---
2
+ client: Acme Corp
3
+ client_tech_level: non-tech
4
+ scenario: 2eng-max5x
5
+ currency: USD
6
+ valid_until: 2020-01-01
7
+ source_architecture: ../ARCHITECTURE.md
8
+ source_estimation: ../estimation.json
9
+ ---
10
+
11
+ # Acme Corp — Proposal
12
+
13
+ ## Executive Summary
14
+ TBD — we deploy the backend API for $9,999.
15
+
16
+ ## Scope
17
+ | Feature | src |
18
+ | --- | --- |
19
+ | Booking | observed |
20
+
21
+ ## Investment & Timeline
22
+ Total: $9,999 over 1–99 months. Cheaper than 3eng-noai.
@@ -0,0 +1,55 @@
1
+ ---
2
+ client: Acme Corp
3
+ client_tech_level: non-tech
4
+ scenario: 2eng-max5x
5
+ currency: USD
6
+ valid_until: 2099-12-31
7
+ source_architecture: ../ARCHITECTURE.md
8
+ source_estimation: ../estimation.json
9
+ ---
10
+
11
+ # Acme Corp — Proposal
12
+
13
+ ## Executive Summary
14
+ Your customers book by phone today; every double-booking costs you a client. We will build an online booking system for $3,400 – $10,300, delivered in 0.2–0.7 months by a two-person team.
15
+
16
+ ## Background & Objectives
17
+ Acme staff manage appointments by hand. The goal: customers book online, reminders go out automatically, and no slot is ever double-booked, live within 0.7 months.
18
+
19
+ ## Proposed Solution
20
+ One new system with two parts: the booking page your customers see, and reminders that go out on their own.
21
+
22
+ ```mermaid
23
+ graph LR; C[Your customers] --> B[Online booking] --> R[Automatic reminders]
24
+ ```
25
+
26
+ ## Scope
27
+ | Feature | What you get |
28
+ | --- | --- |
29
+ | Online booking | Customers pick a free slot; double-booking is impossible |
30
+ | Automatic reminders | Customers get an email before their appointment |
31
+
32
+ ## Out of Scope & Assumptions
33
+ - Text-message reminders are not included.
34
+ - Recurring bookings are not included.
35
+ - We assume all bookings happen in a single timezone.
36
+
37
+ ## Delivery Approach
38
+ Two milestones. M1 - Booking core runs 0.2–0.5 months; M2 - Notifications runs 0.1–0.2 months. You see a working demo every week, and each milestone ends with your sign-off.
39
+
40
+ ## Investment & Timeline
41
+ | Milestone | Duration | Investment |
42
+ | --- | --- | --- |
43
+ | M1 - Booking core | 0.2–0.5 months | $2,600 – $7,700 |
44
+ | M2 - Notifications | 0.1–0.2 months | $900 – $2,600 |
45
+
46
+ **Total: $3,400 – $10,300 over 0.2–0.7 months.** The range reflects estimation confidence; we confirm a fixed price before each milestone begins.
47
+
48
+ ## Team
49
+ One senior engineer and one mid-level engineer, working with AI-assisted tooling.
50
+
51
+ ## About Code Engine Studio
52
+ We build custom software for small businesses. Recent work: a clinic scheduling system and a salon booking app. Contact: hello@codeenginestudio.com
53
+
54
+ ## Next Steps
55
+ This proposal is valid until 2099-12-31. To proceed, reply with your acceptance and we schedule the kick-off call within one week.
@@ -0,0 +1,20 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync } from 'node:fs';
4
+ import {
5
+ TEMPLATE_LIMITS, moduleFiles, templateScripts, violations,
6
+ } from '../../../analyze-requirements/scripts/lib/quality-gate.mjs';
7
+
8
+ const base = new URL('../..', import.meta.url).pathname;
9
+
10
+ for (const file of moduleFiles(base, ['scripts/lib', 'scripts'])) {
11
+ test(`gates: ${file.replace(base, '')}`, () => {
12
+ assert.deepEqual(violations(readFileSync(file, 'utf8')), []);
13
+ });
14
+ }
15
+
16
+ for (const { file, js } of templateScripts(base)) {
17
+ test(`gates: ${file.replace(base, '')}`, () => {
18
+ assert.deepEqual(violations(js, TEMPLATE_LIMITS), []);
19
+ });
20
+ }
@@ -0,0 +1,70 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ const tpl = () => readFileSync(new URL('../../assets/proposal-template.html', import.meta.url), 'utf8');
9
+ const cli = new URL('../render.mjs', import.meta.url).pathname;
10
+ const computeCli = new URL('../../../estimate/scripts/compute.mjs', import.meta.url).pathname;
11
+ const inputs = new URL('../../../estimate/scripts/test/fixtures/booking-inputs.json', import.meta.url).pathname;
12
+ const passMd = new URL('./fixtures/proposal-pass.md', import.meta.url).pathname;
13
+ const failMd = new URL('./fixtures/proposal-fail.md', import.meta.url).pathname;
14
+
15
+ // A stub is enough: the test asserts inlining, not diagram rendering.
16
+ const STUB_BUNDLE = 'globalThis.mermaid={initialize(){},run(){}};';
17
+
18
+ function rendered(md = passMd) {
19
+ const dir = mkdtempSync(join(tmpdir(), 'proposal-render-'));
20
+ const json = join(dir, 'estimation.json');
21
+ execFileSync('node', [computeCli, '--inputs', inputs, '--out', json]);
22
+ const bundle = join(dir, 'mermaid.js');
23
+ writeFileSync(bundle, STUB_BUNDLE);
24
+ execFileSync('node', [cli, '--md', md, '--estimation', json, '--mermaid-bundle', bundle, '--out', dir]);
25
+ return readFileSync(join(dir, 'proposal.html'), 'utf8');
26
+ }
27
+
28
+ test('template carries exactly the five slots and no external URLs', () => {
29
+ const markers = [...tpl().matchAll(/<!-- slot:(\w+) -->/g)].map((m) => m[1]).sort();
30
+ assert.deepEqual([...new Set(markers)], ['CONTENT', 'FONTS', 'MERMAID_BUNDLE', 'NAV', 'TITLE']);
31
+ assert.doesNotMatch(tpl(), /https?:\/\/(?!www\.w3\.org)/);
32
+ });
33
+
34
+ test('template is print-ready', () => {
35
+ assert.match(tpl(), /@media print/);
36
+ assert.match(tpl(), /break-inside/);
37
+ assert.match(tpl(), /@page/);
38
+ });
39
+
40
+ test('render refuses a proposal that fails validation', () => {
41
+ assert.throws(() => rendered(failMd));
42
+ });
43
+
44
+ test('rendered page is self-contained with fonts, nav, and all ten sections', () => {
45
+ const html = rendered();
46
+ assert.doesNotMatch(html, /<!-- slot:/);
47
+ assert.match(html, /@font-face/);
48
+ assert.match(html, /globalThis\.mermaid/);
49
+ assert.doesNotMatch(html, /<(link|script|img)[^>]+(href|src)="https?:/);
50
+ for (const name of ['Executive Summary', 'Investment &amp; Timeline', 'Next Steps']) {
51
+ assert.match(html, new RegExp(`<h2[^>]*>${name}</h2>`));
52
+ }
53
+ assert.match(html, /<nav[\s\S]*?Executive Summary[\s\S]*?<\/nav>/);
54
+ assert.match(html, /Proposal — Acme Corp/);
55
+ });
56
+
57
+ test('rendered page carries the mermaid canvas and no internal markers', () => {
58
+ const html = rendered();
59
+ assert.match(html, /class="mermaid-canvas"/);
60
+ assert.doesNotMatch(html, /data-internal|viewer-link/);
61
+ });
62
+
63
+ test('render refuses a bundle carrying a literal script terminator', () => {
64
+ const dir = mkdtempSync(join(tmpdir(), 'proposal-render-'));
65
+ const json = join(dir, 'estimation.json');
66
+ execFileSync('node', [computeCli, '--inputs', inputs, '--out', json]);
67
+ const bundle = join(dir, 'mermaid.js');
68
+ writeFileSync(bundle, 'var x = "</script>";');
69
+ assert.throws(() => execFileSync('node', [cli, '--md', passMd, '--estimation', json, '--mermaid-bundle', bundle, '--out', dir]));
70
+ });
@@ -0,0 +1,40 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { mkdtempSync } from 'node:fs';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ const cli = new URL('../validate.mjs', import.meta.url).pathname;
9
+ const computeCli = new URL('../../../estimate/scripts/compute.mjs', import.meta.url).pathname;
10
+ const inputs = new URL('../../../estimate/scripts/test/fixtures/booking-inputs.json', import.meta.url).pathname;
11
+ const passMd = new URL('./fixtures/proposal-pass.md', import.meta.url).pathname;
12
+ const failMd = new URL('./fixtures/proposal-fail.md', import.meta.url).pathname;
13
+
14
+ function estimationPath() {
15
+ const dir = mkdtempSync(join(tmpdir(), 'proposal-validate-'));
16
+ const json = join(dir, 'estimation.json');
17
+ execFileSync('node', [computeCli, '--inputs', inputs, '--out', json]);
18
+ return json;
19
+ }
20
+
21
+ test('the pass fixture validates clean', () => {
22
+ const out = execFileSync('node', [cli, '--md', passMd, '--estimation', estimationPath()], { encoding: 'utf8' });
23
+ assert.match(out, /proposal deliverable valid/);
24
+ });
25
+
26
+ test('the fail fixture exits 1 and names every violation class', () => {
27
+ let err;
28
+ try {
29
+ execFileSync('node', [cli, '--md', failMd, '--estimation', estimationPath()], { encoding: 'utf8' });
30
+ } catch (e) { err = e; }
31
+ assert.ok(err, 'expected non-zero exit');
32
+ const findings = err.stderr.toString();
33
+ assert.match(findings, /missing ## Team/);
34
+ assert.match(findings, /placeholder/i);
35
+ assert.match(findings, /valid_until/);
36
+ assert.match(findings, /9,999|9999/);
37
+ assert.match(findings, /"src"/);
38
+ assert.match(findings, /3eng-noai/);
39
+ assert.match(findings, /jargon/i);
40
+ });
@@ -0,0 +1,20 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { checkProposal } from './lib/checks.mjs';
3
+
4
+ function parseArgs(argv) {
5
+ const args = {};
6
+ for (let i = 0; i < argv.length; i += 1) {
7
+ if (argv[i].startsWith('--')) args[argv[i].slice(2)] = argv[++i];
8
+ }
9
+ return args;
10
+ }
11
+
12
+ const args = parseArgs(process.argv.slice(2));
13
+ const md = readFileSync(args.md, 'utf8');
14
+ const estimation = JSON.parse(readFileSync(args.estimation, 'utf8'));
15
+ const findings = checkProposal({ md, estimation });
16
+ if (findings.length) {
17
+ console.error(findings.join('\n'));
18
+ process.exit(1);
19
+ }
20
+ console.log('proposal deliverable valid');
@@ -0,0 +1,12 @@
1
+ import path from 'node:path';
2
+
3
+ export const AGENT_DIRS = { claude: '.claude', codex: '.codex' };
4
+ export const ALL_AGENTS = Object.keys(AGENT_DIRS);
5
+
6
+ export function agentSkillsDir(agent, cwd) {
7
+ return path.join(cwd, AGENT_DIRS[agent], 'skills');
8
+ }
9
+
10
+ export function canonicalSkillsDir(cwd) {
11
+ return path.join(cwd, '.agents', 'skills');
12
+ }
@@ -0,0 +1,46 @@
1
+ import { parseArgs } from 'node:util';
2
+
3
+ export class UsageError extends Error {}
4
+
5
+ export const VALID_AGENTS = ['claude', 'codex'];
6
+ const COMMANDS = new Set(['install', 'uninstall']);
7
+
8
+ const OPTIONS = {
9
+ plugin: { type: 'string', multiple: true, short: 'p' },
10
+ agent: { type: 'string', multiple: true, short: 'a' },
11
+ force: { type: 'boolean', short: 'f' },
12
+ help: { type: 'boolean', short: 'h' },
13
+ version: { type: 'boolean', short: 'v' },
14
+ };
15
+
16
+ export function parseCliArgs(argv) {
17
+ const { values, positionals } = tryParse(argv);
18
+ const command = positionals[0] ?? 'install';
19
+ if (!COMMANDS.has(command)) throw new UsageError(`Unknown command: ${command}`);
20
+ if (positionals.length > 1) throw new UsageError(`Unexpected argument: ${positionals[1]}`);
21
+ validateAgents(values.agent ?? []);
22
+ return {
23
+ command,
24
+ plugins: values.plugin ?? [],
25
+ agents: values.agent ?? [],
26
+ force: values.force ?? false,
27
+ help: values.help ?? false,
28
+ version: values.version ?? false,
29
+ };
30
+ }
31
+
32
+ function tryParse(argv) {
33
+ try {
34
+ return parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });
35
+ } catch (err) {
36
+ throw new UsageError(err.message);
37
+ }
38
+ }
39
+
40
+ function validateAgents(agents) {
41
+ for (const agent of agents) {
42
+ if (!VALID_AGENTS.includes(agent)) {
43
+ throw new UsageError(`Unknown agent: ${agent}. Valid agents: ${VALID_AGENTS.join(', ')}`);
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,68 @@
1
+ import { cpSync, existsSync, lstatSync, mkdirSync, readlinkSync, rmSync, symlinkSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { listSkills } from './registry.mjs';
4
+ import { agentSkillsDir, canonicalSkillsDir } from './agents.mjs';
5
+
6
+ export function installPlugin({ pluginDir, cwd, agents, force = false }) {
7
+ const result = { installed: [], skipped: [], reused: [] };
8
+ for (const skill of listSkills(pluginDir)) {
9
+ const canonical = copyCanonical({ skill, cwd, force, result });
10
+ for (const agent of agents) {
11
+ linkAgent({ skill: skill.name, canonical, agent, cwd, force, result });
12
+ }
13
+ }
14
+ return result;
15
+ }
16
+
17
+ function copyCanonical({ skill, cwd, force, result }) {
18
+ const dest = path.join(canonicalSkillsDir(cwd), skill.name);
19
+ if (existsSync(dest) && !force) {
20
+ result.reused.push({ skill: skill.name, path: dest });
21
+ return dest;
22
+ }
23
+ rmSync(dest, { recursive: true, force: true });
24
+ mkdirSync(path.dirname(dest), { recursive: true });
25
+ cpSync(skill.dir, dest, { recursive: true });
26
+ return dest;
27
+ }
28
+
29
+ function linkAgent({ skill, canonical, agent, cwd, force, result }) {
30
+ const linkPath = path.join(agentSkillsDir(agent, cwd), skill);
31
+ const status = inspectLink(linkPath, canonical);
32
+ if (status === 'correct') return result.installed.push({ skill, agent, mode: 'linked' });
33
+ if (status === 'occupied' && !force) {
34
+ return result.skipped.push({ skill, agent, path: linkPath, reason: 'exists (use --force)' });
35
+ }
36
+ if (status !== 'missing') rmSync(linkPath, { recursive: true, force: true });
37
+ mkdirSync(path.dirname(linkPath), { recursive: true });
38
+ result.installed.push({ skill, agent, mode: createLink(canonical, linkPath) });
39
+ }
40
+
41
+ function inspectLink(linkPath, canonical) {
42
+ let stat;
43
+ try { stat = lstatSync(linkPath); } catch { return 'missing'; }
44
+ if (!stat.isSymbolicLink()) return 'occupied';
45
+ const target = path.resolve(path.dirname(linkPath), readlinkSync(linkPath));
46
+ return target === path.resolve(canonical) ? 'correct' : 'occupied';
47
+ }
48
+
49
+ function createLink(canonical, linkPath) {
50
+ const relTarget = path.relative(path.dirname(linkPath), canonical);
51
+ try {
52
+ symlinkSync(relTarget, linkPath, 'dir');
53
+ return 'symlink';
54
+ } catch (err) {
55
+ if (err.code !== 'EPERM' && err.code !== 'EACCES') throw err;
56
+ return fallbackLink(canonical, linkPath);
57
+ }
58
+ }
59
+
60
+ function fallbackLink(canonical, linkPath) {
61
+ try {
62
+ symlinkSync(path.resolve(canonical), linkPath, 'junction');
63
+ return 'junction';
64
+ } catch {
65
+ cpSync(canonical, linkPath, { recursive: true });
66
+ return 'copy';
67
+ }
68
+ }
@@ -0,0 +1,124 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { parseCliArgs, UsageError, VALID_AGENTS } from './args.mjs';
5
+ import { loadRegistry } from './registry.mjs';
6
+ import { runPicker } from './picker.mjs';
7
+ import { installPlugin } from './install.mjs';
8
+ import { uninstallPlugin } from './uninstall.mjs';
9
+ import { ALL_AGENTS } from './agents.mjs';
10
+
11
+ const PACKAGE_ROOT = fileURLToPath(new URL('../..', import.meta.url));
12
+
13
+ export async function main(argv) {
14
+ try {
15
+ return await run(argv);
16
+ } catch (err) {
17
+ if (process.env.DEBUG) console.error(err.stack);
18
+ else console.error(err.message);
19
+ return 1;
20
+ }
21
+ }
22
+
23
+ async function run(argv) {
24
+ const args = parseCliArgs(argv);
25
+ if (args.help) return printHelp();
26
+ if (args.version) return printVersion();
27
+ const registry = loadRegistry(path.join(PACKAGE_ROOT, 'plugins'));
28
+ const plugins = await resolvePlugins(args, registry);
29
+ const agents = await resolveAgents(args);
30
+ if (!plugins.length || !agents.length) throw new UsageError('Nothing selected.');
31
+ return execute({ args, plugins, agents });
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
+ }
40
+ }
41
+ if (args.plugins.length) return args.plugins.map((n) => registry.find((p) => p.name === n));
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));
49
+ }
50
+
51
+ async function resolveAgents(args) {
52
+ if (args.agents.length) return args.agents;
53
+ if (args.command === 'uninstall') return ALL_AGENTS;
54
+ requireInteractive();
55
+ const picked = await runPicker({
56
+ title: 'Select agents:',
57
+ items: VALID_AGENTS.map((a) => ({ value: a, label: a })),
58
+ });
59
+ if (picked === null) throw new UsageError('Cancelled.');
60
+ return picked;
61
+ }
62
+
63
+ function requireInteractive() {
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 }) {
70
+ let skippedTotal = 0;
71
+ for (const plugin of plugins) {
72
+ const opts = { pluginDir: plugin.dir, cwd: process.cwd(), agents, force: args.force };
73
+ const result = args.command === 'install' ? installPlugin(opts) : uninstallPlugin(opts);
74
+ skippedTotal += printSummary(plugin.name, result);
75
+ }
76
+ return skippedTotal > 0 ? 1 : 0;
77
+ }
78
+
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
+ function printHelp() {
107
+ console.log(`Usage: agents-rock [install|uninstall] [options]
108
+
109
+ Install plugin skills for Claude Code and Codex into the current project.
110
+
111
+ Options:
112
+ -p, --plugin <name> Plugin to install/uninstall (repeatable)
113
+ -a, --agent <name> Target agent: claude, codex (repeatable)
114
+ -f, --force Overwrite/remove collisions
115
+ -h, --help Show help
116
+ -v, --version Show version`);
117
+ return 0;
118
+ }
119
+
120
+ function printVersion() {
121
+ const pkg = JSON.parse(readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
122
+ console.log(pkg.version);
123
+ return 0;
124
+ }