@wundr.io/cli 1.0.12 → 1.0.14

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 (233) hide show
  1. package/dist/ai/ai-service.d.ts +152 -0
  2. package/dist/ai/ai-service.d.ts.map +1 -0
  3. package/dist/ai/ai-service.js +430 -0
  4. package/dist/ai/ai-service.js.map +1 -0
  5. package/dist/ai/claude-client.d.ts +130 -0
  6. package/dist/ai/claude-client.d.ts.map +1 -0
  7. package/dist/ai/claude-client.js +340 -0
  8. package/dist/ai/claude-client.js.map +1 -0
  9. package/dist/ai/conversation-manager.d.ts +164 -0
  10. package/dist/ai/conversation-manager.d.ts.map +1 -0
  11. package/dist/ai/conversation-manager.js +614 -0
  12. package/dist/ai/conversation-manager.js.map +1 -0
  13. package/dist/ai/index.d.ts +5 -0
  14. package/dist/ai/index.d.ts.map +1 -0
  15. package/dist/ai/index.js +8 -0
  16. package/dist/ai/index.js.map +1 -0
  17. package/dist/cli.d.ts +36 -0
  18. package/dist/cli.d.ts.map +1 -0
  19. package/dist/cli.js +192 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/commands/ai.d.ts +89 -0
  22. package/dist/commands/ai.d.ts.map +1 -0
  23. package/dist/commands/ai.js +954 -0
  24. package/dist/commands/ai.js.map +1 -0
  25. package/dist/commands/alignment.d.ts +78 -0
  26. package/dist/commands/alignment.d.ts.map +1 -0
  27. package/dist/commands/alignment.js +817 -0
  28. package/dist/commands/alignment.js.map +1 -0
  29. package/dist/commands/analyze-optimized.d.ts +14 -0
  30. package/dist/commands/analyze-optimized.d.ts.map +1 -0
  31. package/dist/commands/analyze-optimized.js +609 -0
  32. package/dist/commands/analyze-optimized.js.map +1 -0
  33. package/dist/commands/analyze.d.ts +65 -0
  34. package/dist/commands/analyze.d.ts.map +1 -0
  35. package/dist/commands/analyze.js +435 -0
  36. package/dist/commands/analyze.js.map +1 -0
  37. package/dist/commands/batch.d.ts +93 -0
  38. package/dist/commands/batch.d.ts.map +1 -0
  39. package/dist/commands/batch.js +854 -0
  40. package/dist/commands/batch.js.map +1 -0
  41. package/dist/commands/chat.d.ts +72 -0
  42. package/dist/commands/chat.d.ts.map +1 -0
  43. package/dist/commands/chat.js +678 -0
  44. package/dist/commands/chat.js.map +1 -0
  45. package/dist/commands/claude-init.d.ts +28 -0
  46. package/dist/commands/claude-init.d.ts.map +1 -0
  47. package/dist/commands/claude-init.js +591 -0
  48. package/dist/commands/claude-init.js.map +1 -0
  49. package/dist/commands/claude-setup.d.ts +119 -0
  50. package/dist/commands/claude-setup.d.ts.map +1 -0
  51. package/dist/commands/claude-setup.js +1079 -0
  52. package/dist/commands/claude-setup.js.map +1 -0
  53. package/dist/commands/computer-setup.d.ts +8 -0
  54. package/dist/commands/computer-setup.d.ts.map +1 -0
  55. package/dist/commands/computer-setup.js +877 -0
  56. package/dist/commands/computer-setup.js.map +1 -0
  57. package/dist/commands/create-command.d.ts +7 -0
  58. package/dist/commands/create-command.d.ts.map +1 -0
  59. package/dist/commands/create-command.js +158 -0
  60. package/dist/commands/create-command.js.map +1 -0
  61. package/dist/commands/create.d.ts +74 -0
  62. package/dist/commands/create.d.ts.map +1 -0
  63. package/dist/commands/create.js +556 -0
  64. package/dist/commands/create.js.map +1 -0
  65. package/dist/commands/dashboard.d.ts +91 -0
  66. package/dist/commands/dashboard.d.ts.map +1 -0
  67. package/dist/commands/dashboard.js +538 -0
  68. package/dist/commands/dashboard.js.map +1 -0
  69. package/dist/commands/govern.d.ts +70 -0
  70. package/dist/commands/govern.d.ts.map +1 -0
  71. package/dist/commands/govern.js +481 -0
  72. package/dist/commands/govern.js.map +1 -0
  73. package/dist/commands/governance.d.ts +17 -0
  74. package/dist/commands/governance.d.ts.map +1 -0
  75. package/dist/commands/governance.js +703 -0
  76. package/dist/commands/governance.js.map +1 -0
  77. package/dist/commands/guardian.d.ts +20 -0
  78. package/dist/commands/guardian.d.ts.map +1 -0
  79. package/dist/commands/guardian.js +597 -0
  80. package/dist/commands/guardian.js.map +1 -0
  81. package/dist/commands/init.d.ts +59 -0
  82. package/dist/commands/init.d.ts.map +1 -0
  83. package/dist/commands/init.js +650 -0
  84. package/dist/commands/init.js.map +1 -0
  85. package/dist/commands/orchestrator.d.ts +7 -0
  86. package/dist/commands/orchestrator.d.ts.map +1 -0
  87. package/dist/commands/orchestrator.js +578 -0
  88. package/dist/commands/orchestrator.js.map +1 -0
  89. package/dist/commands/performance-optimizer.d.ts +30 -0
  90. package/dist/commands/performance-optimizer.d.ts.map +1 -0
  91. package/dist/commands/performance-optimizer.js +650 -0
  92. package/dist/commands/performance-optimizer.js.map +1 -0
  93. package/dist/commands/plugins.d.ts +87 -0
  94. package/dist/commands/plugins.d.ts.map +1 -0
  95. package/dist/commands/plugins.js +685 -0
  96. package/dist/commands/plugins.js.map +1 -0
  97. package/dist/commands/rag.d.ts +7 -0
  98. package/dist/commands/rag.d.ts.map +1 -0
  99. package/dist/commands/rag.js +751 -0
  100. package/dist/commands/rag.js.map +1 -0
  101. package/dist/commands/session.d.ts +41 -0
  102. package/dist/commands/session.d.ts.map +1 -0
  103. package/dist/commands/session.js +441 -0
  104. package/dist/commands/session.js.map +1 -0
  105. package/dist/commands/setup.d.ts +24 -0
  106. package/dist/commands/setup.d.ts.map +1 -0
  107. package/dist/commands/setup.js +172 -0
  108. package/dist/commands/setup.js.map +1 -0
  109. package/dist/commands/test-init.d.ts +9 -0
  110. package/dist/commands/test-init.d.ts.map +1 -0
  111. package/dist/commands/test-init.js +222 -0
  112. package/dist/commands/test-init.js.map +1 -0
  113. package/dist/commands/test.d.ts +25 -0
  114. package/dist/commands/test.d.ts.map +1 -0
  115. package/dist/commands/test.js +217 -0
  116. package/dist/commands/test.js.map +1 -0
  117. package/dist/commands/watch.d.ts +76 -0
  118. package/dist/commands/watch.d.ts.map +1 -0
  119. package/dist/commands/watch.js +613 -0
  120. package/dist/commands/watch.js.map +1 -0
  121. package/dist/commands/worktree.d.ts +63 -0
  122. package/dist/commands/worktree.d.ts.map +1 -0
  123. package/dist/commands/worktree.js +774 -0
  124. package/dist/commands/worktree.js.map +1 -0
  125. package/dist/context/context-manager.d.ts +155 -0
  126. package/dist/context/context-manager.d.ts.map +1 -0
  127. package/dist/context/context-manager.js +383 -0
  128. package/dist/context/context-manager.js.map +1 -0
  129. package/dist/context/index.d.ts +3 -0
  130. package/dist/context/index.d.ts.map +1 -0
  131. package/dist/context/index.js +6 -0
  132. package/dist/context/index.js.map +1 -0
  133. package/dist/context/session-manager.d.ts +207 -0
  134. package/dist/context/session-manager.d.ts.map +1 -0
  135. package/dist/context/session-manager.js +686 -0
  136. package/dist/context/session-manager.js.map +1 -0
  137. package/dist/framework/command-interface.d.ts +349 -0
  138. package/dist/framework/command-interface.d.ts.map +1 -0
  139. package/dist/framework/command-interface.js +101 -0
  140. package/dist/framework/command-interface.js.map +1 -0
  141. package/dist/framework/command-registry.d.ts +173 -0
  142. package/dist/framework/command-registry.d.ts.map +1 -0
  143. package/dist/framework/command-registry.js +734 -0
  144. package/dist/framework/command-registry.js.map +1 -0
  145. package/dist/framework/completion-exporter.d.ts +79 -0
  146. package/dist/framework/completion-exporter.d.ts.map +1 -0
  147. package/dist/framework/completion-exporter.js +259 -0
  148. package/dist/framework/completion-exporter.js.map +1 -0
  149. package/dist/framework/debug-logger.d.ts +163 -0
  150. package/dist/framework/debug-logger.d.ts.map +1 -0
  151. package/dist/framework/debug-logger.js +373 -0
  152. package/dist/framework/debug-logger.js.map +1 -0
  153. package/dist/framework/error-handler.d.ts +196 -0
  154. package/dist/framework/error-handler.d.ts.map +1 -0
  155. package/dist/framework/error-handler.js +613 -0
  156. package/dist/framework/error-handler.js.map +1 -0
  157. package/dist/framework/help-generator.d.ts +78 -0
  158. package/dist/framework/help-generator.d.ts.map +1 -0
  159. package/dist/framework/help-generator.js +414 -0
  160. package/dist/framework/help-generator.js.map +1 -0
  161. package/dist/framework/index.d.ts +62 -0
  162. package/dist/framework/index.d.ts.map +1 -0
  163. package/dist/framework/index.js +95 -0
  164. package/dist/framework/index.js.map +1 -0
  165. package/dist/framework/interactive-repl.d.ts +138 -0
  166. package/dist/framework/interactive-repl.d.ts.map +1 -0
  167. package/dist/framework/interactive-repl.js +567 -0
  168. package/dist/framework/interactive-repl.js.map +1 -0
  169. package/dist/framework/output-formatter.d.ts +274 -0
  170. package/dist/framework/output-formatter.d.ts.map +1 -0
  171. package/dist/framework/output-formatter.js +545 -0
  172. package/dist/framework/output-formatter.js.map +1 -0
  173. package/dist/framework/progress-manager.d.ts +192 -0
  174. package/dist/framework/progress-manager.d.ts.map +1 -0
  175. package/dist/framework/progress-manager.js +408 -0
  176. package/dist/framework/progress-manager.js.map +1 -0
  177. package/dist/index.d.ts +8 -0
  178. package/dist/index.d.ts.map +1 -0
  179. package/dist/index.js +51 -0
  180. package/dist/index.js.map +1 -0
  181. package/dist/interactive/interactive-mode.d.ts +76 -0
  182. package/dist/interactive/interactive-mode.d.ts.map +1 -0
  183. package/dist/interactive/interactive-mode.js +732 -0
  184. package/dist/interactive/interactive-mode.js.map +1 -0
  185. package/dist/nlp/command-mapper.d.ts +174 -0
  186. package/dist/nlp/command-mapper.d.ts.map +1 -0
  187. package/dist/nlp/command-mapper.js +624 -0
  188. package/dist/nlp/command-mapper.js.map +1 -0
  189. package/dist/nlp/command-parser.d.ts +106 -0
  190. package/dist/nlp/command-parser.d.ts.map +1 -0
  191. package/dist/nlp/command-parser.js +417 -0
  192. package/dist/nlp/command-parser.js.map +1 -0
  193. package/dist/nlp/index.d.ts +5 -0
  194. package/dist/nlp/index.d.ts.map +1 -0
  195. package/dist/nlp/index.js +8 -0
  196. package/dist/nlp/index.js.map +1 -0
  197. package/dist/nlp/intent-classifier.d.ts +59 -0
  198. package/dist/nlp/intent-classifier.d.ts.map +1 -0
  199. package/dist/nlp/intent-classifier.js +384 -0
  200. package/dist/nlp/intent-classifier.js.map +1 -0
  201. package/dist/nlp/intent-parser.d.ts +152 -0
  202. package/dist/nlp/intent-parser.d.ts.map +1 -0
  203. package/dist/nlp/intent-parser.js +746 -0
  204. package/dist/nlp/intent-parser.js.map +1 -0
  205. package/dist/plugins/plugin-manager.d.ts +121 -0
  206. package/dist/plugins/plugin-manager.d.ts.map +1 -0
  207. package/dist/plugins/plugin-manager.js +606 -0
  208. package/dist/plugins/plugin-manager.js.map +1 -0
  209. package/dist/types/index.d.ts +224 -0
  210. package/dist/types/index.d.ts.map +1 -0
  211. package/dist/types/index.js +3 -0
  212. package/dist/types/index.js.map +1 -0
  213. package/dist/utils/backup-rollback-manager.d.ts +72 -0
  214. package/dist/utils/backup-rollback-manager.d.ts.map +1 -0
  215. package/dist/utils/backup-rollback-manager.js +288 -0
  216. package/dist/utils/backup-rollback-manager.js.map +1 -0
  217. package/dist/utils/claude-config-installer.d.ts +98 -0
  218. package/dist/utils/claude-config-installer.d.ts.map +1 -0
  219. package/dist/utils/claude-config-installer.js +678 -0
  220. package/dist/utils/claude-config-installer.js.map +1 -0
  221. package/dist/utils/config-manager.d.ts +73 -0
  222. package/dist/utils/config-manager.d.ts.map +1 -0
  223. package/dist/utils/config-manager.js +339 -0
  224. package/dist/utils/config-manager.js.map +1 -0
  225. package/dist/utils/error-handler.d.ts +46 -0
  226. package/dist/utils/error-handler.d.ts.map +1 -0
  227. package/dist/utils/error-handler.js +169 -0
  228. package/dist/utils/error-handler.js.map +1 -0
  229. package/dist/utils/logger.d.ts +25 -0
  230. package/dist/utils/logger.d.ts.map +1 -0
  231. package/dist/utils/logger.js +105 -0
  232. package/dist/utils/logger.js.map +1 -0
  233. package/package.json +6 -6
