specweave 0.17.16 → 0.17.19

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 (232) hide show
  1. package/CLAUDE.md +405 -2495
  2. package/README.md +92 -2
  3. package/dist/locales/de/.gitkeep +0 -0
  4. package/dist/locales/de/cli.json +108 -0
  5. package/dist/locales/en/cli.json +287 -0
  6. package/dist/locales/en/errors.json +7 -0
  7. package/dist/locales/en/templates.json +6 -0
  8. package/dist/locales/es/.gitkeep +0 -0
  9. package/dist/locales/es/cli.json +41 -0
  10. package/dist/locales/fr/.gitkeep +0 -0
  11. package/dist/locales/fr/cli.json +108 -0
  12. package/dist/locales/ja/.gitkeep +0 -0
  13. package/dist/locales/ja/cli.json +108 -0
  14. package/dist/locales/ko/.gitkeep +0 -0
  15. package/dist/locales/ko/cli.json +108 -0
  16. package/dist/locales/pt/.gitkeep +0 -0
  17. package/dist/locales/pt/cli.json +108 -0
  18. package/dist/locales/ru/.gitkeep +0 -0
  19. package/dist/locales/ru/cli.json +269 -0
  20. package/dist/locales/zh/.gitkeep +0 -0
  21. package/dist/locales/zh/cli.json +108 -0
  22. package/dist/plugins/specweave/lib/hooks/sync-living-docs.d.ts.map +1 -1
  23. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js +188 -36
  24. package/dist/plugins/specweave/lib/hooks/sync-living-docs.js.map +1 -1
  25. package/dist/plugins/specweave-ado/lib/ado-spec-content-sync.d.ts.map +1 -1
  26. package/dist/plugins/specweave-ado/lib/ado-spec-content-sync.js +65 -6
  27. package/dist/plugins/specweave-ado/lib/ado-spec-content-sync.js.map +1 -1
  28. package/dist/plugins/specweave-ado/lib/ado-status-sync.d.ts +54 -0
  29. package/dist/plugins/specweave-ado/lib/ado-status-sync.d.ts.map +1 -0
  30. package/dist/plugins/specweave-ado/lib/ado-status-sync.js +86 -0
  31. package/dist/plugins/specweave-ado/lib/ado-status-sync.js.map +1 -0
  32. package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.d.ts +25 -0
  33. package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.d.ts.map +1 -0
  34. package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.js +191 -0
  35. package/dist/plugins/specweave-ado/lib/enhanced-ado-sync.js.map +1 -0
  36. package/dist/plugins/specweave-github/lib/duplicate-detector.d.ts +139 -0
  37. package/dist/plugins/specweave-github/lib/duplicate-detector.d.ts.map +1 -0
  38. package/dist/plugins/specweave-github/lib/duplicate-detector.js +389 -0
  39. package/dist/plugins/specweave-github/lib/duplicate-detector.js.map +1 -0
  40. package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts +26 -0
  41. package/dist/plugins/specweave-github/lib/enhanced-github-sync.d.ts.map +1 -0
  42. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js +249 -0
  43. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js.map +1 -0
  44. package/dist/plugins/specweave-github/lib/epic-content-builder.d.ts +63 -0
  45. package/dist/plugins/specweave-github/lib/epic-content-builder.d.ts.map +1 -0
  46. package/dist/plugins/specweave-github/lib/epic-content-builder.js +216 -0
  47. package/dist/plugins/specweave-github/lib/epic-content-builder.js.map +1 -0
  48. package/dist/plugins/specweave-github/lib/github-client.d.ts +1 -1
  49. package/dist/plugins/specweave-github/lib/github-client.d.ts.map +1 -1
  50. package/dist/plugins/specweave-github/lib/github-client.js +25 -13
  51. package/dist/plugins/specweave-github/lib/github-client.js.map +1 -1
  52. package/dist/plugins/specweave-github/lib/github-epic-sync.d.ts +83 -0
  53. package/dist/plugins/specweave-github/lib/github-epic-sync.d.ts.map +1 -0
  54. package/dist/plugins/specweave-github/lib/github-epic-sync.js +466 -0
  55. package/dist/plugins/specweave-github/lib/github-epic-sync.js.map +1 -0
  56. package/dist/plugins/specweave-github/lib/github-status-sync.d.ts +43 -0
  57. package/dist/plugins/specweave-github/lib/github-status-sync.d.ts.map +1 -0
  58. package/dist/plugins/specweave-github/lib/github-status-sync.js +82 -0
  59. package/dist/plugins/specweave-github/lib/github-status-sync.js.map +1 -0
  60. package/dist/plugins/specweave-github/lib/task-sync.d.ts +5 -0
  61. package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
  62. package/dist/plugins/specweave-github/lib/task-sync.js +38 -2
  63. package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
  64. package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.d.ts +28 -0
  65. package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.d.ts.map +1 -0
  66. package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.js +156 -0
  67. package/dist/plugins/specweave-jira/lib/enhanced-jira-sync.js.map +1 -0
  68. package/dist/plugins/specweave-jira/lib/jira-epic-sync.d.ts +66 -0
  69. package/dist/plugins/specweave-jira/lib/jira-epic-sync.d.ts.map +1 -0
  70. package/dist/plugins/specweave-jira/lib/jira-epic-sync.js +274 -0
  71. package/dist/plugins/specweave-jira/lib/jira-epic-sync.js.map +1 -0
  72. package/dist/plugins/specweave-jira/lib/jira-status-sync.d.ts +56 -0
  73. package/dist/plugins/specweave-jira/lib/jira-status-sync.d.ts.map +1 -0
  74. package/dist/plugins/specweave-jira/lib/jira-status-sync.js +93 -0
  75. package/dist/plugins/specweave-jira/lib/jira-status-sync.js.map +1 -0
  76. package/dist/spec-parser.js +629 -0
  77. package/dist/src/cli/commands/init.d.ts.map +1 -1
  78. package/dist/src/cli/commands/init.js +107 -3
  79. package/dist/src/cli/commands/init.js.map +1 -1
  80. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  81. package/dist/src/cli/helpers/issue-tracker/index.js +48 -3
  82. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  83. package/dist/src/core/deduplication/command-deduplicator.d.ts +166 -0
  84. package/dist/src/core/deduplication/command-deduplicator.d.ts.map +1 -0
  85. package/dist/src/core/deduplication/command-deduplicator.js +254 -0
  86. package/dist/src/core/deduplication/command-deduplicator.js.map +1 -0
  87. package/dist/src/core/living-docs/hierarchy-mapper.d.ts +142 -0
  88. package/dist/src/core/living-docs/hierarchy-mapper.d.ts.map +1 -0
  89. package/dist/src/core/living-docs/hierarchy-mapper.js +453 -0
  90. package/dist/src/core/living-docs/hierarchy-mapper.js.map +1 -0
  91. package/dist/src/core/living-docs/index.d.ts +10 -84
  92. package/dist/src/core/living-docs/index.d.ts.map +1 -1
  93. package/dist/src/core/living-docs/index.js +10 -164
  94. package/dist/src/core/living-docs/index.js.map +1 -1
  95. package/dist/src/core/living-docs/spec-distributor.d.ts +106 -0
  96. package/dist/src/core/living-docs/spec-distributor.d.ts.map +1 -0
  97. package/dist/src/core/living-docs/spec-distributor.js +823 -0
  98. package/dist/src/core/living-docs/spec-distributor.js.map +1 -0
  99. package/dist/src/core/living-docs/types.d.ts +201 -0
  100. package/dist/src/core/living-docs/types.d.ts.map +1 -0
  101. package/dist/src/core/living-docs/types.js +15 -0
  102. package/dist/src/core/living-docs/types.js.map +1 -0
  103. package/dist/src/core/logging/prompt-logger.d.ts +70 -0
  104. package/dist/src/core/logging/prompt-logger.d.ts.map +1 -0
  105. package/dist/src/core/logging/prompt-logger.js +247 -0
  106. package/dist/src/core/logging/prompt-logger.js.map +1 -0
  107. package/dist/src/core/status-line/status-line-manager.d.ts +15 -24
  108. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  109. package/dist/src/core/status-line/status-line-manager.js +33 -70
  110. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  111. package/dist/src/core/status-line/types.d.ts +19 -31
  112. package/dist/src/core/status-line/types.d.ts.map +1 -1
  113. package/dist/src/core/status-line/types.js +5 -9
  114. package/dist/src/core/status-line/types.js.map +1 -1
  115. package/dist/src/core/sync/conflict-resolver.d.ts +66 -0
  116. package/dist/src/core/sync/conflict-resolver.d.ts.map +1 -0
  117. package/dist/src/core/sync/conflict-resolver.js +108 -0
  118. package/dist/src/core/sync/conflict-resolver.js.map +1 -0
  119. package/dist/src/core/sync/enhanced-content-builder.d.ts +55 -0
  120. package/dist/src/core/sync/enhanced-content-builder.d.ts.map +1 -0
  121. package/dist/src/core/sync/enhanced-content-builder.js +202 -0
  122. package/dist/src/core/sync/enhanced-content-builder.js.map +1 -0
  123. package/dist/src/core/sync/label-detector.d.ts +66 -0
  124. package/dist/src/core/sync/label-detector.d.ts.map +1 -0
  125. package/dist/src/core/sync/label-detector.js +211 -0
  126. package/dist/src/core/sync/label-detector.js.map +1 -0
  127. package/dist/src/core/sync/retry-logic.d.ts +64 -0
  128. package/dist/src/core/sync/retry-logic.d.ts.map +1 -0
  129. package/dist/src/core/sync/retry-logic.js +165 -0
  130. package/dist/src/core/sync/retry-logic.js.map +1 -0
  131. package/dist/src/core/sync/spec-content-sync.d.ts +88 -0
  132. package/dist/src/core/sync/spec-content-sync.d.ts.map +1 -0
  133. package/dist/src/core/sync/spec-content-sync.js +5 -0
  134. package/dist/src/core/sync/spec-content-sync.js.map +1 -0
  135. package/dist/src/core/sync/spec-increment-mapper.d.ts +100 -0
  136. package/dist/src/core/sync/spec-increment-mapper.d.ts.map +1 -0
  137. package/dist/src/core/sync/spec-increment-mapper.js +424 -0
  138. package/dist/src/core/sync/spec-increment-mapper.js.map +1 -0
  139. package/dist/src/core/sync/status-cache.d.ts +91 -0
  140. package/dist/src/core/sync/status-cache.d.ts.map +1 -0
  141. package/dist/src/core/sync/status-cache.js +140 -0
  142. package/dist/src/core/sync/status-cache.js.map +1 -0
  143. package/dist/src/core/sync/status-mapper.d.ts +69 -0
  144. package/dist/src/core/sync/status-mapper.d.ts.map +1 -0
  145. package/dist/src/core/sync/status-mapper.js +90 -0
  146. package/dist/src/core/sync/status-mapper.js.map +1 -0
  147. package/dist/src/core/sync/status-sync-engine.d.ts +162 -0
  148. package/dist/src/core/sync/status-sync-engine.d.ts.map +1 -0
  149. package/dist/src/core/sync/status-sync-engine.js +347 -0
  150. package/dist/src/core/sync/status-sync-engine.js.map +1 -0
  151. package/dist/src/core/sync/sync-event-logger.d.ts +99 -0
  152. package/dist/src/core/sync/sync-event-logger.d.ts.map +1 -0
  153. package/dist/src/core/sync/sync-event-logger.js +103 -0
  154. package/dist/src/core/sync/sync-event-logger.js.map +1 -0
  155. package/dist/src/core/sync/types.d.ts +52 -0
  156. package/dist/src/core/sync/types.d.ts.map +1 -0
  157. package/dist/src/core/sync/types.js +5 -0
  158. package/dist/src/core/sync/types.js.map +1 -0
  159. package/dist/src/core/sync/workflow-detector.d.ts +95 -0
  160. package/dist/src/core/sync/workflow-detector.d.ts.map +1 -0
  161. package/dist/src/core/sync/workflow-detector.js +175 -0
  162. package/dist/src/core/sync/workflow-detector.js.map +1 -0
  163. package/dist/src/core/types/config.d.ts +51 -0
  164. package/dist/src/core/types/config.d.ts.map +1 -1
  165. package/dist/src/core/types/config.js +47 -0
  166. package/dist/src/core/types/config.js.map +1 -1
  167. package/dist/src/core/types/increment-metadata.d.ts +4 -0
  168. package/dist/src/core/types/increment-metadata.d.ts.map +1 -1
  169. package/dist/src/core/types/increment-metadata.js.map +1 -1
  170. package/dist/src/utils/github-url.d.ts +53 -0
  171. package/dist/src/utils/github-url.d.ts.map +1 -0
  172. package/dist/src/utils/github-url.js +90 -0
  173. package/dist/src/utils/github-url.js.map +1 -0
  174. package/dist/src/utils/spec-parser.d.ts +145 -0
  175. package/dist/src/utils/spec-parser.d.ts.map +1 -0
  176. package/dist/src/utils/spec-parser.js +640 -0
  177. package/dist/src/utils/spec-parser.js.map +1 -0
  178. package/dist/tsconfig.tsbuildinfo +1 -0
  179. package/package.json +1 -1
  180. package/plugins/specweave/agents/pm/AGENT.md +160 -13
  181. package/plugins/specweave/agents/pm/templates/increment-spec.md +158 -0
  182. package/plugins/specweave/agents/pm/templates/living-docs-spec.md +113 -0
  183. package/plugins/specweave/commands/specweave-done.md +163 -0
  184. package/plugins/specweave/commands/specweave.md +70 -405
  185. package/plugins/specweave/hooks/hooks.json +4 -0
  186. package/plugins/specweave/hooks/lib/sync-spec-content.sh +2 -2
  187. package/plugins/specweave/hooks/lib/update-status-line.sh +79 -111
  188. package/plugins/specweave/hooks/post-increment-planning.sh +133 -37
  189. package/plugins/specweave/hooks/pre-command-deduplication.sh +86 -0
  190. package/plugins/specweave/lib/hooks/sync-living-docs.js +139 -34
  191. package/plugins/specweave/lib/hooks/sync-living-docs.ts +234 -38
  192. package/plugins/specweave/skills/SKILLS-INDEX.md +4 -24
  193. package/plugins/specweave/skills/increment-planner/SKILL.md +94 -0
  194. package/plugins/specweave/skills/increment-work-router/SKILL.md +466 -0
  195. package/plugins/specweave-ado/commands/specweave-ado-sync-spec.md +1 -1
  196. package/plugins/specweave-ado/lib/ado-spec-content-sync.js +49 -5
  197. package/plugins/specweave-ado/lib/ado-spec-content-sync.ts +72 -6
  198. package/plugins/specweave-ado/lib/ado-status-sync.js +80 -0
  199. package/plugins/specweave-ado/lib/ado-status-sync.ts +121 -0
  200. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
  201. package/plugins/specweave-github/commands/specweave-github-cleanup-duplicates.md +205 -0
  202. package/plugins/specweave-github/commands/specweave-github-sync-epic.md +248 -0
  203. package/plugins/specweave-github/commands/specweave-github-sync-spec.md +1 -1
  204. package/plugins/specweave-github/hooks/post-task-completion.sh +32 -0
  205. package/plugins/specweave-github/lib/duplicate-detector.js +370 -0
  206. package/plugins/specweave-github/lib/duplicate-detector.ts +525 -0
  207. package/plugins/specweave-github/lib/enhanced-github-sync.js +220 -0
  208. package/plugins/specweave-github/lib/enhanced-github-sync.ts +322 -0
  209. package/plugins/specweave-github/lib/epic-content-builder.js +227 -0
  210. package/plugins/specweave-github/lib/epic-content-builder.ts +317 -0
  211. package/plugins/specweave-github/lib/github-client.js +21 -10
  212. package/plugins/specweave-github/lib/github-client.ts +27 -16
  213. package/plugins/specweave-github/lib/github-epic-sync.js +488 -0
  214. package/plugins/specweave-github/lib/github-epic-sync.ts +715 -0
  215. package/plugins/specweave-github/lib/github-status-sync.js +71 -0
  216. package/plugins/specweave-github/lib/github-status-sync.ts +107 -0
  217. package/plugins/specweave-github/lib/task-sync.js +33 -2
  218. package/plugins/specweave-github/lib/task-sync.ts +44 -2
  219. package/plugins/specweave-jira/commands/specweave-jira-sync-epic.md +267 -0
  220. package/plugins/specweave-jira/commands/specweave-jira-sync-spec.md +1 -1
  221. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +134 -0
  222. package/plugins/specweave-jira/lib/enhanced-jira-sync.ts +196 -0
  223. package/plugins/specweave-jira/lib/jira-epic-sync.js +304 -0
  224. package/plugins/specweave-jira/lib/jira-epic-sync.ts +459 -0
  225. package/plugins/specweave-jira/lib/jira-status-sync.js +79 -0
  226. package/plugins/specweave-jira/lib/jira-status-sync.ts +139 -0
  227. package/plugins/specweave-release/commands/specweave-release-platform.md +1 -1
  228. package/plugins/specweave-release/hooks/post-task-completion.sh +2 -2
  229. package/src/templates/AGENTS.md.template +88 -1
  230. package/src/templates/CLAUDE.md.template +49 -0
  231. package/plugins/specweave/skills/increment-quality-judge/SKILL.md +0 -524
  232. package/plugins/specweave/skills/plugin-installer/SKILL.md +0 -353
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Enhanced GitHub Spec Content Sync
3
+ *
4
+ * Uses EnhancedContentBuilder and SpecIncrementMapper for rich external descriptions.
5
+ * NEW (v0.21.0): Supports task checkboxes and automatic labeling.
6
+ */
7
+ import { GitHubClientV2 } from './github-client-v2.js';
8
+ import { EnhancedContentBuilder } from '../../../src/core/sync/enhanced-content-builder.js';
9
+ import { SpecIncrementMapper } from '../../../src/core/sync/spec-increment-mapper.js';
10
+ import { parseSpecContent } from '../../../src/core/spec-content-sync.js';
11
+ import { LabelDetector } from '../../../src/core/sync/label-detector.js';
12
+ import path from 'path';
13
+ import fs from 'fs/promises';
14
+ /**
15
+ * Enhanced sync with rich content including task mappings
16
+ */
17
+ export async function syncSpecWithEnhancedContent(options) {
18
+ const { specPath, owner, repo, dryRun = false, verbose = false } = options;
19
+ try {
20
+ // 1. Parse spec content
21
+ const baseSpec = await parseSpecContent(specPath);
22
+ if (!baseSpec) {
23
+ return {
24
+ success: false,
25
+ action: 'error',
26
+ error: 'Failed to parse spec content',
27
+ };
28
+ }
29
+ if (verbose) {
30
+ console.log(`📄 Parsed spec: ${baseSpec.identifier.compact}`);
31
+ }
32
+ // 2. Build enhanced spec with task mappings
33
+ const specId = baseSpec.identifier.full || baseSpec.identifier.compact;
34
+ const rootDir = await findSpecWeaveRoot(specPath);
35
+ const mapper = new SpecIncrementMapper(rootDir);
36
+ const mapping = await mapper.mapSpecToIncrements(specId);
37
+ if (verbose) {
38
+ console.log(`🔗 Found ${mapping.increments.length} related increments`);
39
+ console.log(`📋 Mapped ${Object.keys(mapping.userStoryMappings).length} user stories to tasks`);
40
+ }
41
+ // 3. Build task mapping for EnhancedSpecContent
42
+ const taskMapping = buildTaskMapping(mapping.increments, owner, repo);
43
+ // 4. Build architecture docs references
44
+ const architectureDocs = await findArchitectureDocs(rootDir, specId);
45
+ // 5. Build source links
46
+ const sourceLinks = buildSourceLinks(mapping.increments[0]?.id, owner, repo);
47
+ // 6. Create enhanced spec content
48
+ const enhancedSpec = {
49
+ ...baseSpec,
50
+ summary: baseSpec.description,
51
+ taskMapping,
52
+ architectureDocs,
53
+ sourceLinks
54
+ };
55
+ // 7. Build external description with task checkboxes
56
+ const builder = new EnhancedContentBuilder();
57
+ // NEW: Override buildTasksSection call to include checkboxes
58
+ const originalBuildExternal = builder.buildExternalDescription.bind(builder);
59
+ const description = (() => {
60
+ const sections = [];
61
+ // Summary
62
+ sections.push(builder.buildSummarySection(enhancedSpec));
63
+ // User stories
64
+ if (enhancedSpec.userStories && enhancedSpec.userStories.length > 0) {
65
+ sections.push(builder.buildUserStoriesSection(enhancedSpec.userStories));
66
+ }
67
+ // Tasks with checkboxes (NEW!)
68
+ if (enhancedSpec.taskMapping) {
69
+ sections.push(builder.buildTasksSection(enhancedSpec.taskMapping, {
70
+ showCheckboxes: true,
71
+ showProgressBar: true,
72
+ showCompletionStatus: true,
73
+ provider: 'github'
74
+ }));
75
+ }
76
+ // Architecture
77
+ if (enhancedSpec.architectureDocs && enhancedSpec.architectureDocs.length > 0) {
78
+ sections.push(builder.buildArchitectureSection(enhancedSpec.architectureDocs));
79
+ }
80
+ // Source links
81
+ if (enhancedSpec.sourceLinks) {
82
+ sections.push(builder.buildSourceLinksSection(enhancedSpec.sourceLinks));
83
+ }
84
+ return sections.filter(s => s.length > 0).join('\n\n---\n\n');
85
+ })();
86
+ if (verbose) {
87
+ console.log(`📝 Generated description: ${description.length} characters`);
88
+ }
89
+ if (dryRun) {
90
+ console.log('🔍 DRY RUN - Would create/update issue with:');
91
+ console.log(` Title: ${baseSpec.title}`);
92
+ console.log(` Description length: ${description.length}`);
93
+ console.log(` Tasks linked: ${taskMapping?.tasks.length || 0}`);
94
+ return {
95
+ success: true,
96
+ action: 'no-change',
97
+ tasksLinked: taskMapping?.tasks.length || 0
98
+ };
99
+ }
100
+ // 8. Create or update GitHub issue
101
+ if (!owner || !repo) {
102
+ return {
103
+ success: false,
104
+ action: 'error',
105
+ error: 'GitHub owner/repo not specified',
106
+ };
107
+ }
108
+ const client = GitHubClientV2.fromRepo(owner, repo);
109
+ // NEW: Detect increment type and apply labels
110
+ const labelDetector = new LabelDetector(undefined, false); // Use GitHub format
111
+ const detection = labelDetector.detectType(await fs.readFile(specPath, 'utf-8'), mapping.increments[0]?.id);
112
+ const githubLabels = labelDetector.getGitHubLabels(detection.type);
113
+ const allLabels = ['spec', ...githubLabels]; // Include both 'spec' and type labels
114
+ if (verbose) {
115
+ console.log(`🏷️ Detected type: ${detection.type} (${detection.confidence}% confidence)`);
116
+ console.log(` Labels: ${allLabels.join(', ')}`);
117
+ }
118
+ // Check if issue already exists
119
+ const existingIssue = await findExistingIssue(client, baseSpec.identifier.compact);
120
+ let result;
121
+ if (existingIssue) {
122
+ // Update existing issue (body + labels)
123
+ await client.updateIssueBody(existingIssue.number, description);
124
+ // Update labels if autoApplyLabels is enabled
125
+ // TODO: Read from config, for now always apply
126
+ await client.addLabels(existingIssue.number, allLabels);
127
+ result = {
128
+ success: true,
129
+ action: 'updated',
130
+ issueNumber: existingIssue.number,
131
+ issueUrl: existingIssue.html_url,
132
+ tasksLinked: taskMapping?.tasks.length || 0
133
+ };
134
+ }
135
+ else {
136
+ // Create new issue with labels
137
+ const issue = await client.createEpicIssue(`[${baseSpec.identifier.compact}] ${baseSpec.title}`, description, undefined, allLabels // Apply labels at creation
138
+ );
139
+ result = {
140
+ success: true,
141
+ action: 'created',
142
+ issueNumber: issue.number,
143
+ issueUrl: issue.html_url,
144
+ tasksLinked: taskMapping?.tasks.length || 0
145
+ };
146
+ // Update spec with GitHub link
147
+ await mapper.updateSpecWithIncrementLinks(specId, mapping.increments[0]?.id);
148
+ }
149
+ if (verbose) {
150
+ console.log(`✅ ${result.action === 'created' ? 'Created' : 'Updated'} issue #${result.issueNumber}`);
151
+ console.log(` URL: ${result.issueUrl}`);
152
+ console.log(` Tasks linked: ${result.tasksLinked}`);
153
+ }
154
+ return result;
155
+ }
156
+ catch (error) {
157
+ return {
158
+ success: false,
159
+ action: 'error',
160
+ error: error.message
161
+ };
162
+ }
163
+ }
164
+ // Helper functions
165
+ async function findSpecWeaveRoot(specPath) {
166
+ let currentDir = path.dirname(specPath);
167
+ while (true) {
168
+ const specweaveDir = path.join(currentDir, '.specweave');
169
+ try {
170
+ await fs.access(specweaveDir);
171
+ return currentDir;
172
+ }
173
+ catch {
174
+ const parentDir = path.dirname(currentDir);
175
+ if (parentDir === currentDir) {
176
+ throw new Error('.specweave directory not found');
177
+ }
178
+ currentDir = parentDir;
179
+ }
180
+ }
181
+ }
182
+ function buildTaskMapping(increments, owner, repo) {
183
+ if (increments.length === 0)
184
+ return undefined;
185
+ const firstIncrement = increments[0];
186
+ const tasks = firstIncrement.tasks.map((task) => ({
187
+ id: task.id,
188
+ title: task.title,
189
+ userStories: task.userStories,
190
+ githubIssue: task.githubIssue
191
+ }));
192
+ return {
193
+ incrementId: firstIncrement.id,
194
+ tasks,
195
+ tasksUrl: `https://github.com/${owner}/${repo}/blob/develop/.specweave/increments/${firstIncrement.id}/tasks.md`
196
+ };
197
+ }
198
+ async function findArchitectureDocs(rootDir, specId) {
199
+ const docs = [];
200
+ const archDir = path.join(rootDir, '.specweave/docs/internal/architecture');
201
+ try {
202
+ // Check for ADRs
203
+ const adrDir = path.join(archDir, 'adr');
204
+ try {
205
+ const adrs = await fs.readdir(adrDir);
206
+ const relatedAdrs = adrs.filter(file => file.includes(specId.replace('spec-', '')));
207
+ for (const adr of relatedAdrs) {
208
+ docs.push({
209
+ type: 'adr',
210
+ path: path.join(adrDir, adr),
211
+ title: adr.replace('.md', '').replace(/-/g, ' ')
212
+ });
213
+ }
214
+ }
215
+ catch { }
216
+ // Check for HLD
217
+ const hlds = await fs.readdir(archDir);
218
+ const relatedHlds = hlds.filter(file => file.includes('hld') && file.includes(specId.replace('spec-', '')));
219
+ for (const hld of relatedHlds) {
220
+ docs.push({
221
+ type: 'hld',
222
+ path: path.join(archDir, hld),
223
+ title: hld.replace('.md', '').replace(/-/g, ' ')
224
+ });
225
+ }
226
+ }
227
+ catch { }
228
+ return docs;
229
+ }
230
+ function buildSourceLinks(incrementId, owner, repo) {
231
+ if (!incrementId)
232
+ return undefined;
233
+ const baseUrl = `https://github.com/${owner}/${repo}/blob/develop/.specweave`;
234
+ return {
235
+ spec: `${baseUrl}/docs/internal/specs/default/spec-${incrementId.replace(/^\d+-/, '')}.md`,
236
+ plan: `${baseUrl}/increments/${incrementId}/plan.md`,
237
+ tasks: `${baseUrl}/increments/${incrementId}/tasks.md`
238
+ };
239
+ }
240
+ async function findExistingIssue(client, specId) {
241
+ try {
242
+ const issues = await client.listIssuesInTimeRange('ALL');
243
+ return issues.find((issue) => issue.title.includes(`[${specId}]`) && issue.labels?.some((l) => l.name === 'spec')) || null;
244
+ }
245
+ catch {
246
+ return null;
247
+ }
248
+ }
249
+ //# sourceMappingURL=enhanced-github-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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I,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC;IACvI,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Epic Content Builder - Hierarchical GitHub issue content for Feature Specs
3
+ *
4
+ * Architecture:
5
+ * - Reads FS-* folder (FEATURE.md + us-*.md files)
6
+ * - Reads increment tasks.md files to map tasks to user stories
7
+ * - Generates hierarchical issue body:
8
+ * 1. User Stories section (with status + increment)
9
+ * 2. Tasks section (grouped by User Story)
10
+ *
11
+ * Key Features:
12
+ * - NO single "Increment" field (epics span multiple increments)
13
+ * - User Stories are checkable with status and increment link
14
+ * - Tasks grouped under their User Story
15
+ * - Shows which increment each US/task belongs to
16
+ */
17
+ export declare class EpicContentBuilder {
18
+ private epicFolder;
19
+ private projectRoot;
20
+ constructor(epicFolder: string, projectRoot: string);
21
+ /**
22
+ * Build hierarchical GitHub issue body
23
+ *
24
+ * Format:
25
+ * - Epic overview
26
+ * - User Stories section (checkable, with status + increment)
27
+ * - Tasks section (grouped by User Story)
28
+ */
29
+ buildIssueBody(): Promise<string>;
30
+ /**
31
+ * Read Epic FEATURE.md frontmatter
32
+ */
33
+ private readEpicMetadata;
34
+ /**
35
+ * Read all user stories from us-*.md files
36
+ */
37
+ private readUserStories;
38
+ /**
39
+ * Extract tasks for a user story from its Implementation section
40
+ */
41
+ private extractTasksForUserStory;
42
+ /**
43
+ * Build overview section
44
+ */
45
+ private buildOverviewSection;
46
+ /**
47
+ * Build User Stories section
48
+ */
49
+ private buildUserStoriesSection;
50
+ /**
51
+ * Build Tasks section (grouped by User Story)
52
+ */
53
+ private buildTasksSection;
54
+ /**
55
+ * Normalize status values
56
+ */
57
+ private normalizeStatus;
58
+ /**
59
+ * Get status emoji
60
+ */
61
+ private getStatusEmoji;
62
+ }
63
+ //# sourceMappingURL=epic-content-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epic-content-builder.d.ts","sourceRoot":"","sources":["../../../../plugins/specweave-github/lib/epic-content-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuCH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;gBAEhB,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAKnD;;;;;;;OAOG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAgBvC;;OAEG;YACW,gBAAgB;IAY9B;;OAEG;YACW,eAAe;IA0C7B;;OAEG;YACW,wBAAwB;IAoEtC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAoB/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiCzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,cAAc;CAgBvB"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Epic Content Builder - Hierarchical GitHub issue content for Feature Specs
3
+ *
4
+ * Architecture:
5
+ * - Reads FS-* folder (FEATURE.md + us-*.md files)
6
+ * - Reads increment tasks.md files to map tasks to user stories
7
+ * - Generates hierarchical issue body:
8
+ * 1. User Stories section (with status + increment)
9
+ * 2. Tasks section (grouped by User Story)
10
+ *
11
+ * Key Features:
12
+ * - NO single "Increment" field (epics span multiple increments)
13
+ * - User Stories are checkable with status and increment link
14
+ * - Tasks grouped under their User Story
15
+ * - Shows which increment each US/task belongs to
16
+ */
17
+ import { readdir, readFile } from 'fs/promises';
18
+ import { existsSync } from 'fs';
19
+ import * as path from 'path';
20
+ import * as yaml from 'yaml';
21
+ export class EpicContentBuilder {
22
+ constructor(epicFolder, projectRoot) {
23
+ this.epicFolder = epicFolder;
24
+ this.projectRoot = projectRoot;
25
+ }
26
+ /**
27
+ * Build hierarchical GitHub issue body
28
+ *
29
+ * Format:
30
+ * - Epic overview
31
+ * - User Stories section (checkable, with status + increment)
32
+ * - Tasks section (grouped by User Story)
33
+ */
34
+ async buildIssueBody() {
35
+ // 1. Read Epic metadata
36
+ const epicData = await this.readEpicMetadata();
37
+ // 2. Read User Stories
38
+ const userStories = await this.readUserStories();
39
+ // 3. Build sections
40
+ const overview = this.buildOverviewSection(epicData);
41
+ const userStoriesSection = this.buildUserStoriesSection(userStories);
42
+ const tasksSection = this.buildTasksSection(userStories);
43
+ // 4. Combine
44
+ return `${overview}\n\n---\n\n${userStoriesSection}\n\n---\n\n${tasksSection}\n\n---\n\n🤖 Auto-created by SpecWeave Epic Sync`;
45
+ }
46
+ /**
47
+ * Read Epic FEATURE.md frontmatter
48
+ */
49
+ async readEpicMetadata() {
50
+ const featurePath = path.join(this.epicFolder, 'FEATURE.md');
51
+ const content = await readFile(featurePath, 'utf-8');
52
+ const match = content.match(/^---\n([\s\S]*?)\n---/);
53
+ if (!match) {
54
+ throw new Error('FEATURE.md missing YAML frontmatter');
55
+ }
56
+ return yaml.parse(match[1]);
57
+ }
58
+ /**
59
+ * Read all user stories from us-*.md files
60
+ */
61
+ async readUserStories() {
62
+ const files = await readdir(this.epicFolder);
63
+ const usFiles = files.filter((f) => f.startsWith('us-') && f.endsWith('.md'));
64
+ const userStories = [];
65
+ for (const file of usFiles.sort()) {
66
+ const filePath = path.join(this.epicFolder, file);
67
+ const content = await readFile(filePath, 'utf-8');
68
+ const match = content.match(/^---\n([\s\S]*?)\n---/);
69
+ if (!match) {
70
+ console.warn(` ⚠️ ${file} missing frontmatter, skipping`);
71
+ continue;
72
+ }
73
+ const frontmatter = yaml.parse(match[1]);
74
+ const bodyContent = content.slice(match[0].length).trim();
75
+ // Extract increment from Implementation section
76
+ const incrementMatch = bodyContent.match(/\*\*Increment\*\*:\s*\[([^\]]+)\]/);
77
+ const increment = incrementMatch ? incrementMatch[1] : null;
78
+ // Extract tasks from Implementation section
79
+ const tasks = await this.extractTasksForUserStory(frontmatter.id, increment, bodyContent);
80
+ userStories.push({
81
+ id: frontmatter.id,
82
+ title: frontmatter.title,
83
+ status: this.normalizeStatus(frontmatter.status),
84
+ increment,
85
+ tasks,
86
+ });
87
+ }
88
+ return userStories;
89
+ }
90
+ /**
91
+ * Extract tasks for a user story from its Implementation section
92
+ */
93
+ async extractTasksForUserStory(userStoryId, incrementId, content) {
94
+ if (!incrementId) {
95
+ return []; // No increment yet, no tasks
96
+ }
97
+ // Find increment folder
98
+ const incrementFolder = path.join(this.projectRoot, '.specweave', 'increments', incrementId);
99
+ if (!existsSync(incrementFolder)) {
100
+ console.warn(` ⚠️ Increment folder not found: ${incrementId}`);
101
+ return [];
102
+ }
103
+ const tasksPath = path.join(incrementFolder, 'tasks.md');
104
+ if (!existsSync(tasksPath)) {
105
+ console.warn(` ⚠️ tasks.md not found in ${incrementId}`);
106
+ return [];
107
+ }
108
+ // Read tasks.md
109
+ const tasksContent = await readFile(tasksPath, 'utf-8');
110
+ // Extract task links from user story's Implementation section
111
+ // Format: - [T-001: Title](link#t-001-title)
112
+ const taskLinkPattern = /- \[([T-\d]+):\s*([^\]]+)\]/g;
113
+ const taskLinks = [];
114
+ let match;
115
+ while ((match = taskLinkPattern.exec(content)) !== null) {
116
+ taskLinks.push({
117
+ id: match[1], // e.g., "T-001"
118
+ title: match[2].trim(),
119
+ });
120
+ }
121
+ // Parse tasks from tasks.md to get completion status
122
+ const tasks = [];
123
+ for (const taskLink of taskLinks) {
124
+ // Find task in tasks.md by heading pattern: ### T-001: Title
125
+ const taskPattern = new RegExp(`###\\s+${taskLink.id}:\\s*([^\\n]+)[\\s\\S]*?\\*\\*Status\\*\\*:\\s*\\[([x\\s])\\]`, 'i');
126
+ const taskMatch = tasksContent.match(taskPattern);
127
+ const isCompleted = taskMatch ? taskMatch[2] === 'x' : false;
128
+ tasks.push({
129
+ id: taskLink.id,
130
+ title: taskLink.title,
131
+ status: isCompleted,
132
+ userStoryId,
133
+ });
134
+ }
135
+ return tasks;
136
+ }
137
+ /**
138
+ * Build overview section
139
+ */
140
+ buildOverviewSection(epic) {
141
+ return `# [${epic.id}] ${epic.title}\n\n**Status**: ${epic.status}\n**Created**: ${epic.created}\n**Last Updated**: ${epic.last_updated}`;
142
+ }
143
+ /**
144
+ * Build User Stories section
145
+ */
146
+ buildUserStoriesSection(userStories) {
147
+ const total = userStories.length;
148
+ const completed = userStories.filter((us) => us.status === 'complete').length;
149
+ const percentage = total > 0 ? Math.round((completed / total) * 100) : 0;
150
+ let section = `## User Stories\n\nProgress: ${completed}/${total} user stories complete (${percentage}%)\n\n`;
151
+ for (const us of userStories) {
152
+ const checkbox = us.status === 'complete' ? '[x]' : '[ ]';
153
+ const statusEmoji = this.getStatusEmoji(us.status);
154
+ const incrementLink = us.increment
155
+ ? `[${us.increment}](../../increments/${us.increment}/)`
156
+ : 'TBD';
157
+ section += `- ${checkbox} **${us.id}: ${us.title}** (${statusEmoji} ${us.status} | Increment: ${incrementLink})\n`;
158
+ }
159
+ return section;
160
+ }
161
+ /**
162
+ * Build Tasks section (grouped by User Story)
163
+ */
164
+ buildTasksSection(userStories) {
165
+ const totalTasks = userStories.reduce((sum, us) => sum + us.tasks.length, 0);
166
+ const completedTasks = userStories.reduce((sum, us) => sum + us.tasks.filter((t) => t.status).length, 0);
167
+ const percentage = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
168
+ let section = `## Tasks by User Story\n\nProgress: ${completedTasks}/${totalTasks} tasks complete (${percentage}%)\n\n`;
169
+ for (const us of userStories) {
170
+ if (us.tasks.length === 0) {
171
+ continue; // Skip user stories with no tasks yet
172
+ }
173
+ const incrementLink = us.increment
174
+ ? `[${us.increment}](../../increments/${us.increment}/tasks.md)`
175
+ : 'TBD';
176
+ section += `### ${us.id}: ${us.title} (Increment: ${incrementLink})\n\n`;
177
+ for (const task of us.tasks) {
178
+ const checkbox = task.status ? '[x]' : '[ ]';
179
+ section += `- ${checkbox} ${task.id}: ${task.title}\n`;
180
+ }
181
+ section += '\n';
182
+ }
183
+ return section;
184
+ }
185
+ /**
186
+ * Normalize status values
187
+ */
188
+ normalizeStatus(status) {
189
+ const normalized = status.toLowerCase();
190
+ if (normalized === 'complete' || normalized === 'completed')
191
+ return 'complete';
192
+ if (normalized === 'active' || normalized === 'in-progress')
193
+ return 'active';
194
+ if (normalized === 'planning')
195
+ return 'planning';
196
+ return 'not-started';
197
+ }
198
+ /**
199
+ * Get status emoji
200
+ */
201
+ getStatusEmoji(status) {
202
+ switch (status) {
203
+ case 'complete':
204
+ return '✅';
205
+ case 'active':
206
+ return '🚧';
207
+ case 'planning':
208
+ return '📋';
209
+ case 'not-started':
210
+ return '⏳';
211
+ default:
212
+ return '❓';
213
+ }
214
+ }
215
+ }
216
+ //# sourceMappingURL=epic-content-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epic-content-builder.js","sourceRoot":"","sources":["../../../../plugins/specweave-github/lib/epic-content-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAkC7B,MAAM,OAAO,kBAAkB;IAI7B,YAAY,UAAkB,EAAE,WAAmB;QACjD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC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,IAAI,CAAC;YACd,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC;YACd,KAAK,aAAa;gBAChB,OAAO,GAAG,CAAC;YACb;gBACE,OAAO,GAAG,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -31,7 +31,7 @@ export declare class GitHubClient {
31
31
  */
