claude-flow 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +612 -0
  3. package/bin/claude-flow +0 -0
  4. package/bin/claude-flow-simple +0 -0
  5. package/bin/claude-flow-typecheck +0 -0
  6. package/deno.json +84 -0
  7. package/package.json +45 -0
  8. package/scripts/check-links.ts +274 -0
  9. package/scripts/check-performance-regression.ts +168 -0
  10. package/scripts/claude-sparc.sh +562 -0
  11. package/scripts/coverage-report.ts +692 -0
  12. package/scripts/demo-task-system.ts +224 -0
  13. package/scripts/install.js +72 -0
  14. package/scripts/test-batch-tasks.ts +29 -0
  15. package/scripts/test-coordination-features.ts +238 -0
  16. package/scripts/test-mcp.ts +251 -0
  17. package/scripts/test-runner.ts +571 -0
  18. package/scripts/validate-examples.ts +288 -0
  19. package/src/cli/cli-core.ts +273 -0
  20. package/src/cli/commands/agent.ts +83 -0
  21. package/src/cli/commands/config.ts +442 -0
  22. package/src/cli/commands/help.ts +765 -0
  23. package/src/cli/commands/index.ts +963 -0
  24. package/src/cli/commands/mcp.ts +191 -0
  25. package/src/cli/commands/memory.ts +74 -0
  26. package/src/cli/commands/monitor.ts +403 -0
  27. package/src/cli/commands/session.ts +595 -0
  28. package/src/cli/commands/start.ts +156 -0
  29. package/src/cli/commands/status.ts +345 -0
  30. package/src/cli/commands/task.ts +79 -0
  31. package/src/cli/commands/workflow.ts +763 -0
  32. package/src/cli/completion.ts +553 -0
  33. package/src/cli/formatter.ts +310 -0
  34. package/src/cli/index.ts +211 -0
  35. package/src/cli/main.ts +23 -0
  36. package/src/cli/repl.ts +1050 -0
  37. package/src/cli/simple-cli.js +211 -0
  38. package/src/cli/simple-cli.ts +211 -0
  39. package/src/coordination/README.md +400 -0
  40. package/src/coordination/advanced-scheduler.ts +487 -0
  41. package/src/coordination/circuit-breaker.ts +366 -0
  42. package/src/coordination/conflict-resolution.ts +490 -0
  43. package/src/coordination/dependency-graph.ts +475 -0
  44. package/src/coordination/index.ts +63 -0
  45. package/src/coordination/manager.ts +460 -0
  46. package/src/coordination/messaging.ts +290 -0
  47. package/src/coordination/metrics.ts +585 -0
  48. package/src/coordination/resources.ts +322 -0
  49. package/src/coordination/scheduler.ts +390 -0
  50. package/src/coordination/work-stealing.ts +224 -0
  51. package/src/core/config.ts +627 -0
  52. package/src/core/event-bus.ts +186 -0
  53. package/src/core/json-persistence.ts +183 -0
  54. package/src/core/logger.ts +262 -0
  55. package/src/core/orchestrator-fixed.ts +312 -0
  56. package/src/core/orchestrator.ts +1234 -0
  57. package/src/core/persistence.ts +276 -0
  58. package/src/mcp/auth.ts +438 -0
  59. package/src/mcp/claude-flow-tools.ts +1280 -0
  60. package/src/mcp/load-balancer.ts +510 -0
  61. package/src/mcp/router.ts +240 -0
  62. package/src/mcp/server.ts +548 -0
  63. package/src/mcp/session-manager.ts +418 -0
  64. package/src/mcp/tools.ts +180 -0
  65. package/src/mcp/transports/base.ts +21 -0
  66. package/src/mcp/transports/http.ts +457 -0
  67. package/src/mcp/transports/stdio.ts +254 -0
  68. package/src/memory/backends/base.ts +22 -0
  69. package/src/memory/backends/markdown.ts +283 -0
  70. package/src/memory/backends/sqlite.ts +329 -0
  71. package/src/memory/cache.ts +238 -0
  72. package/src/memory/indexer.ts +238 -0
  73. package/src/memory/manager.ts +572 -0
  74. package/src/terminal/adapters/base.ts +29 -0
  75. package/src/terminal/adapters/native.ts +504 -0
  76. package/src/terminal/adapters/vscode.ts +340 -0
  77. package/src/terminal/manager.ts +308 -0
  78. package/src/terminal/pool.ts +271 -0
  79. package/src/terminal/session.ts +250 -0
  80. package/src/terminal/vscode-bridge.ts +242 -0
  81. package/src/utils/errors.ts +231 -0
  82. package/src/utils/helpers.ts +476 -0
  83. package/src/utils/types.ts +493 -0