@@ -0,0 +1,1079 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClaudeSetupCommands = void 0;
4
+ exports.createClaudeSetupCommand = createClaudeSetupCommand;
5
+ const tslib_1 = require("tslib");
6
+ const child_process_1 = require("child_process");
7
+ const fs = tslib_1.__importStar(require("fs"));
8
+ const path = tslib_1.__importStar(require("path"));
9
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const commander_1 = require("commander");
11
+ const ora_1 = tslib_1.__importDefault(require("ora"));
12
+ /**
13
+ * Claude Setup Commands
14
+ * Comprehensive setup for Claude Code, Ruflo, and MCP tools
15
+ *
16
+ * Consolidated from:
17
+ * - /src/cli/commands/claude-setup.ts (374 lines) - function-based approach
18
+ * - /packages/@wundr/cli/src/commands/claude-setup.ts (697 lines) - class-based approach
19
+ *
20
+ * This version preserves ALL functionality from both implementations.
21
+ */
22
+ class ClaudeSetupCommands {
23
+ program;
24
+ constructor(program) {
25
+ this.program = program;
26
+ this.registerCommands();
27
+ }
28
+ registerCommands() {
29
+ const claudeSetup = this.program
30
+ .command('claude-setup')
31
+ .alias('cs')
32
+ .description('Setup Claude Code, Ruflo, and MCP tools')
33
+ .addHelpText('after', chalk_1.default.gray(`
34
+ Examples:
35
+ ${chalk_1.default.green('wundr claude-setup')} Interactive Claude setup
36
+ ${chalk_1.default.green('wundr claude-setup install')} Complete ecosystem installation
37
+ ${chalk_1.default.green('wundr claude-setup mcp')} Install all MCP tools
38
+ ${chalk_1.default.green('wundr claude-setup agents')} Configure all 54 agents
39
+ ${chalk_1.default.green('wundr claude-setup optimize')} Setup hardware-adaptive optimizations
40
+ ${chalk_1.default.green('wundr claude-setup validate')} Validate Claude installation
41
+ ${chalk_1.default.green('wundr claude-setup project')} Setup project with templates
42
+ `));
43
+ // Main setup command (default)
44
+ claudeSetup
45
+ .command('install', { isDefault: true })
46
+ .description('Complete Claude ecosystem installation')
47
+ .option('--skip-chrome', 'Skip Chrome installation')
48
+ .option('--skip-mcp', 'Skip MCP tools installation')
49
+ .option('--skip-agents', 'Skip agent configuration')
50
+ .option('--skip-flow', 'Skip Ruflo setup')
51
+ .option('-g, --global', 'Install tools globally')
52
+ .action(async (options) => {
53
+ await this.runCompleteSetup(options);
54
+ });
55
+ // Project setup with templates (from /src/cli/commands/claude-setup.ts)
56
+ claudeSetup
57
+ .command('project [path]')
58
+ .description('Setup Claude Code in a project directory with optional template')
59
+ .option('-g, --global', 'Install tools globally')
60
+ .option('--skip-mcp', 'Skip MCP tools installation')
61
+ .option('--skip-flow', 'Skip Ruflo setup')
62
+ .option('-t, --template <name>', 'Use specific project template (typescript, react, nodejs, monorepo)')
63
+ .action(async (projectPath = '.', options) => {
64
+ await this.runProjectSetup(projectPath, options);
65
+ });
66
+ // MCP tools installation
67
+ claudeSetup
68
+ .command('mcp')
69
+ .description('Install and configure MCP tools')
70
+ .option('--tool <tool>', 'Install specific tool (firecrawl, context7, playwright, browser, sequentialthinking, ruflo)')
71
+ .action(async (options) => {
72
+ await this.installMcpTools(options);
73
+ });
74
+ // Agent configuration
75
+ claudeSetup
76
+ .command('agents')
77
+ .description('Configure Ruflo agents')
78
+ .option('--list', 'List available agents')
79
+ .option('--enable <agents>', 'Enable specific agents (comma-separated)')
80
+ .option('--profile <profile>', 'Use profile-specific agents')
81
+ .action(async (options) => {
82
+ await this.configureAgents(options);
83
+ });
84
+ // Validation
85
+ claudeSetup
86
+ .command('validate')
87
+ .description('Validate Claude installation')
88
+ .option('--fix', 'Attempt to fix issues')
89
+ .action(async (options) => {
90
+ await this.validateInstallation(options);
91
+ });
92
+ // Chrome extension
93
+ claudeSetup
94
+ .command('extension')
95
+ .description('Install Browser MCP Chrome extension')
96
+ .action(async () => {
97
+ await this.installChromeExtension();
98
+ });
99
+ // Hardware optimization
100
+ claudeSetup
101
+ .command('optimize')
102
+ .description('Setup hardware-adaptive Claude Code optimizations')
103
+ .option('--force', 'Force reinstallation of optimization scripts')
104
+ .action(async (options) => {
105
+ await this.setupOptimizations(options);
106
+ });
107
+ // Generate CLAUDE.md
108
+ claudeSetup
109
+ .command('config')
110
+ .description('Generate or update CLAUDE.md configuration')
111
+ .argument('[path]', 'Path to repository (defaults to current directory)', '.')
112
+ .action(async (repoPath) => {
113
+ await this.generateClaudeConfig(repoPath);
114
+ });
115
+ }
116
+ /**
117
+ * Complete setup - combines both implementations' main flows
118
+ */
119
+ async runCompleteSetup(options) {
120
+ const spinner = (0, ora_1.default)();
121
+ console.log(chalk_1.default.cyan.bold('\nšŸ¤– Claude Ecosystem Setup\n'));
122
+ try {
123
+ // Step 1: Install Claude CLI
124
+ if (!this.isClaudeInstalled()) {
125
+ spinner.start('Installing Claude CLI...');
126
+ (0, child_process_1.execSync)('npm install -g @anthropic/claude-cli', { stdio: 'inherit' });
127
+ spinner.succeed('Claude CLI installed');
128
+ }
129
+ else {
130
+ console.log(chalk_1.default.green('āœ“ Claude CLI already installed'));
131
+ }
132
+ // Step 2: Install Chrome (if needed and not skipped)
133
+ if (!options.skipChrome && !this.isChromeInstalled()) {
134
+ spinner.start('Installing Google Chrome...');
135
+ await this.installChrome();
136
+ spinner.succeed('Chrome installed');
137
+ }
138
+ // Step 3: Ruflo setup
139
+ if (!options.skipFlow) {
140
+ await this.setupRuflo(spinner, process.cwd(), options.global);
141
+ }
142
+ // Step 4: Install MCP tools (if not skipped)
143
+ if (!options.skipMcp) {
144
+ await this.installMcpTools({});
145
+ }
146
+ // Step 5: Configure agents (if not skipped)
147
+ if (!options.skipAgents) {
148
+ await this.configureAgents({ profile: 'fullstack' });
149
+ }
150
+ // Step 6: Setup Claude configuration
151
+ spinner.start('Configuring Claude settings...');
152
+ await this.setupClaudeSettings();
153
+ spinner.succeed('Claude configured');
154
+ console.log(chalk_1.default.green.bold('\nāœ… Claude ecosystem setup complete!\n'));
155
+ this.printNextSteps();
156
+ }
157
+ catch (error) {
158
+ spinner.fail('Setup failed');
159
+ console.error(chalk_1.default.red(error));
160
+ process.exit(1);
161
+ }
162
+ }
163
+ /**
164
+ * Project setup - from /src/cli/commands/claude-setup.ts
165
+ */
166
+ async runProjectSetup(projectPath, options) {
167
+ const spinner = (0, ora_1.default)('Starting Claude Code project setup...').start();
168
+ try {
169
+ const repoPath = path.resolve(projectPath);
170
+ // Verify git repository
171
+ if (!fs.existsSync(path.join(repoPath, '.git'))) {
172
+ spinner.stop();
173
+ const inquirer = await Promise.resolve().then(() => tslib_1.__importStar(require('inquirer')));
174
+ const { shouldInitGit } = await inquirer.default.prompt([
175
+ {
176
+ type: 'confirm',
177
+ name: 'shouldInitGit',
178
+ message: 'Not a git repository. Initialize git?',
179
+ default: true,
180
+ },
181
+ ]);
182
+ if (shouldInitGit) {
183
+ spinner.start('Initializing git repository...');
184
+ (0, child_process_1.execSync)('git init', { cwd: repoPath });
185
+ spinner.succeed('Git repository initialized');
186
+ }
187
+ else {
188
+ console.log(chalk_1.default.yellow('Continuing without git...'));
189
+ }
190
+ }
191
+ // Step 1: Ruflo setup
192
+ if (!options.skipFlow) {
193
+ await this.setupRuflo(spinner, repoPath, options.global);
194
+ }
195
+ // Step 2: MCP Tools setup
196
+ if (!options.skipMcp) {
197
+ await this.setupMCPToolsDirectory(spinner, repoPath);
198
+ }
199
+ // Step 3: Generate CLAUDE.md
200
+ await this.generateClaudeConfigForPath(spinner, repoPath);
201
+ // Step 4: Setup project template if specified
202
+ if (options.template) {
203
+ await this.setupProjectTemplate(spinner, repoPath, options.template);
204
+ }
205
+ // Step 5: Initialize swarm if Ruflo is available
206
+ if (!options.skipFlow) {
207
+ await this.initializeSwarm(spinner, repoPath);
208
+ }
209
+ // Step 6: Validation
210
+ await this.validateProjectSetup(spinner, repoPath);
211
+ spinner.succeed('Claude Code project setup completed successfully!');
212
+ // Final instructions
213
+ this.displayProjectFinalInstructions(repoPath, options);
214
+ }
215
+ catch (error) {
216
+ spinner.stop();
217
+ console.error(chalk_1.default.red('āŒ Setup failed:'));
218
+ console.error(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
219
+ process.exit(1);
220
+ }
221
+ }
222
+ /**
223
+ * Setup Ruflo - from /src/cli/commands/claude-setup.ts
224
+ */
225
+ async setupRuflo(spinner, repoPath, global) {
226
+ spinner.text = 'Setting up Ruflo...';
227
+ try {
228
+ // Check if Ruflo is already installed
229
+ (0, child_process_1.execSync)('npx ruflo@latest --version', { stdio: 'ignore' });
230
+ spinner.text = 'Ruflo already available, configuring...';
231
+ }
232
+ catch {
233
+ spinner.text = 'Installing Ruflo...';
234
+ if (global) {
235
+ (0, child_process_1.execSync)('npm install -g ruflo@latest', { stdio: 'inherit' });
236
+ }
237
+ else {
238
+ // Add to package.json dev dependencies if it exists
239
+ if (fs.existsSync(path.join(repoPath, 'package.json'))) {
240
+ (0, child_process_1.execSync)('npm install --save-dev ruflo@latest', {
241
+ cwd: repoPath,
242
+ stdio: 'inherit',
243
+ });
244
+ }
245
+ }
246
+ }
247
+ // Add MCP server configuration
248
+ spinner.text = 'Configuring Claude MCP server...';
249
+ try {
250
+ (0, child_process_1.execSync)('claude mcp add ruflo npx ruflo@latest mcp start', {
251
+ cwd: repoPath,
252
+ stdio: 'pipe',
253
+ });
254
+ }
255
+ catch {
256
+ // MCP configuration might fail if Claude Desktop isn't installed
257
+ console.log(chalk_1.default.yellow('\nāš ļø Could not configure MCP server automatically.'));
258
+ console.log(chalk_1.default.yellow('Please run manually: claude mcp add ruflo npx ruflo@latest mcp start'));
259
+ }
260
+ spinner.text = 'Ruflo setup completed';
261
+ }
262
+ /**
263
+ * Setup MCP Tools directory - from /src/cli/commands/claude-setup.ts
264
+ */
265
+ async setupMCPToolsDirectory(spinner, repoPath) {
266
+ spinner.text = 'Setting up MCP Tools directory...';
267
+ const mcpToolsPath = path.join(repoPath, 'mcp-tools');
268
+ // Create mcp-tools directory if it doesn't exist
269
+ if (!fs.existsSync(mcpToolsPath)) {
270
+ fs.mkdirSync(mcpToolsPath, { recursive: true });
271
+ // Create basic install script
272
+ const installScript = `#!/bin/bash
273
+ # MCP Tools Installation Script
274
+ echo "Installing Wundr MCP Tools..."
275
+
276
+ # Add your MCP tool installations here
277
+ echo "āœ… MCP Tools installation template created"
278
+ echo "Customize this script with your specific MCP tools"
279
+ `;
280
+ fs.writeFileSync(path.join(mcpToolsPath, 'install.sh'), installScript);
281
+ (0, child_process_1.execSync)(`chmod +x ${path.join(mcpToolsPath, 'install.sh')}`);
282
+ // Create package.json for MCP tools
283
+ const mcpPackageJson = {
284
+ name: 'mcp-tools',
285
+ version: '1.0.0',
286
+ description: 'MCP Tools for Claude Code integration',
287
+ private: true,
288
+ scripts: {
289
+ install: './install.sh',
290
+ },
291
+ };
292
+ fs.writeFileSync(path.join(mcpToolsPath, 'package.json'), JSON.stringify(mcpPackageJson, null, 2));
293
+ }
294
+ spinner.text = 'MCP Tools directory setup completed';
295
+ }
296
+ /**
297
+ * Install MCP tools via script or specific tool
298
+ */
299
+ async installMcpTools(options) {
300
+ const spinner = (0, ora_1.default)();
301
+ const scriptPath = path.join(__dirname, '../../../../scripts/install-mcp-tools.sh');
302
+ console.log(chalk_1.default.cyan('\nšŸ“¦ Installing MCP Tools...\n'));
303
+ if (options.tool) {
304
+ // Install specific tool
305
+ spinner.start(`Installing ${options.tool} MCP...`);
306
+ try {
307
+ const installCommands = {
308
+ firecrawl: 'npx claude mcp add firecrawl npx @firecrawl/mcp-server',
309
+ context7: 'npx claude mcp add context7 npx @context7/mcp-server',
310
+ playwright: 'npx claude mcp add playwright npx @playwright/mcp-server',
311
+ browser: 'npx claude mcp add browser npx @browser/mcp-server',
312
+ sequentialthinking: 'npm install -g @modelcontextprotocol/server-sequentialthinking',
313
+ ruflo: 'claude mcp add ruflo npx ruflo@latest mcp start',
314
+ };
315
+ const command = installCommands[options.tool];
316
+ if (command) {
317
+ (0, child_process_1.execSync)(command, { stdio: 'inherit' });
318
+ spinner.succeed(`${options.tool} MCP installed`);
319
+ }
320
+ else {
321
+ spinner.fail(`Unknown tool: ${options.tool}`);
322
+ console.log(chalk_1.default.yellow(`Available tools: ${Object.keys(installCommands).join(', ')}`));
323
+ }
324
+ }
325
+ catch (error) {
326
+ spinner.fail(`Failed to install ${options.tool}`);
327
+ console.error(error);
328
+ }
329
+ }
330
+ else {
331
+ // Try to install all tools using the script if it exists
332
+ if (fs.existsSync(scriptPath)) {
333
+ console.log(chalk_1.default.gray('Running comprehensive MCP tools installation...'));
334
+ const install = (0, child_process_1.spawn)('bash', [scriptPath], {
335
+ stdio: 'inherit',
336
+ shell: true,
337
+ });
338
+ return new Promise((resolve, reject) => {
339
+ install.on('close', code => {
340
+ if (code === 0) {
341
+ console.log(chalk_1.default.green('\nāœ… All MCP tools installed successfully'));
342
+ resolve();
343
+ }
344
+ else {
345
+ reject(new Error(`Installation failed with code ${code}`));
346
+ }
347
+ });
348
+ });
349
+ }
350
+ else {
351
+ // Fallback: install core tools
352
+ console.log(chalk_1.default.gray('Installing core MCP tools...'));
353
+ const coreTools = ['ruflo', 'sequentialthinking'];
354
+ for (const tool of coreTools) {
355
+ try {
356
+ await this.installMcpTools({ tool });
357
+ }
358
+ catch {
359
+ console.log(chalk_1.default.yellow(`āš ļø Could not install ${tool}`));
360
+ }
361
+ }
362
+ console.log(chalk_1.default.green('\nāœ… Core MCP tools installed'));
363
+ }
364
+ }
365
+ }
366
+ /**
367
+ * Configure Ruflo agents
368
+ */
369
+ async configureAgents(options) {
370
+ const spinner = (0, ora_1.default)();
371
+ if (options.list) {
372
+ this.listAgents();
373
+ return;
374
+ }
375
+ spinner.start('Configuring Ruflo agents...');
376
+ const agents = options.enable
377
+ ? options.enable.split(',')
378
+ : this.getProfileAgents(options.profile || 'fullstack');
379
+ // Create agent configurations
380
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
381
+ const agentsDir = path.join(homeDir, '.claude', 'agents');
382
+ try {
383
+ fs.mkdirSync(agentsDir, { recursive: true });
384
+ for (const agent of agents) {
385
+ const config = this.generateAgentConfig(agent);
386
+ fs.writeFileSync(path.join(agentsDir, `${agent}.json`), JSON.stringify(config, null, 2));
387
+ }
388
+ spinner.succeed(`${agents.length} agents configured`);
389
+ }
390
+ catch (error) {
391
+ spinner.fail('Failed to configure agents');
392
+ console.error(error);
393
+ }
394
+ }
395
+ /**
396
+ * Validate Claude installation
397
+ */
398
+ async validateInstallation(options) {
399
+ console.log(chalk_1.default.cyan('\nšŸ” Validating Claude Installation...\n'));
400
+ const checks = [
401
+ { name: 'Claude CLI', check: () => this.isClaudeInstalled() },
402
+ { name: 'Ruflo', check: () => this.isRufloInstalled() },
403
+ { name: 'Chrome Browser', check: () => this.isChromeInstalled() },
404
+ { name: 'Claude Directory', check: () => this.claudeDirExists() },
405
+ { name: 'Agent Configurations', check: () => this.agentsConfigured() },
406
+ { name: 'MCP Servers', check: () => this.mcpServersConfigured() },
407
+ ];
408
+ let allPassed = true;
409
+ for (const check of checks) {
410
+ const passed = check.check();
411
+ if (passed) {
412
+ console.log(chalk_1.default.green(`āœ“ ${check.name}`));
413
+ }
414
+ else {
415
+ console.log(chalk_1.default.red(`āœ— ${check.name}`));
416
+ allPassed = false;
417
+ }
418
+ }
419
+ if (allPassed) {
420
+ console.log(chalk_1.default.green.bold('\nāœ… All checks passed!'));
421
+ }
422
+ else if (options.fix) {
423
+ console.log(chalk_1.default.yellow('\nšŸ”§ Attempting to fix issues...'));
424
+ await this.runCompleteSetup({});
425
+ }
426
+ else {
427
+ console.log(chalk_1.default.yellow('\nāš ļø Some checks failed. Run with --fix to attempt repairs.'));
428
+ }
429
+ }
430
+ /**
431
+ * Install Chrome extension instructions
432
+ */
433
+ async installChromeExtension() {
434
+ console.log(chalk_1.default.cyan('\nšŸ”Œ Browser MCP Chrome Extension Setup\n'));
435
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
436
+ const extensionDir = path.join(homeDir, '.claude', 'browser-extension');
437
+ console.log(chalk_1.default.white('Extension location: ' + extensionDir));
438
+ console.log(chalk_1.default.yellow('\nTo install:'));
439
+ console.log('1. Open Chrome and navigate to chrome://extensions');
440
+ console.log('2. Enable "Developer mode" (top right)');
441
+ console.log('3. Click "Load unpacked"');
442
+ console.log(`4. Select: ${extensionDir}`);
443
+ console.log('\nāœ… The extension will then be active!');
444
+ }
445
+ /**
446
+ * Setup hardware-adaptive optimizations
447
+ */
448
+ async setupOptimizations(options) {
449
+ const spinner = (0, ora_1.default)();
450
+ console.log(chalk_1.default.cyan.bold('\n⚔ Claude Code Hardware-Adaptive Optimization Setup\n'));
451
+ try {
452
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
453
+ const scriptsDir = path.join(homeDir, '.claude', 'scripts');
454
+ const resourcesDir = path.join(__dirname, '../../../computer-setup/resources/scripts');
455
+ // Check if optimization scripts already exist
456
+ const scriptsExist = fs.existsSync(scriptsDir);
457
+ if (scriptsExist && !options.force) {
458
+ const inquirer = await Promise.resolve().then(() => tslib_1.__importStar(require('inquirer')));
459
+ const { overwrite } = await inquirer.default.prompt([
460
+ {
461
+ type: 'confirm',
462
+ name: 'overwrite',
463
+ message: 'Optimization scripts already exist. Do you want to reinstall?',
464
+ default: false,
465
+ },
466
+ ]);
467
+ if (!overwrite) {
468
+ console.log(chalk_1.default.yellow('Optimization setup cancelled'));
469
+ return;
470
+ }
471
+ }
472
+ // Step 1: Create scripts directory
473
+ spinner.start('Creating scripts directory...');
474
+ fs.mkdirSync(scriptsDir, { recursive: true });
475
+ spinner.succeed('Scripts directory ready');
476
+ // Step 2: Copy optimization scripts
477
+ spinner.start('Installing optimization scripts...');
478
+ if (!fs.existsSync(resourcesDir)) {
479
+ spinner.fail('Optimization scripts not found in resources');
480
+ console.error(chalk_1.default.red(`Expected scripts at: ${resourcesDir}\nPlease ensure @wundr/computer-setup is installed.`));
481
+ return;
482
+ }
483
+ // Copy all scripts
484
+ const scripts = [
485
+ 'detect-hardware-limits.js',
486
+ 'claude-optimized',
487
+ 'orchestrator.js',
488
+ 'cleanup-zombies.sh',
489
+ 'README-ORCHESTRATION.md',
490
+ 'QUICK-START.md',
491
+ ];
492
+ for (const script of scripts) {
493
+ const src = path.join(resourcesDir, script);
494
+ const dest = path.join(scriptsDir, script);
495
+ if (fs.existsSync(src)) {
496
+ fs.copyFileSync(src, dest);
497
+ }
498
+ else {
499
+ console.warn(chalk_1.default.yellow(`āš ļø Script not found: ${script}`));
500
+ }
501
+ }
502
+ // Make executable scripts executable
503
+ const executableScripts = ['claude-optimized', 'cleanup-zombies.sh'];
504
+ for (const script of executableScripts) {
505
+ const scriptPath = path.join(scriptsDir, script);
506
+ if (fs.existsSync(scriptPath)) {
507
+ (0, child_process_1.execSync)(`chmod +x "${scriptPath}"`, { stdio: 'pipe' });
508
+ }
509
+ }
510
+ spinner.succeed('Optimization scripts installed');
511
+ // Step 3: Configure shell
512
+ spinner.start('Configuring shell environment...');
513
+ await this.addOptimizationToShell(homeDir);
514
+ spinner.succeed('Shell configuration updated');
515
+ console.log(chalk_1.default.green.bold('\nāœ… Optimization setup complete!\n'));
516
+ // Show what was installed
517
+ console.log(chalk_1.default.cyan('šŸ“¦ Installed Scripts:'));
518
+ console.log(chalk_1.default.white(' • detect-hardware-limits.js - Hardware detection'));
519
+ console.log(chalk_1.default.white(' • claude-optimized - Optimized Claude wrapper'));
520
+ console.log(chalk_1.default.white(' • orchestrator.js - Fault-tolerant orchestration'));
521
+ console.log(chalk_1.default.white(' • cleanup-zombies.sh - Process cleanup utility'));
522
+ console.log(chalk_1.default.cyan('\nšŸ”§ Shell Aliases:'));
523
+ console.log(chalk_1.default.white(' • claude - Hardware-optimized Claude wrapper'));
524
+ console.log(chalk_1.default.white(' • claude-stats - Show hardware statistics'));
525
+ console.log(chalk_1.default.white(' • claude-cleanup - Clean up zombie processes'));
526
+ console.log(chalk_1.default.white(' • claude-orchestrate - Run multi-task orchestrator'));
527
+ console.log(chalk_1.default.cyan('\nšŸ“ Next Steps:'));
528
+ console.log('1. Restart your terminal (or run: source ~/.zshrc)');
529
+ console.log('2. Run "claude-stats" to see your hardware configuration');
530
+ console.log('3. Use "claude" command as normal - now optimized!');
531
+ console.log('4. Read ~/.claude/scripts/QUICK-START.md for advanced usage');
532
+ }
533
+ catch (error) {
534
+ spinner.fail('Optimization setup failed');
535
+ console.error(chalk_1.default.red(error));
536
+ throw error;
537
+ }
538
+ }
539
+ /**
540
+ * Generate CLAUDE.md configuration
541
+ */
542
+ async generateClaudeConfig(repoPath) {
543
+ const spinner = (0, ora_1.default)('Generating CLAUDE.md configuration...').start();
544
+ try {
545
+ const resolvedPath = path.resolve(repoPath);
546
+ await this.generateClaudeConfigForPath(spinner, resolvedPath);
547
+ spinner.succeed('CLAUDE.md generated successfully');
548
+ console.log(chalk_1.default.green(`\nāœ… CLAUDE.md created at: ${path.join(resolvedPath, 'CLAUDE.md')}`));
549
+ }
550
+ catch (error) {
551
+ spinner.fail('Failed to generate CLAUDE.md');
552
+ console.error(chalk_1.default.red(error instanceof Error ? error.message : String(error)));
553
+ }
554
+ }
555
+ /**
556
+ * Generate CLAUDE.md for a specific path
557
+ */
558
+ async generateClaudeConfigForPath(spinner, repoPath) {
559
+ spinner.text = 'Generating CLAUDE.md configuration...';
560
+ try {
561
+ // Try to use the ClaudeConfigGenerator if available
562
+ // Use path.resolve to construct the path at runtime to avoid TypeScript rootDir issues
563
+ const generatorPath = path.resolve(__dirname, '../../../../../src/claude-generator/claude-config-generator.js');
564
+ const { ClaudeConfigGenerator } = await Promise.resolve(`${
565
+ /* @vite-ignore */ generatorPath}`).then(s => tslib_1.__importStar(require(s)));
566
+ const generator = new ClaudeConfigGenerator(repoPath);
567
+ const claudeContent = await generator.generateClaudeMarkdown();
568
+ const claudeFilePath = path.join(repoPath, 'CLAUDE.md');
569
+ fs.writeFileSync(claudeFilePath, claudeContent, 'utf-8');
570
+ }
571
+ catch {
572
+ // Fallback: Create a basic CLAUDE.md
573
+ spinner.text = 'Creating basic CLAUDE.md...';
574
+ const basicContent = this.generateBasicClaudeConfig(repoPath);
575
+ fs.writeFileSync(path.join(repoPath, 'CLAUDE.md'), basicContent, 'utf-8');
576
+ }
577
+ spinner.text = 'CLAUDE.md generated successfully';
578
+ }
579
+ /**
580
+ * Generate basic CLAUDE.md content as fallback
581
+ */
582
+ generateBasicClaudeConfig(repoPath) {
583
+ const projectName = path.basename(repoPath);
584
+ return `# Claude Code Configuration - ${projectName}
585
+
586
+ ## Project Overview
587
+ This project uses Claude Code for AI-assisted development.
588
+
589
+ ## Commands
590
+ - \`npm run build\` - Build the project
591
+ - \`npm run test\` - Run tests
592
+ - \`npm run lint\` - Run linting
593
+
594
+ ## Code Style
595
+ - Follow existing patterns in the codebase
596
+ - Write clear, descriptive commit messages
597
+ - Add tests for new features
598
+
599
+ ## MCP Tools
600
+ Ruflo is configured for enhanced AI coordination.
601
+ Run \`npx ruflo@latest sparc modes\` to see available modes.
602
+ `;
603
+ }
604
+ /**
605
+ * Setup project template - from /src/cli/commands/claude-setup.ts
606
+ */
607
+ async setupProjectTemplate(spinner, repoPath, templateName) {
608
+ spinner.text = `Applying ${templateName} template...`;
609
+ const templates = {
610
+ typescript: () => this.setupTypeScriptTemplate(repoPath),
611
+ react: () => this.setupReactTemplate(repoPath),
612
+ nodejs: () => this.setupNodeTemplate(repoPath),
613
+ monorepo: () => this.setupMonorepoTemplate(repoPath),
614
+ };
615
+ const setupFunction = templates[templateName];
616
+ if (!setupFunction) {
617
+ throw new Error(`Unknown template: ${templateName}. Available: ${Object.keys(templates).join(', ')}`);
618
+ }
619
+ setupFunction();
620
+ spinner.text = `${templateName} template applied`;
621
+ }
622
+ setupTypeScriptTemplate(repoPath) {
623
+ // Create basic TypeScript configuration if not exists
624
+ const tsconfigPath = path.join(repoPath, 'tsconfig.json');
625
+ if (!fs.existsSync(tsconfigPath)) {
626
+ const tsconfig = {
627
+ compilerOptions: {
628
+ target: 'ES2020',
629
+ module: 'ESNext',
630
+ moduleResolution: 'node',
631
+ strict: true,
632
+ esModuleInterop: true,
633
+ skipLibCheck: true,
634
+ forceConsistentCasingInFileNames: true,
635
+ declaration: true,
636
+ outDir: 'dist',
637
+ rootDir: 'src',
638
+ },
639
+ include: ['src/**/*'],
640
+ exclude: ['node_modules', 'dist'],
641
+ };
642
+ fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
643
+ }
644
+ // Create src directory
645
+ const srcPath = path.join(repoPath, 'src');
646
+ if (!fs.existsSync(srcPath)) {
647
+ fs.mkdirSync(srcPath, { recursive: true });
648
+ fs.writeFileSync(path.join(srcPath, 'index.ts'), '// Your TypeScript code here\n');
649
+ }
650
+ }
651
+ setupReactTemplate(repoPath) {
652
+ // Ensure React-specific structure
653
+ const srcPath = path.join(repoPath, 'src');
654
+ if (!fs.existsSync(srcPath)) {
655
+ fs.mkdirSync(srcPath, { recursive: true });
656
+ }
657
+ // Create components directory
658
+ const componentsPath = path.join(srcPath, 'components');
659
+ if (!fs.existsSync(componentsPath)) {
660
+ fs.mkdirSync(componentsPath, { recursive: true });
661
+ }
662
+ // Create hooks directory
663
+ const hooksPath = path.join(srcPath, 'hooks');
664
+ if (!fs.existsSync(hooksPath)) {
665
+ fs.mkdirSync(hooksPath, { recursive: true });
666
+ }
667
+ }
668
+ setupNodeTemplate(repoPath) {
669
+ // Create basic Node.js structure
670
+ const srcPath = path.join(repoPath, 'src');
671
+ if (!fs.existsSync(srcPath)) {
672
+ fs.mkdirSync(srcPath, { recursive: true });
673
+ fs.writeFileSync(path.join(srcPath, 'index.js'), '// Your Node.js code here\n');
674
+ }
675
+ // Create routes directory
676
+ const routesPath = path.join(srcPath, 'routes');
677
+ if (!fs.existsSync(routesPath)) {
678
+ fs.mkdirSync(routesPath, { recursive: true });
679
+ }
680
+ }
681
+ setupMonorepoTemplate(repoPath) {
682
+ // Create packages directory
683
+ const packagesPath = path.join(repoPath, 'packages');
684
+ if (!fs.existsSync(packagesPath)) {
685
+ fs.mkdirSync(packagesPath, { recursive: true });
686
+ }
687
+ // Create apps directory
688
+ const appsPath = path.join(repoPath, 'apps');
689
+ if (!fs.existsSync(appsPath)) {
690
+ fs.mkdirSync(appsPath, { recursive: true });
691
+ }
692
+ // Create workspace package.json if not exists
693
+ const packageJsonPath = path.join(repoPath, 'package.json');
694
+ if (!fs.existsSync(packageJsonPath)) {
695
+ const packageJson = {
696
+ name: 'monorepo-workspace',
697
+ version: '1.0.0',
698
+ private: true,
699
+ workspaces: ['packages/*', 'apps/*'],
700
+ devDependencies: {
701
+ turbo: '^2.0.0',
702
+ },
703
+ };
704
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
705
+ }
706
+ }
707
+ /**
708
+ * Initialize swarm - from /src/cli/commands/claude-setup.ts
709
+ */
710
+ async initializeSwarm(spinner, repoPath) {
711
+ spinner.text = 'Initializing Ruflo swarm...';
712
+ try {
713
+ // Initialize basic swarm configuration
714
+ (0, child_process_1.execSync)('npx ruflo@latest init', {
715
+ cwd: repoPath,
716
+ stdio: 'pipe',
717
+ });
718
+ }
719
+ catch {
720
+ // Swarm init might fail if not properly configured
721
+ console.log(chalk_1.default.yellow('\nāš ļø Could not initialize swarm automatically.'));
722
+ console.log(chalk_1.default.yellow('You can initialize manually later with: npx ruflo@latest init'));
723
+ }
724
+ spinner.text = 'Swarm initialization completed';
725
+ }
726
+ /**
727
+ * Validate project setup - from /src/cli/commands/claude-setup.ts
728
+ */
729
+ async validateProjectSetup(spinner, repoPath) {
730
+ spinner.text = 'Validating setup...';
731
+ const validations = [
732
+ { name: 'CLAUDE.md', path: path.join(repoPath, 'CLAUDE.md') },
733
+ { name: 'MCP Tools', path: path.join(repoPath, 'mcp-tools') },
734
+ { name: 'Git repository', path: path.join(repoPath, '.git') },
735
+ ];
736
+ const results = validations.map(validation => ({
737
+ ...validation,
738
+ exists: fs.existsSync(validation.path),
739
+ }));
740
+ const failures = results.filter(r => !r.exists);
741
+ if (failures.length > 0) {
742
+ throw new Error(`Setup validation failed: Missing ${failures.map(f => f.name).join(', ')}`);
743
+ }
744
+ spinner.text = 'Setup validation passed';
745
+ }
746
+ /**
747
+ * Add shell optimization configuration
748
+ */
749
+ async addOptimizationToShell(homeDir) {
750
+ const shellConfigs = [
751
+ path.join(homeDir, '.zshrc'),
752
+ path.join(homeDir, '.bashrc'),
753
+ ];
754
+ const optimizationConfig = `
755
+ # ═══════════════════════════════════════════════════════════════════════════
756
+ # Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)
757
+ # ═══════════════════════════════════════════════════════════════════════════
758
+
759
+ # Ensure PATH includes usr/local/bin
760
+ export PATH="/usr/local/bin:$PATH"
761
+
762
+ # Hardware-adaptive V8 memory configuration
763
+ if [ -f "$HOME/.claude/scripts/detect-hardware-limits.js" ]; then
764
+ eval "$(node $HOME/.claude/scripts/detect-hardware-limits.js export 2>/dev/null)"
765
+ fi
766
+
767
+ # Alias 'claude' to use hardware-optimized wrapper
768
+ if [ -f "$HOME/.claude/scripts/claude-optimized" ]; then
769
+ alias claude="$HOME/.claude/scripts/claude-optimized"
770
+ else
771
+ # Fallback to standard claude if optimization scripts not available
772
+ alias claude='npx @anthropic-ai/claude-code'
773
+ fi
774
+
775
+ # Convenience aliases for Claude optimization tools
776
+ alias claude-stats='node $HOME/.claude/scripts/detect-hardware-limits.js 2>/dev/null'
777
+ alias claude-cleanup='$HOME/.claude/scripts/cleanup-zombies.sh 2>/dev/null'
778
+ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
779
+
780
+ # ═══════════════════════════════════════════════════════════════════════════
781
+ `;
782
+ for (const configFile of shellConfigs) {
783
+ if (fs.existsSync(configFile)) {
784
+ const content = fs.readFileSync(configFile, 'utf8');
785
+ // Check if optimization config already exists
786
+ if (content.includes('Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)')) {
787
+ // Remove old config and add new one
788
+ const lines = content.split('\n');
789
+ const startIdx = lines.findIndex(line => line.includes('Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)'));
790
+ if (startIdx !== -1) {
791
+ // Find the end of the config block
792
+ let endIdx = startIdx;
793
+ for (let i = startIdx + 1; i < lines.length; i++) {
794
+ if (lines[i]?.includes('═══════════════')) {
795
+ endIdx = i;
796
+ break;
797
+ }
798
+ }
799
+ // Remove old config
800
+ lines.splice(startIdx - 1, endIdx - startIdx + 3);
801
+ const newContent = lines.join('\n');
802
+ fs.writeFileSync(configFile, newContent + optimizationConfig);
803
+ }
804
+ }
805
+ else {
806
+ // Add new config
807
+ fs.appendFileSync(configFile, optimizationConfig);
808
+ }
809
+ }
810
+ }
811
+ }
812
+ /**
813
+ * Install Chrome browser
814
+ */
815
+ async installChrome() {
816
+ if (process.platform === 'darwin') {
817
+ (0, child_process_1.execSync)('curl -L -o ~/Downloads/googlechrome.dmg "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"');
818
+ (0, child_process_1.execSync)('hdiutil attach ~/Downloads/googlechrome.dmg');
819
+ (0, child_process_1.execSync)('cp -R "/Volumes/Google Chrome/Google Chrome.app" /Applications/');
820
+ (0, child_process_1.execSync)('hdiutil detach "/Volumes/Google Chrome"');
821
+ (0, child_process_1.execSync)('rm ~/Downloads/googlechrome.dmg');
822
+ }
823
+ else {
824
+ console.log(chalk_1.default.yellow('Chrome installation is only automated for macOS'));
825
+ }
826
+ }
827
+ /**
828
+ * Setup Claude settings.json
829
+ */
830
+ async setupClaudeSettings() {
831
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
832
+ const configPath = path.join(homeDir, '.claude', 'settings.json');
833
+ const config = {
834
+ claudeCodeOptions: {
835
+ enabledMcpjsonServers: [
836
+ 'ruflo',
837
+ 'firecrawl',
838
+ 'context7',
839
+ 'playwright',
840
+ 'browser',
841
+ 'sequentialthinking',
842
+ ],
843
+ gitAutoCompact: true,
844
+ contextCompactionThreshold: 100000,
845
+ enableHooks: true,
846
+ enableAgentCoordination: true,
847
+ enableNeuralTraining: true,
848
+ enablePerformanceTracking: true,
849
+ },
850
+ };
851
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
852
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
853
+ }
854
+ // ==================== Helper Methods ====================
855
+ isClaudeInstalled() {
856
+ try {
857
+ (0, child_process_1.execSync)('claude --version', { stdio: 'ignore' });
858
+ return true;
859
+ }
860
+ catch {
861
+ return false;
862
+ }
863
+ }
864
+ isRufloInstalled() {
865
+ try {
866
+ (0, child_process_1.execSync)('npx ruflo@latest --version', { stdio: 'ignore' });
867
+ return true;
868
+ }
869
+ catch {
870
+ return false;
871
+ }
872
+ }
873
+ isChromeInstalled() {
874
+ if (process.platform === 'darwin') {
875
+ return fs.existsSync('/Applications/Google Chrome.app');
876
+ }
877
+ return true; // Assume installed on other platforms
878
+ }
879
+ claudeDirExists() {
880
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
881
+ return fs.existsSync(path.join(homeDir, '.claude'));
882
+ }
883
+ agentsConfigured() {
884
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
885
+ const agentsDir = path.join(homeDir, '.claude', 'agents');
886
+ if (!fs.existsSync(agentsDir)) {
887
+ return false;
888
+ }
889
+ const files = fs.readdirSync(agentsDir);
890
+ return files.length > 0;
891
+ }
892
+ mcpServersConfigured() {
893
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
894
+ const settingsPath = path.join(homeDir, '.claude', 'settings.json');
895
+ if (!fs.existsSync(settingsPath)) {
896
+ return false;
897
+ }
898
+ try {
899
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
900
+ return settings.claudeCodeOptions?.enabledMcpjsonServers?.length > 0;
901
+ }
902
+ catch {
903
+ return false;
904
+ }
905
+ }
906
+ listAgents() {
907
+ console.log(chalk_1.default.cyan('\nšŸ“‹ Available Ruflo Agents:\n'));
908
+ const categories = {
909
+ 'Core Development': [
910
+ 'coder',
911
+ 'reviewer',
912
+ 'tester',
913
+ 'planner',
914
+ 'researcher',
915
+ ],
916
+ 'Swarm Coordination': [
917
+ 'hierarchical-coordinator',
918
+ 'mesh-coordinator',
919
+ 'adaptive-coordinator',
920
+ 'collective-intelligence-coordinator',
921
+ 'swarm-memory-manager',
922
+ ],
923
+ 'Consensus & Distributed': [
924
+ 'byzantine-coordinator',
925
+ 'raft-manager',
926
+ 'gossip-coordinator',
927
+ 'consensus-builder',
928
+ 'crdt-synchronizer',
929
+ 'quorum-manager',
930
+ 'security-manager',
931
+ ],
932
+ 'Performance & Optimization': [
933
+ 'perf-analyzer',
934
+ 'performance-benchmarker',
935
+ 'task-orchestrator',
936
+ 'memory-coordinator',
937
+ 'smart-agent',
938
+ ],
939
+ 'GitHub & Repository': [
940
+ 'github-modes',
941
+ 'pr-manager',
942
+ 'code-review-swarm',
943
+ 'issue-tracker',
944
+ 'release-manager',
945
+ 'workflow-automation',
946
+ 'project-board-sync',
947
+ 'repo-architect',
948
+ 'multi-repo-swarm',
949
+ ],
950
+ 'SPARC Methodology': [
951
+ 'sparc-coord',
952
+ 'sparc-coder',
953
+ 'specification',
954
+ 'pseudocode',
955
+ 'architecture',
956
+ 'refinement',
957
+ ],
958
+ 'Specialized Development': [
959
+ 'backend-dev',
960
+ 'mobile-dev',
961
+ 'ml-developer',
962
+ 'cicd-engineer',
963
+ 'api-docs',
964
+ 'system-architect',
965
+ 'code-analyzer',
966
+ 'base-template-generator',
967
+ ],
968
+ 'Testing & Validation': ['tdd-london-swarm', 'production-validator'],
969
+ 'Migration & Planning': ['migration-planner', 'swarm-init'],
970
+ };
971
+ for (const [category, agents] of Object.entries(categories)) {
972
+ console.log(chalk_1.default.yellow(`${category}:`));
973
+ agents.forEach(agent => console.log(` • ${agent}`));
974
+ console.log();
975
+ }
976
+ console.log(chalk_1.default.gray('Total: 54 agents available'));
977
+ }
978
+ getProfileAgents(profile) {
979
+ const profileAgents = {
980
+ frontend: ['coder', 'reviewer', 'tester', 'mobile-dev', 'ui-designer'],
981
+ backend: [
982
+ 'coder',
983
+ 'reviewer',
984
+ 'tester',
985
+ 'backend-dev',
986
+ 'system-architect',
987
+ 'api-docs',
988
+ ],
989
+ fullstack: [
990
+ 'coder',
991
+ 'reviewer',
992
+ 'tester',
993
+ 'planner',
994
+ 'researcher',
995
+ 'system-architect',
996
+ 'backend-dev',
997
+ ],
998
+ devops: [
999
+ 'planner',
1000
+ 'cicd-engineer',
1001
+ 'perf-analyzer',
1002
+ 'github-modes',
1003
+ 'workflow-automation',
1004
+ ],
1005
+ ml: ['ml-developer', 'coder', 'tester', 'perf-analyzer', 'researcher'],
1006
+ };
1007
+ return (profileAgents[profile] ||
1008
+ profileAgents['fullstack'] || ['coder', 'reviewer', 'tester']);
1009
+ }
1010
+ generateAgentConfig(agentName) {
1011
+ return {
1012
+ name: agentName,
1013
+ enabled: true,
1014
+ description: `${agentName} agent for Ruflo`,
1015
+ configuration: {
1016
+ maxTokens: 8000,
1017
+ temperature: 0.7,
1018
+ topP: 0.9,
1019
+ enableMemory: true,
1020
+ enableLearning: true,
1021
+ },
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Display final instructions for project setup
1026
+ */
1027
+ displayProjectFinalInstructions(repoPath, options) {
1028
+ console.log(chalk_1.default.green('\nšŸŽ‰ Claude Code Setup Complete!'));
1029
+ console.log(chalk_1.default.blue('================================'));
1030
+ console.log(chalk_1.default.yellow('\nšŸ“‹ What was set up:'));
1031
+ console.log('āœ… CLAUDE.md configuration generated');
1032
+ if (!options.skipFlow) {
1033
+ console.log('āœ… Ruflo installed and configured');
1034
+ }
1035
+ if (!options.skipMcp) {
1036
+ console.log('āœ… MCP Tools directory created');
1037
+ }
1038
+ console.log('āœ… Project structure validated');
1039
+ console.log(chalk_1.default.yellow('\nšŸš€ Next Steps:'));
1040
+ console.log('1. Review and customize CLAUDE.md as needed');
1041
+ console.log('2. Install MCP tools: cd mcp-tools && ./install.sh');
1042
+ console.log('3. Verify Claude Desktop MCP connection');
1043
+ if (!options.skipFlow) {
1044
+ console.log('4. Test Ruflo: npx ruflo@latest sparc modes');
1045
+ }
1046
+ console.log('5. Start coding with optimized Claude Code integration!');
1047
+ console.log(chalk_1.default.yellow('\nšŸ“š Resources:'));
1048
+ console.log('• Ruflo: https://github.com/ruvnet/ruflo');
1049
+ console.log('• MCP Documentation: https://modelcontextprotocol.io/docs');
1050
+ console.log('• Wundr Documentation: ./docs/');
1051
+ console.log(chalk_1.default.green('\n✨ Happy coding with Claude!'));
1052
+ }
1053
+ /**
1054
+ * Print next steps after complete setup
1055
+ */
1056
+ printNextSteps() {
1057
+ console.log(chalk_1.default.cyan('šŸ“‹ Next Steps:'));
1058
+ console.log('1. Configure API keys for MCP tools (if needed)');
1059
+ console.log('2. Install Browser MCP Chrome extension: wundr claude-setup extension');
1060
+ console.log('3. Restart Claude Desktop to load new configurations');
1061
+ console.log('4. Initialize a project: wundr claude-setup project');
1062
+ console.log('5. Start coding with Ruflo: npx ruflo@latest sparc tdd "feature"');
1063
+ }
1064
+ }
1065
+ exports.ClaudeSetupCommands = ClaudeSetupCommands;
1066
+ /**
1067
+ * Factory function for backwards compatibility with function-based approach
1068
+ * This allows both import patterns to work:
1069
+ * - import claudeSetupCommand from './claude-setup' (class-based)
1070
+ * - import { createClaudeSetupCommand } from './claude-setup' (function-based)
1071
+ */
1072
+ function createClaudeSetupCommand() {
1073
+ const program = new commander_1.Command();
1074
+ new ClaudeSetupCommands(program);
1075
+ return program.commands.find(cmd => cmd.name() === 'claude-setup') || program;
1076
+ }
1077
+ const createClaudeSetupCommands = (program) => new ClaudeSetupCommands(program);
1078
+ exports.default = createClaudeSetupCommands;
1079
+ //# sourceMappingURL=claude-setup.js.map