clavix 4.10.0 → 4.11.2

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 (111) hide show
  1. package/dist/cli/commands/analyze.d.ts +3 -0
  2. package/dist/cli/commands/analyze.js +11 -5
  3. package/dist/cli/commands/execute.d.ts +2 -2
  4. package/dist/cli/commands/execute.js +23 -21
  5. package/dist/cli/commands/improve.d.ts +32 -0
  6. package/dist/cli/commands/improve.js +250 -0
  7. package/dist/cli/commands/init.js +35 -29
  8. package/dist/cli/commands/prd.js +14 -13
  9. package/dist/cli/commands/prompts/clear.d.ts +2 -2
  10. package/dist/cli/commands/prompts/clear.js +32 -26
  11. package/dist/cli/commands/prompts/list.js +14 -19
  12. package/dist/cli/commands/summarize.js +23 -14
  13. package/dist/cli/commands/verify.d.ts +2 -2
  14. package/dist/cli/commands/verify.js +26 -24
  15. package/dist/core/doc-injector.d.ts +2 -0
  16. package/dist/core/doc-injector.js +12 -13
  17. package/dist/core/intelligence/intent-detector.d.ts +4 -0
  18. package/dist/core/intelligence/intent-detector.js +8 -18
  19. package/dist/core/intelligence/pattern-library.d.ts +16 -10
  20. package/dist/core/intelligence/pattern-library.js +47 -35
  21. package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +2 -2
  22. package/dist/core/intelligence/patterns/actionability-enhancer.js +1 -1
  23. package/dist/core/intelligence/patterns/alternative-phrasing-generator.d.ts +2 -2
  24. package/dist/core/intelligence/patterns/alternative-phrasing-generator.js +1 -1
  25. package/dist/core/intelligence/patterns/ambiguity-detector.d.ts +2 -2
  26. package/dist/core/intelligence/patterns/ambiguity-detector.js +1 -1
  27. package/dist/core/intelligence/patterns/assumption-explicitizer.d.ts +2 -2
  28. package/dist/core/intelligence/patterns/assumption-explicitizer.js +1 -1
  29. package/dist/core/intelligence/patterns/base-pattern.d.ts +10 -7
  30. package/dist/core/intelligence/patterns/base-pattern.js +7 -3
  31. package/dist/core/intelligence/patterns/completeness-validator.d.ts +2 -2
  32. package/dist/core/intelligence/patterns/completeness-validator.js +1 -1
  33. package/dist/core/intelligence/patterns/conciseness-filter.d.ts +2 -2
  34. package/dist/core/intelligence/patterns/conciseness-filter.js +1 -1
  35. package/dist/core/intelligence/patterns/context-precision.d.ts +2 -2
  36. package/dist/core/intelligence/patterns/context-precision.js +1 -1
  37. package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +2 -2
  38. package/dist/core/intelligence/patterns/conversation-summarizer.js +1 -1
  39. package/dist/core/intelligence/patterns/dependency-identifier.d.ts +2 -2
  40. package/dist/core/intelligence/patterns/dependency-identifier.js +1 -1
  41. package/dist/core/intelligence/patterns/domain-context-enricher.d.ts +2 -2
  42. package/dist/core/intelligence/patterns/domain-context-enricher.js +1 -1
  43. package/dist/core/intelligence/patterns/edge-case-identifier.d.ts +2 -2
  44. package/dist/core/intelligence/patterns/edge-case-identifier.js +1 -1
  45. package/dist/core/intelligence/patterns/error-tolerance-enhancer.d.ts +2 -2
  46. package/dist/core/intelligence/patterns/error-tolerance-enhancer.js +1 -1
  47. package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +2 -2
  48. package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +1 -1
  49. package/dist/core/intelligence/patterns/objective-clarifier.d.ts +2 -2
  50. package/dist/core/intelligence/patterns/objective-clarifier.js +1 -1
  51. package/dist/core/intelligence/patterns/output-format-enforcer.d.ts +2 -2
  52. package/dist/core/intelligence/patterns/output-format-enforcer.js +1 -1
  53. package/dist/core/intelligence/patterns/prd-structure-enforcer.d.ts +2 -2
  54. package/dist/core/intelligence/patterns/prd-structure-enforcer.js +1 -1
  55. package/dist/core/intelligence/patterns/prerequisite-identifier.d.ts +2 -2
  56. package/dist/core/intelligence/patterns/prerequisite-identifier.js +1 -1
  57. package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +2 -2
  58. package/dist/core/intelligence/patterns/requirement-prioritizer.js +1 -1
  59. package/dist/core/intelligence/patterns/scope-definer.d.ts +2 -2
  60. package/dist/core/intelligence/patterns/scope-definer.js +1 -1
  61. package/dist/core/intelligence/patterns/step-decomposer.d.ts +2 -2
  62. package/dist/core/intelligence/patterns/step-decomposer.js +1 -1
  63. package/dist/core/intelligence/patterns/structure-organizer.d.ts +2 -2
  64. package/dist/core/intelligence/patterns/structure-organizer.js +1 -1
  65. package/dist/core/intelligence/patterns/success-criteria-enforcer.d.ts +2 -2
  66. package/dist/core/intelligence/patterns/success-criteria-enforcer.js +1 -1
  67. package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +2 -2
  68. package/dist/core/intelligence/patterns/success-metrics-enforcer.js +1 -1
  69. package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +2 -2
  70. package/dist/core/intelligence/patterns/technical-context-enricher.js +1 -1
  71. package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +2 -2
  72. package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +1 -1
  73. package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +2 -2
  74. package/dist/core/intelligence/patterns/user-persona-enricher.js +1 -1
  75. package/dist/core/intelligence/patterns/validation-checklist-creator.d.ts +2 -2
  76. package/dist/core/intelligence/patterns/validation-checklist-creator.js +1 -1
  77. package/dist/core/intelligence/types.d.ts +6 -3
  78. package/dist/core/intelligence/universal-optimizer.d.ts +20 -15
  79. package/dist/core/intelligence/universal-optimizer.js +44 -29
  80. package/dist/core/prompt-manager.d.ts +24 -22
  81. package/dist/core/prompt-manager.js +65 -92
  82. package/dist/core/verification-manager.d.ts +8 -7
  83. package/dist/core/verification-manager.js +34 -41
  84. package/dist/templates/agents/octo.md +6 -8
  85. package/dist/templates/instructions/README.md +161 -188
  86. package/dist/templates/instructions/core/clavix-mode.md +3 -4
  87. package/dist/templates/instructions/core/verification.md +15 -17
  88. package/dist/templates/instructions/troubleshooting/jumped-to-implementation.md +1 -1
  89. package/dist/templates/instructions/troubleshooting/skipped-file-creation.md +7 -7
  90. package/dist/templates/slash-commands/_canonical/archive.md +1 -1
  91. package/dist/templates/slash-commands/_canonical/execute.md +39 -41
  92. package/dist/templates/slash-commands/_canonical/improve.md +604 -0
  93. package/dist/templates/slash-commands/_canonical/plan.md +1 -1
  94. package/dist/templates/slash-commands/_canonical/prd.md +2 -2
  95. package/dist/templates/slash-commands/_canonical/start.md +1 -1
  96. package/dist/templates/slash-commands/_canonical/summarize.md +1 -1
  97. package/dist/templates/slash-commands/_canonical/verify.md +9 -9
  98. package/dist/templates/slash-commands/_components/agent-protocols/decision-rules.md +16 -16
  99. package/dist/templates/slash-commands/_components/agent-protocols/self-correction.md +4 -4
  100. package/dist/templates/slash-commands/_components/agent-protocols/state-assertion.md +3 -4
  101. package/dist/templates/slash-commands/_components/agent-protocols/state-awareness.md +1 -1
  102. package/dist/templates/slash-commands/_components/sections/escalation-factors.md +25 -25
  103. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +27 -33
  104. package/dist/templates/slash-commands/_components/troubleshooting/mode-confusion.md +1 -1
  105. package/dist/templates/slash-commands/_components/troubleshooting/triage-escalation.md +9 -9
  106. package/dist/types/config.d.ts +1 -2
  107. package/dist/types/verification.d.ts +7 -6
  108. package/dist/types/verification.js +2 -1
  109. package/package.json +3 -1
  110. package/dist/templates/slash-commands/_canonical/deep.md +0 -651
  111. package/dist/templates/slash-commands/_canonical/fast.md +0 -535
