clavix 4.3.2 → 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.
@@ -1,8 +1,23 @@
1
1
  import { BasePattern } from './patterns/base-pattern.js';
2
2
  import { IntentAnalysis, OptimizationMode, OptimizationPhase } from './types.js';
3
+ import { IntelligenceConfig } from '../../types/config.js';
3
4
  export declare class PatternLibrary {
4
5
  private patterns;
6
+ private config;
5
7
  constructor();
8
+ /**
9
+ * v4.4: Apply configuration settings to pattern library
10
+ * Allows enabling/disabling patterns and adjusting priorities via config
11
+ */
12
+ applyConfig(config: IntelligenceConfig): void;
13
+ /**
14
+ * v4.4: Check if a pattern is disabled via config
15
+ */
16
+ private isPatternDisabled;
17
+ /**
18
+ * v4.4: Get custom settings for a pattern
19
+ */
20
+ getPatternSettings(patternId: string): Record<string, unknown> | undefined;
6
21
  private registerDefaultPatterns;
7
22
  /**
8
23
  * Register a new pattern
@@ -32,9 +32,38 @@ import { TopicCoherenceAnalyzer } from './patterns/topic-coherence-analyzer.js';
32
32
  import { ImplicitRequirementExtractor } from './patterns/implicit-requirement-extractor.js';
33
33
  export class PatternLibrary {
34
34
  patterns = new Map();
35
+ config = null;
35
36
  constructor() {
36
37
  this.registerDefaultPatterns();
37
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
+ }
38
67
  registerDefaultPatterns() {
39
68
  // Register core patterns (available in fast & deep modes)
40
69
  this.register(new ConcisenessFilter()); // HIGH - Remove verbosity
@@ -107,6 +136,10 @@ export class PatternLibrary {
107
136
  selectPatterns(intent, mode) {
108
137
  const applicablePatterns = [];
109
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
+ }
110
143
  // Check mode compatibility
111
144
  if (pattern.mode !== 'both' && pattern.mode !== mode) {
112
145
  continue;
@@ -129,6 +162,10 @@ export class PatternLibrary {
129
162
  const baseMode = this.mapToBaseMode(mode, phase);
130
163
  const applicablePatterns = [];
131
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
+ }
132
169
  // Check mode compatibility (use mapped base mode)
133
170
  if (pattern.mode !== 'both' && pattern.mode !== baseMode) {
134
171
  continue;
@@ -1,10 +1,11 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
- * v4.3.2 Conversational Pattern: ConversationSummarizer
4
+ * v4.4 Conversational Pattern: ConversationSummarizer
5
5
  *
6
6
  * Extracts structured requirements from conversational messages.
7
7
  * Organizes free-form discussion into actionable requirements.
8
+ * Enhanced with expanded marker detection and confidence scoring.
8
9
  */
9
10
  export declare class ConversationSummarizer extends BasePattern {
10
11
  id: string;
@@ -13,9 +14,11 @@ export declare class ConversationSummarizer extends BasePattern {
13
14
  applicableIntents: PromptIntent[];
14
15
  mode: OptimizationMode | 'both';
15
16
  priority: number;
17
+ private readonly conversationalMarkers;
16
18
  apply(prompt: string, _context: PatternContext): PatternResult;
17
19
  private isAlreadyStructured;
18
20
  private isConversationalContent;
21
+ private calculateConfidence;
19
22
  private extractAndStructure;
20
23
  private extractRequirements;
21
24
  private extractConstraints;
@@ -1,9 +1,10 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  /**
3
- * v4.3.2 Conversational Pattern: ConversationSummarizer
3
+ * v4.4 Conversational Pattern: ConversationSummarizer
4
4
  *
5
5
  * Extracts structured requirements from conversational messages.
6
6
  * Organizes free-form discussion into actionable requirements.
7
+ * Enhanced with expanded marker detection and confidence scoring.
7
8
  */
8
9
  export class ConversationSummarizer extends BasePattern {
9
10
  id = 'conversation-summarizer';
@@ -12,6 +13,47 @@ export class ConversationSummarizer extends BasePattern {
12
13
  applicableIntents = ['summarization', 'planning', 'prd-generation'];
13
14
  mode = 'deep';
14
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
+ ];
15
57
  apply(prompt, _context) {
16
58
  // Check if content is already well-structured
17
59
  if (this.isAlreadyStructured(prompt)) {
@@ -65,36 +107,35 @@ export class ConversationSummarizer extends BasePattern {
65
107
  return matches.length >= 3;
66
108
  }
67
109
  isConversationalContent(prompt) {
68
- // Conversational markers
69
- const conversationalMarkers = [
70
- 'i want',
71
- 'i need',
72
- 'we need',
73
- 'should be able to',
74
- 'would like',
75
- 'thinking about',
76
- 'maybe we could',
77
- 'what if',
78
- 'how about',
79
- 'let me',
80
- "let's",
81
- 'also',
82
- 'and then',
83
- 'basically',
84
- 'so basically',
85
- ];
86
110
  const lowerPrompt = prompt.toLowerCase();
87
- const matches = conversationalMarkers.filter((marker) => lowerPrompt.includes(marker));
111
+ const matches = this.conversationalMarkers.filter((marker) => lowerPrompt.includes(marker));
88
112
  // Also check for lack of structure (sentences without bullet points)
89
113
  const sentences = this.extractSentences(prompt);
90
114
  const hasBulletPoints = prompt.includes('- ') || prompt.includes('* ');
115
+ // More lenient threshold with expanded markers
91
116
  return matches.length >= 2 || (sentences.length > 3 && !hasBulletPoints);
92
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
+ }
93
132
  extractAndStructure(prompt) {
94
133
  const requirements = this.extractRequirements(prompt);
95
134
  const constraints = this.extractConstraints(prompt);
96
135
  const goals = this.extractGoals(prompt);
136
+ const confidence = this.calculateConfidence(requirements, goals, constraints);
97
137
  let structured = '### Extracted Requirements\n\n';
138
+ structured += `*Extraction confidence: ${confidence}%*\n\n`;
98
139
  if (goals.length > 0) {
99
140
  structured += '**Goals:**\n';
100
141
  structured += goals.map((g) => `- ${g}`).join('\n');
@@ -110,16 +151,27 @@ export class ConversationSummarizer extends BasePattern {
110
151
  structured += constraints.map((c) => `- ${c}`).join('\n');
111
152
  structured += '\n\n';
112
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
+ }
113
159
  structured += '---\n\n**Original Context:**\n' + prompt;
114
160
  return structured;
115
161
  }
116
162
  extractRequirements(prompt) {
117
163
  const requirements = [];
118
164
  const sentences = this.extractSentences(prompt);
165
+ // Expanded requirement patterns
119
166
  const requirementPatterns = [
120
- /(?:need|want|should|must|require)\s+(?:to\s+)?(.+)/i,
121
- /(?:should be able to|needs to)\s+(.+)/i,
122
- /(?:feature|functionality):\s*(.+)/i,
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,
123
175
  ];
124
176
  for (const sentence of sentences) {
125
177
  for (const pattern of requirementPatterns) {
@@ -168,10 +220,14 @@ export class ConversationSummarizer extends BasePattern {
168
220
  }
169
221
  extractGoals(prompt) {
170
222
  const goals = [];
223
+ // Expanded goal patterns
171
224
  const goalPatterns = [
172
- /(?:goal is to|aim to|objective is to)\s+(.+)/gi,
173
- /(?:trying to|looking to|hoping to)\s+(.+)/gi,
174
- /(?:so that|in order to)\s+(.+)/gi,
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,
175
231
  ];
176
232
  for (const pattern of goalPatterns) {
177
233
  const matches = prompt.matchAll(pattern);
@@ -1,10 +1,11 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
- * v4.3.2 Conversational Pattern: ImplicitRequirementExtractor
4
+ * v4.4 Conversational Pattern: ImplicitRequirementExtractor
5
5
  *
6
6
  * Surfaces requirements mentioned indirectly in conversations.
7
7
  * Identifies hidden assumptions and unstated needs.
8
+ * Enhanced with more detection patterns and categorization.
8
9
  */
9
10
  export declare class ImplicitRequirementExtractor extends BasePattern {
10
11
  id: string;
@@ -13,8 +14,9 @@ export declare class ImplicitRequirementExtractor extends BasePattern {
13
14
  applicableIntents: PromptIntent[];
14
15
  mode: OptimizationMode | 'both';
15
16
  priority: number;
17
+ private readonly implicitPatterns;
16
18
  apply(prompt: string, _context: PatternContext): PatternResult;
17
19
  private extractImplicitRequirements;
18
- private addImplicitRequirements;
20
+ private addImplicitRequirementsSection;
19
21
  }
20
22
  //# sourceMappingURL=implicit-requirement-extractor.d.ts.map
@@ -1,9 +1,10 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  /**
3
- * v4.3.2 Conversational Pattern: ImplicitRequirementExtractor
3
+ * v4.4 Conversational Pattern: ImplicitRequirementExtractor
4
4
  *
5
5
  * Surfaces requirements mentioned indirectly in conversations.
6
6
  * Identifies hidden assumptions and unstated needs.
7
+ * Enhanced with more detection patterns and categorization.
7
8
  */
8
9
  export class ImplicitRequirementExtractor extends BasePattern {
9
10
  id = 'implicit-requirement-extractor';
@@ -12,6 +13,102 @@ export class ImplicitRequirementExtractor extends BasePattern {
12
13
  applicableIntents = ['summarization', 'planning', 'prd-generation'];
13
14
  mode = 'deep';
14
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
+ ];
15
112
  apply(prompt, _context) {
16
113
  // Extract implicit requirements
17
114
  const implicitReqs = this.extractImplicitRequirements(prompt);
@@ -28,7 +125,7 @@ export class ImplicitRequirementExtractor extends BasePattern {
28
125
  };
29
126
  }
30
127
  // Add implicit requirements section
31
- const enhanced = this.addImplicitRequirements(prompt, implicitReqs);
128
+ const enhanced = this.addImplicitRequirementsSection(prompt, implicitReqs);
32
129
  return {
33
130
  enhancedPrompt: enhanced,
34
131
  improvement: {
@@ -46,83 +143,93 @@ export class ImplicitRequirementExtractor extends BasePattern {
46
143
  const likePatterns = prompt.matchAll(/(?:like|similar to|same as)\s+([A-Za-z0-9\s]+)/gi);
47
144
  for (const match of likePatterns) {
48
145
  if (match[1]) {
49
- implicitReqs.push(`Feature parity with "${match[1].trim()}" (implied)`);
146
+ implicitReqs.push({
147
+ requirement: `Feature parity with "${match[1].trim()}" (implied)`,
148
+ category: 'feature',
149
+ });
50
150
  }
51
151
  }
52
- // Pattern 2: Technical mentions imply requirements
53
- if (lowerPrompt.includes('mobile')) {
54
- implicitReqs.push('Mobile-responsive design required');
55
- }
56
- if (lowerPrompt.includes('real-time') || lowerPrompt.includes('realtime')) {
57
- implicitReqs.push('Real-time updates infrastructure needed');
58
- }
59
- if (lowerPrompt.includes('scale') ||
60
- lowerPrompt.includes('thousands') ||
61
- lowerPrompt.includes('millions')) {
62
- implicitReqs.push('Scalability architecture required');
63
- }
64
- if (lowerPrompt.includes('secure') || lowerPrompt.includes('security')) {
65
- implicitReqs.push('Security audit and compliance requirements');
66
- }
67
- if (lowerPrompt.includes('fast') || lowerPrompt.includes('quick')) {
68
- implicitReqs.push('Performance optimization requirements');
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
+ }
69
160
  }
70
- // Pattern 3: User mentions imply auth/permissions
161
+ // Pattern: User mentions imply auth/permissions
71
162
  if ((lowerPrompt.includes('user') || lowerPrompt.includes('admin')) &&
72
163
  !lowerPrompt.includes('authentication')) {
73
- implicitReqs.push('User authentication system (implied by user roles)');
164
+ implicitReqs.push({
165
+ requirement: 'User authentication system (implied by user roles)',
166
+ category: 'security',
167
+ });
74
168
  }
75
- // Pattern 4: Data mentions imply storage
169
+ // Pattern: Data mentions imply storage
76
170
  if ((lowerPrompt.includes('save') ||
77
171
  lowerPrompt.includes('store') ||
78
172
  lowerPrompt.includes('data')) &&
79
173
  !lowerPrompt.includes('database')) {
80
- implicitReqs.push('Data persistence/storage (implied by data operations)');
81
- }
82
- // Pattern 5: "Easy" or "simple" implies UX focus
83
- if (lowerPrompt.includes('easy') ||
84
- lowerPrompt.includes('simple') ||
85
- lowerPrompt.includes('intuitive')) {
86
- implicitReqs.push('User experience priority (simplicity mentioned)');
87
- }
88
- // Pattern 6: Notifications/alerts imply communication system
89
- if (lowerPrompt.includes('notify') ||
90
- lowerPrompt.includes('alert') ||
91
- lowerPrompt.includes('email') ||
92
- lowerPrompt.includes('notification')) {
93
- implicitReqs.push('Notification system infrastructure');
94
- }
95
- // Pattern 7: Search implies search infrastructure
96
- if (lowerPrompt.includes('search') || lowerPrompt.includes('find')) {
97
- implicitReqs.push('Search functionality and indexing');
174
+ implicitReqs.push({
175
+ requirement: 'Data persistence/storage (implied by data operations)',
176
+ category: 'infrastructure',
177
+ });
98
178
  }
99
- // Pattern 8: Reports/analytics implies data aggregation
100
- if (lowerPrompt.includes('report') ||
101
- lowerPrompt.includes('analytics') ||
102
- lowerPrompt.includes('dashboard')) {
103
- implicitReqs.push('Analytics and reporting infrastructure');
104
- }
105
- // Pattern 9: Integration mentions
106
- if (lowerPrompt.includes('integrate') ||
107
- lowerPrompt.includes('connect') ||
108
- lowerPrompt.includes('sync')) {
109
- implicitReqs.push('Integration APIs and webhooks');
110
- }
111
- // Pattern 10: "Always" or "never" implies validation rules
179
+ // Pattern: "Always" or "never" implies validation rules
112
180
  const alwaysNeverPatterns = prompt.matchAll(/(?:always|never|must always|must never)\s+([^.!?]+)/gi);
113
181
  for (const match of alwaysNeverPatterns) {
114
182
  if (match[1]) {
115
- implicitReqs.push(`Business rule: "${match[1].trim()}" (implied constraint)`);
183
+ implicitReqs.push({
184
+ requirement: `Business rule: "${match[1].trim()}" (implied constraint)`,
185
+ category: 'business',
186
+ });
116
187
  }
117
188
  }
118
- // Deduplicate
119
- return [...new Set(implicitReqs)].slice(0, 8);
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
120
199
  }
121
- addImplicitRequirements(prompt, implicitReqs) {
200
+ addImplicitRequirementsSection(prompt, implicitReqs) {
122
201
  let section = '\n\n### Implicit Requirements (Inferred)\n';
123
202
  section += '*The following requirements are implied by the discussion:*\n\n';
124
- section += implicitReqs.map((r) => `- ${r}`).join('\n');
125
- section += '\n\n> **Note:** Please verify these inferred requirements are accurate.';
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.';
126
233
  return prompt + section;
127
234
  }
128
235
  }
@@ -1,10 +1,11 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
- * v4.3.2 Conversational Pattern: TopicCoherenceAnalyzer
4
+ * v4.4 Conversational Pattern: TopicCoherenceAnalyzer
5
5
  *
6
6
  * Detects topic shifts and multi-topic conversations.
7
7
  * Helps organize scattered discussions into coherent themes.
8
+ * Enhanced with expanded topic dictionary and better detection.
8
9
  */
9
10
  export declare class TopicCoherenceAnalyzer extends BasePattern {
10
11
  id: string;
@@ -13,6 +14,7 @@ export declare class TopicCoherenceAnalyzer extends BasePattern {
13
14
  applicableIntents: PromptIntent[];
14
15
  mode: OptimizationMode | 'both';
15
16
  priority: number;
17
+ private readonly topicIndicators;
16
18
  apply(prompt: string, _context: PatternContext): PatternResult;
17
19
  private detectTopics;
18
20
  private hasTopicOrganization;
@@ -1,9 +1,10 @@
1
1
  import { BasePattern } from './base-pattern.js';
2
2
  /**
3
- * v4.3.2 Conversational Pattern: TopicCoherenceAnalyzer
3
+ * v4.4 Conversational Pattern: TopicCoherenceAnalyzer
4
4
  *
5
5
  * Detects topic shifts and multi-topic conversations.
6
6
  * Helps organize scattered discussions into coherent themes.
7
+ * Enhanced with expanded topic dictionary and better detection.
7
8
  */
8
9
  export class TopicCoherenceAnalyzer extends BasePattern {
9
10
  id = 'topic-coherence-analyzer';
@@ -12,6 +13,183 @@ export class TopicCoherenceAnalyzer extends BasePattern {
12
13
  applicableIntents = ['summarization', 'planning'];
13
14
  mode = 'deep';
14
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
+ };
15
193
  apply(prompt, _context) {
16
194
  // Detect topics in the content
17
195
  const topics = this.detectTopics(prompt);
@@ -54,20 +232,7 @@ export class TopicCoherenceAnalyzer extends BasePattern {
54
232
  detectTopics(prompt) {
55
233
  const topics = [];
56
234
  const lowerPrompt = prompt.toLowerCase();
57
- // Topic detection patterns
58
- const topicIndicators = {
59
- 'User Interface': ['ui', 'interface', 'design', 'layout', 'button', 'form', 'page', 'screen'],
60
- 'Backend/API': ['api', 'backend', 'server', 'endpoint', 'route', 'controller'],
61
- Database: ['database', 'db', 'schema', 'table', 'query', 'migration'],
62
- Authentication: ['auth', 'login', 'password', 'session', 'token', 'permission'],
63
- Performance: ['performance', 'speed', 'cache', 'optimize', 'latency'],
64
- Testing: ['test', 'spec', 'coverage', 'qa', 'validation'],
65
- Deployment: ['deploy', 'ci/cd', 'pipeline', 'release', 'environment'],
66
- 'User Experience': ['ux', 'usability', 'accessibility', 'user flow', 'journey'],
67
- 'Business Logic': ['business', 'workflow', 'process', 'rule', 'logic'],
68
- Integration: ['integration', 'third-party', 'external', 'webhook', 'sync'],
69
- };
70
- for (const [topic, keywords] of Object.entries(topicIndicators)) {
235
+ for (const [topic, keywords] of Object.entries(this.topicIndicators)) {
71
236
  const hasKeyword = keywords.some((kw) => lowerPrompt.includes(kw));
72
237
  if (hasKeyword) {
73
238
  topics.push(topic);
@@ -99,30 +264,7 @@ export class TopicCoherenceAnalyzer extends BasePattern {
99
264
  return organized;
100
265
  }
101
266
  extractTopicContent(prompt, topic) {
102
- // Simple extraction based on topic keywords
103
- const topicKeywords = {
104
- 'User Interface': [
105
- 'ui',
106
- 'interface',
107
- 'design',
108
- 'layout',
109
- 'button',
110
- 'form',
111
- 'page',
112
- 'screen',
113
- 'component',
114
- ],
115
- 'Backend/API': ['api', 'backend', 'server', 'endpoint', 'route', 'controller', 'service'],
116
- Database: ['database', 'db', 'schema', 'table', 'query', 'migration', 'model'],
117
- Authentication: ['auth', 'login', 'password', 'session', 'token', 'permission', 'user'],
118
- Performance: ['performance', 'speed', 'cache', 'optimize', 'latency', 'fast', 'slow'],
119
- Testing: ['test', 'spec', 'coverage', 'qa', 'validation', 'verify'],
120
- Deployment: ['deploy', 'ci/cd', 'pipeline', 'release', 'environment', 'production'],
121
- 'User Experience': ['ux', 'usability', 'accessibility', 'user flow', 'journey', 'experience'],
122
- 'Business Logic': ['business', 'workflow', 'process', 'rule', 'logic', 'requirement'],
123
- Integration: ['integration', 'third-party', 'external', 'webhook', 'sync', 'connect'],
124
- };
125
- const keywords = topicKeywords[topic] || [];
267
+ const keywords = this.topicIndicators[topic] || [];
126
268
  const sentences = this.extractSentences(prompt);
127
269
  const relevantSentences = sentences.filter((sentence) => {
128
270
  const lower = sentence.toLowerCase();
@@ -179,7 +179,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
179
179
 
180
180
  ---
181
181
 
182
- ## Agent Transparency (v4.1)
182
+ ## Agent Transparency (v4.4)
183
183
 
184
184
  ### Quality Output Format
185
185
  {{INCLUDE:agent-protocols/quality-output.md}}
@@ -109,7 +109,7 @@ clavix prompts clear --executed
109
109
 
110
110
  ---
111
111
 
112
- ## Agent Transparency (v4.1)
112
+ ## Agent Transparency (v4.4)
113
113
 
114
114
  ### File Format Reference
115
115
  {{INCLUDE:agent-protocols/file-formats.md}}
@@ -158,7 +158,7 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
158
158
 
159
159
  ---
160
160
 
161
- ## Agent Transparency (v4.1)
161
+ ## Agent Transparency (v4.4)
162
162
 
163
163
  ### Quality Output Format
164
164
  {{INCLUDE:agent-protocols/quality-output.md}}
@@ -315,7 +315,7 @@ To find the task ID programmatically, read tasks.md and look for the pattern `ph
315
315
 
316
316
  ---
317
317
 
318
- ## Agent Transparency (v4.1)
318
+ ## Agent Transparency (v4.4)
319
319
 
320
320
  ### Workflow State Detection
321
321
  {{INCLUDE:agent-protocols/state-awareness.md}}
@@ -288,7 +288,7 @@ The generated `tasks.md` will look like:
288
288
 
289
289
  ---
290
290
 
291
- ## Agent Transparency (v4.1)
291
+ ## Agent Transparency (v4.4)
292
292
 
293
293
  ### Workflow State Detection
294
294
  {{INCLUDE:agent-protocols/state-awareness.md}}
@@ -316,7 +316,7 @@ The validation ensures generated PRDs are immediately usable for AI consumption
316
316
 
317
317
  ---
318
318
 
319
- ## Agent Transparency (v4.1)
319
+ ## Agent Transparency (v4.4)
320
320
 
321
321
  ### Quality Output Format
322
322
  {{INCLUDE:agent-protocols/quality-output.md}}
@@ -190,7 +190,27 @@ The goal is natural exploration of requirements, not a rigid questionnaire. Foll
190
190
 
191
191
  ---
192
192
 
193
- ## Agent Transparency (v4.1)
193
+ ## Agent Transparency (v4.4)
194
+
195
+ ### Enhanced Conversational Analysis (v4.4)
196
+
197
+ Clavix Intelligence™ now includes enhanced conversational pattern recognition:
198
+
199
+ **Topic Detection** (~15 topic areas):
200
+ - Automatically detects: User Interface, Backend/API, Database, Authentication, Performance, Testing, Deployment, User Experience, Business Logic, Integration, Security, Analytics, Error Handling, Documentation, State Management
201
+ - Groups related keywords for more accurate multi-topic detection
202
+ - Triggers focus suggestions when 3+ distinct topics detected
203
+
204
+ **Conversational Markers** (~30 patterns):
205
+ - Intent expressions: "i want", "we need", "should be able to"
206
+ - Thinking/exploring: "thinking about", "what if", "how about"
207
+ - Informal markers: "basically", "kind of like", "something like"
208
+ - Collaborative: "can we", "could we", "shall we"
209
+
210
+ **Implicit Requirement Detection**:
211
+ - Surfaces unstated requirements from context
212
+ - Categories: Infrastructure, Security, Performance, UX, Integration
213
+ - Examples: "mobile" → responsive design, "real-time" → WebSocket infrastructure
194
214
 
195
215
  ### Agent Decision Rules
196
216
  {{INCLUDE:agent-protocols/decision-rules.md}}
@@ -104,7 +104,15 @@ Implementation: BLOCKED - I will extract requirements, not implement them
104
104
  - **Success Criteria** [confidence]: How will success be measured?
105
105
  - **Context** [confidence]: Any important background or constraints?
106
106
 
107
- **CHECKPOINT:** Extracted [N] requirements, [M] constraints from conversation
107
+ **Calculate Extraction Confidence (v4.4):**
108
+ - Start with 50% base (conversational content detected)
109
+ - Add 20% if concrete requirements extracted
110
+ - Add 15% if clear goals identified
111
+ - Add 15% if constraints defined
112
+ - Display: "*Extraction confidence: X%*"
113
+ - If confidence < 80%, include verification prompt in output
114
+
115
+ **CHECKPOINT:** Extracted [N] requirements, [M] constraints from conversation (confidence: X%)
108
116
 
109
117
  3. **CREATE OUTPUT FILES (REQUIRED)** - You MUST create three files. This is not optional.
110
118
 
@@ -156,6 +164,12 @@ Implementation: BLOCKED - I will extract requirements, not implement them
156
164
  - [Edge case 1 and how it should be handled]
157
165
  - [Open question 1 - needs clarification]
158
166
 
167
+ ## Implicit Requirements (v4.4)
168
+ *Inferred from conversation context - please verify:*
169
+ - [Category] [Requirement inferred from discussion]
170
+ - [Category] [Another requirement]
171
+ > **Note:** These requirements were surfaced by analyzing conversation patterns.
172
+
159
173
  ## Success Criteria
160
174
  How we know this is complete and working:
161
175
  - ✓ [Specific success criterion 1]
@@ -344,7 +358,34 @@ Implementation: BLOCKED - I will extract requirements, not implement them
344
358
 
345
359
  ---
346
360
 
347
- ## Agent Transparency (v4.1)
361
+ ## Agent Transparency (v4.4)
362
+
363
+ ### Enhanced Extraction Capabilities (v4.4)
364
+
365
+ Clavix Intelligence™ now includes enhanced extraction with confidence scoring:
366
+
367
+ **Extraction Confidence** (auto-calculated):
368
+ - Base confidence: 50% (conversational content detected)
369
+ - +20% if concrete requirements extracted
370
+ - +15% if clear goals identified
371
+ - +15% if constraints defined
372
+ - Display: "Extraction confidence: X%"
373
+ - If <80%, add verification prompt to output
374
+
375
+ **Implicit Requirements** (auto-surfaced):
376
+ - Inferred from conversation context, grouped by category:
377
+ - **Infrastructure**: Mobile-responsive, real-time, scalability, offline, multi-tenant
378
+ - **Security**: Audit compliance, data privacy, encryption
379
+ - **Performance**: Speed optimization, low-latency
380
+ - **UX**: Simplicity focus, accessibility (WCAG)
381
+ - **Integration**: Notifications, search, analytics, APIs, data import/export
382
+ - Up to 10 implicit requirements per extraction
383
+ - Always marked with verification note
384
+
385
+ **Topic Organization**:
386
+ - Detects 15 topic categories with expanded keyword matching
387
+ - Groups multi-topic extractions by area
388
+ - Suggests separate PRDs for 3+ distinct topics
348
389
 
349
390
  ### Quality Output Format
350
391
  {{INCLUDE:agent-protocols/quality-output.md}}
@@ -7,8 +7,32 @@ export interface ClavixConfig {
7
7
  templates: TemplateConfig;
8
8
  outputs: OutputConfig;
9
9
  preferences: PreferencesConfig;
10
+ intelligence?: IntelligenceConfig;
10
11
  experimental?: Record<string, unknown>;
11
12
  }
13
+ /**
14
+ * v4.4 Intelligence Configuration
15
+ * Configure pattern behavior, enable/disable patterns, adjust priorities
16
+ */
17
+ export interface IntelligenceConfig {
18
+ /** Pattern-specific settings */
19
+ patterns?: PatternSettingsConfig;
20
+ /** Default mode for optimization */
21
+ defaultMode?: 'fast' | 'deep';
22
+ /** Enable verbose pattern logging */
23
+ verbosePatternLogs?: boolean;
24
+ }
25
+ /**
26
+ * Pattern-specific settings
27
+ */
28
+ export interface PatternSettingsConfig {
29
+ /** Disabled pattern IDs (won't run even if applicable) */
30
+ disabled?: string[];
31
+ /** Priority overrides (pattern-id → new priority 1-10) */
32
+ priorityOverrides?: Record<string, number>;
33
+ /** Custom pattern parameters (pattern-id → settings) */
34
+ customSettings?: Record<string, Record<string, unknown>>;
35
+ }
12
36
  /**
13
37
  * Legacy config format (pre-v3.5.0)
14
38
  * Supports migration from:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavix",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "description": "Clavix Intelligence™ for AI coding. Automatically optimizes prompts with intent detection, quality assessment, and adaptive patterns—no framework to learn. Works with Claude Code, Cursor, Windsurf, and 19+ other AI coding tools.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",