@claude-flow/cli 3.0.0-alpha.2 ā 3.0.0-alpha.21
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/README.md +172 -6
- package/bin/cli.js +0 -0
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +43 -27
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.d.ts +19 -0
- package/dist/src/commands/analyze.d.ts.map +1 -0
- package/dist/src/commands/analyze.js +1823 -0
- package/dist/src/commands/analyze.js.map +1 -0
- package/dist/src/commands/claims.d.ts +10 -0
- package/dist/src/commands/claims.d.ts.map +1 -0
- package/dist/src/commands/claims.js +288 -0
- package/dist/src/commands/claims.js.map +1 -0
- package/dist/src/commands/completions.d.ts +10 -0
- package/dist/src/commands/completions.d.ts.map +1 -0
- package/dist/src/commands/completions.js +539 -0
- package/dist/src/commands/completions.js.map +1 -0
- package/dist/src/commands/config.js +2 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts +8 -0
- package/dist/src/commands/daemon.d.ts.map +1 -0
- package/dist/src/commands/daemon.js +545 -0
- package/dist/src/commands/daemon.js.map +1 -0
- package/dist/src/commands/deployment.d.ts +10 -0
- package/dist/src/commands/deployment.d.ts.map +1 -0
- package/dist/src/commands/deployment.js +289 -0
- package/dist/src/commands/deployment.js.map +1 -0
- package/dist/src/commands/doctor.d.ts +10 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +429 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/commands/embeddings.d.ts +18 -0
- package/dist/src/commands/embeddings.d.ts.map +1 -0
- package/dist/src/commands/embeddings.js +616 -0
- package/dist/src/commands/embeddings.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +252 -35
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +326 -2
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +13 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +52 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +4 -4
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +236 -170
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts +10 -0
- package/dist/src/commands/neural.d.ts.map +1 -0
- package/dist/src/commands/neural.js +224 -0
- package/dist/src/commands/neural.js.map +1 -0
- package/dist/src/commands/performance.d.ts +10 -0
- package/dist/src/commands/performance.d.ts.map +1 -0
- package/dist/src/commands/performance.js +262 -0
- package/dist/src/commands/performance.js.map +1 -0
- package/dist/src/commands/plugins.d.ts +10 -0
- package/dist/src/commands/plugins.d.ts.map +1 -0
- package/dist/src/commands/plugins.js +280 -0
- package/dist/src/commands/plugins.js.map +1 -0
- package/dist/src/commands/process.d.ts.map +1 -1
- package/dist/src/commands/process.js +95 -20
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/providers.d.ts +10 -0
- package/dist/src/commands/providers.d.ts.map +1 -0
- package/dist/src/commands/providers.js +232 -0
- package/dist/src/commands/providers.js.map +1 -0
- package/dist/src/commands/route.d.ts +16 -0
- package/dist/src/commands/route.d.ts.map +1 -0
- package/dist/src/commands/route.js +603 -0
- package/dist/src/commands/route.js.map +1 -0
- package/dist/src/commands/security.d.ts +10 -0
- package/dist/src/commands/security.d.ts.map +1 -0
- package/dist/src/commands/security.js +261 -0
- package/dist/src/commands/security.js.map +1 -0
- package/dist/src/commands/start.js +2 -2
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +26 -2
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +6 -6
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +218 -362
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +5 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +22 -12
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +17 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +5 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +350 -14
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +317 -0
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
- package/dist/src/mcp-tools/config-tools.d.ts +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +262 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +80 -15
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +6 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +6 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +157 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/session-tools.js +315 -0
- package/dist/src/mcp-tools/session-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +37 -2
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/task-tools.js +302 -0
- package/dist/src/mcp-tools/task-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.js +481 -0
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
- package/dist/src/output.d.ts +16 -0
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +42 -0
- package/dist/src/output.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +277 -0
- package/dist/src/ruvector/ast-analyzer.js.map +1 -0
- package/dist/src/ruvector/coverage-router.d.ts +145 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +451 -0
- package/dist/src/ruvector/coverage-router.js.map +1 -0
- package/dist/src/ruvector/coverage-tools.d.ts +33 -0
- package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-tools.js +157 -0
- package/dist/src/ruvector/coverage-tools.js.map +1 -0
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +662 -0
- package/dist/src/ruvector/diff-classifier.js.map +1 -0
- package/dist/src/ruvector/graph-analyzer.d.ts +174 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +878 -0
- package/dist/src/ruvector/graph-analyzer.js.map +1 -0
- package/dist/src/ruvector/index.d.ts +27 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +49 -0
- package/dist/src/ruvector/index.js.map +1 -0
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +681 -0
- package/dist/src/ruvector/q-learning-router.js.map +1 -0
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +243 -0
- package/dist/src/ruvector/vector-db.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +6 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/worker-daemon.d.ts +153 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +567 -0
- package/dist/src/services/worker-daemon.js.map +1 -0
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +200 -0
- package/dist/src/suggest.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -6
- package/.agentic-flow/intelligence.json +0 -16
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -87
- package/.claude-flow/metrics/task-metrics.json +0 -10
- 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/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/src/commands/agent.ts +0 -941
- package/src/commands/config.ts +0 -452
- package/src/commands/hive-mind.ts +0 -762
- package/src/commands/hooks.ts +0 -2603
- package/src/commands/index.ts +0 -115
- package/src/commands/init.ts +0 -597
- package/src/commands/mcp.ts +0 -753
- package/src/commands/memory.ts +0 -1063
- package/src/commands/migrate.ts +0 -447
- package/src/commands/process.ts +0 -617
- package/src/commands/session.ts +0 -891
- package/src/commands/start.ts +0 -457
- package/src/commands/status.ts +0 -705
- 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 -383
- package/src/infrastructure/in-memory-repositories.ts +0 -310
- package/src/init/claudemd-generator.ts +0 -631
- package/src/init/executor.ts +0 -756
- 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 -274
- package/src/init/statusline-generator.ts +0 -211
- package/src/init/types.ts +0 -447
- package/src/mcp-client.ts +0 -227
- package/src/mcp-server.ts +0 -571
- package/src/mcp-tools/agent-tools.ts +0 -92
- package/src/mcp-tools/config-tools.ts +0 -88
- package/src/mcp-tools/hooks-tools.ts +0 -1819
- package/src/mcp-tools/index.ts +0 -12
- package/src/mcp-tools/memory-tools.ts +0 -89
- package/src/mcp-tools/swarm-tools.ts +0 -69
- package/src/mcp-tools/types.ts +0 -33
- package/src/output.ts +0 -593
- package/src/parser.ts +0 -417
- package/src/prompt.ts +0 -619
- 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/commands/process.ts
DELETED
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V3 CLI Process Management Command
|
|
3
|
-
* Background process management, daemon mode, and monitoring
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { Command, CommandContext, CommandResult } from '../types.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Daemon subcommand - start/stop background daemon
|
|
10
|
-
*/
|
|
11
|
-
const daemonCommand: Command = {
|
|
12
|
-
name: 'daemon',
|
|
13
|
-
description: 'Manage background daemon process',
|
|
14
|
-
options: [
|
|
15
|
-
{
|
|
16
|
-
name: 'action',
|
|
17
|
-
type: 'string',
|
|
18
|
-
description: 'Action to perform',
|
|
19
|
-
choices: ['start', 'stop', 'restart', 'status'],
|
|
20
|
-
default: 'status',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'port',
|
|
24
|
-
type: 'number',
|
|
25
|
-
description: 'Port for daemon HTTP API',
|
|
26
|
-
default: 3847,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'pid-file',
|
|
30
|
-
type: 'string',
|
|
31
|
-
description: 'PID file location',
|
|
32
|
-
default: '.claude-flow/daemon.pid',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'log-file',
|
|
36
|
-
type: 'string',
|
|
37
|
-
description: 'Log file location',
|
|
38
|
-
default: '.claude-flow/daemon.log',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'detach',
|
|
42
|
-
type: 'boolean',
|
|
43
|
-
description: 'Run in detached mode',
|
|
44
|
-
default: true,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
examples: [
|
|
48
|
-
{ command: 'claude-flow process daemon --action start', description: 'Start the daemon' },
|
|
49
|
-
{ command: 'claude-flow process daemon --action stop', description: 'Stop the daemon' },
|
|
50
|
-
{ command: 'claude-flow process daemon --action restart --port 3850', description: 'Restart on different port' },
|
|
51
|
-
{ command: 'claude-flow process daemon --action status', description: 'Check daemon status' },
|
|
52
|
-
],
|
|
53
|
-
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
54
|
-
const action = (ctx.flags?.action as string) || 'status';
|
|
55
|
-
const port = (ctx.flags?.port as number) || 3847;
|
|
56
|
-
const pidFile = (ctx.flags?.['pid-file'] as string) || '.claude-flow/daemon.pid';
|
|
57
|
-
const logFile = (ctx.flags?.['log-file'] as string) || '.claude-flow/daemon.log';
|
|
58
|
-
const detach = ctx.flags?.detach !== false;
|
|
59
|
-
|
|
60
|
-
// Simulated daemon management
|
|
61
|
-
const daemonState = {
|
|
62
|
-
status: 'stopped' as 'running' | 'stopped' | 'starting' | 'stopping',
|
|
63
|
-
pid: null as number | null,
|
|
64
|
-
uptime: 0,
|
|
65
|
-
port,
|
|
66
|
-
startedAt: null as string | null,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
switch (action) {
|
|
70
|
-
case 'start':
|
|
71
|
-
console.log('\nš Starting claude-flow daemon...\n');
|
|
72
|
-
daemonState.status = 'running';
|
|
73
|
-
daemonState.pid = Math.floor(Math.random() * 50000) + 10000;
|
|
74
|
-
daemonState.startedAt = new Date().toISOString();
|
|
75
|
-
daemonState.uptime = 0;
|
|
76
|
-
|
|
77
|
-
console.log(' ā
Daemon started successfully');
|
|
78
|
-
console.log(` š PID: ${daemonState.pid}`);
|
|
79
|
-
console.log(` š HTTP API: http://localhost:${port}`);
|
|
80
|
-
console.log(` š PID file: ${pidFile}`);
|
|
81
|
-
console.log(` š Log file: ${logFile}`);
|
|
82
|
-
console.log(` š Mode: ${detach ? 'detached' : 'foreground'}`);
|
|
83
|
-
console.log('\n Services:');
|
|
84
|
-
console.log(' āā MCP Server: listening');
|
|
85
|
-
console.log(' āā Agent Pool: initialized (0 agents)');
|
|
86
|
-
console.log(' āā Memory Service: connected');
|
|
87
|
-
console.log(' āā Task Queue: ready');
|
|
88
|
-
console.log(' āā Swarm Coordinator: standby');
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
case 'stop':
|
|
92
|
-
console.log('\nš Stopping claude-flow daemon...\n');
|
|
93
|
-
console.log(' ā
Daemon stopped successfully');
|
|
94
|
-
console.log(' š PID file removed');
|
|
95
|
-
console.log(' š§¹ Resources cleaned up');
|
|
96
|
-
break;
|
|
97
|
-
|
|
98
|
-
case 'restart':
|
|
99
|
-
console.log('\nš Restarting claude-flow daemon...\n');
|
|
100
|
-
console.log(' š Stopping current instance...');
|
|
101
|
-
console.log(' ā
Stopped');
|
|
102
|
-
console.log(' š Starting new instance...');
|
|
103
|
-
daemonState.pid = Math.floor(Math.random() * 50000) + 10000;
|
|
104
|
-
console.log(` ā
Daemon restarted (PID: ${daemonState.pid})`);
|
|
105
|
-
console.log(` š HTTP API: http://localhost:${port}`);
|
|
106
|
-
break;
|
|
107
|
-
|
|
108
|
-
case 'status':
|
|
109
|
-
console.log('\nš Daemon Status\n');
|
|
110
|
-
console.log(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
111
|
-
console.log(' ā claude-flow daemon ā');
|
|
112
|
-
console.log(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤');
|
|
113
|
-
console.log(' ā Status: āŖ not running ā');
|
|
114
|
-
console.log(` ā Port: ${port.toString().padEnd(28)}ā`);
|
|
115
|
-
console.log(` ā PID file: ${pidFile.substring(0, 26).padEnd(28)}ā`);
|
|
116
|
-
console.log(' ā Uptime: -- ā');
|
|
117
|
-
console.log(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
118
|
-
console.log('\n To start: claude-flow process daemon --action start');
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return { success: true, data: daemonState };
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Monitor subcommand - real-time process monitoring
|
|
128
|
-
*/
|
|
129
|
-
const monitorCommand: Command = {
|
|
130
|
-
name: 'monitor',
|
|
131
|
-
description: 'Real-time process and resource monitoring',
|
|
132
|
-
options: [
|
|
133
|
-
{
|
|
134
|
-
name: 'interval',
|
|
135
|
-
type: 'number',
|
|
136
|
-
description: 'Refresh interval in seconds',
|
|
137
|
-
default: 2,
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'format',
|
|
141
|
-
type: 'string',
|
|
142
|
-
description: 'Output format',
|
|
143
|
-
choices: ['dashboard', 'compact', 'json'],
|
|
144
|
-
default: 'dashboard',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
name: 'components',
|
|
148
|
-
type: 'string',
|
|
149
|
-
description: 'Components to monitor (comma-separated)',
|
|
150
|
-
default: 'all',
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'watch',
|
|
154
|
-
type: 'boolean',
|
|
155
|
-
description: 'Continuous monitoring mode',
|
|
156
|
-
default: false,
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: 'alerts',
|
|
160
|
-
type: 'boolean',
|
|
161
|
-
description: 'Enable threshold alerts',
|
|
162
|
-
default: true,
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
examples: [
|
|
166
|
-
{ command: 'claude-flow process monitor', description: 'Show process dashboard' },
|
|
167
|
-
{ command: 'claude-flow process monitor --watch --interval 5', description: 'Watch mode' },
|
|
168
|
-
{ command: 'claude-flow process monitor --components agents,memory,tasks', description: 'Monitor specific components' },
|
|
169
|
-
{ command: 'claude-flow process monitor --format json', description: 'JSON output' },
|
|
170
|
-
],
|
|
171
|
-
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
172
|
-
const interval = (ctx.flags?.interval as number) || 2;
|
|
173
|
-
const format = (ctx.flags?.format as string) || 'dashboard';
|
|
174
|
-
const watch = ctx.flags?.watch === true;
|
|
175
|
-
const alerts = ctx.flags?.alerts !== false;
|
|
176
|
-
|
|
177
|
-
// Simulated monitoring data
|
|
178
|
-
const metrics = {
|
|
179
|
-
timestamp: new Date().toISOString(),
|
|
180
|
-
system: {
|
|
181
|
-
cpuUsage: Math.random() * 30 + 5,
|
|
182
|
-
memoryUsed: Math.floor(Math.random() * 500) + 100,
|
|
183
|
-
memoryTotal: 2048,
|
|
184
|
-
uptime: Math.floor(Math.random() * 86400),
|
|
185
|
-
},
|
|
186
|
-
agents: {
|
|
187
|
-
active: Math.floor(Math.random() * 5),
|
|
188
|
-
idle: Math.floor(Math.random() * 3),
|
|
189
|
-
total: 0,
|
|
190
|
-
poolSize: 10,
|
|
191
|
-
},
|
|
192
|
-
tasks: {
|
|
193
|
-
running: Math.floor(Math.random() * 3),
|
|
194
|
-
queued: Math.floor(Math.random() * 5),
|
|
195
|
-
completed: Math.floor(Math.random() * 100) + 50,
|
|
196
|
-
failed: Math.floor(Math.random() * 5),
|
|
197
|
-
},
|
|
198
|
-
memory: {
|
|
199
|
-
vectorCount: Math.floor(Math.random() * 10000) + 1000,
|
|
200
|
-
indexSize: Math.floor(Math.random() * 50) + 10,
|
|
201
|
-
cacheHitRate: Math.random() * 0.3 + 0.65,
|
|
202
|
-
avgSearchTime: Math.random() * 5 + 1,
|
|
203
|
-
},
|
|
204
|
-
network: {
|
|
205
|
-
mcpConnections: Math.floor(Math.random() * 3) + 1,
|
|
206
|
-
requestsPerMin: Math.floor(Math.random() * 100) + 20,
|
|
207
|
-
avgLatency: Math.random() * 50 + 10,
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
metrics.agents.total = metrics.agents.active + metrics.agents.idle;
|
|
212
|
-
|
|
213
|
-
if (format === 'json') {
|
|
214
|
-
console.log(JSON.stringify(metrics, null, 2));
|
|
215
|
-
return { success: true, data: metrics };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (format === 'compact') {
|
|
219
|
-
console.log('\nš Process Monitor (compact)\n');
|
|
220
|
-
console.log(`CPU: ${metrics.system.cpuUsage.toFixed(1)}% | Memory: ${metrics.system.memoryUsed}MB/${metrics.system.memoryTotal}MB`);
|
|
221
|
-
console.log(`Agents: ${metrics.agents.active}/${metrics.agents.total} active | Tasks: ${metrics.tasks.running} running, ${metrics.tasks.queued} queued`);
|
|
222
|
-
console.log(`Memory: ${metrics.memory.vectorCount} vectors | Cache: ${(metrics.memory.cacheHitRate * 100).toFixed(1)}%`);
|
|
223
|
-
return { success: true, data: metrics };
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Dashboard format
|
|
227
|
-
console.log('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
228
|
-
console.log('ā š„ļø CLAUDE-FLOW PROCESS MONITOR ā');
|
|
229
|
-
console.log('ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£');
|
|
230
|
-
|
|
231
|
-
// System metrics
|
|
232
|
-
console.log('ā SYSTEM ā');
|
|
233
|
-
const cpuBar = 'ā'.repeat(Math.floor(metrics.system.cpuUsage / 5)) + 'ā'.repeat(20 - Math.floor(metrics.system.cpuUsage / 5));
|
|
234
|
-
const memPercent = (metrics.system.memoryUsed / metrics.system.memoryTotal) * 100;
|
|
235
|
-
const memBar = 'ā'.repeat(Math.floor(memPercent / 5)) + 'ā'.repeat(20 - Math.floor(memPercent / 5));
|
|
236
|
-
console.log(`ā CPU: [${cpuBar}] ${metrics.system.cpuUsage.toFixed(1).padStart(5)}% ā`);
|
|
237
|
-
console.log(`ā Memory: [${memBar}] ${metrics.system.memoryUsed}MB/${metrics.system.memoryTotal}MB ā`);
|
|
238
|
-
|
|
239
|
-
console.log('ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£');
|
|
240
|
-
|
|
241
|
-
// Agents
|
|
242
|
-
console.log('ā AGENTS ā');
|
|
243
|
-
console.log(`ā Active: ${metrics.agents.active.toString().padEnd(3)} Idle: ${metrics.agents.idle.toString().padEnd(3)} Pool: ${metrics.agents.poolSize.toString().padEnd(3)} ā`);
|
|
244
|
-
|
|
245
|
-
console.log('ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£');
|
|
246
|
-
|
|
247
|
-
// Tasks
|
|
248
|
-
console.log('ā TASKS ā');
|
|
249
|
-
console.log(`ā Running: ${metrics.tasks.running.toString().padEnd(3)} Queued: ${metrics.tasks.queued.toString().padEnd(3)} Completed: ${metrics.tasks.completed.toString().padEnd(5)} Failed: ${metrics.tasks.failed.toString().padEnd(3)}ā`);
|
|
250
|
-
|
|
251
|
-
console.log('ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£');
|
|
252
|
-
|
|
253
|
-
// Memory service
|
|
254
|
-
console.log('ā MEMORY SERVICE ā');
|
|
255
|
-
console.log(`ā Vectors: ${metrics.memory.vectorCount.toString().padEnd(7)} Index: ${metrics.memory.indexSize}MB ā`);
|
|
256
|
-
console.log(`ā Cache Hit: ${(metrics.memory.cacheHitRate * 100).toFixed(1)}% Avg Search: ${metrics.memory.avgSearchTime.toFixed(2)}ms ā`);
|
|
257
|
-
|
|
258
|
-
console.log('ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā£');
|
|
259
|
-
|
|
260
|
-
// Network
|
|
261
|
-
console.log('ā NETWORK ā');
|
|
262
|
-
console.log(`ā MCP Connections: ${metrics.network.mcpConnections} Requests/min: ${metrics.network.requestsPerMin.toString().padEnd(5)} ā`);
|
|
263
|
-
console.log(`ā Avg Latency: ${metrics.network.avgLatency.toFixed(1)}ms ā`);
|
|
264
|
-
|
|
265
|
-
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
266
|
-
|
|
267
|
-
if (alerts) {
|
|
268
|
-
console.log('\nš¢ Alerts:');
|
|
269
|
-
if (metrics.system.cpuUsage > 80) {
|
|
270
|
-
console.log(' ā ļø High CPU usage detected');
|
|
271
|
-
}
|
|
272
|
-
if (memPercent > 80) {
|
|
273
|
-
console.log(' ā ļø High memory usage detected');
|
|
274
|
-
}
|
|
275
|
-
if (metrics.tasks.failed > 10) {
|
|
276
|
-
console.log(' ā ļø Elevated task failure rate');
|
|
277
|
-
}
|
|
278
|
-
if (metrics.memory.cacheHitRate < 0.5) {
|
|
279
|
-
console.log(' ā ļø Low cache hit rate');
|
|
280
|
-
}
|
|
281
|
-
if (metrics.system.cpuUsage <= 80 && memPercent <= 80 && metrics.tasks.failed <= 10 && metrics.memory.cacheHitRate >= 0.5) {
|
|
282
|
-
console.log(' ā
All systems nominal');
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (watch) {
|
|
287
|
-
console.log(`\nš Refresh: ${interval}s | Press Ctrl+C to exit`);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return { success: true, data: metrics };
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Workers subcommand - manage background workers
|
|
296
|
-
*/
|
|
297
|
-
const workersCommand: Command = {
|
|
298
|
-
name: 'workers',
|
|
299
|
-
description: 'Manage background worker processes',
|
|
300
|
-
options: [
|
|
301
|
-
{
|
|
302
|
-
name: 'action',
|
|
303
|
-
type: 'string',
|
|
304
|
-
description: 'Action to perform',
|
|
305
|
-
choices: ['list', 'spawn', 'kill', 'scale'],
|
|
306
|
-
default: 'list',
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
name: 'type',
|
|
310
|
-
type: 'string',
|
|
311
|
-
description: 'Worker type',
|
|
312
|
-
choices: ['task', 'memory', 'coordinator', 'neural'],
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
name: 'count',
|
|
316
|
-
type: 'number',
|
|
317
|
-
description: 'Number of workers',
|
|
318
|
-
default: 1,
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
name: 'id',
|
|
322
|
-
type: 'string',
|
|
323
|
-
description: 'Worker ID (for kill action)',
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
examples: [
|
|
327
|
-
{ command: 'claude-flow process workers --action list', description: 'List all workers' },
|
|
328
|
-
{ command: 'claude-flow process workers --action spawn --type task --count 3', description: 'Spawn task workers' },
|
|
329
|
-
{ command: 'claude-flow process workers --action kill --id worker-123', description: 'Kill specific worker' },
|
|
330
|
-
{ command: 'claude-flow process workers --action scale --type memory --count 5', description: 'Scale memory workers' },
|
|
331
|
-
],
|
|
332
|
-
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
333
|
-
const action = (ctx.flags?.action as string) || 'list';
|
|
334
|
-
const type = ctx.flags?.type as string;
|
|
335
|
-
const count = (ctx.flags?.count as number) || 1;
|
|
336
|
-
const id = ctx.flags?.id as string;
|
|
337
|
-
|
|
338
|
-
// Simulated worker data
|
|
339
|
-
const workers = [
|
|
340
|
-
{ id: 'worker-task-001', type: 'task', status: 'running', started: '2024-01-15T10:30:00Z', tasks: 42 },
|
|
341
|
-
{ id: 'worker-task-002', type: 'task', status: 'running', started: '2024-01-15T10:30:05Z', tasks: 38 },
|
|
342
|
-
{ id: 'worker-memory-001', type: 'memory', status: 'running', started: '2024-01-15T10:30:00Z', tasks: 156 },
|
|
343
|
-
{ id: 'worker-coord-001', type: 'coordinator', status: 'idle', started: '2024-01-15T10:30:00Z', tasks: 12 },
|
|
344
|
-
];
|
|
345
|
-
|
|
346
|
-
switch (action) {
|
|
347
|
-
case 'list':
|
|
348
|
-
console.log('\nš· Background Workers\n');
|
|
349
|
-
console.log('āāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāā¬āāāāāāāāāāā¬āāāāāāāāāā');
|
|
350
|
-
console.log('ā ID ā Type ā Status ā Tasks ā');
|
|
351
|
-
console.log('āāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāā¼āāāāāāāāāā¤');
|
|
352
|
-
for (const worker of workers) {
|
|
353
|
-
const statusIcon = worker.status === 'running' ? 'š¢' : 'š”';
|
|
354
|
-
console.log(`ā ${worker.id.padEnd(18)} ā ${worker.type.padEnd(11)} ā ${statusIcon} ${worker.status.padEnd(6)} ā ${worker.tasks.toString().padEnd(7)} ā`);
|
|
355
|
-
}
|
|
356
|
-
console.log('āāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāā“āāāāāāāāāāā“āāāāāāāāāā');
|
|
357
|
-
console.log(`\nTotal: ${workers.length} workers`);
|
|
358
|
-
break;
|
|
359
|
-
|
|
360
|
-
case 'spawn':
|
|
361
|
-
if (!type) {
|
|
362
|
-
console.log('\nā Worker type required. Use --type <task|memory|coordinator|neural>');
|
|
363
|
-
return { success: false, message: 'Worker type required' };
|
|
364
|
-
}
|
|
365
|
-
console.log(`\nš Spawning ${count} ${type} worker(s)...\n`);
|
|
366
|
-
for (let i = 0; i < count; i++) {
|
|
367
|
-
const newId = `worker-${type}-${String(workers.length + i + 1).padStart(3, '0')}`;
|
|
368
|
-
console.log(` ā
Spawned: ${newId}`);
|
|
369
|
-
}
|
|
370
|
-
console.log(`\n Total ${type} workers: ${workers.filter(w => w.type === type).length + count}`);
|
|
371
|
-
break;
|
|
372
|
-
|
|
373
|
-
case 'kill':
|
|
374
|
-
if (!id) {
|
|
375
|
-
console.log('\nā Worker ID required. Use --id <worker-id>');
|
|
376
|
-
return { success: false, message: 'Worker ID required' };
|
|
377
|
-
}
|
|
378
|
-
console.log(`\nš Killing worker: ${id}...\n`);
|
|
379
|
-
console.log(' ā
Worker terminated');
|
|
380
|
-
console.log(' š§¹ Resources released');
|
|
381
|
-
break;
|
|
382
|
-
|
|
383
|
-
case 'scale':
|
|
384
|
-
if (!type) {
|
|
385
|
-
console.log('\nā Worker type required. Use --type <task|memory|coordinator|neural>');
|
|
386
|
-
return { success: false, message: 'Worker type required' };
|
|
387
|
-
}
|
|
388
|
-
const current = workers.filter(w => w.type === type).length;
|
|
389
|
-
console.log(`\nš Scaling ${type} workers: ${current} ā ${count}\n`);
|
|
390
|
-
if (count > current) {
|
|
391
|
-
console.log(` š Spawning ${count - current} new worker(s)...`);
|
|
392
|
-
} else if (count < current) {
|
|
393
|
-
console.log(` š Terminating ${current - count} worker(s)...`);
|
|
394
|
-
} else {
|
|
395
|
-
console.log(' ā¹ļø No scaling needed');
|
|
396
|
-
}
|
|
397
|
-
console.log(` ā
Scaling complete`);
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return { success: true, data: workers };
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Signals subcommand - send signals to processes
|
|
407
|
-
*/
|
|
408
|
-
const signalsCommand: Command = {
|
|
409
|
-
name: 'signals',
|
|
410
|
-
description: 'Send signals to managed processes',
|
|
411
|
-
options: [
|
|
412
|
-
{
|
|
413
|
-
name: 'target',
|
|
414
|
-
type: 'string',
|
|
415
|
-
description: 'Target process or group',
|
|
416
|
-
required: true,
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
name: 'signal',
|
|
420
|
-
type: 'string',
|
|
421
|
-
description: 'Signal to send',
|
|
422
|
-
choices: ['graceful-shutdown', 'force-kill', 'pause', 'resume', 'reload-config'],
|
|
423
|
-
default: 'graceful-shutdown',
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
name: 'timeout',
|
|
427
|
-
type: 'number',
|
|
428
|
-
description: 'Timeout in seconds',
|
|
429
|
-
default: 30,
|
|
430
|
-
},
|
|
431
|
-
],
|
|
432
|
-
examples: [
|
|
433
|
-
{ command: 'claude-flow process signals --target daemon --signal graceful-shutdown', description: 'Graceful shutdown' },
|
|
434
|
-
{ command: 'claude-flow process signals --target workers --signal pause', description: 'Pause workers' },
|
|
435
|
-
{ command: 'claude-flow process signals --target all --signal reload-config', description: 'Reload all configs' },
|
|
436
|
-
],
|
|
437
|
-
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
438
|
-
const target = ctx.flags?.target as string;
|
|
439
|
-
const signal = (ctx.flags?.signal as string) || 'graceful-shutdown';
|
|
440
|
-
const timeout = (ctx.flags?.timeout as number) || 30;
|
|
441
|
-
|
|
442
|
-
if (!target) {
|
|
443
|
-
console.log('\nā Target required. Use --target <daemon|workers|all|process-id>');
|
|
444
|
-
return { success: false, message: 'Target required' };
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
console.log(`\nš” Sending signal: ${signal}\n`);
|
|
448
|
-
console.log(` Target: ${target}`);
|
|
449
|
-
console.log(` Timeout: ${timeout}s`);
|
|
450
|
-
console.log('');
|
|
451
|
-
|
|
452
|
-
const signalMessages: Record<string, string> = {
|
|
453
|
-
'graceful-shutdown': 'š Initiating graceful shutdown...',
|
|
454
|
-
'force-kill': 'š Force killing process...',
|
|
455
|
-
'pause': 'āøļø Pausing process...',
|
|
456
|
-
'resume': 'ā¶ļø Resuming process...',
|
|
457
|
-
'reload-config': 'š Reloading configuration...',
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
console.log(` ${signalMessages[signal] || 'Sending signal...'}`);
|
|
461
|
-
console.log(' ā
Signal acknowledged');
|
|
462
|
-
|
|
463
|
-
return { success: true, data: { target, signal, timeout } };
|
|
464
|
-
},
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Logs subcommand - view process logs
|
|
469
|
-
*/
|
|
470
|
-
const logsCommand: Command = {
|
|
471
|
-
name: 'logs',
|
|
472
|
-
description: 'View and manage process logs',
|
|
473
|
-
options: [
|
|
474
|
-
{
|
|
475
|
-
name: 'source',
|
|
476
|
-
type: 'string',
|
|
477
|
-
description: 'Log source',
|
|
478
|
-
choices: ['daemon', 'workers', 'tasks', 'all'],
|
|
479
|
-
default: 'all',
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
name: 'tail',
|
|
483
|
-
type: 'number',
|
|
484
|
-
description: 'Number of lines to show',
|
|
485
|
-
default: 50,
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
name: 'follow',
|
|
489
|
-
type: 'boolean',
|
|
490
|
-
description: 'Follow log output',
|
|
491
|
-
default: false,
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
name: 'level',
|
|
495
|
-
type: 'string',
|
|
496
|
-
description: 'Minimum log level',
|
|
497
|
-
choices: ['debug', 'info', 'warn', 'error'],
|
|
498
|
-
default: 'info',
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
name: 'since',
|
|
502
|
-
type: 'string',
|
|
503
|
-
description: 'Show logs since timestamp or duration',
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
name: 'grep',
|
|
507
|
-
type: 'string',
|
|
508
|
-
description: 'Filter logs by pattern',
|
|
509
|
-
},
|
|
510
|
-
],
|
|
511
|
-
examples: [
|
|
512
|
-
{ command: 'claude-flow process logs', description: 'Show recent logs' },
|
|
513
|
-
{ command: 'claude-flow process logs --source daemon --tail 100', description: 'Daemon logs' },
|
|
514
|
-
{ command: 'claude-flow process logs --follow --level error', description: 'Follow error logs' },
|
|
515
|
-
{ command: 'claude-flow process logs --since 1h --grep "error"', description: 'Search logs' },
|
|
516
|
-
],
|
|
517
|
-
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
518
|
-
const source = (ctx.flags?.source as string) || 'all';
|
|
519
|
-
const tail = (ctx.flags?.tail as number) || 50;
|
|
520
|
-
const follow = ctx.flags?.follow === true;
|
|
521
|
-
const level = (ctx.flags?.level as string) || 'info';
|
|
522
|
-
const since = ctx.flags?.since as string;
|
|
523
|
-
const grep = ctx.flags?.grep as string;
|
|
524
|
-
|
|
525
|
-
console.log(`\nš Process Logs (${source})\n`);
|
|
526
|
-
console.log(` Level: ${level}+ | Lines: ${tail}${since ? ` | Since: ${since}` : ''}${grep ? ` | Filter: ${grep}` : ''}`);
|
|
527
|
-
console.log('ā'.repeat(70));
|
|
528
|
-
|
|
529
|
-
// Simulated log entries
|
|
530
|
-
const levels = ['debug', 'info', 'warn', 'error'];
|
|
531
|
-
const levelIcons: Record<string, string> = {
|
|
532
|
-
debug: 'š',
|
|
533
|
-
info: 'ā¹ļø ',
|
|
534
|
-
warn: 'ā ļø ',
|
|
535
|
-
error: 'ā',
|
|
536
|
-
};
|
|
537
|
-
const sources = ['daemon', 'worker-task', 'worker-memory', 'coordinator'];
|
|
538
|
-
const messages = [
|
|
539
|
-
'Processing task queue...',
|
|
540
|
-
'Agent spawned successfully',
|
|
541
|
-
'Memory index optimized',
|
|
542
|
-
'Configuration reloaded',
|
|
543
|
-
'MCP connection established',
|
|
544
|
-
'Task completed: 42ms',
|
|
545
|
-
'Cache hit rate: 87%',
|
|
546
|
-
'Swarm topology updated',
|
|
547
|
-
'Health check passed',
|
|
548
|
-
'Neural pattern learned',
|
|
549
|
-
];
|
|
550
|
-
|
|
551
|
-
const minLevelIdx = levels.indexOf(level);
|
|
552
|
-
const now = Date.now();
|
|
553
|
-
|
|
554
|
-
for (let i = 0; i < Math.min(tail, 15); i++) {
|
|
555
|
-
const logLevel = levels[Math.floor(Math.random() * (levels.length - minLevelIdx)) + minLevelIdx];
|
|
556
|
-
const logSource = sources[Math.floor(Math.random() * sources.length)];
|
|
557
|
-
const message = messages[Math.floor(Math.random() * messages.length)];
|
|
558
|
-
const timestamp = new Date(now - (tail - i) * 1000 * 60).toISOString().substring(11, 23);
|
|
559
|
-
|
|
560
|
-
if (grep && !message.toLowerCase().includes(grep.toLowerCase())) {
|
|
561
|
-
continue;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
console.log(`${timestamp} ${levelIcons[logLevel]} [${logSource.padEnd(14)}] ${message}`);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
console.log('ā'.repeat(70));
|
|
568
|
-
|
|
569
|
-
if (follow) {
|
|
570
|
-
console.log('\nš Following logs... (Ctrl+C to exit)');
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return { success: true, data: { source, tail, level } };
|
|
574
|
-
},
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Main process command
|
|
579
|
-
*/
|
|
580
|
-
export const processCommand: Command = {
|
|
581
|
-
name: 'process',
|
|
582
|
-
description: 'Background process management, daemon, and monitoring',
|
|
583
|
-
aliases: ['proc', 'ps'],
|
|
584
|
-
subcommands: [daemonCommand, monitorCommand, workersCommand, signalsCommand, logsCommand],
|
|
585
|
-
options: [
|
|
586
|
-
{
|
|
587
|
-
name: 'help',
|
|
588
|
-
short: 'h',
|
|
589
|
-
type: 'boolean',
|
|
590
|
-
description: 'Show help for process command',
|
|
591
|
-
},
|
|
592
|
-
],
|
|
593
|
-
examples: [
|
|
594
|
-
{ command: 'claude-flow process daemon --action start', description: 'Start daemon' },
|
|
595
|
-
{ command: 'claude-flow process monitor --watch', description: 'Watch processes' },
|
|
596
|
-
{ command: 'claude-flow process workers --action list', description: 'List workers' },
|
|
597
|
-
{ command: 'claude-flow process logs --follow', description: 'Follow logs' },
|
|
598
|
-
],
|
|
599
|
-
action: async (_ctx: CommandContext): Promise<CommandResult> => {
|
|
600
|
-
// Show help if no subcommand
|
|
601
|
-
console.log('\nš§ Process Management\n');
|
|
602
|
-
console.log('Manage background processes, daemons, and workers.\n');
|
|
603
|
-
console.log('Subcommands:');
|
|
604
|
-
console.log(' daemon - Manage background daemon process');
|
|
605
|
-
console.log(' monitor - Real-time process monitoring');
|
|
606
|
-
console.log(' workers - Manage background workers');
|
|
607
|
-
console.log(' signals - Send signals to processes');
|
|
608
|
-
console.log(' logs - View and manage process logs');
|
|
609
|
-
console.log('\nExamples:');
|
|
610
|
-
console.log(' claude-flow process daemon --action start');
|
|
611
|
-
console.log(' claude-flow process monitor --watch');
|
|
612
|
-
console.log(' claude-flow process workers --action spawn --type task --count 3');
|
|
613
|
-
console.log(' claude-flow process logs --follow --level error');
|
|
614
|
-
|
|
615
|
-
return { success: true, data: { help: true } };
|
|
616
|
-
},
|
|
617
|
-
};
|