specweave 0.26.2 → 0.26.3

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 (101) hide show
  1. package/dist/src/config/types.d.ts +1208 -203
  2. package/dist/src/config/types.d.ts.map +1 -1
  3. package/dist/src/init/architecture/types.d.ts +140 -33
  4. package/dist/src/init/architecture/types.d.ts.map +1 -1
  5. package/dist/src/init/compliance/types.d.ts +27 -30
  6. package/dist/src/init/compliance/types.d.ts.map +1 -1
  7. package/dist/src/init/repo/types.d.ts +34 -11
  8. package/dist/src/init/repo/types.d.ts.map +1 -1
  9. package/dist/src/init/research/src/config/types.d.ts +82 -15
  10. package/dist/src/init/research/src/config/types.d.ts.map +1 -1
  11. package/dist/src/init/research/types.d.ts +93 -38
  12. package/dist/src/init/research/types.d.ts.map +1 -1
  13. package/dist/src/init/team/types.d.ts +42 -4
  14. package/dist/src/init/team/types.d.ts.map +1 -1
  15. package/package.json +1 -1
  16. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  17. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  18. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  19. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  20. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  21. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  22. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  23. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  24. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  25. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  26. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  27. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  28. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  29. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  30. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  31. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  32. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  33. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  34. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  35. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  36. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  37. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  38. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  39. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  40. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  41. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  42. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  43. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  44. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  45. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  46. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  47. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  48. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  49. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  50. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  51. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  52. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  53. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  54. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  55. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  56. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  57. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  58. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  59. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  60. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  61. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  62. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  63. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  64. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  65. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  66. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  67. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  68. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  69. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  70. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  71. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  72. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  73. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  74. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  75. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  76. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  77. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  78. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  79. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  80. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  81. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  82. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  83. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  84. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  85. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  86. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  87. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  88. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  89. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  90. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  91. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  92. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  93. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  94. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  95. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  96. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  97. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -904
  98. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  99. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  100. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -738
  101. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
