@wundr.io/cli 1.0.0 → 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.
- package/README.md +696 -280
- package/dist/ai/ai-service.d.ts +2 -2
- package/dist/ai/ai-service.d.ts.map +1 -1
- package/dist/ai/ai-service.js +1 -1
- package/dist/ai/ai-service.js.map +1 -1
- package/dist/ai/claude-client.d.ts.map +1 -1
- package/dist/ai/claude-client.js +2 -1
- package/dist/ai/claude-client.js.map +1 -1
- package/dist/ai/conversation-manager.d.ts +2 -2
- package/dist/ai/conversation-manager.d.ts.map +1 -1
- package/dist/ai/conversation-manager.js +5 -3
- package/dist/ai/conversation-manager.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +32 -13
- package/dist/cli.js.map +1 -1
- package/dist/commands/ai.d.ts +3 -3
- package/dist/commands/ai.d.ts.map +1 -1
- package/dist/commands/ai.js +2 -2
- package/dist/commands/ai.js.map +1 -1
- 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.map +1 -1
- package/dist/commands/analyze-optimized.js +9 -6
- package/dist/commands/analyze-optimized.js.map +1 -1
- package/dist/commands/analyze.d.ts +3 -3
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +2 -2
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/batch.d.ts +3 -3
- package/dist/commands/batch.d.ts.map +1 -1
- package/dist/commands/batch.js +7 -7
- package/dist/commands/batch.js.map +1 -1
- package/dist/commands/chat.d.ts +3 -3
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +3 -3
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/claude-init.d.ts +1 -1
- package/dist/commands/claude-init.d.ts.map +1 -1
- package/dist/commands/claude-init.js +11 -7
- package/dist/commands/claude-init.js.map +1 -1
- package/dist/commands/claude-setup.d.ts +88 -1
- package/dist/commands/claude-setup.d.ts.map +1 -1
- package/dist/commands/claude-setup.js +549 -46
- package/dist/commands/claude-setup.js.map +1 -1
- package/dist/commands/computer-setup-commands.d.ts +17 -3
- package/dist/commands/computer-setup-commands.d.ts.map +1 -1
- package/dist/commands/computer-setup-commands.js +145 -3
- package/dist/commands/computer-setup-commands.js.map +1 -1
- package/dist/commands/computer-setup.d.ts.map +1 -1
- package/dist/commands/computer-setup.js +372 -4
- package/dist/commands/computer-setup.js.map +1 -1
- package/dist/commands/create-command.d.ts.map +1 -1
- package/dist/commands/create-command.js +3 -3
- package/dist/commands/create-command.js.map +1 -1
- package/dist/commands/create.d.ts +3 -3
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -3
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts +3 -3
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +4 -3
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/govern.d.ts +3 -3
- package/dist/commands/govern.d.ts.map +1 -1
- package/dist/commands/govern.js +4 -3
- package/dist/commands/govern.js.map +1 -1
- 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 +7 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +71 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/performance-optimizer.d.ts +2 -2
- package/dist/commands/performance-optimizer.d.ts.map +1 -1
- package/dist/commands/performance-optimizer.js +8 -7
- package/dist/commands/performance-optimizer.js.map +1 -1
- package/dist/commands/plugins.d.ts +3 -3
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +2 -2
- package/dist/commands/plugins.js.map +1 -1
- 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 +3 -3
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +1 -3
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/test-init.d.ts.map +1 -1
- package/dist/commands/test-init.js +2 -2
- package/dist/commands/test-init.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +2 -2
- package/dist/commands/test.js.map +1 -1
- 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 +3 -3
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +10 -7
- package/dist/commands/watch.js.map +1 -1
- 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 +1 -1
- package/dist/context/context-manager.d.ts.map +1 -1
- package/dist/context/context-manager.js +1 -1
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/session-manager.d.ts +2 -2
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +9 -5
- package/dist/context/session-manager.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive/interactive-mode.d.ts +2 -2
- package/dist/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/interactive/interactive-mode.js +6 -4
- package/dist/interactive/interactive-mode.js.map +1 -1
- package/dist/nlp/command-mapper.d.ts +1 -1
- package/dist/nlp/command-mapper.d.ts.map +1 -1
- package/dist/nlp/command-mapper.js +3 -2
- package/dist/nlp/command-mapper.js.map +1 -1
- package/dist/nlp/command-parser.d.ts +1 -1
- package/dist/nlp/command-parser.d.ts.map +1 -1
- package/dist/nlp/command-parser.js +2 -1
- package/dist/nlp/command-parser.js.map +1 -1
- package/dist/nlp/intent-parser.d.ts +1 -1
- package/dist/nlp/intent-parser.d.ts.map +1 -1
- package/dist/nlp/intent-parser.js +14 -9
- package/dist/nlp/intent-parser.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +2 -2
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +3 -3
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- 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 +1 -1
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/config-manager.js +5 -5
- package/dist/utils/config-manager.js.map +1 -1
- package/dist/utils/error-handler.d.ts +1 -1
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +22 -11
- package/dist/utils/logger.js.map +1 -1
- package/package.json +26 -7
- 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 +42 -13
- package/src/commands/ai.ts +59 -57
- package/src/commands/alignment.ts +1212 -0
- package/src/commands/analyze-optimized.ts +70 -62
- 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 +203 -37
- package/src/commands/computer-setup.ts +474 -4
- 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/tests/computer-setup-integration.test.ts +439 -0
- package/src/types/index.ts +1 -1
- package/src/types/modules.d.ts +1 -0
- package/src/utils/backup-rollback-manager.ts +363 -0
- package/src/utils/claude-config-installer.ts +734 -0
- 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/nlp/intent-parser.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { logger } from '../utils/logger';
|
|
4
4
|
|
|
5
|
+
import type { ClaudeClient, ClaudeMessage } from '../ai/claude-client';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Intent classification result
|
|
7
9
|
*/
|
|
@@ -101,7 +103,7 @@ export class IntentParser extends EventEmitter {
|
|
|
101
103
|
|
|
102
104
|
constructor(
|
|
103
105
|
claudeClient: ClaudeClient,
|
|
104
|
-
config: Partial<IntentParserConfig> = {}
|
|
106
|
+
config: Partial<IntentParserConfig> = {},
|
|
105
107
|
) {
|
|
106
108
|
super();
|
|
107
109
|
|
|
@@ -129,13 +131,13 @@ export class IntentParser extends EventEmitter {
|
|
|
129
131
|
async parseIntent(
|
|
130
132
|
input: string,
|
|
131
133
|
availableCommands: string[],
|
|
132
|
-
context: IntentContext = {}
|
|
134
|
+
context: IntentContext = {},
|
|
133
135
|
): Promise<IntentResult> {
|
|
134
136
|
const normalizedInput = this.normalizeInput(input);
|
|
135
137
|
const cacheKey = this.getCacheKey(
|
|
136
138
|
normalizedInput,
|
|
137
139
|
availableCommands,
|
|
138
|
-
context
|
|
140
|
+
context,
|
|
139
141
|
);
|
|
140
142
|
|
|
141
143
|
// Check cache first
|
|
@@ -149,7 +151,7 @@ export class IntentParser extends EventEmitter {
|
|
|
149
151
|
// Step 1: Quick pattern matching for common commands
|
|
150
152
|
const patternResult = await this.patternMatching(
|
|
151
153
|
normalizedInput,
|
|
152
|
-
availableCommands
|
|
154
|
+
availableCommands,
|
|
153
155
|
);
|
|
154
156
|
if (patternResult.confidence >= 0.9) {
|
|
155
157
|
this.cacheResult(cacheKey, patternResult);
|
|
@@ -166,21 +168,21 @@ export class IntentParser extends EventEmitter {
|
|
|
166
168
|
normalizedInput,
|
|
167
169
|
availableCommands,
|
|
168
170
|
context,
|
|
169
|
-
entities
|
|
171
|
+
entities,
|
|
170
172
|
);
|
|
171
173
|
|
|
172
174
|
// Step 4: Combine results and validate
|
|
173
175
|
const finalResult = this.combineResults(
|
|
174
176
|
patternResult,
|
|
175
177
|
aiResult,
|
|
176
|
-
entities
|
|
178
|
+
entities,
|
|
177
179
|
);
|
|
178
180
|
|
|
179
181
|
// Step 5: Post-processing and validation
|
|
180
182
|
const validatedResult = await this.validateAndEnrich(
|
|
181
183
|
finalResult,
|
|
182
184
|
availableCommands,
|
|
183
|
-
context
|
|
185
|
+
context,
|
|
184
186
|
);
|
|
185
187
|
|
|
186
188
|
this.cacheResult(cacheKey, validatedResult);
|
|
@@ -195,7 +197,7 @@ export class IntentParser extends EventEmitter {
|
|
|
195
197
|
return this.fallbackIntentParsing(
|
|
196
198
|
normalizedInput,
|
|
197
199
|
availableCommands,
|
|
198
|
-
context
|
|
200
|
+
context,
|
|
199
201
|
);
|
|
200
202
|
}
|
|
201
203
|
}
|
|
@@ -206,7 +208,7 @@ export class IntentParser extends EventEmitter {
|
|
|
206
208
|
async extractParameters(
|
|
207
209
|
input: string,
|
|
208
210
|
command: string,
|
|
209
|
-
commandPattern?: CommandPattern
|
|
211
|
+
commandPattern?: CommandPattern,
|
|
210
212
|
): Promise<Record<string, any>> {
|
|
211
213
|
const parameters: Record<string, any> = {};
|
|
212
214
|
|
|
@@ -240,7 +242,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
240
242
|
{
|
|
241
243
|
temperature: 0.1,
|
|
242
244
|
maxTokens: 1024,
|
|
243
|
-
}
|
|
245
|
+
},
|
|
244
246
|
);
|
|
245
247
|
|
|
246
248
|
const result = JSON.parse(response.trim());
|
|
@@ -254,7 +256,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
254
256
|
if (result.parameters[param.name] && param.validation) {
|
|
255
257
|
if (!param.validation.test(result.parameters[param.name])) {
|
|
256
258
|
logger.warn(
|
|
257
|
-
`Parameter validation failed for ${param.name}: ${result.parameters[param.name]}
|
|
259
|
+
`Parameter validation failed for ${param.name}: ${result.parameters[param.name]}`,
|
|
258
260
|
);
|
|
259
261
|
delete result.parameters[param.name];
|
|
260
262
|
}
|
|
@@ -283,7 +285,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
283
285
|
partialInput: string,
|
|
284
286
|
availableCommands: string[],
|
|
285
287
|
context: IntentContext = {},
|
|
286
|
-
limit: number = 5
|
|
288
|
+
limit: number = 5,
|
|
287
289
|
): Promise<
|
|
288
290
|
Array<{
|
|
289
291
|
command: string;
|
|
@@ -302,7 +304,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
302
304
|
// Pattern-based suggestions
|
|
303
305
|
const patternSuggestions = this.getPatternSuggestions(
|
|
304
306
|
partialInput,
|
|
305
|
-
availableCommands
|
|
307
|
+
availableCommands,
|
|
306
308
|
);
|
|
307
309
|
suggestions.push(...patternSuggestions);
|
|
308
310
|
|
|
@@ -313,7 +315,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
313
315
|
partialInput,
|
|
314
316
|
availableCommands,
|
|
315
317
|
context,
|
|
316
|
-
limit - suggestions.length
|
|
318
|
+
limit - suggestions.length,
|
|
317
319
|
);
|
|
318
320
|
suggestions.push(...aiSuggestions);
|
|
319
321
|
} catch (error) {
|
|
@@ -366,7 +368,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
366
368
|
} {
|
|
367
369
|
const now = Date.now();
|
|
368
370
|
const validEntries = Array.from(this.intentCache.values()).filter(
|
|
369
|
-
entry => now - entry.timestamp < this.config.cacheDuration
|
|
371
|
+
entry => now - entry.timestamp < this.config.cacheDuration,
|
|
370
372
|
);
|
|
371
373
|
|
|
372
374
|
const oldestEntry =
|
|
@@ -513,16 +515,16 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
513
515
|
this.entityPatterns.set('file_path', /(?:\.\/|\/|~\/)[^\s]+/g);
|
|
514
516
|
this.entityPatterns.set(
|
|
515
517
|
'package_name',
|
|
516
|
-
/(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*/g
|
|
518
|
+
/(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*/g,
|
|
517
519
|
);
|
|
518
520
|
this.entityPatterns.set(
|
|
519
521
|
'command',
|
|
520
|
-
/(?:wundr\s+)?(?:analyze|create|init|help|dashboard|batch|watch)\b/g
|
|
522
|
+
/(?:wundr\s+)?(?:analyze|create|init|help|dashboard|batch|watch)\b/g,
|
|
521
523
|
);
|
|
522
524
|
this.entityPatterns.set('option', /--?[a-zA-Z][a-zA-Z0-9-]*/g);
|
|
523
525
|
this.entityPatterns.set(
|
|
524
526
|
'technology',
|
|
525
|
-
/\b(?:react|angular|vue|nodejs|typescript|javascript|python|java|docker|kubernetes)\b/gi
|
|
527
|
+
/\b(?:react|angular|vue|nodejs|typescript|javascript|python|java|docker|kubernetes)\b/gi,
|
|
526
528
|
);
|
|
527
529
|
}
|
|
528
530
|
|
|
@@ -537,7 +539,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
537
539
|
private getCacheKey(
|
|
538
540
|
input: string,
|
|
539
541
|
commands: string[],
|
|
540
|
-
context: IntentContext
|
|
542
|
+
context: IntentContext,
|
|
541
543
|
): string {
|
|
542
544
|
const contextKey = JSON.stringify({
|
|
543
545
|
projectType: context.projectType,
|
|
@@ -550,7 +552,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
550
552
|
|
|
551
553
|
private async patternMatching(
|
|
552
554
|
input: string,
|
|
553
|
-
availableCommands: string[]
|
|
555
|
+
availableCommands: string[],
|
|
554
556
|
): Promise<IntentResult> {
|
|
555
557
|
let bestMatch: IntentResult = {
|
|
556
558
|
intent: 'unknown',
|
|
@@ -559,7 +561,9 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
559
561
|
};
|
|
560
562
|
|
|
561
563
|
for (const [intent, pattern] of this.commandPatterns) {
|
|
562
|
-
if (!availableCommands.includes(intent))
|
|
564
|
+
if (!availableCommands.includes(intent)) {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
563
567
|
|
|
564
568
|
const confidence = this.calculatePatternScore(input, pattern);
|
|
565
569
|
|
|
@@ -580,7 +584,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
580
584
|
|
|
581
585
|
private calculatePatternScore(
|
|
582
586
|
input: string,
|
|
583
|
-
pattern: CommandPattern
|
|
587
|
+
pattern: CommandPattern,
|
|
584
588
|
): number {
|
|
585
589
|
let score = 0;
|
|
586
590
|
let totalWeight = 0;
|
|
@@ -592,7 +596,9 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
592
596
|
|
|
593
597
|
let matchCount = 0;
|
|
594
598
|
for (const word of patternWords) {
|
|
595
|
-
if (word.startsWith('{') && word.endsWith('}'))
|
|
599
|
+
if (word.startsWith('{') && word.endsWith('}')) {
|
|
600
|
+
continue;
|
|
601
|
+
} // Skip parameters
|
|
596
602
|
if (inputWords.includes(word)) {
|
|
597
603
|
matchCount++;
|
|
598
604
|
}
|
|
@@ -610,7 +616,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
610
616
|
for (const example of pattern.examples) {
|
|
611
617
|
const similarity = this.calculateStringSimilarity(
|
|
612
618
|
input,
|
|
613
|
-
example.toLowerCase()
|
|
619
|
+
example.toLowerCase(),
|
|
614
620
|
);
|
|
615
621
|
exampleScore = Math.max(exampleScore, similarity);
|
|
616
622
|
}
|
|
@@ -661,7 +667,7 @@ Extract parameters from the user input and respond with JSON only:
|
|
|
661
667
|
input: string,
|
|
662
668
|
availableCommands: string[],
|
|
663
669
|
context: IntentContext,
|
|
664
|
-
entities: Entity[]
|
|
670
|
+
entities: Entity[],
|
|
665
671
|
): Promise<IntentResult> {
|
|
666
672
|
const contextInfo = this.buildContextInfo(context);
|
|
667
673
|
const entityInfo =
|
|
@@ -696,7 +702,7 @@ Analyze and respond with JSON only:
|
|
|
696
702
|
{
|
|
697
703
|
temperature: 0.1,
|
|
698
704
|
maxTokens: 1536,
|
|
699
|
-
}
|
|
705
|
+
},
|
|
700
706
|
);
|
|
701
707
|
|
|
702
708
|
const cleanResponse = response.trim();
|
|
@@ -731,7 +737,7 @@ Analyze and respond with JSON only:
|
|
|
731
737
|
|
|
732
738
|
if (context.recentCommands?.length) {
|
|
733
739
|
parts.push(
|
|
734
|
-
`Recent commands: ${context.recentCommands.slice(0, 3).join(', ')}
|
|
740
|
+
`Recent commands: ${context.recentCommands.slice(0, 3).join(', ')}`,
|
|
735
741
|
);
|
|
736
742
|
}
|
|
737
743
|
|
|
@@ -745,19 +751,19 @@ Analyze and respond with JSON only:
|
|
|
745
751
|
private combineResults(
|
|
746
752
|
patternResult: IntentResult,
|
|
747
753
|
aiResult: IntentResult,
|
|
748
|
-
entities: Entity[]
|
|
754
|
+
entities: Entity[],
|
|
749
755
|
): IntentResult {
|
|
750
756
|
// Use AI result as base, but boost confidence if pattern matching agrees
|
|
751
757
|
let finalResult = { ...aiResult };
|
|
752
758
|
|
|
753
759
|
if (patternResult.intent === aiResult.intent) {
|
|
754
760
|
finalResult.confidence = Math.min(0.98, aiResult.confidence + 0.1);
|
|
755
|
-
finalResult.reasoning +=
|
|
761
|
+
finalResult.reasoning += ' (confirmed by pattern matching)';
|
|
756
762
|
} else if (patternResult.confidence > 0.8) {
|
|
757
763
|
// High-confidence pattern match might override AI
|
|
758
764
|
if (patternResult.confidence > aiResult.confidence) {
|
|
759
765
|
finalResult = patternResult;
|
|
760
|
-
finalResult.reasoning +=
|
|
766
|
+
finalResult.reasoning += ' (overridden by high-confidence pattern match)';
|
|
761
767
|
}
|
|
762
768
|
}
|
|
763
769
|
|
|
@@ -772,7 +778,7 @@ Analyze and respond with JSON only:
|
|
|
772
778
|
private async validateAndEnrich(
|
|
773
779
|
result: IntentResult,
|
|
774
780
|
availableCommands: string[],
|
|
775
|
-
context: IntentContext
|
|
781
|
+
context: IntentContext,
|
|
776
782
|
): Promise<IntentResult> {
|
|
777
783
|
// Validate that the intent command is available
|
|
778
784
|
if (!availableCommands.includes(result.intent)) {
|
|
@@ -784,7 +790,7 @@ Analyze and respond with JSON only:
|
|
|
784
790
|
// Add safety warnings for destructive commands
|
|
785
791
|
const commandPattern = this.commandPatterns.get(result.intent);
|
|
786
792
|
if (commandPattern?.destructive) {
|
|
787
|
-
result.clarification =
|
|
793
|
+
result.clarification = 'This is a destructive operation. Are you sure you want to proceed?';
|
|
788
794
|
}
|
|
789
795
|
|
|
790
796
|
// Enrich with context-aware suggestions
|
|
@@ -792,7 +798,7 @@ Analyze and respond with JSON only:
|
|
|
792
798
|
result.alternatives = await this.getContextualAlternatives(
|
|
793
799
|
result,
|
|
794
800
|
availableCommands,
|
|
795
|
-
context
|
|
801
|
+
context,
|
|
796
802
|
);
|
|
797
803
|
}
|
|
798
804
|
|
|
@@ -802,7 +808,7 @@ Analyze and respond with JSON only:
|
|
|
802
808
|
private async getContextualAlternatives(
|
|
803
809
|
result: IntentResult,
|
|
804
810
|
availableCommands: string[],
|
|
805
|
-
context: IntentContext
|
|
811
|
+
context: IntentContext,
|
|
806
812
|
): Promise<IntentResult['alternatives']> {
|
|
807
813
|
const alternatives: NonNullable<IntentResult['alternatives']> = [];
|
|
808
814
|
|
|
@@ -813,7 +819,7 @@ Analyze and respond with JSON only:
|
|
|
813
819
|
if (pattern) {
|
|
814
820
|
const confidence = this.calculatePatternScore(
|
|
815
821
|
result.command || '',
|
|
816
|
-
pattern
|
|
822
|
+
pattern,
|
|
817
823
|
);
|
|
818
824
|
if (confidence > 0.3) {
|
|
819
825
|
alternatives.push({
|
|
@@ -834,7 +840,7 @@ Analyze and respond with JSON only:
|
|
|
834
840
|
private fallbackIntentParsing(
|
|
835
841
|
input: string,
|
|
836
842
|
availableCommands: string[],
|
|
837
|
-
context: IntentContext
|
|
843
|
+
context: IntentContext,
|
|
838
844
|
): IntentResult {
|
|
839
845
|
// Simple keyword matching as last resort
|
|
840
846
|
const keywords = input.split(/\s+/);
|
|
@@ -867,7 +873,7 @@ Analyze and respond with JSON only:
|
|
|
867
873
|
|
|
868
874
|
private fallbackParameterExtraction(
|
|
869
875
|
input: string,
|
|
870
|
-
pattern: CommandPattern
|
|
876
|
+
pattern: CommandPattern,
|
|
871
877
|
): Record<string, any> {
|
|
872
878
|
const parameters: Record<string, any> = {};
|
|
873
879
|
const words = input.split(/\s+/);
|
|
@@ -882,13 +888,13 @@ Analyze and respond with JSON only:
|
|
|
882
888
|
} else if (param.type === 'boolean') {
|
|
883
889
|
if (
|
|
884
890
|
words.some(word =>
|
|
885
|
-
['yes', 'true', 'on', 'enable'].includes(word.toLowerCase())
|
|
891
|
+
['yes', 'true', 'on', 'enable'].includes(word.toLowerCase()),
|
|
886
892
|
)
|
|
887
893
|
) {
|
|
888
894
|
parameters[param.name] = true;
|
|
889
895
|
} else if (
|
|
890
896
|
words.some(word =>
|
|
891
|
-
['no', 'false', 'off', 'disable'].includes(word.toLowerCase())
|
|
897
|
+
['no', 'false', 'off', 'disable'].includes(word.toLowerCase()),
|
|
892
898
|
)
|
|
893
899
|
) {
|
|
894
900
|
parameters[param.name] = false;
|
|
@@ -906,7 +912,7 @@ Analyze and respond with JSON only:
|
|
|
906
912
|
|
|
907
913
|
private getPatternSuggestions(
|
|
908
914
|
partialInput: string,
|
|
909
|
-
availableCommands: string[]
|
|
915
|
+
availableCommands: string[],
|
|
910
916
|
): Array<{
|
|
911
917
|
command: string;
|
|
912
918
|
description: string;
|
|
@@ -922,14 +928,16 @@ Analyze and respond with JSON only:
|
|
|
922
928
|
|
|
923
929
|
for (const command of availableCommands) {
|
|
924
930
|
const pattern = this.commandPatterns.get(command);
|
|
925
|
-
if (!pattern)
|
|
931
|
+
if (!pattern) {
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
926
934
|
|
|
927
935
|
// Check if partial input matches command or examples
|
|
928
936
|
const confidence = Math.max(
|
|
929
937
|
this.calculateStringSimilarity(partialInput, command),
|
|
930
938
|
...pattern.examples.map(ex =>
|
|
931
|
-
this.calculateStringSimilarity(partialInput, ex)
|
|
932
|
-
)
|
|
939
|
+
this.calculateStringSimilarity(partialInput, ex),
|
|
940
|
+
),
|
|
933
941
|
);
|
|
934
942
|
|
|
935
943
|
if (confidence > 0.3) {
|
|
@@ -949,7 +957,7 @@ Analyze and respond with JSON only:
|
|
|
949
957
|
partialInput: string,
|
|
950
958
|
availableCommands: string[],
|
|
951
959
|
context: IntentContext,
|
|
952
|
-
limit: number
|
|
960
|
+
limit: number,
|
|
953
961
|
): Promise<
|
|
954
962
|
Array<{
|
|
955
963
|
command: string;
|
|
@@ -1057,14 +1065,18 @@ Provide ${limit} suggestions in JSON format:
|
|
|
1057
1065
|
|
|
1058
1066
|
const words = input.toLowerCase().split(/\s+/);
|
|
1059
1067
|
const positiveCount = words.filter(word =>
|
|
1060
|
-
positiveWords.includes(word)
|
|
1068
|
+
positiveWords.includes(word),
|
|
1061
1069
|
).length;
|
|
1062
1070
|
const negativeCount = words.filter(word =>
|
|
1063
|
-
negativeWords.includes(word)
|
|
1071
|
+
negativeWords.includes(word),
|
|
1064
1072
|
).length;
|
|
1065
1073
|
|
|
1066
|
-
if (positiveCount > negativeCount)
|
|
1067
|
-
|
|
1074
|
+
if (positiveCount > negativeCount) {
|
|
1075
|
+
return 'positive';
|
|
1076
|
+
}
|
|
1077
|
+
if (negativeCount > positiveCount) {
|
|
1078
|
+
return 'negative';
|
|
1079
|
+
}
|
|
1068
1080
|
return 'neutral';
|
|
1069
1081
|
}
|
|
1070
1082
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
1
|
import { spawn, type ChildProcess } from 'child_process';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
|
|
7
|
+
|
|
7
8
|
import { errorHandler } from '../utils/error-handler';
|
|
8
|
-
import {
|
|
9
|
+
import { logger } from '../utils/logger';
|
|
10
|
+
|
|
11
|
+
import type { Plugin, PluginContext, PluginCommand, PluginHook } from '../types';
|
|
12
|
+
import type { ConfigManager } from '../utils/config-manager';
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Plugin management system for CLI extensibility
|
|
@@ -32,7 +36,7 @@ export class PluginManager {
|
|
|
32
36
|
'WUNDR_PLUGIN_INIT_FAILED',
|
|
33
37
|
'Failed to initialize plugin system',
|
|
34
38
|
{},
|
|
35
|
-
true
|
|
39
|
+
true,
|
|
36
40
|
);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -61,7 +65,7 @@ export class PluginManager {
|
|
|
61
65
|
'WUNDR_PLUGIN_LOAD_FAILED',
|
|
62
66
|
'Failed to load plugins',
|
|
63
67
|
{},
|
|
64
|
-
true
|
|
68
|
+
true,
|
|
65
69
|
);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
@@ -100,7 +104,7 @@ export class PluginManager {
|
|
|
100
104
|
'WUNDR_PLUGIN_LOAD_SINGLE_FAILED',
|
|
101
105
|
`Failed to load plugin: ${pluginName}`,
|
|
102
106
|
{ pluginName },
|
|
103
|
-
true
|
|
107
|
+
true,
|
|
104
108
|
);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -132,7 +136,7 @@ export class PluginManager {
|
|
|
132
136
|
'WUNDR_PLUGIN_UNLOAD_FAILED',
|
|
133
137
|
`Failed to unload plugin: ${pluginName}`,
|
|
134
138
|
{ pluginName },
|
|
135
|
-
true
|
|
139
|
+
true,
|
|
136
140
|
);
|
|
137
141
|
}
|
|
138
142
|
}
|
|
@@ -162,7 +166,7 @@ export class PluginManager {
|
|
|
162
166
|
'WUNDR_PLUGIN_INSTALL_FAILED',
|
|
163
167
|
`Failed to install plugin: ${pluginName}`,
|
|
164
168
|
{ pluginName, options },
|
|
165
|
-
true
|
|
169
|
+
true,
|
|
166
170
|
);
|
|
167
171
|
}
|
|
168
172
|
}
|
|
@@ -192,7 +196,7 @@ export class PluginManager {
|
|
|
192
196
|
'WUNDR_PLUGIN_UNINSTALL_FAILED',
|
|
193
197
|
`Failed to uninstall plugin: ${pluginName}`,
|
|
194
198
|
{ pluginName },
|
|
195
|
-
true
|
|
199
|
+
true,
|
|
196
200
|
);
|
|
197
201
|
}
|
|
198
202
|
}
|
|
@@ -215,7 +219,7 @@ export class PluginManager {
|
|
|
215
219
|
'WUNDR_PLUGIN_ENABLE_FAILED',
|
|
216
220
|
`Failed to enable plugin: ${pluginName}`,
|
|
217
221
|
{ pluginName },
|
|
218
|
-
true
|
|
222
|
+
true,
|
|
219
223
|
);
|
|
220
224
|
}
|
|
221
225
|
}
|
|
@@ -234,7 +238,7 @@ export class PluginManager {
|
|
|
234
238
|
'WUNDR_PLUGIN_DISABLE_FAILED',
|
|
235
239
|
`Failed to disable plugin: ${pluginName}`,
|
|
236
240
|
{ pluginName },
|
|
237
|
-
true
|
|
241
|
+
true,
|
|
238
242
|
);
|
|
239
243
|
}
|
|
240
244
|
}
|
|
@@ -344,7 +348,7 @@ export class PluginManager {
|
|
|
344
348
|
.filter(
|
|
345
349
|
plugin =>
|
|
346
350
|
plugin.name.toLowerCase().includes(query.toLowerCase()) ||
|
|
347
|
-
plugin.description.toLowerCase().includes(query.toLowerCase())
|
|
351
|
+
plugin.description.toLowerCase().includes(query.toLowerCase()),
|
|
348
352
|
)
|
|
349
353
|
.slice(0, options.limit || 20);
|
|
350
354
|
} catch (error) {
|
|
@@ -371,7 +375,7 @@ export class PluginManager {
|
|
|
371
375
|
'WUNDR_PLUGIN_UPDATE_FAILED',
|
|
372
376
|
`Failed to update plugin: ${pluginName}`,
|
|
373
377
|
{ pluginName },
|
|
374
|
-
true
|
|
378
|
+
true,
|
|
375
379
|
);
|
|
376
380
|
}
|
|
377
381
|
}
|
|
@@ -422,7 +426,7 @@ export class PluginManager {
|
|
|
422
426
|
'WUNDR_PLUGIN_LINK_FAILED',
|
|
423
427
|
'Failed to link plugin',
|
|
424
428
|
{ pluginPath },
|
|
425
|
-
true
|
|
429
|
+
true,
|
|
426
430
|
);
|
|
427
431
|
}
|
|
428
432
|
}
|
|
@@ -450,7 +454,7 @@ export class PluginManager {
|
|
|
450
454
|
'WUNDR_PLUGIN_UNLINK_FAILED',
|
|
451
455
|
'Failed to unlink plugin',
|
|
452
456
|
{ pluginName },
|
|
453
|
-
true
|
|
457
|
+
true,
|
|
454
458
|
);
|
|
455
459
|
}
|
|
456
460
|
}
|
|
@@ -472,7 +476,7 @@ export class PluginManager {
|
|
|
472
476
|
'WUNDR_PLUGIN_TEST_FAILED',
|
|
473
477
|
`Failed to test plugin: ${pluginName}`,
|
|
474
478
|
{ pluginName, options },
|
|
475
|
-
true
|
|
479
|
+
true,
|
|
476
480
|
);
|
|
477
481
|
}
|
|
478
482
|
}
|
|
@@ -494,7 +498,7 @@ export class PluginManager {
|
|
|
494
498
|
'WUNDR_PLUGIN_PUBLISH_FAILED',
|
|
495
499
|
'Failed to publish plugin',
|
|
496
500
|
{ options },
|
|
497
|
-
true
|
|
501
|
+
true,
|
|
498
502
|
);
|
|
499
503
|
}
|
|
500
504
|
}
|
|
@@ -505,7 +509,7 @@ export class PluginManager {
|
|
|
505
509
|
async setPluginConfig(
|
|
506
510
|
pluginName: string,
|
|
507
511
|
key: string,
|
|
508
|
-
value: string
|
|
512
|
+
value: string,
|
|
509
513
|
): Promise<void> {
|
|
510
514
|
this.configManager.set(`plugins.${pluginName}.${key}`, value);
|
|
511
515
|
await this.configManager.saveConfig();
|
|
@@ -626,7 +630,7 @@ export class PluginManager {
|
|
|
626
630
|
private removePluginHooks(pluginName: string): void {
|
|
627
631
|
for (const [event, hooks] of this.pluginHooks) {
|
|
628
632
|
const filteredHooks = hooks.filter(
|
|
629
|
-
hook => !hook.event.startsWith(pluginName)
|
|
633
|
+
hook => !hook.event.startsWith(pluginName),
|
|
630
634
|
);
|
|
631
635
|
this.pluginHooks.set(event, filteredHooks);
|
|
632
636
|
}
|
|
@@ -686,7 +690,7 @@ export class PluginManager {
|
|
|
686
690
|
|
|
687
691
|
private async installNpmPlugin(
|
|
688
692
|
pluginName: string,
|
|
689
|
-
options: any
|
|
693
|
+
options: any,
|
|
690
694
|
): Promise<void> {
|
|
691
695
|
const versionSpec = options.version ? `@${options.version}` : '';
|
|
692
696
|
const targetPath = path.join(this.pluginsDir, pluginName);
|
|
@@ -733,7 +737,7 @@ export class PluginManager {
|
|
|
733
737
|
resolve();
|
|
734
738
|
} else {
|
|
735
739
|
reject(
|
|
736
|
-
new Error(`Command failed with exit code ${code}: ${command}`)
|
|
740
|
+
new Error(`Command failed with exit code ${code}: ${command}`),
|
|
737
741
|
);
|
|
738
742
|
}
|
|
739
743
|
});
|