clavix 4.11.2 → 5.0.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.
Files changed (162) hide show
  1. package/README.md +72 -60
  2. package/dist/cli/commands/update.js +9 -10
  3. package/dist/templates/agents/agents.md +14 -8
  4. package/dist/templates/agents/copilot-instructions.md +1 -1
  5. package/dist/templates/instructions/core/verification.md +2 -2
  6. package/dist/templates/slash-commands/_canonical/archive.md +83 -121
  7. package/dist/templates/slash-commands/_canonical/execute.md +32 -42
  8. package/dist/templates/slash-commands/_canonical/implement.md +32 -44
  9. package/dist/templates/slash-commands/_canonical/improve.md +14 -53
  10. package/dist/templates/slash-commands/_canonical/start.md +1 -1
  11. package/dist/templates/slash-commands/_canonical/summarize.md +8 -8
  12. package/dist/templates/slash-commands/_components/agent-protocols/cli-reference.md +84 -180
  13. package/dist/templates/slash-commands/_components/agent-protocols/error-handling.md +2 -2
  14. package/dist/templates/slash-commands/_components/agent-protocols/file-formats.md +41 -59
  15. package/dist/templates/slash-commands/_components/agent-protocols/state-assertion.md +1 -1
  16. package/dist/templates/slash-commands/_components/references/intent-types.md +1 -1
  17. package/dist/templates/slash-commands/_components/sections/file-saving-protocol.md +20 -27
  18. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +29 -46
  19. package/dist/templates/slash-commands/_components/troubleshooting/file-not-saved.md +4 -5
  20. package/dist/types/config.d.ts +57 -0
  21. package/dist/utils/legacy-command-cleanup.js +31 -4
  22. package/package.json +5 -4
  23. package/dist/cli/commands/analyze.d.ts +0 -17
  24. package/dist/cli/commands/analyze.js +0 -133
  25. package/dist/cli/commands/archive.d.ts +0 -36
  26. package/dist/cli/commands/archive.js +0 -266
  27. package/dist/cli/commands/deep.d.ts +0 -17
  28. package/dist/cli/commands/deep.js +0 -170
  29. package/dist/cli/commands/execute.d.ts +0 -15
  30. package/dist/cli/commands/execute.js +0 -168
  31. package/dist/cli/commands/fast.d.ts +0 -18
  32. package/dist/cli/commands/fast.js +0 -219
  33. package/dist/cli/commands/implement.d.ts +0 -24
  34. package/dist/cli/commands/implement.js +0 -289
  35. package/dist/cli/commands/improve.d.ts +0 -32
  36. package/dist/cli/commands/improve.js +0 -250
  37. package/dist/cli/commands/list.d.ts +0 -17
  38. package/dist/cli/commands/list.js +0 -217
  39. package/dist/cli/commands/plan.d.ts +0 -21
  40. package/dist/cli/commands/plan.js +0 -297
  41. package/dist/cli/commands/prd.d.ts +0 -24
  42. package/dist/cli/commands/prd.js +0 -321
  43. package/dist/cli/commands/prompts/clear.d.ts +0 -16
  44. package/dist/cli/commands/prompts/clear.js +0 -222
  45. package/dist/cli/commands/prompts/list.d.ts +0 -8
  46. package/dist/cli/commands/prompts/list.js +0 -88
  47. package/dist/cli/commands/show.d.ts +0 -21
  48. package/dist/cli/commands/show.js +0 -191
  49. package/dist/cli/commands/start.d.ts +0 -40
  50. package/dist/cli/commands/start.js +0 -210
  51. package/dist/cli/commands/summarize.d.ts +0 -17
  52. package/dist/cli/commands/summarize.js +0 -196
  53. package/dist/cli/commands/task-complete.d.ts +0 -27
  54. package/dist/cli/commands/task-complete.js +0 -269
  55. package/dist/cli/commands/verify.d.ts +0 -28
  56. package/dist/cli/commands/verify.js +0 -349
  57. package/dist/core/archive-manager.d.ts +0 -100
  58. package/dist/core/archive-manager.js +0 -302
  59. package/dist/core/basic-checklist-generator.d.ts +0 -35
  60. package/dist/core/basic-checklist-generator.js +0 -344
  61. package/dist/core/checklist-parser.d.ts +0 -48
  62. package/dist/core/checklist-parser.js +0 -238
  63. package/dist/core/config-manager.d.ts +0 -149
  64. package/dist/core/config-manager.js +0 -230
  65. package/dist/core/conversation-analyzer.d.ts +0 -86
  66. package/dist/core/conversation-analyzer.js +0 -387
  67. package/dist/core/conversation-quality-tracker.d.ts +0 -81
  68. package/dist/core/conversation-quality-tracker.js +0 -195
  69. package/dist/core/git-manager.d.ts +0 -126
  70. package/dist/core/git-manager.js +0 -282
  71. package/dist/core/intelligence/confidence-calculator.d.ts +0 -93
  72. package/dist/core/intelligence/confidence-calculator.js +0 -124
  73. package/dist/core/intelligence/index.d.ts +0 -11
  74. package/dist/core/intelligence/index.js +0 -15
  75. package/dist/core/intelligence/intent-detector.d.ts +0 -54
  76. package/dist/core/intelligence/intent-detector.js +0 -723
  77. package/dist/core/intelligence/pattern-library.d.ts +0 -104
  78. package/dist/core/intelligence/pattern-library.js +0 -339
  79. package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +0 -27
  80. package/dist/core/intelligence/patterns/actionability-enhancer.js +0 -192
  81. package/dist/core/intelligence/patterns/alternative-phrasing-generator.d.ts +0 -29
  82. package/dist/core/intelligence/patterns/alternative-phrasing-generator.js +0 -239
  83. package/dist/core/intelligence/patterns/ambiguity-detector.d.ts +0 -22
  84. package/dist/core/intelligence/patterns/ambiguity-detector.js +0 -196
  85. package/dist/core/intelligence/patterns/assumption-explicitizer.d.ts +0 -30
  86. package/dist/core/intelligence/patterns/assumption-explicitizer.js +0 -296
  87. package/dist/core/intelligence/patterns/base-pattern.d.ts +0 -192
  88. package/dist/core/intelligence/patterns/base-pattern.js +0 -103
  89. package/dist/core/intelligence/patterns/completeness-validator.d.ts +0 -27
  90. package/dist/core/intelligence/patterns/completeness-validator.js +0 -221
  91. package/dist/core/intelligence/patterns/conciseness-filter.d.ts +0 -20
  92. package/dist/core/intelligence/patterns/conciseness-filter.js +0 -92
  93. package/dist/core/intelligence/patterns/context-precision.d.ts +0 -32
  94. package/dist/core/intelligence/patterns/context-precision.js +0 -389
  95. package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +0 -30
  96. package/dist/core/intelligence/patterns/conversation-summarizer.js +0 -277
  97. package/dist/core/intelligence/patterns/dependency-identifier.d.ts +0 -23
  98. package/dist/core/intelligence/patterns/dependency-identifier.js +0 -166
  99. package/dist/core/intelligence/patterns/domain-context-enricher.d.ts +0 -21
  100. package/dist/core/intelligence/patterns/domain-context-enricher.js +0 -198
  101. package/dist/core/intelligence/patterns/edge-case-identifier.d.ts +0 -30
  102. package/dist/core/intelligence/patterns/edge-case-identifier.js +0 -269
  103. package/dist/core/intelligence/patterns/error-tolerance-enhancer.d.ts +0 -22
  104. package/dist/core/intelligence/patterns/error-tolerance-enhancer.js +0 -179
  105. package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +0 -24
  106. package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +0 -259
  107. package/dist/core/intelligence/patterns/objective-clarifier.d.ts +0 -22
  108. package/dist/core/intelligence/patterns/objective-clarifier.js +0 -126
  109. package/dist/core/intelligence/patterns/output-format-enforcer.d.ts +0 -22
  110. package/dist/core/intelligence/patterns/output-format-enforcer.js +0 -151
  111. package/dist/core/intelligence/patterns/prd-structure-enforcer.d.ts +0 -23
  112. package/dist/core/intelligence/patterns/prd-structure-enforcer.js +0 -183
  113. package/dist/core/intelligence/patterns/prerequisite-identifier.d.ts +0 -23
  114. package/dist/core/intelligence/patterns/prerequisite-identifier.js +0 -221
  115. package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +0 -24
  116. package/dist/core/intelligence/patterns/requirement-prioritizer.js +0 -134
  117. package/dist/core/intelligence/patterns/scope-definer.d.ts +0 -26
  118. package/dist/core/intelligence/patterns/scope-definer.js +0 -236
  119. package/dist/core/intelligence/patterns/step-decomposer.d.ts +0 -31
  120. package/dist/core/intelligence/patterns/step-decomposer.js +0 -242
  121. package/dist/core/intelligence/patterns/structure-organizer.d.ts +0 -31
  122. package/dist/core/intelligence/patterns/structure-organizer.js +0 -218
  123. package/dist/core/intelligence/patterns/success-criteria-enforcer.d.ts +0 -22
  124. package/dist/core/intelligence/patterns/success-criteria-enforcer.js +0 -165
  125. package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +0 -24
  126. package/dist/core/intelligence/patterns/success-metrics-enforcer.js +0 -165
  127. package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +0 -25
  128. package/dist/core/intelligence/patterns/technical-context-enricher.js +0 -165
  129. package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +0 -26
  130. package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +0 -300
  131. package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +0 -24
  132. package/dist/core/intelligence/patterns/user-persona-enricher.js +0 -141
  133. package/dist/core/intelligence/patterns/validation-checklist-creator.d.ts +0 -31
  134. package/dist/core/intelligence/patterns/validation-checklist-creator.js +0 -242
  135. package/dist/core/intelligence/quality-assessor.d.ts +0 -51
  136. package/dist/core/intelligence/quality-assessor.js +0 -505
  137. package/dist/core/intelligence/types.d.ts +0 -111
  138. package/dist/core/intelligence/types.js +0 -3
  139. package/dist/core/intelligence/universal-optimizer.d.ts +0 -84
  140. package/dist/core/intelligence/universal-optimizer.js +0 -371
  141. package/dist/core/prd-generator.d.ts +0 -76
  142. package/dist/core/prd-generator.js +0 -173
  143. package/dist/core/prompt-manager.d.ts +0 -110
  144. package/dist/core/prompt-manager.js +0 -274
  145. package/dist/core/prompt-optimizer.d.ts +0 -268
  146. package/dist/core/prompt-optimizer.js +0 -959
  147. package/dist/core/question-engine.d.ts +0 -167
  148. package/dist/core/question-engine.js +0 -356
  149. package/dist/core/session-manager.d.ts +0 -139
  150. package/dist/core/session-manager.js +0 -365
  151. package/dist/core/task-manager.d.ts +0 -211
  152. package/dist/core/task-manager.js +0 -981
  153. package/dist/core/verification-hooks.d.ts +0 -67
  154. package/dist/core/verification-hooks.js +0 -309
  155. package/dist/core/verification-manager.d.ts +0 -107
  156. package/dist/core/verification-manager.js +0 -415
  157. package/dist/index 2.js +0 -13
  158. package/dist/index.d 2.ts +0 -4
  159. package/dist/types/session.d.ts +0 -78
  160. package/dist/types/session.js +0 -8
  161. package/dist/types/verification.d.ts +0 -205
  162. package/dist/types/verification.js +0 -9
