@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.
Files changed (106) hide show
  1. package/dist/src/commands/doctor.d.ts.map +1 -1
  2. package/dist/src/commands/doctor.js +75 -2
  3. package/dist/src/commands/doctor.js.map +1 -1
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +12 -4
  6. package/.agentic-flow/intelligence.json +0 -17
  7. package/.claude-flow/agents/store.json +0 -16
  8. package/.claude-flow/daemon-state.json +0 -123
  9. package/.claude-flow/daemon-test.log +0 -0
  10. package/.claude-flow/daemon.log +0 -0
  11. package/.claude-flow/daemon2.log +0 -0
  12. package/.claude-flow/daemon3.log +0 -0
  13. package/.claude-flow/hive-mind/state.json +0 -51
  14. package/.claude-flow/metrics/agent-metrics.json +0 -1
  15. package/.claude-flow/metrics/codebase-map.json +0 -11
  16. package/.claude-flow/metrics/consolidation.json +0 -6
  17. package/.claude-flow/metrics/performance.json +0 -87
  18. package/.claude-flow/metrics/security-audit.json +0 -10
  19. package/.claude-flow/metrics/task-metrics.json +0 -10
  20. package/.claude-flow/metrics/test-gaps.json +0 -6
  21. package/__tests__/README.md +0 -140
  22. package/__tests__/TEST_SUMMARY.md +0 -144
  23. package/__tests__/cli.test.ts +0 -558
  24. package/__tests__/commands.test.ts +0 -726
  25. package/__tests__/config-adapter.test.ts +0 -362
  26. package/__tests__/config-loading.test.ts +0 -106
  27. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  29. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  30. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  31. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  32. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  33. package/__tests__/mcp-client.test.ts +0 -480
  34. package/__tests__/p1-commands.test.ts +0 -1064
  35. package/agents/architect.yaml +0 -11
  36. package/agents/coder.yaml +0 -11
  37. package/agents/reviewer.yaml +0 -10
  38. package/agents/security-architect.yaml +0 -10
  39. package/agents/tester.yaml +0 -10
  40. package/docs/CONFIG_LOADING.md +0 -236
  41. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  42. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  43. package/docs/REFACTORING_SUMMARY.md +0 -247
  44. package/scripts/publish.sh +0 -46
  45. package/src/commands/agent.ts +0 -955
  46. package/src/commands/claims.ts +0 -317
  47. package/src/commands/completions.ts +0 -558
  48. package/src/commands/config.ts +0 -452
  49. package/src/commands/daemon.ts +0 -621
  50. package/src/commands/deployment.ts +0 -323
  51. package/src/commands/doctor.ts +0 -382
  52. package/src/commands/embeddings.ts +0 -686
  53. package/src/commands/hive-mind.ts +0 -928
  54. package/src/commands/hooks.ts +0 -2603
  55. package/src/commands/index.ts +0 -154
  56. package/src/commands/init.ts +0 -597
  57. package/src/commands/mcp.ts +0 -753
  58. package/src/commands/memory.ts +0 -1161
  59. package/src/commands/migrate.ts +0 -447
  60. package/src/commands/neural.ts +0 -253
  61. package/src/commands/performance.ts +0 -292
  62. package/src/commands/plugins.ts +0 -316
  63. package/src/commands/process.ts +0 -695
  64. package/src/commands/providers.ts +0 -259
  65. package/src/commands/security.ts +0 -288
  66. package/src/commands/session.ts +0 -891
  67. package/src/commands/start.ts +0 -457
  68. package/src/commands/status.ts +0 -736
  69. package/src/commands/swarm.ts +0 -648
  70. package/src/commands/task.ts +0 -792
  71. package/src/commands/workflow.ts +0 -742
  72. package/src/config-adapter.ts +0 -210
  73. package/src/index.ts +0 -443
  74. package/src/infrastructure/in-memory-repositories.ts +0 -310
  75. package/src/init/claudemd-generator.ts +0 -631
  76. package/src/init/executor.ts +0 -762
  77. package/src/init/helpers-generator.ts +0 -628
  78. package/src/init/index.ts +0 -60
  79. package/src/init/mcp-generator.ts +0 -83
  80. package/src/init/settings-generator.ts +0 -284
  81. package/src/init/statusline-generator.ts +0 -211
  82. package/src/init/types.ts +0 -447
  83. package/src/mcp-client.ts +0 -241
  84. package/src/mcp-server.ts +0 -577
  85. package/src/mcp-tools/agent-tools.ts +0 -466
  86. package/src/mcp-tools/config-tools.ts +0 -370
  87. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  88. package/src/mcp-tools/hooks-tools.ts +0 -1888
  89. package/src/mcp-tools/index.ts +0 -16
  90. package/src/mcp-tools/memory-tools.ts +0 -270
  91. package/src/mcp-tools/session-tools.ts +0 -359
  92. package/src/mcp-tools/swarm-tools.ts +0 -105
  93. package/src/mcp-tools/task-tools.ts +0 -347
  94. package/src/mcp-tools/types.ts +0 -33
  95. package/src/mcp-tools/workflow-tools.ts +0 -573
  96. package/src/output.ts +0 -639
  97. package/src/parser.ts +0 -417
  98. package/src/prompt.ts +0 -619
  99. package/src/services/index.ts +0 -15
  100. package/src/services/worker-daemon.ts +0 -726
  101. package/src/suggest.ts +0 -245
  102. package/src/types.ts +0 -287
  103. package/tmp.json +0 -0
  104. package/tsconfig.json +0 -16
  105. package/tsconfig.tsbuildinfo +0 -1
  106. package/vitest.config.ts +0 -13
