@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.6

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 (86) hide show
  1. package/.agentic-flow/intelligence.json +4 -3
  2. package/.claude-flow/metrics/performance.json +3 -3
  3. package/.claude-flow/metrics/task-metrics.json +3 -3
  4. package/agents/architect.yaml +11 -0
  5. package/agents/coder.yaml +11 -0
  6. package/agents/reviewer.yaml +10 -0
  7. package/agents/security-architect.yaml +10 -0
  8. package/agents/tester.yaml +10 -0
  9. package/bin/cli.js +0 -0
  10. package/dist/src/commands/agent.js +1 -1
  11. package/dist/src/commands/agent.js.map +1 -1
  12. package/dist/src/commands/config.js +2 -2
  13. package/dist/src/commands/config.js.map +1 -1
  14. package/dist/src/commands/hooks.js +1 -1
  15. package/dist/src/commands/hooks.js.map +1 -1
  16. package/dist/src/commands/mcp.js +1 -1
  17. package/dist/src/commands/mcp.js.map +1 -1
  18. package/dist/src/commands/memory.d.ts.map +1 -1
  19. package/dist/src/commands/memory.js +234 -168
  20. package/dist/src/commands/memory.js.map +1 -1
  21. package/dist/src/commands/migrate.js +1 -1
  22. package/dist/src/commands/migrate.js.map +1 -1
  23. package/dist/src/commands/process.d.ts.map +1 -1
  24. package/dist/src/commands/process.js +95 -20
  25. package/dist/src/commands/process.js.map +1 -1
  26. package/dist/src/commands/status.d.ts.map +1 -1
  27. package/dist/src/commands/status.js +26 -2
  28. package/dist/src/commands/status.js.map +1 -1
  29. package/dist/src/commands/swarm.js +6 -6
  30. package/dist/src/commands/swarm.js.map +1 -1
  31. package/dist/src/index.d.ts +1 -1
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +18 -1
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/init/executor.d.ts.map +1 -1
  36. package/dist/src/init/executor.js +5 -0
  37. package/dist/src/init/executor.js.map +1 -1
  38. package/dist/src/mcp-client.d.ts.map +1 -1
  39. package/dist/src/mcp-client.js +3 -1
  40. package/dist/src/mcp-client.js.map +1 -1
  41. package/dist/src/mcp-server.d.ts.map +1 -1
  42. package/dist/src/mcp-server.js +5 -0
  43. package/dist/src/mcp-server.js.map +1 -1
  44. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  45. package/dist/src/mcp-tools/hooks-tools.js +34 -8
  46. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  47. package/dist/src/mcp-tools/index.d.ts +2 -0
  48. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  49. package/dist/src/mcp-tools/index.js +2 -0
  50. package/dist/src/mcp-tools/index.js.map +1 -1
  51. package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
  52. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  53. package/dist/src/mcp-tools/memory-tools.js +157 -9
  54. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  55. package/dist/src/mcp-tools/session-tools.d.ts +8 -0
  56. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
  57. package/dist/src/mcp-tools/session-tools.js +100 -0
  58. package/dist/src/mcp-tools/session-tools.js.map +1 -0
  59. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  60. package/dist/src/mcp-tools/swarm-tools.js +37 -2
  61. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  62. package/dist/src/mcp-tools/task-tools.d.ts +8 -0
  63. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
  64. package/dist/src/mcp-tools/task-tools.js +100 -0
  65. package/dist/src/mcp-tools/task-tools.js.map +1 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +1 -1
  68. package/src/commands/agent.ts +1 -1
  69. package/src/commands/config.ts +2 -2
  70. package/src/commands/hooks.ts +1 -1
  71. package/src/commands/mcp.ts +1 -1
  72. package/src/commands/memory.ts +279 -181
  73. package/src/commands/migrate.ts +1 -1
  74. package/src/commands/process.ts +98 -20
  75. package/src/commands/status.ts +33 -2
  76. package/src/commands/swarm.ts +6 -6
  77. package/src/index.ts +18 -1
  78. package/src/init/executor.ts +6 -0
  79. package/src/mcp-client.ts +3 -1
  80. package/src/mcp-server.ts +6 -0
  81. package/src/mcp-tools/hooks-tools.ts +38 -8
  82. package/src/mcp-tools/index.ts +2 -0
  83. package/src/mcp-tools/memory-tools.ts +190 -9
  84. package/src/mcp-tools/session-tools.ts +102 -0
  85. package/src/mcp-tools/swarm-tools.ts +38 -2
  86. package/src/mcp-tools/task-tools.ts +102 -0
