@mobiman/vector 1.1.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 (225) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/agents/vector-codebase-mapper.md +770 -0
  4. package/agents/vector-debugger.md +1338 -0
  5. package/agents/vector-executor.md +487 -0
  6. package/agents/vector-integration-checker.md +443 -0
  7. package/agents/vector-nyquist-auditor.md +176 -0
  8. package/agents/vector-phase-researcher.md +553 -0
  9. package/agents/vector-plan-checker.md +706 -0
  10. package/agents/vector-planner.md +1307 -0
  11. package/agents/vector-project-researcher.md +629 -0
  12. package/agents/vector-research-synthesizer.md +247 -0
  13. package/agents/vector-roadmapper.md +650 -0
  14. package/agents/vector-ui-auditor.md +439 -0
  15. package/agents/vector-ui-checker.md +300 -0
  16. package/agents/vector-ui-researcher.md +353 -0
  17. package/agents/vector-verifier.md +579 -0
  18. package/bin/install.cjs +2907 -0
  19. package/bin/install.cjs.map +1 -0
  20. package/bin/install.cts +3103 -0
  21. package/bin/install.d.cts +3 -0
  22. package/bin/install.d.cts.map +1 -0
  23. package/commands/vector/add-phase.md +43 -0
  24. package/commands/vector/add-tests.md +41 -0
  25. package/commands/vector/add-todo.md +47 -0
  26. package/commands/vector/audit-milestone.md +36 -0
  27. package/commands/vector/autonomous.md +41 -0
  28. package/commands/vector/check-todos.md +45 -0
  29. package/commands/vector/cleanup.md +18 -0
  30. package/commands/vector/complete-milestone.md +136 -0
  31. package/commands/vector/debug.md +168 -0
  32. package/commands/vector/discuss-phase.md +90 -0
  33. package/commands/vector/do.md +30 -0
  34. package/commands/vector/execute-phase.md +41 -0
  35. package/commands/vector/health.md +22 -0
  36. package/commands/vector/help.md +22 -0
  37. package/commands/vector/insert-phase.md +32 -0
  38. package/commands/vector/join-discord.md +18 -0
  39. package/commands/vector/list-phase-assumptions.md +46 -0
  40. package/commands/vector/map-codebase.md +71 -0
  41. package/commands/vector/new-milestone.md +44 -0
  42. package/commands/vector/new-project.md +42 -0
  43. package/commands/vector/pause-work.md +38 -0
  44. package/commands/vector/plan-milestone-gaps.md +34 -0
  45. package/commands/vector/plan-phase.md +45 -0
  46. package/commands/vector/progress.md +24 -0
  47. package/commands/vector/quick.md +47 -0
  48. package/commands/vector/reapply-patches.md +123 -0
  49. package/commands/vector/remove-phase.md +31 -0
  50. package/commands/vector/research-phase.md +190 -0
  51. package/commands/vector/resume-work.md +40 -0
  52. package/commands/vector/set-profile.md +12 -0
  53. package/commands/vector/settings.md +36 -0
  54. package/commands/vector/stats.md +18 -0
  55. package/commands/vector/ui-phase.md +34 -0
  56. package/commands/vector/ui-review.md +32 -0
  57. package/commands/vector/update.md +37 -0
  58. package/commands/vector/validate-phase.md +35 -0
  59. package/commands/vector/verify-work.md +38 -0
  60. package/core/bin/lib/commands.cjs +641 -0
  61. package/core/bin/lib/commands.cjs.map +1 -0
  62. package/core/bin/lib/commands.cts +712 -0
  63. package/core/bin/lib/commands.d.cts +23 -0
  64. package/core/bin/lib/commands.d.cts.map +1 -0
  65. package/core/bin/lib/config.cjs +281 -0
  66. package/core/bin/lib/config.cjs.map +1 -0
  67. package/core/bin/lib/config.cts +301 -0
  68. package/core/bin/lib/config.d.cts +50 -0
  69. package/core/bin/lib/config.d.cts.map +1 -0
  70. package/core/bin/lib/core.cjs +483 -0
  71. package/core/bin/lib/core.cjs.map +1 -0
  72. package/core/bin/lib/core.cts +544 -0
  73. package/core/bin/lib/core.d.cts +96 -0
  74. package/core/bin/lib/core.d.cts.map +1 -0
  75. package/core/bin/lib/frontmatter.cjs +341 -0
  76. package/core/bin/lib/frontmatter.cjs.map +1 -0
  77. package/core/bin/lib/frontmatter.cts +295 -0
  78. package/core/bin/lib/frontmatter.d.cts +18 -0
  79. package/core/bin/lib/frontmatter.d.cts.map +1 -0
  80. package/core/bin/lib/init.cjs +674 -0
  81. package/core/bin/lib/init.cjs.map +1 -0
  82. package/core/bin/lib/init.cts +775 -0
  83. package/core/bin/lib/init.d.cts +16 -0
  84. package/core/bin/lib/init.d.cts.map +1 -0
  85. package/core/bin/lib/milestone.cjs +210 -0
  86. package/core/bin/lib/milestone.cjs.map +1 -0
  87. package/core/bin/lib/milestone.cts +241 -0
  88. package/core/bin/lib/milestone.d.cts +11 -0
  89. package/core/bin/lib/milestone.d.cts.map +1 -0
  90. package/core/bin/lib/model-profiles.cjs +62 -0
  91. package/core/bin/lib/model-profiles.cjs.map +1 -0
  92. package/core/bin/lib/model-profiles.cts +66 -0
  93. package/core/bin/lib/model-profiles.d.cts +33 -0
  94. package/core/bin/lib/model-profiles.d.cts.map +1 -0
  95. package/core/bin/lib/phase.cjs +713 -0
  96. package/core/bin/lib/phase.cjs.map +1 -0
  97. package/core/bin/lib/phase.cts +914 -0
  98. package/core/bin/lib/phase.d.cts +21 -0
  99. package/core/bin/lib/phase.d.cts.map +1 -0
  100. package/core/bin/lib/roadmap.cjs +246 -0
  101. package/core/bin/lib/roadmap.cjs.map +1 -0
  102. package/core/bin/lib/roadmap.cts +311 -0
  103. package/core/bin/lib/roadmap.d.cts +7 -0
  104. package/core/bin/lib/roadmap.d.cts.map +1 -0
  105. package/core/bin/lib/state.cjs +709 -0
  106. package/core/bin/lib/state.cjs.map +1 -0
  107. package/core/bin/lib/state.cts +718 -0
  108. package/core/bin/lib/state.d.cts +47 -0
  109. package/core/bin/lib/state.d.cts.map +1 -0
  110. package/core/bin/lib/template.cjs +220 -0
  111. package/core/bin/lib/template.cjs.map +1 -0
  112. package/core/bin/lib/template.cts +229 -0
  113. package/core/bin/lib/template.d.cts +15 -0
  114. package/core/bin/lib/template.d.cts.map +1 -0
  115. package/core/bin/lib/verify.cjs +824 -0
  116. package/core/bin/lib/verify.cjs.map +1 -0
  117. package/core/bin/lib/verify.cts +829 -0
  118. package/core/bin/lib/verify.d.cts +17 -0
  119. package/core/bin/lib/verify.d.cts.map +1 -0
  120. package/core/bin/vector-tools.cjs +641 -0
  121. package/core/bin/vector-tools.cjs.map +1 -0
  122. package/core/bin/vector-tools.cts +603 -0
  123. package/core/bin/vector-tools.d.cts +128 -0
  124. package/core/bin/vector-tools.d.cts.map +1 -0
  125. package/core/references/checkpoints.md +776 -0
  126. package/core/references/continuation-format.md +249 -0
  127. package/core/references/decimal-phase-calculation.md +65 -0
  128. package/core/references/git-integration.md +248 -0
  129. package/core/references/git-planning-commit.md +38 -0
  130. package/core/references/model-profile-resolution.md +36 -0
  131. package/core/references/model-profiles.md +101 -0
  132. package/core/references/phase-argument-parsing.md +61 -0
  133. package/core/references/planning-config.md +200 -0
  134. package/core/references/questioning.md +162 -0
  135. package/core/references/tdd.md +263 -0
  136. package/core/references/ui-brand.md +160 -0
  137. package/core/references/verification-patterns.md +612 -0
  138. package/core/templates/DEBUG.md +164 -0
  139. package/core/templates/UAT.md +247 -0
  140. package/core/templates/UI-SPEC.md +100 -0
  141. package/core/templates/VALIDATION.md +76 -0
  142. package/core/templates/codebase/architecture.md +255 -0
  143. package/core/templates/codebase/concerns.md +310 -0
  144. package/core/templates/codebase/conventions.md +307 -0
  145. package/core/templates/codebase/integrations.md +280 -0
  146. package/core/templates/codebase/stack.md +186 -0
  147. package/core/templates/codebase/structure.md +285 -0
  148. package/core/templates/codebase/testing.md +480 -0
  149. package/core/templates/config.json +37 -0
  150. package/core/templates/context.md +352 -0
  151. package/core/templates/continue-here.md +78 -0
  152. package/core/templates/copilot-instructions.md +7 -0
  153. package/core/templates/debug-subagent-prompt.md +91 -0
  154. package/core/templates/discovery.md +146 -0
  155. package/core/templates/milestone-archive.md +123 -0
  156. package/core/templates/milestone.md +115 -0
  157. package/core/templates/phase-prompt.md +610 -0
  158. package/core/templates/planner-subagent-prompt.md +117 -0
  159. package/core/templates/project.md +184 -0
  160. package/core/templates/requirements.md +231 -0
  161. package/core/templates/research-project/ARCHITECTURE.md +204 -0
  162. package/core/templates/research-project/FEATURES.md +147 -0
  163. package/core/templates/research-project/PITFALLS.md +200 -0
  164. package/core/templates/research-project/STACK.md +120 -0
  165. package/core/templates/research-project/SUMMARY.md +170 -0
  166. package/core/templates/research.md +552 -0
  167. package/core/templates/retrospective.md +54 -0
  168. package/core/templates/roadmap.md +202 -0
  169. package/core/templates/state.md +176 -0
  170. package/core/templates/summary-complex.md +59 -0
  171. package/core/templates/summary-minimal.md +41 -0
  172. package/core/templates/summary-standard.md +48 -0
  173. package/core/templates/summary.md +248 -0
  174. package/core/templates/user-setup.md +311 -0
  175. package/core/templates/verification-report.md +322 -0
  176. package/core/workflows/add-phase.md +112 -0
  177. package/core/workflows/add-tests.md +351 -0
  178. package/core/workflows/add-todo.md +158 -0
  179. package/core/workflows/audit-milestone.md +332 -0
  180. package/core/workflows/autonomous.md +743 -0
  181. package/core/workflows/check-todos.md +177 -0
  182. package/core/workflows/cleanup.md +152 -0
  183. package/core/workflows/complete-milestone.md +766 -0
  184. package/core/workflows/diagnose-issues.md +219 -0
  185. package/core/workflows/discovery-phase.md +289 -0
  186. package/core/workflows/discuss-phase.md +762 -0
  187. package/core/workflows/do.md +104 -0
  188. package/core/workflows/execute-phase.md +468 -0
  189. package/core/workflows/execute-plan.md +483 -0
  190. package/core/workflows/health.md +159 -0
  191. package/core/workflows/help.md +513 -0
  192. package/core/workflows/insert-phase.md +130 -0
  193. package/core/workflows/list-phase-assumptions.md +178 -0
  194. package/core/workflows/map-codebase.md +316 -0
  195. package/core/workflows/new-milestone.md +386 -0
  196. package/core/workflows/new-project.md +1113 -0
  197. package/core/workflows/node-repair.md +92 -0
  198. package/core/workflows/pause-work.md +122 -0
  199. package/core/workflows/plan-milestone-gaps.md +274 -0
  200. package/core/workflows/plan-phase.md +666 -0
  201. package/core/workflows/progress.md +382 -0
  202. package/core/workflows/quick.md +717 -0
  203. package/core/workflows/remove-phase.md +155 -0
  204. package/core/workflows/research-phase.md +74 -0
  205. package/core/workflows/resume-project.md +307 -0
  206. package/core/workflows/settings.md +243 -0
  207. package/core/workflows/stats.md +60 -0
  208. package/core/workflows/transition.md +544 -0
  209. package/core/workflows/ui-phase.md +290 -0
  210. package/core/workflows/ui-review.md +157 -0
  211. package/core/workflows/update.md +320 -0
  212. package/core/workflows/validate-phase.md +167 -0
  213. package/core/workflows/verify-phase.md +243 -0
  214. package/core/workflows/verify-work.md +584 -0
  215. package/package.json +55 -0
  216. package/scripts/build-hooks.cjs +38 -0
  217. package/scripts/build-hooks.cjs.map +1 -0
  218. package/scripts/build-hooks.cts +41 -0
  219. package/scripts/build-hooks.d.cts +6 -0
  220. package/scripts/build-hooks.d.cts.map +1 -0
  221. package/scripts/run-tests.cjs +28 -0
  222. package/scripts/run-tests.cjs.map +1 -0
  223. package/scripts/run-tests.cts +28 -0
  224. package/scripts/run-tests.d.cts +3 -0
  225. package/scripts/run-tests.d.cts.map +1 -0
