specweave 0.17.15 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/CLAUDE.md +405 -2495
  2. package/README.md +92 -2
  3. package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts.map +1 -1
  4. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js +188 -36
  5. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js.map +1 -1
  6. package/dist/plugins/specweave-ado/lib/ado-status-sync.d.ts +54 -0
  7. package/dist/plugins/specweave-ado/lib/ado-status-sync.d.ts.map +1 -0
  8. package/dist/plugins/specweave-ado/lib/ado-status-sync.js +86 -0
  9. package/dist/plugins/specweave-ado/lib/ado-status-sync.js.map +1 -0
  10. package/dist/plugins/specweave-github/lib/duplicate-detector.d.ts +139 -0
  11. package/dist/plugins/specweave-github/lib/duplicate-detector.d.ts.map +1 -0
  12. package/dist/plugins/specweave-github/lib/duplicate-detector.js +389 -0
  13. package/dist/plugins/specweave-github/lib/duplicate-detector.js.map +1 -0
  14. package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts +26 -0
  15. package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts.map +1 -0
  16. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js +249 -0
  17. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js.map +1 -0
  18. package/dist/plugins/specweave-github/lib/github-client.d.ts +1 -1
  19. package/dist/plugins/specweave-github/lib/github-client.d.ts.map +1 -1
  20. package/dist/plugins/specweave-github/lib/github-client.js +25 -13
  21. package/dist/plugins/specweave-github/lib/github-client.js.map +1 -1
  22. package/dist/plugins/specweave-github/lib/github-epic-sync.d.ts +83 -0
  23. package/dist/plugins/specweave-github/lib/github-epic-sync.d.ts.map +1 -0
  24. package/dist/plugins/specweave-github/lib/github-epic-sync.js +451 -0
  25. package/dist/plugins/specweave-github/lib/github-epic-sync.js.map +1 -0
  26. package/dist/plugins/specweave-github/lib/github-status-sync.d.ts +43 -0
  27. package/dist/plugins/specweave-github/lib/github-status-sync.d.ts.map +1 -0
  28. package/dist/plugins/specweave-github/lib/github-status-sync.js +82 -0
  29. package/dist/plugins/specweave-github/lib/github-status-sync.js.map +1 -0
  30. package/dist/plugins/specweave-github/lib/task-sync.d.ts +5 -0
  31. package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
  32. package/dist/plugins/specweave-github/lib/task-sync.js +38 -2
  33. package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
  34. package/dist/plugins/specweave-jira/lib/jira-epic-sync.d.ts +66 -0
  35. package/dist/plugins/specweave-jira/lib/jira-epic-sync.d.ts.map +1 -0
  36. package/dist/plugins/specweave-jira/lib/jira-epic-sync.js +274 -0
  37. package/dist/plugins/specweave-jira/lib/jira-epic-sync.js.map +1 -0
  38. package/dist/plugins/specweave-jira/lib/jira-status-sync.d.ts +56 -0
  39. package/dist/plugins/specweave-jira/lib/jira-status-sync.d.ts.map +1 -0
  40. package/dist/plugins/specweave-jira/lib/jira-status-sync.js +93 -0
  41. package/dist/plugins/specweave-jira/lib/jira-status-sync.js.map +1 -0
  42. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  43. package/dist/src/cli/helpers/issue-tracker/index.js +48 -3
  44. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  45. package/dist/src/core/living-docs/hierarchy-mapper.d.ts +142 -0
  46. package/dist/src/core/living-docs/hierarchy-mapper.d.ts.map +1 -0
  47. package/dist/src/core/living-docs/hierarchy-mapper.js +453 -0
  48. package/dist/src/core/living-docs/hierarchy-mapper.js.map +1 -0
  49. package/dist/src/core/living-docs/index.d.ts +10 -84
  50. package/dist/src/core/living-docs/index.d.ts.map +1 -1
  51. package/dist/src/core/living-docs/index.js +10 -164
  52. package/dist/src/core/living-docs/index.js.map +1 -1
  53. package/dist/src/core/living-docs/spec-distributor.d.ts +106 -0
  54. package/dist/src/core/living-docs/spec-distributor.d.ts.map +1 -0
  55. package/dist/src/core/living-docs/spec-distributor.js +823 -0
  56. package/dist/src/core/living-docs/spec-distributor.js.map +1 -0
  57. package/dist/src/core/living-docs/types.d.ts +201 -0
  58. package/dist/src/core/living-docs/types.d.ts.map +1 -0
  59. package/dist/src/core/living-docs/types.js +15 -0
  60. package/dist/src/core/living-docs/types.js.map +1 -0
  61. package/dist/src/core/logging/prompt-logger.d.ts +70 -0
  62. package/dist/src/core/logging/prompt-logger.d.ts.map +1 -0
  63. package/dist/src/core/logging/prompt-logger.js +247 -0
  64. package/dist/src/core/logging/prompt-logger.js.map +1 -0
  65. package/dist/src/core/status-line/status-line-manager.d.ts +15 -24
  66. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  67. package/dist/src/core/status-line/status-line-manager.js +33 -70
  68. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  69. package/dist/src/core/status-line/types.d.ts +19 -31
  70. package/dist/src/core/status-line/types.d.ts.map +1 -1
  71. package/dist/src/core/status-line/types.js +5 -9
  72. package/dist/src/core/status-line/types.js.map +1 -1
  73. package/dist/src/core/sync/conflict-resolver.d.ts +66 -0
  74. package/dist/src/core/sync/conflict-resolver.d.ts.map +1 -0
  75. package/dist/src/core/sync/conflict-resolver.js +108 -0
  76. package/dist/src/core/sync/conflict-resolver.js.map +1 -0
  77. package/dist/src/core/sync/enhanced-content-builder.d.ts +77 -0
  78. package/dist/src/core/sync/enhanced-content-builder.d.ts.map +1 -0
  79. package/dist/src/core/sync/enhanced-content-builder.js +199 -0
  80. package/dist/src/core/sync/enhanced-content-builder.js.map +1 -0
  81. package/dist/src/core/sync/label-detector.d.ts +66 -0
  82. package/dist/src/core/sync/label-detector.d.ts.map +1 -0
  83. package/dist/src/core/sync/label-detector.js +211 -0
  84. package/dist/src/core/sync/label-detector.js.map +1 -0
  85. package/dist/src/core/sync/retry-logic.d.ts +64 -0
  86. package/dist/src/core/sync/retry-logic.d.ts.map +1 -0
  87. package/dist/src/core/sync/retry-logic.js +165 -0
  88. package/dist/src/core/sync/retry-logic.js.map +1 -0
  89. package/dist/src/core/sync/spec-increment-mapper.d.ts +100 -0
  90. package/dist/src/core/sync/spec-increment-mapper.d.ts.map +1 -0
  91. package/dist/src/core/sync/spec-increment-mapper.js +424 -0
  92. package/dist/src/core/sync/spec-increment-mapper.js.map +1 -0
  93. package/dist/src/core/sync/status-cache.d.ts +91 -0
  94. package/dist/src/core/sync/status-cache.d.ts.map +1 -0
  95. package/dist/src/core/sync/status-cache.js +140 -0
  96. package/dist/src/core/sync/status-cache.js.map +1 -0
  97. package/dist/src/core/sync/status-mapper.d.ts +69 -0
  98. package/dist/src/core/sync/status-mapper.d.ts.map +1 -0
  99. package/dist/src/core/sync/status-mapper.js +90 -0
  100. package/dist/src/core/sync/status-mapper.js.map +1 -0
  101. package/dist/src/core/sync/status-sync-engine.d.ts +162 -0
  102. package/dist/src/core/sync/status-sync-engine.d.ts.map +1 -0
  103. package/dist/src/core/sync/status-sync-engine.js +347 -0
  104. package/dist/src/core/sync/status-sync-engine.js.map +1 -0
  105. package/dist/src/core/sync/sync-event-logger.d.ts +99 -0
  106. package/dist/src/core/sync/sync-event-logger.d.ts.map +1 -0
  107. package/dist/src/core/sync/sync-event-logger.js +103 -0
  108. package/dist/src/core/sync/sync-event-logger.js.map +1 -0
  109. package/dist/src/core/sync/workflow-detector.d.ts +95 -0
  110. package/dist/src/core/sync/workflow-detector.d.ts.map +1 -0
  111. package/dist/src/core/sync/workflow-detector.js +175 -0
  112. package/dist/src/core/sync/workflow-detector.js.map +1 -0
  113. package/dist/src/core/types/config.d.ts.map +1 -1
  114. package/dist/src/core/types/config.js +31 -0
  115. package/dist/src/core/types/config.js.map +1 -1
  116. package/dist/src/utils/github-url.d.ts +53 -0
  117. package/dist/src/utils/github-url.d.ts.map +1 -0
  118. package/dist/src/utils/github-url.js +90 -0
  119. package/dist/src/utils/github-url.js.map +1 -0
  120. package/dist/src/utils/plugin-validator.d.ts +9 -0
  121. package/dist/src/utils/plugin-validator.d.ts.map +1 -1
  122. package/dist/src/utils/plugin-validator.js +86 -19
  123. package/dist/src/utils/plugin-validator.js.map +1 -1
  124. package/dist/src/utils/spec-parser.d.ts +145 -0
  125. package/dist/src/utils/spec-parser.d.ts.map +1 -0
  126. package/dist/src/utils/spec-parser.js +640 -0
  127. package/dist/src/utils/spec-parser.js.map +1 -0
  128. package/package.json +1 -1
  129. package/plugins/specweave/agents/pm/AGENT.md +1 -1
  130. package/plugins/specweave/agents/pm/templates/increment-spec.md +158 -0
  131. package/plugins/specweave/agents/pm/templates/living-docs-spec.md +113 -0
  132. package/plugins/specweave/commands/specweave-done.md +163 -0
  133. package/plugins/specweave/hooks/lib/update-status-line.sh +79 -111
  134. package/plugins/specweave/hooks/post-increment-planning.sh +107 -35
  135. package/plugins/specweave/lib/hooks/sync-living-docs.js +139 -34
  136. package/plugins/specweave/lib/hooks/sync-living-docs.ts +234 -38
  137. package/plugins/specweave/skills/SKILLS-INDEX.md +4 -24
  138. package/plugins/specweave/skills/increment-planner/SKILL.md +94 -0
  139. package/plugins/specweave/skills/increment-work-router/SKILL.md +466 -0
  140. package/plugins/specweave/skills/plugin-validator/SKILL.md +16 -13
  141. package/plugins/specweave-ado/lib/ado-status-sync.js +80 -0
  142. package/plugins/specweave-ado/lib/ado-status-sync.ts +121 -0
  143. package/plugins/specweave-github/commands/specweave-github-cleanup-duplicates.md +205 -0
  144. package/plugins/specweave-github/commands/specweave-github-sync-epic.md +248 -0
  145. package/plugins/specweave-github/lib/duplicate-detector.js +370 -0
  146. package/plugins/specweave-github/lib/duplicate-detector.ts +525 -0
  147. package/plugins/specweave-github/lib/enhanced-github-sync.js +220 -0
  148. package/plugins/specweave-github/lib/enhanced-github-sync.ts +322 -0
  149. package/plugins/specweave-github/lib/github-client.js +21 -10
  150. package/plugins/specweave-github/lib/github-client.ts +27 -16
  151. package/plugins/specweave-github/lib/github-epic-sync.js +489 -0
  152. package/plugins/specweave-github/lib/github-epic-sync.ts +690 -0
  153. package/plugins/specweave-github/lib/github-status-sync.js +71 -0
  154. package/plugins/specweave-github/lib/github-status-sync.ts +107 -0
  155. package/plugins/specweave-github/lib/task-sync.js +33 -2
  156. package/plugins/specweave-github/lib/task-sync.ts +44 -2
  157. package/plugins/specweave-jira/commands/specweave-jira-sync-epic.md +267 -0
  158. package/plugins/specweave-jira/lib/enhanced-jira-sync.ts.disabled +222 -0
  159. package/plugins/specweave-jira/lib/jira-epic-sync.js +304 -0
  160. package/plugins/specweave-jira/lib/jira-epic-sync.ts +459 -0
  161. package/plugins/specweave-jira/lib/jira-status-sync.js +79 -0
  162. package/plugins/specweave-jira/lib/jira-status-sync.ts +139 -0
  163. package/src/templates/AGENTS.md.template +88 -1
  164. package/src/templates/CLAUDE.md.template +49 -0
  165. package/plugins/specweave/skills/increment-quality-judge/SKILL.md +0 -524
  166. package/plugins/specweave/skills/plugin-installer/SKILL.md +0 -353
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Azure DevOps Status Sync
3
+ *
4
+ * Synchronizes SpecWeave increment statuses with ADO work item states.
5
+ *
6
+ * ADO Work Item State Updates:
7
+ * - Uses JSON Patch format for updates
8
+ * - System.State field controls work item state
9
+ * - Available states: New, Active, On Hold, Resolved, Closed, Removed
10
+ *
11
+ * @module ado-status-sync
12
+ */
13
+
14
+ import axios, { AxiosInstance } from 'axios';
15
+
16
+ /**
17
+ * External status representation (ADO-specific)
18
+ */
19
+ export interface ExternalStatus {
20
+ state: string; // e.g., "New", "Active", "Closed"
21
+ }
22
+
23
+ /**
24
+ * Azure DevOps Status Sync
25
+ *
26
+ * Handles status synchronization with ADO work items.
27
+ */
28
+ export class AdoStatusSync {
29
+ private client: AxiosInstance;
30
+ private organization: string;
31
+ private project: string;
32
+
33
+ constructor(
34
+ organization: string,
35
+ project: string,
36
+ personalAccessToken: string
37
+ ) {
38
+ this.organization = organization;
39
+ this.project = project;
40
+
41
+ // Create ADO API client
42
+ this.client = axios.create({
43
+ baseURL: `https://dev.azure.com/${organization}/${project}/_apis`,
44
+ auth: {
45
+ username: '', // Empty for PAT auth
46
+ password: personalAccessToken
47
+ },
48
+ headers: {
49
+ 'Content-Type': 'application/json-patch+json',
50
+ 'Accept': 'application/json'
51
+ }
52
+ });
53
+ }
54
+
55
+ /**
56
+ * Get current status from ADO work item
57
+ *
58
+ * @param workItemId - ADO work item ID (e.g., 123)
59
+ * @returns Current work item state
60
+ */
61
+ async getStatus(workItemId: number): Promise<ExternalStatus> {
62
+ const response = await this.client.get(
63
+ `/wit/workitems/${workItemId}?api-version=7.0`
64
+ );
65
+
66
+ return {
67
+ state: response.data.fields['System.State']
68
+ };
69
+ }
70
+
71
+ /**
72
+ * Update ADO work item state
73
+ *
74
+ * Uses JSON Patch format to update System.State field.
75
+ *
76
+ * @param workItemId - ADO work item ID (e.g., 123)
77
+ * @param status - Desired status
78
+ */
79
+ async updateStatus(workItemId: number, status: ExternalStatus): Promise<void> {
80
+ // ADO uses JSON Patch format for updates
81
+ const patch = [
82
+ {
83
+ op: 'add',
84
+ path: '/fields/System.State',
85
+ value: status.state
86
+ }
87
+ ];
88
+
89
+ await this.client.patch(
90
+ `/wit/workitems/${workItemId}?api-version=7.0`,
91
+ patch
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Post comment about status change to ADO work item
97
+ *
98
+ * @param workItemId - ADO work item ID (e.g., 123)
99
+ * @param oldStatus - Previous SpecWeave status
100
+ * @param newStatus - New SpecWeave status
101
+ */
102
+ async postStatusComment(
103
+ workItemId: number,
104
+ oldStatus: string,
105
+ newStatus: string
106
+ ): Promise<void> {
107
+ const text = `🔄 Status Update\n\n` +
108
+ `SpecWeave status changed:\n` +
109
+ `• From: ${oldStatus}\n` +
110
+ `• To: ${newStatus}\n` +
111
+ `• When: ${new Date().toISOString()}\n\n` +
112
+ `Synced from SpecWeave`;
113
+
114
+ await this.client.post(
115
+ `/wit/workitems/${workItemId}/comments?api-version=7.0-preview.3`,
116
+ {
117
+ text
118
+ }
119
+ );
120
+ }
121
+ }
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: specweave-github-cleanup-duplicates
3
+ description: Clean up duplicate GitHub issues for an Epic. Finds issues with duplicate titles and closes all except the first created issue.
4
+ ---
5
+
6
+ # Clean Up Duplicate GitHub Issues
7
+
8
+ **CRITICAL**: This command detects and closes duplicate GitHub issues created by multiple syncs.
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ /specweave-github:cleanup-duplicates <epic-id> [--dry-run]
14
+ ```
15
+
16
+ ## What It Does
17
+
18
+ **Duplicate Detection & Cleanup**:
19
+
20
+ 1. **Find all issues** for the Epic (searches by Epic ID in title)
21
+ 2. **Group by title** (detect duplicates)
22
+ 3. **For each duplicate group**:
23
+ - Keep the **FIRST created** issue (lowest number)
24
+ - Close all **LATER** issues with comment: "Duplicate of #XXX"
25
+ 4. **Update Epic README** with correct issue numbers
26
+
27
+ ## Examples
28
+
29
+ ### Dry Run (No Changes)
30
+
31
+ ```bash
32
+ /specweave-github:cleanup-duplicates FS-031 --dry-run
33
+ ```
34
+
35
+ **Output**:
36
+ ```
37
+ 🔍 Scanning for duplicates in Epic FS-031...
38
+ Found 25 total issues
39
+ Detected 10 duplicate groups:
40
+
41
+ 📋 Group 1: "[FS-031] External Tool Status Synchronization"
42
+ - #250 (KEEP) - Created 2025-11-10
43
+ - #255 (CLOSE) - Created 2025-11-11 - DUPLICATE
44
+ - #260 (CLOSE) - Created 2025-11-12 - DUPLICATE
45
+
46
+ 📋 Group 2: "[FS-031] Multi-Project GitHub Sync"
47
+ - #251 (KEEP) - Created 2025-11-10
48
+ - #256 (CLOSE) - Created 2025-11-11 - DUPLICATE
49
+
50
+ ...
51
+
52
+ ✅ Dry run complete!
53
+ Total issues: 25
54
+ Duplicate groups: 10
55
+ Issues to close: 15
56
+
57
+ ⚠️ This was a DRY RUN - no changes made.
58
+ Run without --dry-run to actually close duplicates.
59
+ ```
60
+
61
+ ### Actual Cleanup
62
+
63
+ ```bash
64
+ /specweave-github:cleanup-duplicates FS-031
65
+ ```
66
+
67
+ **Output**:
68
+ ```
69
+ 🔍 Scanning for duplicates in Epic FS-031...
70
+ Found 25 total issues
71
+ Detected 10 duplicate groups
72
+
73
+ ⚠️ CONFIRM: Close 15 duplicate issues? [y/N]
74
+ > y
75
+
76
+ 🗑️ Closing duplicates...
77
+ ✅ Closed #255 (duplicate of #250)
78
+ ✅ Closed #256 (duplicate of #251)
79
+ ✅ Closed #260 (duplicate of #250)
80
+ ...
81
+
82
+ 📝 Updating Epic README frontmatter...
83
+ ✅ Updated frontmatter with correct issue numbers
84
+
85
+ ✅ Cleanup complete!
86
+ Closed: 15 duplicates
87
+ Kept: 10 original issues
88
+ ```
89
+
90
+ ## Arguments
91
+
92
+ - `<epic-id>` - Epic ID (e.g., `FS-031` or just `031`)
93
+ - `--dry-run` - Preview changes without actually closing issues (optional)
94
+
95
+ ## Safety Features
96
+
97
+ ✅ **Confirmation prompt**: Asks before closing issues (unless --dry-run)
98
+ ✅ **Dry run mode**: Preview changes safely
99
+ ✅ **Keeps oldest issue**: Preserves the first created issue
100
+ ✅ **Adds closure comment**: Links to the original issue
101
+ ✅ **Updates metadata**: Fixes Epic README frontmatter
102
+
103
+ ## What Gets Closed
104
+
105
+ **Closed issues**:
106
+ - ✅ Duplicate titles (second, third, etc. occurrences)
107
+ - ✅ Closed with comment: "Duplicate of #XXX"
108
+ - ✅ Original issue kept open (or maintains its status)
109
+
110
+ **Example comment on closed duplicate**:
111
+ ```markdown
112
+ Duplicate of #250
113
+
114
+ This issue was automatically closed by SpecWeave cleanup because it is a duplicate.
115
+
116
+ The original issue (#250) contains the same content and should be used for tracking instead.
117
+
118
+ 🤖 Auto-closed by SpecWeave Duplicate Cleanup
119
+ ```
120
+
121
+ ## Requirements
122
+
123
+ 1. **GitHub CLI** (`gh`) installed and authenticated
124
+ 2. **Write access** to repository (for closing issues)
125
+ 3. **Epic folder exists** at `.specweave/docs/internal/specs/FS-XXX-name/`
126
+
127
+ ## When to Use
128
+
129
+ **Use this command when**:
130
+ - ✅ You see multiple issues with the same title in GitHub
131
+ - ✅ Epic sync ran multiple times and created duplicates
132
+ - ✅ Epic README frontmatter got corrupted and reset
133
+ - ✅ Post-sync validation warns about duplicates
134
+
135
+ **Example warning that triggers this**:
136
+ ```
137
+ ⚠️ WARNING: 10 duplicate(s) detected!
138
+ Run cleanup command to resolve:
139
+ /specweave-github:cleanup-duplicates FS-031
140
+ ```
141
+
142
+ ## Troubleshooting
143
+
144
+ **"No duplicates found"**:
145
+ - Good! Your Epic has no duplicate issues
146
+ - Run epic sync is working correctly with duplicate detection
147
+
148
+ **"GitHub CLI not authenticated"**:
149
+ - Run: `gh auth login`
150
+ - Ensure you have write access to the repository
151
+
152
+ **"Could not find Epic folder"**:
153
+ - Check Epic exists: `ls .specweave/docs/internal/specs/`
154
+ - Verify Epic ID format: `FS-031-epic-name/`
155
+
156
+ **"Error closing issue"**:
157
+ - Check GitHub CLI: `gh auth status`
158
+ - Verify write permissions: `gh repo view`
159
+
160
+ ## Architecture
161
+
162
+ **Duplicate Detection Logic**:
163
+ 1. Group issues by **exact title match**
164
+ 2. Within each group, sort by **issue number** (ascending)
165
+ 3. Keep **first issue** (lowest number = oldest)
166
+ 4. Close **all others** as duplicates
167
+
168
+ **Why lowest number?**:
169
+ - Lower issue numbers were created first
170
+ - Preserves chronological order
171
+ - Maintains links from old documentation
172
+
173
+ ## Related Commands
174
+
175
+ - `/specweave-github:sync-epic` - Sync Epic (now with duplicate detection!)
176
+ - `/specweave:validate` - Validate increment completeness
177
+ - `gh issue list` - View all issues (GitHub CLI)
178
+
179
+ ## Implementation
180
+
181
+ **File**: `plugins/specweave-github/lib/github-epic-sync.ts`
182
+
183
+ **Method**: `cleanupDuplicates(epicId: string, dryRun: boolean)`
184
+
185
+ **Algorithm**:
186
+ 1. Search GitHub for all issues with Epic ID
187
+ 2. Group by title (Map<string, number[]>)
188
+ 3. Filter groups with >1 issue (duplicates)
189
+ 4. For each duplicate group:
190
+ - Keep first issue (lowest number)
191
+ - Close others with gh CLI
192
+ 5. Update Epic README frontmatter
193
+
194
+ ## Next Steps
195
+
196
+ After cleanup:
197
+
198
+ 1. **Verify cleanup**: `gh issue list --search "[FS-031]"`
199
+ 2. **Check Epic README**: Verify frontmatter has correct issue numbers
200
+ 3. **Re-run sync**: `/specweave-github:sync-epic FS-031` (should show no duplicates)
201
+ 4. **Enable duplicate detection**: Already enabled in v0.18.0+
202
+
203
+ ---
204
+
205
+ **✅ SAFE TO USE**: This command is idempotent and safe to run multiple times.
@@ -0,0 +1,248 @@
1
+ ---
2
+ name: specweave-github-sync-epic
3
+ description: Sync SpecWeave Epic folder to GitHub (Milestone + Issues). Implements Universal Hierarchy architecture - Epic → Milestone, Increments → Issues.
4
+ ---
5
+
6
+ # Sync Epic to GitHub (Universal Hierarchy)
7
+
8
+ **Architecture**: Hierarchical sync using Epic folder structure
9
+
10
+ - **Epic (FS-001)** → **GitHub Milestone**
11
+ - **Increment (0001-core-framework)** → **GitHub Issue** (linked to Milestone)
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ /specweave-github:sync-epic <epic-id>
17
+ ```
18
+
19
+ ## What It Does
20
+
21
+ **Hierarchical Sync Process**:
22
+
23
+ 1. **Load Epic folder** from `.specweave/docs/internal/specs/FS-XXX-name/`
24
+ 2. **Parse Epic README.md** to get Epic metadata (title, increments, status)
25
+ 3. **Create or update GitHub Milestone**:
26
+ - Title: `[FS-001] Epic Title`
27
+ - Description: Epic overview + progress stats
28
+ - State: Open (active/planning) or Closed (complete)
29
+ 4. **Sync each increment as GitHub Issue**:
30
+ - Title: `[INC-0001-core-framework] Title`
31
+ - Body: Increment overview + link to tasks.md
32
+ - Milestone: Linked to Epic Milestone
33
+ - Labels: `increment`, `epic-sync`
34
+ 5. **Update frontmatter** in Epic README.md and increment files
35
+
36
+ ## Examples
37
+
38
+ ### Sync Epic FS-001 (Core Framework Architecture)
39
+
40
+ ```bash
41
+ /specweave-github:sync-epic FS-001
42
+ ```
43
+
44
+ **Output**:
45
+ ```
46
+ 🔄 Syncing Epic FS-001 to GitHub...
47
+ 📦 Epic: Core Framework Architecture
48
+ 📊 Increments: 4
49
+ 🚀 Creating GitHub Milestone...
50
+ ✅ Created Milestone #10
51
+
52
+ 📝 Syncing 4 increments...
53
+ ✅ Created Issue #130 for 0001-core-framework
54
+ ✅ Created Issue #131 for 0002-core-enhancements
55
+ ✅ Created Issue #132 for 0004-plugin-architecture
56
+ ✅ Created Issue #133 for 0005-cross-platform-cli
57
+
58
+ ✅ Epic sync complete!
59
+ Milestone: https://github.com/owner/repo/milestone/10
60
+ Issues created: 4
61
+ Issues updated: 0
62
+ ```
63
+
64
+ ### Sync Epic with short ID
65
+
66
+ ```bash
67
+ /specweave-github:sync-epic 031
68
+ # Resolves to FS-031
69
+ ```
70
+
71
+ ### Re-sync Epic (updates existing Milestone/Issues)
72
+
73
+ ```bash
74
+ /specweave-github:sync-epic FS-001
75
+ ```
76
+
77
+ **Output**:
78
+ ```
79
+ 🔄 Syncing Epic FS-001 to GitHub...
80
+ ♻️ Updating existing Milestone #10...
81
+ ✅ Updated Milestone #10
82
+
83
+ 📝 Syncing 4 increments...
84
+ ♻️ Updated Issue #130 for 0001-core-framework
85
+ ♻️ Updated Issue #131 for 0002-core-enhancements
86
+ ♻️ Updated Issue #132 for 0004-plugin-architecture
87
+ ♻️ Updated Issue #133 for 0005-cross-platform-cli
88
+
89
+ ✅ Epic sync complete!
90
+ Milestone: https://github.com/owner/repo/milestone/10
91
+ Issues created: 0
92
+ Issues updated: 4
93
+ ```
94
+
95
+ ## Arguments
96
+
97
+ - `<epic-id>` - Epic ID (e.g., `FS-001` or just `001`)
98
+
99
+ ## What Gets Created
100
+
101
+ ### GitHub Milestone (Epic-level)
102
+
103
+ ```
104
+ Title: [FS-001] Core Framework Architecture
105
+ Description:
106
+ Epic: Core Framework Architecture
107
+
108
+ Progress: 4/4 increments (100%)
109
+
110
+ Priority: P0
111
+ Status: complete
112
+
113
+ State: Closed (if complete) or Open (if active/planning)
114
+ ```
115
+
116
+ ### GitHub Issues (Increment-level)
117
+
118
+ ```markdown
119
+ Title: [INC-0001-core-framework] Core Framework
120
+
121
+ # Core Framework
122
+
123
+ Foundation framework with CLI, plugin system, and agent architecture...
124
+
125
+ ---
126
+
127
+ **Increment**: 0001-core-framework
128
+ **Milestone**: See milestone for Epic progress
129
+
130
+ 🤖 Auto-created by SpecWeave Epic Sync
131
+ ```
132
+
133
+ **Labels**: `increment`, `epic-sync`
134
+ **Milestone**: Linked to Epic Milestone
135
+
136
+ ## Frontmatter Updates
137
+
138
+ ### Epic README.md (after sync)
139
+
140
+ ```yaml
141
+ ---
142
+ id: FS-001
143
+ title: "Core Framework Architecture"
144
+ external_tools:
145
+ github:
146
+ type: milestone
147
+ id: 10 # ← Added
148
+ url: https://github.com/.../milestone/10 # ← Added
149
+ increments:
150
+ - id: 0001-core-framework
151
+ external:
152
+ github: 130 # ← Added
153
+ - id: 0002-core-enhancements
154
+ external:
155
+ github: 131 # ← Added
156
+ ---
157
+ ```
158
+
159
+ ### Increment file (0001-core-framework.md)
160
+
161
+ ```yaml
162
+ ---
163
+ id: 0001-core-framework
164
+ epic: FS-001
165
+ external:
166
+ github:
167
+ issue: 130 # ← Added
168
+ url: https://github.com/.../issues/130 # ← Added
169
+ ---
170
+ ```
171
+
172
+ ## Benefits
173
+
174
+ ✅ **Hierarchical tracking**: GitHub Milestones group related increments
175
+ ✅ **Epic-level progress**: See completion percentage in Milestone
176
+ ✅ **Automatic linking**: All Issues linked to Milestone
177
+ ✅ **Idempotent**: Safe to re-run (updates existing Milestone/Issues)
178
+ ✅ **Brownfield-ready**: Links existing GitHub Milestones/Issues
179
+
180
+ ## Requirements
181
+
182
+ 1. **GitHub CLI** (`gh`) installed and authenticated
183
+ 2. **Git repository** with GitHub remote
184
+ 3. **Write access** to repository (for creating Milestones/Issues)
185
+ 4. **Epic folder exists** at `.specweave/docs/internal/specs/FS-XXX-name/`
186
+
187
+ ## Architecture: Why Milestones?
188
+
189
+ **GitHub's Hierarchy**:
190
+ - GitHub Milestones = Epic-level grouping
191
+ - GitHub Issues = Increment-level work items
192
+ - GitHub Projects = Optional (cross-Epic tracking)
193
+
194
+ **Comparison with JIRA/ADO**:
195
+ - JIRA: Epic → Epic, Increment → Story (with Epic Link field)
196
+ - ADO: Epic → Feature, Increment → User Story (with Parent link)
197
+ - GitHub: Epic → Milestone, Increment → Issue (with Milestone link)
198
+
199
+ All three implement the same Universal Hierarchy, just with different terminology.
200
+
201
+ ## Troubleshooting
202
+
203
+ **"Epic FS-001 not found"**:
204
+ - Check Epic folder exists: `ls .specweave/docs/internal/specs/`
205
+ - Verify Epic ID format: `FS-001-epic-name/`
206
+
207
+ **"Epic README.md missing YAML frontmatter"**:
208
+ - Ensure Epic was migrated with `migrate-to-epic-folders.ts`
209
+ - Frontmatter must start with `---` on line 1
210
+
211
+ **"Failed to create GitHub Milestone"**:
212
+ - Check GitHub CLI auth: `gh auth status`
213
+ - Verify write access: `gh repo view`
214
+ - Check rate limits: `gh api rate_limit`
215
+
216
+ **"Could not extract issue number"**:
217
+ - GitHub CLI output format may have changed
218
+ - Check CLI version: `gh --version` (need v2.0.0+)
219
+
220
+ ## Related Commands
221
+
222
+ - `/specweave-github:sync-spec` - OLD (flat spec → project) - DEPRECATED for Epic architecture
223
+ - `/specweave-jira:sync-epic` - Sync to JIRA Epic + Stories
224
+ - `/specweave-ado:sync-epic` - Sync to ADO Feature + User Stories
225
+
226
+ ## Implementation
227
+
228
+ **File**: `plugins/specweave-github/lib/github-epic-sync.ts`
229
+
230
+ **Core Class**: `GitHubEpicSync`
231
+
232
+ **Methods**:
233
+ - `syncEpicToGitHub(epicId)` - Main sync logic
234
+ - `createMilestone(epic)` - Create GitHub Milestone
235
+ - `updateMilestone(number, epic)` - Update existing Milestone
236
+ - `createIssue(increment, milestone)` - Create GitHub Issue
237
+ - `updateIssue(number, increment, milestone)` - Update existing Issue
238
+ - `updateEpicReadme(path, github)` - Update frontmatter
239
+ - `updateIncrementExternalLink(...)` - Update increment frontmatter
240
+
241
+ ## Next Steps
242
+
243
+ After syncing Epic to GitHub:
244
+
245
+ 1. **View Milestone progress**: `gh milestone view 10`
246
+ 2. **List Issues in Milestone**: `gh issue list --milestone 10`
247
+ 3. **Track completion**: GitHub automatically calculates Milestone progress
248
+ 4. **Close Milestone**: When all increments complete, Milestone auto-closes