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,44 @@
|
|
|
1
|
+
import { BasePattern } from './patterns/base-pattern.js';
|
|
2
|
+
import { IntentAnalysis, OptimizationMode } from './types.js';
|
|
3
|
+
export declare class PatternLibrary {
|
|
4
|
+
private patterns;
|
|
5
|
+
constructor();
|
|
6
|
+
private registerDefaultPatterns;
|
|
7
|
+
/**
|
|
8
|
+
* Register a new pattern
|
|
9
|
+
*/
|
|
10
|
+
register(pattern: BasePattern): void;
|
|
11
|
+
/**
|
|
12
|
+
* Get a specific pattern by ID
|
|
13
|
+
*/
|
|
14
|
+
get(id: string): BasePattern | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get applicable patterns for given context (backward compatibility wrapper)
|
|
17
|
+
* @deprecated Use selectPatterns() method instead
|
|
18
|
+
*/
|
|
19
|
+
getApplicablePatterns(prompt: string, intent: string, quality: {
|
|
20
|
+
clarity: number;
|
|
21
|
+
efficiency: number;
|
|
22
|
+
structure: number;
|
|
23
|
+
completeness: number;
|
|
24
|
+
actionability: number;
|
|
25
|
+
overall: number;
|
|
26
|
+
}, mode: OptimizationMode): BasePattern[];
|
|
27
|
+
/**
|
|
28
|
+
* Select applicable patterns for the given context
|
|
29
|
+
*/
|
|
30
|
+
selectPatterns(intent: IntentAnalysis, mode: OptimizationMode): BasePattern[];
|
|
31
|
+
/**
|
|
32
|
+
* Get all registered patterns
|
|
33
|
+
*/
|
|
34
|
+
getAllPatterns(): BasePattern[];
|
|
35
|
+
/**
|
|
36
|
+
* Get patterns by mode
|
|
37
|
+
*/
|
|
38
|
+
getPatternsByMode(mode: OptimizationMode): BasePattern[];
|
|
39
|
+
/**
|
|
40
|
+
* Get pattern count
|
|
41
|
+
*/
|
|
42
|
+
getPatternCount(): number;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=pattern-library.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ConcisenessFilter } from './patterns/conciseness-filter.js';
|
|
2
|
+
import { ObjectiveClarifier } from './patterns/objective-clarifier.js';
|
|
3
|
+
import { TechnicalContextEnricher } from './patterns/technical-context-enricher.js';
|
|
4
|
+
import { StructureOrganizer } from './patterns/structure-organizer.js';
|
|
5
|
+
import { CompletenessValidator } from './patterns/completeness-validator.js';
|
|
6
|
+
import { ActionabilityEnhancer } from './patterns/actionability-enhancer.js';
|
|
7
|
+
export class PatternLibrary {
|
|
8
|
+
patterns = new Map();
|
|
9
|
+
constructor() {
|
|
10
|
+
this.registerDefaultPatterns();
|
|
11
|
+
}
|
|
12
|
+
registerDefaultPatterns() {
|
|
13
|
+
// Register core patterns (available in fast & deep modes)
|
|
14
|
+
this.register(new ConcisenessFilter()); // HIGH - Remove verbosity
|
|
15
|
+
this.register(new ObjectiveClarifier()); // HIGH - Add clarity
|
|
16
|
+
this.register(new TechnicalContextEnricher()); // MEDIUM - Add technical details
|
|
17
|
+
this.register(new StructureOrganizer()); // HIGH - Reorder logically
|
|
18
|
+
this.register(new CompletenessValidator()); // MEDIUM - Check missing elements
|
|
19
|
+
this.register(new ActionabilityEnhancer()); // HIGH - Vague to specific
|
|
20
|
+
// TODO: Register additional patterns for deep mode (future enhancement)
|
|
21
|
+
// Deep mode exclusive:
|
|
22
|
+
// - AlternativePhrasingGenerator
|
|
23
|
+
// - StructureVariationGenerator
|
|
24
|
+
// - EdgeCaseIdentifier
|
|
25
|
+
// - ValidationChecklistCreator
|
|
26
|
+
// - AssumptionExplicitizer
|
|
27
|
+
// - ScopeDefiner
|
|
28
|
+
// - StepByStepDecomposer
|
|
29
|
+
// - TemplatePatternApplier
|
|
30
|
+
// - ReflectionPrompter
|
|
31
|
+
// - ContextPrecisionBooster
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register a new pattern
|
|
35
|
+
*/
|
|
36
|
+
register(pattern) {
|
|
37
|
+
this.patterns.set(pattern.id, pattern);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a specific pattern by ID
|
|
41
|
+
*/
|
|
42
|
+
get(id) {
|
|
43
|
+
return this.patterns.get(id);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get applicable patterns for given context (backward compatibility wrapper)
|
|
47
|
+
* @deprecated Use selectPatterns() method instead
|
|
48
|
+
*/
|
|
49
|
+
getApplicablePatterns(prompt, intent, quality, mode) {
|
|
50
|
+
// Create IntentAnalysis from parameters
|
|
51
|
+
const intentAnalysis = {
|
|
52
|
+
primaryIntent: intent,
|
|
53
|
+
confidence: 100,
|
|
54
|
+
characteristics: {
|
|
55
|
+
hasCodeContext: false,
|
|
56
|
+
hasTechnicalTerms: false,
|
|
57
|
+
isOpenEnded: false,
|
|
58
|
+
needsStructure: false
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Use existing selectPatterns method
|
|
62
|
+
return this.selectPatterns(intentAnalysis, mode);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Select applicable patterns for the given context
|
|
66
|
+
*/
|
|
67
|
+
selectPatterns(intent, mode) {
|
|
68
|
+
const applicablePatterns = [];
|
|
69
|
+
for (const pattern of this.patterns.values()) {
|
|
70
|
+
// Check mode compatibility
|
|
71
|
+
if (pattern.mode !== 'both' && pattern.mode !== mode) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// Check intent compatibility
|
|
75
|
+
if (!pattern.applicableIntents.includes(intent.primaryIntent)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
applicablePatterns.push(pattern);
|
|
79
|
+
}
|
|
80
|
+
// Sort by priority (highest first)
|
|
81
|
+
return applicablePatterns.sort((a, b) => b.priority - a.priority);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get all registered patterns
|
|
85
|
+
*/
|
|
86
|
+
getAllPatterns() {
|
|
87
|
+
return Array.from(this.patterns.values());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get patterns by mode
|
|
91
|
+
*/
|
|
92
|
+
getPatternsByMode(mode) {
|
|
93
|
+
return Array.from(this.patterns.values())
|
|
94
|
+
.filter(p => p.mode === mode || p.mode === 'both');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get pattern count
|
|
98
|
+
*/
|
|
99
|
+
getPatternCount() {
|
|
100
|
+
return this.patterns.size;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=pattern-library.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Actionability Enhancer Pattern
|
|
5
|
+
*
|
|
6
|
+
* Converts vague goals into specific, actionable tasks.
|
|
7
|
+
* Replaces abstract language with concrete requirements.
|
|
8
|
+
*
|
|
9
|
+
* Priority: HIGH (7)
|
|
10
|
+
*/
|
|
11
|
+
export declare class ActionabilityEnhancer extends BasePattern {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
applicableIntents: PromptIntent[];
|
|
16
|
+
mode: 'fast' | 'deep' | 'both';
|
|
17
|
+
priority: number;
|
|
18
|
+
private readonly VAGUE_WORDS;
|
|
19
|
+
apply(prompt: string, context: PatternContext): PatternResult;
|
|
20
|
+
private detectVagueWords;
|
|
21
|
+
private hasAbstractGoals;
|
|
22
|
+
private replaceVagueWords;
|
|
23
|
+
private addMeasurableCriteria;
|
|
24
|
+
private hasSpecificMetric;
|
|
25
|
+
private concretizeGoals;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=actionability-enhancer.d.ts.map
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* Actionability Enhancer Pattern
|
|
4
|
+
*
|
|
5
|
+
* Converts vague goals into specific, actionable tasks.
|
|
6
|
+
* Replaces abstract language with concrete requirements.
|
|
7
|
+
*
|
|
8
|
+
* Priority: HIGH (7)
|
|
9
|
+
*/
|
|
10
|
+
export class ActionabilityEnhancer extends BasePattern {
|
|
11
|
+
id = 'actionability-enhancer';
|
|
12
|
+
name = 'Actionability Enhancer';
|
|
13
|
+
description = 'Converts vague goals into specific, actionable tasks';
|
|
14
|
+
applicableIntents = ['code-generation', 'planning', 'refinement', 'debugging'];
|
|
15
|
+
mode = 'both';
|
|
16
|
+
priority = 7; // High priority
|
|
17
|
+
VAGUE_WORDS = {
|
|
18
|
+
'better': ['faster', 'more efficient', 'more reliable', 'more maintainable'],
|
|
19
|
+
'improve': ['optimize performance', 'enhance user experience', 'increase reliability', 'refactor for clarity'],
|
|
20
|
+
'good': ['high-performing', 'user-friendly', 'maintainable', 'secure'],
|
|
21
|
+
'nice': ['polished', 'intuitive', 'responsive', 'accessible'],
|
|
22
|
+
'fast': ['< 100ms response time', '< 2s load time', 'under 500ms', 'high-performance'],
|
|
23
|
+
'slow': ['> 2s load time', 'laggy', 'delayed response', 'poor performance'],
|
|
24
|
+
'something': ['[specify what]', '[component/feature/function]', '[define requirement]'],
|
|
25
|
+
'somehow': ['[specify method]', '[define approach]', '[explain how]'],
|
|
26
|
+
'maybe': ['[decide: yes/no]', '[clarify requirement]', '[confirm if needed]'],
|
|
27
|
+
'enhance': ['add features to', 'improve functionality of', 'extend capabilities of'],
|
|
28
|
+
'fix': ['resolve bug in', 'correct error in', 'debug issue with'],
|
|
29
|
+
'update': ['modify', 'change', 'revise', 'upgrade']
|
|
30
|
+
};
|
|
31
|
+
apply(prompt, context) {
|
|
32
|
+
let enhanced = prompt;
|
|
33
|
+
let changesCount = 0;
|
|
34
|
+
// Replace vague words with specific alternatives
|
|
35
|
+
const afterVague = this.replaceVagueWords(enhanced);
|
|
36
|
+
if (afterVague !== enhanced)
|
|
37
|
+
changesCount++;
|
|
38
|
+
enhanced = afterVague;
|
|
39
|
+
// Add measurable criteria where missing
|
|
40
|
+
const afterMeasurable = this.addMeasurableCriteria(enhanced);
|
|
41
|
+
if (afterMeasurable !== enhanced)
|
|
42
|
+
changesCount++;
|
|
43
|
+
enhanced = afterMeasurable;
|
|
44
|
+
// Convert abstract goals to concrete tasks
|
|
45
|
+
const afterConcrete = this.concretizeGoals(enhanced);
|
|
46
|
+
if (afterConcrete !== enhanced)
|
|
47
|
+
changesCount++;
|
|
48
|
+
enhanced = afterConcrete;
|
|
49
|
+
return {
|
|
50
|
+
enhancedPrompt: enhanced,
|
|
51
|
+
improvement: {
|
|
52
|
+
dimension: 'actionability',
|
|
53
|
+
description: `Made ${changesCount} improvements to increase specificity`,
|
|
54
|
+
impact: changesCount >= 3 ? 'high' : changesCount >= 2 ? 'medium' : 'low'
|
|
55
|
+
},
|
|
56
|
+
applied: enhanced !== prompt
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
detectVagueWords(prompt) {
|
|
60
|
+
const found = [];
|
|
61
|
+
for (const vague of Object.keys(this.VAGUE_WORDS)) {
|
|
62
|
+
// Match whole words only
|
|
63
|
+
const regex = new RegExp(`\\b${vague}\\b`, 'gi');
|
|
64
|
+
if (regex.test(prompt)) {
|
|
65
|
+
found.push(vague);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return found;
|
|
69
|
+
}
|
|
70
|
+
hasAbstractGoals(prompt) {
|
|
71
|
+
const abstractPatterns = [
|
|
72
|
+
/make\s+it\s+\w+/i, // "make it better"
|
|
73
|
+
/should\s+be\s+\w+/i, // "should be nice"
|
|
74
|
+
/want\s+it\s+to\s+be\s+\w+/i, // "want it to be good"
|
|
75
|
+
/more\s+\w+/i, // "more efficient"
|
|
76
|
+
/less\s+\w+/i // "less complex"
|
|
77
|
+
];
|
|
78
|
+
return abstractPatterns.some(pattern => pattern.test(prompt));
|
|
79
|
+
}
|
|
80
|
+
replaceVagueWords(prompt) {
|
|
81
|
+
let enhanced = prompt;
|
|
82
|
+
for (const [vague, alternatives] of Object.entries(this.VAGUE_WORDS)) {
|
|
83
|
+
const regex = new RegExp(`\\b${vague}\\b`, 'gi');
|
|
84
|
+
if (regex.test(enhanced)) {
|
|
85
|
+
// For user-facing vague words, add clarifying question
|
|
86
|
+
if (['something', 'somehow', 'maybe'].includes(vague.toLowerCase())) {
|
|
87
|
+
enhanced = enhanced.replace(regex, (match) => {
|
|
88
|
+
return `${match} ${alternatives[0]}`;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// For quality adjectives, suggest specific alternatives
|
|
93
|
+
const suggestion = alternatives[0];
|
|
94
|
+
enhanced = enhanced.replace(regex, (match) => {
|
|
95
|
+
return `${match} (e.g., ${suggestion})`;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return enhanced;
|
|
101
|
+
}
|
|
102
|
+
addMeasurableCriteria(prompt) {
|
|
103
|
+
const needsMeasurement = [
|
|
104
|
+
{ pattern: /\bfast(?:er)?\b/gi, suggestion: ' (specify: < 100ms, < 1s, etc.)' },
|
|
105
|
+
{ pattern: /\bslow(?:er)?\b/gi, suggestion: ' (specify: > 2s, > 5s, etc.)' },
|
|
106
|
+
{ pattern: /\befficient\b/gi, suggestion: ' (specify metrics: time, memory, CPU)' },
|
|
107
|
+
{ pattern: /\bscalable\b/gi, suggestion: ' (specify: handle 1K, 10K, 100K users)' },
|
|
108
|
+
{ pattern: /\breliable\b/gi, suggestion: ' (specify: 99.9% uptime, < 0.1% error rate)' },
|
|
109
|
+
{ pattern: /\bsecure\b/gi, suggestion: ' (specify: HTTPS, auth required, encrypted)' }
|
|
110
|
+
];
|
|
111
|
+
let enhanced = prompt;
|
|
112
|
+
for (const { pattern, suggestion } of needsMeasurement) {
|
|
113
|
+
if (pattern.test(enhanced)) {
|
|
114
|
+
// Only add if not already specific
|
|
115
|
+
if (!this.hasSpecificMetric(enhanced)) {
|
|
116
|
+
enhanced = enhanced.replace(pattern, (match) => match + suggestion);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return enhanced;
|
|
121
|
+
}
|
|
122
|
+
hasSpecificMetric(prompt) {
|
|
123
|
+
const metricPatterns = [
|
|
124
|
+
/\d+\s*(?:ms|s|min|hours?)/i, // Time metrics
|
|
125
|
+
/\d+\s*(?:kb|mb|gb)/i, // Size metrics
|
|
126
|
+
/\d+\s*(?:%|percent)/i, // Percentage
|
|
127
|
+
/<?>\s*\d+/i, // Comparison operators
|
|
128
|
+
/\d+k?\s*(?:users?|requests?)/i // Scale metrics
|
|
129
|
+
];
|
|
130
|
+
return metricPatterns.some(pattern => pattern.test(prompt));
|
|
131
|
+
}
|
|
132
|
+
concretizeGoals(prompt) {
|
|
133
|
+
const abstractPatterns = [
|
|
134
|
+
{
|
|
135
|
+
pattern: /make\s+it\s+better/gi,
|
|
136
|
+
replacement: 'improve by [specify: performance, UX, reliability, etc.]'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
pattern: /should\s+be\s+nice/gi,
|
|
140
|
+
replacement: 'should have [specify: polished UI, intuitive UX, etc.]'
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
pattern: /want\s+it\s+to\s+be\s+good/gi,
|
|
144
|
+
replacement: 'should meet [specify: quality standards, performance targets, etc.]'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
pattern: /more\s+efficient/gi,
|
|
148
|
+
replacement: 'more efficient (reduce time/memory/CPU by [X%])'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
pattern: /less\s+complex/gi,
|
|
152
|
+
replacement: 'less complex (reduce from [X] to [Y] components/lines/dependencies)'
|
|
153
|
+
}
|
|
154
|
+
];
|
|
155
|
+
let enhanced = prompt;
|
|
156
|
+
for (const { pattern, replacement } of abstractPatterns) {
|
|
157
|
+
enhanced = enhanced.replace(pattern, replacement);
|
|
158
|
+
}
|
|
159
|
+
return enhanced;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=actionability-enhancer.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
|
|
2
|
+
export declare abstract class BasePattern {
|
|
3
|
+
abstract id: string;
|
|
4
|
+
abstract name: string;
|
|
5
|
+
abstract description: string;
|
|
6
|
+
abstract applicableIntents: PromptIntent[];
|
|
7
|
+
abstract mode: OptimizationMode | 'both';
|
|
8
|
+
abstract priority: number;
|
|
9
|
+
abstract apply(prompt: string, context: PatternContext): PatternResult;
|
|
10
|
+
/**
|
|
11
|
+
* Check if this pattern is applicable for the given context
|
|
12
|
+
*/
|
|
13
|
+
isApplicable(context: PatternContext): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Utility: Remove extra whitespace
|
|
16
|
+
*/
|
|
17
|
+
protected cleanWhitespace(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Utility: Check if prompt has a section
|
|
20
|
+
*/
|
|
21
|
+
protected hasSection(prompt: string, keywords: string[]): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Utility: Count words
|
|
24
|
+
*/
|
|
25
|
+
protected countWords(text: string): number;
|
|
26
|
+
/**
|
|
27
|
+
* Utility: Extract sentences
|
|
28
|
+
*/
|
|
29
|
+
protected extractSentences(text: string): string[];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=base-pattern.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class BasePattern {
|
|
2
|
+
/**
|
|
3
|
+
* Check if this pattern is applicable for the given context
|
|
4
|
+
*/
|
|
5
|
+
isApplicable(context) {
|
|
6
|
+
// Check mode compatibility
|
|
7
|
+
if (this.mode !== 'both' && this.mode !== context.mode) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
// Check intent compatibility
|
|
11
|
+
return this.applicableIntents.includes(context.intent.primaryIntent);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Utility: Remove extra whitespace
|
|
15
|
+
*/
|
|
16
|
+
cleanWhitespace(text) {
|
|
17
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Utility: Check if prompt has a section
|
|
21
|
+
*/
|
|
22
|
+
hasSection(prompt, keywords) {
|
|
23
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
24
|
+
return keywords.some(keyword => lowerPrompt.includes(keyword.toLowerCase()));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Utility: Count words
|
|
28
|
+
*/
|
|
29
|
+
countWords(text) {
|
|
30
|
+
return text.split(/\s+/).filter(word => word.length > 0).length;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Utility: Extract sentences
|
|
34
|
+
*/
|
|
35
|
+
extractSentences(text) {
|
|
36
|
+
return text.split(/[.!?]+/).filter(s => s.trim().length > 0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=base-pattern.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Completeness Validator Pattern
|
|
5
|
+
*
|
|
6
|
+
* Ensures all necessary requirements are present.
|
|
7
|
+
* Adds placeholder sections for missing critical elements.
|
|
8
|
+
*
|
|
9
|
+
* Priority: MEDIUM (6)
|
|
10
|
+
*/
|
|
11
|
+
export declare class CompletenessValidator 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 findMissingElements;
|
|
20
|
+
private hasObjective;
|
|
21
|
+
private hasTechStack;
|
|
22
|
+
private hasSuccessCriteria;
|
|
23
|
+
private hasConstraints;
|
|
24
|
+
private hasOutputFormat;
|
|
25
|
+
private getMissingElementPrompt;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=completeness-validator.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* Completeness Validator Pattern
|
|
4
|
+
*
|
|
5
|
+
* Ensures all necessary requirements are present.
|
|
6
|
+
* Adds placeholder sections for missing critical elements.
|
|
7
|
+
*
|
|
8
|
+
* Priority: MEDIUM (6)
|
|
9
|
+
*/
|
|
10
|
+
export class CompletenessValidator extends BasePattern {
|
|
11
|
+
id = 'completeness-validator';
|
|
12
|
+
name = 'Completeness Validator';
|
|
13
|
+
description = 'Ensures all necessary requirements are present';
|
|
14
|
+
applicableIntents = ['code-generation', 'planning', 'refinement'];
|
|
15
|
+
mode = 'both';
|
|
16
|
+
priority = 6; // Medium priority
|
|
17
|
+
apply(prompt, context) {
|
|
18
|
+
const missing = this.findMissingElements(prompt);
|
|
19
|
+
if (missing.length === 0) {
|
|
20
|
+
return {
|
|
21
|
+
enhancedPrompt: prompt,
|
|
22
|
+
improvement: {
|
|
23
|
+
dimension: 'completeness',
|
|
24
|
+
description: 'All required elements present',
|
|
25
|
+
impact: 'low'
|
|
26
|
+
},
|
|
27
|
+
applied: false
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Calculate completeness score
|
|
31
|
+
const totalElements = 5;
|
|
32
|
+
const presentElements = totalElements - missing.length;
|
|
33
|
+
const score = Math.round((presentElements / totalElements) * 100);
|
|
34
|
+
let enhanced = prompt + '\n\n';
|
|
35
|
+
// Add missing elements section
|
|
36
|
+
enhanced += '---\n\n';
|
|
37
|
+
enhanced += `**Completeness Check**: ${score}% (${presentElements}/${totalElements} elements present)\n\n`;
|
|
38
|
+
enhanced += '**Missing Information** (please specify):\n\n';
|
|
39
|
+
for (const element of missing) {
|
|
40
|
+
enhanced += this.getMissingElementPrompt(element) + '\n';
|
|
41
|
+
}
|
|
42
|
+
const result = enhanced.trim();
|
|
43
|
+
return {
|
|
44
|
+
enhancedPrompt: result,
|
|
45
|
+
improvement: {
|
|
46
|
+
dimension: 'completeness',
|
|
47
|
+
description: `Added ${missing.length} missing element prompts (${score}% complete)`,
|
|
48
|
+
impact: missing.length >= 3 ? 'high' : missing.length >= 2 ? 'medium' : 'low'
|
|
49
|
+
},
|
|
50
|
+
applied: true
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
findMissingElements(prompt) {
|
|
54
|
+
const missing = [];
|
|
55
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
56
|
+
// Check for objective/goal
|
|
57
|
+
if (!this.hasObjective(lowerPrompt)) {
|
|
58
|
+
missing.push('objective');
|
|
59
|
+
}
|
|
60
|
+
// Check for tech stack
|
|
61
|
+
if (!this.hasTechStack(lowerPrompt)) {
|
|
62
|
+
missing.push('tech-stack');
|
|
63
|
+
}
|
|
64
|
+
// Check for success criteria
|
|
65
|
+
if (!this.hasSuccessCriteria(lowerPrompt)) {
|
|
66
|
+
missing.push('success-criteria');
|
|
67
|
+
}
|
|
68
|
+
// Check for constraints
|
|
69
|
+
if (!this.hasConstraints(lowerPrompt)) {
|
|
70
|
+
missing.push('constraints');
|
|
71
|
+
}
|
|
72
|
+
// Check for output format
|
|
73
|
+
if (!this.hasOutputFormat(lowerPrompt)) {
|
|
74
|
+
missing.push('output-format');
|
|
75
|
+
}
|
|
76
|
+
return missing;
|
|
77
|
+
}
|
|
78
|
+
hasObjective(prompt) {
|
|
79
|
+
const objectivePatterns = [
|
|
80
|
+
'objective', 'goal', 'purpose', 'need to', 'want to',
|
|
81
|
+
'trying to', 'aim', 'intend'
|
|
82
|
+
];
|
|
83
|
+
return objectivePatterns.some(pattern => prompt.includes(pattern));
|
|
84
|
+
}
|
|
85
|
+
hasTechStack(prompt) {
|
|
86
|
+
const techPatterns = [
|
|
87
|
+
// Languages
|
|
88
|
+
'javascript', 'typescript', 'python', 'java', 'rust', 'go',
|
|
89
|
+
'php', 'ruby', 'swift', 'kotlin', 'c++', 'c#',
|
|
90
|
+
// Frameworks
|
|
91
|
+
'react', 'vue', 'angular', 'svelte', 'next', 'nuxt',
|
|
92
|
+
'express', 'fastapi', 'django', 'flask', 'spring', 'rails',
|
|
93
|
+
// Databases
|
|
94
|
+
'postgres', 'mysql', 'mongodb', 'redis', 'sqlite',
|
|
95
|
+
// Tools
|
|
96
|
+
'docker', 'kubernetes', 'aws', 'azure', 'gcp',
|
|
97
|
+
// Generic
|
|
98
|
+
'tech stack', 'technology', 'framework', 'library', 'using', 'built with'
|
|
99
|
+
];
|
|
100
|
+
return techPatterns.some(pattern => prompt.includes(pattern));
|
|
101
|
+
}
|
|
102
|
+
hasSuccessCriteria(prompt) {
|
|
103
|
+
const successPatterns = [
|
|
104
|
+
'success', 'criteria', 'measure', 'metric', 'kpi',
|
|
105
|
+
'should work', 'expected to', 'result in', 'achieve'
|
|
106
|
+
];
|
|
107
|
+
return successPatterns.some(pattern => prompt.includes(pattern));
|
|
108
|
+
}
|
|
109
|
+
hasConstraints(prompt) {
|
|
110
|
+
const constraintPatterns = [
|
|
111
|
+
'constraint', 'limit', 'limitation', 'must not', 'cannot',
|
|
112
|
+
'should not', 'avoid', 'within', 'budget', 'time', 'deadline'
|
|
113
|
+
];
|
|
114
|
+
return constraintPatterns.some(pattern => prompt.includes(pattern));
|
|
115
|
+
}
|
|
116
|
+
hasOutputFormat(prompt) {
|
|
117
|
+
const outputPatterns = [
|
|
118
|
+
'output', 'format', 'return', 'result', 'deliverable',
|
|
119
|
+
'component', 'function', 'class', 'api', 'endpoint',
|
|
120
|
+
'file', 'document', 'report'
|
|
121
|
+
];
|
|
122
|
+
return outputPatterns.some(pattern => prompt.includes(pattern));
|
|
123
|
+
}
|
|
124
|
+
getMissingElementPrompt(element) {
|
|
125
|
+
const prompts = {
|
|
126
|
+
'objective': '- **Objective**: What is the primary goal? What problem are you solving?',
|
|
127
|
+
'tech-stack': '- **Tech Stack**: Which technologies/frameworks? (e.g., React, Node.js, PostgreSQL)',
|
|
128
|
+
'success-criteria': '- **Success Criteria**: How will you know it works? What metrics matter?',
|
|
129
|
+
'constraints': '- **Constraints**: Any limitations? (time, budget, performance, compatibility)',
|
|
130
|
+
'output-format': '- **Expected Output**: What should the result look like? (component, API, file, etc.)'
|
|
131
|
+
};
|
|
132
|
+
return prompts[element] || `- **${element}**: Please specify`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=completeness-validator.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
export declare class ConcisenessFilter 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
|
+
}
|
|
12
|
+
//# sourceMappingURL=conciseness-filter.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
export class ConcisenessFilter extends BasePattern {
|
|
3
|
+
id = 'conciseness-filter';
|
|
4
|
+
name = 'Conciseness Filter';
|
|
5
|
+
description = 'Removes unnecessary pleasantries, fluff words, and redundancy';
|
|
6
|
+
applicableIntents = ['code-generation', 'planning', 'refinement', 'debugging', 'documentation'];
|
|
7
|
+
mode = 'both';
|
|
8
|
+
priority = 10; // High priority - run early
|
|
9
|
+
apply(prompt, context) {
|
|
10
|
+
let cleaned = prompt;
|
|
11
|
+
let changesCount = 0;
|
|
12
|
+
// Remove pleasantries at start
|
|
13
|
+
const pleasantries = [
|
|
14
|
+
/^(please|could you|would you mind|I would appreciate if you could|kindly)\s+/gi,
|
|
15
|
+
/thank you/gi,
|
|
16
|
+
/thanks in advance/gi,
|
|
17
|
+
/I appreciate your help/gi
|
|
18
|
+
];
|
|
19
|
+
for (const pattern of pleasantries) {
|
|
20
|
+
const before = cleaned;
|
|
21
|
+
cleaned = cleaned.replace(pattern, '');
|
|
22
|
+
if (before !== cleaned)
|
|
23
|
+
changesCount++;
|
|
24
|
+
}
|
|
25
|
+
// Remove fluff words
|
|
26
|
+
const fluffWords = ['very', 'really', 'just', 'basically', 'simply', 'actually', 'literally'];
|
|
27
|
+
for (const word of fluffWords) {
|
|
28
|
+
const regex = new RegExp(`\\b${word}\\b`, 'gi');
|
|
29
|
+
const before = cleaned;
|
|
30
|
+
cleaned = cleaned.replace(regex, '');
|
|
31
|
+
if (before !== cleaned)
|
|
32
|
+
changesCount++;
|
|
33
|
+
}
|
|
34
|
+
// Remove redundant phrases
|
|
35
|
+
const redundantPhrases = [
|
|
36
|
+
/in order to/gi, // Replace with "to"
|
|
37
|
+
/at this point in time/gi, // Replace with "now"
|
|
38
|
+
/due to the fact that/gi, // Replace with "because"
|
|
39
|
+
/for the purpose of/gi, // Replace with "for"
|
|
40
|
+
/in the event that/gi // Replace with "if"
|
|
41
|
+
];
|
|
42
|
+
cleaned = cleaned.replace(/in order to/gi, 'to');
|
|
43
|
+
cleaned = cleaned.replace(/at this point in time/gi, 'now');
|
|
44
|
+
cleaned = cleaned.replace(/due to the fact that/gi, 'because');
|
|
45
|
+
cleaned = cleaned.replace(/for the purpose of/gi, 'for');
|
|
46
|
+
cleaned = cleaned.replace(/in the event that/gi, 'if');
|
|
47
|
+
// Clean up extra whitespace
|
|
48
|
+
cleaned = this.cleanWhitespace(cleaned);
|
|
49
|
+
const applied = changesCount > 0 || cleaned !== prompt;
|
|
50
|
+
return {
|
|
51
|
+
enhancedPrompt: cleaned,
|
|
52
|
+
improvement: {
|
|
53
|
+
dimension: 'efficiency',
|
|
54
|
+
description: `Removed ${changesCount} unnecessary phrases for conciseness`,
|
|
55
|
+
impact: changesCount > 3 ? 'high' : changesCount > 1 ? 'medium' : 'low'
|
|
56
|
+
},
|
|
57
|
+
applied
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=conciseness-filter.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BasePattern } from './base-pattern.js';
|
|
2
|
+
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
export declare class ObjectiveClarifier 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 hasExplicitObjective;
|
|
12
|
+
private extractObjective;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=objective-clarifier.d.ts.map
|