clavix 4.2.0 → 4.3.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 (51) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +1 -1
  3. package/dist/cli/commands/deep.js +4 -58
  4. package/dist/cli/commands/init.js +13 -16
  5. package/dist/cli/commands/plan.js +2 -2
  6. package/dist/core/conversation-quality-tracker.d.ts +81 -0
  7. package/dist/core/conversation-quality-tracker.js +195 -0
  8. package/dist/core/intelligence/intent-detector.js +3 -0
  9. package/dist/core/intelligence/pattern-library.d.ts +18 -1
  10. package/dist/core/intelligence/pattern-library.js +131 -0
  11. package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +25 -0
  12. package/dist/core/intelligence/patterns/conversation-summarizer.js +197 -0
  13. package/dist/core/intelligence/patterns/dependency-identifier.d.ts +21 -0
  14. package/dist/core/intelligence/patterns/dependency-identifier.js +149 -0
  15. package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +20 -0
  16. package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +129 -0
  17. package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +22 -0
  18. package/dist/core/intelligence/patterns/requirement-prioritizer.js +117 -0
  19. package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +22 -0
  20. package/dist/core/intelligence/patterns/success-metrics-enforcer.js +142 -0
  21. package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +22 -0
  22. package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +140 -0
  23. package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +22 -0
  24. package/dist/core/intelligence/patterns/user-persona-enricher.js +124 -0
  25. package/dist/core/intelligence/quality-assessor.js +2 -0
  26. package/dist/core/intelligence/types.d.ts +7 -2
  27. package/dist/core/intelligence/universal-optimizer.d.ts +27 -2
  28. package/dist/core/intelligence/universal-optimizer.js +65 -5
  29. package/dist/core/task-manager.d.ts +1 -2
  30. package/dist/core/task-manager.js +21 -26
  31. package/dist/templates/slash-commands/_canonical/deep.md +37 -69
  32. package/dist/templates/slash-commands/_canonical/fast.md +1 -0
  33. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +26 -2
  34. package/package.json +3 -3
  35. package/dist/templates/instructions/README 2.md +0 -311
  36. package/dist/templates/instructions/core 2/clavix-mode.md +0 -275
  37. package/dist/templates/instructions/core 2/file-operations.md +0 -330
  38. package/dist/templates/instructions/core 2/verification.md +0 -377
  39. package/dist/templates/instructions/troubleshooting 2/jumped-to-implementation.md +0 -234
  40. package/dist/templates/instructions/troubleshooting 2/mode-confusion.md +0 -402
  41. package/dist/templates/instructions/troubleshooting 2/skipped-file-creation.md +0 -385
  42. package/dist/templates/slash-commands/_canonical 2/archive.md +0 -410
  43. package/dist/templates/slash-commands/_canonical 2/deep.md +0 -512
  44. package/dist/templates/slash-commands/_canonical 2/execute.md +0 -80
  45. package/dist/templates/slash-commands/_canonical 2/fast.md +0 -370
  46. package/dist/templates/slash-commands/_canonical 2/implement.md +0 -364
  47. package/dist/templates/slash-commands/_canonical 2/plan.md +0 -329
  48. package/dist/templates/slash-commands/_canonical 2/prd.md +0 -320
  49. package/dist/templates/slash-commands/_canonical 2/prompts.md +0 -97
  50. package/dist/templates/slash-commands/_canonical 2/start.md +0 -204
  51. package/dist/templates/slash-commands/_canonical 2/summarize.md +0 -395