@@ -0,0 +1,553 @@
1
+ /**
2
+ * Shell completion generator for Claude-Flow CLI
3
+ */
4
+
5
+ import { colors } from '@cliffy/ansi/colors';
6
+
7
+ export class CompletionGenerator {
8
+ private commands = [
9
+ 'start', 'agent', 'task', 'memory', 'config', 'status',
10
+ 'monitor', 'session', 'workflow', 'repl', 'version', 'completion'
11
+ ];
12
+
13
+ private subcommands = {
14
+ agent: ['spawn', 'list', 'terminate', 'info'],
15
+ task: ['create', 'list', 'status', 'cancel', 'workflow'],
16
+ memory: ['query', 'export', 'import', 'stats', 'cleanup'],
17
+ config: ['show', 'get', 'set', 'init', 'validate'],
18
+ session: ['list', 'save', 'restore', 'delete', 'export', 'import', 'info', 'clean'],
19
+ workflow: ['run', 'validate', 'list', 'status', 'stop', 'template'],
20
+ };
21
+
22
+ async generate(shell: string, install: boolean = false): Promise<void> {
23
+ const detectedShell = shell === 'detect' ? await this.detectShell() : shell;
24
+
25
+ switch (detectedShell) {
26
+ case 'bash':
27
+ await this.generateBashCompletion(install);
28
+ break;
29
+ case 'zsh':
30
+ await this.generateZshCompletion(install);
31
+ break;
32
+ case 'fish':
33
+ await this.generateFishCompletion(install);
34
+ break;
35
+ default:
36
+ console.error(colors.red(`Unsupported shell: ${detectedShell}`));
37
+ console.log(colors.gray('Supported shells: bash, zsh, fish'));
38
+ break;
39
+ }
40
+ }
41
+
42
+ private async detectShell(): Promise<string> {
43
+ const shell = Deno.env.get('SHELL') || '';
44
+
45
+ if (shell.includes('bash')) return 'bash';
46
+ if (shell.includes('zsh')) return 'zsh';
47
+ if (shell.includes('fish')) return 'fish';
48
+
49
+ console.log(colors.yellow('Could not detect shell, defaulting to bash'));
50
+ return 'bash';
51
+ }
52
+
53
+ private async generateBashCompletion(install: boolean): Promise<void> {
54
+ const script = this.getBashCompletionScript();
55
+
56
+ if (install) {
57
+ await this.installBashCompletion(script);
58
+ } else {
59
+ console.log(script);
60
+ }
61
+ }
62
+
63
+ private async generateZshCompletion(install: boolean): Promise<void> {
64
+ const script = this.getZshCompletionScript();
65
+
66
+ if (install) {
67
+ await this.installZshCompletion(script);
68
+ } else {
69
+ console.log(script);
70
+ }
71
+ }
72
+
73
+ private async generateFishCompletion(install: boolean): Promise<void> {
74
+ const script = this.getFishCompletionScript();
75
+
76
+ if (install) {
77
+ await this.installFishCompletion(script);
78
+ } else {
79
+ console.log(script);
80
+ }
81
+ }
82
+
83
+ private getBashCompletionScript(): string {
84
+ return `# Claude-Flow bash completion
85
+ _claude_flow_completion() {
86
+ local cur prev words cword
87
+ _init_completion || return
88
+
89
+ case \${words[1]} in
90
+ agent)
91
+ case \${words[2]} in
92
+ spawn)
93
+ COMPREPLY=($(compgen -W "coordinator researcher implementer analyst custom" -- "$cur"))
94
+ return
95
+ ;;
96
+ terminate|info)
97
+ # In production, this would complete with actual agent IDs
98
+ COMPREPLY=($(compgen -W "agent-001 agent-002 agent-003" -- "$cur"))
99
+ return
100
+ ;;
101
+ *)
102
+ COMPREPLY=($(compgen -W "${this.subcommands.agent.join(' ')}" -- "$cur"))
103
+ return
104
+ ;;
105
+ esac
106
+ ;;
107
+ task)
108
+ case \${words[2]} in
109
+ create)
110
+ if [[ \${#words[@]} -eq 4 ]]; then
111
+ COMPREPLY=($(compgen -W "research implementation analysis coordination" -- "$cur"))
112
+ fi
113
+ return
114
+ ;;
115
+ status|cancel)
116
+ # In production, this would complete with actual task IDs
117
+ COMPREPLY=($(compgen -W "task-001 task-002 task-003" -- "$cur"))
118
+ return
119
+ ;;
120
+ workflow)
121
+ COMPREPLY=($(compgen -f -X '!*.@(json|yaml|yml)' -- "$cur"))
122
+ return
123
+ ;;
124
+ *)
125
+ COMPREPLY=($(compgen -W "${this.subcommands.task.join(' ')}" -- "$cur"))
126
+ return
127
+ ;;
128
+ esac
129
+ ;;
130
+ memory)
131
+ COMPREPLY=($(compgen -W "${this.subcommands.memory.join(' ')}" -- "$cur"))
132
+ return
133
+ ;;
134
+ config)
135
+ COMPREPLY=($(compgen -W "${this.subcommands.config.join(' ')}" -- "$cur"))
136
+ return
137
+ ;;
138
+ session)
139
+ case \${words[2]} in
140
+ restore|delete|info|export)
141
+ # In production, this would complete with actual session IDs
142
+ COMPREPLY=($(compgen -W "session-001 session-002 session-003" -- "$cur"))
143
+ return
144
+ ;;
145
+ import)
146
+ COMPREPLY=($(compgen -f -X '!*.@(json|yaml|yml)' -- "$cur"))
147
+ return
148
+ ;;
149
+ *)
150
+ COMPREPLY=($(compgen -W "${this.subcommands.session.join(' ')}" -- "$cur"))
151
+ return
152
+ ;;
153
+ esac
154
+ ;;
155
+ workflow)
156
+ case \${words[2]} in
157
+ run|validate)
158
+ COMPREPLY=($(compgen -f -X '!*.@(json|yaml|yml)' -- "$cur"))
159
+ return
160
+ ;;
161
+ template)
162
+ COMPREPLY=($(compgen -W "research implementation coordination" -- "$cur"))
163
+ return
164
+ ;;
165
+ status|stop)
166
+ # In production, this would complete with actual workflow IDs
167
+ COMPREPLY=($(compgen -W "workflow-001 workflow-002 workflow-003" -- "$cur"))
168
+ return
169
+ ;;
170
+ *)
171
+ COMPREPLY=($(compgen -W "${this.subcommands.workflow.join(' ')}" -- "$cur"))
172
+ return
173
+ ;;
174
+ esac
175
+ ;;
176
+ completion)
177
+ COMPREPLY=($(compgen -W "bash zsh fish" -- "$cur"))
178
+ return
179
+ ;;
180
+ *)
181
+ COMPREPLY=($(compgen -W "${this.commands.join(' ')}" -- "$cur"))
182
+ return
183
+ ;;
184
+ esac
185
+ }
186
+
187
+ complete -F _claude_flow_completion claude-flow`;
188
+ }
189
+
190
+ private getZshCompletionScript(): string {
191
+ return `#compdef claude-flow
192
+
193
+ # Claude-Flow zsh completion
194
+
195
+ _claude_flow() {
196
+ local context state state_descr line
197
+ typeset -A opt_args
198
+
199
+ _arguments -C \\
200
+ '(-h --help)'{-h,--help}'[Show help information]' \\
201
+ '(-v --verbose)'{-v,--verbose}'[Enable verbose logging]' \\
202
+ '(-q --quiet)'{-q,--quiet}'[Suppress non-essential output]' \\
203
+ '(-c --config)'{-c,--config}'[Path to configuration file]:config file:_files -g "*.json"' \\
204
+ '--log-level[Set log level]:level:(debug info warn error)' \\
205
+ '--no-color[Disable colored output]' \\
206
+ '--json[Output in JSON format]' \\
207
+ '--profile[Use named configuration profile]:profile:' \\
208
+ '1: :_claude_flow_commands' \\
209
+ '*::arg:->args'
210
+
211
+ case $state in
212
+ args)
213
+ case $words[1] in
214
+ agent)
215
+ _claude_flow_agent
216
+ ;;
217
+ task)
218
+ _claude_flow_task
219
+ ;;
220
+ memory)
221
+ _claude_flow_memory
222
+ ;;
223
+ config)
224
+ _claude_flow_config
225
+ ;;
226
+ session)
227
+ _claude_flow_session
228
+ ;;
229
+ workflow)
230
+ _claude_flow_workflow
231
+ ;;
232
+ completion)
233
+ _arguments \\
234
+ '--install[Install completion script automatically]' \\
235
+ '1: :(bash zsh fish)'
236
+ ;;
237
+ esac
238
+ ;;
239
+ esac
240
+ }
241
+
242
+ _claude_flow_commands() {
243
+ local commands
244
+ commands=(
245
+ 'start:Start the Claude-Flow orchestration system'
246
+ 'agent:Manage Claude-Flow agents'
247
+ 'task:Manage tasks'
248
+ 'memory:Manage agent memory'
249
+ 'config:Manage Claude-Flow configuration'
250
+ 'status:Show Claude-Flow system status'
251
+ 'monitor:Start live monitoring dashboard'
252
+ 'session:Manage Claude-Flow sessions'
253
+ 'workflow:Execute and manage workflows'
254
+ 'repl:Start interactive REPL mode'
255
+ 'version:Show detailed version information'
256
+ 'completion:Generate shell completion scripts'
257
+ )
258
+ _describe 'commands' commands
259
+ }
260
+
261
+ _claude_flow_agent() {
262
+ case $words[2] in
263
+ spawn)
264
+ _arguments \\
265
+ '(-n --name)'{-n,--name}'[Agent name]:name:' \\
266
+ '(-p --priority)'{-p,--priority}'[Agent priority]:priority:' \\
267
+ '(-m --max-tasks)'{-m,--max-tasks}'[Maximum concurrent tasks]:max:' \\
268
+ '--system-prompt[Custom system prompt]:prompt:' \\
269
+ '1: :(coordinator researcher implementer analyst custom)'
270
+ ;;
271
+ terminate|info)
272
+ _arguments '1: :_claude_flow_agents'
273
+ ;;
274
+ *)
275
+ _arguments '1: :(${this.subcommands.agent.join(' ')})'
276
+ ;;
277
+ esac
278
+ }
279
+
280
+ _claude_flow_task() {
281
+ case $words[2] in
282
+ create)
283
+ _arguments \\
284
+ '(-p --priority)'{-p,--priority}'[Task priority]:priority:' \\
285
+ '(-d --dependencies)'{-d,--dependencies}'[Comma-separated dependency task IDs]:deps:' \\
286
+ '(-i --input)'{-i,--input}'[Task input as JSON]:input:' \\
287
+ '(-a --assign)'{-a,--assign}'[Assign to specific agent]:agent:_claude_flow_agents' \\
288
+ '1: :(research implementation analysis coordination)' \\
289
+ '2: :_message_or_description'
290
+ ;;
291
+ workflow)
292
+ _arguments '1: :_files -g "*.json *.yaml *.yml"'
293
+ ;;
294
+ status|cancel)
295
+ _arguments '1: :_claude_flow_tasks'
296
+ ;;
297
+ *)
298
+ _arguments '1: :(${this.subcommands.task.join(' ')})'
299
+ ;;
300
+ esac
301
+ }
302
+
303
+ _claude_flow_memory() {
304
+ _arguments '1: :(${this.subcommands.memory.join(' ')})'
305
+ }
306
+
307
+ _claude_flow_config() {
308
+ _arguments '1: :(${this.subcommands.config.join(' ')})'
309
+ }
310
+
311
+ _claude_flow_session() {
312
+ case $words[2] in
313
+ restore|delete|info|export)
314
+ _arguments '1: :_claude_flow_sessions'
315
+ ;;
316
+ import)
317
+ _arguments '1: :_files -g "*.json *.yaml *.yml"'
318
+ ;;
319
+ *)
320
+ _arguments '1: :(${this.subcommands.session.join(' ')})'
321
+ ;;
322
+ esac
323
+ }
324
+
325
+ _claude_flow_workflow() {
326
+ case $words[2] in
327
+ run|validate)
328
+ _arguments '1: :_files -g "*.json *.yaml *.yml"'
329
+ ;;
330
+ template)
331
+ _arguments '1: :(research implementation coordination)'
332
+ ;;
333
+ status|stop)
334
+ _arguments '1: :_claude_flow_workflows'
335
+ ;;
336
+ *)
337
+ _arguments '1: :(${this.subcommands.workflow.join(' ')})'
338
+ ;;
339
+ esac
340
+ }
341
+
342
+ # Helper functions for completion
343
+ _claude_flow_agents() {
344
+ # In production, this would query the running orchestrator
345
+ local agents
346
+ agents=('agent-001:Coordinator Agent' 'agent-002:Research Agent' 'agent-003:Implementation Agent')
347
+ _describe 'agents' agents
348
+ }
349
+
350
+ _claude_flow_tasks() {
351
+ # In production, this would query the running orchestrator
352
+ local tasks
353
+ tasks=('task-001:Research Task' 'task-002:Analysis Task' 'task-003:Implementation Task')
354
+ _describe 'tasks' tasks
355
+ }
356
+
357
+ _claude_flow_sessions() {
358
+ # In production, this would query saved sessions
359
+ local sessions
360
+ sessions=('session-001:Research Session' 'session-002:Development Session' 'session-003:Analysis Session')
361
+ _describe 'sessions' sessions
362
+ }
363
+
364
+ _claude_flow_workflows() {
365
+ # In production, this would query running workflows
366
+ local workflows
367
+ workflows=('workflow-001:Research Workflow' 'workflow-002:Implementation Workflow')
368
+ _describe 'workflows' workflows
369
+ }
370
+
371
+ _message_or_description() {
372
+ _message 'task description'
373
+ }
374
+
375
+ _claude_flow "$@"`;
376
+ }
377
+
378
+ private getFishCompletionScript(): string {
379
+ return `# Claude-Flow fish completion
380
+
381
+ function __fish_claude_flow_needs_command
382
+ set cmd (commandline -opc)
383
+ if [ (count $cmd) -eq 1 ]
384
+ return 0
385
+ end
386
+ return 1
387
+ end
388
+
389
+ function __fish_claude_flow_using_command
390
+ set cmd (commandline -opc)
391
+ if [ (count $cmd) -gt 1 ]
392
+ if [ $argv[1] = $cmd[2] ]
393
+ return 0
394
+ end
395
+ end
396
+ return 1
397
+ end
398
+
399
+ # Main commands
400
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'start' -d 'Start the Claude-Flow orchestration system'
401
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'agent' -d 'Manage Claude-Flow agents'
402
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'task' -d 'Manage tasks'
403
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'memory' -d 'Manage agent memory'
404
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'config' -d 'Manage Claude-Flow configuration'
405
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'status' -d 'Show Claude-Flow system status'
406
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'monitor' -d 'Start live monitoring dashboard'
407
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'session' -d 'Manage Claude-Flow sessions'
408
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'workflow' -d 'Execute and manage workflows'
409
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'repl' -d 'Start interactive REPL mode'
410
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'version' -d 'Show detailed version information'
411
+ complete -f -c claude-flow -n '__fish_claude_flow_needs_command' -a 'completion' -d 'Generate shell completion scripts'
412
+
413
+ # Global options
414
+ complete -c claude-flow -s h -l help -d 'Show help information'
415
+ complete -c claude-flow -s v -l verbose -d 'Enable verbose logging'
416
+ complete -c claude-flow -s q -l quiet -d 'Suppress non-essential output'
417
+ complete -c claude-flow -s c -l config -r -d 'Path to configuration file'
418
+ complete -c claude-flow -l log-level -r -a 'debug info warn error' -d 'Set log level'
419
+ complete -c claude-flow -l no-color -d 'Disable colored output'
420
+ complete -c claude-flow -l json -d 'Output in JSON format'
421
+ complete -c claude-flow -l profile -r -d 'Use named configuration profile'
422
+
423
+ # Agent subcommands
424
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command agent' -a 'spawn' -d 'Spawn a new agent'
425
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command agent' -a 'list' -d 'List all agents'
426
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command agent' -a 'terminate' -d 'Terminate an agent'
427
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command agent' -a 'info' -d 'Get agent information'
428
+
429
+ # Task subcommands
430
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command task' -a 'create' -d 'Create a new task'
431
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command task' -a 'list' -d 'List all tasks'
432
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command task' -a 'status' -d 'Get task status'
433
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command task' -a 'cancel' -d 'Cancel a task'
434
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command task' -a 'workflow' -d 'Execute workflow from file'
435
+
436
+ # Memory subcommands
437
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command memory' -a 'query' -d 'Query memory entries'
438
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command memory' -a 'export' -d 'Export memory to file'
439
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command memory' -a 'import' -d 'Import memory from file'
440
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command memory' -a 'stats' -d 'Show memory statistics'
441
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command memory' -a 'cleanup' -d 'Clean up old entries'
442
+
443
+ # Config subcommands
444
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command config' -a 'show' -d 'Show current configuration'
445
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command config' -a 'get' -d 'Get specific config value'
446
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command config' -a 'set' -d 'Set config value'
447
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command config' -a 'init' -d 'Initialize config file'
448
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command config' -a 'validate' -d 'Validate config file'
449
+
450
+ # Session subcommands
451
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'list' -d 'List all saved sessions'
452
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'save' -d 'Save current session state'
453
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'restore' -d 'Restore a saved session'
454
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'delete' -d 'Delete a saved session'
455
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'export' -d 'Export session to file'
456
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'import' -d 'Import session from file'
457
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'info' -d 'Show detailed session information'
458
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command session' -a 'clean' -d 'Clean up old sessions'
459
+
460
+ # Workflow subcommands
461
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'run' -d 'Execute a workflow from file'
462
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'validate' -d 'Validate a workflow file'
463
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'list' -d 'List running workflows'
464
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'status' -d 'Show workflow execution status'
465
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'stop' -d 'Stop a running workflow'
466
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command workflow' -a 'template' -d 'Generate workflow templates'
467
+
468
+ # Completion subcommands
469
+ complete -f -c claude-flow -n '__fish_claude_flow_using_command completion' -a 'bash zsh fish'`;
470
+ }
471
+
472
+ private async installBashCompletion(script: string): Promise<void> {
473
+ const possiblePaths = [
474
+ '/etc/bash_completion.d/claude-flow',
475
+ '/usr/local/etc/bash_completion.d/claude-flow',
476
+ `${Deno.env.get('HOME')}/.local/share/bash-completion/completions/claude-flow`,
477
+ `${Deno.env.get('HOME')}/.bash_completion.d/claude-flow`
478
+ ];
479
+
480
+ for (const path of possiblePaths) {
481
+ try {
482
+ const dir = path.substring(0, path.lastIndexOf('/'));
483
+ await Deno.mkdir(dir, { recursive: true });
484
+ await Deno.writeTextFile(path, script);
485
+
486
+ console.log(colors.green('✓ Bash completion installed'));
487
+ console.log(`${colors.white('Location:')} ${path}`);
488
+ console.log(colors.gray('Restart your shell or run: source ~/.bashrc'));
489
+ return;
490
+ } catch (error) {
491
+ // Try next path
492
+ continue;
493
+ }
494
+ }
495
+
496
+ console.error(colors.red('Failed to install bash completion'));
497
+ console.log(colors.gray('You can manually save the completion script to a bash completion directory'));
498
+ }
499
+
500
+ private async installZshCompletion(script: string): Promise<void> {
501
+ const possiblePaths = [
502
+ `${Deno.env.get('HOME')}/.zsh/completions/_claude-flow`,
503
+ '/usr/local/share/zsh/site-functions/_claude-flow',
504
+ '/usr/share/zsh/site-functions/_claude-flow'
505
+ ];
506
+
507
+ for (const path of possiblePaths) {
508
+ try {
509
+ const dir = path.substring(0, path.lastIndexOf('/'));
510
+ await Deno.mkdir(dir, { recursive: true });
511
+ await Deno.writeTextFile(path, script);
512
+
513
+ console.log(colors.green('✓ Zsh completion installed'));
514
+ console.log(`${colors.white('Location:')} ${path}`);
515
+ console.log(colors.gray('Restart your shell or run: autoload -U compinit && compinit'));
516
+ return;
517
+ } catch (error) {
518
+ // Try next path
519
+ continue;
520
+ }
521
+ }
522
+
523
+ console.error(colors.red('Failed to install zsh completion'));
524
+ console.log(colors.gray('You can manually save the completion script to your zsh completion directory'));
525
+ }
526
+
527
+ private async installFishCompletion(script: string): Promise<void> {
528
+ const possiblePaths = [
529
+ `${Deno.env.get('HOME')}/.config/fish/completions/claude-flow.fish`,
530
+ '/usr/local/share/fish/completions/claude-flow.fish',
531
+ '/usr/share/fish/completions/claude-flow.fish'
532
+ ];
533
+
534
+ for (const path of possiblePaths) {
535
+ try {
536
+ const dir = path.substring(0, path.lastIndexOf('/'));
537
+ await Deno.mkdir(dir, { recursive: true });
538
+ await Deno.writeTextFile(path, script);
539
+
540
+ console.log(colors.green('✓ Fish completion installed'));
541
+ console.log(`${colors.white('Location:')} ${path}`);
542
+ console.log(colors.gray('Completions will be available in new fish sessions'));
543
+ return;
544
+ } catch (error) {
545
+ // Try next path
546
+ continue;
547
+ }
548
+ }
549
+
550
+ console.error(colors.red('Failed to install fish completion'));
551
+ console.log(colors.gray('You can manually save the completion script to your fish completion directory'));
552
+ }
553
+ }