specweave 0.22.0 → 0.22.2

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 (184) hide show
  1. package/CLAUDE.md +211 -0
  2. package/README.md +5 -5
  3. package/bin/specweave.js +5 -8
  4. package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +1 -1
  5. package/dist/plugins/specweave-github/lib/CodeValidator.js +1 -1
  6. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
  7. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
  8. package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
  9. package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
  10. package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
  11. package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
  12. package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
  13. package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
  14. package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
  15. package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
  16. package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
  17. package/dist/src/cli/commands/next-command.d.ts +52 -0
  18. package/dist/src/cli/commands/next-command.d.ts.map +1 -0
  19. package/dist/src/cli/commands/next-command.js +204 -0
  20. package/dist/src/cli/commands/next-command.js.map +1 -0
  21. package/dist/src/cli/commands/sync-specs.d.ts +16 -0
  22. package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
  23. package/dist/src/cli/commands/sync-specs.js +130 -0
  24. package/dist/src/cli/commands/sync-specs.js.map +1 -0
  25. package/dist/src/cli/count-tasks.d.ts +20 -0
  26. package/dist/src/cli/count-tasks.d.ts.map +1 -0
  27. package/dist/src/cli/count-tasks.js +50 -0
  28. package/dist/src/cli/count-tasks.js.map +1 -0
  29. package/dist/src/config/ConfigManager.d.ts.map +1 -1
  30. package/dist/src/config/ConfigManager.js +2 -1
  31. package/dist/src/config/ConfigManager.js.map +1 -1
  32. package/dist/src/config/types.d.ts +50 -50
  33. package/dist/src/core/cicd/state-manager.d.ts +8 -0
  34. package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
  35. package/dist/src/core/cicd/state-manager.js +60 -15
  36. package/dist/src/core/cicd/state-manager.js.map +1 -1
  37. package/dist/src/core/cost-tracker.d.ts.map +1 -1
  38. package/dist/src/core/cost-tracker.js +2 -1
  39. package/dist/src/core/cost-tracker.js.map +1 -1
  40. package/dist/src/core/iac/template-engine.d.ts.map +1 -1
  41. package/dist/src/core/iac/template-engine.js +28 -0
  42. package/dist/src/core/iac/template-engine.js.map +1 -1
  43. package/dist/src/core/iac/template-generator.d.ts +53 -0
  44. package/dist/src/core/iac/template-generator.d.ts.map +1 -0
  45. package/dist/src/core/iac/template-generator.js +125 -0
  46. package/dist/src/core/iac/template-generator.js.map +1 -0
  47. package/dist/src/core/increment/status-auto-transition.js +3 -3
  48. package/dist/src/core/increment/status-auto-transition.js.map +1 -1
  49. package/dist/src/core/living-docs/CodeValidator.js +1 -1
  50. package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
  51. package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
  52. package/dist/src/core/living-docs/content-distributor.js +11 -1
  53. package/dist/src/core/living-docs/content-distributor.js.map +1 -1
  54. package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
  55. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
  56. package/dist/src/core/living-docs/living-docs-sync.js +726 -0
  57. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
  58. package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
  59. package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
  60. package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
  61. package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
  62. package/dist/src/core/plugin-loader.d.ts +7 -0
  63. package/dist/src/core/plugin-loader.d.ts.map +1 -1
  64. package/dist/src/core/plugin-loader.js +18 -1
  65. package/dist/src/core/plugin-loader.js.map +1 -1
  66. package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
  67. package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
  68. package/dist/src/core/serverless/platform-data-loader.js +14 -0
  69. package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
  70. package/dist/src/core/serverless/types.d.ts +1 -1
  71. package/dist/src/core/serverless/types.d.ts.map +1 -1
  72. package/dist/src/core/status-line/status-line-manager.d.ts +6 -2
  73. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  74. package/dist/src/core/status-line/status-line-manager.js +11 -5
  75. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  76. package/dist/src/core/status-line/task-counter.d.ts +69 -0
  77. package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
  78. package/dist/src/core/status-line/task-counter.js +107 -0
  79. package/dist/src/core/status-line/task-counter.js.map +1 -0
  80. package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
  81. package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
  82. package/dist/src/core/workflow/autonomous-executor.js +275 -0
  83. package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
  84. package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
  85. package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
  86. package/dist/src/core/workflow/backlog-scanner.js +170 -0
  87. package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
  88. package/dist/src/core/workflow/command-invoker.d.ts +86 -0
  89. package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
  90. package/dist/src/core/workflow/command-invoker.js +131 -0
  91. package/dist/src/core/workflow/command-invoker.js.map +1 -0
  92. package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
  93. package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
  94. package/dist/src/core/workflow/cost-estimator.js +222 -0
  95. package/dist/src/core/workflow/cost-estimator.js.map +1 -0
  96. package/dist/src/core/workflow/index.d.ts +20 -0
  97. package/dist/src/core/workflow/index.d.ts.map +1 -0
  98. package/dist/src/core/workflow/index.js +24 -0
  99. package/dist/src/core/workflow/index.js.map +1 -0
  100. package/dist/src/core/workflow/state-manager.d.ts +107 -0
  101. package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
  102. package/dist/src/core/workflow/state-manager.js +126 -0
  103. package/dist/src/core/workflow/state-manager.js.map +1 -0
  104. package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
  105. package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
  106. package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
  107. package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
  108. package/dist/src/init/architecture/types.d.ts +10 -10
  109. package/dist/src/metrics/dora-calculator.js +2 -2
  110. package/dist/src/metrics/dora-calculator.js.map +1 -1
  111. package/dist/src/utils/pricing-constants.d.ts +5 -2
  112. package/dist/src/utils/pricing-constants.d.ts.map +1 -1
  113. package/dist/src/utils/pricing-constants.js +3 -2
  114. package/dist/src/utils/pricing-constants.js.map +1 -1
  115. package/package.json +4 -4
  116. package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
  117. package/plugins/specweave/agents/pm/AGENT.md +58 -1
  118. package/plugins/specweave/commands/specweave-archive-features.md +1 -1
  119. package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
  120. package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
  121. package/plugins/specweave/commands/specweave-done.md +12 -0
  122. package/plugins/specweave/commands/specweave-plan.md +1 -1
  123. package/plugins/specweave/commands/specweave-progress.md +108 -379
  124. package/plugins/specweave/commands/specweave-reopen.md +1 -1
  125. package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
  126. package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
  127. package/plugins/specweave/hooks/lib/update-status-line.sh +44 -35
  128. package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
  129. package/plugins/specweave/hooks/user-prompt-submit.sh +17 -35
  130. package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
  131. package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
  132. package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
  133. package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
  134. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
  135. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
  136. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
  137. package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
  138. package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
  139. package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
  140. package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
  141. package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
  142. package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
  143. package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
  144. package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
  145. package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
  146. package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
  147. package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
  148. package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
  149. package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
  150. package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
  151. package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
  152. package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
  153. package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
  154. package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
  155. package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
  156. package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
  157. package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
  158. package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
  159. package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
  160. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
  161. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
  162. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
  163. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
  164. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
  165. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
  166. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
  167. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
  168. package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
  169. package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
  170. package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
  171. package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
  172. package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
  173. package/plugins/specweave-github/lib/CodeValidator.ts +1 -1
  174. package/plugins/specweave-github/lib/github-client-v2.js +29 -0
  175. package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
  176. package/plugins/specweave-github/lib/task-sync.js +4 -0
  177. package/plugins/specweave-github/lib/task-sync.ts +7 -0
  178. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  179. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +2022 -0
  180. package/src/templates/CLAUDE.md.template +31 -0
  181. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
  182. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
  183. package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
  184. package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
