clavix 4.3.1 → 4.4.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/LICENSE +201 -21
- package/README.md +1 -1
- package/dist/core/conversation-quality-tracker.d.ts +81 -0
- package/dist/core/conversation-quality-tracker.js +195 -0
- package/dist/core/intelligence/intent-detector.js +3 -0
- package/dist/core/intelligence/pattern-library.d.ts +33 -1
- package/dist/core/intelligence/pattern-library.js +168 -0
- package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +28 -0
- package/dist/core/intelligence/patterns/conversation-summarizer.js +253 -0
- package/dist/core/intelligence/patterns/dependency-identifier.d.ts +21 -0
- package/dist/core/intelligence/patterns/dependency-identifier.js +149 -0
- package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +22 -0
- package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +236 -0
- package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +22 -0
- package/dist/core/intelligence/patterns/requirement-prioritizer.js +117 -0
- package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +22 -0
- package/dist/core/intelligence/patterns/success-metrics-enforcer.js +142 -0
- package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +24 -0
- package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +282 -0
- package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +22 -0
- package/dist/core/intelligence/patterns/user-persona-enricher.js +124 -0
- package/dist/core/intelligence/quality-assessor.js +2 -0
- package/dist/core/intelligence/types.d.ts +7 -2
- package/dist/core/intelligence/universal-optimizer.d.ts +27 -2
- package/dist/core/intelligence/universal-optimizer.js +65 -5
- package/dist/templates/slash-commands/_canonical/deep.md +2 -1
- package/dist/templates/slash-commands/_canonical/execute.md +1 -1
- package/dist/templates/slash-commands/_canonical/fast.md +2 -1
- package/dist/templates/slash-commands/_canonical/implement.md +1 -1
- package/dist/templates/slash-commands/_canonical/plan.md +1 -1
- package/dist/templates/slash-commands/_canonical/prd.md +1 -1
- package/dist/templates/slash-commands/_canonical/start.md +21 -1
- package/dist/templates/slash-commands/_canonical/summarize.md +43 -2
- package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +26 -2
- package/dist/types/config.d.ts +24 -0
- package/package.json +2 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.4 Conversational Pattern: TopicCoherenceAnalyzer
|
|
4
|
+
*
|
|
5
|
+
* Detects topic shifts and multi-topic conversations.
|
|
6
|
+
* Helps organize scattered discussions into coherent themes.
|
|
7
|
+
* Enhanced with expanded topic dictionary and better detection.
|
|
8
|
+
*/
|
|
9
|
+
export class TopicCoherenceAnalyzer extends BasePattern {
|
|
10
|
+
id = 'topic-coherence-analyzer';
|
|
11
|
+
name = 'TopicCoherenceAnalyzer';
|
|
12
|
+
description = 'Detects topic shifts and multi-topic conversations';
|
|
13
|
+
applicableIntents = ['summarization', 'planning'];
|
|
14
|
+
mode = 'deep';
|
|
15
|
+
priority = 6;
|
|
16
|
+
// Expanded topic indicators (~15 topics with more keywords)
|
|
17
|
+
topicIndicators = {
|
|
18
|
+
'User Interface': [
|
|
19
|
+
'ui',
|
|
20
|
+
'interface',
|
|
21
|
+
'design',
|
|
22
|
+
'layout',
|
|
23
|
+
'button',
|
|
24
|
+
'form',
|
|
25
|
+
'page',
|
|
26
|
+
'screen',
|
|
27
|
+
'component',
|
|
28
|
+
'modal',
|
|
29
|
+
'dialog',
|
|
30
|
+
'navigation',
|
|
31
|
+
'menu',
|
|
32
|
+
'sidebar',
|
|
33
|
+
'header',
|
|
34
|
+
'footer',
|
|
35
|
+
],
|
|
36
|
+
'Backend/API': [
|
|
37
|
+
'api',
|
|
38
|
+
'backend',
|
|
39
|
+
'server',
|
|
40
|
+
'endpoint',
|
|
41
|
+
'route',
|
|
42
|
+
'controller',
|
|
43
|
+
'service',
|
|
44
|
+
'middleware',
|
|
45
|
+
'rest',
|
|
46
|
+
'graphql',
|
|
47
|
+
'websocket',
|
|
48
|
+
],
|
|
49
|
+
Database: [
|
|
50
|
+
'database',
|
|
51
|
+
'db',
|
|
52
|
+
'schema',
|
|
53
|
+
'table',
|
|
54
|
+
'query',
|
|
55
|
+
'migration',
|
|
56
|
+
'model',
|
|
57
|
+
'orm',
|
|
58
|
+
'sql',
|
|
59
|
+
'nosql',
|
|
60
|
+
'index',
|
|
61
|
+
'relationship',
|
|
62
|
+
],
|
|
63
|
+
Authentication: [
|
|
64
|
+
'auth',
|
|
65
|
+
'login',
|
|
66
|
+
'password',
|
|
67
|
+
'session',
|
|
68
|
+
'token',
|
|
69
|
+
'permission',
|
|
70
|
+
'role',
|
|
71
|
+
'oauth',
|
|
72
|
+
'jwt',
|
|
73
|
+
'sso',
|
|
74
|
+
'mfa',
|
|
75
|
+
'2fa',
|
|
76
|
+
],
|
|
77
|
+
Performance: [
|
|
78
|
+
'performance',
|
|
79
|
+
'speed',
|
|
80
|
+
'cache',
|
|
81
|
+
'optimize',
|
|
82
|
+
'latency',
|
|
83
|
+
'load time',
|
|
84
|
+
'bundle',
|
|
85
|
+
'lazy',
|
|
86
|
+
'memory',
|
|
87
|
+
'cpu',
|
|
88
|
+
],
|
|
89
|
+
Testing: [
|
|
90
|
+
'test',
|
|
91
|
+
'spec',
|
|
92
|
+
'coverage',
|
|
93
|
+
'qa',
|
|
94
|
+
'validation',
|
|
95
|
+
'unit test',
|
|
96
|
+
'integration',
|
|
97
|
+
'e2e',
|
|
98
|
+
'mock',
|
|
99
|
+
'fixture',
|
|
100
|
+
],
|
|
101
|
+
Deployment: [
|
|
102
|
+
'deploy',
|
|
103
|
+
'ci/cd',
|
|
104
|
+
'pipeline',
|
|
105
|
+
'release',
|
|
106
|
+
'environment',
|
|
107
|
+
'production',
|
|
108
|
+
'staging',
|
|
109
|
+
'docker',
|
|
110
|
+
'kubernetes',
|
|
111
|
+
],
|
|
112
|
+
'User Experience': [
|
|
113
|
+
'ux',
|
|
114
|
+
'usability',
|
|
115
|
+
'accessibility',
|
|
116
|
+
'user flow',
|
|
117
|
+
'journey',
|
|
118
|
+
'experience',
|
|
119
|
+
'onboarding',
|
|
120
|
+
'feedback',
|
|
121
|
+
],
|
|
122
|
+
'Business Logic': [
|
|
123
|
+
'business',
|
|
124
|
+
'workflow',
|
|
125
|
+
'process',
|
|
126
|
+
'rule',
|
|
127
|
+
'logic',
|
|
128
|
+
'requirement',
|
|
129
|
+
'feature',
|
|
130
|
+
'use case',
|
|
131
|
+
],
|
|
132
|
+
Integration: [
|
|
133
|
+
'integration',
|
|
134
|
+
'third-party',
|
|
135
|
+
'external',
|
|
136
|
+
'webhook',
|
|
137
|
+
'sync',
|
|
138
|
+
'connect',
|
|
139
|
+
'import',
|
|
140
|
+
'export',
|
|
141
|
+
],
|
|
142
|
+
Security: [
|
|
143
|
+
'security',
|
|
144
|
+
'encryption',
|
|
145
|
+
'vulnerability',
|
|
146
|
+
'xss',
|
|
147
|
+
'csrf',
|
|
148
|
+
'injection',
|
|
149
|
+
'sanitize',
|
|
150
|
+
'audit',
|
|
151
|
+
],
|
|
152
|
+
Analytics: [
|
|
153
|
+
'analytics',
|
|
154
|
+
'tracking',
|
|
155
|
+
'metrics',
|
|
156
|
+
'dashboard',
|
|
157
|
+
'report',
|
|
158
|
+
'insight',
|
|
159
|
+
'data',
|
|
160
|
+
'statistics',
|
|
161
|
+
],
|
|
162
|
+
'Error Handling': [
|
|
163
|
+
'error',
|
|
164
|
+
'exception',
|
|
165
|
+
'fallback',
|
|
166
|
+
'retry',
|
|
167
|
+
'timeout',
|
|
168
|
+
'failure',
|
|
169
|
+
'recovery',
|
|
170
|
+
'logging',
|
|
171
|
+
],
|
|
172
|
+
Documentation: [
|
|
173
|
+
'documentation',
|
|
174
|
+
'docs',
|
|
175
|
+
'readme',
|
|
176
|
+
'guide',
|
|
177
|
+
'tutorial',
|
|
178
|
+
'api docs',
|
|
179
|
+
'comment',
|
|
180
|
+
'jsdoc',
|
|
181
|
+
],
|
|
182
|
+
'State Management': [
|
|
183
|
+
'state',
|
|
184
|
+
'store',
|
|
185
|
+
'redux',
|
|
186
|
+
'context',
|
|
187
|
+
'global state',
|
|
188
|
+
'local state',
|
|
189
|
+
'persist',
|
|
190
|
+
'hydrate',
|
|
191
|
+
],
|
|
192
|
+
};
|
|
193
|
+
apply(prompt, _context) {
|
|
194
|
+
// Detect topics in the content
|
|
195
|
+
const topics = this.detectTopics(prompt);
|
|
196
|
+
// If single topic or already organized, skip
|
|
197
|
+
if (topics.length <= 1) {
|
|
198
|
+
return {
|
|
199
|
+
enhancedPrompt: prompt,
|
|
200
|
+
improvement: {
|
|
201
|
+
dimension: 'structure',
|
|
202
|
+
description: 'Single coherent topic detected',
|
|
203
|
+
impact: 'low',
|
|
204
|
+
},
|
|
205
|
+
applied: false,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Check if already has topic organization
|
|
209
|
+
if (this.hasTopicOrganization(prompt)) {
|
|
210
|
+
return {
|
|
211
|
+
enhancedPrompt: prompt,
|
|
212
|
+
improvement: {
|
|
213
|
+
dimension: 'structure',
|
|
214
|
+
description: 'Topics already organized',
|
|
215
|
+
impact: 'low',
|
|
216
|
+
},
|
|
217
|
+
applied: false,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
// Add topic organization
|
|
221
|
+
const enhanced = this.organizeByTopic(prompt, topics);
|
|
222
|
+
return {
|
|
223
|
+
enhancedPrompt: enhanced,
|
|
224
|
+
improvement: {
|
|
225
|
+
dimension: 'structure',
|
|
226
|
+
description: `Organized ${topics.length} distinct topics for clarity`,
|
|
227
|
+
impact: 'medium',
|
|
228
|
+
},
|
|
229
|
+
applied: true,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
detectTopics(prompt) {
|
|
233
|
+
const topics = [];
|
|
234
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
235
|
+
for (const [topic, keywords] of Object.entries(this.topicIndicators)) {
|
|
236
|
+
const hasKeyword = keywords.some((kw) => lowerPrompt.includes(kw));
|
|
237
|
+
if (hasKeyword) {
|
|
238
|
+
topics.push(topic);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return topics;
|
|
242
|
+
}
|
|
243
|
+
hasTopicOrganization(prompt) {
|
|
244
|
+
// Check for existing topic headers
|
|
245
|
+
const topicHeaders = /##\s*(user interface|backend|database|auth|performance|testing|deploy)/i;
|
|
246
|
+
return topicHeaders.test(prompt);
|
|
247
|
+
}
|
|
248
|
+
organizeByTopic(prompt, topics) {
|
|
249
|
+
// Add topic summary at the beginning
|
|
250
|
+
let organized = '### Topics Covered\n';
|
|
251
|
+
organized += 'This conversation touches on multiple areas:\n';
|
|
252
|
+
organized += topics.map((t, i) => `${i + 1}. **${t}**`).join('\n');
|
|
253
|
+
organized += '\n\n---\n\n';
|
|
254
|
+
// Extract content relevant to each topic
|
|
255
|
+
organized += '### Discussion by Topic\n\n';
|
|
256
|
+
for (const topic of topics) {
|
|
257
|
+
const relevantContent = this.extractTopicContent(prompt, topic);
|
|
258
|
+
if (relevantContent) {
|
|
259
|
+
organized += `#### ${topic}\n`;
|
|
260
|
+
organized += relevantContent + '\n\n';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
organized += '---\n\n**Full Context:**\n' + prompt;
|
|
264
|
+
return organized;
|
|
265
|
+
}
|
|
266
|
+
extractTopicContent(prompt, topic) {
|
|
267
|
+
const keywords = this.topicIndicators[topic] || [];
|
|
268
|
+
const sentences = this.extractSentences(prompt);
|
|
269
|
+
const relevantSentences = sentences.filter((sentence) => {
|
|
270
|
+
const lower = sentence.toLowerCase();
|
|
271
|
+
return keywords.some((kw) => lower.includes(kw));
|
|
272
|
+
});
|
|
273
|
+
if (relevantSentences.length === 0) {
|
|
274
|
+
return `- Discussion related to ${topic}`;
|
|
275
|
+
}
|
|
276
|
+
return relevantSentences
|
|
277
|
+
.slice(0, 3)
|
|
278
|
+
.map((s) => `- ${s.trim()}`)
|
|
279
|
+
.join('\n');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=topic-coherence-analyzer.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* v4.3.2 PRD Pattern: UserPersonaEnricher
|
|
5
|
+
*
|
|
6
|
+
* Adds missing user context and personas to PRD content.
|
|
7
|
+
* Ensures the "who" is clearly defined alongside the "what".
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserPersonaEnricher extends BasePattern {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
applicableIntents: PromptIntent[];
|
|
14
|
+
mode: OptimizationMode | 'both';
|
|
15
|
+
priority: number;
|
|
16
|
+
apply(prompt: string, _context: PatternContext): PatternResult;
|
|
17
|
+
private hasUserContext;
|
|
18
|
+
private needsUserContext;
|
|
19
|
+
private addUserPersona;
|
|
20
|
+
private inferUserType;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=user-persona-enricher.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.3.2 PRD Pattern: UserPersonaEnricher
|
|
4
|
+
*
|
|
5
|
+
* Adds missing user context and personas to PRD content.
|
|
6
|
+
* Ensures the "who" is clearly defined alongside the "what".
|
|
7
|
+
*/
|
|
8
|
+
export class UserPersonaEnricher extends BasePattern {
|
|
9
|
+
id = 'user-persona-enricher';
|
|
10
|
+
name = 'UserPersonaEnricher';
|
|
11
|
+
description = 'Adds missing user context and personas';
|
|
12
|
+
applicableIntents = ['prd-generation', 'planning'];
|
|
13
|
+
mode = 'deep';
|
|
14
|
+
priority = 6;
|
|
15
|
+
apply(prompt, _context) {
|
|
16
|
+
// Check if user/persona context already exists
|
|
17
|
+
if (this.hasUserContext(prompt)) {
|
|
18
|
+
return {
|
|
19
|
+
enhancedPrompt: prompt,
|
|
20
|
+
improvement: {
|
|
21
|
+
dimension: 'completeness',
|
|
22
|
+
description: 'User context already present',
|
|
23
|
+
impact: 'low',
|
|
24
|
+
},
|
|
25
|
+
applied: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Check if this is PRD-like content that needs users
|
|
29
|
+
if (!this.needsUserContext(prompt)) {
|
|
30
|
+
return {
|
|
31
|
+
enhancedPrompt: prompt,
|
|
32
|
+
improvement: {
|
|
33
|
+
dimension: 'completeness',
|
|
34
|
+
description: 'Content does not require user persona',
|
|
35
|
+
impact: 'low',
|
|
36
|
+
},
|
|
37
|
+
applied: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Add user persona section
|
|
41
|
+
const enhanced = this.addUserPersona(prompt);
|
|
42
|
+
return {
|
|
43
|
+
enhancedPrompt: enhanced,
|
|
44
|
+
improvement: {
|
|
45
|
+
dimension: 'completeness',
|
|
46
|
+
description: 'Added user persona context (who will use this)',
|
|
47
|
+
impact: 'medium',
|
|
48
|
+
},
|
|
49
|
+
applied: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasUserContext(prompt) {
|
|
53
|
+
const userKeywords = [
|
|
54
|
+
'user persona',
|
|
55
|
+
'target user',
|
|
56
|
+
'end user',
|
|
57
|
+
'user profile',
|
|
58
|
+
'audience',
|
|
59
|
+
'stakeholder',
|
|
60
|
+
'as a user',
|
|
61
|
+
'users can',
|
|
62
|
+
'users will',
|
|
63
|
+
'for users',
|
|
64
|
+
'customer',
|
|
65
|
+
'developer',
|
|
66
|
+
'admin',
|
|
67
|
+
'target audience',
|
|
68
|
+
];
|
|
69
|
+
return this.hasSection(prompt, userKeywords);
|
|
70
|
+
}
|
|
71
|
+
needsUserContext(prompt) {
|
|
72
|
+
// PRD-like content that talks about features but not users
|
|
73
|
+
const featureKeywords = [
|
|
74
|
+
'feature',
|
|
75
|
+
'build',
|
|
76
|
+
'create',
|
|
77
|
+
'implement',
|
|
78
|
+
'functionality',
|
|
79
|
+
'should',
|
|
80
|
+
'must',
|
|
81
|
+
'requirement',
|
|
82
|
+
];
|
|
83
|
+
return this.hasSection(prompt, featureKeywords);
|
|
84
|
+
}
|
|
85
|
+
addUserPersona(prompt) {
|
|
86
|
+
// Detect the likely user type from content
|
|
87
|
+
const userType = this.inferUserType(prompt);
|
|
88
|
+
const personaSection = `\n\n### Target Users\n` +
|
|
89
|
+
`**Primary User:** ${userType}\n` +
|
|
90
|
+
`- Goals: [What they want to achieve]\n` +
|
|
91
|
+
`- Pain Points: [Current frustrations]\n` +
|
|
92
|
+
`- Context: [When and how they'll use this]`;
|
|
93
|
+
return prompt + personaSection;
|
|
94
|
+
}
|
|
95
|
+
inferUserType(prompt) {
|
|
96
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
97
|
+
// Try to infer user type from content
|
|
98
|
+
if (lowerPrompt.includes('api') ||
|
|
99
|
+
lowerPrompt.includes('sdk') ||
|
|
100
|
+
lowerPrompt.includes('library')) {
|
|
101
|
+
return 'Developers integrating with the system';
|
|
102
|
+
}
|
|
103
|
+
if (lowerPrompt.includes('admin') ||
|
|
104
|
+
lowerPrompt.includes('manage') ||
|
|
105
|
+
lowerPrompt.includes('dashboard')) {
|
|
106
|
+
return 'Administrators managing the system';
|
|
107
|
+
}
|
|
108
|
+
if (lowerPrompt.includes('e-commerce') ||
|
|
109
|
+
lowerPrompt.includes('shop') ||
|
|
110
|
+
lowerPrompt.includes('buy')) {
|
|
111
|
+
return 'Customers making purchases';
|
|
112
|
+
}
|
|
113
|
+
if (lowerPrompt.includes('content') ||
|
|
114
|
+
lowerPrompt.includes('blog') ||
|
|
115
|
+
lowerPrompt.includes('cms')) {
|
|
116
|
+
return 'Content creators and editors';
|
|
117
|
+
}
|
|
118
|
+
if (lowerPrompt.includes('mobile') || lowerPrompt.includes('app')) {
|
|
119
|
+
return 'Mobile app users';
|
|
120
|
+
}
|
|
121
|
+
return '[Define primary user type]';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=user-persona-enricher.js.map
|
|
@@ -11,6 +11,8 @@ export class QualityAssessor {
|
|
|
11
11
|
'security-review': ['scope', 'threat-model', 'compliance-requirements', 'known-issues'],
|
|
12
12
|
learning: ['current-knowledge', 'learning-goal', 'preferred-depth', 'context'],
|
|
13
13
|
'prd-generation': ['product-vision', 'user-personas', 'features', 'success-metrics'],
|
|
14
|
+
// v4.3.2: Conversational mode intent
|
|
15
|
+
summarization: ['conversation-context', 'key-requirements', 'constraints', 'success-criteria'],
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* Assess quality of a prompt (backward compatibility wrapper)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning';
|
|
1
|
+
export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning' | 'summarization';
|
|
2
2
|
export type QualityDimension = 'clarity' | 'efficiency' | 'structure' | 'completeness' | 'actionability' | 'specificity';
|
|
3
3
|
export type ImpactLevel = 'low' | 'medium' | 'high';
|
|
4
|
-
export type OptimizationMode = 'fast' | 'deep';
|
|
4
|
+
export type OptimizationMode = 'fast' | 'deep' | 'prd' | 'conversational';
|
|
5
|
+
export type OptimizationPhase = 'question-validation' | 'output-generation' | 'conversation-tracking' | 'summarization';
|
|
6
|
+
export type DocumentType = 'full-prd' | 'quick-prd' | 'mini-prd' | 'prompt';
|
|
5
7
|
export interface IntentAnalysis {
|
|
6
8
|
primaryIntent: PromptIntent;
|
|
7
9
|
confidence: number;
|
|
@@ -55,6 +57,9 @@ export interface PatternContext {
|
|
|
55
57
|
intent: IntentAnalysis;
|
|
56
58
|
mode: OptimizationMode;
|
|
57
59
|
originalPrompt: string;
|
|
60
|
+
phase?: OptimizationPhase;
|
|
61
|
+
documentType?: DocumentType;
|
|
62
|
+
questionId?: string;
|
|
58
63
|
}
|
|
59
64
|
export interface PatternResult {
|
|
60
65
|
enhancedPrompt: string;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { IntentDetector } from './intent-detector.js';
|
|
2
2
|
import { PatternLibrary } from './pattern-library.js';
|
|
3
3
|
import { QualityAssessor } from './quality-assessor.js';
|
|
4
|
-
import { OptimizationResult, OptimizationMode, EscalationAnalysis } from './types.js';
|
|
4
|
+
import { OptimizationResult, OptimizationMode, OptimizationPhase, DocumentType, EscalationAnalysis } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* v4.3.2: Extended context options for PRD and Conversational modes
|
|
7
|
+
*/
|
|
8
|
+
export interface OptimizationContextOverride {
|
|
9
|
+
phase?: OptimizationPhase;
|
|
10
|
+
documentType?: DocumentType;
|
|
11
|
+
questionId?: string;
|
|
12
|
+
intent?: string;
|
|
13
|
+
}
|
|
5
14
|
export declare class UniversalOptimizer {
|
|
6
15
|
private intentDetector;
|
|
7
16
|
private patternLibrary;
|
|
@@ -9,8 +18,24 @@ export declare class UniversalOptimizer {
|
|
|
9
18
|
constructor(intentDetector?: IntentDetector, patternLibrary?: PatternLibrary, qualityAssessor?: QualityAssessor);
|
|
10
19
|
/**
|
|
11
20
|
* Optimize a prompt using Clavix Intelligence
|
|
21
|
+
* @param prompt The prompt to optimize
|
|
22
|
+
* @param mode The optimization mode
|
|
23
|
+
* @param contextOverride Optional context override for PRD/Conversational modes
|
|
24
|
+
*/
|
|
25
|
+
optimize(prompt: string, mode: OptimizationMode, contextOverride?: OptimizationContextOverride): Promise<OptimizationResult>;
|
|
26
|
+
/**
|
|
27
|
+
* v4.3.2: Validate a PRD answer and provide friendly suggestions
|
|
28
|
+
* Uses adaptive threshold (< 50% quality triggers suggestions)
|
|
29
|
+
*/
|
|
30
|
+
validatePRDAnswer(answer: string, questionId: string): Promise<{
|
|
31
|
+
needsClarification: boolean;
|
|
32
|
+
suggestion?: string;
|
|
33
|
+
quality: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
|
|
12
37
|
*/
|
|
13
|
-
|
|
38
|
+
private generateFriendlySuggestion;
|
|
14
39
|
/**
|
|
15
40
|
* Determine if deep mode should be recommended (for fast mode results)
|
|
16
41
|
* @deprecated Use analyzeEscalation() for more detailed analysis
|
|
@@ -12,13 +12,24 @@ export class UniversalOptimizer {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Optimize a prompt using Clavix Intelligence
|
|
15
|
+
* @param prompt The prompt to optimize
|
|
16
|
+
* @param mode The optimization mode
|
|
17
|
+
* @param contextOverride Optional context override for PRD/Conversational modes
|
|
15
18
|
*/
|
|
16
|
-
async optimize(prompt, mode) {
|
|
19
|
+
async optimize(prompt, mode, contextOverride) {
|
|
17
20
|
const startTime = Date.now();
|
|
18
|
-
// Step 1: Detect intent
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Step 1: Detect intent (or use override)
|
|
22
|
+
let intent = this.intentDetector.analyze(prompt);
|
|
23
|
+
if (contextOverride?.intent) {
|
|
24
|
+
intent = {
|
|
25
|
+
...intent,
|
|
26
|
+
primaryIntent: contextOverride.intent,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Step 2: Select applicable patterns using mode-aware selection
|
|
30
|
+
const patterns = mode === 'prd' || mode === 'conversational'
|
|
31
|
+
? this.patternLibrary.selectPatternsForMode(mode, intent, contextOverride?.phase)
|
|
32
|
+
: this.patternLibrary.selectPatterns(intent, mode);
|
|
22
33
|
// Step 3: Apply patterns sequentially
|
|
23
34
|
let enhanced = prompt;
|
|
24
35
|
const improvements = [];
|
|
@@ -27,6 +38,10 @@ export class UniversalOptimizer {
|
|
|
27
38
|
intent,
|
|
28
39
|
mode,
|
|
29
40
|
originalPrompt: prompt,
|
|
41
|
+
// v4.3.2: Extended context
|
|
42
|
+
phase: contextOverride?.phase,
|
|
43
|
+
documentType: contextOverride?.documentType,
|
|
44
|
+
questionId: contextOverride?.questionId,
|
|
30
45
|
};
|
|
31
46
|
for (const pattern of patterns) {
|
|
32
47
|
try {
|
|
@@ -61,6 +76,51 @@ export class UniversalOptimizer {
|
|
|
61
76
|
processingTimeMs,
|
|
62
77
|
};
|
|
63
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* v4.3.2: Validate a PRD answer and provide friendly suggestions
|
|
81
|
+
* Uses adaptive threshold (< 50% quality triggers suggestions)
|
|
82
|
+
*/
|
|
83
|
+
async validatePRDAnswer(answer, questionId) {
|
|
84
|
+
const result = await this.optimize(answer, 'prd', {
|
|
85
|
+
phase: 'question-validation',
|
|
86
|
+
questionId,
|
|
87
|
+
intent: 'prd-generation',
|
|
88
|
+
});
|
|
89
|
+
// Adaptive threshold: only suggest improvements for very vague answers
|
|
90
|
+
if (result.quality.overall < 50) {
|
|
91
|
+
return {
|
|
92
|
+
needsClarification: true,
|
|
93
|
+
suggestion: this.generateFriendlySuggestion(result, questionId),
|
|
94
|
+
quality: result.quality.overall,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
needsClarification: false,
|
|
99
|
+
quality: result.quality.overall,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
|
|
104
|
+
*/
|
|
105
|
+
generateFriendlySuggestion(result, questionId) {
|
|
106
|
+
const suggestions = {
|
|
107
|
+
q1: ["the problem you're solving", 'why this matters', 'who benefits'],
|
|
108
|
+
q2: ['specific features', 'user actions', 'key functionality'],
|
|
109
|
+
q3: ['technologies', 'frameworks', 'constraints'],
|
|
110
|
+
q4: ["what's explicitly out of scope", 'features to avoid', 'limitations'],
|
|
111
|
+
q5: ['additional context', 'constraints', 'timeline considerations'],
|
|
112
|
+
};
|
|
113
|
+
const questionSuggestions = suggestions[questionId] || suggestions.q5;
|
|
114
|
+
// Pick the most relevant suggestion based on what's missing
|
|
115
|
+
let detail = questionSuggestions[0];
|
|
116
|
+
if (result.quality.completeness < 40) {
|
|
117
|
+
detail = questionSuggestions[Math.min(1, questionSuggestions.length - 1)];
|
|
118
|
+
}
|
|
119
|
+
if (result.quality.specificity < 40) {
|
|
120
|
+
detail = questionSuggestions[Math.min(2, questionSuggestions.length - 1)];
|
|
121
|
+
}
|
|
122
|
+
return `adding ${detail} would help`;
|
|
123
|
+
}
|
|
64
124
|
/**
|
|
65
125
|
* Determine if deep mode should be recommended (for fast mode results)
|
|
66
126
|
* @deprecated Use analyzeEscalation() for more detailed analysis
|
|
@@ -93,6 +93,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
|
|
|
93
93
|
- **migration**: Version upgrades, porting code between frameworks
|
|
94
94
|
- **security-review**: Security audits, vulnerability checks
|
|
95
95
|
- **learning**: Conceptual understanding, tutorials, explanations
|
|
96
|
+
- **summarization**: Extracting requirements from conversations
|
|
96
97
|
|
|
97
98
|
3. **Strategic Scope Detection** (before detailed analysis):
|
|
98
99
|
|
|
@@ -178,7 +179,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
|
|
|
178
179
|
|
|
179
180
|
---
|
|
180
181
|
|
|
181
|
-
## Agent Transparency (v4.
|
|
182
|
+
## Agent Transparency (v4.4)
|
|
182
183
|
|
|
183
184
|
### Quality Output Format
|
|
184
185
|
{{INCLUDE:agent-protocols/quality-output.md}}
|
|
@@ -91,6 +91,7 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
|
|
|
91
91
|
- **migration**: Version upgrades, porting code between frameworks
|
|
92
92
|
- **security-review**: Security audits, vulnerability checks
|
|
93
93
|
- **learning**: Conceptual understanding, tutorials, explanations
|
|
94
|
+
- **summarization**: Extracting requirements from conversations
|
|
94
95
|
|
|
95
96
|
3. **Quality Assessment** - Evaluate across 6 dimensions:
|
|
96
97
|
|
|
@@ -157,7 +158,7 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
|
|
|
157
158
|
|
|
158
159
|
---
|
|
159
160
|
|
|
160
|
-
## Agent Transparency (v4.
|
|
161
|
+
## Agent Transparency (v4.4)
|
|
161
162
|
|
|
162
163
|
### Quality Output Format
|
|
163
164
|
{{INCLUDE:agent-protocols/quality-output.md}}
|