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,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Budget — Estimate context utilization and quality for current phase
|
|
3
|
+
*
|
|
4
|
+
* Reads state.md, phase plans, and config to produce a context health report.
|
|
5
|
+
* Makes PAN's context rot prevention visible and measurable.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { output, error, safeReadFile, loadConfig, findPhaseInternal, toPosix } = require('./core.cjs');
|
|
11
|
+
const { planningPath, phasesPath, fileAccessible } = require('./utils.cjs');
|
|
12
|
+
const { STATE_FILE, ROADMAP_FILE, PROJECT_FILE, isPlanFile, isSummaryFile, CHARS_PER_TOKEN, CONTEXT_WINDOW, WARNING_THRESHOLD, CRITICAL_THRESHOLD } = require('./constants.cjs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Estimate token count from text content.
|
|
16
|
+
* @param {string} text - Text content
|
|
17
|
+
* @returns {number} Estimated token count
|
|
18
|
+
*/
|
|
19
|
+
function estimateTokens(text) {
|
|
20
|
+
if (!text) return 0;
|
|
21
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Compute context budget for the current project state.
|
|
26
|
+
* @param {string} cwd - Project root directory
|
|
27
|
+
* @param {boolean} raw - If true, output human-readable string
|
|
28
|
+
*/
|
|
29
|
+
function cmdContextBudget(cwd, raw) {
|
|
30
|
+
const planDir = planningPath(cwd);
|
|
31
|
+
if (!fileAccessible(planDir)) {
|
|
32
|
+
return output({ error: '.planning/ directory not found', hint: 'Run /pan:new-project to initialize' }, raw,
|
|
33
|
+
'Error: .planning/ directory not found\nHint: Run /pan:new-project to initialize');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const config = loadConfig(cwd);
|
|
37
|
+
|
|
38
|
+
// Read core files and estimate tokens
|
|
39
|
+
const stateContent = safeReadFile(path.join(planDir, STATE_FILE));
|
|
40
|
+
const roadmapContent = safeReadFile(path.join(planDir, ROADMAP_FILE));
|
|
41
|
+
const projectContent = safeReadFile(path.join(planDir, PROJECT_FILE));
|
|
42
|
+
|
|
43
|
+
const stateTokens = estimateTokens(stateContent);
|
|
44
|
+
const roadmapTokens = estimateTokens(roadmapContent);
|
|
45
|
+
const projectTokens = estimateTokens(projectContent);
|
|
46
|
+
|
|
47
|
+
// Find current phase and estimate plan tokens
|
|
48
|
+
let currentPhase = null;
|
|
49
|
+
let planTokens = 0;
|
|
50
|
+
let planCount = 0;
|
|
51
|
+
let incompletePlanCount = 0;
|
|
52
|
+
let phaseDir = null;
|
|
53
|
+
|
|
54
|
+
if (stateContent) {
|
|
55
|
+
const phaseMatch = stateContent.match(/\*\*Current Phase:\*\*\s*(\S+)/);
|
|
56
|
+
if (phaseMatch) {
|
|
57
|
+
currentPhase = phaseMatch[1];
|
|
58
|
+
const phaseInfo = findPhaseInternal(cwd, currentPhase);
|
|
59
|
+
if (phaseInfo && phaseInfo.found) {
|
|
60
|
+
phaseDir = phaseInfo.directory;
|
|
61
|
+
planCount = phaseInfo.plans.length;
|
|
62
|
+
incompletePlanCount = phaseInfo.incomplete_plans.length;
|
|
63
|
+
|
|
64
|
+
// Estimate plan tokens
|
|
65
|
+
const fullPhasePath = path.join(cwd, phaseInfo.directory);
|
|
66
|
+
for (const planFile of phaseInfo.plans) {
|
|
67
|
+
const planContent = safeReadFile(path.join(fullPhasePath, planFile));
|
|
68
|
+
planTokens += estimateTokens(planContent);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Calculate totals
|
|
75
|
+
const contextTokens = stateTokens + roadmapTokens + projectTokens;
|
|
76
|
+
const totalTokens = contextTokens + planTokens;
|
|
77
|
+
const utilization = totalTokens / CONTEXT_WINDOW;
|
|
78
|
+
|
|
79
|
+
// Determine status
|
|
80
|
+
let status = 'healthy';
|
|
81
|
+
if (!currentPhase) {
|
|
82
|
+
status = 'idle';
|
|
83
|
+
} else if (utilization >= CRITICAL_THRESHOLD) {
|
|
84
|
+
status = 'critical';
|
|
85
|
+
} else if (utilization >= WARNING_THRESHOLD) {
|
|
86
|
+
status = 'warning';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Generate recommendation
|
|
90
|
+
let recommendation;
|
|
91
|
+
if (status === 'idle') {
|
|
92
|
+
recommendation = 'No active phase. Run /pan:plan-phase to start.';
|
|
93
|
+
} else if (status === 'critical') {
|
|
94
|
+
recommendation = 'Context budget near limit. Consider splitting this phase into smaller phases.';
|
|
95
|
+
} else if (status === 'warning') {
|
|
96
|
+
recommendation = 'Context usage is elevated. Monitor quality during execution.';
|
|
97
|
+
} else {
|
|
98
|
+
const remainingTokens = CONTEXT_WINDOW - totalTokens;
|
|
99
|
+
const avgPlanTokens = planCount > 0 ? Math.ceil(planTokens / planCount) : 5000;
|
|
100
|
+
const additionalPlans = avgPlanTokens > 0 ? Math.floor(remainingTokens / avgPlanTokens) : 0;
|
|
101
|
+
recommendation = `Within budget. ~${additionalPlans} more plans could fit before degradation.`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const result = {
|
|
105
|
+
status,
|
|
106
|
+
currentPhase: currentPhase || null,
|
|
107
|
+
phaseDirectory: phaseDir ? toPosix(phaseDir) : null,
|
|
108
|
+
plans: planCount,
|
|
109
|
+
incompletePlans: incompletePlanCount,
|
|
110
|
+
modelProfile: config.model_profile,
|
|
111
|
+
tokens: {
|
|
112
|
+
project: projectTokens,
|
|
113
|
+
roadmap: roadmapTokens,
|
|
114
|
+
state: stateTokens,
|
|
115
|
+
plans: planTokens,
|
|
116
|
+
total: totalTokens,
|
|
117
|
+
},
|
|
118
|
+
contextWindow: CONTEXT_WINDOW,
|
|
119
|
+
budgetUtilization: Math.round(utilization * 1000) / 1000,
|
|
120
|
+
recommendation,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
if (raw) {
|
|
124
|
+
const lines = [
|
|
125
|
+
`Context Budget: ${status.toUpperCase()}`,
|
|
126
|
+
``,
|
|
127
|
+
`Current Phase: ${currentPhase || 'none'}`,
|
|
128
|
+
`Model Profile: ${config.model_profile}`,
|
|
129
|
+
`Plans: ${planCount} total, ${incompletePlanCount} incomplete`,
|
|
130
|
+
``,
|
|
131
|
+
`Token Estimates:`,
|
|
132
|
+
` project.md: ${projectTokens.toLocaleString()}`,
|
|
133
|
+
` roadmap.md: ${roadmapTokens.toLocaleString()}`,
|
|
134
|
+
` state.md: ${stateTokens.toLocaleString()}`,
|
|
135
|
+
` Phase Plans: ${planTokens.toLocaleString()}`,
|
|
136
|
+
` Total: ${totalTokens.toLocaleString()} / ${CONTEXT_WINDOW.toLocaleString()}`,
|
|
137
|
+
``,
|
|
138
|
+
`Utilization: ${(utilization * 100).toFixed(1)}%`,
|
|
139
|
+
`${recommendation}`,
|
|
140
|
+
];
|
|
141
|
+
return output(result, true, lines.join('\n'));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return output(result, false);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
module.exports = {
|
|
148
|
+
cmdContextBudget,
|
|
149
|
+
estimateTokens,
|
|
150
|
+
};
|