@claude-flow/cli 3.0.0-alpha.10 → 3.0.0-alpha.11
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/.agentic-flow/intelligence.json +4 -4
- package/.claude-flow/daemon-state.json +35 -47
- package/.claude-flow/metrics/codebase-map.json +2 -2
- package/.claude-flow/metrics/consolidation.json +1 -1
- package/.claude-flow/metrics/performance.json +3 -3
- package/.claude-flow/metrics/security-audit.json +1 -1
- package/.claude-flow/metrics/task-metrics.json +3 -3
- package/.claude-flow/metrics/test-gaps.json +1 -1
- package/agents/architect.yaml +1 -1
- package/agents/coder.yaml +1 -1
- package/agents/reviewer.yaml +1 -1
- package/agents/security-architect.yaml +1 -1
- package/agents/tester.yaml +1 -1
- 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/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/embeddings.d.ts +10 -0
- package/dist/src/commands/embeddings.d.ts.map +1 -0
- package/dist/src/commands/embeddings.js +294 -0
- package/dist/src/commands/embeddings.js.map +1 -0
- package/dist/src/commands/index.d.ts +8 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +28 -1
- package/dist/src/commands/index.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/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/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/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/claims.ts +317 -0
- package/src/commands/deployment.ts +323 -0
- package/src/commands/embeddings.ts +332 -0
- package/src/commands/index.ts +28 -1
- package/src/commands/neural.ts +253 -0
- package/src/commands/performance.ts +292 -0
- package/src/commands/plugins.ts +316 -0
- package/src/commands/providers.ts +259 -0
- package/src/commands/security.ts +288 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 CLI Providers Command
|
|
3
|
+
* Manage AI providers, models, and configurations
|
|
4
|
+
*
|
|
5
|
+
* Created with ❤️ by ruv.io
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Command, CommandContext, CommandResult } from '../types.js';
|
|
9
|
+
import { output } from '../output.js';
|
|
10
|
+
|
|
11
|
+
// List subcommand
|
|
12
|
+
const listCommand: Command = {
|
|
13
|
+
name: 'list',
|
|
14
|
+
description: 'List available AI providers and models',
|
|
15
|
+
options: [
|
|
16
|
+
{ name: 'type', short: 't', type: 'string', description: 'Filter by type: llm, embedding, image', default: 'all' },
|
|
17
|
+
{ name: 'active', short: 'a', type: 'boolean', description: 'Show only active providers' },
|
|
18
|
+
],
|
|
19
|
+
examples: [
|
|
20
|
+
{ command: 'claude-flow providers list', description: 'List all providers' },
|
|
21
|
+
{ command: 'claude-flow providers list -t embedding', description: 'List embedding providers' },
|
|
22
|
+
],
|
|
23
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
24
|
+
const type = ctx.flags.type as string || 'all';
|
|
25
|
+
|
|
26
|
+
output.writeln();
|
|
27
|
+
output.writeln(output.bold('Available Providers'));
|
|
28
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
29
|
+
|
|
30
|
+
output.printTable({
|
|
31
|
+
columns: [
|
|
32
|
+
{ key: 'provider', header: 'Provider', width: 18 },
|
|
33
|
+
{ key: 'type', header: 'Type', width: 12 },
|
|
34
|
+
{ key: 'models', header: 'Models', width: 25 },
|
|
35
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
36
|
+
],
|
|
37
|
+
data: [
|
|
38
|
+
{ provider: 'Anthropic', type: 'LLM', models: 'claude-3.5-sonnet, opus', status: output.success('Active') },
|
|
39
|
+
{ provider: 'OpenAI', type: 'LLM', models: 'gpt-4o, gpt-4-turbo', status: output.success('Active') },
|
|
40
|
+
{ provider: 'OpenAI', type: 'Embedding', models: 'text-embedding-3-small/large', status: output.success('Active') },
|
|
41
|
+
{ provider: 'Transformers.js', type: 'Embedding', models: 'all-MiniLM-L6-v2', status: output.success('Active') },
|
|
42
|
+
{ provider: 'Agentic Flow', type: 'Embedding', models: 'ONNX optimized', status: output.success('Active') },
|
|
43
|
+
{ provider: 'Mock', type: 'All', models: 'mock-*', status: output.dim('Dev only') },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return { success: true };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Configure subcommand
|
|
52
|
+
const configureCommand: Command = {
|
|
53
|
+
name: 'configure',
|
|
54
|
+
description: 'Configure provider settings and API keys',
|
|
55
|
+
options: [
|
|
56
|
+
{ name: 'provider', short: 'p', type: 'string', description: 'Provider name', required: true },
|
|
57
|
+
{ name: 'key', short: 'k', type: 'string', description: 'API key' },
|
|
58
|
+
{ name: 'model', short: 'm', type: 'string', description: 'Default model' },
|
|
59
|
+
{ name: 'endpoint', short: 'e', type: 'string', description: 'Custom endpoint URL' },
|
|
60
|
+
],
|
|
61
|
+
examples: [
|
|
62
|
+
{ command: 'claude-flow providers configure -p openai -k sk-...', description: 'Set OpenAI key' },
|
|
63
|
+
{ command: 'claude-flow providers configure -p anthropic -m claude-3.5-sonnet', description: 'Set default model' },
|
|
64
|
+
],
|
|
65
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
66
|
+
const provider = ctx.flags.provider as string;
|
|
67
|
+
const hasKey = ctx.flags.key as string;
|
|
68
|
+
const model = ctx.flags.model as string;
|
|
69
|
+
|
|
70
|
+
if (!provider) {
|
|
71
|
+
output.printError('Provider name is required');
|
|
72
|
+
return { success: false, exitCode: 1 };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
output.writeln();
|
|
76
|
+
output.writeln(output.bold(`Configure: ${provider}`));
|
|
77
|
+
output.writeln(output.dim('─'.repeat(40)));
|
|
78
|
+
|
|
79
|
+
const spinner = output.createSpinner({ text: 'Updating configuration...', spinner: 'dots' });
|
|
80
|
+
spinner.start();
|
|
81
|
+
await new Promise(r => setTimeout(r, 500));
|
|
82
|
+
spinner.succeed('Configuration updated');
|
|
83
|
+
|
|
84
|
+
output.writeln();
|
|
85
|
+
output.printBox([
|
|
86
|
+
`Provider: ${provider}`,
|
|
87
|
+
`API Key: ${hasKey ? '••••••••' + (hasKey as string).slice(-4) : 'Not set'}`,
|
|
88
|
+
`Model: ${model || 'Default'}`,
|
|
89
|
+
`Status: Active`,
|
|
90
|
+
].join('\n'), 'Configuration');
|
|
91
|
+
|
|
92
|
+
return { success: true };
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Test subcommand
|
|
97
|
+
const testCommand: Command = {
|
|
98
|
+
name: 'test',
|
|
99
|
+
description: 'Test provider connectivity and API access',
|
|
100
|
+
options: [
|
|
101
|
+
{ name: 'provider', short: 'p', type: 'string', description: 'Provider to test' },
|
|
102
|
+
{ name: 'all', short: 'a', type: 'boolean', description: 'Test all configured providers' },
|
|
103
|
+
],
|
|
104
|
+
examples: [
|
|
105
|
+
{ command: 'claude-flow providers test -p openai', description: 'Test OpenAI connection' },
|
|
106
|
+
{ command: 'claude-flow providers test --all', description: 'Test all providers' },
|
|
107
|
+
],
|
|
108
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
109
|
+
const provider = ctx.flags.provider as string;
|
|
110
|
+
const testAll = ctx.flags.all as boolean;
|
|
111
|
+
|
|
112
|
+
output.writeln();
|
|
113
|
+
output.writeln(output.bold('Provider Connectivity Test'));
|
|
114
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
115
|
+
|
|
116
|
+
const providers = testAll || !provider
|
|
117
|
+
? ['Anthropic', 'OpenAI (LLM)', 'OpenAI (Embedding)', 'Transformers.js', 'Agentic Flow']
|
|
118
|
+
: [provider];
|
|
119
|
+
|
|
120
|
+
for (const p of providers) {
|
|
121
|
+
const spinner = output.createSpinner({ text: `Testing ${p}...`, spinner: 'dots' });
|
|
122
|
+
spinner.start();
|
|
123
|
+
await new Promise(r => setTimeout(r, 300));
|
|
124
|
+
spinner.succeed(`${p}: Connected`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
output.writeln();
|
|
128
|
+
output.printSuccess(`All ${providers.length} providers connected successfully`);
|
|
129
|
+
|
|
130
|
+
return { success: true };
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Models subcommand
|
|
135
|
+
const modelsCommand: Command = {
|
|
136
|
+
name: 'models',
|
|
137
|
+
description: 'List and manage available models',
|
|
138
|
+
options: [
|
|
139
|
+
{ name: 'provider', short: 'p', type: 'string', description: 'Filter by provider' },
|
|
140
|
+
{ name: 'capability', short: 'c', type: 'string', description: 'Filter by capability: chat, completion, embedding' },
|
|
141
|
+
],
|
|
142
|
+
examples: [
|
|
143
|
+
{ command: 'claude-flow providers models', description: 'List all models' },
|
|
144
|
+
{ command: 'claude-flow providers models -p anthropic', description: 'List Anthropic models' },
|
|
145
|
+
],
|
|
146
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
147
|
+
output.writeln();
|
|
148
|
+
output.writeln(output.bold('Available Models'));
|
|
149
|
+
output.writeln(output.dim('─'.repeat(70)));
|
|
150
|
+
|
|
151
|
+
output.printTable({
|
|
152
|
+
columns: [
|
|
153
|
+
{ key: 'model', header: 'Model', width: 28 },
|
|
154
|
+
{ key: 'provider', header: 'Provider', width: 14 },
|
|
155
|
+
{ key: 'capability', header: 'Capability', width: 12 },
|
|
156
|
+
{ key: 'context', header: 'Context', width: 10 },
|
|
157
|
+
{ key: 'cost', header: 'Cost/1K', width: 12 },
|
|
158
|
+
],
|
|
159
|
+
data: [
|
|
160
|
+
{ model: 'claude-3.5-sonnet-20241022', provider: 'Anthropic', capability: 'Chat', context: '200K', cost: '$0.003/$0.015' },
|
|
161
|
+
{ model: 'claude-3-opus-20240229', provider: 'Anthropic', capability: 'Chat', context: '200K', cost: '$0.015/$0.075' },
|
|
162
|
+
{ model: 'gpt-4o', provider: 'OpenAI', capability: 'Chat', context: '128K', cost: '$0.005/$0.015' },
|
|
163
|
+
{ model: 'gpt-4-turbo', provider: 'OpenAI', capability: 'Chat', context: '128K', cost: '$0.01/$0.03' },
|
|
164
|
+
{ model: 'text-embedding-3-small', provider: 'OpenAI', capability: 'Embedding', context: '8K', cost: '$0.00002' },
|
|
165
|
+
{ model: 'text-embedding-3-large', provider: 'OpenAI', capability: 'Embedding', context: '8K', cost: '$0.00013' },
|
|
166
|
+
{ model: 'all-MiniLM-L6-v2', provider: 'Transformers', capability: 'Embedding', context: '512', cost: output.success('Free') },
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return { success: true };
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Usage subcommand
|
|
175
|
+
const usageCommand: Command = {
|
|
176
|
+
name: 'usage',
|
|
177
|
+
description: 'View provider usage and costs',
|
|
178
|
+
options: [
|
|
179
|
+
{ name: 'provider', short: 'p', type: 'string', description: 'Filter by provider' },
|
|
180
|
+
{ name: 'timeframe', short: 't', type: 'string', description: 'Timeframe: 24h, 7d, 30d', default: '7d' },
|
|
181
|
+
],
|
|
182
|
+
examples: [
|
|
183
|
+
{ command: 'claude-flow providers usage', description: 'View all usage' },
|
|
184
|
+
{ command: 'claude-flow providers usage -t 30d', description: 'View 30-day usage' },
|
|
185
|
+
],
|
|
186
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
187
|
+
const timeframe = ctx.flags.timeframe as string || '7d';
|
|
188
|
+
|
|
189
|
+
output.writeln();
|
|
190
|
+
output.writeln(output.bold(`Provider Usage (${timeframe})`));
|
|
191
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
192
|
+
|
|
193
|
+
output.printTable({
|
|
194
|
+
columns: [
|
|
195
|
+
{ key: 'provider', header: 'Provider', width: 15 },
|
|
196
|
+
{ key: 'requests', header: 'Requests', width: 12 },
|
|
197
|
+
{ key: 'tokens', header: 'Tokens', width: 15 },
|
|
198
|
+
{ key: 'cost', header: 'Est. Cost', width: 12 },
|
|
199
|
+
{ key: 'trend', header: 'Trend', width: 12 },
|
|
200
|
+
],
|
|
201
|
+
data: [
|
|
202
|
+
{ provider: 'Anthropic', requests: '12,847', tokens: '4.2M', cost: '$12.60', trend: output.warning('↑ 15%') },
|
|
203
|
+
{ provider: 'OpenAI (LLM)', requests: '3,421', tokens: '1.1M', cost: '$5.50', trend: output.success('↓ 8%') },
|
|
204
|
+
{ provider: 'OpenAI (Embed)', requests: '89,234', tokens: '12.4M', cost: '$0.25', trend: output.success('↓ 12%') },
|
|
205
|
+
{ provider: 'Transformers.js', requests: '234,567', tokens: '45.2M', cost: output.success('$0.00'), trend: '→' },
|
|
206
|
+
],
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
output.writeln();
|
|
210
|
+
output.printBox([
|
|
211
|
+
`Total Requests: 340,069`,
|
|
212
|
+
`Total Tokens: 62.9M`,
|
|
213
|
+
`Total Cost: $18.35`,
|
|
214
|
+
``,
|
|
215
|
+
`Savings from local embeddings: $890.12`,
|
|
216
|
+
].join('\n'), 'Summary');
|
|
217
|
+
|
|
218
|
+
return { success: true };
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Main providers command
|
|
223
|
+
export const providersCommand: Command = {
|
|
224
|
+
name: 'providers',
|
|
225
|
+
description: 'Manage AI providers, models, and configurations',
|
|
226
|
+
subcommands: [listCommand, configureCommand, testCommand, modelsCommand, usageCommand],
|
|
227
|
+
examples: [
|
|
228
|
+
{ command: 'claude-flow providers list', description: 'List all providers' },
|
|
229
|
+
{ command: 'claude-flow providers configure -p openai', description: 'Configure OpenAI' },
|
|
230
|
+
{ command: 'claude-flow providers test --all', description: 'Test all providers' },
|
|
231
|
+
],
|
|
232
|
+
action: async (): Promise<CommandResult> => {
|
|
233
|
+
output.writeln();
|
|
234
|
+
output.writeln(output.bold('Claude Flow Provider Management'));
|
|
235
|
+
output.writeln(output.dim('Multi-provider AI orchestration'));
|
|
236
|
+
output.writeln();
|
|
237
|
+
output.writeln('Subcommands:');
|
|
238
|
+
output.printList([
|
|
239
|
+
'list - List available providers and their status',
|
|
240
|
+
'configure - Configure provider settings and API keys',
|
|
241
|
+
'test - Test provider connectivity',
|
|
242
|
+
'models - List and manage available models',
|
|
243
|
+
'usage - View usage statistics and costs',
|
|
244
|
+
]);
|
|
245
|
+
output.writeln();
|
|
246
|
+
output.writeln('Supported Providers:');
|
|
247
|
+
output.printList([
|
|
248
|
+
'Anthropic (Claude models)',
|
|
249
|
+
'OpenAI (GPT + embeddings)',
|
|
250
|
+
'Transformers.js (local ONNX)',
|
|
251
|
+
'Agentic Flow (optimized ONNX with SIMD)',
|
|
252
|
+
]);
|
|
253
|
+
output.writeln();
|
|
254
|
+
output.writeln(output.dim('Created with ❤️ by ruv.io'));
|
|
255
|
+
return { success: true };
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export default providersCommand;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 CLI Security Command
|
|
3
|
+
* Security scanning, CVE detection, threat modeling, vulnerability management
|
|
4
|
+
*
|
|
5
|
+
* Created with ❤️ by ruv.io
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Command, CommandContext, CommandResult } from '../types.js';
|
|
9
|
+
import { output } from '../output.js';
|
|
10
|
+
|
|
11
|
+
// Scan subcommand
|
|
12
|
+
const scanCommand: Command = {
|
|
13
|
+
name: 'scan',
|
|
14
|
+
description: 'Run security scan on target (code, dependencies, containers)',
|
|
15
|
+
options: [
|
|
16
|
+
{ name: 'target', short: 't', type: 'string', description: 'Target path or URL to scan', default: '.' },
|
|
17
|
+
{ name: 'depth', short: 'd', type: 'string', description: 'Scan depth: quick, standard, deep', default: 'standard' },
|
|
18
|
+
{ name: 'type', type: 'string', description: 'Scan type: code, deps, container, all', default: 'all' },
|
|
19
|
+
{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, sarif', default: 'text' },
|
|
20
|
+
{ name: 'fix', short: 'f', type: 'boolean', description: 'Auto-fix vulnerabilities where possible' },
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
{ command: 'claude-flow security scan -t ./src', description: 'Scan source directory' },
|
|
24
|
+
{ command: 'claude-flow security scan --depth deep --fix', description: 'Deep scan with auto-fix' },
|
|
25
|
+
],
|
|
26
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
27
|
+
const target = ctx.flags.target as string || '.';
|
|
28
|
+
const depth = ctx.flags.depth as string || 'standard';
|
|
29
|
+
const scanType = ctx.flags.type as string || 'all';
|
|
30
|
+
|
|
31
|
+
output.writeln();
|
|
32
|
+
output.writeln(output.bold('Security Scan'));
|
|
33
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
34
|
+
|
|
35
|
+
const spinner = output.createSpinner({ text: `Scanning ${target}...`, spinner: 'dots' });
|
|
36
|
+
spinner.start();
|
|
37
|
+
|
|
38
|
+
// Simulate scan phases
|
|
39
|
+
const phases = ['Analyzing code patterns', 'Checking dependencies', 'CVE database lookup', 'Generating report'];
|
|
40
|
+
for (const phase of phases) {
|
|
41
|
+
spinner.setText(phase + '...');
|
|
42
|
+
await new Promise(r => setTimeout(r, 400));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
spinner.succeed('Scan complete');
|
|
46
|
+
|
|
47
|
+
output.writeln();
|
|
48
|
+
output.printTable({
|
|
49
|
+
columns: [
|
|
50
|
+
{ key: 'severity', header: 'Severity', width: 12 },
|
|
51
|
+
{ key: 'type', header: 'Type', width: 18 },
|
|
52
|
+
{ key: 'location', header: 'Location', width: 25 },
|
|
53
|
+
{ key: 'description', header: 'Description', width: 35 },
|
|
54
|
+
],
|
|
55
|
+
data: [
|
|
56
|
+
{ severity: output.error('CRITICAL'), type: 'CVE-2024-1234', location: 'package.json:45', description: 'Prototype pollution in lodash' },
|
|
57
|
+
{ severity: output.warning('HIGH'), type: 'Hardcoded Secret', location: 'src/config.ts:12', description: 'API key exposed in source' },
|
|
58
|
+
{ severity: output.warning('MEDIUM'), type: 'SQL Injection', location: 'src/db/query.ts:78', description: 'Unsanitized user input' },
|
|
59
|
+
{ severity: output.info('LOW'), type: 'Outdated Dep', location: 'package.json:23', description: 'axios@0.21.0 has known issues' },
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
output.writeln();
|
|
64
|
+
output.printBox([
|
|
65
|
+
`Target: ${target}`,
|
|
66
|
+
`Depth: ${depth}`,
|
|
67
|
+
`Type: ${scanType}`,
|
|
68
|
+
``,
|
|
69
|
+
`Critical: 1 High: 1 Medium: 1 Low: 1`,
|
|
70
|
+
`Total Issues: 4`,
|
|
71
|
+
].join('\n'), 'Scan Summary');
|
|
72
|
+
|
|
73
|
+
return { success: true };
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// CVE subcommand
|
|
78
|
+
const cveCommand: Command = {
|
|
79
|
+
name: 'cve',
|
|
80
|
+
description: 'Check and manage CVE vulnerabilities',
|
|
81
|
+
options: [
|
|
82
|
+
{ name: 'check', short: 'c', type: 'string', description: 'Check specific CVE ID' },
|
|
83
|
+
{ name: 'list', short: 'l', type: 'boolean', description: 'List all known CVEs' },
|
|
84
|
+
{ name: 'severity', short: 's', type: 'string', description: 'Filter by severity: critical, high, medium, low' },
|
|
85
|
+
],
|
|
86
|
+
examples: [
|
|
87
|
+
{ command: 'claude-flow security cve --list', description: 'List all CVEs' },
|
|
88
|
+
{ command: 'claude-flow security cve -c CVE-2024-1234', description: 'Check specific CVE' },
|
|
89
|
+
],
|
|
90
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
91
|
+
const checkCve = ctx.flags.check as string;
|
|
92
|
+
|
|
93
|
+
output.writeln();
|
|
94
|
+
output.writeln(output.bold('CVE Database'));
|
|
95
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
96
|
+
|
|
97
|
+
if (checkCve) {
|
|
98
|
+
output.printBox([
|
|
99
|
+
`CVE ID: ${checkCve}`,
|
|
100
|
+
`Severity: CRITICAL (9.8)`,
|
|
101
|
+
`Status: Active`,
|
|
102
|
+
``,
|
|
103
|
+
`Description: Remote code execution vulnerability`,
|
|
104
|
+
`Affected: lodash < 4.17.21`,
|
|
105
|
+
`Fix: Upgrade to lodash >= 4.17.21`,
|
|
106
|
+
``,
|
|
107
|
+
`References:`,
|
|
108
|
+
` - https://nvd.nist.gov/vuln/detail/${checkCve}`,
|
|
109
|
+
` - https://github.com/advisories`,
|
|
110
|
+
].join('\n'), 'CVE Details');
|
|
111
|
+
} else {
|
|
112
|
+
output.printTable({
|
|
113
|
+
columns: [
|
|
114
|
+
{ key: 'id', header: 'CVE ID', width: 18 },
|
|
115
|
+
{ key: 'severity', header: 'Severity', width: 12 },
|
|
116
|
+
{ key: 'package', header: 'Package', width: 20 },
|
|
117
|
+
{ key: 'status', header: 'Status', width: 15 },
|
|
118
|
+
],
|
|
119
|
+
data: [
|
|
120
|
+
{ id: 'CVE-2024-1234', severity: output.error('CRITICAL'), package: 'lodash@4.17.20', status: output.warning('Unfixed') },
|
|
121
|
+
{ id: 'CVE-2024-5678', severity: output.warning('HIGH'), package: 'axios@0.21.0', status: output.success('Fixed') },
|
|
122
|
+
{ id: 'CVE-2024-9012', severity: output.info('MEDIUM'), package: 'express@4.17.0', status: output.success('Fixed') },
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return { success: true };
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Threats subcommand
|
|
132
|
+
const threatsCommand: Command = {
|
|
133
|
+
name: 'threats',
|
|
134
|
+
description: 'Threat modeling and analysis',
|
|
135
|
+
options: [
|
|
136
|
+
{ name: 'model', short: 'm', type: 'string', description: 'Threat model: stride, dread, pasta', default: 'stride' },
|
|
137
|
+
{ name: 'scope', short: 's', type: 'string', description: 'Analysis scope', default: '.' },
|
|
138
|
+
{ name: 'export', short: 'e', type: 'string', description: 'Export format: json, md, html' },
|
|
139
|
+
],
|
|
140
|
+
examples: [
|
|
141
|
+
{ command: 'claude-flow security threats --model stride', description: 'Run STRIDE analysis' },
|
|
142
|
+
{ command: 'claude-flow security threats -e md', description: 'Export as markdown' },
|
|
143
|
+
],
|
|
144
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
145
|
+
const model = ctx.flags.model as string || 'stride';
|
|
146
|
+
|
|
147
|
+
output.writeln();
|
|
148
|
+
output.writeln(output.bold(`Threat Model: ${model.toUpperCase()}`));
|
|
149
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
150
|
+
|
|
151
|
+
output.printTable({
|
|
152
|
+
columns: [
|
|
153
|
+
{ key: 'category', header: 'Category', width: 20 },
|
|
154
|
+
{ key: 'threat', header: 'Threat', width: 30 },
|
|
155
|
+
{ key: 'risk', header: 'Risk', width: 10 },
|
|
156
|
+
{ key: 'mitigation', header: 'Mitigation', width: 30 },
|
|
157
|
+
],
|
|
158
|
+
data: [
|
|
159
|
+
{ category: 'Spoofing', threat: 'API key theft', risk: output.error('High'), mitigation: 'Use secure key storage' },
|
|
160
|
+
{ category: 'Tampering', threat: 'Data manipulation', risk: output.warning('Medium'), mitigation: 'Input validation' },
|
|
161
|
+
{ category: 'Repudiation', threat: 'Action denial', risk: output.info('Low'), mitigation: 'Audit logging' },
|
|
162
|
+
{ category: 'Info Disclosure', threat: 'Data leakage', risk: output.error('High'), mitigation: 'Encryption at rest' },
|
|
163
|
+
{ category: 'DoS', threat: 'Resource exhaustion', risk: output.warning('Medium'), mitigation: 'Rate limiting' },
|
|
164
|
+
{ category: 'Elevation', threat: 'Privilege escalation', risk: output.error('High'), mitigation: 'RBAC implementation' },
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return { success: true };
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Audit subcommand
|
|
173
|
+
const auditCommand: Command = {
|
|
174
|
+
name: 'audit',
|
|
175
|
+
description: 'Security audit logging and compliance',
|
|
176
|
+
options: [
|
|
177
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: log, list, export, clear', default: 'list' },
|
|
178
|
+
{ name: 'limit', short: 'l', type: 'number', description: 'Number of entries to show', default: '20' },
|
|
179
|
+
{ name: 'filter', short: 'f', type: 'string', description: 'Filter by event type' },
|
|
180
|
+
],
|
|
181
|
+
examples: [
|
|
182
|
+
{ command: 'claude-flow security audit --action list', description: 'List audit logs' },
|
|
183
|
+
{ command: 'claude-flow security audit -a export', description: 'Export audit trail' },
|
|
184
|
+
],
|
|
185
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
186
|
+
const action = ctx.flags.action as string || 'list';
|
|
187
|
+
|
|
188
|
+
output.writeln();
|
|
189
|
+
output.writeln(output.bold('Security Audit Log'));
|
|
190
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
191
|
+
|
|
192
|
+
output.printTable({
|
|
193
|
+
columns: [
|
|
194
|
+
{ key: 'timestamp', header: 'Timestamp', width: 22 },
|
|
195
|
+
{ key: 'event', header: 'Event', width: 20 },
|
|
196
|
+
{ key: 'user', header: 'User', width: 15 },
|
|
197
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
198
|
+
],
|
|
199
|
+
data: [
|
|
200
|
+
{ timestamp: '2024-01-15 14:32:01', event: 'AUTH_LOGIN', user: 'admin', status: output.success('Success') },
|
|
201
|
+
{ timestamp: '2024-01-15 14:30:45', event: 'CONFIG_CHANGE', user: 'system', status: output.success('Success') },
|
|
202
|
+
{ timestamp: '2024-01-15 14:28:12', event: 'AUTH_FAILED', user: 'unknown', status: output.error('Failed') },
|
|
203
|
+
{ timestamp: '2024-01-15 14:25:33', event: 'SCAN_COMPLETE', user: 'ci-bot', status: output.success('Success') },
|
|
204
|
+
{ timestamp: '2024-01-15 14:20:00', event: 'KEY_ROTATE', user: 'admin', status: output.success('Success') },
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return { success: true };
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// Secrets subcommand
|
|
213
|
+
const secretsCommand: Command = {
|
|
214
|
+
name: 'secrets',
|
|
215
|
+
description: 'Detect and manage secrets in codebase',
|
|
216
|
+
options: [
|
|
217
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: scan, list, rotate', default: 'scan' },
|
|
218
|
+
{ name: 'path', short: 'p', type: 'string', description: 'Path to scan', default: '.' },
|
|
219
|
+
{ name: 'ignore', short: 'i', type: 'string', description: 'Patterns to ignore' },
|
|
220
|
+
],
|
|
221
|
+
examples: [
|
|
222
|
+
{ command: 'claude-flow security secrets --action scan', description: 'Scan for secrets' },
|
|
223
|
+
{ command: 'claude-flow security secrets -a rotate', description: 'Rotate compromised secrets' },
|
|
224
|
+
],
|
|
225
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
226
|
+
const path = ctx.flags.path as string || '.';
|
|
227
|
+
|
|
228
|
+
output.writeln();
|
|
229
|
+
output.writeln(output.bold('Secret Detection'));
|
|
230
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
231
|
+
|
|
232
|
+
const spinner = output.createSpinner({ text: 'Scanning for secrets...', spinner: 'dots' });
|
|
233
|
+
spinner.start();
|
|
234
|
+
await new Promise(r => setTimeout(r, 800));
|
|
235
|
+
spinner.succeed('Scan complete');
|
|
236
|
+
|
|
237
|
+
output.writeln();
|
|
238
|
+
output.printTable({
|
|
239
|
+
columns: [
|
|
240
|
+
{ key: 'type', header: 'Secret Type', width: 20 },
|
|
241
|
+
{ key: 'location', header: 'Location', width: 30 },
|
|
242
|
+
{ key: 'risk', header: 'Risk', width: 12 },
|
|
243
|
+
{ key: 'action', header: 'Recommended', width: 20 },
|
|
244
|
+
],
|
|
245
|
+
data: [
|
|
246
|
+
{ type: 'AWS Access Key', location: 'src/config.ts:15', risk: output.error('Critical'), action: 'Rotate immediately' },
|
|
247
|
+
{ type: 'GitHub Token', location: '.env.example:8', risk: output.warning('High'), action: 'Remove from repo' },
|
|
248
|
+
{ type: 'JWT Secret', location: 'src/auth.ts:42', risk: output.warning('High'), action: 'Use env variable' },
|
|
249
|
+
{ type: 'DB Password', location: 'docker-compose.yml:23', risk: output.warning('Medium'), action: 'Use secrets mgmt' },
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return { success: true };
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Main security command
|
|
258
|
+
export const securityCommand: Command = {
|
|
259
|
+
name: 'security',
|
|
260
|
+
description: 'Security scanning, CVE detection, threat modeling, vulnerability management',
|
|
261
|
+
subcommands: [scanCommand, cveCommand, threatsCommand, auditCommand, secretsCommand],
|
|
262
|
+
examples: [
|
|
263
|
+
{ command: 'claude-flow security scan', description: 'Run security scan' },
|
|
264
|
+
{ command: 'claude-flow security cve --list', description: 'List known CVEs' },
|
|
265
|
+
{ command: 'claude-flow security threats', description: 'Run threat analysis' },
|
|
266
|
+
],
|
|
267
|
+
action: async (): Promise<CommandResult> => {
|
|
268
|
+
output.writeln();
|
|
269
|
+
output.writeln(output.bold('Claude Flow Security Suite'));
|
|
270
|
+
output.writeln(output.dim('Comprehensive security scanning and vulnerability management'));
|
|
271
|
+
output.writeln();
|
|
272
|
+
output.writeln('Subcommands:');
|
|
273
|
+
output.printList([
|
|
274
|
+
'scan - Run security scans on code, deps, containers',
|
|
275
|
+
'cve - Check and manage CVE vulnerabilities',
|
|
276
|
+
'threats - Threat modeling (STRIDE, DREAD, PASTA)',
|
|
277
|
+
'audit - Security audit logging and compliance',
|
|
278
|
+
'secrets - Detect and manage secrets in codebase',
|
|
279
|
+
]);
|
|
280
|
+
output.writeln();
|
|
281
|
+
output.writeln('Use --help with subcommands for more info');
|
|
282
|
+
output.writeln();
|
|
283
|
+
output.writeln(output.dim('Created with ❤️ by ruv.io'));
|
|
284
|
+
return { success: true };
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export default securityCommand;
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* V3 CLI Main Entry Point
|
|
3
3
|
* Modernized CLI for Claude Flow V3
|
|
4
|
+
*
|
|
5
|
+
* Created with ❤️ by ruv.io
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
import { readFileSync } from 'fs';
|
|
@@ -267,6 +269,8 @@ export class CLI {
|
|
|
267
269
|
|
|
268
270
|
this.output.writeln(this.output.dim('Run "claude-flow <command> --help" for command help'));
|
|
269
271
|
this.output.writeln();
|
|
272
|
+
this.output.writeln(this.output.dim('Created with ❤️ by ruv.io'));
|
|
273
|
+
this.output.writeln();
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
/**
|