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.
Files changed (77) hide show
  1. package/dist/core/adapters/instructions-generator.d.ts +2 -1
  2. package/dist/core/adapters/instructions-generator.js +21 -8
  3. package/dist/core/intelligence/confidence-calculator.d.ts +93 -0
  4. package/dist/core/intelligence/confidence-calculator.js +124 -0
  5. package/dist/core/intelligence/index.d.ts +1 -0
  6. package/dist/core/intelligence/index.js +2 -0
  7. package/dist/core/intelligence/intent-detector.js +10 -8
  8. package/dist/core/intelligence/pattern-library.d.ts +47 -10
  9. package/dist/core/intelligence/pattern-library.js +151 -79
  10. package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +10 -10
  11. package/dist/core/intelligence/patterns/actionability-enhancer.js +31 -6
  12. package/dist/core/intelligence/patterns/alternative-phrasing-generator.d.ts +10 -8
  13. package/dist/core/intelligence/patterns/alternative-phrasing-generator.js +21 -3
  14. package/dist/core/intelligence/patterns/ambiguity-detector.d.ts +10 -8
  15. package/dist/core/intelligence/patterns/ambiguity-detector.js +31 -3
  16. package/dist/core/intelligence/patterns/assumption-explicitizer.d.ts +10 -8
  17. package/dist/core/intelligence/patterns/assumption-explicitizer.js +26 -3
  18. package/dist/core/intelligence/patterns/base-pattern.d.ts +166 -8
  19. package/dist/core/intelligence/patterns/base-pattern.js +64 -4
  20. package/dist/core/intelligence/patterns/completeness-validator.d.ts +10 -10
  21. package/dist/core/intelligence/patterns/completeness-validator.js +26 -5
  22. package/dist/core/intelligence/patterns/conciseness-filter.d.ts +15 -7
  23. package/dist/core/intelligence/patterns/conciseness-filter.js +36 -4
  24. package/dist/core/intelligence/patterns/context-precision.d.ts +10 -8
  25. package/dist/core/intelligence/patterns/context-precision.js +28 -5
  26. package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +14 -9
  27. package/dist/core/intelligence/patterns/conversation-summarizer.js +109 -29
  28. package/dist/core/intelligence/patterns/dependency-identifier.d.ts +11 -9
  29. package/dist/core/intelligence/patterns/dependency-identifier.js +21 -4
  30. package/dist/core/intelligence/patterns/domain-context-enricher.d.ts +10 -8
  31. package/dist/core/intelligence/patterns/domain-context-enricher.js +27 -3
  32. package/dist/core/intelligence/patterns/edge-case-identifier.d.ts +10 -8
  33. package/dist/core/intelligence/patterns/edge-case-identifier.js +21 -3
  34. package/dist/core/intelligence/patterns/error-tolerance-enhancer.d.ts +10 -8
  35. package/dist/core/intelligence/patterns/error-tolerance-enhancer.js +22 -4
  36. package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +14 -10
  37. package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +193 -63
  38. package/dist/core/intelligence/patterns/objective-clarifier.d.ts +15 -7
  39. package/dist/core/intelligence/patterns/objective-clarifier.js +46 -17
  40. package/dist/core/intelligence/patterns/output-format-enforcer.d.ts +10 -8
  41. package/dist/core/intelligence/patterns/output-format-enforcer.js +20 -3
  42. package/dist/core/intelligence/patterns/prd-structure-enforcer.d.ts +10 -8
  43. package/dist/core/intelligence/patterns/prd-structure-enforcer.js +25 -3
  44. package/dist/core/intelligence/patterns/prerequisite-identifier.d.ts +10 -8
  45. package/dist/core/intelligence/patterns/prerequisite-identifier.js +28 -4
  46. package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +11 -9
  47. package/dist/core/intelligence/patterns/requirement-prioritizer.js +21 -4
  48. package/dist/core/intelligence/patterns/scope-definer.d.ts +10 -8
  49. package/dist/core/intelligence/patterns/scope-definer.js +27 -3
  50. package/dist/core/intelligence/patterns/step-decomposer.d.ts +10 -8
  51. package/dist/core/intelligence/patterns/step-decomposer.js +21 -3
  52. package/dist/core/intelligence/patterns/structure-organizer.d.ts +10 -10
  53. package/dist/core/intelligence/patterns/structure-organizer.js +25 -5
  54. package/dist/core/intelligence/patterns/success-criteria-enforcer.d.ts +10 -8
  55. package/dist/core/intelligence/patterns/success-criteria-enforcer.js +20 -3
  56. package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +11 -9
  57. package/dist/core/intelligence/patterns/success-metrics-enforcer.js +27 -4
  58. package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +16 -7
  59. package/dist/core/intelligence/patterns/technical-context-enricher.js +71 -38
  60. package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +13 -9
  61. package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +202 -42
  62. package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +11 -9
  63. package/dist/core/intelligence/patterns/user-persona-enricher.js +21 -4
  64. package/dist/core/intelligence/patterns/validation-checklist-creator.d.ts +11 -8
  65. package/dist/core/intelligence/patterns/validation-checklist-creator.js +31 -3
  66. package/dist/templates/slash-commands/_canonical/deep.md +1 -1
  67. package/dist/templates/slash-commands/_canonical/execute.md +1 -1
  68. package/dist/templates/slash-commands/_canonical/fast.md +1 -1
  69. package/dist/templates/slash-commands/_canonical/implement.md +1 -1
  70. package/dist/templates/slash-commands/_canonical/plan.md +1 -1
  71. package/dist/templates/slash-commands/_canonical/prd.md +1 -1
  72. package/dist/templates/slash-commands/_canonical/start.md +21 -1
  73. package/dist/templates/slash-commands/_canonical/summarize.md +43 -2
  74. package/dist/templates/slash-commands/_components/references/intent-types.md +3 -1
  75. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +9 -9
  76. package/dist/types/config.d.ts +24 -0
  77. package/package.json +1 -1
