specialist-agent 2.13.0 → 3.3.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 (329) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +36 -206
  3. package/dist/catalog.json +16677 -0
  4. package/dist/hw-worker.mjs +288 -0
  5. package/dist/icones/icone.ico +0 -0
  6. package/dist/icones/icone.png +0 -0
  7. package/dist/interface/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
  8. package/dist/interface/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
  9. package/dist/interface/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
  10. package/dist/interface/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
  11. package/dist/interface/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
  12. package/dist/interface/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
  13. package/dist/interface/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
  14. package/dist/interface/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
  15. package/dist/interface/assets/index-BltVv7tb.js +24 -0
  16. package/dist/interface/assets/index-Cpa6kApK.css +1 -0
  17. package/dist/interface/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  18. package/dist/interface/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  19. package/dist/interface/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  20. package/dist/interface/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  21. package/dist/interface/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
  22. package/dist/interface/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
  23. package/dist/interface/assets/unbounded-latin-500-normal-4slEIF53.woff2 +0 -0
  24. package/dist/interface/assets/unbounded-latin-700-normal-CaoNriVp.woff2 +0 -0
  25. package/dist/interface/assets/unbounded-latin-ext-500-normal-BTIpesyw.woff2 +0 -0
  26. package/dist/interface/assets/unbounded-latin-ext-700-normal-BLzWLLjG.woff2 +0 -0
  27. package/dist/interface/icones/apple-touch-icon.png +0 -0
  28. package/dist/interface/icones/favicon-32.png +0 -0
  29. package/dist/interface/icones/icone-192.png +0 -0
  30. package/dist/interface/icones/icone-512.png +0 -0
  31. package/dist/interface/icones/icone-mascara-512.png +0 -0
  32. package/dist/interface/index.html +19 -0
  33. package/dist/interface/manifest.webmanifest +19 -0
  34. package/dist/interface/sw.js +64 -0
  35. package/dist/licencas/BRAND.md +22 -0
  36. package/dist/licencas/LICENSE-CONTENT.md +44 -0
  37. package/dist/licencas/OFL-Figtree.txt +93 -0
  38. package/dist/licencas/OFL-JetBrainsMono.txt +93 -0
  39. package/dist/licencas/OFL-Unbounded.txt +93 -0
  40. package/dist/licencas/TERCEIROS.txt +104 -0
  41. package/dist/specialist-agent.mjs +14515 -0
  42. package/dist/usage-worker.mjs +1077 -0
  43. package/package.json +34 -58
  44. package/.claude-plugin/marketplace.json +0 -52
  45. package/.claude-plugin/plugin.json +0 -37
  46. package/.codex/INSTALL.md +0 -145
  47. package/.cursor-plugin/marketplace.json +0 -52
  48. package/.cursor-plugin/plugin.json +0 -37
  49. package/.opencode/INSTALL.md +0 -127
  50. package/.opencode/opencode.json +0 -186
  51. package/agents/analyst-lite.md +0 -48
  52. package/agents/analyst.md +0 -396
  53. package/agents/api-lite.md +0 -43
  54. package/agents/api.md +0 -427
  55. package/agents/architect-lite.md +0 -104
  56. package/agents/architect.md +0 -571
  57. package/agents/autopilot-lite.md +0 -46
  58. package/agents/autopilot.md +0 -196
  59. package/agents/cloud-lite.md +0 -75
  60. package/agents/cloud.md +0 -213
  61. package/agents/data-lite.md +0 -67
  62. package/agents/data.md +0 -306
  63. package/agents/debugger-lite.md +0 -46
  64. package/agents/debugger.md +0 -410
  65. package/agents/deps-lite.md +0 -41
  66. package/agents/deps.md +0 -363
  67. package/agents/designer-lite.md +0 -67
  68. package/agents/designer.md +0 -195
  69. package/agents/devops-lite.md +0 -67
  70. package/agents/devops.md +0 -205
  71. package/agents/docs-lite.md +0 -42
  72. package/agents/docs.md +0 -454
  73. package/agents/executor-lite.md +0 -61
  74. package/agents/executor.md +0 -695
  75. package/agents/explorer-lite.md +0 -55
  76. package/agents/explorer.md +0 -152
  77. package/agents/finance-lite.md +0 -66
  78. package/agents/finance.md +0 -255
  79. package/agents/i18n-lite.md +0 -44
  80. package/agents/i18n.md +0 -594
  81. package/agents/legal-lite.md +0 -113
  82. package/agents/legal.md +0 -302
  83. package/agents/marketing-lite.md +0 -25
  84. package/agents/marketing.md +0 -188
  85. package/agents/memory.md +0 -166
  86. package/agents/orchestrator-lite.md +0 -40
  87. package/agents/orchestrator.md +0 -512
  88. package/agents/pair-lite.md +0 -38
  89. package/agents/pair.md +0 -310
  90. package/agents/perf-lite.md +0 -42
  91. package/agents/perf.md +0 -320
  92. package/agents/planner-lite.md +0 -59
  93. package/agents/planner.md +0 -272
  94. package/agents/product-lite.md +0 -25
  95. package/agents/product.md +0 -195
  96. package/agents/refactor-lite.md +0 -42
  97. package/agents/refactor.md +0 -467
  98. package/agents/ripple-lite.md +0 -106
  99. package/agents/ripple.md +0 -166
  100. package/agents/scout-lite.md +0 -37
  101. package/agents/scout.md +0 -224
  102. package/agents/security-lite.md +0 -66
  103. package/agents/security.md +0 -252
  104. package/agents/sentry-triage-lite.md +0 -54
  105. package/agents/sentry-triage.md +0 -217
  106. package/agents/starter-lite.md +0 -80
  107. package/agents/starter.md +0 -300
  108. package/agents/support-lite.md +0 -24
  109. package/agents/support.md +0 -191
  110. package/agents/tdd-lite.md +0 -43
  111. package/agents/tdd.md +0 -329
  112. package/agents/tester-lite.md +0 -71
  113. package/agents/tester.md +0 -237
  114. package/cli/architectures.mjs +0 -713
  115. package/cli/detect-architecture.mjs +0 -752
  116. package/cli/generate-architecture.mjs +0 -1096
  117. package/cli/index.mjs +0 -1217
  118. package/cli/recommend-architecture.mjs +0 -870
  119. package/hooks/after-review.mjs +0 -130
  120. package/hooks/after-task.mjs +0 -117
  121. package/hooks/before-plan.mjs +0 -155
  122. package/hooks/before-review.mjs +0 -139
  123. package/hooks/hooks.json +0 -66
  124. package/hooks/lifecycle.json +0 -91
  125. package/hooks/native/auto-dispatch.mjs +0 -207
  126. package/hooks/native/auto-format.mjs +0 -176
  127. package/hooks/native/mcp-discovery.mjs +0 -168
  128. package/hooks/native/security-config.json +0 -38
  129. package/hooks/native/security-guard.mjs +0 -323
  130. package/hooks/native/session-context.mjs +0 -179
  131. package/hooks/native/session-end.mjs +0 -42
  132. package/hooks/native/utils.mjs +0 -62
  133. package/hooks/on-error.mjs +0 -129
  134. package/hooks/session-end.mjs +0 -185
  135. package/hooks/session-start.mjs +0 -154
  136. package/packs/angular/ARCHITECTURE.md +0 -814
  137. package/packs/angular/CLAUDE.md +0 -105
  138. package/packs/angular/agents/builder.md +0 -113
  139. package/packs/angular/agents/doctor.md +0 -187
  140. package/packs/angular/agents/migrator.md +0 -101
  141. package/packs/angular/agents/reviewer.md +0 -252
  142. package/packs/angular/agents-lite/builder.md +0 -65
  143. package/packs/angular/agents-lite/doctor.md +0 -64
  144. package/packs/angular/agents-lite/migrator.md +0 -75
  145. package/packs/angular/agents-lite/reviewer.md +0 -69
  146. package/packs/angular/skills/dev-create-component/SKILL.md +0 -56
  147. package/packs/angular/skills/dev-create-injectable/SKILL.md +0 -60
  148. package/packs/angular/skills/dev-create-module/SKILL.md +0 -49
  149. package/packs/angular/skills/dev-create-service/SKILL.md +0 -34
  150. package/packs/angular/skills/dev-create-test/SKILL.md +0 -78
  151. package/packs/angular/skills/dev-generate-types/SKILL.md +0 -37
  152. package/packs/angular/skills/docs-onboard/SKILL.md +0 -42
  153. package/packs/angular/skills/migration-migrate-component/SKILL.md +0 -42
  154. package/packs/angular/skills/migration-migrate-module/SKILL.md +0 -25
  155. package/packs/angular/skills/review-check-architecture/SKILL.md +0 -67
  156. package/packs/angular/skills/review-fix-violations/SKILL.md +0 -43
  157. package/packs/angular/skills/review-review/SKILL.md +0 -43
  158. package/packs/astro/ARCHITECTURE.md +0 -718
  159. package/packs/astro/CLAUDE.md +0 -106
  160. package/packs/astro/agents/builder.md +0 -123
  161. package/packs/astro/agents/doctor.md +0 -200
  162. package/packs/astro/agents/migrator.md +0 -105
  163. package/packs/astro/agents/reviewer.md +0 -253
  164. package/packs/astro/agents-lite/builder.md +0 -71
  165. package/packs/astro/agents-lite/doctor.md +0 -66
  166. package/packs/astro/agents-lite/migrator.md +0 -71
  167. package/packs/astro/agents-lite/reviewer.md +0 -70
  168. package/packs/astro/skills/dev-create-component/SKILL.md +0 -50
  169. package/packs/astro/skills/dev-create-island/SKILL.md +0 -63
  170. package/packs/astro/skills/dev-create-module/SKILL.md +0 -49
  171. package/packs/astro/skills/dev-create-service/SKILL.md +0 -34
  172. package/packs/astro/skills/dev-create-test/SKILL.md +0 -76
  173. package/packs/astro/skills/dev-generate-types/SKILL.md +0 -37
  174. package/packs/astro/skills/docs-onboard/SKILL.md +0 -51
  175. package/packs/astro/skills/migration-migrate-component/SKILL.md +0 -48
  176. package/packs/astro/skills/migration-migrate-module/SKILL.md +0 -25
  177. package/packs/astro/skills/review-check-architecture/SKILL.md +0 -72
  178. package/packs/astro/skills/review-fix-violations/SKILL.md +0 -43
  179. package/packs/astro/skills/review-review/SKILL.md +0 -45
  180. package/packs/nextjs/ARCHITECTURE.md +0 -1033
  181. package/packs/nextjs/CLAUDE.md +0 -106
  182. package/packs/nextjs/agents/builder.md +0 -132
  183. package/packs/nextjs/agents/doctor.md +0 -226
  184. package/packs/nextjs/agents/migrator.md +0 -101
  185. package/packs/nextjs/agents/reviewer.md +0 -243
  186. package/packs/nextjs/agents-lite/builder.md +0 -74
  187. package/packs/nextjs/agents-lite/doctor.md +0 -74
  188. package/packs/nextjs/agents-lite/migrator.md +0 -75
  189. package/packs/nextjs/agents-lite/reviewer.md +0 -73
  190. package/packs/nextjs/skills/dev-create-component/SKILL.md +0 -82
  191. package/packs/nextjs/skills/dev-create-hook/SKILL.md +0 -90
  192. package/packs/nextjs/skills/dev-create-module/SKILL.md +0 -63
  193. package/packs/nextjs/skills/dev-create-service/SKILL.md +0 -35
  194. package/packs/nextjs/skills/dev-create-test/SKILL.md +0 -106
  195. package/packs/nextjs/skills/dev-generate-types/SKILL.md +0 -37
  196. package/packs/nextjs/skills/docs-onboard/SKILL.md +0 -55
  197. package/packs/nextjs/skills/migration-migrate-component/SKILL.md +0 -58
  198. package/packs/nextjs/skills/migration-migrate-module/SKILL.md +0 -25
  199. package/packs/nextjs/skills/review-check-architecture/SKILL.md +0 -101
  200. package/packs/nextjs/skills/review-fix-violations/SKILL.md +0 -48
  201. package/packs/nextjs/skills/review-review/SKILL.md +0 -47
  202. package/packs/nuxt/ARCHITECTURE.md +0 -831
  203. package/packs/nuxt/CLAUDE.md +0 -111
  204. package/packs/nuxt/agents/builder.md +0 -120
  205. package/packs/nuxt/agents/doctor.md +0 -198
  206. package/packs/nuxt/agents/migrator.md +0 -101
  207. package/packs/nuxt/agents/reviewer.md +0 -255
  208. package/packs/nuxt/agents-lite/builder.md +0 -67
  209. package/packs/nuxt/agents-lite/doctor.md +0 -67
  210. package/packs/nuxt/agents-lite/migrator.md +0 -80
  211. package/packs/nuxt/agents-lite/reviewer.md +0 -71
  212. package/packs/nuxt/skills/dev-create-component/SKILL.md +0 -60
  213. package/packs/nuxt/skills/dev-create-composable/SKILL.md +0 -33
  214. package/packs/nuxt/skills/dev-create-module/SKILL.md +0 -49
  215. package/packs/nuxt/skills/dev-create-service/SKILL.md +0 -34
  216. package/packs/nuxt/skills/dev-create-test/SKILL.md +0 -61
  217. package/packs/nuxt/skills/dev-generate-types/SKILL.md +0 -37
  218. package/packs/nuxt/skills/docs-onboard/SKILL.md +0 -49
  219. package/packs/nuxt/skills/migration-migrate-component/SKILL.md +0 -48
  220. package/packs/nuxt/skills/migration-migrate-module/SKILL.md +0 -25
  221. package/packs/nuxt/skills/review-check-architecture/SKILL.md +0 -71
  222. package/packs/nuxt/skills/review-fix-violations/SKILL.md +0 -43
  223. package/packs/nuxt/skills/review-review/SKILL.md +0 -45
  224. package/packs/react/ARCHITECTURE.md +0 -991
  225. package/packs/react/CLAUDE.md +0 -102
  226. package/packs/react/agents/builder.md +0 -113
  227. package/packs/react/agents/doctor.md +0 -203
  228. package/packs/react/agents/migrator.md +0 -101
  229. package/packs/react/agents/reviewer.md +0 -252
  230. package/packs/react/agents-lite/builder.md +0 -65
  231. package/packs/react/agents-lite/doctor.md +0 -64
  232. package/packs/react/agents-lite/migrator.md +0 -74
  233. package/packs/react/agents-lite/reviewer.md +0 -69
  234. package/packs/react/skills/dev-create-component/SKILL.md +0 -53
  235. package/packs/react/skills/dev-create-hook/SKILL.md +0 -78
  236. package/packs/react/skills/dev-create-module/SKILL.md +0 -51
  237. package/packs/react/skills/dev-create-service/SKILL.md +0 -34
  238. package/packs/react/skills/dev-create-test/SKILL.md +0 -92
  239. package/packs/react/skills/dev-generate-types/SKILL.md +0 -37
  240. package/packs/react/skills/docs-onboard/SKILL.md +0 -42
  241. package/packs/react/skills/migration-migrate-component/SKILL.md +0 -44
  242. package/packs/react/skills/migration-migrate-module/SKILL.md +0 -25
  243. package/packs/react/skills/review-check-architecture/SKILL.md +0 -73
  244. package/packs/react/skills/review-fix-violations/SKILL.md +0 -45
  245. package/packs/react/skills/review-review/SKILL.md +0 -44
  246. package/packs/svelte/ARCHITECTURE.md +0 -975
  247. package/packs/svelte/CLAUDE.md +0 -102
  248. package/packs/svelte/agents/builder.md +0 -114
  249. package/packs/svelte/agents/doctor.md +0 -174
  250. package/packs/svelte/agents/migrator.md +0 -101
  251. package/packs/svelte/agents/reviewer.md +0 -238
  252. package/packs/svelte/agents-lite/builder.md +0 -66
  253. package/packs/svelte/agents-lite/doctor.md +0 -67
  254. package/packs/svelte/agents-lite/migrator.md +0 -82
  255. package/packs/svelte/agents-lite/reviewer.md +0 -70
  256. package/packs/svelte/skills/dev-create-component/SKILL.md +0 -77
  257. package/packs/svelte/skills/dev-create-module/SKILL.md +0 -59
  258. package/packs/svelte/skills/dev-create-service/SKILL.md +0 -35
  259. package/packs/svelte/skills/dev-create-store/SKILL.md +0 -94
  260. package/packs/svelte/skills/dev-create-test/SKILL.md +0 -98
  261. package/packs/svelte/skills/dev-generate-types/SKILL.md +0 -37
  262. package/packs/svelte/skills/docs-onboard/SKILL.md +0 -47
  263. package/packs/svelte/skills/migration-migrate-component/SKILL.md +0 -51
  264. package/packs/svelte/skills/migration-migrate-module/SKILL.md +0 -25
  265. package/packs/svelte/skills/review-check-architecture/SKILL.md +0 -79
  266. package/packs/svelte/skills/review-fix-violations/SKILL.md +0 -47
  267. package/packs/svelte/skills/review-review/SKILL.md +0 -45
  268. package/packs/vue/ARCHITECTURE.md +0 -798
  269. package/packs/vue/CLAUDE.md +0 -102
  270. package/packs/vue/agents/builder.md +0 -112
  271. package/packs/vue/agents/doctor.md +0 -185
  272. package/packs/vue/agents/migrator.md +0 -101
  273. package/packs/vue/agents/reviewer.md +0 -249
  274. package/packs/vue/agents-lite/builder.md +0 -65
  275. package/packs/vue/agents-lite/doctor.md +0 -63
  276. package/packs/vue/agents-lite/migrator.md +0 -73
  277. package/packs/vue/agents-lite/reviewer.md +0 -68
  278. package/packs/vue/skills/dev-create-component/SKILL.md +0 -58
  279. package/packs/vue/skills/dev-create-composable/SKILL.md +0 -31
  280. package/packs/vue/skills/dev-create-module/SKILL.md +0 -50
  281. package/packs/vue/skills/dev-create-service/SKILL.md +0 -34
  282. package/packs/vue/skills/dev-create-test/SKILL.md +0 -62
  283. package/packs/vue/skills/dev-generate-types/SKILL.md +0 -37
  284. package/packs/vue/skills/docs-onboard/SKILL.md +0 -42
  285. package/packs/vue/skills/migration-migrate-component/SKILL.md +0 -41
  286. package/packs/vue/skills/migration-migrate-module/SKILL.md +0 -25
  287. package/packs/vue/skills/review-check-architecture/SKILL.md +0 -73
  288. package/packs/vue/skills/review-fix-violations/SKILL.md +0 -42
  289. package/packs/vue/skills/review-review/SKILL.md +0 -43
  290. package/skills/audit/SKILL.md +0 -231
  291. package/skills/autofix/SKILL.md +0 -166
  292. package/skills/autopilot/SKILL.md +0 -286
  293. package/skills/brainstorm/SKILL.md +0 -298
  294. package/skills/checkpoint/SKILL.md +0 -217
  295. package/skills/codereview/SKILL.md +0 -268
  296. package/skills/commit/SKILL.md +0 -150
  297. package/skills/copywriting/SKILL.md +0 -218
  298. package/skills/cro/SKILL.md +0 -234
  299. package/skills/debug/SKILL.md +0 -210
  300. package/skills/design-review/SKILL.md +0 -217
  301. package/skills/discovery/SKILL.md +0 -218
  302. package/skills/estimate/SKILL.md +0 -154
  303. package/skills/finish/SKILL.md +0 -220
  304. package/skills/grill/SKILL.md +0 -270
  305. package/skills/health/SKILL.md +0 -251
  306. package/skills/improve-architecture/SKILL.md +0 -205
  307. package/skills/learn/SKILL.md +0 -260
  308. package/skills/lint/SKILL.md +0 -126
  309. package/skills/migrate-architecture/SKILL.md +0 -242
  310. package/skills/migrate-framework/SKILL.md +0 -172
  311. package/skills/onboard/SKILL.md +0 -168
  312. package/skills/plan/SKILL.md +0 -141
  313. package/skills/prd/SKILL.md +0 -241
  314. package/skills/recall/SKILL.md +0 -112
  315. package/skills/remember/SKILL.md +0 -108
  316. package/skills/seo-audit/SKILL.md +0 -240
  317. package/skills/tdd/SKILL.md +0 -201
  318. package/skills/tutorial/SKILL.md +0 -346
  319. package/skills/verify/SKILL.md +0 -168
  320. package/skills/worktree/SKILL.md +0 -168
  321. package/skills/write-skill/SKILL.md +0 -225
  322. package/templates/autopilot/PROMPT.md +0 -39
  323. package/templates/autopilot/README.md +0 -122
  324. package/templates/autopilot/devcontainer.json +0 -21
  325. package/templates/industry/ecommerce.md +0 -127
  326. package/templates/industry/fintech.md +0 -161
  327. package/templates/industry/saas.md +0 -134
  328. package/templates/session-memory.json +0 -48
  329. package/templates/skill-template/SKILL.md +0 -90
