specweave 0.24.6 → 0.24.8

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 (147) hide show
  1. package/CLAUDE.md +64 -0
  2. package/README.md +34 -0
  3. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts +5 -2
  4. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
  5. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +72 -6
  6. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
  7. package/dist/src/cli/helpers/issue-tracker/github.d.ts +2 -1
  8. package/dist/src/cli/helpers/issue-tracker/github.d.ts.map +1 -1
  9. package/dist/src/cli/helpers/issue-tracker/github.js +4 -3
  10. package/dist/src/cli/helpers/issue-tracker/github.js.map +1 -1
  11. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  12. package/dist/src/cli/helpers/issue-tracker/index.js +26 -9
  13. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  14. package/dist/src/cli/helpers/issue-tracker/types.d.ts +1 -0
  15. package/dist/src/cli/helpers/issue-tracker/types.d.ts.map +1 -1
  16. package/dist/src/cli/helpers/issue-tracker/types.js.map +1 -1
  17. package/dist/src/core/repo-structure/git-error-handler.d.ts +37 -0
  18. package/dist/src/core/repo-structure/git-error-handler.d.ts.map +1 -0
  19. package/dist/src/core/repo-structure/git-error-handler.js +214 -0
  20. package/dist/src/core/repo-structure/git-error-handler.js.map +1 -0
  21. package/dist/src/core/repo-structure/git-provider.d.ts +183 -0
  22. package/dist/src/core/repo-structure/git-provider.d.ts.map +1 -0
  23. package/dist/src/core/repo-structure/git-provider.js +57 -0
  24. package/dist/src/core/repo-structure/git-provider.js.map +1 -0
  25. package/dist/src/core/repo-structure/github-validator.d.ts +1 -0
  26. package/dist/src/core/repo-structure/github-validator.d.ts.map +1 -1
  27. package/dist/src/core/repo-structure/github-validator.js +35 -9
  28. package/dist/src/core/repo-structure/github-validator.js.map +1 -1
  29. package/dist/src/core/repo-structure/platform-registry.d.ts +114 -0
  30. package/dist/src/core/repo-structure/platform-registry.d.ts.map +1 -0
  31. package/dist/src/core/repo-structure/platform-registry.js +195 -0
  32. package/dist/src/core/repo-structure/platform-registry.js.map +1 -0
  33. package/dist/src/core/repo-structure/prompt-consolidator.d.ts +30 -0
  34. package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
  35. package/dist/src/core/repo-structure/prompt-consolidator.js +69 -0
  36. package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
  37. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts +54 -0
  38. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts.map +1 -0
  39. package/dist/src/core/repo-structure/providers/bitbucket-provider.js +104 -0
  40. package/dist/src/core/repo-structure/providers/bitbucket-provider.js.map +1 -0
  41. package/dist/src/core/repo-structure/providers/github-provider.d.ts +53 -0
  42. package/dist/src/core/repo-structure/providers/github-provider.d.ts.map +1 -0
  43. package/dist/src/core/repo-structure/providers/github-provider.js +239 -0
  44. package/dist/src/core/repo-structure/providers/github-provider.js.map +1 -0
  45. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts +50 -0
  46. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts.map +1 -0
  47. package/dist/src/core/repo-structure/providers/gitlab-provider.js +97 -0
  48. package/dist/src/core/repo-structure/providers/gitlab-provider.js.map +1 -0
  49. package/dist/src/core/repo-structure/providers/index.d.ts +33 -0
  50. package/dist/src/core/repo-structure/providers/index.d.ts.map +1 -0
  51. package/dist/src/core/repo-structure/providers/index.js +60 -0
  52. package/dist/src/core/repo-structure/providers/index.js.map +1 -0
  53. package/dist/src/core/repo-structure/repo-structure-manager.d.ts +10 -3
  54. package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
  55. package/dist/src/core/repo-structure/repo-structure-manager.js +125 -42
  56. package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
  57. package/dist/src/core/repo-structure/url-generator.d.ts +80 -0
  58. package/dist/src/core/repo-structure/url-generator.d.ts.map +1 -0
  59. package/dist/src/core/repo-structure/url-generator.js +110 -0
  60. package/dist/src/core/repo-structure/url-generator.js.map +1 -0
  61. package/package.json +1 -1
  62. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  63. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  64. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  65. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  66. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  67. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  68. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  69. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  70. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  71. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  72. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  73. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  74. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  75. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  76. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  77. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  78. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  79. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  80. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  81. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  82. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  83. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  84. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  85. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  86. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  87. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  88. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  89. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  90. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  91. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  92. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  93. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  94. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  95. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  96. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  97. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  98. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  99. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  100. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  101. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  102. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  103. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  104. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  105. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  106. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  107. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  108. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  109. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  110. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  111. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  112. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  113. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  114. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  115. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  116. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  117. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  118. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  119. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  120. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  121. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  122. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  123. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  124. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  125. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  126. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  127. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  128. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  129. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  130. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  131. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  132. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  133. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  134. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  135. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  136. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  137. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  138. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  139. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  140. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  141. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  142. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  143. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -360
  144. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  145. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  146. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -444
  147. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
