@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,641 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cmdGenerateSlug = cmdGenerateSlug;
7
+ exports.cmdCurrentTimestamp = cmdCurrentTimestamp;
8
+ exports.cmdListTodos = cmdListTodos;
9
+ exports.cmdVerifyPathExists = cmdVerifyPathExists;
10
+ exports.cmdHistoryDigest = cmdHistoryDigest;
11
+ exports.cmdResolveModel = cmdResolveModel;
12
+ exports.cmdCommit = cmdCommit;
13
+ exports.cmdSummaryExtract = cmdSummaryExtract;
14
+ exports.cmdWebsearch = cmdWebsearch;
15
+ exports.cmdProgressRender = cmdProgressRender;
16
+ exports.cmdTodoComplete = cmdTodoComplete;
17
+ exports.cmdScaffold = cmdScaffold;
18
+ exports.cmdStats = cmdStats;
19
+ /**
20
+ * Commands — Standalone utility commands
21
+ */
22
+ const fs_1 = __importDefault(require("fs"));
23
+ const path_1 = __importDefault(require("path"));
24
+ const core_cjs_1 = require("./core.cjs");
25
+ const frontmatter_cjs_1 = require("./frontmatter.cjs");
26
+ const model_profiles_cjs_1 = require("./model-profiles.cjs");
27
+ function cmdGenerateSlug(text, raw) {
28
+ if (!text) {
29
+ (0, core_cjs_1.error)('text required for slug generation');
30
+ }
31
+ const slug = text
32
+ .toLowerCase()
33
+ .replace(/[^a-z0-9]+/g, '-')
34
+ .replace(/^-+|-+$/g, '');
35
+ const result = { slug };
36
+ (0, core_cjs_1.output)(result, raw, slug);
37
+ }
38
+ function cmdCurrentTimestamp(format, raw) {
39
+ const now = new Date();
40
+ let result;
41
+ switch (format) {
42
+ case 'date':
43
+ result = now.toISOString().split('T')[0];
44
+ break;
45
+ case 'filename':
46
+ result = now.toISOString().replace(/:/g, '-').replace(/\..+/, '');
47
+ break;
48
+ case 'full':
49
+ default:
50
+ result = now.toISOString();
51
+ break;
52
+ }
53
+ (0, core_cjs_1.output)({ timestamp: result }, raw, result);
54
+ }
55
+ function cmdListTodos(cwd, area, raw) {
56
+ const pendingDir = path_1.default.join(cwd, '.planning', 'todos', 'pending');
57
+ let count = 0;
58
+ const todos = [];
59
+ try {
60
+ const files = fs_1.default.readdirSync(pendingDir).filter(f => f.endsWith('.md'));
61
+ for (const file of files) {
62
+ try {
63
+ const content = fs_1.default.readFileSync(path_1.default.join(pendingDir, file), 'utf-8');
64
+ const createdMatch = content.match(/^created:\s*(.+)$/m);
65
+ const titleMatch = content.match(/^title:\s*(.+)$/m);
66
+ const areaMatch = content.match(/^area:\s*(.+)$/m);
67
+ const todoArea = areaMatch ? areaMatch[1].trim() : 'general';
68
+ // Apply area filter if specified
69
+ if (area && todoArea !== area)
70
+ continue;
71
+ count++;
72
+ todos.push({
73
+ file,
74
+ created: createdMatch ? createdMatch[1].trim() : 'unknown',
75
+ title: titleMatch ? titleMatch[1].trim() : 'Untitled',
76
+ area: todoArea,
77
+ path: (0, core_cjs_1.toPosixPath)(path_1.default.join('.planning', 'todos', 'pending', file)),
78
+ });
79
+ }
80
+ catch { }
81
+ }
82
+ }
83
+ catch { }
84
+ const result = { count, todos };
85
+ (0, core_cjs_1.output)(result, raw, count.toString());
86
+ }
87
+ function cmdVerifyPathExists(cwd, targetPath, raw) {
88
+ if (!targetPath) {
89
+ (0, core_cjs_1.error)('path required for verification');
90
+ }
91
+ const fullPath = path_1.default.isAbsolute(targetPath) ? targetPath : path_1.default.join(cwd, targetPath);
92
+ try {
93
+ const stats = fs_1.default.statSync(fullPath);
94
+ const type = stats.isDirectory() ? 'directory' : stats.isFile() ? 'file' : 'other';
95
+ const result = { exists: true, type };
96
+ (0, core_cjs_1.output)(result, raw, 'true');
97
+ }
98
+ catch {
99
+ const result = { exists: false, type: null };
100
+ (0, core_cjs_1.output)(result, raw, 'false');
101
+ }
102
+ }
103
+ function cmdHistoryDigest(cwd, raw) {
104
+ const phasesDir = path_1.default.join(cwd, '.planning', 'phases');
105
+ const digest = { phases: {}, decisions: [], tech_stack: new Set() };
106
+ // Collect all phase directories: archived + current
107
+ const allPhaseDirs = [];
108
+ // Add archived phases first (oldest milestones first)
109
+ const archived = (0, core_cjs_1.getArchivedPhaseDirs)(cwd);
110
+ for (const a of archived) {
111
+ allPhaseDirs.push({ name: a.name, fullPath: a.fullPath, milestone: a.milestone });
112
+ }
113
+ // Add current phases
114
+ if (fs_1.default.existsSync(phasesDir)) {
115
+ try {
116
+ const currentDirs = fs_1.default.readdirSync(phasesDir, { withFileTypes: true })
117
+ .filter(e => e.isDirectory())
118
+ .map(e => e.name)
119
+ .sort();
120
+ for (const dir of currentDirs) {
121
+ allPhaseDirs.push({ name: dir, fullPath: path_1.default.join(phasesDir, dir), milestone: null });
122
+ }
123
+ }
124
+ catch { }
125
+ }
126
+ if (allPhaseDirs.length === 0) {
127
+ digest.tech_stack = [];
128
+ (0, core_cjs_1.output)(digest, raw);
129
+ return;
130
+ }
131
+ try {
132
+ for (const { name: dir, fullPath: dirPath } of allPhaseDirs) {
133
+ const summaries = fs_1.default.readdirSync(dirPath).filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
134
+ for (const summary of summaries) {
135
+ try {
136
+ const content = fs_1.default.readFileSync(path_1.default.join(dirPath, summary), 'utf-8');
137
+ const fm = (0, frontmatter_cjs_1.extractFrontmatter)(content);
138
+ const phaseNum = fm.phase || dir.split('-')[0];
139
+ if (!digest.phases[phaseNum]) {
140
+ digest.phases[phaseNum] = {
141
+ name: fm.name || dir.split('-').slice(1).join(' ') || 'Unknown',
142
+ provides: new Set(),
143
+ affects: new Set(),
144
+ patterns: new Set(),
145
+ };
146
+ }
147
+ const phaseEntry = digest.phases[phaseNum];
148
+ // Merge provides
149
+ const depGraph = fm['dependency-graph'];
150
+ if (depGraph && depGraph.provides) {
151
+ depGraph.provides.forEach(p => phaseEntry.provides.add(p));
152
+ }
153
+ else if (fm.provides) {
154
+ fm.provides.forEach(p => phaseEntry.provides.add(p));
155
+ }
156
+ // Merge affects
157
+ if (depGraph && depGraph.affects) {
158
+ depGraph.affects.forEach(a => phaseEntry.affects.add(a));
159
+ }
160
+ // Merge patterns
161
+ if (fm['patterns-established']) {
162
+ fm['patterns-established'].forEach(p => phaseEntry.patterns.add(p));
163
+ }
164
+ // Merge decisions
165
+ if (fm['key-decisions']) {
166
+ fm['key-decisions'].forEach(d => {
167
+ digest.decisions.push({ phase: phaseNum, decision: d });
168
+ });
169
+ }
170
+ // Merge tech stack
171
+ if (fm['tech-stack'] && fm['tech-stack'].added) {
172
+ fm['tech-stack'].added.forEach(t => digest.tech_stack.add(typeof t === 'string' ? t : t.name));
173
+ }
174
+ }
175
+ catch {
176
+ // Skip malformed summaries
177
+ }
178
+ }
179
+ }
180
+ // Convert Sets to Arrays for JSON output
181
+ Object.keys(digest.phases).forEach(p => {
182
+ const phase = digest.phases[p];
183
+ phase.provides = [...phase.provides];
184
+ phase.affects = [...phase.affects];
185
+ phase.patterns = [...phase.patterns];
186
+ });
187
+ digest.tech_stack = [...digest.tech_stack];
188
+ (0, core_cjs_1.output)(digest, raw);
189
+ }
190
+ catch (e) {
191
+ (0, core_cjs_1.error)('Failed to generate history digest: ' + e.message);
192
+ }
193
+ }
194
+ function cmdResolveModel(cwd, agentType, raw) {
195
+ if (!agentType) {
196
+ (0, core_cjs_1.error)('agent-type required');
197
+ }
198
+ const config = (0, core_cjs_1.loadConfig)(cwd);
199
+ const profile = config.model_profile || 'balanced';
200
+ const model = (0, core_cjs_1.resolveModelInternal)(cwd, agentType);
201
+ const agentModels = model_profiles_cjs_1.MODEL_PROFILES[agentType];
202
+ const result = agentModels
203
+ ? { model, profile }
204
+ : { model, profile, unknown_agent: true };
205
+ (0, core_cjs_1.output)(result, raw, model);
206
+ }
207
+ function cmdCommit(cwd, message, files, raw, amend) {
208
+ if (!message && !amend) {
209
+ (0, core_cjs_1.error)('commit message required');
210
+ }
211
+ const config = (0, core_cjs_1.loadConfig)(cwd);
212
+ // Check commit_docs config
213
+ if (!config.commit_docs) {
214
+ const result = { committed: false, hash: null, reason: 'skipped_commit_docs_false' };
215
+ (0, core_cjs_1.output)(result, raw, 'skipped');
216
+ return;
217
+ }
218
+ // Check if .planning is gitignored
219
+ if ((0, core_cjs_1.isGitIgnored)(cwd, '.planning')) {
220
+ const result = { committed: false, hash: null, reason: 'skipped_gitignored' };
221
+ (0, core_cjs_1.output)(result, raw, 'skipped');
222
+ return;
223
+ }
224
+ // Stage files
225
+ const filesToStage = files && files.length > 0 ? files : ['.planning/'];
226
+ for (const file of filesToStage) {
227
+ (0, core_cjs_1.execGit)(cwd, ['add', file]);
228
+ }
229
+ // Commit
230
+ const commitArgs = amend ? ['commit', '--amend', '--no-edit'] : ['commit', '-m', message];
231
+ const commitResult = (0, core_cjs_1.execGit)(cwd, commitArgs);
232
+ if (commitResult.exitCode !== 0) {
233
+ if (commitResult.stdout.includes('nothing to commit') || commitResult.stderr.includes('nothing to commit')) {
234
+ const result = { committed: false, hash: null, reason: 'nothing_to_commit' };
235
+ (0, core_cjs_1.output)(result, raw, 'nothing');
236
+ return;
237
+ }
238
+ const result = { committed: false, hash: null, reason: 'nothing_to_commit', error: commitResult.stderr };
239
+ (0, core_cjs_1.output)(result, raw, 'nothing');
240
+ return;
241
+ }
242
+ // Get short hash
243
+ const hashResult = (0, core_cjs_1.execGit)(cwd, ['rev-parse', '--short', 'HEAD']);
244
+ const hash = hashResult.exitCode === 0 ? hashResult.stdout : null;
245
+ const result = { committed: true, hash, reason: 'committed' };
246
+ (0, core_cjs_1.output)(result, raw, hash || 'committed');
247
+ }
248
+ function cmdSummaryExtract(cwd, summaryPath, fields, raw) {
249
+ if (!summaryPath) {
250
+ (0, core_cjs_1.error)('summary-path required for summary-extract');
251
+ }
252
+ const fullPath = path_1.default.join(cwd, summaryPath);
253
+ if (!fs_1.default.existsSync(fullPath)) {
254
+ (0, core_cjs_1.output)({ error: 'File not found', path: summaryPath }, raw);
255
+ return;
256
+ }
257
+ const content = fs_1.default.readFileSync(fullPath, 'utf-8');
258
+ const fm = (0, frontmatter_cjs_1.extractFrontmatter)(content);
259
+ // Parse key-decisions into structured format
260
+ const parseDecisions = (decisionsList) => {
261
+ if (!decisionsList || !Array.isArray(decisionsList))
262
+ return [];
263
+ return decisionsList.map(d => {
264
+ const colonIdx = d.indexOf(':');
265
+ if (colonIdx > 0) {
266
+ return {
267
+ summary: d.substring(0, colonIdx).trim(),
268
+ rationale: d.substring(colonIdx + 1).trim(),
269
+ };
270
+ }
271
+ return { summary: d, rationale: null };
272
+ });
273
+ };
274
+ // Build full result
275
+ const fullResult = {
276
+ path: summaryPath,
277
+ one_liner: fm['one-liner'] || null,
278
+ key_files: fm['key-files'] || [],
279
+ tech_added: (fm['tech-stack'] && fm['tech-stack'].added) || [],
280
+ patterns: fm['patterns-established'] || [],
281
+ decisions: parseDecisions(fm['key-decisions']),
282
+ requirements_completed: fm['requirements-completed'] || [],
283
+ };
284
+ // If fields specified, filter to only those fields
285
+ if (fields && fields.length > 0) {
286
+ const filtered = { path: summaryPath };
287
+ for (const field of fields) {
288
+ if (fullResult[field] !== undefined) {
289
+ filtered[field] = fullResult[field];
290
+ }
291
+ }
292
+ (0, core_cjs_1.output)(filtered, raw);
293
+ return;
294
+ }
295
+ (0, core_cjs_1.output)(fullResult, raw);
296
+ }
297
+ async function cmdWebsearch(query, options, raw) {
298
+ const apiKey = process.env.BRAVE_API_KEY;
299
+ if (!apiKey) {
300
+ // No key = silent skip, agent falls back to built-in WebSearch
301
+ (0, core_cjs_1.output)({ available: false, reason: 'BRAVE_API_KEY not set' }, raw, '');
302
+ return;
303
+ }
304
+ if (!query) {
305
+ (0, core_cjs_1.output)({ available: false, error: 'Query required' }, raw, '');
306
+ return;
307
+ }
308
+ const params = new URLSearchParams({
309
+ q: query,
310
+ count: String(options.limit || 10),
311
+ country: 'us',
312
+ search_lang: 'en',
313
+ text_decorations: 'false'
314
+ });
315
+ if (options.freshness) {
316
+ params.set('freshness', options.freshness);
317
+ }
318
+ try {
319
+ const response = await fetch(`https://api.search.brave.com/res/v1/web/search?${params}`, {
320
+ headers: {
321
+ 'Accept': 'application/json',
322
+ 'X-Subscription-Token': apiKey
323
+ }
324
+ });
325
+ if (!response.ok) {
326
+ (0, core_cjs_1.output)({ available: false, error: `API error: ${response.status}` }, raw, '');
327
+ return;
328
+ }
329
+ const data = await response.json();
330
+ const results = (data.web?.results || []).map(r => ({
331
+ title: r.title,
332
+ url: r.url,
333
+ description: r.description,
334
+ age: r.age || null
335
+ }));
336
+ (0, core_cjs_1.output)({
337
+ available: true,
338
+ query,
339
+ count: results.length,
340
+ results
341
+ }, raw, results.map(r => `${r.title}\n${r.url}\n${r.description}`).join('\n\n'));
342
+ }
343
+ catch (err) {
344
+ (0, core_cjs_1.output)({ available: false, error: err.message }, raw, '');
345
+ }
346
+ }
347
+ function cmdProgressRender(cwd, format, raw) {
348
+ const phasesDir = path_1.default.join(cwd, '.planning', 'phases');
349
+ const milestone = (0, core_cjs_1.getMilestoneInfo)(cwd);
350
+ const phases = [];
351
+ let totalPlans = 0;
352
+ let totalSummaries = 0;
353
+ try {
354
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
355
+ const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort((a, b) => (0, core_cjs_1.comparePhaseNum)(a, b));
356
+ for (const dir of dirs) {
357
+ const dm = dir.match(/^(\d+(?:\.\d+)*)-?(.*)/);
358
+ const phaseNum = dm ? dm[1] : dir;
359
+ const phaseName = dm && dm[2] ? dm[2].replace(/-/g, ' ') : '';
360
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, dir));
361
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md').length;
362
+ const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md').length;
363
+ totalPlans += plans;
364
+ totalSummaries += summaries;
365
+ let status;
366
+ if (plans === 0)
367
+ status = 'Pending';
368
+ else if (summaries >= plans)
369
+ status = 'Complete';
370
+ else if (summaries > 0)
371
+ status = 'In Progress';
372
+ else
373
+ status = 'Planned';
374
+ phases.push({ number: phaseNum, name: phaseName, plans, summaries, status });
375
+ }
376
+ }
377
+ catch { }
378
+ const percent = totalPlans > 0 ? Math.min(100, Math.round((totalSummaries / totalPlans) * 100)) : 0;
379
+ if (format === 'table') {
380
+ // Render markdown table
381
+ const barWidth = 10;
382
+ const filled = Math.round((percent / 100) * barWidth);
383
+ const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(barWidth - filled);
384
+ let out = `# ${milestone.version} ${milestone.name}\n\n`;
385
+ out += `**Progress:** [${bar}] ${totalSummaries}/${totalPlans} plans (${percent}%)\n\n`;
386
+ out += `| Phase | Name | Plans | Status |\n`;
387
+ out += `|-------|------|-------|--------|\n`;
388
+ for (const p of phases) {
389
+ out += `| ${p.number} | ${p.name} | ${p.summaries}/${p.plans} | ${p.status} |\n`;
390
+ }
391
+ (0, core_cjs_1.output)({ rendered: out }, raw, out);
392
+ }
393
+ else if (format === 'bar') {
394
+ const barWidth = 20;
395
+ const filled = Math.round((percent / 100) * barWidth);
396
+ const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(barWidth - filled);
397
+ const text = `[${bar}] ${totalSummaries}/${totalPlans} plans (${percent}%)`;
398
+ (0, core_cjs_1.output)({ bar: text, percent, completed: totalSummaries, total: totalPlans }, raw, text);
399
+ }
400
+ else {
401
+ // JSON format
402
+ (0, core_cjs_1.output)({
403
+ milestone_version: milestone.version,
404
+ milestone_name: milestone.name,
405
+ phases,
406
+ total_plans: totalPlans,
407
+ total_summaries: totalSummaries,
408
+ percent,
409
+ }, raw);
410
+ }
411
+ }
412
+ function cmdTodoComplete(cwd, filename, raw) {
413
+ if (!filename) {
414
+ (0, core_cjs_1.error)('filename required for todo complete');
415
+ }
416
+ const pendingDir = path_1.default.join(cwd, '.planning', 'todos', 'pending');
417
+ const completedDir = path_1.default.join(cwd, '.planning', 'todos', 'completed');
418
+ const sourcePath = path_1.default.join(pendingDir, filename);
419
+ if (!fs_1.default.existsSync(sourcePath)) {
420
+ (0, core_cjs_1.error)(`Todo not found: ${filename}`);
421
+ }
422
+ // Ensure completed directory exists
423
+ fs_1.default.mkdirSync(completedDir, { recursive: true });
424
+ // Read, add completion timestamp, move
425
+ let content = fs_1.default.readFileSync(sourcePath, 'utf-8');
426
+ const today = new Date().toISOString().split('T')[0];
427
+ content = `completed: ${today}\n` + content;
428
+ fs_1.default.writeFileSync(path_1.default.join(completedDir, filename), content, 'utf-8');
429
+ fs_1.default.unlinkSync(sourcePath);
430
+ (0, core_cjs_1.output)({ completed: true, file: filename, date: today }, raw, 'completed');
431
+ }
432
+ function cmdScaffold(cwd, type, options, raw) {
433
+ const { phase, name } = options;
434
+ const padded = phase ? (0, core_cjs_1.normalizePhaseName)(phase) : '00';
435
+ const today = new Date().toISOString().split('T')[0];
436
+ // Find phase directory
437
+ const phaseInfo = phase ? (0, core_cjs_1.findPhaseInternal)(cwd, phase) : null;
438
+ const phaseDir = phaseInfo?.directory ? path_1.default.join(cwd, phaseInfo.directory) : null;
439
+ if (phase && !phaseDir && type !== 'phase-dir') {
440
+ (0, core_cjs_1.error)(`Phase ${phase} directory not found`);
441
+ }
442
+ let filePath, content;
443
+ switch (type) {
444
+ case 'context': {
445
+ filePath = path_1.default.join(phaseDir, `${padded}-CONTEXT.md`);
446
+ content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — Context\n\n## Decisions\n\n_Decisions will be captured during /vector:discuss-phase ${phase}_\n\n## Discretion Areas\n\n_Areas where the executor can use judgment_\n\n## Deferred Ideas\n\n_Ideas to consider later_\n`;
447
+ break;
448
+ }
449
+ case 'uat': {
450
+ filePath = path_1.default.join(phaseDir, `${padded}-UAT.md`);
451
+ content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\nstatus: pending\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — User Acceptance Testing\n\n## Test Results\n\n| # | Test | Status | Notes |\n|---|------|--------|-------|\n\n## Summary\n\n_Pending UAT_\n`;
452
+ break;
453
+ }
454
+ case 'verification': {
455
+ filePath = path_1.default.join(phaseDir, `${padded}-VERIFICATION.md`);
456
+ content = `---\nphase: "${padded}"\nname: "${name || phaseInfo?.phase_name || 'Unnamed'}"\ncreated: ${today}\nstatus: pending\n---\n\n# Phase ${phase}: ${name || phaseInfo?.phase_name || 'Unnamed'} — Verification\n\n## Goal-Backward Verification\n\n**Phase Goal:** [From ROADMAP.md]\n\n## Checks\n\n| # | Requirement | Status | Evidence |\n|---|------------|--------|----------|\n\n## Result\n\n_Pending verification_\n`;
457
+ break;
458
+ }
459
+ case 'phase-dir': {
460
+ if (!phase || !name) {
461
+ (0, core_cjs_1.error)('phase and name required for phase-dir scaffold');
462
+ }
463
+ const slug = (0, core_cjs_1.generateSlugInternal)(name);
464
+ const dirName = `${padded}-${slug}`;
465
+ const phasesParent = path_1.default.join(cwd, '.planning', 'phases');
466
+ fs_1.default.mkdirSync(phasesParent, { recursive: true });
467
+ const dirPath = path_1.default.join(phasesParent, dirName);
468
+ fs_1.default.mkdirSync(dirPath, { recursive: true });
469
+ (0, core_cjs_1.output)({ created: true, directory: `.planning/phases/${dirName}`, path: dirPath }, raw, dirPath);
470
+ return;
471
+ }
472
+ default:
473
+ (0, core_cjs_1.error)(`Unknown scaffold type: ${type}. Available: context, uat, verification, phase-dir`);
474
+ return;
475
+ }
476
+ if (fs_1.default.existsSync(filePath)) {
477
+ (0, core_cjs_1.output)({ created: false, reason: 'already_exists', path: filePath }, raw, 'exists');
478
+ return;
479
+ }
480
+ fs_1.default.writeFileSync(filePath, content, 'utf-8');
481
+ const relPath = (0, core_cjs_1.toPosixPath)(path_1.default.relative(cwd, filePath));
482
+ (0, core_cjs_1.output)({ created: true, path: relPath }, raw, relPath);
483
+ }
484
+ function cmdStats(cwd, format, raw) {
485
+ const phasesDir = path_1.default.join(cwd, '.planning', 'phases');
486
+ const roadmapPath = path_1.default.join(cwd, '.planning', 'ROADMAP.md');
487
+ const reqPath = path_1.default.join(cwd, '.planning', 'REQUIREMENTS.md');
488
+ const statePath = path_1.default.join(cwd, '.planning', 'STATE.md');
489
+ const milestone = (0, core_cjs_1.getMilestoneInfo)(cwd);
490
+ const isDirInMilestone = (0, core_cjs_1.getMilestonePhaseFilter)(cwd);
491
+ // Phase & plan stats (reuse progress pattern)
492
+ const phasesByNumber = new Map();
493
+ let totalPlans = 0;
494
+ let totalSummaries = 0;
495
+ try {
496
+ const roadmapContent = (0, core_cjs_1.stripShippedMilestones)(fs_1.default.readFileSync(roadmapPath, 'utf-8'));
497
+ const headingPattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
498
+ let match;
499
+ while ((match = headingPattern.exec(roadmapContent)) !== null) {
500
+ phasesByNumber.set(match[1], {
501
+ number: match[1],
502
+ name: match[2].replace(/\(INSERTED\)/i, '').trim(),
503
+ plans: 0,
504
+ summaries: 0,
505
+ status: 'Not Started',
506
+ });
507
+ }
508
+ }
509
+ catch { }
510
+ try {
511
+ const entries = fs_1.default.readdirSync(phasesDir, { withFileTypes: true });
512
+ const dirs = entries
513
+ .filter(e => e.isDirectory())
514
+ .map(e => e.name)
515
+ .filter(isDirInMilestone)
516
+ .sort((a, b) => (0, core_cjs_1.comparePhaseNum)(a, b));
517
+ for (const dir of dirs) {
518
+ const dm = dir.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i);
519
+ const phaseNum = dm ? dm[1] : dir;
520
+ const phaseName = dm && dm[2] ? dm[2].replace(/-/g, ' ') : '';
521
+ const phaseFiles = fs_1.default.readdirSync(path_1.default.join(phasesDir, dir));
522
+ const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md').length;
523
+ const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md').length;
524
+ totalPlans += plans;
525
+ totalSummaries += summaries;
526
+ let status;
527
+ if (plans === 0)
528
+ status = 'Not Started';
529
+ else if (summaries >= plans)
530
+ status = 'Complete';
531
+ else if (summaries > 0)
532
+ status = 'In Progress';
533
+ else
534
+ status = 'Planned';
535
+ const existing = phasesByNumber.get(phaseNum);
536
+ phasesByNumber.set(phaseNum, {
537
+ number: phaseNum,
538
+ name: existing?.name || phaseName,
539
+ plans,
540
+ summaries,
541
+ status,
542
+ });
543
+ }
544
+ }
545
+ catch { }
546
+ const phases = [...phasesByNumber.values()].sort((a, b) => (0, core_cjs_1.comparePhaseNum)(a.number, b.number));
547
+ const completedPhases = phases.filter(p => p.status === 'Complete').length;
548
+ const planPercent = totalPlans > 0 ? Math.min(100, Math.round((totalSummaries / totalPlans) * 100)) : 0;
549
+ const percent = phases.length > 0 ? Math.min(100, Math.round((completedPhases / phases.length) * 100)) : 0;
550
+ // Requirements stats
551
+ let requirementsTotal = 0;
552
+ let requirementsComplete = 0;
553
+ try {
554
+ if (fs_1.default.existsSync(reqPath)) {
555
+ const reqContent = fs_1.default.readFileSync(reqPath, 'utf-8');
556
+ const checked = reqContent.match(/^- \[x\] \*\*/gm);
557
+ const unchecked = reqContent.match(/^- \[ \] \*\*/gm);
558
+ requirementsComplete = checked ? checked.length : 0;
559
+ requirementsTotal = requirementsComplete + (unchecked ? unchecked.length : 0);
560
+ }
561
+ }
562
+ catch { }
563
+ // Last activity from STATE.md
564
+ let lastActivity = null;
565
+ try {
566
+ if (fs_1.default.existsSync(statePath)) {
567
+ const stateContent = fs_1.default.readFileSync(statePath, 'utf-8');
568
+ const activityMatch = stateContent.match(/^last_activity:\s*(.+)$/im)
569
+ || stateContent.match(/\*\*Last Activity:\*\*\s*(.+)/i)
570
+ || stateContent.match(/^Last Activity:\s*(.+)$/im)
571
+ || stateContent.match(/^Last activity:\s*(.+)$/im);
572
+ if (activityMatch)
573
+ lastActivity = activityMatch[1].trim();
574
+ }
575
+ }
576
+ catch { }
577
+ // Git stats
578
+ let gitCommits = 0;
579
+ let gitFirstCommitDate = null;
580
+ const commitCount = (0, core_cjs_1.execGit)(cwd, ['rev-list', '--count', 'HEAD']);
581
+ if (commitCount.exitCode === 0) {
582
+ gitCommits = parseInt(commitCount.stdout, 10) || 0;
583
+ }
584
+ const rootHash = (0, core_cjs_1.execGit)(cwd, ['rev-list', '--max-parents=0', 'HEAD']);
585
+ if (rootHash.exitCode === 0 && rootHash.stdout) {
586
+ const firstCommit = rootHash.stdout.split('\n')[0].trim();
587
+ const firstDate = (0, core_cjs_1.execGit)(cwd, ['show', '-s', '--format=%as', firstCommit]);
588
+ if (firstDate.exitCode === 0) {
589
+ gitFirstCommitDate = firstDate.stdout || null;
590
+ }
591
+ }
592
+ const result = {
593
+ milestone_version: milestone.version,
594
+ milestone_name: milestone.name,
595
+ phases,
596
+ phases_completed: completedPhases,
597
+ phases_total: phases.length,
598
+ total_plans: totalPlans,
599
+ total_summaries: totalSummaries,
600
+ percent,
601
+ plan_percent: planPercent,
602
+ requirements_total: requirementsTotal,
603
+ requirements_complete: requirementsComplete,
604
+ git_commits: gitCommits,
605
+ git_first_commit_date: gitFirstCommitDate,
606
+ last_activity: lastActivity,
607
+ };
608
+ if (format === 'table') {
609
+ const barWidth = 10;
610
+ const filled = Math.round((percent / 100) * barWidth);
611
+ const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(barWidth - filled);
612
+ let out = `# ${milestone.version} ${milestone.name} \u2014 Statistics\n\n`;
613
+ out += `**Progress:** [${bar}] ${completedPhases}/${phases.length} phases (${percent}%)\n`;
614
+ if (totalPlans > 0) {
615
+ out += `**Plans:** ${totalSummaries}/${totalPlans} complete (${planPercent}%)\n`;
616
+ }
617
+ out += `**Phases:** ${completedPhases}/${phases.length} complete\n`;
618
+ if (requirementsTotal > 0) {
619
+ out += `**Requirements:** ${requirementsComplete}/${requirementsTotal} complete\n`;
620
+ }
621
+ out += '\n';
622
+ out += `| Phase | Name | Plans | Completed | Status |\n`;
623
+ out += `|-------|------|-------|-----------|--------|\n`;
624
+ for (const p of phases) {
625
+ out += `| ${p.number} | ${p.name} | ${p.plans} | ${p.summaries} | ${p.status} |\n`;
626
+ }
627
+ if (gitCommits > 0) {
628
+ out += `\n**Git:** ${gitCommits} commits`;
629
+ if (gitFirstCommitDate)
630
+ out += ` (since ${gitFirstCommitDate})`;
631
+ out += '\n';
632
+ }
633
+ if (lastActivity)
634
+ out += `**Last activity:** ${lastActivity}\n`;
635
+ (0, core_cjs_1.output)({ rendered: out }, raw, out);
636
+ }
637
+ else {
638
+ (0, core_cjs_1.output)(result, raw);
639
+ }
640
+ }
641
+ //# sourceMappingURL=commands.cjs.map