@wundr.io/cli 1.0.1 → 1.0.3

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 (249) 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 +735 -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 +440 -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 +71 -0
  38. package/dist/commands/batch.d.ts.map +1 -0
  39. package/dist/commands/batch.js +738 -0
  40. package/dist/commands/batch.js.map +1 -0
  41. package/dist/commands/chat.d.ts +71 -0
  42. package/dist/commands/chat.d.ts.map +1 -0
  43. package/dist/commands/chat.js +674 -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 +1073 -0
  52. package/dist/commands/claude-setup.js.map +1 -0
  53. package/dist/commands/computer-setup-commands.d.ts +53 -0
  54. package/dist/commands/computer-setup-commands.d.ts.map +1 -0
  55. package/dist/commands/computer-setup-commands.js +705 -0
  56. package/dist/commands/computer-setup-commands.js.map +1 -0
  57. package/dist/commands/computer-setup.d.ts +7 -0
  58. package/dist/commands/computer-setup.d.ts.map +1 -0
  59. package/dist/commands/computer-setup.js +849 -0
  60. package/dist/commands/computer-setup.js.map +1 -0
  61. package/dist/commands/create-command.d.ts +7 -0
  62. package/dist/commands/create-command.d.ts.map +1 -0
  63. package/dist/commands/create-command.js +158 -0
  64. package/dist/commands/create-command.js.map +1 -0
  65. package/dist/commands/create.d.ts +74 -0
  66. package/dist/commands/create.d.ts.map +1 -0
  67. package/dist/commands/create.js +556 -0
  68. package/dist/commands/create.js.map +1 -0
  69. package/dist/commands/dashboard.d.ts +91 -0
  70. package/dist/commands/dashboard.d.ts.map +1 -0
  71. package/dist/commands/dashboard.js +538 -0
  72. package/dist/commands/dashboard.js.map +1 -0
  73. package/dist/commands/govern.d.ts +70 -0
  74. package/dist/commands/govern.d.ts.map +1 -0
  75. package/dist/commands/govern.js +481 -0
  76. package/dist/commands/govern.js.map +1 -0
  77. package/dist/commands/governance.d.ts +17 -0
  78. package/dist/commands/governance.d.ts.map +1 -0
  79. package/dist/commands/governance.js +703 -0
  80. package/dist/commands/governance.js.map +1 -0
  81. package/dist/commands/guardian.d.ts +20 -0
  82. package/dist/commands/guardian.d.ts.map +1 -0
  83. package/dist/commands/guardian.js +597 -0
  84. package/dist/commands/guardian.js.map +1 -0
  85. package/dist/commands/init.d.ts +59 -0
  86. package/dist/commands/init.d.ts.map +1 -0
  87. package/dist/commands/init.js +650 -0
  88. package/dist/commands/init.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 +748 -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 +29 -0
  106. package/dist/commands/setup.d.ts.map +1 -0
  107. package/dist/commands/setup.js +397 -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/vp.d.ts +7 -0
  118. package/dist/commands/vp.d.ts.map +1 -0
  119. package/dist/commands/vp.js +571 -0
  120. package/dist/commands/vp.js.map +1 -0
  121. package/dist/commands/watch.d.ts +76 -0
  122. package/dist/commands/watch.d.ts.map +1 -0
  123. package/dist/commands/watch.js +613 -0
  124. package/dist/commands/watch.js.map +1 -0
  125. package/dist/commands/worktree.d.ts +63 -0
  126. package/dist/commands/worktree.d.ts.map +1 -0
  127. package/dist/commands/worktree.js +774 -0
  128. package/dist/commands/worktree.js.map +1 -0
  129. package/dist/context/context-manager.d.ts +155 -0
  130. package/dist/context/context-manager.d.ts.map +1 -0
  131. package/dist/context/context-manager.js +383 -0
  132. package/dist/context/context-manager.js.map +1 -0
  133. package/dist/context/index.d.ts +3 -0
  134. package/dist/context/index.d.ts.map +1 -0
  135. package/dist/context/index.js +6 -0
  136. package/dist/context/index.js.map +1 -0
  137. package/dist/context/session-manager.d.ts +207 -0
  138. package/dist/context/session-manager.d.ts.map +1 -0
  139. package/dist/context/session-manager.js +686 -0
  140. package/dist/context/session-manager.js.map +1 -0
  141. package/dist/index.d.ts +8 -0
  142. package/dist/index.d.ts.map +1 -0
  143. package/dist/index.js +51 -0
  144. package/dist/index.js.map +1 -0
  145. package/dist/interactive/interactive-mode.d.ts +76 -0
  146. package/dist/interactive/interactive-mode.d.ts.map +1 -0
  147. package/dist/interactive/interactive-mode.js +732 -0
  148. package/dist/interactive/interactive-mode.js.map +1 -0
  149. package/dist/nlp/command-mapper.d.ts +174 -0
  150. package/dist/nlp/command-mapper.d.ts.map +1 -0
  151. package/dist/nlp/command-mapper.js +624 -0
  152. package/dist/nlp/command-mapper.js.map +1 -0
  153. package/dist/nlp/command-parser.d.ts +106 -0
  154. package/dist/nlp/command-parser.d.ts.map +1 -0
  155. package/dist/nlp/command-parser.js +417 -0
  156. package/dist/nlp/command-parser.js.map +1 -0
  157. package/dist/nlp/index.d.ts +5 -0
  158. package/dist/nlp/index.d.ts.map +1 -0
  159. package/dist/nlp/index.js +8 -0
  160. package/dist/nlp/index.js.map +1 -0
  161. package/dist/nlp/intent-classifier.d.ts +59 -0
  162. package/dist/nlp/intent-classifier.d.ts.map +1 -0
  163. package/dist/nlp/intent-classifier.js +384 -0
  164. package/dist/nlp/intent-classifier.js.map +1 -0
  165. package/dist/nlp/intent-parser.d.ts +152 -0
  166. package/dist/nlp/intent-parser.d.ts.map +1 -0
  167. package/dist/nlp/intent-parser.js +744 -0
  168. package/dist/nlp/intent-parser.js.map +1 -0
  169. package/dist/plugins/plugin-manager.d.ts +120 -0
  170. package/dist/plugins/plugin-manager.d.ts.map +1 -0
  171. package/dist/plugins/plugin-manager.js +595 -0
  172. package/dist/plugins/plugin-manager.js.map +1 -0
  173. package/dist/types/index.d.ts +224 -0
  174. package/dist/types/index.d.ts.map +1 -0
  175. package/dist/types/index.js +3 -0
  176. package/dist/types/index.js.map +1 -0
  177. package/dist/utils/backup-rollback-manager.d.ts +72 -0
  178. package/dist/utils/backup-rollback-manager.d.ts.map +1 -0
  179. package/dist/utils/backup-rollback-manager.js +289 -0
  180. package/dist/utils/backup-rollback-manager.js.map +1 -0
  181. package/dist/utils/claude-config-installer.d.ts +94 -0
  182. package/dist/utils/claude-config-installer.d.ts.map +1 -0
  183. package/dist/utils/claude-config-installer.js +628 -0
  184. package/dist/utils/claude-config-installer.js.map +1 -0
  185. package/dist/utils/config-manager.d.ts +73 -0
  186. package/dist/utils/config-manager.d.ts.map +1 -0
  187. package/dist/utils/config-manager.js +339 -0
  188. package/dist/utils/config-manager.js.map +1 -0
  189. package/dist/utils/error-handler.d.ts +46 -0
  190. package/dist/utils/error-handler.d.ts.map +1 -0
  191. package/dist/utils/error-handler.js +169 -0
  192. package/dist/utils/error-handler.js.map +1 -0
  193. package/dist/utils/logger.d.ts +25 -0
  194. package/dist/utils/logger.d.ts.map +1 -0
  195. package/dist/utils/logger.js +105 -0
  196. package/dist/utils/logger.js.map +1 -0
  197. package/package.json +23 -4
  198. package/src/ai/ai-service.ts +22 -19
  199. package/src/ai/claude-client.ts +20 -16
  200. package/src/ai/conversation-manager.ts +37 -30
  201. package/src/cli.ts +42 -13
  202. package/src/commands/ai.ts +59 -57
  203. package/src/commands/alignment.ts +1212 -0
  204. package/src/commands/analyze-optimized.ts +70 -62
  205. package/src/commands/analyze.ts +22 -20
  206. package/src/commands/batch.ts +41 -38
  207. package/src/commands/chat.ts +37 -34
  208. package/src/commands/claude-init.ts +38 -30
  209. package/src/commands/claude-setup.ts +692 -97
  210. package/src/commands/computer-setup-commands.ts +45 -39
  211. package/src/commands/computer-setup.ts +474 -4
  212. package/src/commands/create-command.ts +7 -7
  213. package/src/commands/create.ts +36 -33
  214. package/src/commands/dashboard.ts +33 -28
  215. package/src/commands/govern.ts +34 -29
  216. package/src/commands/governance.ts +1005 -0
  217. package/src/commands/guardian.ts +887 -0
  218. package/src/commands/init.ts +112 -22
  219. package/src/commands/performance-optimizer.ts +48 -42
  220. package/src/commands/plugins.ts +35 -32
  221. package/src/commands/project-update.ts +1053 -0
  222. package/src/commands/rag.ts +904 -0
  223. package/src/commands/session.ts +631 -0
  224. package/src/commands/setup.ts +35 -31
  225. package/src/commands/test-init.ts +6 -5
  226. package/src/commands/test.ts +7 -6
  227. package/src/commands/vp.ts +762 -0
  228. package/src/commands/watch.ts +44 -33
  229. package/src/commands/worktree.ts +1057 -0
  230. package/src/context/context-manager.ts +15 -12
  231. package/src/context/session-manager.ts +51 -40
  232. package/src/index.ts +7 -6
  233. package/src/interactive/interactive-mode.ts +25 -18
  234. package/src/lib/conflict-resolution.ts +28 -0
  235. package/src/lib/merge-strategy.ts +28 -0
  236. package/src/lib/safety-mechanisms.ts +47 -0
  237. package/src/lib/state-detection.ts +28 -0
  238. package/src/nlp/command-mapper.ts +35 -30
  239. package/src/nlp/command-parser.ts +20 -17
  240. package/src/nlp/intent-classifier.ts +7 -7
  241. package/src/nlp/intent-parser.ts +61 -49
  242. package/src/plugins/plugin-manager.ts +27 -23
  243. package/src/types/index.ts +1 -1
  244. package/src/types/modules.d.ts +1 -0
  245. package/src/utils/backup-rollback-manager.ts +13 -11
  246. package/src/utils/claude-config-installer.ts +18 -16
  247. package/src/utils/config-manager.ts +12 -9
  248. package/src/utils/error-handler.ts +5 -3
  249. package/src/utils/logger.ts +35 -12