@@ -32,9 +32,45 @@ import { TopicCoherenceAnalyzer } from './patterns/topic-coherence-analyzer.js';
32
32
  import { ImplicitRequirementExtractor } from './patterns/implicit-requirement-extractor.js';
33
33
  export class PatternLibrary {
34
34
  patterns = new Map();
35
+ config = null;
36
+ priorityOverrides = new Map();
35
37
  constructor() {
36
38
  this.registerDefaultPatterns();
37
39
  }
40
+ /**
41
+ * v4.5: Apply configuration settings to pattern library
42
+ * Allows enabling/disabling patterns and adjusting priorities via config.
43
+ * Priority overrides are stored separately (pattern.priority is readonly).
44
+ */
45
+ applyConfig(config) {
46
+ this.config = config;
47
+ // Store priority overrides (patterns have readonly priority)
48
+ if (config.patterns?.priorityOverrides) {
49
+ for (const [patternId, newPriority] of Object.entries(config.patterns.priorityOverrides)) {
50
+ if (this.patterns.has(patternId) && newPriority >= 1 && newPriority <= 10) {
51
+ this.priorityOverrides.set(patternId, newPriority);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ /**
57
+ * v4.5: Get effective priority for a pattern (considers overrides)
58
+ */
59
+ getEffectivePriority(pattern) {
60
+ return this.priorityOverrides.get(pattern.id) ?? pattern.priority;
61
+ }
62
+ /**
63
+ * v4.4: Check if a pattern is disabled via config
64
+ */
65
+ isPatternDisabled(patternId) {
66
+ return this.config?.patterns?.disabled?.includes(patternId) ?? false;
67
+ }
68
+ /**
69
+ * v4.4: Get custom settings for a pattern
70
+ */
71
+ getPatternSettings(patternId) {
72
+ return this.config?.patterns?.customSettings?.[patternId];
73
+ }
38
74
  registerDefaultPatterns() {
39
75
  // Register core patterns (available in fast & deep modes)
40
76
  this.register(new ConcisenessFilter()); // HIGH - Remove verbosity
@@ -71,9 +107,12 @@ export class PatternLibrary {
71
107
  this.register(new ImplicitRequirementExtractor()); // P7 - Surface implicit requirements
72
108
  }
73
109
  /**
74
- * Register a new pattern
110
+ * Register a new pattern.
111
+ * v4.5: Injects library reference for config access.
75
112
  */
76
113
  register(pattern) {
114
+ // Inject library reference for config access
115
+ pattern.setPatternLibrary(this);
77
116
  this.patterns.set(pattern.id, pattern);
78
117
  }
79
118
  /**
@@ -107,6 +146,10 @@ export class PatternLibrary {
107
146
  selectPatterns(intent, mode) {
108
147
  const applicablePatterns = [];
109
148
  for (const pattern of this.patterns.values()) {
149
+ // v4.4: Check if pattern is disabled via config
150
+ if (this.isPatternDisabled(pattern.id)) {
151
+ continue;
152
+ }
110
153
  // Check mode compatibility
111
154
  if (pattern.mode !== 'both' && pattern.mode !== mode) {
112
155
  continue;
@@ -117,11 +160,81 @@ export class PatternLibrary {
117
160
  }
118
161
  applicablePatterns.push(pattern);
119
162
  }
120
- // Sort by priority (highest first)
121
- return applicablePatterns.sort((a, b) => b.priority - a.priority);
163
+ // v4.5: Sort by priority and respect dependencies
164
+ return this.sortPatternsWithDependencies(applicablePatterns);
165
+ }
166
+ /**
167
+ * v4.5: Sort patterns by priority while respecting dependency constraints.
168
+ * Handles runAfter (must run after specified patterns) and excludesWith (mutually exclusive).
169
+ */
170
+ sortPatternsWithDependencies(patterns) {
171
+ // First, handle exclusions - remove patterns that conflict with higher priority ones
172
+ const filteredPatterns = this.filterExcludedPatterns(patterns);
173
+ // Sort by priority first
174
+ const sortedByPriority = [...filteredPatterns].sort((a, b) => this.getEffectivePriority(b) - this.getEffectivePriority(a));
175
+ // Then adjust for runAfter dependencies
176
+ return this.adjustForDependencies(sortedByPriority);
177
+ }
178
+ /**
179
+ * v4.5: Filter out patterns that are mutually exclusive with higher priority patterns.
180
+ */
181
+ filterExcludedPatterns(patterns) {
182
+ // Sort by priority (highest first) to determine which exclusion wins
183
+ const sortedByPriority = [...patterns].sort((a, b) => this.getEffectivePriority(b) - this.getEffectivePriority(a));
184
+ const excludedIds = new Set();
185
+ for (const pattern of sortedByPriority) {
186
+ // Skip if this pattern was already excluded
187
+ if (excludedIds.has(pattern.id)) {
188
+ continue;
189
+ }
190
+ // Check if this pattern excludes others
191
+ const excludes = pattern.dependencies?.excludesWith || [];
192
+ for (const excludedId of excludes) {
193
+ excludedIds.add(excludedId);
194
+ }
195
+ }
196
+ // Return patterns that weren't excluded
197
+ return sortedByPriority.filter((p) => !excludedIds.has(p.id));
198
+ }
199
+ /**
200
+ * v4.5: Adjust pattern order to respect runAfter dependencies.
201
+ * If pattern A declares runAfter: ['B'], ensure B runs before A.
202
+ */
203
+ adjustForDependencies(patterns) {
204
+ const patternMap = new Map(patterns.map((p) => [p.id, p]));
205
+ const result = [];
206
+ const processed = new Set();
207
+ const processing = new Set();
208
+ // Depth-first processing to handle dependencies
209
+ const processPattern = (pattern) => {
210
+ if (processed.has(pattern.id)) {
211
+ return; // Already processed
212
+ }
213
+ if (processing.has(pattern.id)) {
214
+ // Circular dependency detected - skip to avoid infinite loop
215
+ return;
216
+ }
217
+ processing.add(pattern.id);
218
+ // Process dependencies first (patterns that must run before this one)
219
+ const runAfter = pattern.dependencies?.runAfter || [];
220
+ for (const depId of runAfter) {
221
+ const depPattern = patternMap.get(depId);
222
+ if (depPattern && !processed.has(depId)) {
223
+ processPattern(depPattern);
224
+ }
225
+ }
226
+ processing.delete(pattern.id);
227
+ processed.add(pattern.id);
228
+ result.push(pattern);
229
+ };
230
+ // Process all patterns in priority order
231
+ for (const pattern of patterns) {
232
+ processPattern(pattern);
233
+ }
234
+ return result;
122
235
  }
123
236
  /**
124
- * v4.3.2: Select patterns for specific mode with phase-awareness
237
+ * v4.5: Select patterns for specific mode with phase-awareness
125
238
  * Maps PRD and conversational modes to appropriate base modes and patterns
126
239
  */
127
240
  selectPatternsForMode(mode, intent, phase) {
@@ -129,6 +242,10 @@ export class PatternLibrary {
129
242
  const baseMode = this.mapToBaseMode(mode, phase);
130
243
  const applicablePatterns = [];
131
244
  for (const pattern of this.patterns.values()) {
245
+ // v4.4: Check if pattern is disabled via config
246
+ if (this.isPatternDisabled(pattern.id)) {
247
+ continue;
248
+ }
132
249
  // Check mode compatibility (use mapped base mode)
133
250
  if (pattern.mode !== 'both' && pattern.mode !== baseMode) {
134
251
  continue;
@@ -137,22 +254,39 @@ export class PatternLibrary {
137
254
  if (!pattern.applicableIntents.includes(intent.primaryIntent)) {
138
255
  continue;
139
256
  }
140
- // Phase-specific filtering for PRD mode
141
- if (mode === 'prd' && phase) {
142
- if (!this.isPatternApplicableForPRDPhase(pattern, phase)) {
143
- continue;
144
- }
145
- }
146
- // Phase-specific filtering for conversational mode
147
- if (mode === 'conversational' && phase) {
148
- if (!this.isPatternApplicableForConversationalPhase(pattern, phase)) {
149
- continue;
150
- }
257
+ // v4.5: Phase-specific filtering using pattern's phases property
258
+ if (phase && !this.isPatternApplicableForPhase(pattern, phase)) {
259
+ continue;
151
260
  }
152
261
  applicablePatterns.push(pattern);
153
262
  }
154
- // Sort by priority (highest first)
155
- return applicablePatterns.sort((a, b) => b.priority - a.priority);
263
+ // v4.5: Sort by priority and respect dependencies
264
+ return this.sortPatternsWithDependencies(applicablePatterns);
265
+ }
266
+ /**
267
+ * v4.5: Check if pattern is applicable for a given phase.
268
+ * Uses pattern's declared phases property instead of hardcoded mappings.
269
+ */
270
+ isPatternApplicableForPhase(pattern, phase) {
271
+ // Map OptimizationPhase to PatternPhase
272
+ const patternPhase = this.mapOptimizationPhaseToPatternPhase(phase);
273
+ if (!patternPhase) {
274
+ return true; // Unknown phase, allow pattern
275
+ }
276
+ // Check if pattern applies to this phase or to 'all' phases
277
+ return pattern.phases.includes('all') || pattern.phases.includes(patternPhase);
278
+ }
279
+ /**
280
+ * v4.5: Map OptimizationPhase string to PatternPhase type
281
+ */
282
+ mapOptimizationPhaseToPatternPhase(phase) {
283
+ const mapping = {
284
+ 'question-validation': 'question-validation',
285
+ 'output-generation': 'output-generation',
286
+ 'conversation-tracking': 'conversation-tracking',
287
+ summarization: 'summarization',
288
+ };
289
+ return mapping[phase] || null;
156
290
  }
157
291
  /**
158
292
  * Map extended modes to base modes for pattern compatibility
@@ -171,68 +305,6 @@ export class PatternLibrary {
171
305
  return mode;
172
306
  }
173
307
  }
174
- /**
175
- * Check if pattern is applicable for PRD phase
176
- */
177
- isPatternApplicableForPRDPhase(pattern, phase) {
178
- // Patterns for question validation (lightweight, clarity-focused)
179
- const questionValidationPatterns = [
180
- 'ambiguity-detector',
181
- 'completeness-validator',
182
- 'objective-clarifier',
183
- ];
184
- // Patterns for output generation (comprehensive)
185
- const outputGenerationPatterns = [
186
- 'prd-structure-enforcer',
187
- 'structure-organizer',
188
- 'success-criteria-enforcer',
189
- 'scope-definer',
190
- 'edge-case-identifier',
191
- 'assumption-explicitizer',
192
- 'technical-context-enricher',
193
- 'domain-context-enricher',
194
- // v4.3.2 PRD patterns will be added here
195
- 'requirement-prioritizer',
196
- 'user-persona-enricher',
197
- 'success-metrics-enforcer',
198
- 'dependency-identifier',
199
- ];
200
- if (phase === 'question-validation') {
201
- return questionValidationPatterns.includes(pattern.id);
202
- }
203
- if (phase === 'output-generation') {
204
- return outputGenerationPatterns.includes(pattern.id);
205
- }
206
- return true; // Default: allow pattern
207
- }
208
- /**
209
- * Check if pattern is applicable for conversational phase
210
- */
211
- isPatternApplicableForConversationalPhase(pattern, phase) {
212
- // Patterns for conversation tracking (minimal, non-intrusive)
213
- const conversationTrackingPatterns = ['ambiguity-detector', 'completeness-validator'];
214
- // Patterns for summarization (comprehensive extraction)
215
- const summarizationPatterns = [
216
- 'structure-organizer',
217
- 'completeness-validator',
218
- 'success-criteria-enforcer',
219
- 'edge-case-identifier',
220
- 'actionability-enhancer',
221
- 'technical-context-enricher',
222
- 'domain-context-enricher',
223
- // v4.3.2 Conversational patterns will be added here
224
- 'conversation-summarizer',
225
- 'topic-coherence-analyzer',
226
- 'implicit-requirement-extractor',
227
- ];
228
- if (phase === 'conversation-tracking') {
229
- return conversationTrackingPatterns.includes(pattern.id);
230
- }
231
- if (phase === 'summarization') {
232
- return summarizationPatterns.includes(pattern.id);
233
- }
234
- return true; // Default: allow pattern
235
- }
236
308
  /**
237
309
  * Get all registered patterns
238
310
  */
@@ -1,20 +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
- * Actionability Enhancer Pattern
4
+ * v4.5 Pattern: Actionability Enhancer
5
5
  *
6
6
  * Converts vague goals into specific, actionable tasks.
7
7
  * Replaces abstract language with concrete requirements.
8
- *
9
- * Priority: HIGH (7)
10
8
  */
11
9
  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;
10
+ readonly id = "actionability-enhancer";
11
+ readonly name = "Actionability Enhancer";
12
+ readonly description = "Converts vague goals into specific, actionable tasks";
13
+ readonly applicableIntents: PromptIntent[];
14
+ readonly mode: PatternMode;
15
+ readonly priority: PatternPriority;
16
+ readonly phases: PatternPhase[];
17
+ static readonly configSchema: PatternConfigSchema;
18
18
  private readonly VAGUE_WORDS;
19
19
  apply(prompt: string, _context: PatternContext): PatternResult;
20
20
  private detectVagueWords;
@@ -1,19 +1,44 @@
1
- import { BasePattern } from './base-pattern.js';
1
+ import { BasePattern, } from './base-pattern.js';
2
2
  /**
3
- * Actionability Enhancer Pattern
3
+ * v4.5 Pattern: Actionability Enhancer
4
4
  *
5
5
  * Converts vague goals into specific, actionable tasks.
6
6
  * Replaces abstract language with concrete requirements.
7
- *
8
- * Priority: HIGH (7)
9
7
  */
10
8
  export class ActionabilityEnhancer extends BasePattern {
9
+ // -------------------------------------------------------------------------
10
+ // Pattern Metadata (v4.5 unified types)
11
+ // -------------------------------------------------------------------------
11
12
  id = 'actionability-enhancer';
12
13
  name = 'Actionability Enhancer';
13
14
  description = 'Converts vague goals into specific, actionable tasks';
14
- applicableIntents = ['code-generation', 'planning', 'refinement', 'debugging'];
15
+ applicableIntents = [
16
+ 'code-generation',
17
+ 'planning',
18
+ 'refinement',
19
+ 'debugging',
20
+ ];
15
21
  mode = 'both';
16
- priority = 7; // High priority
22
+ priority = 4; // LOW - polish phase
23
+ phases = ['all'];
24
+ // -------------------------------------------------------------------------
25
+ // Configuration Schema (v4.5)
26
+ // -------------------------------------------------------------------------
27
+ static configSchema = {
28
+ replaceVagueWords: {
29
+ type: 'boolean',
30
+ default: true,
31
+ description: 'Replace vague words with specific alternatives',
32
+ },
33
+ addMeasurableCriteria: {
34
+ type: 'boolean',
35
+ default: true,
36
+ description: 'Add suggestions for measurable criteria',
37
+ },
38
+ };
39
+ // -------------------------------------------------------------------------
40
+ // Pattern Data
41
+ // -------------------------------------------------------------------------
17
42
  VAGUE_WORDS = {
18
43
  better: ['faster', 'more efficient', 'more reliable', 'more maintainable'],
19
44
  improve: [
@@ -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.0 Deep Mode Pattern: Alternative Phrasing Generator
4
+ * v4.5 Pattern: Alternative Phrasing Generator
5
5
  *
6
6
  * Generates 2-3 alternative prompt structures to give users options
7
7
  * for different approaches to the same request.
8
8
  */
9
9
  export declare class AlternativePhrasingGenerator extends BasePattern {
10
- id: string;
11
- name: string;
12
- description: string;
13
- applicableIntents: PromptIntent[];
14
- mode: "deep";
15
- priority: number;
10
+ readonly id = "alternative-phrasing-generator";
11
+ readonly name = "Alternative Phrasing Generator";
12
+ readonly description = "Generate alternative prompt structures for different approaches";
13
+ readonly applicableIntents: PromptIntent[];
14
+ readonly mode: PatternMode;
15
+ readonly priority: PatternPriority;
16
+ readonly phases: PatternPhase[];
17
+ static readonly configSchema: PatternConfigSchema;
16
18
  apply(prompt: string, context: PatternContext): PatternResult;
17
19
  private generateAlternatives;
18
20
  private generateCodeAlternatives;
@@ -1,11 +1,14 @@
1
- import { BasePattern } from './base-pattern.js';
1
+ import { BasePattern, } from './base-pattern.js';
2
2
  /**
3
- * v4.0 Deep Mode Pattern: Alternative Phrasing Generator
3
+ * v4.5 Pattern: Alternative Phrasing Generator
4
4
  *
5
5
  * Generates 2-3 alternative prompt structures to give users options
6
6
  * for different approaches to the same request.
7
7
  */
8
8
  export class AlternativePhrasingGenerator extends BasePattern {
9
+ // -------------------------------------------------------------------------
10
+ // Pattern Metadata (v4.5 unified types)
11
+ // -------------------------------------------------------------------------
9
12
  id = 'alternative-phrasing-generator';
10
13
  name = 'Alternative Phrasing Generator';
11
14
  description = 'Generate alternative prompt structures for different approaches';
@@ -19,7 +22,22 @@ export class AlternativePhrasingGenerator extends BasePattern {
19
22
  'documentation',
20
23
  ];
21
24
  mode = 'deep';
22
- priority = 5;
25
+ priority = 3; // VERY LOW - final touches
26
+ phases = ['all'];
27
+ // -------------------------------------------------------------------------
28
+ // Configuration Schema (v4.5)
29
+ // -------------------------------------------------------------------------
30
+ static configSchema = {
31
+ maxAlternatives: {
32
+ type: 'number',
33
+ default: 3,
34
+ description: 'Maximum number of alternative approaches to generate',
35
+ validation: { min: 1, max: 5 },
36
+ },
37
+ };
38
+ // -------------------------------------------------------------------------
39
+ // Pattern Application
40
+ // -------------------------------------------------------------------------
23
41
  apply(prompt, context) {
24
42
  const alternatives = this.generateAlternatives(prompt, context.intent.primaryIntent);
25
43
  if (alternatives.length === 0) {
@@ -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
- * AmbiguityDetector Pattern (v4.1)
4
+ * v4.5 Pattern: Ambiguity Detector
5
5
  *
6
6
  * Identifies and clarifies ambiguous terms, vague references, and unclear
7
7
  * specifications in prompts. Helps agents understand exactly what's needed.
8
8
  */
9
9
  export declare class AmbiguityDetector extends BasePattern {
10
- id: string;
11
- name: string;
12
- description: string;
13
- applicableIntents: PromptIntent[];
14
- mode: 'fast' | 'deep' | 'both';
15
- priority: number;
10
+ readonly id = "ambiguity-detector";
11
+ readonly name = "Ambiguity Detector";
12
+ readonly description = "Identifies and clarifies ambiguous terms and vague references";
13
+ readonly applicableIntents: PromptIntent[];
14
+ readonly mode: PatternMode;
15
+ readonly priority: PatternPriority;
16
+ readonly phases: PatternPhase[];
17
+ static readonly configSchema: PatternConfigSchema;
16
18
  private ambiguousTerms;
17
19
  private vaguePatterns;
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
- * AmbiguityDetector Pattern (v4.1)
3
+ * v4.5 Pattern: Ambiguity Detector
4
4
  *
5
5
  * Identifies and clarifies ambiguous terms, vague references, and unclear
6
6
  * specifications in prompts. Helps agents understand exactly what's needed.
7
7
  */
8
8
  export class AmbiguityDetector extends BasePattern {
9
+ // -------------------------------------------------------------------------
10
+ // Pattern Metadata (v4.5 unified types)
11
+ // -------------------------------------------------------------------------
9
12
  id = 'ambiguity-detector';
10
13
  name = 'Ambiguity Detector';
11
14
  description = 'Identifies and clarifies ambiguous terms and vague references';
@@ -20,7 +23,32 @@ export class AmbiguityDetector extends BasePattern {
20
23
  'migration',
21
24
  ];
22
25
  mode = 'both';
23
- priority = 9; // High priority - detect ambiguity early
26
+ priority = 9; // VERY HIGH - structural integrity
27
+ phases = ['all'];
28
+ // -------------------------------------------------------------------------
29
+ // Configuration Schema (v4.5)
30
+ // -------------------------------------------------------------------------
31
+ static configSchema = {
32
+ checkVaguePatterns: {
33
+ type: 'boolean',
34
+ default: true,
35
+ description: 'Check for vague phrases like "should work", "properly", etc.',
36
+ },
37
+ checkUndefinedPronouns: {
38
+ type: 'boolean',
39
+ default: true,
40
+ description: 'Check for unclear pronoun references',
41
+ },
42
+ maxClarifications: {
43
+ type: 'number',
44
+ default: 10,
45
+ description: 'Maximum number of clarifications to add',
46
+ validation: { min: 1, max: 20 },
47
+ },
48
+ };
49
+ // -------------------------------------------------------------------------
50
+ // Pattern Data
51
+ // -------------------------------------------------------------------------
24
52
  // Common ambiguous terms that need clarification
25
53
  ambiguousTerms = {
26
54
  // Generic terms needing specificity
@@ -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.0 Deep Mode Pattern: Assumption Explicitizer
4
+ * v4.5 Pattern: Assumption Explicitizer
5
5
  *
6
6
  * Makes implicit assumptions explicit to prevent misunderstandings
7
7
  * and ensure comprehensive requirement coverage.
8
8
  */
9
9
  export declare class AssumptionExplicitizer extends BasePattern {
10
- id: string;
11
- name: string;
12
- description: string;
13
- applicableIntents: PromptIntent[];
14
- mode: "deep";
15
- priority: number;
10
+ readonly id = "assumption-explicitizer";
11
+ readonly name = "Assumption Explicitizer";
12
+ readonly description = "Make implicit assumptions explicit to prevent misunderstandings";
13
+ readonly applicableIntents: PromptIntent[];
14
+ readonly mode: PatternMode;
15
+ readonly priority: PatternPriority;
16
+ readonly phases: PatternPhase[];
17
+ static readonly configSchema: PatternConfigSchema;
16
18
  apply(prompt: string, context: PatternContext): PatternResult;
17
19
  private identifyAssumptions;
18
20
  private identifyMissingContext;
@@ -1,11 +1,14 @@
1
- import { BasePattern } from './base-pattern.js';
1
+ import { BasePattern, } from './base-pattern.js';
2
2
  /**
3
- * v4.0 Deep Mode Pattern: Assumption Explicitizer
3
+ * v4.5 Pattern: Assumption Explicitizer
4
4
  *
5
5
  * Makes implicit assumptions explicit to prevent misunderstandings
6
6
  * and ensure comprehensive requirement coverage.
7
7
  */
8
8
  export class AssumptionExplicitizer extends BasePattern {
9
+ // -------------------------------------------------------------------------
10
+ // Pattern Metadata (v4.5 unified types)
11
+ // -------------------------------------------------------------------------
9
12
  id = 'assumption-explicitizer';
10
13
  name = 'Assumption Explicitizer';
11
14
  description = 'Make implicit assumptions explicit to prevent misunderstandings';
@@ -18,7 +21,27 @@ export class AssumptionExplicitizer extends BasePattern {
18
21
  'prd-generation',
19
22
  ];
20
23
  mode = 'deep';
21
- priority = 6;
24
+ priority = 6; // MEDIUM - standard enhancement
25
+ phases = ['all'];
26
+ // -------------------------------------------------------------------------
27
+ // Configuration Schema (v4.5)
28
+ // -------------------------------------------------------------------------
29
+ static configSchema = {
30
+ maxAssumptions: {
31
+ type: 'number',
32
+ default: 8,
33
+ description: 'Maximum number of assumptions to surface',
34
+ validation: { min: 1, max: 15 },
35
+ },
36
+ checkDomainAssumptions: {
37
+ type: 'boolean',
38
+ default: true,
39
+ description: 'Check for domain-specific assumptions (auth, API style, etc.)',
40
+ },
41
+ };
42
+ // -------------------------------------------------------------------------
43
+ // Pattern Application
44
+ // -------------------------------------------------------------------------
22
45
  apply(prompt, context) {
23
46
  const assumptions = this.identifyAssumptions(prompt, context.intent.primaryIntent);
24
47
  if (assumptions.length === 0) {