@@ -1,231 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import { IssueSeverity } from "./types/reflection-types";
4
- function generateReflectionMarkdown(result) {
5
- const sections = [];
6
- sections.push(`# Self-Reflection: ${result.taskName}`);
7
- sections.push("");
8
- sections.push(`**Completed**: ${result.completed}`);
9
- if (result.duration) {
10
- sections.push(`**Duration**: ${result.duration}`);
11
- }
12
- sections.push(`**Files Modified**: ${result.filesModified.count} files, +${result.filesModified.linesAdded} -${result.filesModified.linesRemoved}`);
13
- sections.push("");
14
- sections.push("---");
15
- sections.push("");
16
- sections.push("## \u2705 What Was Accomplished");
17
- sections.push("");
18
- if (result.accomplishments.length > 0) {
19
- for (const accomplishment of result.accomplishments) {
20
- sections.push(`- ${accomplishment}`);
21
- }
22
- } else {
23
- sections.push("(No accomplishments recorded)");
24
- }
25
- sections.push("");
26
- sections.push("---");
27
- sections.push("");
28
- sections.push("## \u{1F3AF} Quality Assessment");
29
- sections.push("");
30
- sections.push("### \u2705 Strengths");
31
- sections.push("");
32
- if (result.strengths.length > 0) {
33
- for (const strength of result.strengths) {
34
- sections.push(`- \u2705 ${strength}`);
35
- }
36
- } else {
37
- sections.push("(No strengths recorded)");
38
- }
39
- sections.push("");
40
- sections.push("### \u26A0\uFE0F Issues Identified");
41
- sections.push("");
42
- if (result.issues.length === 0) {
43
- sections.push("\u2705 No critical issues detected. Code follows best practices.");
44
- } else {
45
- const criticalIssues = result.issues.filter((i) => i.severity === IssueSeverity.CRITICAL);
46
- const highIssues = result.issues.filter((i) => i.severity === IssueSeverity.HIGH);
47
- const mediumIssues = result.issues.filter((i) => i.severity === IssueSeverity.MEDIUM);
48
- const lowIssues = result.issues.filter((i) => i.severity === IssueSeverity.LOW);
49
- const issueGroups = [
50
- { issues: criticalIssues, severity: IssueSeverity.CRITICAL },
51
- { issues: highIssues, severity: IssueSeverity.HIGH },
52
- { issues: mediumIssues, severity: IssueSeverity.MEDIUM },
53
- { issues: lowIssues, severity: IssueSeverity.LOW }
54
- ];
55
- for (const group of issueGroups) {
56
- if (group.issues.length === 0) continue;
57
- for (const issue of group.issues) {
58
- sections.push(`**${issue.severity} (${issue.category})**`);
59
- sections.push(`- \u274C ${issue.description}`);
60
- sections.push(` - **Impact**: ${issue.impact}`);
61
- sections.push(` - **Recommendation**: ${issue.recommendation}`);
62
- if (issue.location) {
63
- const locationStr = issue.location.line ? `${issue.location.file}:${issue.location.line}` : issue.location.file;
64
- sections.push(` - **Location**: \`${locationStr}\``);
65
- if (issue.location.snippet) {
66
- sections.push(" - **Code Snippet**:");
67
- sections.push(" ```");
68
- sections.push(` ${issue.location.snippet}`);
69
- sections.push(" ```");
70
- }
71
- }
72
- sections.push("");
73
- }
74
- }
75
- }
76
- sections.push("---");
77
- sections.push("");
78
- sections.push("## \u{1F527} Recommended Follow-Up Actions");
79
- sections.push("");
80
- const hasActions = result.recommendedActions.priority1.length > 0 || result.recommendedActions.priority2.length > 0 || result.recommendedActions.priority3.length > 0;
81
- if (!hasActions) {
82
- sections.push("\u2705 No follow-up actions required. Ready to proceed.");
83
- } else {
84
- if (result.recommendedActions.priority1.length > 0) {
85
- sections.push("**Priority 1 (MUST FIX - before closing increment)**:");
86
- for (let i = 0; i < result.recommendedActions.priority1.length; i++) {
87
- sections.push(`${i + 1}. ${result.recommendedActions.priority1[i]}`);
88
- }
89
- sections.push("");
90
- }
91
- if (result.recommendedActions.priority2.length > 0) {
92
- sections.push("**Priority 2 (SHOULD FIX - this increment)**:");
93
- for (let i = 0; i < result.recommendedActions.priority2.length; i++) {
94
- sections.push(`${i + 1}. ${result.recommendedActions.priority2[i]}`);
95
- }
96
- sections.push("");
97
- }
98
- if (result.recommendedActions.priority3.length > 0) {
99
- sections.push("**Priority 3 (NICE TO HAVE - future increment)**:");
100
- for (let i = 0; i < result.recommendedActions.priority3.length; i++) {
101
- sections.push(`${i + 1}. ${result.recommendedActions.priority3[i]}`);
102
- }
103
- sections.push("");
104
- }
105
- }
106
- sections.push("---");
107
- sections.push("");
108
- const hasLessons = result.lessonsLearned.whatWentWell.length > 0 || result.lessonsLearned.whatCouldImprove.length > 0 || result.lessonsLearned.forNextTime.length > 0;
109
- if (hasLessons) {
110
- sections.push("## \u{1F4DA} Lessons Learned");
111
- sections.push("");
112
- if (result.lessonsLearned.whatWentWell.length > 0) {
113
- sections.push("**What went well**:");
114
- for (const lesson of result.lessonsLearned.whatWentWell) {
115
- sections.push(`- ${lesson}`);
116
- }
117
- sections.push("");
118
- }
119
- if (result.lessonsLearned.whatCouldImprove.length > 0) {
120
- sections.push("**What could improve**:");
121
- for (const lesson of result.lessonsLearned.whatCouldImprove) {
122
- sections.push(`- ${lesson}`);
123
- }
124
- sections.push("");
125
- }
126
- if (result.lessonsLearned.forNextTime.length > 0) {
127
- sections.push("**For next time**:");
128
- for (const lesson of result.lessonsLearned.forNextTime) {
129
- sections.push(`- ${lesson}`);
130
- }
131
- sections.push("");
132
- }
133
- sections.push("---");
134
- sections.push("");
135
- }
136
- sections.push("## \u{1F4CA} Metrics");
137
- sections.push("");
138
- sections.push(`- **Code Quality**: ${result.metrics.codeQuality}/10`);
139
- sections.push(`- **Security**: ${result.metrics.security}/10`);
140
- if (result.metrics.testCoverage !== void 0) {
141
- sections.push(`- **Test Coverage**: ${result.metrics.testCoverage}%`);
142
- } else {
143
- sections.push(`- **Test Coverage**: N/A`);
144
- }
145
- sections.push(`- **Technical Debt**: ${result.metrics.technicalDebt}`);
146
- sections.push(`- **Performance**: ${result.metrics.performance.replace(/_/g, " ")}`);
147
- sections.push("");
148
- if (result.relatedTasks && result.relatedTasks.length > 0) {
149
- sections.push("---");
150
- sections.push("");
151
- sections.push("## \u{1F517} Related Tasks");
152
- sections.push("");
153
- for (const task of result.relatedTasks) {
154
- sections.push(`- ${task}`);
155
- }
156
- sections.push("");
157
- }
158
- sections.push("---");
159
- sections.push("");
160
- sections.push("**Auto-generated by**: SpecWeave Self-Reflection System");
161
- sections.push(`**Model**: Claude 3.5 ${result.metadata.model.charAt(0).toUpperCase() + result.metadata.model.slice(1)}`);
162
- sections.push(`**Reflection Time**: ${result.metadata.reflectionTime} seconds`);
163
- sections.push(`**Estimated Cost**: ~$${result.metadata.estimatedCost.toFixed(3)}`);
164
- sections.push("");
165
- return sections.join("\n");
166
- }
167
- function getReflectionLogDir(incrementId, projectRoot) {
168
- const rootDir = projectRoot || process.cwd();
169
- return path.join(
170
- rootDir,
171
- ".specweave",
172
- "increments",
173
- incrementId,
174
- "logs",
175
- "reflections"
176
- );
177
- }
178
- function getReflectionFilename(taskId, timestamp) {
179
- const date = timestamp || /* @__PURE__ */ new Date();
180
- const dateStr = date.toISOString().split("T")[0];
181
- const sanitizedTaskId = taskId.replace(/[^a-zA-Z0-9-]/g, "-");
182
- return `task-${sanitizedTaskId}-reflection-${dateStr}.md`;
183
- }
184
- function saveReflection(result, incrementId, taskId, projectRoot) {
185
- const logDir = getReflectionLogDir(incrementId, projectRoot);
186
- fs.mkdirpSync(logDir);
187
- const filename = getReflectionFilename(taskId);
188
- const filepath = path.join(logDir, filename);
189
- const markdown = generateReflectionMarkdown(result);
190
- try {
191
- fs.writeFileSync(filepath, markdown, "utf-8");
192
- return filepath;
193
- } catch (error) {
194
- throw new Error(`Failed to save reflection: ${error.message}`);
195
- }
196
- }
197
- function listReflections(incrementId, projectRoot) {
198
- const logDir = getReflectionLogDir(incrementId, projectRoot);
199
- if (!fs.existsSync(logDir)) {
200
- return [];
201
- }
202
- const files = fs.readdirSync(logDir).filter((file) => file.endsWith(".md")).map((file) => path.join(logDir, file)).sort((a, b) => {
203
- const statA = fs.statSync(a);
204
- const statB = fs.statSync(b);
205
- return statB.mtime.getTime() - statA.mtime.getTime();
206
- });
207
- return files;
208
- }
209
- function readReflection(filepath) {
210
- try {
211
- return fs.readFileSync(filepath, "utf-8");
212
- } catch (error) {
213
- throw new Error(`Failed to read reflection: ${error.message}`);
214
- }
215
- }
216
- function deleteReflection(filepath) {
217
- try {
218
- fs.removeSync(filepath);
219
- } catch (error) {
220
- throw new Error(`Failed to delete reflection: ${error.message}`);
221
- }
222
- }
223
- export {
224
- deleteReflection,
225
- generateReflectionMarkdown,
226
- getReflectionFilename,
227
- getReflectionLogDir,
228
- listReflections,
229
- readReflection,
230
- saveReflection
231
- };
@@ -1,369 +0,0 @@
1
- /**
2
- * Reflection Storage Manager
3
- *
4
- * Writes reflection results to markdown files in increment logs
5
- * Stores reflections in .specweave/increments/{id}/logs/reflections/
6
- *
7
- * @module reflection-storage
8
- */
9
-
10
- import fs from 'fs-extra';
11
- import path from 'path';
12
- import { ReflectionResult, IssueSeverity } from './types/reflection-types';
13
-
14
- /**
15
- * Generate markdown content from reflection result
16
- * Follows the exact format specified in reflective-reviewer agent
17
- *
18
- * @param result Reflection result object
19
- * @returns Markdown-formatted reflection content
20
- */
21
- export function generateReflectionMarkdown(result: ReflectionResult): string {
22
- const sections: string[] = [];
23
-
24
- // Header
25
- sections.push(`# Self-Reflection: ${result.taskName}`);
26
- sections.push('');
27
- sections.push(`**Completed**: ${result.completed}`);
28
-
29
- if (result.duration) {
30
- sections.push(`**Duration**: ${result.duration}`);
31
- }
32
-
33
- sections.push(`**Files Modified**: ${result.filesModified.count} files, +${result.filesModified.linesAdded} -${result.filesModified.linesRemoved}`);
34
- sections.push('');
35
- sections.push('---');
36
- sections.push('');
37
-
38
- // What Was Accomplished
39
- sections.push('## ✅ What Was Accomplished');
40
- sections.push('');
41
-
42
- if (result.accomplishments.length > 0) {
43
- for (const accomplishment of result.accomplishments) {
44
- sections.push(`- ${accomplishment}`);
45
- }
46
- } else {
47
- sections.push('(No accomplishments recorded)');
48
- }
49
-
50
- sections.push('');
51
- sections.push('---');
52
- sections.push('');
53
-
54
- // Quality Assessment
55
- sections.push('## 🎯 Quality Assessment');
56
- sections.push('');
57
-
58
- // Strengths
59
- sections.push('### ✅ Strengths');
60
- sections.push('');
61
-
62
- if (result.strengths.length > 0) {
63
- for (const strength of result.strengths) {
64
- sections.push(`- ✅ ${strength}`);
65
- }
66
- } else {
67
- sections.push('(No strengths recorded)');
68
- }
69
-
70
- sections.push('');
71
-
72
- // Issues Identified
73
- sections.push('### ⚠️ Issues Identified');
74
- sections.push('');
75
-
76
- if (result.issues.length === 0) {
77
- sections.push('✅ No critical issues detected. Code follows best practices.');
78
- } else {
79
- // Group issues by severity
80
- const criticalIssues = result.issues.filter(i => i.severity === IssueSeverity.CRITICAL);
81
- const highIssues = result.issues.filter(i => i.severity === IssueSeverity.HIGH);
82
- const mediumIssues = result.issues.filter(i => i.severity === IssueSeverity.MEDIUM);
83
- const lowIssues = result.issues.filter(i => i.severity === IssueSeverity.LOW);
84
-
85
- const issueGroups = [
86
- { issues: criticalIssues, severity: IssueSeverity.CRITICAL },
87
- { issues: highIssues, severity: IssueSeverity.HIGH },
88
- { issues: mediumIssues, severity: IssueSeverity.MEDIUM },
89
- { issues: lowIssues, severity: IssueSeverity.LOW }
90
- ];
91
-
92
- for (const group of issueGroups) {
93
- if (group.issues.length === 0) continue;
94
-
95
- for (const issue of group.issues) {
96
- sections.push(`**${issue.severity} (${issue.category})**`);
97
- sections.push(`- ❌ ${issue.description}`);
98
- sections.push(` - **Impact**: ${issue.impact}`);
99
- sections.push(` - **Recommendation**: ${issue.recommendation}`);
100
-
101
- if (issue.location) {
102
- const locationStr = issue.location.line
103
- ? `${issue.location.file}:${issue.location.line}`
104
- : issue.location.file;
105
- sections.push(` - **Location**: \`${locationStr}\``);
106
-
107
- if (issue.location.snippet) {
108
- sections.push(' - **Code Snippet**:');
109
- sections.push(' ```');
110
- sections.push(` ${issue.location.snippet}`);
111
- sections.push(' ```');
112
- }
113
- }
114
-
115
- sections.push('');
116
- }
117
- }
118
- }
119
-
120
- sections.push('---');
121
- sections.push('');
122
-
123
- // Recommended Follow-Up Actions
124
- sections.push('## 🔧 Recommended Follow-Up Actions');
125
- sections.push('');
126
-
127
- const hasActions =
128
- result.recommendedActions.priority1.length > 0 ||
129
- result.recommendedActions.priority2.length > 0 ||
130
- result.recommendedActions.priority3.length > 0;
131
-
132
- if (!hasActions) {
133
- sections.push('✅ No follow-up actions required. Ready to proceed.');
134
- } else {
135
- if (result.recommendedActions.priority1.length > 0) {
136
- sections.push('**Priority 1 (MUST FIX - before closing increment)**:');
137
- for (let i = 0; i < result.recommendedActions.priority1.length; i++) {
138
- sections.push(`${i + 1}. ${result.recommendedActions.priority1[i]}`);
139
- }
140
- sections.push('');
141
- }
142
-
143
- if (result.recommendedActions.priority2.length > 0) {
144
- sections.push('**Priority 2 (SHOULD FIX - this increment)**:');
145
- for (let i = 0; i < result.recommendedActions.priority2.length; i++) {
146
- sections.push(`${i + 1}. ${result.recommendedActions.priority2[i]}`);
147
- }
148
- sections.push('');
149
- }
150
-
151
- if (result.recommendedActions.priority3.length > 0) {
152
- sections.push('**Priority 3 (NICE TO HAVE - future increment)**:');
153
- for (let i = 0; i < result.recommendedActions.priority3.length; i++) {
154
- sections.push(`${i + 1}. ${result.recommendedActions.priority3[i]}`);
155
- }
156
- sections.push('');
157
- }
158
- }
159
-
160
- sections.push('---');
161
- sections.push('');
162
-
163
- // Lessons Learned (optional - may be empty for QUICK depth)
164
- const hasLessons =
165
- result.lessonsLearned.whatWentWell.length > 0 ||
166
- result.lessonsLearned.whatCouldImprove.length > 0 ||
167
- result.lessonsLearned.forNextTime.length > 0;
168
-
169
- if (hasLessons) {
170
- sections.push('## 📚 Lessons Learned');
171
- sections.push('');
172
-
173
- if (result.lessonsLearned.whatWentWell.length > 0) {
174
- sections.push('**What went well**:');
175
- for (const lesson of result.lessonsLearned.whatWentWell) {
176
- sections.push(`- ${lesson}`);
177
- }
178
- sections.push('');
179
- }
180
-
181
- if (result.lessonsLearned.whatCouldImprove.length > 0) {
182
- sections.push('**What could improve**:');
183
- for (const lesson of result.lessonsLearned.whatCouldImprove) {
184
- sections.push(`- ${lesson}`);
185
- }
186
- sections.push('');
187
- }
188
-
189
- if (result.lessonsLearned.forNextTime.length > 0) {
190
- sections.push('**For next time**:');
191
- for (const lesson of result.lessonsLearned.forNextTime) {
192
- sections.push(`- ${lesson}`);
193
- }
194
- sections.push('');
195
- }
196
-
197
- sections.push('---');
198
- sections.push('');
199
- }
200
-
201
- // Metrics
202
- sections.push('## 📊 Metrics');
203
- sections.push('');
204
- sections.push(`- **Code Quality**: ${result.metrics.codeQuality}/10`);
205
- sections.push(`- **Security**: ${result.metrics.security}/10`);
206
-
207
- if (result.metrics.testCoverage !== undefined) {
208
- sections.push(`- **Test Coverage**: ${result.metrics.testCoverage}%`);
209
- } else {
210
- sections.push(`- **Test Coverage**: N/A`);
211
- }
212
-
213
- sections.push(`- **Technical Debt**: ${result.metrics.technicalDebt}`);
214
- sections.push(`- **Performance**: ${result.metrics.performance.replace(/_/g, ' ')}`);
215
- sections.push('');
216
-
217
- // Related Tasks (optional)
218
- if (result.relatedTasks && result.relatedTasks.length > 0) {
219
- sections.push('---');
220
- sections.push('');
221
- sections.push('## 🔗 Related Tasks');
222
- sections.push('');
223
- for (const task of result.relatedTasks) {
224
- sections.push(`- ${task}`);
225
- }
226
- sections.push('');
227
- }
228
-
229
- // Footer
230
- sections.push('---');
231
- sections.push('');
232
- sections.push('**Auto-generated by**: SpecWeave Self-Reflection System');
233
- sections.push(`**Model**: Claude 3.5 ${result.metadata.model.charAt(0).toUpperCase() + result.metadata.model.slice(1)}`);
234
- sections.push(`**Reflection Time**: ${result.metadata.reflectionTime} seconds`);
235
- sections.push(`**Estimated Cost**: ~$${result.metadata.estimatedCost.toFixed(3)}`);
236
- sections.push('');
237
-
238
- return sections.join('\n');
239
- }
240
-
241
- /**
242
- * Get reflection log directory for an increment
243
- * @param incrementId Increment identifier (e.g., "0016-self-reflection-system")
244
- * @param projectRoot Project root directory (optional, auto-detected if not provided)
245
- * @returns Path to reflection logs directory
246
- */
247
- export function getReflectionLogDir(
248
- incrementId: string,
249
- projectRoot?: string
250
- ): string {
251
- const rootDir = projectRoot || process.cwd();
252
- return path.join(
253
- rootDir,
254
- '.specweave',
255
- 'increments',
256
- incrementId,
257
- 'logs',
258
- 'reflections'
259
- );
260
- }
261
-
262
- /**
263
- * Generate filename for reflection log
264
- * @param taskId Task identifier (e.g., "T-005")
265
- * @param timestamp Optional timestamp (defaults to current date)
266
- * @returns Filename (e.g., "task-T-005-reflection-2025-11-10.md")
267
- */
268
- export function getReflectionFilename(
269
- taskId: string,
270
- timestamp?: Date
271
- ): string {
272
- const date = timestamp || new Date();
273
- const dateStr = date.toISOString().split('T')[0]; // YYYY-MM-DD
274
- const sanitizedTaskId = taskId.replace(/[^a-zA-Z0-9-]/g, '-');
275
- return `task-${sanitizedTaskId}-reflection-${dateStr}.md`;
276
- }
277
-
278
- /**
279
- * Save reflection result to markdown file
280
- * Creates directory structure if it doesn't exist
281
- *
282
- * @param result Reflection result to save
283
- * @param incrementId Increment identifier
284
- * @param taskId Task identifier
285
- * @param projectRoot Project root directory (optional)
286
- * @returns Path to saved reflection file
287
- * @throws Error if file cannot be written
288
- */
289
- export function saveReflection(
290
- result: ReflectionResult,
291
- incrementId: string,
292
- taskId: string,
293
- projectRoot?: string
294
- ): string {
295
- // Ensure reflection logs directory exists
296
- const logDir = getReflectionLogDir(incrementId, projectRoot);
297
- fs.mkdirpSync(logDir);
298
-
299
- // Generate filename
300
- const filename = getReflectionFilename(taskId);
301
- const filepath = path.join(logDir, filename);
302
-
303
- // Generate markdown content
304
- const markdown = generateReflectionMarkdown(result);
305
-
306
- // Write to file
307
- try {
308
- fs.writeFileSync(filepath, markdown, 'utf-8');
309
- return filepath;
310
- } catch (error: any) {
311
- throw new Error(`Failed to save reflection: ${error.message}`);
312
- }
313
- }
314
-
315
- /**
316
- * List all reflection files for an increment
317
- * @param incrementId Increment identifier
318
- * @param projectRoot Project root directory (optional)
319
- * @returns Array of reflection file paths (sorted by date, newest first)
320
- */
321
- export function listReflections(
322
- incrementId: string,
323
- projectRoot?: string
324
- ): string[] {
325
- const logDir = getReflectionLogDir(incrementId, projectRoot);
326
-
327
- if (!fs.existsSync(logDir)) {
328
- return [];
329
- }
330
-
331
- const files = fs.readdirSync(logDir)
332
- .filter(file => file.endsWith('.md'))
333
- .map(file => path.join(logDir, file))
334
- .sort((a, b) => {
335
- // Sort by modification time (newest first)
336
- const statA = fs.statSync(a);
337
- const statB = fs.statSync(b);
338
- return statB.mtime.getTime() - statA.mtime.getTime();
339
- });
340
-
341
- return files;
342
- }
343
-
344
- /**
345
- * Read reflection from file
346
- * @param filepath Path to reflection markdown file
347
- * @returns Markdown content as string
348
- * @throws Error if file cannot be read
349
- */
350
- export function readReflection(filepath: string): string {
351
- try {
352
- return fs.readFileSync(filepath, 'utf-8');
353
- } catch (error: any) {
354
- throw new Error(`Failed to read reflection: ${error.message}`);
355
- }
356
- }
357
-
358
- /**
359
- * Delete reflection file
360
- * @param filepath Path to reflection markdown file
361
- * @throws Error if file cannot be deleted
362
- */
363
- export function deleteReflection(filepath: string): void {
364
- try {
365
- fs.removeSync(filepath);
366
- } catch (error: any) {
367
- throw new Error(`Failed to delete reflection: ${error.message}`);
368
- }
369
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Core Reflection Engine
3
- *
4
- * Orchestrates the self-reflection process:
5
- * 1. Load configuration
6
- * 2. Get modified files
7
- * 3. Build prompt
8
- * 4. Invoke reflective-reviewer agent
9
- * 5. Parse response
10
- * 6. Store reflection
11
- *
12
- * @module run-self-reflection
13
- */
14
- import { ReflectionContext, ReflectionExecutionResult } from './types/reflection-types';
15
- /**
16
- * Run self-reflection analysis
17
- * Main entry point for the reflection system
18
- *
19
- * @param context Reflection context with increment, task, and files
20
- * @returns Reflection execution result (success or error)
21
- */
22
- export declare function runSelfReflection(context: ReflectionContext): Promise<ReflectionExecutionResult>;
23
- /**
24
- * Create reflection context from hook environment
25
- * Helper function for hook integration
26
- *
27
- * @param incrementId Increment identifier
28
- * @param taskId Task identifier
29
- * @param projectRoot Project root directory (optional, auto-detected)
30
- * @returns Reflection context ready for runSelfReflection
31
- */
32
- export declare function createReflectionContext(incrementId: string, taskId: string, projectRoot?: string): ReflectionContext;
33
- /**
34
- * Run reflection with automatic context creation
35
- * Convenience function for hook integration
36
- *
37
- * @param incrementId Increment identifier
38
- * @param taskId Task identifier
39
- * @param projectRoot Project root directory (optional)
40
- * @returns Reflection execution result
41
- */
42
- export declare function runReflectionAuto(incrementId: string, taskId: string, projectRoot?: string): Promise<ReflectionExecutionResult>;
43
- //# sourceMappingURL=run-self-reflection.d.ts.map