@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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Detection - Stub implementation
|
|
3
|
+
* TODO: Implement full state detection system
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface ProjectState {
|
|
7
|
+
type: string;
|
|
8
|
+
customizations: CustomizationInfo[];
|
|
9
|
+
dependencies: Record<string, string>;
|
|
10
|
+
healthScore?: number;
|
|
11
|
+
isWundrOutdated?: boolean;
|
|
12
|
+
recommendations?: string[];
|
|
13
|
+
wundrVersion?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CustomizationInfo {
|
|
17
|
+
file: string;
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function detectProjectState(): Promise<ProjectState> {
|
|
23
|
+
throw new Error('State detection not yet implemented');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getStateSummary(_state: ProjectState): string {
|
|
27
|
+
return 'State detection not yet implemented';
|
|
28
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
1
2
|
import { EventEmitter } from 'events';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import { logger } from '../utils/logger';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
import type { IntentResult } from './intent-parser';
|
|
7
|
+
import type { ChildProcess } from 'child_process';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Command execution result
|
|
@@ -135,7 +138,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
135
138
|
*/
|
|
136
139
|
async mapIntentToCommand(
|
|
137
140
|
intentResult: IntentResult,
|
|
138
|
-
context: ExecutionContext
|
|
141
|
+
context: ExecutionContext,
|
|
139
142
|
): Promise<{
|
|
140
143
|
command: string;
|
|
141
144
|
args: string[];
|
|
@@ -147,7 +150,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
147
150
|
|
|
148
151
|
if (!template) {
|
|
149
152
|
throw new Error(
|
|
150
|
-
`No command template found for intent: ${intentResult.intent}
|
|
153
|
+
`No command template found for intent: ${intentResult.intent}`,
|
|
151
154
|
);
|
|
152
155
|
}
|
|
153
156
|
|
|
@@ -155,14 +158,14 @@ export class CommandMapper extends EventEmitter {
|
|
|
155
158
|
const { command, args } = await this.buildCommand(
|
|
156
159
|
template,
|
|
157
160
|
intentResult.parameters || {},
|
|
158
|
-
context
|
|
161
|
+
context,
|
|
159
162
|
);
|
|
160
163
|
|
|
161
164
|
// Validate command
|
|
162
165
|
const validation = await this.validateCommand(
|
|
163
166
|
template,
|
|
164
167
|
intentResult.parameters || {},
|
|
165
|
-
context
|
|
168
|
+
context,
|
|
166
169
|
);
|
|
167
170
|
|
|
168
171
|
this.emit('command_mapped', {
|
|
@@ -193,7 +196,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
193
196
|
streaming?: boolean;
|
|
194
197
|
onOutput?: (output: string) => void;
|
|
195
198
|
onError?: (error: string) => void;
|
|
196
|
-
} = {}
|
|
199
|
+
} = {},
|
|
197
200
|
): Promise<CommandResult> {
|
|
198
201
|
const startTime = Date.now();
|
|
199
202
|
const executionId = `cmd_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -330,7 +333,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
330
333
|
if (this.runningCommands.has(executionId)) {
|
|
331
334
|
childProcess.kill('SIGTERM');
|
|
332
335
|
logger.warn(
|
|
333
|
-
`Command timed out after ${this.config.timeout}ms: ${command}
|
|
336
|
+
`Command timed out after ${this.config.timeout}ms: ${command}`,
|
|
334
337
|
);
|
|
335
338
|
}
|
|
336
339
|
}, this.config.timeout);
|
|
@@ -349,7 +352,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
349
352
|
streaming?: boolean;
|
|
350
353
|
onOutput?: (output: string) => void;
|
|
351
354
|
onError?: (error: string) => void;
|
|
352
|
-
} = {}
|
|
355
|
+
} = {},
|
|
353
356
|
): Promise<CommandResult> {
|
|
354
357
|
// Map intent to command
|
|
355
358
|
const mappedCommand = await this.mapIntentToCommand(intentResult, context);
|
|
@@ -357,7 +360,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
357
360
|
// Check validation
|
|
358
361
|
if (!mappedCommand.validation.valid) {
|
|
359
362
|
throw new Error(
|
|
360
|
-
`Command validation failed: ${mappedCommand.validation.errors.join(', ')}
|
|
363
|
+
`Command validation failed: ${mappedCommand.validation.errors.join(', ')}`,
|
|
361
364
|
);
|
|
362
365
|
}
|
|
363
366
|
|
|
@@ -370,7 +373,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
370
373
|
) {
|
|
371
374
|
const confirmed = await this.confirmExecution(
|
|
372
375
|
mappedCommand,
|
|
373
|
-
intentResult
|
|
376
|
+
intentResult,
|
|
374
377
|
);
|
|
375
378
|
if (!confirmed) {
|
|
376
379
|
throw new Error('Command execution cancelled by user');
|
|
@@ -382,7 +385,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
382
385
|
mappedCommand.command,
|
|
383
386
|
mappedCommand.args,
|
|
384
387
|
context,
|
|
385
|
-
options
|
|
388
|
+
options,
|
|
386
389
|
);
|
|
387
390
|
}
|
|
388
391
|
|
|
@@ -401,7 +404,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
401
404
|
async validateCommand(
|
|
402
405
|
template: CommandTemplate,
|
|
403
406
|
parameters: Record<string, any>,
|
|
404
|
-
context: ExecutionContext
|
|
407
|
+
context: ExecutionContext,
|
|
405
408
|
): Promise<ValidationResult> {
|
|
406
409
|
const result: ValidationResult = {
|
|
407
410
|
valid: true,
|
|
@@ -421,7 +424,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
421
424
|
const isValid = await this.executeValidationRule(
|
|
422
425
|
rule,
|
|
423
426
|
parameters,
|
|
424
|
-
context
|
|
427
|
+
context,
|
|
425
428
|
);
|
|
426
429
|
|
|
427
430
|
if (!isValid) {
|
|
@@ -434,7 +437,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
434
437
|
}
|
|
435
438
|
} catch (error) {
|
|
436
439
|
result.errors.push(
|
|
437
|
-
`Validation error: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
440
|
+
`Validation error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
438
441
|
);
|
|
439
442
|
result.valid = false;
|
|
440
443
|
}
|
|
@@ -444,7 +447,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
444
447
|
for (const mapping of template.parameterMapping) {
|
|
445
448
|
if (mapping.required && !parameters[mapping.intentParam]) {
|
|
446
449
|
result.errors.push(
|
|
447
|
-
`Required parameter missing: ${mapping.intentParam}
|
|
450
|
+
`Required parameter missing: ${mapping.intentParam}`,
|
|
448
451
|
);
|
|
449
452
|
result.valid = false;
|
|
450
453
|
}
|
|
@@ -452,7 +455,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
452
455
|
if (parameters[mapping.intentParam] && mapping.validation) {
|
|
453
456
|
if (!mapping.validation(parameters[mapping.intentParam])) {
|
|
454
457
|
result.errors.push(
|
|
455
|
-
`Invalid value for parameter: ${mapping.intentParam}
|
|
458
|
+
`Invalid value for parameter: ${mapping.intentParam}`,
|
|
456
459
|
);
|
|
457
460
|
result.valid = false;
|
|
458
461
|
}
|
|
@@ -482,7 +485,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
482
485
|
successOnly?: boolean;
|
|
483
486
|
intent?: string;
|
|
484
487
|
since?: Date;
|
|
485
|
-
} = {}
|
|
488
|
+
} = {},
|
|
486
489
|
): CommandResult[] {
|
|
487
490
|
let history = [...this.commandHistory];
|
|
488
491
|
|
|
@@ -490,7 +493,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
490
493
|
history = history.filter(
|
|
491
494
|
cmd =>
|
|
492
495
|
cmd.metadata?.['startTime'] &&
|
|
493
|
-
new Date(cmd.metadata['startTime']) >= filters.since
|
|
496
|
+
new Date(cmd.metadata['startTime']) >= filters.since!,
|
|
494
497
|
);
|
|
495
498
|
}
|
|
496
499
|
|
|
@@ -500,7 +503,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
500
503
|
|
|
501
504
|
if (filters.intent) {
|
|
502
505
|
history = history.filter(
|
|
503
|
-
cmd => cmd.metadata?.['intent'] === filters.intent
|
|
506
|
+
cmd => cmd.metadata?.['intent'] === filters.intent,
|
|
504
507
|
);
|
|
505
508
|
}
|
|
506
509
|
|
|
@@ -557,7 +560,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
557
560
|
*/
|
|
558
561
|
async previewCommand(
|
|
559
562
|
intentResult: IntentResult,
|
|
560
|
-
context: ExecutionContext
|
|
563
|
+
context: ExecutionContext,
|
|
561
564
|
): Promise<{
|
|
562
565
|
command: string;
|
|
563
566
|
explanation: string;
|
|
@@ -569,7 +572,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
569
572
|
const explanation = this.generateCommandExplanation(
|
|
570
573
|
mappedCommand.command,
|
|
571
574
|
mappedCommand.args,
|
|
572
|
-
intentResult
|
|
575
|
+
intentResult,
|
|
573
576
|
);
|
|
574
577
|
|
|
575
578
|
return {
|
|
@@ -599,7 +602,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
599
602
|
commandFlag: '--focus',
|
|
600
603
|
validation: (value: string) =>
|
|
601
604
|
['dependencies', 'quality', 'security', 'performance'].includes(
|
|
602
|
-
value
|
|
605
|
+
value,
|
|
603
606
|
),
|
|
604
607
|
},
|
|
605
608
|
{
|
|
@@ -742,14 +745,14 @@ export class CommandMapper extends EventEmitter {
|
|
|
742
745
|
];
|
|
743
746
|
|
|
744
747
|
defaultTemplates.forEach(template =>
|
|
745
|
-
this.registerCommandTemplate(template)
|
|
748
|
+
this.registerCommandTemplate(template),
|
|
746
749
|
);
|
|
747
750
|
}
|
|
748
751
|
|
|
749
752
|
private async buildCommand(
|
|
750
753
|
template: CommandTemplate,
|
|
751
754
|
parameters: Record<string, any>,
|
|
752
|
-
context: ExecutionContext
|
|
755
|
+
context: ExecutionContext,
|
|
753
756
|
): Promise<{ command: string; args: string[] }> {
|
|
754
757
|
const commandParts = template.commandTemplate.split(' ');
|
|
755
758
|
const baseCommand = commandParts[0] || '';
|
|
@@ -793,7 +796,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
793
796
|
private async executeValidationRule(
|
|
794
797
|
rule: ValidationRule,
|
|
795
798
|
parameters: Record<string, any>,
|
|
796
|
-
context: ExecutionContext
|
|
799
|
+
context: ExecutionContext,
|
|
797
800
|
): Promise<boolean> {
|
|
798
801
|
switch (rule.type) {
|
|
799
802
|
case 'parameter':
|
|
@@ -807,7 +810,9 @@ export class CommandMapper extends EventEmitter {
|
|
|
807
810
|
case 'directory_exists':
|
|
808
811
|
const fsDir = await import('fs-extra');
|
|
809
812
|
const dirPath = parameters[rule.rule as string];
|
|
810
|
-
if (!dirPath)
|
|
813
|
+
if (!dirPath) {
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
811
816
|
const stats = await fsDir.stat(dirPath).catch(() => null);
|
|
812
817
|
return stats ? stats.isDirectory() : false;
|
|
813
818
|
|
|
@@ -835,14 +840,14 @@ export class CommandMapper extends EventEmitter {
|
|
|
835
840
|
|
|
836
841
|
private async confirmExecution(
|
|
837
842
|
mappedCommand: any,
|
|
838
|
-
intentResult: IntentResult
|
|
843
|
+
intentResult: IntentResult,
|
|
839
844
|
): Promise<boolean> {
|
|
840
845
|
// In a real implementation, this would show a confirmation dialog
|
|
841
846
|
// For now, we'll assume confirmation based on safety level
|
|
842
847
|
|
|
843
848
|
if (mappedCommand.safetyLevel === 'dangerous') {
|
|
844
849
|
logger.warn(
|
|
845
|
-
`Dangerous command requires confirmation: ${mappedCommand.command} ${mappedCommand.args.join(' ')}
|
|
850
|
+
`Dangerous command requires confirmation: ${mappedCommand.command} ${mappedCommand.args.join(' ')}`,
|
|
846
851
|
);
|
|
847
852
|
// In a real CLI, this would prompt the user
|
|
848
853
|
return false; // Default to not confirmed for dangerous commands
|
|
@@ -854,7 +859,7 @@ export class CommandMapper extends EventEmitter {
|
|
|
854
859
|
private generateCommandExplanation(
|
|
855
860
|
command: string,
|
|
856
861
|
args: string[],
|
|
857
|
-
intentResult: IntentResult
|
|
862
|
+
intentResult: IntentResult,
|
|
858
863
|
): string {
|
|
859
864
|
const fullCommand = `${command} ${args.join(' ')}`;
|
|
860
865
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { logger } from '../utils/logger';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import type { AIService, ConversationContext } from '../ai/ai-service';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Natural language command parsing result
|
|
@@ -57,7 +58,7 @@ export class CommandParser {
|
|
|
57
58
|
*/
|
|
58
59
|
async parseCommand(
|
|
59
60
|
input: string,
|
|
60
|
-
context?: ConversationContext
|
|
61
|
+
context?: ConversationContext,
|
|
61
62
|
): Promise<ParsedCommand> {
|
|
62
63
|
try {
|
|
63
64
|
// First, try template-based parsing for common patterns
|
|
@@ -79,7 +80,7 @@ export class CommandParser {
|
|
|
79
80
|
// Fall back to AI-powered parsing
|
|
80
81
|
const aiResult = await this.aiService.parseNaturalLanguageCommand(
|
|
81
82
|
input,
|
|
82
|
-
context
|
|
83
|
+
context,
|
|
83
84
|
);
|
|
84
85
|
|
|
85
86
|
// Parse the command string into components
|
|
@@ -118,7 +119,7 @@ export class CommandParser {
|
|
|
118
119
|
*/
|
|
119
120
|
async parseComplexCommand(
|
|
120
121
|
input: string,
|
|
121
|
-
context?: ConversationContext
|
|
122
|
+
context?: ConversationContext,
|
|
122
123
|
): Promise<ParsedCommand> {
|
|
123
124
|
try {
|
|
124
125
|
// Check if this is a complex command (contains "and", "then", "after")
|
|
@@ -141,7 +142,9 @@ export class CommandParser {
|
|
|
141
142
|
|
|
142
143
|
for (let i = 0; i < steps.length; i++) {
|
|
143
144
|
const step = steps[i];
|
|
144
|
-
if (!step)
|
|
145
|
+
if (!step) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
145
148
|
|
|
146
149
|
const stepResult = await this.parseCommand(step, context);
|
|
147
150
|
|
|
@@ -186,7 +189,7 @@ export class CommandParser {
|
|
|
186
189
|
if (!parsedCommand.command || parsedCommand.command.trim() === '') {
|
|
187
190
|
issues.push('No valid command identified');
|
|
188
191
|
recommendations.push(
|
|
189
|
-
'Try rephrasing with a specific action like "analyze", "create", or "init"'
|
|
192
|
+
'Try rephrasing with a specific action like "analyze", "create", or "init"',
|
|
190
193
|
);
|
|
191
194
|
}
|
|
192
195
|
|
|
@@ -204,7 +207,7 @@ export class CommandParser {
|
|
|
204
207
|
if (parsedCommand.confidence < 0.6) {
|
|
205
208
|
issues.push('Low confidence in command interpretation');
|
|
206
209
|
recommendations.push(
|
|
207
|
-
'Consider providing more specific details about what you want to accomplish'
|
|
210
|
+
'Consider providing more specific details about what you want to accomplish',
|
|
208
211
|
);
|
|
209
212
|
}
|
|
210
213
|
|
|
@@ -223,7 +226,7 @@ export class CommandParser {
|
|
|
223
226
|
*/
|
|
224
227
|
async generateSuggestions(
|
|
225
228
|
input: string,
|
|
226
|
-
context?: ConversationContext
|
|
229
|
+
context?: ConversationContext,
|
|
227
230
|
): Promise<string[]> {
|
|
228
231
|
try {
|
|
229
232
|
const suggestions = await this.aiService.suggestCommands(input, context);
|
|
@@ -442,8 +445,8 @@ export class CommandParser {
|
|
|
442
445
|
step =>
|
|
443
446
|
step.length > 0 &&
|
|
444
447
|
!['and', 'then', 'after', 'next', 'followed by'].includes(
|
|
445
|
-
step.toLowerCase()
|
|
446
|
-
)
|
|
448
|
+
step.toLowerCase(),
|
|
449
|
+
),
|
|
447
450
|
);
|
|
448
451
|
}
|
|
449
452
|
|
|
@@ -474,7 +477,7 @@ export class CommandParser {
|
|
|
474
477
|
private async validateCommandSpecifics(
|
|
475
478
|
parsedCommand: ParsedCommand,
|
|
476
479
|
issues: string[],
|
|
477
|
-
recommendations: string[]
|
|
480
|
+
recommendations: string[],
|
|
478
481
|
): Promise<void> {
|
|
479
482
|
const commandParts = parsedCommand.command.split(' ');
|
|
480
483
|
const baseCommand = commandParts[1]; // Skip "wundr"
|
|
@@ -483,10 +486,10 @@ export class CommandParser {
|
|
|
483
486
|
case 'create':
|
|
484
487
|
if (parsedCommand.args.length === 0) {
|
|
485
488
|
issues.push(
|
|
486
|
-
'Create command requires a type (service, component, etc.)'
|
|
489
|
+
'Create command requires a type (service, component, etc.)',
|
|
487
490
|
);
|
|
488
491
|
recommendations.push(
|
|
489
|
-
'Specify what you want to create: "wundr create service MyService"'
|
|
492
|
+
'Specify what you want to create: "wundr create service MyService"',
|
|
490
493
|
);
|
|
491
494
|
}
|
|
492
495
|
break;
|
|
@@ -495,7 +498,7 @@ export class CommandParser {
|
|
|
495
498
|
// Analyze command is flexible, but we can suggest focus areas
|
|
496
499
|
if (!parsedCommand.options['focus']) {
|
|
497
500
|
recommendations.push(
|
|
498
|
-
'Consider using --focus to target specific areas (dependencies, duplicates, quality)'
|
|
501
|
+
'Consider using --focus to target specific areas (dependencies, duplicates, quality)',
|
|
499
502
|
);
|
|
500
503
|
}
|
|
501
504
|
break;
|
|
@@ -506,7 +509,7 @@ export class CommandParser {
|
|
|
506
509
|
parsedCommand.args.length === 0
|
|
507
510
|
) {
|
|
508
511
|
recommendations.push(
|
|
509
|
-
'Specify file patterns to watch: "wundr watch --pattern "**/*.ts""'
|
|
512
|
+
'Specify file patterns to watch: "wundr watch --pattern "**/*.ts""',
|
|
510
513
|
);
|
|
511
514
|
}
|
|
512
515
|
break;
|
|
@@ -517,10 +520,10 @@ export class CommandParser {
|
|
|
517
520
|
!parsedCommand.options['interactive']
|
|
518
521
|
) {
|
|
519
522
|
issues.push(
|
|
520
|
-
'Batch command requires either a batch file or interactive mode'
|
|
523
|
+
'Batch command requires either a batch file or interactive mode',
|
|
521
524
|
);
|
|
522
525
|
recommendations.push(
|
|
523
|
-
'Use --file <batch-file> or --interactive for step-by-step execution'
|
|
526
|
+
'Use --file <batch-file> or --interactive for step-by-step execution',
|
|
524
527
|
);
|
|
525
528
|
}
|
|
526
529
|
break;
|
|
@@ -44,7 +44,7 @@ export class IntentClassifier {
|
|
|
44
44
|
|
|
45
45
|
// Extract entities using pattern extractors
|
|
46
46
|
for (const [entityName, extractor] of Object.entries(
|
|
47
|
-
pattern.entityExtractors
|
|
47
|
+
pattern.entityExtractors,
|
|
48
48
|
)) {
|
|
49
49
|
try {
|
|
50
50
|
entities[entityName] = extractor(match);
|
|
@@ -56,7 +56,7 @@ export class IntentClassifier {
|
|
|
56
56
|
const confidence = this.calculateConfidence(
|
|
57
57
|
match,
|
|
58
58
|
pattern,
|
|
59
|
-
normalizedInput
|
|
59
|
+
normalizedInput,
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
results.push({
|
|
@@ -98,7 +98,7 @@ export class IntentClassifier {
|
|
|
98
98
|
matchesIntent(
|
|
99
99
|
input: string,
|
|
100
100
|
intentName: string,
|
|
101
|
-
minConfidence = 0.7
|
|
101
|
+
minConfidence = 0.7,
|
|
102
102
|
): boolean {
|
|
103
103
|
const intents = this.classifyIntent(input);
|
|
104
104
|
const matchedIntent = intents.find(intent => intent.name === intentName);
|
|
@@ -351,7 +351,7 @@ export class IntentClassifier {
|
|
|
351
351
|
private calculateConfidence(
|
|
352
352
|
match: RegExpMatchArray,
|
|
353
353
|
pattern: IntentPattern,
|
|
354
|
-
normalizedInput: string
|
|
354
|
+
normalizedInput: string,
|
|
355
355
|
): number {
|
|
356
356
|
let confidence = 0.7; // Base confidence
|
|
357
357
|
|
|
@@ -376,14 +376,14 @@ export class IntentClassifier {
|
|
|
376
376
|
// Entity extraction helper methods
|
|
377
377
|
private extractServiceName(input: string): string | undefined {
|
|
378
378
|
const match = input.match(
|
|
379
|
-
/(?:service\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)
|
|
379
|
+
/(?:service\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)/,
|
|
380
380
|
);
|
|
381
381
|
return match?.[1];
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
private extractComponentName(input: string): string | undefined {
|
|
385
385
|
const match = input.match(
|
|
386
|
-
/(?:component\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)
|
|
386
|
+
/(?:component\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)/,
|
|
387
387
|
);
|
|
388
388
|
return match?.[1];
|
|
389
389
|
}
|
|
@@ -425,7 +425,7 @@ export class IntentClassifier {
|
|
|
425
425
|
|
|
426
426
|
private extractBatchFile(input: string): string | undefined {
|
|
427
427
|
const match = input.match(
|
|
428
|
-
/batch\s+(?:file\s+)?([^\s]+\.(?:json|yaml|yml))
|
|
428
|
+
/batch\s+(?:file\s+)?([^\s]+\.(?:json|yaml|yml))/,
|
|
429
429
|
);
|
|
430
430
|
return match?.[1];
|
|
431
431
|
}
|