pan-wizard 3.8.0 → 3.12.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 (72) hide show
  1. package/README.md +80 -9
  2. package/agents/pan-conductor.md +15 -3
  3. package/agents/pan-counterfactual.md +1 -2
  4. package/agents/pan-debugger.md +1 -2
  5. package/agents/pan-distiller.md +1 -2
  6. package/agents/pan-document_code.md +1 -0
  7. package/agents/pan-executor.md +1 -0
  8. package/agents/pan-experiment-runner.md +1 -2
  9. package/agents/pan-hardener.md +1 -2
  10. package/agents/pan-integration-checker.md +1 -2
  11. package/agents/pan-knowledge.md +1 -2
  12. package/agents/pan-meta-reviewer.md +1 -2
  13. package/agents/pan-optimizer.md +1 -0
  14. package/agents/pan-phase-researcher.md +1 -0
  15. package/agents/pan-plan-checker.md +1 -2
  16. package/agents/pan-planner.md +1 -0
  17. package/agents/pan-previewer.md +1 -2
  18. package/agents/pan-project-researcher.md +6 -0
  19. package/agents/pan-release.md +58 -0
  20. package/agents/pan-research-synthesizer.md +7 -0
  21. package/agents/pan-reviewer.md +2 -3
  22. package/agents/pan-roadmapper.md +1 -0
  23. package/agents/pan-verifier.md +1 -2
  24. package/assets/pan-avatar.png +0 -0
  25. package/assets/pan-developer.png +0 -0
  26. package/assets/pan-docs-header.png +0 -0
  27. package/assets/pan-hero.png +0 -0
  28. package/assets/pan-logo-2000-transparent.svg +11 -30
  29. package/assets/pan-logo-2000.svg +12 -43
  30. package/assets/pan-logo-lockup.svg +11 -0
  31. package/assets/pan-mark.svg +7 -0
  32. package/assets/pan-orchestration.png +0 -0
  33. package/assets/pan-readme-hero.png +0 -0
  34. package/assets/terminal.svg +39 -119
  35. package/bin/install-lib.cjs +661 -46
  36. package/bin/install.js +722 -116
  37. package/commands/pan/army.md +169 -0
  38. package/commands/pan/dashboard.md +25 -0
  39. package/commands/pan/experiment.md +2 -0
  40. package/commands/pan/focus-auto.md +32 -4
  41. package/commands/pan/hud.md +91 -0
  42. package/commands/pan/profile.md +2 -0
  43. package/hooks/dist/pan-cost-logger.js +22 -7
  44. package/package.json +5 -4
  45. package/pan-wizard-core/bin/lib/campaign.cjs +198 -0
  46. package/pan-wizard-core/bin/lib/commands-learnings.cjs +544 -0
  47. package/pan-wizard-core/bin/lib/commands.cjs +12 -523
  48. package/pan-wizard-core/bin/lib/constants.cjs +8 -0
  49. package/pan-wizard-core/bin/lib/core.cjs +80 -0
  50. package/pan-wizard-core/bin/lib/cost.cjs +62 -8
  51. package/pan-wizard-core/bin/lib/focus.cjs +13 -1
  52. package/pan-wizard-core/bin/lib/git.cjs +6 -1
  53. package/pan-wizard-core/bin/lib/hud.cjs +887 -0
  54. package/pan-wizard-core/bin/lib/lock.cjs +108 -0
  55. package/pan-wizard-core/bin/lib/milestone.cjs +3 -2
  56. package/pan-wizard-core/bin/lib/phase-remove.cjs +392 -0
  57. package/pan-wizard-core/bin/lib/phase.cjs +4 -369
  58. package/pan-wizard-core/bin/lib/runner.cjs +5 -0
  59. package/pan-wizard-core/bin/lib/squads.cjs +152 -0
  60. package/pan-wizard-core/bin/lib/state.cjs +10 -1
  61. package/pan-wizard-core/bin/lib/verify-deploy.cjs +181 -0
  62. package/pan-wizard-core/bin/lib/verify-drift.cjs +255 -0
  63. package/pan-wizard-core/bin/lib/verify-preflight.cjs +261 -0
  64. package/pan-wizard-core/bin/lib/verify-retro.cjs +177 -0
  65. package/pan-wizard-core/bin/lib/verify.cjs +10 -797
  66. package/pan-wizard-core/bin/lib/worktree.cjs +123 -0
  67. package/pan-wizard-core/bin/pan-tools.cjs +78 -0
  68. package/pan-wizard-core/learnings/universal/autonomous-loop.md +56 -0
  69. package/pan-wizard-core/workflows/plan-phase.md +11 -0
  70. package/scripts/build-plugin.js +105 -0
  71. package/scripts/install-git-hooks.js +64 -0
  72. package/scripts/release-check.js +13 -2
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Verify / Retrospective analysis — milestone retro over historical .planning/ data.
3
+ * Extracted from verify.cjs (IMPROVEMENT-TODO P2 module decomposition);
4
+ * verify.cjs re-exports everything here, so consumers are unaffected.
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { safeReadFile, output } = require('./core.cjs');
10
+ const { extractFrontmatter } = require('./frontmatter.cjs');
11
+ const { ROADMAP_FILE, isVerificationFile } = require('./constants.cjs');
12
+ const { planningPath, phasesPath } = require('./utils.cjs');
13
+
14
+ /**
15
+ * Scan verification files in a phases directory and collect stats.
16
+ * @param {string} phasesDir - Absolute path to phases directory
17
+ * @returns {{ total: number, passed: number, gaps_found: number, human_needed: number, gap_patterns: string[] }}
18
+ */
19
+ function collectVerificationStats(phasesDir) {
20
+ const stats = { total: 0, passed: 0, gaps_found: 0, human_needed: 0, gap_patterns: [] };
21
+ let dirs;
22
+ try { dirs = fs.readdirSync(phasesDir, { withFileTypes: true }); } catch { return stats; }
23
+ for (const d of dirs) {
24
+ if (!d.isDirectory()) continue;
25
+ const phaseDir = path.join(phasesDir, d.name);
26
+ let files;
27
+ try { files = fs.readdirSync(phaseDir); } catch { continue; }
28
+ for (const f of files) {
29
+ if (!isVerificationFile(f)) continue;
30
+ stats.total++;
31
+ const content = safeReadFile(path.join(phaseDir, f));
32
+ if (!content) continue;
33
+ const fm = extractFrontmatter(content);
34
+ const status = (fm.status || '').toLowerCase();
35
+ if (status === 'passed') stats.passed++;
36
+ else if (status === 'gaps_found') stats.gaps_found++;
37
+ else if (status === 'human_needed') stats.human_needed++;
38
+ // Extract gap descriptions from ## Gaps section
39
+ const gapsMatch = content.match(/## Gaps[\s\S]*?(?=\n## |$)/);
40
+ if (gapsMatch) {
41
+ const lines = gapsMatch[0].split('\n').filter(l => l.match(/^[-*]\s+/));
42
+ for (const line of lines) {
43
+ const desc = line.replace(/^[-*]\s+/, '').trim();
44
+ if (desc) stats.gap_patterns.push(desc);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return stats;
50
+ }
51
+
52
+ /**
53
+ * Count phases from roadmap: total planned, completed, and decimal (gap closure) phases.
54
+ * @param {string} roadmapContent - Roadmap file content
55
+ * @returns {{ planned: number, completed: number, decimal_phases: number }}
56
+ */
57
+ function countRoadmapPhases(roadmapContent) {
58
+ const result = { planned: 0, completed: 0, decimal_phases: 0 };
59
+ const checkboxRe = /- \[([ x])\]\s*(?:\*\*)?Phase\s+(\d+[A-Z]?(?:\.\d+)*)/gi;
60
+ let m;
61
+ while ((m = checkboxRe.exec(roadmapContent)) !== null) {
62
+ result.planned++;
63
+ if (m[1] === 'x') result.completed++;
64
+ if (m[2].includes('.')) result.decimal_phases++;
65
+ }
66
+ return result;
67
+ }
68
+
69
+ /**
70
+ * Group gap patterns by similarity (simple keyword grouping).
71
+ * @param {string[]} patterns - Raw gap descriptions
72
+ * @returns {Array<{pattern: string, count: number}>}
73
+ */
74
+ function groupGapPatterns(patterns) {
75
+ const groups = {};
76
+ for (const p of patterns) {
77
+ const key = p.toLowerCase().replace(/[^a-z0-9\s]/g, '').trim();
78
+ const words = key.split(/\s+/).slice(0, 3).join(' ');
79
+ groups[words] = (groups[words] || 0) + 1;
80
+ }
81
+ return Object.entries(groups)
82
+ .map(([pattern, count]) => ({ pattern, count }))
83
+ .sort((a, b) => b.count - a.count)
84
+ .slice(0, 10);
85
+ }
86
+
87
+ /**
88
+ * Milestone retrospective — analyze historical .planning/ data for process improvement.
89
+ * @param {string} cwd - Working directory
90
+ * @param {boolean} raw - Raw output flag
91
+ */
92
+ function cmdRetro(cwd, raw, args) {
93
+ const roadmapPath = path.join(planningPath(cwd), ROADMAP_FILE);
94
+ const roadmapContent = safeReadFile(roadmapPath);
95
+ if (!roadmapContent) {
96
+ return output({ error: 'roadmap.md not found' }, raw, 'roadmap.md not found');
97
+ }
98
+
99
+ const phases = countRoadmapPhases(roadmapContent);
100
+ const pDir = phasesPath(cwd);
101
+ const verification = collectVerificationStats(pDir);
102
+ const gapGroups = groupGapPatterns(verification.gap_patterns);
103
+
104
+ // Estimation accuracy: planned phases vs actual (including decimal gap closures)
105
+ const basePlanned = phases.planned - phases.decimal_phases;
106
+ const estimationAccuracy = basePlanned > 0
107
+ ? Math.round((basePlanned / phases.planned) * 100)
108
+ : 100;
109
+
110
+ const result = {
111
+ phases_planned: phases.planned,
112
+ phases_completed: phases.completed,
113
+ phases_decimal: phases.decimal_phases,
114
+ estimation_accuracy_pct: estimationAccuracy,
115
+ verifications_total: verification.total,
116
+ verifications_passed_first_try: verification.passed,
117
+ verifications_gaps_found: verification.gaps_found,
118
+ verifications_human_needed: verification.human_needed,
119
+ first_try_rate_pct: verification.total > 0
120
+ ? Math.round((verification.passed / verification.total) * 100)
121
+ : null,
122
+ common_gap_patterns: gapGroups,
123
+ };
124
+
125
+ // E-4: optional memory write. Top gap patterns become lessons for pan-planner
126
+ // (they surface what plans routinely miss). First-try rate deltas feed
127
+ // pan-verifier memory.
128
+ const argsList = Array.isArray(args) ? args : [];
129
+ if (argsList.includes('--write-memory')) {
130
+ const { appendMemory } = require('./memory.cjs');
131
+ const lessons_written = { 'pan-planner': 0, 'pan-verifier': 0 };
132
+ const maxIdx = argsList.indexOf('--max');
133
+ const maxLessons = maxIdx !== -1 && argsList[maxIdx + 1]
134
+ ? Math.max(1, Math.min(10, Number(argsList[maxIdx + 1]) || 3))
135
+ : 3;
136
+
137
+ // Top N gap patterns → planner memory as single-line lessons.
138
+ const top = gapGroups.slice(0, maxLessons);
139
+ for (const g of top) {
140
+ const lesson = `Recurring plan gap (${g.count}x across phases): "${g.pattern}" — factor into plan-checker inputs`;
141
+ const r = appendMemory(cwd, 'pan-planner', lesson);
142
+ if (r.appended) lessons_written['pan-planner'] += 1;
143
+ }
144
+
145
+ // Low first-try rate → verifier memory.
146
+ if (verification.total >= 3 && result.first_try_rate_pct != null && result.first_try_rate_pct < 60) {
147
+ const lesson = `First-try verification rate ${result.first_try_rate_pct}% over ${verification.total} runs — tighten verification criteria and pre-exec checks`;
148
+ const r = appendMemory(cwd, 'pan-verifier', lesson);
149
+ if (r.appended) lessons_written['pan-verifier'] += 1;
150
+ }
151
+
152
+ result.memory = { wrote: lessons_written, max: maxLessons };
153
+ }
154
+
155
+ const rawLines = [
156
+ `Phases: ${phases.completed}/${phases.planned} completed (${phases.decimal_phases} gap closures)`,
157
+ `Estimation accuracy: ${estimationAccuracy}%`,
158
+ `Verifications: ${verification.passed}/${verification.total} passed first try`,
159
+ `Gaps found: ${verification.gaps_found}, Human needed: ${verification.human_needed}`,
160
+ ];
161
+ if (gapGroups.length > 0) {
162
+ rawLines.push('Common gap patterns:');
163
+ for (const g of gapGroups) rawLines.push(` - ${g.pattern} (${g.count}x)`);
164
+ }
165
+ if (result.memory) {
166
+ rawLines.push(`Memory: wrote ${result.memory.wrote['pan-planner']} planner + ${result.memory.wrote['pan-verifier']} verifier lessons`);
167
+ }
168
+
169
+ output(result, raw, rawLines.join('\n'));
170
+ }
171
+
172
+ module.exports = {
173
+ collectVerificationStats,
174
+ countRoadmapPhases,
175
+ groupGapPatterns,
176
+ cmdRetro,
177
+ };