@@ -0,0 +1,140 @@
1
+ import { BasePattern } from './base-pattern.js';
2
+ /**
3
+ * v4.3.2 Conversational Pattern: TopicCoherenceAnalyzer
4
+ *
5
+ * Detects topic shifts and multi-topic conversations.
6
+ * Helps organize scattered discussions into coherent themes.
7
+ */
8
+ export class TopicCoherenceAnalyzer extends BasePattern {
9
+ id = 'topic-coherence-analyzer';
10
+ name = 'TopicCoherenceAnalyzer';
11
+ description = 'Detects topic shifts and multi-topic conversations';
12
+ applicableIntents = ['summarization', 'planning'];
13
+ mode = 'deep';
14
+ priority = 6;
15
+ apply(prompt, _context) {
16
+ // Detect topics in the content
17
+ const topics = this.detectTopics(prompt);
18
+ // If single topic or already organized, skip
19
+ if (topics.length <= 1) {
20
+ return {
21
+ enhancedPrompt: prompt,
22
+ improvement: {
23
+ dimension: 'structure',
24
+ description: 'Single coherent topic detected',
25
+ impact: 'low',
26
+ },
27
+ applied: false,
28
+ };
29
+ }
30
+ // Check if already has topic organization
31
+ if (this.hasTopicOrganization(prompt)) {
32
+ return {
33
+ enhancedPrompt: prompt,
34
+ improvement: {
35
+ dimension: 'structure',
36
+ description: 'Topics already organized',
37
+ impact: 'low',
38
+ },
39
+ applied: false,
40
+ };
41
+ }
42
+ // Add topic organization
43
+ const enhanced = this.organizeByTopic(prompt, topics);
44
+ return {
45
+ enhancedPrompt: enhanced,
46
+ improvement: {
47
+ dimension: 'structure',
48
+ description: `Organized ${topics.length} distinct topics for clarity`,
49
+ impact: 'medium',
50
+ },
51
+ applied: true,
52
+ };
53
+ }
54
+ detectTopics(prompt) {
55
+ const topics = [];
56
+ const lowerPrompt = prompt.toLowerCase();
57
+ // Topic detection patterns
58
+ const topicIndicators = {
59
+ 'User Interface': ['ui', 'interface', 'design', 'layout', 'button', 'form', 'page', 'screen'],
60
+ 'Backend/API': ['api', 'backend', 'server', 'endpoint', 'route', 'controller'],
61
+ Database: ['database', 'db', 'schema', 'table', 'query', 'migration'],
62
+ Authentication: ['auth', 'login', 'password', 'session', 'token', 'permission'],
63
+ Performance: ['performance', 'speed', 'cache', 'optimize', 'latency'],
64
+ Testing: ['test', 'spec', 'coverage', 'qa', 'validation'],
65
+ Deployment: ['deploy', 'ci/cd', 'pipeline', 'release', 'environment'],
66
+ 'User Experience': ['ux', 'usability', 'accessibility', 'user flow', 'journey'],
67
+ 'Business Logic': ['business', 'workflow', 'process', 'rule', 'logic'],
68
+ Integration: ['integration', 'third-party', 'external', 'webhook', 'sync'],
69
+ };
70
+ for (const [topic, keywords] of Object.entries(topicIndicators)) {
71
+ const hasKeyword = keywords.some((kw) => lowerPrompt.includes(kw));
72
+ if (hasKeyword) {
73
+ topics.push(topic);
74
+ }
75
+ }
76
+ return topics;
77
+ }
78
+ hasTopicOrganization(prompt) {
79
+ // Check for existing topic headers
80
+ const topicHeaders = /##\s*(user interface|backend|database|auth|performance|testing|deploy)/i;
81
+ return topicHeaders.test(prompt);
82
+ }
83
+ organizeByTopic(prompt, topics) {
84
+ // Add topic summary at the beginning
85
+ let organized = '### Topics Covered\n';
86
+ organized += 'This conversation touches on multiple areas:\n';
87
+ organized += topics.map((t, i) => `${i + 1}. **${t}**`).join('\n');
88
+ organized += '\n\n---\n\n';
89
+ // Extract content relevant to each topic
90
+ organized += '### Discussion by Topic\n\n';
91
+ for (const topic of topics) {
92
+ const relevantContent = this.extractTopicContent(prompt, topic);
93
+ if (relevantContent) {
94
+ organized += `#### ${topic}\n`;
95
+ organized += relevantContent + '\n\n';
96
+ }
97
+ }
98
+ organized += '---\n\n**Full Context:**\n' + prompt;
99
+ return organized;
100
+ }
101
+ extractTopicContent(prompt, topic) {
102
+ // Simple extraction based on topic keywords
103
+ const topicKeywords = {
104
+ 'User Interface': [
105
+ 'ui',
106
+ 'interface',
107
+ 'design',
108
+ 'layout',
109
+ 'button',
110
+ 'form',
111
+ 'page',
112
+ 'screen',
113
+ 'component',
114
+ ],
115
+ 'Backend/API': ['api', 'backend', 'server', 'endpoint', 'route', 'controller', 'service'],
116
+ Database: ['database', 'db', 'schema', 'table', 'query', 'migration', 'model'],
117
+ Authentication: ['auth', 'login', 'password', 'session', 'token', 'permission', 'user'],
118
+ Performance: ['performance', 'speed', 'cache', 'optimize', 'latency', 'fast', 'slow'],
119
+ Testing: ['test', 'spec', 'coverage', 'qa', 'validation', 'verify'],
120
+ Deployment: ['deploy', 'ci/cd', 'pipeline', 'release', 'environment', 'production'],
121
+ 'User Experience': ['ux', 'usability', 'accessibility', 'user flow', 'journey', 'experience'],
122
+ 'Business Logic': ['business', 'workflow', 'process', 'rule', 'logic', 'requirement'],
123
+ Integration: ['integration', 'third-party', 'external', 'webhook', 'sync', 'connect'],
124
+ };
125
+ const keywords = topicKeywords[topic] || [];
126
+ const sentences = this.extractSentences(prompt);
127
+ const relevantSentences = sentences.filter((sentence) => {
128
+ const lower = sentence.toLowerCase();
129
+ return keywords.some((kw) => lower.includes(kw));
130
+ });
131
+ if (relevantSentences.length === 0) {
132
+ return `- Discussion related to ${topic}`;
133
+ }
134
+ return relevantSentences
135
+ .slice(0, 3)
136
+ .map((s) => `- ${s.trim()}`)
137
+ .join('\n');
138
+ }
139
+ }
140
+ //# sourceMappingURL=topic-coherence-analyzer.js.map
@@ -0,0 +1,22 @@
1
+ import { BasePattern } from './base-pattern.js';
2
+ import { PromptIntent, OptimizationMode, PatternContext, PatternResult } from '../types.js';
3
+ /**
4
+ * v4.3.2 PRD Pattern: UserPersonaEnricher
5
+ *
6
+ * Adds missing user context and personas to PRD content.
7
+ * Ensures the "who" is clearly defined alongside the "what".
8
+ */
9
+ export declare class UserPersonaEnricher extends BasePattern {
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ applicableIntents: PromptIntent[];
14
+ mode: OptimizationMode | 'both';
15
+ priority: number;
16
+ apply(prompt: string, _context: PatternContext): PatternResult;
17
+ private hasUserContext;
18
+ private needsUserContext;
19
+ private addUserPersona;
20
+ private inferUserType;
21
+ }
22
+ //# sourceMappingURL=user-persona-enricher.d.ts.map
@@ -0,0 +1,124 @@
1
+ import { BasePattern } from './base-pattern.js';
2
+ /**
3
+ * v4.3.2 PRD Pattern: UserPersonaEnricher
4
+ *
5
+ * Adds missing user context and personas to PRD content.
6
+ * Ensures the "who" is clearly defined alongside the "what".
7
+ */
8
+ export class UserPersonaEnricher extends BasePattern {
9
+ id = 'user-persona-enricher';
10
+ name = 'UserPersonaEnricher';
11
+ description = 'Adds missing user context and personas';
12
+ applicableIntents = ['prd-generation', 'planning'];
13
+ mode = 'deep';
14
+ priority = 6;
15
+ apply(prompt, _context) {
16
+ // Check if user/persona context already exists
17
+ if (this.hasUserContext(prompt)) {
18
+ return {
19
+ enhancedPrompt: prompt,
20
+ improvement: {
21
+ dimension: 'completeness',
22
+ description: 'User context already present',
23
+ impact: 'low',
24
+ },
25
+ applied: false,
26
+ };
27
+ }
28
+ // Check if this is PRD-like content that needs users
29
+ if (!this.needsUserContext(prompt)) {
30
+ return {
31
+ enhancedPrompt: prompt,
32
+ improvement: {
33
+ dimension: 'completeness',
34
+ description: 'Content does not require user persona',
35
+ impact: 'low',
36
+ },
37
+ applied: false,
38
+ };
39
+ }
40
+ // Add user persona section
41
+ const enhanced = this.addUserPersona(prompt);
42
+ return {
43
+ enhancedPrompt: enhanced,
44
+ improvement: {
45
+ dimension: 'completeness',
46
+ description: 'Added user persona context (who will use this)',
47
+ impact: 'medium',
48
+ },
49
+ applied: true,
50
+ };
51
+ }
52
+ hasUserContext(prompt) {
53
+ const userKeywords = [
54
+ 'user persona',
55
+ 'target user',
56
+ 'end user',
57
+ 'user profile',
58
+ 'audience',
59
+ 'stakeholder',
60
+ 'as a user',
61
+ 'users can',
62
+ 'users will',
63
+ 'for users',
64
+ 'customer',
65
+ 'developer',
66
+ 'admin',
67
+ 'target audience',
68
+ ];
69
+ return this.hasSection(prompt, userKeywords);
70
+ }
71
+ needsUserContext(prompt) {
72
+ // PRD-like content that talks about features but not users
73
+ const featureKeywords = [
74
+ 'feature',
75
+ 'build',
76
+ 'create',
77
+ 'implement',
78
+ 'functionality',
79
+ 'should',
80
+ 'must',
81
+ 'requirement',
82
+ ];
83
+ return this.hasSection(prompt, featureKeywords);
84
+ }
85
+ addUserPersona(prompt) {
86
+ // Detect the likely user type from content
87
+ const userType = this.inferUserType(prompt);
88
+ const personaSection = `\n\n### Target Users\n` +
89
+ `**Primary User:** ${userType}\n` +
90
+ `- Goals: [What they want to achieve]\n` +
91
+ `- Pain Points: [Current frustrations]\n` +
92
+ `- Context: [When and how they'll use this]`;
93
+ return prompt + personaSection;
94
+ }
95
+ inferUserType(prompt) {
96
+ const lowerPrompt = prompt.toLowerCase();
97
+ // Try to infer user type from content
98
+ if (lowerPrompt.includes('api') ||
99
+ lowerPrompt.includes('sdk') ||
100
+ lowerPrompt.includes('library')) {
101
+ return 'Developers integrating with the system';
102
+ }
103
+ if (lowerPrompt.includes('admin') ||
104
+ lowerPrompt.includes('manage') ||
105
+ lowerPrompt.includes('dashboard')) {
106
+ return 'Administrators managing the system';
107
+ }
108
+ if (lowerPrompt.includes('e-commerce') ||
109
+ lowerPrompt.includes('shop') ||
110
+ lowerPrompt.includes('buy')) {
111
+ return 'Customers making purchases';
112
+ }
113
+ if (lowerPrompt.includes('content') ||
114
+ lowerPrompt.includes('blog') ||
115
+ lowerPrompt.includes('cms')) {
116
+ return 'Content creators and editors';
117
+ }
118
+ if (lowerPrompt.includes('mobile') || lowerPrompt.includes('app')) {
119
+ return 'Mobile app users';
120
+ }
121
+ return '[Define primary user type]';
122
+ }
123
+ }
124
+ //# sourceMappingURL=user-persona-enricher.js.map
@@ -11,6 +11,8 @@ export class QualityAssessor {
11
11
  'security-review': ['scope', 'threat-model', 'compliance-requirements', 'known-issues'],
12
12
  learning: ['current-knowledge', 'learning-goal', 'preferred-depth', 'context'],
13
13
  'prd-generation': ['product-vision', 'user-personas', 'features', 'success-metrics'],
14
+ // v4.3.2: Conversational mode intent
15
+ summarization: ['conversation-context', 'key-requirements', 'constraints', 'success-criteria'],
14
16
  };
