specialist-agent 2.11.0 → 2.11.2
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 +73 -472
- 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('')
|
|
@@ -1150,29 +970,7 @@ async function main() {
|
|
|
1150
970
|
|
|
1151
971
|
// ── Auto-detect everything ──────────────────────────
|
|
1152
972
|
|
|
1153
|
-
//
|
|
1154
|
-
if (!existsSync(join(cwd, 'package.json'))) {
|
|
1155
|
-
clack.log.warn('No package.json found.')
|
|
1156
|
-
|
|
1157
|
-
const createPkg = await clack.confirm({
|
|
1158
|
-
message: 'Create a package.json to initialize this project?',
|
|
1159
|
-
initialValue: true,
|
|
1160
|
-
})
|
|
1161
|
-
|
|
1162
|
-
if (clack.isCancel(createPkg)) handleCancel()
|
|
1163
|
-
|
|
1164
|
-
if (!createPkg) {
|
|
1165
|
-
clack.cancel('Run this command from the root of your project.')
|
|
1166
|
-
process.exit(1)
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
const dirName = cwd.split(/[\\/]/).pop() || 'my-project'
|
|
1170
|
-
writeFileSync(
|
|
1171
|
-
join(cwd, 'package.json'),
|
|
1172
|
-
JSON.stringify({ name: dirName, version: '0.1.0', private: true }, null, 2) + '\n'
|
|
1173
|
-
)
|
|
1174
|
-
clack.log.success('package.json created')
|
|
1175
|
-
}
|
|
973
|
+
// package.json is optional — init continues without it
|
|
1176
974
|
|
|
1177
975
|
// Auto-detect framework
|
|
1178
976
|
const packs = readdirSync(join(ROOT, 'packs'), { withFileTypes: true })
|
|
@@ -1183,10 +981,6 @@ async function main() {
|
|
|
1183
981
|
|
|
1184
982
|
const detected = detectFramework(join(cwd, 'package.json'), packs)
|
|
1185
983
|
|
|
1186
|
-
// Auto-detect platforms
|
|
1187
|
-
const detectedPlatforms = detectPlatforms(cwd)
|
|
1188
|
-
const platformLabels = detectedPlatforms.map(p => p.label).join(', ')
|
|
1189
|
-
|
|
1190
984
|
// Auto-detect architecture
|
|
1191
985
|
let framework = detected
|
|
1192
986
|
const isEmptyProject = !detected
|
|
@@ -1200,9 +994,8 @@ async function main() {
|
|
|
1200
994
|
if (detected) {
|
|
1201
995
|
detectionLines.push(`${GREEN}✓${NC} Framework: ${BOLD}${packLabels[detected] || detected}${NC}`)
|
|
1202
996
|
} else {
|
|
1203
|
-
detectionLines.push(`${DIM}○ Framework: none detected
|
|
997
|
+
detectionLines.push(`${DIM}○ Framework: none detected${NC}`)
|
|
1204
998
|
}
|
|
1205
|
-
detectionLines.push(`${GREEN}✓${NC} Platforms: ${BOLD}${platformLabels}${NC}`)
|
|
1206
999
|
if (detectedArch && detectedArch !== 'unstructured') {
|
|
1207
1000
|
detectionLines.push(`${GREEN}✓${NC} Architecture: ${BOLD}${detectedArchName}${NC}`)
|
|
1208
1001
|
}
|
|
@@ -1249,17 +1042,13 @@ async function main() {
|
|
|
1249
1042
|
// ── Step 4: Customize (optional) ───────────────────
|
|
1250
1043
|
|
|
1251
1044
|
const customize = await clack.confirm({
|
|
1252
|
-
message: `Customize installation? ${DIM}(hooks,
|
|
1045
|
+
message: `Customize installation? ${DIM}(hooks, agent selection)${NC}`,
|
|
1253
1046
|
initialValue: false,
|
|
1254
1047
|
})
|
|
1255
1048
|
|
|
1256
1049
|
if (clack.isCancel(customize)) handleCancel()
|
|
1257
1050
|
|
|
1258
1051
|
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
1052
|
let installStarter = true
|
|
1264
1053
|
let installWorkflow = true
|
|
1265
1054
|
let installSpecialists = true
|
|
@@ -1301,120 +1090,6 @@ async function main() {
|
|
|
1301
1090
|
installSpecialists = agentGroups.includes('specialist')
|
|
1302
1091
|
installBusiness = agentGroups.includes('business')
|
|
1303
1092
|
}
|
|
1304
|
-
|
|
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
|
-
})
|
|
1330
|
-
|
|
1331
|
-
if (clack.isCancel(teamSize)) handleCancel()
|
|
1332
|
-
|
|
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
|
-
}
|
|
1349
|
-
|
|
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
1093
|
}
|
|
1419
1094
|
|
|
1420
1095
|
// ── Install ─────────────────────────────────────────
|
|
@@ -1431,29 +1106,12 @@ async function main() {
|
|
|
1431
1106
|
: join(cwd, '.claude', 'agents')
|
|
1432
1107
|
mkdirSync(agentsDest, { recursive: true })
|
|
1433
1108
|
|
|
1434
|
-
// Handle existing agents
|
|
1435
|
-
const existingAgents = detectExistingAgents(agentsDest)
|
|
1436
|
-
let shouldOverwrite = forceMode
|
|
1437
|
-
|
|
1438
|
-
if (existingAgents.length > 0 && !forceMode) {
|
|
1439
|
-
const overwriteChoice = await clack.confirm({
|
|
1440
|
-
message: `${existingAgents.length} existing agents found. Overwrite?`,
|
|
1441
|
-
initialValue: false,
|
|
1442
|
-
})
|
|
1443
|
-
if (clack.isCancel(overwriteChoice)) handleCancel()
|
|
1444
|
-
shouldOverwrite = overwriteChoice
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
1109
|
const s = clack.spinner()
|
|
1448
|
-
s.start('Installing agents, skills, and
|
|
1110
|
+
s.start('Installing agents, skills, and hooks...')
|
|
1449
1111
|
|
|
1450
|
-
// Install pack agents
|
|
1112
|
+
// Install pack agents (additive: updates ours, preserves user's)
|
|
1451
1113
|
if (existsSync(agentsSource)) {
|
|
1452
|
-
|
|
1453
|
-
copyDir(agentsSource, agentsDest)
|
|
1454
|
-
} else {
|
|
1455
|
-
copyNewOnly(agentsSource, agentsDest)
|
|
1456
|
-
}
|
|
1114
|
+
copyManagedFiles(agentsSource, agentsDest)
|
|
1457
1115
|
}
|
|
1458
1116
|
|
|
1459
1117
|
// Install all agent groups
|
|
@@ -1481,26 +1139,22 @@ async function main() {
|
|
|
1481
1139
|
const suffix = mode === 'lite' ? '-lite.md' : '.md'
|
|
1482
1140
|
const source = join(ROOT, 'agents', `${name}${suffix}`)
|
|
1483
1141
|
const dest = join(agentsDest, `${name}.md`)
|
|
1484
|
-
if (existsSync(source)
|
|
1142
|
+
if (existsSync(source)) {
|
|
1485
1143
|
cpSync(source, dest)
|
|
1486
1144
|
}
|
|
1487
1145
|
}
|
|
1488
1146
|
|
|
1489
|
-
// Install skills
|
|
1147
|
+
// Install skills (additive: updates ours, preserves user's)
|
|
1490
1148
|
const skillsDest = join(cwd, '.claude', 'skills')
|
|
1491
1149
|
mkdirSync(skillsDest, { recursive: true })
|
|
1492
1150
|
let skillCount = 0
|
|
1493
1151
|
if (existsSync(skillsSource)) {
|
|
1494
|
-
skillCount =
|
|
1495
|
-
? copyDir(skillsSource, skillsDest)
|
|
1496
|
-
: copyNewOnly(skillsSource, skillsDest)
|
|
1152
|
+
skillCount = copyManagedFiles(skillsSource, skillsDest)
|
|
1497
1153
|
}
|
|
1498
1154
|
|
|
1499
1155
|
const genericSkillsSource = join(ROOT, 'skills')
|
|
1500
1156
|
if (existsSync(genericSkillsSource)) {
|
|
1501
|
-
skillCount +=
|
|
1502
|
-
? copyDir(genericSkillsSource, skillsDest)
|
|
1503
|
-
: copyNewOnly(genericSkillsSource, skillsDest)
|
|
1157
|
+
skillCount += copyManagedFiles(genericSkillsSource, skillsDest)
|
|
1504
1158
|
}
|
|
1505
1159
|
|
|
1506
1160
|
// Install native hooks (defaults: security-guard, auto-dispatch, session-context)
|
|
@@ -1509,34 +1163,6 @@ async function main() {
|
|
|
1509
1163
|
nativeHooksInstalled = setupNativeHooks(cwd, selectedHooks)
|
|
1510
1164
|
}
|
|
1511
1165
|
|
|
1512
|
-
// Install ARCHITECTURE.md
|
|
1513
|
-
const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
|
|
1514
|
-
let archInstalled = false
|
|
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
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
1166
|
// Install CLAUDE.md
|
|
1541
1167
|
const claudeDest = join(cwd, 'CLAUDE.md')
|
|
1542
1168
|
let claudeInstalled = false
|
|
@@ -1553,13 +1179,6 @@ async function main() {
|
|
|
1553
1179
|
}
|
|
1554
1180
|
}
|
|
1555
1181
|
|
|
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
|
-
|
|
1563
1182
|
s.stop('Installation complete')
|
|
1564
1183
|
|
|
1565
1184
|
// ── Summary ────────────────────────────────────────
|
|
@@ -1568,29 +1187,11 @@ async function main() {
|
|
|
1568
1187
|
const packLabel = isNone ? 'Universal' : (packLabels[framework] || framework)
|
|
1569
1188
|
|
|
1570
1189
|
const summaryLines = []
|
|
1571
|
-
summaryLines.push(`${BOLD}${installedAgentNames.length} agents${NC}
|
|
1572
|
-
if (skillCount > 0) summaryLines.push(`${BOLD}${skillCount} skills${NC}
|
|
1573
|
-
if (nativeHooksInstalled > 0) summaryLines.push(`${BOLD}${nativeHooksInstalled}
|
|
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
|
-
}
|
|
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/`)
|
|
1579
1193
|
if (claudeInstalled) summaryLines.push(`${GREEN}✓${NC} CLAUDE.md`)
|
|
1580
1194
|
|
|
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}`)
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
if (existingAgents.length > 0 && !shouldOverwrite) {
|
|
1590
|
-
summaryLines.push('')
|
|
1591
|
-
summaryLines.push(`${DIM}${existingAgents.length} existing agent(s) preserved. Use --force to overwrite.${NC}`)
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
1195
|
const scopeLabel = installGlobal ? 'Global' : 'Project'
|
|
1595
1196
|
clack.note(summaryLines.join('\n'), `${packLabel} · ${mode === 'full' ? 'Full' : 'Lite'} · ${scopeLabel}`)
|
|
1596
1197
|
|
|
@@ -1599,7 +1200,7 @@ async function main() {
|
|
|
1599
1200
|
? readdirSync(skillsDest, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => '/' + d.name)
|
|
1600
1201
|
: []
|
|
1601
1202
|
|
|
1602
|
-
clack.note(buildGettingStarted(installedAgentNames, installedSkills,
|
|
1203
|
+
clack.note(buildGettingStarted(installedAgentNames, installedSkills, isNone), 'Getting started')
|
|
1603
1204
|
|
|
1604
1205
|
if (mode === 'lite') {
|
|
1605
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
|
-
}
|