package/cli/index.mjs DELETED
@@ -1,1217 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import * as clack from '@clack/prompts'
4
- import { existsSync, mkdirSync, cpSync, rmSync, readdirSync, readFileSync, writeFileSync } from 'fs'
5
- import { execFileSync } from 'child_process'
6
- import { join, dirname, resolve } from 'path'
7
- import { fileURLToPath } from 'url'
8
- import { homedir } from 'os'
9
- import { ARCHITECTURE_PATTERNS } from './architectures.mjs'
10
- import { detectProjectArchitecture, generateDetectionReport } from './detect-architecture.mjs'
11
- import { getRecommendations } from './recommend-architecture.mjs'
12
- import { generateArchitectureGuide } from './generate-architecture.mjs'
13
-
14
- const __filename = fileURLToPath(import.meta.url)
15
- const __dirname = dirname(__filename)
16
- const ROOT = resolve(__dirname, '..')
17
-
18
- const YELLOW = '\x1b[33m'
19
- const RED = '\x1b[31m'
20
- const GREEN = '\x1b[32m'
21
- const BOLD = '\x1b[1m'
22
- const DIM = '\x1b[2m'
23
- const NC = '\x1b[0m'
24
-
25
- // ── Helpers ──────────────────────────────────────────
26
-
27
- function copyManagedFiles(src, dest) {
28
- // Additive merge: update our files, preserve user files
29
- if (!existsSync(src)) return 0
30
- let count = 0
31
- for (const entry of readdirSync(src, { withFileTypes: true })) {
32
- const srcPath = join(src, entry.name)
33
- const destPath = join(dest, entry.name)
34
- if (entry.isDirectory()) {
35
- mkdirSync(destPath, { recursive: true })
36
- count += copyManagedFiles(srcPath, destPath)
37
- } else {
38
- cpSync(srcPath, destPath)
39
- count++
40
- }
41
- }
42
- return count
43
- }
44
-
45
-
46
- function getAgentNames(dir) {
47
- if (!existsSync(dir)) return []
48
- return readdirSync(dir)
49
- .filter(f => f.endsWith('.md'))
50
- .map(f => {
51
- const content = readFileSync(join(dir, f), 'utf-8')
52
- const match = content.match(/^name:\s*(.+)$/m)
53
- return match ? match[1].trim() : f.replace('.md', '')
54
- })
55
- }
56
-
57
- function handleCancel() {
58
- clack.cancel('Setup cancelled.')
59
- process.exit(0)
60
- }
61
-
62
- // ── Native Hooks Setup ──────────────────────────────────
63
-
64
- function setupNativeHooks(cwd, selectedHooks) {
65
- // 1. Copy hook scripts to .claude/hooks/ (inside Claude ecosystem)
66
- const nativeSource = join(ROOT, 'hooks', 'native')
67
- const hooksDest = join(cwd, '.claude', 'hooks')
68
- mkdirSync(hooksDest, { recursive: true })
69
-
70
- const HOOK_FILES = {
71
- 'security-guard': ['security-guard.mjs', 'security-config.json', 'utils.mjs'],
72
- 'auto-dispatch': ['auto-dispatch.mjs', 'utils.mjs'],
73
- 'session-context': ['session-context.mjs', 'utils.mjs'],
74
- 'mcp-discovery': ['mcp-discovery.mjs', 'utils.mjs'],
75
- 'auto-format': ['auto-format.mjs', 'utils.mjs'],
76
- }
77
-
78
- const copiedFiles = new Set()
79
- for (const hookName of selectedHooks) {
80
- const files = HOOK_FILES[hookName] || []
81
- for (const file of files) {
82
- if (copiedFiles.has(file)) continue
83
- const src = join(nativeSource, file)
84
- if (existsSync(src)) {
85
- cpSync(src, join(hooksDest, file))
86
- copiedFiles.add(file)
87
- }
88
- }
89
- }
90
-
91
- // 2. Build hook entries pointing to .claude/hooks/
92
- const HOOK_COMMANDS = {
93
- 'security-guard': { event: 'PreToolUse', matcher: 'Bash', command: 'node .claude/hooks/security-guard.mjs', timeout: 5 },
94
- 'auto-dispatch': { event: 'UserPromptSubmit', command: 'node .claude/hooks/auto-dispatch.mjs', timeout: 5 },
95
- 'session-context': { event: 'SessionStart', command: 'node .claude/hooks/session-context.mjs', timeout: 10 },
96
- 'mcp-discovery': { event: 'SessionStart', command: 'node .claude/hooks/mcp-discovery.mjs', timeout: 5 },
97
- 'auto-format': { event: 'PostToolUse', matcher: 'Write|Edit', command: 'node .claude/hooks/auto-format.mjs', timeout: 15 },
98
- }
99
-
100
- const filteredHooks = {}
101
- for (const hookName of selectedHooks) {
102
- const def = HOOK_COMMANDS[hookName]
103
- if (!def) continue
104
- const entry = { hooks: [{ type: 'command', command: def.command, timeout: def.timeout }] }
105
- if (def.matcher) entry.matcher = def.matcher
106
- if (!filteredHooks[def.event]) filteredHooks[def.event] = []
107
- filteredHooks[def.event].push(entry)
108
- }
109
-
110
- // 3. Read existing settings and merge additively
111
- const settingsPath = join(cwd, '.claude', 'settings.json')
112
-
113
- let existing = {}
114
- if (existsSync(settingsPath)) {
115
- try {
116
- existing = JSON.parse(readFileSync(settingsPath, 'utf-8'))
117
- } catch {
118
- existing = {}
119
- }
120
- }
121
-
122
- if (!existing.hooks) existing.hooks = {}
123
-
124
- const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
125
- const OLD_PREFIX = 'node .specialist-agent/hooks/native/'
126
- const NEW_PREFIX = 'node .claude/hooks/'
127
-
128
- for (const [eventName, entries] of Object.entries(filteredHooks)) {
129
- if (UNSAFE_KEYS.has(eventName)) continue
130
- if (!existing.hooks[eventName]) {
131
- existing.hooks[eventName] = entries
132
- } else {
133
- for (const newEntry of entries) {
134
- const newCommand = newEntry.hooks?.[0]?.command || ''
135
- // Find existing entry: exact match or old path match
136
- const existingIdx = existing.hooks[eventName].findIndex(existingEntry =>
137
- existingEntry.hooks?.some(h =>
138
- h.command === newCommand || h.command === newCommand.replace(NEW_PREFIX, OLD_PREFIX)
139
- )
140
- )
141
- if (existingIdx !== -1) {
142
- // Update old path to new path
143
- existing.hooks[eventName][existingIdx] = newEntry
144
- } else {
145
- existing.hooks[eventName].push(newEntry)
146
- }
147
- }
148
- }
149
- }
150
-
151
- // 4. Write merged settings
152
- writeFileSync(settingsPath, JSON.stringify(existing, null, 2))
153
-
154
- return selectedHooks.length
155
- }
156
-
157
- async function checkForUpdates(currentVersion) {
158
- try {
159
- const res = await fetch('https://registry.npmjs.org/specialist-agent/latest', {
160
- signal: AbortSignal.timeout(3000),
161
- })
162
- if (!res.ok) return null
163
- const data = await res.json()
164
- const latest = data.version
165
- if (latest && latest !== currentVersion) return latest
166
- return null
167
- } catch {
168
- return null
169
- }
170
- }
171
-
172
- function detectFramework(pkgPath, availablePacks) {
173
- if (!existsSync(pkgPath)) return null
174
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
175
- const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
176
-
177
- // Order matters: nuxt includes vue, next includes react - check meta-frameworks first
178
- if (deps['nuxt'] && availablePacks.includes('nuxt')) return 'nuxt'
179
- if (deps['next'] && availablePacks.includes('nextjs')) return 'nextjs'
180
- if ((deps['@sveltejs/kit'] || deps['svelte']) && availablePacks.includes('svelte')) return 'svelte'
181
- if (deps['@angular/core'] && availablePacks.includes('angular')) return 'angular'
182
- if (deps['astro'] && availablePacks.includes('astro')) return 'astro'
183
- if (deps['vue'] && availablePacks.includes('vue')) return 'vue'
184
- if (deps['react'] && availablePacks.includes('react')) return 'react'
185
-
186
- return null
187
- }
188
-
189
-
190
- // ── Guidance texts ───────────────────────────────────
191
-
192
- function buildGettingStarted(agentNames, installedSkills, isEmptyProject) {
193
- const lines = []
194
-
195
- if (isEmptyProject) {
196
- lines.push('You\'re starting fresh — here\'s how to get going:')
197
- lines.push('')
198
- lines.push(' $ claude')
199
- lines.push('')
200
- if (agentNames.includes('starter')) {
201
- lines.push(' Create a project from scratch:')
202
- lines.push(' > "Use @starter to create an app with Next.js + PostgreSQL"')
203
- lines.push(' > "Use @starter to create a Vue 3 SaaS with Stripe"')
204
- lines.push('')
205
- }
206
- if (agentNames.includes('planner')) {
207
- lines.push(' Plan before building:')
208
- lines.push(' > /plan add user authentication with JWT')
209
- lines.push(' > /discovery implement real-time chat with WebSocket')
210
- lines.push('')
211
- }
212
- lines.push(' All 35 agents are installed. When you choose a framework,')
213
- lines.push(' re-run to swap to framework-specific pack agents:')
214
- lines.push(' > npx specialist-agent init')
215
- return lines.join('\n')
216
- }
217
-
218
- lines.push('Agents use best practices for your framework.')
219
- lines.push('To detect and customize architecture: specialist-agent detect')
220
- lines.push('')
221
- lines.push('Examples:')
222
- lines.push('')
223
- lines.push(' $ claude')
224
-
225
- if (agentNames.includes('builder')) {
226
- lines.push(' > "Use @builder to create the products module with CRUD"')
227
- }
228
- if (agentNames.includes('reviewer')) {
229
- lines.push(' > "Use @reviewer to review src/modules/auth/"')
230
- }
231
- if (agentNames.includes('doctor')) {
232
- lines.push(' > "Use @doctor to investigate the dashboard error"')
233
- }
234
-
235
- if (installedSkills.length > 0) {
236
- lines.push('')
237
- lines.push('Skills (slash commands):')
238
- const topSkills = ['/plan', '/tdd', '/audit', '/discovery']
239
- const available = topSkills.filter(s => installedSkills.includes(s))
240
- if (available.length > 0) {
241
- available.forEach(skill => lines.push(` > ${skill}`))
242
- } else {
243
- installedSkills.slice(0, 4).forEach(skill => lines.push(` > ${skill}`))
244
- }
245
- }
246
-
247
- if (agentNames.includes('starter')) {
248
- lines.push('')
249
- lines.push('Scaffold a new project from scratch:')
250
- lines.push(' > "Use @starter to create an e-commerce app with Next.js"')
251
- }
252
-
253
- return lines.join('\n')
254
- }
255
-
256
- // ── CLI argument handling ────────────────────────────
257
-
258
- const args = process.argv.slice(2)
259
-
260
- const validCommands = ['init', 'create-agent', 'list', 'profiles', 'community', 'detect']
261
- const command = args.find(a => !a.startsWith('-'))
262
- if (command && !validCommands.includes(command)) {
263
- console.error(` ${YELLOW}Unknown command: ${command}${NC}`)
264
- console.error(` Run ${BOLD}specialist-agent --help${NC} for usage.`)
265
- process.exit(1)
266
- }
267
-
268
- if (args.includes('--help') || args.includes('-h')) {
269
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
270
- console.log()
271
- console.log(` ${BOLD}specialist-agent${NC} ${DIM}v${pkg.version}${NC}`)
272
- console.log()
273
- console.log(' Usage: specialist-agent <command> [options]')
274
- console.log()
275
- console.log(' Commands:')
276
- console.log(` init ${DIM}Install 36 agents and 32 skills (works on empty projects too)${NC}`)
277
- console.log(` detect ${DIM}Detect architecture, monorepo, and suggest migrations${NC}`)
278
- console.log(` create-agent <name> ${DIM}Create a custom agent from template${NC}`)
279
- console.log(` list ${DIM}List installed agents, skills, and memory${NC}`)
280
- console.log(` profiles ${DIM}Manage AI team profiles${NC}`)
281
- console.log(` community ${DIM}Manage community skills (list/install/remove)${NC}`)
282
- console.log()
283
- console.log(' Options:')
284
- console.log(` -h, --help ${DIM}Show this help message${NC}`)
285
- console.log(` -v, --version ${DIM}Show version number${NC}`)
286
- console.log(` -f, --force ${DIM}Overwrite existing agents without asking${NC}`)
287
- console.log()
288
- console.log(' Examples:')
289
- console.log(` ${DIM}$ specialist-agent init # Install in existing project${NC}`)
290
- console.log(` ${DIM}$ specialist-agent init # Start from empty dir (no framework yet)${NC}`)
291
- console.log(` ${DIM}$ specialist-agent detect # Analyze architecture & get recommendations${NC}`)
292
- console.log(` ${DIM}$ specialist-agent create-agent @qa # Create a custom agent${NC}`)
293
- console.log(` ${DIM}$ specialist-agent profiles set startup-fast${NC}`)
294
- console.log()
295
- process.exit(0)
296
- }
297
-
298
- if (args.includes('--version') || args.includes('-v')) {
299
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
300
- console.log(pkg.version)
301
- process.exit(0)
302
- }
303
-
304
- const forceMode = args.includes('--force') || args.includes('-f')
305
-
306
- // ── Agent Template ───────────────────────────────────
307
-
308
- const AGENT_TEMPLATE = `---
309
- name: {{name}}
310
- description: "{{description}}"
311
- model: {{model}}
312
- tools: Read, Write, Edit, Bash, Glob, Grep
313
- ---
314
-
315
- # @{{name}} - {{title}}
316
-
317
- ## Mission
318
-
319
- {{mission}}
320
-
321
- ## Workflow
322
-
323
- ### Step 1: Understand Context
324
- 1. Read relevant files
325
- 2. Understand existing patterns
326
- 3. Plan approach
327
-
328
- ### Step 2: Execute
329
- 1. Implement changes
330
- 2. Validate results
331
- 3. Report completion
332
-
333
- ## Output
334
-
335
- After completing work, provide:
336
- - What was done
337
- - Files created/modified
338
- - Validation results
339
- - Next steps
340
-
341
- ## Rules
342
-
343
- 1. Follow ARCHITECTURE.md patterns
344
- 2. Write clean, readable code
345
- 3. Add appropriate tests
346
- 4. Document changes
347
-
348
- ## Handoff Protocol
349
-
350
- - If code review needed → suggest @reviewer
351
- - If bugs found → suggest @doctor
352
- - If tests needed → suggest @tester
353
- `
354
-
355
- // ── Create Agent Command ─────────────────────────────
356
-
357
- async function createAgent() {
358
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
359
- clack.intro(`Create Custom Agent ${DIM}v${pkg.version}${NC}`)
360
-
361
- // Get agent name from args or prompt
362
- let agentName = args.find(a => a.startsWith('@'))?.replace('@', '') || args[args.indexOf('create-agent') + 1]
363
-
364
- if (!agentName || agentName.startsWith('-')) {
365
- const nameInput = await clack.text({
366
- message: 'Agent name (without @):',
367
- placeholder: 'my-agent',
368
- validate: (value) => {
369
- if (!value) return 'Name is required'
370
- if (!/^[a-z][a-z0-9-]*$/.test(value)) return 'Use lowercase letters, numbers, and hyphens'
371
- }
372
- })
373
- if (clack.isCancel(nameInput)) handleCancel()
374
- agentName = nameInput
375
- }
376
-
377
- agentName = agentName.replace('@', '')
378
-
379
- const description = await clack.text({
380
- message: 'What does this agent do?',
381
- placeholder: 'Handles X when Y happens',
382
- validate: (value) => !value ? 'Description is required' : undefined
383
- })
384
- if (clack.isCancel(description)) handleCancel()
385
-
386
- const title = await clack.text({
387
- message: 'Agent title (short):',
388
- placeholder: 'Custom Agent',
389
- initialValue: agentName.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')
390
- })
391
- if (clack.isCancel(title)) handleCancel()
392
-
393
- const mission = await clack.text({
394
- message: 'Mission statement (one sentence):',
395
- placeholder: 'Help developers with X by doing Y.'
396
- })
397
- if (clack.isCancel(mission)) handleCancel()
398
-
399
- const model = await clack.select({
400
- message: 'Default model:',
401
- options: [
402
- { value: 'sonnet', label: 'Sonnet', hint: 'Balanced (default)' },
403
- { value: 'haiku', label: 'Haiku', hint: 'Faster, cheaper' },
404
- { value: 'opus', label: 'Opus', hint: 'Most capable' },
405
- ]
406
- })
407
- if (clack.isCancel(model)) handleCancel()
408
-
409
- const installScope = await clack.select({
410
- message: 'Where to create?',
411
- options: [
412
- { value: 'project', label: 'This project', hint: '.claude/agents/' },
413
- { value: 'global', label: 'Global', hint: '~/.claude/agents/' },
414
- ]
415
- })
416
- if (clack.isCancel(installScope)) handleCancel()
417
-
418
- // Generate agent content
419
- const content = AGENT_TEMPLATE
420
- .replace(/\{\{name\}\}/g, agentName)
421
- .replace(/\{\{description\}\}/g, description)
422
- .replace(/\{\{title\}\}/g, title)
423
- .replace(/\{\{mission\}\}/g, mission || 'Help with specific tasks.')
424
- .replace(/model: \{\{model\}\}\n/, model === 'sonnet' ? '' : `model: ${model}\n`)
425
-
426
- // Determine destination
427
- const agentsDest = installScope === 'global'
428
- ? join(homedir(), '.claude', 'agents')
429
- : join(process.cwd(), '.claude', 'agents')
430
-
431
- mkdirSync(agentsDest, { recursive: true })
432
-
433
- const filePath = join(agentsDest, `${agentName}.md`)
434
-
435
- if (existsSync(filePath) && !forceMode) {
436
- const overwrite = await clack.confirm({
437
- message: `Agent @${agentName} already exists. Overwrite?`,
438
- initialValue: false
439
- })
440
- if (clack.isCancel(overwrite)) handleCancel()
441
- if (!overwrite) {
442
- clack.cancel('Agent creation cancelled.')
443
- process.exit(0)
444
- }
445
- }
446
-
447
- writeFileSync(filePath, content)
448
-
449
- clack.note([
450
- `File: ${filePath}`,
451
- '',
452
- 'Next steps:',
453
- `1. Edit the agent file to customize behavior`,
454
- `2. Use in Claude Code: "Use @${agentName} to..."`,
455
- ].join('\n'), `@${agentName} created!`)
456
-
457
- clack.outro('Agent ready to use!')
458
- }
459
-
460
- // ── List Command ─────────────────────────────────────
461
-
462
- async function listAgents() {
463
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
464
- console.log()
465
- console.log(` ${BOLD}Specialist Agent${NC} ${DIM}v${pkg.version}${NC}`)
466
- console.log()
467
-
468
- const cwd = process.cwd()
469
- const projectAgents = join(cwd, '.claude', 'agents')
470
- const globalAgents = join(homedir(), '.claude', 'agents')
471
- const projectSkills = join(cwd, '.claude', 'skills')
472
-
473
- console.log(` ${BOLD}Agents${NC}`)
474
- console.log()
475
-
476
- // Project agents
477
- if (existsSync(projectAgents)) {
478
- const agents = getAgentNames(projectAgents)
479
- if (agents.length > 0) {
480
- console.log(` ${DIM}Project (.claude/agents/):${NC}`)
481
- agents.forEach(a => console.log(` @${a}`))
482
- console.log()
483
- }
484
- }
485
-
486
- // Global agents
487
- if (existsSync(globalAgents)) {
488
- const agents = getAgentNames(globalAgents)
489
- if (agents.length > 0) {
490
- console.log(` ${DIM}Global (~/.claude/agents/):${NC}`)
491
- agents.forEach(a => console.log(` @${a}`))
492
- console.log()
493
- }
494
- }
495
-
496
- // Skills
497
- if (existsSync(projectSkills)) {
498
- const skills = readdirSync(projectSkills, { withFileTypes: true })
499
- .filter(d => d.isDirectory())
500
- .map(d => d.name)
501
-
502
- if (skills.length > 0) {
503
- console.log(` ${BOLD}Skills${NC}`)
504
- console.log()
505
- console.log(` ${DIM}Project (.claude/skills/):${NC}`)
506
- skills.forEach(s => console.log(` /${s}`))
507
- console.log()
508
- }
509
- }
510
-
511
- // Check for session memory
512
- const memoryFile = join(cwd, '.claude', 'session-memory.json')
513
- if (existsSync(memoryFile)) {
514
- console.log(` ${BOLD}Session Memory${NC}`)
515
- console.log(` ${DIM}Active: .claude/session-memory.json${NC}`)
516
- console.log()
517
- }
518
-
519
- // Check for profile
520
- const configFile = join(cwd, '.claude', 'config.json')
521
- if (existsSync(configFile)) {
522
- try {
523
- const config = JSON.parse(readFileSync(configFile, 'utf-8'))
524
- if (config.profile) {
525
- console.log(` ${BOLD}Profile${NC}`)
526
- console.log(` ${DIM}Active: ${config.profile}${NC}`)
527
- console.log()
528
- }
529
- } catch {}
530
- }
531
- }
532
-
533
- // ── Profiles Command ─────────────────────────────────
534
-
535
- async function manageProfiles() {
536
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
537
- clack.intro(`AI Team Profiles ${DIM}v${pkg.version}${NC}`)
538
-
539
- const profiles = {
540
- 'startup-fast': {
541
- description: 'Move fast, ship quickly. Minimal validation, Haiku model.',
542
- settings: { model: 'haiku', validation: 'minimal', checkpoints: false }
543
- },
544
- 'enterprise-strict': {
545
- description: 'Strict quality gates. Full validation, detailed reviews.',
546
- settings: { model: 'sonnet', validation: 'full', checkpoints: true }
547
- },
548
- 'learning-mode': {
549
- description: 'Explain everything. Learning-focused, verbose output.',
550
- settings: { model: 'sonnet', validation: 'full', explain: true }
551
- },
552
- 'cost-optimized': {
553
- description: 'Minimize token usage. Haiku where possible, skip extras.',
554
- settings: { model: 'haiku', validation: 'minimal', checkpoints: false }
555
- }
556
- }
557
-
558
- const subcommand = args[args.indexOf('profiles') + 1]
559
-
560
- if (subcommand === 'list' || !subcommand) {
561
- console.log()
562
- console.log(` ${BOLD}Available Profiles${NC}`)
563
- console.log()
564
- Object.entries(profiles).forEach(([name, info]) => {
565
- console.log(` ${BOLD}${name}${NC}`)
566
- console.log(` ${DIM}${info.description}${NC}`)
567
- console.log()
568
- })
569
-
570
- const configFile = join(process.cwd(), '.claude', 'config.json')
571
- if (existsSync(configFile)) {
572
- try {
573
- const config = JSON.parse(readFileSync(configFile, 'utf-8'))
574
- if (config.profile) {
575
- console.log(` ${BOLD}Current:${NC} ${config.profile}`)
576
- }
577
- } catch {}
578
- }
579
- return
580
- }
581
-
582
- if (subcommand === 'set') {
583
- const profileName = args[args.indexOf('set') + 1]
584
-
585
- if (!profileName || !profiles[profileName]) {
586
- const selected = await clack.select({
587
- message: 'Select profile:',
588
- options: Object.entries(profiles).map(([name, info]) => ({
589
- value: name,
590
- label: name,
591
- hint: info.description.substring(0, 50)
592
- }))
593
- })
594
- if (clack.isCancel(selected)) handleCancel()
595
-
596
- const configDir = join(process.cwd(), '.claude')
597
- mkdirSync(configDir, { recursive: true })
598
-
599
- const configFile = join(configDir, 'config.json')
600
- let config = {}
601
- if (existsSync(configFile)) {
602
- try { config = JSON.parse(readFileSync(configFile, 'utf-8')) } catch {}
603
- }
604
-
605
- config.profile = selected
606
- config.profileSettings = profiles[selected].settings
607
-
608
- writeFileSync(configFile, JSON.stringify(config, null, 2))
609
- clack.outro(`Profile set to: ${selected}`)
610
- } else {
611
- const configDir = join(process.cwd(), '.claude')
612
- mkdirSync(configDir, { recursive: true })
613
-
614
- const configFile = join(configDir, 'config.json')
615
- let config = {}
616
- if (existsSync(configFile)) {
617
- try { config = JSON.parse(readFileSync(configFile, 'utf-8')) } catch {}
618
- }
619
-
620
- config.profile = profileName
621
- config.profileSettings = profiles[profileName].settings
622
-
623
- writeFileSync(configFile, JSON.stringify(config, null, 2))
624
- console.log(` Profile set to: ${profileName}`)
625
- }
626
- }
627
- }
628
-
629
- // ── Community Skills ─────────────────────────────────
630
-
631
- async function manageCommunity() {
632
- const subCmd = args[1] || 'list'
633
- const homeDir = homedir()
634
- const communityDir = join(homeDir, '.claude', 'community-skills')
635
-
636
- if (subCmd === 'list') {
637
- console.log()
638
- console.log(` ${BOLD}Community Skills${NC}`)
639
- console.log()
640
-
641
- if (!existsSync(communityDir)) {
642
- console.log(` ${DIM}No community skills installed.${NC}`)
643
- console.log(` ${DIM}Install with: specialist-agent community install <git-url>${NC}`)
644
- return
645
- }
646
-
647
- const entries = readdirSync(communityDir, { withFileTypes: true })
648
- let count = 0
649
- for (const entry of entries) {
650
- if (!entry.isDirectory()) continue
651
- const skillFile = join(communityDir, entry.name, 'SKILL.md')
652
- if (existsSync(skillFile)) {
653
- const content = readFileSync(skillFile, 'utf-8')
654
- const nameMatch = content.match(/^name:\s*(.+)$/m)
655
- const descMatch = content.match(/^description:\s*"?([^"]*)"?$/m)
656
- const name = nameMatch ? nameMatch[1].trim() : entry.name
657
- const desc = descMatch ? descMatch[1].trim() : ''
658
- console.log(` ${GREEN}/${name}${NC} ${DIM}- ${desc}${NC}`)
659
- count++
660
- }
661
- }
662
-
663
- if (count === 0) {
664
- console.log(` ${DIM}No community skills found in ${communityDir}${NC}`)
665
- } else {
666
- console.log()
667
- console.log(` ${DIM}${count} community skill(s) installed${NC}`)
668
- }
669
- console.log()
670
-
671
- } else if (subCmd === 'install') {
672
- const source = args[2]
673
- if (!source) {
674
- console.error(` ${RED}Usage: specialist-agent community install <git-url|path>${NC}`)
675
- process.exit(1)
676
- }
677
-
678
- if (!existsSync(join(homeDir, '.claude'))) {
679
- mkdirSync(join(homeDir, '.claude'), { recursive: true })
680
- }
681
- if (!existsSync(communityDir)) {
682
- mkdirSync(communityDir, { recursive: true })
683
- }
684
-
685
- if (source.startsWith('http') || source.startsWith('git@')) {
686
- // Validate URL format to prevent injection
687
- if (source.startsWith('http')) {
688
- try { new URL(source) } catch {
689
- console.error(` ${RED}Invalid URL: ${source}${NC}`)
690
- process.exit(1)
691
- }
692
- }
693
-
694
- // Sanitize repo name — allow only safe characters
695
- const rawName = source.split('/').pop().replace('.git', '')
696
- const repoName = rawName.replace(/[^a-zA-Z0-9._-]/g, '')
697
- if (!repoName) {
698
- console.error(` ${RED}Invalid repository name${NC}`)
699
- process.exit(1)
700
- }
701
- const targetDir = join(communityDir, repoName)
702
-
703
- if (existsSync(targetDir)) {
704
- console.error(` ${YELLOW}Skill "${repoName}" already installed. Use --force to overwrite.${NC}`)
705
- if (!args.includes('--force')) process.exit(1)
706
- rmSync(targetDir, { recursive: true })
707
- }
708
-
709
- console.log(` Cloning ${source}...`)
710
- try {
711
- // Use execFileSync with array args to prevent command injection
712
- execFileSync('git', ['clone', '--depth', '1', source, targetDir], { stdio: 'pipe' })
713
- console.log(` ${GREEN}✓${NC} Installed "${repoName}" to community skills`)
714
- } catch (err) {
715
- console.error(` ${RED}Failed to clone: ${err.message}${NC}`)
716
- process.exit(1)
717
- }
718
- } else {
719
- // Local path copy
720
- const skillName = source.split('/').pop().split('\\').pop()
721
- const targetDir = join(communityDir, skillName)
722
-
723
- if (!existsSync(source)) {
724
- console.error(` ${RED}Source not found: ${source}${NC}`)
725
- process.exit(1)
726
- }
727
-
728
- if (existsSync(targetDir)) {
729
- console.error(` ${YELLOW}Skill "${skillName}" already installed. Use --force to overwrite.${NC}`)
730
- if (!args.includes('--force')) process.exit(1)
731
- rmSync(targetDir, { recursive: true })
732
- }
733
-
734
- cpSync(source, targetDir, { recursive: true })
735
- console.log(` ${GREEN}✓${NC} Installed "${skillName}" to community skills`)
736
- }
737
-
738
- } else if (subCmd === 'remove') {
739
- const skillName = args[2]
740
- if (!skillName) {
741
- console.error(` ${RED}Usage: specialist-agent community remove <skill-name>${NC}`)
742
- process.exit(1)
743
- }
744
-
745
- // Validate skill name — prevent path traversal (e.g. "../../etc")
746
- if (!/^[a-zA-Z0-9._-]+$/.test(skillName)) {
747
- console.error(` ${RED}Invalid skill name. Use only letters, numbers, dots, hyphens, and underscores.${NC}`)
748
- process.exit(1)
749
- }
750
-
751
- const targetDir = join(communityDir, skillName)
752
- if (!existsSync(targetDir)) {
753
- console.error(` ${RED}Skill "${skillName}" not found in community skills${NC}`)
754
- process.exit(1)
755
- }
756
-
757
- rmSync(targetDir, { recursive: true })
758
- console.log(` ${GREEN}✓${NC} Removed "${skillName}" from community skills`)
759
-
760
- } else {
761
- console.error(` ${YELLOW}Unknown subcommand: ${subCmd}${NC}`)
762
- console.log(` Usage: specialist-agent community [list|install|remove]`)
763
- process.exit(1)
764
- }
765
- }
766
-
767
- // ── Detect Command ──────────────────────────────────
768
-
769
- async function detectArchitecture() {
770
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
771
- clack.intro(`Architecture Detection ${DIM}v${pkg.version}${NC}`)
772
-
773
- const cwd = process.cwd()
774
- const isJson = args.includes('--json')
775
-
776
- // Detect framework
777
- const packs = readdirSync(join(ROOT, 'packs'), { withFileTypes: true })
778
- .filter(d => d.isDirectory())
779
- .map(d => d.name)
780
- const framework = detectFramework(join(cwd, 'package.json'), packs)
781
-
782
- // Run detection
783
- const s = clack.spinner()
784
- s.start('Scanning project structure...')
785
-
786
- const result = detectProjectArchitecture(cwd, { framework })
787
-
788
- s.stop('Detection complete')
789
-
790
- if (isJson) {
791
- console.log(JSON.stringify(result, null, 2))
792
- return
793
- }
794
-
795
- // Display report
796
- const report = generateDetectionReport(result)
797
- clack.note(report, 'Architecture Detection')
798
-
799
- // Get recommendations
800
- const teamSize = await clack.select({
801
- message: 'Team size (for recommendations)?',
802
- options: [
803
- { value: 'small', label: '1-3 developers', hint: 'Solo or small team' },
804
- { value: 'medium', label: '3-10 developers', hint: 'Medium team' },
805
- { value: 'large', label: '10-20 developers', hint: 'Large team' },
806
- { value: 'enterprise', label: '20+ developers', hint: 'Enterprise' },
807
- ],
808
- })
809
-
810
- if (clack.isCancel(teamSize)) handleCancel()
811
-
812
- const recs = getRecommendations(result, { teamSize })
813
-
814
- // Display recommendations
815
- const recLines = []
816
- recLines.push(recs.reason)
817
- recLines.push('')
818
-
819
- if (recs.monorepoNote) {
820
- recLines.push(recs.monorepoNote)
821
- recLines.push('')
822
- }
823
-
824
- for (const rec of recs.recommendations) {
825
- const tagLabel = rec.tag === 'recommended' ? `${GREEN}RECOMMENDED${NC}`
826
- : rec.tag === 'backend-recommended' ? `${YELLOW}BACKEND${NC}`
827
- : `${DIM}ALTERNATIVE${NC}`
828
- const sameNote = rec.isSameArch ? ` ${DIM}(current)${NC}` : ''
829
-
830
- recLines.push(` ${tagLabel} ${BOLD}${rec.name}${NC}${sameNote}`)
831
- recLines.push(` ${DIM}${rec.description}${NC}`)
832
-
833
- if (rec.migration) {
834
- const effortColor = rec.migration.effort === 'low' ? GREEN : rec.migration.effort === 'medium' ? YELLOW : RED
835
- recLines.push(` Migration: ${effortColor}${rec.migration.effort}${NC} - ${rec.migration.description}`)
836
- recLines.push(` Agents: ${rec.migration.agents.join(', ')}`)
837
- }
838
-
839
- recLines.push(` Variants:`)
840
- for (const v of rec.variants) {
841
- recLines.push(` ${BOLD}${v.name}${NC}: ${v.description.slice(0, 100)}${v.description.length > 100 ? '...' : ''}`)
842
- if (v.directoryStructure) {
843
- for (const line of v.directoryStructure.slice(0, 6)) {
844
- recLines.push(` ${DIM}${line}${NC}`)
845
- }
846
- if (v.directoryStructure.length > 6) {
847
- recLines.push(` ${DIM}... (${v.directoryStructure.length - 6} more)${NC}`)
848
- }
849
- }
850
- }
851
- recLines.push('')
852
- }
853
-
854
- // Framework notes
855
- if (recs.frameworkNotes) {
856
- recLines.push(`${BOLD}Framework Notes:${NC}`)
857
- for (const note of recs.frameworkNotes.extraNotes) {
858
- recLines.push(` - ${note}`)
859
- }
860
- if (recs.frameworkNotes.preferredStateManagement) {
861
- recLines.push(` State management: ${recs.frameworkNotes.preferredStateManagement}`)
862
- }
863
- }
864
-
865
- clack.note(recLines.join('\n'), 'Architecture Recommendations')
866
-
867
- // Offer to generate ARCHITECTURE.md
868
- const generateArch = await clack.confirm({
869
- message: 'Generate docs/ARCHITECTURE.md for the recommended architecture?',
870
- initialValue: false,
871
- })
872
-
873
- if (clack.isCancel(generateArch)) handleCancel()
874
-
875
- if (generateArch && recs.recommendations.length > 0) {
876
- const archChoice = recs.recommendations.length > 1
877
- ? await clack.select({
878
- message: 'Which architecture?',
879
- options: recs.recommendations.map(r => ({
880
- value: r.id,
881
- label: r.name,
882
- hint: r.tag === 'recommended' ? 'Recommended' : r.tag,
883
- })),
884
- })
885
- : recs.recommendations[0].id
886
-
887
- if (clack.isCancel(archChoice)) handleCancel()
888
-
889
- const variantChoice = await clack.select({
890
- message: 'Which variant?',
891
- options: [
892
- { value: 'full', label: 'Full', hint: 'All layers and patterns' },
893
- { value: 'lite', label: 'Simplified', hint: 'Fewer layers, same principles' },
894
- ],
895
- })
896
-
897
- if (clack.isCancel(variantChoice)) handleCancel()
898
-
899
- const guide = generateArchitectureGuide({
900
- architecture: archChoice,
901
- framework: framework || 'react',
902
- variant: variantChoice,
903
- nextjsRouter: result.nextjsRouter,
904
- })
905
-
906
- const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
907
- if (existsSync(archDest)) {
908
- const overwrite = await clack.confirm({
909
- message: 'docs/ARCHITECTURE.md already exists. Overwrite?',
910
- initialValue: false,
911
- })
912
- if (clack.isCancel(overwrite)) handleCancel()
913
- if (!overwrite) {
914
- clack.log.info('Skipped ARCHITECTURE.md generation.')
915
- clack.outro('Detection complete!')
916
- return
917
- }
918
- }
919
-
920
- mkdirSync(dirname(archDest), { recursive: true })
921
- writeFileSync(archDest, guide)
922
- clack.log.success(`Generated docs/ARCHITECTURE.md (${ARCHITECTURE_PATTERNS[archChoice]?.name || archChoice} - ${variantChoice})`)
923
- }
924
-
925
- clack.outro('Detection complete! Use /migrate-architecture to apply changes.')
926
- }
927
-
928
- // ── Command Router ───────────────────────────────────
929
-
930
- if (command === 'detect') {
931
- detectArchitecture().catch(err => {
932
- clack.log.error(err.message)
933
- process.exit(1)
934
- })
935
- } else if (command === 'create-agent') {
936
- createAgent().catch(err => {
937
- clack.log.error(err.message)
938
- process.exit(1)
939
- })
940
- } else if (command === 'list') {
941
- listAgents()
942
- } else if (command === 'profiles') {
943
- manageProfiles().catch(err => {
944
- clack.log.error(err.message)
945
- process.exit(1)
946
- })
947
- } else if (command === 'community') {
948
- manageCommunity().catch(err => {
949
- clack.log.error(err.message)
950
- process.exit(1)
951
- })
952
- } else {
953
- // Default to init
954
-
955
- // ── Main ─────────────────────────────────────────────
956
-
957
- async function main() {
958
- const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
959
-
960
- clack.intro(`Specialist Agent ${DIM}v${pkg.version}${NC}`)
961
-
962
- // Check for updates (non-blocking)
963
- const latestVersion = await checkForUpdates(pkg.version)
964
- if (latestVersion) {
965
- clack.log.warn(`Update available: v${pkg.version} → v${latestVersion}`)
966
- clack.log.info(`${DIM}Run: npm i -g specialist-agent@latest${NC}`)
967
- }
968
-
969
- const cwd = process.cwd()
970
-
971
- // ── Auto-detect everything ──────────────────────────
972
-
973
- // package.json is optional — init continues without it
974
-
975
- // Auto-detect framework
976
- const packs = readdirSync(join(ROOT, 'packs'), { withFileTypes: true })
977
- .filter(d => d.isDirectory())
978
- .map(d => d.name)
979
-
980
- const packLabels = { vue: 'Vue 3', react: 'React', nextjs: 'Next.js', svelte: 'SvelteKit', angular: 'Angular', astro: 'Astro', nuxt: 'Nuxt' }
981
-
982
- const detected = detectFramework(join(cwd, 'package.json'), packs)
983
-
984
- // Auto-detect architecture
985
- let framework = detected
986
- const isEmptyProject = !detected
987
- const archDetection = detectProjectArchitecture(cwd, { framework: isEmptyProject ? null : framework })
988
- const detectedArch = archDetection.architecture
989
- const detectedArchName = ARCHITECTURE_PATTERNS[detectedArch]?.name || detectedArch
990
-
991
- // ── Show detection results ──────────────────────────
992
-
993
- const detectionLines = []
994
- if (detected) {
995
- detectionLines.push(`${GREEN}✓${NC} Framework: ${BOLD}${packLabels[detected] || detected}${NC}`)
996
- } else {
997
- detectionLines.push(`${DIM}○ Framework: none detected${NC}`)
998
- }
999
- if (detectedArch && detectedArch !== 'unstructured') {
1000
- detectionLines.push(`${GREEN}✓${NC} Architecture: ${BOLD}${detectedArchName}${NC}`)
1001
- }
1002
- if (archDetection.monorepo) {
1003
- detectionLines.push(`${GREEN}✓${NC} Monorepo: ${BOLD}${archDetection.monorepo.name}${NC} (${archDetection.monorepo.apps.length} apps/packages)`)
1004
- }
1005
-
1006
- clack.note(detectionLines.join('\n'), 'Auto-detected')
1007
-
1008
- // ── Step 1: Framework (only ask if not detected) ────
1009
-
1010
- if (!detected) {
1011
- framework = 'none'
1012
- clack.log.info('No framework detected — installing universal agents.')
1013
- clack.log.info(`${DIM}When you choose a framework, re-run: npx specialist-agent init${NC}`)
1014
- }
1015
-
1016
- const isNone = framework === 'none' || !framework
1017
-
1018
- // ── Step 2: Mode ────────────────────────────────────
1019
-
1020
- const mode = await clack.select({
1021
- message: 'Agent mode?',
1022
- options: [
1023
- { value: 'full', label: 'Full', hint: 'Sonnet/Opus — best quality' },
1024
- { value: 'lite', label: 'Lite', hint: 'Haiku — lower cost, faster' },
1025
- ],
1026
- })
1027
-
1028
- if (clack.isCancel(mode)) handleCancel()
1029
-
1030
- // ── Step 3: Install scope ──────────────────────────
1031
-
1032
- const installScope = await clack.select({
1033
- message: 'Install scope?',
1034
- options: [
1035
- { value: 'project', label: 'This project', hint: '.claude/agents/' },
1036
- { value: 'global', label: 'Global', hint: '~/.claude/agents/ — all projects' },
1037
- ],
1038
- })
1039
-
1040
- if (clack.isCancel(installScope)) handleCancel()
1041
-
1042
- // ── Step 4: Customize (optional) ───────────────────
1043
-
1044
- const customize = await clack.confirm({
1045
- message: `Customize installation? ${DIM}(hooks, agent selection)${NC}`,
1046
- initialValue: false,
1047
- })
1048
-
1049
- if (clack.isCancel(customize)) handleCancel()
1050
-
1051
- let selectedHooks = ['security-guard', 'auto-dispatch', 'session-context', 'mcp-discovery']
1052
- let installStarter = true
1053
- let installWorkflow = true
1054
- let installSpecialists = true
1055
- let installBusiness = true
1056
-
1057
- if (customize) {
1058
- // Native hooks selection
1059
- const hookChoices = await clack.multiselect({
1060
- message: 'Native Claude Code hooks:',
1061
- options: [
1062
- { value: 'security-guard', label: 'Security Guard', hint: 'Block dangerous commands', selected: true },
1063
- { value: 'auto-dispatch', label: 'Auto-Dispatch', hint: 'Suggest agents based on prompt', selected: true },
1064
- { value: 'session-context', label: 'Session Context', hint: 'Inject project state on start', selected: true },
1065
- { value: 'mcp-discovery', label: 'MCP Discovery', hint: 'Detect MCP servers and enhance agents', selected: true },
1066
- { value: 'auto-format', label: 'Auto-Format', hint: 'Format files after Write/Edit', selected: false },
1067
- ],
1068
- required: false,
1069
- })
1070
-
1071
- if (!clack.isCancel(hookChoices)) {
1072
- selectedHooks = hookChoices
1073
- }
1074
-
1075
- // Agent group selection
1076
- const agentGroups = await clack.multiselect({
1077
- message: 'Agent groups to install:',
1078
- options: [
1079
- { value: 'core', label: 'Core', hint: '@builder, @reviewer, @doctor, @migrator, @starter', selected: true },
1080
- { value: 'workflow', label: 'Workflow', hint: '@planner, @executor, @tdd, @debugger, @pair, @analyst, @orchestrator', selected: true },
1081
- { value: 'specialist', label: 'Specialist', hint: '@api, @perf, @security, @finance, @data, @devops, @architect, ...', selected: true },
1082
- { value: 'business', label: 'Business', hint: '@marketing, @product, @support', selected: true },
1083
- ],
1084
- required: true,
1085
- })
1086
-
1087
- if (!clack.isCancel(agentGroups)) {
1088
- installStarter = agentGroups.includes('core')
1089
- installWorkflow = agentGroups.includes('workflow')
1090
- installSpecialists = agentGroups.includes('specialist')
1091
- installBusiness = agentGroups.includes('business')
1092
- }
1093
- }
1094
-
1095
- // ── Install ─────────────────────────────────────────
1096
-
1097
- const defaultPack = isNone ? 'react' : framework
1098
- const packDir = join(ROOT, 'packs', defaultPack)
1099
- const agentsSource = mode === 'lite' ? join(packDir, 'agents-lite') : join(packDir, 'agents')
1100
- const skillsSource = join(packDir, 'skills')
1101
- const claudeSource = isNone ? join(ROOT, 'CLAUDE.md') : join(packDir, 'CLAUDE.md')
1102
-
1103
- const installGlobal = installScope === 'global'
1104
- const agentsDest = installGlobal
1105
- ? join(homedir(), '.claude', 'agents')
1106
- : join(cwd, '.claude', 'agents')
1107
- mkdirSync(agentsDest, { recursive: true })
1108
-
1109
- const s = clack.spinner()
1110
- s.start('Installing agents, skills, and hooks...')
1111
-
1112
- // Install pack agents (additive: updates ours, preserves user's)
1113
- if (existsSync(agentsSource)) {
1114
- copyManagedFiles(agentsSource, agentsDest)
1115
- }
1116
-
1117
- // Install all agent groups
1118
- const allAgentNames = []
1119
-
1120
- if (installStarter) allAgentNames.push('starter')
1121
-
1122
- if (installWorkflow) {
1123
- allAgentNames.push('planner', 'executor', 'tdd', 'debugger', 'pair', 'analyst', 'orchestrator', 'scout', 'memory')
1124
- }
1125
-
1126
- if (installSpecialists) {
1127
- allAgentNames.push(
1128
- 'api', 'perf', 'i18n', 'docs', 'refactor', 'deps',
1129
- 'explorer', 'finance', 'cloud', 'security', 'designer', 'data',
1130
- 'devops', 'tester', 'legal', 'architect', 'ripple', 'sentry-triage'
1131
- )
1132
- }
1133
-
1134
- if (installBusiness) {
1135
- allAgentNames.push('marketing', 'product', 'support')
1136
- }
1137
-
1138
- for (const name of allAgentNames) {
1139
- const suffix = mode === 'lite' ? '-lite.md' : '.md'
1140
- const source = join(ROOT, 'agents', `${name}${suffix}`)
1141
- const dest = join(agentsDest, `${name}.md`)
1142
- if (existsSync(source)) {
1143
- cpSync(source, dest)
1144
- }
1145
- }
1146
-
1147
- // Install skills (additive: updates ours, preserves user's)
1148
- const skillsDest = join(cwd, '.claude', 'skills')
1149
- mkdirSync(skillsDest, { recursive: true })
1150
- let skillCount = 0
1151
- if (existsSync(skillsSource)) {
1152
- skillCount = copyManagedFiles(skillsSource, skillsDest)
1153
- }
1154
-
1155
- const genericSkillsSource = join(ROOT, 'skills')
1156
- if (existsSync(genericSkillsSource)) {
1157
- skillCount += copyManagedFiles(genericSkillsSource, skillsDest)
1158
- }
1159
-
1160
- // Install native hooks (defaults: security-guard, auto-dispatch, session-context)
1161
- let nativeHooksInstalled = 0
1162
- if (selectedHooks.length > 0) {
1163
- nativeHooksInstalled = setupNativeHooks(cwd, selectedHooks)
1164
- }
1165
-
1166
- // Install CLAUDE.md
1167
- const claudeDest = join(cwd, 'CLAUDE.md')
1168
- let claudeInstalled = false
1169
- if (!existsSync(claudeDest)) {
1170
- if (claudeSource && existsSync(claudeSource)) {
1171
- cpSync(claudeSource, claudeDest)
1172
- claudeInstalled = true
1173
- } else {
1174
- const rootClaude = join(ROOT, 'CLAUDE.md')
1175
- if (existsSync(rootClaude)) {
1176
- cpSync(rootClaude, claudeDest)
1177
- claudeInstalled = true
1178
- }
1179
- }
1180
- }
1181
-
1182
- s.stop('Installation complete')
1183
-
1184
- // ── Summary ────────────────────────────────────────
1185
-
1186
- const installedAgentNames = getAgentNames(agentsDest)
1187
- const packLabel = isNone ? 'Universal' : (packLabels[framework] || framework)
1188
-
1189
- const summaryLines = []
1190
- summaryLines.push(`${GREEN}✓${NC} ${BOLD}${installedAgentNames.length} agents${NC} → .claude/agents/`)
1191
- if (skillCount > 0) summaryLines.push(`${GREEN}✓${NC} ${BOLD}${skillCount} skills${NC} → .claude/skills/`)
1192
- if (nativeHooksInstalled > 0) summaryLines.push(`${GREEN}✓${NC} ${BOLD}${nativeHooksInstalled} hooks${NC} → .claude/hooks/`)
1193
- if (claudeInstalled) summaryLines.push(`${GREEN}✓${NC} CLAUDE.md`)
1194
-
1195
- const scopeLabel = installGlobal ? 'Global' : 'Project'
1196
- clack.note(summaryLines.join('\n'), `${packLabel} · ${mode === 'full' ? 'Full' : 'Lite'} · ${scopeLabel}`)
1197
-
1198
- // Getting started
1199
- const installedSkills = existsSync(skillsDest)
1200
- ? readdirSync(skillsDest, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => '/' + d.name)
1201
- : []
1202
-
1203
- clack.note(buildGettingStarted(installedAgentNames, installedSkills, isNone), 'Getting started')
1204
-
1205
- if (mode === 'lite') {
1206
- clack.log.info(`${DIM}Lite mode: agents run on Haiku (lower cost, faster).${NC}`)
1207
- clack.log.info(`${DIM}Switch to Full: npx specialist-agent init${NC}`)
1208
- }
1209
-
1210
- clack.outro('Setup complete! Run claude to get started.')
1211
- }
1212
-
1213
- main().catch((err) => {
1214
- clack.log.error(err.message)
1215
- process.exit(1)
1216
- })
1217
- }