specialist-agent 2.11.1 → 2.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.mjs +72 -449
- package/hooks/native/security-guard.mjs +1 -1
- package/package.json +1 -1
- package/hooks/native/settings-template.json +0 -59
package/cli/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ 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
|
|
9
|
+
import { ARCHITECTURE_PATTERNS } from './architectures.mjs'
|
|
10
10
|
import { detectProjectArchitecture, generateDetectionReport } from './detect-architecture.mjs'
|
|
11
11
|
import { getRecommendations } from './recommend-architecture.mjs'
|
|
12
12
|
import { generateArchitectureGuide } from './generate-architecture.mjs'
|
|
@@ -18,20 +18,14 @@ const ROOT = resolve(__dirname, '..')
|
|
|
18
18
|
const YELLOW = '\x1b[33m'
|
|
19
19
|
const RED = '\x1b[31m'
|
|
20
20
|
const GREEN = '\x1b[32m'
|
|
21
|
-
const CYAN = '\x1b[36m'
|
|
22
21
|
const BOLD = '\x1b[1m'
|
|
23
22
|
const DIM = '\x1b[2m'
|
|
24
23
|
const NC = '\x1b[0m'
|
|
25
24
|
|
|
26
25
|
// ── Helpers ──────────────────────────────────────────
|
|
27
26
|
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
cpSync(src, dest, { recursive: true })
|
|
31
|
-
return countFiles(dest)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function copyNewOnly(src, dest) {
|
|
27
|
+
function copyManagedFiles(src, dest) {
|
|
28
|
+
// Additive merge: update our files, preserve user files
|
|
35
29
|
if (!existsSync(src)) return 0
|
|
36
30
|
let count = 0
|
|
37
31
|
for (const entry of readdirSync(src, { withFileTypes: true })) {
|
|
@@ -39,8 +33,8 @@ function copyNewOnly(src, dest) {
|
|
|
39
33
|
const destPath = join(dest, entry.name)
|
|
40
34
|
if (entry.isDirectory()) {
|
|
41
35
|
mkdirSync(destPath, { recursive: true })
|
|
42
|
-
count +=
|
|
43
|
-
} else
|
|
36
|
+
count += copyManagedFiles(srcPath, destPath)
|
|
37
|
+
} else {
|
|
44
38
|
cpSync(srcPath, destPath)
|
|
45
39
|
count++
|
|
46
40
|
}
|
|
@@ -48,20 +42,6 @@ function copyNewOnly(src, dest) {
|
|
|
48
42
|
return count
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
function detectExistingAgents(agentsDir) {
|
|
52
|
-
if (!existsSync(agentsDir)) return []
|
|
53
|
-
return readdirSync(agentsDir).filter(f => f.endsWith('.md'))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function countFiles(dir) {
|
|
57
|
-
if (!existsSync(dir)) return 0
|
|
58
|
-
let count = 0
|
|
59
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
60
|
-
if (entry.isDirectory()) count += countFiles(join(dir, entry.name))
|
|
61
|
-
else if (entry.name.endsWith('.md')) count++
|
|
62
|
-
}
|
|
63
|
-
return count
|
|
64
|
-
}
|
|
65
45
|
|
|
66
46
|
function getAgentNames(dir) {
|
|
67
47
|
if (!existsSync(dir)) return []
|
|
@@ -81,94 +61,94 @@ function handleCancel() {
|
|
|
81
61
|
|
|
82
62
|
// ── Native Hooks Setup ──────────────────────────────────
|
|
83
63
|
|
|
84
|
-
const HOOK_EVENT_MAP = {
|
|
85
|
-
'security-guard': 'PreToolUse',
|
|
86
|
-
'auto-dispatch': 'UserPromptSubmit',
|
|
87
|
-
'session-context': 'SessionStart',
|
|
88
|
-
'mcp-discovery': 'SessionStart',
|
|
89
|
-
'auto-format': 'PostToolUse',
|
|
90
|
-
}
|
|
91
|
-
|
|
92
64
|
function setupNativeHooks(cwd, selectedHooks) {
|
|
93
|
-
// 1. Copy hook scripts to
|
|
65
|
+
// 1. Copy hook scripts to .claude/hooks/ (inside Claude ecosystem)
|
|
94
66
|
const nativeSource = join(ROOT, 'hooks', 'native')
|
|
95
|
-
const
|
|
96
|
-
mkdirSync(
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
'utils.mjs',
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'mcp-discovery.mjs',
|
|
105
|
-
'auto-format.mjs',
|
|
106
|
-
]
|
|
107
|
-
for (const file of filesToCopy) {
|
|
108
|
-
const src = join(nativeSource, file)
|
|
109
|
-
if (existsSync(src)) cpSync(src, join(nativeDest, file))
|
|
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'],
|
|
110
76
|
}
|
|
111
77
|
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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 },
|
|
120
98
|
}
|
|
121
99
|
|
|
122
|
-
// 3. Filter template to only selected hooks
|
|
123
100
|
const filteredHooks = {}
|
|
124
101
|
for (const hookName of selectedHooks) {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
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)
|
|
129
108
|
}
|
|
130
109
|
|
|
131
|
-
//
|
|
132
|
-
const
|
|
133
|
-
mkdirSync(settingsDir, { recursive: true })
|
|
134
|
-
const settingsPath = join(settingsDir, 'settings.json')
|
|
110
|
+
// 3. Read existing settings and merge additively
|
|
111
|
+
const settingsPath = join(cwd, '.claude', 'settings.json')
|
|
135
112
|
|
|
136
113
|
let existing = {}
|
|
137
114
|
if (existsSync(settingsPath)) {
|
|
138
115
|
try {
|
|
139
116
|
existing = JSON.parse(readFileSync(settingsPath, 'utf-8'))
|
|
140
|
-
// Create backup
|
|
141
|
-
writeFileSync(settingsPath + '.bak', JSON.stringify(existing, null, 2))
|
|
142
117
|
} catch {
|
|
143
118
|
existing = {}
|
|
144
119
|
}
|
|
145
120
|
}
|
|
146
121
|
|
|
147
|
-
// 5. Deep-merge hooks (idempotent - skip if command already exists)
|
|
148
122
|
if (!existing.hooks) existing.hooks = {}
|
|
149
123
|
|
|
150
|
-
// Reject prototype pollution keys
|
|
151
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/'
|
|
152
127
|
|
|
153
128
|
for (const [eventName, entries] of Object.entries(filteredHooks)) {
|
|
154
|
-
if (UNSAFE_KEYS.has(eventName)) continue
|
|
129
|
+
if (UNSAFE_KEYS.has(eventName)) continue
|
|
155
130
|
if (!existing.hooks[eventName]) {
|
|
156
131
|
existing.hooks[eventName] = entries
|
|
157
132
|
} else {
|
|
158
|
-
// Check for duplicates by command
|
|
159
133
|
for (const newEntry of entries) {
|
|
160
134
|
const newCommand = newEntry.hooks?.[0]?.command || ''
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
)
|
|
163
140
|
)
|
|
164
|
-
if (
|
|
141
|
+
if (existingIdx !== -1) {
|
|
142
|
+
// Update old path to new path
|
|
143
|
+
existing.hooks[eventName][existingIdx] = newEntry
|
|
144
|
+
} else {
|
|
165
145
|
existing.hooks[eventName].push(newEntry)
|
|
166
146
|
}
|
|
167
147
|
}
|
|
168
148
|
}
|
|
169
149
|
}
|
|
170
150
|
|
|
171
|
-
//
|
|
151
|
+
// 4. Write merged settings
|
|
172
152
|
writeFileSync(settingsPath, JSON.stringify(existing, null, 2))
|
|
173
153
|
|
|
174
154
|
return selectedHooks.length
|
|
@@ -206,160 +186,10 @@ function detectFramework(pkgPath, availablePacks) {
|
|
|
206
186
|
return null
|
|
207
187
|
}
|
|
208
188
|
|
|
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
189
|
|
|
360
190
|
// ── Guidance texts ───────────────────────────────────
|
|
361
191
|
|
|
362
|
-
function buildGettingStarted(agentNames, installedSkills,
|
|
192
|
+
function buildGettingStarted(agentNames, installedSkills, isEmptyProject) {
|
|
363
193
|
const lines = []
|
|
364
194
|
|
|
365
195
|
if (isEmptyProject) {
|
|
@@ -385,18 +215,8 @@ function buildGettingStarted(agentNames, installedSkills, archInstalled, isEmpty
|
|
|
385
215
|
return lines.join('\n')
|
|
386
216
|
}
|
|
387
217
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
lines.push('They ensure consistency across modules — the more you use them,')
|
|
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"')
|
|
396
|
-
} else {
|
|
397
|
-
lines.push('Agents use generic best practices for your framework.')
|
|
398
|
-
lines.push('To customize patterns, run: specialist-agent detect')
|
|
399
|
-
}
|
|
218
|
+
lines.push('Agents use best practices for your framework.')
|
|
219
|
+
lines.push('To detect and customize architecture: specialist-agent detect')
|
|
400
220
|
lines.push('')
|
|
401
221
|
lines.push('Examples:')
|
|
402
222
|
lines.push('')
|
|
@@ -1161,10 +981,6 @@ async function main() {
|
|
|
1161
981
|
|
|
1162
982
|
const detected = detectFramework(join(cwd, 'package.json'), packs)
|
|
1163
983
|
|
|
1164
|
-
// Auto-detect platforms
|
|
1165
|
-
const detectedPlatforms = detectPlatforms(cwd)
|
|
1166
|
-
const platformLabels = detectedPlatforms.map(p => p.label).join(', ')
|
|
1167
|
-
|
|
1168
984
|
// Auto-detect architecture
|
|
1169
985
|
let framework = detected
|
|
1170
986
|
const isEmptyProject = !detected
|
|
@@ -1178,9 +994,8 @@ async function main() {
|
|
|
1178
994
|
if (detected) {
|
|
1179
995
|
detectionLines.push(`${GREEN}✓${NC} Framework: ${BOLD}${packLabels[detected] || detected}${NC}`)
|
|
1180
996
|
} else {
|
|
1181
|
-
detectionLines.push(`${DIM}○ Framework: none detected
|
|
997
|
+
detectionLines.push(`${DIM}○ Framework: none detected${NC}`)
|
|
1182
998
|
}
|
|
1183
|
-
detectionLines.push(`${GREEN}✓${NC} Platforms: ${BOLD}${platformLabels}${NC}`)
|
|
1184
999
|
if (detectedArch && detectedArch !== 'unstructured') {
|
|
1185
1000
|
detectionLines.push(`${GREEN}✓${NC} Architecture: ${BOLD}${detectedArchName}${NC}`)
|
|
1186
1001
|
}
|
|
@@ -1227,17 +1042,13 @@ async function main() {
|
|
|
1227
1042
|
// ── Step 4: Customize (optional) ───────────────────
|
|
1228
1043
|
|
|
1229
1044
|
const customize = await clack.confirm({
|
|
1230
|
-
message: `Customize installation? ${DIM}(hooks,
|
|
1045
|
+
message: `Customize installation? ${DIM}(hooks, agent selection)${NC}`,
|
|
1231
1046
|
initialValue: false,
|
|
1232
1047
|
})
|
|
1233
1048
|
|
|
1234
1049
|
if (clack.isCancel(customize)) handleCancel()
|
|
1235
1050
|
|
|
1236
1051
|
let selectedHooks = ['security-guard', 'auto-dispatch', 'session-context', 'mcp-discovery']
|
|
1237
|
-
let installArch = true
|
|
1238
|
-
let selectedArchitecture = 'modular'
|
|
1239
|
-
let selectedArchVariant = 'full'
|
|
1240
|
-
let generateCustomArch = false
|
|
1241
1052
|
let installStarter = true
|
|
1242
1053
|
let installWorkflow = true
|
|
1243
1054
|
let installSpecialists = true
|
|
@@ -1279,120 +1090,6 @@ async function main() {
|
|
|
1279
1090
|
installSpecialists = agentGroups.includes('specialist')
|
|
1280
1091
|
installBusiness = agentGroups.includes('business')
|
|
1281
1092
|
}
|
|
1282
|
-
|
|
1283
|
-
// Architecture selection
|
|
1284
|
-
const archAction = await clack.select({
|
|
1285
|
-
message: 'Architecture guide?',
|
|
1286
|
-
options: [
|
|
1287
|
-
{ value: 'default', label: 'Modular (default)', hint: 'Feature-based — recommended for most projects' },
|
|
1288
|
-
{ value: 'choose', label: 'Choose pattern', hint: 'Clean, Hexagonal, DDD, CQRS, ...' },
|
|
1289
|
-
{ value: 'detect', label: 'Detect & suggest', hint: 'Analyze your project and recommend' },
|
|
1290
|
-
{ value: 'skip', label: 'Skip', hint: 'No architecture guide' },
|
|
1291
|
-
],
|
|
1292
|
-
})
|
|
1293
|
-
|
|
1294
|
-
if (clack.isCancel(archAction)) handleCancel()
|
|
1295
|
-
|
|
1296
|
-
if (archAction === 'skip') {
|
|
1297
|
-
installArch = false
|
|
1298
|
-
} else if (archAction === 'detect') {
|
|
1299
|
-
const teamSize = await clack.select({
|
|
1300
|
-
message: 'Team size?',
|
|
1301
|
-
options: [
|
|
1302
|
-
{ value: 'small', label: '1-3 developers' },
|
|
1303
|
-
{ value: 'medium', label: '3-10 developers' },
|
|
1304
|
-
{ value: 'large', label: '10-20 developers' },
|
|
1305
|
-
{ value: 'enterprise', label: '20+ developers' },
|
|
1306
|
-
],
|
|
1307
|
-
})
|
|
1308
|
-
|
|
1309
|
-
if (clack.isCancel(teamSize)) handleCancel()
|
|
1310
|
-
|
|
1311
|
-
const recs = getRecommendations(archDetection, { teamSize })
|
|
1312
|
-
|
|
1313
|
-
const recOptions = []
|
|
1314
|
-
for (const rec of recs.recommendations) {
|
|
1315
|
-
const tagPrefix = rec.tag === 'recommended' ? '[RECOMMENDED] '
|
|
1316
|
-
: rec.tag === 'backend-recommended' ? '[BACKEND] '
|
|
1317
|
-
: ''
|
|
1318
|
-
const effortNote = rec.migration ? ` (effort: ${rec.migration.effort})` : ''
|
|
1319
|
-
const sameNote = rec.isSameArch ? ' (current)' : ''
|
|
1320
|
-
|
|
1321
|
-
recOptions.push({
|
|
1322
|
-
value: rec.id,
|
|
1323
|
-
label: `${tagPrefix}${rec.name}${sameNote}`,
|
|
1324
|
-
hint: `${rec.description.slice(0, 60)}${effortNote}`,
|
|
1325
|
-
})
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
recOptions.push({ value: 'skip', label: 'Skip', hint: 'No architecture guide' })
|
|
1329
|
-
|
|
1330
|
-
if (recs.reason) clack.log.info(recs.reason)
|
|
1331
|
-
|
|
1332
|
-
const archChoice = await clack.select({
|
|
1333
|
-
message: 'Which architecture?',
|
|
1334
|
-
options: recOptions,
|
|
1335
|
-
})
|
|
1336
|
-
|
|
1337
|
-
if (clack.isCancel(archChoice)) handleCancel()
|
|
1338
|
-
|
|
1339
|
-
if (archChoice !== 'skip') {
|
|
1340
|
-
selectedArchitecture = archChoice
|
|
1341
|
-
generateCustomArch = true
|
|
1342
|
-
|
|
1343
|
-
const chosenRec = recs.recommendations.find(r => r.id === archChoice)
|
|
1344
|
-
if (chosenRec?.variants.length > 0) {
|
|
1345
|
-
const variantChoice = await clack.select({
|
|
1346
|
-
message: 'Variant?',
|
|
1347
|
-
options: chosenRec.variants.map(v => ({
|
|
1348
|
-
value: v.id,
|
|
1349
|
-
label: v.name,
|
|
1350
|
-
hint: v.description.slice(0, 70),
|
|
1351
|
-
})),
|
|
1352
|
-
})
|
|
1353
|
-
|
|
1354
|
-
if (clack.isCancel(variantChoice)) handleCancel()
|
|
1355
|
-
selectedArchVariant = variantChoice
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
if (chosenRec?.migration && !chosenRec.isSameArch) {
|
|
1359
|
-
clack.log.info(`${DIM}After install, use /migrate-architecture to apply.${NC}`)
|
|
1360
|
-
}
|
|
1361
|
-
} else {
|
|
1362
|
-
installArch = false
|
|
1363
|
-
}
|
|
1364
|
-
} else if (archAction === 'choose') {
|
|
1365
|
-
const archChoice = await clack.select({
|
|
1366
|
-
message: 'Architecture pattern?',
|
|
1367
|
-
options: [
|
|
1368
|
-
{ value: 'modular', label: 'Modular (Feature-Based)', hint: 'Recommended for most projects' },
|
|
1369
|
-
{ value: 'clean', label: 'Clean Architecture', hint: 'Domain > Use Cases > Adapters' },
|
|
1370
|
-
{ value: 'hexagonal', label: 'Hexagonal (Ports & Adapters)', hint: 'Core isolated' },
|
|
1371
|
-
{ value: 'fsd', label: 'Feature-Sliced Design', hint: 'Strict layered' },
|
|
1372
|
-
{ value: 'ddd', label: 'Domain-Driven Design', hint: 'Bounded contexts' },
|
|
1373
|
-
{ value: 'modular-monolith', label: 'Modular Monolith', hint: 'Backend/fullstack' },
|
|
1374
|
-
{ value: 'atomic', label: 'Atomic Design', hint: 'Component granularity' },
|
|
1375
|
-
{ value: 'cqrs', label: 'CQRS', hint: 'Command/query separation' },
|
|
1376
|
-
{ value: 'mvc', label: 'MVC / Layered', hint: 'Classic layers' },
|
|
1377
|
-
],
|
|
1378
|
-
})
|
|
1379
|
-
|
|
1380
|
-
if (clack.isCancel(archChoice)) handleCancel()
|
|
1381
|
-
selectedArchitecture = archChoice
|
|
1382
|
-
generateCustomArch = true
|
|
1383
|
-
|
|
1384
|
-
const variantChoice = await clack.select({
|
|
1385
|
-
message: 'Variant?',
|
|
1386
|
-
options: [
|
|
1387
|
-
{ value: 'full', label: 'Full', hint: 'All layers — established teams' },
|
|
1388
|
-
{ value: 'lite', label: 'Simplified', hint: 'Fewer layers — smaller teams' },
|
|
1389
|
-
],
|
|
1390
|
-
})
|
|
1391
|
-
|
|
1392
|
-
if (clack.isCancel(variantChoice)) handleCancel()
|
|
1393
|
-
selectedArchVariant = variantChoice
|
|
1394
|
-
}
|
|
1395
|
-
// archAction === 'default': keep defaults
|
|
1396
1093
|
}
|
|
1397
1094
|
|
|
1398
1095
|
// ── Install ─────────────────────────────────────────
|
|
@@ -1409,29 +1106,12 @@ async function main() {
|
|
|
1409
1106
|
: join(cwd, '.claude', 'agents')
|
|
1410
1107
|
mkdirSync(agentsDest, { recursive: true })
|
|
1411
1108
|
|
|
1412
|
-
// Handle existing agents
|
|
1413
|
-
const existingAgents = detectExistingAgents(agentsDest)
|
|
1414
|
-
let shouldOverwrite = forceMode
|
|
1415
|
-
|
|
1416
|
-
if (existingAgents.length > 0 && !forceMode) {
|
|
1417
|
-
const overwriteChoice = await clack.confirm({
|
|
1418
|
-
message: `${existingAgents.length} existing agents found. Overwrite?`,
|
|
1419
|
-
initialValue: false,
|
|
1420
|
-
})
|
|
1421
|
-
if (clack.isCancel(overwriteChoice)) handleCancel()
|
|
1422
|
-
shouldOverwrite = overwriteChoice
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
1109
|
const s = clack.spinner()
|
|
1426
|
-
s.start('Installing agents, skills, and
|
|
1110
|
+
s.start('Installing agents, skills, and hooks...')
|
|
1427
1111
|
|
|
1428
|
-
// Install pack agents
|
|
1112
|
+
// Install pack agents (additive: updates ours, preserves user's)
|
|
1429
1113
|
if (existsSync(agentsSource)) {
|
|
1430
|
-
|
|
1431
|
-
copyDir(agentsSource, agentsDest)
|
|
1432
|
-
} else {
|
|
1433
|
-
copyNewOnly(agentsSource, agentsDest)
|
|
1434
|
-
}
|
|
1114
|
+
copyManagedFiles(agentsSource, agentsDest)
|
|
1435
1115
|
}
|
|
1436
1116
|
|
|
1437
1117
|
// Install all agent groups
|
|
@@ -1459,26 +1139,22 @@ async function main() {
|
|
|
1459
1139
|
const suffix = mode === 'lite' ? '-lite.md' : '.md'
|
|
1460
1140
|
const source = join(ROOT, 'agents', `${name}${suffix}`)
|
|
1461
1141
|
const dest = join(agentsDest, `${name}.md`)
|
|
1462
|
-
if (existsSync(source)
|
|
1142
|
+
if (existsSync(source)) {
|
|
1463
1143
|
cpSync(source, dest)
|
|
1464
1144
|
}
|
|
1465
1145
|
}
|
|
1466
1146
|
|
|
1467
|
-
// Install skills
|
|
1147
|
+
// Install skills (additive: updates ours, preserves user's)
|
|
1468
1148
|
const skillsDest = join(cwd, '.claude', 'skills')
|
|
1469
1149
|
mkdirSync(skillsDest, { recursive: true })
|
|
1470
1150
|
let skillCount = 0
|
|
1471
1151
|
if (existsSync(skillsSource)) {
|
|
1472
|
-
skillCount =
|
|
1473
|
-
? copyDir(skillsSource, skillsDest)
|
|
1474
|
-
: copyNewOnly(skillsSource, skillsDest)
|
|
1152
|
+
skillCount = copyManagedFiles(skillsSource, skillsDest)
|
|
1475
1153
|
}
|
|
1476
1154
|
|
|
1477
1155
|
const genericSkillsSource = join(ROOT, 'skills')
|
|
1478
1156
|
if (existsSync(genericSkillsSource)) {
|
|
1479
|
-
skillCount +=
|
|
1480
|
-
? copyDir(genericSkillsSource, skillsDest)
|
|
1481
|
-
: copyNewOnly(genericSkillsSource, skillsDest)
|
|
1157
|
+
skillCount += copyManagedFiles(genericSkillsSource, skillsDest)
|
|
1482
1158
|
}
|
|
1483
1159
|
|
|
1484
1160
|
// Install native hooks (defaults: security-guard, auto-dispatch, session-context)
|
|
@@ -1487,34 +1163,6 @@ async function main() {
|
|
|
1487
1163
|
nativeHooksInstalled = setupNativeHooks(cwd, selectedHooks)
|
|
1488
1164
|
}
|
|
1489
1165
|
|
|
1490
|
-
// Install ARCHITECTURE.md
|
|
1491
|
-
const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
|
|
1492
|
-
let archInstalled = false
|
|
1493
|
-
if (installArch) {
|
|
1494
|
-
if (generateCustomArch) {
|
|
1495
|
-
const guide = generateArchitectureGuide({
|
|
1496
|
-
architecture: selectedArchitecture,
|
|
1497
|
-
framework: defaultPack,
|
|
1498
|
-
variant: selectedArchVariant,
|
|
1499
|
-
nextjsRouter: archDetection.nextjsRouter,
|
|
1500
|
-
})
|
|
1501
|
-
mkdirSync(dirname(archDest), { recursive: true })
|
|
1502
|
-
writeFileSync(archDest, guide)
|
|
1503
|
-
archInstalled = true
|
|
1504
|
-
} else if (!existsSync(archDest)) {
|
|
1505
|
-
// Default: generate Modular architecture
|
|
1506
|
-
const guide = generateArchitectureGuide({
|
|
1507
|
-
architecture: 'modular',
|
|
1508
|
-
framework: defaultPack,
|
|
1509
|
-
variant: 'full',
|
|
1510
|
-
nextjsRouter: archDetection.nextjsRouter,
|
|
1511
|
-
})
|
|
1512
|
-
mkdirSync(dirname(archDest), { recursive: true })
|
|
1513
|
-
writeFileSync(archDest, guide)
|
|
1514
|
-
archInstalled = true
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
1166
|
// Install CLAUDE.md
|
|
1519
1167
|
const claudeDest = join(cwd, 'CLAUDE.md')
|
|
1520
1168
|
let claudeInstalled = false
|
|
@@ -1531,13 +1179,6 @@ async function main() {
|
|
|
1531
1179
|
}
|
|
1532
1180
|
}
|
|
1533
1181
|
|
|
1534
|
-
// ── Setup platform configs ─────────────────────────
|
|
1535
|
-
|
|
1536
|
-
const extraPlatforms = detectedPlatforms.filter(p => p.id !== 'claude-code')
|
|
1537
|
-
const platformResults = extraPlatforms.length > 0
|
|
1538
|
-
? setupPlatformConfigs(cwd, extraPlatforms, { framework: defaultPack, version: pkg.version })
|
|
1539
|
-
: []
|
|
1540
|
-
|
|
1541
1182
|
s.stop('Installation complete')
|
|
1542
1183
|
|
|
1543
1184
|
// ── Summary ────────────────────────────────────────
|
|
@@ -1546,29 +1187,11 @@ async function main() {
|
|
|
1546
1187
|
const packLabel = isNone ? 'Universal' : (packLabels[framework] || framework)
|
|
1547
1188
|
|
|
1548
1189
|
const summaryLines = []
|
|
1549
|
-
summaryLines.push(`${BOLD}${installedAgentNames.length} agents${NC}
|
|
1550
|
-
if (skillCount > 0) summaryLines.push(`${BOLD}${skillCount} skills${NC}
|
|
1551
|
-
if (nativeHooksInstalled > 0) summaryLines.push(`${BOLD}${nativeHooksInstalled}
|
|
1552
|
-
if (archInstalled) {
|
|
1553
|
-
const archLabel = ARCHITECTURE_PATTERNS[selectedArchitecture]?.name || selectedArchitecture
|
|
1554
|
-
const varLabel = selectedArchVariant === 'lite' ? ' (Simplified)' : ''
|
|
1555
|
-
summaryLines.push(`${GREEN}✓${NC} docs/ARCHITECTURE.md (${archLabel}${varLabel})`)
|
|
1556
|
-
}
|
|
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/`)
|
|
1557
1193
|
if (claudeInstalled) summaryLines.push(`${GREEN}✓${NC} CLAUDE.md`)
|
|
1558
1194
|
|
|
1559
|
-
// Platform results
|
|
1560
|
-
summaryLines.push('')
|
|
1561
|
-
summaryLines.push(`${BOLD}Platforms:${NC}`)
|
|
1562
|
-
summaryLines.push(` ${GREEN}✓${NC} Claude Code → .claude/agents/`)
|
|
1563
|
-
for (const result of platformResults) {
|
|
1564
|
-
summaryLines.push(` ${GREEN}✓${NC} ${result.platform} → ${result.path}`)
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
if (existingAgents.length > 0 && !shouldOverwrite) {
|
|
1568
|
-
summaryLines.push('')
|
|
1569
|
-
summaryLines.push(`${DIM}${existingAgents.length} existing agent(s) preserved. Use --force to overwrite.${NC}`)
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
1195
|
const scopeLabel = installGlobal ? 'Global' : 'Project'
|
|
1573
1196
|
clack.note(summaryLines.join('\n'), `${packLabel} · ${mode === 'full' ? 'Full' : 'Lite'} · ${scopeLabel}`)
|
|
1574
1197
|
|
|
@@ -1577,7 +1200,7 @@ async function main() {
|
|
|
1577
1200
|
? readdirSync(skillsDest, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => '/' + d.name)
|
|
1578
1201
|
: []
|
|
1579
1202
|
|
|
1580
|
-
clack.note(buildGettingStarted(installedAgentNames, installedSkills,
|
|
1203
|
+
clack.note(buildGettingStarted(installedAgentNames, installedSkills, isNone), 'Getting started')
|
|
1581
1204
|
|
|
1582
1205
|
if (mode === 'lite') {
|
|
1583
1206
|
clack.log.info(`${DIM}Lite mode: agents run on Haiku (lower cost, faster).${NC}`)
|
|
@@ -305,7 +305,7 @@ async function main() {
|
|
|
305
305
|
const result = evaluateCommand(command, config);
|
|
306
306
|
|
|
307
307
|
if (result.blocked) {
|
|
308
|
-
process.stderr.write(`\n🛡️ Security Guard\n${result.message}\n\nRule: ${result.rule} (${result.severity})\nTo customize: edit hooks/
|
|
308
|
+
process.stderr.write(`\n🛡️ Security Guard\n${result.message}\n\nRule: ${result.rule} (${result.severity})\nTo customize: edit .claude/hooks/security-config.json\n`);
|
|
309
309
|
process.exit(2);
|
|
310
310
|
}
|
|
311
311
|
|
package/package.json
CHANGED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"hooks": {
|
|
3
|
-
"PreToolUse": [
|
|
4
|
-
{
|
|
5
|
-
"matcher": "Bash",
|
|
6
|
-
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
"type": "command",
|
|
9
|
-
"command": "node .specialist-agent/hooks/native/security-guard.mjs",
|
|
10
|
-
"timeout": 5
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"UserPromptSubmit": [
|
|
16
|
-
{
|
|
17
|
-
"hooks": [
|
|
18
|
-
{
|
|
19
|
-
"type": "command",
|
|
20
|
-
"command": "node .specialist-agent/hooks/native/auto-dispatch.mjs",
|
|
21
|
-
"timeout": 5
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"SessionStart": [
|
|
27
|
-
{
|
|
28
|
-
"hooks": [
|
|
29
|
-
{
|
|
30
|
-
"type": "command",
|
|
31
|
-
"command": "node .specialist-agent/hooks/native/session-context.mjs",
|
|
32
|
-
"timeout": 10
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"hooks": [
|
|
38
|
-
{
|
|
39
|
-
"type": "command",
|
|
40
|
-
"command": "node .specialist-agent/hooks/native/mcp-discovery.mjs",
|
|
41
|
-
"timeout": 5
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"PostToolUse": [
|
|
47
|
-
{
|
|
48
|
-
"matcher": "Write|Edit",
|
|
49
|
-
"hooks": [
|
|
50
|
-
{
|
|
51
|
-
"type": "command",
|
|
52
|
-
"command": "node .specialist-agent/hooks/native/auto-format.mjs",
|
|
53
|
-
"timeout": 15
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
}
|