@@ -1,13 +1,54 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
1
  import { execSync, spawn } from 'child_process';
5
- import * as path from 'path';
6
2
  import * as fs from 'fs';
3
+ import * as path from 'path';
4
+
5
+ import chalk from 'chalk';
6
+ import { Command } from 'commander';
7
+ import ora from 'ora';
8
+
9
+ import type { Ora } from 'ora';
10
+
11
+
12
+ // Type for ora spinner
13
+ type OraSpinner = Ora;
14
+
15
+ // Type definitions
16
+ interface SetupOptions {
17
+ global?: boolean;
18
+ skipMcp?: boolean;
19
+ skipFlow?: boolean;
20
+ skipChrome?: boolean;
21
+ skipAgents?: boolean;
22
+ template?: string;
23
+ }
24
+
25
+ interface McpOptions {
26
+ tool?: string;
27
+ }
28
+
29
+ interface AgentOptions {
30
+ list?: boolean;
31
+ enable?: string;
32
+ profile?: string;
33
+ }
34
+
35
+ interface ValidateOptions {
36
+ fix?: boolean;
37
+ }
38
+
39
+ interface OptimizeOptions {
40
+ force?: boolean;
41
+ }
7
42
 
8
43
  /**
9
44
  * Claude Setup Commands
10
45
  * Comprehensive setup for Claude Code, Claude Flow, and MCP tools
46
+ *
47
+ * Consolidated from:
48
+ * - /src/cli/commands/claude-setup.ts (374 lines) - function-based approach
49
+ * - /packages/@wundr/cli/src/commands/claude-setup.ts (697 lines) - class-based approach
50
+ *
51
+ * This version preserves ALL functionality from both implementations.
11
52
  */