@@ -1,15 +1,64 @@
1
1
  /**
2
2
  * Memory MCP Tools for CLI
3
3
  *
4
- * Tool definitions for memory management.
4
+ * Tool definitions for memory management with file-based persistence.
5
5
  */
6
6
 
7
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
8
+ import { join, resolve } from 'path';
7
9
  import type { MCPTool } from './types.js';
8
10
 
11
+ // Simple file-based memory store
12
+ interface MemoryEntry {
13
+ key: string;
14
+ value: unknown;
15
+ metadata?: Record<string, unknown>;
16
+ storedAt: string;
17
+ accessCount: number;
18
+ lastAccessed: string;
19
+ }
20
+
21
+ interface MemoryStore {
22
+ entries: Record<string, MemoryEntry>;
23
+ version: string;
24
+ }
25
+
26
+ const MEMORY_DIR = '.claude-flow/memory';
27
+ const MEMORY_FILE = 'store.json';
28
+
29
+ function getMemoryPath(): string {
30
+ return resolve(join(MEMORY_DIR, MEMORY_FILE));
31
+ }
32
+
33
+ function ensureMemoryDir(): void {
34
+ const dir = resolve(MEMORY_DIR);
35
+ if (!existsSync(dir)) {
36
+ mkdirSync(dir, { recursive: true });
37
+ }
38
+ }
39
+
40
+ function loadMemoryStore(): MemoryStore {
41
+ try {
42
+ const path = getMemoryPath();
43
+ if (existsSync(path)) {
44
+ const data = readFileSync(path, 'utf-8');
45
+ return JSON.parse(data);
46
+ }
47
+ } catch {
48
+ // Return empty store on error
49
+ }
50
+ return { entries: {}, version: '3.0.0' };
51
+ }
52
+
53
+ function saveMemoryStore(store: MemoryStore): void {
54
+ ensureMemoryDir();
55
+ writeFileSync(getMemoryPath(), JSON.stringify(store, null, 2), 'utf-8');
56
+ }
57
+
9
58
  export const memoryTools: MCPTool[] = [
10
59
  {
11
60
  name: 'memory/store',
12
- description: 'Store a value in memory',
61
+ description: 'Store a value in memory (persisted to disk)',
13
62
  category: 'memory',
14
63
  inputSchema: {
15
64
  type: 'object',
@@ -21,10 +70,27 @@ export const memoryTools: MCPTool[] = [
21
70
  required: ['key', 'value'],
22
71
  },
23
72
  handler: async (input) => {
73
+ const store = loadMemoryStore();
74
+ const now = new Date().toISOString();
75
+
76
+ const entry: MemoryEntry = {
77
+ key: input.key as string,
78
+ value: input.value,
79
+ metadata: (input.metadata as Record<string, unknown>) || {},
80
+ storedAt: now,
81
+ accessCount: 0,
82
+ lastAccessed: now,
83
+ };
84
+
85
+ store.entries[input.key as string] = entry;
86
+ saveMemoryStore(store);
87
+
24
88
  return {
25
89
  success: true,
26
90
  key: input.key,
27
91
  stored: true,
92
+ storedAt: now,
93
+ totalEntries: Object.keys(store.entries).length,
28
94
  };
29
95
  },
30
96
  },
@@ -40,8 +106,28 @@ export const memoryTools: MCPTool[] = [
40
106
  required: ['key'],
41
107
  },
42
108
  handler: async (input) => {
109
+ const store = loadMemoryStore();
110
+ const key = input.key as string;
111
+ const entry = store.entries[key];
112
+
113
+ if (entry) {
114
+ // Update access stats
115
+ entry.accessCount++;
116
+ entry.lastAccessed = new Date().toISOString();
117
+ saveMemoryStore(store);
118
+
119
+ return {
120
+ key,
121
+ value: entry.value,
122
+ metadata: entry.metadata,
123
+ storedAt: entry.storedAt,
124
+ accessCount: entry.accessCount,
125
+ found: true,
126
+ };
127
+ }
128
+
43
129
  return {
44
- key: input.key,
130
+ key,
45
131
  value: null,
46
132
  found: false,
47
133
  };
@@ -49,7 +135,7 @@ export const memoryTools: MCPTool[] = [
49
135
  },
50
136
  {
51
137
  name: 'memory/search',
52
- description: 'Search memory',
138
+ description: 'Search memory by keyword',
53
139
  category: 'memory',
54
140
  inputSchema: {
55
141
  type: 'object',
@@ -60,10 +146,33 @@ export const memoryTools: MCPTool[] = [
60
146
  required: ['query'],
61
147
  },
62
148
  handler: async (input) => {
149
+ const store = loadMemoryStore();
150
+ const query = (input.query as string).toLowerCase();
151
+ const limit = (input.limit as number) || 10;
152
+ const startTime = performance.now();
153
+
154
+ const results = Object.values(store.entries)
155
+ .filter(entry => {
156
+ const keyMatch = entry.key.toLowerCase().includes(query);
157
+ const valueStr = typeof entry.value === 'string' ? entry.value.toLowerCase() : JSON.stringify(entry.value).toLowerCase();
158
+ const valueMatch = valueStr.includes(query);
159
+ return keyMatch || valueMatch;
160
+ })
161
+ .slice(0, limit)
162
+ .map(entry => ({
163
+ key: entry.key,
164
+ value: entry.value,
165
+ score: 1.0, // Simple keyword match
166
+ storedAt: entry.storedAt,
167
+ }));
168
+
169
+ const duration = performance.now() - startTime;
170
+
63
171
  return {
64
172
  query: input.query,
65
- results: [],
66
- total: 0,
173
+ results,
174
+ total: results.length,
175
+ searchTime: `${duration.toFixed(2)}ms`,
67
176
  };
68
177
  },
69
178
  },
@@ -79,10 +188,82 @@ export const memoryTools: MCPTool[] = [
79
188
  required: ['key'],
80
189
  },
81
190
  handler: async (input) => {
191
+ const store = loadMemoryStore();
192
+ const key = input.key as string;
193
+ const existed = key in store.entries;
194
+
195
+ if (existed) {
196
+ delete store.entries[key];
197
+ saveMemoryStore(store);
198
+ }
199
+
82
200
  return {
83
- success: true,
84
- key: input.key,
85
- deleted: true,
201
+ success: existed,
202
+ key,
203
+ deleted: existed,
204
+ remainingEntries: Object.keys(store.entries).length,
205
+ };
206
+ },
207
+ },
208
+ {
209
+ name: 'memory/list',
210
+ description: 'List all memory entries',
211
+ category: 'memory',
212
+ inputSchema: {
213
+ type: 'object',
214
+ properties: {
215
+ limit: { type: 'number', description: 'Result limit' },
216
+ offset: { type: 'number', description: 'Result offset' },
217
+ },
218
+ },
219
+ handler: async (input) => {
220
+ const store = loadMemoryStore();
221
+ const limit = (input.limit as number) || 50;
222
+ const offset = (input.offset as number) || 0;
223
+
224
+ const allEntries = Object.values(store.entries);
225
+ const entries = allEntries.slice(offset, offset + limit).map(e => ({
226
+ key: e.key,
227
+ storedAt: e.storedAt,
228
+ accessCount: e.accessCount,
229
+ preview: typeof e.value === 'string'
230
+ ? e.value.substring(0, 50) + (e.value.length > 50 ? '...' : '')
231
+ : JSON.stringify(e.value).substring(0, 50),
232
+ }));
233
+
234
+ return {
235
+ entries,
236
+ total: allEntries.length,
237
+ limit,
238
+ offset,
239
+ };
240
+ },
241
+ },
242
+ {
243
+ name: 'memory/stats',
244
+ description: 'Get memory storage statistics',
245
+ category: 'memory',
246
+ inputSchema: {
247
+ type: 'object',
248
+ properties: {},
249
+ },
250
+ handler: async () => {
251
+ const store = loadMemoryStore();
252
+ const entries = Object.values(store.entries);
253
+ const totalSize = JSON.stringify(store).length;
254
+
255
+ return {
256
+ totalEntries: entries.length,
257
+ totalSize: `${(totalSize / 1024).toFixed(2)} KB`,
258
+ version: store.version,
259
+ backend: 'file',
260
+ location: getMemoryPath(),
261
+ oldestEntry: entries.length > 0
262
+ ? entries.reduce((a, b) => a.storedAt < b.storedAt ? a : b).storedAt
263
+ : null,
264
+ newestEntry: entries.length > 0
265
+ ? entries.reduce((a, b) => a.storedAt > b.storedAt ? a : b).storedAt
266
+ : null,
86
267
  };
87
268
  },
88
269
  },
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Session MCP Tools for CLI
3
+ *
4
+ * Tool definitions for session management.
5
+ */
6
+
7
+ import type { MCPTool } from './types.js';
8
+
9
+ export const sessionTools: MCPTool[] = [
10
+ {
11
+ name: 'session/save',
12
+ description: 'Save current session state',
13
+ category: 'session',
14
+ inputSchema: {
15
+ type: 'object',
16
+ properties: {
17
+ name: { type: 'string', description: 'Session name' },
18
+ description: { type: 'string', description: 'Session description' },
19
+ includeMemory: { type: 'boolean', description: 'Include memory in session' },
20
+ includeTasks: { type: 'boolean', description: 'Include tasks in session' },
21
+ includeAgents: { type: 'boolean', description: 'Include agents in session' },
22
+ },
23
+ required: ['name'],
24
+ },
25
+ handler: async (input) => {
26
+ const sessionId = `session-${Date.now()}`;
27
+ return {
28
+ sessionId,
29
+ name: input.name,
30
+ savedAt: new Date().toISOString(),
31
+ stats: {
32
+ tasks: 0,
33
+ agents: 0,
34
+ memoryEntries: 0,
35
+ totalSize: 0,
36
+ },
37
+ };
38
+ },
39
+ },
40
+ {
41
+ name: 'session/restore',
42
+ description: 'Restore a saved session',
43
+ category: 'session',
44
+ inputSchema: {
45
+ type: 'object',
46
+ properties: {
47
+ sessionId: { type: 'string', description: 'Session ID to restore' },
48
+ name: { type: 'string', description: 'Session name to restore' },
49
+ },
50
+ },
51
+ handler: async (input) => {
52
+ return {
53
+ sessionId: input.sessionId || input.name || 'latest',
54
+ restored: true,
55
+ restoredAt: new Date().toISOString(),
56
+ stats: {
57
+ tasks: 0,
58
+ agents: 0,
59
+ memoryEntries: 0,
60
+ },
61
+ };
62
+ },
63
+ },
64
+ {
65
+ name: 'session/list',
66
+ description: 'List saved sessions',
67
+ category: 'session',
68
+ inputSchema: {
69
+ type: 'object',
70
+ properties: {
71
+ limit: { type: 'number', description: 'Maximum sessions to return' },
72
+ sortBy: { type: 'string', description: 'Sort field (date, name, size)' },
73
+ },
74
+ },
75
+ handler: async (input) => {
76
+ return {
77
+ sessions: [],
78
+ total: 0,
79
+ limit: (input.limit as number) || 10,
80
+ };
81
+ },
82
+ },
83
+ {
84
+ name: 'session/delete',
85
+ description: 'Delete a saved session',
86
+ category: 'session',
87
+ inputSchema: {
88
+ type: 'object',
89
+ properties: {
90
+ sessionId: { type: 'string', description: 'Session ID to delete' },
91
+ },
92
+ required: ['sessionId'],
93
+ },
94
+ handler: async (input) => {
95
+ return {
96
+ sessionId: input.sessionId,
97
+ deleted: true,
98
+ deletedAt: new Date().toISOString(),
99
+ };
100
+ },
101
+ },
102
+ ];
@@ -20,11 +20,23 @@ export const swarmTools: MCPTool[] = [
20
20
  },
21
21
  },
22
22
  handler: async (input) => {
23
+ const topology = input.topology || 'hierarchical-mesh';
24
+ const maxAgents = input.maxAgents || 15;
25
+ const config = (input.config || {}) as Record<string, unknown>;
26
+
23
27
  return {
24
28
  success: true,
25
29
  swarmId: `swarm-${Date.now()}`,
26
- topology: input.topology || 'hierarchical-mesh',
27
- maxAgents: input.maxAgents || 15,
30
+ topology,
31
+ initializedAt: new Date().toISOString(),
32
+ config: {
33
+ topology,
34
+ maxAgents,
35
+ currentAgents: 0,
36
+ communicationProtocol: (config.communicationProtocol as string) || 'message-bus',
37
+ autoScaling: (config.autoScaling as boolean) ?? true,
38
+ consensusMechanism: (config.consensusMechanism as string) || 'majority',
39
+ },
28
40
  };
29
41
  },
30
42
  },
@@ -66,4 +78,28 @@ export const swarmTools: MCPTool[] = [
66
78
  };
67
79
  },
