specialist-agent 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.mjs +165 -63
- package/package.json +1 -1
package/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { createInterface } from 'readline'
|
|
4
|
-
import { existsSync, mkdirSync, cpSync, readdirSync, readFileSync } from 'fs'
|
|
4
|
+
import { existsSync, mkdirSync, cpSync, readdirSync, readFileSync, writeFileSync } from 'fs'
|
|
5
5
|
import { join, dirname, resolve } from 'path'
|
|
6
6
|
import { fileURLToPath } from 'url'
|
|
7
7
|
|
|
@@ -16,25 +16,68 @@ const BOLD = '\x1b[1m'
|
|
|
16
16
|
const DIM = '\x1b[2m'
|
|
17
17
|
const NC = '\x1b[0m'
|
|
18
18
|
|
|
19
|
+
const W = 50
|
|
20
|
+
|
|
19
21
|
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
22
|
+
rl.on('close', () => {
|
|
23
|
+
console.log()
|
|
24
|
+
process.exit(0)
|
|
25
|
+
})
|
|
20
26
|
|
|
21
|
-
function ask(question, options) {
|
|
27
|
+
function ask(question, options, stepInfo) {
|
|
22
28
|
return new Promise((resolve) => {
|
|
29
|
+
const prefix = stepInfo ? `${BLUE}[${stepInfo}]${NC} ` : ''
|
|
30
|
+
console.log()
|
|
31
|
+
console.log(` ${prefix}${question}`)
|
|
23
32
|
if (options) {
|
|
24
33
|
console.log()
|
|
25
34
|
options.forEach((opt, i) => {
|
|
26
|
-
console.log(`
|
|
35
|
+
console.log(` ${BOLD}${i + 1}${NC}) ${opt.label}${opt.hint ? ` ${DIM}${opt.hint}${NC}` : ''}`)
|
|
27
36
|
})
|
|
28
37
|
console.log()
|
|
29
38
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const doPrompt = () => {
|
|
40
|
+
rl.question(` ${BLUE}\u203a${NC} `, (answer) => {
|
|
41
|
+
if (options) {
|
|
42
|
+
const idx = parseInt(answer, 10) - 1
|
|
43
|
+
if (idx >= 0 && idx < options.length) {
|
|
44
|
+
resolve(options[idx].value)
|
|
45
|
+
} else {
|
|
46
|
+
console.log(` ${YELLOW}Enter a number between 1 and ${options.length}${NC}`)
|
|
47
|
+
doPrompt()
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
resolve(answer.trim())
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
doPrompt()
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function confirm(question, defaultYes, stepInfo) {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
const prefix = stepInfo ? `${BLUE}[${stepInfo}]${NC} ` : ''
|
|
61
|
+
const hint = defaultYes ? `${DIM}(Y/n)${NC}` : `${DIM}(y/N)${NC}`
|
|
62
|
+
console.log()
|
|
63
|
+
console.log(` ${prefix}${question} ${hint}`)
|
|
64
|
+
console.log()
|
|
65
|
+
const doPrompt = () => {
|
|
66
|
+
rl.question(` ${BLUE}\u203a${NC} `, (answer) => {
|
|
67
|
+
const val = answer.trim().toLowerCase()
|
|
68
|
+
if (val === '') {
|
|
69
|
+
resolve(defaultYes)
|
|
70
|
+
} else if (val === 'y' || val === 'yes') {
|
|
71
|
+
resolve(true)
|
|
72
|
+
} else if (val === 'n' || val === 'no') {
|
|
73
|
+
resolve(false)
|
|
74
|
+
} else {
|
|
75
|
+
console.log(` ${YELLOW}Enter Y or N${NC}`)
|
|
76
|
+
doPrompt()
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
doPrompt()
|
|
38
81
|
})
|
|
39
82
|
}
|
|
40
83
|
|
|
@@ -66,22 +109,33 @@ function getAgentNames(dir) {
|
|
|
66
109
|
}
|
|
67
110
|
|
|
68
111
|
async function main() {
|
|
112
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
|
|
113
|
+
const ver = `v${pkg.version}`
|
|
114
|
+
|
|
115
|
+
// Header
|
|
69
116
|
console.log()
|
|
70
|
-
console.log(
|
|
71
|
-
console.log(
|
|
72
|
-
console.log(
|
|
73
|
-
console.log()
|
|
74
|
-
console.log(` ${
|
|
117
|
+
console.log(` ${BLUE}\u256d${'─'.repeat(W)}\u256e${NC}`)
|
|
118
|
+
console.log(` ${BLUE}\u2502${NC}${' '.repeat(W)}${BLUE}\u2502${NC}`)
|
|
119
|
+
console.log(` ${BLUE}\u2502${NC} ${BOLD}Specialist Agent${NC}${' '.repeat(W - 22 - ver.length)}${DIM}${ver}${NC} ${BLUE}\u2502${NC}`)
|
|
120
|
+
console.log(` ${BLUE}\u2502${NC} ${DIM}AI agents for Claude Code${NC}${' '.repeat(W - 28)}${BLUE}\u2502${NC}`)
|
|
121
|
+
console.log(` ${BLUE}\u2502${NC}${' '.repeat(W)}${BLUE}\u2502${NC}`)
|
|
122
|
+
console.log(` ${BLUE}\u2570${'─'.repeat(W)}\u256f${NC}`)
|
|
75
123
|
console.log()
|
|
76
124
|
|
|
77
125
|
// Check we're in a project
|
|
78
126
|
const cwd = process.cwd()
|
|
79
127
|
if (!existsSync(join(cwd, 'package.json'))) {
|
|
80
|
-
console.log(
|
|
81
|
-
|
|
128
|
+
console.log(` ${YELLOW}\u26a0${NC} No package.json found in current directory.`)
|
|
129
|
+
const createPkg = await confirm('Create a package.json to initialize this project?', true)
|
|
130
|
+
if (!createPkg) {
|
|
131
|
+
console.log(` Run this command from the root of your project.`)
|
|
132
|
+
console.log()
|
|
133
|
+
process.exit(1)
|
|
134
|
+
}
|
|
135
|
+
const dirName = cwd.split(/[\\/]/).pop() || 'my-project'
|
|
136
|
+
writeFileSync(join(cwd, 'package.json'), JSON.stringify({ name: dirName, version: '0.1.0', private: true }, null, 2) + '\n')
|
|
137
|
+
console.log(` ${GREEN}\u2713${NC} package.json created`)
|
|
82
138
|
console.log()
|
|
83
|
-
rl.close()
|
|
84
|
-
process.exit(1)
|
|
85
139
|
}
|
|
86
140
|
|
|
87
141
|
// 1. Framework
|
|
@@ -97,31 +151,26 @@ async function main() {
|
|
|
97
151
|
hint: ''
|
|
98
152
|
}))
|
|
99
153
|
|
|
100
|
-
const framework = await ask('Which framework?', packOptions)
|
|
154
|
+
const framework = await ask('Which framework?', packOptions, '1/4')
|
|
101
155
|
|
|
102
156
|
// 2. Mode
|
|
103
157
|
const mode = await ask('Agent mode?', [
|
|
104
|
-
{ label: 'Full', value: 'full', hint: '(Sonnet/Opus
|
|
105
|
-
{ label: 'Lite', value: 'lite', hint: '(Haiku
|
|
106
|
-
])
|
|
158
|
+
{ label: 'Full', value: 'full', hint: '(Sonnet/Opus)' },
|
|
159
|
+
{ label: 'Lite', value: 'lite', hint: '(Haiku \u2014 lower cost)' },
|
|
160
|
+
], '2/4')
|
|
107
161
|
|
|
108
162
|
// 3. Starter agent
|
|
109
|
-
const installStarter = await
|
|
110
|
-
{ label: 'Yes', value: true, hint: '(recommended)' },
|
|
111
|
-
{ label: 'No', value: false, hint: '' },
|
|
112
|
-
])
|
|
163
|
+
const installStarter = await confirm('Install @starter agent?', true, '3/4')
|
|
113
164
|
|
|
114
165
|
// 4. Specialist agents
|
|
115
|
-
const installSpecialists = await
|
|
116
|
-
{ label: 'Yes', value: true, hint: '(recommended)' },
|
|
117
|
-
{ label: 'No', value: false, hint: '' },
|
|
118
|
-
])
|
|
166
|
+
const installSpecialists = await confirm('Install specialist agents?', true, '4/4')
|
|
119
167
|
|
|
168
|
+
// Summary
|
|
169
|
+
const packLabel = packLabels[framework] || framework
|
|
170
|
+
console.log()
|
|
171
|
+
console.log(` ${BLUE}${'─'.repeat(W)}${NC}`)
|
|
120
172
|
console.log()
|
|
121
|
-
console.log(
|
|
122
|
-
console.log(` ${BOLD}Installing Specialist Agent${NC}`)
|
|
123
|
-
console.log(` ${DIM}Pack: ${framework} | Mode: ${mode} | Starter: ${installStarter ? 'yes' : 'no'} | Specialists: ${installSpecialists ? 'yes' : 'no'}${NC}`)
|
|
124
|
-
console.log(`${BLUE} ─────────────────────────────────────${NC}`)
|
|
173
|
+
console.log(` ${packLabel} ${DIM}\u00b7${NC} ${mode === 'full' ? 'Full' : 'Lite'} ${DIM}\u00b7${NC} Starter: ${installStarter ? 'yes' : 'no'} ${DIM}\u00b7${NC} Specialists: ${installSpecialists ? 'yes' : 'no'}`)
|
|
125
174
|
console.log()
|
|
126
175
|
|
|
127
176
|
const packDir = join(ROOT, 'packs', framework)
|
|
@@ -130,16 +179,15 @@ async function main() {
|
|
|
130
179
|
const archSource = join(packDir, 'ARCHITECTURE.md')
|
|
131
180
|
const claudeSource = join(packDir, 'CLAUDE.md')
|
|
132
181
|
|
|
133
|
-
// Install agents
|
|
182
|
+
// Install pack agents
|
|
134
183
|
const agentsDest = join(cwd, '.claude', 'agents')
|
|
135
184
|
mkdirSync(agentsDest, { recursive: true })
|
|
136
185
|
const agentCount = copyDir(agentsSource, agentsDest)
|
|
137
186
|
const agentNames = getAgentNames(agentsDest)
|
|
138
187
|
|
|
139
188
|
agentNames.forEach(name => {
|
|
140
|
-
console.log(` ${GREEN}
|
|
189
|
+
console.log(` ${GREEN}\u2713${NC} @${name}`)
|
|
141
190
|
})
|
|
142
|
-
console.log(` ${GREEN}${agentCount} agents installed${NC}`)
|
|
143
191
|
|
|
144
192
|
// Install starter agent
|
|
145
193
|
if (installStarter) {
|
|
@@ -149,13 +197,13 @@ async function main() {
|
|
|
149
197
|
|
|
150
198
|
if (existsSync(starterSource)) {
|
|
151
199
|
cpSync(starterSource, starterDest)
|
|
152
|
-
console.log(` ${GREEN}
|
|
200
|
+
console.log(` ${GREEN}\u2713${NC} @starter`)
|
|
153
201
|
}
|
|
154
202
|
}
|
|
155
203
|
|
|
156
204
|
// Install specialist agents
|
|
157
205
|
if (installSpecialists) {
|
|
158
|
-
const specialistNames = ['finance', 'cloud', 'security', 'designer', 'data', 'devops', 'tester']
|
|
206
|
+
const specialistNames = ['explorer', 'finance', 'cloud', 'security', 'designer', 'data', 'devops', 'tester']
|
|
159
207
|
for (const name of specialistNames) {
|
|
160
208
|
const suffix = mode === 'lite' ? `-lite.md` : '.md'
|
|
161
209
|
const source = join(ROOT, 'agents', `${name}${suffix}`)
|
|
@@ -163,57 +211,78 @@ async function main() {
|
|
|
163
211
|
|
|
164
212
|
if (existsSync(source)) {
|
|
165
213
|
cpSync(source, dest)
|
|
166
|
-
console.log(` ${GREEN}
|
|
214
|
+
console.log(` ${GREEN}\u2713${NC} @${name}`)
|
|
167
215
|
}
|
|
168
216
|
}
|
|
169
217
|
}
|
|
170
218
|
|
|
219
|
+
console.log(` ${DIM}${agentCount} pack agents + extras installed${NC}`)
|
|
220
|
+
|
|
171
221
|
// Install skills
|
|
172
222
|
console.log()
|
|
173
223
|
const skillsDest = join(cwd, '.claude', 'skills')
|
|
174
224
|
mkdirSync(skillsDest, { recursive: true })
|
|
175
225
|
const skillCount = copyDir(skillsSource, skillsDest)
|
|
176
|
-
|
|
226
|
+
if (skillCount > 0) {
|
|
227
|
+
console.log(` ${GREEN}\u2713${NC} ${skillCount} skills installed`)
|
|
228
|
+
} else {
|
|
229
|
+
console.log(` ${DIM} No skills available for this pack${NC}`)
|
|
230
|
+
}
|
|
177
231
|
|
|
178
232
|
// Install ARCHITECTURE.md
|
|
179
|
-
console.log()
|
|
180
233
|
const archDest = join(cwd, 'docs', 'ARCHITECTURE.md')
|
|
181
234
|
if (!existsSync(archDest)) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
235
|
+
if (existsSync(archSource)) {
|
|
236
|
+
mkdirSync(dirname(archDest), { recursive: true })
|
|
237
|
+
cpSync(archSource, archDest)
|
|
238
|
+
console.log(` ${GREEN}\u2713${NC} docs/ARCHITECTURE.md`)
|
|
239
|
+
} else {
|
|
240
|
+
console.log(` ${YELLOW}\u26a0${NC} ARCHITECTURE.md not found in pack ${DIM}(skipped)${NC}`)
|
|
241
|
+
}
|
|
185
242
|
} else {
|
|
186
|
-
console.log(` ${
|
|
243
|
+
console.log(` ${DIM} docs/ARCHITECTURE.md already exists${NC}`)
|
|
187
244
|
}
|
|
188
245
|
|
|
189
246
|
// Install CLAUDE.md
|
|
190
247
|
const claudeDest = join(cwd, 'CLAUDE.md')
|
|
191
248
|
if (!existsSync(claudeDest)) {
|
|
192
|
-
|
|
193
|
-
|
|
249
|
+
if (existsSync(claudeSource)) {
|
|
250
|
+
cpSync(claudeSource, claudeDest)
|
|
251
|
+
console.log(` ${GREEN}\u2713${NC} CLAUDE.md`)
|
|
252
|
+
} else {
|
|
253
|
+
console.log(` ${YELLOW}\u26a0${NC} CLAUDE.md not found in pack ${DIM}(skipped)${NC}`)
|
|
254
|
+
}
|
|
194
255
|
} else {
|
|
195
|
-
console.log(` ${
|
|
256
|
+
console.log(` ${DIM} CLAUDE.md already exists${NC}`)
|
|
196
257
|
}
|
|
197
258
|
|
|
198
259
|
// Done
|
|
199
260
|
console.log()
|
|
200
|
-
console.log(
|
|
201
|
-
console.log(
|
|
202
|
-
console.log(
|
|
261
|
+
console.log(` ${BLUE}${'─'.repeat(W)}${NC}`)
|
|
262
|
+
console.log()
|
|
263
|
+
console.log(` ${GREEN}${BOLD}Setup complete!${NC}`)
|
|
203
264
|
console.log()
|
|
204
265
|
|
|
205
266
|
if (mode === 'lite') {
|
|
206
|
-
console.log(` ${
|
|
207
|
-
console.log(` ${
|
|
267
|
+
console.log(` ${DIM}Lite mode: agents run on Haiku (lower cost, faster).${NC}`)
|
|
268
|
+
console.log(` ${DIM}Switch to Full: npx specialist-agent init${NC}`)
|
|
208
269
|
console.log()
|
|
209
270
|
}
|
|
210
271
|
|
|
211
|
-
|
|
272
|
+
// Show installed skills as examples
|
|
273
|
+
const installedSkills = existsSync(skillsDest)
|
|
274
|
+
? readdirSync(skillsDest, { withFileTypes: true }).filter(d => d.isDirectory()).map(d => '/' + d.name)
|
|
275
|
+
: []
|
|
276
|
+
|
|
277
|
+
console.log(` Get started:`)
|
|
212
278
|
console.log()
|
|
213
|
-
console.log(` claude`)
|
|
214
|
-
console.log(` /agents
|
|
215
|
-
|
|
216
|
-
|
|
279
|
+
console.log(` ${DIM}$${NC} claude`)
|
|
280
|
+
console.log(` ${DIM}$${NC} /agents ${DIM}# list installed agents${NC}`)
|
|
281
|
+
if (installedSkills.length > 0) {
|
|
282
|
+
installedSkills.slice(0, 2).forEach(skill => {
|
|
283
|
+
console.log(` ${DIM}$${NC} ${skill}`)
|
|
284
|
+
})
|
|
285
|
+
}
|
|
217
286
|
console.log()
|
|
218
287
|
console.log(` Or just ask:`)
|
|
219
288
|
console.log()
|
|
@@ -225,8 +294,41 @@ async function main() {
|
|
|
225
294
|
rl.close()
|
|
226
295
|
}
|
|
227
296
|
|
|
297
|
+
// CLI argument handling
|
|
298
|
+
const args = process.argv.slice(2)
|
|
299
|
+
|
|
300
|
+
const validCommands = ['init']
|
|
301
|
+
const command = args.find(a => !a.startsWith('-'))
|
|
302
|
+
if (command && !validCommands.includes(command)) {
|
|
303
|
+
console.error(` ${YELLOW}Unknown command: ${command}${NC}`)
|
|
304
|
+
console.error(` Run ${BOLD}specialist-agent --help${NC} for usage.`)
|
|
305
|
+
process.exit(1)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
309
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
|
|
310
|
+
console.log()
|
|
311
|
+
console.log(` ${BOLD}specialist-agent${NC} ${DIM}v${pkg.version}${NC}`)
|
|
312
|
+
console.log()
|
|
313
|
+
console.log(' Usage: specialist-agent [init] [options]')
|
|
314
|
+
console.log()
|
|
315
|
+
console.log(' Options:')
|
|
316
|
+
console.log(` -h, --help ${DIM}Show this help message${NC}`)
|
|
317
|
+
console.log(` -v, --version ${DIM}Show version number${NC}`)
|
|
318
|
+
console.log()
|
|
319
|
+
console.log(` ${DIM}Run the setup wizard to install AI agents for Claude Code.${NC}`)
|
|
320
|
+
console.log(` ${DIM}Can be executed from any directory (creates package.json if needed).${NC}`)
|
|
321
|
+
console.log()
|
|
322
|
+
process.exit(0)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
326
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8'))
|
|
327
|
+
console.log(pkg.version)
|
|
328
|
+
process.exit(0)
|
|
329
|
+
}
|
|
330
|
+
|
|
228
331
|
main().catch((err) => {
|
|
229
|
-
console.error(err)
|
|
230
|
-
rl.close()
|
|
332
|
+
console.error(` ${YELLOW}Error: ${err.message}${NC}`)
|
|
231
333
|
process.exit(1)
|
|
232
334
|
})
|