pan-wizard 3.36.0 → 3.37.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.
- package/CHANGELOG.md +3645 -0
- package/README.md +36 -48
- package/agents/pan-conductor.md +2 -3
- package/agents/pan-counterfactual.md +1 -2
- package/agents/pan-debugger.md +14 -3
- package/agents/pan-design-checker.md +1 -2
- package/agents/pan-designer.md +1 -2
- package/agents/pan-document_code.md +1 -2
- package/agents/pan-hardener.md +2 -3
- package/agents/pan-integration-checker.md +1 -2
- package/agents/pan-knowledge.md +1 -2
- package/agents/pan-meta-reviewer.md +3 -3
- package/agents/pan-optimizer.md +4 -4
- package/agents/pan-phase-researcher.md +79 -488
- package/agents/pan-plan-checker.md +12 -2
- package/agents/pan-planner.md +10 -6
- package/agents/pan-previewer.md +1 -2
- package/agents/pan-project-researcher.md +70 -499
- package/agents/pan-release.md +1 -1
- package/agents/pan-reviewer.md +9 -3
- package/agents/pan-roadmapper.md +12 -7
- package/agents/pan-verifier.md +7 -2
- package/bin/install-lib.cjs +134 -14
- package/bin/install.js +59 -12
- package/commands/pan/army.md +1 -1
- package/commands/pan/autodev.md +76 -0
- package/commands/pan/exec-phase.md +3 -4
- package/commands/pan/focus-auto.md +14 -7
- package/commands/pan/focus-design.md +4 -5
- package/commands/pan/focus-docs.md +24 -0
- package/commands/pan/learn.md +13 -6
- package/commands/pan/milestone-audit.md +8 -1
- package/commands/pan/milestone-done.md +10 -5
- package/commands/pan/milestone-new.md +2 -2
- package/commands/pan/new-project.md +15 -12
- package/commands/pan/plan-phase.md +15 -9
- package/commands/pan/quick.md +1 -1
- package/commands/pan/review-deep.md +11 -5
- package/commands/pan/settings.md +6 -0
- package/commands/pan/verify-phase.md +6 -2
- package/docs/AGENTS.md +917 -0
- package/docs/ARCHITECTURE.md +1054 -0
- package/docs/CLI-REFERENCE.md +4582 -0
- package/docs/COMPARISON.md +116 -0
- package/docs/DEVELOPMENT.md +490 -0
- package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
- package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
- package/docs/EXAMPLES.md +584 -0
- package/docs/FAQ.md +254 -0
- package/docs/FIELD-HARVEST-2026-07.md +88 -0
- package/docs/FIELD-REPORT-army-2026-06.md +121 -0
- package/docs/HOOKS.md +638 -0
- package/docs/IMPROVEMENT-TODO.md +246 -0
- package/docs/INTERNALS.md +485 -0
- package/docs/MIGRATION-v2-to-v3.md +258 -0
- package/docs/SECURITY-HARDENING.md +230 -0
- package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
- package/docs/SKILLS-FULL-TEXT.md +9685 -0
- package/docs/SKILLS-REFERENCE.md +1037 -0
- package/docs/TROUBLESHOOTING.md +1084 -0
- package/docs/USER-GUIDE.md +1437 -0
- package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
- package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
- package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
- package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
- package/docs/audits/OUTSTANDING-2026-08.md +275 -0
- package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
- package/docs/branding/README-brand-draft.md +119 -0
- package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
- package/docs/branding/handoff/README-brand-draft.md +119 -0
- package/docs/branding/handoff/image-prompts.md +46 -0
- package/docs/branding/image-prompts.md +46 -0
- package/docs/branding/nano-banana-prompts.txt +60 -0
- package/docs/context-monitor.md +13 -0
- package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
- package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
- package/docs/decisions/ADR-0003-smart-execution.md +84 -0
- package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
- package/docs/decisions/ADR-0005-command-naming.md +80 -0
- package/docs/decisions/ADR-0006-focus-commands.md +101 -0
- package/docs/decisions/ADR-0007-ship-v1.md +73 -0
- package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
- package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
- package/docs/decisions/ADR-0010-standards-integration.md +79 -0
- package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
- package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
- package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
- package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
- package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
- package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
- package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
- package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
- package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
- package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
- package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
- package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
- package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
- package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
- package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
- package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
- package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
- package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
- package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
- package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
- package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
- package/docs/decisions/ADR-0032-squad-model.md +64 -0
- package/docs/decisions/ADR-0033-army-campaign.md +40 -0
- package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
- package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
- package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
- package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
- package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
- package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
- package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
- package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
- package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
- package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
- package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
- package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
- package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
- package/docs/decisions/ADR-0047-pan-harness.md +76 -0
- package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
- package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
- package/docs/specs/ai_drift_prevention_featureai.md +286 -0
- package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
- package/docs/specs/command_naming_optimization_featureai.md +930 -0
- package/docs/specs/comp_analysis_markdown_v1.md +149 -0
- package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
- package/docs/specs/contributors_attribution_index_featureai.md +476 -0
- package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
- package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
- package/docs/specs/custom-skills-assessment.md +461 -0
- package/docs/specs/deployment_audit_findings_featureai.md +243 -0
- package/docs/specs/doc_code_link_graph_featureai.md +253 -0
- package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
- package/docs/specs/e2e_visual_testing_featureai.md +615 -0
- package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
- package/docs/specs/evidence-loop-plan.md +76 -0
- package/docs/specs/evidence_loop_featureai.md +497 -0
- package/docs/specs/focus-auto-optimize-category.md +449 -0
- package/docs/specs/focus-auto-optimize-superplan.md +188 -0
- package/docs/specs/focus_auto_runner_featureai.md +1102 -0
- package/docs/specs/focus_design_v2_featureai.md +197 -0
- package/docs/specs/focus_sync_v2_featureai.md +202 -0
- package/docs/specs/git_integration_overhaul_featureai.md +326 -0
- package/docs/specs/glm_zai_provider_featureai.md +200 -0
- package/docs/specs/googlecli_adoption_featureai.md +661 -0
- package/docs/specs/help_commands_rewrite_featureai.md +860 -0
- package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
- package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
- package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
- package/docs/specs/investigations/README.md +31 -0
- package/docs/specs/investigations/digests/2026-09-28.md +47 -0
- package/docs/specs/investigations/digests/2026-10-08.md +62 -0
- package/docs/specs/investigations/digests/2026-10-10.md +61 -0
- package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
- package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
- package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
- package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
- package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
- package/docs/specs/lifecycle_completeness_featureai.md +754 -0
- package/docs/specs/local-first-ci.md +42 -0
- package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
- package/docs/specs/market-delta-2026-09-superplan.md +310 -0
- package/docs/specs/market-ideas-2026-09.md +131 -0
- package/docs/specs/market-ideas-2026-10.md +428 -0
- package/docs/specs/market-ideas-ledger.md +177 -0
- package/docs/specs/memory-optimization-2026-10.md +285 -0
- package/docs/specs/multi-track-planning-roots.md +143 -0
- package/docs/specs/multi_model_routing_featureai.md +687 -0
- package/docs/specs/multi_model_routing_superplan.md +197 -0
- package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
- package/docs/specs/opus_47_extended_features_featureai.md +363 -0
- package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
- package/docs/specs/pan_focus_commands_featureai.md +2336 -0
- package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
- package/docs/specs/product-excellence-superplan.md +315 -0
- package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
- package/docs/specs/production_deployment_readiness_featureai.md +433 -0
- package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
- package/docs/specs/real_test_enforcement_featureai.md +213 -0
- package/docs/specs/reality-check-2026-09-superplan.md +362 -0
- package/docs/specs/right-sized-ceremony.md +74 -0
- package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
- package/docs/specs/self_improvement_loop_featureai.md +875 -0
- package/docs/specs/skill-aligned-decomposition.md +155 -0
- package/docs/specs/standards_integration_featureai.md +833 -0
- package/docs/specs/testing-system-redesign-2026-09.md +267 -0
- package/docs/specs/user_reality_testing_system_featureai.md +788 -0
- package/docs/specs/watch-triggers.json +22 -0
- package/docs/specs/workflow-integration-redesign.md +742 -0
- package/docs/specs/workflow_state_consistency_featureai.md +183 -0
- package/hooks/dist/pan-context-monitor.js +9 -2
- package/hooks/dist/pan-cost-logger.js +5 -0
- package/hooks/dist/pan-guard.js +28 -5
- package/hooks/dist/pan-stop-guard.js +9 -9
- package/hooks/dist/pan-trace-logger.js +5 -0
- package/package.json +10 -2
- package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
- package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
- package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
- package/pan-wizard-core/bin/lib/ci.cjs +143 -0
- package/pan-wizard-core/bin/lib/commands.cjs +1 -1
- package/pan-wizard-core/bin/lib/config.cjs +31 -2
- package/pan-wizard-core/bin/lib/constants.cjs +27 -1
- package/pan-wizard-core/bin/lib/core.cjs +22 -10
- package/pan-wizard-core/bin/lib/cost.cjs +14 -4
- package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
- package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
- package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
- package/pan-wizard-core/bin/lib/findings.cjs +34 -4
- package/pan-wizard-core/bin/lib/focus.cjs +1 -1
- package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
- package/pan-wizard-core/bin/lib/init.cjs +7 -2
- package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
- package/pan-wizard-core/bin/lib/merge.cjs +50 -0
- package/pan-wizard-core/bin/lib/mutate.cjs +16 -5
- package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
- package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
- package/pan-wizard-core/bin/lib/phase.cjs +48 -4
- package/pan-wizard-core/bin/lib/plan-lint.cjs +150 -1
- package/pan-wizard-core/bin/lib/preview.cjs +23 -4
- package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
- package/pan-wizard-core/bin/lib/research-lint.cjs +150 -3
- package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
- package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
- package/pan-wizard-core/bin/lib/runner.cjs +2 -16
- package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
- package/pan-wizard-core/bin/lib/squads.cjs +1 -1
- package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
- package/pan-wizard-core/bin/lib/uat.cjs +149 -0
- package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
- package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
- package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
- package/pan-wizard-core/bin/lib/verify-red.cjs +37 -1
- package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
- package/pan-wizard-core/bin/lib/verify.cjs +59 -4
- package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
- package/pan-wizard-core/bin/pan-tools.cjs +168 -27
- package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
- package/pan-wizard-core/references/continuation-format.md +3 -3
- package/pan-wizard-core/references/guardrails.md +1 -1
- package/pan-wizard-core/references/model-profiles.md +2 -3
- package/pan-wizard-core/references/questioning.md +24 -0
- package/pan-wizard-core/references/ui-brand.md +4 -6
- package/pan-wizard-core/references/verdict-contract.md +2 -1
- package/pan-wizard-core/templates/config.json +5 -1
- package/pan-wizard-core/templates/debug.md +1 -0
- package/pan-wizard-core/templates/discovery.md +2 -2
- package/pan-wizard-core/templates/requirements.md +9 -0
- package/pan-wizard-core/workflows/add-phase.md +4 -6
- package/pan-wizard-core/workflows/assumptions.md +19 -1
- package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
- package/pan-wizard-core/workflows/discuss-phase.md +4 -2
- package/pan-wizard-core/workflows/exec-lean.md +69 -0
- package/pan-wizard-core/workflows/exec-phase.md +36 -8
- package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
- package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
- package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
- package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
- package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
- package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
- package/pan-wizard-core/workflows/health.md +6 -0
- package/pan-wizard-core/workflows/help.md +31 -53
- package/pan-wizard-core/workflows/insert-phase.md +4 -6
- package/pan-wizard-core/workflows/learn.md +3 -3
- package/pan-wizard-core/workflows/milestone-audit.md +2 -2
- package/pan-wizard-core/workflows/milestone-new.md +38 -95
- package/pan-wizard-core/workflows/new-project.md +96 -258
- package/pan-wizard-core/workflows/optimize.md +107 -5
- package/pan-wizard-core/workflows/phase-tests.md +10 -0
- package/pan-wizard-core/workflows/plan-phase.md +86 -43
- package/pan-wizard-core/workflows/profile.md +50 -0
- package/pan-wizard-core/workflows/progress.md +10 -0
- package/pan-wizard-core/workflows/quick.md +34 -43
- package/pan-wizard-core/workflows/research-phase.md +118 -40
- package/pan-wizard-core/workflows/resume-project.md +18 -2
- package/pan-wizard-core/workflows/settings.md +21 -24
- package/pan-wizard-core/workflows/todo-check.md +6 -2
- package/pan-wizard-core/workflows/transition.md +22 -4
- package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
- package/pan-wizard-core/workflows/update.md +1 -1
- package/pan-wizard-core/workflows/verify-phase.md +2 -2
- package/scripts/build-agent-plugin.js +35 -15
- package/scripts/build-plugin.js +10 -1
- package/scripts/deprecate-old-versions.js +70 -3
- package/scripts/generate-skills-docs.py +1 -1
- package/scripts/git-hooks/pre-push +27 -0
- package/scripts/install-git-hooks.js +7 -5
- package/scripts/install-pre-push.cjs +38 -0
- package/scripts/land.cjs +151 -0
- package/scripts/local-ci.cjs +501 -0
- package/scripts/local-schedule.cjs +277 -0
- package/scripts/prompt-lint.cjs +32 -0
- package/scripts/prompt-rules.cjs +156 -0
- package/scripts/run-tests.cjs +7 -1
- package/scripts/test-quality-lint.cjs +3 -3
- package/scripts/test-surface.cjs +9 -2
- package/agents/pan-research-synthesizer.md +0 -246
- package/commands/pan/audit-deployment.md +0 -386
- package/commands/pan/dashboard.md +0 -22
- package/commands/pan/discord.md +0 -19
- package/commands/pan/mcp-bridge.md +0 -143
- package/commands/pan/milestone-cleanup.md +0 -19
- package/commands/pan/milestone-gaps.md +0 -35
- package/commands/pan/optimize.md +0 -115
- package/commands/pan/profile.md +0 -76
- package/commands/pan/research-phase.md +0 -189
- package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
- package/pan-wizard-core/templates/research-project/architecture.md +0 -210
- package/pan-wizard-core/templates/research-project/features.md +0 -153
- package/pan-wizard-core/templates/research-project/pitfalls.md +0 -206
- package/pan-wizard-core/templates/research-project/stack.md +0 -126
- package/pan-wizard-core/templates/research-project/summary.md +0 -170
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* The autodev proof dossier and replay (program A5).
|
|
4
|
+
*
|
|
5
|
+
* autodev replay re-runs the stop logic (autodev.cjs decideStop) over the inputs the
|
|
6
|
+
* flight recorder wrote to blackbox.jsonl, and reports any decision it
|
|
7
|
+
* would not make again. Identical decisions are the recorder's proof.
|
|
8
|
+
* autodev report the dossier: per phase, requirement → plans → units and commits →
|
|
9
|
+
* oracle evidence → verdict → dispositions → cost. Written beside the
|
|
10
|
+
* ledger as dossier.md (the PR body) and dossier.html.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const { spawnSync } = require('child_process');
|
|
16
|
+
const { output, escapeRegex, escapeTableCell } = require('./core.cjs');
|
|
17
|
+
const { planningPath } = require('./utils.cjs');
|
|
18
|
+
const { decideStop } = require('./autodev.cjs');
|
|
19
|
+
|
|
20
|
+
const runDir = (cwd, id) => planningPath(cwd, 'autodev', id);
|
|
21
|
+
|
|
22
|
+
function readRows(file) {
|
|
23
|
+
try { return fs.readFileSync(file, 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); } catch { return []; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function latestRun(cwd) {
|
|
27
|
+
try {
|
|
28
|
+
const root = planningPath(cwd, 'autodev');
|
|
29
|
+
return fs.readdirSync(root).filter((n) => n.startsWith('run-') && fs.existsSync(path.join(root, n, 'run.json')))
|
|
30
|
+
.sort((a, b) => fs.statSync(path.join(root, b)).mtimeMs - fs.statSync(path.join(root, a)).mtimeMs)[0] || null;
|
|
31
|
+
} catch { return null; }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Re-run decideStop over each recorded input; compare with the recorded decision. */
|
|
35
|
+
function replayRun(cwd, runId) {
|
|
36
|
+
const id = runId || latestRun(cwd);
|
|
37
|
+
if (!id) return { error: 'no_run', reason: 'no autodev run to replay' };
|
|
38
|
+
const box = readRows(path.join(runDir(cwd, id), 'blackbox.jsonl'));
|
|
39
|
+
if (!box.length) return { error: 'no_blackbox', reason: `run ${id} has no blackbox.jsonl` };
|
|
40
|
+
const norm = (d) => (d ? { reason: d.reason, detail: d.detail } : null);
|
|
41
|
+
const mismatches = [];
|
|
42
|
+
box.forEach((b, index) => {
|
|
43
|
+
const again = norm(decideStop(b.inputs));
|
|
44
|
+
if (JSON.stringify(again) !== JSON.stringify(norm(b.decision))) mismatches.push({ index, recorded: norm(b.decision), replayed: again });
|
|
45
|
+
});
|
|
46
|
+
return { run: id, entries: box.length, identical: mismatches.length === 0, mismatches };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const money = (n) => `$${(Number(n) || 0).toFixed(2)}`;
|
|
50
|
+
|
|
51
|
+
function phaseSection(roadmap, num) {
|
|
52
|
+
const re = new RegExp(`^#{2,4} Phase ${escapeRegex(String(num))}:([^\\n]*)\\n([\\s\\S]*?)(?=^#{2,4} Phase |(?![\\s\\S]))`, 'm');
|
|
53
|
+
const m = roadmap.match(re);
|
|
54
|
+
return m ? { name: m[1].trim(), body: m[2] } : { name: '', body: '' };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function phaseDir(cwd, num) {
|
|
58
|
+
const root = planningPath(cwd, 'phases');
|
|
59
|
+
const n = String(num);
|
|
60
|
+
const padded = n.includes('.') ? n : n.padStart(2, '0');
|
|
61
|
+
try {
|
|
62
|
+
const d = fs.readdirSync(root).find((x) => x === padded || x.startsWith(`${padded}-`) || x.startsWith(`${n}-`));
|
|
63
|
+
return d ? path.join(root, d) : null;
|
|
64
|
+
} catch { return null; }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function frontmatterField(text, key) {
|
|
68
|
+
const fm = String(text || '').match(/^---\n([\s\S]*?)\n---/);
|
|
69
|
+
const m = fm && fm[1].match(new RegExp(`^${key}:\\s*["']?([^"'\\n]+)`, 'm'));
|
|
70
|
+
return m ? m[1].trim() : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function commitsBetween(cwd, from, to) {
|
|
74
|
+
if (!from || !to || from === to) return [];
|
|
75
|
+
const r = spawnSync('git', ['log', '--oneline', '--no-decorate', `${from}..${to}`], { cwd, encoding: 'utf8' });
|
|
76
|
+
return r.status === 0 ? r.stdout.trim().split('\n').filter(Boolean) : [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function buildDossier(cwd, runId) {
|
|
80
|
+
const id = runId || latestRun(cwd);
|
|
81
|
+
if (!id) return { error: 'no_run', reason: 'no autodev run to report' };
|
|
82
|
+
const dir = runDir(cwd, id);
|
|
83
|
+
let run = {};
|
|
84
|
+
try { run = JSON.parse(fs.readFileSync(path.join(dir, 'run.json'), 'utf8')); } catch {}
|
|
85
|
+
const rows = readRows(path.join(dir, 'ledger.jsonl'));
|
|
86
|
+
const finished = rows.filter((r) => r.status === 'finished');
|
|
87
|
+
const stopped = rows.filter((r) => r.status === 'stopped').pop();
|
|
88
|
+
const spent = finished.reduce((n, r) => n + (Number(r.cost_usd) || 0), 0);
|
|
89
|
+
const seqs = new Set(finished.map((r) => r.seq));
|
|
90
|
+
let roadmap = '';
|
|
91
|
+
try { roadmap = fs.readFileSync(planningPath(cwd, 'roadmap.md'), 'utf8').replace(/\r\n/g, '\n'); } catch {}
|
|
92
|
+
const { phaseRequirementIds } = require('./roadmap.cjs');
|
|
93
|
+
const { listFindings } = require('./findings.cjs');
|
|
94
|
+
|
|
95
|
+
const lines = [`# Autodev dossier: ${id}`, ''];
|
|
96
|
+
lines.push(`- **Host:** ${run.host || rows.map((r) => r.host).find(Boolean) || 'unknown'}`);
|
|
97
|
+
lines.push(`- **Stopped:** ${stopped ? `${stopped.reason} — ${stopped.detail}` : 'still running, or interrupted'}`);
|
|
98
|
+
lines.push(`- **Units:** ${seqs.size} (${finished.length} attempts)`);
|
|
99
|
+
lines.push(`- **Spent:** ${money(spent)}${run.limits && run.limits.maxUsd != null ? ` of ${money(run.limits.maxUsd)}` : ''}`);
|
|
100
|
+
|
|
101
|
+
const phases = [...new Set(finished.map((r) => r.unit && r.unit.phase).filter((p) => p != null))];
|
|
102
|
+
const sections = [];
|
|
103
|
+
for (const num of phases) {
|
|
104
|
+
const sec = phaseSection(roadmap, num);
|
|
105
|
+
const pdir = phaseDir(cwd, num);
|
|
106
|
+
const files = pdir ? fs.readdirSync(pdir).sort() : [];
|
|
107
|
+
const verification = files.find((f) => f === 'verification.md' || f.endsWith('-verification.md'));
|
|
108
|
+
const vtext = verification ? fs.readFileSync(path.join(pdir, verification), 'utf8') : '';
|
|
109
|
+
const mine = finished.filter((r) => r.unit && String(r.unit.phase) === String(num));
|
|
110
|
+
const bySeq = new Map();
|
|
111
|
+
for (const r of mine) { if (!bySeq.has(r.seq)) bySeq.set(r.seq, []); bySeq.get(r.seq).push(r); }
|
|
112
|
+
const units = [...bySeq.values()].map((attempts) => {
|
|
113
|
+
const a = attempts[0].unit.action;
|
|
114
|
+
const cost = attempts.reduce((n, r) => n + (Number(r.cost_usd) || 0), 0);
|
|
115
|
+
const failures = attempts.filter((r) => r.failure_class).map((r) => `${r.failure_class} → ${r.policy}`);
|
|
116
|
+
const recovered = attempts[attempts.length - 1].exit === 0 && failures.length ? ', recovered' : '';
|
|
117
|
+
const note = attempts.length > 1 ? ` (${attempts.length} attempts: ${failures.join(', ')}${recovered})` : '';
|
|
118
|
+
return a === 'complete_phase' ? `${a}${note}` : `${a} ${money(cost)}${note}`;
|
|
119
|
+
});
|
|
120
|
+
const starts = mine.map((r) => r.start_sha).filter(Boolean);
|
|
121
|
+
const ends = mine.map((r) => r.end_sha).filter(Boolean);
|
|
122
|
+
const commits = commitsBetween(cwd, starts[0], ends[ends.length - 1]);
|
|
123
|
+
const f = listFindings(cwd, { phase: String(num) });
|
|
124
|
+
const byStatus = Object.entries(f.counts.by_status || {}).map(([k, v]) => `${k} ${v}`).join(', ');
|
|
125
|
+
const testGate = frontmatterField(vtext, 'test_gate');
|
|
126
|
+
const status = frontmatterField(vtext, 'status');
|
|
127
|
+
const reqs = phaseRequirementIds(sec.body);
|
|
128
|
+
const cost = mine.reduce((n, r) => n + (Number(r.cost_usd) || 0), 0);
|
|
129
|
+
const rowsTable = [
|
|
130
|
+
['Requirements', reqs.length ? reqs.join(', ') : 'none recorded'],
|
|
131
|
+
['Plans', files.filter((x) => /-plan\.md$/i.test(x)).join(', ') || 'none'],
|
|
132
|
+
['Units', units.join(' · ')],
|
|
133
|
+
['Commits', commits.length ? commits.join('; ') : 'none recorded'],
|
|
134
|
+
['Oracle', testGate ? `test gate ${testGate}` : 'no test gate recorded'],
|
|
135
|
+
['Verdict', status ? `verification ${status}` : 'no verification'],
|
|
136
|
+
['Findings', f.counts.total ? `${f.counts.total} (${byStatus})` : 'none'],
|
|
137
|
+
['Cost', money(cost)],
|
|
138
|
+
];
|
|
139
|
+
sections.push({ title: `Phase ${num}${sec.name ? `: ${sec.name}` : ''}`, rows: rowsTable });
|
|
140
|
+
lines.push('', `## Phase ${num}${sec.name ? `: ${sec.name}` : ''}`, '', '| | |', '|---|---|');
|
|
141
|
+
for (const [k, v] of rowsTable) lines.push(`| ${k} | ${escapeTableCell(String(v))} |`);
|
|
142
|
+
}
|
|
143
|
+
return { run: id, markdown: lines.join('\n') + '\n', sections, header: lines.slice(2, 6) };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
147
|
+
|
|
148
|
+
function renderHtml(d) {
|
|
149
|
+
const head = d.header.map((l) => `<li>${esc(l.replace(/^- /, '').replace(/\*\*/g, ''))}</li>`).join('');
|
|
150
|
+
const body = d.sections.map((s) => `<h2>${esc(s.title)}</h2><table>${s.rows.map(([k, v]) => `<tr><th>${esc(k)}</th><td>${esc(v)}</td></tr>`).join('')}</table>`).join('\n');
|
|
151
|
+
return `<!doctype html>
|
|
152
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
153
|
+
<title>Autodev dossier</title>
|
|
154
|
+
<style>
|
|
155
|
+
:root{--bg:#fff;--fg:#1d1d1f;--muted:#6e6e73;--line:#e5e5ea}
|
|
156
|
+
@media (prefers-color-scheme: dark){:root{--bg:#161618;--fg:#f2f2f7;--muted:#a1a1a6;--line:#2c2c2e}}
|
|
157
|
+
body{background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,sans-serif;max-width:860px;margin:0 auto;padding:24px 16px}
|
|
158
|
+
th{text-align:left;color:var(--muted);font-weight:500;padding:6px 16px 6px 0;vertical-align:top;white-space:nowrap}
|
|
159
|
+
td{padding:6px 0;border-bottom:1px solid var(--line)}table{border-collapse:collapse;width:100%}h2{margin-top:32px}
|
|
160
|
+
</style></head><body>
|
|
161
|
+
<h1>Autodev dossier: ${esc(d.run)}</h1><ul>${head}</ul>
|
|
162
|
+
${body}
|
|
163
|
+
</body></html>
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function writeDossier(cwd, runId) {
|
|
168
|
+
const d = buildDossier(cwd, runId);
|
|
169
|
+
if (d.error) return d;
|
|
170
|
+
const dir = runDir(cwd, d.run);
|
|
171
|
+
fs.writeFileSync(path.join(dir, 'dossier.md'), d.markdown);
|
|
172
|
+
fs.writeFileSync(path.join(dir, 'dossier.html'), renderHtml(d));
|
|
173
|
+
const rel = (f) => path.relative(cwd, path.join(dir, f)).replace(/\\/g, '/');
|
|
174
|
+
return { run: d.run, markdown: rel('dossier.md'), html: rel('dossier.html') };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function cmdAutodevReport(cwd, runId, raw) { const r = writeDossier(cwd, runId); output(r, raw, r.markdown || r.error); }
|
|
178
|
+
function cmdAutodevReplay(cwd, runId, raw) { const r = replayRun(cwd, runId); output(r, raw, r.error || String(r.identical)); }
|
|
179
|
+
|
|
180
|
+
module.exports = { replayRun, buildDossier, writeDossier, renderHtml, cmdAutodevReport, cmdAutodevReplay };
|