@@ -0,0 +1,824 @@
1
+ "use strict";
2
+ /**
3
+ * Verify — Verification suite, consistency, and health validation
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.cmdVerifySummary = cmdVerifySummary;
10
+ exports.cmdVerifyPlanStructure = cmdVerifyPlanStructure;
11
+ exports.cmdVerifyPhaseCompleteness = cmdVerifyPhaseCompleteness;
12
+ exports.cmdVerifyReferences = cmdVerifyReferences;
13
+ exports.cmdVerifyCommits = cmdVerifyCommits;
14
+ exports.cmdVerifyArtifacts = cmdVerifyArtifacts;
15
+ exports.cmdVerifyKeyLinks = cmdVerifyKeyLinks;
16
+ exports.cmdValidateConsistency = cmdValidateConsistency;
17
+ exports.cmdValidateHealth = cmdValidateHealth;
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const core_cjs_1 = require("./core.cjs");
21
+ const frontmatter_cjs_1 = require("./frontmatter.cjs");
22
+ const state_cjs_1 = require("./state.cjs");
23
+ function cmdVerifySummary(cwd, summaryPath, checkFileCount, raw) {
24
+ if (!summaryPath) {
25
+ (0, core_cjs_1.error)('summary-path required');
26
+ }
27
+ const fullPath = path_1.default.join(cwd, summaryPath);
28
+ const checkCount = checkFileCount || 2;
29
+ // Check 1: Summary exists
30
+ if (!fs_1.default.existsSync(fullPath)) {
31
+ const result = {
32
+ passed: false,
33
+ checks: {
34
+ summary_exists: false,
35
+ files_created: { checked: 0, found: 0, missing: [] },
36
+ commits_exist: false,
37
+ self_check: 'not_found',
38
+ },
39
+ errors: ['SUMMARY.md not found'],
40
+ };
41
+ (0, core_cjs_1.output)(result, raw, 'failed');
42
+ return;
43
+ }
44
+ const content = fs_1.default.readFileSync(fullPath, 'utf-8');
45
+ const errors = [];
46
+ // Check 2: Spot-check files mentioned in summary
47
+ const mentionedFiles = new Set();
48
+ const patterns = [
49
+ /`([^`]+\.[a-zA-Z]+)`/g,
50
+ /(?:Created|Modified|Added|Updated|Edited):\s*`?([^\s`]+\.[a-zA-Z]+)`?/gi,
51
+ ];
52
+ for (const pattern of patterns) {
53
+ let m;
54
+ while ((m = pattern.exec(content)) !== null) {
55
+ const filePath = m[1];
56
+ if (filePath && !filePath.startsWith('http') && filePath.includes('/')) {
57
+ mentionedFiles.add(filePath);
58
+ }
59
+ }
60
+ }
61
+ const filesToCheck = Array.from(mentionedFiles).slice(0, checkCount);
62
+ const missing = [];
63
+ for (const file of filesToCheck) {
64
+ if (!fs_1.default.existsSync(path_1.default.join(cwd, file))) {
65
+ missing.push(file);
66
+ }
67
+ }
68
+ // Check 3: Commits exist
69
+ const commitHashPattern = /\b[0-9a-f]{7,40}\b/g;
70
+ const hashes = content.match(commitHashPattern) || [];
71
+ let commitsExist = false;
72
+ if (hashes.length > 0) {
73
+ for (const hash of hashes.slice(0, 3)) {
74
+ const result = (0, core_cjs_1.execGit)(cwd, ['cat-file', '-t', hash]);
75
+ if (result.exitCode === 0 && result.stdout === 'commit') {
76
+ commitsExist = true;
77
+ break;
78
+ }
79
+ }
80
+ }
81
+ // Check 4: Self-check section
82
+ let selfCheck = 'not_found';
83
+ const selfCheckPattern = /##\s*(?:Self[- ]?Check|Verification|Quality Check)/i;
84
+ if (selfCheckPattern.test(content)) {
85
+ const passPattern = /(?:all\s+)?(?:pass|✓|✅|complete|succeeded)/i;
86
+ const failPattern = /(?:fail|✗|❌|incomplete|blocked)/i;
87
+ const checkSection = content.slice(content.search(selfCheckPattern));
88
+ if (failPattern.test(checkSection)) {
89
+ selfCheck = 'failed';
90
+ }
91
+ else if (passPattern.test(checkSection)) {
92
+ selfCheck = 'passed';
93
+ }
94
+ }
95
+ if (missing.length > 0)
96
+ errors.push('Missing files: ' + missing.join(', '));
97
+ if (!commitsExist && hashes.length > 0)
98
+ errors.push('Referenced commit hashes not found in git history');
99
+ if (selfCheck === 'failed')
100
+ errors.push('Self-check section indicates failure');
101
+ const checks = {
102
+ summary_exists: true,
103
+ files_created: { checked: filesToCheck.length, found: filesToCheck.length - missing.length, missing },
104
+ commits_exist: commitsExist,
105
+ self_check: selfCheck,
106
+ };
107
+ const passed = missing.length === 0 && selfCheck !== 'failed';
108
+ const result = { passed, checks, errors };
109
+ (0, core_cjs_1.output)(result, raw, passed ? 'passed' : 'failed');
110
+ }
111
+ function cmdVerifyPlanStructure(cwd, filePath, raw) {
112
+ if (!filePath) {
113
+ (0, core_cjs_1.error)('file path required');
114
+ }
115
+ const fullPath = path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(cwd, filePath);
116
+ const content = (0, core_cjs_1.safeReadFile)(fullPath);
117
+ if (!content) {
118
+ (0, core_cjs_1.output)({ error: 'File not found', path: filePath }, raw);
119
+ return;
120
+ }
121
+ const fm = (0, frontmatter_cjs_1.extractFrontmatter)(content);
122
+ const errors = [];
123
+ const warnings = [];
124
+ // Check required frontmatter fields
125
+ const required = ['phase', 'plan', 'type', 'wave', 'depends_on', 'files_modified', 'autonomous', 'must_haves'];
126
+ for (const field of required) {
127
+ if (fm[field] === undefined)
128
+ errors.push(`Missing required frontmatter field: ${field}`);
129
+ }
130
+ // Parse and check task elements
131
+ const taskPattern = /<task[^>]*>([\s\S]*?)<\/task>/g;
132
+ const tasks = [];
133
+ let taskMatch;
134
+ while ((taskMatch = taskPattern.exec(content)) !== null) {
135
+ const taskContent = taskMatch[1];
136
+ const nameMatch = taskContent.match(/<name>([\s\S]*?)<\/name>/);
137
+ const taskName = nameMatch ? nameMatch[1].trim() : 'unnamed';
138
+ const hasFiles = /<files>/.test(taskContent);
139
+ const hasAction = /<action>/.test(taskContent);
140
+ const hasVerify = /<verify>/.test(taskContent);
141
+ const hasDone = /<done>/.test(taskContent);
142
+ if (!nameMatch)
143
+ errors.push('Task missing <name> element');
144
+ if (!hasAction)
145
+ errors.push(`Task '${taskName}' missing <action>`);
146
+ if (!hasVerify)
147
+ warnings.push(`Task '${taskName}' missing <verify>`);
148
+ if (!hasDone)
149
+ warnings.push(`Task '${taskName}' missing <done>`);
150
+ if (!hasFiles)
151
+ warnings.push(`Task '${taskName}' missing <files>`);
152
+ tasks.push({ name: taskName, hasFiles, hasAction, hasVerify, hasDone });
153
+ }
154
+ if (tasks.length === 0)
155
+ warnings.push('No <task> elements found');
156
+ // Wave/depends_on consistency
157
+ if (fm.wave && parseInt(fm.wave) > 1 && (!fm.depends_on || (Array.isArray(fm.depends_on) && fm.depends_on.length === 0))) {
158
+ warnings.push('Wave > 1 but depends_on is empty');
159
+ }
160
+ // Autonomous/checkpoint consistency
161
+ const hasCheckpoints = /<task\s+type=["']?checkpoint/.test(content);
162
+ if (hasCheckpoints && fm.autonomous !== 'false' && fm.autonomous !== false) {
163
+ errors.push('Has checkpoint tasks but autonomous is not false');
164
+ }
165
+ (0, core_cjs_1.output)({
166
+ valid: errors.length === 0,
167
+ errors,
168
+ warnings,
169
+ task_count: tasks.length,
170
+ tasks,
171
+ frontmatter_fields: Object.keys(fm),
172
+ }, raw, errors.length === 0 ? 'valid' : 'invalid');
173
+ }
174
+ function cmdVerifyPhaseCompleteness(cwd, phase, raw) {
175
+ if (!phase) {
176
+ (0, core_cjs_1.error)('phase required');
177
+ }
178
+ const phaseInfo = (0, core_cjs_1.findPhaseInternal)(cwd, phase);
179
+ if (!phaseInfo || !phaseInfo.found) {
180
+ (0, core_cjs_1.output)({ error: 'Phase not found', phase }, raw);
181
+ return;
182
+ }
183
+ const errors = [];
184
+ const warnings = [];
185
+ const phaseDir = path_1.default.join(cwd, phaseInfo.directory);
186
+ // List plans and summaries
187
+ let files;
188
+ try {
189
+ files = fs_1.default.readdirSync(phaseDir);
190
+ }
191
+ catch {
192
+ (0, core_cjs_1.output)({ error: 'Cannot read phase directory' }, raw);
193
+ return;
194
+ }
195
+ const plans = files.filter(f => f.match(/-PLAN\.md$/i));
196
+ const summaries = files.filter(f => f.match(/-SUMMARY\.md$/i));
197
+ // Extract plan IDs (everything before -PLAN.md)
198
+ const planIds = new Set(plans.map(p => p.replace(/-PLAN\.md$/i, '')));
199
+ const summaryIds = new Set(summaries.map(s => s.replace(/-SUMMARY\.md$/i, '')));
200
+ // Plans without summaries
201
+ const incompletePlans = [...planIds].filter(id => !summaryIds.has(id));
202
+ if (incompletePlans.length > 0) {
203
+ errors.push(`Plans without summaries: ${incompletePlans.join(', ')}`);
204
+ }
205
+ // Summaries without plans (orphans)
206
+ const orphanSummaries = [...summaryIds].filter(id => !planIds.has(id));
207
+ if (orphanSummaries.length > 0) {
208
+ warnings.push(`Summaries without plans: ${orphanSummaries.join(', ')}`);
209
+ }
210
+ (0, core_cjs_1.output)({
211
+ complete: errors.length === 0,
212
+ phase: phaseInfo.phase_number,
213
+ plan_count: plans.length,
214
+ summary_count: summaries.length,
215
+ incomplete_plans: incompletePlans,
216
+ orphan_summaries: orphanSummaries,
217
+ errors,
218
+ warnings,
219
+ }, raw, errors.length === 0 ? 'complete' : 'incomplete');
220
+ }
221
+ function cmdVerifyReferences(cwd, filePath, raw) {
222
+ if (!filePath) {
223
+ (0, core_cjs_1.error)('file path required');
224
+ }
225
+ const fullPath = path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(cwd, filePath);
226
+ const content = (0, core_cjs_1.safeReadFile)(fullPath);
227
+ if (!content) {
228
+ (0, core_cjs_1.output)({ error: 'File not found', path: filePath }, raw);
229
+ return;
230
+ }
231
+ const found = [];
232
+ const missing = [];
233
+ // Find @-references: @path/to/file (must contain / to be a file path)
234
+ const atRefs = content.match(/@([^\s\n,)]+\/[^\s\n,)]+)/g) || [];
235
+ for (const ref of atRefs) {
236
+ const cleanRef = ref.slice(1); // remove @
237
+ const resolved = cleanRef.startsWith('~/')
238
+ ? path_1.default.join(process.env.HOME || '', cleanRef.slice(2))
239
+ : path_1.default.join(cwd, cleanRef);
240
+ if (fs_1.default.existsSync(resolved)) {
241
+ found.push(cleanRef);
242
+ }
243
+ else {
244
+ missing.push(cleanRef);
245
+ }
246
+ }
247
+ // Find backtick file paths that look like real paths (contain / and have extension)
248
+ const backtickRefs = content.match(/`([^`]+\/[^`]+\.[a-zA-Z]{1,10})`/g) || [];
249
+ for (const ref of backtickRefs) {
250
+ const cleanRef = ref.slice(1, -1); // remove backticks
251
+ if (cleanRef.startsWith('http') || cleanRef.includes('${') || cleanRef.includes('{{'))
252
+ continue;
253
+ if (found.includes(cleanRef) || missing.includes(cleanRef))
254
+ continue; // dedup
255
+ const resolved = path_1.default.join(cwd, cleanRef);
256
+ if (fs_1.default.existsSync(resolved)) {
257
+ found.push(cleanRef);
258
+ }
259
+ else {
260
+ missing.push(cleanRef);
261
+ }
262
+ }
263
+ (0, core_cjs_1.output)({
264
+ valid: missing.length === 0,
265
+ found: found.length,
266
+ missing,
267
+ total: found.length + missing.length,
268
+ }, raw, missing.length === 0 ? 'valid' : 'invalid');
269
+ }
270
+ function cmdVerifyCommits(cwd, hashes, raw) {
271
+ if (!hashes || hashes.length === 0) {
272
+ (0, core_cjs_1.error)('At least one commit hash required');
273
+ }
274
+ const valid = [];
275
+ const invalid = [];
276
+ for (const hash of hashes) {
277
+ const result = (0, core_cjs_1.execGit)(cwd, ['cat-file', '-t', hash]);
278
+ if (result.exitCode === 0 && result.stdout.trim() === 'commit') {
279
+ valid.push(hash);
280
+ }
281
+ else {
282
+ invalid.push(hash);
283
+ }
284
+ }
285
+ (0, core_cjs_1.output)({
286
+ all_valid: invalid.length === 0,
287
+ valid,
288
+ invalid,
289
+ total: hashes.length,
290
+ }, raw, invalid.length === 0 ? 'valid' : 'invalid');
291
+ }
292
+ function cmdVerifyArtifacts(cwd, planFilePath, raw) {
293
+ if (!planFilePath) {
294
+ (0, core_cjs_1.error)('plan file path required');
295
+ }
296
+ const fullPath = path_1.default.isAbsolute(planFilePath) ? planFilePath : path_1.default.join(cwd, planFilePath);
297
+ const content = (0, core_cjs_1.safeReadFile)(fullPath);
298
+ if (!content) {
299
+ (0, core_cjs_1.output)({ error: 'File not found', path: planFilePath }, raw);
300
+ return;
301
+ }
302
+ const artifacts = (0, frontmatter_cjs_1.parseMustHavesBlock)(content, 'artifacts');
303
+ if (artifacts.length === 0) {
304
+ (0, core_cjs_1.output)({ error: 'No must_haves.artifacts found in frontmatter', path: planFilePath }, raw);
305
+ return;
306
+ }
307
+ const results = [];
308
+ for (const artifact of artifacts) {
309
+ if (typeof artifact === 'string')
310
+ continue; // skip simple string items
311
+ const artObj = artifact;
312
+ const artPath = artObj.path;
313
+ if (!artPath)
314
+ continue;
315
+ const artFullPath = path_1.default.join(cwd, artPath);
316
+ const exists = fs_1.default.existsSync(artFullPath);
317
+ const check = { path: artPath, exists, issues: [], passed: false };
318
+ if (exists) {
319
+ const fileContent = (0, core_cjs_1.safeReadFile)(artFullPath) || '';
320
+ const lineCount = fileContent.split('\n').length;
321
+ if (artObj.min_lines && lineCount < artObj.min_lines) {
322
+ check.issues.push(`Only ${lineCount} lines, need ${artObj.min_lines}`);
323
+ }
324
+ if (artObj.contains && !fileContent.includes(artObj.contains)) {
325
+ check.issues.push(`Missing pattern: ${artObj.contains}`);
326
+ }
327
+ if (artObj.exports) {
328
+ const exports = Array.isArray(artObj.exports) ? artObj.exports : [artObj.exports];
329
+ for (const exp of exports) {
330
+ if (!fileContent.includes(exp))
331
+ check.issues.push(`Missing export: ${exp}`);
332
+ }
333
+ }
334
+ check.passed = check.issues.length === 0;
335
+ }
336
+ else {
337
+ check.issues.push('File not found');
338
+ }
339
+ results.push(check);
340
+ }
341
+ const passed = results.filter(r => r.passed).length;
342
+ (0, core_cjs_1.output)({
343
+ all_passed: passed === results.length,
344
+ passed,
345
+ total: results.length,
346
+ artifacts: results,
347
+ }, raw, passed === results.length ? 'valid' : 'invalid');
348
+ }
349
+ function cmdVerifyKeyLinks(cwd, planFilePath, raw) {
350
+ if (!planFilePath) {
351
+ (0, core_cjs_1.error)('plan file path required');
352
+ }
353
+ const fullPath = path_1.default.isAbsolute(planFilePath) ? planFilePath : path_1.default.join(cwd, planFilePath);
354
+ const content = (0, core_cjs_1.safeReadFile)(fullPath);
355
+ if (!content) {
356
+ (0, core_cjs_1.output)({ error: 'File not found', path: planFilePath }, raw);
357
+ return;
358
+ }
359
+ const keyLinks = (0, frontmatter_cjs_1.parseMustHavesBlock)(content, 'key_links');
360
+ if (keyLinks.length === 0) {
361
+ (0, core_cjs_1.output)({ error: 'No must_haves.key_links found in frontmatter', path: planFilePath }, raw);
362
+ return;
363
+ }
364
+ const results = [];
365
+ for (const link of keyLinks) {
366
+ if (typeof link === 'string')
367
+ continue;
368
+ const linkObj = link;
369
+ const check = { from: linkObj.from, to: linkObj.to, via: linkObj.via || '', verified: false, detail: '' };
370
+ const sourceContent = (0, core_cjs_1.safeReadFile)(path_1.default.join(cwd, linkObj.from || ''));
371
+ if (!sourceContent) {
372
+ check.detail = 'Source file not found';
373
+ }
374
+ else if (linkObj.pattern) {
375
+ try {
376
+ const regex = new RegExp(linkObj.pattern);
377
+ if (regex.test(sourceContent)) {
378
+ check.verified = true;
379
+ check.detail = 'Pattern found in source';
380
+ }
381
+ else {
382
+ const targetContent = (0, core_cjs_1.safeReadFile)(path_1.default.join(cwd, linkObj.to || ''));
383
+ if (targetContent && regex.test(targetContent)) {
384
+ check.verified = true;
385
+ check.detail = 'Pattern found in target';
386
+ }
387
+ else {
388
+ check.detail = `Pattern "${linkObj.pattern}" not found in source or target`;
389
+ }
390
+ }
391
+ }
392
+ catch {
393
+ check.detail = `Invalid regex pattern: ${linkObj.pattern}`;
394
+ }
395
+ }
396
+ else {
397
+ // No pattern: just check source references target
398
+ if (sourceContent.includes(linkObj.to || '')) {
399
+ check.verified = true;
400
+ check.detail = 'Target referenced in source';
401
+ }
402
+ else {
403
+ check.detail = 'Target not referenced in source';
404
+ }
405
+ }
406
+ results.push(check);
407
+ }
408
+ const verified = results.filter(r => r.verified).length;
409
+ (0, core_cjs_1.output)({
410
+ all_verified: verified === results.length,
411
+ verified,
412
+ total: results.length,
413
+ links: results,
414
+ }, raw, verified === results.length ? 'valid' : 'invalid');
415
+ }
416
+ function cmdValidateConsistency(cwd, raw) {
417
+ const roadmapPath = path_1.default.join(cwd, '.planning', 'ROADMAP.md');
418
+ const phasesDir = path_1.default.join(cwd, '.planning', 'phases');
419
+ const errors = [];
420
+ const warnings = [];
421
+ // Check for ROADMAP
422
+ if (!fs_1.default.existsSync(roadmapPath)) {
423
+ errors.push('ROADMAP.md not found');
424
+ (0, core_cjs_1.output)({ passed: false, errors, warnings }, raw, 'failed');
425
+ return;
426
+ }
427
+ const roadmapContent = fs_1.default.readFileSync(roadmapPath, 'utf-8');
428
+ // Extract phases from ROADMAP
429
+ const roadmapPhases = new Set();
430
+ const phasePattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:/gi;
431
+ let m;
432
+ while ((m = phasePattern.exec(roadmapContent)) !== null) {
433
+ roadmapPhases.add(m[1]);
434
+ }
435
+ // Get phases on disk
436
+ const diskPhases = new Set();
437
+ try {
438
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
439
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name);
440
+ for (const dir of dirs) {
441
+ const dm = dir.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
442
+ if (dm)
443
+ diskPhases.add(dm[1]);
444
+ }
445
+ }
446
+ catch { }
447
+ // Check: phases in ROADMAP but not on disk
448
+ for (const p of roadmapPhases) {
449
+ if (!diskPhases.has(p) && !diskPhases.has((0, core_cjs_1.normalizePhaseName)(p))) {
450
+ warnings.push(`Phase ${p} in ROADMAP.md but no directory on disk`);
451
+ }
452
+ }
453
+ // Check: phases on disk but not in ROADMAP
454
+ for (const p of diskPhases) {
455
+ const unpadded = String(parseInt(p, 10));
456
+ if (!roadmapPhases.has(p) && !roadmapPhases.has(unpadded)) {
457
+ warnings.push(`Phase ${p} exists on disk but not in ROADMAP.md`);
458
+ }
459
+ }
460
+ // Check: sequential phase numbers (integers only)
461
+ const integerPhases = [...diskPhases]
462
+ .filter(p => !p.includes('.'))
463
+ .map(p => parseInt(p, 10))
464
+ .sort((a, b) => a - b);
465
+ for (let i = 1; i < integerPhases.length; i++) {
466
+ if (integerPhases[i] !== integerPhases[i - 1] + 1) {
467
+ warnings.push(`Gap in phase numbering: ${integerPhases[i - 1]} → ${integerPhases[i]}`);
468
+ }
469
+ }
470
+ // Check: plan numbering within phases
471
+ try {
472
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
473
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort();
474
+ for (const dir of dirs) {
475
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, dir));
476
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md')).sort();
477
+ // Extract plan numbers
478
+ const planNums = plans.map(p => {
479
+ const pm = p.match(/-(\d{2})-PLAN\.md$/);
480
+ return pm ? parseInt(pm[1], 10) : null;
481
+ }).filter((n) => n !== null);
482
+ for (let i = 1; i < planNums.length; i++) {
483
+ if (planNums[i] !== planNums[i - 1] + 1) {
484
+ warnings.push(`Gap in plan numbering in ${dir}: plan ${planNums[i - 1]} → ${planNums[i]}`);
485
+ }
486
+ }
487
+ // Check: plans without summaries (completed plans)
488
+ const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md'));
489
+ const planIds = new Set(plans.map(p => p.replace('-PLAN.md', '')));
490
+ const summaryIds = new Set(summaries.map(s => s.replace('-SUMMARY.md', '')));
491
+ // Summary without matching plan is suspicious
492
+ for (const sid of summaryIds) {
493
+ if (!planIds.has(sid)) {
494
+ warnings.push(`Summary ${sid}-SUMMARY.md in ${dir} has no matching PLAN.md`);
495
+ }
496
+ }
497
+ }
498
+ }
499
+ catch { }
500
+ // Check: frontmatter in plans has required fields
501
+ try {
502
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
503
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name);
504
+ for (const dir of dirs) {
505
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, dir));
506
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md'));
507
+ for (const plan of plans) {
508
+ const content = fs_1.default.readFileSync(path_1.default.join(phasesDir, dir, plan), 'utf-8');
509
+ const fm = (0, frontmatter_cjs_1.extractFrontmatter)(content);
510
+ if (!fm.wave) {
511
+ warnings.push(`${dir}/${plan}: missing 'wave' in frontmatter`);
512
+ }
513
+ }
514
+ }
515
+ }
516
+ catch { }
517
+ const passed = errors.length === 0;
518
+ (0, core_cjs_1.output)({ passed, errors, warnings, warning_count: warnings.length }, raw, passed ? 'passed' : 'failed');
519
+ }
520
+ function cmdValidateHealth(cwd, options, raw) {
521
+ const planningDir = path_1.default.join(cwd, '.planning');
522
+ const projectPath = path_1.default.join(planningDir, 'PROJECT.md');
523
+ const roadmapPath = path_1.default.join(planningDir, 'ROADMAP.md');
524
+ const statePath = path_1.default.join(planningDir, 'STATE.md');
525
+ const configPath = path_1.default.join(planningDir, 'config.json');
526
+ const phasesDir = path_1.default.join(planningDir, 'phases');
527
+ const errors = [];
528
+ const warnings = [];
529
+ const info = [];
530
+ const repairs = [];
531
+ // Helper to add issue
532
+ const addIssue = (severity, code, message, fix, repairable = false) => {
533
+ const issue = { code, message, fix, repairable };
534
+ if (severity === 'error')
535
+ errors.push(issue);
536
+ else if (severity === 'warning')
537
+ warnings.push(issue);
538
+ else
539
+ info.push(issue);
540
+ };
541
+ // ─── Check 1: .planning/ exists ───────────────────────────────────────────
542
+ if (!fs_1.default.existsSync(planningDir)) {
543
+ addIssue('error', 'E001', '.planning/ directory not found', 'Run /vector:new-project to initialize');
544
+ (0, core_cjs_1.output)({
545
+ status: 'broken',
546
+ errors,
547
+ warnings,
548
+ info,
549
+ repairable_count: 0,
550
+ }, raw);
551
+ return;
552
+ }
553
+ // ─── Check 2: PROJECT.md exists and has required sections ─────────────────
554
+ if (!fs_1.default.existsSync(projectPath)) {
555
+ addIssue('error', 'E002', 'PROJECT.md not found', 'Run /vector:new-project to create');
556
+ }
557
+ else {
558
+ const content = fs_1.default.readFileSync(projectPath, 'utf-8');
559
+ const requiredSections = ['## What This Is', '## Core Value', '## Requirements'];
560
+ for (const section of requiredSections) {
561
+ if (!content.includes(section)) {
562
+ addIssue('warning', 'W001', `PROJECT.md missing section: ${section}`, 'Add section manually');
563
+ }
564
+ }
565
+ }
566
+ // ─── Check 3: ROADMAP.md exists ───────────────────────────────────────────
567
+ if (!fs_1.default.existsSync(roadmapPath)) {
568
+ addIssue('error', 'E003', 'ROADMAP.md not found', 'Run /vector:new-milestone to create roadmap');
569
+ }
570
+ // ─── Check 4: STATE.md exists and references valid phases ─────────────────
571
+ if (!fs_1.default.existsSync(statePath)) {
572
+ addIssue('error', 'E004', 'STATE.md not found', 'Run /vector:health --repair to regenerate', true);
573
+ repairs.push('regenerateState');
574
+ }
575
+ else {
576
+ const stateContent = fs_1.default.readFileSync(statePath, 'utf-8');
577
+ // Extract phase references from STATE.md
578
+ const phaseRefs = [...stateContent.matchAll(/[Pp]hase\s+(\d+(?:\.\d+)*)/g)].map(m => m[1]);
579
+ // Get disk phases
580
+ const diskPhases = new Set();
581
+ try {
582
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
583
+ for (const e of entries) {
584
+ if (e.isDirectory()) {
585
+ const m = e.name.match(/^(\d+(?:\.\d+)*)/);
586
+ if (m)
587
+ diskPhases.add(m[1]);
588
+ }
589
+ }
590
+ }
591
+ catch { }
592
+ // Check for invalid references
593
+ for (const ref of phaseRefs) {
594
+ const normalizedRef = String(parseInt(ref, 10)).padStart(2, '0');
595
+ if (!diskPhases.has(ref) && !diskPhases.has(normalizedRef) && !diskPhases.has(String(parseInt(ref, 10)))) {
596
+ // Only warn if phases dir has any content (not just an empty project)
597
+ if (diskPhases.size > 0) {
598
+ addIssue('warning', 'W002', `STATE.md references phase ${ref}, but only phases ${[...diskPhases].sort().join(', ')} exist`, 'Run /vector:health --repair to regenerate STATE.md', true);
599
+ if (!repairs.includes('regenerateState'))
600
+ repairs.push('regenerateState');
601
+ }
602
+ }
603
+ }
604
+ }
605
+ // ─── Check 5: config.json valid JSON + valid schema ───────────────────────
606
+ if (!fs_1.default.existsSync(configPath)) {
607
+ addIssue('warning', 'W003', 'config.json not found', 'Run /vector:health --repair to create with defaults', true);
608
+ repairs.push('createConfig');
609
+ }
610
+ else {
611
+ try {
612
+ const rawConfig = fs_1.default.readFileSync(configPath, 'utf-8');
613
+ const parsed = JSON.parse(rawConfig);
614
+ // Validate known fields
615
+ const validProfiles = ['quality', 'balanced', 'budget', 'inherit'];
616
+ if (parsed.model_profile && !validProfiles.includes(parsed.model_profile)) {
617
+ addIssue('warning', 'W004', `config.json: invalid model_profile "${parsed.model_profile}"`, `Valid values: ${validProfiles.join(', ')}`);
618
+ }
619
+ }
620
+ catch (err) {
621
+ addIssue('error', 'E005', `config.json: JSON parse error - ${err.message}`, 'Run /vector:health --repair to reset to defaults', true);
622
+ repairs.push('resetConfig');
623
+ }
624
+ }
625
+ // ─── Check 5b: Nyquist validation key presence ──────────────────────────
626
+ if (fs_1.default.existsSync(configPath)) {
627
+ try {
628
+ const configRaw = fs_1.default.readFileSync(configPath, 'utf-8');
629
+ const configParsed = JSON.parse(configRaw);
630
+ if (configParsed.workflow && configParsed.workflow.nyquist_validation === undefined) {
631
+ addIssue('warning', 'W008', 'config.json: workflow.nyquist_validation absent (defaults to enabled but agents may skip)', 'Run /vector:health --repair to add key', true);
632
+ if (!repairs.includes('addNyquistKey'))
633
+ repairs.push('addNyquistKey');
634
+ }
635
+ }
636
+ catch { }
637
+ }
638
+ // ─── Check 6: Phase directory naming (NN-name format) ─────────────────────
639
+ try {
640
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
641
+ for (const e of entries) {
642
+ if (e.isDirectory() && !e.name.match(/^\d{2}(?:\.\d+)*-[\w-]+$/)) {
643
+ addIssue('warning', 'W005', `Phase directory "${e.name}" doesn't follow NN-name format`, 'Rename to match pattern (e.g., 01-setup)');
644
+ }
645
+ }
646
+ }
647
+ catch { }
648
+ // ─── Check 7: Orphaned plans (PLAN without SUMMARY) ───────────────────────
649
+ try {
650
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
651
+ for (const e of entries) {
652
+ if (!e.isDirectory())
653
+ continue;
654
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, e.name));
655
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md');
656
+ const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
657
+ const summaryBases = new Set(summaries.map(s => s.replace('-SUMMARY.md', '').replace('SUMMARY.md', '')));
658
+ for (const plan of plans) {
659
+ const planBase = plan.replace('-PLAN.md', '').replace('PLAN.md', '');
660
+ if (!summaryBases.has(planBase)) {
661
+ addIssue('info', 'I001', `${e.name}/${plan} has no SUMMARY.md`, 'May be in progress');
662
+ }
663
+ }
664
+ }
665
+ }
666
+ catch { }
667
+ // ─── Check 7b: Nyquist VALIDATION.md consistency ────────────────────────
668
+ try {
669
+ const phaseEntries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
670
+ for (const e of phaseEntries) {
671
+ if (!e.isDirectory())
672
+ continue;
673
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, e.name));
674
+ const hasResearch = phaseFiles.some(f => f.endsWith('-RESEARCH.md'));
675
+ const hasValidation = phaseFiles.some(f => f.endsWith('-VALIDATION.md'));
676
+ if (hasResearch && !hasValidation) {
677
+ const researchFile = phaseFiles.find(f => f.endsWith('-RESEARCH.md'));
678
+ if (researchFile) {
679
+ const researchContent = fs_1.default.readFileSync(path_1.default.join(phasesDir, e.name, researchFile), 'utf-8');
680
+ if (researchContent.includes('## Validation Architecture')) {
681
+ addIssue('warning', 'W009', `Phase ${e.name}: has Validation Architecture in RESEARCH.md but no VALIDATION.md`, 'Re-run /vector:plan-phase with --research to regenerate');
682
+ }
683
+ }
684
+ }
685
+ }
686
+ }
687
+ catch { }
688
+ // ─── Check 8: Run existing consistency checks ─────────────────────────────
689
+ // Inline subset of cmdValidateConsistency
690
+ if (fs_1.default.existsSync(roadmapPath)) {
691
+ const roadmapContent = fs_1.default.readFileSync(roadmapPath, 'utf-8');
692
+ const roadmapPhases = new Set();
693
+ const phasePattern2 = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:/gi;
694
+ let m2;
695
+ while ((m2 = phasePattern2.exec(roadmapContent)) !== null) {
696
+ roadmapPhases.add(m2[1]);
697
+ }
698
+ const diskPhases = new Set();
699
+ try {
700
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
701
+ for (const e of entries) {
702
+ if (e.isDirectory()) {
703
+ const dm = e.name.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
704
+ if (dm)
705
+ diskPhases.add(dm[1]);
706
+ }
707
+ }
708
+ }
709
+ catch { }
710
+ // Phases in ROADMAP but not on disk
711
+ for (const p of roadmapPhases) {
712
+ const padded = String(parseInt(p, 10)).padStart(2, '0');
713
+ if (!diskPhases.has(p) && !diskPhases.has(padded)) {
714
+ addIssue('warning', 'W006', `Phase ${p} in ROADMAP.md but no directory on disk`, 'Create phase directory or remove from roadmap');
715
+ }
716
+ }
717
+ // Phases on disk but not in ROADMAP
718
+ for (const p of diskPhases) {
719
+ const unpadded = String(parseInt(p, 10));
720
+ if (!roadmapPhases.has(p) && !roadmapPhases.has(unpadded)) {
721
+ addIssue('warning', 'W007', `Phase ${p} exists on disk but not in ROADMAP.md`, 'Add to roadmap or remove directory');
722
+ }
723
+ }
724
+ }
725
+ // ─── Perform repairs if requested ─────────────────────────────────────────
726
+ const repairActions = [];
727
+ if (options.repair && repairs.length > 0) {
728
+ for (const repair of repairs) {
729
+ try {
730
+ switch (repair) {
731
+ case 'createConfig':
732
+ case 'resetConfig': {
733
+ const defaults = {
734
+ model_profile: 'balanced',
735
+ commit_docs: true,
736
+ search_gitignored: false,
737
+ branching_strategy: 'none',
738
+ phase_branch_template: 'vector/phase-{phase}-{slug}',
739
+ milestone_branch_template: 'vector/{milestone}-{slug}',
740
+ workflow: {
741
+ research: true,
742
+ plan_check: true,
743
+ verifier: true,
744
+ nyquist_validation: true,
745
+ },
746
+ parallelization: true,
747
+ brave_search: false,
748
+ };
749
+ fs_1.default.writeFileSync(configPath, JSON.stringify(defaults, null, 2), 'utf-8');
750
+ repairActions.push({ action: repair, success: true, path: 'config.json' });
751
+ break;
752
+ }
753
+ case 'regenerateState': {
754
+ // Create timestamped backup before overwriting
755
+ if (fs_1.default.existsSync(statePath)) {
756
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
757
+ const backupPath = `${statePath}.bak-${timestamp}`;
758
+ fs_1.default.copyFileSync(statePath, backupPath);
759
+ repairActions.push({ action: 'backupState', success: true, path: backupPath });
760
+ }
761
+ // Generate minimal STATE.md from ROADMAP.md structure
762
+ const milestone = (0, core_cjs_1.getMilestoneInfo)(cwd);
763
+ let stateContent = `# Session State\n\n`;
764
+ stateContent += `## Project Reference\n\n`;
765
+ stateContent += `See: .planning/PROJECT.md\n\n`;
766
+ stateContent += `## Position\n\n`;
767
+ stateContent += `**Milestone:** ${milestone.version} ${milestone.name}\n`;
768
+ stateContent += `**Current phase:** (determining...)\n`;
769
+ stateContent += `**Status:** Resuming\n\n`;
770
+ stateContent += `## Session Log\n\n`;
771
+ stateContent += `- ${new Date().toISOString().split('T')[0]}: STATE.md regenerated by /vector:health --repair\n`;
772
+ (0, state_cjs_1.writeStateMd)(statePath, stateContent, cwd);
773
+ repairActions.push({ action: repair, success: true, path: 'STATE.md' });
774
+ break;
775
+ }
776
+ case 'addNyquistKey': {
777
+ if (fs_1.default.existsSync(configPath)) {
778
+ try {
779
+ const configRaw = fs_1.default.readFileSync(configPath, 'utf-8');
780
+ const configParsed = JSON.parse(configRaw);
781
+ if (!configParsed.workflow)
782
+ configParsed.workflow = {};
783
+ if (configParsed.workflow.nyquist_validation === undefined) {
784
+ configParsed.workflow.nyquist_validation = true;
785
+ fs_1.default.writeFileSync(configPath, JSON.stringify(configParsed, null, 2), 'utf-8');
786
+ }
787
+ repairActions.push({ action: repair, success: true, path: 'config.json' });
788
+ }
789
+ catch (err) {
790
+ repairActions.push({ action: repair, success: false, error: err.message });
791
+ }
792
+ }
793
+ break;
794
+ }
795
+ }
796
+ }
797
+ catch (err) {
798
+ repairActions.push({ action: repair, success: false, error: err.message });
799
+ }
800
+ }
801
+ }
802
+ // ─── Determine overall status ─────────────────────────────────────────────
803
+ let status;
804
+ if (errors.length > 0) {
805
+ status = 'broken';
806
+ }
807
+ else if (warnings.length > 0) {
808
+ status = 'degraded';
809
+ }
810
+ else {
811
+ status = 'healthy';
812
+ }
813
+ const repairableCount = errors.filter(e => e.repairable).length +
814
+ warnings.filter(w => w.repairable).length;
815
+ (0, core_cjs_1.output)({
816
+ status,
817
+ errors,
818
+ warnings,
819
+ info,
820
+ repairable_count: repairableCount,
821
+ repairs_performed: repairActions.length > 0 ? repairActions : undefined,
822
+ }, raw);
823
+ }
824
+ //# sourceMappingURL=verify.cjs.map