@@ -1,264 +0,0 @@
1
- /**
2
- * Translator Skill Invocation Utility
3
- *
4
- * Provides programmatic invocation of the translator skill for automated translation.
5
- * Used by hooks and CLI scripts to translate content without manual intervention.
6
- *
7
- * @see plugins/specweave/skills/translator/SKILL.md
8
- * @see plugins/specweave/commands/translate.md
9
- */
10
-
11
- import fs from 'fs-extra';
12
- import path from 'path';
13
- import {
14
- detectLanguage,
15
- prepareTranslation,
16
- postProcessTranslation,
17
- getLanguageName,
18
- type SupportedLanguage,
19
- } from '../../../../dist/src/utils/translation.js';
20
-
21
- /**
22
- * Translation result
23
- */
24
- export interface TranslationResult {
25
- success: boolean;
26
- sourceLanguage: SupportedLanguage;
27
- targetLanguage: SupportedLanguage;
28
- originalContent: string;
29
- translatedContent?: string;
30
- error?: string;
31
- }
32
-
33
- /**
34
- * Invokes translator skill to translate content
35
- *
36
- * This function integrates with the translator skill by:
37
- * 1. Preparing translation prompt
38
- * 2. Writing prompt to a temp file
39
- * 3. Outputting instructions for Claude to process
40
- * 4. Returning the translated content
41
- *
42
- * In an automated context (hooks), this provides clear instructions.
43
- * In an interactive context, the translator skill can auto-activate.
44
- *
45
- * @param content - Content to translate
46
- * @param sourceLang - Source language
47
- * @param targetLang - Target language
48
- * @returns Translation result
49
- */
50
- export async function invokeTranslatorSkill(
51
- content: string,
52
- sourceLang: SupportedLanguage,
53
- targetLang: SupportedLanguage = 'en'
54
- ): Promise<TranslationResult> {
55
- try {
56
- // Prepare translation
57
- const prepared = prepareTranslation(content, sourceLang, targetLang);
58
-
59
- // For now, we use a practical approach:
60
- // Output the translation request clearly so it can be processed
61
-
62
- const result: TranslationResult = {
63
- success: true,
64
- sourceLanguage: sourceLang,
65
- targetLanguage: targetLang,
66
- originalContent: content,
67
- translatedContent: await performTranslation(prepared.prompt, prepared.preserved),
68
- };
69
-
70
- return result;
71
- } catch (error) {
72
- const errorMessage = error instanceof Error ? error.message : String(error);
73
- return {
74
- success: false,
75
- sourceLanguage: sourceLang,
76
- targetLanguage: targetLang,
77
- originalContent: content,
78
- error: errorMessage,
79
- };
80
- }
81
- }
82
-
83
- /**
84
- * Performs the actual translation using Anthropic API
85
- *
86
- * PRODUCTION IMPLEMENTATION:
87
- * 1. Checks for ANTHROPIC_API_KEY in environment
88
- * 2. If available: Uses Anthropic API directly (fully automatic)
89
- * 3. If not available: Provides clear instructions for manual translation
90
- *
91
- * @param prompt - Translation prompt
92
- * @param preserved - Preserved content structure
93
- * @returns Translated content
94
- */
95
- async function performTranslation(
96
- prompt: string,
97
- preserved: any
98
- ): Promise<string> {
99
- // Extract content for processing
100
- const contentMatch = prompt.match(/SOURCE DOCUMENT[^\n]*:\n---\n([\s\S]*?)\n---/);
101
- const contentToTranslate = contentMatch ? contentMatch[1] : '';
102
-
103
- // Check if ANTHROPIC_API_KEY is available
104
- const apiKey = process.env.ANTHROPIC_API_KEY;
105
-
106
- if (apiKey) {
107
- // Fully automatic translation using Anthropic API
108
- console.log(`\n🤖 Translating via Anthropic API (Haiku model)...`);
109
-
110
- try {
111
- // Dynamic import of Anthropic SDK (allows graceful fallback if not installed)
112
- const Anthropic = await import('@anthropic-ai/sdk').then(m => m.default);
113
-
114
- const anthropic = new Anthropic({
115
- apiKey,
116
- });
117
-
118
- const message = await anthropic.messages.create({
119
- model: 'claude-3-haiku-20240307',
120
- max_tokens: 8000,
121
- messages: [
122
- {
123
- role: 'user',
124
- content: prompt,
125
- },
126
- ],
127
- });
128
-
129
- // Extract translated content from response
130
- const translatedContent = message.content[0].type === 'text'
131
- ? message.content[0].text
132
- : contentToTranslate;
133
-
134
- console.log(`✅ Translation complete via API`);
135
- console.log(` Input tokens: ${message.usage.input_tokens}`);
136
- console.log(` Output tokens: ${message.usage.output_tokens}`);
137
- console.log(` Cost: ~$${((message.usage.input_tokens * 0.25 + message.usage.output_tokens * 1.25) / 1000000).toFixed(4)}\n`);
138
-
139
- return postProcessTranslation(translatedContent, preserved);
140
- } catch (error: any) {
141
- console.error(`\n❌ API translation failed: ${error.message}`);
142
- console.error(` Falling back to manual translation instructions\n`);
143
- // Fall through to manual instructions
144
- }
145
- }
146
-
147
- // Fallback: Manual translation instructions
148
- const isInteractive = process.env.CLAUDE_CODE_SESSION === 'true';
149
-
150
- if (isInteractive) {
151
- // In Claude Code environment, output translation request
152
- console.log('\n' + '='.repeat(80));
153
- console.log('🌐 TRANSLATION REQUEST (translator skill will auto-activate)');
154
- console.log('='.repeat(80));
155
- console.log(prompt);
156
- console.log('='.repeat(80));
157
- console.log('💡 Tip: Set ANTHROPIC_API_KEY for fully automatic translation\n');
158
-
159
- return postProcessTranslation(
160
- `<!-- ⚠️ TRANSLATION REQUESTED - Awaiting translator skill activation -->\n\n${contentToTranslate}`,
161
- preserved
162
- );
163
- } else {
164
- // Non-interactive environment - provide clear instructions
165
- console.error('\n⚠️ AUTO-TRANSLATION REQUIRES ONE OF:');
166
- console.error(' Option A (Recommended): Set ANTHROPIC_API_KEY environment variable');
167
- console.error(' Option B: Run /specweave:translate <file-path>');
168
- console.error(' Option C: Manually translate the content\n');
169
-
170
- return postProcessTranslation(
171
- `<!-- ⚠️ AUTO-TRANSLATION PENDING -->\n<!-- Set ANTHROPIC_API_KEY for automatic translation -->\n<!-- Or run: /specweave:translate to complete -->\n<!-- Original content below -->\n\n${contentToTranslate}`,
172
- preserved
173
- );
174
- }
175
- }
176
-
177
- /**
178
- * Translate a file using translator skill
179
- *
180
- * @param filePath - Path to file to translate
181
- * @param targetLang - Target language
182
- * @returns Translation result
183
- */
184
- export async function translateFile(
185
- filePath: string,
186
- targetLang: SupportedLanguage = 'en'
187
- ): Promise<TranslationResult & { filePath: string }> {
188
- // Read file
189
- if (!await fs.pathExists(filePath)) {
190
- throw new Error(`File not found: ${filePath}`);
191
- }
192
-
193
- const content = await fs.readFile(filePath, 'utf-8');
194
-
195
- // Detect source language
196
- const detection = detectLanguage(content);
197
- const sourceLang = detection.language;
198
-
199
- // Check if already in target language
200
- if (sourceLang === targetLang) {
201
- return {
202
- success: true,
203
- filePath,
204
- sourceLanguage: sourceLang,
205
- targetLanguage: targetLang,
206
- originalContent: content,
207
- translatedContent: content,
208
- };
209
- }
210
-
211
- // Translate
212
- const result = await invokeTranslatorSkill(content, sourceLang, targetLang);
213
-
214
- // Write back if successful
215
- if (result.success && result.translatedContent) {
216
- await fs.writeFile(filePath, result.translatedContent, 'utf-8');
217
- console.log(`✅ Translated: ${filePath} (${getLanguageName(sourceLang)} → ${getLanguageName(targetLang)})`);
218
- }
219
-
220
- return {
221
- ...result,
222
- filePath,
223
- };
224
- }
225
-
226
- /**
227
- * Batch translate multiple files
228
- *
229
- * @param filePaths - Array of file paths
230
- * @param targetLang - Target language
231
- * @returns Array of translation results
232
- */
233
- export async function batchTranslateFiles(
234
- filePaths: string[],
235
- targetLang: SupportedLanguage = 'en'
236
- ): Promise<Array<TranslationResult & { filePath: string }>> {
237
- const results: Array<TranslationResult & { filePath: string }> = [];
238
-
239
- console.log(`\n🌐 Batch translating ${filePaths.length} file(s) to ${getLanguageName(targetLang)}...\n`);
240
-
241
- for (const filePath of filePaths) {
242
- try {
243
- const result = await translateFile(filePath, targetLang);
244
- results.push(result);
245
- } catch (error) {
246
- const errorMessage = error instanceof Error ? error.message : String(error);
247
- console.error(`❌ Failed to translate ${filePath}: ${errorMessage}`);
248
- results.push({
249
- success: false,
250
- filePath,
251
- sourceLanguage: 'unknown',
252
- targetLanguage: targetLang,
253
- originalContent: '',
254
- error: errorMessage,
255
- });
256
- }
257
- }
258
-
259
- // Summary
260
- const successful = results.filter(r => r.success).length;
261
- console.log(`\n📊 Batch translation complete: ${successful}/${filePaths.length} files translated\n`);
262
-
263
- return results;
264
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Prepare Reflection Context
3
- *
4
- * Prepares context for reflection and saves to temp file
5
- * Used by post-task-completion hook to prepare for reflection invocation
6
- *
7
- * @module prepare-reflection-context
8
- */
9
- /**
10
- * Prepare reflection context and save to temp file
11
- * This allows the hook to prepare data without actually invoking the agent
12
- *
13
- * @param incrementId Increment identifier
14
- * @param taskId Task identifier
15
- * @param projectRoot Project root directory (optional)
16
- * @returns Path to saved context file or null if reflection should be skipped
17
- */
18
- export declare function prepareReflectionContext(incrementId: string, taskId: string, projectRoot?: string): string | null;
19
- /**
20
- * Check if reflection context exists for an increment
21
- *
22
- * @param incrementId Increment identifier
23
- * @param projectRoot Project root directory (optional)
24
- * @returns True if context file exists
25
- */
26
- export declare function hasReflectionContext(incrementId: string, projectRoot?: string): boolean;
27
- /**
28
- * Read reflection context from file
29
- *
30
- * @param incrementId Increment identifier
31
- * @param projectRoot Project root directory (optional)
32
- * @returns Context data or null if not found
33
- */
34
- export declare function readReflectionContext(incrementId: string, projectRoot?: string): any | null;
35
- /**
36
- * Clear reflection context after reflection completes
37
- *
38
- * @param incrementId Increment identifier
39
- * @param projectRoot Project root directory (optional)
40
- */
41
- export declare function clearReflectionContext(incrementId: string, projectRoot?: string): void;
42
- //# sourceMappingURL=prepare-reflection-context.d.ts.map
@@ -1,110 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import { createReflectionContext } from "./run-self-reflection";
4
- import { getModifiedFilesSummary } from "./git-diff-analyzer";
5
- function prepareReflectionContext(incrementId, taskId, projectRoot) {
6
- try {
7
- const context = createReflectionContext(incrementId, taskId, projectRoot);
8
- if (!context.config.enabled || context.modifiedFiles.length === 0) {
9
- return null;
10
- }
11
- const rootDir = projectRoot || process.cwd();
12
- const tempDir = path.join(rootDir, ".specweave", "increments", incrementId, "logs", "reflections", ".temp");
13
- fs.mkdirpSync(tempDir);
14
- const contextFile = path.join(tempDir, "reflection-context.json");
15
- const fileStats = getModifiedFilesSummary(context.modifiedFiles);
16
- const contextData = {
17
- incrementId: context.incrementId,
18
- taskId: context.taskId,
19
- modifiedFiles: context.modifiedFiles.map((f) => ({
20
- file: f.file,
21
- linesAdded: f.linesAdded,
22
- linesRemoved: f.linesRemoved
23
- // Exclude diff content to save space
24
- })),
25
- fileSummary: {
26
- count: fileStats.count,
27
- linesAdded: fileStats.linesAdded,
28
- linesRemoved: fileStats.linesRemoved
29
- },
30
- config: context.config,
31
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
32
- };
33
- fs.writeJsonSync(contextFile, contextData, { spaces: 2 });
34
- return contextFile;
35
- } catch (error) {
36
- console.error(`Failed to prepare reflection context: ${error.message}`);
37
- return null;
38
- }
39
- }
40
- function hasReflectionContext(incrementId, projectRoot) {
41
- const rootDir = projectRoot || process.cwd();
42
- const contextFile = path.join(
43
- rootDir,
44
- ".specweave",
45
- "increments",
46
- incrementId,
47
- "logs",
48
- "reflections",
49
- ".temp",
50
- "reflection-context.json"
51
- );
52
- return fs.existsSync(contextFile);
53
- }
54
- function readReflectionContext(incrementId, projectRoot) {
55
- const rootDir = projectRoot || process.cwd();
56
- const contextFile = path.join(
57
- rootDir,
58
- ".specweave",
59
- "increments",
60
- incrementId,
61
- "logs",
62
- "reflections",
63
- ".temp",
64
- "reflection-context.json"
65
- );
66
- if (!fs.existsSync(contextFile)) {
67
- return null;
68
- }
69
- try {
70
- return fs.readJsonSync(contextFile);
71
- } catch {
72
- return null;
73
- }
74
- }
75
- function clearReflectionContext(incrementId, projectRoot) {
76
- const rootDir = projectRoot || process.cwd();
77
- const tempDir = path.join(
78
- rootDir,
79
- ".specweave",
80
- "increments",
81
- incrementId,
82
- "logs",
83
- "reflections",
84
- ".temp"
85
- );
86
- if (fs.existsSync(tempDir)) {
87
- fs.removeSync(tempDir);
88
- }
89
- }
90
- if (require.main === module) {
91
- const incrementId = process.argv[2];
92
- const taskId = process.argv[3];
93
- if (!incrementId || !taskId) {
94
- console.error("Usage: node prepare-reflection-context.js <increment-id> <task-id>");
95
- process.exit(1);
96
- }
97
- const contextFile = prepareReflectionContext(incrementId, taskId);
98
- if (contextFile) {
99
- console.log(`Reflection context prepared: ${contextFile}`);
100
- console.log("\u2728 Reflection ready. Run /specweave:reflect to analyze your work.");
101
- } else {
102
- console.log("Reflection skipped (disabled or no changes).");
103
- }
104
- }
105
- export {
106
- clearReflectionContext,
107
- hasReflectionContext,
108
- prepareReflectionContext,
109
- readReflectionContext
110
- };
@@ -1,178 +0,0 @@
1
- /**
2
- * Prepare Reflection Context
3
- *
4
- * Prepares context for reflection and saves to temp file
5
- * Used by post-task-completion hook to prepare for reflection invocation
6
- *
7
- * @module prepare-reflection-context
8
- */
9
-
10
- import fs from 'fs-extra';
11
- import path from 'path';
12
- import { createReflectionContext } from './run-self-reflection';
13
- import { getModifiedFilesSummary } from './git-diff-analyzer';
14
-
15
- /**
16
- * Prepare reflection context and save to temp file
17
- * This allows the hook to prepare data without actually invoking the agent
18
- *
19
- * @param incrementId Increment identifier
20
- * @param taskId Task identifier
21
- * @param projectRoot Project root directory (optional)
22
- * @returns Path to saved context file or null if reflection should be skipped
23
- */
24
- export function prepareReflectionContext(
25
- incrementId: string,
26
- taskId: string,
27
- projectRoot?: string
28
- ): string | null {
29
- try {
30
- const context = createReflectionContext(incrementId, taskId, projectRoot);
31
-
32
- // Check if reflection should run
33
- if (!context.config.enabled || context.modifiedFiles.length === 0) {
34
- return null;
35
- }
36
-
37
- // Create temp directory for reflection context
38
- const rootDir = projectRoot || process.cwd();
39
- const tempDir = path.join(rootDir, '.specweave', 'increments', incrementId, 'logs', 'reflections', '.temp');
40
- fs.mkdirpSync(tempDir);
41
-
42
- // Save context to temp file
43
- const contextFile = path.join(tempDir, 'reflection-context.json');
44
-
45
- const fileStats = getModifiedFilesSummary(context.modifiedFiles);
46
-
47
- const contextData = {
48
- incrementId: context.incrementId,
49
- taskId: context.taskId,
50
- modifiedFiles: context.modifiedFiles.map(f => ({
51
- file: f.file,
52
- linesAdded: f.linesAdded,
53
- linesRemoved: f.linesRemoved
54
- // Exclude diff content to save space
55
- })),
56
- fileSummary: {
57
- count: fileStats.count,
58
- linesAdded: fileStats.linesAdded,
59
- linesRemoved: fileStats.linesRemoved
60
- },
61
- config: context.config,
62
- timestamp: new Date().toISOString()
63
- };
64
-
65
- fs.writeJsonSync(contextFile, contextData, { spaces: 2 });
66
-
67
- return contextFile;
68
- } catch (error: any) {
69
- console.error(`Failed to prepare reflection context: ${error.message}`);
70
- return null;
71
- }
72
- }
73
-
74
- /**
75
- * Check if reflection context exists for an increment
76
- *
77
- * @param incrementId Increment identifier
78
- * @param projectRoot Project root directory (optional)
79
- * @returns True if context file exists
80
- */
81
- export function hasReflectionContext(
82
- incrementId: string,
83
- projectRoot?: string
84
- ): boolean {
85
- const rootDir = projectRoot || process.cwd();
86
- const contextFile = path.join(
87
- rootDir,
88
- '.specweave',
89
- 'increments',
90
- incrementId,
91
- 'logs',
92
- 'reflections',
93
- '.temp',
94
- 'reflection-context.json'
95
- );
96
-
97
- return fs.existsSync(contextFile);
98
- }
99
-
100
- /**
101
- * Read reflection context from file
102
- *
103
- * @param incrementId Increment identifier
104
- * @param projectRoot Project root directory (optional)
105
- * @returns Context data or null if not found
106
- */
107
- export function readReflectionContext(
108
- incrementId: string,
109
- projectRoot?: string
110
- ): any | null {
111
- const rootDir = projectRoot || process.cwd();
112
- const contextFile = path.join(
113
- rootDir,
114
- '.specweave',
115
- 'increments',
116
- incrementId,
117
- 'logs',
118
- 'reflections',
119
- '.temp',
120
- 'reflection-context.json'
121
- );
122
-
123
- if (!fs.existsSync(contextFile)) {
124
- return null;
125
- }
126
-
127
- try {
128
- return fs.readJsonSync(contextFile);
129
- } catch {
130
- return null;
131
- }
132
- }
133
-
134
- /**
135
- * Clear reflection context after reflection completes
136
- *
137
- * @param incrementId Increment identifier
138
- * @param projectRoot Project root directory (optional)
139
- */
140
- export function clearReflectionContext(
141
- incrementId: string,
142
- projectRoot?: string
143
- ): void {
144
- const rootDir = projectRoot || process.cwd();
145
- const tempDir = path.join(
146
- rootDir,
147
- '.specweave',
148
- 'increments',
149
- incrementId,
150
- 'logs',
151
- 'reflections',
152
- '.temp'
153
- );
154
-
155
- if (fs.existsSync(tempDir)) {
156
- fs.removeSync(tempDir);
157
- }
158
- }
159
-
160
- // CLI entry point for hook integration
161
- if (require.main === module) {
162
- const incrementId = process.argv[2];
163
- const taskId = process.argv[3];
164
-
165
- if (!incrementId || !taskId) {
166
- console.error('Usage: node prepare-reflection-context.js <increment-id> <task-id>');
167
- process.exit(1);
168
- }
169
-
170
- const contextFile = prepareReflectionContext(incrementId, taskId);
171
-
172
- if (contextFile) {
173
- console.log(`Reflection context prepared: ${contextFile}`);
174
- console.log('✨ Reflection ready. Run /specweave:reflect to analyze your work.');
175
- } else {
176
- console.log('Reflection skipped (disabled or no changes).');
177
- }
178
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Reflection Configuration Loader
3
- *
4
- * Loads and validates reflection configuration from .specweave/config.json
5
- * Merges user config with defaults, validates against schema
6
- *
7
- * @module reflection-config-loader
8
- */
9
- import { ReflectionConfig } from './types/reflection-types';
10
- /**
11
- * Find .specweave directory by traversing up from current directory
12
- * @param startDir Starting directory (defaults to cwd)
13
- * @returns Path to .specweave directory or null if not found
14
- */
15
- export declare function findSpecweaveRoot(startDir?: string): string | null;
16
- /**
17
- * Load reflection configuration from .specweave/config.json
18
- * Falls back to defaults if config file doesn't exist or reflection section is missing
19
- *
20
- * @param projectRoot Path to project root (optional, auto-detected if not provided)
21
- * @returns Merged reflection configuration
22
- * @throws Error if config file exists but has invalid JSON
23
- */
24
- export declare function loadReflectionConfig(projectRoot?: string): ReflectionConfig;
25
- /**
26
- * Validate reflection configuration against constraints
27
- * Checks for logical inconsistencies (e.g., all categories disabled)
28
- *
29
- * @param config Reflection configuration to validate
30
- * @returns Validation result with errors array
31
- */
32
- export declare function validateReflectionConfig(config: ReflectionConfig): {
33
- valid: boolean;
34
- errors: string[];
35
- };
36
- /**
37
- * Load and validate reflection configuration
38
- * Throws error if configuration is invalid
39
- *
40
- * @param projectRoot Path to project root (optional, auto-detected if not provided)
41
- * @returns Valid reflection configuration
42
- * @throws Error if configuration is invalid
43
- */
44
- export declare function loadAndValidateReflectionConfig(projectRoot?: string): ReflectionConfig;
45
- //# sourceMappingURL=reflection-config-loader.d.ts.map