68
80
  },
81
+ {
82
+ name: 'swarm/health',
83
+ description: 'Check swarm health status',
84
+ category: 'swarm',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {
88
+ swarmId: { type: 'string', description: 'Swarm ID to check' },
89
+ },
90
+ },
91
+ handler: async (input) => {
92
+ return {
93
+ status: 'healthy' as const,
94
+ swarmId: input.swarmId || 'default',
95
+ checks: [
96
+ { name: 'coordinator', status: 'ok', message: 'Coordinator responding' },
97
+ { name: 'agents', status: 'ok', message: 'Agent pool healthy' },
98
+ { name: 'memory', status: 'ok', message: 'Memory backend connected' },
99
+ { name: 'messaging', status: 'ok', message: 'Message bus active' },
100
+ ],
101
+ checkedAt: new Date().toISOString(),
102
+ };
103
+ },
104
+ },
69
105
  ];
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Task MCP Tools for CLI
3
+ *
4
+ * Tool definitions for task management.
5
+ */
6
+
7
+ import type { MCPTool } from './types.js';
8
+
9
+ export const taskTools: MCPTool[] = [
10
+ {
11
+ name: 'task/create',
12
+ description: 'Create a new task',
13
+ category: 'task',
14
+ inputSchema: {
15
+ type: 'object',
16
+ properties: {
17
+ type: { type: 'string', description: 'Task type (feature, bugfix, research, refactor)' },
18
+ description: { type: 'string', description: 'Task description' },
19
+ priority: { type: 'string', description: 'Task priority (low, normal, high, critical)' },
20
+ assignTo: { type: 'array', items: { type: 'string' }, description: 'Agent IDs to assign' },
21
+ tags: { type: 'array', items: { type: 'string' }, description: 'Task tags' },
22
+ },
23
+ required: ['type', 'description'],
24
+ },
25
+ handler: async (input) => {
26
+ const taskId = `task-${Date.now()}`;
27
+ return {
28
+ taskId,
29
+ type: input.type,
30
+ description: input.description,
31
+ priority: (input.priority as string) || 'normal',
32
+ status: 'pending',
33
+ createdAt: new Date().toISOString(),
34
+ assignedTo: (input.assignTo as string[]) || [],
35
+ tags: (input.tags as string[]) || [],
36
+ };
37
+ },
38
+ },
39
+ {
40
+ name: 'task/status',
41
+ description: 'Get task status',
42
+ category: 'task',
43
+ inputSchema: {
44
+ type: 'object',
45
+ properties: {
46
+ taskId: { type: 'string', description: 'Task ID' },
47
+ },
48
+ required: ['taskId'],
49
+ },
50
+ handler: async (input) => {
51
+ return {
52
+ taskId: input.taskId,
53
+ status: 'pending',
54
+ progress: 0,
55
+ assignedTo: [],
56
+ startedAt: null,
57
+ completedAt: null,
58
+ };
59
+ },
60
+ },
61
+ {
62
+ name: 'task/list',
63
+ description: 'List all tasks',
64
+ category: 'task',
65
+ inputSchema: {
66
+ type: 'object',
67
+ properties: {
68
+ status: { type: 'string', description: 'Filter by status' },
69
+ type: { type: 'string', description: 'Filter by type' },
70
+ assignedTo: { type: 'string', description: 'Filter by assigned agent' },
71
+ },
72
+ },
73
+ handler: async (input) => {
74
+ return {
75
+ tasks: [],
76
+ total: 0,
77
+ filters: input,
78
+ };
79
+ },
80
+ },
81
+ {
82
+ name: 'task/complete',
83
+ description: 'Mark task as complete',
84
+ category: 'task',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {
88
+ taskId: { type: 'string', description: 'Task ID' },
89
+ result: { type: 'object', description: 'Task result data' },
90
+ },
91
+ required: ['taskId'],
92
+ },
93
+ handler: async (input) => {
94
+ return {
95
+ taskId: input.taskId,
96
+ status: 'completed',
97
+ completedAt: new Date().toISOString(),
98
+ result: input.result || {},
99
+ };
100
+ },
101
+ },
102
+ ];