@@ -1,84 +0,0 @@
1
- import { IntentDetector } from './intent-detector.js';
2
- import { PatternLibrary } from './pattern-library.js';
3
- import { QualityAssessor } from './quality-assessor.js';
4
- import { OptimizationResult, OptimizationMode, OptimizationPhase, DocumentType, EscalationAnalysis, DepthLevel } from './types.js';
5
- /**
6
- * v4.11: Extended context options for optimization modes
7
- */
8
- export interface OptimizationContextOverride {
9
- phase?: OptimizationPhase;
10
- documentType?: DocumentType;
11
- questionId?: string;
12
- intent?: string;
13
- depthLevel?: DepthLevel;
14
- }
15
- export declare class UniversalOptimizer {
16
- private intentDetector;
17
- private patternLibrary;
18
- private qualityAssessor;
19
- constructor(intentDetector?: IntentDetector, patternLibrary?: PatternLibrary, qualityAssessor?: QualityAssessor);
20
- /**
21
- * v4.11: Optimize a prompt using Clavix Intelligence
22
- * @param prompt The prompt to optimize
23
- * @param mode The optimization mode ('improve' | 'prd' | 'conversational')
24
- * @param contextOverride Optional context override including depthLevel
25
- */
26
- optimize(prompt: string, mode: OptimizationMode, contextOverride?: OptimizationContextOverride): Promise<OptimizationResult>;
27
- /**
28
- * v4.3.2: Validate a PRD answer and provide friendly suggestions
29
- * Uses adaptive threshold (< 50% quality triggers suggestions)
30
- */
31
- validatePRDAnswer(answer: string, questionId: string): Promise<{
32
- needsClarification: boolean;
33
- suggestion?: string;
34
- quality: number;
35
- }>;
36
- /**
37
- * v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
38
- */
39
- private generateFriendlySuggestion;
40
- /**
41
- * v4.11: Determine if comprehensive depth should be recommended
42
- * @deprecated Use analyzeEscalation() for more detailed analysis
43
- */
44
- shouldRecommendComprehensive(result: OptimizationResult): boolean;
45
- /**
46
- * @deprecated Use shouldRecommendComprehensive() instead
47
- */
48
- shouldRecommendDeepMode(result: OptimizationResult): boolean;
49
- /**
50
- * v4.11: Analyze whether to escalate from standard to comprehensive depth
51
- * Uses multi-factor scoring for intelligent triage decisions
52
- *
53
- * IMPORTANT: Quality checks use the ORIGINAL prompt, not the enhanced one,
54
- * because triage decisions should be based on what the user wrote.
55
- */
56
- analyzeEscalation(result: OptimizationResult): EscalationAnalysis;
57
- /**
58
- * v4.11: Generate a user-friendly explanation of what comprehensive depth would provide
59
- */
60
- private generateComprehensiveValue;
61
- /**
62
- * v4.11: Get recommendation message for user
63
- * Enhanced with escalation analysis for improve mode
64
- */
65
- getRecommendation(result: OptimizationResult): string | null;
66
- /**
67
- * v4.11: Get detailed escalation recommendation with all reasons
68
- * Useful for verbose output or debugging
69
- */
70
- getDetailedRecommendation(result: OptimizationResult): {
71
- message: string;
72
- escalation?: EscalationAnalysis;
73
- qualityLevel: 'excellent' | 'good' | 'decent' | 'needs-work';
74
- };
75
- /**
76
- * v4.11: Get statistics about the optimizer
77
- */
78
- getStatistics(): {
79
- totalPatterns: number;
80
- standardPatterns: number;
81
- comprehensivePatterns: number;
82
- };
83
- }
84
- //# sourceMappingURL=universal-optimizer.d.ts.map
@@ -1,371 +0,0 @@
1
- import { IntentDetector } from './intent-detector.js';
2
- import { PatternLibrary } from './pattern-library.js';
3
- import { QualityAssessor } from './quality-assessor.js';
4
- export class UniversalOptimizer {
5
- intentDetector;
6
- patternLibrary;
7
- qualityAssessor;
8
- constructor(intentDetector, patternLibrary, qualityAssessor) {
9
- this.intentDetector = intentDetector || new IntentDetector();
10
- this.patternLibrary = patternLibrary || new PatternLibrary();
11
- this.qualityAssessor = qualityAssessor || new QualityAssessor();
12
- }
13
- /**
14
- * v4.11: Optimize a prompt using Clavix Intelligence
15
- * @param prompt The prompt to optimize
16
- * @param mode The optimization mode ('improve' | 'prd' | 'conversational')
17
- * @param contextOverride Optional context override including depthLevel
18
- */
19
- async optimize(prompt, mode, contextOverride) {
20
- const startTime = Date.now();
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
- // v4.11: Get depth level (explicit or auto-detected)
30
- const depthLevel = contextOverride?.depthLevel;
31
- // Step 2: Select applicable patterns using mode-aware selection
32
- const patterns = mode === 'prd' || mode === 'conversational'
33
- ? this.patternLibrary.selectPatternsForMode(mode, intent, contextOverride?.phase, depthLevel)
34
- : this.patternLibrary.selectPatterns(intent, mode, depthLevel);
35
- // Step 3: Apply patterns sequentially
36
- let enhanced = prompt;
37
- const improvements = [];
38
- const appliedPatterns = [];
39
- const context = {
40
- intent,
41
- mode,
42
- originalPrompt: prompt,
43
- // v4.3.2: Extended context
44
- phase: contextOverride?.phase,
45
- documentType: contextOverride?.documentType,
46
- questionId: contextOverride?.questionId,
47
- // v4.11: Depth level for pattern selection
48
- depthLevel,
49
- };
50
- for (const pattern of patterns) {
51
- try {
52
- const result = pattern.apply(enhanced, context);
53
- if (result.applied) {
54
- enhanced = result.enhancedPrompt;
55
- improvements.push(result.improvement);
56
- appliedPatterns.push({
57
- name: pattern.name,
58
- description: pattern.description,
59
- impact: result.improvement.impact,
60
- });
61
- }
62
- }
63
- catch (error) {
64
- // Log error but continue with other patterns
65
- console.error(`Error applying pattern ${pattern.id}:`, error);
66
- }
67
- }
68
- // Step 4: Assess quality
69
- const quality = this.qualityAssessor.assess(prompt, enhanced, intent);
70
- // Step 5: Calculate processing time
71
- const processingTimeMs = Date.now() - startTime;
72
- return {
73
- original: prompt,
74
- enhanced,
75
- intent,
76
- quality,
77
- improvements,
78
- appliedPatterns,
79
- mode,
80
- depthUsed: depthLevel, // v4.11: Track which depth was used
81
- processingTimeMs,
82
- };
83
- }
84
- /**
85
- * v4.3.2: Validate a PRD answer and provide friendly suggestions
86
- * Uses adaptive threshold (< 50% quality triggers suggestions)
87
- */
88
- async validatePRDAnswer(answer, questionId) {
89
- const result = await this.optimize(answer, 'prd', {
90
- phase: 'question-validation',
91
- questionId,
92
- intent: 'prd-generation',
93
- });
94
- // Adaptive threshold: only suggest improvements for very vague answers
95
- if (result.quality.overall < 50) {
96
- return {
97
- needsClarification: true,
98
- suggestion: this.generateFriendlySuggestion(result, questionId),
99
- quality: result.quality.overall,
100
- };
101
- }
102
- return {
103
- needsClarification: false,
104
- quality: result.quality.overall,
105
- };
106
- }
107
- /**
108
- * v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
109
- */
110
- generateFriendlySuggestion(result, questionId) {
111
- const suggestions = {
112
- q1: ["the problem you're solving", 'why this matters', 'who benefits'],
113
- q2: ['specific features', 'user actions', 'key functionality'],
114
- q3: ['technologies', 'frameworks', 'constraints'],
115
- q4: ["what's explicitly out of scope", 'features to avoid', 'limitations'],
116
- q5: ['additional context', 'constraints', 'timeline considerations'],
117
- };
118
- const questionSuggestions = suggestions[questionId] || suggestions.q5;
119
- // Pick the most relevant suggestion based on what's missing
120
- let detail = questionSuggestions[0];
121
- if (result.quality.completeness < 40) {
122
- detail = questionSuggestions[Math.min(1, questionSuggestions.length - 1)];
123
- }
124
- if (result.quality.specificity < 40) {
125
- detail = questionSuggestions[Math.min(2, questionSuggestions.length - 1)];
126
- }
127
- return `adding ${detail} would help`;
128
- }
129
- /**
130
- * v4.11: Determine if comprehensive depth should be recommended
131
- * @deprecated Use analyzeEscalation() for more detailed analysis
132
- */
133
- shouldRecommendComprehensive(result) {
134
- const escalation = this.analyzeEscalation(result);
135
- return escalation.shouldEscalate;
136
- }
137
- /**
138
- * @deprecated Use shouldRecommendComprehensive() instead
139
- */
140
- shouldRecommendDeepMode(result) {
141
- return this.shouldRecommendComprehensive(result);
142
- }
143
- /**
144
- * v4.11: Analyze whether to escalate from standard to comprehensive depth
145
- * Uses multi-factor scoring for intelligent triage decisions
146
- *
147
- * IMPORTANT: Quality checks use the ORIGINAL prompt, not the enhanced one,
148
- * because triage decisions should be based on what the user wrote.
149
- */
150
- analyzeEscalation(result) {
151
- const reasons = [];
152
- let totalScore = 0;
153
- // Assess the ORIGINAL prompt's quality for triage decisions
154
- // (result.quality is for the enhanced prompt)
155
- const originalQuality = this.qualityAssessor.assessQuality(result.original, result.intent.primaryIntent);
156
- // Factor 1: Intent type (planning, prd-generation → +30 pts)
157
- const escalationIntents = ['planning', 'prd-generation'];
158
- if (escalationIntents.includes(result.intent.primaryIntent)) {
159
- const contribution = 30;
160
- totalScore += contribution;
161
- reasons.push({
162
- factor: 'intent-type',
163
- contribution,
164
- description: `${result.intent.primaryIntent} tasks benefit from comprehensive analysis`,
165
- });
166
- }
167
- // Factor 2: Low confidence (<60% → up to +20 pts)
168
- if (result.intent.confidence < 60) {
169
- const contribution = Math.round((60 - result.intent.confidence) / 3); // Max 20 pts
170
- totalScore += contribution;
171
- reasons.push({
172
- factor: 'low-confidence',
173
- contribution,
174
- description: `Intent detection confidence is low (${result.intent.confidence}%)`,
175
- });
176
- }
177
- // Factor 3: Overall quality score (<65 → up to +25 pts) - uses ORIGINAL quality
178
- if (originalQuality.overall < 65) {
179
- const contribution = Math.round((65 - originalQuality.overall) / 2.6); // Max ~25 pts
180
- totalScore += contribution;
181
- reasons.push({
182
- factor: 'low-quality',
183
- contribution,
184
- description: `Original prompt quality is below threshold (${Math.round(originalQuality.overall)}/100)`,
185
- });
186
- }
187
- // Factor 4: Low completeness (<60% → +15 pts) - uses ORIGINAL quality
188
- if (originalQuality.completeness < 60) {
189
- const contribution = 15;
190
- totalScore += contribution;
191
- reasons.push({
192
- factor: 'missing-completeness',
193
- contribution,
194
- description: `Missing required details (completeness: ${Math.round(originalQuality.completeness)}%)`,
195
- });
196
- }
197
- // Factor 5: Low specificity (<60% → +15 pts) - v4.0 new dimension, uses ORIGINAL quality
198
- if (originalQuality.specificity < 60) {
199
- const contribution = 15;
200
- totalScore += contribution;
201
- reasons.push({
202
- factor: 'low-specificity',
203
- contribution,
204
- description: `Prompt lacks concrete details (specificity: ${Math.round(originalQuality.specificity)}%)`,
205
- });
206
- }
207
- // Factor 6: High ambiguity (open-ended + needs structure → +20 pts)
208
- if (result.intent.characteristics.isOpenEnded && result.intent.characteristics.needsStructure) {
209
- const contribution = 20;
210
- totalScore += contribution;
211
- reasons.push({
212
- factor: 'high-ambiguity',
213
- contribution,
214
- description: 'Open-ended request without clear structure',
215
- });
216
- }
217
- // Factor 7: Length mismatch (short prompt + incomplete → +15 pts) - uses ORIGINAL quality
218
- if (result.original.length < 50 && originalQuality.completeness < 70) {
219
- const contribution = 15;
220
- totalScore += contribution;
221
- reasons.push({
222
- factor: 'length-mismatch',
223
- contribution,
224
- description: 'Very short prompt with incomplete requirements',
225
- });
226
- }
227
- // Factor 8: Complex intents that benefit from deep analysis
228
- const complexIntents = ['migration', 'security-review'];
229
- if (complexIntents.includes(result.intent.primaryIntent)) {
230
- const contribution = 20;
231
- totalScore += contribution;
232
- reasons.push({
233
- factor: 'complex-intent',
234
- contribution,
235
- description: `${result.intent.primaryIntent} requires thorough analysis`,
236
- });
237
- }
238
- // Determine escalation confidence
239
- // Thresholds: 45 for escalation, 60 for medium confidence, 75 for high confidence
240
- let escalationConfidence;
241
- if (totalScore >= 75) {
242
- escalationConfidence = 'high';
243
- }
244
- else if (totalScore >= 60) {
245
- escalationConfidence = 'medium';
246
- }
247
- else {
248
- escalationConfidence = 'low';
249
- }
250
- // v4.11: Generate comprehensive mode value proposition
251
- const comprehensiveValue = this.generateComprehensiveValue(result, reasons);
252
- return {
253
- // Threshold of 45 ensures planning prompts with missing completeness trigger escalation
254
- shouldEscalate: totalScore >= 45,
255
- escalationScore: Math.min(totalScore, 100),
256
- escalationConfidence,
257
- reasons,
258
- comprehensiveValue,
259
- };
260
- }
261
- /**
262
- * v4.11: Generate a user-friendly explanation of what comprehensive depth would provide
263
- */
264
- generateComprehensiveValue(result, reasons) {
265
- const benefits = [];
266
- // Based on primary issues, suggest specific comprehensive depth benefits
267
- const hasLowQuality = reasons.some((r) => r.factor === 'low-quality');
268
- const hasLowCompleteness = reasons.some((r) => r.factor === 'missing-completeness');
269
- const hasHighAmbiguity = reasons.some((r) => r.factor === 'high-ambiguity');
270
- const hasLowSpecificity = reasons.some((r) => r.factor === 'low-specificity');
271
- const isPlanningIntent = result.intent.primaryIntent === 'planning' ||
272
- result.intent.primaryIntent === 'prd-generation';
273
- if (isPlanningIntent) {
274
- benefits.push('structured implementation plan');
275
- }
276
- if (hasLowQuality || hasLowCompleteness) {
277
- benefits.push('comprehensive requirements extraction');
278
- }
279
- if (hasHighAmbiguity) {
280
- benefits.push('alternative approaches and trade-offs');
281
- }
282
- if (hasLowSpecificity) {
283
- benefits.push('concrete examples and specifications');
284
- }
285
- if (result.intent.primaryIntent === 'migration') {
286
- benefits.push('migration checklist and risk assessment');
287
- }
288
- if (result.intent.primaryIntent === 'security-review') {
289
- benefits.push('security checklist and threat analysis');
290
- }
291
- // Always include validation checklist for comprehensive depth
292
- benefits.push('validation checklist');
293
- if (benefits.length === 0) {
294
- return 'Comprehensive analysis provides thorough examination with alternative approaches.';
295
- }
296
- return `Comprehensive analysis would provide: ${benefits.join(', ')}.`;
297
- }
298
- /**
299
- * v4.11: Get recommendation message for user
300
- * Enhanced with escalation analysis for improve mode
301
- */
302
- getRecommendation(result) {
303
- // v4.11: Check for escalation only in improve mode with standard depth
304
- if (result.mode === 'improve' && result.depthUsed !== 'comprehensive') {
305
- const escalation = this.analyzeEscalation(result);
306
- if (escalation.shouldEscalate) {
307
- return `${escalation.comprehensiveValue} Run: /clavix:improve --comprehensive`;
308
- }
309
- }
310
- if (result.quality.overall >= 90) {
311
- return 'Excellent! Your prompt is AI-ready.';
312
- }
313
- if (result.quality.overall >= 80) {
314
- return 'Good quality. Ready to use!';
315
- }
316
- if (result.quality.overall >= 70) {
317
- return 'Decent quality. Consider the improvements listed above.';
318
- }
319
- return null;
320
- }
321
- /**
322
- * v4.11: Get detailed escalation recommendation with all reasons
323
- * Useful for verbose output or debugging
324
- */
325
- getDetailedRecommendation(result) {
326
- // v4.11: Check escalation for improve mode with non-comprehensive depth
327
- const escalation = result.mode === 'improve' && result.depthUsed !== 'comprehensive'
328
- ? this.analyzeEscalation(result)
329
- : undefined;
330
- let qualityLevel;
331
- let message;
332
- if (result.quality.overall >= 90) {
333
- qualityLevel = 'excellent';
334
- message = 'Excellent! Your prompt is AI-ready.';
335
- }
336
- else if (result.quality.overall >= 80) {
337
- qualityLevel = 'good';
338
- message = 'Good quality. Ready to use!';
339
- }
340
- else if (result.quality.overall >= 70) {
341
- qualityLevel = 'decent';
342
- message = 'Decent quality. Consider the improvements listed above.';
343
- }
344
- else {
345
- qualityLevel = 'needs-work';
346
- message = 'This prompt needs improvement for best results.';
347
- }
348
- if (escalation?.shouldEscalate) {
349
- message = `${escalation.comprehensiveValue} Run: /clavix:improve --comprehensive`;
350
- }
351
- return {
352
- message,
353
- escalation,
354
- qualityLevel,
355
- };
356
- }
357
- /**
358
- * v4.11: Get statistics about the optimizer
359
- */
360
- getStatistics() {
361
- const totalPatterns = this.patternLibrary.getPatternCount();
362
- const standardPatterns = this.patternLibrary.getPatternsByScope('standard').length;
363
- const comprehensivePatterns = this.patternLibrary.getPatternsByScope('comprehensive').length;
364
- return {
365
- totalPatterns,
366
- standardPatterns,
367
- comprehensivePatterns,
368
- };
369
- }
370
- }
371
- //# sourceMappingURL=universal-optimizer.js.map
@@ -1,76 +0,0 @@
1
- /**
2
- * PrdGenerator - Generates Product Requirements Documents from collected answers
3
- *
4
- * This class handles:
5
- * - Template loading and rendering with Handlebars
6
- * - Project name extraction
7
- * - File generation (full PRD and quick PRD)
8
- * - Output organization and timestamps
9
- */
10
- /**
11
- * Options for PRD generation
12
- */
13
- export interface PrdGenerationOptions {
14
- projectName?: string;
15
- outputDir?: string;
16
- timestamp?: Date;
17
- }
18
- /**
19
- * Metadata added to generated PRD files
20
- */
21
- export interface PrdMetadata {
22
- generatedAt: string;
23
- generatedBy: string;
24
- projectName: string;
25
- version: string;
26
- }
27
- /**
28
- * PrdGenerator class
29
- *
30
- * Generates comprehensive and quick-reference PRD documents
31
- * from collected question answers
32
- */
33
- export declare class PrdGenerator {
34
- private readonly templatesDir;
35
- private readonly defaultOutputDir;
36
- constructor();
37
- /**
38
- * Generate PRD documents from answers
39
- *
40
- * @param answers - Collected answers from QuestionEngine
41
- * @param options - Generation options
42
- * @returns Path to the output directory
43
- */
44
- generate(answers: Record<string, unknown>, options?: PrdGenerationOptions): Promise<string>;
45
- /**
46
- * Extract project name from answers
47
- *
48
- * Tries to infer a project name from the problem statement or user responses
49
- */
50
- extractProjectName(answers: Record<string, unknown>): string;
51
- /**
52
- * Extract a concise name from text (e.g., from problem statement)
53
- */
54
- private extractNameFromText;
55
- /**
56
- * Sanitize project name for use as directory name
57
- */
58
- private sanitizeProjectName;
59
- /**
60
- * Prepare answers for template rendering
61
- */
62
- private prepareAnswersForTemplate;
63
- /**
64
- * Generate full PRD document
65
- */
66
- generateFullPrd(data: Record<string, unknown>, outputPath: string): Promise<void>;
67
- /**
68
- * Generate quick PRD document
69
- */
70
- generateQuickPrd(data: Record<string, unknown>, outputPath: string): Promise<void>;
71
- /**
72
- * Format timestamp for display
73
- */
74
- private formatTimestamp;
75
- }
76
- //# sourceMappingURL=prd-generator.d.ts.map