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
|
@@ -21,11 +21,49 @@ import { SuccessCriteriaEnforcer } from './patterns/success-criteria-enforcer.js
|
|
|
21
21
|
import { ErrorToleranceEnhancer } from './patterns/error-tolerance-enhancer.js';
|
|
22
22
|
import { PrerequisiteIdentifier } from './patterns/prerequisite-identifier.js';
|
|
23
23
|
import { DomainContextEnricher } from './patterns/domain-context-enricher.js';
|
|
24
|
+
// v4.3.2 PRD patterns
|
|
25
|
+
import { RequirementPrioritizer } from './patterns/requirement-prioritizer.js';
|
|
26
|
+
import { UserPersonaEnricher } from './patterns/user-persona-enricher.js';
|
|
27
|
+
import { SuccessMetricsEnforcer } from './patterns/success-metrics-enforcer.js';
|
|
28
|
+
import { DependencyIdentifier } from './patterns/dependency-identifier.js';
|
|
29
|
+
// v4.3.2 Conversational patterns
|
|
30
|
+
import { ConversationSummarizer } from './patterns/conversation-summarizer.js';
|
|
31
|
+
import { TopicCoherenceAnalyzer } from './patterns/topic-coherence-analyzer.js';
|
|
32
|
+
import { ImplicitRequirementExtractor } from './patterns/implicit-requirement-extractor.js';
|
|
24
33
|
export class PatternLibrary {
|
|
25
34
|
patterns = new Map();
|
|
35
|
+
config = null;
|
|
26
36
|
constructor() {
|
|
27
37
|
this.registerDefaultPatterns();
|
|
28
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* v4.4: Apply configuration settings to pattern library
|
|
41
|
+
* Allows enabling/disabling patterns and adjusting priorities via config
|
|
42
|
+
*/
|
|
43
|
+
applyConfig(config) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
// Apply priority overrides
|
|
46
|
+
if (config.patterns?.priorityOverrides) {
|
|
47
|
+
for (const [patternId, newPriority] of Object.entries(config.patterns.priorityOverrides)) {
|
|
48
|
+
const pattern = this.patterns.get(patternId);
|
|
49
|
+
if (pattern && newPriority >= 1 && newPriority <= 10) {
|
|
50
|
+
pattern.priority = newPriority;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* v4.4: Check if a pattern is disabled via config
|
|
57
|
+
*/
|
|
58
|
+
isPatternDisabled(patternId) {
|
|
59
|
+
return this.config?.patterns?.disabled?.includes(patternId) ?? false;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* v4.4: Get custom settings for a pattern
|
|
63
|
+
*/
|
|
64
|
+
getPatternSettings(patternId) {
|
|
65
|
+
return this.config?.patterns?.customSettings?.[patternId];
|
|
66
|
+
}
|
|
29
67
|
registerDefaultPatterns() {
|
|
30
68
|
// Register core patterns (available in fast & deep modes)
|
|
31
69
|
this.register(new ConcisenessFilter()); // HIGH - Remove verbosity
|
|
@@ -51,6 +89,15 @@ export class PatternLibrary {
|
|
|
51
89
|
this.register(new ErrorToleranceEnhancer()); // P5 - Add error handling (deep only)
|
|
52
90
|
this.register(new PrerequisiteIdentifier()); // P6 - Identify prerequisites (deep only)
|
|
53
91
|
this.register(new DomainContextEnricher()); // P5 - Add domain best practices (both modes)
|
|
92
|
+
// v4.3.2 PRD patterns
|
|
93
|
+
this.register(new RequirementPrioritizer()); // P7 - Separate must-have from nice-to-have
|
|
94
|
+
this.register(new UserPersonaEnricher()); // P6 - Add user context and personas
|
|
95
|
+
this.register(new SuccessMetricsEnforcer()); // P7 - Ensure measurable success criteria
|
|
96
|
+
this.register(new DependencyIdentifier()); // P5 - Identify technical/external dependencies
|
|
97
|
+
// v4.3.2 Conversational patterns
|
|
98
|
+
this.register(new ConversationSummarizer()); // P8 - Extract structured requirements
|
|
99
|
+
this.register(new TopicCoherenceAnalyzer()); // P6 - Detect topic shifts
|
|
100
|
+
this.register(new ImplicitRequirementExtractor()); // P7 - Surface implicit requirements
|
|
54
101
|
}
|
|
55
102
|
/**
|
|
56
103
|
* Register a new pattern
|
|
@@ -89,6 +136,10 @@ export class PatternLibrary {
|
|
|
89
136
|
selectPatterns(intent, mode) {
|
|
90
137
|
const applicablePatterns = [];
|
|
91
138
|
for (const pattern of this.patterns.values()) {
|
|
139
|
+
// v4.4: Check if pattern is disabled via config
|
|
140
|
+
if (this.isPatternDisabled(pattern.id)) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
92
143
|
// Check mode compatibility
|
|
93
144
|
if (pattern.mode !== 'both' && pattern.mode !== mode) {
|
|
94
145
|
continue;
|
|
@@ -102,6 +153,123 @@ export class PatternLibrary {
|
|
|
102
153
|
// Sort by priority (highest first)
|
|
103
154
|
return applicablePatterns.sort((a, b) => b.priority - a.priority);
|
|
104
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* v4.3.2: Select patterns for specific mode with phase-awareness
|
|
158
|
+
* Maps PRD and conversational modes to appropriate base modes and patterns
|
|
159
|
+
*/
|
|
160
|
+
selectPatternsForMode(mode, intent, phase) {
|
|
161
|
+
// Map PRD/conversational modes to base modes for pattern selection
|
|
162
|
+
const baseMode = this.mapToBaseMode(mode, phase);
|
|
163
|
+
const applicablePatterns = [];
|
|
164
|
+
for (const pattern of this.patterns.values()) {
|
|
165
|
+
// v4.4: Check if pattern is disabled via config
|
|
166
|
+
if (this.isPatternDisabled(pattern.id)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
// Check mode compatibility (use mapped base mode)
|
|
170
|
+
if (pattern.mode !== 'both' && pattern.mode !== baseMode) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// Check intent compatibility
|
|
174
|
+
if (!pattern.applicableIntents.includes(intent.primaryIntent)) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
// Phase-specific filtering for PRD mode
|
|
178
|
+
if (mode === 'prd' && phase) {
|
|
179
|
+
if (!this.isPatternApplicableForPRDPhase(pattern, phase)) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Phase-specific filtering for conversational mode
|
|
184
|
+
if (mode === 'conversational' && phase) {
|
|
185
|
+
if (!this.isPatternApplicableForConversationalPhase(pattern, phase)) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
applicablePatterns.push(pattern);
|
|
190
|
+
}
|
|
191
|
+
// Sort by priority (highest first)
|
|
192
|
+
return applicablePatterns.sort((a, b) => b.priority - a.priority);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Map extended modes to base modes for pattern compatibility
|
|
196
|
+
*/
|
|
197
|
+
mapToBaseMode(mode, phase) {
|
|
198
|
+
switch (mode) {
|
|
199
|
+
case 'prd':
|
|
200
|
+
// PRD uses deep mode for output generation, fast for validation
|
|
201
|
+
return phase === 'question-validation' ? 'fast' : 'deep';
|
|
202
|
+
case 'conversational':
|
|
203
|
+
// Conversational uses fast mode for tracking, deep for summarization
|
|
204
|
+
return phase === 'summarization' ? 'deep' : 'fast';
|
|
205
|
+
case 'fast':
|
|
206
|
+
case 'deep':
|
|
207
|
+
default:
|
|
208
|
+
return mode;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Check if pattern is applicable for PRD phase
|
|
213
|
+
*/
|
|
214
|
+
isPatternApplicableForPRDPhase(pattern, phase) {
|
|
215
|
+
// Patterns for question validation (lightweight, clarity-focused)
|
|
216
|
+
const questionValidationPatterns = [
|
|
217
|
+
'ambiguity-detector',
|
|
218
|
+
'completeness-validator',
|
|
219
|
+
'objective-clarifier',
|
|
220
|
+
];
|
|
221
|
+
// Patterns for output generation (comprehensive)
|
|
222
|
+
const outputGenerationPatterns = [
|
|
223
|
+
'prd-structure-enforcer',
|
|
224
|
+
'structure-organizer',
|
|
225
|
+
'success-criteria-enforcer',
|
|
226
|
+
'scope-definer',
|
|
227
|
+
'edge-case-identifier',
|
|
228
|
+
'assumption-explicitizer',
|
|
229
|
+
'technical-context-enricher',
|
|
230
|
+
'domain-context-enricher',
|
|
231
|
+
// v4.3.2 PRD patterns will be added here
|
|
232
|
+
'requirement-prioritizer',
|
|
233
|
+
'user-persona-enricher',
|
|
234
|
+
'success-metrics-enforcer',
|
|
235
|
+
'dependency-identifier',
|
|
236
|
+
];
|
|
237
|
+
if (phase === 'question-validation') {
|
|
238
|
+
return questionValidationPatterns.includes(pattern.id);
|
|
239
|
+
}
|
|
240
|
+
if (phase === 'output-generation') {
|
|
241
|
+
return outputGenerationPatterns.includes(pattern.id);
|
|
242
|
+
}
|
|
243
|
+
return true; // Default: allow pattern
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Check if pattern is applicable for conversational phase
|
|
247
|
+
*/
|
|
248
|
+
isPatternApplicableForConversationalPhase(pattern, phase) {
|
|
249
|
+
// Patterns for conversation tracking (minimal, non-intrusive)
|
|
250
|
+
const conversationTrackingPatterns = ['ambiguity-detector', 'completeness-validator'];
|
|
251
|
+
// Patterns for summarization (comprehensive extraction)
|
|
252
|
+
const summarizationPatterns = [
|
|
253
|
+
'structure-organizer',
|
|
254
|
+
'completeness-validator',
|
|
255
|
+
'success-criteria-enforcer',
|
|
256
|
+
'edge-case-identifier',
|
|
257
|
+
'actionability-enhancer',
|
|
258
|
+
'technical-context-enricher',
|
|
259
|
+
'domain-context-enricher',
|
|
260
|
+
// v4.3.2 Conversational patterns will be added here
|
|
261
|
+
'conversation-summarizer',
|
|
262
|
+
'topic-coherence-analyzer',
|
|
263
|
+
'implicit-requirement-extractor',
|
|
264
|
+
];
|
|
265
|
+
if (phase === 'conversation-tracking') {
|
|
266
|
+
return conversationTrackingPatterns.includes(pattern.id);
|
|
267
|
+
}
|
|
268
|
+
if (phase === 'summarization') {
|
|
269
|
+
return summarizationPatterns.includes(pattern.id);
|
|
270
|
+
}
|
|
271
|
+
return true; // Default: allow pattern
|
|
272
|
+
}
|
|
105
273
|
/**
|
|
106
274
|
* Get all registered patterns
|
|
107
275
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* v4.4 Conversational Pattern: ConversationSummarizer
|
|
5
|
+
*
|
|
6
|
+
* Extracts structured requirements from conversational messages.
|
|
7
|
+
* Organizes free-form discussion into actionable requirements.
|
|
8
|
+
* Enhanced with expanded marker detection and confidence scoring.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ConversationSummarizer extends BasePattern {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
applicableIntents: PromptIntent[];
|
|
15
|
+
mode: OptimizationMode | 'both';
|
|
16
|
+
priority: number;
|
|
17
|
+
private readonly conversationalMarkers;
|
|
18
|
+
apply(prompt: string, _context: PatternContext): PatternResult;
|
|
19
|
+
private isAlreadyStructured;
|
|
20
|
+
private isConversationalContent;
|
|
21
|
+
private calculateConfidence;
|
|
22
|
+
private extractAndStructure;
|
|
23
|
+
private extractRequirements;
|
|
24
|
+
private extractConstraints;
|
|
25
|
+
private extractGoals;
|
|
26
|
+
private cleanRequirement;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=conversation-summarizer.d.ts.map
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.4 Conversational Pattern: ConversationSummarizer
|
|
4
|
+
*
|
|
5
|
+
* Extracts structured requirements from conversational messages.
|
|
6
|
+
* Organizes free-form discussion into actionable requirements.
|
|
7
|
+
* Enhanced with expanded marker detection and confidence scoring.
|
|
8
|
+
*/
|
|
9
|
+
export class ConversationSummarizer extends BasePattern {
|
|
10
|
+
id = 'conversation-summarizer';
|
|
11
|
+
name = 'ConversationSummarizer';
|
|
12
|
+
description = 'Extracts structured requirements from messages';
|
|
13
|
+
applicableIntents = ['summarization', 'planning', 'prd-generation'];
|
|
14
|
+
mode = 'deep';
|
|
15
|
+
priority = 8;
|
|
16
|
+
// Expanded conversational markers (~30 markers)
|
|
17
|
+
conversationalMarkers = [
|
|
18
|
+
// Intent expressions
|
|
19
|
+
'i want',
|
|
20
|
+
'i need',
|
|
21
|
+
'we need',
|
|
22
|
+
'we want',
|
|
23
|
+
'i would like',
|
|
24
|
+
'we would like',
|
|
25
|
+
'would like to',
|
|
26
|
+
'should be able to',
|
|
27
|
+
'needs to',
|
|
28
|
+
// Thinking/exploring
|
|
29
|
+
'thinking about',
|
|
30
|
+
'maybe we could',
|
|
31
|
+
'what if',
|
|
32
|
+
'how about',
|
|
33
|
+
'perhaps we',
|
|
34
|
+
'considering',
|
|
35
|
+
'wondering if',
|
|
36
|
+
// Conversational connectors
|
|
37
|
+
"let's",
|
|
38
|
+
'let me',
|
|
39
|
+
'also',
|
|
40
|
+
'and then',
|
|
41
|
+
'plus',
|
|
42
|
+
'another thing',
|
|
43
|
+
'oh and',
|
|
44
|
+
'by the way',
|
|
45
|
+
// Informal markers
|
|
46
|
+
'basically',
|
|
47
|
+
'so basically',
|
|
48
|
+
'essentially',
|
|
49
|
+
'kind of like',
|
|
50
|
+
'sort of',
|
|
51
|
+
'something like',
|
|
52
|
+
// Collaborative
|
|
53
|
+
'can we',
|
|
54
|
+
'could we',
|
|
55
|
+
'shall we',
|
|
56
|
+
];
|
|
57
|
+
apply(prompt, _context) {
|
|
58
|
+
// Check if content is already well-structured
|
|
59
|
+
if (this.isAlreadyStructured(prompt)) {
|
|
60
|
+
return {
|
|
61
|
+
enhancedPrompt: prompt,
|
|
62
|
+
improvement: {
|
|
63
|
+
dimension: 'structure',
|
|
64
|
+
description: 'Content already well-structured',
|
|
65
|
+
impact: 'low',
|
|
66
|
+
},
|
|
67
|
+
applied: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Check if this looks like conversational content
|
|
71
|
+
if (!this.isConversationalContent(prompt)) {
|
|
72
|
+
return {
|
|
73
|
+
enhancedPrompt: prompt,
|
|
74
|
+
improvement: {
|
|
75
|
+
dimension: 'structure',
|
|
76
|
+
description: 'Not conversational content',
|
|
77
|
+
impact: 'low',
|
|
78
|
+
},
|
|
79
|
+
applied: false,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Extract and structure requirements
|
|
83
|
+
const enhanced = this.extractAndStructure(prompt);
|
|
84
|
+
return {
|
|
85
|
+
enhancedPrompt: enhanced,
|
|
86
|
+
improvement: {
|
|
87
|
+
dimension: 'structure',
|
|
88
|
+
description: 'Extracted structured requirements from conversation',
|
|
89
|
+
impact: 'high',
|
|
90
|
+
},
|
|
91
|
+
applied: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
isAlreadyStructured(prompt) {
|
|
95
|
+
// Check for markdown structure
|
|
96
|
+
const structureIndicators = [
|
|
97
|
+
'##',
|
|
98
|
+
'###',
|
|
99
|
+
'**Requirements:**',
|
|
100
|
+
'**Features:**',
|
|
101
|
+
'- [ ]',
|
|
102
|
+
'1.',
|
|
103
|
+
'2.',
|
|
104
|
+
'3.',
|
|
105
|
+
];
|
|
106
|
+
const matches = structureIndicators.filter((indicator) => prompt.includes(indicator));
|
|
107
|
+
return matches.length >= 3;
|
|
108
|
+
}
|
|
109
|
+
isConversationalContent(prompt) {
|
|
110
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
111
|
+
const matches = this.conversationalMarkers.filter((marker) => lowerPrompt.includes(marker));
|
|
112
|
+
// Also check for lack of structure (sentences without bullet points)
|
|
113
|
+
const sentences = this.extractSentences(prompt);
|
|
114
|
+
const hasBulletPoints = prompt.includes('- ') || prompt.includes('* ');
|
|
115
|
+
// More lenient threshold with expanded markers
|
|
116
|
+
return matches.length >= 2 || (sentences.length > 3 && !hasBulletPoints);
|
|
117
|
+
}
|
|
118
|
+
calculateConfidence(requirements, goals, constraints) {
|
|
119
|
+
// Calculate extraction confidence based on what was found
|
|
120
|
+
const hasRequirements = requirements.length > 0;
|
|
121
|
+
const hasGoals = goals.length > 0;
|
|
122
|
+
const hasConstraints = constraints.length > 0;
|
|
123
|
+
let confidence = 50; // Base confidence for conversational detection
|
|
124
|
+
if (hasRequirements)
|
|
125
|
+
confidence += 20;
|
|
126
|
+
if (hasGoals)
|
|
127
|
+
confidence += 15;
|
|
128
|
+
if (hasConstraints)
|
|
129
|
+
confidence += 15;
|
|
130
|
+
return Math.min(confidence, 100);
|
|
131
|
+
}
|
|
132
|
+
extractAndStructure(prompt) {
|
|
133
|
+
const requirements = this.extractRequirements(prompt);
|
|
134
|
+
const constraints = this.extractConstraints(prompt);
|
|
135
|
+
const goals = this.extractGoals(prompt);
|
|
136
|
+
const confidence = this.calculateConfidence(requirements, goals, constraints);
|
|
137
|
+
let structured = '### Extracted Requirements\n\n';
|
|
138
|
+
structured += `*Extraction confidence: ${confidence}%*\n\n`;
|
|
139
|
+
if (goals.length > 0) {
|
|
140
|
+
structured += '**Goals:**\n';
|
|
141
|
+
structured += goals.map((g) => `- ${g}`).join('\n');
|
|
142
|
+
structured += '\n\n';
|
|
143
|
+
}
|
|
144
|
+
if (requirements.length > 0) {
|
|
145
|
+
structured += '**Requirements:**\n';
|
|
146
|
+
structured += requirements.map((r) => `- ${r}`).join('\n');
|
|
147
|
+
structured += '\n\n';
|
|
148
|
+
}
|
|
149
|
+
if (constraints.length > 0) {
|
|
150
|
+
structured += '**Constraints:**\n';
|
|
151
|
+
structured += constraints.map((c) => `- ${c}`).join('\n');
|
|
152
|
+
structured += '\n\n';
|
|
153
|
+
}
|
|
154
|
+
// Add verification prompt if confidence is below 80%
|
|
155
|
+
if (confidence < 80) {
|
|
156
|
+
structured +=
|
|
157
|
+
'> **Note:** Please verify these extracted requirements are complete and accurate.\n\n';
|
|
158
|
+
}
|
|
159
|
+
structured += '---\n\n**Original Context:**\n' + prompt;
|
|
160
|
+
return structured;
|
|
161
|
+
}
|
|
162
|
+
extractRequirements(prompt) {
|
|
163
|
+
const requirements = [];
|
|
164
|
+
const sentences = this.extractSentences(prompt);
|
|
165
|
+
// Expanded requirement patterns
|
|
166
|
+
const requirementPatterns = [
|
|
167
|
+
/(?:i |we )?(?:need|want|should|must|require)\s+(?:to\s+)?(.+)/i,
|
|
168
|
+
/(?:should be able to|needs to|has to|have to)\s+(.+)/i,
|
|
169
|
+
/(?:feature|functionality|capability):\s*(.+)/i,
|
|
170
|
+
/(?:it should|it must|it needs to)\s+(.+)/i,
|
|
171
|
+
/(?:users? (?:can|should|will|must))\s+(.+)/i,
|
|
172
|
+
/(?:the system (?:should|must|will))\s+(.+)/i,
|
|
173
|
+
/(?:support(?:s|ing)?)\s+(.+)/i,
|
|
174
|
+
/(?:provide(?:s)?|enable(?:s)?|allow(?:s)?)\s+(.+)/i,
|
|
175
|
+
];
|
|
176
|
+
for (const sentence of sentences) {
|
|
177
|
+
for (const pattern of requirementPatterns) {
|
|
178
|
+
const match = sentence.match(pattern);
|
|
179
|
+
if (match && match[1]) {
|
|
180
|
+
const req = this.cleanRequirement(match[1]);
|
|
181
|
+
if (req && !requirements.includes(req)) {
|
|
182
|
+
requirements.push(req);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return requirements.slice(0, 10); // Max 10 requirements
|
|
188
|
+
}
|
|
189
|
+
extractConstraints(prompt) {
|
|
190
|
+
const constraints = [];
|
|
191
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
192
|
+
const constraintPatterns = [
|
|
193
|
+
/(?:can't|cannot|shouldn't|must not)\s+(.+)/gi,
|
|
194
|
+
/(?:limited to|restricted to|only)\s+(.+)/gi,
|
|
195
|
+
/(?:within|budget|deadline|timeline):\s*(.+)/gi,
|
|
196
|
+
/(?:no more than|at most|maximum)\s+(.+)/gi,
|
|
197
|
+
];
|
|
198
|
+
for (const pattern of constraintPatterns) {
|
|
199
|
+
const matches = prompt.matchAll(pattern);
|
|
200
|
+
for (const match of matches) {
|
|
201
|
+
if (match[1]) {
|
|
202
|
+
const constraint = this.cleanRequirement(match[1]);
|
|
203
|
+
if (constraint && !constraints.includes(constraint)) {
|
|
204
|
+
constraints.push(constraint);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Common constraint keywords
|
|
210
|
+
if (lowerPrompt.includes('performance')) {
|
|
211
|
+
constraints.push('Performance requirements to be defined');
|
|
212
|
+
}
|
|
213
|
+
if (lowerPrompt.includes('security')) {
|
|
214
|
+
constraints.push('Security requirements to be defined');
|
|
215
|
+
}
|
|
216
|
+
if (lowerPrompt.includes('mobile') && lowerPrompt.includes('desktop')) {
|
|
217
|
+
constraints.push('Must work on both mobile and desktop');
|
|
218
|
+
}
|
|
219
|
+
return constraints.slice(0, 5); // Max 5 constraints
|
|
220
|
+
}
|
|
221
|
+
extractGoals(prompt) {
|
|
222
|
+
const goals = [];
|
|
223
|
+
// Expanded goal patterns
|
|
224
|
+
const goalPatterns = [
|
|
225
|
+
/(?:goal is to|aim(?:ing)? to|objective is to)\s+(.+)/gi,
|
|
226
|
+
/(?:trying to|looking to|hoping to|want(?:ing)? to)\s+(.+)/gi,
|
|
227
|
+
/(?:so that|in order to|to achieve)\s+(.+)/gi,
|
|
228
|
+
/(?:the purpose is|main purpose|key purpose)\s+(.+)/gi,
|
|
229
|
+
/(?:ultimately|end goal|final goal|main goal)\s+(.+)/gi,
|
|
230
|
+
/(?:we're building this to|this will help)\s+(.+)/gi,
|
|
231
|
+
];
|
|
232
|
+
for (const pattern of goalPatterns) {
|
|
233
|
+
const matches = prompt.matchAll(pattern);
|
|
234
|
+
for (const match of matches) {
|
|
235
|
+
if (match[1]) {
|
|
236
|
+
const goal = this.cleanRequirement(match[1]);
|
|
237
|
+
if (goal && !goals.includes(goal)) {
|
|
238
|
+
goals.push(goal);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return goals.slice(0, 3); // Max 3 goals
|
|
244
|
+
}
|
|
245
|
+
cleanRequirement(text) {
|
|
246
|
+
return text
|
|
247
|
+
.trim()
|
|
248
|
+
.replace(/[.!?,;:]+$/, '')
|
|
249
|
+
.replace(/\s+/g, ' ')
|
|
250
|
+
.substring(0, 200);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=conversation-summarizer.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* v4.3.2 PRD Pattern: DependencyIdentifier
|
|
5
|
+
*
|
|
6
|
+
* Identifies technical and external dependencies in PRD content.
|
|
7
|
+
* Helps surface hidden requirements and blockers.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DependencyIdentifier 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 hasDependencySection;
|
|
18
|
+
private identifyDependencies;
|
|
19
|
+
private addDependencySection;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=dependency-identifier.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.3.2 PRD Pattern: DependencyIdentifier
|
|
4
|
+
*
|
|
5
|
+
* Identifies technical and external dependencies in PRD content.
|
|
6
|
+
* Helps surface hidden requirements and blockers.
|
|
7
|
+
*/
|
|
8
|
+
export class DependencyIdentifier extends BasePattern {
|
|
9
|
+
id = 'dependency-identifier';
|
|
10
|
+
name = 'DependencyIdentifier';
|
|
11
|
+
description = 'Identifies technical and external dependencies';
|
|
12
|
+
applicableIntents = ['prd-generation', 'planning', 'migration'];
|
|
13
|
+
mode = 'deep';
|
|
14
|
+
priority = 5;
|
|
15
|
+
apply(prompt, _context) {
|
|
16
|
+
// Check if dependencies are already documented
|
|
17
|
+
if (this.hasDependencySection(prompt)) {
|
|
18
|
+
return {
|
|
19
|
+
enhancedPrompt: prompt,
|
|
20
|
+
improvement: {
|
|
21
|
+
dimension: 'completeness',
|
|
22
|
+
description: 'Dependencies already documented',
|
|
23
|
+
impact: 'low',
|
|
24
|
+
},
|
|
25
|
+
applied: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Check if this content has identifiable dependencies
|
|
29
|
+
const dependencies = this.identifyDependencies(prompt);
|
|
30
|
+
if (dependencies.length === 0) {
|
|
31
|
+
return {
|
|
32
|
+
enhancedPrompt: prompt,
|
|
33
|
+
improvement: {
|
|
34
|
+
dimension: 'completeness',
|
|
35
|
+
description: 'No clear dependencies identified',
|
|
36
|
+
impact: 'low',
|
|
37
|
+
},
|
|
38
|
+
applied: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Add dependency section
|
|
42
|
+
const enhanced = this.addDependencySection(prompt, dependencies);
|
|
43
|
+
return {
|
|
44
|
+
enhancedPrompt: enhanced,
|
|
45
|
+
improvement: {
|
|
46
|
+
dimension: 'completeness',
|
|
47
|
+
description: `Identified ${dependencies.length} dependencies (technical/external)`,
|
|
48
|
+
impact: 'medium',
|
|
49
|
+
},
|
|
50
|
+
applied: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
hasDependencySection(prompt) {
|
|
54
|
+
const dependencyKeywords = [
|
|
55
|
+
'dependencies',
|
|
56
|
+
'depends on',
|
|
57
|
+
'prerequisite',
|
|
58
|
+
'requires',
|
|
59
|
+
'blocked by',
|
|
60
|
+
'blocker',
|
|
61
|
+
'external service',
|
|
62
|
+
'third-party',
|
|
63
|
+
'integration with',
|
|
64
|
+
];
|
|
65
|
+
return this.hasSection(prompt, dependencyKeywords);
|
|
66
|
+
}
|
|
67
|
+
identifyDependencies(prompt) {
|
|
68
|
+
const dependencies = [];
|
|
69
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
70
|
+
// Technical dependencies
|
|
71
|
+
if (lowerPrompt.includes('api')) {
|
|
72
|
+
dependencies.push('API availability and documentation');
|
|
73
|
+
}
|
|
74
|
+
if (lowerPrompt.includes('database') || lowerPrompt.includes('db')) {
|
|
75
|
+
dependencies.push('Database schema and migrations');
|
|
76
|
+
}
|
|
77
|
+
if (lowerPrompt.includes('authentication') || lowerPrompt.includes('auth')) {
|
|
78
|
+
dependencies.push('Authentication system integration');
|
|
79
|
+
}
|
|
80
|
+
if (lowerPrompt.includes('payment') ||
|
|
81
|
+
lowerPrompt.includes('stripe') ||
|
|
82
|
+
lowerPrompt.includes('billing')) {
|
|
83
|
+
dependencies.push('Payment provider integration');
|
|
84
|
+
}
|
|
85
|
+
if (lowerPrompt.includes('email') || lowerPrompt.includes('notification')) {
|
|
86
|
+
dependencies.push('Email/notification service');
|
|
87
|
+
}
|
|
88
|
+
if (lowerPrompt.includes('storage') ||
|
|
89
|
+
lowerPrompt.includes('s3') ||
|
|
90
|
+
lowerPrompt.includes('file')) {
|
|
91
|
+
dependencies.push('File storage service');
|
|
92
|
+
}
|
|
93
|
+
if (lowerPrompt.includes('search') || lowerPrompt.includes('elasticsearch')) {
|
|
94
|
+
dependencies.push('Search infrastructure');
|
|
95
|
+
}
|
|
96
|
+
if (lowerPrompt.includes('analytics') || lowerPrompt.includes('tracking')) {
|
|
97
|
+
dependencies.push('Analytics platform');
|
|
98
|
+
}
|
|
99
|
+
if (lowerPrompt.includes('ci/cd') || lowerPrompt.includes('deploy')) {
|
|
100
|
+
dependencies.push('CI/CD pipeline');
|
|
101
|
+
}
|
|
102
|
+
if (lowerPrompt.includes('cache') || lowerPrompt.includes('redis')) {
|
|
103
|
+
dependencies.push('Caching infrastructure');
|
|
104
|
+
}
|
|
105
|
+
// External dependencies
|
|
106
|
+
if (lowerPrompt.includes('third-party') || lowerPrompt.includes('external')) {
|
|
107
|
+
dependencies.push('Third-party service availability');
|
|
108
|
+
}
|
|
109
|
+
if (lowerPrompt.includes('team') || lowerPrompt.includes('collaboration')) {
|
|
110
|
+
dependencies.push('Cross-team coordination');
|
|
111
|
+
}
|
|
112
|
+
if (lowerPrompt.includes('approval') || lowerPrompt.includes('sign-off')) {
|
|
113
|
+
dependencies.push('Stakeholder approvals');
|
|
114
|
+
}
|
|
115
|
+
if (lowerPrompt.includes('legal') || lowerPrompt.includes('compliance')) {
|
|
116
|
+
dependencies.push('Legal/compliance review');
|
|
117
|
+
}
|
|
118
|
+
if (lowerPrompt.includes('design') ||
|
|
119
|
+
lowerPrompt.includes('ui') ||
|
|
120
|
+
lowerPrompt.includes('ux')) {
|
|
121
|
+
dependencies.push('Design specifications');
|
|
122
|
+
}
|
|
123
|
+
return dependencies;
|
|
124
|
+
}
|
|
125
|
+
addDependencySection(prompt, dependencies) {
|
|
126
|
+
// Categorize dependencies
|
|
127
|
+
const technical = dependencies.filter((d) => d.includes('API') ||
|
|
128
|
+
d.includes('Database') ||
|
|
129
|
+
d.includes('Authentication') ||
|
|
130
|
+
d.includes('service') ||
|
|
131
|
+
d.includes('infrastructure') ||
|
|
132
|
+
d.includes('pipeline'));
|
|
133
|
+
const external = dependencies.filter((d) => !technical.includes(d));
|
|
134
|
+
let section = '\n\n### Dependencies\n';
|
|
135
|
+
if (technical.length > 0) {
|
|
136
|
+
section += '**Technical Dependencies:**\n';
|
|
137
|
+
section += technical.map((d) => `- ${d}`).join('\n');
|
|
138
|
+
section += '\n\n';
|
|
139
|
+
}
|
|
140
|
+
if (external.length > 0) {
|
|
141
|
+
section += '**External Dependencies:**\n';
|
|
142
|
+
section += external.map((d) => `- ${d}`).join('\n');
|
|
143
|
+
section += '\n';
|
|
144
|
+
}
|
|
145
|
+
section += '\n**Dependency Status:** [Track status of each dependency]';
|
|
146
|
+
return prompt + section;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=dependency-identifier.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.4 Conversational Pattern: ImplicitRequirementExtractor
|
|
5
|
+
*
|
|
6
|
+
* Surfaces requirements mentioned indirectly in conversations.
|
|
7
|
+
* Identifies hidden assumptions and unstated needs.
|
|
8
|
+
* Enhanced with more detection patterns and categorization.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ImplicitRequirementExtractor extends BasePattern {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
applicableIntents: PromptIntent[];
|
|
15
|
+
mode: OptimizationMode | 'both';
|
|
16
|
+
priority: number;
|
|
17
|
+
private readonly implicitPatterns;
|
|
18
|
+
apply(prompt: string, _context: PatternContext): PatternResult;
|
|
19
|
+
private extractImplicitRequirements;
|
|
20
|
+
private addImplicitRequirementsSection;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=implicit-requirement-extractor.d.ts.map
|