@@ -563,6 +563,37 @@ Skills/agents activate automatically based on context.
563
563
  - >80% coverage for critical paths
564
564
  - Tests MUST tell the truth
565
565
 
566
+ ### Writing Modern Tests (Vitest)
567
+
568
+ **SpecWeave uses Vitest**. Key patterns:
569
+
570
+ ```typescript
571
+ // ✅ CORRECT: ES6 imports, Vitest API, type-safe mocks
572
+ import { describe, it, expect, vi } from 'vitest';
573
+ vi.mock('fs-extra', () => ({ default: { readFile: vi.fn() } }));
574
+ import fs from 'fs-extra';
575
+
576
+ describe('Feature', () => {
577
+ const mockReadFile = vi.mocked(fs.readFile);
578
+
579
+ beforeEach(() => {
580
+ vi.clearAllMocks();
581
+ mockReadFile.mockResolvedValue('data');
582
+ });
583
+
584
+ it('works', async () => {
585
+ const result = await MyModule.doSomething();
586
+ expect(mockReadFile).toHaveBeenCalled();
587
+ });
588
+ });
589
+ ```
590
+
591
+ **Common mistakes to avoid**:
592
+ - ❌ `require()` → ✅ `import` (ES modules only)
593
+ - ❌ `jest.fn()` → ✅ `vi.fn()` (Vitest API)
594
+ - ❌ `fs as anyed<>` → ✅ `vi.mocked(fs.method)` (type-safe)
595
+ - ❌ External variable in `vi.mock()` factory → ✅ Inline `vi.fn()`
596
+
566
597
  ---