15
17
  /**
16
18
  * Assess quality of a prompt (backward compatibility wrapper)
@@ -1,7 +1,9 @@
1
- export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning';
1
+ export type PromptIntent = 'code-generation' | 'planning' | 'refinement' | 'debugging' | 'documentation' | 'prd-generation' | 'testing' | 'migration' | 'security-review' | 'learning' | 'summarization';
2
2
  export type QualityDimension = 'clarity' | 'efficiency' | 'structure' | 'completeness' | 'actionability' | 'specificity';
3
3
  export type ImpactLevel = 'low' | 'medium' | 'high';
4
- export type OptimizationMode = 'fast' | 'deep';
4
+ export type OptimizationMode = 'fast' | 'deep' | 'prd' | 'conversational';
5
+ export type OptimizationPhase = 'question-validation' | 'output-generation' | 'conversation-tracking' | 'summarization';
6
+ export type DocumentType = 'full-prd' | 'quick-prd' | 'mini-prd' | 'prompt';
5
7
  export interface IntentAnalysis {
6
8
  primaryIntent: PromptIntent;
7
9
  confidence: number;
@@ -55,6 +57,9 @@ export interface PatternContext {
55
57
  intent: IntentAnalysis;
56
58
  mode: OptimizationMode;
57
59
  originalPrompt: string;
60
+ phase?: OptimizationPhase;
61
+ documentType?: DocumentType;
62
+ questionId?: string;
58
63
  }
59
64
  export interface PatternResult {
60
65
  enhancedPrompt: string;
@@ -1,7 +1,16 @@
1
1
  import { IntentDetector } from './intent-detector.js';
2
2
  import { PatternLibrary } from './pattern-library.js';
3
3
  import { QualityAssessor } from './quality-assessor.js';
4
- import { OptimizationResult, OptimizationMode, EscalationAnalysis } from './types.js';
4
+ import { OptimizationResult, OptimizationMode, OptimizationPhase, DocumentType, EscalationAnalysis } from './types.js';
5
+ /**
6
+ * v4.3.2: Extended context options for PRD and Conversational modes
7
+ */
8
+ export interface OptimizationContextOverride {
9
+ phase?: OptimizationPhase;
10
+ documentType?: DocumentType;
11
+ questionId?: string;
12
+ intent?: string;
13
+ }
5
14
  export declare class UniversalOptimizer {
6
15
  private intentDetector;
7
16
  private patternLibrary;
@@ -9,8 +18,24 @@ export declare class UniversalOptimizer {
9
18
  constructor(intentDetector?: IntentDetector, patternLibrary?: PatternLibrary, qualityAssessor?: QualityAssessor);
10
19
  /**
11
20
  * Optimize a prompt using Clavix Intelligence
21
+ * @param prompt The prompt to optimize
22
+ * @param mode The optimization mode
23
+ * @param contextOverride Optional context override for PRD/Conversational modes
24
+ */
25
+ optimize(prompt: string, mode: OptimizationMode, contextOverride?: OptimizationContextOverride): Promise<OptimizationResult>;
26
+ /**
27
+ * v4.3.2: Validate a PRD answer and provide friendly suggestions
28
+ * Uses adaptive threshold (< 50% quality triggers suggestions)
29
+ */
30
+ validatePRDAnswer(answer: string, questionId: string): Promise<{
31
+ needsClarification: boolean;
32
+ suggestion?: string;
33
+ quality: number;
34
+ }>;
35
+ /**
36
+ * v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
12
37
  */
13
- optimize(prompt: string, mode: OptimizationMode): Promise<OptimizationResult>;
38
+ private generateFriendlySuggestion;
14
39
  /**
15
40
  * Determine if deep mode should be recommended (for fast mode results)
16
41
  * @deprecated Use analyzeEscalation() for more detailed analysis
@@ -12,13 +12,24 @@ export class UniversalOptimizer {
12
12
  }
13
13
  /**
14
14
  * Optimize a prompt using Clavix Intelligence
15
+ * @param prompt The prompt to optimize
16
+ * @param mode The optimization mode
17
+ * @param contextOverride Optional context override for PRD/Conversational modes
15
18
  */
16
- async optimize(prompt, mode) {
19
+ async optimize(prompt, mode, contextOverride) {
17
20
  const startTime = Date.now();
18
- // Step 1: Detect intent
19
- const intent = this.intentDetector.analyze(prompt);
20
- // Step 2: Select applicable patterns
21
- const patterns = this.patternLibrary.selectPatterns(intent, mode);
21
+ // Step 1: Detect intent (or use override)
22
+ let intent = this.intentDetector.analyze(prompt);
23
+ if (contextOverride?.intent) {
24
+ intent = {
25
+ ...intent,
26
+ primaryIntent: contextOverride.intent,
27
+ };
28
+ }
29
+ // Step 2: Select applicable patterns using mode-aware selection
30
+ const patterns = mode === 'prd' || mode === 'conversational'
31
+ ? this.patternLibrary.selectPatternsForMode(mode, intent, contextOverride?.phase)
32
+ : this.patternLibrary.selectPatterns(intent, mode);
22
33
  // Step 3: Apply patterns sequentially
23
34
  let enhanced = prompt;
24
35
  const improvements = [];
@@ -27,6 +38,10 @@ export class UniversalOptimizer {
27
38
  intent,
28
39
  mode,
29
40
  originalPrompt: prompt,
41
+ // v4.3.2: Extended context
42
+ phase: contextOverride?.phase,
43
+ documentType: contextOverride?.documentType,
44
+ questionId: contextOverride?.questionId,
30
45
  };
31
46
  for (const pattern of patterns) {
32
47
  try {
@@ -61,6 +76,51 @@ export class UniversalOptimizer {
61
76
  processingTimeMs,
62
77
  };
63
78
  }
79
+ /**
80
+ * v4.3.2: Validate a PRD answer and provide friendly suggestions
81
+ * Uses adaptive threshold (< 50% quality triggers suggestions)
82
+ */
83
+ async validatePRDAnswer(answer, questionId) {
84
+ const result = await this.optimize(answer, 'prd', {
85
+ phase: 'question-validation',
86
+ questionId,
87
+ intent: 'prd-generation',
88
+ });
89
+ // Adaptive threshold: only suggest improvements for very vague answers
90
+ if (result.quality.overall < 50) {
91
+ return {
92
+ needsClarification: true,
93
+ suggestion: this.generateFriendlySuggestion(result, questionId),
94
+ quality: result.quality.overall,
95
+ };
96
+ }
97
+ return {
98
+ needsClarification: false,
99
+ quality: result.quality.overall,
100
+ };
101
+ }
102
+ /**
103
+ * v4.3.2: Generate a friendly, non-intrusive suggestion for low-quality answers
104
+ */
105
+ generateFriendlySuggestion(result, questionId) {
106
+ const suggestions = {
107
+ q1: ["the problem you're solving", 'why this matters', 'who benefits'],
108
+ q2: ['specific features', 'user actions', 'key functionality'],
109
+ q3: ['technologies', 'frameworks', 'constraints'],
110
+ q4: ["what's explicitly out of scope", 'features to avoid', 'limitations'],
111
+ q5: ['additional context', 'constraints', 'timeline considerations'],
112
+ };
113
+ const questionSuggestions = suggestions[questionId] || suggestions.q5;
114
+ // Pick the most relevant suggestion based on what's missing
115
+ let detail = questionSuggestions[0];
116
+ if (result.quality.completeness < 40) {
117
+ detail = questionSuggestions[Math.min(1, questionSuggestions.length - 1)];
118
+ }
119
+ if (result.quality.specificity < 40) {
120
+ detail = questionSuggestions[Math.min(2, questionSuggestions.length - 1)];
121
+ }
122
+ return `adding ${detail} would help`;
123
+ }
64
124
  /**
65
125
  * Determine if deep mode should be recommended (for fast mode results)
66
126
  * @deprecated Use analyzeEscalation() for more detailed analysis
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This class handles:
5
5
  * - Analyzing PRD documents
6
- * - Generating CLEAR-optimized task breakdowns
6
+ * - Generating optimized task breakdowns
7
7
  * - Reading/writing tasks.md with checkbox format
8
8
  * - Tracking task completion state
9
9
  * - Managing session resume capability
@@ -51,7 +51,6 @@ export interface TaskGenerationResult {
51
51
  * Generates and manages implementation tasks from PRD documents
52
52
  */
53
53
  export declare class TaskManager {
54
- private readonly optimizer;
55
54
  constructor();
56
55
  /**
57
56
  * Generate tasks.md from PRD
@@ -3,14 +3,13 @@
3
3
  *
4
4
  * This class handles:
5
5
  * - Analyzing PRD documents
6
- * - Generating CLEAR-optimized task breakdowns
6
+ * - Generating optimized task breakdowns
7
7
  * - Reading/writing tasks.md with checkbox format
8
8
  * - Tracking task completion state
9
9
  * - Managing session resume capability
10
10
  */
11
11
  import fs from 'fs-extra';
12
12
  import * as path from 'path';
13
- import { PromptOptimizer } from './prompt-optimizer.js';
14
13
  import { FileSystem } from '../utils/file-system.js';
15
14
  const SOURCE_FILE_MAP = {
16
15
  full: ['full-prd.md', 'PRD.md', 'prd.md', 'Full-PRD.md', 'FULL_PRD.md', 'FULL-PRD.md'],
@@ -18,7 +17,12 @@ const SOURCE_FILE_MAP = {
18
17
  mini: ['mini-prd.md'],
19
18
  prompt: ['optimized-prompt.md'],
20
19
  };
21
- const SOURCE_ORDER_AUTO = ['full', 'quick', 'mini', 'prompt'];
20
+ const SOURCE_ORDER_AUTO = [
21
+ 'full',
22
+ 'quick',
23
+ 'mini',
24
+ 'prompt',
25
+ ];
22
26
  const ALL_KNOWN_PRD_FILES = Array.from(new Set(Object.values(SOURCE_FILE_MAP).flat()));
23
27
  /**
24
28
  * TaskManager class
@@ -26,9 +30,8 @@ const ALL_KNOWN_PRD_FILES = Array.from(new Set(Object.values(SOURCE_FILE_MAP).fl
26
30
  * Generates and manages implementation tasks from PRD documents
27
31
  */
28
32
  export class TaskManager {
29
- optimizer;
30
33
  constructor() {
31
- this.optimizer = new PromptOptimizer();
34
+ // TaskManager uses Clavix Intelligence for optimization
32
35
  }
33
36
  /**
34
37
  * Generate tasks.md from PRD
@@ -184,7 +187,7 @@ export class TaskManager {
184
187
  'Configuration & Setup': [],
185
188
  'Core Implementation': [],
186
189
  'Testing & Validation': [],
187
- 'Documentation': [],
190
+ Documentation: [],
188
191
  'Integration & Release': [],
189
192
  };
190
193
  features.forEach((feature) => {
@@ -235,7 +238,9 @@ export class TaskManager {
235
238
  if (topLevelMatch) {
236
239
  const value = topLevelMatch[1].trim();
237
240
  // Skip items that look like code examples, file paths, or implementation details
238
- if (value && !this.looksLikeCodeOrPath(value) && !this.looksLikeImplementationDetail(value)) {
241
+ if (value &&
242
+ !this.looksLikeCodeOrPath(value) &&
243
+ !this.looksLikeImplementationDetail(value)) {
239
244
  items.push(value.replace(/\s+/g, ' ').replace(/\.$/, ''));
240
245
  }
241
246
  }
@@ -311,17 +316,11 @@ export class TaskManager {
311
316
  }
312
317
  // Conversion/migration tasks - Convert + test
313
318
  if (isConversion) {
314
- return [
315
- this.convertBehaviorToTask(feature),
316
- `Test ${formattedFeature} works correctly`,
317
- ];
319
+ return [this.convertBehaviorToTask(feature), `Test ${formattedFeature} works correctly`];
318
320
  }
319
321
  // Default for complex features - Implementation + testing only
320
322
  // (No more "integrate into end-to-end" boilerplate)
321
- return [
322
- this.convertBehaviorToTask(feature),
323
- `Add tests covering ${formattedFeature}`,
324
- ];
323
+ return [this.convertBehaviorToTask(feature), `Add tests covering ${formattedFeature}`];
325
324
  }
326
325
  formatInlineText(text) {
327
326
  if (!text) {
@@ -446,9 +445,7 @@ export class TaskManager {
446
445
  const featureName = featureHeaders[i][2].trim();
447
446
  // Extract content between this header and the next one
448
447
  const startIndex = featureHeaders[i].index;
449
- const endIndex = i < featureHeaders.length - 1
450
- ? featureHeaders[i + 1].index
451
- : featuresContent.length;
448
+ const endIndex = i < featureHeaders.length - 1 ? featureHeaders[i + 1].index : featuresContent.length;
452
449
  const featureContent = featuresContent.substring(startIndex, endIndex);
453
450
  // Extract behavior points using hierarchical parsing
454
451
  const behaviorMatch = featureContent.match(/\*\*Behavior\*\*:([\s\S]*?)(?=\*\*|####|$)/);
@@ -740,9 +737,7 @@ export class TaskManager {
740
737
  const content = await fs.readFile(tasksPath, 'utf-8');
741
738
  // Find the task line and replace [ ] with [x]
742
739
  // We need to find the exact task by description
743
- const targetTask = phases
744
- .flatMap((p) => p.tasks)
745
- .find((t) => t.id === taskId);
740
+ const targetTask = phases.flatMap((p) => p.tasks).find((t) => t.id === taskId);
746
741
  if (!targetTask) {
747
742
  throw new Error(`Task not found: ${taskId}`);
748
743
  }
@@ -769,7 +764,7 @@ export class TaskManager {
769
764
  */
770
765
  validateTaskExists(phases, taskId) {
771
766
  for (const phase of phases) {
772
- const task = phase.tasks.find(t => t.id === taskId);
767
+ const task = phase.tasks.find((t) => t.id === taskId);
773
768
  if (task) {
774
769
  return task;
775
770
  }
@@ -828,7 +823,7 @@ export class TaskManager {
828
823
  const task = this.validateTaskExists(phases, taskId);
829
824
  if (!task) {
830
825
  // Task not found - provide helpful error
831
- const allTaskIds = phases.flatMap(p => p.tasks.map(t => t.id));
826
+ const allTaskIds = phases.flatMap((p) => p.tasks.map((t) => t.id));
832
827
  return {
833
828
  success: false,
834
829
  error: `Task ID "${taskId}" not found. Available task IDs:\n${allTaskIds.join('\n')}`,
@@ -876,7 +871,7 @@ export class TaskManager {
876
871
  }
877
872
  }
878
873
  // Clean up backup on success
879
- if (backupPath && await fs.pathExists(backupPath)) {
874
+ if (backupPath && (await fs.pathExists(backupPath))) {
880
875
  await fs.remove(backupPath);
881
876
  }
882
877
  return {
@@ -886,7 +881,7 @@ export class TaskManager {
886
881
  }
887
882
  catch (error) {
888
883
  // Restore from backup if available
889
- if (backupPath && await fs.pathExists(backupPath)) {
884
+ if (backupPath && (await fs.pathExists(backupPath))) {
890
885
  try {
891
886
  await fs.copyFile(backupPath, tasksPath);
892
887
  warnings.push('Restored tasks.md from backup due to error');
@@ -919,7 +914,7 @@ export class TaskManager {
919
914
  */
920
915
  async findPrdDirectory(projectName) {
921
916
  const baseDir = '.clavix/outputs';
922
- if (!await fs.pathExists(baseDir)) {
917
+ if (!(await fs.pathExists(baseDir))) {
923
918
  throw new Error('No .clavix/outputs directory found. Have you generated a PRD yet?');
924
919
  }
925
920
  // If project name specified, look for it