@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,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 CLI Claims Command
|
|
3
|
+
* Claims-based authorization, permissions, and access control
|
|
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 claims and permissions',
|
|
15
|
+
options: [
|
|
16
|
+
{ name: 'user', short: 'u', type: 'string', description: 'Filter by user ID' },
|
|
17
|
+
{ name: 'role', short: 'r', type: 'string', description: 'Filter by role' },
|
|
18
|
+
{ name: 'resource', type: 'string', description: 'Filter by resource' },
|
|
19
|
+
],
|
|
20
|
+
examples: [
|
|
21
|
+
{ command: 'claude-flow claims list', description: 'List all claims' },
|
|
22
|
+
{ command: 'claude-flow claims list -u user123', description: 'List user claims' },
|
|
23
|
+
],
|
|
24
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
25
|
+
output.writeln();
|
|
26
|
+
output.writeln(output.bold('Claims & Permissions'));
|
|
27
|
+
output.writeln(output.dim('─'.repeat(70)));
|
|
28
|
+
|
|
29
|
+
output.printTable({
|
|
30
|
+
columns: [
|
|
31
|
+
{ key: 'claim', header: 'Claim', width: 25 },
|
|
32
|
+
{ key: 'type', header: 'Type', width: 12 },
|
|
33
|
+
{ key: 'scope', header: 'Scope', width: 15 },
|
|
34
|
+
{ key: 'value', header: 'Value', width: 20 },
|
|
35
|
+
],
|
|
36
|
+
data: [
|
|
37
|
+
{ claim: 'swarm:create', type: 'Permission', scope: 'Global', value: output.success('Allowed') },
|
|
38
|
+
{ claim: 'swarm:delete', type: 'Permission', scope: 'Owned', value: output.success('Allowed') },
|
|
39
|
+
{ claim: 'agent:spawn', type: 'Permission', scope: 'Global', value: output.success('Allowed') },
|
|
40
|
+
{ claim: 'memory:read', type: 'Permission', scope: 'Namespace', value: output.success('Allowed') },
|
|
41
|
+
{ claim: 'memory:write', type: 'Permission', scope: 'Namespace', value: output.success('Allowed') },
|
|
42
|
+
{ claim: 'admin:*', type: 'Permission', scope: 'Global', value: output.error('Denied') },
|
|
43
|
+
{ claim: 'role', type: 'Identity', scope: 'System', value: 'developer' },
|
|
44
|
+
{ claim: 'tier', type: 'Identity', scope: 'System', value: 'pro' },
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { success: true };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Check subcommand
|
|
53
|
+
const checkCommand: Command = {
|
|
54
|
+
name: 'check',
|
|
55
|
+
description: 'Check if a specific claim is granted',
|
|
56
|
+
options: [
|
|
57
|
+
{ name: 'claim', short: 'c', type: 'string', description: 'Claim to check', required: true },
|
|
58
|
+
{ name: 'user', short: 'u', type: 'string', description: 'User ID to check' },
|
|
59
|
+
{ name: 'resource', short: 'r', type: 'string', description: 'Resource context' },
|
|
60
|
+
],
|
|
61
|
+
examples: [
|
|
62
|
+
{ command: 'claude-flow claims check -c swarm:create', description: 'Check swarm creation permission' },
|
|
63
|
+
{ command: 'claude-flow claims check -c admin:delete -u user123', description: 'Check user permission' },
|
|
64
|
+
],
|
|
65
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
66
|
+
const claim = ctx.flags.claim as string;
|
|
67
|
+
const user = ctx.flags.user as string || 'current';
|
|
68
|
+
|
|
69
|
+
if (!claim) {
|
|
70
|
+
output.printError('Claim is required');
|
|
71
|
+
return { success: false, exitCode: 1 };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
output.writeln();
|
|
75
|
+
output.writeln(output.bold('Claim Check'));
|
|
76
|
+
output.writeln(output.dim('─'.repeat(40)));
|
|
77
|
+
|
|
78
|
+
const spinner = output.createSpinner({ text: 'Evaluating claim...', spinner: 'dots' });
|
|
79
|
+
spinner.start();
|
|
80
|
+
await new Promise(r => setTimeout(r, 300));
|
|
81
|
+
|
|
82
|
+
// Simulate claim check
|
|
83
|
+
const isGranted = !claim.startsWith('admin:');
|
|
84
|
+
|
|
85
|
+
if (isGranted) {
|
|
86
|
+
spinner.succeed('Claim granted');
|
|
87
|
+
} else {
|
|
88
|
+
spinner.fail('Claim denied');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
output.writeln();
|
|
92
|
+
output.printBox([
|
|
93
|
+
`Claim: ${claim}`,
|
|
94
|
+
`User: ${user}`,
|
|
95
|
+
`Result: ${isGranted ? output.success('GRANTED') : output.error('DENIED')}`,
|
|
96
|
+
``,
|
|
97
|
+
`Reason: ${isGranted ? 'User has required role' : 'Requires admin role'}`,
|
|
98
|
+
].join('\n'), 'Result');
|
|
99
|
+
|
|
100
|
+
return { success: true };
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Grant subcommand
|
|
105
|
+
const grantCommand: Command = {
|
|
106
|
+
name: 'grant',
|
|
107
|
+
description: 'Grant a claim to user or role',
|
|
108
|
+
options: [
|
|
109
|
+
{ name: 'claim', short: 'c', type: 'string', description: 'Claim to grant', required: true },
|
|
110
|
+
{ name: 'user', short: 'u', type: 'string', description: 'User ID' },
|
|
111
|
+
{ name: 'role', short: 'r', type: 'string', description: 'Role name' },
|
|
112
|
+
{ name: 'scope', short: 's', type: 'string', description: 'Scope: global, namespace, resource', default: 'global' },
|
|
113
|
+
{ name: 'expires', short: 'e', type: 'string', description: 'Expiration time (e.g., 24h, 7d)' },
|
|
114
|
+
],
|
|
115
|
+
examples: [
|
|
116
|
+
{ command: 'claude-flow claims grant -c swarm:create -u user123', description: 'Grant to user' },
|
|
117
|
+
{ command: 'claude-flow claims grant -c agent:spawn -r developer', description: 'Grant to role' },
|
|
118
|
+
],
|
|
119
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
120
|
+
const claim = ctx.flags.claim as string;
|
|
121
|
+
const user = ctx.flags.user as string;
|
|
122
|
+
const role = ctx.flags.role as string;
|
|
123
|
+
const scope = ctx.flags.scope as string || 'global';
|
|
124
|
+
|
|
125
|
+
if (!claim) {
|
|
126
|
+
output.printError('Claim is required');
|
|
127
|
+
return { success: false, exitCode: 1 };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!user && !role) {
|
|
131
|
+
output.printError('Either user or role is required');
|
|
132
|
+
return { success: false, exitCode: 1 };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
output.writeln();
|
|
136
|
+
const spinner = output.createSpinner({ text: 'Granting claim...', spinner: 'dots' });
|
|
137
|
+
spinner.start();
|
|
138
|
+
await new Promise(r => setTimeout(r, 400));
|
|
139
|
+
spinner.succeed('Claim granted');
|
|
140
|
+
|
|
141
|
+
output.writeln();
|
|
142
|
+
output.printBox([
|
|
143
|
+
`Claim: ${claim}`,
|
|
144
|
+
`Target: ${user ? `User: ${user}` : `Role: ${role}`}`,
|
|
145
|
+
`Scope: ${scope}`,
|
|
146
|
+
`Status: ${output.success('Active')}`,
|
|
147
|
+
].join('\n'), 'Grant Complete');
|
|
148
|
+
|
|
149
|
+
return { success: true };
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Revoke subcommand
|
|
154
|
+
const revokeCommand: Command = {
|
|
155
|
+
name: 'revoke',
|
|
156
|
+
description: 'Revoke a claim from user or role',
|
|
157
|
+
options: [
|
|
158
|
+
{ name: 'claim', short: 'c', type: 'string', description: 'Claim to revoke', required: true },
|
|
159
|
+
{ name: 'user', short: 'u', type: 'string', description: 'User ID' },
|
|
160
|
+
{ name: 'role', short: 'r', type: 'string', description: 'Role name' },
|
|
161
|
+
],
|
|
162
|
+
examples: [
|
|
163
|
+
{ command: 'claude-flow claims revoke -c swarm:delete -u user123', description: 'Revoke from user' },
|
|
164
|
+
{ command: 'claude-flow claims revoke -c admin:* -r guest', description: 'Revoke from role' },
|
|
165
|
+
],
|
|
166
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
167
|
+
const claim = ctx.flags.claim as string;
|
|
168
|
+
const user = ctx.flags.user as string;
|
|
169
|
+
const role = ctx.flags.role as string;
|
|
170
|
+
|
|
171
|
+
if (!claim) {
|
|
172
|
+
output.printError('Claim is required');
|
|
173
|
+
return { success: false, exitCode: 1 };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
output.writeln();
|
|
177
|
+
const spinner = output.createSpinner({ text: 'Revoking claim...', spinner: 'dots' });
|
|
178
|
+
spinner.start();
|
|
179
|
+
await new Promise(r => setTimeout(r, 300));
|
|
180
|
+
spinner.succeed('Claim revoked');
|
|
181
|
+
|
|
182
|
+
return { success: true };
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Roles subcommand
|
|
187
|
+
const rolesCommand: Command = {
|
|
188
|
+
name: 'roles',
|
|
189
|
+
description: 'Manage roles and their claims',
|
|
190
|
+
options: [
|
|
191
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: list, create, delete, show', default: 'list' },
|
|
192
|
+
{ name: 'name', short: 'n', type: 'string', description: 'Role name' },
|
|
193
|
+
],
|
|
194
|
+
examples: [
|
|
195
|
+
{ command: 'claude-flow claims roles', description: 'List all roles' },
|
|
196
|
+
{ command: 'claude-flow claims roles -a show -n admin', description: 'Show role details' },
|
|
197
|
+
],
|
|
198
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
199
|
+
const action = ctx.flags.action as string || 'list';
|
|
200
|
+
const name = ctx.flags.name as string;
|
|
201
|
+
|
|
202
|
+
output.writeln();
|
|
203
|
+
output.writeln(output.bold('Roles'));
|
|
204
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
205
|
+
|
|
206
|
+
if (action === 'show' && name) {
|
|
207
|
+
output.printBox([
|
|
208
|
+
`Role: ${name}`,
|
|
209
|
+
`Description: Full system access`,
|
|
210
|
+
``,
|
|
211
|
+
`Claims:`,
|
|
212
|
+
` - swarm:* (all swarm operations)`,
|
|
213
|
+
` - agent:* (all agent operations)`,
|
|
214
|
+
` - memory:* (all memory operations)`,
|
|
215
|
+
` - admin:* (administrative functions)`,
|
|
216
|
+
``,
|
|
217
|
+
`Members: 2`,
|
|
218
|
+
`Created: 2024-01-01`,
|
|
219
|
+
].join('\n'), 'Role Details');
|
|
220
|
+
} else {
|
|
221
|
+
output.printTable({
|
|
222
|
+
columns: [
|
|
223
|
+
{ key: 'role', header: 'Role', width: 15 },
|
|
224
|
+
{ key: 'description', header: 'Description', width: 30 },
|
|
225
|
+
{ key: 'claims', header: 'Claims', width: 12 },
|
|
226
|
+
{ key: 'members', header: 'Members', width: 10 },
|
|
227
|
+
],
|
|
228
|
+
data: [
|
|
229
|
+
{ role: output.highlight('admin'), description: 'Full system access', claims: '15', members: '2' },
|
|
230
|
+
{ role: output.highlight('developer'), description: 'Development operations', claims: '10', members: '12' },
|
|
231
|
+
{ role: output.highlight('operator'), description: 'Operational tasks', claims: '8', members: '5' },
|
|
232
|
+
{ role: output.highlight('viewer'), description: 'Read-only access', claims: '3', members: '25' },
|
|
233
|
+
{ role: output.highlight('guest'), description: 'Limited access', claims: '1', members: '100' },
|
|
234
|
+
],
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return { success: true };
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// Policies subcommand
|
|
243
|
+
const policiesCommand: Command = {
|
|
244
|
+
name: 'policies',
|
|
245
|
+
description: 'Manage claim policies',
|
|
246
|
+
options: [
|
|
247
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: list, create, delete', default: 'list' },
|
|
248
|
+
{ name: 'name', short: 'n', type: 'string', description: 'Policy name' },
|
|
249
|
+
],
|
|
250
|
+
examples: [
|
|
251
|
+
{ command: 'claude-flow claims policies', description: 'List policies' },
|
|
252
|
+
{ command: 'claude-flow claims policies -a create -n rate-limit', description: 'Create policy' },
|
|
253
|
+
],
|
|
254
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
255
|
+
output.writeln();
|
|
256
|
+
output.writeln(output.bold('Claim Policies'));
|
|
257
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
258
|
+
|
|
259
|
+
output.printTable({
|
|
260
|
+
columns: [
|
|
261
|
+
{ key: 'policy', header: 'Policy', width: 20 },
|
|
262
|
+
{ key: 'type', header: 'Type', width: 15 },
|
|
263
|
+
{ key: 'condition', header: 'Condition', width: 30 },
|
|
264
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
265
|
+
],
|
|
266
|
+
data: [
|
|
267
|
+
{ policy: 'rate-limit', type: 'Throttle', condition: 'Max 100 req/min', status: output.success('Active') },
|
|
268
|
+
{ policy: 'geo-restrict', type: 'Location', condition: 'US, EU only', status: output.success('Active') },
|
|
269
|
+
{ policy: 'time-window', type: 'Temporal', condition: 'Business hours', status: output.dim('Inactive') },
|
|
270
|
+
{ policy: 'ip-allowlist', type: 'Network', condition: '10.0.0.0/8', status: output.success('Active') },
|
|
271
|
+
{ policy: 'mfa-required', type: 'Auth', condition: 'Admin operations', status: output.success('Active') },
|
|
272
|
+
],
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return { success: true };
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// Main claims command
|
|
280
|
+
export const claimsCommand: Command = {
|
|
281
|
+
name: 'claims',
|
|
282
|
+
description: 'Claims-based authorization, permissions, and access control',
|
|
283
|
+
subcommands: [listCommand, checkCommand, grantCommand, revokeCommand, rolesCommand, policiesCommand],
|
|
284
|
+
examples: [
|
|
285
|
+
{ command: 'claude-flow claims list', description: 'List all claims' },
|
|
286
|
+
{ command: 'claude-flow claims check -c swarm:create', description: 'Check permission' },
|
|
287
|
+
{ command: 'claude-flow claims grant -c agent:spawn -r developer', description: 'Grant claim' },
|
|
288
|
+
],
|
|
289
|
+
action: async (): Promise<CommandResult> => {
|
|
290
|
+
output.writeln();
|
|
291
|
+
output.writeln(output.bold('Claude Flow Claims System'));
|
|
292
|
+
output.writeln(output.dim('Fine-grained authorization and access control'));
|
|
293
|
+
output.writeln();
|
|
294
|
+
output.writeln('Subcommands:');
|
|
295
|
+
output.printList([
|
|
296
|
+
'list - List claims and permissions',
|
|
297
|
+
'check - Check if a claim is granted',
|
|
298
|
+
'grant - Grant a claim to user or role',
|
|
299
|
+
'revoke - Revoke a claim',
|
|
300
|
+
'roles - Manage roles and their claims',
|
|
301
|
+
'policies - Manage claim policies',
|
|
302
|
+
]);
|
|
303
|
+
output.writeln();
|
|
304
|
+
output.writeln('Claim Types:');
|
|
305
|
+
output.printList([
|
|
306
|
+
'swarm:* - Swarm operations (create, delete, scale)',
|
|
307
|
+
'agent:* - Agent operations (spawn, terminate)',
|
|
308
|
+
'memory:* - Memory operations (read, write, delete)',
|
|
309
|
+
'admin:* - Administrative operations',
|
|
310
|
+
]);
|
|
311
|
+
output.writeln();
|
|
312
|
+
output.writeln(output.dim('Created with ❤️ by ruv.io'));
|
|
313
|
+
return { success: true };
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export default claimsCommand;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 CLI Deployment Command
|
|
3
|
+
* Deployment management, environments, rollbacks
|
|
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
|
+
// Deploy subcommand
|
|
12
|
+
const deployCommand: Command = {
|
|
13
|
+
name: 'deploy',
|
|
14
|
+
description: 'Deploy to target environment',
|
|
15
|
+
options: [
|
|
16
|
+
{ name: 'env', short: 'e', type: 'string', description: 'Environment: dev, staging, prod', default: 'staging' },
|
|
17
|
+
{ name: 'version', short: 'v', type: 'string', description: 'Version to deploy', default: 'latest' },
|
|
18
|
+
{ name: 'dry-run', short: 'd', type: 'boolean', description: 'Simulate deployment without changes' },
|
|
19
|
+
{ name: 'force', short: 'f', type: 'boolean', description: 'Force deployment without checks' },
|
|
20
|
+
{ name: 'rollback-on-fail', type: 'boolean', description: 'Auto rollback on failure', default: 'true' },
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
{ command: 'claude-flow deployment deploy -e prod', description: 'Deploy to production' },
|
|
24
|
+
{ command: 'claude-flow deployment deploy --dry-run', description: 'Simulate deployment' },
|
|
25
|
+
],
|
|
26
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
27
|
+
const env = ctx.flags.env as string || 'staging';
|
|
28
|
+
const version = ctx.flags.version as string || 'latest';
|
|
29
|
+
const dryRun = ctx.flags['dry-run'] as boolean;
|
|
30
|
+
|
|
31
|
+
output.writeln();
|
|
32
|
+
output.writeln(output.bold(`Deployment: ${env.toUpperCase()}`));
|
|
33
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
34
|
+
|
|
35
|
+
if (dryRun) {
|
|
36
|
+
output.printWarning('DRY RUN - No changes will be made');
|
|
37
|
+
output.writeln();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const steps = [
|
|
41
|
+
{ name: 'Pre-flight checks', status: 'running' },
|
|
42
|
+
{ name: 'Build artifacts', status: 'pending' },
|
|
43
|
+
{ name: 'Run tests', status: 'pending' },
|
|
44
|
+
{ name: 'Security scan', status: 'pending' },
|
|
45
|
+
{ name: 'Deploy to target', status: 'pending' },
|
|
46
|
+
{ name: 'Health checks', status: 'pending' },
|
|
47
|
+
{ name: 'DNS update', status: 'pending' },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
for (const step of steps) {
|
|
51
|
+
const spinner = output.createSpinner({ text: step.name + '...', spinner: 'dots' });
|
|
52
|
+
spinner.start();
|
|
53
|
+
await new Promise(r => setTimeout(r, 400));
|
|
54
|
+
spinner.succeed(step.name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
output.writeln();
|
|
58
|
+
output.printBox([
|
|
59
|
+
`Environment: ${env}`,
|
|
60
|
+
`Version: ${version}`,
|
|
61
|
+
`Status: ${output.success('Deployed')}`,
|
|
62
|
+
``,
|
|
63
|
+
`URL: https://${env === 'prod' ? 'api' : env}.claude-flow.io`,
|
|
64
|
+
`Deployed at: ${new Date().toISOString()}`,
|
|
65
|
+
`Duration: 12.4s`,
|
|
66
|
+
].join('\n'), 'Deployment Complete');
|
|
67
|
+
|
|
68
|
+
return { success: true };
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Status subcommand
|
|
73
|
+
const statusCommand: Command = {
|
|
74
|
+
name: 'status',
|
|
75
|
+
description: 'Check deployment status across environments',
|
|
76
|
+
options: [
|
|
77
|
+
{ name: 'env', short: 'e', type: 'string', description: 'Specific environment to check' },
|
|
78
|
+
{ name: 'watch', short: 'w', type: 'boolean', description: 'Watch for changes' },
|
|
79
|
+
],
|
|
80
|
+
examples: [
|
|
81
|
+
{ command: 'claude-flow deployment status', description: 'Show all environments' },
|
|
82
|
+
{ command: 'claude-flow deployment status -e prod', description: 'Check production' },
|
|
83
|
+
],
|
|
84
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
85
|
+
output.writeln();
|
|
86
|
+
output.writeln(output.bold('Deployment Status'));
|
|
87
|
+
output.writeln(output.dim('─'.repeat(70)));
|
|
88
|
+
|
|
89
|
+
output.printTable({
|
|
90
|
+
columns: [
|
|
91
|
+
{ key: 'env', header: 'Environment', width: 12 },
|
|
92
|
+
{ key: 'version', header: 'Version', width: 18 },
|
|
93
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
94
|
+
{ key: 'health', header: 'Health', width: 10 },
|
|
95
|
+
{ key: 'deployed', header: 'Deployed', width: 20 },
|
|
96
|
+
],
|
|
97
|
+
data: [
|
|
98
|
+
{ env: 'Production', version: 'v3.0.0-alpha.10', status: output.success('Active'), health: output.success('100%'), deployed: '2h ago' },
|
|
99
|
+
{ env: 'Staging', version: 'v3.0.0-alpha.11', status: output.success('Active'), health: output.success('100%'), deployed: '30m ago' },
|
|
100
|
+
{ env: 'Development', version: 'v3.0.0-alpha.12', status: output.success('Active'), health: output.success('100%'), deployed: '5m ago' },
|
|
101
|
+
{ env: 'Preview', version: 'pr-456', status: output.warning('Deploying'), health: output.dim('--'), deployed: 'In progress' },
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return { success: true };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Rollback subcommand
|
|
110
|
+
const rollbackCommand: Command = {
|
|
111
|
+
name: 'rollback',
|
|
112
|
+
description: 'Rollback to previous deployment',
|
|
113
|
+
options: [
|
|
114
|
+
{ name: 'env', short: 'e', type: 'string', description: 'Environment to rollback', required: true },
|
|
115
|
+
{ name: 'version', short: 'v', type: 'string', description: 'Specific version to rollback to' },
|
|
116
|
+
{ name: 'steps', short: 's', type: 'number', description: 'Number of versions to rollback', default: '1' },
|
|
117
|
+
],
|
|
118
|
+
examples: [
|
|
119
|
+
{ command: 'claude-flow deployment rollback -e prod', description: 'Rollback production' },
|
|
120
|
+
{ command: 'claude-flow deployment rollback -e prod -v v3.0.0', description: 'Rollback to specific version' },
|
|
121
|
+
],
|
|
122
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
123
|
+
const env = ctx.flags.env as string;
|
|
124
|
+
const version = ctx.flags.version as string;
|
|
125
|
+
|
|
126
|
+
if (!env) {
|
|
127
|
+
output.printError('Environment is required for rollback');
|
|
128
|
+
return { success: false, exitCode: 1 };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
output.writeln();
|
|
132
|
+
output.writeln(output.bold(`Rollback: ${env.toUpperCase()}`));
|
|
133
|
+
output.writeln(output.dim('─'.repeat(40)));
|
|
134
|
+
|
|
135
|
+
output.printWarning(`Rolling back ${env} to ${version || 'previous version'}`);
|
|
136
|
+
output.writeln();
|
|
137
|
+
|
|
138
|
+
const spinner = output.createSpinner({ text: 'Initiating rollback...', spinner: 'dots' });
|
|
139
|
+
spinner.start();
|
|
140
|
+
|
|
141
|
+
const steps = ['Stopping current deployment', 'Restoring previous version', 'Running health checks', 'Updating DNS'];
|
|
142
|
+
for (const step of steps) {
|
|
143
|
+
spinner.setText(step + '...');
|
|
144
|
+
await new Promise(r => setTimeout(r, 400));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
spinner.succeed('Rollback complete');
|
|
148
|
+
|
|
149
|
+
output.writeln();
|
|
150
|
+
output.printBox([
|
|
151
|
+
`Environment: ${env}`,
|
|
152
|
+
`Rolled back to: ${version || 'v3.0.0-alpha.9'}`,
|
|
153
|
+
`Status: ${output.success('Active')}`,
|
|
154
|
+
].join('\n'), 'Rollback Complete');
|
|
155
|
+
|
|
156
|
+
return { success: true };
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// History subcommand
|
|
161
|
+
const historyCommand: Command = {
|
|
162
|
+
name: 'history',
|
|
163
|
+
description: 'View deployment history',
|
|
164
|
+
options: [
|
|
165
|
+
{ name: 'env', short: 'e', type: 'string', description: 'Filter by environment' },
|
|
166
|
+
{ name: 'limit', short: 'l', type: 'number', description: 'Number of entries', default: '10' },
|
|
167
|
+
],
|
|
168
|
+
examples: [
|
|
169
|
+
{ command: 'claude-flow deployment history', description: 'Show all history' },
|
|
170
|
+
{ command: 'claude-flow deployment history -e prod', description: 'Production history' },
|
|
171
|
+
],
|
|
172
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
173
|
+
const env = ctx.flags.env as string;
|
|
174
|
+
|
|
175
|
+
output.writeln();
|
|
176
|
+
output.writeln(output.bold(`Deployment History${env ? `: ${env}` : ''}`));
|
|
177
|
+
output.writeln(output.dim('─'.repeat(80)));
|
|
178
|
+
|
|
179
|
+
output.printTable({
|
|
180
|
+
columns: [
|
|
181
|
+
{ key: 'id', header: 'ID', width: 10 },
|
|
182
|
+
{ key: 'env', header: 'Env', width: 10 },
|
|
183
|
+
{ key: 'version', header: 'Version', width: 18 },
|
|
184
|
+
{ key: 'status', header: 'Status', width: 12 },
|
|
185
|
+
{ key: 'deployer', header: 'Deployer', width: 12 },
|
|
186
|
+
{ key: 'timestamp', header: 'Timestamp', width: 20 },
|
|
187
|
+
],
|
|
188
|
+
data: [
|
|
189
|
+
{ id: 'dep-123', env: 'prod', version: 'v3.0.0-alpha.10', status: output.success('Success'), deployer: 'ci-bot', timestamp: '2024-01-15 14:30' },
|
|
190
|
+
{ id: 'dep-122', env: 'staging', version: 'v3.0.0-alpha.11', status: output.success('Success'), deployer: 'ci-bot', timestamp: '2024-01-15 14:00' },
|
|
191
|
+
{ id: 'dep-121', env: 'prod', version: 'v3.0.0-alpha.9', status: output.dim('Rolled back'), deployer: 'ci-bot', timestamp: '2024-01-15 12:30' },
|
|
192
|
+
{ id: 'dep-120', env: 'staging', version: 'v3.0.0-alpha.10', status: output.success('Success'), deployer: 'developer', timestamp: '2024-01-15 10:00' },
|
|
193
|
+
{ id: 'dep-119', env: 'dev', version: 'v3.0.0-alpha.10', status: output.error('Failed'), deployer: 'developer', timestamp: '2024-01-15 09:30' },
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return { success: true };
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Environments subcommand
|
|
202
|
+
const environmentsCommand: Command = {
|
|
203
|
+
name: 'environments',
|
|
204
|
+
description: 'Manage deployment environments',
|
|
205
|
+
aliases: ['envs'],
|
|
206
|
+
options: [
|
|
207
|
+
{ name: 'action', short: 'a', type: 'string', description: 'Action: list, create, delete', default: 'list' },
|
|
208
|
+
{ name: 'name', short: 'n', type: 'string', description: 'Environment name' },
|
|
209
|
+
],
|
|
210
|
+
examples: [
|
|
211
|
+
{ command: 'claude-flow deployment environments', description: 'List environments' },
|
|
212
|
+
{ command: 'claude-flow deployment envs -a create -n preview', description: 'Create environment' },
|
|
213
|
+
],
|
|
214
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
215
|
+
output.writeln();
|
|
216
|
+
output.writeln(output.bold('Deployment Environments'));
|
|
217
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
218
|
+
|
|
219
|
+
output.printTable({
|
|
220
|
+
columns: [
|
|
221
|
+
{ key: 'name', header: 'Name', width: 15 },
|
|
222
|
+
{ key: 'url', header: 'URL', width: 30 },
|
|
223
|
+
{ key: 'auto', header: 'Auto Deploy', width: 12 },
|
|
224
|
+
{ key: 'protected', header: 'Protected', width: 12 },
|
|
225
|
+
],
|
|
226
|
+
data: [
|
|
227
|
+
{ name: 'production', url: 'https://api.claude-flow.io', auto: output.error('No'), protected: output.success('Yes') },
|
|
228
|
+
{ name: 'staging', url: 'https://staging.claude-flow.io', auto: output.success('Yes'), protected: output.error('No') },
|
|
229
|
+
{ name: 'development', url: 'https://dev.claude-flow.io', auto: output.success('Yes'), protected: output.error('No') },
|
|
230
|
+
{ name: 'preview/*', url: 'https://pr-*.claude-flow.io', auto: output.success('Yes'), protected: output.error('No') },
|
|
231
|
+
],
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
return { success: true };
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// Logs subcommand
|
|
239
|
+
const logsCommand: Command = {
|
|
240
|
+
name: 'logs',
|
|
241
|
+
description: 'View deployment logs',
|
|
242
|
+
options: [
|
|
243
|
+
{ name: 'deployment', short: 'd', type: 'string', description: 'Deployment ID' },
|
|
244
|
+
{ name: 'env', short: 'e', type: 'string', description: 'Environment' },
|
|
245
|
+
{ name: 'follow', short: 'f', type: 'boolean', description: 'Follow log output' },
|
|
246
|
+
{ name: 'lines', short: 'n', type: 'number', description: 'Number of lines', default: '50' },
|
|
247
|
+
],
|
|
248
|
+
examples: [
|
|
249
|
+
{ command: 'claude-flow deployment logs -e prod', description: 'View production logs' },
|
|
250
|
+
{ command: 'claude-flow deployment logs -d dep-123', description: 'View specific deployment' },
|
|
251
|
+
],
|
|
252
|
+
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
|
253
|
+
const env = ctx.flags.env as string || 'staging';
|
|
254
|
+
|
|
255
|
+
output.writeln();
|
|
256
|
+
output.writeln(output.bold(`Deployment Logs: ${env}`));
|
|
257
|
+
output.writeln(output.dim('─'.repeat(60)));
|
|
258
|
+
output.writeln();
|
|
259
|
+
|
|
260
|
+
const logs = [
|
|
261
|
+
{ time: '14:30:01', level: 'INFO', msg: 'Starting deployment v3.0.0-alpha.10' },
|
|
262
|
+
{ time: '14:30:02', level: 'INFO', msg: 'Building Docker image...' },
|
|
263
|
+
{ time: '14:30:15', level: 'INFO', msg: 'Image built: sha256:abc123...' },
|
|
264
|
+
{ time: '14:30:16', level: 'INFO', msg: 'Pushing to registry...' },
|
|
265
|
+
{ time: '14:30:25', level: 'INFO', msg: 'Deploying to kubernetes...' },
|
|
266
|
+
{ time: '14:30:30', level: 'INFO', msg: 'Rolling update started' },
|
|
267
|
+
{ time: '14:30:45', level: 'INFO', msg: 'Health check passed (1/3)' },
|
|
268
|
+
{ time: '14:30:50', level: 'INFO', msg: 'Health check passed (2/3)' },
|
|
269
|
+
{ time: '14:30:55', level: 'INFO', msg: 'Health check passed (3/3)' },
|
|
270
|
+
{ time: '14:31:00', level: 'INFO', msg: 'Deployment complete!' },
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
for (const log of logs) {
|
|
274
|
+
const levelColor = log.level === 'ERROR' ? output.error(log.level) :
|
|
275
|
+
log.level === 'WARN' ? output.warning(log.level) :
|
|
276
|
+
output.dim(log.level);
|
|
277
|
+
output.writeln(`${output.dim(log.time)} ${levelColor} ${log.msg}`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { success: true };
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// Main deployment command
|
|
285
|
+
export const deploymentCommand: Command = {
|
|
286
|
+
name: 'deployment',
|
|
287
|
+
description: 'Deployment management, environments, rollbacks',
|
|
288
|
+
aliases: ['deploy'],
|
|
289
|
+
subcommands: [deployCommand, statusCommand, rollbackCommand, historyCommand, environmentsCommand, logsCommand],
|
|
290
|
+
examples: [
|
|
291
|
+
{ command: 'claude-flow deployment deploy -e prod', description: 'Deploy to production' },
|
|
292
|
+
{ command: 'claude-flow deployment status', description: 'Check all environments' },
|
|
293
|
+
{ command: 'claude-flow deployment rollback -e prod', description: 'Rollback production' },
|
|
294
|
+
],
|
|
295
|
+
action: async (): Promise<CommandResult> => {
|
|
296
|
+
output.writeln();
|
|
297
|
+
output.writeln(output.bold('Claude Flow Deployment'));
|
|
298
|
+
output.writeln(output.dim('Multi-environment deployment management'));
|
|
299
|
+
output.writeln();
|
|
300
|
+
output.writeln('Subcommands:');
|
|
301
|
+
output.printList([
|
|
302
|
+
'deploy - Deploy to target environment',
|
|
303
|
+
'status - Check deployment status',
|
|
304
|
+
'rollback - Rollback to previous version',
|
|
305
|
+
'history - View deployment history',
|
|
306
|
+
'environments - Manage deployment environments',
|
|
307
|
+
'logs - View deployment logs',
|
|
308
|
+
]);
|
|
309
|
+
output.writeln();
|
|
310
|
+
output.writeln('Features:');
|
|
311
|
+
output.printList([
|
|
312
|
+
'Zero-downtime rolling deployments',
|
|
313
|
+
'Automatic rollback on failure',
|
|
314
|
+
'Environment-specific configurations',
|
|
315
|
+
'Deployment previews for PRs',
|
|
316
|
+
]);
|
|
317
|
+
output.writeln();
|
|
318
|
+
output.writeln(output.dim('Created with ❤️ by ruv.io'));
|
|
319
|
+
return { success: true };
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export default deploymentCommand;
|