567
598
 
568
599
  ## Key SpecWeave Principles
@@ -1,116 +0,0 @@
1
- /**
2
- * Three-Layer Bidirectional Sync Manager
3
- *
4
- * Manages synchronization between three layers:
5
- * 1. GitHub Issues (stakeholder UI)
6
- * 2. Living Docs User Stories (intermediate)
7
- * 3. Increment spec.md + tasks.md (source of truth)
8
- *
9
- * Sync flows:
10
- * - GitHub → Living Docs → Increment (checkbox changes from stakeholders)
11
- * - Increment → Living Docs → GitHub (implementation updates)
12
- */
13
- /**
14
- * Sync direction
15
- */
16
- export type SyncDirection = 'github-to-increment' | 'increment-to-github' | 'bidirectional';
17
- /**
18
- * Sync result
19
- */
20
- export interface SyncResult {
21
- /** Number of ACs synced */
22
- acsSynced: number;
23
- /** Number of tasks synced */
24
- tasksSynced: number;
25
- /** Conflicts detected (Increment always wins) */
26
- conflictsResolved: number;
27
- /** Tasks reopened due to missing code */
28
- tasksReopened: number;
29
- /** Errors encountered */
30
- errors: string[];
31
- /** Warnings */
32
- warnings: string[];
33
- }
34
- /**
35
- * ThreeLayerSyncManager - Handles bidirectional sync
36
- */
37
- export declare class ThreeLayerSyncManager {
38
- private distributor;
39
- private codeValidator;
40
- private completionPropagator;
41
- constructor();
42
- /**
43
- * Sync GitHub Issues → Living Docs → Increment
44
- *
45
- * Handles checkbox changes from stakeholders in GitHub.
46
- *
47
- * @param githubIssueId - GitHub issue number
48
- * @param incrementPath - Path to increment
49
- * @param livingDocsPath - Path to living docs
50
- */
51
- syncGitHubToIncrement(githubIssueId: number, incrementPath: string, livingDocsPath: string): Promise<SyncResult>;
52
- /**
53
- * Sync Increment → Living Docs → GitHub
54
- *
55
- * Propagates implementation changes to stakeholders.
56
- *
57
- * @param incrementPath - Path to increment
58
- * @param livingDocsPath - Path to living docs
59
- */
60
- syncIncrementToGitHub(incrementPath: string, livingDocsPath: string): Promise<SyncResult>;
61
- /**
62
- * Bidirectional sync with conflict resolution
63
- *
64
- * Increment always wins in conflicts (source of truth discipline).
65
- */
66
- syncBidirectional(incrementPath: string, livingDocsPath: string): Promise<SyncResult>;
67
- /**
68
- * Reopen task if code validation fails
69
- *
70
- * @param taskId - Task ID to reopen
71
- * @param incrementPath - Path to increment
72
- * @param reason - Reason for reopening
73
- */
74
- reopenTask(taskId: string, incrementPath: string, reason: string): Promise<void>;
75
- /**
76
- * Fetch GitHub issue checkbox states
77
- */
78
- private fetchGitHubCheckboxStates;
79
- /**
80
- * Parse checkbox states from GitHub issue body
81
- */
82
- private parseCheckboxStatesFromBody;
83
- /**
84
- * Find User Story file by GitHub issue number
85
- */
86
- private findUserStoryByGitHubIssue;
87
- /**
88
- * Find all markdown files recursively
89
- */
90
- private findMarkdownFiles;
91
- /**
92
- * Update AC checkbox in content
93
- */
94
- private updateAcCheckboxInContent;
95
- /**
96
- * Update Task checkbox in content
97
- */
98
- private updateTaskCheckboxInContent;
99
- /**
100
- * Sync Living Docs changes to Increment
101
- */
102
- private syncLivingDocsToIncrement;
103
- /**
104
- * Parse ACs from content
105
- */
106
- private parseAcsFromContent;
107
- /**
108
- * Parse Tasks from content
109
- */
110
- private parseTasksFromContent;
111
- /**
112
- * Update task completion in tasks.md file
113
- */
114
- private updateTaskCompletionInTasksFile;
115
- }
116
- //# sourceMappingURL=ThreeLayerSyncManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThreeLayerSyncManager.d.ts","sourceRoot":"","sources":["../../../../src/core/living-docs/ThreeLayerSyncManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,qBAAqB,GAAG,qBAAqB,GAAG,eAAe,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAElB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IAEpB,iDAAiD;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IAEtB,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,eAAe;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAgBD;;GAEG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,oBAAoB,CAAuB;;IAQnD;;;;;;;;OAQG;IACG,qBAAqB,CACzB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC;IA8DtB;;;;;;;OAOG;IACG,qBAAqB,CACzB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC;IAoCtB;;;;OAIG;IACG,iBAAiB,CACrB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC;IAYtB;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCtF;;OAEG;YACW,yBAAyB;IAYvC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IA8BnC;;OAEG;YACW,0BAA0B;IAuBxC;;OAEG;YACW,iBAAiB;IAqB/B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAMjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAMnC;;OAEG;YACW,yBAAyB;IAiCvC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;IACH,OAAO,CAAC,+BAA+B;CAYxC"}
@@ -1,356 +0,0 @@
1
- /**
2
- * Three-Layer Bidirectional Sync Manager
3
- *
4
- * Manages synchronization between three layers:
5
- * 1. GitHub Issues (stakeholder UI)
6
- * 2. Living Docs User Stories (intermediate)
7
- * 3. Increment spec.md + tasks.md (source of truth)
8
- *
9
- * Sync flows:
10
- * - GitHub → Living Docs → Increment (checkbox changes from stakeholders)
11
- * - Increment → Living Docs → GitHub (implementation updates)
12
- */
13
- import fs from 'fs/promises';
14
- import path from 'path';
15
- import { execSync } from 'child_process';
16
- import { SpecDistributor } from './SpecDistributor.js';
17
- import { CodeValidator } from './CodeValidator.js';
18
- import { CompletionPropagator } from './CompletionPropagator.js';
19
- /**
20
- * ThreeLayerSyncManager - Handles bidirectional sync
21
- */
22
- export class ThreeLayerSyncManager {
23
- constructor() {
24
- this.distributor = new SpecDistributor();
25
- this.codeValidator = new CodeValidator();
26
- this.completionPropagator = new CompletionPropagator();
27
- }
28
- /**
29
- * Sync GitHub Issues → Living Docs → Increment
30
- *
31
- * Handles checkbox changes from stakeholders in GitHub.
32
- *
33
- * @param githubIssueId - GitHub issue number
34
- * @param incrementPath - Path to increment
35
- * @param livingDocsPath - Path to living docs
36
- */
37
- async syncGitHubToIncrement(githubIssueId, incrementPath, livingDocsPath) {
38
- const result = {
39
- acsSynced: 0,
40
- tasksSynced: 0,
41
- conflictsResolved: 0,
42
- tasksReopened: 0,
43
- errors: [],
44
- warnings: []
45
- };
46
- try {
47
- // 1. Fetch GitHub issue checkbox states
48
- const checkboxStates = await this.fetchGitHubCheckboxStates(githubIssueId);
49
- // 2. Find corresponding User Story file
50
- const userStoryFile = await this.findUserStoryByGitHubIssue(livingDocsPath, githubIssueId);
51
- if (!userStoryFile) {
52
- result.errors.push(`No User Story file found for GitHub issue #${githubIssueId}`);
53
- return result;
54
- }
55
- // 3. Update Living Docs User Story
56
- const livingDocsContent = await fs.readFile(userStoryFile, 'utf-8');
57
- let updatedContent = livingDocsContent;
58
- for (const checkbox of checkboxStates) {
59
- if (checkbox.type === 'ac') {
60
- updatedContent = this.updateAcCheckboxInContent(updatedContent, checkbox.id, checkbox.completed);
61
- result.acsSynced++;
62
- }
63
- else {
64
- updatedContent = this.updateTaskCheckboxInContent(updatedContent, checkbox.id, checkbox.completed);
65
- result.tasksSynced++;
66
- }
67
- }
68
- await fs.writeFile(userStoryFile, updatedContent, 'utf-8');
69
- // 4. Validate code exists for completed tasks
70
- const completedTasks = checkboxStates.filter(cb => cb.type === 'task' && cb.completed);
71
- for (const taskCheckbox of completedTasks) {
72
- const codeExists = await this.codeValidator.validateCodeExists(taskCheckbox.id, incrementPath);
73
- if (!codeExists) {
74
- // Reopen task
75
- await this.reopenTask(taskCheckbox.id, incrementPath, 'Code validation failed: Expected files not found');
76
- result.tasksReopened++;
77
- result.warnings.push(`Task ${taskCheckbox.id} reopened: Code not found`);
78
- }
79
- }
80
- // 5. Update Increment (source of truth)
81
- await this.syncLivingDocsToIncrement(userStoryFile, incrementPath);
82
- // 6. Propagate completion bottom-up (Tasks → ACs → User Stories)
83
- await this.completionPropagator.propagateCompletion(incrementPath);
84
- }
85
- catch (error) {
86
- result.errors.push(error.message);
87
- }
88
- return result;
89
- }
90
- /**
91
- * Sync Increment → Living Docs → GitHub
92
- *
93
- * Propagates implementation changes to stakeholders.
94
- *
95
- * @param incrementPath - Path to increment
96
- * @param livingDocsPath - Path to living docs
97
- */
98
- async syncIncrementToGitHub(incrementPath, livingDocsPath) {
99
- const result = {
100
- acsSynced: 0,
101
- tasksSynced: 0,
102
- conflictsResolved: 0,
103
- tasksReopened: 0,
104
- errors: [],
105
- warnings: []
106
- };
107
- try {
108
- // 1. Read increment spec.md and tasks.md
109
- // 2. Update Living Docs User Stories (via SpecDistributor)
110
- await this.distributor.copyAcsAndTasksToUserStories(incrementPath, livingDocsPath);
111
- // 3. Count synced items
112
- const specPath = path.join(incrementPath, 'spec.md');
113
- const tasksPath = path.join(incrementPath, 'tasks.md');
114
- const specContent = await fs.readFile(specPath, 'utf-8');
115
- const tasksContent = await fs.readFile(tasksPath, 'utf-8');
116
- result.acsSynced = (specContent.match(/- \[([ x])\] AC-/g) || []).length;
117
- result.tasksSynced = (tasksContent.match(/### T-\d+/g) || []).length;
118
- // 4. Update GitHub issues with latest status
119
- // This would integrate with GitHub API to update issue body checkboxes
120
- // For now, we'll mark this as a placeholder for integration
121
- result.warnings.push('GitHub issue update not implemented yet - manual sync required');
122
- }
123
- catch (error) {
124
- result.errors.push(error.message);
125
- }
126
- return result;
127
- }
128
- /**
129
- * Bidirectional sync with conflict resolution
130
- *
131
- * Increment always wins in conflicts (source of truth discipline).
132
- */
133
- async syncBidirectional(incrementPath, livingDocsPath) {
134
- // Always prioritize Increment → GitHub direction
135
- // GitHub changes are advisory only (source of truth discipline)
136
- const result = await this.syncIncrementToGitHub(incrementPath, livingDocsPath);
137
- // Detect conflicts by checking if GitHub has different states
138
- // If conflicts exist, Increment wins and overwrites GitHub
139
- result.warnings.push('Bidirectional sync: Increment is source of truth, GitHub is informational');
140
- return result;
141
- }
142
- /**
143
- * Reopen task if code validation fails
144
- *
145
- * @param taskId - Task ID to reopen
146
- * @param incrementPath - Path to increment
147
- * @param reason - Reason for reopening
148
- */
149
- async reopenTask(taskId, incrementPath, reason) {
150
- try {
151
- // 1. Uncheck task in increment tasks.md
152
- const tasksPath = path.join(incrementPath, 'tasks.md');
153
- let tasksContent = await fs.readFile(tasksPath, 'utf-8');
154
- // Find task section and uncheck "Completed" field
155
- const taskPattern = new RegExp(`### ${taskId}:.*?(?=###|$)`, 's');
156
- const taskMatch = tasksContent.match(taskPattern);
157
- if (taskMatch) {
158
- const taskSection = taskMatch[0];
159
- const updatedSection = taskSection.replace(/\*\*Completed\*\*:\s*\d{4}-\d{2}-\d{2}/, '**Completed**: Not completed');
160
- tasksContent = tasksContent.replace(taskSection, updatedSection);
161
- await fs.writeFile(tasksPath, tasksContent, 'utf-8');
162
- }
163
- // 2. Add comment to task explaining reopen
164
- const comment = `\n**Reopened**: ${new Date().toISOString().split('T')[0]} - ${reason}\n`;
165
- tasksContent = tasksContent.replace(new RegExp(`(### ${taskId}:.*?)\n---`, 's'), `$1\n${comment}---`);
166
- await fs.writeFile(tasksPath, tasksContent, 'utf-8');
167
- // 3. TODO: Add GitHub comment explaining why
168
- // This would use GitHub API to add a comment to the issue
169
- // For now, this is a placeholder
170
- }
171
- catch (error) {
172
- throw new Error(`Failed to reopen task ${taskId}: ${error.message}`);
173
- }
174
- }
175
- /**
176
- * Fetch GitHub issue checkbox states
177
- */
178
- async fetchGitHubCheckboxStates(issueId) {
179
- try {
180
- // Fetch issue body using gh CLI
181
- const cmd = `gh issue view ${issueId} --json body --jq .body`;
182
- const body = execSync(cmd, { encoding: 'utf-8' }).trim();
183
- return this.parseCheckboxStatesFromBody(body);
184
- }
185
- catch (error) {
186
- throw new Error(`Failed to fetch GitHub issue #${issueId}: ${error.message}`);
187
- }
188
- }
189
- /**
190
- * Parse checkbox states from GitHub issue body
191
- */
192
- parseCheckboxStatesFromBody(body) {
193
- const states = [];
194
- const lines = body.split('\n');
195
- for (const line of lines) {
196
- // Match AC checkboxes: - [x] AC-US1-01: Description
197
- const acMatch = line.match(/^- \[([ x])\] (AC-[A-Z0-9]+-\d+):/);
198
- if (acMatch) {
199
- states.push({
200
- id: acMatch[2],
201
- completed: acMatch[1] === 'x',
202
- type: 'ac'
203
- });
204
- continue;
205
- }
206
- // Match Task checkboxes: - [x] T-001: Description
207
- const taskMatch = line.match(/^- \[([ x])\] (T-\d+):/);
208
- if (taskMatch) {
209
- states.push({
210
- id: taskMatch[2],
211
- completed: taskMatch[1] === 'x',
212
- type: 'task'
213
- });
214
- }
215
- }
216
- return states;
217
- }
218
- /**
219
- * Find User Story file by GitHub issue number
220
- */
221
- async findUserStoryByGitHubIssue(livingDocsPath, issueId) {
222
- try {
223
- // Search for user story files containing GitHub issue reference
224
- const userStoriesPath = path.join(livingDocsPath, 'user-stories');
225
- const files = await this.findMarkdownFiles(userStoriesPath);
226
- for (const file of files) {
227
- const content = await fs.readFile(file, 'utf-8');
228
- // Look for GitHub issue reference in frontmatter or content
229
- if (content.includes(`github_issue: ${issueId}`) || content.includes(`#${issueId}`)) {
230
- return file;
231
- }
232
- }
233
- return null;
234
- }
235
- catch {
236
- return null;
237
- }
238
- }
239
- /**
240
- * Find all markdown files recursively
241
- */
242
- async findMarkdownFiles(dir) {
243
- const files = [];
244
- try {
245
- const entries = await fs.readdir(dir, { withFileTypes: true });
246
- for (const entry of entries) {
247
- const fullPath = path.join(dir, entry.name);
248
- if (entry.isDirectory()) {
249
- files.push(...await this.findMarkdownFiles(fullPath));
250
- }
251
- else if (entry.isFile() && entry.name.endsWith('.md')) {
252
- files.push(fullPath);
253
- }
254
- }
255
- }
256
- catch {
257
- // Directory doesn't exist, return empty
258
- }
259
- return files;
260
- }
261
- /**
262
- * Update AC checkbox in content
263
- */
264
- updateAcCheckboxInContent(content, acId, completed) {
265
- const checkbox = completed ? 'x' : ' ';
266
- const pattern = new RegExp(`^- \\[([ x])\\] ${acId}:`, 'gm');
267
- return content.replace(pattern, `- [${checkbox}] ${acId}:`);
268
- }
269
- /**
270
- * Update Task checkbox in content
271
- */
272
- updateTaskCheckboxInContent(content, taskId, completed) {
273
- const checkbox = completed ? 'x' : ' ';
274
- const pattern = new RegExp(`^- \\[([ x])\\] ${taskId}:`, 'gm');
275
- return content.replace(pattern, `- [${checkbox}] ${taskId}:`);
276
- }
277
- /**
278
- * Sync Living Docs changes to Increment
279
- */
280
- async syncLivingDocsToIncrement(userStoryFile, incrementPath) {
281
- // Read User Story file
282
- const content = await fs.readFile(userStoryFile, 'utf-8');
283
- // Parse ACs and Tasks
284
- const acs = this.parseAcsFromContent(content);
285
- const tasks = this.parseTasksFromContent(content);
286
- // Update increment spec.md
287
- if (acs.length > 0) {
288
- const specPath = path.join(incrementPath, 'spec.md');
289
- let specContent = await fs.readFile(specPath, 'utf-8');
290
- for (const ac of acs) {
291
- specContent = this.updateAcCheckboxInContent(specContent, ac.id, ac.completed);
292
- }
293
- await fs.writeFile(specPath, specContent, 'utf-8');
294
- }
295
- // Update increment tasks.md
296
- if (tasks.length > 0) {
297
- const tasksPath = path.join(incrementPath, 'tasks.md');
298
- let tasksContent = await fs.readFile(tasksPath, 'utf-8');
299
- for (const task of tasks) {
300
- tasksContent = this.updateTaskCompletionInTasksFile(tasksContent, task.id, task.completed);
301
- }
302
- await fs.writeFile(tasksPath, tasksContent, 'utf-8');
303
- }
304
- }
305
- /**
306
- * Parse ACs from content
307
- */
308
- parseAcsFromContent(content) {
309
- const acs = [];
310
- const lines = content.split('\n');
311
- for (const line of lines) {
312
- const match = line.match(/^- \[([ x])\] (AC-[A-Z0-9]+-\d+):/);
313
- if (match) {
314
- acs.push({
315
- id: match[2],
316
- completed: match[1] === 'x'
317
- });
318
- }
319
- }
320
- return acs;
321
- }
322
- /**
323
- * Parse Tasks from content
324
- */
325
- parseTasksFromContent(content) {
326
- const tasks = [];
327
- const lines = content.split('\n');
328
- for (const line of lines) {
329
- const match = line.match(/^- \[([ x])\] (T-\d+):/);
330
- if (match) {
331
- tasks.push({
332
- id: match[2],
333
- completed: match[1] === 'x'
334
- });
335
- }
336
- }
337
- return tasks;
338
- }
339
- /**
340
- * Update task completion in tasks.md file
341
- */
342
- updateTaskCompletionInTasksFile(content, taskId, completed) {
343
- if (completed) {
344
- // Add completion date
345
- const today = new Date().toISOString().split('T')[0];
346
- const pattern = new RegExp(`(### ${taskId}:.*?)\\n\\*\\*Completed\\*\\*:.*?\\n`, 's');
347
- return content.replace(pattern, `$1\n**Completed**: ${today}\n`);
348
- }
349
- else {
350
- // Remove completion date
351
- const pattern = new RegExp(`(### ${taskId}:.*?)\\n\\*\\*Completed\\*\\*:.*?\\n`, 's');
352
- return content.replace(pattern, `$1\n**Completed**: Not completed\n`);
353
- }
354
- }
355
- }
356
- //# sourceMappingURL=ThreeLayerSyncManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThreeLayerSyncManager.js","sourceRoot":"","sources":["../../../../src/core/living-docs/ThreeLayerSyncManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MA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