@@ -4,14 +4,14 @@ import { TechnicalContextEnricher } from './patterns/technical-context-enricher.
4
4
  import { StructureOrganizer } from './patterns/structure-organizer.js';
5
5
  import { CompletenessValidator } from './patterns/completeness-validator.js';
6
6
  import { ActionabilityEnhancer } from './patterns/actionability-enhancer.js';
7
- // v4.0 Deep mode patterns
7
+ // v4.0 Comprehensive scope patterns
8
8
  import { AlternativePhrasingGenerator } from './patterns/alternative-phrasing-generator.js';
9
9
  import { EdgeCaseIdentifier } from './patterns/edge-case-identifier.js';
10
10
  import { ValidationChecklistCreator } from './patterns/validation-checklist-creator.js';
11
11
  import { AssumptionExplicitizer } from './patterns/assumption-explicitizer.js';
12
12
  import { ScopeDefiner } from './patterns/scope-definer.js';
13
13
  import { PRDStructureEnforcer } from './patterns/prd-structure-enforcer.js';
14
- // v4.0 Both mode patterns
14
+ // v4.0 Both scope patterns (standard & comprehensive)
15
15
  import { StepDecomposer } from './patterns/step-decomposer.js';
16
16
  import { ContextPrecisionBooster } from './patterns/context-precision.js';
