@wundr.io/cli 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/ai-service.d.ts +152 -0
- package/dist/ai/ai-service.d.ts.map +1 -0
- package/dist/ai/ai-service.js +430 -0
- package/dist/ai/ai-service.js.map +1 -0
- package/dist/ai/claude-client.d.ts +130 -0
- package/dist/ai/claude-client.d.ts.map +1 -0
- package/dist/ai/claude-client.js +340 -0
- package/dist/ai/claude-client.js.map +1 -0
- package/dist/ai/conversation-manager.d.ts +164 -0
- package/dist/ai/conversation-manager.d.ts.map +1 -0
- package/dist/ai/conversation-manager.js +614 -0
- package/dist/ai/conversation-manager.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +8 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/cli.d.ts +36 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +192 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/ai.d.ts +89 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +799 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/alignment.d.ts +78 -0
- package/dist/commands/alignment.d.ts.map +1 -0
- package/dist/commands/alignment.js +817 -0
- package/dist/commands/alignment.js.map +1 -0
- package/dist/commands/analyze-optimized.d.ts +14 -0
- package/dist/commands/analyze-optimized.d.ts.map +1 -0
- package/dist/commands/analyze-optimized.js +600 -0
- package/dist/commands/analyze-optimized.js.map +1 -0
- package/dist/commands/analyze.d.ts +65 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +435 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/batch.d.ts +71 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +738 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/chat.d.ts +71 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +674 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/claude-init.d.ts +28 -0
- package/dist/commands/claude-init.d.ts.map +1 -0
- package/dist/commands/claude-init.js +591 -0
- package/dist/commands/claude-init.js.map +1 -0
- package/dist/commands/claude-setup.d.ts +119 -0
- package/dist/commands/claude-setup.d.ts.map +1 -0
- package/dist/commands/claude-setup.js +1073 -0
- package/dist/commands/claude-setup.js.map +1 -0
- package/dist/commands/computer-setup-commands.d.ts +53 -0
- package/dist/commands/computer-setup-commands.d.ts.map +1 -0
- package/dist/commands/computer-setup-commands.js +705 -0
- package/dist/commands/computer-setup-commands.js.map +1 -0
- package/dist/commands/computer-setup.d.ts +7 -0
- package/dist/commands/computer-setup.d.ts.map +1 -0
- package/dist/commands/computer-setup.js +849 -0
- package/dist/commands/computer-setup.js.map +1 -0
- package/dist/commands/create-command.d.ts +7 -0
- package/dist/commands/create-command.d.ts.map +1 -0
- package/dist/commands/create-command.js +158 -0
- package/dist/commands/create-command.js.map +1 -0
- package/dist/commands/create.d.ts +74 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +556 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dashboard.d.ts +91 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +538 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/govern.d.ts +70 -0
- package/dist/commands/govern.d.ts.map +1 -0
- package/dist/commands/govern.js +481 -0
- package/dist/commands/govern.js.map +1 -0
- package/dist/commands/governance.d.ts +17 -0
- package/dist/commands/governance.d.ts.map +1 -0
- package/dist/commands/governance.js +703 -0
- package/dist/commands/governance.js.map +1 -0
- package/dist/commands/guardian.d.ts +20 -0
- package/dist/commands/guardian.d.ts.map +1 -0
- package/dist/commands/guardian.js +597 -0
- package/dist/commands/guardian.js.map +1 -0
- package/dist/commands/init.d.ts +59 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +650 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/performance-optimizer.d.ts +30 -0
- package/dist/commands/performance-optimizer.d.ts.map +1 -0
- package/dist/commands/performance-optimizer.js +650 -0
- package/dist/commands/performance-optimizer.js.map +1 -0
- package/dist/commands/plugins.d.ts +87 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +685 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/rag.d.ts +7 -0
- package/dist/commands/rag.d.ts.map +1 -0
- package/dist/commands/rag.js +748 -0
- package/dist/commands/rag.js.map +1 -0
- package/dist/commands/session.d.ts +41 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +441 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +29 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +397 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/test-init.d.ts +9 -0
- package/dist/commands/test-init.d.ts.map +1 -0
- package/dist/commands/test-init.js +222 -0
- package/dist/commands/test-init.js.map +1 -0
- package/dist/commands/test.d.ts +25 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +217 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/vp.d.ts +7 -0
- package/dist/commands/vp.d.ts.map +1 -0
- package/dist/commands/vp.js +571 -0
- package/dist/commands/vp.js.map +1 -0
- package/dist/commands/watch.d.ts +76 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +613 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/worktree.d.ts +63 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +774 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/context/context-manager.d.ts +155 -0
- package/dist/context/context-manager.d.ts.map +1 -0
- package/dist/context/context-manager.js +383 -0
- package/dist/context/context-manager.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +6 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/session-manager.d.ts +207 -0
- package/dist/context/session-manager.d.ts.map +1 -0
- package/dist/context/session-manager.js +686 -0
- package/dist/context/session-manager.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive/interactive-mode.d.ts +76 -0
- package/dist/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/interactive/interactive-mode.js +732 -0
- package/dist/interactive/interactive-mode.js.map +1 -0
- package/dist/nlp/command-mapper.d.ts +174 -0
- package/dist/nlp/command-mapper.d.ts.map +1 -0
- package/dist/nlp/command-mapper.js +624 -0
- package/dist/nlp/command-mapper.js.map +1 -0
- package/dist/nlp/command-parser.d.ts +106 -0
- package/dist/nlp/command-parser.d.ts.map +1 -0
- package/dist/nlp/command-parser.js +417 -0
- package/dist/nlp/command-parser.js.map +1 -0
- package/dist/nlp/index.d.ts +5 -0
- package/dist/nlp/index.d.ts.map +1 -0
- package/dist/nlp/index.js +8 -0
- package/dist/nlp/index.js.map +1 -0
- package/dist/nlp/intent-classifier.d.ts +59 -0
- package/dist/nlp/intent-classifier.d.ts.map +1 -0
- package/dist/nlp/intent-classifier.js +384 -0
- package/dist/nlp/intent-classifier.js.map +1 -0
- package/dist/nlp/intent-parser.d.ts +152 -0
- package/dist/nlp/intent-parser.d.ts.map +1 -0
- package/dist/nlp/intent-parser.js +744 -0
- package/dist/nlp/intent-parser.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +120 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.js +595 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/types/index.d.ts +224 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/backup-rollback-manager.d.ts +72 -0
- package/dist/utils/backup-rollback-manager.d.ts.map +1 -0
- package/dist/utils/backup-rollback-manager.js +289 -0
- package/dist/utils/backup-rollback-manager.js.map +1 -0
- package/dist/utils/claude-config-installer.d.ts +94 -0
- package/dist/utils/claude-config-installer.d.ts.map +1 -0
- package/dist/utils/claude-config-installer.js +628 -0
- package/dist/utils/claude-config-installer.js.map +1 -0
- package/dist/utils/config-manager.d.ts +73 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +339 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/error-handler.d.ts +46 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +169 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +105 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +6 -4
- package/src/ai/ai-service.ts +22 -19
- package/src/ai/claude-client.ts +20 -16
- package/src/ai/conversation-manager.ts +37 -30
- package/src/cli.ts +46 -17
- package/src/commands/ai.ts +196 -88
- package/src/commands/alignment.ts +1212 -0
- package/src/commands/analyze-optimized.ts +394 -89
- package/src/commands/analyze.ts +22 -20
- package/src/commands/batch.ts +41 -38
- package/src/commands/chat.ts +37 -34
- package/src/commands/claude-init.ts +38 -30
- package/src/commands/claude-setup.ts +692 -97
- package/src/commands/computer-setup-commands.ts +45 -39
- package/src/commands/computer-setup.ts +490 -20
- package/src/commands/create-command.ts +7 -7
- package/src/commands/create.ts +36 -33
- package/src/commands/dashboard.ts +33 -28
- package/src/commands/govern.ts +34 -29
- package/src/commands/governance.ts +1005 -0
- package/src/commands/guardian.ts +887 -0
- package/src/commands/init.ts +112 -22
- package/src/commands/performance-optimizer.ts +48 -42
- package/src/commands/plugins.ts +35 -32
- package/src/commands/project-update.ts +1053 -0
- package/src/commands/rag.ts +904 -0
- package/src/commands/session.ts +631 -0
- package/src/commands/setup.ts +35 -31
- package/src/commands/test-init.ts +6 -5
- package/src/commands/test.ts +7 -6
- package/src/commands/vp.ts +762 -0
- package/src/commands/watch.ts +44 -33
- package/src/commands/worktree.ts +1057 -0
- package/src/context/context-manager.ts +15 -12
- package/src/context/session-manager.ts +51 -40
- package/src/index.ts +7 -6
- package/src/interactive/interactive-mode.ts +25 -18
- package/src/lib/conflict-resolution.ts +28 -0
- package/src/lib/merge-strategy.ts +28 -0
- package/src/lib/safety-mechanisms.ts +47 -0
- package/src/lib/state-detection.ts +28 -0
- package/src/nlp/command-mapper.ts +35 -30
- package/src/nlp/command-parser.ts +20 -17
- package/src/nlp/intent-classifier.ts +7 -7
- package/src/nlp/intent-parser.ts +61 -49
- package/src/plugins/plugin-manager.ts +27 -23
- package/src/types/index.ts +1 -1
- package/src/types/modules.d.ts +1 -0
- package/src/utils/backup-rollback-manager.ts +13 -11
- package/src/utils/claude-config-installer.ts +18 -16
- package/src/utils/config-manager.ts +12 -9
- package/src/utils/error-handler.ts +5 -3
- package/src/utils/logger.ts +35 -12
package/src/commands/ai.ts
CHANGED
|
@@ -1,24 +1,55 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
1
|
import chalk from 'chalk';
|
|
4
|
-
import
|
|
5
|
-
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
|
|
6
4
|
import { AIService } from '../ai/ai-service';
|
|
7
|
-
import { logger } from '../utils/logger';
|
|
8
5
|
import { errorHandler } from '../utils/error-handler';
|
|
9
|
-
import {
|
|
6
|
+
import { logger } from '../utils/logger';
|
|
7
|
+
|
|
8
|
+
import type { PluginManager } from '../plugins/plugin-manager';
|
|
9
|
+
import type { ChatSession } from '../types';
|
|
10
|
+
import type { ConfigManager } from '../utils/config-manager';
|
|
11
|
+
import type { Command } from 'commander';
|
|
12
|
+
|
|
13
|
+
/** Review result for a single file */
|
|
14
|
+
interface FileReviewResult {
|
|
15
|
+
file: string;
|
|
16
|
+
issues: Array<{ severity: string; description: string }>;
|
|
17
|
+
suggestions: string[];
|
|
18
|
+
score: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Refactoring plan from AI analysis */
|
|
22
|
+
interface RefactoringPlan {
|
|
23
|
+
description: string;
|
|
24
|
+
changes: Array<{ description: string; code?: string }>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Optimization plan from AI analysis */
|
|
28
|
+
interface OptimizationPlan {
|
|
29
|
+
description: string;
|
|
30
|
+
changes: Array<{ description: string; code?: string }>;
|
|
31
|
+
optimizedCode: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Benchmark result metrics */
|
|
35
|
+
interface BenchmarkResult {
|
|
36
|
+
time: number;
|
|
37
|
+
memory: number;
|
|
38
|
+
}
|
|
10
39
|
|
|
11
40
|
/**
|
|
12
41
|
* AI commands for AI-powered development features
|
|
13
42
|
*/
|
|
14
43
|
export class AICommands {
|
|
15
44
|
private aiService: AIService;
|
|
45
|
+
private pluginManager: PluginManager;
|
|
16
46
|
|
|
17
47
|
constructor(
|
|
18
48
|
private program: Command,
|
|
19
49
|
private configManager: ConfigManager,
|
|
20
|
-
|
|
50
|
+
pluginManager: PluginManager,
|
|
21
51
|
) {
|
|
52
|
+
this.pluginManager = pluginManager;
|
|
22
53
|
this.aiService = new AIService(configManager);
|
|
23
54
|
this.registerCommands();
|
|
24
55
|
}
|
|
@@ -48,7 +79,7 @@ export class AICommands {
|
|
|
48
79
|
.option(
|
|
49
80
|
'--focus <aspect>',
|
|
50
81
|
'review focus (security, performance, style)',
|
|
51
|
-
'all'
|
|
82
|
+
'all',
|
|
52
83
|
)
|
|
53
84
|
.option('--severity <level>', 'minimum issue severity', 'info')
|
|
54
85
|
.option('--suggest-fixes', 'suggest fixes for issues')
|
|
@@ -63,12 +94,12 @@ export class AICommands {
|
|
|
63
94
|
.option(
|
|
64
95
|
'--type <type>',
|
|
65
96
|
'refactoring type (extract, rename, optimize)',
|
|
66
|
-
'optimize'
|
|
97
|
+
'optimize',
|
|
67
98
|
)
|
|
68
99
|
.option(
|
|
69
100
|
'--scope <scope>',
|
|
70
101
|
'refactoring scope (function, class, file)',
|
|
71
|
-
'function'
|
|
102
|
+
'function',
|
|
72
103
|
)
|
|
73
104
|
.option('--dry-run', 'show refactoring plan without applying')
|
|
74
105
|
.action(async (target, options) => {
|
|
@@ -82,12 +113,12 @@ export class AICommands {
|
|
|
82
113
|
.option(
|
|
83
114
|
'--type <type>',
|
|
84
115
|
'documentation type (api, readme, comments)',
|
|
85
|
-
'api'
|
|
116
|
+
'api',
|
|
86
117
|
)
|
|
87
118
|
.option(
|
|
88
119
|
'--format <format>',
|
|
89
120
|
'output format (markdown, html, json)',
|
|
90
|
-
'markdown'
|
|
121
|
+
'markdown',
|
|
91
122
|
)
|
|
92
123
|
.option('--include-examples', 'include code examples')
|
|
93
124
|
.action(async (target, options) => {
|
|
@@ -101,12 +132,12 @@ export class AICommands {
|
|
|
101
132
|
.option(
|
|
102
133
|
'--framework <framework>',
|
|
103
134
|
'testing framework (jest, mocha, vitest)',
|
|
104
|
-
'jest'
|
|
135
|
+
'jest',
|
|
105
136
|
)
|
|
106
137
|
.option(
|
|
107
138
|
'--coverage <level>',
|
|
108
139
|
'coverage level (unit, integration, e2e)',
|
|
109
|
-
'unit'
|
|
140
|
+
'unit',
|
|
110
141
|
)
|
|
111
142
|
.option('--mocks', 'generate mock objects')
|
|
112
143
|
.action(async (target, options) => {
|
|
@@ -132,7 +163,7 @@ export class AICommands {
|
|
|
132
163
|
.option(
|
|
133
164
|
'--aspect <aspect>',
|
|
134
165
|
'analysis aspect (complexity, maintainability, security)',
|
|
135
|
-
'all'
|
|
166
|
+
'all',
|
|
136
167
|
)
|
|
137
168
|
.option('--suggestions', 'include improvement suggestions')
|
|
138
169
|
.action(async (target, options) => {
|
|
@@ -146,7 +177,7 @@ export class AICommands {
|
|
|
146
177
|
.option(
|
|
147
178
|
'--focus <focus>',
|
|
148
179
|
'optimization focus (speed, memory, bundle)',
|
|
149
|
-
'speed'
|
|
180
|
+
'speed',
|
|
150
181
|
)
|
|
151
182
|
.option('--benchmarks', 'run before/after benchmarks')
|
|
152
183
|
.action(async (target, options) => {
|
|
@@ -207,7 +238,7 @@ export class AICommands {
|
|
|
207
238
|
if (!this.aiService.isReady()) {
|
|
208
239
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
209
240
|
console.log(
|
|
210
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
241
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
211
242
|
);
|
|
212
243
|
return;
|
|
213
244
|
}
|
|
@@ -238,7 +269,7 @@ export class AICommands {
|
|
|
238
269
|
'WUNDR_AI_GENERATE_FAILED',
|
|
239
270
|
'Failed to generate code',
|
|
240
271
|
{ type, options },
|
|
241
|
-
true
|
|
272
|
+
true,
|
|
242
273
|
);
|
|
243
274
|
}
|
|
244
275
|
}
|
|
@@ -252,7 +283,7 @@ export class AICommands {
|
|
|
252
283
|
if (!this.aiService.isReady()) {
|
|
253
284
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
254
285
|
console.log(
|
|
255
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
286
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
256
287
|
);
|
|
257
288
|
return;
|
|
258
289
|
}
|
|
@@ -261,12 +292,7 @@ export class AICommands {
|
|
|
261
292
|
|
|
262
293
|
const filesToReview =
|
|
263
294
|
files.length > 0 ? files : await this.getChangedFiles();
|
|
264
|
-
const reviewResults:
|
|
265
|
-
file: string;
|
|
266
|
-
issues: any;
|
|
267
|
-
suggestions: any;
|
|
268
|
-
score: any;
|
|
269
|
-
}> = [];
|
|
295
|
+
const reviewResults: FileReviewResult[] = [];
|
|
270
296
|
|
|
271
297
|
for (const file of filesToReview) {
|
|
272
298
|
logger.debug(`Reviewing ${file}...`);
|
|
@@ -297,7 +323,7 @@ export class AICommands {
|
|
|
297
323
|
'WUNDR_AI_REVIEW_FAILED',
|
|
298
324
|
'Failed to review code',
|
|
299
325
|
{ files, options },
|
|
300
|
-
true
|
|
326
|
+
true,
|
|
301
327
|
);
|
|
302
328
|
}
|
|
303
329
|
}
|
|
@@ -311,7 +337,7 @@ export class AICommands {
|
|
|
311
337
|
if (!this.aiService.isReady()) {
|
|
312
338
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
313
339
|
console.log(
|
|
314
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
340
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
315
341
|
);
|
|
316
342
|
return;
|
|
317
343
|
}
|
|
@@ -354,7 +380,7 @@ export class AICommands {
|
|
|
354
380
|
'WUNDR_AI_REFACTOR_FAILED',
|
|
355
381
|
'Failed to refactor code',
|
|
356
382
|
{ target, options },
|
|
357
|
-
true
|
|
383
|
+
true,
|
|
358
384
|
);
|
|
359
385
|
}
|
|
360
386
|
}
|
|
@@ -368,17 +394,17 @@ export class AICommands {
|
|
|
368
394
|
if (!this.aiService.isReady()) {
|
|
369
395
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
370
396
|
console.log(
|
|
371
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
397
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
372
398
|
);
|
|
373
399
|
return;
|
|
374
400
|
}
|
|
375
401
|
|
|
376
402
|
logger.info(
|
|
377
|
-
`Generating ${options.type} documentation for ${chalk.cyan(target)}
|
|
403
|
+
`Generating ${options.type} documentation for ${chalk.cyan(target)}...`,
|
|
378
404
|
);
|
|
379
405
|
|
|
380
406
|
const code = await this.readFile(target);
|
|
381
|
-
const
|
|
407
|
+
const docs = await this.callAI('docs', {
|
|
382
408
|
code,
|
|
383
409
|
target,
|
|
384
410
|
type: options.type,
|
|
@@ -389,9 +415,9 @@ export class AICommands {
|
|
|
389
415
|
const outputPath = this.getDocsOutputPath(
|
|
390
416
|
target,
|
|
391
417
|
options.type,
|
|
392
|
-
options.format
|
|
418
|
+
options.format,
|
|
393
419
|
);
|
|
394
|
-
await this.saveGeneratedDocs(
|
|
420
|
+
await this.saveGeneratedDocs(docs, outputPath);
|
|
395
421
|
|
|
396
422
|
logger.success(`Documentation generated: ${outputPath}`);
|
|
397
423
|
} catch (error) {
|
|
@@ -399,7 +425,7 @@ export class AICommands {
|
|
|
399
425
|
'WUNDR_AI_DOCS_FAILED',
|
|
400
426
|
'Failed to generate documentation',
|
|
401
427
|
{ target, options },
|
|
402
|
-
true
|
|
428
|
+
true,
|
|
403
429
|
);
|
|
404
430
|
}
|
|
405
431
|
}
|
|
@@ -413,7 +439,7 @@ export class AICommands {
|
|
|
413
439
|
if (!this.aiService.isReady()) {
|
|
414
440
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
415
441
|
console.log(
|
|
416
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
442
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
417
443
|
);
|
|
418
444
|
return;
|
|
419
445
|
}
|
|
@@ -438,7 +464,7 @@ export class AICommands {
|
|
|
438
464
|
'WUNDR_AI_TEST_FAILED',
|
|
439
465
|
'Failed to generate tests',
|
|
440
466
|
{ target, options },
|
|
441
|
-
true
|
|
467
|
+
true,
|
|
442
468
|
);
|
|
443
469
|
}
|
|
444
470
|
}
|
|
@@ -452,7 +478,7 @@ export class AICommands {
|
|
|
452
478
|
if (!this.aiService.isReady()) {
|
|
453
479
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
454
480
|
console.log(
|
|
455
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
481
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
456
482
|
);
|
|
457
483
|
return;
|
|
458
484
|
}
|
|
@@ -469,7 +495,7 @@ export class AICommands {
|
|
|
469
495
|
'WUNDR_AI_CHAT_FAILED',
|
|
470
496
|
'Failed to start chat session',
|
|
471
497
|
{ options },
|
|
472
|
-
true
|
|
498
|
+
true,
|
|
473
499
|
);
|
|
474
500
|
}
|
|
475
501
|
}
|
|
@@ -483,7 +509,7 @@ export class AICommands {
|
|
|
483
509
|
if (!this.aiService.isReady()) {
|
|
484
510
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
485
511
|
console.log(
|
|
486
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
512
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
487
513
|
);
|
|
488
514
|
return;
|
|
489
515
|
}
|
|
@@ -504,7 +530,7 @@ export class AICommands {
|
|
|
504
530
|
'WUNDR_AI_ANALYZE_FAILED',
|
|
505
531
|
'Failed to analyze code',
|
|
506
532
|
{ target, options },
|
|
507
|
-
true
|
|
533
|
+
true,
|
|
508
534
|
);
|
|
509
535
|
}
|
|
510
536
|
}
|
|
@@ -518,7 +544,7 @@ export class AICommands {
|
|
|
518
544
|
if (!this.aiService.isReady()) {
|
|
519
545
|
console.log(chalk.red('\n❌ AI service not configured'));
|
|
520
546
|
console.log(
|
|
521
|
-
chalk.yellow('Run `wundr ai setup` to configure your API key first')
|
|
547
|
+
chalk.yellow('Run `wundr ai setup` to configure your API key first'),
|
|
522
548
|
);
|
|
523
549
|
return;
|
|
524
550
|
}
|
|
@@ -526,13 +552,13 @@ export class AICommands {
|
|
|
526
552
|
logger.info(`Optimizing ${chalk.cyan(target)}...`);
|
|
527
553
|
|
|
528
554
|
const code = await this.readFile(target);
|
|
529
|
-
let beforeBenchmark
|
|
555
|
+
let beforeBenchmark: BenchmarkResult | undefined;
|
|
530
556
|
|
|
531
557
|
if (options.benchmarks) {
|
|
532
558
|
beforeBenchmark = await this.runBenchmark(target);
|
|
533
559
|
}
|
|
534
560
|
|
|
535
|
-
const
|
|
561
|
+
const optimization: OptimizationPlan = await this.callAI('optimize', {
|
|
536
562
|
code,
|
|
537
563
|
target,
|
|
538
564
|
focus: options.focus,
|
|
@@ -548,9 +574,9 @@ export class AICommands {
|
|
|
548
574
|
]);
|
|
549
575
|
|
|
550
576
|
if (apply) {
|
|
551
|
-
await this.applyOptimization(target,
|
|
577
|
+
await this.applyOptimization(target, optimization);
|
|
552
578
|
|
|
553
|
-
if (options.benchmarks) {
|
|
579
|
+
if (options.benchmarks && beforeBenchmark) {
|
|
554
580
|
const afterBenchmark = await this.runBenchmark(target);
|
|
555
581
|
this.displayBenchmarkComparison(beforeBenchmark, afterBenchmark);
|
|
556
582
|
}
|
|
@@ -562,7 +588,7 @@ export class AICommands {
|
|
|
562
588
|
'WUNDR_AI_OPTIMIZE_FAILED',
|
|
563
589
|
'Failed to optimize code',
|
|
564
590
|
{ target, options },
|
|
565
|
-
true
|
|
591
|
+
true,
|
|
566
592
|
);
|
|
567
593
|
}
|
|
568
594
|
}
|
|
@@ -580,7 +606,7 @@ export class AICommands {
|
|
|
580
606
|
'WUNDR_AI_CONFIG_SET_FAILED',
|
|
581
607
|
'Failed to set AI configuration',
|
|
582
608
|
{ key, value },
|
|
583
|
-
true
|
|
609
|
+
true,
|
|
584
610
|
);
|
|
585
611
|
}
|
|
586
612
|
}
|
|
@@ -602,7 +628,7 @@ export class AICommands {
|
|
|
602
628
|
'WUNDR_AI_CONFIG_GET_FAILED',
|
|
603
629
|
'Failed to get AI configuration',
|
|
604
630
|
{ key },
|
|
605
|
-
true
|
|
631
|
+
true,
|
|
606
632
|
);
|
|
607
633
|
}
|
|
608
634
|
}
|
|
@@ -614,7 +640,7 @@ export class AICommands {
|
|
|
614
640
|
try {
|
|
615
641
|
console.log(chalk.blue('\n🤖 Wundr AI Setup'));
|
|
616
642
|
console.log(
|
|
617
|
-
chalk.gray('Configure your AI assistant for enhanced CLI features\n')
|
|
643
|
+
chalk.gray('Configure your AI assistant for enhanced CLI features\n'),
|
|
618
644
|
);
|
|
619
645
|
|
|
620
646
|
let { provider, apiKey } = options;
|
|
@@ -671,7 +697,7 @@ export class AICommands {
|
|
|
671
697
|
console.log(chalk.green('✅ API key is valid and working!'));
|
|
672
698
|
} else {
|
|
673
699
|
console.log(
|
|
674
|
-
chalk.red(`❌ API key validation failed: ${validation.error}`)
|
|
700
|
+
chalk.red(`❌ API key validation failed: ${validation.error}`),
|
|
675
701
|
);
|
|
676
702
|
return;
|
|
677
703
|
}
|
|
@@ -688,7 +714,7 @@ export class AICommands {
|
|
|
688
714
|
'WUNDR_AI_SETUP_FAILED',
|
|
689
715
|
'Failed to setup AI configuration',
|
|
690
716
|
{ options },
|
|
691
|
-
true
|
|
717
|
+
true,
|
|
692
718
|
);
|
|
693
719
|
}
|
|
694
720
|
}
|
|
@@ -705,24 +731,24 @@ export class AICommands {
|
|
|
705
731
|
console.log(`Provider: ${chalk.cyan(status.provider)}`);
|
|
706
732
|
console.log(`Model: ${chalk.cyan(status.model)}`);
|
|
707
733
|
console.log(
|
|
708
|
-
`API Key: ${status.hasApiKey ? chalk.green('✅ Configured') : chalk.red('❌ Missing')}
|
|
734
|
+
`API Key: ${status.hasApiKey ? chalk.green('✅ Configured') : chalk.red('❌ Missing')}`,
|
|
709
735
|
);
|
|
710
736
|
console.log(
|
|
711
|
-
`Status: ${status.ready ? chalk.green('✅ Ready') : chalk.yellow('⚠️ Not Ready')}
|
|
737
|
+
`Status: ${status.ready ? chalk.green('✅ Ready') : chalk.yellow('⚠️ Not Ready')}`,
|
|
712
738
|
);
|
|
713
739
|
|
|
714
740
|
if (!status.hasApiKey) {
|
|
715
741
|
console.log(chalk.yellow('\n⚠️ API key not configured'));
|
|
716
742
|
console.log(
|
|
717
|
-
chalk.gray('Run `wundr ai setup` to configure your API key')
|
|
743
|
+
chalk.gray('Run `wundr ai setup` to configure your API key'),
|
|
718
744
|
);
|
|
719
745
|
console.log(
|
|
720
|
-
chalk.gray('Or set the CLAUDE_API_KEY environment variable')
|
|
746
|
+
chalk.gray('Or set the CLAUDE_API_KEY environment variable'),
|
|
721
747
|
);
|
|
722
748
|
} else if (!status.ready) {
|
|
723
749
|
console.log(chalk.yellow('\n⚠️ AI service not ready'));
|
|
724
750
|
console.log(
|
|
725
|
-
chalk.gray('Try running `wundr ai validate` to check connection')
|
|
751
|
+
chalk.gray('Try running `wundr ai validate` to check connection'),
|
|
726
752
|
);
|
|
727
753
|
}
|
|
728
754
|
} catch (error) {
|
|
@@ -730,7 +756,7 @@ export class AICommands {
|
|
|
730
756
|
'WUNDR_AI_STATUS_FAILED',
|
|
731
757
|
'Failed to get AI status',
|
|
732
758
|
{},
|
|
733
|
-
true
|
|
759
|
+
true,
|
|
734
760
|
);
|
|
735
761
|
}
|
|
736
762
|
}
|
|
@@ -757,12 +783,12 @@ export class AICommands {
|
|
|
757
783
|
if (validation.error?.includes('API key')) {
|
|
758
784
|
console.log(chalk.yellow('\n💡 Try:'));
|
|
759
785
|
console.log(
|
|
760
|
-
chalk.gray('1. Run `wundr ai setup` to configure your API key')
|
|
786
|
+
chalk.gray('1. Run `wundr ai setup` to configure your API key'),
|
|
761
787
|
);
|
|
762
788
|
console.log(
|
|
763
789
|
chalk.gray(
|
|
764
|
-
'2. Check your API key is valid and has sufficient credits'
|
|
765
|
-
)
|
|
790
|
+
'2. Check your API key is valid and has sufficient credits',
|
|
791
|
+
),
|
|
766
792
|
);
|
|
767
793
|
console.log(chalk.gray('3. Verify your internet connection'));
|
|
768
794
|
}
|
|
@@ -772,7 +798,7 @@ export class AICommands {
|
|
|
772
798
|
'WUNDR_AI_VALIDATE_FAILED',
|
|
773
799
|
'Failed to validate AI connection',
|
|
774
800
|
{},
|
|
775
|
-
true
|
|
801
|
+
true,
|
|
776
802
|
);
|
|
777
803
|
}
|
|
778
804
|
}
|
|
@@ -829,11 +855,19 @@ export class AICommands {
|
|
|
829
855
|
}
|
|
830
856
|
|
|
831
857
|
private async saveGeneratedCode(
|
|
832
|
-
|
|
833
|
-
outputPath: string
|
|
858
|
+
code: string,
|
|
859
|
+
outputPath: string,
|
|
834
860
|
): Promise<void> {
|
|
835
|
-
|
|
836
|
-
|
|
861
|
+
const fs = await import('fs/promises');
|
|
862
|
+
const path = await import('path');
|
|
863
|
+
|
|
864
|
+
// Ensure directory exists
|
|
865
|
+
const dir = path.dirname(outputPath);
|
|
866
|
+
await fs.mkdir(dir, { recursive: true });
|
|
867
|
+
|
|
868
|
+
// Write the generated code to file
|
|
869
|
+
await fs.writeFile(outputPath, code, 'utf-8');
|
|
870
|
+
logger.debug(`Saved generated code to ${outputPath}`);
|
|
837
871
|
}
|
|
838
872
|
|
|
839
873
|
private async readFile(filePath: string): Promise<string> {
|
|
@@ -846,47 +880,84 @@ export class AICommands {
|
|
|
846
880
|
return ['src/example.ts'];
|
|
847
881
|
}
|
|
848
882
|
|
|
849
|
-
private displayReviewResults(results:
|
|
883
|
+
private displayReviewResults(results: FileReviewResult[]): void {
|
|
850
884
|
console.log(chalk.blue('\nCode Review Results:'));
|
|
851
885
|
results.forEach(result => {
|
|
852
886
|
console.log(`\n${chalk.cyan(result.file)} (Score: ${result.score}/100)`);
|
|
853
887
|
if (result.issues.length > 0) {
|
|
854
|
-
result.issues.forEach((issue
|
|
888
|
+
result.issues.forEach((issue) => {
|
|
855
889
|
console.log(` ${issue.severity}: ${issue.description}`);
|
|
856
890
|
});
|
|
857
891
|
}
|
|
858
892
|
});
|
|
859
893
|
}
|
|
860
894
|
|
|
861
|
-
private async suggestFixes(
|
|
862
|
-
// Implementation for suggesting fixes
|
|
895
|
+
private async suggestFixes(results: FileReviewResult[]): Promise<void> {
|
|
863
896
|
logger.info('Generating fix suggestions...');
|
|
897
|
+
|
|
898
|
+
for (const result of results) {
|
|
899
|
+
if (result.issues.length > 0) {
|
|
900
|
+
console.log(chalk.yellow(`\nSuggested fixes for ${result.file}:`));
|
|
901
|
+
for (const issue of result.issues) {
|
|
902
|
+
const fix = await this.callAI('suggest-fix', {
|
|
903
|
+
file: result.file,
|
|
904
|
+
issue: issue.description,
|
|
905
|
+
severity: issue.severity,
|
|
906
|
+
});
|
|
907
|
+
console.log(` - ${issue.description}: ${fix.suggestion || 'No automatic fix available'}`);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
864
911
|
}
|
|
865
912
|
|
|
866
|
-
private async applyRefactoring(target: string,
|
|
867
|
-
|
|
913
|
+
private async applyRefactoring(target: string, plan: RefactoringPlan): Promise<void> {
|
|
914
|
+
const fs = await import('fs/promises');
|
|
915
|
+
|
|
868
916
|
logger.debug(`Applying refactoring to ${target}`);
|
|
917
|
+
logger.info(`Refactoring: ${plan.description}`);
|
|
918
|
+
|
|
919
|
+
// Apply each change from the refactoring plan
|
|
920
|
+
for (const change of plan.changes) {
|
|
921
|
+
logger.debug(` Applying: ${change.description}`);
|
|
922
|
+
if (change.code) {
|
|
923
|
+
await fs.writeFile(target, change.code, 'utf-8');
|
|
924
|
+
}
|
|
925
|
+
}
|
|
869
926
|
}
|
|
870
927
|
|
|
871
928
|
private getDocsOutputPath(
|
|
872
929
|
target: string,
|
|
873
930
|
type: string,
|
|
874
|
-
format: string
|
|
931
|
+
format: string,
|
|
875
932
|
): string {
|
|
876
933
|
const ext = format === 'markdown' ? 'md' : format;
|
|
877
934
|
return `docs/${target}.${type}.${ext}`;
|
|
878
935
|
}
|
|
879
936
|
|
|
880
937
|
private async saveGeneratedDocs(
|
|
881
|
-
|
|
882
|
-
outputPath: string
|
|
938
|
+
docs: string,
|
|
939
|
+
outputPath: string,
|
|
883
940
|
): Promise<void> {
|
|
884
|
-
|
|
885
|
-
|
|
941
|
+
const fs = await import('fs/promises');
|
|
942
|
+
const path = await import('path');
|
|
943
|
+
|
|
944
|
+
// Ensure docs directory exists
|
|
945
|
+
const dir = path.dirname(outputPath);
|
|
946
|
+
await fs.mkdir(dir, { recursive: true });
|
|
947
|
+
|
|
948
|
+
// Write the generated documentation to file
|
|
949
|
+
await fs.writeFile(outputPath, docs, 'utf-8');
|
|
950
|
+
logger.debug(`Saved documentation to ${outputPath}`);
|
|
886
951
|
}
|
|
887
952
|
|
|
888
|
-
private getTestOutputPath(target: string,
|
|
889
|
-
|
|
953
|
+
private getTestOutputPath(target: string, framework: string): string {
|
|
954
|
+
const path = require('path');
|
|
955
|
+
const baseName = path.basename(target, path.extname(target));
|
|
956
|
+
const dirName = path.dirname(target);
|
|
957
|
+
|
|
958
|
+
// Use framework-specific test file extensions
|
|
959
|
+
const extension = framework === 'vitest' ? '.test.ts' : '.test.js';
|
|
960
|
+
return path.join(dirName, '__tests__', `${baseName}${extension}`);
|
|
890
961
|
}
|
|
891
962
|
|
|
892
963
|
private async loadChatSession(sessionId: string): Promise<ChatSession> {
|
|
@@ -948,8 +1019,8 @@ export class AICommands {
|
|
|
948
1019
|
console.log(chalk.red(`Error: ${error.message}`));
|
|
949
1020
|
console.log(
|
|
950
1021
|
chalk.yellow(
|
|
951
|
-
'\nTip: Try `wundr ai validate` to check your connection'
|
|
952
|
-
)
|
|
1022
|
+
'\nTip: Try `wundr ai validate` to check your connection',
|
|
1023
|
+
),
|
|
953
1024
|
);
|
|
954
1025
|
}
|
|
955
1026
|
}
|
|
@@ -970,26 +1041,63 @@ export class AICommands {
|
|
|
970
1041
|
}
|
|
971
1042
|
}
|
|
972
1043
|
|
|
973
|
-
private async runBenchmark(
|
|
974
|
-
|
|
975
|
-
|
|
1044
|
+
private async runBenchmark(target: string): Promise<BenchmarkResult> {
|
|
1045
|
+
const { performance } = await import('perf_hooks');
|
|
1046
|
+
|
|
1047
|
+
logger.debug(`Running benchmark for ${target}`);
|
|
1048
|
+
|
|
1049
|
+
const startTime = performance.now();
|
|
1050
|
+
const startMemory = process.memoryUsage().heapUsed / 1024 / 1024;
|
|
1051
|
+
|
|
1052
|
+
// Simulate loading and analyzing the file for benchmarking
|
|
1053
|
+
const code = await this.readFile(target);
|
|
1054
|
+
// Simple analysis to measure time
|
|
1055
|
+
const lines = code.split('\n').length;
|
|
1056
|
+
logger.debug(`Analyzed ${lines} lines`);
|
|
1057
|
+
|
|
1058
|
+
const endTime = performance.now();
|
|
1059
|
+
const endMemory = process.memoryUsage().heapUsed / 1024 / 1024;
|
|
1060
|
+
|
|
1061
|
+
return {
|
|
1062
|
+
time: Math.round(endTime - startTime),
|
|
1063
|
+
memory: Math.round(endMemory - startMemory),
|
|
1064
|
+
};
|
|
976
1065
|
}
|
|
977
1066
|
|
|
978
1067
|
private async applyOptimization(
|
|
979
1068
|
target: string,
|
|
980
|
-
|
|
1069
|
+
optimization: OptimizationPlan,
|
|
981
1070
|
): Promise<void> {
|
|
982
|
-
|
|
1071
|
+
const fs = await import('fs/promises');
|
|
1072
|
+
|
|
983
1073
|
logger.debug(`Applying optimization to ${target}`);
|
|
1074
|
+
logger.info(`Optimization: ${optimization.description}`);
|
|
1075
|
+
|
|
1076
|
+
// Log each change being applied
|
|
1077
|
+
for (const change of optimization.changes) {
|
|
1078
|
+
logger.debug(` Applying: ${change.description}`);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// Write the optimized code to the file
|
|
1082
|
+
if (optimization.optimizedCode) {
|
|
1083
|
+
await fs.writeFile(target, optimization.optimizedCode, 'utf-8');
|
|
1084
|
+
logger.success(`Optimization applied to ${target}`);
|
|
1085
|
+
}
|
|
984
1086
|
}
|
|
985
1087
|
|
|
986
|
-
private displayBenchmarkComparison(before:
|
|
1088
|
+
private displayBenchmarkComparison(before: BenchmarkResult, after: BenchmarkResult): void {
|
|
987
1089
|
console.log(chalk.blue('\nBenchmark Comparison:'));
|
|
1090
|
+
const timeDiff = after.time - before.time;
|
|
1091
|
+
const memDiff = after.memory - before.memory;
|
|
1092
|
+
|
|
1093
|
+
const timeColor = timeDiff < 0 ? chalk.green : chalk.yellow;
|
|
1094
|
+
const memColor = memDiff < 0 ? chalk.green : chalk.yellow;
|
|
1095
|
+
|
|
988
1096
|
console.log(
|
|
989
|
-
`Time: ${before.time}ms → ${after.time}ms (${
|
|
1097
|
+
`Time: ${before.time}ms → ${after.time}ms (${timeColor(timeDiff > 0 ? '+' : '')}${timeColor(timeDiff + 'ms')})`,
|
|
990
1098
|
);
|
|
991
1099
|
console.log(
|
|
992
|
-
`Memory: ${before.memory}MB → ${after.memory}MB (${
|
|
1100
|
+
`Memory: ${before.memory}MB → ${after.memory}MB (${memColor(memDiff > 0 ? '+' : '')}${memColor(memDiff + 'MB')})`,
|
|
993
1101
|
);
|
|
994
1102
|
}
|
|
995
1103
|
}
|