@claude-flow/cli 3.0.0-alpha.13 → 3.0.0-alpha.15
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/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +75 -2
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -4
- package/.agentic-flow/intelligence.json +0 -17
- package/.claude-flow/agents/store.json +0 -16
- package/.claude-flow/daemon-state.json +0 -123
- package/.claude-flow/daemon-test.log +0 -0
- package/.claude-flow/daemon.log +0 -0
- package/.claude-flow/daemon2.log +0 -0
- package/.claude-flow/daemon3.log +0 -0
- package/.claude-flow/hive-mind/state.json +0 -51
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/codebase-map.json +0 -11
- package/.claude-flow/metrics/consolidation.json +0 -6
- package/.claude-flow/metrics/performance.json +0 -87
- package/.claude-flow/metrics/security-audit.json +0 -10
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude-flow/metrics/test-gaps.json +0 -6
- package/__tests__/README.md +0 -140
- package/__tests__/TEST_SUMMARY.md +0 -144
- package/__tests__/cli.test.ts +0 -558
- package/__tests__/commands.test.ts +0 -726
- package/__tests__/config-adapter.test.ts +0 -362
- package/__tests__/config-loading.test.ts +0 -106
- package/__tests__/coverage/.tmp/coverage-0.json +0 -1
- package/__tests__/coverage/.tmp/coverage-1.json +0 -1
- package/__tests__/coverage/.tmp/coverage-2.json +0 -1
- package/__tests__/coverage/.tmp/coverage-3.json +0 -1
- package/__tests__/coverage/.tmp/coverage-4.json +0 -1
- package/__tests__/coverage/.tmp/coverage-5.json +0 -1
- package/__tests__/mcp-client.test.ts +0 -480
- package/__tests__/p1-commands.test.ts +0 -1064
- package/agents/architect.yaml +0 -11
- package/agents/coder.yaml +0 -11
- package/agents/reviewer.yaml +0 -10
- package/agents/security-architect.yaml +0 -10
- package/agents/tester.yaml +0 -10
- package/docs/CONFIG_LOADING.md +0 -236
- package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
- package/docs/MCP_CLIENT_GUIDE.md +0 -620
- package/docs/REFACTORING_SUMMARY.md +0 -247
- package/scripts/publish.sh +0 -46
- package/src/commands/agent.ts +0 -955
- package/src/commands/claims.ts +0 -317
- package/src/commands/completions.ts +0 -558
- package/src/commands/config.ts +0 -452
- package/src/commands/daemon.ts +0 -621
- package/src/commands/deployment.ts +0 -323
- package/src/commands/doctor.ts +0 -382
- package/src/commands/embeddings.ts +0 -686
- package/src/commands/hive-mind.ts +0 -928
- package/src/commands/hooks.ts +0 -2603
- package/src/commands/index.ts +0 -154
- package/src/commands/init.ts +0 -597
- package/src/commands/mcp.ts +0 -753
- package/src/commands/memory.ts +0 -1161
- package/src/commands/migrate.ts +0 -447
- package/src/commands/neural.ts +0 -253
- package/src/commands/performance.ts +0 -292
- package/src/commands/plugins.ts +0 -316
- package/src/commands/process.ts +0 -695
- package/src/commands/providers.ts +0 -259
- package/src/commands/security.ts +0 -288
- package/src/commands/session.ts +0 -891
- package/src/commands/start.ts +0 -457
- package/src/commands/status.ts +0 -736
- package/src/commands/swarm.ts +0 -648
- package/src/commands/task.ts +0 -792
- package/src/commands/workflow.ts +0 -742
- package/src/config-adapter.ts +0 -210
- package/src/index.ts +0 -443
- package/src/infrastructure/in-memory-repositories.ts +0 -310
- package/src/init/claudemd-generator.ts +0 -631
- package/src/init/executor.ts +0 -762
- package/src/init/helpers-generator.ts +0 -628
- package/src/init/index.ts +0 -60
- package/src/init/mcp-generator.ts +0 -83
- package/src/init/settings-generator.ts +0 -284
- package/src/init/statusline-generator.ts +0 -211
- package/src/init/types.ts +0 -447
- package/src/mcp-client.ts +0 -241
- package/src/mcp-server.ts +0 -577
- package/src/mcp-tools/agent-tools.ts +0 -466
- package/src/mcp-tools/config-tools.ts +0 -370
- package/src/mcp-tools/hive-mind-tools.ts +0 -521
- package/src/mcp-tools/hooks-tools.ts +0 -1888
- package/src/mcp-tools/index.ts +0 -16
- package/src/mcp-tools/memory-tools.ts +0 -270
- package/src/mcp-tools/session-tools.ts +0 -359
- package/src/mcp-tools/swarm-tools.ts +0 -105
- package/src/mcp-tools/task-tools.ts +0 -347
- package/src/mcp-tools/types.ts +0 -33
- package/src/mcp-tools/workflow-tools.ts +0 -573
- package/src/output.ts +0 -639
- package/src/parser.ts +0 -417
- package/src/prompt.ts +0 -619
- package/src/services/index.ts +0 -15
- package/src/services/worker-daemon.ts +0 -726
- package/src/suggest.ts +0 -245
- package/src/types.ts +0 -287
- package/tmp.json +0 -0
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -13
package/src/init/types.ts
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V3 Init System Types
|
|
3
|
-
* Configuration options for initializing Claude Code integration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Components that can be initialized
|
|
11
|
-
*/
|
|
12
|
-
export interface InitComponents {
|
|
13
|
-
/** Create .claude/settings.json with hooks */
|
|
14
|
-
settings: boolean;
|
|
15
|
-
/** Copy skills to .claude/skills/ */
|
|
16
|
-
skills: boolean;
|
|
17
|
-
/** Copy commands to .claude/commands/ */
|
|
18
|
-
commands: boolean;
|
|
19
|
-
/** Copy agents to .claude/agents/ */
|
|
20
|
-
agents: boolean;
|
|
21
|
-
/** Create helper scripts in .claude/helpers/ */
|
|
22
|
-
helpers: boolean;
|
|
23
|
-
/** Configure statusline */
|
|
24
|
-
statusline: boolean;
|
|
25
|
-
/** Create MCP configuration */
|
|
26
|
-
mcp: boolean;
|
|
27
|
-
/** Create .claude-flow/ directory (V3 runtime) */
|
|
28
|
-
runtime: boolean;
|
|
29
|
-
/** Create CLAUDE.md with swarm guidance */
|
|
30
|
-
claudeMd: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Hook configuration options
|
|
35
|
-
*/
|
|
36
|
-
export interface HooksConfig {
|
|
37
|
-
/** Enable PreToolUse hooks */
|
|
38
|
-
preToolUse: boolean;
|
|
39
|
-
/** Enable PostToolUse hooks */
|
|
40
|
-
postToolUse: boolean;
|
|
41
|
-
/** Enable UserPromptSubmit for routing */
|
|
42
|
-
userPromptSubmit: boolean;
|
|
43
|
-
/** Enable SessionStart hooks */
|
|
44
|
-
sessionStart: boolean;
|
|
45
|
-
/** Enable Stop hooks */
|
|
46
|
-
stop: boolean;
|
|
47
|
-
/** Enable Notification hooks */
|
|
48
|
-
notification: boolean;
|
|
49
|
-
/** Enable PermissionRequest auto-allow for claude-flow */
|
|
50
|
-
permissionRequest: boolean;
|
|
51
|
-
/** Hook timeout in milliseconds */
|
|
52
|
-
timeout: number;
|
|
53
|
-
/** Continue on hook error */
|
|
54
|
-
continueOnError: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Skills configuration
|
|
59
|
-
*/
|
|
60
|
-
export interface SkillsConfig {
|
|
61
|
-
/** Include core skills (swarm, memory, sparc) */
|
|
62
|
-
core: boolean;
|
|
63
|
-
/** Include AgentDB skills */
|
|
64
|
-
agentdb: boolean;
|
|
65
|
-
/** Include GitHub integration skills */
|
|
66
|
-
github: boolean;
|
|
67
|
-
/** Include Flow Nexus skills */
|
|
68
|
-
flowNexus: boolean;
|
|
69
|
-
/** Include V3 implementation skills */
|
|
70
|
-
v3: boolean;
|
|
71
|
-
/** Include all available skills */
|
|
72
|
-
all: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Commands configuration
|
|
77
|
-
*/
|
|
78
|
-
export interface CommandsConfig {
|
|
79
|
-
/** Include core commands */
|
|
80
|
-
core: boolean;
|
|
81
|
-
/** Include analysis commands */
|
|
82
|
-
analysis: boolean;
|
|
83
|
-
/** Include automation commands */
|
|
84
|
-
automation: boolean;
|
|
85
|
-
/** Include github commands */
|
|
86
|
-
github: boolean;
|
|
87
|
-
/** Include hooks commands */
|
|
88
|
-
hooks: boolean;
|
|
89
|
-
/** Include monitoring commands */
|
|
90
|
-
monitoring: boolean;
|
|
91
|
-
/** Include optimization commands */
|
|
92
|
-
optimization: boolean;
|
|
93
|
-
/** Include SPARC commands */
|
|
94
|
-
sparc: boolean;
|
|
95
|
-
/** Include all commands */
|
|
96
|
-
all: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Agents configuration
|
|
101
|
-
*/
|
|
102
|
-
export interface AgentsConfig {
|
|
103
|
-
/** Include core agents (coder, tester, reviewer) */
|
|
104
|
-
core: boolean;
|
|
105
|
-
/** Include consensus agents */
|
|
106
|
-
consensus: boolean;
|
|
107
|
-
/** Include GitHub agents */
|
|
108
|
-
github: boolean;
|
|
109
|
-
/** Include hive-mind agents */
|
|
110
|
-
hiveMind: boolean;
|
|
111
|
-
/** Include SPARC agents */
|
|
112
|
-
sparc: boolean;
|
|
113
|
-
/** Include swarm coordinators */
|
|
114
|
-
swarm: boolean;
|
|
115
|
-
/** Include all agents */
|
|
116
|
-
all: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Statusline configuration
|
|
121
|
-
*/
|
|
122
|
-
export interface StatuslineConfig {
|
|
123
|
-
/** Enable statusline */
|
|
124
|
-
enabled: boolean;
|
|
125
|
-
/** Show V3 progress */
|
|
126
|
-
showProgress: boolean;
|
|
127
|
-
/** Show security status */
|
|
128
|
-
showSecurity: boolean;
|
|
129
|
-
/** Show swarm activity */
|
|
130
|
-
showSwarm: boolean;
|
|
131
|
-
/** Show hooks metrics */
|
|
132
|
-
showHooks: boolean;
|
|
133
|
-
/** Show performance targets */
|
|
134
|
-
showPerformance: boolean;
|
|
135
|
-
/** Refresh interval in milliseconds */
|
|
136
|
-
refreshInterval: number;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* MCP configuration
|
|
141
|
-
*/
|
|
142
|
-
export interface MCPConfig {
|
|
143
|
-
/** Include claude-flow MCP server */
|
|
144
|
-
claudeFlow: boolean;
|
|
145
|
-
/** Include ruv-swarm MCP server */
|
|
146
|
-
ruvSwarm: boolean;
|
|
147
|
-
/** Include flow-nexus MCP server */
|
|
148
|
-
flowNexus: boolean;
|
|
149
|
-
/** Auto-start MCP server */
|
|
150
|
-
autoStart: boolean;
|
|
151
|
-
/** Server port */
|
|
152
|
-
port: number;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Runtime configuration (.claude-flow/)
|
|
157
|
-
*/
|
|
158
|
-
export interface RuntimeConfig {
|
|
159
|
-
/** Swarm topology */
|
|
160
|
-
topology: 'mesh' | 'hierarchical' | 'hierarchical-mesh' | 'adaptive';
|
|
161
|
-
/** Maximum agents */
|
|
162
|
-
maxAgents: number;
|
|
163
|
-
/** Memory backend */
|
|
164
|
-
memoryBackend: 'memory' | 'sqlite' | 'agentdb' | 'hybrid';
|
|
165
|
-
/** Enable HNSW indexing */
|
|
166
|
-
enableHNSW: boolean;
|
|
167
|
-
/** Enable neural learning */
|
|
168
|
-
enableNeural: boolean;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Detected platform information
|
|
173
|
-
*/
|
|
174
|
-
export interface PlatformInfo {
|
|
175
|
-
/** Operating system */
|
|
176
|
-
os: 'windows' | 'darwin' | 'linux';
|
|
177
|
-
/** Architecture */
|
|
178
|
-
arch: 'x64' | 'arm64' | 'arm' | 'ia32';
|
|
179
|
-
/** Node.js version */
|
|
180
|
-
nodeVersion: string;
|
|
181
|
-
/** Shell type */
|
|
182
|
-
shell: 'powershell' | 'cmd' | 'bash' | 'zsh' | 'sh';
|
|
183
|
-
/** Home directory */
|
|
184
|
-
homeDir: string;
|
|
185
|
-
/** Config directory (platform-specific) */
|
|
186
|
-
configDir: string;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Detect current platform
|
|
191
|
-
*/
|
|
192
|
-
export function detectPlatform(): PlatformInfo {
|
|
193
|
-
const platform = os.platform();
|
|
194
|
-
const arch = os.arch();
|
|
195
|
-
const homeDir = os.homedir();
|
|
196
|
-
|
|
197
|
-
let osType: 'windows' | 'darwin' | 'linux';
|
|
198
|
-
let shell: 'powershell' | 'cmd' | 'bash' | 'zsh' | 'sh';
|
|
199
|
-
let configDir: string;
|
|
200
|
-
|
|
201
|
-
switch (platform) {
|
|
202
|
-
case 'win32':
|
|
203
|
-
osType = 'windows';
|
|
204
|
-
shell = process.env.PSModulePath ? 'powershell' : 'cmd';
|
|
205
|
-
configDir = process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming');
|
|
206
|
-
break;
|
|
207
|
-
case 'darwin':
|
|
208
|
-
osType = 'darwin';
|
|
209
|
-
shell = process.env.SHELL?.includes('zsh') ? 'zsh' : 'bash';
|
|
210
|
-
configDir = path.join(homeDir, 'Library', 'Application Support');
|
|
211
|
-
break;
|
|
212
|
-
default:
|
|
213
|
-
osType = 'linux';
|
|
214
|
-
shell = process.env.SHELL?.includes('zsh') ? 'zsh' : (process.env.SHELL?.includes('bash') ? 'bash' : 'sh');
|
|
215
|
-
configDir = process.env.XDG_CONFIG_HOME || path.join(homeDir, '.config');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
os: osType,
|
|
220
|
-
arch: arch as PlatformInfo['arch'],
|
|
221
|
-
nodeVersion: process.version,
|
|
222
|
-
shell,
|
|
223
|
-
homeDir,
|
|
224
|
-
configDir,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Complete init options
|
|
230
|
-
*/
|
|
231
|
-
export interface InitOptions {
|
|
232
|
-
/** Target directory */
|
|
233
|
-
targetDir: string;
|
|
234
|
-
/** Source base directory for skills/commands/agents (optional) */
|
|
235
|
-
sourceBaseDir?: string;
|
|
236
|
-
/** Force overwrite existing files */
|
|
237
|
-
force: boolean;
|
|
238
|
-
/** Run in interactive mode */
|
|
239
|
-
interactive: boolean;
|
|
240
|
-
/** Components to initialize */
|
|
241
|
-
components: InitComponents;
|
|
242
|
-
/** Hooks configuration */
|
|
243
|
-
hooks: HooksConfig;
|
|
244
|
-
/** Skills configuration */
|
|
245
|
-
skills: SkillsConfig;
|
|
246
|
-
/** Commands configuration */
|
|
247
|
-
commands: CommandsConfig;
|
|
248
|
-
/** Agents configuration */
|
|
249
|
-
agents: AgentsConfig;
|
|
250
|
-
/** Statusline configuration */
|
|
251
|
-
statusline: StatuslineConfig;
|
|
252
|
-
/** MCP configuration */
|
|
253
|
-
mcp: MCPConfig;
|
|
254
|
-
/** Runtime configuration */
|
|
255
|
-
runtime: RuntimeConfig;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Default init options - full V3 setup
|
|
260
|
-
*/
|
|
261
|
-
export const DEFAULT_INIT_OPTIONS: InitOptions = {
|
|
262
|
-
targetDir: process.cwd(),
|
|
263
|
-
force: false,
|
|
264
|
-
interactive: true,
|
|
265
|
-
components: {
|
|
266
|
-
settings: true,
|
|
267
|
-
skills: true,
|
|
268
|
-
commands: true,
|
|
269
|
-
agents: true,
|
|
270
|
-
helpers: true,
|
|
271
|
-
statusline: true,
|
|
272
|
-
mcp: true,
|
|
273
|
-
runtime: true,
|
|
274
|
-
claudeMd: true,
|
|
275
|
-
},
|
|
276
|
-
hooks: {
|
|
277
|
-
preToolUse: true,
|
|
278
|
-
postToolUse: true,
|
|
279
|
-
userPromptSubmit: true,
|
|
280
|
-
sessionStart: true,
|
|
281
|
-
stop: true,
|
|
282
|
-
notification: true,
|
|
283
|
-
permissionRequest: true,
|
|
284
|
-
timeout: 5000,
|
|
285
|
-
continueOnError: true,
|
|
286
|
-
},
|
|
287
|
-
skills: {
|
|
288
|
-
core: true,
|
|
289
|
-
agentdb: true,
|
|
290
|
-
github: true,
|
|
291
|
-
flowNexus: false,
|
|
292
|
-
v3: true,
|
|
293
|
-
all: false,
|
|
294
|
-
},
|
|
295
|
-
commands: {
|
|
296
|
-
core: true,
|
|
297
|
-
analysis: true,
|
|
298
|
-
automation: true,
|
|
299
|
-
github: true,
|
|
300
|
-
hooks: true,
|
|
301
|
-
monitoring: true,
|
|
302
|
-
optimization: true,
|
|
303
|
-
sparc: true,
|
|
304
|
-
all: false,
|
|
305
|
-
},
|
|
306
|
-
agents: {
|
|
307
|
-
core: true,
|
|
308
|
-
consensus: false,
|
|
309
|
-
github: true,
|
|
310
|
-
hiveMind: true,
|
|
311
|
-
sparc: true,
|
|
312
|
-
swarm: true,
|
|
313
|
-
all: false,
|
|
314
|
-
},
|
|
315
|
-
statusline: {
|
|
316
|
-
enabled: true,
|
|
317
|
-
showProgress: true,
|
|
318
|
-
showSecurity: true,
|
|
319
|
-
showSwarm: true,
|
|
320
|
-
showHooks: true,
|
|
321
|
-
showPerformance: true,
|
|
322
|
-
refreshInterval: 5000,
|
|
323
|
-
},
|
|
324
|
-
mcp: {
|
|
325
|
-
claudeFlow: true,
|
|
326
|
-
ruvSwarm: false,
|
|
327
|
-
flowNexus: false,
|
|
328
|
-
autoStart: false,
|
|
329
|
-
port: 3000,
|
|
330
|
-
},
|
|
331
|
-
runtime: {
|
|
332
|
-
topology: 'hierarchical-mesh',
|
|
333
|
-
maxAgents: 15,
|
|
334
|
-
memoryBackend: 'hybrid',
|
|
335
|
-
enableHNSW: true,
|
|
336
|
-
enableNeural: true,
|
|
337
|
-
},
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Minimal init options
|
|
342
|
-
*/
|
|
343
|
-
export const MINIMAL_INIT_OPTIONS: InitOptions = {
|
|
344
|
-
...DEFAULT_INIT_OPTIONS,
|
|
345
|
-
components: {
|
|
346
|
-
settings: true,
|
|
347
|
-
skills: true,
|
|
348
|
-
commands: false,
|
|
349
|
-
agents: false,
|
|
350
|
-
helpers: false,
|
|
351
|
-
statusline: false,
|
|
352
|
-
mcp: true,
|
|
353
|
-
runtime: true,
|
|
354
|
-
claudeMd: true,
|
|
355
|
-
},
|
|
356
|
-
hooks: {
|
|
357
|
-
...DEFAULT_INIT_OPTIONS.hooks,
|
|
358
|
-
userPromptSubmit: false,
|
|
359
|
-
stop: false,
|
|
360
|
-
notification: false,
|
|
361
|
-
},
|
|
362
|
-
skills: {
|
|
363
|
-
core: true,
|
|
364
|
-
agentdb: false,
|
|
365
|
-
github: false,
|
|
366
|
-
flowNexus: false,
|
|
367
|
-
v3: false,
|
|
368
|
-
all: false,
|
|
369
|
-
},
|
|
370
|
-
agents: {
|
|
371
|
-
core: true,
|
|
372
|
-
consensus: false,
|
|
373
|
-
github: false,
|
|
374
|
-
hiveMind: false,
|
|
375
|
-
sparc: false,
|
|
376
|
-
swarm: false,
|
|
377
|
-
all: false,
|
|
378
|
-
},
|
|
379
|
-
runtime: {
|
|
380
|
-
topology: 'mesh',
|
|
381
|
-
maxAgents: 5,
|
|
382
|
-
memoryBackend: 'memory',
|
|
383
|
-
enableHNSW: false,
|
|
384
|
-
enableNeural: false,
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Full init options (everything enabled)
|
|
390
|
-
*/
|
|
391
|
-
export const FULL_INIT_OPTIONS: InitOptions = {
|
|
392
|
-
...DEFAULT_INIT_OPTIONS,
|
|
393
|
-
components: {
|
|
394
|
-
settings: true,
|
|
395
|
-
skills: true,
|
|
396
|
-
commands: true,
|
|
397
|
-
agents: true,
|
|
398
|
-
helpers: true,
|
|
399
|
-
statusline: true,
|
|
400
|
-
mcp: true,
|
|
401
|
-
runtime: true,
|
|
402
|
-
claudeMd: true,
|
|
403
|
-
},
|
|
404
|
-
skills: {
|
|
405
|
-
core: true,
|
|
406
|
-
agentdb: true,
|
|
407
|
-
github: true,
|
|
408
|
-
flowNexus: true,
|
|
409
|
-
v3: true,
|
|
410
|
-
all: true,
|
|
411
|
-
},
|
|
412
|
-
commands: {
|
|
413
|
-
...DEFAULT_INIT_OPTIONS.commands,
|
|
414
|
-
all: true,
|
|
415
|
-
},
|
|
416
|
-
agents: {
|
|
417
|
-
...DEFAULT_INIT_OPTIONS.agents,
|
|
418
|
-
all: true,
|
|
419
|
-
},
|
|
420
|
-
mcp: {
|
|
421
|
-
claudeFlow: true,
|
|
422
|
-
ruvSwarm: true,
|
|
423
|
-
flowNexus: true,
|
|
424
|
-
autoStart: false,
|
|
425
|
-
port: 3000,
|
|
426
|
-
},
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Init result
|
|
431
|
-
*/
|
|
432
|
-
export interface InitResult {
|
|
433
|
-
success: boolean;
|
|
434
|
-
platform: PlatformInfo;
|
|
435
|
-
created: {
|
|
436
|
-
directories: string[];
|
|
437
|
-
files: string[];
|
|
438
|
-
};
|
|
439
|
-
skipped: string[];
|
|
440
|
-
errors: string[];
|
|
441
|
-
summary: {
|
|
442
|
-
skillsCount: number;
|
|
443
|
-
commandsCount: number;
|
|
444
|
-
agentsCount: number;
|
|
445
|
-
hooksEnabled: number;
|
|
446
|
-
};
|
|
447
|
-
}
|
package/src/mcp-client.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V3 CLI MCP Client
|
|
3
|
-
*
|
|
4
|
-
* Thin wrapper for calling MCP tools from CLI commands.
|
|
5
|
-
* Implements ADR-005: MCP-First API Design - CLI as thin wrapper around MCP tools
|
|
6
|
-
*
|
|
7
|
-
* This provides a simple interface for CLI commands to call MCP tools without
|
|
8
|
-
* containing hardcoded business logic. All business logic lives in MCP tool handlers.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { MCPTool } from './mcp-tools/types.js';
|
|
12
|
-
|
|
13
|
-
// Import MCP tool handlers from local package
|
|
14
|
-
import { agentTools } from './mcp-tools/agent-tools.js';
|
|
15
|
-
import { swarmTools } from './mcp-tools/swarm-tools.js';
|
|
16
|
-
import { memoryTools } from './mcp-tools/memory-tools.js';
|
|
17
|
-
import { configTools } from './mcp-tools/config-tools.js';
|
|
18
|
-
import { hooksTools } from './mcp-tools/hooks-tools.js';
|
|
19
|
-
import { taskTools } from './mcp-tools/task-tools.js';
|
|
20
|
-
import { sessionTools } from './mcp-tools/session-tools.js';
|
|
21
|
-
import { hiveMindTools } from './mcp-tools/hive-mind-tools.js';
|
|
22
|
-
import { workflowTools } from './mcp-tools/workflow-tools.js';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* MCP Tool Registry
|
|
26
|
-
* Maps tool names to their handler functions
|
|
27
|
-
*/
|
|
28
|
-
const TOOL_REGISTRY = new Map<string, MCPTool>();
|
|
29
|
-
|
|
30
|
-
// Register all tools
|
|
31
|
-
function registerTools(tools: MCPTool[]): void {
|
|
32
|
-
tools.forEach(tool => {
|
|
33
|
-
TOOL_REGISTRY.set(tool.name, tool);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Initialize registry with all available tools
|
|
38
|
-
registerTools([
|
|
39
|
-
...agentTools,
|
|
40
|
-
...swarmTools,
|
|
41
|
-
...memoryTools,
|
|
42
|
-
...configTools,
|
|
43
|
-
...hooksTools,
|
|
44
|
-
...taskTools,
|
|
45
|
-
...sessionTools,
|
|
46
|
-
...hiveMindTools,
|
|
47
|
-
...workflowTools,
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* MCP Client Error
|
|
52
|
-
*/
|
|
53
|
-
export class MCPClientError extends Error {
|
|
54
|
-
constructor(
|
|
55
|
-
message: string,
|
|
56
|
-
public toolName: string,
|
|
57
|
-
public cause?: Error
|
|
58
|
-
) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = 'MCPClientError';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Call an MCP tool by name with input parameters
|
|
66
|
-
*
|
|
67
|
-
* @param toolName - Name of the MCP tool (e.g., 'agent/spawn', 'swarm/init')
|
|
68
|
-
* @param input - Input parameters for the tool
|
|
69
|
-
* @param context - Optional tool context
|
|
70
|
-
* @returns Promise resolving to tool result
|
|
71
|
-
* @throws {MCPClientError} If tool not found or execution fails
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* // Spawn an agent
|
|
76
|
-
* const result = await callMCPTool('agent/spawn', {
|
|
77
|
-
* agentType: 'coder',
|
|
78
|
-
* priority: 'normal'
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* // Initialize swarm
|
|
82
|
-
* const swarm = await callMCPTool('swarm/init', {
|
|
83
|
-
* topology: 'hierarchical-mesh',
|
|
84
|
-
* maxAgents: 15
|
|
85
|
-
* });
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export async function callMCPTool<T = unknown>(
|
|
89
|
-
toolName: string,
|
|
90
|
-
input: Record<string, unknown> = {},
|
|
91
|
-
context?: Record<string, unknown>
|
|
92
|
-
): Promise<T> {
|
|
93
|
-
// Look up tool in registry
|
|
94
|
-
const tool = TOOL_REGISTRY.get(toolName);
|
|
95
|
-
|
|
96
|
-
if (!tool) {
|
|
97
|
-
throw new MCPClientError(
|
|
98
|
-
`MCP tool not found: ${toolName}`,
|
|
99
|
-
toolName
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
// Call the tool handler
|
|
105
|
-
const result = await tool.handler(input, context);
|
|
106
|
-
return result as T;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
// Wrap and re-throw with context
|
|
109
|
-
throw new MCPClientError(
|
|
110
|
-
`Failed to execute MCP tool '${toolName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
-
toolName,
|
|
112
|
-
error instanceof Error ? error : undefined
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get tool metadata by name
|
|
119
|
-
*
|
|
120
|
-
* @param toolName - Name of the MCP tool
|
|
121
|
-
* @returns Tool metadata or undefined if not found
|
|
122
|
-
*/
|
|
123
|
-
export function getToolMetadata(toolName: string): Omit<MCPTool, 'handler'> | undefined {
|
|
124
|
-
const tool = TOOL_REGISTRY.get(toolName);
|
|
125
|
-
|
|
126
|
-
if (!tool) {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Return everything except the handler function
|
|
131
|
-
return {
|
|
132
|
-
name: tool.name,
|
|
133
|
-
description: tool.description,
|
|
134
|
-
inputSchema: tool.inputSchema,
|
|
135
|
-
category: tool.category,
|
|
136
|
-
tags: tool.tags,
|
|
137
|
-
version: tool.version,
|
|
138
|
-
cacheable: tool.cacheable,
|
|
139
|
-
cacheTTL: tool.cacheTTL,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* List all available MCP tools
|
|
145
|
-
*
|
|
146
|
-
* @param category - Optional category filter
|
|
147
|
-
* @returns Array of tool metadata
|
|
148
|
-
*/
|
|
149
|
-
export function listMCPTools(category?: string): Array<Omit<MCPTool, 'handler'>> {
|
|
150
|
-
const tools = Array.from(TOOL_REGISTRY.values());
|
|
151
|
-
|
|
152
|
-
const filtered = category
|
|
153
|
-
? tools.filter(t => t.category === category)
|
|
154
|
-
: tools;
|
|
155
|
-
|
|
156
|
-
return filtered.map(tool => ({
|
|
157
|
-
name: tool.name,
|
|
158
|
-
description: tool.description,
|
|
159
|
-
inputSchema: tool.inputSchema,
|
|
160
|
-
category: tool.category,
|
|
161
|
-
tags: tool.tags,
|
|
162
|
-
version: tool.version,
|
|
163
|
-
cacheable: tool.cacheable,
|
|
164
|
-
cacheTTL: tool.cacheTTL,
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Check if an MCP tool exists
|
|
170
|
-
*
|
|
171
|
-
* @param toolName - Name of the MCP tool
|
|
172
|
-
* @returns True if tool exists
|
|
173
|
-
*/
|
|
174
|
-
export function hasTool(toolName: string): boolean {
|
|
175
|
-
return TOOL_REGISTRY.has(toolName);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Get all tool categories
|
|
180
|
-
*
|
|
181
|
-
* @returns Array of unique categories
|
|
182
|
-
*/
|
|
183
|
-
export function getToolCategories(): string[] {
|
|
184
|
-
const categories = new Set<string>();
|
|
185
|
-
|
|
186
|
-
TOOL_REGISTRY.forEach(tool => {
|
|
187
|
-
if (tool.category) {
|
|
188
|
-
categories.add(tool.category);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
return Array.from(categories).sort();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Validate tool input against schema
|
|
197
|
-
*
|
|
198
|
-
* @param toolName - Name of the MCP tool
|
|
199
|
-
* @param input - Input to validate
|
|
200
|
-
* @returns Validation result with errors if any
|
|
201
|
-
*/
|
|
202
|
-
export function validateToolInput(
|
|
203
|
-
toolName: string,
|
|
204
|
-
input: Record<string, unknown>
|
|
205
|
-
): { valid: boolean; errors?: string[] } {
|
|
206
|
-
const tool = TOOL_REGISTRY.get(toolName);
|
|
207
|
-
|
|
208
|
-
if (!tool) {
|
|
209
|
-
return {
|
|
210
|
-
valid: false,
|
|
211
|
-
errors: [`Tool '${toolName}' not found`],
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Basic validation - check required fields
|
|
216
|
-
const schema = tool.inputSchema;
|
|
217
|
-
const errors: string[] = [];
|
|
218
|
-
|
|
219
|
-
if (schema.required && Array.isArray(schema.required)) {
|
|
220
|
-
for (const requiredField of schema.required) {
|
|
221
|
-
if (!(requiredField in input)) {
|
|
222
|
-
errors.push(`Missing required field: ${requiredField}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
valid: errors.length === 0,
|
|
229
|
-
errors: errors.length > 0 ? errors : undefined,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export default {
|
|
234
|
-
callMCPTool,
|
|
235
|
-
getToolMetadata,
|
|
236
|
-
listMCPTools,
|
|
237
|
-
hasTool,
|
|
238
|
-
getToolCategories,
|
|
239
|
-
validateToolInput,
|
|
240
|
-
MCPClientError,
|
|
241
|
-
};
|