clavix 2.8.2 → 3.0.1
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/README.md +26 -6
- package/dist/cli/commands/deep.d.ts +3 -4
- package/dist/cli/commands/deep.js +162 -261
- package/dist/cli/commands/fast.d.ts +3 -4
- package/dist/cli/commands/fast.js +126 -303
- package/dist/cli/commands/init.js +184 -22
- package/dist/cli/commands/prd.d.ts +7 -6
- package/dist/cli/commands/prd.js +113 -132
- package/dist/cli/commands/summarize.d.ts +1 -12
- package/dist/cli/commands/summarize.js +63 -131
- package/dist/core/intelligence/index.d.ts +10 -0
- package/dist/core/intelligence/index.js +13 -0
- package/dist/core/intelligence/intent-detector.d.ts +33 -0
- package/dist/core/intelligence/intent-detector.js +311 -0
- package/dist/core/intelligence/pattern-library.d.ts +44 -0
- package/dist/core/intelligence/pattern-library.js +103 -0
- package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +27 -0
- package/dist/core/intelligence/patterns/actionability-enhancer.js +162 -0
- package/dist/core/intelligence/patterns/base-pattern.d.ts +31 -0
- package/dist/core/intelligence/patterns/base-pattern.js +39 -0
- package/dist/core/intelligence/patterns/completeness-validator.d.ts +27 -0
- package/dist/core/intelligence/patterns/completeness-validator.js +135 -0
- package/dist/core/intelligence/patterns/conciseness-filter.d.ts +12 -0
- package/dist/core/intelligence/patterns/conciseness-filter.js +61 -0
- package/dist/core/intelligence/patterns/objective-clarifier.d.ts +14 -0
- package/dist/core/intelligence/patterns/objective-clarifier.js +97 -0
- package/dist/core/intelligence/patterns/structure-organizer.d.ts +31 -0
- package/dist/core/intelligence/patterns/structure-organizer.js +185 -0
- package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +16 -0
- package/dist/core/intelligence/patterns/technical-context-enricher.js +132 -0
- package/dist/core/intelligence/quality-assessor.d.ts +42 -0
- package/dist/core/intelligence/quality-assessor.js +296 -0
- package/dist/core/intelligence/types.d.ts +81 -0
- package/dist/core/intelligence/types.js +3 -0
- package/dist/core/intelligence/universal-optimizer.d.ts +31 -0
- package/dist/core/intelligence/universal-optimizer.js +118 -0
- package/dist/core/prd-generator.d.ts +2 -2
- package/dist/core/task-manager.js +18 -5
- package/dist/templates/agents/agents.md +2 -2
- package/dist/templates/agents/copilot-instructions.md +15 -15
- package/dist/templates/agents/octo.md +35 -30
- package/dist/templates/agents/warp.md +3 -3
- package/dist/templates/full-prd-template.hbs +1 -1
- package/dist/templates/prd-questions.md +1 -1
- package/dist/templates/quick-prd-template.hbs +1 -1
- package/dist/templates/slash-commands/_canonical/deep.md +261 -122
- package/dist/templates/slash-commands/_canonical/fast.md +101 -69
- package/dist/templates/slash-commands/_canonical/implement.md +1 -1
- package/dist/templates/slash-commands/_canonical/plan.md +12 -12
- package/dist/templates/slash-commands/_canonical/prd.md +34 -24
- package/dist/templates/slash-commands/_canonical/start.md +13 -12
- package/dist/templates/slash-commands/_canonical/summarize.md +42 -25
- package/dist/utils/error-utils.d.ts +7 -0
- package/dist/utils/error-utils.js +17 -0
- package/package.json +21 -12
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
export class ObjectiveClarifier extends BasePattern {
|
|
3
|
+
id = 'objective-clarifier';
|
|
4
|
+
name = 'Objective Clarifier';
|
|
5
|
+
description = 'Extracts or infers clear goal statement';
|
|
6
|
+
applicableIntents = ['code-generation', 'planning', 'refinement', 'debugging', 'documentation'];
|
|
7
|
+
mode = 'both';
|
|
8
|
+
priority = 9;
|
|
9
|
+
apply(prompt, context) {
|
|
10
|
+
// Check if prompt already has clear objective section
|
|
11
|
+
if (this.hasExplicitObjective(prompt)) {
|
|
12
|
+
return {
|
|
13
|
+
enhancedPrompt: prompt,
|
|
14
|
+
improvement: {
|
|
15
|
+
dimension: 'clarity',
|
|
16
|
+
description: 'Objective already clearly stated',
|
|
17
|
+
impact: 'low'
|
|
18
|
+
},
|
|
19
|
+
applied: false
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Extract or infer objective
|
|
23
|
+
const objective = this.extractObjective(prompt, context.intent.primaryIntent);
|
|
24
|
+
// If we couldn't infer a clear objective, just ensure it's at the top
|
|
25
|
+
if (!objective) {
|
|
26
|
+
return {
|
|
27
|
+
enhancedPrompt: prompt,
|
|
28
|
+
improvement: {
|
|
29
|
+
dimension: 'clarity',
|
|
30
|
+
description: 'Could not infer clear objective',
|
|
31
|
+
impact: 'low'
|
|
32
|
+
},
|
|
33
|
+
applied: false
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Add objective section
|
|
37
|
+
const enhanced = `# Objective\n${objective}\n\n${prompt}`;
|
|
38
|
+
return {
|
|
39
|
+
enhancedPrompt: enhanced,
|
|
40
|
+
improvement: {
|
|
41
|
+
dimension: 'clarity',
|
|
42
|
+
description: 'Added clear objective statement',
|
|
43
|
+
impact: 'high'
|
|
44
|
+
},
|
|
45
|
+
applied: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
hasExplicitObjective(prompt) {
|
|
49
|
+
const objectiveMarkers = [
|
|
50
|
+
/^#+ objective/im,
|
|
51
|
+
/^objective:/im,
|
|
52
|
+
/^goal:/im,
|
|
53
|
+
/^purpose:/im
|
|
54
|
+
];
|
|
55
|
+
return objectiveMarkers.some(marker => marker.test(prompt));
|
|
56
|
+
}
|
|
57
|
+
extractObjective(prompt, intent) {
|
|
58
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
59
|
+
// Look for explicit goal statements
|
|
60
|
+
const goalPatterns = [
|
|
61
|
+
/(?:i need to|i want to|i'm trying to|goal is to|objective is to|purpose is to)\s+(.+?)(?:\.|$)/i,
|
|
62
|
+
/(?:create|build|make|implement|develop|write)\s+(.+?)(?:\.|$)/i
|
|
63
|
+
];
|
|
64
|
+
for (const pattern of goalPatterns) {
|
|
65
|
+
const match = prompt.match(pattern);
|
|
66
|
+
if (match && match[1]) {
|
|
67
|
+
return match[1].trim();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Intent-specific inference
|
|
71
|
+
if (intent === 'code-generation') {
|
|
72
|
+
if (lowerPrompt.includes('function')) {
|
|
73
|
+
return 'Create a function that meets the specified requirements';
|
|
74
|
+
}
|
|
75
|
+
else if (lowerPrompt.includes('component')) {
|
|
76
|
+
return 'Build a component with the described functionality';
|
|
77
|
+
}
|
|
78
|
+
else if (lowerPrompt.includes('api')) {
|
|
79
|
+
return 'Implement an API endpoint as specified';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (intent === 'debugging') {
|
|
83
|
+
return 'Fix the identified error or bug';
|
|
84
|
+
}
|
|
85
|
+
else if (intent === 'refinement') {
|
|
86
|
+
return 'Improve and optimize the existing code';
|
|
87
|
+
}
|
|
88
|
+
else if (intent === 'documentation') {
|
|
89
|
+
return 'Provide clear documentation and explanation';
|
|
90
|
+
}
|
|
91
|
+
else if (intent === 'planning') {
|
|
92
|
+
return 'Plan and design the described system or feature';
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=objective-clarifier.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Structure Organizer Pattern
|
|
5
|
+
*
|
|
6
|
+
* Reorders information logically following the flow:
|
|
7
|
+
* Objective → Requirements → Technical Constraints → Expected Output → Success Criteria
|
|
8
|
+
*
|
|
9
|
+
* Priority: HIGH (8)
|
|
10
|
+
*/
|
|
11
|
+
export declare class StructureOrganizer extends BasePattern {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
applicableIntents: PromptIntent[];
|
|
16
|
+
mode: 'fast' | 'deep' | 'both';
|
|
17
|
+
priority: number;
|
|
18
|
+
apply(prompt: string, context: PatternContext): PatternResult;
|
|
19
|
+
private detectSections;
|
|
20
|
+
private isWellOrdered;
|
|
21
|
+
private isDisorganized;
|
|
22
|
+
private extractObjective;
|
|
23
|
+
private extractRequirements;
|
|
24
|
+
private extractTechnical;
|
|
25
|
+
private extractExpectedOutput;
|
|
26
|
+
private extractSuccessCriteria;
|
|
27
|
+
private extractConstraints;
|
|
28
|
+
private extractOther;
|
|
29
|
+
private addSectionHeaders;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=structure-organizer.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* Structure Organizer Pattern
|
|
4
|
+
*
|
|
5
|
+
* Reorders information logically following the flow:
|
|
6
|
+
* Objective → Requirements → Technical Constraints → Expected Output → Success Criteria
|
|
7
|
+
*
|
|
8
|
+
* Priority: HIGH (8)
|
|
9
|
+
*/
|
|
10
|
+
export class StructureOrganizer extends BasePattern {
|
|
11
|
+
id = 'structure-organizer';
|
|
12
|
+
name = 'Structure Organizer';
|
|
13
|
+
description = 'Reorders information into logical sections';
|
|
14
|
+
applicableIntents = ['code-generation', 'planning', 'refinement', 'debugging', 'documentation'];
|
|
15
|
+
mode = 'both';
|
|
16
|
+
priority = 8; // High priority
|
|
17
|
+
apply(prompt, context) {
|
|
18
|
+
// Detect existing sections
|
|
19
|
+
const sections = this.detectSections(prompt);
|
|
20
|
+
// If already well-structured, minimal changes
|
|
21
|
+
if (sections.length === 0 || this.isWellOrdered(sections)) {
|
|
22
|
+
const enhanced = this.addSectionHeaders(prompt);
|
|
23
|
+
return {
|
|
24
|
+
enhancedPrompt: enhanced,
|
|
25
|
+
improvement: {
|
|
26
|
+
dimension: 'structure',
|
|
27
|
+
description: 'Added section headers for clarity',
|
|
28
|
+
impact: 'low'
|
|
29
|
+
},
|
|
30
|
+
applied: enhanced !== prompt
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Extract content by type
|
|
34
|
+
const objective = this.extractObjective(prompt);
|
|
35
|
+
const requirements = this.extractRequirements(prompt);
|
|
36
|
+
const technical = this.extractTechnical(prompt);
|
|
37
|
+
const expectedOutput = this.extractExpectedOutput(prompt);
|
|
38
|
+
const successCriteria = this.extractSuccessCriteria(prompt);
|
|
39
|
+
const constraints = this.extractConstraints(prompt);
|
|
40
|
+
const other = this.extractOther(prompt, [objective, requirements, technical, expectedOutput, successCriteria, constraints]);
|
|
41
|
+
// Build structured output
|
|
42
|
+
let structured = '';
|
|
43
|
+
let sectionsCount = 0;
|
|
44
|
+
if (objective) {
|
|
45
|
+
structured += '## Objective\n\n' + objective + '\n\n';
|
|
46
|
+
sectionsCount++;
|
|
47
|
+
}
|
|
48
|
+
if (requirements) {
|
|
49
|
+
structured += '## Requirements\n\n' + requirements + '\n\n';
|
|
50
|
+
sectionsCount++;
|
|
51
|
+
}
|
|
52
|
+
if (technical) {
|
|
53
|
+
structured += '## Technical Constraints\n\n' + technical + '\n\n';
|
|
54
|
+
sectionsCount++;
|
|
55
|
+
}
|
|
56
|
+
if (constraints) {
|
|
57
|
+
structured += '## Constraints\n\n' + constraints + '\n\n';
|
|
58
|
+
sectionsCount++;
|
|
59
|
+
}
|
|
60
|
+
if (expectedOutput) {
|
|
61
|
+
structured += '## Expected Output\n\n' + expectedOutput + '\n\n';
|
|
62
|
+
sectionsCount++;
|
|
63
|
+
}
|
|
64
|
+
if (successCriteria) {
|
|
65
|
+
structured += '## Success Criteria\n\n' + successCriteria + '\n\n';
|
|
66
|
+
sectionsCount++;
|
|
67
|
+
}
|
|
68
|
+
if (other) {
|
|
69
|
+
structured += other + '\n';
|
|
70
|
+
}
|
|
71
|
+
const enhanced = structured.trim();
|
|
72
|
+
return {
|
|
73
|
+
enhancedPrompt: enhanced,
|
|
74
|
+
improvement: {
|
|
75
|
+
dimension: 'structure',
|
|
76
|
+
description: `Reorganized content into ${sectionsCount} logical sections`,
|
|
77
|
+
impact: sectionsCount >= 4 ? 'high' : sectionsCount >= 2 ? 'medium' : 'low'
|
|
78
|
+
},
|
|
79
|
+
applied: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
detectSections(prompt) {
|
|
83
|
+
const sectionMarkers = [
|
|
84
|
+
/^#+\s+.+$/gm, // Markdown headers
|
|
85
|
+
/^[A-Z][^.!?]+:$/gm, // "Objective:", "Requirements:"
|
|
86
|
+
/^\d+\.\s+[A-Z]/gm, // Numbered lists
|
|
87
|
+
/^[-*]\s+/gm // Bullet points
|
|
88
|
+
];
|
|
89
|
+
const sections = [];
|
|
90
|
+
for (const marker of sectionMarkers) {
|
|
91
|
+
const matches = prompt.match(marker);
|
|
92
|
+
if (matches) {
|
|
93
|
+
sections.push(...matches);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return sections;
|
|
97
|
+
}
|
|
98
|
+
isWellOrdered(sections) {
|
|
99
|
+
const idealOrder = ['objective', 'requirement', 'technical', 'constraint', 'output', 'success'];
|
|
100
|
+
let lastIndex = -1;
|
|
101
|
+
for (const section of sections) {
|
|
102
|
+
const sectionLower = section.toLowerCase();
|
|
103
|
+
const currentIndex = idealOrder.findIndex(keyword => sectionLower.includes(keyword));
|
|
104
|
+
if (currentIndex !== -1) {
|
|
105
|
+
if (currentIndex < lastIndex) {
|
|
106
|
+
return false; // Out of order
|
|
107
|
+
}
|
|
108
|
+
lastIndex = currentIndex;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
isDisorganized(prompt) {
|
|
114
|
+
// Check for requirements before objective
|
|
115
|
+
const objectiveIndex = prompt.toLowerCase().indexOf('objective');
|
|
116
|
+
const requirementIndex = prompt.toLowerCase().indexOf('requirement');
|
|
117
|
+
if (objectiveIndex > 0 && requirementIndex > 0 && requirementIndex < objectiveIndex) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
// Check for output before requirements
|
|
121
|
+
const outputIndex = prompt.toLowerCase().indexOf('output');
|
|
122
|
+
if (outputIndex > 0 && requirementIndex > 0 && outputIndex < requirementIndex) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
extractObjective(prompt) {
|
|
128
|
+
const patterns = [
|
|
129
|
+
/(?:objective|goal|purpose|need to|want to)[:]\s*(.+?)(?:\n\n|$)/is,
|
|
130
|
+
/^(.{20,100}?)(?:\n|$)/i // First sentence if no explicit objective
|
|
131
|
+
];
|
|
132
|
+
for (const pattern of patterns) {
|
|
133
|
+
const match = prompt.match(pattern);
|
|
134
|
+
if (match) {
|
|
135
|
+
return match[1].trim();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return '';
|
|
139
|
+
}
|
|
140
|
+
extractRequirements(prompt) {
|
|
141
|
+
const pattern = /(?:requirements?|must have|need|should)[:]\s*(.+?)(?:\n\n|##|$)/is;
|
|
142
|
+
const match = prompt.match(pattern);
|
|
143
|
+
return match ? match[1].trim() : '';
|
|
144
|
+
}
|
|
145
|
+
extractTechnical(prompt) {
|
|
146
|
+
const pattern = /(?:technical|tech stack|technology|using|built? with)[:]\s*(.+?)(?:\n\n|##|$)/is;
|
|
147
|
+
const match = prompt.match(pattern);
|
|
148
|
+
return match ? match[1].trim() : '';
|
|
149
|
+
}
|
|
150
|
+
extractExpectedOutput(prompt) {
|
|
151
|
+
const pattern = /(?:expected output|output|result|deliverable)[:]\s*(.+?)(?:\n\n|##|$)/is;
|
|
152
|
+
const match = prompt.match(pattern);
|
|
153
|
+
return match ? match[1].trim() : '';
|
|
154
|
+
}
|
|
155
|
+
extractSuccessCriteria(prompt) {
|
|
156
|
+
const pattern = /(?:success criteria|success|criteria|measure)[:]\s*(.+?)(?:\n\n|##|$)/is;
|
|
157
|
+
const match = prompt.match(pattern);
|
|
158
|
+
return match ? match[1].trim() : '';
|
|
159
|
+
}
|
|
160
|
+
extractConstraints(prompt) {
|
|
161
|
+
const pattern = /(?:constraints?|limitations?|must not|cannot)[:]\s*(.+?)(?:\n\n|##|$)/is;
|
|
162
|
+
const match = prompt.match(pattern);
|
|
163
|
+
return match ? match[1].trim() : '';
|
|
164
|
+
}
|
|
165
|
+
extractOther(prompt, extracted) {
|
|
166
|
+
let remaining = prompt;
|
|
167
|
+
for (const section of extracted) {
|
|
168
|
+
if (section) {
|
|
169
|
+
remaining = remaining.replace(section, '');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
remaining = remaining.replace(/#{1,6}\s*.+\n/g, ''); // Remove headers
|
|
173
|
+
remaining = remaining.replace(/\n{3,}/g, '\n\n'); // Normalize newlines
|
|
174
|
+
return remaining.trim();
|
|
175
|
+
}
|
|
176
|
+
addSectionHeaders(prompt) {
|
|
177
|
+
// If prompt already has headers, return as-is
|
|
178
|
+
if (prompt.match(/^#+\s+/m)) {
|
|
179
|
+
return prompt;
|
|
180
|
+
}
|
|
181
|
+
// Add a simple objective header
|
|
182
|
+
return '## Objective\n\n' + prompt;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=structure-organizer.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
export declare class TechnicalContextEnricher extends BasePattern {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
applicableIntents: PromptIntent[];
|
|
8
|
+
mode: 'fast' | 'deep' | 'both';
|
|
9
|
+
priority: number;
|
|
10
|
+
apply(prompt: string, context: PatternContext): PatternResult;
|
|
11
|
+
private hasTechnicalContext;
|
|
12
|
+
private detectLanguage;
|
|
13
|
+
private detectFramework;
|
|
14
|
+
private hasVersionInfo;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=technical-context-enricher.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
export class TechnicalContextEnricher extends BasePattern {
|
|
3
|
+
id = 'technical-context-enricher';
|
|
4
|
+
name = 'Technical Context Enricher';
|
|
5
|
+
description = 'Adds missing technical context (language, framework, versions)';
|
|
6
|
+
applicableIntents = ['code-generation', 'refinement', 'debugging'];
|
|
7
|
+
mode = 'both';
|
|
8
|
+
priority = 8;
|
|
9
|
+
apply(prompt, context) {
|
|
10
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
11
|
+
const enhancements = [];
|
|
12
|
+
// Check if technical context is already present
|
|
13
|
+
if (this.hasTechnicalContext(prompt)) {
|
|
14
|
+
return {
|
|
15
|
+
enhancedPrompt: prompt,
|
|
16
|
+
improvement: {
|
|
17
|
+
dimension: 'completeness',
|
|
18
|
+
description: 'Technical context already specified',
|
|
19
|
+
impact: 'low'
|
|
20
|
+
},
|
|
21
|
+
applied: false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// Detect language mentions without versions
|
|
25
|
+
const detectedLanguage = this.detectLanguage(lowerPrompt);
|
|
26
|
+
if (detectedLanguage && !this.hasVersionInfo(prompt)) {
|
|
27
|
+
enhancements.push(`Language: ${detectedLanguage} (please specify version if critical)`);
|
|
28
|
+
}
|
|
29
|
+
// Suggest adding framework if code generation
|
|
30
|
+
if (context.intent.primaryIntent === 'code-generation') {
|
|
31
|
+
const framework = this.detectFramework(lowerPrompt);
|
|
32
|
+
if (framework) {
|
|
33
|
+
enhancements.push(`Framework: ${framework}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// No enhancements needed
|
|
37
|
+
if (enhancements.length === 0) {
|
|
38
|
+
return {
|
|
39
|
+
enhancedPrompt: prompt,
|
|
40
|
+
improvement: {
|
|
41
|
+
dimension: 'completeness',
|
|
42
|
+
description: 'No additional technical context needed',
|
|
43
|
+
impact: 'low'
|
|
44
|
+
},
|
|
45
|
+
applied: false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Add technical context section
|
|
49
|
+
const contextSection = `\n\n# Technical Constraints\n${enhancements.map(e => `- ${e}`).join('\n')}`;
|
|
50
|
+
const enhanced = prompt + contextSection;
|
|
51
|
+
return {
|
|
52
|
+
enhancedPrompt: enhanced,
|
|
53
|
+
improvement: {
|
|
54
|
+
dimension: 'completeness',
|
|
55
|
+
description: `Added ${enhancements.length} technical context specifications`,
|
|
56
|
+
impact: 'medium'
|
|
57
|
+
},
|
|
58
|
+
applied: true
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
hasTechnicalContext(prompt) {
|
|
62
|
+
const contextMarkers = [
|
|
63
|
+
/version|v\d+\.\d+/i,
|
|
64
|
+
/technical (context|constraints|requirements)/i,
|
|
65
|
+
/language:.*framework:/i,
|
|
66
|
+
/using (python|javascript|typescript|java|rust|go) \d/i
|
|
67
|
+
];
|
|
68
|
+
return contextMarkers.some(marker => marker.test(prompt));
|
|
69
|
+
}
|
|
70
|
+
detectLanguage(prompt) {
|
|
71
|
+
const languages = {
|
|
72
|
+
'python': 'Python',
|
|
73
|
+
'javascript': 'JavaScript',
|
|
74
|
+
'typescript': 'TypeScript',
|
|
75
|
+
'java': 'Java',
|
|
76
|
+
'rust': 'Rust',
|
|
77
|
+
'go': 'Go',
|
|
78
|
+
'php': 'PHP',
|
|
79
|
+
'ruby': 'Ruby',
|
|
80
|
+
'swift': 'Swift',
|
|
81
|
+
'kotlin': 'Kotlin',
|
|
82
|
+
'c++': 'C++',
|
|
83
|
+
'csharp': 'C#',
|
|
84
|
+
'c#': 'C#'
|
|
85
|
+
};
|
|
86
|
+
for (const [key, name] of Object.entries(languages)) {
|
|
87
|
+
if (prompt.includes(key)) {
|
|
88
|
+
return name;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Check for common patterns
|
|
92
|
+
if (prompt.includes('react') || prompt.includes('vue') || prompt.includes('angular')) {
|
|
93
|
+
return 'JavaScript/TypeScript';
|
|
94
|
+
}
|
|
95
|
+
if (prompt.includes('django') || prompt.includes('flask')) {
|
|
96
|
+
return 'Python';
|
|
97
|
+
}
|
|
98
|
+
if (prompt.includes('spring') || prompt.includes('hibernate')) {
|
|
99
|
+
return 'Java';
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
detectFramework(prompt) {
|
|
104
|
+
const frameworks = {
|
|
105
|
+
'react': 'React',
|
|
106
|
+
'vue': 'Vue.js',
|
|
107
|
+
'angular': 'Angular',
|
|
108
|
+
'svelte': 'Svelte',
|
|
109
|
+
'next': 'Next.js',
|
|
110
|
+
'nextjs': 'Next.js',
|
|
111
|
+
'nuxt': 'Nuxt.js',
|
|
112
|
+
'django': 'Django',
|
|
113
|
+
'flask': 'Flask',
|
|
114
|
+
'fastapi': 'FastAPI',
|
|
115
|
+
'express': 'Express.js',
|
|
116
|
+
'nestjs': 'NestJS',
|
|
117
|
+
'spring': 'Spring Boot',
|
|
118
|
+
'rails': 'Ruby on Rails',
|
|
119
|
+
'laravel': 'Laravel'
|
|
120
|
+
};
|
|
121
|
+
for (const [key, name] of Object.entries(frameworks)) {
|
|
122
|
+
if (prompt.includes(key)) {
|
|
123
|
+
return name;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
hasVersionInfo(prompt) {
|
|
129
|
+
return /\d+\.\d+/.test(prompt) || /v\d+/.test(prompt);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=technical-context-enricher.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IntentAnalysis, QualityMetrics } from './types.js';
|
|
2
|
+
export declare class QualityAssessor {
|
|
3
|
+
/**
|
|
4
|
+
* Assess quality of a prompt (backward compatibility wrapper)
|
|
5
|
+
* @deprecated Use assess() method instead for full quality metrics
|
|
6
|
+
*/
|
|
7
|
+
assessQuality(prompt: string, intent: string): {
|
|
8
|
+
clarity: number;
|
|
9
|
+
efficiency: number;
|
|
10
|
+
structure: number;
|
|
11
|
+
completeness: number;
|
|
12
|
+
actionability: number;
|
|
13
|
+
overall: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Assess quality of a prompt
|
|
17
|
+
*/
|
|
18
|
+
assess(original: string, enhanced: string, intent: IntentAnalysis): QualityMetrics;
|
|
19
|
+
private assessClarity;
|
|
20
|
+
private assessEfficiency;
|
|
21
|
+
private assessStructure;
|
|
22
|
+
private assessCompleteness;
|
|
23
|
+
private assessActionability;
|
|
24
|
+
private calculateOverall;
|
|
25
|
+
private identifyStrengths;
|
|
26
|
+
private identifyImprovements;
|
|
27
|
+
private hasObjective;
|
|
28
|
+
private hasTechStack;
|
|
29
|
+
private hasOutputFormat;
|
|
30
|
+
private hasSuccessCriteria;
|
|
31
|
+
private hasSection;
|
|
32
|
+
private countSignalWords;
|
|
33
|
+
private hasInputOutput;
|
|
34
|
+
private hasEdgeCases;
|
|
35
|
+
private hasProblemStatement;
|
|
36
|
+
private hasGoal;
|
|
37
|
+
private hasConstraints;
|
|
38
|
+
private hasExpectedBehavior;
|
|
39
|
+
private hasActualBehavior;
|
|
40
|
+
private hasExamples;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=quality-assessor.d.ts.map
|