@sparkleideas/ruv-swarm 1.0.18-patch.1

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 (87) hide show
  1. package/README.md +1565 -0
  2. package/bin/ruv-swarm-clean.js +1872 -0
  3. package/bin/ruv-swarm-memory.js +119 -0
  4. package/bin/ruv-swarm-secure-heartbeat.js +1549 -0
  5. package/bin/ruv-swarm-secure.js +1689 -0
  6. package/package.json +221 -0
  7. package/src/agent.ts +342 -0
  8. package/src/benchmark.js +267 -0
  9. package/src/claude-flow-enhanced.js +839 -0
  10. package/src/claude-integration/advanced-commands.js +561 -0
  11. package/src/claude-integration/core.js +112 -0
  12. package/src/claude-integration/docs.js +1548 -0
  13. package/src/claude-integration/env-template.js +39 -0
  14. package/src/claude-integration/index.js +209 -0
  15. package/src/claude-integration/remote.js +408 -0
  16. package/src/cli-diagnostics.js +364 -0
  17. package/src/cognitive-pattern-evolution.js +1317 -0
  18. package/src/daa-cognition.js +977 -0
  19. package/src/daa-service.d.ts +298 -0
  20. package/src/daa-service.js +1116 -0
  21. package/src/diagnostics.js +533 -0
  22. package/src/errors.js +528 -0
  23. package/src/github-coordinator/README.md +193 -0
  24. package/src/github-coordinator/claude-hooks.js +162 -0
  25. package/src/github-coordinator/gh-cli-coordinator.js +260 -0
  26. package/src/hooks/cli.js +82 -0
  27. package/src/hooks/index.js +1900 -0
  28. package/src/index-enhanced.d.ts +371 -0
  29. package/src/index-enhanced.js +734 -0
  30. package/src/index.d.ts +287 -0
  31. package/src/index.js +405 -0
  32. package/src/index.ts +457 -0
  33. package/src/logger.js +182 -0
  34. package/src/logging-config.js +179 -0
  35. package/src/mcp-daa-tools.js +735 -0
  36. package/src/mcp-tools-benchmarks.js +328 -0
  37. package/src/mcp-tools-enhanced.js +2863 -0
  38. package/src/memory-config.js +42 -0
  39. package/src/meta-learning-framework.js +1359 -0
  40. package/src/neural-agent.js +830 -0
  41. package/src/neural-coordination-protocol.js +1363 -0
  42. package/src/neural-models/README.md +118 -0
  43. package/src/neural-models/autoencoder.js +543 -0
  44. package/src/neural-models/base.js +269 -0
  45. package/src/neural-models/cnn.js +497 -0
  46. package/src/neural-models/gnn.js +447 -0
  47. package/src/neural-models/gru.js +536 -0
  48. package/src/neural-models/index.js +273 -0
  49. package/src/neural-models/lstm.js +551 -0
  50. package/src/neural-models/neural-presets-complete.js +1306 -0
  51. package/src/neural-models/presets/graph.js +392 -0
  52. package/src/neural-models/presets/index.js +279 -0
  53. package/src/neural-models/presets/nlp.js +328 -0
  54. package/src/neural-models/presets/timeseries.js +368 -0
  55. package/src/neural-models/presets/vision.js +387 -0
  56. package/src/neural-models/resnet.js +534 -0
  57. package/src/neural-models/transformer.js +515 -0
  58. package/src/neural-models/vae.js +489 -0
  59. package/src/neural-network-manager.js +1938 -0
  60. package/src/neural-network.ts +296 -0
  61. package/src/neural.js +574 -0
  62. package/src/performance-benchmarks.js +898 -0
  63. package/src/performance.js +458 -0
  64. package/src/persistence-pooled.js +695 -0
  65. package/src/persistence.js +480 -0
  66. package/src/schemas.js +864 -0
  67. package/src/security.js +218 -0
  68. package/src/singleton-container.js +183 -0
  69. package/src/sqlite-pool.js +587 -0
  70. package/src/sqlite-worker.js +141 -0
  71. package/src/types.ts +164 -0
  72. package/src/utils.ts +286 -0
  73. package/src/wasm-loader.js +601 -0
  74. package/src/wasm-loader2.js +404 -0
  75. package/src/wasm-memory-optimizer.js +783 -0
  76. package/src/wasm-types.d.ts +63 -0
  77. package/wasm/README.md +347 -0
  78. package/wasm/neuro-divergent.wasm +0 -0
  79. package/wasm/package.json +18 -0
  80. package/wasm/ruv-fann.wasm +0 -0
  81. package/wasm/ruv_swarm_simd.wasm +0 -0
  82. package/wasm/ruv_swarm_wasm.d.ts +391 -0
  83. package/wasm/ruv_swarm_wasm.js +2164 -0
  84. package/wasm/ruv_swarm_wasm_bg.wasm +0 -0
  85. package/wasm/ruv_swarm_wasm_bg.wasm.d.ts +123 -0
  86. package/wasm/wasm-bindings-loader.mjs +435 -0
  87. package/wasm/wasm-updates.md +684 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Environment variable template for @sparkleideas/ruv-swarm projects