17
17
  // v4.1 New patterns - Agent transparency & quality improvements
@@ -72,30 +72,30 @@ export class PatternLibrary {
72
72
  return this.config?.patterns?.customSettings?.[patternId];
73
73
  }
74
74
  registerDefaultPatterns() {
75
- // Register core patterns (available in fast & deep modes)
75
+ // Register core patterns (available in standard & comprehensive scopes)
76
76
  this.register(new ConcisenessFilter()); // HIGH - Remove verbosity
77
77
  this.register(new ObjectiveClarifier()); // HIGH - Add clarity
78
78
  this.register(new TechnicalContextEnricher()); // MEDIUM - Add technical details
79
79
  this.register(new StructureOrganizer()); // HIGH - Reorder logically
80
80
  this.register(new CompletenessValidator()); // MEDIUM - Check missing elements
81
81
  this.register(new ActionabilityEnhancer()); // HIGH - Vague to specific
82
- // v4.0 Deep mode patterns
82
+ // v4.0 Comprehensive scope patterns
83
83
  this.register(new AlternativePhrasingGenerator()); // P5 - Generate alternative structures
84
84
  this.register(new EdgeCaseIdentifier()); // P4 - Identify edge cases by domain
85
85
  this.register(new ValidationChecklistCreator()); // P3 - Create validation checklists
86
86
  this.register(new AssumptionExplicitizer()); // P6 - Make implicit assumptions explicit
87
87
  this.register(new ScopeDefiner()); // P5 - Add scope boundaries
88
88
  this.register(new PRDStructureEnforcer()); // P9 - Ensure PRD completeness
89
- // v4.0 Both mode patterns (fast & deep)
89
+ // v4.0 Both scope patterns (standard & comprehensive)
90
90
  this.register(new StepDecomposer()); // P7 - Break complex prompts into steps
91
91
  this.register(new ContextPrecisionBooster()); // P8 - Add precise context when missing
92
92
  // v4.1 New patterns - Agent transparency & quality improvements
93
- this.register(new AmbiguityDetector()); // P9 - Identify ambiguous terms (both modes)
94
- this.register(new OutputFormatEnforcer()); // P7 - Add output format specs (both modes)
95
- this.register(new SuccessCriteriaEnforcer()); // P6 - Add success criteria (both modes)
96
- this.register(new ErrorToleranceEnhancer()); // P5 - Add error handling (deep only)
97
- this.register(new PrerequisiteIdentifier()); // P6 - Identify prerequisites (deep only)
98
- this.register(new DomainContextEnricher()); // P5 - Add domain best practices (both modes)
93
+ this.register(new AmbiguityDetector()); // P9 - Identify ambiguous terms (both scopes)
94
+ this.register(new OutputFormatEnforcer()); // P7 - Add output format specs (both scopes)
95
+ this.register(new SuccessCriteriaEnforcer()); // P6 - Add success criteria (both scopes)
96
+ this.register(new ErrorToleranceEnhancer()); // P5 - Add error handling (comprehensive only)
97
+ this.register(new PrerequisiteIdentifier()); // P6 - Identify prerequisites (comprehensive only)
98
+ this.register(new DomainContextEnricher()); // P5 - Add domain best practices (both scopes)
99
99
  // v4.3.2 PRD patterns
100
100
  this.register(new RequirementPrioritizer()); // P7 - Separate must-have from nice-to-have
101
101
  this.register(new UserPersonaEnricher()); // P6 - Add user context and personas
@@ -125,7 +125,7 @@ export class PatternLibrary {
125
125
  * Get applicable patterns for given context (backward compatibility wrapper)
126
126
  * @deprecated Use selectPatterns() method instead
127
127
  */
128
- getApplicablePatterns(prompt, intent, quality, mode) {
128
+ getApplicablePatterns(prompt, intent, quality, mode, depthLevel) {
129
129
  // Create IntentAnalysis from parameters
130
130
  const intentAnalysis = {
131
131
  primaryIntent: intent,
@@ -138,20 +138,23 @@ export class PatternLibrary {
138
138
  },
139
139
  };
140
140
  // Use existing selectPatterns method
141
- return this.selectPatterns(intentAnalysis, mode);
141
+ return this.selectPatterns(intentAnalysis, mode, depthLevel);
142
142
  }
143
143
  /**
144
- * Select applicable patterns for the given context
144
+ * v4.11: Select applicable patterns for the given context
145
+ * Now uses DepthLevel ('standard' | 'comprehensive') for pattern filtering
145
146
  */
146
- selectPatterns(intent, mode) {
147
+ selectPatterns(intent, mode, depthLevel) {
147
148
  const applicablePatterns = [];
149
+ // v4.11: Default to 'standard' depth for 'improve' mode if not specified
150
+ const effectiveDepth = depthLevel || (mode === 'improve' ? 'standard' : 'comprehensive');
148
151
  for (const pattern of this.patterns.values()) {
149
152
  // v4.4: Check if pattern is disabled via config
150
153
  if (this.isPatternDisabled(pattern.id)) {
151
154
  continue;
152
155
  }
153
- // Check mode compatibility
154
- if (pattern.mode !== 'both' && pattern.mode !== mode) {
156
+ // v4.11: Check scope compatibility using DepthLevel
157
+ if (pattern.scope !== 'both' && pattern.scope !== effectiveDepth) {
155
158
  continue;
156
159
  }
157
160
  // Check intent compatibility
@@ -234,20 +237,20 @@ export class PatternLibrary {
234
237
  return result;
235
238
  }
236
239
  /**
237
- * v4.5: Select patterns for specific mode with phase-awareness
238
- * Maps PRD and conversational modes to appropriate base modes and patterns
240
+ * v4.11: Select patterns for specific mode with phase-awareness
241
+ * Maps PRD and conversational modes to appropriate depth levels for pattern selection
239
242
  */
240
- selectPatternsForMode(mode, intent, phase) {
241
- // Map PRD/conversational modes to base modes for pattern selection
242
- const baseMode = this.mapToBaseMode(mode, phase);
243
+ selectPatternsForMode(mode, intent, phase, depthLevel) {
244
+ // v4.11: Map mode/phase to depth level for pattern selection
245
+ const effectiveDepth = depthLevel || this.mapToDepthLevel(mode, phase);
243
246
  const applicablePatterns = [];
244
247
  for (const pattern of this.patterns.values()) {
245
248
  // v4.4: Check if pattern is disabled via config
246
249
  if (this.isPatternDisabled(pattern.id)) {
247
250
  continue;
248
251
  }
249
- // Check mode compatibility (use mapped base mode)
250
- if (pattern.mode !== 'both' && pattern.mode !== baseMode) {
252
+ // v4.11: Check scope compatibility using depth level
253
+ if (pattern.scope !== 'both' && pattern.scope !== effectiveDepth) {
251
254
  continue;
252
255
  }
253
256
  // Check intent compatibility
@@ -289,20 +292,20 @@ export class PatternLibrary {
289
292
  return mapping[phase] || null;
290
293
  }
291
294
  /**
292
- * Map extended modes to base modes for pattern compatibility
295
+ * v4.11: Map mode and phase to depth level for pattern selection
293
296
  */
294
- mapToBaseMode(mode, phase) {
297
+ mapToDepthLevel(mode, phase) {
295
298
  switch (mode) {
296
299
  case 'prd':
297
- // PRD uses deep mode for output generation, fast for validation
298
- return phase === 'question-validation' ? 'fast' : 'deep';
300
+ // PRD uses comprehensive for output generation, standard for validation
301
+ return phase === 'question-validation' ? 'standard' : 'comprehensive';
299
302
  case 'conversational':
300
- // Conversational uses fast mode for tracking, deep for summarization
301
- return phase === 'summarization' ? 'deep' : 'fast';
302
- case 'fast':
303
- case 'deep':
303
+ // Conversational uses standard for tracking, comprehensive for summarization
304
+ return phase === 'summarization' ? 'comprehensive' : 'standard';
305
+ case 'improve':
304
306
  default:
305
- return mode;
307
+ // 'improve' mode defaults to standard; caller can override with depthLevel param
308
+ return 'standard';
306
309
  }
307
310
  }
308
311
  /**
@@ -312,10 +315,19 @@ export class PatternLibrary {
312
315
  return Array.from(this.patterns.values());
313
316
  }
314
317
  /**
315
- * Get patterns by mode
318
+ * v4.11: Get patterns by scope (standard or comprehensive)
319
+ */
320
+ getPatternsByScope(scope) {
321
+ return Array.from(this.patterns.values()).filter((p) => p.scope === scope || p.scope === 'both');
322
+ }
323
+ /**
324
+ * Get patterns by mode (backward compatibility)
325
+ * @deprecated Use getPatternsByScope() instead
316
326
  */
317
327
  getPatternsByMode(mode) {
318
- return Array.from(this.patterns.values()).filter((p) => p.mode === mode || p.mode === 'both');
328
+ // v4.11: Map old mode names to scope for backward compatibility
329
+ const scope = mode === 'improve' ? 'standard' : 'comprehensive';
330
+ return this.getPatternsByScope(scope);
319
331
  }
320
332
  /**
321
333
  * Get pattern count
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Actionability Enhancer
@@ -11,7 +11,7 @@ export declare class ActionabilityEnhancer extends BasePattern {
11
11
  readonly name = "Actionability Enhancer";
12
12
  readonly description = "Converts vague goals into specific, actionable tasks";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -18,7 +18,7 @@ export class ActionabilityEnhancer extends BasePattern {
18
18
  'refinement',
19
19
  'debugging',
20
20
  ];
21
- mode = 'both';
21
+ scope = 'both';
22
22
  priority = 4; // LOW - polish phase
23
23
  phases = ['all'];
24
24
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Alternative Phrasing Generator
@@ -11,7 +11,7 @@ export declare class AlternativePhrasingGenerator extends BasePattern {
11
11
  readonly name = "Alternative Phrasing Generator";
12
12
  readonly description = "Generate alternative prompt structures for different approaches";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -21,7 +21,7 @@ export class AlternativePhrasingGenerator extends BasePattern {
21
21
  'security-review',
22
22
  'documentation',
23
23
  ];
24
- mode = 'deep';
24
+ scope = 'comprehensive';
25
25
  priority = 3; // VERY LOW - final touches
26
26
  phases = ['all'];
27
27
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Ambiguity Detector
@@ -11,7 +11,7 @@ export declare class AmbiguityDetector extends BasePattern {
11
11
  readonly name = "Ambiguity Detector";
12
12
  readonly description = "Identifies and clarifies ambiguous terms and vague references";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -22,7 +22,7 @@ export class AmbiguityDetector extends BasePattern {
22
22
  'testing',
23
23
  'migration',
24
24
  ];
25
- mode = 'both';
25
+ scope = 'both';
26
26
  priority = 9; // VERY HIGH - structural integrity
27
27
  phases = ['all'];
28
28
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Assumption Explicitizer
@@ -11,7 +11,7 @@ export declare class AssumptionExplicitizer extends BasePattern {
11
11
  readonly name = "Assumption Explicitizer";
12
12
  readonly description = "Make implicit assumptions explicit to prevent misunderstandings";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -20,7 +20,7 @@ export class AssumptionExplicitizer extends BasePattern {
20
20
  'debugging',
21
21
  'prd-generation',
22
22
  ];
23
- mode = 'deep';
23
+ scope = 'comprehensive';
24
24
  priority = 6; // MEDIUM - standard enhancement
25
25
  phases = ['all'];
26
26
  // -------------------------------------------------------------------------
@@ -1,11 +1,14 @@
1
1
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
2
2
  /**
3
- * Pattern mode determines when a pattern is active.
4
- * - 'fast': Only in fast optimization mode
5
- * - 'deep': Only in deep analysis mode
6
- * - 'both': Available in both modes
3
+ * v4.11: Pattern scope determines when a pattern is active.
4
+ * - 'standard': Only for standard depth optimization
5
+ * - 'comprehensive': Only for comprehensive depth analysis
6
+ * - 'both': Available at both depth levels
7
+ *
8
+ * Note: Renamed from PatternMode in v4.11. 'fast' → 'standard', 'deep' → 'comprehensive'
7
9
  */
8
- export type PatternMode = 'fast' | 'deep' | 'both';
10
+ export type PatternScope = 'standard' | 'comprehensive' | 'both';
11
+ export type PatternMode = PatternScope;
9
12
  /**
10
13
  * Pattern phases for PRD and Conversational modes.
11
14
  * Patterns declare which phases they apply to.
@@ -120,8 +123,8 @@ export declare abstract class BasePattern {
120
123
  abstract readonly description: string;
121
124
  /** Which intents this pattern is applicable to */
122
125
  abstract readonly applicableIntents: PromptIntent[];
123
- /** Which mode(s) this pattern runs in */
124
- abstract readonly mode: PatternMode;
126
+ /** Which depth level(s) this pattern runs at (v4.11: renamed from mode) */
127
+ abstract readonly scope: PatternScope;
125
128
  /** Execution priority (1-10, higher runs first) */
126
129
  abstract readonly priority: PatternPriority;
127
130
  /** Which phases this pattern applies to (PRD/conversational modes) */
@@ -60,9 +60,13 @@ export class BasePattern {
60
60
  * Can be overridden for custom applicability logic.
61
61
  */
62
62
  isApplicable(context) {
63
- // Check mode compatibility
64
- if (this.mode !== 'both' && this.mode !== context.mode) {
65
- return false;
63
+ // v4.11: Check scope compatibility with depth level
64
+ // For improve mode, compare scope with depthLevel
65
+ // For prd/conversational modes, use the derived depth from phase
66
+ if (context.depthLevel) {
67
+ if (this.scope !== 'both' && this.scope !== context.depthLevel) {
68
+ return false;
69
+ }
66
70
  }
67
71
  // Check intent compatibility
68
72
  return this.applicableIntents.includes(context.intent.primaryIntent);
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Completeness Validator
@@ -11,7 +11,7 @@ export declare class CompletenessValidator extends BasePattern {
11
11
  readonly name = "Completeness Validator";
12
12
  readonly description = "Ensures all necessary requirements are present";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -13,7 +13,7 @@ export class CompletenessValidator extends BasePattern {
13
13
  name = 'Completeness Validator';
14
14
  description = 'Ensures all necessary requirements are present';
15
15
  applicableIntents = ['code-generation', 'planning', 'refinement'];
16
- mode = 'both';
16
+ scope = 'both';
17
17
  priority = 6; // MEDIUM - standard enhancement
18
18
  phases = ['all'];
19
19
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Conciseness Filter
@@ -11,7 +11,7 @@ export declare class ConcisenessFilter extends BasePattern {
11
11
  readonly name = "Conciseness Filter";
12
12
  readonly description = "Removes unnecessary pleasantries, fluff words, and redundancy";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -19,7 +19,7 @@ export class ConcisenessFilter extends BasePattern {
19
19
  'debugging',
20
20
  'documentation',
21
21
  ];
22
- mode = 'both';
22
+ scope = 'both';
23
23
  priority = 4; // LOW - Polish phase
24
24
  phases = ['all'];
25
25
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Context Precision Booster
@@ -11,7 +11,7 @@ export declare class ContextPrecisionBooster extends BasePattern {
11
11
  readonly name = "Context Precision Booster";
12
12
  readonly description = "Add precise context when missing";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -21,7 +21,7 @@ export class ContextPrecisionBooster extends BasePattern {
21
21
  'migration',
22
22
  'security-review',
23
23
  ];
24
- mode = 'both';
24
+ scope = 'both';
25
25
  priority = 6; // MEDIUM - standard enhancement
26
26
  phases = ['all'];
27
27
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Conversation Summarizer
@@ -12,7 +12,7 @@ export declare class ConversationSummarizer extends BasePattern {
12
12
  readonly name = "Conversation Summarizer";
13
13
  readonly description = "Extracts structured requirements from messages";
14
14
  readonly applicableIntents: PromptIntent[];
15
- readonly mode: PatternMode;
15
+ readonly scope: PatternScope;
16
16
  readonly priority: PatternPriority;
17
17
  readonly phases: PatternPhase[];
18
18
  static readonly configSchema: PatternConfigSchema;
@@ -15,7 +15,7 @@ export class ConversationSummarizer extends BasePattern {
15
15
  name = 'Conversation Summarizer';
16
16
  description = 'Extracts structured requirements from messages';
17
17
  applicableIntents = ['summarization', 'planning', 'prd-generation'];
18
- mode = 'deep';
18
+ scope = 'comprehensive';
19
19
  priority = 8; // HIGH - core enhancement
20
20
  phases = ['summarization'];
21
21
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Dependency Identifier
@@ -11,7 +11,7 @@ export declare class DependencyIdentifier extends BasePattern {
11
11
  readonly name = "Dependency Identifier";
12
12
  readonly description = "Identifies technical and external dependencies";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -13,7 +13,7 @@ export class DependencyIdentifier extends BasePattern {
13
13
  name = 'Dependency Identifier';
14
14
  description = 'Identifies technical and external dependencies';
15
15
  applicableIntents = ['prd-generation', 'planning', 'migration'];
16
- mode = 'deep';
16
+ scope = 'comprehensive';
17
17
  priority = 5; // MEDIUM-LOW - supplementary
18
18
  phases = ['question-validation', 'output-generation'];
19
19
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Domain Context Enricher
@@ -11,7 +11,7 @@ export declare class DomainContextEnricher extends BasePattern {
11
11
  readonly name = "Domain Context Enricher";
12
12
  readonly description = "Adds domain-specific best practices and context";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -21,7 +21,7 @@ export class DomainContextEnricher extends BasePattern {
21
21
  'security-review',
22
22
  'migration',
23
23
  ];
24
- mode = 'both';
24
+ scope = 'both';
25
25
  priority = 5; // MEDIUM-LOW - supplementary
26
26
  phases = ['all'];
27
27
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Edge Case Identifier
@@ -11,7 +11,7 @@ export declare class EdgeCaseIdentifier extends BasePattern {
11
11
  readonly name = "Edge Case Identifier";
12
12
  readonly description = "Identify potential edge cases and failure modes by domain";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -19,7 +19,7 @@ export class EdgeCaseIdentifier extends BasePattern {
19
19
  'migration',
20
20
  'security-review',
21
21
  ];
22
- mode = 'deep';
22
+ scope = 'comprehensive';
23
23
  priority = 4; // LOW - polish phase
24
24
  phases = ['all'];
25
25
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Error Tolerance Enhancer
@@ -11,7 +11,7 @@ export declare class ErrorToleranceEnhancer extends BasePattern {
11
11
  readonly name = "Error Tolerance Enhancer";
12
12
  readonly description = "Adds error handling requirements and failure mode considerations";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -19,7 +19,7 @@ export class ErrorToleranceEnhancer extends BasePattern {
19
19
  'migration',
20
20
  'testing',
21
21
  ];
22
- mode = 'deep';
22
+ scope = 'comprehensive';
23
23
  priority = 5; // MEDIUM-LOW - supplementary
24
24
  phases = ['all'];
25
25
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PromptIntent, PatternContext, PatternResult } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Implicit Requirement Extractor
@@ -12,7 +12,7 @@ export declare class ImplicitRequirementExtractor extends BasePattern {
12
12
  readonly name = "Implicit Requirement Extractor";
13
13
  readonly description = "Surfaces requirements mentioned indirectly";
14
14
  readonly applicableIntents: PromptIntent[];
15
- readonly mode: PatternMode;
15
+ readonly scope: PatternScope;
16
16
  readonly priority: PatternPriority;
17
17
  readonly phases: PatternPhase[];
18
18
  static readonly configSchema: PatternConfigSchema;
@@ -14,7 +14,7 @@ export class ImplicitRequirementExtractor extends BasePattern {
14
14
  name = 'Implicit Requirement Extractor';
15
15
  description = 'Surfaces requirements mentioned indirectly';
16
16
  applicableIntents = ['summarization', 'planning', 'prd-generation'];
17
- mode = 'deep';
17
+ scope = 'comprehensive';
18
18
  priority = 5; // MEDIUM-LOW - supplementary
19
19
  phases = ['conversation-tracking', 'summarization'];
20
20
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
2
2
  import { PatternContext, PatternResult, PromptIntent } from '../types.js';
3
3
  /**
4
4
  * v4.5 Pattern: Objective Clarifier
@@ -11,7 +11,7 @@ export declare class ObjectiveClarifier extends BasePattern {
11
11
  readonly name = "Objective Clarifier";
12
12
  readonly description = "Extracts or infers clear goal statement";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -19,7 +19,7 @@ export class ObjectiveClarifier extends BasePattern {
19
19
  'debugging',
20
20
  'documentation',
21
21
  ];
22
- mode = 'both';
22
+ scope = 'both';
23
23
  priority = 9; // VERY HIGH - structural integrity
24
24
  phases = ['all'];
25
25
  // -------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- import { BasePattern, PatternMode, PatternPriority, PatternPhase, PatternConfigSchema } from './base-pattern.js';
1
+ import { BasePattern, PatternScope, 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
@@ -11,7 +11,7 @@ export declare class OutputFormatEnforcer extends BasePattern {
11
11
  readonly name = "Output Format Enforcer";
12
12
  readonly description = "Adds explicit output format specifications for agent clarity";
13
13
  readonly applicableIntents: PromptIntent[];
14
- readonly mode: PatternMode;
14
+ readonly scope: PatternScope;
15
15
  readonly priority: PatternPriority;
16
16
  readonly phases: PatternPhase[];
17
17
  static readonly configSchema: PatternConfigSchema;
@@ -19,7 +19,7 @@ export class OutputFormatEnforcer extends BasePattern {
19
19
  'prd-generation',
20
20
  'testing',
21
21
  ];
22
- mode = 'both';
22
+ scope = 'both';
23
23
  priority = 7; // MEDIUM-HIGH - important enrichment
24
24
  phases = ['all'];
25
25
  // -------------------------------------------------------------------------