clavix 4.3.2 → 4.5.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.
- package/dist/core/adapters/instructions-generator.d.ts +2 -1
- package/dist/core/adapters/instructions-generator.js +21 -8
- package/dist/core/intelligence/confidence-calculator.d.ts +93 -0
- package/dist/core/intelligence/confidence-calculator.js +124 -0
- package/dist/core/intelligence/index.d.ts +1 -0
- package/dist/core/intelligence/index.js +2 -0
- package/dist/core/intelligence/intent-detector.js +10 -8
- package/dist/core/intelligence/pattern-library.d.ts +47 -10
- package/dist/core/intelligence/pattern-library.js +151 -79
- package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +10 -10
- package/dist/core/intelligence/patterns/actionability-enhancer.js +31 -6
- package/dist/core/intelligence/patterns/alternative-phrasing-generator.d.ts +10 -8
- package/dist/core/intelligence/patterns/alternative-phrasing-generator.js +21 -3
- package/dist/core/intelligence/patterns/ambiguity-detector.d.ts +10 -8
- package/dist/core/intelligence/patterns/ambiguity-detector.js +31 -3
- package/dist/core/intelligence/patterns/assumption-explicitizer.d.ts +10 -8
- package/dist/core/intelligence/patterns/assumption-explicitizer.js +26 -3
- package/dist/core/intelligence/patterns/base-pattern.d.ts +166 -8
- package/dist/core/intelligence/patterns/base-pattern.js +64 -4
- package/dist/core/intelligence/patterns/completeness-validator.d.ts +10 -10
- package/dist/core/intelligence/patterns/completeness-validator.js +26 -5
- package/dist/core/intelligence/patterns/conciseness-filter.d.ts +15 -7
- package/dist/core/intelligence/patterns/conciseness-filter.js +36 -4
- package/dist/core/intelligence/patterns/context-precision.d.ts +10 -8
- package/dist/core/intelligence/patterns/context-precision.js +28 -5
- package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +14 -9
- package/dist/core/intelligence/patterns/conversation-summarizer.js +109 -29
- package/dist/core/intelligence/patterns/dependency-identifier.d.ts +11 -9
- package/dist/core/intelligence/patterns/dependency-identifier.js +21 -4
- package/dist/core/intelligence/patterns/domain-context-enricher.d.ts +10 -8
- package/dist/core/intelligence/patterns/domain-context-enricher.js +27 -3
- package/dist/core/intelligence/patterns/edge-case-identifier.d.ts +10 -8
- package/dist/core/intelligence/patterns/edge-case-identifier.js +21 -3
- package/dist/core/intelligence/patterns/error-tolerance-enhancer.d.ts +10 -8
- package/dist/core/intelligence/patterns/error-tolerance-enhancer.js +22 -4
- package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +14 -10
- package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +193 -63
- package/dist/core/intelligence/patterns/objective-clarifier.d.ts +15 -7
- package/dist/core/intelligence/patterns/objective-clarifier.js +46 -17
- package/dist/core/intelligence/patterns/output-format-enforcer.d.ts +10 -8
- package/dist/core/intelligence/patterns/output-format-enforcer.js +20 -3
- package/dist/core/intelligence/patterns/prd-structure-enforcer.d.ts +10 -8
- package/dist/core/intelligence/patterns/prd-structure-enforcer.js +25 -3
- package/dist/core/intelligence/patterns/prerequisite-identifier.d.ts +10 -8
- package/dist/core/intelligence/patterns/prerequisite-identifier.js +28 -4
- package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +11 -9
- package/dist/core/intelligence/patterns/requirement-prioritizer.js +21 -4
- package/dist/core/intelligence/patterns/scope-definer.d.ts +10 -8
- package/dist/core/intelligence/patterns/scope-definer.js +27 -3
- package/dist/core/intelligence/patterns/step-decomposer.d.ts +10 -8
- package/dist/core/intelligence/patterns/step-decomposer.js +21 -3
- package/dist/core/intelligence/patterns/structure-organizer.d.ts +10 -10
- package/dist/core/intelligence/patterns/structure-organizer.js +25 -5
- package/dist/core/intelligence/patterns/success-criteria-enforcer.d.ts +10 -8
- package/dist/core/intelligence/patterns/success-criteria-enforcer.js +20 -3
- package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +11 -9
- package/dist/core/intelligence/patterns/success-metrics-enforcer.js +27 -4
- package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +16 -7
- package/dist/core/intelligence/patterns/technical-context-enricher.js +71 -38
- package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +13 -9
- package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +202 -42
- package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +11 -9
- package/dist/core/intelligence/patterns/user-persona-enricher.js +21 -4
- package/dist/core/intelligence/patterns/validation-checklist-creator.d.ts +11 -8
- package/dist/core/intelligence/patterns/validation-checklist-creator.js +31 -3
- package/dist/templates/slash-commands/_canonical/deep.md +1 -1
- package/dist/templates/slash-commands/_canonical/execute.md +1 -1
- package/dist/templates/slash-commands/_canonical/fast.md +1 -1
- package/dist/templates/slash-commands/_canonical/implement.md +1 -1
- package/dist/templates/slash-commands/_canonical/plan.md +1 -1
- package/dist/templates/slash-commands/_canonical/prd.md +1 -1
- package/dist/templates/slash-commands/_canonical/start.md +21 -1
- package/dist/templates/slash-commands/_canonical/summarize.md +43 -2
- package/dist/templates/slash-commands/_components/references/intent-types.md +3 -1
- package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +9 -9
- package/dist/types/config.d.ts +24 -0
- package/package.json +1 -1
|
@@ -1,17 +1,137 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, } from './base-pattern.js';
|
|
2
2
|
/**
|
|
3
|
-
* v4.
|
|
3
|
+
* v4.5 Pattern: Implicit Requirement Extractor
|
|
4
4
|
*
|
|
5
5
|
* Surfaces requirements mentioned indirectly in conversations.
|
|
6
6
|
* Identifies hidden assumptions and unstated needs.
|
|
7
|
+
* Enhanced with more detection patterns and categorization.
|
|
7
8
|
*/
|
|
8
9
|
export class ImplicitRequirementExtractor extends BasePattern {
|
|
10
|
+
// -------------------------------------------------------------------------
|
|
11
|
+
// Pattern Metadata (v4.5 unified types)
|
|
12
|
+
// -------------------------------------------------------------------------
|
|
9
13
|
id = 'implicit-requirement-extractor';
|
|
10
|
-
name = '
|
|
14
|
+
name = 'Implicit Requirement Extractor';
|
|
11
15
|
description = 'Surfaces requirements mentioned indirectly';
|
|
12
16
|
applicableIntents = ['summarization', 'planning', 'prd-generation'];
|
|
13
17
|
mode = 'deep';
|
|
14
|
-
priority =
|
|
18
|
+
priority = 5; // MEDIUM-LOW - supplementary
|
|
19
|
+
phases = ['conversation-tracking', 'summarization'];
|
|
20
|
+
// -------------------------------------------------------------------------
|
|
21
|
+
// Configuration Schema (v4.5)
|
|
22
|
+
// -------------------------------------------------------------------------
|
|
23
|
+
static configSchema = {
|
|
24
|
+
maxImplicitRequirements: {
|
|
25
|
+
type: 'number',
|
|
26
|
+
default: 10,
|
|
27
|
+
description: 'Maximum number of implicit requirements to surface',
|
|
28
|
+
validation: { min: 1, max: 15 },
|
|
29
|
+
},
|
|
30
|
+
groupByCategory: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
default: true,
|
|
33
|
+
description: 'Group requirements by category',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
// -------------------------------------------------------------------------
|
|
37
|
+
// Pattern Data
|
|
38
|
+
// -------------------------------------------------------------------------
|
|
39
|
+
// Categories for implicit requirements
|
|
40
|
+
implicitPatterns = [
|
|
41
|
+
// Infrastructure requirements
|
|
42
|
+
{
|
|
43
|
+
check: (p) => p.includes('mobile'),
|
|
44
|
+
requirement: 'Mobile-responsive design required',
|
|
45
|
+
category: 'infrastructure',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
check: (p) => p.includes('real-time') || p.includes('realtime'),
|
|
49
|
+
requirement: 'Real-time updates infrastructure needed',
|
|
50
|
+
category: 'infrastructure',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
check: (p) => p.includes('scale') || p.includes('thousands') || p.includes('millions'),
|
|
54
|
+
requirement: 'Scalability architecture required',
|
|
55
|
+
category: 'infrastructure',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
check: (p) => p.includes('offline') || p.includes('without internet'),
|
|
59
|
+
requirement: 'Offline-capable architecture needed',
|
|
60
|
+
category: 'infrastructure',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
check: (p) => p.includes('multi-tenant') || p.includes('multiple organizations'),
|
|
64
|
+
requirement: 'Multi-tenancy support required',
|
|
65
|
+
category: 'infrastructure',
|
|
66
|
+
},
|
|
67
|
+
// Security requirements
|
|
68
|
+
{
|
|
69
|
+
check: (p) => p.includes('secure') || p.includes('security'),
|
|
70
|
+
requirement: 'Security audit and compliance requirements',
|
|
71
|
+
category: 'security',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
check: (p) => p.includes('gdpr') || p.includes('privacy') || p.includes('compliant'),
|
|
75
|
+
requirement: 'Data privacy and compliance infrastructure',
|
|
76
|
+
category: 'security',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
check: (p) => p.includes('encrypt') || p.includes('sensitive'),
|
|
80
|
+
requirement: 'Data encryption requirements',
|
|
81
|
+
category: 'security',
|
|
82
|
+
},
|
|
83
|
+
// Performance requirements
|
|
84
|
+
{
|
|
85
|
+
check: (p) => p.includes('fast') || p.includes('quick'),
|
|
86
|
+
requirement: 'Performance optimization requirements',
|
|
87
|
+
category: 'performance',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
check: (p) => p.includes('responsive') || p.includes('instant'),
|
|
91
|
+
requirement: 'Low-latency response requirements',
|
|
92
|
+
category: 'performance',
|
|
93
|
+
},
|
|
94
|
+
// UX requirements
|
|
95
|
+
{
|
|
96
|
+
check: (p) => p.includes('easy') || p.includes('simple') || p.includes('intuitive'),
|
|
97
|
+
requirement: 'User experience priority (simplicity mentioned)',
|
|
98
|
+
category: 'ux',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
check: (p) => p.includes('accessible') || p.includes('a11y'),
|
|
102
|
+
requirement: 'Accessibility (WCAG) compliance required',
|
|
103
|
+
category: 'ux',
|
|
104
|
+
},
|
|
105
|
+
// Integration requirements
|
|
106
|
+
{
|
|
107
|
+
check: (p) => p.includes('notify') ||
|
|
108
|
+
p.includes('alert') ||
|
|
109
|
+
p.includes('email') ||
|
|
110
|
+
p.includes('notification'),
|
|
111
|
+
requirement: 'Notification system infrastructure',
|
|
112
|
+
category: 'integration',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
check: (p) => p.includes('search') || p.includes('find'),
|
|
116
|
+
requirement: 'Search functionality and indexing',
|
|
117
|
+
category: 'integration',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
check: (p) => p.includes('report') || p.includes('analytics') || p.includes('dashboard'),
|
|
121
|
+
requirement: 'Analytics and reporting infrastructure',
|
|
122
|
+
category: 'integration',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
check: (p) => p.includes('integrate') || p.includes('connect') || p.includes('sync'),
|
|
126
|
+
requirement: 'Integration APIs and webhooks',
|
|
127
|
+
category: 'integration',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
check: (p) => p.includes('import') || p.includes('export') || p.includes('csv'),
|
|
131
|
+
requirement: 'Data import/export functionality',
|
|
132
|
+
category: 'integration',
|
|
133
|
+
},
|
|
134
|
+
];
|
|
15
135
|
apply(prompt, _context) {
|
|
16
136
|
// Extract implicit requirements
|
|
17
137
|
const implicitReqs = this.extractImplicitRequirements(prompt);
|
|
@@ -28,7 +148,7 @@ export class ImplicitRequirementExtractor extends BasePattern {
|
|
|
28
148
|
};
|
|
29
149
|
}
|
|
30
150
|
// Add implicit requirements section
|
|
31
|
-
const enhanced = this.
|
|
151
|
+
const enhanced = this.addImplicitRequirementsSection(prompt, implicitReqs);
|
|
32
152
|
return {
|
|
33
153
|
enhancedPrompt: enhanced,
|
|
34
154
|
improvement: {
|
|
@@ -46,83 +166,93 @@ export class ImplicitRequirementExtractor extends BasePattern {
|
|
|
46
166
|
const likePatterns = prompt.matchAll(/(?:like|similar to|same as)\s+([A-Za-z0-9\s]+)/gi);
|
|
47
167
|
for (const match of likePatterns) {
|
|
48
168
|
if (match[1]) {
|
|
49
|
-
implicitReqs.push(
|
|
169
|
+
implicitReqs.push({
|
|
170
|
+
requirement: `Feature parity with "${match[1].trim()}" (implied)`,
|
|
171
|
+
category: 'feature',
|
|
172
|
+
});
|
|
50
173
|
}
|
|
51
174
|
}
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
lowerPrompt.includes('thousands') ||
|
|
61
|
-
lowerPrompt.includes('millions')) {
|
|
62
|
-
implicitReqs.push('Scalability architecture required');
|
|
63
|
-
}
|
|
64
|
-
if (lowerPrompt.includes('secure') || lowerPrompt.includes('security')) {
|
|
65
|
-
implicitReqs.push('Security audit and compliance requirements');
|
|
66
|
-
}
|
|
67
|
-
if (lowerPrompt.includes('fast') || lowerPrompt.includes('quick')) {
|
|
68
|
-
implicitReqs.push('Performance optimization requirements');
|
|
175
|
+
// Use pattern-based detection
|
|
176
|
+
for (const pattern of this.implicitPatterns) {
|
|
177
|
+
if (pattern.check(lowerPrompt)) {
|
|
178
|
+
implicitReqs.push({
|
|
179
|
+
requirement: pattern.requirement,
|
|
180
|
+
category: pattern.category,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
69
183
|
}
|
|
70
|
-
// Pattern
|
|
184
|
+
// Pattern: User mentions imply auth/permissions
|
|
71
185
|
if ((lowerPrompt.includes('user') || lowerPrompt.includes('admin')) &&
|
|
72
186
|
!lowerPrompt.includes('authentication')) {
|
|
73
|
-
implicitReqs.push(
|
|
187
|
+
implicitReqs.push({
|
|
188
|
+
requirement: 'User authentication system (implied by user roles)',
|
|
189
|
+
category: 'security',
|
|
190
|
+
});
|
|
74
191
|
}
|
|
75
|
-
// Pattern
|
|
192
|
+
// Pattern: Data mentions imply storage
|
|
76
193
|
if ((lowerPrompt.includes('save') ||
|
|
77
194
|
lowerPrompt.includes('store') ||
|
|
78
195
|
lowerPrompt.includes('data')) &&
|
|
79
196
|
!lowerPrompt.includes('database')) {
|
|
80
|
-
implicitReqs.push(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
lowerPrompt.includes('simple') ||
|
|
85
|
-
lowerPrompt.includes('intuitive')) {
|
|
86
|
-
implicitReqs.push('User experience priority (simplicity mentioned)');
|
|
87
|
-
}
|
|
88
|
-
// Pattern 6: Notifications/alerts imply communication system
|
|
89
|
-
if (lowerPrompt.includes('notify') ||
|
|
90
|
-
lowerPrompt.includes('alert') ||
|
|
91
|
-
lowerPrompt.includes('email') ||
|
|
92
|
-
lowerPrompt.includes('notification')) {
|
|
93
|
-
implicitReqs.push('Notification system infrastructure');
|
|
94
|
-
}
|
|
95
|
-
// Pattern 7: Search implies search infrastructure
|
|
96
|
-
if (lowerPrompt.includes('search') || lowerPrompt.includes('find')) {
|
|
97
|
-
implicitReqs.push('Search functionality and indexing');
|
|
197
|
+
implicitReqs.push({
|
|
198
|
+
requirement: 'Data persistence/storage (implied by data operations)',
|
|
199
|
+
category: 'infrastructure',
|
|
200
|
+
});
|
|
98
201
|
}
|
|
99
|
-
// Pattern
|
|
100
|
-
if (lowerPrompt.includes('report') ||
|
|
101
|
-
lowerPrompt.includes('analytics') ||
|
|
102
|
-
lowerPrompt.includes('dashboard')) {
|
|
103
|
-
implicitReqs.push('Analytics and reporting infrastructure');
|
|
104
|
-
}
|
|
105
|
-
// Pattern 9: Integration mentions
|
|
106
|
-
if (lowerPrompt.includes('integrate') ||
|
|
107
|
-
lowerPrompt.includes('connect') ||
|
|
108
|
-
lowerPrompt.includes('sync')) {
|
|
109
|
-
implicitReqs.push('Integration APIs and webhooks');
|
|
110
|
-
}
|
|
111
|
-
// Pattern 10: "Always" or "never" implies validation rules
|
|
202
|
+
// Pattern: "Always" or "never" implies validation rules
|
|
112
203
|
const alwaysNeverPatterns = prompt.matchAll(/(?:always|never|must always|must never)\s+([^.!?]+)/gi);
|
|
113
204
|
for (const match of alwaysNeverPatterns) {
|
|
114
205
|
if (match[1]) {
|
|
115
|
-
implicitReqs.push(
|
|
206
|
+
implicitReqs.push({
|
|
207
|
+
requirement: `Business rule: "${match[1].trim()}" (implied constraint)`,
|
|
208
|
+
category: 'business',
|
|
209
|
+
});
|
|
116
210
|
}
|
|
117
211
|
}
|
|
118
|
-
// Deduplicate
|
|
119
|
-
|
|
212
|
+
// Deduplicate by requirement text
|
|
213
|
+
const seen = new Set();
|
|
214
|
+
return implicitReqs
|
|
215
|
+
.filter((r) => {
|
|
216
|
+
if (seen.has(r.requirement))
|
|
217
|
+
return false;
|
|
218
|
+
seen.add(r.requirement);
|
|
219
|
+
return true;
|
|
220
|
+
})
|
|
221
|
+
.slice(0, 10); // Increased to 10
|
|
120
222
|
}
|
|
121
|
-
|
|
223
|
+
addImplicitRequirementsSection(prompt, implicitReqs) {
|
|
122
224
|
let section = '\n\n### Implicit Requirements (Inferred)\n';
|
|
123
225
|
section += '*The following requirements are implied by the discussion:*\n\n';
|
|
124
|
-
|
|
125
|
-
|
|
226
|
+
// Group by category for better organization
|
|
227
|
+
const byCategory = new Map();
|
|
228
|
+
for (const req of implicitReqs) {
|
|
229
|
+
const existing = byCategory.get(req.category) || [];
|
|
230
|
+
existing.push(req.requirement);
|
|
231
|
+
byCategory.set(req.category, existing);
|
|
232
|
+
}
|
|
233
|
+
// Format with category headers if multiple categories
|
|
234
|
+
if (byCategory.size > 2) {
|
|
235
|
+
const categoryLabels = {
|
|
236
|
+
infrastructure: '🏗️ Infrastructure',
|
|
237
|
+
security: '🔒 Security',
|
|
238
|
+
performance: '⚡ Performance',
|
|
239
|
+
ux: '✨ User Experience',
|
|
240
|
+
integration: '🔗 Integration',
|
|
241
|
+
feature: '📋 Feature',
|
|
242
|
+
business: '📊 Business Rules',
|
|
243
|
+
};
|
|
244
|
+
for (const [category, reqs] of byCategory) {
|
|
245
|
+
section += `**${categoryLabels[category] || category}:**\n`;
|
|
246
|
+
section += reqs.map((r) => `- ${r}`).join('\n');
|
|
247
|
+
section += '\n\n';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
// Simple list for fewer categories
|
|
252
|
+
section += implicitReqs.map((r) => `- ${r.requirement}`).join('\n');
|
|
253
|
+
section += '\n\n';
|
|
254
|
+
}
|
|
255
|
+
section += '> **Note:** Please verify these inferred requirements are accurate.';
|
|
126
256
|
return prompt + section;
|
|
127
257
|
}
|
|
128
258
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
|
|
2
2
|
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* v4.5 Pattern: Objective Clarifier
|
|
5
|
+
*
|
|
6
|
+
* Extracts or infers clear goal statement from prompts.
|
|
7
|
+
* Ensures every prompt has an explicit objective section.
|
|
8
|
+
*/
|
|
3
9
|
export declare class ObjectiveClarifier extends BasePattern {
|
|
4
|
-
id
|
|
5
|
-
name
|
|
6
|
-
description
|
|
7
|
-
applicableIntents: PromptIntent[];
|
|
8
|
-
mode:
|
|
9
|
-
priority:
|
|
10
|
+
readonly id = "objective-clarifier";
|
|
11
|
+
readonly name = "Objective Clarifier";
|
|
12
|
+
readonly description = "Extracts or infers clear goal statement";
|
|
13
|
+
readonly applicableIntents: PromptIntent[];
|
|
14
|
+
readonly mode: PatternMode;
|
|
15
|
+
readonly priority: PatternPriority;
|
|
16
|
+
readonly phases: PatternPhase[];
|
|
17
|
+
static readonly configSchema: PatternConfigSchema;
|
|
10
18
|
apply(prompt: string, context: PatternContext): PatternResult;
|
|
11
19
|
private hasExplicitObjective;
|
|
12
20
|
private extractObjective;
|
|
@@ -1,11 +1,45 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, } from './base-pattern.js';
|
|
2
|
+
/**
|
|
3
|
+
* v4.5 Pattern: Objective Clarifier
|
|
4
|
+
*
|
|
5
|
+
* Extracts or infers clear goal statement from prompts.
|
|
6
|
+
* Ensures every prompt has an explicit objective section.
|
|
7
|
+
*/
|
|
2
8
|
export class ObjectiveClarifier extends BasePattern {
|
|
9
|
+
// -------------------------------------------------------------------------
|
|
10
|
+
// Pattern Metadata (v4.5 unified types)
|
|
11
|
+
// -------------------------------------------------------------------------
|
|
3
12
|
id = 'objective-clarifier';
|
|
4
13
|
name = 'Objective Clarifier';
|
|
5
14
|
description = 'Extracts or infers clear goal statement';
|
|
6
|
-
applicableIntents = [
|
|
15
|
+
applicableIntents = [
|
|
16
|
+
'code-generation',
|
|
17
|
+
'planning',
|
|
18
|
+
'refinement',
|
|
19
|
+
'debugging',
|
|
20
|
+
'documentation',
|
|
21
|
+
];
|
|
7
22
|
mode = 'both';
|
|
8
|
-
priority = 9;
|
|
23
|
+
priority = 9; // VERY HIGH - structural integrity
|
|
24
|
+
phases = ['all'];
|
|
25
|
+
// -------------------------------------------------------------------------
|
|
26
|
+
// Configuration Schema (v4.5)
|
|
27
|
+
// -------------------------------------------------------------------------
|
|
28
|
+
static configSchema = {
|
|
29
|
+
inferFromContext: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: true,
|
|
32
|
+
description: 'Attempt to infer objective when not explicitly stated',
|
|
33
|
+
},
|
|
34
|
+
addHeaderPrefix: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
default: true,
|
|
37
|
+
description: 'Add "# Objective" header prefix when adding objective',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// -------------------------------------------------------------------------
|
|
41
|
+
// Pattern Application
|
|
42
|
+
// -------------------------------------------------------------------------
|
|
9
43
|
apply(prompt, context) {
|
|
10
44
|
// Check if prompt already has clear objective section
|
|
11
45
|
if (this.hasExplicitObjective(prompt)) {
|
|
@@ -14,9 +48,9 @@ export class ObjectiveClarifier extends BasePattern {
|
|
|
14
48
|
improvement: {
|
|
15
49
|
dimension: 'clarity',
|
|
16
50
|
description: 'Objective already clearly stated',
|
|
17
|
-
impact: 'low'
|
|
51
|
+
impact: 'low',
|
|
18
52
|
},
|
|
19
|
-
applied: false
|
|
53
|
+
applied: false,
|
|
20
54
|
};
|
|
21
55
|
}
|
|
22
56
|
// Extract or infer objective
|
|
@@ -28,9 +62,9 @@ export class ObjectiveClarifier extends BasePattern {
|
|
|
28
62
|
improvement: {
|
|
29
63
|
dimension: 'clarity',
|
|
30
64
|
description: 'Could not infer clear objective',
|
|
31
|
-
impact: 'low'
|
|
65
|
+
impact: 'low',
|
|
32
66
|
},
|
|
33
|
-
applied: false
|
|
67
|
+
applied: false,
|
|
34
68
|
};
|
|
35
69
|
}
|
|
36
70
|
// Add objective section
|
|
@@ -40,26 +74,21 @@ export class ObjectiveClarifier extends BasePattern {
|
|
|
40
74
|
improvement: {
|
|
41
75
|
dimension: 'clarity',
|
|
42
76
|
description: 'Added clear objective statement',
|
|
43
|
-
impact: 'high'
|
|
77
|
+
impact: 'high',
|
|
44
78
|
},
|
|
45
|
-
applied: true
|
|
79
|
+
applied: true,
|
|
46
80
|
};
|
|
47
81
|
}
|
|
48
82
|
hasExplicitObjective(prompt) {
|
|
49
|
-
const objectiveMarkers = [
|
|
50
|
-
|
|
51
|
-
/^objective:/im,
|
|
52
|
-
/^goal:/im,
|
|
53
|
-
/^purpose:/im
|
|
54
|
-
];
|
|
55
|
-
return objectiveMarkers.some(marker => marker.test(prompt));
|
|
83
|
+
const objectiveMarkers = [/^#+ objective/im, /^objective:/im, /^goal:/im, /^purpose:/im];
|
|
84
|
+
return objectiveMarkers.some((marker) => marker.test(prompt));
|
|
56
85
|
}
|
|
57
86
|
extractObjective(prompt, intent) {
|
|
58
87
|
const lowerPrompt = prompt.toLowerCase();
|
|
59
88
|
// Look for explicit goal statements
|
|
60
89
|
const goalPatterns = [
|
|
61
90
|
/(?: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
|
|
91
|
+
/(?:create|build|make|implement|develop|write)\s+(.+?)(?:\.|$)/i,
|
|
63
92
|
];
|
|
64
93
|
for (const pattern of goalPatterns) {
|
|
65
94
|
const match = prompt.match(pattern);
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
|
|
2
2
|
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* v4.5 Pattern: Output Format Enforcer
|
|
5
5
|
*
|
|
6
6
|
* Ensures prompts specify the expected output format, which is critical
|
|
7
7
|
* for agent-first design - agents need to know exactly what to produce.
|
|
8
8
|
*/
|
|
9
9
|
export declare class OutputFormatEnforcer extends BasePattern {
|
|
10
|
-
id
|
|
11
|
-
name
|
|
12
|
-
description
|
|
13
|
-
applicableIntents: PromptIntent[];
|
|
14
|
-
mode:
|
|
15
|
-
priority:
|
|
10
|
+
readonly id = "output-format-enforcer";
|
|
11
|
+
readonly name = "Output Format Enforcer";
|
|
12
|
+
readonly description = "Adds explicit output format specifications for agent clarity";
|
|
13
|
+
readonly applicableIntents: PromptIntent[];
|
|
14
|
+
readonly mode: PatternMode;
|
|
15
|
+
readonly priority: PatternPriority;
|
|
16
|
+
readonly phases: PatternPhase[];
|
|
17
|
+
static readonly configSchema: PatternConfigSchema;
|
|
16
18
|
private formatIndicators;
|
|
17
19
|
private intentFormats;
|
|
18
20
|
apply(prompt: string, context: PatternContext): PatternResult;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, } from './base-pattern.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* v4.5 Pattern: Output Format Enforcer
|
|
4
4
|
*
|
|
5
5
|
* Ensures prompts specify the expected output format, which is critical
|
|
6
6
|
* for agent-first design - agents need to know exactly what to produce.
|
|
7
7
|
*/
|
|
8
8
|
export class OutputFormatEnforcer extends BasePattern {
|
|
9
|
+
// -------------------------------------------------------------------------
|
|
10
|
+
// Pattern Metadata (v4.5 unified types)
|
|
11
|
+
// -------------------------------------------------------------------------
|
|
9
12
|
id = 'output-format-enforcer';
|
|
10
13
|
name = 'Output Format Enforcer';
|
|
11
14
|
description = 'Adds explicit output format specifications for agent clarity';
|
|
@@ -17,7 +20,21 @@ export class OutputFormatEnforcer extends BasePattern {
|
|
|
17
20
|
'testing',
|
|
18
21
|
];
|
|
19
22
|
mode = 'both';
|
|
20
|
-
priority = 7; //
|
|
23
|
+
priority = 7; // MEDIUM-HIGH - important enrichment
|
|
24
|
+
phases = ['all'];
|
|
25
|
+
// -------------------------------------------------------------------------
|
|
26
|
+
// Configuration Schema (v4.5)
|
|
27
|
+
// -------------------------------------------------------------------------
|
|
28
|
+
static configSchema = {
|
|
29
|
+
showFormatSuggestions: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
default: true,
|
|
32
|
+
description: 'Show format suggestions based on intent',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
// -------------------------------------------------------------------------
|
|
36
|
+
// Pattern Data
|
|
37
|
+
// -------------------------------------------------------------------------
|
|
21
38
|
// Format indicators that suggest format is already specified
|
|
22
39
|
formatIndicators = [
|
|
23
40
|
'output format',
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
|
|
2
2
|
import { PromptIntent, PatternContext, PatternResult } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
* v4.
|
|
4
|
+
* v4.5 Pattern: PRD Structure Enforcer
|
|
5
5
|
*
|
|
6
6
|
* Ensures PRD prompts include all necessary sections
|
|
7
7
|
* for comprehensive product requirement documentation.
|
|
8
8
|
*/
|
|
9
9
|
export declare class PRDStructureEnforcer extends BasePattern {
|
|
10
|
-
id
|
|
11
|
-
name
|
|
12
|
-
description
|
|
13
|
-
applicableIntents: PromptIntent[];
|
|
14
|
-
mode:
|
|
15
|
-
priority:
|
|
10
|
+
readonly id = "prd-structure-enforcer";
|
|
11
|
+
readonly name = "PRD Structure Enforcer";
|
|
12
|
+
readonly description = "Ensure PRD prompts include all necessary sections";
|
|
13
|
+
readonly applicableIntents: PromptIntent[];
|
|
14
|
+
readonly mode: PatternMode;
|
|
15
|
+
readonly priority: PatternPriority;
|
|
16
|
+
readonly phases: PatternPhase[];
|
|
17
|
+
static readonly configSchema: PatternConfigSchema;
|
|
16
18
|
private readonly PRD_SECTIONS;
|
|
17
19
|
apply(prompt: string, _context: PatternContext): PatternResult;
|
|
18
20
|
private analyzePRDCompleteness;
|
|
@@ -1,17 +1,39 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, } from './base-pattern.js';
|
|
2
2
|
/**
|
|
3
|
-
* v4.
|
|
3
|
+
* v4.5 Pattern: PRD Structure Enforcer
|
|
4
4
|
*
|
|
5
5
|
* Ensures PRD prompts include all necessary sections
|
|
6
6
|
* for comprehensive product requirement documentation.
|
|
7
7
|
*/
|
|
8
8
|
export class PRDStructureEnforcer extends BasePattern {
|
|
9
|
+
// -------------------------------------------------------------------------
|
|
10
|
+
// Pattern Metadata (v4.5 unified types)
|
|
11
|
+
// -------------------------------------------------------------------------
|
|
9
12
|
id = 'prd-structure-enforcer';
|
|
10
13
|
name = 'PRD Structure Enforcer';
|
|
11
14
|
description = 'Ensure PRD prompts include all necessary sections';
|
|
12
15
|
applicableIntents = ['prd-generation'];
|
|
13
16
|
mode = 'deep';
|
|
14
|
-
priority = 9;
|
|
17
|
+
priority = 9; // VERY HIGH - structural integrity
|
|
18
|
+
phases = ['question-validation', 'output-generation'];
|
|
19
|
+
// -------------------------------------------------------------------------
|
|
20
|
+
// Configuration Schema (v4.5)
|
|
21
|
+
// -------------------------------------------------------------------------
|
|
22
|
+
static configSchema = {
|
|
23
|
+
showCompletenessScore: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
default: true,
|
|
26
|
+
description: 'Show PRD completeness percentage',
|
|
27
|
+
},
|
|
28
|
+
includeBestPractices: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
default: true,
|
|
31
|
+
description: 'Include PRD best practices reminder',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
// -------------------------------------------------------------------------
|
|
35
|
+
// Pattern Data
|
|
36
|
+
// -------------------------------------------------------------------------
|
|
15
37
|
// Required PRD sections with their purposes
|
|
16
38
|
PRD_SECTIONS = [
|
|
17
39
|
{
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
|
|
2
2
|
import { PatternContext, PatternResult, PromptIntent } from '../types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* v4.5 Pattern: Prerequisite Identifier
|
|
5
5
|
*
|
|
6
6
|
* Identifies and explicitly states prerequisites and dependencies
|
|
7
7
|
* that must be in place before the task can be executed.
|
|
8
8
|
*/
|
|
9
9
|
export declare class PrerequisiteIdentifier extends BasePattern {
|
|
10
|
-
id
|
|
11
|
-
name
|
|
12
|
-
description
|
|
13
|
-
applicableIntents: PromptIntent[];
|
|
14
|
-
mode:
|
|
15
|
-
priority:
|
|
10
|
+
readonly id = "prerequisite-identifier";
|
|
11
|
+
readonly name = "Prerequisite Identifier";
|
|
12
|
+
readonly description = "Identifies and documents prerequisites and dependencies for task execution";
|
|
13
|
+
readonly applicableIntents: PromptIntent[];
|
|
14
|
+
readonly mode: PatternMode;
|
|
15
|
+
readonly priority: PatternPriority;
|
|
16
|
+
readonly phases: PatternPhase[];
|
|
17
|
+
static readonly configSchema: PatternConfigSchema;
|
|
16
18
|
private prerequisiteIndicators;
|
|
17
19
|
private techPrerequisites;
|
|
18
20
|
private intentPrerequisites;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { BasePattern } from './base-pattern.js';
|
|
1
|
+
import { BasePattern, } from './base-pattern.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* v4.5 Pattern: Prerequisite Identifier
|
|
4
4
|
*
|
|
5
5
|
* Identifies and explicitly states prerequisites and dependencies
|
|
6
6
|
* that must be in place before the task can be executed.
|
|
7
7
|
*/
|
|
8
8
|
export class PrerequisiteIdentifier extends BasePattern {
|
|
9
|
+
// -------------------------------------------------------------------------
|
|
10
|
+
// Pattern Metadata (v4.5 unified types)
|
|
11
|
+
// -------------------------------------------------------------------------
|
|
9
12
|
id = 'prerequisite-identifier';
|
|
10
13
|
name = 'Prerequisite Identifier';
|
|
11
14
|
description = 'Identifies and documents prerequisites and dependencies for task execution';
|
|
@@ -16,8 +19,29 @@ export class PrerequisiteIdentifier extends BasePattern {
|
|
|
16
19
|
'testing',
|
|
17
20
|
'debugging',
|
|
18
21
|
];
|
|
19
|
-
mode = 'deep';
|
|
20
|
-
priority = 6; //
|
|
22
|
+
mode = 'deep';
|
|
23
|
+
priority = 6; // MEDIUM - standard enhancement
|
|
24
|
+
phases = ['all'];
|
|
25
|
+
// -------------------------------------------------------------------------
|
|
26
|
+
// Configuration Schema (v4.5)
|
|
27
|
+
// -------------------------------------------------------------------------
|
|
28
|
+
static configSchema = {
|
|
29
|
+
maxPrerequisites: {
|
|
30
|
+
type: 'number',
|
|
31
|
+
default: 8,
|
|
32
|
+
description: 'Maximum number of prerequisites to list',
|
|
33
|
+
validation: { min: 1, max: 15 },
|
|
34
|
+
},
|
|
35
|
+
maxTechnologies: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
default: 3,
|
|
38
|
+
description: 'Maximum number of technologies to detect',
|
|
39
|
+
validation: { min: 1, max: 5 },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
// -------------------------------------------------------------------------
|
|
43
|
+
// Pattern Data
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
21
45
|
// Keywords that suggest prerequisites are already addressed
|
|
22
46
|
prerequisiteIndicators = [
|
|
23
47
|
'prerequisite',
|