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,505 +0,0 @@
1
- export class QualityAssessor {
2
- // v4.0: Intent-specific completeness requirements
3
- COMPLETENESS_REQUIREMENTS = {
4
- 'code-generation': ['objective', 'tech-stack', 'output-format', 'integration-points'],
5
- debugging: ['error-message', 'expected-behavior', 'actual-behavior', 'reproduction-steps'],
6
- testing: ['test-type', 'coverage-scope', 'edge-cases', 'mocking-needs'],
7
- migration: ['source-version', 'target-version', 'data-considerations', 'breaking-changes'],
8
- planning: ['problem-statement', 'goals', 'constraints', 'timeline'],
9
- refinement: ['current-state', 'desired-improvement', 'metrics', 'constraints'],
10
- documentation: ['audience', 'scope', 'format', 'examples-needed'],
11
- 'security-review': ['scope', 'threat-model', 'compliance-requirements', 'known-issues'],
12
- learning: ['current-knowledge', 'learning-goal', 'preferred-depth', 'context'],
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'],
16
- };
17
- /**
18
- * Assess quality of a prompt (backward compatibility wrapper)
19
- * @deprecated Use assess() method instead for full quality metrics
20
- * v4.0: Now includes specificity in return type
21
- */
22
- assessQuality(prompt, intent) {
23
- // Create minimal IntentAnalysis from string intent
24
- const intentAnalysis = {
25
- primaryIntent: intent,
26
- confidence: 100,
27
- characteristics: {
28
- hasCodeContext: false,
29
- hasTechnicalTerms: false,
30
- isOpenEnded: false,
31
- needsStructure: false,
32
- },
33
- };
34
- // Call existing assess method with same prompt for both original and enhanced
35
- const result = this.assess(prompt, prompt, intentAnalysis);
36
- // Return only the numeric scores (exclude strengths and improvements arrays)
37
- return {
38
- clarity: result.clarity,
39
- efficiency: result.efficiency,
40
- structure: result.structure,
41
- completeness: result.completeness,
42
- actionability: result.actionability,
43
- specificity: result.specificity,
44
- overall: result.overall,
45
- };
46
- }
47
- /**
48
- * Assess quality of a prompt
49
- * v4.0: Now includes specificity as 6th quality dimension
50
- */
51
- assess(original, enhanced, intent) {
52
- const clarity = this.assessClarity(enhanced, intent);
53
- const efficiency = this.assessEfficiency(enhanced);
54
- const structure = this.assessStructure(enhanced, intent);
55
- const completeness = this.assessCompleteness(enhanced, intent);
56
- const actionability = this.assessActionability(enhanced, intent);
57
- const specificity = this.assessSpecificity(enhanced, intent);
58
- const overall = this.calculateOverall({ clarity, efficiency, structure, completeness, actionability, specificity }, intent);
59
- const strengths = this.identifyStrengths(enhanced, {
60
- clarity,
61
- efficiency,
62
- structure,
63
- completeness,
64
- actionability,
65
- specificity,
66
- });
67
- const improvements = this.identifyImprovements(original, enhanced);
68
- return {
69
- clarity,
70
- efficiency,
71
- structure,
72
- completeness,
73
- actionability,
74
- specificity,
75
- overall,
76
- strengths,
77
- improvements,
78
- };
79
- }
80
- assessClarity(prompt, intent) {
81
- let score = 100;
82
- const lowerPrompt = prompt.toLowerCase();
83
- // Check for objective statement
84
- if (!this.hasObjective(prompt)) {
85
- score -= 20;
86
- }
87
- // Check for technical specifications (for code generation)
88
- if (intent.primaryIntent === 'code-generation') {
89
- if (!this.hasTechStack(prompt)) {
90
- score -= 15;
91
- }
92
- if (!this.hasOutputFormat(prompt)) {
93
- score -= 15;
94
- }
95
- }
96
- // Check for success criteria
97
- if (!this.hasSuccessCriteria(prompt)) {
98
- score -= 10;
99
- }
100
- // Check for vague language
101
- const vagueTerms = ['something', 'somehow', 'maybe', 'kind of', 'sort of', 'stuff', 'things'];
102
- const vagueCount = vagueTerms.filter((term) => lowerPrompt.includes(term)).length;
103
- score -= vagueCount * 5;
104
- return Math.max(0, Math.min(100, score));
105
- }
106
- assessEfficiency(prompt) {
107
- let score = 100;
108
- // Check for pleasantries
109
- const pleasantries = ['please', 'thank you', 'thanks', 'could you', 'would you'];
110
- const lowerPrompt = prompt.toLowerCase();
111
- const pleasantryCount = pleasantries.filter((p) => lowerPrompt.includes(p)).length;
112
- score -= pleasantryCount * 5;
113
- // Check for fluff words
114
- const fluffWords = ['very', 'really', 'just', 'basically', 'simply', 'actually', 'literally'];
115
- const fluffCount = fluffWords.filter((w) => lowerPrompt.includes(w)).length;
116
- score -= fluffCount * 3;
117
- // Calculate signal-to-noise ratio
118
- const words = prompt.split(/\s+/);
119
- const signalWords = this.countSignalWords(prompt);
120
- const ratio = words.length > 0 ? signalWords / words.length : 0;
121
- if (ratio < 0.6) {
122
- score -= 30;
123
- }
124
- else if (ratio < 0.75) {
125
- score -= 15;
126
- }
127
- return Math.max(0, Math.min(100, score));
128
- }
129
- assessStructure(prompt, intent) {
130
- let score = 100;
131
- // Check for logical flow: context → requirements → constraints → output
132
- const hasContext = this.hasSection(prompt, ['context', 'background', 'currently']);
133
- const hasRequirements = this.hasSection(prompt, ['requirement', 'need', 'should', 'must']);
134
- const hasOutput = this.hasSection(prompt, ['output', 'result', 'deliverable', 'expected']);
135
- // Penalize missing sections based on intent
136
- if (intent.primaryIntent !== 'refinement' && !hasContext) {
137
- score -= 20;
138
- }
139
- if (!hasRequirements) {
140
- score -= 25;
141
- }
142
- if (!hasOutput) {
143
- score -= 15;
144
- }
145
- // Check for markdown structure
146
- const hasHeaders = /^#+\s+/m.test(prompt);
147
- if (hasHeaders) {
148
- score += 10; // Bonus for using headers
149
- }
150
- return Math.max(0, Math.min(100, score));
151
- }
152
- assessCompleteness(prompt, intent) {
153
- let score = 100;
154
- const lowerPrompt = prompt.toLowerCase();
155
- // Intent-specific completeness checks
156
- if (intent.primaryIntent === 'code-generation') {
157
- if (!this.hasTechStack(prompt))
158
- score -= 20;
159
- if (!this.hasInputOutput(prompt))
160
- score -= 20;
161
- if (!this.hasEdgeCases(prompt))
162
- score -= 10;
163
- }
164
- else if (intent.primaryIntent === 'planning') {
165
- if (!this.hasProblemStatement(prompt))
166
- score -= 25;
167
- if (!this.hasGoal(prompt))
168
- score -= 25;
169
- if (!this.hasConstraints(prompt))
170
- score -= 15;
171
- }
172
- else if (intent.primaryIntent === 'debugging') {
173
- if (!lowerPrompt.includes('error'))
174
- score -= 20;
175
- if (!this.hasExpectedBehavior(prompt))
176
- score -= 15;
177
- if (!this.hasActualBehavior(prompt))
178
- score -= 15;
179
- }
180
- return Math.max(0, Math.min(100, score));
181
- }
182
- assessActionability(prompt, intent) {
183
- let score = 100;
184
- const lowerPrompt = prompt.toLowerCase();
185
- // Check for ambiguous terms
186
- const ambiguousTerms = ['etc', 'and so on', 'or something', 'whatever', 'anything'];
187
- const ambiguousCount = ambiguousTerms.filter((term) => lowerPrompt.includes(term)).length;
188
- score -= ambiguousCount * 10;
189
- // Check for concrete examples
190
- const hasExamples = this.hasExamples(prompt);
191
- if (!hasExamples && intent.primaryIntent === 'code-generation') {
192
- score -= 15;
193
- }
194
- // Check for clear success criteria
195
- if (!this.hasSuccessCriteria(prompt)) {
196
- score -= 20;
197
- }
198
- // Check for too many questions (makes it un-actionable)
199
- const questionCount = (prompt.match(/\?/g) || []).length;
200
- if (questionCount > 3) {
201
- score -= questionCount * 5;
202
- }
203
- return Math.max(0, Math.min(100, score));
204
- }
205
- /**
206
- * v4.0: Assess specificity - How concrete and precise is the prompt?
207
- * Penalizes vague language, rewards concrete indicators
208
- */
209
- assessSpecificity(prompt, intent) {
210
- let score = 100;
211
- const lowerPrompt = prompt.toLowerCase();
212
- const words = prompt.split(/\s+/);
213
- // Penalize vague terms heavily (-15 each)
214
- const vagueTerms = ['something', 'stuff', 'things', 'whatever', 'somehow', 'somewhere'];
215
- const vagueCount = vagueTerms.filter((term) => lowerPrompt.includes(term)).length;
216
- score -= vagueCount * 15;
217
- // Penalize undefined pronouns in short prompts (-5 each)
218
- // Only apply for shorter prompts where pronouns likely lack antecedents
219
- if (words.length < 50) {
220
- const undefinedPronouns = ['it', 'this', 'that', 'they', 'them'];
221
- // Check if pronouns appear without clear referents (simplified check)
222
- const pronounCount = undefinedPronouns.filter((pronoun) => {
223
- const regex = new RegExp(`\\b${pronoun}\\b`, 'gi');
224
- return regex.test(prompt);
225
- }).length;
226
- // Only penalize if there are multiple pronouns in a short prompt
227
- if (pronounCount > 2) {
228
- score -= (pronounCount - 2) * 5;
229
- }
230
- }
231
- // Reward concrete indicators
232
- // Numbers (+10) - versions, counts, sizes, etc.
233
- const hasNumbers = /\b\d+(\.\d+)?\b/.test(prompt);
234
- if (hasNumbers) {
235
- score += 10;
236
- }
237
- // File paths (+10)
238
- const hasFilePaths = /[/\\][\w.-]+[/\\]?|\.\w{2,4}\b|\.\/|\.\.\//.test(prompt);
239
- if (hasFilePaths) {
240
- score += 10;
241
- }
242
- // Technical terms (+5) - specific technologies, frameworks, concepts
243
- const technicalTerms = [
244
- 'api',
245
- 'endpoint',
246
- 'database',
247
- 'schema',
248
- 'component',
249
- 'function',
250
- 'class',
251
- 'interface',
252
- 'module',
253
- 'service',
254
- 'controller',
255
- 'model',
256
- 'view',
257
- 'route',
258
- 'middleware',
259
- 'hook',
260
- 'state',
261
- 'props',
262
- 'query',
263
- 'mutation',
264
- 'resolver',
265
- ];
266
- const techTermCount = technicalTerms.filter((term) => lowerPrompt.includes(term)).length;
267
- if (techTermCount > 0) {
268
- score += Math.min(techTermCount * 5, 15); // Cap bonus at +15
269
- }
270
- // Code blocks indicate specificity (+10)
271
- if (prompt.includes('```')) {
272
- score += 10;
273
- }
274
- // Specific identifiers (camelCase, PascalCase, snake_case) (+5)
275
- const hasIdentifiers = /\b[a-z]+[A-Z][a-zA-Z]*\b|\b[A-Z][a-z]+[A-Z][a-zA-Z]*\b|\b[a-z]+_[a-z]+\b/.test(prompt);
276
- if (hasIdentifiers) {
277
- score += 5;
278
- }
279
- // Intent-specific specificity requirements
280
- if (intent.primaryIntent === 'code-generation' || intent.primaryIntent === 'debugging') {
281
- // These intents require high specificity
282
- if (!hasFilePaths && !prompt.includes('```')) {
283
- score -= 10;
284
- }
285
- }
286
- else if (intent.primaryIntent === 'migration') {
287
- // Migration needs version numbers
288
- const hasVersions = /v?\d+\.\d+(\.\d+)?|version\s*\d+/i.test(prompt);
289
- if (!hasVersions) {
290
- score -= 15;
291
- }
292
- }
293
- return Math.max(0, Math.min(100, score));
294
- }
295
- calculateOverall(scores, intent) {
296
- // v4.0: Intent-specific weights including specificity
297
- if (intent.primaryIntent === 'code-generation') {
298
- // Code generation benefits most from specificity
299
- return (scores.clarity * 0.2 +
300
- scores.completeness * 0.25 +
301
- scores.actionability * 0.2 +
302
- scores.specificity * 0.15 +
303
- scores.efficiency * 0.1 +
304
- scores.structure * 0.1);
305
- }
306
- else if (intent.primaryIntent === 'planning') {
307
- // Planning needs structure and completeness, less specificity
308
- return (scores.structure * 0.25 +
309
- scores.completeness * 0.25 +
310
- scores.clarity * 0.2 +
311
- scores.specificity * 0.1 +
312
- scores.efficiency * 0.1 +
313
- scores.actionability * 0.1);
314
- }
315
- else if (intent.primaryIntent === 'debugging') {
316
- // Debugging requires high specificity and actionability
317
- return (scores.actionability * 0.25 +
318
- scores.completeness * 0.25 +
319
- scores.specificity * 0.2 +
320
- scores.clarity * 0.15 +
321
- scores.structure * 0.1 +
322
- scores.efficiency * 0.05);
323
- }
324
- else if (intent.primaryIntent === 'migration') {
325
- // Migration needs high specificity (versions, paths)
326
- return (scores.specificity * 0.25 +
327
- scores.completeness * 0.25 +
328
- scores.clarity * 0.2 +
329
- scores.actionability * 0.15 +
330
- scores.structure * 0.1 +
331
- scores.efficiency * 0.05);
332
- }
333
- else if (intent.primaryIntent === 'testing') {
334
- // Testing needs specificity and completeness
335
- return (scores.completeness * 0.25 +
336
- scores.specificity * 0.2 +
337
- scores.actionability * 0.2 +
338
- scores.clarity * 0.15 +
339
- scores.structure * 0.1 +
340
- scores.efficiency * 0.1);
341
- }
342
- else if (intent.primaryIntent === 'security-review') {
343
- // Security review needs completeness and specificity
344
- return (scores.completeness * 0.25 +
345
- scores.specificity * 0.2 +
346
- scores.clarity * 0.2 +
347
- scores.actionability * 0.15 +
348
- scores.structure * 0.1 +
349
- scores.efficiency * 0.1);
350
- }
351
- else if (intent.primaryIntent === 'learning') {
352
- // Learning is less about specificity, more about clarity
353
- return (scores.clarity * 0.3 +
354
- scores.structure * 0.2 +
355
- scores.completeness * 0.2 +
356
- scores.specificity * 0.1 +
357
- scores.actionability * 0.1 +
358
- scores.efficiency * 0.1);
359
- }
360
- // Default weights (refinement, documentation, prd-generation)
361
- return (scores.clarity * 0.18 +
362
- scores.efficiency * 0.12 +
363
- scores.structure * 0.18 +
364
- scores.completeness * 0.22 +
365
- scores.actionability * 0.18 +
366
- scores.specificity * 0.12);
367
- }
368
- identifyStrengths(prompt, scores) {
369
- const strengths = [];
370
- if (scores.clarity >= 85)
371
- strengths.push('Clear objective and goals');
372
- if (scores.efficiency >= 85)
373
- strengths.push('Concise and focused');
374
- if (scores.structure >= 85)
375
- strengths.push('Well-structured with logical flow');
376
- if (scores.completeness >= 85)
377
- strengths.push('Comprehensive with all necessary details');
378
- if (scores.actionability >= 85)
379
- strengths.push('Immediately actionable');
380
- if (scores.specificity >= 85)
381
- strengths.push('Highly specific with concrete details');
382
- return strengths;
383
- }
384
- identifyImprovements(original, enhanced) {
385
- const improvements = [];
386
- // This is a simplified version - in real implementation,
387
- // we'd track what changed between original and enhanced
388
- if (enhanced.length > original.length * 1.2) {
389
- improvements.push('Added missing context and specifications');
390
- }
391
- if (enhanced.includes('# Objective') && !original.includes('# Objective')) {
392
- improvements.push('Added clear objective statement');
393
- }
394
- if (enhanced.includes('# Technical Constraints') &&
395
- !original.includes('# Technical Constraints')) {
396
- improvements.push('Added technical context');
397
- }
398
- return improvements;
399
- }
400
- // Helper methods
401
- hasObjective(prompt) {
402
- return /objective|goal|purpose|need to|want to|^#+\s*objective/im.test(prompt);
403
- }
404
- hasTechStack(prompt) {
405
- const techTerms = [
406
- 'python',
407
- 'javascript',
408
- 'typescript',
409
- 'java',
410
- 'rust',
411
- 'go',
412
- 'php',
413
- 'react',
414
- 'vue',
415
- 'angular',
416
- 'django',
417
- 'flask',
418
- 'express',
419
- 'spring',
420
- ];
421
- const lowerPrompt = prompt.toLowerCase();
422
- return techTerms.some((term) => lowerPrompt.includes(term));
423
- }
424
- hasOutputFormat(prompt) {
425
- return /output|return|result|format|structure|response/i.test(prompt);
426
- }
427
- hasSuccessCriteria(prompt) {
428
- return /success|criteria|metric|measure|test|verify|validate/i.test(prompt);
429
- }
430
- hasSection(prompt, keywords) {
431
- const lowerPrompt = prompt.toLowerCase();
432
- return keywords.some((keyword) => lowerPrompt.includes(keyword));
433
- }
434
- countSignalWords(prompt) {
435
- // Count words that carry meaning (not stop words)
436
- const stopWords = new Set([
437
- 'the',
438
- 'a',
439
- 'an',
440
- 'and',
441
- 'or',
442
- 'but',
443
- 'in',
444
- 'on',
445
- 'at',
446
- 'to',
447
- 'for',
448
- 'of',
449
- 'with',
450
- 'by',
451
- 'from',
452
- 'as',
453
- 'is',
454
- 'was',
455
- 'are',
456
- 'were',
457
- 'been',
458
- 'be',
459
- 'have',
460
- 'has',
461
- 'had',
462
- 'do',
463
- 'does',
464
- 'did',
465
- 'will',
466
- 'would',
467
- 'could',
468
- 'should',
469
- 'may',
470
- 'might',
471
- 'can',
472
- 'this',
473
- 'that',
474
- 'these',
475
- 'those',
476
- ]);
477
- const words = prompt.toLowerCase().split(/\s+/);
478
- return words.filter((word) => !stopWords.has(word) && word.length > 2).length;
479
- }
480
- hasInputOutput(prompt) {
481
- return /input|output|parameter|argument|return/i.test(prompt);
482
- }
483
- hasEdgeCases(prompt) {
484
- return /edge case|empty|null|zero|negative|invalid|error/i.test(prompt);
485
- }
486
- hasProblemStatement(prompt) {
487
- return /problem|issue|challenge|currently|pain point/i.test(prompt);
488
- }
489
- hasGoal(prompt) {
490
- return /goal|objective|aim|purpose|achieve|accomplish/i.test(prompt);
491
- }
492
- hasConstraints(prompt) {
493
- return /constraint|limit|must not|cannot|within|maximum|minimum/i.test(prompt);
494
- }
495
- hasExpectedBehavior(prompt) {
496
- return /expected|should|supposed to|intended/i.test(prompt);
497
- }
498
- hasActualBehavior(prompt) {
499
- return /actual|currently|instead|but|however|getting/i.test(prompt);
500
- }
501
- hasExamples(prompt) {
502
- return /example|for instance|such as|like|e\.g\.|```/i.test(prompt);
503
- }
504
- }
505
- //# sourceMappingURL=quality-assessor.js.map
@@ -1,111 +0,0 @@
1
- export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning' | 'summarization';
2
- export type QualityDimension = 'clarity' | 'efficiency' | 'structure' | 'completeness' | 'actionability' | 'specificity';
3
- export type ImpactLevel = 'low' | 'medium' | 'high';
4
- export type OptimizationMode = 'improve' | 'prd' | 'conversational';
5
- export type DepthLevel = 'standard' | 'comprehensive';
6
- export type OptimizationPhase = 'question-validation' | 'output-generation' | 'conversation-tracking' | 'summarization';
7
- export type DocumentType = 'full-prd' | 'quick-prd' | 'mini-prd' | 'prompt';
8
- export interface IntentAnalysis {
9
- primaryIntent: PromptIntent;
10
- confidence: number;
11
- characteristics: {
12
- hasCodeContext: boolean;
13
- hasTechnicalTerms: boolean;
14
- isOpenEnded: boolean;
15
- needsStructure: boolean;
16
- };
17
- suggestedMode?: OptimizationMode;
18
- }
19
- export interface SecondaryIntent {
20
- intent: PromptIntent;
21
- confidence: number;
22
- }
23
- export type IntentAmbiguity = 'low' | 'medium' | 'high';
24
- export interface EnhancedIntentAnalysis extends IntentAnalysis {
25
- secondaryIntents: SecondaryIntent[];
26
- intentAmbiguity: IntentAmbiguity;
27
- }
28
- export interface EscalationReason {
29
- factor: string;
30
- contribution: number;
31
- description: string;
32
- }
33
- export interface EscalationAnalysis {
34
- shouldEscalate: boolean;
35
- escalationScore: number;
36
- escalationConfidence: 'high' | 'medium' | 'low';
37
- reasons: EscalationReason[];
38
- comprehensiveValue: string;
39
- }
40
- export interface QualityMetrics {
41
- clarity: number;
42
- efficiency: number;
43
- structure: number;
44
- completeness: number;
45
- actionability: number;
46
- specificity: number;
47
- overall: number;
48
- strengths: string[];
49
- improvements: string[];
50
- remainingIssues?: string[];
51
- }
52
- export interface Improvement {
53
- dimension: QualityDimension;
54
- description: string;
55
- impact: ImpactLevel;
56
- }
57
- export interface PatternContext {
58
- intent: IntentAnalysis;
59
- mode: OptimizationMode;
60
- originalPrompt: string;
61
- phase?: OptimizationPhase;
62
- documentType?: DocumentType;
63
- questionId?: string;
64
- depthLevel?: DepthLevel;
65
- }
66
- export interface PatternResult {
67
- enhancedPrompt: string;
68
- improvement: Improvement;
69
- applied: boolean;
70
- }
71
- export interface PatternSummary {
72
- name: string;
73
- description: string;
74
- impact: ImpactLevel;
75
- }
76
- export interface OptimizationResult {
77
- original: string;
78
- enhanced: string;
79
- intent: IntentAnalysis;
80
- quality: QualityMetrics;
81
- improvements: Improvement[];
82
- appliedPatterns: PatternSummary[];
83
- mode: OptimizationMode;
84
- depthUsed?: DepthLevel;
85
- processingTimeMs: number;
86
- }
87
- export interface AlternativeApproach {
88
- title: string;
89
- description: string;
90
- prompt: string;
91
- }
92
- export interface AlternativeStructure {
93
- type: 'step-by-step' | 'template-based' | 'example-driven';
94
- title: string;
95
- content: string;
96
- }
97
- export interface ValidationItem {
98
- description: string;
99
- checked: boolean;
100
- }
101
- export interface EdgeCase {
102
- scenario: string;
103
- consideration: string;
104
- }
105
- export interface ComprehensiveModeExtras {
106
- alternatives: AlternativeApproach[];
107
- structures: AlternativeStructure[];
108
- validation: ValidationItem[];
109
- edgeCases: EdgeCase[];
110
- }
111
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +0,0 @@
1
- // Core types for the Clavix Intelligence system
2
- export {};
3
- //# sourceMappingURL=types.js.map