@tmddev/tmd 0.1.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 (53) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +424 -0
  3. package/bin/tmd.js +3 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.js +92 -0
  6. package/dist/commands/act.d.ts +3 -0
  7. package/dist/commands/act.js +210 -0
  8. package/dist/commands/check.d.ts +3 -0
  9. package/dist/commands/check.js +183 -0
  10. package/dist/commands/do.d.ts +3 -0
  11. package/dist/commands/do.js +310 -0
  12. package/dist/commands/list.d.ts +3 -0
  13. package/dist/commands/list.js +56 -0
  14. package/dist/commands/plan.d.ts +3 -0
  15. package/dist/commands/plan.js +89 -0
  16. package/dist/commands/show.d.ts +2 -0
  17. package/dist/commands/show.js +69 -0
  18. package/dist/commands/skills.d.ts +3 -0
  19. package/dist/commands/skills.js +243 -0
  20. package/dist/types.d.ts +79 -0
  21. package/dist/types.js +5 -0
  22. package/dist/utils/act-processing.d.ts +64 -0
  23. package/dist/utils/act-processing.js +222 -0
  24. package/dist/utils/analysis.d.ts +34 -0
  25. package/dist/utils/analysis.js +159 -0
  26. package/dist/utils/comparison.d.ts +34 -0
  27. package/dist/utils/comparison.js +217 -0
  28. package/dist/utils/language-validator.d.ts +11 -0
  29. package/dist/utils/language-validator.js +39 -0
  30. package/dist/utils/openspec.d.ts +5 -0
  31. package/dist/utils/openspec.js +91 -0
  32. package/dist/utils/paths.d.ts +10 -0
  33. package/dist/utils/paths.js +33 -0
  34. package/dist/utils/skills.d.ts +3 -0
  35. package/dist/utils/skills.js +248 -0
  36. package/dist/utils/skillssh.d.ts +12 -0
  37. package/dist/utils/skillssh.js +135 -0
  38. package/dist/utils/standardization.d.ts +26 -0
  39. package/dist/utils/standardization.js +106 -0
  40. package/dist/utils/task-chain.d.ts +35 -0
  41. package/dist/utils/task-chain.js +146 -0
  42. package/dist/utils/task-id.d.ts +5 -0
  43. package/dist/utils/task-id.js +15 -0
  44. package/dist/utils/task-status.d.ts +6 -0
  45. package/dist/utils/task-status.js +61 -0
  46. package/dist/utils/task-validator.d.ts +42 -0
  47. package/dist/utils/task-validator.js +178 -0
  48. package/dist/utils/tasks.d.ts +27 -0
  49. package/dist/utils/tasks.js +125 -0
  50. package/dist/utils/templates.d.ts +12 -0
  51. package/dist/utils/templates.js +143 -0
  52. package/package.json +84 -0
  53. package/scripts/postinstall.js +92 -0
