@wundr.io/cli 1.0.0
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 +551 -0
- package/bin/wundr.js +39 -0
- 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 +339 -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 +612 -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 +173 -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 +735 -0
- package/dist/commands/ai.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 +437 -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 +587 -0
- package/dist/commands/claude-init.js.map +1 -0
- package/dist/commands/claude-setup.d.ts +32 -0
- package/dist/commands/claude-setup.d.ts.map +1 -0
- package/dist/commands/claude-setup.js +570 -0
- package/dist/commands/claude-setup.js.map +1 -0
- package/dist/commands/computer-setup-commands.d.ts +39 -0
- package/dist/commands/computer-setup-commands.d.ts.map +1 -0
- package/dist/commands/computer-setup-commands.js +563 -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 +481 -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 +537 -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 +480 -0
- package/dist/commands/govern.js.map +1 -0
- package/dist/commands/init.d.ts +55 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +584 -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 +649 -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/setup.d.ts +29 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +399 -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/watch.d.ts +76 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +610 -0
- package/dist/commands/watch.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 +682 -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 +730 -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 +623 -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 +416 -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 +739 -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/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 +94 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +119 -0
- package/src/ai/ai-service.ts +595 -0
- package/src/ai/claude-client.ts +490 -0
- package/src/ai/conversation-manager.ts +907 -0
- package/src/ai/index.ts +8 -0
- package/src/cli.ts +202 -0
- package/src/commands/ai.ts +995 -0
- package/src/commands/analyze-optimized.ts +641 -0
- package/src/commands/analyze.ts +576 -0
- package/src/commands/batch.ts +935 -0
- package/src/commands/chat.ts +876 -0
- package/src/commands/claude-init.ts +715 -0
- package/src/commands/claude-setup.ts +697 -0
- package/src/commands/computer-setup-commands.ts +709 -0
- package/src/commands/computer-setup.ts +565 -0
- package/src/commands/create-command.ts +175 -0
- package/src/commands/create.ts +727 -0
- package/src/commands/dashboard.ts +691 -0
- package/src/commands/govern.ts +635 -0
- package/src/commands/init.ts +677 -0
- package/src/commands/performance-optimizer.ts +864 -0
- package/src/commands/plugins.ts +848 -0
- package/src/commands/setup.ts +508 -0
- package/src/commands/test-init.ts +242 -0
- package/src/commands/test.ts +264 -0
- package/src/commands/watch.ts +755 -0
- package/src/context/context-manager.ts +546 -0
- package/src/context/index.ts +9 -0
- package/src/context/session-manager.ts +1019 -0
- package/src/index.ts +64 -0
- package/src/interactive/interactive-mode.ts +830 -0
- package/src/nlp/command-mapper.ts +885 -0
- package/src/nlp/command-parser.ts +564 -0
- package/src/nlp/index.ts +4 -0
- package/src/nlp/intent-classifier.ts +458 -0
- package/src/nlp/intent-parser.ts +1101 -0
- package/src/plugins/plugin-manager.ts +744 -0
- package/src/types/index.ts +252 -0
- package/src/types/modules.d.ts +56 -0
- package/src/utils/config-manager.ts +391 -0
- package/src/utils/error-handler.ts +192 -0
- package/src/utils/logger.ts +104 -0
- package/templates/batch/ci-cd.yaml +62 -0
- package/templates/component/{{fileName}}.test.tsx +17 -0
- package/templates/component/{{fileName}}.tsx +21 -0
- package/templates/service/{{fileName}}.ts +98 -0
- package/templates/wundr-test.config.js +0 -0
- package/test-suites/api/health.spec.ts +134 -0
- package/test-suites/helpers/test-config.ts +84 -0
- package/test-suites/ui/accessibility.spec.ts +102 -0
- package/test-suites/ui/smoke.spec.ts +92 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent classification for natural language commands
|
|
3
|
+
*/
|
|
4
|
+
export interface Intent {
|
|
5
|
+
name: string;
|
|
6
|
+
confidence: number;
|
|
7
|
+
entities: Record<string, any>;
|
|
8
|
+
metadata?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Intent classification patterns
|
|
13
|
+
*/
|
|
14
|
+
export interface IntentPattern {
|
|
15
|
+
intent: string;
|
|
16
|
+
patterns: RegExp[];
|
|
17
|
+
entityExtractors: Record<string, (match: RegExpMatchArray) => any>;
|
|
18
|
+
priority: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Intent classifier for natural language processing
|
|
23
|
+
*/
|
|
24
|
+
export class IntentClassifier {
|
|
25
|
+
private patterns: IntentPattern[];
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
this.patterns = this.initializePatterns();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Classify user intent from natural language input
|
|
33
|
+
*/
|
|
34
|
+
classifyIntent(input: string): Intent[] {
|
|
35
|
+
const results: Intent[] = [];
|
|
36
|
+
const normalizedInput = input.toLowerCase().trim();
|
|
37
|
+
|
|
38
|
+
for (const pattern of this.patterns) {
|
|
39
|
+
for (const regex of pattern.patterns) {
|
|
40
|
+
const match = normalizedInput.match(regex);
|
|
41
|
+
|
|
42
|
+
if (match) {
|
|
43
|
+
const entities: Record<string, any> = {};
|
|
44
|
+
|
|
45
|
+
// Extract entities using pattern extractors
|
|
46
|
+
for (const [entityName, extractor] of Object.entries(
|
|
47
|
+
pattern.entityExtractors
|
|
48
|
+
)) {
|
|
49
|
+
try {
|
|
50
|
+
entities[entityName] = extractor(match);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// Skip failed entity extraction
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const confidence = this.calculateConfidence(
|
|
57
|
+
match,
|
|
58
|
+
pattern,
|
|
59
|
+
normalizedInput
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
results.push({
|
|
63
|
+
name: pattern.intent,
|
|
64
|
+
confidence,
|
|
65
|
+
entities,
|
|
66
|
+
metadata: {
|
|
67
|
+
matchedPattern: regex.source,
|
|
68
|
+
priority: pattern.priority,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Sort by confidence and priority
|
|
76
|
+
return results.sort((a, b) => {
|
|
77
|
+
const confidenceDiff = b.confidence - a.confidence;
|
|
78
|
+
if (Math.abs(confidenceDiff) < 0.1) {
|
|
79
|
+
return (
|
|
80
|
+
(b.metadata?.['priority'] || 0) - (a.metadata?.['priority'] || 0)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return confidenceDiff;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get the best intent classification
|
|
89
|
+
*/
|
|
90
|
+
getBestIntent(input: string): Intent | null {
|
|
91
|
+
const intents = this.classifyIntent(input);
|
|
92
|
+
return intents.length > 0 && intents[0] ? intents[0] : null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Check if input matches a specific intent
|
|
97
|
+
*/
|
|
98
|
+
matchesIntent(
|
|
99
|
+
input: string,
|
|
100
|
+
intentName: string,
|
|
101
|
+
minConfidence = 0.7
|
|
102
|
+
): boolean {
|
|
103
|
+
const intents = this.classifyIntent(input);
|
|
104
|
+
const matchedIntent = intents.find(intent => intent.name === intentName);
|
|
105
|
+
return matchedIntent ? matchedIntent.confidence >= minConfidence : false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize intent patterns
|
|
110
|
+
*/
|
|
111
|
+
private initializePatterns(): IntentPattern[] {
|
|
112
|
+
return [
|
|
113
|
+
// Analysis intents
|
|
114
|
+
{
|
|
115
|
+
intent: 'analyze_project',
|
|
116
|
+
patterns: [
|
|
117
|
+
/analyze\s+(?:the\s+)?project/i,
|
|
118
|
+
/scan\s+(?:the\s+)?project/i,
|
|
119
|
+
/check\s+(?:the\s+)?project/i,
|
|
120
|
+
/examine\s+(?:the\s+)?project/i,
|
|
121
|
+
],
|
|
122
|
+
entityExtractors: {},
|
|
123
|
+
priority: 10,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
intent: 'analyze_dependencies',
|
|
127
|
+
patterns: [
|
|
128
|
+
/analyze\s+dependencies/i,
|
|
129
|
+
/check\s+dependencies/i,
|
|
130
|
+
/dependency\s+analysis/i,
|
|
131
|
+
/deps?\s+check/i,
|
|
132
|
+
/find\s+dependency\s+issues/i,
|
|
133
|
+
],
|
|
134
|
+
entityExtractors: {},
|
|
135
|
+
priority: 10,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
intent: 'analyze_duplicates',
|
|
139
|
+
patterns: [
|
|
140
|
+
/find\s+duplicates?/i,
|
|
141
|
+
/duplicate\s+(?:code|analysis)/i,
|
|
142
|
+
/check\s+for\s+duplicates?/i,
|
|
143
|
+
/detect\s+duplicates?/i,
|
|
144
|
+
],
|
|
145
|
+
entityExtractors: {},
|
|
146
|
+
priority: 10,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
intent: 'analyze_quality',
|
|
150
|
+
patterns: [
|
|
151
|
+
/code\s+quality/i,
|
|
152
|
+
/quality\s+check/i,
|
|
153
|
+
/analyze\s+quality/i,
|
|
154
|
+
/check\s+code\s+quality/i,
|
|
155
|
+
],
|
|
156
|
+
entityExtractors: {},
|
|
157
|
+
priority: 10,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
intent: 'analyze_path',
|
|
161
|
+
patterns: [
|
|
162
|
+
/analyze\s+(.+?)(?:\s|$)/i,
|
|
163
|
+
/scan\s+(.+?)(?:\s|$)/i,
|
|
164
|
+
/check\s+(.+?)(?:\s|$)/i,
|
|
165
|
+
],
|
|
166
|
+
entityExtractors: {
|
|
167
|
+
path: match => match[1]?.trim(),
|
|
168
|
+
},
|
|
169
|
+
priority: 8,
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
// Creation intents
|
|
173
|
+
{
|
|
174
|
+
intent: 'create_service',
|
|
175
|
+
patterns: [
|
|
176
|
+
/create\s+(?:a\s+)?service/i,
|
|
177
|
+
/new\s+service/i,
|
|
178
|
+
/generate\s+service/i,
|
|
179
|
+
/make\s+(?:a\s+)?service/i,
|
|
180
|
+
],
|
|
181
|
+
entityExtractors: {
|
|
182
|
+
name: match => this.extractServiceName(match.input || ''),
|
|
183
|
+
},
|
|
184
|
+
priority: 10,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
intent: 'create_component',
|
|
188
|
+
patterns: [
|
|
189
|
+
/create\s+(?:a\s+)?component/i,
|
|
190
|
+
/new\s+component/i,
|
|
191
|
+
/generate\s+component/i,
|
|
192
|
+
/make\s+(?:a\s+)?component/i,
|
|
193
|
+
],
|
|
194
|
+
entityExtractors: {
|
|
195
|
+
name: match => this.extractComponentName(match.input || ''),
|
|
196
|
+
},
|
|
197
|
+
priority: 10,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
intent: 'create_template',
|
|
201
|
+
patterns: [
|
|
202
|
+
/create\s+(?:a\s+)?template/i,
|
|
203
|
+
/new\s+template/i,
|
|
204
|
+
/generate\s+template/i,
|
|
205
|
+
/make\s+(?:a\s+)?template/i,
|
|
206
|
+
],
|
|
207
|
+
entityExtractors: {
|
|
208
|
+
type: match => this.extractTemplateType(match.input || ''),
|
|
209
|
+
},
|
|
210
|
+
priority: 10,
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
// Initialization intents
|
|
214
|
+
{
|
|
215
|
+
intent: 'init_project',
|
|
216
|
+
patterns: [
|
|
217
|
+
/init(?:ialize)?\s+(?:a\s+)?project/i,
|
|
218
|
+
/setup\s+(?:a\s+)?project/i,
|
|
219
|
+
/start\s+(?:a\s+)?new\s+project/i,
|
|
220
|
+
/create\s+(?:a\s+)?new\s+project/i,
|
|
221
|
+
],
|
|
222
|
+
entityExtractors: {
|
|
223
|
+
name: match => this.extractProjectName(match.input || ''),
|
|
224
|
+
type: match => this.extractProjectType(match.input || ''),
|
|
225
|
+
},
|
|
226
|
+
priority: 10,
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
intent: 'init_config',
|
|
230
|
+
patterns: [
|
|
231
|
+
/init(?:ialize)?\s+config/i,
|
|
232
|
+
/setup\s+config/i,
|
|
233
|
+
/create\s+config/i,
|
|
234
|
+
/configure\s+wundr/i,
|
|
235
|
+
],
|
|
236
|
+
entityExtractors: {},
|
|
237
|
+
priority: 10,
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
// Dashboard intents
|
|
241
|
+
{
|
|
242
|
+
intent: 'start_dashboard',
|
|
243
|
+
patterns: [
|
|
244
|
+
/start\s+dashboard/i,
|
|
245
|
+
/open\s+dashboard/i,
|
|
246
|
+
/show\s+dashboard/i,
|
|
247
|
+
/launch\s+dashboard/i,
|
|
248
|
+
/run\s+dashboard/i,
|
|
249
|
+
],
|
|
250
|
+
entityExtractors: {
|
|
251
|
+
port: match => this.extractPort(match.input || ''),
|
|
252
|
+
open: match => /open/.test(match.input || ''),
|
|
253
|
+
},
|
|
254
|
+
priority: 10,
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// Governance intents
|
|
258
|
+
{
|
|
259
|
+
intent: 'apply_governance',
|
|
260
|
+
patterns: [
|
|
261
|
+
/apply\s+governance/i,
|
|
262
|
+
/governance\s+check/i,
|
|
263
|
+
/compliance\s+check/i,
|
|
264
|
+
/enforce\s+rules/i,
|
|
265
|
+
],
|
|
266
|
+
entityExtractors: {},
|
|
267
|
+
priority: 10,
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
// Watch intents
|
|
271
|
+
{
|
|
272
|
+
intent: 'watch_files',
|
|
273
|
+
patterns: [
|
|
274
|
+
/watch\s+files?/i,
|
|
275
|
+
/monitor\s+files?/i,
|
|
276
|
+
/auto\s+run/i,
|
|
277
|
+
/continuous\s+(?:build|test|check)/i,
|
|
278
|
+
],
|
|
279
|
+
entityExtractors: {
|
|
280
|
+
pattern: match => this.extractWatchPattern(match.input || ''),
|
|
281
|
+
command: match => this.extractWatchCommand(match.input || ''),
|
|
282
|
+
},
|
|
283
|
+
priority: 10,
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
// Batch intents
|
|
287
|
+
{
|
|
288
|
+
intent: 'run_batch',
|
|
289
|
+
patterns: [
|
|
290
|
+
/run\s+batch/i,
|
|
291
|
+
/execute\s+batch/i,
|
|
292
|
+
/batch\s+(?:operation|job|process)/i,
|
|
293
|
+
/run\s+multiple\s+commands/i,
|
|
294
|
+
],
|
|
295
|
+
entityExtractors: {
|
|
296
|
+
file: match => this.extractBatchFile(match.input || ''),
|
|
297
|
+
},
|
|
298
|
+
priority: 10,
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
// Plugin intents
|
|
302
|
+
{
|
|
303
|
+
intent: 'manage_plugins',
|
|
304
|
+
patterns: [
|
|
305
|
+
/manage\s+plugins?/i,
|
|
306
|
+
/plugin\s+(?:list|install|remove)/i,
|
|
307
|
+
/add\s+plugin/i,
|
|
308
|
+
/install\s+plugin/i,
|
|
309
|
+
],
|
|
310
|
+
entityExtractors: {
|
|
311
|
+
action: match => this.extractPluginAction(match.input || ''),
|
|
312
|
+
name: match => this.extractPluginName(match.input || ''),
|
|
313
|
+
},
|
|
314
|
+
priority: 10,
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
// Help intents
|
|
318
|
+
{
|
|
319
|
+
intent: 'get_help',
|
|
320
|
+
patterns: [
|
|
321
|
+
/help/i,
|
|
322
|
+
/how\s+(?:do\s+i|to)/i,
|
|
323
|
+
/what\s+(?:is|does)/i,
|
|
324
|
+
/show\s+(?:commands|options)/i,
|
|
325
|
+
/usage/i,
|
|
326
|
+
],
|
|
327
|
+
entityExtractors: {
|
|
328
|
+
topic: match => this.extractHelpTopic(match.input || ''),
|
|
329
|
+
},
|
|
330
|
+
priority: 8,
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
// Generic action intents
|
|
334
|
+
{
|
|
335
|
+
intent: 'generic_action',
|
|
336
|
+
patterns: [
|
|
337
|
+
/^(analyze|create|init|start|run|execute|show|open|install|remove|add|delete|update)/i,
|
|
338
|
+
],
|
|
339
|
+
entityExtractors: {
|
|
340
|
+
action: match => match[1]?.toLowerCase(),
|
|
341
|
+
target: match => this.extractActionTarget(match.input || ''),
|
|
342
|
+
},
|
|
343
|
+
priority: 5,
|
|
344
|
+
},
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Calculate confidence score for a match
|
|
350
|
+
*/
|
|
351
|
+
private calculateConfidence(
|
|
352
|
+
match: RegExpMatchArray,
|
|
353
|
+
pattern: IntentPattern,
|
|
354
|
+
normalizedInput: string
|
|
355
|
+
): number {
|
|
356
|
+
let confidence = 0.7; // Base confidence
|
|
357
|
+
|
|
358
|
+
// Boost confidence for exact matches
|
|
359
|
+
if (match[0] === normalizedInput) {
|
|
360
|
+
confidence += 0.2;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Boost confidence for longer matches
|
|
364
|
+
const matchRatio = match[0].length / normalizedInput.length;
|
|
365
|
+
confidence += Math.min(0.2, matchRatio * 0.3);
|
|
366
|
+
|
|
367
|
+
// Boost confidence for high-priority patterns
|
|
368
|
+
if (pattern.priority >= 10) {
|
|
369
|
+
confidence += 0.1;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Cap confidence at 1.0
|
|
373
|
+
return Math.min(1.0, confidence);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Entity extraction helper methods
|
|
377
|
+
private extractServiceName(input: string): string | undefined {
|
|
378
|
+
const match = input.match(
|
|
379
|
+
/(?:service\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)/
|
|
380
|
+
);
|
|
381
|
+
return match?.[1];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private extractComponentName(input: string): string | undefined {
|
|
385
|
+
const match = input.match(
|
|
386
|
+
/(?:component\s+)?(?:called\s+|named\s+)?([A-Z][a-zA-Z]*)/
|
|
387
|
+
);
|
|
388
|
+
return match?.[1];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
private extractTemplateType(input: string): string | undefined {
|
|
392
|
+
const match = input.match(/template\s+for\s+([a-zA-Z]+)/);
|
|
393
|
+
return match?.[1];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private extractProjectName(input: string): string | undefined {
|
|
397
|
+
const match = input.match(/project\s+(?:called\s+|named\s+)?([a-zA-Z-_]+)/);
|
|
398
|
+
return match?.[1];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private extractProjectType(input: string): string | undefined {
|
|
402
|
+
const types = ['node', 'react', 'typescript', 'express', 'next', 'vue'];
|
|
403
|
+
for (const type of types) {
|
|
404
|
+
if (input.includes(type)) {
|
|
405
|
+
return type;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private extractPort(input: string): number | undefined {
|
|
412
|
+
const match = input.match(/port\s+(\d+)/);
|
|
413
|
+
return match && match[1] ? parseInt(match[1], 10) : undefined;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private extractWatchPattern(input: string): string | undefined {
|
|
417
|
+
const match = input.match(/watch\s+"([^"]+)"/);
|
|
418
|
+
return match?.[1];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private extractWatchCommand(input: string): string | undefined {
|
|
422
|
+
const match = input.match(/run\s+"([^"]+)"/);
|
|
423
|
+
return match?.[1];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private extractBatchFile(input: string): string | undefined {
|
|
427
|
+
const match = input.match(
|
|
428
|
+
/batch\s+(?:file\s+)?([^\s]+\.(?:json|yaml|yml))/
|
|
429
|
+
);
|
|
430
|
+
return match?.[1];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
private extractPluginAction(input: string): string | undefined {
|
|
434
|
+
const actions = ['install', 'remove', 'list', 'enable', 'disable'];
|
|
435
|
+
for (const action of actions) {
|
|
436
|
+
if (input.includes(action)) {
|
|
437
|
+
return action;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private extractPluginName(input: string): string | undefined {
|
|
444
|
+
const match = input.match(/plugin\s+([a-zA-Z-_@\/]+)/);
|
|
445
|
+
return match?.[1];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private extractHelpTopic(input: string): string | undefined {
|
|
449
|
+
const match = input.match(/help\s+(?:with\s+)?([a-zA-Z]+)/);
|
|
450
|
+
return match?.[1];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
private extractActionTarget(input: string): string | undefined {
|
|
454
|
+
const words = input.split(/\s+/);
|
|
455
|
+
// Return words after the action verb
|
|
456
|
+
return words.slice(1).join(' ') || undefined;
|
|
457
|
+
}
|
|
458
|
+
}
|