@@ -1,247 +0,0 @@
1
- # CLI Commands Refactoring Summary
2
-
3
- ## ADR-005 Implementation: MCP-First API Design
4
-
5
- This document summarizes the refactoring of CLI commands to use MCP tools instead of hardcoded business logic.
6
-
7
- ## Key Changes
8
-
9
- ### 1. Created MCP Client Helper (`/workspaces/claude-flow/v3/@claude-flow/cli/src/mcp-client.ts`)
10
-
11
- **Purpose**: Thin wrapper for calling MCP tools from CLI commands
12
-
13
- **Key Functions**:
14
- - `callMCPTool<T>(toolName, input, context)` - Call any MCP tool by name
15
- - `getToolMetadata(toolName)` - Get tool schema and metadata
16
- - `listMCPTools(category?)` - List available tools
17
- - `validateToolInput(toolName, input)` - Validate inputs against schema
18
- - `MCPClientError` - Custom error class for MCP tool failures
19
-
20
- **Example Usage**:
21
- ```typescript
22
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
23
-
24
- try {
25
- const result = await callMCPTool('agent/spawn', {
26
- agentType: 'coder',
27
- priority: 'normal'
28
- });
29
- // Handle success
30
- } catch (error) {
31
- if (error instanceof MCPClientError) {
32
- output.printError(`Failed: ${error.message}`);
33
- }
34
- }
35
- ```
36
-
37
- ### 2. Refactoring Pattern
38
-
39
- **Before** (Hardcoded Business Logic):
40
- ```typescript
41
- action: async (ctx: CommandContext): Promise<CommandResult> => {
42
- // Hardcoded agent creation logic
43
- const agentConfig = {
44
- id: `agent-${Date.now()}`,
45
- type: agentType,
46
- name: agentName,
47
- status: 'initializing',
48
- // ...more hardcoded logic
49
- };
50
-
51
- return { success: true, data: agentConfig };
52
- }
53
- ```
54
-
55
- **After** (MCP Tool Call):
56
- ```typescript
57
- action: async (ctx: CommandContext): Promise<CommandResult> => {
58
- try {
59
- // Call MCP tool - business logic lives in tool handler
60
- const result = await callMCPTool('agent/spawn', {
61
- agentType,
62
- id: agentName,
63
- config: { ... },
64
- priority: 'normal'
65
- });
66
-
67
- // Only display formatting logic remains in CLI
68
- output.printTable(/* format result */);
69
- return { success: true, data: result };
70
- } catch (error) {
71
- if (error instanceof MCPClientError) {
72
- output.printError(`Failed: ${error.message}`);
73
- }
74
- return { success: false, exitCode: 1 };
75
- }
76
- }
77
- ```
78
-
79
- ### 3. Refactored Commands
80
-
81
- #### ✅ Agent Commands (`/workspaces/claude-flow/v3/@claude-flow/cli/src/commands/agent.ts`)
82
-
83
- | Command | MCP Tool | Status |
84
- |---------|----------|--------|
85
- | `agent spawn` | `agent/spawn` | ✅ Refactored |
86
- | `agent list` | `agent/list` | ✅ Refactored |
87
- | `agent status` | `agent/status` | ✅ Refactored |
88
- | `agent stop` | `agent/terminate` | ✅ Refactored |
89
- | `agent metrics` | (Display only - uses agent/list) | ⚠️ Stub |
90
-
91
- #### 🔄 Swarm Commands (`/workspaces/claude-flow/v3/@claude-flow/cli/src/commands/swarm.ts`)
92
-
93
- | Command | MCP Tool | Status |
94
- |---------|----------|--------|
95
- | `swarm init` | `swarm/init` | ✅ Refactored |
96
- | `swarm start` | (Composite - spawns agents) | ⏳ Partial |
97
- | `swarm status` | `swarm/status` | ⏳ TODO |
98
- | `swarm stop` | (Uses agent/terminate) | ⏳ TODO |
99
- | `swarm scale` | `swarm/scale` | ⏳ TODO |
100
- | `swarm coordinate` | (Display only - shows V3 agents) | ⚠️ Stub |
101
-
102
- #### ⏳ Memory Commands (`/workspaces/claude-flow/v3/@claude-flow/cli/src/commands/memory.ts`)
103
-
104
- | Command | MCP Tool | Status |
105
- |---------|----------|--------|
106
- | `memory store` | `memory/store` | ⏳ TODO |
107
- | `memory retrieve` | (Uses memory/search) | ⏳ TODO |
108
- | `memory search` | `memory/search` | ⏳ TODO |
109
- | `memory list` | `memory/list` | ⏳ TODO |
110
- | `memory delete` | (Not implemented in MCP yet) | ⏳ TODO |
111
- | `memory stats` | (Aggregate of memory/list) | ⏳ TODO |
112
- | `memory configure` | (Uses config/save) | ⏳ TODO |
113
-
114
- #### ⏳ Config Commands (`/workspaces/claude-flow/v3/@claude-flow/cli/src/commands/config.ts`)
115
-
116
- | Command | MCP Tool | Status |
117
- |---------|----------|--------|
118
- | `config init` | `config/save` | ⏳ TODO |
119
- | `config get` | `config/load` | ⏳ TODO |
120
- | `config set` | `config/save` | ⏳ TODO |
121
- | `config providers` | `config/load` + formatting | ⏳ TODO |
122
- | `config reset` | `config/save` | ⏳ TODO |
123
- | `config export` | `config/load` | ⏳ TODO |
124
- | `config import` | `config/save` | ⏳ TODO |
125
-
126
- ### 4. Benefits of Refactoring
127
-
128
- 1. **Separation of Concerns**: CLI only handles user interaction & display, MCP tools handle business logic
129
- 2. **Testability**: MCP tools can be tested independently of CLI
130
- 3. **Consistency**: Same business logic whether called from CLI, API, or other interfaces
131
- 4. **Maintainability**: Single source of truth for operations
132
- 5. **Extensibility**: Easy to add new commands by calling existing MCP tools
133
-
134
- ### 5. File Organization
135
-
136
- ```
137
- v3/@claude-flow/cli/src/
138
- ├── mcp-client.ts # NEW: MCP tool client helper
139
- ├── commands/
140
- │ ├── agent.ts # ✅ Refactored to use MCP tools
141
- │ ├── swarm.ts # 🔄 Partially refactored
142
- │ ├── memory.ts # ⏳ TODO
143
- │ └── config.ts # ⏳ TODO
144
- └── ...
145
-
146
- v3/mcp/tools/
147
- ├── agent-tools.ts # MCP tool implementations
148
- ├── swarm-tools.ts
149
- ├── memory-tools.ts
150
- └── config-tools.ts
151
- ```
152
-
153
- ### 6. Next Steps
154
-
155
- To complete the refactoring:
156
-
157
- 1. **Swarm Commands**: Finish refactoring status, stop, scale commands
158
- 2. **Memory Commands**: Refactor all memory commands to call MCP tools
159
- 3. **Config Commands**: Refactor all config commands to call MCP tools
160
- 4. **Testing**: Add integration tests for CLI → MCP tool flow
161
- 5. **Documentation**: Update user documentation with new patterns
162
-
163
- ### 7. Example: Complete Refactored Command
164
-
165
- ```typescript
166
- // /workspaces/claude-flow/v3/@claude-flow/cli/src/commands/agent.ts
167
-
168
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
169
-
170
- const spawnCommand: Command = {
171
- name: 'spawn',
172
- description: 'Spawn a new agent',
173
- options: [...],
174
- action: async (ctx: CommandContext): Promise<CommandResult> => {
175
- // 1. Gather input (interactive prompts if needed)
176
- let agentType = ctx.flags.type as string;
177
- if (!agentType && ctx.interactive) {
178
- agentType = await select({
179
- message: 'Select agent type:',
180
- options: AGENT_TYPES
181
- });
182
- }
183
-
184
- // 2. Validate required inputs
185
- if (!agentType) {
186
- output.printError('Agent type is required');
187
- return { success: false, exitCode: 1 };
188
- }
189
-
190
- // 3. Call MCP tool (business logic)
191
- try {
192
- const result = await callMCPTool('agent/spawn', {
193
- agentType,
194
- config: { /* from flags */ },
195
- priority: 'normal'
196
- });
197
-
198
- // 4. Format and display output
199
- output.printTable({
200
- data: [
201
- { property: 'ID', value: result.agentId },
202
- { property: 'Type', value: result.agentType },
203
- { property: 'Status', value: result.status }
204
- ]
205
- });
206
-
207
- output.printSuccess('Agent spawned successfully');
208
-
209
- if (ctx.flags.format === 'json') {
210
- output.printJson(result);
211
- }
212
-
213
- return { success: true, data: result };
214
- } catch (error) {
215
- // 5. Handle errors
216
- if (error instanceof MCPClientError) {
217
- output.printError(`Failed to spawn agent: ${error.message}`);
218
- } else {
219
- output.printError(`Unexpected error: ${String(error)}`);
220
- }
221
- return { success: false, exitCode: 1 };
222
- }
223
- }
224
- };
225
- ```
226
-
227
- ### 8. MCP Tool Integration Points
228
-
229
- Each CLI command maps to one or more MCP tools:
230
-
231
- | CLI Pattern | MCP Tools Used | Notes |
232
- |-------------|----------------|-------|
233
- | Simple CRUD | Single tool (e.g., `agent/spawn`) | Direct 1:1 mapping |
234
- | List/Query | Single tool with filters | MCP tool handles filtering |
235
- | Composite | Multiple tools | CLI orchestrates, tools execute |
236
- | Display-only | Query tool + formatting | CLI adds visual enhancements |
237
-
238
- ## Conclusion
239
-
240
- The refactoring successfully implements ADR-005 by making CLI commands thin wrappers around MCP tools. All business logic now resides in MCP tool handlers, with CLI commands responsible only for:
241
- - User interaction (prompts, confirmations)
242
- - Input validation and formatting
243
- - Calling MCP tools
244
- - Output formatting and display
245
- - Error handling and user feedback
246
-
247
- This creates a clean separation of concerns and follows the "CLI as thin wrapper around MCP tools" principle.
@@ -1,46 +0,0 @@
1
- #!/bin/bash
2
- # Publish script for @claude-flow/cli
3
- # Publishes to both @claude-flow/cli@alpha AND claude-flow@v3alpha
4
-
5
- set -e
6
-
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- CLI_DIR="$(dirname "$SCRIPT_DIR")"
9
-
10
- cd "$CLI_DIR"
11
-
12
- # Get current version
13
- VERSION=$(node -p "require('./package.json').version")
14
- echo "Publishing version: $VERSION"
15
-
16
- # 1. Publish @claude-flow/cli with alpha tag
17
- echo ""
18
- echo "=== Publishing @claude-flow/cli@$VERSION (alpha tag) ==="
19
- npm publish --tag alpha
20
-
21
- # 2. Publish to claude-flow with v3alpha tag
22
- echo ""
23
- echo "=== Publishing claude-flow@$VERSION (v3alpha tag) ==="
24
-
25
- # Create temp directory
26
- TEMP_DIR=$(mktemp -d)
27
- trap "rm -rf $TEMP_DIR" EXIT
28
-
29
- # Copy necessary files
30
- cp -r dist bin src package.json README.md "$TEMP_DIR/"
31
-
32
- # Change package name to unscoped
33
- cd "$TEMP_DIR"
34
- sed -i 's/"name": "@claude-flow\/cli"/"name": "claude-flow"/' package.json
35
-
36
- # Publish with v3alpha tag
37
- npm publish --tag v3alpha
38
-
39
- echo ""
40
- echo "=== Published successfully ==="
41
- echo " @claude-flow/cli@$VERSION (alpha)"
42
- echo " claude-flow@$VERSION (v3alpha)"
43
- echo ""
44
- echo "Install with:"
45
- echo " npx @claude-flow/cli@alpha"
46
- echo " npx claude-flow@v3alpha"