12
53
  export class ClaudeSetupCommands {
13
54
  constructor(private program: Command) {
@@ -24,33 +65,49 @@ export class ClaudeSetupCommands {
24
65
  chalk.gray(`
25
66
  Examples:
26
67
  ${chalk.green('wundr claude-setup')} Interactive Claude setup
68
+ ${chalk.green('wundr claude-setup install')} Complete ecosystem installation
27
69
  ${chalk.green('wundr claude-setup mcp')} Install all MCP tools
28
70
  ${chalk.green('wundr claude-setup agents')} Configure all 54 agents
29
71
  ${chalk.green('wundr claude-setup optimize')} Setup hardware-adaptive optimizations
30
72
  ${chalk.green('wundr claude-setup validate')} Validate Claude installation
31
- `)
73
+ ${chalk.green('wundr claude-setup project')} Setup project with templates
74
+ `),
32
75
  );
33
76
 
34
- // Main setup command
77
+ // Main setup command (default)
35
78
  claudeSetup
36
79
  .command('install', { isDefault: true })
37
80
  .description('Complete Claude ecosystem installation')
38
81
  .option('--skip-chrome', 'Skip Chrome installation')
39
82
  .option('--skip-mcp', 'Skip MCP tools installation')
40
83
  .option('--skip-agents', 'Skip agent configuration')
41
- .action(async options => {
84
+ .option('--skip-flow', 'Skip Claude Flow setup')
85
+ .option('-g, --global', 'Install tools globally')
86
+ .action(async (options: SetupOptions) => {
42
87
  await this.runCompleteSetup(options);
43
88
  });
44
89
 
90
+ // Project setup with templates (from /src/cli/commands/claude-setup.ts)
91
+ claudeSetup
92
+ .command('project [path]')
93
+ .description('Setup Claude Code in a project directory with optional template')
94
+ .option('-g, --global', 'Install tools globally')
95
+ .option('--skip-mcp', 'Skip MCP tools installation')
96
+ .option('--skip-flow', 'Skip Claude Flow setup')
97
+ .option('-t, --template <name>', 'Use specific project template (typescript, react, nodejs, monorepo)')
98
+ .action(async (projectPath: string = '.', options: SetupOptions) => {
99
+ await this.runProjectSetup(projectPath, options);
100
+ });
101
+
45
102
  // MCP tools installation
46
103
  claudeSetup
47
104
  .command('mcp')
48
105
  .description('Install and configure MCP tools')
49
106
  .option(
50
107
  '--tool <tool>',
51
- 'Install specific tool (firecrawl, context7, playwright, browser, sequentialthinking)'
108
+ 'Install specific tool (firecrawl, context7, playwright, browser, sequentialthinking, claude-flow)',
52
109
  )
53
- .action(async options => {
110
+ .action(async (options: McpOptions) => {
54
111
  await this.installMcpTools(options);
55
112
  });
56
113
 
@@ -61,7 +118,7 @@ Examples:
61
118
  .option('--list', 'List available agents')
62
119
  .option('--enable <agents>', 'Enable specific agents (comma-separated)')
63
120
  .option('--profile <profile>', 'Use profile-specific agents')
64
- .action(async options => {
121
+ .action(async (options: AgentOptions) => {
65
122
  await this.configureAgents(options);
66
123
  });
67
124
 
@@ -70,7 +127,7 @@ Examples:
70
127
  .command('validate')
71
128
  .description('Validate Claude installation')
72
129
  .option('--fix', 'Attempt to fix issues')
73
- .action(async options => {
130
+ .action(async (options: ValidateOptions) => {
74
131
  await this.validateInstallation(options);
75
132
  });
76
133
 
@@ -87,12 +144,24 @@ Examples:
87
144
  .command('optimize')
88
145
  .description('Setup hardware-adaptive Claude Code optimizations')
89
146
  .option('--force', 'Force reinstallation of optimization scripts')
90
- .action(async options => {
147
+ .action(async (options: OptimizeOptions) => {
91
148
  await this.setupOptimizations(options);
92
149
  });
150
+
151
+ // Generate CLAUDE.md
152
+ claudeSetup
153
+ .command('config')
154
+ .description('Generate or update CLAUDE.md configuration')
155
+ .argument('[path]', 'Path to repository (defaults to current directory)', '.')
156
+ .action(async (repoPath: string) => {
157
+ await this.generateClaudeConfig(repoPath);
158
+ });
93
159
  }
94
160
 
95
- private async runCompleteSetup(options: any): Promise<void> {
161
+ /**
162
+ * Complete setup - combines both implementations' main flows
163
+ */
164
+ private async runCompleteSetup(options: SetupOptions): Promise<void> {
96
165
  const spinner = ora();
97
166
  console.log(chalk.cyan.bold('\nšŸ¤– Claude Ecosystem Setup\n'));
98
167
 
@@ -113,19 +182,24 @@ Examples:
113
182
  spinner.succeed('Chrome installed');
114
183
  }
115
184
 
116
- // Step 3: Install MCP tools (if not skipped)
185
+ // Step 3: Claude Flow setup
186
+ if (!options.skipFlow) {
187
+ await this.setupClaudeFlow(spinner, process.cwd(), options.global);
188
+ }
189
+
190
+ // Step 4: Install MCP tools (if not skipped)
117
191
  if (!options.skipMcp) {
118
192
  await this.installMcpTools({});
119
193
  }
120
194
 
121
- // Step 4: Configure agents (if not skipped)
195
+ // Step 5: Configure agents (if not skipped)
122
196
  if (!options.skipAgents) {
123
197
  await this.configureAgents({ profile: 'fullstack' });
124
198
  }
125
199
 
126
- // Step 5: Setup Claude configuration
200
+ // Step 6: Setup Claude configuration
127
201
  spinner.start('Configuring Claude settings...');
128
- await this.setupClaudeConfig();
202
+ await this.setupClaudeSettings();
129
203
  spinner.succeed('Claude configured');
130
204
 
131
205
  console.log(chalk.green.bold('\nāœ… Claude ecosystem setup complete!\n'));
@@ -137,21 +211,168 @@ Examples:
137
211
  }
138
212
  }
139
213
 
140
- private async installMcpTools(options: any): Promise<void> {
214
+ /**
215
+ * Project setup - from /src/cli/commands/claude-setup.ts
216
+ */
217
+ private async runProjectSetup(projectPath: string, options: SetupOptions): Promise<void> {
218
+ const spinner = ora('Starting Claude Code project setup...').start();
219
+
220
+ try {
221
+ const repoPath = path.resolve(projectPath);
222
+
223
+ // Verify git repository
224
+ if (!fs.existsSync(path.join(repoPath, '.git'))) {
225
+ spinner.stop();
226
+ const inquirer = await import('inquirer');
227
+ const { shouldInitGit } = await inquirer.default.prompt([{
228
+ type: 'confirm',
229
+ name: 'shouldInitGit',
230
+ message: 'Not a git repository. Initialize git?',
231
+ default: true,
232
+ }]);
233
+
234
+ if (shouldInitGit) {
235
+ spinner.start('Initializing git repository...');
236
+ execSync('git init', { cwd: repoPath });
237
+ spinner.succeed('Git repository initialized');
238
+ } else {
239
+ console.log(chalk.yellow('Continuing without git...'));
240
+ }
241
+ }
242
+
243
+ // Step 1: Claude Flow setup
244
+ if (!options.skipFlow) {
245
+ await this.setupClaudeFlow(spinner, repoPath, options.global);
246
+ }
247
+
248
+ // Step 2: MCP Tools setup
249
+ if (!options.skipMcp) {
250
+ await this.setupMCPToolsDirectory(spinner, repoPath);
251
+ }
252
+
253
+ // Step 3: Generate CLAUDE.md
254
+ await this.generateClaudeConfigForPath(spinner, repoPath);
255
+
256
+ // Step 4: Setup project template if specified
257
+ if (options.template) {
258
+ await this.setupProjectTemplate(spinner, repoPath, options.template);
259
+ }
260
+
261
+ // Step 5: Initialize swarm if Claude Flow is available
262
+ if (!options.skipFlow) {
263
+ await this.initializeSwarm(spinner, repoPath);
264
+ }
265
+
266
+ // Step 6: Validation
267
+ await this.validateProjectSetup(spinner, repoPath);
268
+
269
+ spinner.succeed('Claude Code project setup completed successfully!');
270
+
271
+ // Final instructions
272
+ this.displayProjectFinalInstructions(repoPath, options);
273
+
274
+ } catch (error) {
275
+ spinner.stop();
276
+ console.error(chalk.red('āŒ Setup failed:'));
277
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
278
+ process.exit(1);
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Setup Claude Flow - from /src/cli/commands/claude-setup.ts
284
+ */
285
+ private async setupClaudeFlow(spinner: OraSpinner, repoPath: string, global?: boolean): Promise<void> {
286
+ spinner.text = 'Setting up Claude Flow...';
287
+
288
+ try {
289
+ // Check if Claude Flow is already installed
290
+ execSync('npx claude-flow --version', { stdio: 'ignore' });
291
+ spinner.text = 'Claude Flow already available, configuring...';
292
+ } catch {
293
+ spinner.text = 'Installing Claude Flow...';
294
+
295
+ if (global) {
296
+ execSync('npm install -g claude-flow@alpha', { stdio: 'inherit' });
297
+ } else {
298
+ // Add to package.json dev dependencies if it exists
299
+ if (fs.existsSync(path.join(repoPath, 'package.json'))) {
300
+ execSync('npm install --save-dev claude-flow@alpha', { cwd: repoPath, stdio: 'inherit' });
301
+ }
302
+ }
303
+ }
304
+
305
+ // Add MCP server configuration
306
+ spinner.text = 'Configuring Claude MCP server...';
307
+ try {
308
+ execSync('claude mcp add claude-flow npx claude-flow@alpha mcp start', {
309
+ cwd: repoPath,
310
+ stdio: 'pipe',
311
+ });
312
+ } catch {
313
+ // MCP configuration might fail if Claude Desktop isn't installed
314
+ console.log(chalk.yellow('\nāš ļø Could not configure MCP server automatically.'));
315
+ console.log(chalk.yellow('Please run manually: claude mcp add claude-flow npx claude-flow@alpha mcp start'));
316
+ }
317
+
318
+ spinner.text = 'Claude Flow setup completed';
319
+ }
320
+
321
+ /**
322
+ * Setup MCP Tools directory - from /src/cli/commands/claude-setup.ts
323
+ */
324
+ private async setupMCPToolsDirectory(spinner: OraSpinner, repoPath: string): Promise<void> {
325
+ spinner.text = 'Setting up MCP Tools directory...';
326
+
327
+ const mcpToolsPath = path.join(repoPath, 'mcp-tools');
328
+
329
+ // Create mcp-tools directory if it doesn't exist
330
+ if (!fs.existsSync(mcpToolsPath)) {
331
+ fs.mkdirSync(mcpToolsPath, { recursive: true });
332
+
333
+ // Create basic install script
334
+ const installScript = `#!/bin/bash
335
+ # MCP Tools Installation Script
336
+ echo "Installing Wundr MCP Tools..."
337
+
338
+ # Add your MCP tool installations here
339
+ echo "āœ… MCP Tools installation template created"
340
+ echo "Customize this script with your specific MCP tools"
341
+ `;
342
+
343
+ fs.writeFileSync(path.join(mcpToolsPath, 'install.sh'), installScript);
344
+ execSync(`chmod +x ${path.join(mcpToolsPath, 'install.sh')}`);
345
+
346
+ // Create package.json for MCP tools
347
+ const mcpPackageJson = {
348
+ name: 'mcp-tools',
349
+ version: '1.0.0',
350
+ description: 'MCP Tools for Claude Code integration',
351
+ private: true,
352
+ scripts: {
353
+ install: './install.sh',
354
+ },
355
+ };
356
+
357
+ fs.writeFileSync(
358
+ path.join(mcpToolsPath, 'package.json'),
359
+ JSON.stringify(mcpPackageJson, null, 2),
360
+ );
361
+ }
362
+
363
+ spinner.text = 'MCP Tools directory setup completed';
364
+ }
365
+
366
+ /**
367
+ * Install MCP tools via script or specific tool
368
+ */
369
+ private async installMcpTools(options: McpOptions): Promise<void> {
141
370
  const spinner = ora();
142
371
  const scriptPath = path.join(
143
372
  __dirname,
144
- '../../../../scripts/install-mcp-tools.sh'
373
+ '../../../../scripts/install-mcp-tools.sh',
145
374
  );
146
375
 
147
- if (!fs.existsSync(scriptPath)) {
148
- console.error(chalk.red('āŒ MCP tools installation script not found'));
149
- console.log(
150
- chalk.yellow('Please ensure the script exists at: ' + scriptPath)
151
- );
152
- return;
153
- }
154
-
155
376
  console.log(chalk.cyan('\nšŸ“¦ Installing MCP Tools...\n'));
156
377
 
157
378
  if (options.tool) {
@@ -161,11 +382,10 @@ Examples:
161
382
  const installCommands: Record<string, string> = {
162
383
  firecrawl: 'npx claude mcp add firecrawl npx @firecrawl/mcp-server',
163
384
  context7: 'npx claude mcp add context7 npx @context7/mcp-server',
164
- playwright:
165
- 'npx claude mcp add playwright npx @playwright/mcp-server',
385
+ playwright: 'npx claude mcp add playwright npx @playwright/mcp-server',
166
386
  browser: 'npx claude mcp add browser npx @browser/mcp-server',
167
- sequentialthinking:
168
- 'npm install -g @modelcontextprotocol/server-sequentialthinking',
387
+ sequentialthinking: 'npm install -g @modelcontextprotocol/server-sequentialthinking',
388
+ 'claude-flow': 'claude mcp add claude-flow npx claude-flow@alpha mcp start',
169
389
  };
170
390
 
171
391
  const command = installCommands[options.tool];
@@ -174,38 +394,54 @@ Examples:
174
394
  spinner.succeed(`${options.tool} MCP installed`);
175
395
  } else {
176
396
  spinner.fail(`Unknown tool: ${options.tool}`);
397
+ console.log(chalk.yellow(`Available tools: ${Object.keys(installCommands).join(', ')}`));
177
398
  }
178
399
  } catch (error) {
179
400
  spinner.fail(`Failed to install ${options.tool}`);
180
401
  console.error(error);
181
402
  }
182
403
  } else {
183
- // Install all tools using the script
184
- console.log(
185
- chalk.gray('Running comprehensive MCP tools installation...')
186
- );
404
+ // Try to install all tools using the script if it exists
405
+ if (fs.existsSync(scriptPath)) {
406
+ console.log(chalk.gray('Running comprehensive MCP tools installation...'));
187
407
 
188
- const install = spawn('bash', [scriptPath], {
189
- stdio: 'inherit',
190
- shell: true,
191
- });
408
+ const install = spawn('bash', [scriptPath], {
409
+ stdio: 'inherit',
410
+ shell: true,
411
+ });
192
412
 
193
- return new Promise((resolve, reject) => {
194
- install.on('close', code => {
195
- if (code === 0) {
196
- console.log(
197
- chalk.green('\nāœ… All MCP tools installed successfully')
198
- );
199
- resolve();
200
- } else {
201
- reject(new Error(`Installation failed with code ${code}`));
202
- }
413
+ return new Promise((resolve, reject) => {
414
+ install.on('close', code => {
415
+ if (code === 0) {
416
+ console.log(chalk.green('\nāœ… All MCP tools installed successfully'));
417
+ resolve();
418
+ } else {
419
+ reject(new Error(`Installation failed with code ${code}`));
420
+ }
421
+ });
203
422
  });
204
- });
423
+ } else {
424
+ // Fallback: install core tools
425
+ console.log(chalk.gray('Installing core MCP tools...'));
426
+
427
+ const coreTools = ['claude-flow', 'sequentialthinking'];
428
+ for (const tool of coreTools) {
429
+ try {
430
+ await this.installMcpTools({ tool });
431
+ } catch {
432
+ console.log(chalk.yellow(`āš ļø Could not install ${tool}`));
433
+ }
434
+ }
435
+
436
+ console.log(chalk.green('\nāœ… Core MCP tools installed'));
437
+ }
205
438
  }
206
439
  }
207
440
 
208
- private async configureAgents(options: any): Promise<void> {
441
+ /**
442
+ * Configure Claude Flow agents
443
+ */
444
+ private async configureAgents(options: AgentOptions): Promise<void> {
209
445
  const spinner = ora();
210
446
 
211
447
  if (options.list) {
@@ -220,7 +456,7 @@ Examples:
220
456
  : this.getProfileAgents(options.profile || 'fullstack');
221
457
 
222
458
  // Create agent configurations
223
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
459
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
224
460
  const agentsDir = path.join(homeDir, '.claude', 'agents');
225
461
 
226
462
  try {
@@ -230,7 +466,7 @@ Examples:
230
466
  const config = this.generateAgentConfig(agent);
231
467
  fs.writeFileSync(
232
468
  path.join(agentsDir, `${agent}.json`),
233
- JSON.stringify(config, null, 2)
469
+ JSON.stringify(config, null, 2),
234
470
  );
235
471
  }
236
472
 
@@ -241,7 +477,10 @@ Examples:
241
477
  }
242
478
  }
243
479
 
244
- private async validateInstallation(options: any): Promise<void> {
480
+ /**
481
+ * Validate Claude installation
482
+ */
483
+ private async validateInstallation(options: ValidateOptions): Promise<void> {
245
484
  console.log(chalk.cyan('\nšŸ” Validating Claude Installation...\n'));
246
485
 
247
486
  const checks = [
@@ -273,16 +512,19 @@ Examples:
273
512
  } else {
274
513
  console.log(
275
514
  chalk.yellow(
276
- '\nāš ļø Some checks failed. Run with --fix to attempt repairs.'
277
- )
515
+ '\nāš ļø Some checks failed. Run with --fix to attempt repairs.',
516
+ ),
278
517
  );
279
518
  }
280
519
  }
281
520
 
521
+ /**
522
+ * Install Chrome extension instructions
523
+ */
282
524
  private async installChromeExtension(): Promise<void> {
283
525
  console.log(chalk.cyan('\nšŸ”Œ Browser MCP Chrome Extension Setup\n'));
284
526
 
285
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
527
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
286
528
  const extensionDir = path.join(homeDir, '.claude', 'browser-extension');
287
529
 
288
530
  console.log(chalk.white('Extension location: ' + extensionDir));
@@ -294,26 +536,28 @@ Examples:
294
536
  console.log('\nāœ… The extension will then be active!');
295
537
  }
296
538
 
297
- private async setupOptimizations(options: any): Promise<void> {
539
+ /**
540
+ * Setup hardware-adaptive optimizations
541
+ */
542
+ private async setupOptimizations(options: OptimizeOptions): Promise<void> {
298
543
  const spinner = ora();
299
544
  console.log(
300
- chalk.cyan.bold('\n⚔ Claude Code Hardware-Adaptive Optimization Setup\n')
545
+ chalk.cyan.bold('\n⚔ Claude Code Hardware-Adaptive Optimization Setup\n'),
301
546
  );
302
547
 
303
548
  try {
304
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
549
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
305
550
  const scriptsDir = path.join(homeDir, '.claude', 'scripts');
306
551
  const resourcesDir = path.join(
307
552
  __dirname,
308
- '../../../computer-setup/resources/scripts'
553
+ '../../../computer-setup/resources/scripts',
309
554
  );
310
555
 
311
556
  // Check if optimization scripts already exist
312
557
  const scriptsExist = fs.existsSync(scriptsDir);
313
558
  if (scriptsExist && !options.force) {
314
- const { overwrite } = await (
315
- await import('inquirer')
316
- ).default.prompt([
559
+ const inquirer = await import('inquirer');
560
+ const { overwrite } = await inquirer.default.prompt([
317
561
  {
318
562
  type: 'confirm',
319
563
  name: 'overwrite',
@@ -341,8 +585,8 @@ Examples:
341
585
  spinner.fail('Optimization scripts not found in resources');
342
586
  console.error(
343
587
  chalk.red(
344
- `Expected scripts at: ${resourcesDir}\nPlease ensure @wundr/computer-setup is installed.`
345
- )
588
+ `Expected scripts at: ${resourcesDir}\nPlease ensure @wundr/computer-setup is installed.`,
589
+ ),
346
590
  );
347
591
  return;
348
592
  }
@@ -389,26 +633,26 @@ Examples:
389
633
  // Show what was installed
390
634
  console.log(chalk.cyan('šŸ“¦ Installed Scripts:'));
391
635
  console.log(
392
- chalk.white(' • detect-hardware-limits.js - Hardware detection')
636
+ chalk.white(' • detect-hardware-limits.js - Hardware detection'),
393
637
  );
394
638
  console.log(
395
- chalk.white(' • claude-optimized - Optimized Claude wrapper')
639
+ chalk.white(' • claude-optimized - Optimized Claude wrapper'),
396
640
  );
397
641
  console.log(
398
- chalk.white(' • orchestrator.js - Fault-tolerant orchestration')
642
+ chalk.white(' • orchestrator.js - Fault-tolerant orchestration'),
399
643
  );
400
644
  console.log(
401
- chalk.white(' • cleanup-zombies.sh - Process cleanup utility')
645
+ chalk.white(' • cleanup-zombies.sh - Process cleanup utility'),
402
646
  );
403
647
 
404
648
  console.log(chalk.cyan('\nšŸ”§ Shell Aliases:'));
405
649
  console.log(
406
- chalk.white(' • claude - Hardware-optimized Claude wrapper')
650
+ chalk.white(' • claude - Hardware-optimized Claude wrapper'),
407
651
  );
408
652
  console.log(chalk.white(' • claude-stats - Show hardware statistics'));
409
653
  console.log(chalk.white(' • claude-cleanup - Clean up zombie processes'));
410
654
  console.log(
411
- chalk.white(' • claude-orchestrate - Run multi-task orchestrator')
655
+ chalk.white(' • claude-orchestrate - Run multi-task orchestrator'),
412
656
  );
413
657
 
414
658
  console.log(chalk.cyan('\nšŸ“ Next Steps:'));
@@ -416,7 +660,7 @@ Examples:
416
660
  console.log('2. Run "claude-stats" to see your hardware configuration');
417
661
  console.log('3. Use "claude" command as normal - now optimized!');
418
662
  console.log(
419
- '4. Read ~/.claude/scripts/QUICK-START.md for advanced usage'
663
+ '4. Read ~/.claude/scripts/QUICK-START.md for advanced usage',
420
664
  );
421
665
  } catch (error) {
422
666
  spinner.fail('Optimization setup failed');
@@ -425,6 +669,245 @@ Examples:
425
669
  }
426
670
  }
427
671
 
672
+ /**
673
+ * Generate CLAUDE.md configuration
674
+ */
675
+ private async generateClaudeConfig(repoPath: string): Promise<void> {
676
+ const spinner = ora('Generating CLAUDE.md configuration...').start();
677
+
678
+ try {
679
+ const resolvedPath = path.resolve(repoPath);
680
+ await this.generateClaudeConfigForPath(spinner, resolvedPath);
681
+ spinner.succeed('CLAUDE.md generated successfully');
682
+ console.log(chalk.green(`\nāœ… CLAUDE.md created at: ${path.join(resolvedPath, 'CLAUDE.md')}`));
683
+ } catch (error) {
684
+ spinner.fail('Failed to generate CLAUDE.md');
685
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
686
+ }
687
+ }
688
+
689
+ /**
690
+ * Generate CLAUDE.md for a specific path
691
+ */
692
+ private async generateClaudeConfigForPath(spinner: OraSpinner, repoPath: string): Promise<void> {
693
+ spinner.text = 'Generating CLAUDE.md configuration...';
694
+
695
+ try {
696
+ // Try to use the ClaudeConfigGenerator if available
697
+ // Use path.resolve to construct the path at runtime to avoid TypeScript rootDir issues
698
+ const generatorPath = path.resolve(__dirname, '../../../../../src/claude-generator/claude-config-generator.js');
699
+ const { ClaudeConfigGenerator } = await import(/* @vite-ignore */ generatorPath);
700
+ const generator = new ClaudeConfigGenerator(repoPath);
701
+
702
+ const claudeContent = await generator.generateClaudeMarkdown();
703
+ const claudeFilePath = path.join(repoPath, 'CLAUDE.md');
704
+
705
+ fs.writeFileSync(claudeFilePath, claudeContent, 'utf-8');
706
+ } catch {
707
+ // Fallback: Create a basic CLAUDE.md
708
+ spinner.text = 'Creating basic CLAUDE.md...';
709
+ const basicContent = this.generateBasicClaudeConfig(repoPath);
710
+ fs.writeFileSync(path.join(repoPath, 'CLAUDE.md'), basicContent, 'utf-8');
711
+ }
712
+
713
+ spinner.text = 'CLAUDE.md generated successfully';
714
+ }
715
+
716
+ /**
717
+ * Generate basic CLAUDE.md content as fallback
718
+ */
719
+ private generateBasicClaudeConfig(repoPath: string): string {
720
+ const projectName = path.basename(repoPath);
721
+ return `# Claude Code Configuration - ${projectName}
722
+
723
+ ## Project Overview
724
+ This project uses Claude Code for AI-assisted development.
725
+
726
+ ## Commands
727
+ - \`npm run build\` - Build the project
728
+ - \`npm run test\` - Run tests
729
+ - \`npm run lint\` - Run linting
730
+
731
+ ## Code Style
732
+ - Follow existing patterns in the codebase
733
+ - Write clear, descriptive commit messages
734
+ - Add tests for new features
735
+
736
+ ## MCP Tools
737
+ Claude Flow is configured for enhanced AI coordination.
738
+ Run \`npx claude-flow sparc modes\` to see available modes.
739
+ `;
740
+ }
741
+
742
+ /**
743
+ * Setup project template - from /src/cli/commands/claude-setup.ts
744
+ */
745
+ private async setupProjectTemplate(spinner: OraSpinner, repoPath: string, templateName: string): Promise<void> {
746
+ spinner.text = `Applying ${templateName} template...`;
747
+
748
+ const templates: Record<string, () => void> = {
749
+ 'typescript': () => this.setupTypeScriptTemplate(repoPath),
750
+ 'react': () => this.setupReactTemplate(repoPath),
751
+ 'nodejs': () => this.setupNodeTemplate(repoPath),
752
+ 'monorepo': () => this.setupMonorepoTemplate(repoPath),
753
+ };
754
+
755
+ const setupFunction = templates[templateName];
756
+ if (!setupFunction) {
757
+ throw new Error(`Unknown template: ${templateName}. Available: ${Object.keys(templates).join(', ')}`);
758
+ }
759
+
760
+ setupFunction();
761
+
762
+ spinner.text = `${templateName} template applied`;
763
+ }
764
+
765
+ private setupTypeScriptTemplate(repoPath: string): void {
766
+ // Create basic TypeScript configuration if not exists
767
+ const tsconfigPath = path.join(repoPath, 'tsconfig.json');
768
+ if (!fs.existsSync(tsconfigPath)) {
769
+ const tsconfig = {
770
+ compilerOptions: {
771
+ target: 'ES2020',
772
+ module: 'ESNext',
773
+ moduleResolution: 'node',
774
+ strict: true,
775
+ esModuleInterop: true,
776
+ skipLibCheck: true,
777
+ forceConsistentCasingInFileNames: true,
778
+ declaration: true,
779
+ outDir: 'dist',
780
+ rootDir: 'src',
781
+ },
782
+ include: ['src/**/*'],
783
+ exclude: ['node_modules', 'dist'],
784
+ };
785
+
786
+ fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
787
+ }
788
+
789
+ // Create src directory
790
+ const srcPath = path.join(repoPath, 'src');
791
+ if (!fs.existsSync(srcPath)) {
792
+ fs.mkdirSync(srcPath, { recursive: true });
793
+ fs.writeFileSync(path.join(srcPath, 'index.ts'), '// Your TypeScript code here\n');
794
+ }
795
+ }
796
+
797
+ private setupReactTemplate(repoPath: string): void {
798
+ // Ensure React-specific structure
799
+ const srcPath = path.join(repoPath, 'src');
800
+ if (!fs.existsSync(srcPath)) {
801
+ fs.mkdirSync(srcPath, { recursive: true });
802
+ }
803
+
804
+ // Create components directory
805
+ const componentsPath = path.join(srcPath, 'components');
806
+ if (!fs.existsSync(componentsPath)) {
807
+ fs.mkdirSync(componentsPath, { recursive: true });
808
+ }
809
+
810
+ // Create hooks directory
811
+ const hooksPath = path.join(srcPath, 'hooks');
812
+ if (!fs.existsSync(hooksPath)) {
813
+ fs.mkdirSync(hooksPath, { recursive: true });
814
+ }
815
+ }
816
+
817
+ private setupNodeTemplate(repoPath: string): void {
818
+ // Create basic Node.js structure
819
+ const srcPath = path.join(repoPath, 'src');
820
+ if (!fs.existsSync(srcPath)) {
821
+ fs.mkdirSync(srcPath, { recursive: true });
822
+ fs.writeFileSync(path.join(srcPath, 'index.js'), '// Your Node.js code here\n');
823
+ }
824
+
825
+ // Create routes directory
826
+ const routesPath = path.join(srcPath, 'routes');
827
+ if (!fs.existsSync(routesPath)) {
828
+ fs.mkdirSync(routesPath, { recursive: true });
829
+ }
830
+ }
831
+
832
+ private setupMonorepoTemplate(repoPath: string): void {
833
+ // Create packages directory
834
+ const packagesPath = path.join(repoPath, 'packages');
835
+ if (!fs.existsSync(packagesPath)) {
836
+ fs.mkdirSync(packagesPath, { recursive: true });
837
+ }
838
+
839
+ // Create apps directory
840
+ const appsPath = path.join(repoPath, 'apps');
841
+ if (!fs.existsSync(appsPath)) {
842
+ fs.mkdirSync(appsPath, { recursive: true });
843
+ }
844
+
845
+ // Create workspace package.json if not exists
846
+ const packageJsonPath = path.join(repoPath, 'package.json');
847
+ if (!fs.existsSync(packageJsonPath)) {
848
+ const packageJson = {
849
+ name: 'monorepo-workspace',
850
+ version: '1.0.0',
851
+ private: true,
852
+ workspaces: ['packages/*', 'apps/*'],
853
+ devDependencies: {
854
+ 'turbo': '^2.0.0',
855
+ },
856
+ };
857
+
858
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
859
+ }
860
+ }
861
+
862
+ /**
863
+ * Initialize swarm - from /src/cli/commands/claude-setup.ts
864
+ */
865
+ private async initializeSwarm(spinner: OraSpinner, repoPath: string): Promise<void> {
866
+ spinner.text = 'Initializing Claude Flow swarm...';
867
+
868
+ try {
869
+ // Initialize basic swarm configuration
870
+ execSync('npx claude-flow@alpha init', {
871
+ cwd: repoPath,
872
+ stdio: 'pipe',
873
+ });
874
+ } catch {
875
+ // Swarm init might fail if not properly configured
876
+ console.log(chalk.yellow('\nāš ļø Could not initialize swarm automatically.'));
877
+ console.log(chalk.yellow('You can initialize manually later with: npx claude-flow init'));
878
+ }
879
+
880
+ spinner.text = 'Swarm initialization completed';
881
+ }
882
+
883
+ /**
884
+ * Validate project setup - from /src/cli/commands/claude-setup.ts
885
+ */
886
+ private async validateProjectSetup(spinner: OraSpinner, repoPath: string): Promise<void> {
887
+ spinner.text = 'Validating setup...';
888
+
889
+ const validations = [
890
+ { name: 'CLAUDE.md', path: path.join(repoPath, 'CLAUDE.md') },
891
+ { name: 'MCP Tools', path: path.join(repoPath, 'mcp-tools') },
892
+ { name: 'Git repository', path: path.join(repoPath, '.git') },
893
+ ];
894
+
895
+ const results = validations.map(validation => ({
896
+ ...validation,
897
+ exists: fs.existsSync(validation.path),
898
+ }));
899
+
900
+ const failures = results.filter(r => !r.exists);
901
+ if (failures.length > 0) {
902
+ throw new Error(`Setup validation failed: Missing ${failures.map(f => f.name).join(', ')}`);
903
+ }
904
+
905
+ spinner.text = 'Setup validation passed';
906
+ }
907
+
908
+ /**
909
+ * Add shell optimization configuration
910
+ */
428
911
  private async addOptimizationToShell(homeDir: string): Promise<void> {
429
912
  const shellConfigs = [
430
913
  path.join(homeDir, '.zshrc'),
@@ -467,15 +950,15 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
467
950
  // Check if optimization config already exists
468
951
  if (
469
952
  content.includes(
470
- 'Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)'
953
+ 'Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)',
471
954
  )
472
955
  ) {
473
956
  // Remove old config and add new one
474
957
  const lines = content.split('\n');
475
958
  const startIdx = lines.findIndex(line =>
476
959
  line.includes(
477
- 'Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)'
478
- )
960
+ 'Claude Code - Hardware-Adaptive Configuration (Auto-generated by Wundr)',
961
+ ),
479
962
  );
480
963
 
481
964
  if (startIdx !== -1) {
@@ -501,26 +984,32 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
501
984
  }
502
985
  }
503
986
 
987
+ /**
988
+ * Install Chrome browser
989
+ */
504
990
  private async installChrome(): Promise<void> {
505
991
  if (process.platform === 'darwin') {
506
992
  execSync(
507
- 'curl -L -o ~/Downloads/googlechrome.dmg "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"'
993
+ 'curl -L -o ~/Downloads/googlechrome.dmg "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg"',
508
994
  );
509
995
  execSync('hdiutil attach ~/Downloads/googlechrome.dmg');
510
996
  execSync(
511
- 'cp -R "/Volumes/Google Chrome/Google Chrome.app" /Applications/'
997
+ 'cp -R "/Volumes/Google Chrome/Google Chrome.app" /Applications/',
512
998
  );
513
999
  execSync('hdiutil detach "/Volumes/Google Chrome"');
514
1000
  execSync('rm ~/Downloads/googlechrome.dmg');
515
1001
  } else {
516
1002
  console.log(
517
- chalk.yellow('Chrome installation is only automated for macOS')
1003
+ chalk.yellow('Chrome installation is only automated for macOS'),
518
1004
  );
519
1005
  }
520
1006
  }
521
1007
 
522
- private async setupClaudeConfig(): Promise<void> {
523
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
1008
+ /**
1009
+ * Setup Claude settings.json
1010
+ */
1011
+ private async setupClaudeSettings(): Promise<void> {
1012
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
524
1013
  const configPath = path.join(homeDir, '.claude', 'settings.json');
525
1014
 
526
1015
  const config = {
@@ -546,6 +1035,8 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
546
1035
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
547
1036
  }
548
1037
 
1038
+ // ==================== Helper Methods ====================
1039
+
549
1040
  private isClaudeInstalled(): boolean {
550
1041
  try {
551
1042
  execSync('claude --version', { stdio: 'ignore' });
@@ -572,24 +1063,28 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
572
1063
  }
573
1064
 
574
1065
  private claudeDirExists(): boolean {
575
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
1066
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
576
1067
  return fs.existsSync(path.join(homeDir, '.claude'));
577
1068
  }
578
1069
 
579
1070
  private agentsConfigured(): boolean {
580
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
1071
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
581
1072
  const agentsDir = path.join(homeDir, '.claude', 'agents');
582
- if (!fs.existsSync(agentsDir)) return false;
1073
+ if (!fs.existsSync(agentsDir)) {
1074
+ return false;
1075
+ }
583
1076
 
584
1077
  const files = fs.readdirSync(agentsDir);
585
1078
  return files.length > 0;
586
1079
  }
587
1080
 
588
1081
  private mcpServersConfigured(): boolean {
589
- const homeDir = process.env.HOME || process.env.USERPROFILE || '';
1082
+ const homeDir = process.env['HOME'] || process.env['USERPROFILE'] || '';
590
1083
  const settingsPath = path.join(homeDir, '.claude', 'settings.json');
591
1084
 
592
- if (!fs.existsSync(settingsPath)) return false;
1085
+ if (!fs.existsSync(settingsPath)) {
1086
+ return false;
1087
+ }
593
1088
 
594
1089
  try {
595
1090
  const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
@@ -602,7 +1097,7 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
602
1097
  private listAgents(): void {
603
1098
  console.log(chalk.cyan('\nšŸ“‹ Available Claude Flow Agents:\n'));
604
1099
 
605
- const categories = {
1100
+ const categories: Record<string, string[]> = {
606
1101
  'Core Development': [
607
1102
  'coder',
608
1103
  'reviewer',
@@ -614,18 +1109,61 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
614
1109
  'hierarchical-coordinator',
615
1110
  'mesh-coordinator',
616
1111
  'adaptive-coordinator',
1112
+ 'collective-intelligence-coordinator',
1113
+ 'swarm-memory-manager',
617
1114
  ],
618
- 'GitHub Integration': [
1115
+ 'Consensus & Distributed': [
1116
+ 'byzantine-coordinator',
1117
+ 'raft-manager',
1118
+ 'gossip-coordinator',
1119
+ 'consensus-builder',
1120
+ 'crdt-synchronizer',
1121
+ 'quorum-manager',
1122
+ 'security-manager',
1123
+ ],
1124
+ 'Performance & Optimization': [
1125
+ 'perf-analyzer',
1126
+ 'performance-benchmarker',
1127
+ 'task-orchestrator',
1128
+ 'memory-coordinator',
1129
+ 'smart-agent',
1130
+ ],
1131
+ 'GitHub & Repository': [
619
1132
  'github-modes',
620
1133
  'pr-manager',
1134
+ 'code-review-swarm',
621
1135
  'issue-tracker',
622
1136
  'release-manager',
1137
+ 'workflow-automation',
1138
+ 'project-board-sync',
1139
+ 'repo-architect',
1140
+ 'multi-repo-swarm',
1141
+ ],
1142
+ 'SPARC Methodology': [
1143
+ 'sparc-coord',
1144
+ 'sparc-coder',
1145
+ 'specification',
1146
+ 'pseudocode',
1147
+ 'architecture',
1148
+ 'refinement',
623
1149
  ],
624
- Specialized: [
1150
+ 'Specialized Development': [
625
1151
  'backend-dev',
626
1152
  'mobile-dev',
627
1153
  'ml-developer',
1154
+ 'cicd-engineer',
1155
+ 'api-docs',
628
1156
  'system-architect',
1157
+ 'code-analyzer',
1158
+ 'base-template-generator',
1159
+ ],
1160
+ 'Testing & Validation': [
1161
+ 'tdd-london-swarm',
1162
+ 'production-validator',
1163
+ ],
1164
+ 'Migration & Planning': [
1165
+ 'migration-planner',
1166
+ 'swarm-init',
629
1167
  ],
630
1168
  };
631
1169
 
@@ -634,17 +1172,20 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
634
1172
  agents.forEach(agent => console.log(` • ${agent}`));
635
1173
  console.log();
636
1174
  }
1175
+
1176
+ console.log(chalk.gray('Total: 54 agents available'));
637
1177
  }
638
1178
 
639
1179
  private getProfileAgents(profile: string): string[] {
640
1180
  const profileAgents: Record<string, string[]> = {
641
- frontend: ['coder', 'reviewer', 'tester', 'mobile-dev'],
1181
+ frontend: ['coder', 'reviewer', 'tester', 'mobile-dev', 'ui-designer'],
642
1182
  backend: [
643
1183
  'coder',
644
1184
  'reviewer',
645
1185
  'tester',
646
1186
  'backend-dev',
647
1187
  'system-architect',
1188
+ 'api-docs',
648
1189
  ],
649
1190
  fullstack: [
650
1191
  'coder',
@@ -653,17 +1194,19 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
653
1194
  'planner',
654
1195
  'researcher',
655
1196
  'system-architect',
1197
+ 'backend-dev',
656
1198
  ],
657
- devops: ['planner', 'cicd-engineer', 'perf-analyzer', 'github-modes'],
1199
+ devops: ['planner', 'cicd-engineer', 'perf-analyzer', 'github-modes', 'workflow-automation'],
1200
+ ml: ['ml-developer', 'coder', 'tester', 'perf-analyzer', 'researcher'],
658
1201
  };
659
1202
 
660
1203
  return (
661
1204
  profileAgents[profile] ||
662
- profileAgents.fullstack || ['coder', 'reviewer', 'tester']
1205
+ profileAgents['fullstack'] || ['coder', 'reviewer', 'tester']
663
1206
  );
664
1207
  }
665
1208
 
666
- private generateAgentConfig(agentName: string): any {
1209
+ private generateAgentConfig(agentName: string): Record<string, unknown> {
667
1210
  return {
668
1211
  name: agentName,
669
1212
  enabled: true,
@@ -678,20 +1221,72 @@ alias claude-orchestrate='node $HOME/.claude/scripts/orchestrator.js'
678
1221
  };
679
1222
  }
680
1223
 
1224
+ /**
1225
+ * Display final instructions for project setup
1226
+ */
1227
+ private displayProjectFinalInstructions(repoPath: string, options: SetupOptions): void {
1228
+ console.log(chalk.green('\nšŸŽ‰ Claude Code Setup Complete!'));
1229
+ console.log(chalk.blue('================================'));
1230
+
1231
+ console.log(chalk.yellow('\nšŸ“‹ What was set up:'));
1232
+ console.log('āœ… CLAUDE.md configuration generated');
1233
+ if (!options.skipFlow) {
1234
+ console.log('āœ… Claude Flow installed and configured');
1235
+ }
1236
+ if (!options.skipMcp) {
1237
+ console.log('āœ… MCP Tools directory created');
1238
+ }
1239
+ console.log('āœ… Project structure validated');
1240
+
1241
+ console.log(chalk.yellow('\nšŸš€ Next Steps:'));
1242
+ console.log('1. Review and customize CLAUDE.md as needed');
1243
+ console.log('2. Install MCP tools: cd mcp-tools && ./install.sh');
1244
+ console.log('3. Verify Claude Desktop MCP connection');
1245
+
1246
+ if (!options.skipFlow) {
1247
+ console.log('4. Test Claude Flow: npx claude-flow sparc modes');
1248
+ }
1249
+
1250
+ console.log('5. Start coding with optimized Claude Code integration!');
1251
+
1252
+ console.log(chalk.yellow('\nšŸ“š Resources:'));
1253
+ console.log('• Claude Flow: https://github.com/ruvnet/claude-flow');
1254
+ console.log('• MCP Documentation: https://modelcontextprotocol.io/docs');
1255
+ console.log('• Wundr Documentation: ./docs/');
1256
+
1257
+ console.log(chalk.green('\n✨ Happy coding with Claude!'));
1258
+ }
1259
+
1260
+ /**
1261
+ * Print next steps after complete setup
1262
+ */
681
1263
  private printNextSteps(): void {
682
1264
  console.log(chalk.cyan('šŸ“‹ Next Steps:'));
683
1265
  console.log('1. Configure API keys for MCP tools (if needed)');
684
1266
  console.log(
685
- '2. Install Browser MCP Chrome extension: wundr claude-setup extension'
1267
+ '2. Install Browser MCP Chrome extension: wundr claude-setup extension',
686
1268
  );
687
1269
  console.log('3. Restart Claude Desktop to load new configurations');
688
- console.log('4. Initialize a project: wundr claude-init');
1270
+ console.log('4. Initialize a project: wundr claude-setup project');
689
1271
  console.log(
690
- '5. Start coding with Claude Flow: npx claude-flow@alpha sparc tdd "feature"'
1272
+ '5. Start coding with Claude Flow: npx claude-flow@alpha sparc tdd "feature"',
691
1273
  );
692
1274
  }
693
1275
  }
694
1276
 
695
- const createClaudeSetupCommands = (program: Command) =>
1277
+ /**
1278
+ * Factory function for backwards compatibility with function-based approach
1279
+ * This allows both import patterns to work:
1280
+ * - import claudeSetupCommand from './claude-setup' (class-based)
1281
+ * - import { createClaudeSetupCommand } from './claude-setup' (function-based)
1282
+ */
1283
+ export function createClaudeSetupCommand(): Command {
1284
+ const program = new Command();
696
1285
  new ClaudeSetupCommands(program);
1286
+ return program.commands.find(cmd => cmd.name() === 'claude-setup') || program;
1287
+ }
1288
+
1289
+ const createClaudeSetupCommands = (program: Command): ClaudeSetupCommands =>
1290
+ new ClaudeSetupCommands(program);
1291
+
697
1292
  export default createClaudeSetupCommands;