specweave 1.0.464 → 1.0.466

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 (109) hide show
  1. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator-cli.d.ts +16 -0
  2. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator-cli.js +139 -0
  3. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator-cli.js.map +1 -0
  4. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator.d.ts +111 -0
  5. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator.js +304 -0
  6. package/dist/plugins/specweave/lib/vendor/core/ac-test-validator.js.map +1 -0
  7. package/dist/plugins/specweave/lib/vendor/core/increment/ac-status-manager.d.ts +115 -0
  8. package/dist/plugins/specweave/lib/vendor/core/increment/ac-status-manager.js +359 -0
  9. package/dist/plugins/specweave/lib/vendor/core/increment/ac-status-manager.js.map +1 -0
  10. package/dist/plugins/specweave/lib/vendor/core/increment/active-increment-manager.d.ts +121 -0
  11. package/dist/plugins/specweave/lib/vendor/core/increment/active-increment-manager.js +273 -0
  12. package/dist/plugins/specweave/lib/vendor/core/increment/active-increment-manager.js.map +1 -0
  13. package/dist/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.d.ts +72 -0
  14. package/dist/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.js +237 -0
  15. package/dist/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.js.map +1 -0
  16. package/dist/plugins/specweave/lib/vendor/core/increment/duplicate-detector.d.ts +52 -0
  17. package/dist/plugins/specweave/lib/vendor/core/increment/duplicate-detector.js +281 -0
  18. package/dist/plugins/specweave/lib/vendor/core/increment/duplicate-detector.js.map +1 -0
  19. package/dist/plugins/specweave/lib/vendor/core/increment/metadata-manager.d.ts +278 -0
  20. package/dist/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +925 -0
  21. package/dist/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -0
  22. package/dist/plugins/specweave/lib/vendor/core/increment/status-auto-transition.d.ts +113 -0
  23. package/dist/plugins/specweave/lib/vendor/core/increment/status-auto-transition.js +317 -0
  24. package/dist/plugins/specweave/lib/vendor/core/increment/status-auto-transition.js.map +1 -0
  25. package/dist/plugins/specweave/lib/vendor/core/types/increment-metadata.d.ts +442 -0
  26. package/dist/plugins/specweave/lib/vendor/core/types/increment-metadata.js +246 -0
  27. package/dist/plugins/specweave/lib/vendor/core/types/increment-metadata.js.map +1 -0
  28. package/dist/plugins/specweave/lib/vendor/core/universal-auto-create.d.ts +64 -0
  29. package/dist/plugins/specweave/lib/vendor/core/universal-auto-create.js +228 -0
  30. package/dist/plugins/specweave/lib/vendor/core/universal-auto-create.js.map +1 -0
  31. package/dist/plugins/specweave/lib/vendor/generators/spec/task-parser.d.ts +95 -0
  32. package/dist/plugins/specweave/lib/vendor/generators/spec/task-parser.js +300 -0
  33. package/dist/plugins/specweave/lib/vendor/generators/spec/task-parser.js.map +1 -0
  34. package/dist/plugins/specweave/lib/vendor/sync/config.d.ts +73 -0
  35. package/dist/plugins/specweave/lib/vendor/sync/config.js +132 -0
  36. package/dist/plugins/specweave/lib/vendor/sync/config.js.map +1 -0
  37. package/dist/plugins/specweave/lib/vendor/sync/github-reconciler.d.ts +163 -0
  38. package/dist/plugins/specweave/lib/vendor/sync/github-reconciler.js +898 -0
  39. package/dist/plugins/specweave/lib/vendor/sync/github-reconciler.js.map +1 -0
  40. package/dist/plugins/specweave/lib/vendor/sync/provider-router.d.ts +86 -0
  41. package/dist/plugins/specweave/lib/vendor/sync/provider-router.js +147 -0
  42. package/dist/plugins/specweave/lib/vendor/sync/provider-router.js.map +1 -0
  43. package/dist/plugins/specweave/lib/vendor/sync/status-mapper.d.ts +120 -0
  44. package/dist/plugins/specweave/lib/vendor/sync/status-mapper.js +164 -0
  45. package/dist/plugins/specweave/lib/vendor/sync/status-mapper.js.map +1 -0
  46. package/dist/plugins/specweave/lib/vendor/utils/auth-helpers.d.ts +151 -0
  47. package/dist/plugins/specweave/lib/vendor/utils/auth-helpers.js +359 -0
  48. package/dist/plugins/specweave/lib/vendor/utils/auth-helpers.js.map +1 -0
  49. package/dist/plugins/specweave/lib/vendor/utils/chalk-fallback.d.ts +38 -0
  50. package/dist/plugins/specweave/lib/vendor/utils/chalk-fallback.js +118 -0
  51. package/dist/plugins/specweave/lib/vendor/utils/chalk-fallback.js.map +1 -0
  52. package/dist/plugins/specweave/lib/vendor/utils/clean-env.d.ts +47 -0
  53. package/dist/plugins/specweave/lib/vendor/utils/clean-env.js +63 -0
  54. package/dist/plugins/specweave/lib/vendor/utils/clean-env.js.map +1 -0
  55. package/dist/plugins/specweave/lib/vendor/utils/credential-masker.d.ts +118 -0
  56. package/dist/plugins/specweave/lib/vendor/utils/credential-masker.js +275 -0
  57. package/dist/plugins/specweave/lib/vendor/utils/credential-masker.js.map +1 -0
  58. package/dist/plugins/specweave/lib/vendor/utils/execFileNoThrow.d.ts +99 -0
  59. package/dist/plugins/specweave/lib/vendor/utils/execFileNoThrow.js +149 -0
  60. package/dist/plugins/specweave/lib/vendor/utils/execFileNoThrow.js.map +1 -0
  61. package/dist/plugins/specweave/lib/vendor/utils/feature-id-derivation.d.ts +63 -0
  62. package/dist/plugins/specweave/lib/vendor/utils/feature-id-derivation.js +85 -0
  63. package/dist/plugins/specweave/lib/vendor/utils/feature-id-derivation.js.map +1 -0
  64. package/dist/plugins/specweave/lib/vendor/utils/fs-native.d.ts +219 -0
  65. package/dist/plugins/specweave/lib/vendor/utils/fs-native.js +397 -0
  66. package/dist/plugins/specweave/lib/vendor/utils/fs-native.js.map +1 -0
  67. package/dist/plugins/specweave/lib/vendor/utils/logger.d.ts +56 -0
  68. package/dist/plugins/specweave/lib/vendor/utils/logger.js +123 -0
  69. package/dist/plugins/specweave/lib/vendor/utils/logger.js.map +1 -0
  70. package/dist/plugins/specweave/lib/vendor/utils/translation.d.ts +187 -0
  71. package/dist/plugins/specweave/lib/vendor/utils/translation.js +414 -0
  72. package/dist/plugins/specweave/lib/vendor/utils/translation.js.map +1 -0
  73. package/dist/plugins/specweave-ado/lib/ado-ac-checkbox-sync.js +1 -1
  74. package/dist/plugins/specweave-ado/lib/ado-ac-checkbox-sync.js.map +1 -1
  75. package/dist/plugins/specweave-ado/lib/ado-spec-sync.js +1 -1
  76. package/dist/plugins/specweave-ado/lib/ado-spec-sync.js.map +1 -1
  77. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.js +2 -2
  78. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.js.map +1 -1
  79. package/dist/plugins/specweave-github/lib/github-feature-sync.d.ts.map +1 -1
  80. package/dist/plugins/specweave-github/lib/github-feature-sync.js +13 -4
  81. package/dist/plugins/specweave-github/lib/github-feature-sync.js.map +1 -1
  82. package/dist/plugins/specweave-jira/lib/jira-ac-checkbox-sync.js +1 -1
  83. package/dist/plugins/specweave-jira/lib/jira-ac-checkbox-sync.js.map +1 -1
  84. package/dist/plugins/specweave-jira/lib/jira-spec-sync.js +1 -1
  85. package/dist/plugins/specweave-jira/lib/jira-spec-sync.js.map +1 -1
  86. package/dist/src/sync/spec-to-living-docs-sync.js +1 -1
  87. package/dist/src/sync/spec-to-living-docs-sync.js.map +1 -1
  88. package/package.json +1 -1
  89. package/plugins/specweave/lib/vendor/utils/auth-helpers.d.ts +151 -0
  90. package/plugins/specweave/lib/vendor/utils/auth-helpers.js +359 -0
  91. package/plugins/specweave/lib/vendor/utils/auth-helpers.js.map +1 -0
  92. package/plugins/specweave/skills/team-lead/SKILL.md +150 -56
  93. package/plugins/specweave/skills/team-lead/agents/backend.md +13 -9
  94. package/plugins/specweave/skills/team-lead/agents/database.md +13 -9
  95. package/plugins/specweave/skills/team-lead/agents/frontend.md +12 -8
  96. package/plugins/specweave/skills/team-lead/agents/security.md +13 -9
  97. package/plugins/specweave/skills/team-lead/agents/testing.md +12 -8
  98. package/plugins/specweave-ado/lib/ado-ac-checkbox-sync.js +1 -1
  99. package/plugins/specweave-ado/lib/ado-ac-checkbox-sync.ts +1 -1
  100. package/plugins/specweave-ado/lib/ado-spec-sync.js +1 -1
  101. package/plugins/specweave-ado/lib/ado-spec-sync.ts +1 -1
  102. package/plugins/specweave-github/lib/github-ac-checkbox-sync.js +1 -1
  103. package/plugins/specweave-github/lib/github-ac-checkbox-sync.ts +2 -2
  104. package/plugins/specweave-github/lib/github-feature-sync.js +11 -3
  105. package/plugins/specweave-github/lib/github-feature-sync.ts +13 -4
  106. package/plugins/specweave-jira/lib/jira-ac-checkbox-sync.js +1 -1
  107. package/plugins/specweave-jira/lib/jira-ac-checkbox-sync.ts +1 -1
  108. package/plugins/specweave-jira/lib/jira-spec-sync.js +1 -1
  109. package/plugins/specweave-jira/lib/jira-spec-sync.ts +1 -1
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Represents the completion status of an Acceptance Criteria
3
+ */
4
+ export interface ACCompletionStatus {
5
+ acId: string;
6
+ totalTasks: number;
7
+ completedTasks: number;
8
+ percentage: number;
9
+ isComplete: boolean;
10
+ tasks: string[];
11
+ }
12
+ /**
13
+ * Represents an Acceptance Criteria definition in spec.md
14
+ */
15
+ export interface ACDefinition {
16
+ acId: string;
17
+ description: string;
18
+ checked: boolean;
19
+ lineNumber: number;
20
+ fullLine: string;
21
+ }
22
+ /**
23
+ * Result of syncing AC status
24
+ */
25
+ export interface ACSyncResult {
26
+ synced: boolean;
27
+ updated: string[];
28
+ conflicts: string[];
29
+ warnings: string[];
30
+ changes: string[];
31
+ }
32
+ /**
33
+ * Validation result for AC-task mapping
34
+ */
35
+ export interface ValidationResult {
36
+ valid: boolean;
37
+ orphanedACs: string[];
38
+ invalidReferences: string[];
39
+ errors: string[];
40
+ }
41
+ /**
42
+ * AC sync event for metadata logging
43
+ */
44
+ export interface ACSyncEvent {
45
+ timestamp: string;
46
+ updated: string[];
47
+ conflicts: string[];
48
+ warnings: string[];
49
+ changesCount: number;
50
+ }
51
+ /**
52
+ * AC completion summary
53
+ */
54
+ export interface ACCompletionSummary {
55
+ totalACs: number;
56
+ completeACs: number;
57
+ incompleteACs: number;
58
+ percentage: number;
59
+ acStatuses: Map<string, ACCompletionStatus>;
60
+ }
61
+ /**
62
+ * ACStatusManager: Automatically sync spec.md AC checkboxes with tasks.md completion status
63
+ */
64
+ export declare class ACStatusManager {
65
+ private rootPath;
66
+ constructor(rootPath: string);
67
+ /**
68
+ * Parse tasks.md and extract AC completion status
69
+ *
70
+ * @param tasksContent - Content of tasks.md file
71
+ * @returns Map of AC-ID to ACCompletionStatus
72
+ */
73
+ parseTasksForACStatus(tasksContent: string): Map<string, ACCompletionStatus>;
74
+ /**
75
+ * Helper method to add a task to the AC map
76
+ */
77
+ private addTaskToACMap;
78
+ /**
79
+ * Parse spec.md and extract AC checkboxes
80
+ *
81
+ * @param specContent - Content of spec.md file
82
+ * @returns Map of AC-ID to ACDefinition
83
+ */
84
+ parseSpecForACs(specContent: string): Map<string, ACDefinition>;
85
+ /**
86
+ * Sync AC status from tasks.md to spec.md
87
+ *
88
+ * @param incrementId - Increment ID (e.g., "0039")
89
+ * @returns Result of sync operation
90
+ */
91
+ syncACStatus(incrementId: string): Promise<ACSyncResult>;
92
+ /**
93
+ * Log AC sync event to metadata.json
94
+ * Keeps last 20 events for audit trail
95
+ *
96
+ * @param incrementId - Increment ID
97
+ * @param result - Sync result to log
98
+ */
99
+ private logSyncEvent;
100
+ /**
101
+ * Validate AC-task mapping
102
+ *
103
+ * @param incrementId - Increment ID
104
+ * @returns Validation result
105
+ */
106
+ validateACMapping(incrementId: string): ValidationResult;
107
+ /**
108
+ * Get AC completion summary
109
+ *
110
+ * @param incrementId - Increment ID
111
+ * @returns Summary of AC completion status
112
+ */
113
+ getACCompletionSummary(incrementId: string): ACCompletionSummary;
114
+ }
115
+ //# sourceMappingURL=ac-status-manager.d.ts.map
@@ -0,0 +1,359 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ /**
4
+ * ACStatusManager: Automatically sync spec.md AC checkboxes with tasks.md completion status
5
+ */
6
+ export class ACStatusManager {
7
+ constructor(rootPath) {
8
+ this.rootPath = rootPath;
9
+ }
10
+ /**
11
+ * Parse tasks.md and extract AC completion status
12
+ *
13
+ * @param tasksContent - Content of tasks.md file
14
+ * @returns Map of AC-ID to ACCompletionStatus
15
+ */
16
+ parseTasksForACStatus(tasksContent) {
17
+ const acMap = new Map();
18
+ // Regex to match task headers: ### T-###: Task name
19
+ const taskHeaderRegex = /###\s+(T-\d+):/g;
20
+ // Split content by task headers
21
+ const lines = tasksContent.split('\n');
22
+ let currentTaskId = null;
23
+ let currentTaskACs = [];
24
+ let hasCheckedBoxes = false;
25
+ let hasUncheckedBoxes = false;
26
+ for (let i = 0; i < lines.length; i++) {
27
+ const line = lines[i];
28
+ // Check if this is a task header
29
+ const taskMatch = line.match(/###\s+(T-\d+):/);
30
+ if (taskMatch) {
31
+ // Process previous task if exists
32
+ if (currentTaskId && currentTaskACs.length > 0) {
33
+ // Task is complete if it has at least one [x] and no [ ]
34
+ const currentTaskComplete = hasCheckedBoxes && !hasUncheckedBoxes;
35
+ this.addTaskToACMap(acMap, currentTaskId, currentTaskACs, currentTaskComplete);
36
+ }
37
+ // Start new task
38
+ currentTaskId = taskMatch[1];
39
+ currentTaskACs = [];
40
+ hasCheckedBoxes = false;
41
+ hasUncheckedBoxes = false;
42
+ continue;
43
+ }
44
+ // Check if this line contains AC tags (supports both old and new formats)
45
+ // Old format: **AC**: AC-US1-01
46
+ // New format: **Satisfies ACs**: AC-US1-01, AC-US1-02
47
+ const acMatch = line.match(/\*\*(?:AC|Satisfies ACs)\*\*:\s*(.+)/);
48
+ if (acMatch && currentTaskId) {
49
+ // Extract AC-IDs (can be comma or space separated)
50
+ const acText = acMatch[1].trim();
51
+ const acIds = acText
52
+ .split(/[,\s]+/)
53
+ .map(id => id.trim())
54
+ .filter(id => id.startsWith('AC-'));
55
+ currentTaskACs.push(...acIds);
56
+ continue;
57
+ }
58
+ // Check task completion status
59
+ // Support BOTH formats:
60
+ // 1. List items: - [x] or - [ ]
61
+ // 2. Field format: **Status**: [x] completed (NEW - v0.23.0+)
62
+ if (currentTaskId) {
63
+ // Check for list item checkboxes
64
+ if (line.includes('- [')) {
65
+ if (line.includes('- [ ]')) {
66
+ hasUncheckedBoxes = true;
67
+ }
68
+ else if (line.includes('- [x]')) {
69
+ hasCheckedBoxes = true;
70
+ }
71
+ }
72
+ // Check for field format: **Status**: [x] completed
73
+ else if (line.match(/\*\*Status\*\*:\s*\[x\]/i)) {
74
+ hasCheckedBoxes = true;
75
+ }
76
+ // Check for field format: **Status**: [ ] pending
77
+ else if (line.match(/\*\*Status\*\*:\s*\[\s\]/i)) {
78
+ hasUncheckedBoxes = true;
79
+ }
80
+ }
81
+ }
82
+ // Process last task
83
+ if (currentTaskId && currentTaskACs.length > 0) {
84
+ const currentTaskComplete = hasCheckedBoxes && !hasUncheckedBoxes;
85
+ this.addTaskToACMap(acMap, currentTaskId, currentTaskACs, currentTaskComplete);
86
+ }
87
+ return acMap;
88
+ }
89
+ /**
90
+ * Helper method to add a task to the AC map
91
+ */
92
+ addTaskToACMap(acMap, taskId, acIds, isComplete) {
93
+ for (const acId of acIds) {
94
+ if (!acMap.has(acId)) {
95
+ acMap.set(acId, {
96
+ acId,
97
+ totalTasks: 0,
98
+ completedTasks: 0,
99
+ percentage: 0,
100
+ isComplete: false,
101
+ tasks: []
102
+ });
103
+ }
104
+ const status = acMap.get(acId);
105
+ status.totalTasks++;
106
+ if (isComplete) {
107
+ status.completedTasks++;
108
+ }
109
+ status.tasks.push(taskId);
110
+ // Calculate percentage
111
+ status.percentage = status.totalTasks > 0
112
+ ? Math.round((status.completedTasks / status.totalTasks) * 100 * 100) / 100
113
+ : 0;
114
+ // Update isComplete flag
115
+ status.isComplete = status.percentage === 100;
116
+ }
117
+ }
118
+ /**
119
+ * Parse spec.md and extract AC checkboxes
120
+ *
121
+ * @param specContent - Content of spec.md file
122
+ * @returns Map of AC-ID to ACDefinition
123
+ */
124
+ parseSpecForACs(specContent) {
125
+ const acMap = new Map();
126
+ const lines = specContent.split('\n');
127
+ for (let i = 0; i < lines.length; i++) {
128
+ const line = lines[i];
129
+ // Match AC checkbox pattern: - [ ] AC-ID: Description
130
+ // or: - [x] AC-ID: Description
131
+ // Also handles bold format: - [ ] **AC-ID**: Description
132
+ const acMatch = line.match(/^-\s+\[([ x])\]\s+\*{0,2}(AC-[A-Z0-9-]+)\*{0,2}:\s*(.+)/);
133
+ if (acMatch) {
134
+ const checked = acMatch[1] === 'x';
135
+ const acId = acMatch[2];
136
+ const description = acMatch[3].trim();
137
+ acMap.set(acId, {
138
+ acId,
139
+ description,
140
+ checked,
141
+ lineNumber: i + 1, // 1-indexed
142
+ fullLine: line
143
+ });
144
+ }
145
+ }
146
+ return acMap;
147
+ }
148
+ /**
149
+ * Sync AC status from tasks.md to spec.md
150
+ *
151
+ * @param incrementId - Increment ID (e.g., "0039")
152
+ * @returns Result of sync operation
153
+ */
154
+ async syncACStatus(incrementId) {
155
+ const result = {
156
+ synced: false,
157
+ updated: [],
158
+ conflicts: [],
159
+ warnings: [],
160
+ changes: []
161
+ };
162
+ // Paths
163
+ const incrementPath = path.join(this.rootPath, '.specweave', 'increments', incrementId);
164
+ const specPath = path.join(incrementPath, 'spec.md');
165
+ const tasksPath = path.join(incrementPath, 'tasks.md');
166
+ // Check files exist
167
+ if (!fs.existsSync(specPath)) {
168
+ result.warnings.push('spec.md does not exist');
169
+ return result;
170
+ }
171
+ if (!fs.existsSync(tasksPath)) {
172
+ result.warnings.push('tasks.md does not exist');
173
+ return result;
174
+ }
175
+ // Read files
176
+ const specContent = fs.readFileSync(specPath, 'utf-8');
177
+ const tasksContent = fs.readFileSync(tasksPath, 'utf-8');
178
+ // Parse both files
179
+ const taskACStatuses = this.parseTasksForACStatus(tasksContent);
180
+ const specACs = this.parseSpecForACs(specContent);
181
+ // Sync logic
182
+ const specLines = specContent.split('\n');
183
+ let updated = false;
184
+ for (const [acId, taskStatus] of taskACStatuses.entries()) {
185
+ const specAC = specACs.get(acId);
186
+ if (!specAC) {
187
+ result.warnings.push(`${acId} referenced in tasks.md but not found in spec.md`);
188
+ continue;
189
+ }
190
+ // Check if status should change
191
+ const shouldBeChecked = taskStatus.isComplete;
192
+ const currentlyChecked = specAC.checked;
193
+ if (shouldBeChecked && !currentlyChecked) {
194
+ // Update from [ ] to [x]
195
+ const oldLine = specLines[specAC.lineNumber - 1];
196
+ const newLine = oldLine.replace('- [ ]', '- [x]');
197
+ specLines[specAC.lineNumber - 1] = newLine;
198
+ result.updated.push(acId);
199
+ result.changes.push(`${acId}: [ ] → [x] (${taskStatus.completedTasks}/${taskStatus.totalTasks} tasks complete)`);
200
+ updated = true;
201
+ }
202
+ else if (!shouldBeChecked && currentlyChecked) {
203
+ // Conflict: AC is [x] but tasks incomplete
204
+ result.conflicts.push(`${acId}: [x] but only ${taskStatus.completedTasks}/${taskStatus.totalTasks} tasks complete (${taskStatus.percentage}%)`);
205
+ }
206
+ }
207
+ // Check for ACs with no tasks
208
+ for (const [acId, specAC] of specACs.entries()) {
209
+ if (!taskACStatuses.has(acId)) {
210
+ if (specAC.checked) {
211
+ result.warnings.push(`${acId}: [x] but no tasks found (manual verification?)`);
212
+ }
213
+ else {
214
+ result.warnings.push(`${acId}: has no tasks mapped`);
215
+ }
216
+ }
217
+ }
218
+ // Write updated spec.md
219
+ if (updated) {
220
+ const newSpecContent = specLines.join('\n');
221
+ fs.writeFileSync(specPath, newSpecContent, 'utf-8');
222
+ result.synced = true;
223
+ }
224
+ // Log sync event to metadata.json
225
+ if (result.synced || result.conflicts.length > 0 || result.warnings.length > 0) {
226
+ this.logSyncEvent(incrementId, result);
227
+ }
228
+ return result;
229
+ }
230
+ /**
231
+ * Log AC sync event to metadata.json
232
+ * Keeps last 20 events for audit trail
233
+ *
234
+ * @param incrementId - Increment ID
235
+ * @param result - Sync result to log
236
+ */
237
+ logSyncEvent(incrementId, result) {
238
+ const metadataPath = path.join(this.rootPath, '.specweave', 'increments', incrementId, 'metadata.json');
239
+ try {
240
+ // Read existing metadata
241
+ let metadata = {};
242
+ if (fs.existsSync(metadataPath)) {
243
+ const metadataContent = fs.readFileSync(metadataPath, 'utf-8');
244
+ metadata = JSON.parse(metadataContent);
245
+ }
246
+ // Initialize acSyncEvents array if doesn't exist
247
+ if (!metadata.acSyncEvents) {
248
+ metadata.acSyncEvents = [];
249
+ }
250
+ // Create new event
251
+ const event = {
252
+ timestamp: new Date().toISOString(),
253
+ updated: result.updated,
254
+ conflicts: result.conflicts,
255
+ warnings: result.warnings,
256
+ changesCount: result.updated.length
257
+ };
258
+ // Add event to beginning (newest first)
259
+ metadata.acSyncEvents.unshift(event);
260
+ // Keep only last 20 events (rolling history)
261
+ if (metadata.acSyncEvents.length > 20) {
262
+ metadata.acSyncEvents = metadata.acSyncEvents.slice(0, 20);
263
+ }
264
+ // Update lastActivity timestamp
265
+ metadata.lastActivity = new Date().toISOString();
266
+ // Write updated metadata
267
+ fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), 'utf-8');
268
+ }
269
+ catch (error) {
270
+ // Non-blocking: Log error but don't fail sync
271
+ console.error('Warning: Failed to log AC sync event to metadata.json', error);
272
+ }
273
+ }
274
+ /**
275
+ * Validate AC-task mapping
276
+ *
277
+ * @param incrementId - Increment ID
278
+ * @returns Validation result
279
+ */
280
+ validateACMapping(incrementId) {
281
+ const result = {
282
+ valid: true,
283
+ orphanedACs: [],
284
+ invalidReferences: [],
285
+ errors: []
286
+ };
287
+ const incrementPath = path.join(this.rootPath, '.specweave', 'increments', incrementId);
288
+ const specPath = path.join(incrementPath, 'spec.md');
289
+ const tasksPath = path.join(incrementPath, 'tasks.md');
290
+ // Check files exist
291
+ if (!fs.existsSync(specPath)) {
292
+ result.errors.push('spec.md does not exist');
293
+ result.valid = false;
294
+ return result;
295
+ }
296
+ if (!fs.existsSync(tasksPath)) {
297
+ result.errors.push('tasks.md does not exist');
298
+ result.valid = false;
299
+ return result;
300
+ }
301
+ // Read and parse
302
+ const specContent = fs.readFileSync(specPath, 'utf-8');
303
+ const tasksContent = fs.readFileSync(tasksPath, 'utf-8');
304
+ const taskACStatuses = this.parseTasksForACStatus(tasksContent);
305
+ const specACs = this.parseSpecForACs(specContent);
306
+ // Find orphaned ACs (in spec but no tasks)
307
+ for (const acId of specACs.keys()) {
308
+ if (!taskACStatuses.has(acId)) {
309
+ result.orphanedACs.push(acId);
310
+ result.valid = false;
311
+ }
312
+ }
313
+ // Find invalid references (in tasks but not in spec)
314
+ for (const acId of taskACStatuses.keys()) {
315
+ if (!specACs.has(acId)) {
316
+ result.invalidReferences.push(acId);
317
+ result.valid = false;
318
+ }
319
+ }
320
+ return result;
321
+ }
322
+ /**
323
+ * Get AC completion summary
324
+ *
325
+ * @param incrementId - Increment ID
326
+ * @returns Summary of AC completion status
327
+ */
328
+ getACCompletionSummary(incrementId) {
329
+ const incrementPath = path.join(this.rootPath, '.specweave', 'increments', incrementId);
330
+ const tasksPath = path.join(incrementPath, 'tasks.md');
331
+ const summary = {
332
+ totalACs: 0,
333
+ completeACs: 0,
334
+ incompleteACs: 0,
335
+ percentage: 0,
336
+ acStatuses: new Map()
337
+ };
338
+ if (!fs.existsSync(tasksPath)) {
339
+ return summary;
340
+ }
341
+ const tasksContent = fs.readFileSync(tasksPath, 'utf-8');
342
+ const acStatuses = this.parseTasksForACStatus(tasksContent);
343
+ summary.acStatuses = acStatuses;
344
+ summary.totalACs = acStatuses.size;
345
+ for (const status of acStatuses.values()) {
346
+ if (status.isComplete) {
347
+ summary.completeACs++;
348
+ }
349
+ else {
350
+ summary.incompleteACs++;
351
+ }
352
+ }
353
+ summary.percentage = summary.totalACs > 0
354
+ ? Math.round((summary.completeACs / summary.totalACs) * 100)
355
+ : 0;
356
+ return summary;
357
+ }
358
+ }
359
+ //# sourceMappingURL=ac-status-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ac-status-manager.js","sourceRoot":"","sources":["../../../../src/core/increment/ac-status-manager.ts"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B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,QAAQ,GAAG,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;YAC5D,CAAC,CAAC,CAAC,CAAC;QAEN,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Active Increment Manager
3
+ *
4
+ * Manages the `.specweave/state/active-increment.json` file which tracks
5
+ * the currently active increment for status line display.
6
+ *
7
+ * **Critical**: This file MUST be updated whenever increment status changes:
8
+ * - When new increment is created → Set as active
9
+ * - When increment is completed → Clear or set to next active
10
+ * - When increment is paused → Set to next active (or clear if none)
11
+ * - When increment is resumed → Set as active
12
+ *
13
+ * Part of increment 0021: Fix Active Increment Tracking
14
+ */
15
+ /**
16
+ * Active increment state stored in .specweave/state/active-increment.json
17
+ *
18
+ * **UPGRADED**: Now supports MULTIPLE active increments (up to 2)
19
+ * - One regular feature increment
20
+ * - One hotfix/bug increment (optional)
21
+ */
22
+ export interface ActiveIncrementState {
23
+ ids: string[];
24
+ id?: string | null;
25
+ lastUpdated: string;
26
+ }
27
+ /**
28
+ * Active Increment Manager
29
+ *
30
+ * Central authority for managing which increment is currently active.
31
+ */
32
+ export declare class ActiveIncrementManager {
33
+ private rootDir;
34
+ private stateFile;
35
+ constructor(rootDir?: string);
36
+ /**
37
+ * Get all currently active increment IDs
38
+ * Returns empty array if no increments are active
39
+ *
40
+ * **NEW**: Returns array of ALL active increments (max 2)
41
+ */
42
+ getActive(): string[];
43
+ /**
44
+ * Get the primary active increment (first in list)
45
+ * Returns null if no increments are active
46
+ *
47
+ * This maintains backwards compatibility with code expecting a single ID
48
+ */
49
+ getPrimary(): string | null;
50
+ /**
51
+ * Add an increment to the active list
52
+ * Validates that the increment exists and is actually active
53
+ *
54
+ * **NEW**: Adds to list instead of replacing (max 2)
55
+ * @param skipValidation - Skip validation (used during lazy initialization to prevent circular dependency)
56
+ */
57
+ addActive(incrementId: string, skipValidation?: boolean): void;
58
+ /**
59
+ * Remove an increment from the active list
60
+ */
61
+ removeActive(incrementId: string): void;
62
+ /**
63
+ * Set the active increment (legacy method for backwards compatibility)
64
+ * Now delegates to addActive()
65
+ * @param skipValidation - Skip validation (used during lazy initialization to prevent circular dependency)
66
+ */
67
+ setActive(incrementId: string, skipValidation?: boolean): void;
68
+ /**
69
+ * Clear all active increments
70
+ */
71
+ clearActive(): void;
72
+ /**
73
+ * Smart update: Rebuild active list from metadata
74
+ *
75
+ * This is called when:
76
+ * - An increment is completed
77
+ * - An increment is paused
78
+ * - An increment is abandoned
79
+ *
80
+ * Logic:
81
+ * 1. Scan all increments for status=active
82
+ * 2. Update cache to match reality
83
+ * 3. Max 2 increments (sorted by lastActivity)
84
+ */
85
+ smartUpdate(): void;
86
+ /**
87
+ * Validate that all active increment pointers are correct
88
+ * Does NOT fix stale pointers - caller should call smartUpdate() if needed
89
+ *
90
+ * Returns true if all valid, false if any invalid
91
+ */
92
+ validate(): boolean;
93
+ /**
94
+ * Validate and auto-repair the active increment state
95
+ *
96
+ * This is the recommended method to call on startup to ensure
97
+ * the active-increment.json is in sync with metadata.json files.
98
+ *
99
+ * Part of 0168: Status Single Source of Truth
100
+ *
101
+ * @returns Object with validation result and any repairs made
102
+ */
103
+ validateAndRepair(): {
104
+ valid: boolean;
105
+ repaired: boolean;
106
+ details: string[];
107
+ };
108
+ /**
109
+ * Write state file atomically (temp file → rename)
110
+ */
111
+ private writeState;
112
+ /**
113
+ * Get state file path (for testing)
114
+ */
115
+ getStateFilePath(): string;
116
+ /**
117
+ * Check if state file exists (for testing)
118
+ */
119
+ exists(): boolean;
120
+ }
121
+ //# sourceMappingURL=active-increment-manager.d.ts.map