3
+ */
4
+
5
+ const envTemplate = `# @sparkleideas/ruv-swarm Configuration
6
+ NODE_ENV=development
7
+
8
+ # Git Integration
9
+ RUV_SWARM_AUTO_COMMIT=true
10
+ RUV_SWARM_AUTO_PUSH=false
11
+ RUV_SWARM_COMMIT_PREFIX=feat
12
+ RUV_SWARM_GIT_AUTHOR=@sparkleideas/ruv-swarm
13
+
14
+ # Agent Reports
15
+ RUV_SWARM_GENERATE_REPORTS=true
16
+ RUV_SWARM_REPORT_DIR=.@sparkleideas/ruv-swarm/agent-reports
17
+
18
+ # Memory & Learning
19
+ RUV_SWARM_MEMORY_PERSIST=true
20
+ RUV_SWARM_NEURAL_LEARNING=true
21
+
22
+ # Performance Tracking
23
+ RUV_SWARM_PERFORMANCE_TRACKING=true
24
+ RUV_SWARM_TELEMETRY_ENABLED=true
25
+
26
+ # Hook Configuration
27
+ RUV_SWARM_HOOKS_ENABLED=true
28
+ RUV_SWARM_HOOK_DEBUG=false
29
+
30
+ # Coordination
31
+ RUV_SWARM_COORDINATION_MODE=adaptive
32
+ RUV_SWARM_AUTO_INIT=true
33
+
34
+ # Remote Execution
35
+ RUV_SWARM_REMOTE_EXECUTION=true
36
+ RUV_SWARM_REMOTE_READY=true
37
+ `;
38
+
39
+ module.exports = { envTemplate };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Main Claude Code integration orchestrator
3
+ * Coordinates all integration modules for modular, remote-capable setup
4
+ */
5
+
6
+ import { ClaudeIntegrationCore } from './core.js';
7
+ import { ClaudeDocsGenerator } from './docs.js';
8
+ import { RemoteWrapperGenerator } from './remote.js';
9
+
10
+ class ClaudeIntegrationOrchestrator {
11
+ constructor(options = {}) {
12
+ this.options = {
13
+ autoSetup: options.autoSetup || false,
14
+ forceSetup: options.forceSetup || false,
15
+ mergeSetup: options.mergeSetup || false,
16
+ backupSetup: options.backupSetup || false,
17
+ noBackup: options.noBackup || false,
18
+ interactive: options.interactive !== false, // Default to true
19
+ workingDir: options.workingDir || process.cwd(),
20
+ packageName: options.packageName || '@sparkleideas/ruv-swarm',
21
+ ...options,
22
+ };
23
+
24
+ // Initialize modules
25
+ this.core = new ClaudeIntegrationCore(this.options);
26
+ this.docs = new ClaudeDocsGenerator(this.options);
27
+ this.remote = new RemoteWrapperGenerator(this.options);
28
+ }
29
+
30
+ /**
31
+ * Setup complete Claude Code integration
32
+ */
33
+ async setupIntegration() {
34
+ console.log('🚀 Setting up modular Claude Code integration...');
35
+ console.log(' Working directory:', this.options.workingDir);
36
+ console.log(' Force setup:', this.options.forceSetup);
37
+ console.log(' Backup setup:', this.options.backupSetup);
38
+ console.log(' Merge setup:', this.options.mergeSetup);
39
+ console.log(' Auto setup MCP:', this.options.autoSetup);
40
+
41
+ try {
42
+ const results = {
43
+ timestamp: new Date().toISOString(),
44
+ workingDir: this.options.workingDir,
45
+ success: true,
46
+ modules: {},
47
+ };
48
+
49
+ // Step 1: Generate documentation
50
+ console.log('\n📚 Step 1: Documentation Generation');
51
+ results.modules.docs = await this.docs.generateAll({
52
+ force: this.options.forceSetup,
53
+ merge: this.options.mergeSetup,
54
+ backup: this.options.backupSetup,
55
+ noBackup: this.options.noBackup,
56
+ interactive: this.options.interactive,
57
+ });
58
+
59
+ // Step 2: Setup remote capabilities
60
+ console.log('\n🌐 Step 2: Remote Execution Setup');
61
+ results.modules.remote = await this.remote.createAll();
62
+
63
+ // Step 3: Initialize core integration (if auto setup enabled)
64
+ if (this.options.autoSetup) {
65
+ console.log('\n🔧 Step 3: Core Integration Setup');
66
+ try {
67
+ results.modules.core = await this.core.initialize();
68
+ } catch (error) {
69
+ console.log('⚠️ Core integration setup failed (manual setup required)');
70
+ console.log(' Error:', error.message);
71
+ results.modules.core = {
72
+ success: false,
73
+ error: error.message,
74
+ manualSetup: true,
75
+ };
76
+ }
77
+ } else {
78
+ console.log('\n💡 Step 3: Manual Core Setup Required');
79
+ results.modules.core = {
80
+ success: true,
81
+ manualSetup: true,
82
+ instructions: [
83
+ 'Run: claude mcp add @sparkleideas/ruv-swarm npx @sparkleideas/ruv-swarm mcp start',
84
+ 'Test with: mcp__ruv-swarm__agent_spawn',
85
+ ],
86
+ };
87
+ }
88
+
89
+ // Summary
90
+ console.log('\n✅ Modular Claude Code integration setup complete!');
91
+ console.log('\n📋 What was created:');
92
+ console.log(' 📄 claude.md - Main configuration guide');
93
+ console.log(' 📁 .claude/commands/ - Command documentation');
94
+ console.log(' 🔧 Cross-platform wrapper scripts');
95
+ console.log(' 🤖 Claude helper scripts');
96
+ console.log(' 🌐 Remote execution support');
97
+
98
+ console.log('\n🔗 Next steps:');
99
+ if (results.modules.core.manualSetup) {
100
+ console.log(' 1. claude mcp add @sparkleideas/ruv-swarm npx @sparkleideas/ruv-swarm mcp start');
101
+ console.log(' 2. Test with MCP tools: mcp__ruv-swarm__agent_spawn');
102
+ } else {
103
+ console.log(' 1. Test with MCP tools: mcp__ruv-swarm__agent_spawn');
104
+ }
105
+ console.log(' 3. Check .claude/commands/ for detailed usage guides');
106
+ console.log(' 4. Use wrapper scripts for remote execution');
107
+
108
+ return results;
109
+
110
+ } catch (error) {
111
+ console.error('❌ Integration setup failed:', error.message);
112
+ throw error;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Invoke Claude with a prompt using the core module
118
+ */
119
+ async invokeClaudeWithPrompt(prompt) {
120
+ return await this.core.invokeClaudeWithPrompt(prompt);
121
+ }
122
+
123
+ /**
124
+ * Check integration status
125
+ */
126
+ async checkStatus() {
127
+ console.log('🔍 Checking Claude Code integration status...');
128
+
129
+ try {
130
+ const status = {
131
+ claudeAvailable: await this.core.isClaudeAvailable(),
132
+ filesExist: await this.core.checkExistingFiles(),
133
+ workingDir: this.options.workingDir,
134
+ timestamp: new Date().toISOString(),
135
+ };
136
+
137
+ console.log('Claude CLI available:', status.claudeAvailable ? '✅' : '❌');
138
+ console.log('Integration files exist:', status.filesExist ? '✅' : '❌');
139
+
140
+ return status;
141
+ } catch (error) {
142
+ console.error('❌ Status check failed:', error.message);
143
+ throw error;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Clean up integration files
149
+ */
150
+ async cleanup() {
151
+ console.log('🧹 Cleaning up Claude Code integration files...');
152
+
153
+ const fs = require('fs').promises;
154
+ const path = require('path');
155
+
156
+ try {
157
+ const filesToRemove = [
158
+ 'claude.md',
159
+ '.claude',
160
+ this.options.packageName,
161
+ `${this.options.packageName }.bat`,
162
+ `${this.options.packageName }.ps1`,
163
+ 'claude-swarm.sh',
164
+ 'claude-swarm.bat',
165
+ ];
166
+
167
+ const removedFiles = [];
168
+
169
+ for (const file of filesToRemove) {
170
+ try {
171
+ const filePath = path.join(this.options.workingDir, file);
172
+ await fs.rm(filePath, { recursive: true, force: true });
173
+ removedFiles.push(file);
174
+ } catch {
175
+ // File doesn't exist, continue
176
+ }
177
+ }
178
+
179
+ console.log('✅ Cleanup complete. Removed:', removedFiles.join(', '));
180
+ return { success: true, removedFiles };
181
+
182
+ } catch (error) {
183
+ console.error('❌ Cleanup failed:', error.message);
184
+ throw error;
185
+ }
186
+ }
187
+ }
188
+
189
+ // Convenience function for simple setup
190
+ async function setupClaudeIntegration(options = {}) {
191
+ const orchestrator = new ClaudeIntegrationOrchestrator(options);
192
+ return await orchestrator.setupIntegration();
193
+ }
194
+
195
+ // Convenience function for Claude invocation
196
+ async function invokeClaudeWithSwarm(prompt, options = {}) {
197
+ const orchestrator = new ClaudeIntegrationOrchestrator(options);
198
+ return await orchestrator.invokeClaudeWithPrompt(prompt);
199
+ }
200
+
201
+ export {
202
+ ClaudeIntegrationOrchestrator,
203
+ setupClaudeIntegration,
204
+ invokeClaudeWithSwarm,
205
+ // Export individual modules for advanced usage
206
+ ClaudeIntegrationCore,
207
+ ClaudeDocsGenerator,
208
+ RemoteWrapperGenerator,
209
+ };
@@ -0,0 +1,408 @@
1
+ /**
2
+ * Remote wrapper generation module
3
+ * Creates cross-platform wrapper scripts for remote execution
4
+ */
5
+
6
+ import { promises as fs } from 'fs';
7
+ import path from 'path';
8
+
9
+ class RemoteWrapperGenerator {
10
+ constructor(options = {}) {
11
+ this.workingDir = options.workingDir || process.cwd();
12
+ this.packageName = options.packageName || '@sparkleideas/ruv-swarm';
13
+ }
14
+
15
+ /**
16
+ * Generate bash wrapper script for Unix-like systems
17
+ */
18
+ generateBashWrapper() {
19
+ return `#!/usr/bin/env bash
20
+ # ${this.packageName} local wrapper
21
+ # This script ensures ${this.packageName} runs from your project directory
22
+
23
+ # Save the current directory
24
+ PROJECT_DIR="\${PWD}"
25
+
26
+ # Set environment to ensure correct working directory
27
+ export PWD="\${PROJECT_DIR}"
28
+ export RUVSW_WORKING_DIR="\${PROJECT_DIR}"
29
+
30
+ # Function to find and execute ${this.packageName}
31
+ find_and_execute() {
32
+ # 1. Try local npm/npx
33
+ if command -v npx &> /dev/null; then
34
+ cd "\${PROJECT_DIR}"
35
+ exec npx ${this.packageName} "\$@"
36
+
37
+ # 2. Try local node_modules
38
+ elif [ -f "\${PROJECT_DIR}/node_modules/.bin/${this.packageName}" ]; then
39
+ cd "\${PROJECT_DIR}"
40
+ exec "\${PROJECT_DIR}/node_modules/.bin/${this.packageName}" "\$@"
41
+
42
+ # 3. Try global installation
43
+ elif command -v ${this.packageName} &> /dev/null; then
44
+ cd "\${PROJECT_DIR}"
45
+ exec ${this.packageName} "\$@"
46
+
47
+ # 4. Fallback to latest version
48
+ else
49
+ cd "\${PROJECT_DIR}"
50
+ exec npx ${this.packageName}@latest "\$@"
51
+ fi
52
+ }
53
+
54
+ # Handle remote execution if SSH context detected
55
+ if [ -n "\$SSH_CLIENT" ] || [ -n "\$SSH_TTY" ] || [ "\$TERM" = "screen" ]; then
56
+ echo "🌐 Remote execution detected"
57
+ export RUVSW_REMOTE_MODE=1
58
+ fi
59
+
60
+ # Execute with error handling
61
+ find_and_execute "\$@"
62
+ `;
63
+ }
64
+
65
+ /**
66
+ * Generate Windows batch wrapper script
67
+ */
68
+ generateBatchWrapper() {
69
+ return `@echo off
70
+ REM ${this.packageName} local wrapper (Windows)
71
+ REM This script ensures ${this.packageName} runs from your project directory
72
+
73
+ set PROJECT_DIR=%CD%
74
+ set RUVSW_WORKING_DIR=%PROJECT_DIR%
75
+
76
+ REM Check for remote execution (basic detection)
77
+ if defined SSH_CLIENT set RUVSW_REMOTE_MODE=1
78
+ if defined SSH_TTY set RUVSW_REMOTE_MODE=1
79
+
80
+ REM Function to find and execute ${this.packageName}
81
+ call :find_and_execute %*
82
+ goto :eof
83
+
84
+ :find_and_execute
85
+ REM 1. Try npx
86
+ where npx >nul 2>nul
87
+ if %ERRORLEVEL% == 0 (
88
+ cd /d "%PROJECT_DIR%"
89
+ npx ${this.packageName} %*
90
+ exit /b %ERRORLEVEL%
91
+ )
92
+
93
+ REM 2. Try local node_modules
94
+ if exist "%PROJECT_DIR%\\node_modules\\.bin\\${this.packageName}.cmd" (
95
+ cd /d "%PROJECT_DIR%"
96
+ "%PROJECT_DIR%\\node_modules\\.bin\\${this.packageName}.cmd" %*
97
+ exit /b %ERRORLEVEL%
98
+ )
99
+
100
+ REM 3. Try global installation
101
+ where ${this.packageName} >nul 2>nul
102
+ if %ERRORLEVEL% == 0 (
103
+ cd /d "%PROJECT_DIR%"
104
+ ${this.packageName} %*
105
+ exit /b %ERRORLEVEL%
106
+ )
107
+
108
+ REM 4. Fallback to latest
109
+ cd /d "%PROJECT_DIR%"
110
+ npx ${this.packageName}@latest %*
111
+ exit /b %ERRORLEVEL%
112
+ `;
113
+ }
114
+
115
+ /**
116
+ * Generate PowerShell wrapper script
117
+ */
118
+ generatePowerShellWrapper() {
119
+ return `#!/usr/bin/env pwsh
120
+ # ${this.packageName} local wrapper (PowerShell)
121
+ # Cross-platform PowerShell script for ${this.packageName}
122
+
123
+ param([Parameter(ValueFromRemainingArguments)][string[]]$Arguments)
124
+
125
+ # Save the current directory
126
+ $ProjectDir = Get-Location
127
+ $env:PWD = $ProjectDir
128
+ $env:RUVSW_WORKING_DIR = $ProjectDir
129
+
130
+ # Detect remote execution
131
+ if ($env:SSH_CLIENT -or $env:SSH_TTY -or $env:TERM -eq "screen") {
132
+ Write-Host "🌐 Remote execution detected"
133
+ $env:RUVSW_REMOTE_MODE = "1"
134
+ }
135
+
136
+ # Function to find and execute ${this.packageName}
137
+ function Find-And-Execute {
138
+ param([string[]]$Args)
139
+
140
+ try {
141
+ # 1. Try npx
142
+ if (Get-Command npx -ErrorAction SilentlyContinue) {
143
+ Set-Location $ProjectDir
144
+ & npx ${this.packageName} @Args
145
+ return
146
+ }
147
+
148
+ # 2. Try local node_modules
149
+ $localBin = Join-Path $ProjectDir "node_modules" ".bin" "${this.packageName}"
150
+ if (Test-Path $localBin) {
151
+ Set-Location $ProjectDir
152
+ & $localBin @Args
153
+ return
154
+ }
155
+
156
+ # 3. Try global installation
157
+ if (Get-Command ${this.packageName} -ErrorAction SilentlyContinue) {
158
+ Set-Location $ProjectDir
159
+ & ${this.packageName} @Args
160
+ return
161
+ }
162
+
163
+ # 4. Fallback to latest
164
+ Set-Location $ProjectDir
165
+ & npx ${this.packageName}@latest @Args
166
+
167
+ } catch {
168
+ Write-Error "Failed to execute ${this.packageName}: $_"
169
+ exit 1
170
+ }
171
+ }
172
+
173
+ # Execute with arguments
174
+ Find-And-Execute $Arguments
175
+ `;
176
+ }
177
+
178
+ /**
179
+ * Generate Claude helper scripts
180
+ */
181
+ generateClaudeHelpers() {
182
+ const bashHelper = `#!/usr/bin/env bash
183
+ # Claude Code Direct Swarm Invocation Helper
184
+ # Generated by ${this.packageName} --claude setup
185
+
186
+ # Colors for output
187
+ GREEN='\\033[0;32m'
188
+ YELLOW='\\033[1;33m'
189
+ RED='\\033[0;31m'
190
+ NC='\\033[0m'
191
+
192
+ echo -e "\${GREEN}🐝 ${this.packageName} Claude Code Direct Invocation\${NC}"
193
+ echo "============================================="
194
+ echo
195
+
196
+ # Function to invoke Claude with swarm commands
197
+ invoke_claude_swarm() {
198
+ local prompt="\$1"
199
+ local skip_permissions="\$2"
200
+
201
+ echo -e "\${YELLOW}🚀 Invoking Claude Code with swarm integration...\${NC}"
202
+ echo "Prompt: \$prompt"
203
+ echo
204
+
205
+ if [ "\$skip_permissions" = "true" ]; then
206
+ echo -e "\${RED}⚠️ Using --dangerously-skip-permissions flag\${NC}"
207
+ claude "\$prompt" --dangerously-skip-permissions
208
+ else
209
+ claude "\$prompt"
210
+ fi
211
+ }
212
+
213
+ # Predefined swarm prompts with remote support
214
+ case "\$1" in
215
+ "research")
216
+ invoke_claude_swarm "Initialize a research swarm with 5 agents using ${this.packageName}. Create researcher, analyst, and coder agents. Then orchestrate the task: \$2" "\$3"
217
+ ;;
218
+ "development")
219
+ invoke_claude_swarm "Initialize a development swarm with 8 agents using ${this.packageName} in hierarchical topology. Create architect, frontend coder, backend coder, and tester agents. Then orchestrate the task: \$2" "\$3"
220
+ ;;
221
+ "analysis")
222
+ invoke_claude_swarm "Initialize an analysis swarm with 6 agents using ${this.packageName}. Create multiple analyst agents with different specializations. Then orchestrate the task: \$2" "\$3"
223
+ ;;
224
+ "optimization")
225
+ invoke_claude_swarm "Initialize an optimization swarm with 4 agents using ${this.packageName}. Create optimizer and analyst agents. Then orchestrate the performance optimization task: \$2" "\$3"
226
+ ;;
227
+ "custom")
228
+ invoke_claude_swarm "\$2" "\$3"
229
+ ;;
230
+ "help")
231
+ echo -e "\${GREEN}Usage:\${NC}"
232
+ echo " ./claude-swarm.sh research \\"task description\\" [skip-permissions]"
233
+ echo " ./claude-swarm.sh development \\"task description\\" [skip-permissions]"
234
+ echo " ./claude-swarm.sh analysis \\"task description\\" [skip-permissions]"
235
+ echo " ./claude-swarm.sh optimization \\"task description\\" [skip-permissions]"
236
+ echo " ./claude-swarm.sh custom \\"full claude prompt\\" [skip-permissions]"
237
+ echo
238
+ echo -e "\${GREEN}Examples:\${NC}"
239
+ echo ' ./claude-swarm.sh research "Analyze modern web frameworks" true'
240
+ echo ' ./claude-swarm.sh development "Build user authentication API"'
241
+ echo ' ./claude-swarm.sh custom "Initialize ${this.packageName} and create 3 agents for data processing"'
242
+ echo
243
+ echo -e "\${YELLOW}Note:\${NC} Add 'true' as the last parameter to use --dangerously-skip-permissions"
244
+ ;;
245
+ *)
246
+ echo -e "\${RED}Unknown command: \$1\${NC}"
247
+ echo "Run './claude-swarm.sh help' for usage information"
248
+ exit 1
249
+ ;;
250
+ esac`;
251
+
252
+ const batchHelper = `@echo off
253
+ REM Claude Code Direct Swarm Invocation Helper (Windows)
254
+ REM Generated by ${this.packageName} --claude setup
255
+
256
+ echo 🐝 ${this.packageName} Claude Code Direct Invocation
257
+ echo ============================================
258
+ echo.
259
+
260
+ if "%1"=="research" (
261
+ echo 🚀 Invoking Claude Code with research swarm...
262
+ if "%3"=="true" (
263
+ claude "Initialize a research swarm with 5 agents using ${this.packageName}. Create researcher, analyst, and coder agents. Then orchestrate the task: %2" --dangerously-skip-permissions
264
+ ) else (
265
+ claude "Initialize a research swarm with 5 agents using ${this.packageName}. Create researcher, analyst, and coder agents. Then orchestrate the task: %2"
266
+ )
267
+ ) else if "%1"=="development" (
268
+ echo 🚀 Invoking Claude Code with development swarm...
269
+ if "%3"=="true" (
270
+ claude "Initialize a development swarm with 8 agents using ${this.packageName} in hierarchical topology. Create architect, frontend coder, backend coder, and tester agents. Then orchestrate the task: %2" --dangerously-skip-permissions
271
+ ) else (
272
+ claude "Initialize a development swarm with 8 agents using ${this.packageName} in hierarchical topology. Create architect, frontend coder, backend coder, and tester agents. Then orchestrate the task: %2"
273
+ )
274
+ ) else if "%1"=="custom" (
275
+ echo 🚀 Invoking Claude Code with custom prompt...
276
+ if "%3"=="true" (
277
+ claude "%2" --dangerously-skip-permissions
278
+ ) else (
279
+ claude "%2"
280
+ )
281
+ ) else if "%1"=="help" (
282
+ echo Usage:
283
+ echo claude-swarm.bat research "task description" [skip-permissions]
284
+ echo claude-swarm.bat development "task description" [skip-permissions]
285
+ echo claude-swarm.bat custom "full claude prompt" [skip-permissions]
286
+ echo.
287
+ echo Examples:
288
+ echo claude-swarm.bat research "Analyze modern web frameworks" true
289
+ echo claude-swarm.bat development "Build user authentication API"
290
+ echo.
291
+ echo Note: Add 'true' as the last parameter to use --dangerously-skip-permissions
292
+ ) else (
293
+ echo Unknown command: %1
294
+ echo Run 'claude-swarm.bat help' for usage information
295
+ exit /b 1
296
+ )`;
297
+
298
+ return { bash: bashHelper, batch: batchHelper };
299
+ }
300
+
301
+ /**
302
+ * Create all wrapper scripts
303
+ */
304
+ async createWrappers() {
305
+ console.log('🔧 Creating remote wrapper scripts...');
306
+
307
+ try {
308
+ const scripts = [
309
+ {
310
+ name: `${this.packageName}-wrapper`,
311
+ content: this.generateBashWrapper(),
312
+ mode: 0o755,
313
+ },
314
+ {
315
+ name: `${this.packageName}-wrapper.bat`,
316
+ content: this.generateBatchWrapper(),
317
+ mode: 0o644,
318
+ },
319
+ {
320
+ name: `${this.packageName}-wrapper.ps1`,
321
+ content: this.generatePowerShellWrapper(),
322
+ mode: 0o755,
323
+ },
324
+ ];
325
+
326
+ const createdFiles = [];
327
+
328
+ for (const script of scripts) {
329
+ const filePath = path.join(this.workingDir, script.name);
330
+ await fs.writeFile(filePath, script.content, { mode: script.mode });
331
+ createdFiles.push(script.name);
332
+ }
333
+
334
+ console.log(`✅ Created wrapper scripts: ${ createdFiles.join(', ')}`);
335
+ return { files: createdFiles, success: true };
336
+
337
+ } catch (error) {
338
+ console.error('❌ Failed to create wrapper scripts:', error.message);
339
+ throw error;
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Create Claude helper scripts
345
+ */
346
+ async createClaudeHelpers() {
347
+ console.log('🤖 Creating Claude helper scripts...');
348
+
349
+ try {
350
+ const helpers = this.generateClaudeHelpers();
351
+
352
+ const scripts = [
353
+ {
354
+ name: 'claude-swarm.sh',
355
+ content: helpers.bash,
356
+ mode: 0o755,
357
+ },
358
+ {
359
+ name: 'claude-swarm.bat',
360
+ content: helpers.batch,
361
+ mode: 0o644,
362
+ },
363
+ ];
364
+
365
+ const createdFiles = [];
366
+
367
+ for (const script of scripts) {
368
+ const filePath = path.join(this.workingDir, script.name);
369
+ await fs.writeFile(filePath, script.content, { mode: script.mode });
370
+ createdFiles.push(script.name);
371
+ }
372
+
373
+ console.log(`✅ Created Claude helper scripts: ${ createdFiles.join(', ')}`);
374
+ return { files: createdFiles, success: true };
375
+
376
+ } catch (error) {
377
+ console.error('❌ Failed to create Claude helper scripts:', error.message);
378
+ throw error;
379
+ }
380
+ }
381
+
382
+ /**
383
+ * Create all remote scripts
384
+ */
385
+ async createAll() {
386
+ console.log('🌐 Setting up remote execution capabilities...');
387
+
388
+ try {
389
+ const results = {
390
+ wrappers: await this.createWrappers(),
391
+ helpers: await this.createClaudeHelpers(),
392
+ success: true,
393
+ };
394
+
395
+ console.log('✅ Remote execution setup complete');
396
+ console.log(' - Cross-platform wrapper scripts');
397
+ console.log(' - Claude integration helpers');
398
+ console.log(' - Remote execution detection');
399
+
400
+ return results;
401
+ } catch (error) {
402
+ console.error('❌ Failed to setup remote execution:', error.message);
403
+ throw error;
404
+ }
405
+ }
406
+ }
407
+
408
+ export { RemoteWrapperGenerator };