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,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pan:update
|
|
3
|
+
group: System
|
|
4
|
+
description: Update PAN to latest version with changelog display
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- AskUserQuestion
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<objective>
|
|
11
|
+
Check for PAN updates, install if available, and display what changed.
|
|
12
|
+
|
|
13
|
+
Routes to the update workflow which handles:
|
|
14
|
+
- Version detection (local vs global installation)
|
|
15
|
+
- npm version checking
|
|
16
|
+
- Changelog fetching and display
|
|
17
|
+
- User confirmation with clean install warning
|
|
18
|
+
- Update execution and cache clearing
|
|
19
|
+
- Restart reminder
|
|
20
|
+
</objective>
|
|
21
|
+
|
|
22
|
+
<execution_context>
|
|
23
|
+
@~/.claude/pan-wizard-core/workflows/update.md
|
|
24
|
+
</execution_context>
|
|
25
|
+
|
|
26
|
+
<process>
|
|
27
|
+
**Follow the update workflow** from `@~/.claude/pan-wizard-core/workflows/update.md`.
|
|
28
|
+
|
|
29
|
+
The workflow handles all logic including:
|
|
30
|
+
1. Installed version detection (local/global)
|
|
31
|
+
2. Latest version checking via npm
|
|
32
|
+
3. Version comparison
|
|
33
|
+
4. Changelog fetching and extraction
|
|
34
|
+
5. Clean install warning display
|
|
35
|
+
6. User confirmation
|
|
36
|
+
7. Update execution
|
|
37
|
+
8. Cache clearing
|
|
38
|
+
</process>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pan:verify-phase
|
|
3
|
+
group: Phase Lifecycle
|
|
4
|
+
description: Validate built features through conversational UAT with test suite gate
|
|
5
|
+
argument-hint: "[phase number, e.g., '4']"
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Bash
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Edit
|
|
12
|
+
- Write
|
|
13
|
+
- Task
|
|
14
|
+
---
|
|
15
|
+
<objective>
|
|
16
|
+
Validate built features through conversational testing with persistent state.
|
|
17
|
+
|
|
18
|
+
Purpose: Confirm what Claude built actually works from user's perspective. One test at a time, plain text responses, no interrogation. When issues are found, automatically diagnose, plan fixes, and prepare for execution.
|
|
19
|
+
|
|
20
|
+
Output: {phase_num}-uat.md tracking all test results. If issues found: diagnosed gaps, verified fix plans ready for /pan:exec-phase
|
|
21
|
+
</objective>
|
|
22
|
+
|
|
23
|
+
<execution_context>
|
|
24
|
+
@~/.claude/pan-wizard-core/workflows/verify-phase.md
|
|
25
|
+
@~/.claude/pan-wizard-core/templates/uat.md
|
|
26
|
+
</execution_context>
|
|
27
|
+
|
|
28
|
+
<context>
|
|
29
|
+
Phase: $ARGUMENTS (optional)
|
|
30
|
+
- If provided: Test specific phase (e.g., "4")
|
|
31
|
+
- If not provided: Check for active sessions or prompt for phase
|
|
32
|
+
|
|
33
|
+
Context files are resolved inside the workflow (`init verify-work`) and delegated via `<files_to_read>` blocks.
|
|
34
|
+
</context>
|
|
35
|
+
|
|
36
|
+
<process>
|
|
37
|
+
Execute the verify-work workflow from @~/.claude/pan-wizard-core/workflows/verify-phase.md end-to-end.
|
|
38
|
+
Preserve all workflow gates (session management, test presentation, diagnosis, fix planning, routing).
|
|
39
|
+
</process>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Check for PAN updates in background, write result to cache
|
|
3
|
+
// Called by SessionStart hook - runs once per session
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
|
|
10
|
+
const homeDir = os.homedir();
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const cacheDir = path.join(homeDir, '.claude', 'cache');
|
|
13
|
+
const cacheFile = path.join(cacheDir, 'pan-update-check.json');
|
|
14
|
+
|
|
15
|
+
// VERSION file locations (check project first, then global)
|
|
16
|
+
const projectVersionFile = path.join(cwd, '.claude', 'pan-wizard-core', 'VERSION');
|
|
17
|
+
const globalVersionFile = path.join(homeDir, '.claude', 'pan-wizard-core', 'VERSION');
|
|
18
|
+
|
|
19
|
+
// Ensure cache directory exists
|
|
20
|
+
if (!fs.existsSync(cacheDir)) {
|
|
21
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Run check in background (spawn background process, windowsHide prevents console flash)
|
|
25
|
+
const child = spawn(process.execPath, ['-e', `
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const { execSync } = require('child_process');
|
|
28
|
+
|
|
29
|
+
const cacheFile = ${JSON.stringify(cacheFile)};
|
|
30
|
+
const projectVersionFile = ${JSON.stringify(projectVersionFile)};
|
|
31
|
+
const globalVersionFile = ${JSON.stringify(globalVersionFile)};
|
|
32
|
+
|
|
33
|
+
// Check project directory first (local install), then global
|
|
34
|
+
let installed = '0.0.0';
|
|
35
|
+
try {
|
|
36
|
+
if (fs.existsSync(projectVersionFile)) {
|
|
37
|
+
installed = fs.readFileSync(projectVersionFile, 'utf8').trim();
|
|
38
|
+
} else if (fs.existsSync(globalVersionFile)) {
|
|
39
|
+
installed = fs.readFileSync(globalVersionFile, 'utf8').trim();
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {}
|
|
42
|
+
|
|
43
|
+
let latest = null;
|
|
44
|
+
try {
|
|
45
|
+
latest = execSync('npm view pan-wizard version', { encoding: 'utf8', timeout: 10000, windowsHide: true }).trim();
|
|
46
|
+
} catch (e) {}
|
|
47
|
+
|
|
48
|
+
const result = {
|
|
49
|
+
update_available: latest && installed !== latest,
|
|
50
|
+
installed,
|
|
51
|
+
latest: latest || 'unknown',
|
|
52
|
+
checked: Math.floor(Date.now() / 1000)
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
fs.writeFileSync(cacheFile, JSON.stringify(result));
|
|
56
|
+
`], {
|
|
57
|
+
stdio: 'ignore',
|
|
58
|
+
windowsHide: true,
|
|
59
|
+
detached: true // Required on Windows for proper process detachment
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
child.unref();
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Context Monitor - PostToolUse hook
|
|
3
|
+
// Reads context metrics from the statusline bridge file and injects
|
|
4
|
+
// warnings when context usage is high. This makes the AGENT aware of
|
|
5
|
+
// context limits (the statusline only shows the user).
|
|
6
|
+
//
|
|
7
|
+
// How it works:
|
|
8
|
+
// 1. The statusline hook writes metrics to /tmp/claude-ctx-{session_id}.json
|
|
9
|
+
// 2. This hook reads those metrics after each tool use
|
|
10
|
+
// 3. When remaining context drops below thresholds, it injects a warning
|
|
11
|
+
// as additionalContext, which the agent sees in its conversation
|
|
12
|
+
//
|
|
13
|
+
// Thresholds:
|
|
14
|
+
// WARNING (remaining <= 35%): Agent should wrap up current task
|
|
15
|
+
// CRITICAL (remaining <= 25%): Agent should stop immediately and save state
|
|
16
|
+
//
|
|
17
|
+
// Debounce: 5 tool uses between warnings to avoid spam
|
|
18
|
+
// Severity escalation bypasses debounce (WARNING -> CRITICAL fires immediately)
|
|
19
|
+
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const os = require('os');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
|
|
24
|
+
const WARNING_THRESHOLD = 35; // remaining_percentage <= 35%
|
|
25
|
+
const CRITICAL_THRESHOLD = 25; // remaining_percentage <= 25%
|
|
26
|
+
const STALE_SECONDS = 60; // ignore metrics older than 60s
|
|
27
|
+
const DEBOUNCE_CALLS = 5; // min tool uses between warnings
|
|
28
|
+
|
|
29
|
+
let input = '';
|
|
30
|
+
process.stdin.setEncoding('utf8');
|
|
31
|
+
process.stdin.on('data', chunk => input += chunk);
|
|
32
|
+
process.stdin.on('end', () => {
|
|
33
|
+
try {
|
|
34
|
+
const data = JSON.parse(input);
|
|
35
|
+
const sessionId = data.session_id;
|
|
36
|
+
|
|
37
|
+
if (!sessionId) {
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const tmpDir = os.tmpdir();
|
|
42
|
+
const metricsPath = path.join(tmpDir, `claude-ctx-${sessionId}.json`);
|
|
43
|
+
|
|
44
|
+
// If no metrics file, this is a subagent or fresh session -- exit silently
|
|
45
|
+
if (!fs.existsSync(metricsPath)) {
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const metrics = JSON.parse(fs.readFileSync(metricsPath, 'utf8'));
|
|
50
|
+
const now = Math.floor(Date.now() / 1000);
|
|
51
|
+
|
|
52
|
+
// Ignore stale metrics
|
|
53
|
+
if (metrics.timestamp && (now - metrics.timestamp) > STALE_SECONDS) {
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const remaining = metrics.remaining_percentage;
|
|
58
|
+
const usedPct = metrics.used_pct;
|
|
59
|
+
|
|
60
|
+
// No warning needed
|
|
61
|
+
if (remaining > WARNING_THRESHOLD) {
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Debounce: check if we warned recently
|
|
66
|
+
const warnPath = path.join(tmpDir, `claude-ctx-${sessionId}-warned.json`);
|
|
67
|
+
let warnData = { callsSinceWarn: 0, lastLevel: null };
|
|
68
|
+
let firstWarn = true;
|
|
69
|
+
|
|
70
|
+
if (fs.existsSync(warnPath)) {
|
|
71
|
+
try {
|
|
72
|
+
warnData = JSON.parse(fs.readFileSync(warnPath, 'utf8'));
|
|
73
|
+
firstWarn = false;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
// Corrupted file, reset
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
warnData.callsSinceWarn = (warnData.callsSinceWarn || 0) + 1;
|
|
80
|
+
|
|
81
|
+
const isCritical = remaining <= CRITICAL_THRESHOLD;
|
|
82
|
+
const currentLevel = isCritical ? 'critical' : 'warning';
|
|
83
|
+
|
|
84
|
+
// Emit immediately on first warning, then debounce subsequent ones
|
|
85
|
+
// Severity escalation (WARNING -> CRITICAL) bypasses debounce
|
|
86
|
+
const severityEscalated = currentLevel === 'critical' && warnData.lastLevel === 'warning';
|
|
87
|
+
if (!firstWarn && warnData.callsSinceWarn < DEBOUNCE_CALLS && !severityEscalated) {
|
|
88
|
+
// Update counter and exit without warning
|
|
89
|
+
fs.writeFileSync(warnPath, JSON.stringify(warnData));
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Reset debounce counter
|
|
94
|
+
warnData.callsSinceWarn = 0;
|
|
95
|
+
warnData.lastLevel = currentLevel;
|
|
96
|
+
fs.writeFileSync(warnPath, JSON.stringify(warnData));
|
|
97
|
+
|
|
98
|
+
// Build warning message
|
|
99
|
+
let message;
|
|
100
|
+
if (isCritical) {
|
|
101
|
+
message = `CONTEXT MONITOR CRITICAL: Usage at ${usedPct}%. Remaining: ${remaining}%. ` +
|
|
102
|
+
'STOP new work immediately. Save state NOW and inform the user that context is nearly exhausted. ' +
|
|
103
|
+
'If using PAN, run /pan:pause to save execution state.';
|
|
104
|
+
} else {
|
|
105
|
+
message = `CONTEXT MONITOR WARNING: Usage at ${usedPct}%. Remaining: ${remaining}%. ` +
|
|
106
|
+
'Begin wrapping up current task. Do not start new complex work. ' +
|
|
107
|
+
'If using PAN, consider /pan:pause to save state.';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const output = {
|
|
111
|
+
hookSpecificOutput: {
|
|
112
|
+
hookEventName: "PostToolUse",
|
|
113
|
+
additionalContext: message
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
process.stdout.write(JSON.stringify(output));
|
|
118
|
+
} catch (e) {
|
|
119
|
+
// Silent fail -- never block tool execution
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Claude Code Statusline - PAN Edition
|
|
3
|
+
// Shows: model | current task | directory | context usage
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
|
|
9
|
+
// Read JSON from stdin
|
|
10
|
+
let input = '';
|
|
11
|
+
process.stdin.setEncoding('utf8');
|
|
12
|
+
process.stdin.on('data', chunk => input += chunk);
|
|
13
|
+
process.stdin.on('end', () => {
|
|
14
|
+
try {
|
|
15
|
+
const data = JSON.parse(input);
|
|
16
|
+
const model = data.model?.display_name || 'Claude';
|
|
17
|
+
const dir = data.workspace?.current_dir || process.cwd();
|
|
18
|
+
const session = data.session_id || '';
|
|
19
|
+
const remaining = data.context_window?.remaining_percentage;
|
|
20
|
+
|
|
21
|
+
// Context window display (shows USED percentage scaled to 80% limit)
|
|
22
|
+
// Claude Code enforces an 80% context limit, so we scale to show 100% at that point
|
|
23
|
+
let ctx = '';
|
|
24
|
+
if (remaining != null) {
|
|
25
|
+
const rem = Math.round(remaining);
|
|
26
|
+
const rawUsed = Math.max(0, Math.min(100, 100 - rem));
|
|
27
|
+
// Scale: 80% real usage = 100% displayed
|
|
28
|
+
const used = Math.min(100, Math.round((rawUsed / 80) * 100));
|
|
29
|
+
|
|
30
|
+
// Write context metrics to bridge file for the context-monitor PostToolUse hook.
|
|
31
|
+
// The monitor reads this file to inject agent-facing warnings when context is low.
|
|
32
|
+
if (session) {
|
|
33
|
+
try {
|
|
34
|
+
const bridgePath = path.join(os.tmpdir(), `claude-ctx-${session}.json`);
|
|
35
|
+
const bridgeData = JSON.stringify({
|
|
36
|
+
session_id: session,
|
|
37
|
+
remaining_percentage: remaining,
|
|
38
|
+
used_pct: used,
|
|
39
|
+
timestamp: Math.floor(Date.now() / 1000)
|
|
40
|
+
});
|
|
41
|
+
fs.writeFileSync(bridgePath, bridgeData);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// Silent fail -- bridge is best-effort, don't break statusline
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Build progress bar (10 segments)
|
|
48
|
+
const filled = Math.floor(used / 10);
|
|
49
|
+
const bar = 'â–ˆ'.repeat(filled) + 'â–‘'.repeat(10 - filled);
|
|
50
|
+
|
|
51
|
+
// Color based on scaled usage (thresholds adjusted for new scale)
|
|
52
|
+
if (used < 63) { // ~50% real
|
|
53
|
+
ctx = ` \x1b[32m${bar} ${used}%\x1b[0m`;
|
|
54
|
+
} else if (used < 81) { // ~65% real
|
|
55
|
+
ctx = ` \x1b[33m${bar} ${used}%\x1b[0m`;
|
|
56
|
+
} else if (used < 95) { // ~76% real
|
|
57
|
+
ctx = ` \x1b[38;5;208m${bar} ${used}%\x1b[0m`;
|
|
58
|
+
} else {
|
|
59
|
+
ctx = ` \x1b[5;31m💀 ${bar} ${used}%\x1b[0m`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Current task from todos
|
|
64
|
+
let task = '';
|
|
65
|
+
const homeDir = os.homedir();
|
|
66
|
+
const todosDir = path.join(homeDir, '.claude', 'todos');
|
|
67
|
+
if (session && fs.existsSync(todosDir)) {
|
|
68
|
+
try {
|
|
69
|
+
const files = fs.readdirSync(todosDir)
|
|
70
|
+
.filter(f => f.startsWith(session) && f.includes('-agent-') && f.endsWith('.json'))
|
|
71
|
+
.map(f => ({ name: f, mtime: fs.statSync(path.join(todosDir, f)).mtime }))
|
|
72
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
73
|
+
|
|
74
|
+
if (files.length > 0) {
|
|
75
|
+
try {
|
|
76
|
+
const todos = JSON.parse(fs.readFileSync(path.join(todosDir, files[0].name), 'utf8'));
|
|
77
|
+
const inProgress = todos.find(t => t.status === 'in_progress');
|
|
78
|
+
if (inProgress) task = inProgress.activeForm || '';
|
|
79
|
+
} catch (e) {}
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// Silently fail on file system errors - don't break statusline
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// PAN update available?
|
|
87
|
+
let panUpdate = '';
|
|
88
|
+
const cacheFile = path.join(homeDir, '.claude', 'cache', 'pan-update-check.json');
|
|
89
|
+
if (fs.existsSync(cacheFile)) {
|
|
90
|
+
try {
|
|
91
|
+
const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
|
92
|
+
if (cache.update_available) {
|
|
93
|
+
panUpdate = '\x1b[33m⬆ /pan:update\x1b[0m │ ';
|
|
94
|
+
}
|
|
95
|
+
} catch (e) {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Output
|
|
99
|
+
const dirname = path.basename(dir);
|
|
100
|
+
if (task) {
|
|
101
|
+
process.stdout.write(`${panUpdate}\x1b[2m${model}\x1b[0m │ \x1b[1m${task}\x1b[0m │ \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
102
|
+
} else {
|
|
103
|
+
process.stdout.write(`${panUpdate}\x1b[2m${model}\x1b[0m │ \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
// Silent fail - don't break statusline on parse errors
|
|
107
|
+
}
|
|
108
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pan-wizard",
|
|
3
|
+
"version": "2.8.1",
|
|
4
|
+
"description": "A lightweight workflow automation and context engineering system for Claude Code, OpenCode, Gemini CLI, Codex, and Copilot CLI.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"pan-wizard": "bin/install.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"commands",
|
|
11
|
+
"pan-wizard-core",
|
|
12
|
+
"agents",
|
|
13
|
+
"hooks/dist",
|
|
14
|
+
"scripts",
|
|
15
|
+
"assets"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"claude",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"ai",
|
|
21
|
+
"workflow-automation",
|
|
22
|
+
"context-engineering",
|
|
23
|
+
"project-automation",
|
|
24
|
+
"gemini",
|
|
25
|
+
"gemini-cli",
|
|
26
|
+
"codex",
|
|
27
|
+
"codex-cli",
|
|
28
|
+
"copilot",
|
|
29
|
+
"copilot-cli",
|
|
30
|
+
"github-copilot"
|
|
31
|
+
],
|
|
32
|
+
"author": "PAN Wizard Contributors",
|
|
33
|
+
"contributors": [
|
|
34
|
+
{
|
|
35
|
+
"name": "oharms",
|
|
36
|
+
"url": "https://github.com/oharms"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/oharms/PanWizard.git"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/oharms/PanWizard#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/oharms/PanWizard/issues"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.7.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@playwright/test": "^1.58.2",
|
|
53
|
+
"@vscode/test-electron": "^2.5.2",
|
|
54
|
+
"esbuild": "^0.24.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build:hooks": "node scripts/build-hooks.js",
|
|
58
|
+
"prepublishOnly": "npm run build:hooks",
|
|
59
|
+
"test": "node --test tests/*.test.cjs",
|
|
60
|
+
"test:scenarios": "node --test tests/scenarios/*.test.cjs",
|
|
61
|
+
"test:all": "node --test tests/*.test.cjs tests/scenarios/*.test.cjs",
|
|
62
|
+
"test:e2e": "node --test tests/scenarios/*.test.cjs",
|
|
63
|
+
"test:vscode": "npx playwright test --config tests/e2e/playwright.config.mjs",
|
|
64
|
+
"test:watch": "node --test --watch tests/*.test.cjs"
|
|
65
|
+
}
|
|
66
|
+
}
|