32
32
  private getMilestoneByTitle;
33
33
  /**
34
- * Create epic issue (increment-level)
34
+ * Create epic issue (increment-level) with FULL DUPLICATE PROTECTION
35
35
  */
36
36
  createEpicIssue(title: string, body: string, milestone?: number | string, labels?: string[]): Promise<GitHubIssue>;
37
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"github-client.d.ts","sourceRoot":"","sources":["../../../../plugins/specweave-github/lib/github-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,CAAC,EAAE,MAAM;IAKzB;;OAEG;IACH,OAAO,CAAC,UAAU;IAalB;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAevF;;;;;;OAMG;IACG,oBAAoB,CACxB,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,GAAE,MAAU,GACtB,OAAO,CAAC,eAAe,CAAC;IAuB3B;;OAEG;YACW,mBAAmB;IAUjC;;OAEG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAC3B,MAAM,GAAE,MAAM,EAAO,GACpB,OAAO,CAAC,WAAW,CAAC;IAgCvB;;OAEG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UA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e,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,GAAG,OAAO,CAAC,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CAsBnI"}
1
+ {"version":3,"file":"github-client.d.ts","sourceRoot":"","sources":["../../../../plugins/specweave-github/lib/github-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGvD,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,CAAC,EAAE,MAAM;IAKzB;;OAEG;IACH,OAAO,CAAC,UAAU;IAalB;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAevF;;;;;;OAMG;IACG,oBAAoB,CACxB,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,GAAE,MAAU,GACtB,OAAO,CAAC,eAAe,CAAC;IAuB3B;;OAEG;YACW,mBAAmB;IAUjC;;OAEG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAC3B,MAAM,GAAE,MAAM,EAAO,GACpB,OAAO,CAAC,WAAW,CAAC;IA0CvB;;OAEG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAC3B,MAAM,GAAE,MAAM,EAAO,GACpB,OAAO,CAAC,WAAW,CAAC;IAmCvB;;OAEG;IACG,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,O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;KAAC,CAAC,CAAC;CAsBnI"}
@@ -3,6 +3,7 @@
3
3
  * Uses `gh` command for GitHub API operations
4
4
  */
5
5
  import { execSync } from 'child_process';
6
+ import { DuplicateDetector } from './duplicate-detector.js';
6
7
  export class GitHubClient {
7
8
  constructor(repo) {
8
9
  // Auto-detect repo from git remote if not provided
@@ -83,24 +84,35 @@ export class GitHubClient {
83
84
  }
84
85
  }
85
86
  /**
86
- * Create epic issue (increment-level)
87
+ * Create epic issue (increment-level) with FULL DUPLICATE PROTECTION
87
88
  */
88
89
  async createEpicIssue(title, body, milestone, labels = []) {
89
- const labelArgs = labels.map(l => `-l "${l}"`).join(' ');
90
- const milestoneArg = milestone ? `-m "${milestone}"` : '';
91
- // Create issue (returns URL)
92
- const createCmd = `gh issue create --repo ${this.repo} --title "${this.escapeQuotes(title)}" --body "${this.escapeQuotes(body)}" ${labelArgs} ${milestoneArg}`;
90
+ // Extract title pattern for duplicate detection (e.g., "[FS-031]" from "[FS-031] Feature Title")
91
+ const titlePattern = DuplicateDetector.extractTitlePattern(title);
92
+ if (!titlePattern) {
93
+ throw new Error(`Epic issue title must start with pattern like [FS-XXX] or [INC-XXXX]: ${title}`);
94
+ }
93
95
  try {
94
- const issueUrl = execSync(createCmd, { encoding: 'utf-8' }).trim();
95
- // Extract issue number from URL (e.g., https://github.com/owner/repo/issues/123)
96
- const issueNumber = parseInt(issueUrl.split('/').pop() || '0', 10);
97
- if (!issueNumber) {
98
- throw new Error('Failed to extract issue number from URL: ' + issueUrl);
99
- }
100
- // Fetch issue details
101
- const viewCmd = `gh issue view ${issueNumber} --repo ${this.repo} --json number,title,body,state,url,labels,milestone`;
96
+ // Use DuplicateDetector for full 3-phase protection
97
+ const result = await DuplicateDetector.createWithProtection({
98
+ title,
99
+ body,
100
+ titlePattern,
101
+ labels: labels.length > 0 ? labels : ['specweave', 'increment'],
102
+ milestone: milestone?.toString(),
103
+ repo: this.repo
104
+ });
105
+ // Fetch full issue details (DuplicateDetector returns minimal info)
106
+ const viewCmd = `gh issue view ${result.issue.number} --repo ${this.repo} --json number,title,body,state,url,labels,milestone`;
102
107
  const output = execSync(viewCmd, { encoding: 'utf-8' });
103
108
  const issue = JSON.parse(output);
109
+ // Log duplicate detection results if any
110
+ if (result.wasReused) {
111
+ console.log(` ♻️ Reused existing issue #${result.issue.number} (duplicate prevention)`);
112
+ }
113
+ if (result.duplicatesFound > 0) {
114
+ console.log(` 🛡️ Duplicates detected: ${result.duplicatesFound} (auto-closed: ${result.duplicatesClosed})`);
115
+ }
104
116
  return {
105
117
  ...issue,
106
118
  html_url: issue.url,