pan-wizard 2.8.1
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.
- package/LICENSE +21 -0
- package/README.md +772 -0
- package/agents/pan-debugger.md +1246 -0
- package/agents/pan-document_code.md +965 -0
- package/agents/pan-executor.md +469 -0
- package/agents/pan-integration-checker.md +443 -0
- package/agents/pan-phase-researcher.md +572 -0
- package/agents/pan-plan-checker.md +763 -0
- package/agents/pan-planner.md +1297 -0
- package/agents/pan-project-researcher.md +647 -0
- package/agents/pan-research-synthesizer.md +239 -0
- package/agents/pan-reviewer.md +112 -0
- package/agents/pan-roadmapper.md +642 -0
- package/agents/pan-verifier.md +672 -0
- package/assets/pan-logo-2000-transparent.svg +30 -0
- package/assets/pan-logo-2000.svg +43 -0
- package/assets/terminal.svg +119 -0
- package/bin/install-lib.cjs +616 -0
- package/bin/install.js +1936 -0
- package/commands/pan/add-phase.md +44 -0
- package/commands/pan/assumptions.md +47 -0
- package/commands/pan/audit-deployment.md +378 -0
- package/commands/pan/debug.md +168 -0
- package/commands/pan/discord.md +19 -0
- package/commands/pan/discuss-phase.md +84 -0
- package/commands/pan/exec-phase.md +45 -0
- package/commands/pan/focus-auto.md +323 -0
- package/commands/pan/focus-design.md +816 -0
- package/commands/pan/focus-exec.md +316 -0
- package/commands/pan/focus-plan.md +101 -0
- package/commands/pan/focus-scan.md +272 -0
- package/commands/pan/focus-sync.md +104 -0
- package/commands/pan/health.md +23 -0
- package/commands/pan/help.md +23 -0
- package/commands/pan/insert-phase.md +33 -0
- package/commands/pan/map-codebase.md +72 -0
- package/commands/pan/milestone-audit.md +37 -0
- package/commands/pan/milestone-cleanup.md +19 -0
- package/commands/pan/milestone-done.md +137 -0
- package/commands/pan/milestone-gaps.md +35 -0
- package/commands/pan/milestone-new.md +45 -0
- package/commands/pan/new-project.md +43 -0
- package/commands/pan/patches.md +110 -0
- package/commands/pan/pause.md +39 -0
- package/commands/pan/phase-budget.md +23 -0
- package/commands/pan/phase-tests.md +42 -0
- package/commands/pan/plan-phase.md +46 -0
- package/commands/pan/profile.md +36 -0
- package/commands/pan/progress.md +25 -0
- package/commands/pan/quick.md +42 -0
- package/commands/pan/remove-phase.md +32 -0
- package/commands/pan/research-phase.md +190 -0
- package/commands/pan/resume.md +41 -0
- package/commands/pan/retro.md +33 -0
- package/commands/pan/settings.md +37 -0
- package/commands/pan/todo-add.md +48 -0
- package/commands/pan/todo-check.md +46 -0
- package/commands/pan/update.md +38 -0
- package/commands/pan/verify-phase.md +39 -0
- package/hooks/dist/pan-check-update.js +62 -0
- package/hooks/dist/pan-context-monitor.js +122 -0
- package/hooks/dist/pan-statusline.js +108 -0
- package/package.json +66 -0
- package/pan-wizard-core/bin/lib/codebase.cjs +746 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1435 -0
- package/pan-wizard-core/bin/lib/config.cjs +611 -0
- package/pan-wizard-core/bin/lib/constants.cjs +696 -0
- package/pan-wizard-core/bin/lib/context-budget.cjs +150 -0
- package/pan-wizard-core/bin/lib/core.cjs +650 -0
- package/pan-wizard-core/bin/lib/focus.cjs +900 -0
- package/pan-wizard-core/bin/lib/frontmatter.cjs +442 -0
- package/pan-wizard-core/bin/lib/init.cjs +881 -0
- package/pan-wizard-core/bin/lib/milestone.cjs +276 -0
- package/pan-wizard-core/bin/lib/phase.cjs +1212 -0
- package/pan-wizard-core/bin/lib/roadmap.cjs +470 -0
- package/pan-wizard-core/bin/lib/state.cjs +1029 -0
- package/pan-wizard-core/bin/lib/template.cjs +314 -0
- package/pan-wizard-core/bin/lib/utils.cjs +171 -0
- package/pan-wizard-core/bin/lib/verify.cjs +1808 -0
- package/pan-wizard-core/bin/pan-tools.cjs +773 -0
- package/pan-wizard-core/references/checkpoints.md +776 -0
- package/pan-wizard-core/references/continuation-format.md +249 -0
- package/pan-wizard-core/references/decimal-phase-calculation.md +65 -0
- package/pan-wizard-core/references/git-integration.md +248 -0
- package/pan-wizard-core/references/git-planning-commit.md +38 -0
- package/pan-wizard-core/references/model-profile-resolution.md +34 -0
- package/pan-wizard-core/references/model-profiles.md +111 -0
- package/pan-wizard-core/references/phase-argument-parsing.md +61 -0
- package/pan-wizard-core/references/planning-config.md +196 -0
- package/pan-wizard-core/references/questioning.md +145 -0
- package/pan-wizard-core/references/tdd.md +263 -0
- package/pan-wizard-core/references/ui-brand.md +160 -0
- package/pan-wizard-core/references/verification-patterns.md +612 -0
- package/pan-wizard-core/templates/codebase/architecture.md +283 -0
- package/pan-wizard-core/templates/codebase/best-practices.md +133 -0
- package/pan-wizard-core/templates/codebase/concerns.md +325 -0
- package/pan-wizard-core/templates/codebase/conventions.md +307 -0
- package/pan-wizard-core/templates/codebase/integrations.md +305 -0
- package/pan-wizard-core/templates/codebase/relationships.md +124 -0
- package/pan-wizard-core/templates/codebase/stack.md +199 -0
- package/pan-wizard-core/templates/codebase/structure.md +298 -0
- package/pan-wizard-core/templates/codebase/testing.md +480 -0
- package/pan-wizard-core/templates/config.json +37 -0
- package/pan-wizard-core/templates/context.md +283 -0
- package/pan-wizard-core/templates/continue-here.md +78 -0
- package/pan-wizard-core/templates/debug-subagent-prompt.md +91 -0
- package/pan-wizard-core/templates/debug.md +164 -0
- package/pan-wizard-core/templates/discovery.md +146 -0
- package/pan-wizard-core/templates/milestone-archive.md +123 -0
- package/pan-wizard-core/templates/milestone.md +115 -0
- package/pan-wizard-core/templates/phase-prompt.md +593 -0
- package/pan-wizard-core/templates/planner-subagent-prompt.md +117 -0
- package/pan-wizard-core/templates/project.md +184 -0
- package/pan-wizard-core/templates/requirements.md +231 -0
- package/pan-wizard-core/templates/research-project/architecture.md +204 -0
- package/pan-wizard-core/templates/research-project/features.md +147 -0
- package/pan-wizard-core/templates/research-project/pitfalls.md +200 -0
- package/pan-wizard-core/templates/research-project/stack.md +120 -0
- package/pan-wizard-core/templates/research-project/summary.md +170 -0
- package/pan-wizard-core/templates/research.md +552 -0
- package/pan-wizard-core/templates/retrospective.md +54 -0
- package/pan-wizard-core/templates/roadmap.md +202 -0
- package/pan-wizard-core/templates/standards.md +24 -0
- package/pan-wizard-core/templates/state.md +176 -0
- package/pan-wizard-core/templates/summary-complex.md +59 -0
- package/pan-wizard-core/templates/summary-minimal.md +41 -0
- package/pan-wizard-core/templates/summary-standard.md +49 -0
- package/pan-wizard-core/templates/summary.md +249 -0
- package/pan-wizard-core/templates/uat.md +247 -0
- package/pan-wizard-core/templates/user-setup.md +311 -0
- package/pan-wizard-core/templates/validation.md +76 -0
- package/pan-wizard-core/templates/verification-report.md +322 -0
- package/pan-wizard-core/workflows/add-phase.md +111 -0
- package/pan-wizard-core/workflows/assumptions.md +178 -0
- package/pan-wizard-core/workflows/diagnose-issues.md +219 -0
- package/pan-wizard-core/workflows/discuss-phase.md +542 -0
- package/pan-wizard-core/workflows/exec-phase.md +572 -0
- package/pan-wizard-core/workflows/execute-plan.md +448 -0
- package/pan-wizard-core/workflows/health.md +156 -0
- package/pan-wizard-core/workflows/help.md +431 -0
- package/pan-wizard-core/workflows/insert-phase.md +129 -0
- package/pan-wizard-core/workflows/map-codebase.md +401 -0
- package/pan-wizard-core/workflows/milestone-audit.md +297 -0
- package/pan-wizard-core/workflows/milestone-cleanup.md +152 -0
- package/pan-wizard-core/workflows/milestone-gaps.md +274 -0
- package/pan-wizard-core/workflows/milestone-new.md +382 -0
- package/pan-wizard-core/workflows/new-project.md +1178 -0
- package/pan-wizard-core/workflows/pause.md +122 -0
- package/pan-wizard-core/workflows/phase-tests.md +388 -0
- package/pan-wizard-core/workflows/plan-phase.md +569 -0
- package/pan-wizard-core/workflows/profile.md +115 -0
- package/pan-wizard-core/workflows/progress.md +381 -0
- package/pan-wizard-core/workflows/quick.md +453 -0
- package/pan-wizard-core/workflows/remove-phase.md +154 -0
- package/pan-wizard-core/workflows/research-phase.md +73 -0
- package/pan-wizard-core/workflows/resume-project.md +306 -0
- package/pan-wizard-core/workflows/retro.md +121 -0
- package/pan-wizard-core/workflows/settings.md +213 -0
- package/pan-wizard-core/workflows/todo-add.md +157 -0
- package/pan-wizard-core/workflows/todo-check.md +176 -0
- package/pan-wizard-core/workflows/transition.md +544 -0
- package/pan-wizard-core/workflows/update.md +219 -0
- package/pan-wizard-core/workflows/verify-phase.md +301 -0
- package/scripts/build-hooks.js +43 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Milestone — Milestone and requirements lifecycle operations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { PLANNING_DIR, PHASES_DIR, MILESTONES_DIR, ROADMAP_FILE, REQUIREMENTS_FILE, STATE_FILE, isPlanFile } = require('./constants.cjs');
|
|
8
|
+
const { planningPath, phasesPath, filterPlanFiles, filterSummaryFiles, fileAccessible } = require('./utils.cjs');
|
|
9
|
+
const { output, error, isGitRepo, execGit } = require('./core.cjs');
|
|
10
|
+
const { extractFrontmatter } = require('./frontmatter.cjs');
|
|
11
|
+
const { writeStateMd } = require('./state.cjs');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mark requirement IDs as complete in requirements.md checkboxes and traceability table.
|
|
15
|
+
* @param {string} cwd - Working directory path
|
|
16
|
+
* @param {string[]} reqIdsRaw - Array of requirement ID strings (e.g., ["REQ-01", "REQ-02"])
|
|
17
|
+
* @param {boolean} raw - If true, output raw value instead of JSON
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
function cmdRequirementsMarkComplete(cwd, reqIdsRaw, raw) {
|
|
21
|
+
if (!reqIdsRaw || reqIdsRaw.length === 0) {
|
|
22
|
+
error('requirement IDs required. Usage: requirements mark-complete REQ-01,REQ-02 or REQ-01 REQ-02');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Accept comma-separated, space-separated, or bracket-wrapped: [REQ-01, REQ-02]
|
|
26
|
+
const reqIds = reqIdsRaw
|
|
27
|
+
.join(' ')
|
|
28
|
+
.replace(/[\[\]]/g, '')
|
|
29
|
+
.split(/[,\s]+/)
|
|
30
|
+
.map(id => id.trim())
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
|
|
33
|
+
if (reqIds.length === 0) {
|
|
34
|
+
error('no valid requirement IDs found');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const reqPath = path.join(planningPath(cwd), REQUIREMENTS_FILE);
|
|
38
|
+
let reqContent;
|
|
39
|
+
try {
|
|
40
|
+
reqContent = fs.readFileSync(reqPath, 'utf-8');
|
|
41
|
+
} catch {
|
|
42
|
+
output({ updated: false, reason: 'requirements.md not found', ids: reqIds }, raw, 'no requirements file');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const updated = [];
|
|
46
|
+
const notFound = [];
|
|
47
|
+
|
|
48
|
+
for (const reqId of reqIds) {
|
|
49
|
+
let found = false;
|
|
50
|
+
|
|
51
|
+
// Update checkbox: - [ ] **REQ-ID** -> - [x] **REQ-ID**
|
|
52
|
+
const checkboxPattern = new RegExp(`(-\\s*\\[)[ ](\\]\\s*\\*\\*${reqId}\\*\\*)`, 'gi');
|
|
53
|
+
if (checkboxPattern.test(reqContent)) {
|
|
54
|
+
reqContent = reqContent.replace(checkboxPattern, '$1x$2');
|
|
55
|
+
found = true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Update traceability table: | REQ-ID | Phase N | Pending | -> | REQ-ID | Phase N | Complete |
|
|
59
|
+
const tablePattern = new RegExp(`(\\|\\s*${reqId}\\s*\\|[^|]+\\|)\\s*Pending\\s*(\\|)`, 'gi');
|
|
60
|
+
if (tablePattern.test(reqContent)) {
|
|
61
|
+
// Re-create regex since test() advances lastIndex for global regex
|
|
62
|
+
reqContent = reqContent.replace(
|
|
63
|
+
new RegExp(`(\\|\\s*${reqId}\\s*\\|[^|]+\\|)\\s*Pending\\s*(\\|)`, 'gi'),
|
|
64
|
+
'$1 Complete $2'
|
|
65
|
+
);
|
|
66
|
+
found = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (found) {
|
|
70
|
+
updated.push(reqId);
|
|
71
|
+
} else {
|
|
72
|
+
notFound.push(reqId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (updated.length > 0) {
|
|
77
|
+
try {
|
|
78
|
+
fs.writeFileSync(reqPath, reqContent, 'utf-8');
|
|
79
|
+
} catch (err) {
|
|
80
|
+
output({ error: 'Failed to write requirements.md: ' + err.message }, raw);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
output({
|
|
86
|
+
updated: updated.length > 0,
|
|
87
|
+
marked_complete: updated,
|
|
88
|
+
not_found: notFound,
|
|
89
|
+
total: reqIds.length,
|
|
90
|
+
}, raw, `${updated.length}/${reqIds.length} requirements marked complete`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gather phase/plan/task stats and accomplishments from all phase directories.
|
|
95
|
+
* @param {string} cwd - Working directory path
|
|
96
|
+
* @returns {{phaseCount: number, totalPlans: number, totalTasks: number, accomplishments: string[]}}
|
|
97
|
+
*/
|
|
98
|
+
function gatherMilestoneStats(cwd) {
|
|
99
|
+
const phasesDirPath = phasesPath(cwd);
|
|
100
|
+
let phaseCount = 0, totalPlans = 0, totalTasks = 0;
|
|
101
|
+
const accomplishments = [];
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
const entries = fs.readdirSync(phasesDirPath, { withFileTypes: true });
|
|
105
|
+
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort();
|
|
106
|
+
|
|
107
|
+
for (const dirName of dirs) {
|
|
108
|
+
phaseCount++;
|
|
109
|
+
let phaseFiles;
|
|
110
|
+
try {
|
|
111
|
+
phaseFiles = fs.readdirSync(path.join(phasesDirPath, dirName));
|
|
112
|
+
} catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
totalPlans += filterPlanFiles(phaseFiles).length;
|
|
116
|
+
|
|
117
|
+
for (const sf of filterSummaryFiles(phaseFiles)) {
|
|
118
|
+
try {
|
|
119
|
+
const content = fs.readFileSync(path.join(phasesDirPath, dirName, sf), 'utf-8');
|
|
120
|
+
const fm = extractFrontmatter(content);
|
|
121
|
+
if (fm['one-liner']) accomplishments.push(fm['one-liner']);
|
|
122
|
+
totalTasks += (content.match(/##\s*Task\s*\d+/gi) || []).length;
|
|
123
|
+
} catch { /* skip unreadable */ }
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} catch { /* phases dir missing */ }
|
|
127
|
+
|
|
128
|
+
return { phaseCount, totalPlans, totalTasks, accomplishments };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Archive milestone files (ROADMAP, REQUIREMENTS, audit) into the milestones directory.
|
|
133
|
+
* @param {string} planningDir - Absolute path to .planning/
|
|
134
|
+
* @param {string} version - Milestone version (e.g., "v1.0")
|
|
135
|
+
* @param {string} archiveDir - Absolute path to milestones archive directory
|
|
136
|
+
* @param {string} today - Date string (YYYY-MM-DD)
|
|
137
|
+
* @param {string} milestoneName - Human-readable milestone name
|
|
138
|
+
*/
|
|
139
|
+
function archiveMilestoneFiles(planningDir, version, archiveDir, today, milestoneName) {
|
|
140
|
+
const warnings = [];
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const roadmap = fs.readFileSync(path.join(planningDir, ROADMAP_FILE), 'utf-8');
|
|
144
|
+
fs.writeFileSync(path.join(archiveDir, `${version}-roadmap.md`), roadmap, 'utf-8');
|
|
145
|
+
} catch (e) {
|
|
146
|
+
if (e.code !== 'ENOENT') warnings.push('roadmap: ' + e.message);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const req = fs.readFileSync(path.join(planningDir, REQUIREMENTS_FILE), 'utf-8');
|
|
151
|
+
const header = `# Requirements Archive: ${version} ${milestoneName}\n\n**Archived:** ${today}\n**Status:** SHIPPED\n\nFor current requirements, see \`.planning/${REQUIREMENTS_FILE}\`.\n\n---\n\n`;
|
|
152
|
+
fs.writeFileSync(path.join(archiveDir, `${version}-${REQUIREMENTS_FILE}`), header + req, 'utf-8');
|
|
153
|
+
} catch (e) {
|
|
154
|
+
if (e.code !== 'ENOENT') warnings.push('requirements: ' + e.message);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
fs.renameSync(path.join(planningDir, `${version}-milestone-audit.md`), path.join(archiveDir, `${version}-milestone-audit.md`));
|
|
159
|
+
} catch (e) {
|
|
160
|
+
if (e.code !== 'ENOENT') warnings.push('audit: ' + e.message);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return { warnings };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Build a milestone entry string for milestones.md.
|
|
168
|
+
* @param {string} version - Milestone version
|
|
169
|
+
* @param {string} name - Milestone name
|
|
170
|
+
* @param {string} today - Date string
|
|
171
|
+
* @param {{phaseCount: number, totalPlans: number, totalTasks: number, accomplishments: string[]}} stats
|
|
172
|
+
* @returns {string}
|
|
173
|
+
*/
|
|
174
|
+
function createMilestoneEntry(version, name, today, stats) {
|
|
175
|
+
const list = stats.accomplishments.map(item => `- ${item}`).join('\n');
|
|
176
|
+
return `## ${version} ${name} (Shipped: ${today})\n\n**Phases completed:** ${stats.phaseCount} phases, ${stats.totalPlans} plans, ${stats.totalTasks} tasks\n\n**Key accomplishments:**\n${list || '- (none recorded)'}\n\n---\n\n`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function cmdMilestoneComplete(cwd, version, options, raw) {
|
|
180
|
+
if (!version) {
|
|
181
|
+
error('version required for milestone complete (e.g., v1.0)');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const planningDir = planningPath(cwd);
|
|
185
|
+
const statePath = path.join(planningDir, STATE_FILE);
|
|
186
|
+
const milestonesPath = path.join(planningDir, 'milestones.md');
|
|
187
|
+
const archiveDir = path.join(planningDir, MILESTONES_DIR);
|
|
188
|
+
const today = new Date().toISOString().split('T')[0];
|
|
189
|
+
const milestoneName = options.name || version;
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
fs.mkdirSync(archiveDir, { recursive: true });
|
|
193
|
+
} catch (e) {
|
|
194
|
+
error(`Failed to create archive directory: ${e.message}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const stats = gatherMilestoneStats(cwd);
|
|
198
|
+
const archiveResult = archiveMilestoneFiles(planningDir, version, archiveDir, today, milestoneName);
|
|
199
|
+
|
|
200
|
+
// Create or append the milestone entry in milestones.md
|
|
201
|
+
const milestoneEntry = createMilestoneEntry(version, milestoneName, today, stats);
|
|
202
|
+
try {
|
|
203
|
+
let existing;
|
|
204
|
+
try { existing = fs.readFileSync(milestonesPath, 'utf-8'); } catch { existing = null; }
|
|
205
|
+
if (existing !== null) {
|
|
206
|
+
fs.writeFileSync(milestonesPath, existing + '\n' + milestoneEntry, 'utf-8');
|
|
207
|
+
} else {
|
|
208
|
+
fs.writeFileSync(milestonesPath, `# Milestones\n\n${milestoneEntry}`, 'utf-8');
|
|
209
|
+
}
|
|
210
|
+
} catch (e) {
|
|
211
|
+
error(`Failed to update milestones.md: ${e.message}`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Update state.md with milestone completion info
|
|
215
|
+
try {
|
|
216
|
+
let stateContent = fs.readFileSync(statePath, 'utf-8');
|
|
217
|
+
stateContent = stateContent.replace(/(\*\*Status:\*\*\s*).*/, `$1${version} milestone complete`);
|
|
218
|
+
stateContent = stateContent.replace(/(\*\*Last Activity:\*\*\s*).*/, `$1${today}`);
|
|
219
|
+
stateContent = stateContent.replace(/(\*\*Last Activity Description:\*\*\s*).*/, `$1${version} milestone completed and archived`);
|
|
220
|
+
writeStateMd(statePath, stateContent, cwd);
|
|
221
|
+
} catch { /* best-effort */ }
|
|
222
|
+
|
|
223
|
+
// Archive phase directories if explicitly requested
|
|
224
|
+
let phasesArchived = false;
|
|
225
|
+
if (options.archivePhases) {
|
|
226
|
+
try {
|
|
227
|
+
const phaseArchiveDir = path.join(archiveDir, `${version}-${PHASES_DIR}`);
|
|
228
|
+
fs.mkdirSync(phaseArchiveDir, { recursive: true });
|
|
229
|
+
const phaseEntries = fs.readdirSync(phasesPath(cwd), { withFileTypes: true });
|
|
230
|
+
const dirs = phaseEntries.filter(e => e.isDirectory()).map(e => e.name);
|
|
231
|
+
for (const dirName of dirs) {
|
|
232
|
+
fs.renameSync(path.join(phasesPath(cwd), dirName), path.join(phaseArchiveDir, dirName));
|
|
233
|
+
}
|
|
234
|
+
phasesArchived = dirs.length > 0;
|
|
235
|
+
} catch { /* locked or missing */ }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const result = {
|
|
239
|
+
version, name: milestoneName, date: today,
|
|
240
|
+
phases: stats.phaseCount, plans: stats.totalPlans, tasks: stats.totalTasks,
|
|
241
|
+
accomplishments: stats.accomplishments,
|
|
242
|
+
archived: {
|
|
243
|
+
roadmap: fileAccessible(path.join(archiveDir, `${version}-roadmap.md`)),
|
|
244
|
+
requirements: fileAccessible(path.join(archiveDir, `${version}-${REQUIREMENTS_FILE}`)),
|
|
245
|
+
audit: fileAccessible(path.join(archiveDir, `${version}-milestone-audit.md`)),
|
|
246
|
+
phases: phasesArchived,
|
|
247
|
+
},
|
|
248
|
+
milestones_updated: true,
|
|
249
|
+
state_updated: fileAccessible(statePath),
|
|
250
|
+
};
|
|
251
|
+
if (archiveResult.warnings.length > 0) {
|
|
252
|
+
result.archive_warnings = archiveResult.warnings;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Auto-commit + tag unless --no-commit or not a git repo
|
|
256
|
+
if (!options.noCommit && isGitRepo(cwd)) {
|
|
257
|
+
execGit(cwd, ['add', PLANNING_DIR + '/']);
|
|
258
|
+
const commitMsg = `docs: milestone ${version} complete`;
|
|
259
|
+
const commitResult = execGit(cwd, ['commit', '-m', commitMsg]);
|
|
260
|
+
if (commitResult.exitCode === 0) {
|
|
261
|
+
const hashResult = execGit(cwd, ['rev-parse', '--short', 'HEAD']);
|
|
262
|
+
result.commit_hash = hashResult.exitCode === 0 ? hashResult.stdout : null;
|
|
263
|
+
// Create tag
|
|
264
|
+
const tagName = `milestone-${version}`;
|
|
265
|
+
const tagResult = execGit(cwd, ['tag', tagName]);
|
|
266
|
+
result.tag = tagResult.exitCode === 0 ? tagName : null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
output(result, raw);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
module.exports = {
|
|
274
|
+
cmdRequirementsMarkComplete,
|
|
275
|
+
cmdMilestoneComplete,
|
|
276
|
+
};
|