specweave 1.0.372 → 1.0.374

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 (32) hide show
  1. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.d.ts +5 -0
  2. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.d.ts.map +1 -1
  3. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.js +25 -9
  4. package/dist/plugins/specweave-github/lib/github-ac-checkbox-sync.js.map +1 -1
  5. package/dist/plugins/specweave-github/lib/github-ac-comment-poster.js +31 -5
  6. package/dist/plugins/specweave-github/lib/github-ac-comment-poster.js.map +1 -1
  7. package/dist/src/core/ac-progress-sync.d.ts +17 -0
  8. package/dist/src/core/ac-progress-sync.d.ts.map +1 -1
  9. package/dist/src/core/ac-progress-sync.js +42 -7
  10. package/dist/src/core/ac-progress-sync.js.map +1 -1
  11. package/dist/src/core/increment/template-creator.d.ts +2 -2
  12. package/dist/src/core/increment/template-creator.d.ts.map +1 -1
  13. package/dist/src/core/increment/template-creator.js +3 -3
  14. package/dist/src/core/increment/template-creator.js.map +1 -1
  15. package/dist/src/core/specs/spec-metadata-manager.d.ts +3 -1
  16. package/dist/src/core/specs/spec-metadata-manager.d.ts.map +1 -1
  17. package/dist/src/core/specs/spec-metadata-manager.js +8 -2
  18. package/dist/src/core/specs/spec-metadata-manager.js.map +1 -1
  19. package/dist/src/core/universal-auto-create.js +1 -1
  20. package/dist/src/core/universal-auto-create.js.map +1 -1
  21. package/dist/src/sync/external-issue-auto-creator.js +3 -3
  22. package/dist/src/sync/external-issue-auto-creator.js.map +1 -1
  23. package/dist/src/sync/sync-coordinator.d.ts.map +1 -1
  24. package/dist/src/sync/sync-coordinator.js +26 -1
  25. package/dist/src/sync/sync-coordinator.js.map +1 -1
  26. package/package.json +1 -1
  27. package/plugins/specweave/lib/vendor/core/universal-auto-create.js +1 -1
  28. package/plugins/specweave/lib/vendor/core/universal-auto-create.js.map +1 -1
  29. package/plugins/specweave-github/lib/github-ac-checkbox-sync.js +22 -9
  30. package/plugins/specweave-github/lib/github-ac-checkbox-sync.ts +26 -9
  31. package/plugins/specweave-github/lib/github-ac-comment-poster.js +20 -3
  32. package/plugins/specweave-github/lib/github-ac-comment-poster.ts +33 -5
@@ -89,17 +89,34 @@ async function parseIssueLinks(specPath) {
89
89
  }
90
90
  return links;
91
91
  }
92
+ function parseUSIdParts(usId) {
93
+ const compoundMatch = usId.match(/^US-([A-Z]+)-(\d+)$/);
94
+ if (compoundMatch) {
95
+ return { prefix: compoundMatch[1], num: parseInt(compoundMatch[2], 10) };
96
+ }
97
+ const simpleMatch = usId.match(/^US-(\d+)$/);
98
+ if (simpleMatch) {
99
+ return { num: parseInt(simpleMatch[1], 10) };
100
+ }
101
+ const fallback = usId.match(/(\d+)$/);
102
+ return { num: fallback ? parseInt(fallback[1], 10) : 0 };
103
+ }
104
+ function buildACPrefix(usId) {
105
+ const { prefix, num } = parseUSIdParts(usId);
106
+ return prefix ? `AC-${prefix}-US${num}-` : `AC-US${num}-`;
107
+ }
92
108
  function parseACStatesForUS(content, usId) {
93
109
  const states = [];
94
- const usNum = String(parseInt(usId.replace("US-", ""), 10));
110
+ const acPrefix = buildACPrefix(usId);
111
+ const escapedPrefix = acPrefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
95
112
  const acPattern = new RegExp(
96
- `- \\[([ x])\\] (?:\\*\\*)?AC-US${usNum}-(\\d+)(?:\\*\\*)?:\\s*(.+)`,
113
+ `- \\[([ x])\\] (?:\\*\\*)?${escapedPrefix}(\\d+)(?:\\*\\*)?:\\s*(.+)`,
97
114
  "g"
98
115
  );
99
116
  let match;
100
117
  while ((match = acPattern.exec(content)) !== null) {
101
118
  states.push({
102
- id: `AC-US${usNum}-${match[2]}`,
119
+ id: `${acPrefix}${match[2]}`,
103
120
  description: match[3].trim(),
104
121
  completed: match[1] === "x"
105
122
  });
@@ -174,24 +174,52 @@ async function parseIssueLinks(specPath: string): Promise<Record<string, ParsedU
174
174
  return links;
175
175
  }
176
176
 
177
+ /**
178
+ * Parse a US ID into parts for AC matching.
179
+ * US-001 → { prefix: undefined, num: 1 }
180
+ * US-SPE-001 → { prefix: 'SPE', num: 1 }
181
+ */
182
+ function parseUSIdParts(usId: string): { prefix?: string; num: number } {
183
+ const compoundMatch = usId.match(/^US-([A-Z]+)-(\d+)$/);
184
+ if (compoundMatch) {
185
+ return { prefix: compoundMatch[1], num: parseInt(compoundMatch[2], 10) };
186
+ }
187
+ const simpleMatch = usId.match(/^US-(\d+)$/);
188
+ if (simpleMatch) {
189
+ return { num: parseInt(simpleMatch[1], 10) };
190
+ }
191
+ const fallback = usId.match(/(\d+)$/);
192
+ return { num: fallback ? parseInt(fallback[1], 10) : 0 };
193
+ }
194
+
195
+ /**
196
+ * Build the AC ID prefix for a given US ID.
197
+ * US-001 → "AC-US1-", US-SPE-001 → "AC-SPE-US1-"
198
+ */
199
+ function buildACPrefix(usId: string): string {
200
+ const { prefix, num } = parseUSIdParts(usId);
201
+ return prefix ? `AC-${prefix}-US${num}-` : `AC-US${num}-`;
202
+ }
203
+
177
204
  /**
178
205
  * Extract AC states for a specific user story from spec.md content.
206
+ * Supports both simple (AC-US1-01) and compound (AC-SPE-US1-01) AC ID formats.
179
207
  */
180
208
  function parseACStatesForUS(content: string, usId: string): ParsedACState[] {
181
209
  const states: ParsedACState[] = [];
182
- // AC IDs use unpadded US number: US-001 → AC-US1-XX
183
- const usNum = String(parseInt(usId.replace('US-', ''), 10));
210
+ const acPrefix = buildACPrefix(usId);
211
+ const escapedPrefix = acPrefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
184
212
 
185
- // Support both bold (**AC-US1-01**:) and plain (AC-US1-01:) formats
213
+ // Support both bold (**AC-...**:) and plain (AC-...:) formats
186
214
  const acPattern = new RegExp(
187
- `- \\[([ x])\\] (?:\\*\\*)?AC-US${usNum}-(\\d+)(?:\\*\\*)?:\\s*(.+)`,
215
+ `- \\[([ x])\\] (?:\\*\\*)?${escapedPrefix}(\\d+)(?:\\*\\*)?:\\s*(.+)`,
188
216
  'g',
189
217
  );
190
218
 
191
219
  let match;
192
220
  while ((match = acPattern.exec(content)) !== null) {
193
221
  states.push({
194
- id: `AC-US${usNum}-${match[2]}`,
222
+ id: `${acPrefix}${match[2]}`,
195
223
  description: match[3].trim(),
196
224
  completed: match[1] === 'x',
197
225
  });