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,236 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.4 Conversational Pattern: ImplicitRequirementExtractor
|
|
4
|
+
*
|
|
5
|
+
* Surfaces requirements mentioned indirectly in conversations.
|
|
6
|
+
* Identifies hidden assumptions and unstated needs.
|
|
7
|
+
* Enhanced with more detection patterns and categorization.
|
|
8
|
+
*/
|
|
9
|
+
export class ImplicitRequirementExtractor extends BasePattern {
|
|
10
|
+
id = 'implicit-requirement-extractor';
|
|
11
|
+
name = 'ImplicitRequirementExtractor';
|
|
12
|
+
description = 'Surfaces requirements mentioned indirectly';
|
|
13
|
+
applicableIntents = ['summarization', 'planning', 'prd-generation'];
|
|
14
|
+
mode = 'deep';
|
|
15
|
+
priority = 7;
|
|
16
|
+
// Categories for implicit requirements
|
|
17
|
+
implicitPatterns = [
|
|
18
|
+
// Infrastructure requirements
|
|
19
|
+
{
|
|
20
|
+
check: (p) => p.includes('mobile'),
|
|
21
|
+
requirement: 'Mobile-responsive design required',
|
|
22
|
+
category: 'infrastructure',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
check: (p) => p.includes('real-time') || p.includes('realtime'),
|
|
26
|
+
requirement: 'Real-time updates infrastructure needed',
|
|
27
|
+
category: 'infrastructure',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
check: (p) => p.includes('scale') || p.includes('thousands') || p.includes('millions'),
|
|
31
|
+
requirement: 'Scalability architecture required',
|
|
32
|
+
category: 'infrastructure',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
check: (p) => p.includes('offline') || p.includes('without internet'),
|
|
36
|
+
requirement: 'Offline-capable architecture needed',
|
|
37
|
+
category: 'infrastructure',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
check: (p) => p.includes('multi-tenant') || p.includes('multiple organizations'),
|
|
41
|
+
requirement: 'Multi-tenancy support required',
|
|
42
|
+
category: 'infrastructure',
|
|
43
|
+
},
|
|
44
|
+
// Security requirements
|
|
45
|
+
{
|
|
46
|
+
check: (p) => p.includes('secure') || p.includes('security'),
|
|
47
|
+
requirement: 'Security audit and compliance requirements',
|
|
48
|
+
category: 'security',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
check: (p) => p.includes('gdpr') || p.includes('privacy') || p.includes('compliant'),
|
|
52
|
+
requirement: 'Data privacy and compliance infrastructure',
|
|
53
|
+
category: 'security',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
check: (p) => p.includes('encrypt') || p.includes('sensitive'),
|
|
57
|
+
requirement: 'Data encryption requirements',
|
|
58
|
+
category: 'security',
|
|
59
|
+
},
|
|
60
|
+
// Performance requirements
|
|
61
|
+
{
|
|
62
|
+
check: (p) => p.includes('fast') || p.includes('quick'),
|
|
63
|
+
requirement: 'Performance optimization requirements',
|
|
64
|
+
category: 'performance',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
check: (p) => p.includes('responsive') || p.includes('instant'),
|
|
68
|
+
requirement: 'Low-latency response requirements',
|
|
69
|
+
category: 'performance',
|
|
70
|
+
},
|
|
71
|
+
// UX requirements
|
|
72
|
+
{
|
|
73
|
+
check: (p) => p.includes('easy') || p.includes('simple') || p.includes('intuitive'),
|
|
74
|
+
requirement: 'User experience priority (simplicity mentioned)',
|
|
75
|
+
category: 'ux',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
check: (p) => p.includes('accessible') || p.includes('a11y'),
|
|
79
|
+
requirement: 'Accessibility (WCAG) compliance required',
|
|
80
|
+
category: 'ux',
|
|
81
|
+
},
|
|
82
|
+
// Integration requirements
|
|
83
|
+
{
|
|
84
|
+
check: (p) => p.includes('notify') ||
|
|
85
|
+
p.includes('alert') ||
|
|
86
|
+
p.includes('email') ||
|
|
87
|
+
p.includes('notification'),
|
|
88
|
+
requirement: 'Notification system infrastructure',
|
|
89
|
+
category: 'integration',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
check: (p) => p.includes('search') || p.includes('find'),
|
|
93
|
+
requirement: 'Search functionality and indexing',
|
|
94
|
+
category: 'integration',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
check: (p) => p.includes('report') || p.includes('analytics') || p.includes('dashboard'),
|
|
98
|
+
requirement: 'Analytics and reporting infrastructure',
|
|
99
|
+
category: 'integration',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
check: (p) => p.includes('integrate') || p.includes('connect') || p.includes('sync'),
|
|
103
|
+
requirement: 'Integration APIs and webhooks',
|
|
104
|
+
category: 'integration',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
check: (p) => p.includes('import') || p.includes('export') || p.includes('csv'),
|
|
108
|
+
requirement: 'Data import/export functionality',
|
|
109
|
+
category: 'integration',
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
apply(prompt, _context) {
|
|
113
|
+
// Extract implicit requirements
|
|
114
|
+
const implicitReqs = this.extractImplicitRequirements(prompt);
|
|
115
|
+
// If no implicit requirements found, skip
|
|
116
|
+
if (implicitReqs.length === 0) {
|
|
117
|
+
return {
|
|
118
|
+
enhancedPrompt: prompt,
|
|
119
|
+
improvement: {
|
|
120
|
+
dimension: 'completeness',
|
|
121
|
+
description: 'No implicit requirements detected',
|
|
122
|
+
impact: 'low',
|
|
123
|
+
},
|
|
124
|
+
applied: false,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Add implicit requirements section
|
|
128
|
+
const enhanced = this.addImplicitRequirementsSection(prompt, implicitReqs);
|
|
129
|
+
return {
|
|
130
|
+
enhancedPrompt: enhanced,
|
|
131
|
+
improvement: {
|
|
132
|
+
dimension: 'completeness',
|
|
133
|
+
description: `Surfaced ${implicitReqs.length} implicit requirements`,
|
|
134
|
+
impact: 'medium',
|
|
135
|
+
},
|
|
136
|
+
applied: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
extractImplicitRequirements(prompt) {
|
|
140
|
+
const implicitReqs = [];
|
|
141
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
142
|
+
// Pattern 1: "like X" implies feature parity
|
|
143
|
+
const likePatterns = prompt.matchAll(/(?:like|similar to|same as)\s+([A-Za-z0-9\s]+)/gi);
|
|
144
|
+
for (const match of likePatterns) {
|
|
145
|
+
if (match[1]) {
|
|
146
|
+
implicitReqs.push({
|
|
147
|
+
requirement: `Feature parity with "${match[1].trim()}" (implied)`,
|
|
148
|
+
category: 'feature',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Use pattern-based detection
|
|
153
|
+
for (const pattern of this.implicitPatterns) {
|
|
154
|
+
if (pattern.check(lowerPrompt)) {
|
|
155
|
+
implicitReqs.push({
|
|
156
|
+
requirement: pattern.requirement,
|
|
157
|
+
category: pattern.category,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Pattern: User mentions imply auth/permissions
|
|
162
|
+
if ((lowerPrompt.includes('user') || lowerPrompt.includes('admin')) &&
|
|
163
|
+
!lowerPrompt.includes('authentication')) {
|
|
164
|
+
implicitReqs.push({
|
|
165
|
+
requirement: 'User authentication system (implied by user roles)',
|
|
166
|
+
category: 'security',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// Pattern: Data mentions imply storage
|
|
170
|
+
if ((lowerPrompt.includes('save') ||
|
|
171
|
+
lowerPrompt.includes('store') ||
|
|
172
|
+
lowerPrompt.includes('data')) &&
|
|
173
|
+
!lowerPrompt.includes('database')) {
|
|
174
|
+
implicitReqs.push({
|
|
175
|
+
requirement: 'Data persistence/storage (implied by data operations)',
|
|
176
|
+
category: 'infrastructure',
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// Pattern: "Always" or "never" implies validation rules
|
|
180
|
+
const alwaysNeverPatterns = prompt.matchAll(/(?:always|never|must always|must never)\s+([^.!?]+)/gi);
|
|
181
|
+
for (const match of alwaysNeverPatterns) {
|
|
182
|
+
if (match[1]) {
|
|
183
|
+
implicitReqs.push({
|
|
184
|
+
requirement: `Business rule: "${match[1].trim()}" (implied constraint)`,
|
|
185
|
+
category: 'business',
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Deduplicate by requirement text
|
|
190
|
+
const seen = new Set();
|
|
191
|
+
return implicitReqs
|
|
192
|
+
.filter((r) => {
|
|
193
|
+
if (seen.has(r.requirement))
|
|
194
|
+
return false;
|
|
195
|
+
seen.add(r.requirement);
|
|
196
|
+
return true;
|
|
197
|
+
})
|
|
198
|
+
.slice(0, 10); // Increased to 10
|
|
199
|
+
}
|
|
200
|
+
addImplicitRequirementsSection(prompt, implicitReqs) {
|
|
201
|
+
let section = '\n\n### Implicit Requirements (Inferred)\n';
|
|
202
|
+
section += '*The following requirements are implied by the discussion:*\n\n';
|
|
203
|
+
// Group by category for better organization
|
|
204
|
+
const byCategory = new Map();
|
|
205
|
+
for (const req of implicitReqs) {
|
|
206
|
+
const existing = byCategory.get(req.category) || [];
|
|
207
|
+
existing.push(req.requirement);
|
|
208
|
+
byCategory.set(req.category, existing);
|
|
209
|
+
}
|
|
210
|
+
// Format with category headers if multiple categories
|
|
211
|
+
if (byCategory.size > 2) {
|
|
212
|
+
const categoryLabels = {
|
|
213
|
+
infrastructure: '🏗️ Infrastructure',
|
|
214
|
+
security: '🔒 Security',
|
|
215
|
+
performance: '⚡ Performance',
|
|
216
|
+
ux: '✨ User Experience',
|
|
217
|
+
integration: '🔗 Integration',
|
|
218
|
+
feature: '📋 Feature',
|
|
219
|
+
business: '📊 Business Rules',
|
|
220
|
+
};
|
|
221
|
+
for (const [category, reqs] of byCategory) {
|
|
222
|
+
section += `**${categoryLabels[category] || category}:**\n`;
|
|
223
|
+
section += reqs.map((r) => `- ${r}`).join('\n');
|
|
224
|
+
section += '\n\n';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// Simple list for fewer categories
|
|
229
|
+
section += implicitReqs.map((r) => `- ${r.requirement}`).join('\n');
|
|
230
|
+
section += '\n\n';
|
|
231
|
+
}
|
|
232
|
+
section += '> **Note:** Please verify these inferred requirements are accurate.';
|
|
233
|
+
return prompt + section;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=implicit-requirement-extractor.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: RequirementPrioritizer
|
|
5
|
+
*
|
|
6
|
+
* Separates must-have from nice-to-have requirements in PRD content.
|
|
7
|
+
* Helps clarify priorities and MVP scope.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RequirementPrioritizer 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 hasFeatureContent;
|
|
18
|
+
private hasPrioritization;
|
|
19
|
+
private addPrioritization;
|
|
20
|
+
private extractFeatureSection;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=requirement-prioritizer.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.3.2 PRD Pattern: RequirementPrioritizer
|
|
4
|
+
*
|
|
5
|
+
* Separates must-have from nice-to-have requirements in PRD content.
|
|
6
|
+
* Helps clarify priorities and MVP scope.
|
|
7
|
+
*/
|
|
8
|
+
export class RequirementPrioritizer extends BasePattern {
|
|
9
|
+
id = 'requirement-prioritizer';
|
|
10
|
+
name = 'RequirementPrioritizer';
|
|
11
|
+
description = 'Separates must-have from nice-to-have requirements';
|
|
12
|
+
applicableIntents = ['prd-generation', 'planning'];
|
|
13
|
+
mode = 'deep';
|
|
14
|
+
priority = 7;
|
|
15
|
+
apply(prompt, _context) {
|
|
16
|
+
// Only apply to PRD-related content with features
|
|
17
|
+
if (!this.hasFeatureContent(prompt)) {
|
|
18
|
+
return {
|
|
19
|
+
enhancedPrompt: prompt,
|
|
20
|
+
improvement: {
|
|
21
|
+
dimension: 'structure',
|
|
22
|
+
description: 'No feature content to prioritize',
|
|
23
|
+
impact: 'low',
|
|
24
|
+
},
|
|
25
|
+
applied: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Check if prioritization already exists
|
|
29
|
+
if (this.hasPrioritization(prompt)) {
|
|
30
|
+
return {
|
|
31
|
+
enhancedPrompt: prompt,
|
|
32
|
+
improvement: {
|
|
33
|
+
dimension: 'structure',
|
|
34
|
+
description: 'Requirements already prioritized',
|
|
35
|
+
impact: 'low',
|
|
36
|
+
},
|
|
37
|
+
applied: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Add prioritization framework
|
|
41
|
+
const enhanced = this.addPrioritization(prompt);
|
|
42
|
+
return {
|
|
43
|
+
enhancedPrompt: enhanced,
|
|
44
|
+
improvement: {
|
|
45
|
+
dimension: 'structure',
|
|
46
|
+
description: 'Added requirement prioritization (must-have vs nice-to-have)',
|
|
47
|
+
impact: 'high',
|
|
48
|
+
},
|
|
49
|
+
applied: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasFeatureContent(prompt) {
|
|
53
|
+
const featureKeywords = [
|
|
54
|
+
'feature',
|
|
55
|
+
'requirement',
|
|
56
|
+
'functionality',
|
|
57
|
+
'capability',
|
|
58
|
+
'should',
|
|
59
|
+
'must',
|
|
60
|
+
'need',
|
|
61
|
+
'want',
|
|
62
|
+
'implement',
|
|
63
|
+
];
|
|
64
|
+
return this.hasSection(prompt, featureKeywords);
|
|
65
|
+
}
|
|
66
|
+
hasPrioritization(prompt) {
|
|
67
|
+
const priorityKeywords = [
|
|
68
|
+
'must-have',
|
|
69
|
+
'must have',
|
|
70
|
+
'nice-to-have',
|
|
71
|
+
'nice to have',
|
|
72
|
+
'p0',
|
|
73
|
+
'p1',
|
|
74
|
+
'p2',
|
|
75
|
+
'priority:',
|
|
76
|
+
'mvp',
|
|
77
|
+
'phase 1',
|
|
78
|
+
'phase 2',
|
|
79
|
+
'critical',
|
|
80
|
+
'optional',
|
|
81
|
+
];
|
|
82
|
+
return this.hasSection(prompt, priorityKeywords);
|
|
83
|
+
}
|
|
84
|
+
addPrioritization(prompt) {
|
|
85
|
+
// Look for feature sections and add prioritization guidance
|
|
86
|
+
const featureSection = this.extractFeatureSection(prompt);
|
|
87
|
+
if (!featureSection) {
|
|
88
|
+
// No clear feature section, add prioritization note
|
|
89
|
+
return (prompt +
|
|
90
|
+
'\n\n### Requirement Priorities\n' +
|
|
91
|
+
'**Must-Have (MVP):**\n- [Core features required for launch]\n\n' +
|
|
92
|
+
'**Nice-to-Have (Post-MVP):**\n- [Features to add after initial release]');
|
|
93
|
+
}
|
|
94
|
+
// Features exist but aren't prioritized - add framework
|
|
95
|
+
const priorityNote = '\n\n> **Priority Framework:** Consider categorizing features as:\n' +
|
|
96
|
+
'> - **Must-Have (P0):** Required for MVP, blocking issues\n' +
|
|
97
|
+
'> - **Should-Have (P1):** Important but not blocking\n' +
|
|
98
|
+
'> - **Nice-to-Have (P2):** Enhancements for future iterations';
|
|
99
|
+
return prompt + priorityNote;
|
|
100
|
+
}
|
|
101
|
+
extractFeatureSection(prompt) {
|
|
102
|
+
// Try to find feature-related sections
|
|
103
|
+
const featurePatterns = [
|
|
104
|
+
/features?:?\s*\n([\s\S]*?)(?=\n##|\n\*\*[A-Z]|$)/i,
|
|
105
|
+
/requirements?:?\s*\n([\s\S]*?)(?=\n##|\n\*\*[A-Z]|$)/i,
|
|
106
|
+
/what we(?:'re| are) building:?\s*\n([\s\S]*?)(?=\n##|\n\*\*[A-Z]|$)/i,
|
|
107
|
+
];
|
|
108
|
+
for (const pattern of featurePatterns) {
|
|
109
|
+
const match = prompt.match(pattern);
|
|
110
|
+
if (match) {
|
|
111
|
+
return match[1];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=requirement-prioritizer.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: SuccessMetricsEnforcer
|
|
5
|
+
*
|
|
6
|
+
* Ensures measurable success criteria exist in PRD content.
|
|
7
|
+
* Adds KPIs and metrics when missing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SuccessMetricsEnforcer 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 hasSuccessMetrics;
|
|
18
|
+
private needsMetrics;
|
|
19
|
+
private addSuccessMetrics;
|
|
20
|
+
private inferRelevantMetrics;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=success-metrics-enforcer.d.ts.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.3.2 PRD Pattern: SuccessMetricsEnforcer
|
|
4
|
+
*
|
|
5
|
+
* Ensures measurable success criteria exist in PRD content.
|
|
6
|
+
* Adds KPIs and metrics when missing.
|
|
7
|
+
*/
|
|
8
|
+
export class SuccessMetricsEnforcer extends BasePattern {
|
|
9
|
+
id = 'success-metrics-enforcer';
|
|
10
|
+
name = 'SuccessMetricsEnforcer';
|
|
11
|
+
description = 'Ensures measurable success criteria exist';
|
|
12
|
+
applicableIntents = ['prd-generation', 'planning'];
|
|
13
|
+
mode = 'deep';
|
|
14
|
+
priority = 7;
|
|
15
|
+
apply(prompt, _context) {
|
|
16
|
+
// Check if success metrics already exist
|
|
17
|
+
if (this.hasSuccessMetrics(prompt)) {
|
|
18
|
+
return {
|
|
19
|
+
enhancedPrompt: prompt,
|
|
20
|
+
improvement: {
|
|
21
|
+
dimension: 'completeness',
|
|
22
|
+
description: 'Success metrics already present',
|
|
23
|
+
impact: 'low',
|
|
24
|
+
},
|
|
25
|
+
applied: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Check if this is content that needs metrics
|
|
29
|
+
if (!this.needsMetrics(prompt)) {
|
|
30
|
+
return {
|
|
31
|
+
enhancedPrompt: prompt,
|
|
32
|
+
improvement: {
|
|
33
|
+
dimension: 'completeness',
|
|
34
|
+
description: 'Content does not require success metrics',
|
|
35
|
+
impact: 'low',
|
|
36
|
+
},
|
|
37
|
+
applied: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Add success metrics section
|
|
41
|
+
const enhanced = this.addSuccessMetrics(prompt);
|
|
42
|
+
return {
|
|
43
|
+
enhancedPrompt: enhanced,
|
|
44
|
+
improvement: {
|
|
45
|
+
dimension: 'completeness',
|
|
46
|
+
description: 'Added measurable success criteria and KPIs',
|
|
47
|
+
impact: 'high',
|
|
48
|
+
},
|
|
49
|
+
applied: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasSuccessMetrics(prompt) {
|
|
53
|
+
const metricsKeywords = [
|
|
54
|
+
'success metric',
|
|
55
|
+
'success criteria',
|
|
56
|
+
'kpi',
|
|
57
|
+
'measure success',
|
|
58
|
+
'acceptance criteria',
|
|
59
|
+
'% increase',
|
|
60
|
+
'% decrease',
|
|
61
|
+
'conversion rate',
|
|
62
|
+
'completion rate',
|
|
63
|
+
'response time',
|
|
64
|
+
'latency',
|
|
65
|
+
'uptime',
|
|
66
|
+
'sla',
|
|
67
|
+
'benchmark',
|
|
68
|
+
];
|
|
69
|
+
return this.hasSection(prompt, metricsKeywords);
|
|
70
|
+
}
|
|
71
|
+
needsMetrics(prompt) {
|
|
72
|
+
// PRD-like content that describes features
|
|
73
|
+
const prdKeywords = [
|
|
74
|
+
'feature',
|
|
75
|
+
'build',
|
|
76
|
+
'implement',
|
|
77
|
+
'goal',
|
|
78
|
+
'objective',
|
|
79
|
+
'product',
|
|
80
|
+
'launch',
|
|
81
|
+
'release',
|
|
82
|
+
];
|
|
83
|
+
return this.hasSection(prompt, prdKeywords);
|
|
84
|
+
}
|
|
85
|
+
addSuccessMetrics(prompt) {
|
|
86
|
+
// Detect the type of project to suggest relevant metrics
|
|
87
|
+
const metrics = this.inferRelevantMetrics(prompt);
|
|
88
|
+
const metricsSection = `\n\n### Success Metrics\n` +
|
|
89
|
+
`**Primary KPIs:**\n` +
|
|
90
|
+
metrics.map((m) => `- ${m}`).join('\n') +
|
|
91
|
+
`\n\n**Measurement Approach:**\n` +
|
|
92
|
+
`- Baseline: [Current state before implementation]\n` +
|
|
93
|
+
`- Target: [Specific, measurable goals]\n` +
|
|
94
|
+
`- Timeline: [When to measure success]`;
|
|
95
|
+
return prompt + metricsSection;
|
|
96
|
+
}
|
|
97
|
+
inferRelevantMetrics(prompt) {
|
|
98
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
99
|
+
const metrics = [];
|
|
100
|
+
// Performance-related
|
|
101
|
+
if (lowerPrompt.includes('performance') ||
|
|
102
|
+
lowerPrompt.includes('fast') ||
|
|
103
|
+
lowerPrompt.includes('speed')) {
|
|
104
|
+
metrics.push('Response time < [X]ms (p95)');
|
|
105
|
+
metrics.push('Page load time improvement by [X]%');
|
|
106
|
+
}
|
|
107
|
+
// User engagement
|
|
108
|
+
if (lowerPrompt.includes('user') ||
|
|
109
|
+
lowerPrompt.includes('engagement') ||
|
|
110
|
+
lowerPrompt.includes('retention')) {
|
|
111
|
+
metrics.push('User engagement increase by [X]%');
|
|
112
|
+
metrics.push('Task completion rate > [X]%');
|
|
113
|
+
}
|
|
114
|
+
// Conversion/business
|
|
115
|
+
if (lowerPrompt.includes('conversion') ||
|
|
116
|
+
lowerPrompt.includes('sales') ||
|
|
117
|
+
lowerPrompt.includes('revenue')) {
|
|
118
|
+
metrics.push('Conversion rate improvement by [X]%');
|
|
119
|
+
metrics.push('Revenue impact of $[X]');
|
|
120
|
+
}
|
|
121
|
+
// Technical quality
|
|
122
|
+
if (lowerPrompt.includes('quality') ||
|
|
123
|
+
lowerPrompt.includes('bug') ||
|
|
124
|
+
lowerPrompt.includes('error')) {
|
|
125
|
+
metrics.push('Error rate < [X]%');
|
|
126
|
+
metrics.push('Test coverage > [X]%');
|
|
127
|
+
}
|
|
128
|
+
// API/integration
|
|
129
|
+
if (lowerPrompt.includes('api') || lowerPrompt.includes('integration')) {
|
|
130
|
+
metrics.push('API availability > [X]%');
|
|
131
|
+
metrics.push('Integration success rate > [X]%');
|
|
132
|
+
}
|
|
133
|
+
// Default metrics if none matched
|
|
134
|
+
if (metrics.length === 0) {
|
|
135
|
+
metrics.push('[Define primary success metric]');
|
|
136
|
+
metrics.push('[Define secondary success metric]');
|
|
137
|
+
metrics.push('[Define timeline for measurement]');
|
|
138
|
+
}
|
|
139
|
+
return metrics.slice(0, 4); // Max 4 metrics
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=success-metrics-enforcer.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* v4.4 Conversational Pattern: TopicCoherenceAnalyzer
|
|
5
|
+
*
|
|
6
|
+
* Detects topic shifts and multi-topic conversations.
|
|
7
|
+
* Helps organize scattered discussions into coherent themes.
|
|
8
|
+
* Enhanced with expanded topic dictionary and better detection.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TopicCoherenceAnalyzer extends BasePattern {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
applicableIntents: PromptIntent[];
|
|
15
|
+
mode: OptimizationMode | 'both';
|
|
16
|
+
priority: number;
|
|
17
|
+
private readonly topicIndicators;
|
|
18
|
+
apply(prompt: string, _context: PatternContext): PatternResult;
|
|
19
|
+
private detectTopics;
|
|
20
|
+
private hasTopicOrganization;
|
|
21
|
+
private organizeByTopic;
|
|
22
|
+
private extractTopicContent;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=topic-coherence-analyzer.d.ts.map
|