specialist-agent 2.9.0 → 2.11.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.
- package/.claude-plugin/marketplace.json +5 -5
- package/.claude-plugin/plugin.json +2 -2
- package/.cursor-plugin/marketplace.json +1 -1
- package/.cursor-plugin/plugin.json +2 -2
- package/.opencode/INSTALL.md +74 -79
- package/.opencode/opencode.json +141 -0
- package/README.md +128 -250
- package/agents/analyst.md +1 -0
- package/agents/api.md +4 -4
- package/agents/architect-lite.md +2 -2
- package/agents/architect.md +29 -20
- package/agents/cloud-lite.md +1 -1
- package/agents/cloud.md +4 -4
- package/agents/data-lite.md +1 -1
- package/agents/data.md +4 -4
- package/agents/debugger.md +1 -0
- package/agents/deps.md +4 -4
- package/agents/designer-lite.md +1 -1
- package/agents/designer.md +4 -4
- package/agents/devops-lite.md +1 -1
- package/agents/devops.md +4 -4
- package/agents/docs.md +4 -4
- package/agents/executor.md +95 -0
- package/agents/explorer-lite.md +1 -1
- package/agents/explorer.md +4 -4
- package/agents/finance-lite.md +1 -1
- package/agents/finance.md +4 -4
- package/agents/i18n.md +4 -4
- package/agents/legal-lite.md +1 -1
- package/agents/legal.md +4 -4
- package/agents/marketing-lite.md +25 -0
- package/agents/marketing.md +179 -0
- package/agents/memory.md +13 -12
- package/agents/orchestrator.md +102 -0
- package/agents/pair.md +1 -0
- package/agents/perf.md +4 -4
- package/agents/planner.md +1 -0
- package/agents/product-lite.md +25 -0
- package/agents/product.md +186 -0
- package/agents/refactor.md +4 -4
- package/agents/ripple.md +1 -0
- package/agents/scout.md +1 -0
- package/agents/security-lite.md +1 -1
- package/agents/security.md +4 -4
- package/agents/sentry-triage-lite.md +54 -0
- package/agents/sentry-triage.md +214 -0
- package/agents/starter-lite.md +4 -4
- package/agents/starter.md +8 -8
- package/agents/support-lite.md +24 -0
- package/agents/support.md +190 -0
- package/agents/tdd.md +1 -0
- package/agents/tester-lite.md +1 -1
- package/agents/tester.md +43 -10
- package/cli/architectures.mjs +713 -0
- package/cli/detect-architecture.mjs +752 -0
- package/cli/generate-architecture.mjs +1096 -0
- package/cli/index.mjs +681 -179
- package/cli/recommend-architecture.mjs +870 -0
- package/hooks/native/auto-dispatch.mjs +22 -23
- package/hooks/native/auto-format.mjs +5 -25
- package/hooks/native/mcp-discovery.mjs +168 -0
- package/hooks/native/security-config.json +7 -0
- package/hooks/native/security-guard.mjs +77 -27
- package/hooks/native/session-context.mjs +61 -18
- package/hooks/native/settings-template.json +9 -0
- package/package.json +1 -1
- package/packs/angular/agents/builder.md +10 -54
- package/packs/angular/agents/doctor.md +7 -61
- package/packs/angular/agents/migrator.md +7 -101
- package/packs/angular/agents/reviewer.md +22 -33
- package/packs/angular/skills/review-check-architecture/SKILL.md +7 -7
- package/packs/angular/skills/review-review/SKILL.md +1 -0
- package/packs/astro/agents/builder.md +10 -79
- package/packs/astro/agents/doctor.md +7 -61
- package/packs/astro/agents/migrator.md +7 -111
- package/packs/astro/agents/reviewer.md +22 -32
- package/packs/astro/skills/review-check-architecture/SKILL.md +9 -9
- package/packs/astro/skills/review-review/SKILL.md +1 -0
- package/packs/nextjs/agents/builder.md +11 -108
- package/packs/nextjs/agents/doctor.md +7 -62
- package/packs/nextjs/agents/migrator.md +6 -194
- package/packs/nextjs/agents/reviewer.md +22 -76
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +15 -15
- package/packs/nextjs/skills/review-review/SKILL.md +1 -0
- package/packs/nuxt/agents/builder.md +10 -55
- package/packs/nuxt/agents/doctor.md +7 -61
- package/packs/nuxt/agents/migrator.md +7 -109
- package/packs/nuxt/agents/reviewer.md +22 -42
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +11 -11
- package/packs/nuxt/skills/review-review/SKILL.md +1 -0
- package/packs/react/agents/builder.md +10 -55
- package/packs/react/agents/doctor.md +7 -61
- package/packs/react/agents/migrator.md +7 -106
- package/packs/react/agents/reviewer.md +22 -55
- package/packs/react/skills/review-check-architecture/SKILL.md +10 -10
- package/packs/react/skills/review-review/SKILL.md +1 -0
- package/packs/svelte/agents/builder.md +10 -58
- package/packs/svelte/agents/doctor.md +7 -60
- package/packs/svelte/agents/migrator.md +7 -118
- package/packs/svelte/agents/reviewer.md +22 -42
- package/packs/svelte/skills/review-check-architecture/SKILL.md +12 -12
- package/packs/svelte/skills/review-review/SKILL.md +1 -0
- package/packs/vue/agents/builder.md +10 -55
- package/packs/vue/agents/doctor.md +7 -61
- package/packs/vue/agents/migrator.md +7 -93
- package/packs/vue/agents/reviewer.md +20 -32
- package/packs/vue/skills/review-check-architecture/SKILL.md +10 -10
- package/packs/vue/skills/review-review/SKILL.md +1 -0
- package/skills/autofix/SKILL.md +166 -0
- package/skills/discovery/SKILL.md +218 -0
- package/skills/migrate-architecture/SKILL.md +242 -0
package/cli/index.mjs
CHANGED
|
@@ -6,6 +6,10 @@ import { execFileSync } from 'child_process'
|
|
|
6
6
|
import { join, dirname, resolve } from 'path'
|
|
7
7
|
import { fileURLToPath } from 'url'
|
|
8
8
|
import { homedir } from 'os'
|
|
9
|
+
import { ARCHITECTURE_PATTERNS, MIGRATION_MAP } 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'
|
|
9
13
|
|
|
10
14
|
const __filename = fileURLToPath(import.meta.url)
|
|
11
15
|
const __dirname = dirname(__filename)
|
|
@@ -14,6 +18,7 @@ const ROOT = resolve(__dirname, '..')
|
|
|
14
18
|
const YELLOW = '\x1b[33m'
|
|
15
19
|
const RED = '\x1b[31m'
|
|
16
20
|
const GREEN = '\x1b[32m'
|
|
21
|
+
const CYAN = '\x1b[36m'
|
|
17
22
|
const BOLD = '\x1b[1m'
|
|
18
23
|
const DIM = '\x1b[2m'
|
|
19
24
|
const NC = '\x1b[0m'
|
|
@@ -80,6 +85,7 @@ const HOOK_EVENT_MAP = {
|
|
|
80
85
|
'security-guard': 'PreToolUse',
|
|
81
86
|
'auto-dispatch': 'UserPromptSubmit',
|
|
82
87
|
'session-context': 'SessionStart',
|
|
88
|
+
'mcp-discovery': 'SessionStart',
|
|
83
89
|
'auto-format': 'PostToolUse',
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -95,6 +101,7 @@ function setupNativeHooks(cwd, selectedHooks) {
|
|
|
95
101
|
'security-config.json',
|
|
96
102
|
'auto-dispatch.mjs',
|
|
97
103
|
'session-context.mjs',
|
|
104
|
+
'mcp-discovery.mjs',
|
|
98
105
|
'auto-format.mjs',
|
|
99
106
|
]
|
|
100
107
|
for (const file of filesToCopy) {
|
|
@@ -199,18 +206,196 @@ function detectFramework(pkgPath, availablePacks) {
|
|
|
199
206
|
return null
|
|
200
207
|
}
|
|
201
208
|
|
|
209
|
+
// ── Platform Detection ──────────────────────────────
|
|
210
|
+
|
|
211
|
+
const PLATFORMS = {
|
|
212
|
+
'claude-code': {
|
|
213
|
+
label: 'Claude Code',
|
|
214
|
+
detect: (cwd) => true, // always install (primary platform)
|
|
215
|
+
},
|
|
216
|
+
'cursor': {
|
|
217
|
+
label: 'Cursor',
|
|
218
|
+
detect: (cwd) => {
|
|
219
|
+
if (existsSync(join(cwd, '.cursor'))) return true
|
|
220
|
+
if (existsSync(join(cwd, '.cursorignore'))) return true
|
|
221
|
+
if (existsSync(join(cwd, '.cursorrules'))) return true
|
|
222
|
+
try { execFileSync('cursor', ['--version'], { stdio: 'pipe', timeout: 3000 }); return true } catch { return false }
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
'windsurf': {
|
|
226
|
+
label: 'Windsurf',
|
|
227
|
+
detect: (cwd) => {
|
|
228
|
+
if (existsSync(join(cwd, '.windsurf'))) return true
|
|
229
|
+
if (existsSync(join(cwd, '.windsurfrules'))) return true
|
|
230
|
+
try { execFileSync('windsurf', ['--version'], { stdio: 'pipe', timeout: 3000 }); return true } catch { return false }
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
'vscode': {
|
|
234
|
+
label: 'VS Code',
|
|
235
|
+
detect: (cwd) => {
|
|
236
|
+
if (existsSync(join(cwd, '.vscode'))) return true
|
|
237
|
+
try { execFileSync('code', ['--version'], { stdio: 'pipe', timeout: 3000 }); return true } catch { return false }
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
'codex': {
|
|
241
|
+
label: 'Codex',
|
|
242
|
+
detect: (cwd) => {
|
|
243
|
+
if (existsSync(join(cwd, '.codex'))) return true
|
|
244
|
+
try { execFileSync('codex', ['--version'], { stdio: 'pipe', timeout: 3000 }); return true } catch { return false }
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
'opencode': {
|
|
248
|
+
label: 'OpenCode',
|
|
249
|
+
detect: (cwd) => {
|
|
250
|
+
if (existsSync(join(cwd, '.opencode'))) return true
|
|
251
|
+
if (existsSync(join(cwd, 'opencode.json'))) return true
|
|
252
|
+
try { execFileSync('opencode', ['--version'], { stdio: 'pipe', timeout: 3000 }); return true } catch { return false }
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function detectPlatforms(cwd) {
|
|
258
|
+
const detected = []
|
|
259
|
+
for (const [id, platform] of Object.entries(PLATFORMS)) {
|
|
260
|
+
if (platform.detect(cwd)) {
|
|
261
|
+
detected.push({ id, label: platform.label })
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return detected
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function setupPlatformConfigs(cwd, platforms, { framework, version }) {
|
|
268
|
+
const installed = []
|
|
269
|
+
|
|
270
|
+
for (const platform of platforms) {
|
|
271
|
+
switch (platform.id) {
|
|
272
|
+
case 'claude-code':
|
|
273
|
+
// Handled by main install flow
|
|
274
|
+
break
|
|
275
|
+
|
|
276
|
+
case 'cursor': {
|
|
277
|
+
const cursorDir = join(cwd, '.cursor')
|
|
278
|
+
mkdirSync(cursorDir, { recursive: true })
|
|
279
|
+
|
|
280
|
+
// Copy agents to .cursor/agents/ (Cursor reads agents from here)
|
|
281
|
+
const cursorAgentsDir = join(cursorDir, 'agents')
|
|
282
|
+
const claudeAgentsDir = join(cwd, '.claude', 'agents')
|
|
283
|
+
if (existsSync(claudeAgentsDir)) {
|
|
284
|
+
mkdirSync(cursorAgentsDir, { recursive: true })
|
|
285
|
+
copyDir(claudeAgentsDir, cursorAgentsDir)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
installed.push({ platform: 'Cursor', path: '.cursor/agents/' })
|
|
289
|
+
break
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
case 'windsurf': {
|
|
293
|
+
const windsurfDir = join(cwd, '.windsurf')
|
|
294
|
+
mkdirSync(windsurfDir, { recursive: true })
|
|
295
|
+
|
|
296
|
+
// Copy agents to .windsurf/agents/
|
|
297
|
+
const wsAgentsDir = join(windsurfDir, 'agents')
|
|
298
|
+
const claudeAgentsDir = join(cwd, '.claude', 'agents')
|
|
299
|
+
if (existsSync(claudeAgentsDir)) {
|
|
300
|
+
mkdirSync(wsAgentsDir, { recursive: true })
|
|
301
|
+
copyDir(claudeAgentsDir, wsAgentsDir)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
installed.push({ platform: 'Windsurf', path: '.windsurf/agents/' })
|
|
305
|
+
break
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
case 'vscode': {
|
|
309
|
+
// VS Code uses .vscode/ — just ensure the settings reference .claude/
|
|
310
|
+
const vscodeDir = join(cwd, '.vscode')
|
|
311
|
+
mkdirSync(vscodeDir, { recursive: true })
|
|
312
|
+
|
|
313
|
+
const settingsPath = join(vscodeDir, 'settings.json')
|
|
314
|
+
let settings = {}
|
|
315
|
+
if (existsSync(settingsPath)) {
|
|
316
|
+
try { settings = JSON.parse(readFileSync(settingsPath, 'utf-8')) } catch {}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!settings['specialist-agent.framework']) {
|
|
320
|
+
settings['specialist-agent.framework'] = framework || 'auto'
|
|
321
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2))
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
installed.push({ platform: 'VS Code', path: '.vscode/settings.json' })
|
|
325
|
+
break
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
case 'codex': {
|
|
329
|
+
// Codex reads from .claude/agents/ — same as Claude Code, just confirm
|
|
330
|
+
installed.push({ platform: 'Codex', path: '.claude/agents/' })
|
|
331
|
+
break
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
case 'opencode': {
|
|
335
|
+
// Copy agents to .opencode/agents/
|
|
336
|
+
const opencodeDir = join(cwd, '.opencode')
|
|
337
|
+
mkdirSync(join(opencodeDir, 'agents'), { recursive: true })
|
|
338
|
+
|
|
339
|
+
const claudeAgentsDir = join(cwd, '.claude', 'agents')
|
|
340
|
+
if (existsSync(claudeAgentsDir)) {
|
|
341
|
+
copyDir(claudeAgentsDir, join(opencodeDir, 'agents'))
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Copy opencode.json if it doesn't exist
|
|
345
|
+
const opencodeConfigSrc = join(ROOT, '.opencode', 'opencode.json')
|
|
346
|
+
const opencodeConfigDest = join(cwd, 'opencode.json')
|
|
347
|
+
if (!existsSync(opencodeConfigDest) && existsSync(opencodeConfigSrc)) {
|
|
348
|
+
cpSync(opencodeConfigSrc, opencodeConfigDest)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
installed.push({ platform: 'OpenCode', path: '.opencode/agents/' })
|
|
352
|
+
break
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return installed
|
|
358
|
+
}
|
|
359
|
+
|
|
202
360
|
// ── Guidance texts ───────────────────────────────────
|
|
203
361
|
|
|
204
|
-
function buildGettingStarted(agentNames, installedSkills, archInstalled) {
|
|
362
|
+
function buildGettingStarted(agentNames, installedSkills, archInstalled, isEmptyProject) {
|
|
205
363
|
const lines = []
|
|
206
364
|
|
|
365
|
+
if (isEmptyProject) {
|
|
366
|
+
lines.push('You\'re starting fresh — here\'s how to get going:')
|
|
367
|
+
lines.push('')
|
|
368
|
+
lines.push(' $ claude')
|
|
369
|
+
lines.push('')
|
|
370
|
+
if (agentNames.includes('starter')) {
|
|
371
|
+
lines.push(' Create a project from scratch:')
|
|
372
|
+
lines.push(' > "Use @starter to create an app with Next.js + PostgreSQL"')
|
|
373
|
+
lines.push(' > "Use @starter to create a Vue 3 SaaS with Stripe"')
|
|
374
|
+
lines.push('')
|
|
375
|
+
}
|
|
376
|
+
if (agentNames.includes('planner')) {
|
|
377
|
+
lines.push(' Plan before building:')
|
|
378
|
+
lines.push(' > /plan add user authentication with JWT')
|
|
379
|
+
lines.push(' > /discovery implement real-time chat with WebSocket')
|
|
380
|
+
lines.push('')
|
|
381
|
+
}
|
|
382
|
+
lines.push(' All 35 agents are installed. When you choose a framework,')
|
|
383
|
+
lines.push(' re-run to swap to framework-specific pack agents:')
|
|
384
|
+
lines.push(' > npx specialist-agent init')
|
|
385
|
+
return lines.join('\n')
|
|
386
|
+
}
|
|
387
|
+
|
|
207
388
|
if (archInstalled) {
|
|
208
389
|
lines.push('Agents enforce the architecture defined in docs/ARCHITECTURE.md.')
|
|
209
|
-
lines.push('They ensure consistency across modules
|
|
390
|
+
lines.push('They ensure consistency across modules — the more you use them,')
|
|
210
391
|
lines.push('the more value they deliver.')
|
|
392
|
+
lines.push('')
|
|
393
|
+
lines.push('To migrate your project to the new architecture:')
|
|
394
|
+
lines.push(' > "Use /migrate-architecture to restructure my project"')
|
|
395
|
+
lines.push(' > "Use @architect to assess my current architecture"')
|
|
211
396
|
} else {
|
|
212
397
|
lines.push('Agents use generic best practices for your framework.')
|
|
213
|
-
lines.push('To customize patterns,
|
|
398
|
+
lines.push('To customize patterns, run: specialist-agent detect')
|
|
214
399
|
}
|
|
215
400
|
lines.push('')
|
|
216
401
|
lines.push('Examples:')
|
|
@@ -230,16 +415,19 @@ function buildGettingStarted(agentNames, installedSkills, archInstalled) {
|
|
|
230
415
|
if (installedSkills.length > 0) {
|
|
231
416
|
lines.push('')
|
|
232
417
|
lines.push('Skills (slash commands):')
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
418
|
+
const topSkills = ['/plan', '/tdd', '/audit', '/discovery']
|
|
419
|
+
const available = topSkills.filter(s => installedSkills.includes(s))
|
|
420
|
+
if (available.length > 0) {
|
|
421
|
+
available.forEach(skill => lines.push(` > ${skill}`))
|
|
422
|
+
} else {
|
|
423
|
+
installedSkills.slice(0, 4).forEach(skill => lines.push(` > ${skill}`))
|
|
424
|
+
}
|
|
236
425
|
}
|
|
237
426
|
|
|
238
427
|
if (agentNames.includes('starter')) {
|
|
239
428
|
lines.push('')
|
|
240
|
-
lines.push('
|
|
241
|
-
lines.push('
|
|
242
|
-
lines.push(' > "Use @starter to create my project"')
|
|
429
|
+
lines.push('Scaffold a new project from scratch:')
|
|
430
|
+
lines.push(' > "Use @starter to create an e-commerce app with Next.js"')
|
|
243
431
|
}
|
|
244
432
|
|
|
245
433
|
return lines.join('\n')
|
|
@@ -249,7 +437,7 @@ function buildGettingStarted(agentNames, installedSkills, archInstalled) {
|
|
|
249
437
|
|
|
250
438
|
const args = process.argv.slice(2)
|
|
251
439
|
|
|
252
|
-
const validCommands = ['init', 'create-agent', 'list', 'profiles', 'community']
|
|
440
|
+
const validCommands = ['init', 'create-agent', 'list', 'profiles', 'community', 'detect']
|
|
253
441
|
const command = args.find(a => !a.startsWith('-'))
|
|
254
442
|
if (command && !validCommands.includes(command)) {
|
|
255
443
|
console.error(` ${YELLOW}Unknown command: ${command}${NC}`)
|
|
@@ -265,11 +453,12 @@ if (args.includes('--help') || args.includes('-h')) {
|
|
|
265
453
|
console.log(' Usage: specialist-agent <command> [options]')
|
|
266
454
|
console.log()
|
|
267
455
|
console.log(' Commands:')
|
|
268
|
-
console.log(` init ${DIM}Install agents and skills
|
|
456
|
+
console.log(` init ${DIM}Install 35 agents and 24 skills (works on empty projects too)${NC}`)
|
|
457
|
+
console.log(` detect ${DIM}Detect architecture, monorepo, and suggest migrations${NC}`)
|
|
269
458
|
console.log(` create-agent <name> ${DIM}Create a custom agent from template${NC}`)
|
|
270
|
-
console.log(` list ${DIM}List installed agents and
|
|
459
|
+
console.log(` list ${DIM}List installed agents, skills, and memory${NC}`)
|
|
271
460
|
console.log(` profiles ${DIM}Manage AI team profiles${NC}`)
|
|
272
|
-
console.log(` community ${DIM}Manage community skills${NC}`)
|
|
461
|
+
console.log(` community ${DIM}Manage community skills (list/install/remove)${NC}`)
|
|
273
462
|
console.log()
|
|
274
463
|
console.log(' Options:')
|
|
275
464
|
console.log(` -h, --help ${DIM}Show this help message${NC}`)
|
|
@@ -277,8 +466,10 @@ if (args.includes('--help') || args.includes('-h')) {
|
|
|
277
466
|
console.log(` -f, --force ${DIM}Overwrite existing agents without asking${NC}`)
|
|
278
467
|
console.log()
|
|
279
468
|
console.log(' Examples:')
|
|
280
|
-
console.log(` ${DIM}$ specialist-agent init${NC}`)
|
|
281
|
-
console.log(` ${DIM}$ specialist-agent
|
|
469
|
+
console.log(` ${DIM}$ specialist-agent init # Install in existing project${NC}`)
|
|
470
|
+
console.log(` ${DIM}$ specialist-agent init # Start from empty dir (no framework yet)${NC}`)
|
|
471
|
+
console.log(` ${DIM}$ specialist-agent detect # Analyze architecture & get recommendations${NC}`)
|
|
472
|
+
console.log(` ${DIM}$ specialist-agent create-agent @qa # Create a custom agent${NC}`)
|
|
282
473
|
console.log(` ${DIM}$ specialist-agent profiles set startup-fast${NC}`)
|
|
283
474
|
console.log()
|
|
284
475
|
process.exit(0)
|
|
@@ -753,9 +944,175 @@ async function manageCommunity() {
|
|
|
753
944
|
}
|
|
754
945
|
}
|
|
755
946
|
|
|
947
|
+
// ── Detect Command ──────────────────────────────────
|
|
948
|
+
|
|
949
|
+
async function detectArchitecture() {
|
|
950
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
|
|
951
|
+
clack.intro(`Architecture Detection ${DIM}v${pkg.version}${NC}`)
|
|
952
|
+
|
|
953
|
+
const cwd = process.cwd()
|
|
954
|
+
const isJson = args.includes('--json')
|
|
955
|
+
|
|
956
|
+
// Detect framework
|
|
957
|
+
const packs = readdirSync(join(ROOT, 'packs'), { withFileTypes: true })
|
|
958
|
+
.filter(d => d.isDirectory())
|
|
959
|
+
.map(d => d.name)
|
|
960
|
+
const framework = detectFramework(join(cwd, 'package.json'), packs)
|
|
961
|
+
|
|
962
|
+
// Run detection
|
|
963
|
+
const s = clack.spinner()
|
|
964
|
+
s.start('Scanning project structure...')
|
|
965
|
+
|
|
966
|
+
const result = detectProjectArchitecture(cwd, { framework })
|
|
967
|
+
|
|
968
|
+
s.stop('Detection complete')
|
|
969
|
+
|
|
970
|
+
if (isJson) {
|
|
971
|
+
console.log(JSON.stringify(result, null, 2))
|
|
972
|
+
return
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// Display report
|
|
976
|
+
const report = generateDetectionReport(result)
|
|
977
|
+
clack.note(report, 'Architecture Detection')
|
|
978
|
+
|
|
979
|
+
// Get recommendations
|
|
980
|
+
const teamSize = await clack.select({
|
|
981
|
+
message: 'Team size (for recommendations)?',
|
|
982
|
+
options: [
|
|
983
|
+
{ value: 'small', label: '1-3 developers', hint: 'Solo or small team' },
|
|
984
|
+
{ value: 'medium', label: '3-10 developers', hint: 'Medium team' },
|
|
985
|
+
{ value: 'large', label: '10-20 developers', hint: 'Large team' },
|
|
986
|
+
{ value: 'enterprise', label: '20+ developers', hint: 'Enterprise' },
|
|
987
|
+
],
|
|
988
|
+
})
|
|
989
|
+
|
|
990
|
+
if (clack.isCancel(teamSize)) handleCancel()
|
|
991
|
+
|
|
992
|
+
const recs = getRecommendations(result, { teamSize })
|
|
993
|
+
|
|
994
|
+
// Display recommendations
|
|
995
|
+
const recLines = []
|
|
996
|
+
recLines.push(recs.reason)
|
|
997
|
+
recLines.push('')
|
|
998
|
+
|
|
999
|
+
if (recs.monorepoNote) {
|
|
1000
|
+
recLines.push(recs.monorepoNote)
|
|
1001
|
+
recLines.push('')
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
for (const rec of recs.recommendations) {
|
|
1005
|
+
const tagLabel = rec.tag === 'recommended' ? `${GREEN}RECOMMENDED${NC}`
|
|
1006
|
+
: rec.tag === 'backend-recommended' ? `${YELLOW}BACKEND${NC}`
|
|
1007
|
+
: `${DIM}ALTERNATIVE${NC}`
|
|
1008
|
+
const sameNote = rec.isSameArch ? ` ${DIM}(current)${NC}` : ''
|
|
1009
|
+
|
|
1010
|
+
recLines.push(` ${tagLabel} ${BOLD}${rec.name}${NC}${sameNote}`)
|
|
1011
|
+
recLines.push(` ${DIM}${rec.description}${NC}`)
|
|
1012
|
+
|
|
1013
|
+
if (rec.migration) {
|
|
1014
|
+
const effortColor = rec.migration.effort === 'low' ? GREEN : rec.migration.effort === 'medium' ? YELLOW : RED
|
|
1015
|
+
recLines.push(` Migration: ${effortColor}${rec.migration.effort}${NC} - ${rec.migration.description}`)
|
|
1016
|
+
recLines.push(` Agents: ${rec.migration.agents.join(', ')}`)
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
recLines.push(` Variants:`)
|
|
1020
|
+
for (const v of rec.variants) {
|
|
1021
|
+
recLines.push(` ${BOLD}${v.name}${NC}: ${v.description.slice(0, 100)}${v.description.length > 100 ? '...' : ''}`)
|
|
1022
|
+
if (v.directoryStructure) {
|
|
1023
|
+
for (const line of v.directoryStructure.slice(0, 6)) {
|
|
1024
|
+
recLines.push(` ${DIM}${line}${NC}`)
|
|
1025
|
+
}
|
|
1026
|
+
if (v.directoryStructure.length > 6) {
|
|
1027
|
+
recLines.push(` ${DIM}... (${v.directoryStructure.length - 6} more)${NC}`)
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
recLines.push('')
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// Framework notes
|
|
1035
|
+
if (recs.frameworkNotes) {
|
|
1036
|
+
recLines.push(`${BOLD}Framework Notes:${NC}`)
|
|
1037
|
+
for (const note of recs.frameworkNotes.extraNotes) {
|
|
1038
|
+
recLines.push(` - ${note}`)
|
|
1039
|
+
}
|
|
1040
|
+
if (recs.frameworkNotes.preferredStateManagement) {
|
|
1041
|
+
recLines.push(` State management: ${recs.frameworkNotes.preferredStateManagement}`)
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
clack.note(recLines.join('\n'), 'Architecture Recommendations')
|
|
1046
|
+
|
|
1047
|
+
// Offer to generate ARCHITECTURE.md
|
|
1048
|
+
const generateArch = await clack.confirm({
|
|
1049
|
+
message: 'Generate docs/ARCHITECTURE.md for the recommended architecture?',
|
|
1050
|
+
initialValue: false,
|
|
1051
|
+
})
|
|
1052
|
+
|
|
1053
|
+
if (clack.isCancel(generateArch)) handleCancel()
|
|
1054
|
+
|
|
1055
|
+
if (generateArch && recs.recommendations.length > 0) {
|
|
1056
|
+
const archChoice = recs.recommendations.length > 1
|
|
1057
|
+
? await clack.select({
|
|
1058
|
+
message: 'Which architecture?',
|
|
1059
|
+
options: recs.recommendations.map(r => ({
|
|
1060
|
+
value: r.id,
|
|
1061
|
+
label: r.name,
|
|
1062
|
+
hint: r.tag === 'recommended' ? 'Recommended' : r.tag,
|
|
1063
|
+
})),
|
|
1064
|
+
})
|
|
1065
|
+
: recs.recommendations[0].id
|
|
1066
|
+
|
|
1067
|
+
if (clack.isCancel(archChoice)) handleCancel()
|
|
1068
|
+
|
|
1069
|
+
const variantChoice = await clack.select({
|
|
1070
|
+
message: 'Which variant?',
|
|
1071
|
+
options: [
|
|
1072
|
+
{ value: 'full', label: 'Full', hint: 'All layers and patterns' },
|
|
1073
|
+
{ value: 'lite', label: 'Simplified', hint: 'Fewer layers, same principles' },
|
|
1074
|
+
],
|
|
1075
|
+
})
|
|
1076
|
+
|
|
1077
|
+
if (clack.isCancel(variantChoice)) handleCancel()
|
|
1078
|
+
|
|
1079
|
+
const guide = generateArchitectureGuide({
|
|
1080
|
+
architecture: archChoice,
|
|
1081
|
+
framework: framework || 'react',
|
|
1082
|
+
variant: variantChoice,
|
|
1083
|
+
nextjsRouter: result.nextjsRouter,
|
|
1084
|
+
})
|
|
1085
|
+
|
|
1086
|
+
const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
|
|
1087
|
+
if (existsSync(archDest)) {
|
|
1088
|
+
const overwrite = await clack.confirm({
|
|
1089
|
+
message: 'docs/ARCHITECTURE.md already exists. Overwrite?',
|
|
1090
|
+
initialValue: false,
|
|
1091
|
+
})
|
|
1092
|
+
if (clack.isCancel(overwrite)) handleCancel()
|
|
1093
|
+
if (!overwrite) {
|
|
1094
|
+
clack.log.info('Skipped ARCHITECTURE.md generation.')
|
|
1095
|
+
clack.outro('Detection complete!')
|
|
1096
|
+
return
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
mkdirSync(dirname(archDest), { recursive: true })
|
|
1101
|
+
writeFileSync(archDest, guide)
|
|
1102
|
+
clack.log.success(`Generated docs/ARCHITECTURE.md (${ARCHITECTURE_PATTERNS[archChoice]?.name || archChoice} - ${variantChoice})`)
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
clack.outro('Detection complete! Use /migrate-architecture to apply changes.')
|
|
1106
|
+
}
|
|
1107
|
+
|
|
756
1108
|
// ── Command Router ───────────────────────────────────
|
|
757
1109
|
|
|
758
|
-
if (command === '
|
|
1110
|
+
if (command === 'detect') {
|
|
1111
|
+
detectArchitecture().catch(err => {
|
|
1112
|
+
clack.log.error(err.message)
|
|
1113
|
+
process.exit(1)
|
|
1114
|
+
})
|
|
1115
|
+
} else if (command === 'create-agent') {
|
|
759
1116
|
createAgent().catch(err => {
|
|
760
1117
|
clack.log.error(err.message)
|
|
761
1118
|
process.exit(1)
|
|
@@ -782,17 +1139,20 @@ async function main() {
|
|
|
782
1139
|
|
|
783
1140
|
clack.intro(`Specialist Agent ${DIM}v${pkg.version}${NC}`)
|
|
784
1141
|
|
|
785
|
-
// Check for updates
|
|
1142
|
+
// Check for updates (non-blocking)
|
|
786
1143
|
const latestVersion = await checkForUpdates(pkg.version)
|
|
787
1144
|
if (latestVersion) {
|
|
788
1145
|
clack.log.warn(`Update available: v${pkg.version} → v${latestVersion}`)
|
|
789
1146
|
clack.log.info(`${DIM}Run: npm i -g specialist-agent@latest${NC}`)
|
|
790
1147
|
}
|
|
791
1148
|
|
|
792
|
-
// Check we're in a project
|
|
793
1149
|
const cwd = process.cwd()
|
|
1150
|
+
|
|
1151
|
+
// ── Auto-detect everything ──────────────────────────
|
|
1152
|
+
|
|
1153
|
+
// Check/create package.json
|
|
794
1154
|
if (!existsSync(join(cwd, 'package.json'))) {
|
|
795
|
-
clack.log.warn('No package.json found
|
|
1155
|
+
clack.log.warn('No package.json found.')
|
|
796
1156
|
|
|
797
1157
|
const createPkg = await clack.confirm({
|
|
798
1158
|
message: 'Create a package.json to initialize this project?',
|
|
@@ -814,7 +1174,7 @@ async function main() {
|
|
|
814
1174
|
clack.log.success('package.json created')
|
|
815
1175
|
}
|
|
816
1176
|
|
|
817
|
-
//
|
|
1177
|
+
// Auto-detect framework
|
|
818
1178
|
const packs = readdirSync(join(ROOT, 'packs'), { withFileTypes: true })
|
|
819
1179
|
.filter(d => d.isDirectory())
|
|
820
1180
|
.map(d => d.name)
|
|
@@ -822,136 +1182,248 @@ async function main() {
|
|
|
822
1182
|
const packLabels = { vue: 'Vue 3', react: 'React', nextjs: 'Next.js', svelte: 'SvelteKit', angular: 'Angular', astro: 'Astro', nuxt: 'Nuxt' }
|
|
823
1183
|
|
|
824
1184
|
const detected = detectFramework(join(cwd, 'package.json'), packs)
|
|
825
|
-
let framework
|
|
826
1185
|
|
|
827
|
-
|
|
828
|
-
|
|
1186
|
+
// Auto-detect platforms
|
|
1187
|
+
const detectedPlatforms = detectPlatforms(cwd)
|
|
1188
|
+
const platformLabels = detectedPlatforms.map(p => p.label).join(', ')
|
|
829
1189
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1190
|
+
// Auto-detect architecture
|
|
1191
|
+
let framework = detected
|
|
1192
|
+
const isEmptyProject = !detected
|
|
1193
|
+
const archDetection = detectProjectArchitecture(cwd, { framework: isEmptyProject ? null : framework })
|
|
1194
|
+
const detectedArch = archDetection.architecture
|
|
1195
|
+
const detectedArchName = ARCHITECTURE_PATTERNS[detectedArch]?.name || detectedArch
|
|
834
1196
|
|
|
835
|
-
|
|
1197
|
+
// ── Show detection results ──────────────────────────
|
|
836
1198
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
framework = await clack.select({
|
|
841
|
-
message: 'Which framework?',
|
|
842
|
-
options: packs.map(p => ({
|
|
843
|
-
value: p,
|
|
844
|
-
label: packLabels[p] || p.charAt(0).toUpperCase() + p.slice(1),
|
|
845
|
-
})),
|
|
846
|
-
})
|
|
847
|
-
|
|
848
|
-
if (clack.isCancel(framework)) handleCancel()
|
|
849
|
-
}
|
|
1199
|
+
const detectionLines = []
|
|
1200
|
+
if (detected) {
|
|
1201
|
+
detectionLines.push(`${GREEN}✓${NC} Framework: ${BOLD}${packLabels[detected] || detected}${NC}`)
|
|
850
1202
|
} else {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1203
|
+
detectionLines.push(`${DIM}○ Framework: none detected (empty project)${NC}`)
|
|
1204
|
+
}
|
|
1205
|
+
detectionLines.push(`${GREEN}✓${NC} Platforms: ${BOLD}${platformLabels}${NC}`)
|
|
1206
|
+
if (detectedArch && detectedArch !== 'unstructured') {
|
|
1207
|
+
detectionLines.push(`${GREEN}✓${NC} Architecture: ${BOLD}${detectedArchName}${NC}`)
|
|
1208
|
+
}
|
|
1209
|
+
if (archDetection.monorepo) {
|
|
1210
|
+
detectionLines.push(`${GREEN}✓${NC} Monorepo: ${BOLD}${archDetection.monorepo.name}${NC} (${archDetection.monorepo.apps.length} apps/packages)`)
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
clack.note(detectionLines.join('\n'), 'Auto-detected')
|
|
858
1214
|
|
|
859
|
-
|
|
1215
|
+
// ── Step 1: Framework (only ask if not detected) ────
|
|
1216
|
+
|
|
1217
|
+
if (!detected) {
|
|
1218
|
+
framework = 'none'
|
|
1219
|
+
clack.log.info('No framework detected — installing universal agents.')
|
|
1220
|
+
clack.log.info(`${DIM}When you choose a framework, re-run: npx specialist-agent init${NC}`)
|
|
860
1221
|
}
|
|
861
1222
|
|
|
862
|
-
|
|
1223
|
+
const isNone = framework === 'none' || !framework
|
|
1224
|
+
|
|
1225
|
+
// ── Step 2: Mode ────────────────────────────────────
|
|
1226
|
+
|
|
863
1227
|
const mode = await clack.select({
|
|
864
1228
|
message: 'Agent mode?',
|
|
865
1229
|
options: [
|
|
866
|
-
{ value: 'full', label: 'Full', hint: 'Sonnet/Opus' },
|
|
867
|
-
{ value: 'lite', label: 'Lite', hint: 'Haiku
|
|
1230
|
+
{ value: 'full', label: 'Full', hint: 'Sonnet/Opus — best quality' },
|
|
1231
|
+
{ value: 'lite', label: 'Lite', hint: 'Haiku — lower cost, faster' },
|
|
868
1232
|
],
|
|
869
1233
|
})
|
|
870
1234
|
|
|
871
1235
|
if (clack.isCancel(mode)) handleCancel()
|
|
872
1236
|
|
|
873
|
-
// 3
|
|
874
|
-
const installStarter = await clack.confirm({
|
|
875
|
-
message: 'Install @starter agent?',
|
|
876
|
-
initialValue: true,
|
|
877
|
-
})
|
|
878
|
-
|
|
879
|
-
if (clack.isCancel(installStarter)) handleCancel()
|
|
880
|
-
|
|
881
|
-
// 4. Workflow agents
|
|
882
|
-
const installWorkflow = await clack.confirm({
|
|
883
|
-
message: `Install workflow agents? ${DIM}(@planner, @executor, @tdd, @debugger, @pair)${NC}`,
|
|
884
|
-
initialValue: true,
|
|
885
|
-
})
|
|
886
|
-
|
|
887
|
-
if (clack.isCancel(installWorkflow)) handleCancel()
|
|
888
|
-
|
|
889
|
-
// 5. Specialist agents
|
|
890
|
-
const installSpecialists = await clack.confirm({
|
|
891
|
-
message: `Install specialist agents? ${DIM}(@api, @perf, @security, @finance, @data, @i18n, @docs, @deps, @legal, ...)${NC}`,
|
|
892
|
-
initialValue: true,
|
|
893
|
-
})
|
|
1237
|
+
// ── Step 3: Install scope ──────────────────────────
|
|
894
1238
|
|
|
895
|
-
if (clack.isCancel(installSpecialists)) handleCancel()
|
|
896
|
-
|
|
897
|
-
// 6. Install scope
|
|
898
1239
|
const installScope = await clack.select({
|
|
899
|
-
message: '
|
|
1240
|
+
message: 'Install scope?',
|
|
900
1241
|
options: [
|
|
901
|
-
{ value: 'project', label: 'This project
|
|
902
|
-
{ value: 'global', label: '
|
|
1242
|
+
{ value: 'project', label: 'This project', hint: '.claude/agents/' },
|
|
1243
|
+
{ value: 'global', label: 'Global', hint: '~/.claude/agents/ — all projects' },
|
|
903
1244
|
],
|
|
904
1245
|
})
|
|
905
1246
|
|
|
906
1247
|
if (clack.isCancel(installScope)) handleCancel()
|
|
907
1248
|
|
|
908
|
-
// ──
|
|
1249
|
+
// ── Step 4: Customize (optional) ───────────────────
|
|
909
1250
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
message: `Install native Claude Code hooks? ${DIM}(security guard, auto-dispatch, session context, auto-format)${NC}`,
|
|
914
|
-
initialValue: true,
|
|
1251
|
+
const customize = await clack.confirm({
|
|
1252
|
+
message: `Customize installation? ${DIM}(hooks, architecture, agent selection)${NC}`,
|
|
1253
|
+
initialValue: false,
|
|
915
1254
|
})
|
|
916
1255
|
|
|
917
|
-
if (clack.isCancel(
|
|
1256
|
+
if (clack.isCancel(customize)) handleCancel()
|
|
918
1257
|
|
|
919
|
-
|
|
1258
|
+
let selectedHooks = ['security-guard', 'auto-dispatch', 'session-context', 'mcp-discovery']
|
|
1259
|
+
let installArch = true
|
|
1260
|
+
let selectedArchitecture = 'modular'
|
|
1261
|
+
let selectedArchVariant = 'full'
|
|
1262
|
+
let generateCustomArch = false
|
|
1263
|
+
let installStarter = true
|
|
1264
|
+
let installWorkflow = true
|
|
1265
|
+
let installSpecialists = true
|
|
1266
|
+
let installBusiness = true
|
|
1267
|
+
|
|
1268
|
+
if (customize) {
|
|
1269
|
+
// Native hooks selection
|
|
920
1270
|
const hookChoices = await clack.multiselect({
|
|
921
|
-
message: '
|
|
1271
|
+
message: 'Native Claude Code hooks:',
|
|
922
1272
|
options: [
|
|
923
|
-
{ value: 'security-guard', label: 'Security Guard', hint: 'Block dangerous commands
|
|
924
|
-
{ value: 'auto-dispatch', label: 'Auto-Dispatch', hint: 'Suggest agents based on
|
|
925
|
-
{ value: 'session-context', label: 'Session Context', hint: 'Inject project state on
|
|
1273
|
+
{ value: 'security-guard', label: 'Security Guard', hint: 'Block dangerous commands', selected: true },
|
|
1274
|
+
{ value: 'auto-dispatch', label: 'Auto-Dispatch', hint: 'Suggest agents based on prompt', selected: true },
|
|
1275
|
+
{ value: 'session-context', label: 'Session Context', hint: 'Inject project state on start', selected: true },
|
|
1276
|
+
{ value: 'mcp-discovery', label: 'MCP Discovery', hint: 'Detect MCP servers and enhance agents', selected: true },
|
|
926
1277
|
{ value: 'auto-format', label: 'Auto-Format', hint: 'Format files after Write/Edit', selected: false },
|
|
927
1278
|
],
|
|
928
1279
|
required: false,
|
|
929
1280
|
})
|
|
930
1281
|
|
|
931
|
-
if (!clack.isCancel(hookChoices)
|
|
1282
|
+
if (!clack.isCancel(hookChoices)) {
|
|
932
1283
|
selectedHooks = hookChoices
|
|
933
1284
|
}
|
|
934
|
-
}
|
|
935
1285
|
|
|
936
|
-
|
|
1286
|
+
// Agent group selection
|
|
1287
|
+
const agentGroups = await clack.multiselect({
|
|
1288
|
+
message: 'Agent groups to install:',
|
|
1289
|
+
options: [
|
|
1290
|
+
{ value: 'core', label: 'Core', hint: '@builder, @reviewer, @doctor, @migrator, @starter', selected: true },
|
|
1291
|
+
{ value: 'workflow', label: 'Workflow', hint: '@planner, @executor, @tdd, @debugger, @pair, @analyst, @orchestrator', selected: true },
|
|
1292
|
+
{ value: 'specialist', label: 'Specialist', hint: '@api, @perf, @security, @finance, @data, @devops, @architect, ...', selected: true },
|
|
1293
|
+
{ value: 'business', label: 'Business', hint: '@marketing, @product, @support', selected: true },
|
|
1294
|
+
],
|
|
1295
|
+
required: true,
|
|
1296
|
+
})
|
|
937
1297
|
|
|
938
|
-
|
|
1298
|
+
if (!clack.isCancel(agentGroups)) {
|
|
1299
|
+
installStarter = agentGroups.includes('core')
|
|
1300
|
+
installWorkflow = agentGroups.includes('workflow')
|
|
1301
|
+
installSpecialists = agentGroups.includes('specialist')
|
|
1302
|
+
installBusiness = agentGroups.includes('business')
|
|
1303
|
+
}
|
|
939
1304
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1305
|
+
// Architecture selection
|
|
1306
|
+
const archAction = await clack.select({
|
|
1307
|
+
message: 'Architecture guide?',
|
|
1308
|
+
options: [
|
|
1309
|
+
{ value: 'default', label: 'Modular (default)', hint: 'Feature-based — recommended for most projects' },
|
|
1310
|
+
{ value: 'choose', label: 'Choose pattern', hint: 'Clean, Hexagonal, DDD, CQRS, ...' },
|
|
1311
|
+
{ value: 'detect', label: 'Detect & suggest', hint: 'Analyze your project and recommend' },
|
|
1312
|
+
{ value: 'skip', label: 'Skip', hint: 'No architecture guide' },
|
|
1313
|
+
],
|
|
1314
|
+
})
|
|
1315
|
+
|
|
1316
|
+
if (clack.isCancel(archAction)) handleCancel()
|
|
1317
|
+
|
|
1318
|
+
if (archAction === 'skip') {
|
|
1319
|
+
installArch = false
|
|
1320
|
+
} else if (archAction === 'detect') {
|
|
1321
|
+
const teamSize = await clack.select({
|
|
1322
|
+
message: 'Team size?',
|
|
1323
|
+
options: [
|
|
1324
|
+
{ value: 'small', label: '1-3 developers' },
|
|
1325
|
+
{ value: 'medium', label: '3-10 developers' },
|
|
1326
|
+
{ value: 'large', label: '10-20 developers' },
|
|
1327
|
+
{ value: 'enterprise', label: '20+ developers' },
|
|
1328
|
+
],
|
|
1329
|
+
})
|
|
944
1330
|
|
|
945
|
-
|
|
946
|
-
installArch = wantArch
|
|
1331
|
+
if (clack.isCancel(teamSize)) handleCancel()
|
|
947
1332
|
|
|
948
|
-
|
|
1333
|
+
const recs = getRecommendations(archDetection, { teamSize })
|
|
1334
|
+
|
|
1335
|
+
const recOptions = []
|
|
1336
|
+
for (const rec of recs.recommendations) {
|
|
1337
|
+
const tagPrefix = rec.tag === 'recommended' ? '[RECOMMENDED] '
|
|
1338
|
+
: rec.tag === 'backend-recommended' ? '[BACKEND] '
|
|
1339
|
+
: ''
|
|
1340
|
+
const effortNote = rec.migration ? ` (effort: ${rec.migration.effort})` : ''
|
|
1341
|
+
const sameNote = rec.isSameArch ? ' (current)' : ''
|
|
1342
|
+
|
|
1343
|
+
recOptions.push({
|
|
1344
|
+
value: rec.id,
|
|
1345
|
+
label: `${tagPrefix}${rec.name}${sameNote}`,
|
|
1346
|
+
hint: `${rec.description.slice(0, 60)}${effortNote}`,
|
|
1347
|
+
})
|
|
1348
|
+
}
|
|
949
1349
|
|
|
950
|
-
|
|
1350
|
+
recOptions.push({ value: 'skip', label: 'Skip', hint: 'No architecture guide' })
|
|
1351
|
+
|
|
1352
|
+
if (recs.reason) clack.log.info(recs.reason)
|
|
1353
|
+
|
|
1354
|
+
const archChoice = await clack.select({
|
|
1355
|
+
message: 'Which architecture?',
|
|
1356
|
+
options: recOptions,
|
|
1357
|
+
})
|
|
1358
|
+
|
|
1359
|
+
if (clack.isCancel(archChoice)) handleCancel()
|
|
1360
|
+
|
|
1361
|
+
if (archChoice !== 'skip') {
|
|
1362
|
+
selectedArchitecture = archChoice
|
|
1363
|
+
generateCustomArch = true
|
|
1364
|
+
|
|
1365
|
+
const chosenRec = recs.recommendations.find(r => r.id === archChoice)
|
|
1366
|
+
if (chosenRec?.variants.length > 0) {
|
|
1367
|
+
const variantChoice = await clack.select({
|
|
1368
|
+
message: 'Variant?',
|
|
1369
|
+
options: chosenRec.variants.map(v => ({
|
|
1370
|
+
value: v.id,
|
|
1371
|
+
label: v.name,
|
|
1372
|
+
hint: v.description.slice(0, 70),
|
|
1373
|
+
})),
|
|
1374
|
+
})
|
|
1375
|
+
|
|
1376
|
+
if (clack.isCancel(variantChoice)) handleCancel()
|
|
1377
|
+
selectedArchVariant = variantChoice
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if (chosenRec?.migration && !chosenRec.isSameArch) {
|
|
1381
|
+
clack.log.info(`${DIM}After install, use /migrate-architecture to apply.${NC}`)
|
|
1382
|
+
}
|
|
1383
|
+
} else {
|
|
1384
|
+
installArch = false
|
|
1385
|
+
}
|
|
1386
|
+
} else if (archAction === 'choose') {
|
|
1387
|
+
const archChoice = await clack.select({
|
|
1388
|
+
message: 'Architecture pattern?',
|
|
1389
|
+
options: [
|
|
1390
|
+
{ value: 'modular', label: 'Modular (Feature-Based)', hint: 'Recommended for most projects' },
|
|
1391
|
+
{ value: 'clean', label: 'Clean Architecture', hint: 'Domain > Use Cases > Adapters' },
|
|
1392
|
+
{ value: 'hexagonal', label: 'Hexagonal (Ports & Adapters)', hint: 'Core isolated' },
|
|
1393
|
+
{ value: 'fsd', label: 'Feature-Sliced Design', hint: 'Strict layered' },
|
|
1394
|
+
{ value: 'ddd', label: 'Domain-Driven Design', hint: 'Bounded contexts' },
|
|
1395
|
+
{ value: 'modular-monolith', label: 'Modular Monolith', hint: 'Backend/fullstack' },
|
|
1396
|
+
{ value: 'atomic', label: 'Atomic Design', hint: 'Component granularity' },
|
|
1397
|
+
{ value: 'cqrs', label: 'CQRS', hint: 'Command/query separation' },
|
|
1398
|
+
{ value: 'mvc', label: 'MVC / Layered', hint: 'Classic layers' },
|
|
1399
|
+
],
|
|
1400
|
+
})
|
|
1401
|
+
|
|
1402
|
+
if (clack.isCancel(archChoice)) handleCancel()
|
|
1403
|
+
selectedArchitecture = archChoice
|
|
1404
|
+
generateCustomArch = true
|
|
1405
|
+
|
|
1406
|
+
const variantChoice = await clack.select({
|
|
1407
|
+
message: 'Variant?',
|
|
1408
|
+
options: [
|
|
1409
|
+
{ value: 'full', label: 'Full', hint: 'All layers — established teams' },
|
|
1410
|
+
{ value: 'lite', label: 'Simplified', hint: 'Fewer layers — smaller teams' },
|
|
1411
|
+
],
|
|
1412
|
+
})
|
|
1413
|
+
|
|
1414
|
+
if (clack.isCancel(variantChoice)) handleCancel()
|
|
1415
|
+
selectedArchVariant = variantChoice
|
|
1416
|
+
}
|
|
1417
|
+
// archAction === 'default': keep defaults
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// ── Install ─────────────────────────────────────────
|
|
1421
|
+
|
|
1422
|
+
const defaultPack = isNone ? 'react' : framework
|
|
1423
|
+
const packDir = join(ROOT, 'packs', defaultPack)
|
|
951
1424
|
const agentsSource = mode === 'lite' ? join(packDir, 'agents-lite') : join(packDir, 'agents')
|
|
952
1425
|
const skillsSource = join(packDir, 'skills')
|
|
953
|
-
const
|
|
954
|
-
const claudeSource = join(packDir, 'CLAUDE.md')
|
|
1426
|
+
const claudeSource = isNone ? join(ROOT, 'CLAUDE.md') : join(packDir, 'CLAUDE.md')
|
|
955
1427
|
|
|
956
1428
|
const installGlobal = installScope === 'global'
|
|
957
1429
|
const agentsDest = installGlobal
|
|
@@ -959,15 +1431,13 @@ async function main() {
|
|
|
959
1431
|
: join(cwd, '.claude', 'agents')
|
|
960
1432
|
mkdirSync(agentsDest, { recursive: true })
|
|
961
1433
|
|
|
962
|
-
//
|
|
963
|
-
const agentsLabel = installGlobal ? '~/.claude/agents/' : '.claude/agents/'
|
|
1434
|
+
// Handle existing agents
|
|
964
1435
|
const existingAgents = detectExistingAgents(agentsDest)
|
|
965
1436
|
let shouldOverwrite = forceMode
|
|
966
1437
|
|
|
967
1438
|
if (existingAgents.length > 0 && !forceMode) {
|
|
968
|
-
clack.log.warn(`Existing agents detected in ${agentsLabel} (${existingAgents.length} files)`)
|
|
969
1439
|
const overwriteChoice = await clack.confirm({
|
|
970
|
-
message:
|
|
1440
|
+
message: `${existingAgents.length} existing agents found. Overwrite?`,
|
|
971
1441
|
initialValue: false,
|
|
972
1442
|
})
|
|
973
1443
|
if (clack.isCancel(overwriteChoice)) handleCancel()
|
|
@@ -975,129 +1445,161 @@ async function main() {
|
|
|
975
1445
|
}
|
|
976
1446
|
|
|
977
1447
|
const s = clack.spinner()
|
|
978
|
-
|
|
979
|
-
s.start('Installing new agents and skills (preserving existing)...')
|
|
980
|
-
} else {
|
|
981
|
-
s.start('Installing agents and skills...')
|
|
982
|
-
}
|
|
1448
|
+
s.start('Installing agents, skills, and platform configs...')
|
|
983
1449
|
|
|
984
1450
|
// Install pack agents
|
|
985
|
-
if (
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
// Install starter agent
|
|
992
|
-
if (installStarter) {
|
|
993
|
-
const starterFile = mode === 'lite' ? 'starter-lite.md' : 'starter.md'
|
|
994
|
-
const starterSource = join(ROOT, 'agents', starterFile)
|
|
995
|
-
const starterDest = join(agentsDest, 'starter.md')
|
|
996
|
-
if (existsSync(starterSource) && (shouldOverwrite || !existsSync(starterDest))) {
|
|
997
|
-
cpSync(starterSource, starterDest)
|
|
1451
|
+
if (existsSync(agentsSource)) {
|
|
1452
|
+
if (shouldOverwrite) {
|
|
1453
|
+
copyDir(agentsSource, agentsDest)
|
|
1454
|
+
} else {
|
|
1455
|
+
copyNewOnly(agentsSource, agentsDest)
|
|
998
1456
|
}
|
|
999
1457
|
}
|
|
1000
1458
|
|
|
1001
|
-
// Install
|
|
1459
|
+
// Install all agent groups
|
|
1460
|
+
const allAgentNames = []
|
|
1461
|
+
|
|
1462
|
+
if (installStarter) allAgentNames.push('starter')
|
|
1463
|
+
|
|
1002
1464
|
if (installWorkflow) {
|
|
1003
|
-
|
|
1004
|
-
for (const name of workflowNames) {
|
|
1005
|
-
const suffix = mode === 'lite' ? '-lite.md' : '.md'
|
|
1006
|
-
const source = join(ROOT, 'agents', `${name}${suffix}`)
|
|
1007
|
-
const dest = join(agentsDest, `${name}.md`)
|
|
1008
|
-
if (existsSync(source) && (shouldOverwrite || !existsSync(dest))) {
|
|
1009
|
-
cpSync(source, dest)
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1465
|
+
allAgentNames.push('planner', 'executor', 'tdd', 'debugger', 'pair', 'analyst', 'orchestrator', 'scout', 'memory')
|
|
1012
1466
|
}
|
|
1013
1467
|
|
|
1014
|
-
// Install specialist agents
|
|
1015
1468
|
if (installSpecialists) {
|
|
1016
|
-
|
|
1469
|
+
allAgentNames.push(
|
|
1017
1470
|
'api', 'perf', 'i18n', 'docs', 'refactor', 'deps',
|
|
1018
1471
|
'explorer', 'finance', 'cloud', 'security', 'designer', 'data',
|
|
1019
|
-
'devops', 'tester', 'legal', 'architect', 'ripple'
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1472
|
+
'devops', 'tester', 'legal', 'architect', 'ripple', 'sentry-triage'
|
|
1473
|
+
)
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
if (installBusiness) {
|
|
1477
|
+
allAgentNames.push('marketing', 'product', 'support')
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
for (const name of allAgentNames) {
|
|
1481
|
+
const suffix = mode === 'lite' ? '-lite.md' : '.md'
|
|
1482
|
+
const source = join(ROOT, 'agents', `${name}${suffix}`)
|
|
1483
|
+
const dest = join(agentsDest, `${name}.md`)
|
|
1484
|
+
if (existsSync(source) && (shouldOverwrite || !existsSync(dest))) {
|
|
1485
|
+
cpSync(source, dest)
|
|
1028
1486
|
}
|
|
1029
1487
|
}
|
|
1030
1488
|
|
|
1031
|
-
// Install skills
|
|
1489
|
+
// Install skills
|
|
1032
1490
|
const skillsDest = join(cwd, '.claude', 'skills')
|
|
1033
1491
|
mkdirSync(skillsDest, { recursive: true })
|
|
1034
|
-
let skillCount =
|
|
1035
|
-
|
|
1036
|
-
|
|
1492
|
+
let skillCount = 0
|
|
1493
|
+
if (existsSync(skillsSource)) {
|
|
1494
|
+
skillCount = shouldOverwrite
|
|
1495
|
+
? copyDir(skillsSource, skillsDest)
|
|
1496
|
+
: copyNewOnly(skillsSource, skillsDest)
|
|
1497
|
+
}
|
|
1037
1498
|
|
|
1038
|
-
// Install generic skills
|
|
1039
1499
|
const genericSkillsSource = join(ROOT, 'skills')
|
|
1040
1500
|
if (existsSync(genericSkillsSource)) {
|
|
1041
|
-
|
|
1501
|
+
skillCount += shouldOverwrite
|
|
1042
1502
|
? copyDir(genericSkillsSource, skillsDest)
|
|
1043
1503
|
: copyNewOnly(genericSkillsSource, skillsDest)
|
|
1044
|
-
skillCount += genericSkillCount
|
|
1045
1504
|
}
|
|
1046
1505
|
|
|
1047
|
-
// Install native hooks (
|
|
1506
|
+
// Install native hooks (defaults: security-guard, auto-dispatch, session-context)
|
|
1048
1507
|
let nativeHooksInstalled = 0
|
|
1049
1508
|
if (selectedHooks.length > 0) {
|
|
1050
1509
|
nativeHooksInstalled = setupNativeHooks(cwd, selectedHooks)
|
|
1051
1510
|
}
|
|
1052
1511
|
|
|
1053
|
-
// Install ARCHITECTURE.md
|
|
1512
|
+
// Install ARCHITECTURE.md
|
|
1054
1513
|
const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
|
|
1055
1514
|
let archInstalled = false
|
|
1056
|
-
if (installArch
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1515
|
+
if (installArch) {
|
|
1516
|
+
if (generateCustomArch) {
|
|
1517
|
+
const guide = generateArchitectureGuide({
|
|
1518
|
+
architecture: selectedArchitecture,
|
|
1519
|
+
framework: defaultPack,
|
|
1520
|
+
variant: selectedArchVariant,
|
|
1521
|
+
nextjsRouter: archDetection.nextjsRouter,
|
|
1522
|
+
})
|
|
1523
|
+
mkdirSync(dirname(archDest), { recursive: true })
|
|
1524
|
+
writeFileSync(archDest, guide)
|
|
1525
|
+
archInstalled = true
|
|
1526
|
+
} else if (!existsSync(archDest)) {
|
|
1527
|
+
// Default: generate Modular architecture
|
|
1528
|
+
const guide = generateArchitectureGuide({
|
|
1529
|
+
architecture: 'modular',
|
|
1530
|
+
framework: defaultPack,
|
|
1531
|
+
variant: 'full',
|
|
1532
|
+
nextjsRouter: archDetection.nextjsRouter,
|
|
1533
|
+
})
|
|
1534
|
+
mkdirSync(dirname(archDest), { recursive: true })
|
|
1535
|
+
writeFileSync(archDest, guide)
|
|
1536
|
+
archInstalled = true
|
|
1537
|
+
}
|
|
1060
1538
|
}
|
|
1061
1539
|
|
|
1062
1540
|
// Install CLAUDE.md
|
|
1063
1541
|
const claudeDest = join(cwd, 'CLAUDE.md')
|
|
1064
1542
|
let claudeInstalled = false
|
|
1065
|
-
if (!existsSync(claudeDest)
|
|
1066
|
-
|
|
1067
|
-
|
|
1543
|
+
if (!existsSync(claudeDest)) {
|
|
1544
|
+
if (claudeSource && existsSync(claudeSource)) {
|
|
1545
|
+
cpSync(claudeSource, claudeDest)
|
|
1546
|
+
claudeInstalled = true
|
|
1547
|
+
} else {
|
|
1548
|
+
const rootClaude = join(ROOT, 'CLAUDE.md')
|
|
1549
|
+
if (existsSync(rootClaude)) {
|
|
1550
|
+
cpSync(rootClaude, claudeDest)
|
|
1551
|
+
claudeInstalled = true
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1068
1554
|
}
|
|
1069
1555
|
|
|
1556
|
+
// ── Setup platform configs ─────────────────────────
|
|
1557
|
+
|
|
1558
|
+
const extraPlatforms = detectedPlatforms.filter(p => p.id !== 'claude-code')
|
|
1559
|
+
const platformResults = extraPlatforms.length > 0
|
|
1560
|
+
? setupPlatformConfigs(cwd, extraPlatforms, { framework: defaultPack, version: pkg.version })
|
|
1561
|
+
: []
|
|
1562
|
+
|
|
1070
1563
|
s.stop('Installation complete')
|
|
1071
1564
|
|
|
1072
1565
|
// ── Summary ────────────────────────────────────────
|
|
1073
1566
|
|
|
1074
|
-
const
|
|
1075
|
-
const packLabel = packLabels[framework] || framework
|
|
1567
|
+
const installedAgentNames = getAgentNames(agentsDest)
|
|
1568
|
+
const packLabel = isNone ? 'Universal' : (packLabels[framework] || framework)
|
|
1076
1569
|
|
|
1077
1570
|
const summaryLines = []
|
|
1078
|
-
|
|
1079
|
-
if (skillCount > 0) summaryLines.push(
|
|
1080
|
-
if (nativeHooksInstalled > 0) summaryLines.push(
|
|
1081
|
-
if (archInstalled)
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1571
|
+
summaryLines.push(`${BOLD}${installedAgentNames.length} agents${NC} installed`)
|
|
1572
|
+
if (skillCount > 0) summaryLines.push(`${BOLD}${skillCount} skills${NC} installed`)
|
|
1573
|
+
if (nativeHooksInstalled > 0) summaryLines.push(`${BOLD}${nativeHooksInstalled} native hooks${NC} configured`)
|
|
1574
|
+
if (archInstalled) {
|
|
1575
|
+
const archLabel = ARCHITECTURE_PATTERNS[selectedArchitecture]?.name || selectedArchitecture
|
|
1576
|
+
const varLabel = selectedArchVariant === 'lite' ? ' (Simplified)' : ''
|
|
1577
|
+
summaryLines.push(`${GREEN}✓${NC} docs/ARCHITECTURE.md (${archLabel}${varLabel})`)
|
|
1578
|
+
}
|
|
1579
|
+
if (claudeInstalled) summaryLines.push(`${GREEN}✓${NC} CLAUDE.md`)
|
|
1580
|
+
|
|
1581
|
+
// Platform results
|
|
1582
|
+
summaryLines.push('')
|
|
1583
|
+
summaryLines.push(`${BOLD}Platforms:${NC}`)
|
|
1584
|
+
summaryLines.push(` ${GREEN}✓${NC} Claude Code → .claude/agents/`)
|
|
1585
|
+
for (const result of platformResults) {
|
|
1586
|
+
summaryLines.push(` ${GREEN}✓${NC} ${result.platform} → ${result.path}`)
|
|
1089
1587
|
}
|
|
1090
1588
|
|
|
1091
1589
|
if (existingAgents.length > 0 && !shouldOverwrite) {
|
|
1092
|
-
|
|
1590
|
+
summaryLines.push('')
|
|
1591
|
+
summaryLines.push(`${DIM}${existingAgents.length} existing agent(s) preserved. Use --force to overwrite.${NC}`)
|
|
1093
1592
|
}
|
|
1094
1593
|
|
|
1594
|
+
const scopeLabel = installGlobal ? 'Global' : 'Project'
|
|
1595
|
+
clack.note(summaryLines.join('\n'), `${packLabel} · ${mode === 'full' ? 'Full' : 'Lite'} · ${scopeLabel}`)
|
|
1596
|
+
|
|
1095
1597
|
// Getting started
|
|
1096
1598
|
const installedSkills = existsSync(skillsDest)
|
|
1097
1599
|
? readdirSync(skillsDest, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => '/' + d.name)
|
|
1098
1600
|
: []
|
|
1099
1601
|
|
|
1100
|
-
clack.note(buildGettingStarted(
|
|
1602
|
+
clack.note(buildGettingStarted(installedAgentNames, installedSkills, archInstalled, isNone), 'Getting started')
|
|
1101
1603
|
|
|
1102
1604
|
if (mode === 'lite') {
|
|
1103
1605
|
clack.log.info(`${DIM}Lite mode: agents run on Haiku (lower cost, faster).${NC}`)
|