clavix 4.3.1 → 4.3.2
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 +18 -1
- package/dist/core/intelligence/pattern-library.js +131 -0
- package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +25 -0
- package/dist/core/intelligence/patterns/conversation-summarizer.js +197 -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 +20 -0
- package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +129 -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 +22 -0
- package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +140 -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 +1 -0
- package/dist/templates/slash-commands/_canonical/fast.md +1 -0
- package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +26 -2
- package/package.json +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.3.2 PRD Pattern: UserPersonaEnricher
|
|
4
|
+
*
|
|
5
|
+
* Adds missing user context and personas to PRD content.
|
|
6
|
+
* Ensures the "who" is clearly defined alongside the "what".
|
|
7
|
+
*/
|
|
8
|
+
export class UserPersonaEnricher extends BasePattern {
|
|
9
|
+
id = 'user-persona-enricher';
|
|
10
|
+
name = 'UserPersonaEnricher';
|
|
11
|
+
description = 'Adds missing user context and personas';
|
|
12
|
+
applicableIntents = ['prd-generation', 'planning'];
|
|
13
|
+
mode = 'deep';
|
|
14
|
+
priority = 6;
|
|
15
|
+
apply(prompt, _context) {
|
|
16
|
+
// Check if user/persona context already exists
|
|
17
|
+
if (this.hasUserContext(prompt)) {
|
|
18
|
+
return {
|
|
19
|
+
enhancedPrompt: prompt,
|
|
20
|
+
improvement: {
|
|
21
|
+
dimension: 'completeness',
|
|
22
|
+
description: 'User context already present',
|
|
23
|
+
impact: 'low',
|
|
24
|
+
},
|
|
25
|
+
applied: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Check if this is PRD-like content that needs users
|
|
29
|
+
if (!this.needsUserContext(prompt)) {
|
|
30
|
+
return {
|
|
31
|
+
enhancedPrompt: prompt,
|
|
32
|
+
improvement: {
|
|
33
|
+
dimension: 'completeness',
|
|
34
|
+
description: 'Content does not require user persona',
|
|
35
|
+
impact: 'low',
|
|
36
|
+
},
|
|
37
|
+
applied: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Add user persona section
|
|
41
|
+
const enhanced = this.addUserPersona(prompt);
|
|
42
|
+
return {
|
|
43
|
+
enhancedPrompt: enhanced,
|
|
44
|
+
improvement: {
|
|
45
|
+
dimension: 'completeness',
|
|
46
|
+
description: 'Added user persona context (who will use this)',
|
|
47
|
+
impact: 'medium',
|
|
48
|
+
},
|
|
49
|
+
applied: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasUserContext(prompt) {
|
|
53
|
+
const userKeywords = [
|
|
54
|
+
'user persona',
|
|
55
|
+
'target user',
|
|
56
|
+
'end user',
|
|
57
|
+
'user profile',
|
|
58
|
+
'audience',
|
|
59
|
+
'stakeholder',
|
|
60
|
+
'as a user',
|
|
61
|
+
'users can',
|
|
62
|
+
'users will',
|
|
63
|
+
'for users',
|
|
64
|
+
'customer',
|
|
65
|
+
'developer',
|
|
66
|
+
'admin',
|
|
67
|
+
'target audience',
|
|
68
|
+
];
|
|
69
|
+
return this.hasSection(prompt, userKeywords);
|
|
70
|
+
}
|
|
71
|
+
needsUserContext(prompt) {
|
|
72
|
+
// PRD-like content that talks about features but not users
|
|
73
|
+
const featureKeywords = [
|
|
74
|
+
'feature',
|
|
75
|
+
'build',
|
|
76
|
+
'create',
|
|
77
|
+
'implement',
|
|
78
|
+
'functionality',
|
|
79
|
+
'should',
|
|
80
|
+
'must',
|
|
81
|
+
'requirement',
|
|
82
|
+
];
|
|
83
|
+
return this.hasSection(prompt, featureKeywords);
|
|
84
|
+
}
|
|
85
|
+
addUserPersona(prompt) {
|
|
86
|
+
// Detect the likely user type from content
|
|
87
|
+
const userType = this.inferUserType(prompt);
|
|
88
|
+
const personaSection = `\n\n### Target Users\n` +
|
|
89
|
+
`**Primary User:** ${userType}\n` +
|
|
90
|
+
`- Goals: [What they want to achieve]\n` +
|
|
91
|
+
`- Pain Points: [Current frustrations]\n` +
|
|
92
|
+
`- Context: [When and how they'll use this]`;
|
|
93
|
+
return prompt + personaSection;
|
|
94
|
+
}
|
|
95
|
+
inferUserType(prompt) {
|
|
96
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
97
|
+
// Try to infer user type from content
|
|
98
|
+
if (lowerPrompt.includes('api') ||
|
|
99
|
+
lowerPrompt.includes('sdk') ||
|
|
100
|
+
lowerPrompt.includes('library')) {
|
|
101
|
+
return 'Developers integrating with the system';
|
|
102
|
+
}
|
|
103
|
+
if (lowerPrompt.includes('admin') ||
|
|
104
|
+
lowerPrompt.includes('manage') ||
|
|
105
|
+
lowerPrompt.includes('dashboard')) {
|
|
106
|
+
return 'Administrators managing the system';
|
|
107
|
+
}
|
|
108
|
+
if (lowerPrompt.includes('e-commerce') ||
|
|
109
|
+
lowerPrompt.includes('shop') ||
|
|
110
|
+
lowerPrompt.includes('buy')) {
|
|
111
|
+
return 'Customers making purchases';
|
|
112
|
+
}
|
|
113
|
+
if (lowerPrompt.includes('content') ||
|
|
114
|
+
lowerPrompt.includes('blog') ||
|
|
115
|
+
lowerPrompt.includes('cms')) {
|
|
116
|
+
return 'Content creators and editors';
|
|
117
|
+
}
|
|
118
|
+
if (lowerPrompt.includes('mobile') || lowerPrompt.includes('app')) {
|
|
119
|
+
return 'Mobile app users';
|
|
120
|
+
}
|
|
121
|
+
return '[Define primary user type]';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=user-persona-enricher.js.map
|
|
@@ -11,6 +11,8 @@ export class QualityAssessor {
|
|
|
11
11
|
'security-review': ['scope', 'threat-model', 'compliance-requirements', 'known-issues'],
|
|
12
12
|
learning: ['current-knowledge', 'learning-goal', 'preferred-depth', 'context'],
|
|
13
13
|
'prd-generation': ['product-vision', 'user-personas', 'features', 'success-metrics'],
|
|
14
|
+
// v4.3.2: Conversational mode intent
|
|
15
|
+
summarization: ['conversation-context', 'key-requirements', 'constraints', 'success-criteria'],
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* Assess quality of a prompt (backward compatibility wrapper)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning';
|
|
1
|
+
export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning' | 'summarization';
|
|
2
2
|
export type QualityDimension = 'clarity' | 'efficiency' | 'structure' | 'completeness' | 'actionability' | 'specificity';
|
|
3
3
|
export type ImpactLevel = 'low' | 'medium' | 'high';
|
|
4
|
-
export type OptimizationMode = 'fast' | 'deep';
|
|
4
|
+
export type OptimizationMode = 'fast' | 'deep' | 'prd' | 'conversational';
|
|
5
|
+
export type OptimizationPhase = 'question-validation' | 'output-generation' | 'conversation-tracking' | 'summarization';
|
|
6
|
+
export type DocumentType = 'full-prd' | 'quick-prd' | 'mini-prd' | 'prompt';
|
|
5
7
|
export interface IntentAnalysis {
|
|
6
8
|
primaryIntent: PromptIntent;
|
|
7
9
|
confidence: number;
|
|
@@ -55,6 +57,9 @@ export interface PatternContext {
|
|
|
55
57
|
intent: IntentAnalysis;
|
|
56
58
|
mode: OptimizationMode;
|
|
57
59
|
originalPrompt: string;
|
|
60
|
+
phase?: OptimizationPhase;
|
|
61
|
+
documentType?: DocumentType;
|
|
62
|
+
questionId?: string;
|
|
58
63
|
}
|
|
59
64
|
export interface PatternResult {
|
|
60
65
|
enhancedPrompt: string;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { IntentDetector } from './intent-detector.js';
|
|
2
2
|
import { PatternLibrary } from './pattern-library.js';
|
|
3
3
|
import { QualityAssessor } from './quality-assessor.js';
|
|
4
|
-
import { OptimizationResult, OptimizationMode, EscalationAnalysis } from './types.js';
|
|
4
|
+
import { OptimizationResult, OptimizationMode, OptimizationPhase, DocumentType, EscalationAnalysis } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* v4.3.2: Extended context options for PRD and Conversational modes
|
|
7
|
+
*/
|
|
8
|
+
export interface OptimizationContextOverride {
|
|
9
|
+
phase?: OptimizationPhase;
|
|
10
|
+
documentType?: DocumentType;
|
|
11
|
+
questionId?: string;
|
|
12
|
+
intent?: string;
|
|
13
|
+
}
|
|
5
14
|
export declare class UniversalOptimizer {
|
|
6
15
|
private intentDetector;
|
|
7
16
|
private patternLibrary;
|
|
@@ -9,8 +18,24 @@ export declare class UniversalOptimizer {
|
|
|
9
18
|
constructor(intentDetector?: IntentDetector, patternLibrary?: PatternLibrary, qualityAssessor?: QualityAssessor);
|
|
10
19
|
/**
|
|
11
20
|
* Optimize a prompt using Clavix Intelligence
|
|
21
|
+
* @param prompt The prompt to optimize
|
|
22
|
+
* @param mode The optimization mode
|
|
23
|
+
* @param contextOverride Optional context override for PRD/Conversational modes
|
|
24
|
+
*/
|
|
25
|
+
optimize(prompt: string, mode: OptimizationMode, contextOverride?: OptimizationContextOverride): Promise<OptimizationResult>;
|
|
26
|
+
/**
|
|
27
|
+
* v4.3.2: Validate a PRD answer and provide friendly suggestions
|
|
28
|
+
* Uses adaptive threshold (< 50% quality triggers suggestions)
|
|
29
|
+
*/
|
|
30
|
+
validatePRDAnswer(answer: string, questionId: string): Promise<{
|
|
31
|
+
needsClarification: boolean;
|
|
32
|
+
suggestion?: string;
|
|
33
|
+
quality: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
|
|
12
37
|
*/
|
|
13
|
-
|
|
38
|
+
private generateFriendlySuggestion;
|
|
14
39
|
/**
|
|
15
40
|
* Determine if deep mode should be recommended (for fast mode results)
|
|
16
41
|
* @deprecated Use analyzeEscalation() for more detailed analysis
|
|
@@ -12,13 +12,24 @@ export class UniversalOptimizer {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Optimize a prompt using Clavix Intelligence
|
|
15
|
+
* @param prompt The prompt to optimize
|
|
16
|
+
* @param mode The optimization mode
|
|
17
|
+
* @param contextOverride Optional context override for PRD/Conversational modes
|
|
15
18
|
*/
|
|
16
|
-
async optimize(prompt, mode) {
|
|
19
|
+
async optimize(prompt, mode, contextOverride) {
|
|
17
20
|
const startTime = Date.now();
|
|
18
|
-
// Step 1: Detect intent
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Step 1: Detect intent (or use override)
|
|
22
|
+
let intent = this.intentDetector.analyze(prompt);
|
|
23
|
+
if (contextOverride?.intent) {
|
|
24
|
+
intent = {
|
|
25
|
+
...intent,
|
|
26
|
+
primaryIntent: contextOverride.intent,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Step 2: Select applicable patterns using mode-aware selection
|
|
30
|
+
const patterns = mode === 'prd' || mode === 'conversational'
|
|
31
|
+
? this.patternLibrary.selectPatternsForMode(mode, intent, contextOverride?.phase)
|
|
32
|
+
: this.patternLibrary.selectPatterns(intent, mode);
|
|
22
33
|
// Step 3: Apply patterns sequentially
|
|
23
34
|
let enhanced = prompt;
|
|
24
35
|
const improvements = [];
|
|
@@ -27,6 +38,10 @@ export class UniversalOptimizer {
|
|
|
27
38
|
intent,
|
|
28
39
|
mode,
|
|
29
40
|
originalPrompt: prompt,
|
|
41
|
+
// v4.3.2: Extended context
|
|
42
|
+
phase: contextOverride?.phase,
|
|
43
|
+
documentType: contextOverride?.documentType,
|
|
44
|
+
questionId: contextOverride?.questionId,
|
|
30
45
|
};
|
|
31
46
|
for (const pattern of patterns) {
|
|
32
47
|
try {
|
|
@@ -61,6 +76,51 @@ export class UniversalOptimizer {
|
|
|
61
76
|
processingTimeMs,
|
|
62
77
|
};
|
|
63
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* v4.3.2: Validate a PRD answer and provide friendly suggestions
|
|
81
|
+
* Uses adaptive threshold (< 50% quality triggers suggestions)
|
|
82
|
+
*/
|
|
83
|
+
async validatePRDAnswer(answer, questionId) {
|
|
84
|
+
const result = await this.optimize(answer, 'prd', {
|
|
85
|
+
phase: 'question-validation',
|
|
86
|
+
questionId,
|
|
87
|
+
intent: 'prd-generation',
|
|
88
|
+
});
|
|
89
|
+
// Adaptive threshold: only suggest improvements for very vague answers
|
|
90
|
+
if (result.quality.overall < 50) {
|
|
91
|
+
return {
|
|
92
|
+
needsClarification: true,
|
|
93
|
+
suggestion: this.generateFriendlySuggestion(result, questionId),
|
|
94
|
+
quality: result.quality.overall,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
needsClarification: false,
|
|
99
|
+
quality: result.quality.overall,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
|
|
104
|
+
*/
|
|
105
|
+
generateFriendlySuggestion(result, questionId) {
|
|
106
|
+
const suggestions = {
|
|
107
|
+
q1: ["the problem you're solving", 'why this matters', 'who benefits'],
|
|
108
|
+
q2: ['specific features', 'user actions', 'key functionality'],
|
|
109
|
+
q3: ['technologies', 'frameworks', 'constraints'],
|
|
110
|
+
q4: ["what's explicitly out of scope", 'features to avoid', 'limitations'],
|
|
111
|
+
q5: ['additional context', 'constraints', 'timeline considerations'],
|
|
112
|
+
};
|
|
113
|
+
const questionSuggestions = suggestions[questionId] || suggestions.q5;
|
|
114
|
+
// Pick the most relevant suggestion based on what's missing
|
|
115
|
+
let detail = questionSuggestions[0];
|
|
116
|
+
if (result.quality.completeness < 40) {
|
|
117
|
+
detail = questionSuggestions[Math.min(1, questionSuggestions.length - 1)];
|
|
118
|
+
}
|
|
119
|
+
if (result.quality.specificity < 40) {
|
|
120
|
+
detail = questionSuggestions[Math.min(2, questionSuggestions.length - 1)];
|
|
121
|
+
}
|
|
122
|
+
return `adding ${detail} would help`;
|
|
123
|
+
}
|
|
64
124
|
/**
|
|
65
125
|
* Determine if deep mode should be recommended (for fast mode results)
|
|
66
126
|
* @deprecated Use analyzeEscalation() for more detailed analysis
|
|
@@ -93,6 +93,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
|
|
|
93
93
|
- **migration**: Version upgrades, porting code between frameworks
|
|
94
94
|
- **security-review**: Security audits, vulnerability checks
|
|
95
95
|
- **learning**: Conceptual understanding, tutorials, explanations
|
|
96
|
+
- **summarization**: Extracting requirements from conversations
|
|
96
97
|
|
|
97
98
|
3. **Strategic Scope Detection** (before detailed analysis):
|
|
98
99
|
|
|
@@ -91,6 +91,7 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
|
|
|
91
91
|
- **migration**: Version upgrades, porting code between frameworks
|
|
92
92
|
- **security-review**: Security audits, vulnerability checks
|
|
93
93
|
- **learning**: Conceptual understanding, tutorials, explanations
|
|
94
|
+
- **summarization**: Extracting requirements from conversations
|
|
94
95
|
|
|
95
96
|
3. **Quality Assessment** - Evaluate across 6 dimensions:
|
|
96
97
|
|
|
@@ -75,6 +75,21 @@ Patterns: 7 applied (deep mode)
|
|
|
75
75
|
| SuccessCriteriaEnforcer | 6 | Adds measurable success criteria |
|
|
76
76
|
| DomainContextEnricher | 5 | Adds domain-specific best practices |
|
|
77
77
|
|
|
78
|
+
**v4.3.2 PRD Mode Patterns (deep mode):**
|
|
79
|
+
| Pattern | Priority | What It Does |
|
|
80
|
+
|---------|----------|--------------|
|
|
81
|
+
| RequirementPrioritizer | 7 | Separates must-have from nice-to-have requirements |
|
|
82
|
+
| UserPersonaEnricher | 6 | Adds missing user context and personas |
|
|
83
|
+
| SuccessMetricsEnforcer | 7 | Ensures measurable success criteria exist |
|
|
84
|
+
| DependencyIdentifier | 5 | Identifies technical and external dependencies |
|
|
85
|
+
|
|
86
|
+
**v4.3.2 Conversational Mode Patterns (deep mode):**
|
|
87
|
+
| Pattern | Priority | What It Does |
|
|
88
|
+
|---------|----------|--------------|
|
|
89
|
+
| ConversationSummarizer | 8 | Extracts structured requirements from messages |
|
|
90
|
+
| TopicCoherenceAnalyzer | 6 | Detects topic shifts and multi-topic conversations |
|
|
91
|
+
| ImplicitRequirementExtractor | 7 | Surfaces requirements mentioned indirectly |
|
|
92
|
+
|
|
78
93
|
### Pattern Selection Logic
|
|
79
94
|
|
|
80
95
|
Patterns are selected based on:
|
|
@@ -109,11 +124,20 @@ Deep mode only:
|
|
|
109
124
|
AlternativePhrasingGenerator, EdgeCaseIdentifier, ValidationChecklistCreator,
|
|
110
125
|
AssumptionExplicitizer, ScopeDefiner, PRDStructureEnforcer,
|
|
111
126
|
ErrorToleranceEnhancer, PrerequisiteIdentifier
|
|
127
|
+
|
|
128
|
+
v4.3.2 PRD mode (deep):
|
|
129
|
+
RequirementPrioritizer, UserPersonaEnricher, SuccessMetricsEnforcer,
|
|
130
|
+
DependencyIdentifier
|
|
131
|
+
|
|
132
|
+
v4.3.2 Conversational mode (deep):
|
|
133
|
+
ConversationSummarizer, TopicCoherenceAnalyzer, ImplicitRequirementExtractor
|
|
112
134
|
```
|
|
113
135
|
|
|
114
136
|
### Pattern Count by Mode
|
|
115
137
|
|
|
116
138
|
| Mode | Patterns Available | Typical Applied |
|
|
117
139
|
|------|-------------------|-----------------|
|
|
118
|
-
| Fast |
|
|
119
|
-
| Deep |
|
|
140
|
+
| Fast | 21 core patterns | 4-7 patterns |
|
|
141
|
+
| Deep | 27 total patterns | 8-14 patterns |
|
|
142
|
+
| PRD | 15 patterns | 10-15 patterns |
|
|
143
|
+
| Conversational | 11 patterns | 6-11 patterns |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavix",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"requirements"
|
|
55
55
|
],
|
|
56
56
|
"author": "ClavixDev",
|
|
57
|
-
"license": "
|
|
57
|
+
"license": "Apache-2.0",
|
|
58
58
|
"bugs": {
|
|
59
59
|
"url": "https://github.com/ClavixDev/Clavix/issues"
|
|
60
60
|
},
|