package/dist/cli.js ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { createRequire } from 'module';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
6
+ import { planCommand } from './commands/plan.js';
7
+ import { doCommand } from './commands/do.js';
8
+ import { checkCommand } from './commands/check.js';
9
+ import { actCommand } from './commands/act.js';
10
+ import { listCommand } from './commands/list.js';
11
+ import { showCommand } from './commands/show.js';
12
+ import { skillsCommand } from './commands/skills.js';
13
+ const program = new Command();
14
+ // Use fileURLToPath to resolve package.json relative to project root
15
+ // When running from bin/tmd.js -> dist/cli.js, we need to go up from dist/ to project root
16
+ const require = createRequire(import.meta.url);
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ // dist/cli.js -> dist/ -> project root
19
+ const projectRoot = dirname(dirname(__filename));
20
+ const packageJsonPath = join(projectRoot, 'package.json');
21
+ const pkg = require(packageJsonPath);
22
+ const { version } = pkg;
23
+ program
24
+ .name('tmd')
25
+ .description('Task Markdown Driven - PDCA cycle management framework')
26
+ .version(version);
27
+ // PDCA commands
28
+ program
29
+ .command('plan')
30
+ .alias('p')
31
+ .description('Plan phase: Define objectives, analyze problems, and create plans')
32
+ .argument('<description>', 'Task description')
33
+ .option('--openspec', 'Create or link OpenSpec change proposal')
34
+ .option('--skill', 'Create skill definition')
35
+ .option('--use-skill <skill-name>', 'Use existing skill')
36
+ .option('--validate-tasks', 'Validate task size: pee-break (10 seconds to 10 minutes)')
37
+ .action(planCommand);
38
+ program
39
+ .command('do')
40
+ .alias('d')
41
+ .description('Do phase: Execute actions and collect data')
42
+ .argument('<task-id>', 'Task ID')
43
+ .option('--data <key=value>', 'Record data')
44
+ .option('--skill <skill-name>', 'Execute skill')
45
+ .option('--list', 'Show task status without modifying')
46
+ .option('--task <index>', 'Mark task at index as complete', (value) => parseInt(value, 10))
47
+ .option('--parallel', 'Enable concurrent execution of independent tasks')
48
+ .option('--max-concurrency <n>', 'Maximum number of concurrent operations', (value) => parseInt(value, 10))
49
+ .action(doCommand);
50
+ program
51
+ .command('check')
52
+ .alias('c')
53
+ .description('Check phase: Evaluate results and analyze deviations')
54
+ .argument('<task-id>', 'Task ID')
55
+ .option('--compare', 'Automatic comparison (default behavior)')
56
+ .option('--analyze', 'Perform root cause analysis')
57
+ .option('--recommend', 'Generate adjustment recommendations')
58
+ .option('--manual', 'Manual mode (disable automatic comparison)')
59
+ .option('--validate-skill', 'Validate skill execution')
60
+ .action(checkCommand);
61
+ program
62
+ .command('act')
63
+ .alias('a')
64
+ .description('Act phase: Take improvement actions and standardize')
65
+ .argument('<task-id>', 'Task ID')
66
+ .option('--standardize', 'Automatically identify and document successful practices')
67
+ .option('--carry-forward', 'Generate next cycle planning items for unresolved issues')
68
+ .option('--manual', 'Manual mode (disable automatic processing)')
69
+ .option('--complete', 'Mark task as completed')
70
+ .action(actCommand);
71
+ // Task management commands
72
+ program
73
+ .command('list')
74
+ .description('List all tasks')
75
+ .option('--status <status>', 'Filter by status')
76
+ .option('--phase <phase>', 'Filter by phase')
77
+ .action(listCommand);
78
+ program
79
+ .command('show')
80
+ .description('Show task details')
81
+ .argument('<task-id>', 'Task ID')
82
+ .action(showCommand);
83
+ // Skills commands
84
+ program
85
+ .command('skills')
86
+ .description('Manage skills')
87
+ .argument('[action]', 'Action: list, search, show, invoke')
88
+ .argument('[name]', 'Skill name or search query')
89
+ .option('--input <params>', 'Input parameters for invoke')
90
+ .action(skillsCommand);
91
+ program.parse();
92
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,3 @@
1
+ import type { ActCommandOptions } from '../types.js';
2
+ export declare function actCommand(taskId: string, options: ActCommandOptions): void;
3
+ //# sourceMappingURL=act.d.ts.map
@@ -0,0 +1,210 @@
1
+ import { existsSync } from 'fs';
2
+ import { ensureDir, getActDir, getCheckDir } from '../utils/paths.js';
3
+ import { improvementTemplate, standardizationTemplate, renderTemplate } from '../utils/templates.js';
4
+ import { updateTaskStatus } from '../utils/task-status.js';
5
+ import { parseEvaluationResults, parseDeviationAnalysis, identifySuccesses, identifyFailures, identifyUnresolvedIssues } from '../utils/act-processing.js';
6
+ import { extractSuccessfulPractices, generateStandardizationRecommendations, formatStandardizationDocument } from '../utils/standardization.js';
7
+ import { writeFileSync } from 'fs';
8
+ import { join } from 'path';
9
+ import chalk from 'chalk';
10
+ function generateImprovementDocument(failures, taskId) {
11
+ let content = renderTemplate(improvementTemplate, { taskId });
12
+ // Add corrective actions
13
+ const criticalFailures = failures.filter(f => f.severity === 'critical');
14
+ const majorFailures = failures.filter(f => f.severity === 'major');
15
+ const minorFailures = failures.filter(f => f.severity === 'minor');
16
+ if (failures.length > 0) {
17
+ content += '\n## Corrective Actions\n\n';
18
+ if (criticalFailures.length > 0) {
19
+ content += '### Immediate Actions (Critical)\n\n';
20
+ for (const failure of criticalFailures) {
21
+ content += `- **${failure.goal}**: ${failure.lesson ?? failure.deviation}\n`;
22
+ if (failure.rootCause) {
23
+ content += ` - Root cause: ${failure.rootCause}\n`;
24
+ }
25
+ content += '\n';
26
+ }
27
+ }
28
+ if (majorFailures.length > 0) {
29
+ content += '### Short-term Fixes (Major)\n\n';
30
+ for (const failure of majorFailures) {
31
+ content += `- **${failure.goal}**: ${failure.lesson ?? failure.deviation}\n`;
32
+ if (failure.rootCause) {
33
+ content += ` - Root cause: ${failure.rootCause}\n`;
34
+ }
35
+ content += '\n';
36
+ }
37
+ }
38
+ if (minorFailures.length > 0) {
39
+ content += '### Long-term Improvements (Minor)\n\n';
40
+ for (const failure of minorFailures) {
41
+ content += `- **${failure.goal}**: ${failure.lesson ?? failure.deviation}\n\n`;
42
+ }
43
+ }
44
+ }
45
+ // Add preventive measures
46
+ const rootCauses = new Set(failures.map(f => f.rootCause).filter(Boolean));
47
+ if (rootCauses.size > 0) {
48
+ content += '\n## Preventive Measures\n\n';
49
+ content += 'Based on root cause analysis, the following preventive measures are recommended:\n\n';
50
+ for (const rootCause of rootCauses) {
51
+ if (rootCause) {
52
+ content += `### ${rootCause}\n\n`;
53
+ content += '- Implement process improvements to prevent similar failures\n';
54
+ content += '- Establish early warning indicators\n';
55
+ content += '- Add process controls to maintain quality\n';
56
+ content += '- Consider training or knowledge sharing\n\n';
57
+ }
58
+ }
59
+ }
60
+ // Add lessons learned
61
+ if (failures.length > 0) {
62
+ content += '\n## Lessons Learned\n\n';
63
+ content += `### Summary of Failures\n\n`;
64
+ content += `Total failures encountered: ${String(failures.length)}\n`;
65
+ content += `- Critical: ${String(criticalFailures.length)}\n`;
66
+ content += `- Major: ${String(majorFailures.length)}\n`;
67
+ content += `- Minor: ${String(minorFailures.length)}\n\n`;
68
+ content += `### Failure Patterns\n\n`;
69
+ const byType = {};
70
+ for (const failure of failures) {
71
+ const type = failure.deviation.split(':')[0] ?? 'unknown';
72
+ byType[type] = (byType[type] ?? 0) + 1;
73
+ }
74
+ for (const [type, count] of Object.entries(byType)) {
75
+ content += `- ${type}: ${String(count)} occurrence(s)\n`;
76
+ }
77
+ content += '\n';
78
+ content += `### Key Lessons\n\n`;
79
+ for (const failure of failures) {
80
+ if (failure.lesson) {
81
+ content += `- ${failure.lesson}\n`;
82
+ }
83
+ }
84
+ content += '\n';
85
+ }
86
+ return content;
87
+ }
88
+ function generateNextCycleItems(unresolvedIssues, taskId) {
89
+ let content = `# Next Cycle Planning Items\n\n`;
90
+ content += `Items identified from task ${taskId} that need to be addressed in the next PDCA cycle.\n\n`;
91
+ if (unresolvedIssues.length === 0) {
92
+ content += 'No unresolved issues identified. All goals were achieved or can be addressed in current cycle.\n';
93
+ return content;
94
+ }
95
+ content += `## Unresolved Issues\n\n`;
96
+ content += `Total unresolved issues: ${String(unresolvedIssues.length)}\n\n`;
97
+ // Group by priority
98
+ const byPriority = {
99
+ high: unresolvedIssues.filter(i => i.priority === 'high'),
100
+ medium: unresolvedIssues.filter(i => i.priority === 'medium'),
101
+ low: unresolvedIssues.filter(i => i.priority === 'low')
102
+ };
103
+ for (const priority of ['high', 'medium', 'low']) {
104
+ if (byPriority[priority].length > 0) {
105
+ const priorityLabel = priority.charAt(0).toUpperCase() + priority.slice(1);
106
+ const emoji = priority === 'high' ? '🔴' : priority === 'medium' ? '🟡' : '🟢';
107
+ content += `### ${emoji} ${priorityLabel} Priority\n\n`;
108
+ for (const issue of byPriority[priority]) {
109
+ content += `#### ${issue.goal}\n\n`;
110
+ content += `**Description**: ${issue.description}\n\n`;
111
+ content += `**Reason**: ${issue.reason}\n\n`;
112
+ if (issue.linkToDeviation) {
113
+ content += `**Related Deviation**: ${issue.linkToDeviation}\n\n`;
114
+ }
115
+ content += `**Next Cycle Action**: Create new plan to address: ${issue.goal}\n\n`;
116
+ }
117
+ }
118
+ }
119
+ content += `## Planning Items for Next Cycle\n\n`;
120
+ content += `Use these items when creating the next PDCA cycle plan:\n\n`;
121
+ for (const issue of unresolvedIssues) {
122
+ content += `- [ ] ${issue.description} (Priority: ${issue.priority})\n`;
123
+ }
124
+ return content;
125
+ }
126
+ export function actCommand(taskId, options) {
127
+ // Validate check exists
128
+ const evaluationPath = join(getCheckDir(taskId), 'evaluation.md');
129
+ const deviationPath = join(getCheckDir(taskId), 'deviation.md');
130
+ if (!existsSync(evaluationPath)) {
131
+ console.error(chalk.red(`✗ Check results not found for task: ${taskId}`));
132
+ console.error(chalk.yellow(` Run 'tmd check ${taskId}' first to generate evaluation results.`));
133
+ process.exit(1);
134
+ }
135
+ const actDir = getActDir(taskId);
136
+ ensureDir(actDir);
137
+ // Determine if automatic processing should run (default unless --manual)
138
+ const shouldProcess = !options.manual;
139
+ let improvementContent = renderTemplate(improvementTemplate, { taskId });
140
+ let standardizationContent = '';
141
+ let nextCycleContent = '';
142
+ let successes = [];
143
+ let failures = [];
144
+ let unresolvedIssues = [];
145
+ // Automatic processing
146
+ if (shouldProcess) {
147
+ // Parse check results
148
+ const evaluationResults = parseEvaluationResults(evaluationPath);
149
+ const deviationAnalysis = existsSync(deviationPath)
150
+ ? parseDeviationAnalysis(deviationPath)
151
+ : { deviations: [], rootCauses: [] };
152
+ // Identify successes and failures
153
+ successes = identifySuccesses(evaluationResults);
154
+ failures = identifyFailures(deviationAnalysis, evaluationResults);
155
+ unresolvedIssues = identifyUnresolvedIssues(evaluationResults, deviationAnalysis);
156
+ // Generate improvement document with processed results
157
+ improvementContent = generateImprovementDocument(failures, taskId);
158
+ // Generate standardization if requested or if successes found
159
+ if (options.standardize || successes.length > 0) {
160
+ const practices = extractSuccessfulPractices(successes);
161
+ const recommendations = generateStandardizationRecommendations(practices);
162
+ standardizationContent = formatStandardizationDocument(practices, recommendations);
163
+ }
164
+ else {
165
+ standardizationContent = renderTemplate(standardizationTemplate, { taskId });
166
+ }
167
+ // Generate next cycle items if requested or if unresolved issues found
168
+ if (options.carryForward || unresolvedIssues.length > 0) {
169
+ nextCycleContent = generateNextCycleItems(unresolvedIssues, taskId);
170
+ }
171
+ // Display summary
172
+ console.log(chalk.blue('\n Processing Summary:'));
173
+ console.log(chalk.green(` Successful practices identified: ${String(successes.length)}`));
174
+ console.log(chalk.red(` Failures and lessons learned: ${String(failures.length)}`));
175
+ if (unresolvedIssues.length > 0) {
176
+ console.log(chalk.yellow(` Unresolved issues for next cycle: ${String(unresolvedIssues.length)}`));
177
+ }
178
+ if (options.standardize && successes.length > 0) {
179
+ console.log(chalk.blue(` Standardization recommendations: ${String(successes.length)}`));
180
+ }
181
+ }
182
+ else {
183
+ // Manual mode - just create templates
184
+ standardizationContent = renderTemplate(standardizationTemplate, { taskId });
185
+ }
186
+ // Write documents
187
+ writeFileSync(join(actDir, 'improvement.md'), improvementContent);
188
+ if (options.standardize || (shouldProcess && successes.length > 0)) {
189
+ writeFileSync(join(actDir, 'standardization.md'), standardizationContent);
190
+ }
191
+ if (options.carryForward || (shouldProcess && unresolvedIssues.length > 0)) {
192
+ writeFileSync(join(actDir, 'next-cycle-items.md'), nextCycleContent);
193
+ }
194
+ // Update task status
195
+ updateTaskStatus(taskId, 'acting');
196
+ console.log(chalk.green(`\n✓ Started act phase for task: ${taskId}`));
197
+ console.log(chalk.blue(` Directory: ${actDir}`));
198
+ console.log(chalk.blue(` Improvement: ${join(actDir, 'improvement.md')}`));
199
+ if (existsSync(join(actDir, 'standardization.md'))) {
200
+ console.log(chalk.blue(` Standardization: ${join(actDir, 'standardization.md')}`));
201
+ }
202
+ if (existsSync(join(actDir, 'next-cycle-items.md'))) {
203
+ console.log(chalk.blue(` Next Cycle Items: ${join(actDir, 'next-cycle-items.md')}`));
204
+ }
205
+ if (options.complete) {
206
+ updateTaskStatus(taskId, 'completed');
207
+ console.log(chalk.green(` Task marked as completed`));
208
+ }
209
+ }
210
+ //# sourceMappingURL=act.js.map
@@ -0,0 +1,3 @@
1
+ import type { CheckCommandOptions } from '../types.js';
2
+ export declare function checkCommand(taskId: string, options: CheckCommandOptions): void;
3
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1,183 @@
1
+ import { existsSync } from 'fs';
2
+ import { ensureDir, getCheckDir, getPlanDir, getDoDir } from '../utils/paths.js';
3
+ import { evaluationTemplate, renderTemplate } from '../utils/templates.js';
4
+ import { updateTaskStatus } from '../utils/task-status.js';
5
+ import { extractGoals, extractResults, compareGoalsAndResults } from '../utils/comparison.js';
6
+ import { identifyDeviations, analyzeRootCauses, recommendAdjustments } from '../utils/analysis.js';
7
+ import { writeFileSync } from 'fs';
8
+ import { join } from 'path';
9
+ import chalk from 'chalk';
10
+ function generateComparisonTable(comparisons) {
11
+ let table = '\n## Comparison with Plan\n\n';
12
+ table += '| Goal | Planned Value | Actual Value | Status | Deviation |\n';
13
+ table += '|------|---------------|--------------|--------|-----------|\n';
14
+ for (const comp of comparisons) {
15
+ const goal = comp.goal.description.substring(0, 50) + (comp.goal.description.length > 50 ? '...' : '');
16
+ const planned = comp.goal.targetValue !== undefined ? String(comp.goal.targetValue) : 'N/A';
17
+ const actual = comp.result?.value !== undefined ? String(comp.result.value) : (comp.result?.description?.substring(0, 30) ?? 'No data');
18
+ const status = comp.status === 'met' ? '✅ Met' :
19
+ comp.status === 'unmet' ? '❌ Unmet' :
20
+ comp.status === 'over-achieved' ? '📈 Over-achieved' :
21
+ comp.status === 'partial' ? '⚠️ Partial' : '❓ No Data';
22
+ const deviation = comp.deviation !== undefined ?
23
+ `${comp.deviation > 0 ? '+' : ''}${comp.deviation.toFixed(2)}${comp.deviationPercent !== undefined ? ` (${comp.deviationPercent > 0 ? '+' : ''}${comp.deviationPercent.toFixed(1)}%)` : ''}` :
24
+ 'N/A';
25
+ table += `| ${goal} | ${planned} | ${actual} | ${status} | ${deviation} |\n`;
26
+ }
27
+ return table;
28
+ }
29
+ function generateDeviationAnalysis(deviations) {
30
+ if (deviations.length === 0) {
31
+ return '\n## Deviations Identified\n\nNo deviations found. All goals were met.\n';
32
+ }
33
+ let analysis = '\n## Deviations Identified\n\n';
34
+ for (const deviation of deviations) {
35
+ analysis += `### ${deviation.description}\n\n`;
36
+ analysis += `- **Type**: ${deviation.type}\n`;
37
+ analysis += `- **Severity**: ${deviation.severity}\n`;
38
+ analysis += `- **Status**: ${deviation.comparison.status}\n`;
39
+ if (deviation.comparison.deviation !== undefined) {
40
+ analysis += `- **Deviation**: ${String(deviation.comparison.deviation)}\n`;
41
+ }
42
+ analysis += '\n';
43
+ }
44
+ return analysis;
45
+ }
46
+ function generateRootCauseAnalysis(rootCauses) {
47
+ if (rootCauses.length === 0) {
48
+ return '\n## Root Cause Analysis\n\nNo clear root causes identified.\n';
49
+ }
50
+ let analysis = '\n## Root Cause Analysis\n\n';
51
+ for (const cause of rootCauses) {
52
+ analysis += `### ${cause.category.charAt(0).toUpperCase() + cause.category.slice(1)} Issues\n\n`;
53
+ analysis += `${cause.description}\n\n`;
54
+ analysis += `**Confidence**: ${cause.confidence}\n\n`;
55
+ if (cause.evidence.length > 0) {
56
+ analysis += `**Evidence**:\n`;
57
+ for (const evidence of cause.evidence) {
58
+ analysis += `- ${evidence}\n`;
59
+ }
60
+ analysis += '\n';
61
+ }
62
+ }
63
+ return analysis;
64
+ }
65
+ function generateRecommendations(recommendations) {
66
+ if (recommendations.length === 0) {
67
+ return '\n## Recommendations\n\nNo specific recommendations at this time.\n';
68
+ }
69
+ let recs = '\n## Recommendations\n\n';
70
+ const byPriority = {
71
+ high: recommendations.filter(r => r.priority === 'high'),
72
+ medium: recommendations.filter(r => r.priority === 'medium'),
73
+ low: recommendations.filter(r => r.priority === 'low')
74
+ };
75
+ for (const priority of ['high', 'medium', 'low']) {
76
+ if (byPriority[priority].length > 0) {
77
+ recs += `### ${priority.charAt(0).toUpperCase() + priority.slice(1)} Priority\n\n`;
78
+ for (const rec of byPriority[priority]) {
79
+ recs += `- **${rec.action}** (${rec.category})\n`;
80
+ recs += ` ${rec.description}\n\n`;
81
+ }
82
+ }
83
+ }
84
+ return recs;
85
+ }
86
+ export function checkCommand(taskId, options) {
87
+ // Validate plan and execution exist
88
+ const planPath = join(getPlanDir(taskId), 'plan.md');
89
+ const executionPath = join(getDoDir(taskId), 'execution.md');
90
+ const dataPath = join(getDoDir(taskId), 'data.md');
91
+ if (!existsSync(planPath)) {
92
+ console.error(chalk.red(`✗ Plan not found for task: ${taskId}`));
93
+ process.exit(1);
94
+ }
95
+ if (!existsSync(executionPath)) {
96
+ console.error(chalk.red(`✗ Execution not found for task: ${taskId}`));
97
+ process.exit(1);
98
+ }
99
+ const checkDir = getCheckDir(taskId);
100
+ ensureDir(checkDir);
101
+ // Determine if automatic comparison should run (default unless --manual)
102
+ const shouldCompare = !options.manual;
103
+ let evaluationContent = renderTemplate(evaluationTemplate, { taskId });
104
+ let deviationContent = '# Deviation Analysis\n\n';
105
+ // Automatic comparison and analysis
106
+ if (shouldCompare) {
107
+ // Extract goals and results
108
+ const goals = extractGoals(planPath);
109
+ const results = extractResults(executionPath, dataPath);
110
+ if (goals.length === 0) {
111
+ console.log(chalk.yellow(' ⚠ No goals found in plan.md. Add goals to enable automatic comparison.'));
112
+ }
113
+ else {
114
+ // Perform comparison
115
+ const comparisons = compareGoalsAndResults(goals, results);
116
+ // Generate comparison table
117
+ evaluationContent += generateComparisonTable(comparisons);
118
+ // Calculate summary statistics
119
+ const totalGoals = comparisons.length;
120
+ const metGoals = comparisons.filter(c => c.status === 'met').length;
121
+ const unmetGoals = comparisons.filter(c => c.status === 'unmet').length;
122
+ const successRate = totalGoals > 0 ? Math.round((metGoals / totalGoals) * 100) : 0;
123
+ // Display summary
124
+ console.log(chalk.blue('\n Comparison Summary:'));
125
+ console.log(chalk.gray(` Total goals: ${String(totalGoals)}`));
126
+ console.log(chalk.green(` Goals met: ${String(metGoals)}`));
127
+ if (unmetGoals > 0) {
128
+ console.log(chalk.red(` Goals unmet: ${String(unmetGoals)}`));
129
+ }
130
+ console.log(chalk.blue(` Success rate: ${String(successRate)}%`));
131
+ // Identify deviations
132
+ const deviations = identifyDeviations(comparisons);
133
+ const criticalDeviations = deviations.filter(d => d.severity === 'critical').length;
134
+ if (criticalDeviations > 0) {
135
+ console.log(chalk.red(` Critical deviations: ${String(criticalDeviations)}`));
136
+ }
137
+ // Generate deviation analysis
138
+ deviationContent += generateDeviationAnalysis(deviations);
139
+ // Root cause analysis
140
+ if (options.analyze && deviations.length > 0) {
141
+ const rootCauses = analyzeRootCauses(deviations);
142
+ deviationContent += generateRootCauseAnalysis(rootCauses);
143
+ console.log(chalk.blue(`\n Root Cause Analysis:`));
144
+ for (const cause of rootCauses) {
145
+ console.log(chalk.gray(` ${cause.category}: ${cause.description}`));
146
+ }
147
+ }
148
+ // Recommendations
149
+ if (options.recommend && deviations.length > 0) {
150
+ const rootCauses = options.analyze ? analyzeRootCauses(deviations) : [];
151
+ const recommendations = recommendAdjustments(deviations, rootCauses);
152
+ evaluationContent += generateRecommendations(recommendations);
153
+ console.log(chalk.blue(`\n Recommendations:`));
154
+ for (const rec of recommendations.filter(r => r.priority === 'high')) {
155
+ console.log(chalk.yellow(` [${rec.priority.toUpperCase()}] ${rec.action}`));
156
+ }
157
+ }
158
+ // Add summary to evaluation
159
+ evaluationContent += `\n## Results Summary\n\n`;
160
+ evaluationContent += `- Total goals: ${String(totalGoals)}\n`;
161
+ evaluationContent += `- Goals met: ${String(metGoals)}\n`;
162
+ evaluationContent += `- Goals unmet: ${String(unmetGoals)}\n`;
163
+ evaluationContent += `- Success rate: ${String(successRate)}%\n`;
164
+ if (criticalDeviations > 0) {
165
+ evaluationContent += `- Critical deviations: ${String(criticalDeviations)}\n`;
166
+ }
167
+ }
168
+ }
169
+ writeFileSync(join(checkDir, 'evaluation.md'), evaluationContent);
170
+ writeFileSync(join(checkDir, 'deviation.md'), deviationContent);
171
+ // Update task status
172
+ updateTaskStatus(taskId, 'checking');
173
+ console.log(chalk.green(`\n✓ Started check phase for task: ${taskId}`));
174
+ console.log(chalk.blue(` Directory: ${checkDir}`));
175
+ console.log(chalk.blue(` Evaluation: ${join(checkDir, 'evaluation.md')}`));
176
+ console.log(chalk.blue(` Deviation Analysis: ${join(checkDir, 'deviation.md')}`));
177
+ // Skill validation
178
+ if (options.validateSkill) {
179
+ console.log(chalk.yellow(' Skill validation: Basic validation implemented'));
180
+ // TODO: Full skill validation
181
+ }
182
+ }
183
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1,3 @@
1
+ import type { DoCommandOptions } from '../types.js';
2
+ export declare function doCommand(taskId: string, options: DoCommandOptions): Promise<void>;
3
+ //# sourceMappingURL=do.d.ts.map