@nathapp/nax 0.28.0 → 0.30.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 +23 -2
- package/bin/nax.ts +2 -3
- package/dist/nax.js +72753 -0
- package/package.json +11 -3
- package/src/cli/analyze.ts +2 -7
- package/src/cli/config.ts +3 -1
- package/src/config/defaults.ts +1 -0
- package/src/config/schemas.ts +1 -0
- package/src/config/types.ts +1 -0
- package/src/context/builder.ts +10 -1
- package/src/execution/lifecycle/headless-formatter.ts +2 -4
- package/src/prompts/builder.ts +12 -69
- package/src/prompts/sections/isolation.ts +38 -8
- package/src/prompts/sections/role-task.ts +79 -17
- package/src/review/runner.ts +6 -1
- package/src/version.ts +2 -1
- package/.claude/rules/01-project-conventions.md +0 -34
- package/.claude/rules/02-test-architecture.md +0 -39
- package/.claude/rules/03-test-writing.md +0 -58
- package/.claude/rules/04-forbidden-patterns.md +0 -29
- package/.claude/settings.json +0 -15
- package/.githooks/pre-commit +0 -16
- package/.gitlab-ci.yml +0 -103
- package/.mcp.json +0 -8
- package/BRIEF.md +0 -140
- package/CLAUDE.md +0 -143
- package/US-007-IMPLEMENTATION.md +0 -139
- package/biome.json +0 -14
- package/bun.lock +0 -163
- package/bunfig.toml +0 -12
- package/docker-compose.test.yml +0 -15
- package/docs/20260216-fix-plan-context-review.md +0 -56
- package/docs/20260216-relentless-vs-ngent-comparison.md +0 -208
- package/docs/20260216-v02-plan.md +0 -136
- package/docs/20260216-v02-review.md +0 -685
- package/docs/20260217-dogfood-findings.md +0 -56
- package/docs/20260217-p2-plus-plan.md +0 -117
- package/docs/20260217-partial-fixes-plan.md +0 -62
- package/docs/20260217-plan-analyze-spec.md +0 -117
- package/docs/20260217-post-impl-review.md +0 -1137
- package/docs/20260217-quick-wins-plan.md +0 -66
- package/docs/20260217-split-runner-plan.md +0 -75
- package/docs/20260217-v03-impl-plan.md +0 -80
- package/docs/20260217-v03-post-impl-review.md +0 -589
- package/docs/20260217-v04-impl-plan.md +0 -86
- package/docs/20260217-v05-post-impl-review.md +0 -850
- package/docs/20260217-v06-post-impl-review.md +0 -817
- package/docs/20260218-adr003-port-plan.md +0 -151
- package/docs/20260218-review-adr003-verification.md +0 -175
- package/docs/20260219-fix-plan-bug16-19.md +0 -79
- package/docs/20260219-fix-plan-bug20-22.md +0 -114
- package/docs/20260219-plan-llm-routing.md +0 -116
- package/docs/20260219-review-bug20-22-fixes.md +0 -135
- package/docs/20260219-routing-baseline-keyword.md +0 -63
- package/docs/20260220-plan-structured-logging-p1.md +0 -80
- package/docs/20260220-plan-structured-logging-p2.md +0 -37
- package/docs/20260220-review-llm-routing.md +0 -180
- package/docs/20260220-review-post-fix-llm-routing.md +0 -70
- package/docs/20260221-fix-plan-relevantfiles-split.md +0 -101
- package/docs/20260221-fix-plan-routing-mode.md +0 -125
- package/docs/20260221-review-v0.9-implementation.md +0 -379
- package/docs/20260222-fix-plan-v091-routing-isolation.md +0 -197
- package/docs/20260223-fix-plan-prompt-audit.md +0 -62
- package/docs/20260224-nax-roadmap-phases.md +0 -189
- package/docs/20260225-phase2-llm-service-layer.md +0 -401
- package/docs/20260225-review-v0.10.1.md +0 -187
- package/docs/20260303-v010-implementation-plan.md +0 -165
- package/docs/20260304-review-nax.md +0 -492
- package/docs/CLAUDE.md.bak +0 -191
- package/docs/ROADMAP.md +0 -390
- package/docs/SPEC-rectification.md +0 -0
- package/docs/SPEC.md +0 -324
- package/docs/US-001-plugin-loading-verification.md +0 -152
- package/docs/adr/ADR-005-implementation-plan.md +0 -655
- package/docs/adr/ADR-005-pipeline-re-architecture.md +0 -464
- package/docs/architecture-analysis.md +0 -1076
- package/docs/bugs/BUG-21-escalation-null-attempts.md +0 -48
- package/docs/bugs-from-dogfood-run-c.md +0 -243
- package/docs/code-review-20260228.md +0 -612
- package/docs/code-review-v0.15.0.md +0 -629
- package/docs/hook-lifecycle-test-plan.md +0 -149
- package/docs/releases/v0.11.0-and-earlier.md +0 -20
- package/docs/releases/v0.12.0.md +0 -15
- package/docs/releases/v0.13.0.md +0 -14
- package/docs/releases/v0.14.0.md +0 -20
- package/docs/releases/v0.14.1.md +0 -36
- package/docs/releases/v0.14.2.md +0 -51
- package/docs/releases/v0.14.3.md +0 -174
- package/docs/releases/v0.14.4.md +0 -94
- package/docs/releases/v0.15.0.md +0 -502
- package/docs/releases/v0.15.1.md +0 -170
- package/docs/releases/v0.15.3.md +0 -193
- package/docs/specs/bug-039-orphan-processes.md +0 -131
- package/docs/specs/bug-040-review-rectification.md +0 -82
- package/docs/specs/bug-041-cross-story-test-isolation.md +0 -88
- package/docs/specs/bug-042-verifier-failure-capture.md +0 -117
- package/docs/specs/bun-pty-migration.md +0 -171
- package/docs/specs/central-run-registry.md +0 -116
- package/docs/specs/feat-010-smart-runner-git-history.md +0 -96
- package/docs/specs/feat-011-file-context-strategy.md +0 -73
- package/docs/specs/feat-012-tdd-writer-tier.md +0 -79
- package/docs/specs/feat-013-test-after-review.md +0 -89
- package/docs/specs/feat-014-heartbeat-observability.md +0 -127
- package/docs/specs/status-file-consolidation.md +0 -93
- package/docs/specs/status-file-v0.10.1.md +0 -812
- package/docs/specs/trigger-completion.md +0 -145
- package/docs/specs/verification-architecture-v2.md +0 -343
- package/docs/tdd/strategies.md +0 -97
- package/docs/v0.10-global-config.md +0 -206
- package/docs/v0.10-plugin-system.md +0 -415
- package/docs/v0.10-prompt-optimizer.md +0 -234
- package/docs/v0.3-spec.md +0 -244
- package/docs/v0.4-spec.md +0 -140
- package/docs/v0.5-spec.md +0 -237
- package/docs/v0.6-spec.md +0 -371
- package/docs/v0.7-spec.md +0 -177
- package/docs/v0.8-llm-routing.md +0 -206
- package/docs/v0.8-structured-logging.md +0 -132
- package/docs/v0.9.3-prompt-audit.md +0 -112
- package/examples/plugins/console-reporter/index.test.ts +0 -207
- package/examples/plugins/console-reporter/index.ts +0 -110
- package/memory/topic/feat-010-baseref.md +0 -28
- package/memory/topic/feat-013-test-after-deprecation.md +0 -22
- package/nax/config.json +0 -154
- package/nax/features/bug-039-medium/prd.json +0 -45
- package/nax/features/bugfix-v0171/prd.json +0 -52
- package/nax/features/central-run-registry/prd.json +0 -105
- package/nax/features/config-management/prd.json +0 -108
- package/nax/features/config-management/progress.txt +0 -5
- package/nax/features/diagnose/acceptance.test.ts +0 -414
- package/nax/features/diagnose/prd.json +0 -41
- package/nax/features/nax-compliance/prd.json +0 -52
- package/nax/features/nax-compliance/progress.txt +0 -1
- package/nax/features/orchestration-fixes/prd.json +0 -89
- package/nax/features/orchestration-fixes/progress.txt +0 -1
- package/nax/features/plugin-integration/US-007-VERIFICATION.md +0 -259
- package/nax/features/plugin-integration/prd.json +0 -208
- package/nax/features/plugin-integration/progress.txt +0 -5
- package/nax/features/post-rearch-bugfix/prd.json +0 -137
- package/nax/features/precheck/prd.json +0 -205
- package/nax/features/precheck/progress.txt +0 -15
- package/nax/features/prompt-builder/prd.json +0 -152
- package/nax/features/prompt-builder/progress.txt +0 -3
- package/nax/features/review-quality/prd.json +0 -55
- package/nax/features/routing-persistence/prd.json +0 -104
- package/nax/features/routing-persistence/progress.txt +0 -1
- package/nax/features/smart-test-runner/plan.md +0 -7
- package/nax/features/smart-test-runner/prd.json +0 -203
- package/nax/features/smart-test-runner/progress.txt +0 -13
- package/nax/features/smart-test-runner/spec.md +0 -7
- package/nax/features/smart-test-runner/tasks.md +0 -8
- package/nax/features/status-file-consolidation/prd.json +0 -106
- package/nax/features/structured-logging/prd.json +0 -199
- package/nax/features/trigger-completion/prd.json +0 -150
- package/nax/features/trigger-completion/progress.txt +0 -7
- package/nax/features/unlock/prd.json +0 -36
- package/nax/features/v0.18.3-execution-reliability/prd.json +0 -80
- package/nax/features/v0.18.3-execution-reliability/progress.txt +0 -3
- package/nax/features/v0.19.0-hardening/plan.md +0 -7
- package/nax/features/v0.19.0-hardening/prd.json +0 -84
- package/nax/features/v0.19.0-hardening/progress.txt +0 -7
- package/nax/features/v0.19.0-hardening/spec.md +0 -18
- package/nax/features/v0.19.0-hardening/tasks.md +0 -8
- package/nax/features/verify-v2/prd.json +0 -79
- package/nax/features/verify-v2/progress.txt +0 -3
- package/nax/status.json +0 -36
- package/src/prompts/templates/implementer.ts +0 -6
- package/src/prompts/templates/single-session.ts +0 -6
- package/src/prompts/templates/test-writer.ts +0 -6
- package/src/prompts/templates/verifier.ts +0 -6
- package/test/COVERAGE-GAPS.md +0 -333
- package/test/e2e/cm-003-default-view.test.ts +0 -195
- package/test/e2e/plan-analyze-run.test.ts +0 -902
- package/test/helpers/helpers.test.ts +0 -295
- package/test/helpers/timeout.ts +0 -42
- package/test/integration/US-002-TEST-SUMMARY.md +0 -107
- package/test/integration/US-003-TEST-SUMMARY.md +0 -149
- package/test/integration/US-004-TEST-SUMMARY.md +0 -106
- package/test/integration/US-005-TEST-SUMMARY.md +0 -138
- package/test/integration/US-007-TEST-SUMMARY.md +0 -100
- package/test/integration/cli/agent-validation.test.ts +0 -439
- package/test/integration/cli/cli-config-default-edge-cases.test.ts +0 -223
- package/test/integration/cli/cli-config-default-view.test.ts +0 -230
- package/test/integration/cli/cli-config-diff.test.ts +0 -461
- package/test/integration/cli/cli-config-prompts-explain.test.ts +0 -74
- package/test/integration/cli/cli-config.test.ts +0 -737
- package/test/integration/cli/cli-diagnose.test.ts +0 -595
- package/test/integration/cli/cli-logs.test.ts +0 -346
- package/test/integration/cli/cli-plugins.test.ts +0 -679
- package/test/integration/cli/cli-precheck.test.ts +0 -372
- package/test/integration/cli/cli-run-headless.test.ts +0 -174
- package/test/integration/cli/cli.test.ts +0 -76
- package/test/integration/cli/precheck-integration.test.ts +0 -476
- package/test/integration/cli/precheck-orchestrator.test.ts +0 -247
- package/test/integration/cli/precheck.test.ts +0 -806
- package/test/integration/config/config-loader.test.ts +0 -266
- package/test/integration/config/config.test.ts +0 -444
- package/test/integration/config/merger.test.ts +0 -466
- package/test/integration/config/paths.test.ts +0 -52
- package/test/integration/config/security-loader.test.ts +0 -83
- package/test/integration/context/context-integration.test.ts +0 -703
- package/test/integration/context/context-path-security.test.ts +0 -173
- package/test/integration/context/context-provider-injection.test.ts +0 -507
- package/test/integration/context/context-verification-integration.test.ts +0 -296
- package/test/integration/context/s5-greenfield-fallback.test.ts +0 -298
- package/test/integration/execution/execution-isolation.test.ts +0 -143
- package/test/integration/execution/execution.test.ts +0 -634
- package/test/integration/execution/feature-status-write.test.ts +0 -302
- package/test/integration/execution/parallel.test.ts +0 -251
- package/test/integration/execution/prd-pause.test.ts +0 -205
- package/test/integration/execution/prd-resolvers.test.ts +0 -186
- package/test/integration/execution/progress.test.ts +0 -34
- package/test/integration/execution/runner-batching.test.ts +0 -682
- package/test/integration/execution/runner-config-plugins.test.ts +0 -462
- package/test/integration/execution/runner-escalation.test.ts +0 -561
- package/test/integration/execution/runner-fixes.test.ts +0 -400
- package/test/integration/execution/runner-plugin-integration.test.ts +0 -544
- package/test/integration/execution/runner-queue-and-attempts.test.ts +0 -476
- package/test/integration/execution/status-file-integration.test.ts +0 -289
- package/test/integration/execution/status-file.test.ts +0 -380
- package/test/integration/execution/status-writer.test.ts +0 -447
- package/test/integration/execution/story-id-in-events.test.ts +0 -274
- package/test/integration/interaction/interaction-chain-pipeline.test.ts +0 -476
- package/test/integration/pipeline/hooks.test.ts +0 -363
- package/test/integration/pipeline/pipeline-acceptance.test.ts +0 -303
- package/test/integration/pipeline/pipeline-events.test.ts +0 -476
- package/test/integration/pipeline/pipeline.test.ts +0 -660
- package/test/integration/pipeline/reporter-lifecycle.test.ts +0 -862
- package/test/integration/pipeline/verify-stage.test.ts +0 -286
- package/test/integration/plan/analyze-integration.test.ts +0 -262
- package/test/integration/plan/analyze-scanner.test.ts +0 -132
- package/test/integration/plan/logger.test.ts +0 -461
- package/test/integration/plan/plan.test.ts +0 -157
- package/test/integration/plugins/config-integration.test.ts +0 -173
- package/test/integration/plugins/config-resolution.test.ts +0 -523
- package/test/integration/plugins/loader.test.ts +0 -644
- package/test/integration/plugins/plugins-registry.test.ts +0 -747
- package/test/integration/plugins/validator.test.ts +0 -564
- package/test/integration/prompts/pb-004-migration.test.ts +0 -523
- package/test/integration/review/review-config-commands.test.ts +0 -320
- package/test/integration/review/review-config-schema.test.ts +0 -117
- package/test/integration/review/review-plugin-integration.test.ts +0 -729
- package/test/integration/review/review.test.ts +0 -150
- package/test/integration/routing/plugin-routing-advanced.test.ts +0 -461
- package/test/integration/routing/plugin-routing-core.test.ts +0 -527
- package/test/integration/routing/routing-stage-bug-021.test.ts +0 -275
- package/test/integration/routing/routing-stage-greenfield.test.ts +0 -287
- package/test/integration/tdd/tdd-cleanup.test.ts +0 -246
- package/test/integration/tdd/tdd-orchestrator-core.test.ts +0 -565
- package/test/integration/tdd/tdd-orchestrator-failureCategory.test.ts +0 -355
- package/test/integration/tdd/tdd-orchestrator-fallback.test.ts +0 -311
- package/test/integration/tdd/tdd-orchestrator-lite.test.ts +0 -289
- package/test/integration/tdd/tdd-orchestrator-prompts.test.ts +0 -260
- package/test/integration/tdd/tdd-orchestrator-verdict.test.ts +0 -536
- package/test/integration/tmp/headless-test/test.jsonl +0 -30
- package/test/integration/verification/test-scanner.test.ts +0 -403
- package/test/integration/verification/verification-asset-check.test.ts +0 -143
- package/test/integration/worktree/manager.test.ts +0 -218
- package/test/integration/worktree/worktree-merge.test.ts +0 -341
- package/test/manual/logging-formatter-demo.ts +0 -158
- package/test/ui/tui-agent-panel.test.tsx +0 -99
- package/test/ui/tui-pty-integration.test.tsx +0 -146
- package/test/unit/acceptance.test.ts +0 -187
- package/test/unit/agent-stderr-capture.test.ts +0 -147
- package/test/unit/agents/claude.test.ts +0 -107
- package/test/unit/analyze-classifier.test.ts +0 -216
- package/test/unit/analyze.test.ts +0 -224
- package/test/unit/auto-detect.test.ts +0 -250
- package/test/unit/cli-status-project-level.test.ts +0 -283
- package/test/unit/cli-status.test.ts +0 -418
- package/test/unit/commands/common.test.ts +0 -321
- package/test/unit/commands/logs.test.ts +0 -458
- package/test/unit/commands/runs.test.ts +0 -303
- package/test/unit/commands/unlock.test.ts +0 -320
- package/test/unit/config/defaults.test.ts +0 -70
- package/test/unit/config/quality-commands-schema.test.ts +0 -72
- package/test/unit/config/regression-gate-schema.test.ts +0 -160
- package/test/unit/config/smart-runner-flag.test.ts +0 -250
- package/test/unit/constitution-generators.test.ts +0 -161
- package/test/unit/constitution.test.ts +0 -210
- package/test/unit/context/context-autodetect.test.ts +0 -297
- package/test/unit/context/context-build.test.ts +0 -575
- package/test/unit/context/context-coverage.test.ts +0 -236
- package/test/unit/context/context-error.test.ts +0 -93
- package/test/unit/context/context-estimate-tokens.test.ts +0 -201
- package/test/unit/context/context-format.test.ts +0 -302
- package/test/unit/context/context-isolation.test.ts +0 -267
- package/test/unit/context/context-sort.test.ts +0 -93
- package/test/unit/context/context-story.test.ts +0 -108
- package/test/unit/context/prior-failures.test.ts +0 -463
- package/test/unit/context.test.ts +0 -1726
- package/test/unit/cost.test.ts +0 -231
- package/test/unit/crash-recovery.test.ts +0 -309
- package/test/unit/escalation.test.ts +0 -127
- package/test/unit/execution/lifecycle/run-completion.test.ts +0 -240
- package/test/unit/execution/lifecycle/run-regression.test.ts +0 -420
- package/test/unit/execution/pid-registry.test.ts +0 -241
- package/test/unit/execution/sequential-executor.test.ts +0 -235
- package/test/unit/execution/sfc-004-dead-code-cleanup.test.ts +0 -89
- package/test/unit/execution/structured-failure.test.ts +0 -415
- package/test/unit/execution-logging-stderr.test.ts +0 -157
- package/test/unit/execution-stage.test.ts +0 -123
- package/test/unit/fix-generator.test.ts +0 -276
- package/test/unit/formatters.test.ts +0 -468
- package/test/unit/greenfield.test.ts +0 -180
- package/test/unit/hooks/shell-security.test.ts +0 -40
- package/test/unit/interaction/auto-plugin.test.ts +0 -162
- package/test/unit/interaction/human-review-trigger.test.ts +0 -165
- package/test/unit/interaction-network-failures.test.ts +0 -390
- package/test/unit/interaction-plugins.test.ts +0 -472
- package/test/unit/logging/formatter.test.ts +0 -456
- package/test/unit/merge.test.ts +0 -269
- package/test/unit/metrics/aggregator.test.ts +0 -164
- package/test/unit/metrics/tracker.test.ts +0 -186
- package/test/unit/metrics.test.ts +0 -276
- package/test/unit/optimizer/noop.optimizer.test.ts +0 -125
- package/test/unit/optimizer/rule-based.optimizer.test.ts +0 -358
- package/test/unit/pipeline/event-bus.test.ts +0 -105
- package/test/unit/pipeline/routing-partial-override.test.ts +0 -121
- package/test/unit/pipeline/runner-retry.test.ts +0 -89
- package/test/unit/pipeline/stages/autofix.test.ts +0 -97
- package/test/unit/pipeline/stages/completion-review-gate.test.ts +0 -218
- package/test/unit/pipeline/stages/execution-ambiguity.test.ts +0 -311
- package/test/unit/pipeline/stages/execution-merge-conflict.test.ts +0 -218
- package/test/unit/pipeline/stages/rectify.test.ts +0 -101
- package/test/unit/pipeline/stages/regression-stage.test.ts +0 -69
- package/test/unit/pipeline/stages/review.test.ts +0 -201
- package/test/unit/pipeline/stages/routing-idempotence.test.ts +0 -139
- package/test/unit/pipeline/stages/routing-initial-complexity.test.ts +0 -321
- package/test/unit/pipeline/stages/routing-persistence.test.ts +0 -380
- package/test/unit/pipeline/stages/verify.test.ts +0 -267
- package/test/unit/pipeline/subscribers/events-writer.test.ts +0 -227
- package/test/unit/pipeline/subscribers/hooks.test.ts +0 -84
- package/test/unit/pipeline/subscribers/interaction.test.ts +0 -313
- package/test/unit/pipeline/subscribers/registry.test.ts +0 -149
- package/test/unit/pipeline/subscribers/reporters.test.ts +0 -90
- package/test/unit/pipeline/verify-smart-runner.test.ts +0 -345
- package/test/unit/prd-auto-default.test.ts +0 -291
- package/test/unit/prd-failure-category.test.ts +0 -177
- package/test/unit/prd-get-next-story.test.ts +0 -215
- package/test/unit/precheck/checks-warnings.test.ts +0 -114
- package/test/unit/precheck-checks.test.ts +0 -841
- package/test/unit/precheck-story-size-gate.test.ts +0 -288
- package/test/unit/precheck-types.test.ts +0 -143
- package/test/unit/prompts/builder.test.ts +0 -258
- package/test/unit/prompts/loader.test.ts +0 -355
- package/test/unit/prompts/sections/conventions.test.ts +0 -30
- package/test/unit/prompts/sections/isolation.test.ts +0 -35
- package/test/unit/prompts/sections/role-task.test.ts +0 -40
- package/test/unit/prompts/sections/sections.test.ts +0 -238
- package/test/unit/prompts/sections/story.test.ts +0 -45
- package/test/unit/prompts/sections/verdict.test.ts +0 -58
- package/test/unit/prompts.test.ts +0 -476
- package/test/unit/queue.test.ts +0 -237
- package/test/unit/rectification.test.ts +0 -285
- package/test/unit/registry.test.ts +0 -288
- package/test/unit/review/runner.test.ts +0 -117
- package/test/unit/routing/content-hash.test.ts +0 -99
- package/test/unit/routing/routing-stability.test.ts +0 -208
- package/test/unit/routing/strategies/llm.test.ts +0 -306
- package/test/unit/routing-advanced.test.ts +0 -313
- package/test/unit/routing-core.test.ts +0 -341
- package/test/unit/routing-strategies.test.ts +0 -440
- package/test/unit/storyid-events.test.ts +0 -213
- package/test/unit/tdd-verdict.test.ts +0 -492
- package/test/unit/test-output-parser.test.ts +0 -377
- package/test/unit/ui/tui-controls.test.ts +0 -335
- package/test/unit/ui/tui-cost-and-pty.test.ts +0 -190
- package/test/unit/ui/tui-layout.test.ts +0 -379
- package/test/unit/ui/tui-stories.test.ts +0 -333
- package/test/unit/unit-isolation.test.ts +0 -135
- package/test/unit/utils/git.test.ts +0 -50
- package/test/unit/utils/path-security.test.ts +0 -47
- package/test/unit/utils-helpers.test.ts +0 -318
- package/test/unit/verdict.test.ts +0 -325
- package/test/unit/verification/orchestrator-types.test.ts +0 -54
- package/test/unit/verification/orchestrator.test.ts +0 -66
- package/test/unit/verification/smart-runner-config.test.ts +0 -163
- package/test/unit/verification/smart-runner-discovery.test.ts +0 -354
- package/test/unit/verification/smart-runner.test.ts +0 -262
- package/test/unit/verification/strategies/acceptance.test.ts +0 -33
- package/test/unit/verification/strategies/regression.test.ts +0 -87
- package/test/unit/verification/strategies/scoped.test.ts +0 -100
- package/test/unit/worktree-manager.test.ts +0 -159
- package/tsconfig.json +0 -27
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
// RE-ARCH: keep
|
|
2
|
-
/**
|
|
3
|
-
* Integration Tests: Status File — runner + CLI (T2)
|
|
4
|
-
*
|
|
5
|
-
* Verifies:
|
|
6
|
-
* - RunOptions.statusFile: string is required
|
|
7
|
-
* - Status file always written at all 4 write points (dry-run path)
|
|
8
|
-
* - Valid JSON at each stage, NaxStatusFile schema correct
|
|
9
|
-
* - completed status, progress counts, null current at end
|
|
10
|
-
* - CLI automatically computes statusFile to <workdir>/nax/status.json
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { afterAll, afterEach, beforeAll, describe, expect, it } from "bun:test";
|
|
14
|
-
import * as nodeFs from "node:fs";
|
|
15
|
-
import * as fs from "node:fs/promises";
|
|
16
|
-
import * as os from "node:os";
|
|
17
|
-
import * as path from "node:path";
|
|
18
|
-
import { ALL_AGENTS } from "../../../src/agents/registry";
|
|
19
|
-
import type {
|
|
20
|
-
AgentAdapter,
|
|
21
|
-
AgentCapabilities,
|
|
22
|
-
AgentResult,
|
|
23
|
-
AgentRunOptions,
|
|
24
|
-
DecomposeOptions,
|
|
25
|
-
DecomposeResult,
|
|
26
|
-
PlanOptions,
|
|
27
|
-
PlanResult,
|
|
28
|
-
} from "../../../src/agents/types";
|
|
29
|
-
import { DEFAULT_CONFIG } from "../../../src/config";
|
|
30
|
-
import type { NaxConfig } from "../../../src/config";
|
|
31
|
-
import { run } from "../../../src/execution/runner";
|
|
32
|
-
import type { RunOptions } from "../../../src/execution/runner";
|
|
33
|
-
import type { NaxStatusFile } from "../../../src/execution/status-file";
|
|
34
|
-
import type { PRD } from "../../../src/prd/types";
|
|
35
|
-
|
|
36
|
-
// ============================================================================
|
|
37
|
-
// Mock agent (satisfies agent installation check in runner)
|
|
38
|
-
// ============================================================================
|
|
39
|
-
class MockAgentAdapter implements AgentAdapter {
|
|
40
|
-
readonly name = "mock";
|
|
41
|
-
readonly displayName = "Mock Agent";
|
|
42
|
-
readonly binary = "mock-agent";
|
|
43
|
-
readonly capabilities: AgentCapabilities = {
|
|
44
|
-
supportedTiers: ["fast", "balanced", "powerful"],
|
|
45
|
-
maxContextTokens: 200_000,
|
|
46
|
-
features: new Set(["tdd", "review", "refactor", "batch"]),
|
|
47
|
-
};
|
|
48
|
-
async isInstalled(): Promise<boolean> {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
buildCommand(_o: AgentRunOptions): string[] {
|
|
52
|
-
return [this.binary];
|
|
53
|
-
}
|
|
54
|
-
async run(_o: AgentRunOptions): Promise<AgentResult> {
|
|
55
|
-
return { success: true, exitCode: 0, output: "", durationMs: 10, estimatedCost: 0, rateLimited: false };
|
|
56
|
-
}
|
|
57
|
-
async plan(_o: PlanOptions): Promise<PlanResult> {
|
|
58
|
-
return { specContent: "# Feature\n" };
|
|
59
|
-
}
|
|
60
|
-
async decompose(_o: DecomposeOptions): Promise<DecomposeResult> {
|
|
61
|
-
return { stories: [] };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let cleanupAgent: () => void;
|
|
66
|
-
beforeAll(() => {
|
|
67
|
-
const adapter = new MockAgentAdapter();
|
|
68
|
-
ALL_AGENTS.push(adapter);
|
|
69
|
-
cleanupAgent = () => {
|
|
70
|
-
const idx = ALL_AGENTS.findIndex((a) => a.name === "mock");
|
|
71
|
-
if (idx !== -1) ALL_AGENTS.splice(idx, 1);
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
afterAll(() => {
|
|
75
|
-
cleanupAgent?.();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// ============================================================================
|
|
79
|
-
// Helpers
|
|
80
|
-
// ============================================================================
|
|
81
|
-
function createTestConfig(): NaxConfig {
|
|
82
|
-
return {
|
|
83
|
-
...DEFAULT_CONFIG,
|
|
84
|
-
autoMode: { ...DEFAULT_CONFIG.autoMode, defaultAgent: "mock" },
|
|
85
|
-
execution: { ...DEFAULT_CONFIG.execution, maxIterations: 20, maxStoriesPerFeature: 500, iterationDelayMs: 0 },
|
|
86
|
-
review: { ...DEFAULT_CONFIG.review, enabled: false },
|
|
87
|
-
acceptance: { ...DEFAULT_CONFIG.acceptance, enabled: false },
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function makePRD(feature: string, storyCount = 2): PRD {
|
|
92
|
-
return {
|
|
93
|
-
project: "test-project",
|
|
94
|
-
feature,
|
|
95
|
-
branchName: `feat/${feature}`,
|
|
96
|
-
createdAt: new Date().toISOString(),
|
|
97
|
-
updatedAt: new Date().toISOString(),
|
|
98
|
-
userStories: Array.from({ length: storyCount }, (_, i) => ({
|
|
99
|
-
id: `US-${String(i + 1).padStart(3, "0")}`,
|
|
100
|
-
title: `Story ${i + 1}`,
|
|
101
|
-
description: `Desc ${i + 1}`,
|
|
102
|
-
acceptanceCriteria: [`AC: works`],
|
|
103
|
-
tags: [],
|
|
104
|
-
dependencies: [],
|
|
105
|
-
status: "pending" as const,
|
|
106
|
-
passes: false,
|
|
107
|
-
escalations: [],
|
|
108
|
-
attempts: 0,
|
|
109
|
-
})),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async function setupDir(feature: string, storyCount = 2) {
|
|
114
|
-
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "nax-sf-int-"));
|
|
115
|
-
const naxDir = path.join(tmpDir, "nax");
|
|
116
|
-
const featureDir = path.join(naxDir, "features", feature);
|
|
117
|
-
nodeFs.mkdirSync(path.join(featureDir, "runs"), { recursive: true });
|
|
118
|
-
const prdPath = path.join(featureDir, "prd.json");
|
|
119
|
-
await Bun.write(prdPath, JSON.stringify(makePRD(feature, storyCount), null, 2));
|
|
120
|
-
return { tmpDir, featureDir, prdPath };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function runWithStatus(feature: string, storyCount = 1, extraOpts: Partial<RunOptions> = {}) {
|
|
124
|
-
const setup = await setupDir(feature, storyCount);
|
|
125
|
-
const statusFilePath = path.join(setup.tmpDir, "nax-status.json");
|
|
126
|
-
await run({
|
|
127
|
-
prdPath: setup.prdPath,
|
|
128
|
-
workdir: setup.tmpDir,
|
|
129
|
-
config: createTestConfig(),
|
|
130
|
-
hooks: { hooks: {} },
|
|
131
|
-
feature,
|
|
132
|
-
featureDir: setup.featureDir,
|
|
133
|
-
dryRun: true,
|
|
134
|
-
statusFile: statusFilePath,
|
|
135
|
-
skipPrecheck: true,
|
|
136
|
-
...extraOpts,
|
|
137
|
-
});
|
|
138
|
-
return { setup, statusFilePath };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ============================================================================
|
|
142
|
-
// RunOptions type-level checks
|
|
143
|
-
// ============================================================================
|
|
144
|
-
describe("RunOptions.statusFile", () => {
|
|
145
|
-
it("is required", () => {
|
|
146
|
-
const opts: RunOptions = {
|
|
147
|
-
prdPath: "/tmp/prd.json",
|
|
148
|
-
workdir: "/tmp",
|
|
149
|
-
config: createTestConfig(),
|
|
150
|
-
hooks: { hooks: {} },
|
|
151
|
-
feature: "test",
|
|
152
|
-
dryRun: true,
|
|
153
|
-
statusFile: "/tmp/nax/status.json",
|
|
154
|
-
};
|
|
155
|
-
expect(opts.statusFile).toBe("/tmp/nax/status.json");
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// ============================================================================
|
|
160
|
-
// Status file is always written when provided
|
|
161
|
-
// ============================================================================
|
|
162
|
-
describe("status file always written when provided", () => {
|
|
163
|
-
let tmpDir: string;
|
|
164
|
-
afterEach(async () => {
|
|
165
|
-
if (tmpDir) await fs.rm(tmpDir, { recursive: true, force: true });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("writes status file to provided path during dry-run", async () => {
|
|
169
|
-
const { setup, statusFilePath } = await runWithStatus("sf-always-written", 1);
|
|
170
|
-
tmpDir = setup.tmpDir;
|
|
171
|
-
expect(nodeFs.existsSync(statusFilePath)).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// ============================================================================
|
|
176
|
-
// Status file written during dry-run
|
|
177
|
-
// ============================================================================
|
|
178
|
-
describe("status file written during dry-run", () => {
|
|
179
|
-
let tmpDir: string;
|
|
180
|
-
afterEach(async () => {
|
|
181
|
-
if (tmpDir) await fs.rm(tmpDir, { recursive: true, force: true });
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("creates the file", async () => {
|
|
185
|
-
const { setup, statusFilePath } = await runWithStatus("sf-creates");
|
|
186
|
-
tmpDir = setup.tmpDir;
|
|
187
|
-
expect(nodeFs.existsSync(statusFilePath)).toBe(true);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("produces valid JSON", async () => {
|
|
191
|
-
const { setup, statusFilePath } = await runWithStatus("sf-valid-json");
|
|
192
|
-
tmpDir = setup.tmpDir;
|
|
193
|
-
expect(() => JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8"))).not.toThrow();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("has correct NaxStatusFile schema (version, run, progress, cost, current, iterations, updatedAt, durationMs)", async () => {
|
|
197
|
-
const { setup, statusFilePath } = await runWithStatus("sf-schema", 2);
|
|
198
|
-
tmpDir = setup.tmpDir;
|
|
199
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
200
|
-
expect(p.version).toBe(1);
|
|
201
|
-
expect(typeof p.run.id).toBe("string");
|
|
202
|
-
expect(p.run.feature).toBe("sf-schema");
|
|
203
|
-
expect(typeof p.run.startedAt).toBe("string");
|
|
204
|
-
expect(p.run.dryRun).toBe(true);
|
|
205
|
-
expect(typeof p.progress.total).toBe("number");
|
|
206
|
-
expect(typeof p.progress.passed).toBe("number");
|
|
207
|
-
expect(typeof p.progress.pending).toBe("number");
|
|
208
|
-
expect(typeof p.cost.spent).toBe("number");
|
|
209
|
-
expect(typeof p.iterations).toBe("number");
|
|
210
|
-
expect(typeof p.updatedAt).toBe("string");
|
|
211
|
-
expect(typeof p.durationMs).toBe("number");
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("run.status is 'completed' when all stories pass", async () => {
|
|
215
|
-
const { setup, statusFilePath } = await runWithStatus("sf-completed", 2);
|
|
216
|
-
tmpDir = setup.tmpDir;
|
|
217
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
218
|
-
expect(p.run.status).toBe("completed");
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("progress.passed equals story count after dry-run", async () => {
|
|
222
|
-
const storyCount = 3;
|
|
223
|
-
const { setup, statusFilePath } = await runWithStatus("sf-progress", storyCount);
|
|
224
|
-
tmpDir = setup.tmpDir;
|
|
225
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
226
|
-
expect(p.progress.total).toBe(storyCount);
|
|
227
|
-
expect(p.progress.passed).toBe(storyCount);
|
|
228
|
-
expect(p.progress.pending).toBe(0);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it("current is null at run end (write point 4)", async () => {
|
|
232
|
-
const { setup, statusFilePath } = await runWithStatus("sf-current-null");
|
|
233
|
-
tmpDir = setup.tmpDir;
|
|
234
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
235
|
-
expect(p.current).toBeNull();
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("no .tmp file left behind after write", async () => {
|
|
239
|
-
const { setup, statusFilePath } = await runWithStatus("sf-no-tmp");
|
|
240
|
-
tmpDir = setup.tmpDir;
|
|
241
|
-
expect(nodeFs.existsSync(`${statusFilePath}.tmp`)).toBe(false);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it("run.id starts with 'run-'", async () => {
|
|
245
|
-
const { setup, statusFilePath } = await runWithStatus("sf-runid");
|
|
246
|
-
tmpDir = setup.tmpDir;
|
|
247
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
248
|
-
expect(p.run.id).toMatch(/^run-/);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("cost.limit is null when config.costLimit is Infinity", async () => {
|
|
252
|
-
const setup = await setupDir("sf-cost-null", 1);
|
|
253
|
-
tmpDir = setup.tmpDir;
|
|
254
|
-
const statusFilePath = path.join(setup.tmpDir, "nax-status.json");
|
|
255
|
-
const config = createTestConfig();
|
|
256
|
-
config.execution.costLimit = Number.POSITIVE_INFINITY;
|
|
257
|
-
await run({
|
|
258
|
-
prdPath: setup.prdPath,
|
|
259
|
-
workdir: setup.tmpDir,
|
|
260
|
-
config,
|
|
261
|
-
hooks: { hooks: {} },
|
|
262
|
-
feature: "sf-cost-null",
|
|
263
|
-
featureDir: setup.featureDir,
|
|
264
|
-
dryRun: true,
|
|
265
|
-
statusFile: statusFilePath,
|
|
266
|
-
skipPrecheck: true,
|
|
267
|
-
});
|
|
268
|
-
const p = JSON.parse(nodeFs.readFileSync(statusFilePath, "utf-8")) as NaxStatusFile;
|
|
269
|
-
expect(p.cost.limit).toBeNull();
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// ============================================================================
|
|
274
|
-
// CLI status file wiring (type check only)
|
|
275
|
-
// ============================================================================
|
|
276
|
-
describe("CLI auto-computed status file", () => {
|
|
277
|
-
it("RunOptions.statusFile is required and always provided", () => {
|
|
278
|
-
const opts: RunOptions = {
|
|
279
|
-
prdPath: "/tmp/prd.json",
|
|
280
|
-
workdir: "/tmp",
|
|
281
|
-
config: createTestConfig(),
|
|
282
|
-
hooks: { hooks: {} },
|
|
283
|
-
feature: "test",
|
|
284
|
-
dryRun: false,
|
|
285
|
-
statusFile: "/tmp/nax/status.json",
|
|
286
|
-
};
|
|
287
|
-
expect(opts.statusFile).toBe("/tmp/nax/status.json");
|
|
288
|
-
});
|
|
289
|
-
});
|
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
// RE-ARCH: keep
|
|
2
|
-
/**
|
|
3
|
-
* Status File Tests
|
|
4
|
-
*
|
|
5
|
-
* Tests for src/execution/status-file.ts:
|
|
6
|
-
* - NaxStatusFile interface shape
|
|
7
|
-
* - writeStatusFile(): atomic write via .tmp + rename
|
|
8
|
-
* - countProgress(): correct PRD story status counts
|
|
9
|
-
* - buildStatusSnapshot(): valid NaxStatusFile from run state
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
13
|
-
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
14
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
15
|
-
import { tmpdir } from "node:os";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
type NaxStatusFile,
|
|
20
|
-
type RunStateSnapshot,
|
|
21
|
-
buildStatusSnapshot,
|
|
22
|
-
countProgress,
|
|
23
|
-
writeStatusFile,
|
|
24
|
-
} from "../../../src/execution/status-file";
|
|
25
|
-
import type { PRD, UserStory } from "../../../src/prd";
|
|
26
|
-
|
|
27
|
-
// ============================================================================
|
|
28
|
-
// Helpers
|
|
29
|
-
// ============================================================================
|
|
30
|
-
|
|
31
|
-
function makeStory(id: string, status: UserStory["status"]): UserStory {
|
|
32
|
-
return {
|
|
33
|
-
id,
|
|
34
|
-
title: `Story ${id}`,
|
|
35
|
-
description: `Description for ${id}`,
|
|
36
|
-
acceptanceCriteria: ["AC-1"],
|
|
37
|
-
tags: [],
|
|
38
|
-
dependencies: [],
|
|
39
|
-
status,
|
|
40
|
-
passes: status === "passed",
|
|
41
|
-
escalations: [],
|
|
42
|
-
attempts: 0,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function makePrd(stories: UserStory[]): PRD {
|
|
47
|
-
return {
|
|
48
|
-
project: "test-project",
|
|
49
|
-
feature: "test-feature",
|
|
50
|
-
branchName: "feat/test",
|
|
51
|
-
createdAt: "2026-02-25T10:00:00.000Z",
|
|
52
|
-
updatedAt: "2026-02-25T10:00:00.000Z",
|
|
53
|
-
userStories: stories,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function makeRunState(overrides: Partial<RunStateSnapshot> = {}): RunStateSnapshot {
|
|
58
|
-
return {
|
|
59
|
-
runId: "run-2026-02-25T10-00-00-000Z",
|
|
60
|
-
feature: "auth-refactor",
|
|
61
|
-
startedAt: "2026-02-25T10:00:00.000Z",
|
|
62
|
-
runStatus: "running",
|
|
63
|
-
dryRun: false,
|
|
64
|
-
pid: process.pid,
|
|
65
|
-
prd: makePrd([makeStory("US-001", "pending")]),
|
|
66
|
-
totalCost: 0,
|
|
67
|
-
costLimit: 5.0,
|
|
68
|
-
currentStory: null,
|
|
69
|
-
iterations: 0,
|
|
70
|
-
startTimeMs: Date.now() - 1000,
|
|
71
|
-
...overrides,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ============================================================================
|
|
76
|
-
// countProgress
|
|
77
|
-
// ============================================================================
|
|
78
|
-
|
|
79
|
-
describe("countProgress", () => {
|
|
80
|
-
test("counts all story statuses correctly", () => {
|
|
81
|
-
const stories = [
|
|
82
|
-
makeStory("US-001", "passed"),
|
|
83
|
-
makeStory("US-002", "passed"),
|
|
84
|
-
makeStory("US-003", "failed"),
|
|
85
|
-
makeStory("US-004", "paused"),
|
|
86
|
-
makeStory("US-005", "blocked"),
|
|
87
|
-
makeStory("US-006", "pending"),
|
|
88
|
-
makeStory("US-007", "in-progress"),
|
|
89
|
-
];
|
|
90
|
-
const prd = makePrd(stories);
|
|
91
|
-
const progress = countProgress(prd);
|
|
92
|
-
|
|
93
|
-
expect(progress.total).toBe(7);
|
|
94
|
-
expect(progress.passed).toBe(2);
|
|
95
|
-
expect(progress.failed).toBe(1);
|
|
96
|
-
expect(progress.paused).toBe(1);
|
|
97
|
-
expect(progress.blocked).toBe(1);
|
|
98
|
-
// pending = 7 - 2 - 1 - 1 - 1 = 2 (pending + in-progress)
|
|
99
|
-
expect(progress.pending).toBe(2);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test("all passed → pending is 0", () => {
|
|
103
|
-
const prd = makePrd([makeStory("US-001", "passed"), makeStory("US-002", "passed")]);
|
|
104
|
-
const progress = countProgress(prd);
|
|
105
|
-
|
|
106
|
-
expect(progress.total).toBe(2);
|
|
107
|
-
expect(progress.passed).toBe(2);
|
|
108
|
-
expect(progress.failed).toBe(0);
|
|
109
|
-
expect(progress.paused).toBe(0);
|
|
110
|
-
expect(progress.blocked).toBe(0);
|
|
111
|
-
expect(progress.pending).toBe(0);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test("all pending → passed/failed/paused/blocked are 0", () => {
|
|
115
|
-
const prd = makePrd([makeStory("US-001", "pending"), makeStory("US-002", "pending")]);
|
|
116
|
-
const progress = countProgress(prd);
|
|
117
|
-
|
|
118
|
-
expect(progress.total).toBe(2);
|
|
119
|
-
expect(progress.passed).toBe(0);
|
|
120
|
-
expect(progress.failed).toBe(0);
|
|
121
|
-
expect(progress.paused).toBe(0);
|
|
122
|
-
expect(progress.blocked).toBe(0);
|
|
123
|
-
expect(progress.pending).toBe(2);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("empty PRD → all zeros", () => {
|
|
127
|
-
const prd = makePrd([]);
|
|
128
|
-
const progress = countProgress(prd);
|
|
129
|
-
|
|
130
|
-
expect(progress.total).toBe(0);
|
|
131
|
-
expect(progress.passed).toBe(0);
|
|
132
|
-
expect(progress.failed).toBe(0);
|
|
133
|
-
expect(progress.paused).toBe(0);
|
|
134
|
-
expect(progress.blocked).toBe(0);
|
|
135
|
-
expect(progress.pending).toBe(0);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("pending = total - passed - failed - paused - blocked", () => {
|
|
139
|
-
const stories = [
|
|
140
|
-
makeStory("US-001", "passed"),
|
|
141
|
-
makeStory("US-002", "failed"),
|
|
142
|
-
makeStory("US-003", "paused"),
|
|
143
|
-
makeStory("US-004", "blocked"),
|
|
144
|
-
makeStory("US-005", "pending"),
|
|
145
|
-
makeStory("US-006", "in-progress"),
|
|
146
|
-
makeStory("US-007", "skipped"),
|
|
147
|
-
];
|
|
148
|
-
const prd = makePrd(stories);
|
|
149
|
-
const p = countProgress(prd);
|
|
150
|
-
|
|
151
|
-
expect(p.pending).toBe(p.total - p.passed - p.failed - p.paused - p.blocked);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test("skipped stories count as pending (not a tracked terminal state)", () => {
|
|
155
|
-
const prd = makePrd([makeStory("US-001", "skipped")]);
|
|
156
|
-
const p = countProgress(prd);
|
|
157
|
-
|
|
158
|
-
expect(p.total).toBe(1);
|
|
159
|
-
expect(p.pending).toBe(1);
|
|
160
|
-
expect(p.passed).toBe(0);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test("in-progress stories count toward pending", () => {
|
|
164
|
-
const prd = makePrd([makeStory("US-001", "in-progress")]);
|
|
165
|
-
const p = countProgress(prd);
|
|
166
|
-
|
|
167
|
-
expect(p.pending).toBe(1);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// ============================================================================
|
|
172
|
-
// buildStatusSnapshot
|
|
173
|
-
// ============================================================================
|
|
174
|
-
|
|
175
|
-
describe("buildStatusSnapshot", () => {
|
|
176
|
-
test("builds valid NaxStatusFile with version 1", () => {
|
|
177
|
-
const snapshot = buildStatusSnapshot(makeRunState());
|
|
178
|
-
expect(snapshot.version).toBe(1);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test("run metadata matches run state", () => {
|
|
182
|
-
const state = makeRunState({
|
|
183
|
-
runId: "run-test-id",
|
|
184
|
-
feature: "my-feature",
|
|
185
|
-
startedAt: "2026-02-25T10:00:00.000Z",
|
|
186
|
-
runStatus: "running",
|
|
187
|
-
dryRun: true,
|
|
188
|
-
pid: 12345,
|
|
189
|
-
});
|
|
190
|
-
const snapshot = buildStatusSnapshot(state);
|
|
191
|
-
|
|
192
|
-
expect(snapshot.run.id).toBe("run-test-id");
|
|
193
|
-
expect(snapshot.run.feature).toBe("my-feature");
|
|
194
|
-
expect(snapshot.run.startedAt).toBe("2026-02-25T10:00:00.000Z");
|
|
195
|
-
expect(snapshot.run.status).toBe("running");
|
|
196
|
-
expect(snapshot.run.dryRun).toBe(true);
|
|
197
|
-
expect(snapshot.run.pid).toBe(12345);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test("PID is included for crash detection", () => {
|
|
201
|
-
const testPid = 99999;
|
|
202
|
-
const snapshot = buildStatusSnapshot(makeRunState({ pid: testPid }));
|
|
203
|
-
|
|
204
|
-
expect(snapshot.run.pid).toBe(testPid);
|
|
205
|
-
expect(typeof snapshot.run.pid).toBe("number");
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
test("PID defaults to process.pid when not overridden", () => {
|
|
209
|
-
const snapshot = buildStatusSnapshot(makeRunState());
|
|
210
|
-
|
|
211
|
-
expect(snapshot.run.pid).toBe(process.pid);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test("progress is derived from PRD stories", () => {
|
|
215
|
-
const prd = makePrd([makeStory("US-001", "passed"), makeStory("US-002", "failed"), makeStory("US-003", "pending")]);
|
|
216
|
-
const snapshot = buildStatusSnapshot(makeRunState({ prd }));
|
|
217
|
-
|
|
218
|
-
expect(snapshot.progress.total).toBe(3);
|
|
219
|
-
expect(snapshot.progress.passed).toBe(1);
|
|
220
|
-
expect(snapshot.progress.failed).toBe(1);
|
|
221
|
-
expect(snapshot.progress.pending).toBe(1);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test("cost fields populated from state", () => {
|
|
225
|
-
const snapshot = buildStatusSnapshot(makeRunState({ totalCost: 2.5, costLimit: 10.0 }));
|
|
226
|
-
|
|
227
|
-
expect(snapshot.cost.spent).toBe(2.5);
|
|
228
|
-
expect(snapshot.cost.limit).toBe(10.0);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
test("cost limit is null when not set", () => {
|
|
232
|
-
const snapshot = buildStatusSnapshot(makeRunState({ costLimit: null }));
|
|
233
|
-
expect(snapshot.cost.limit).toBeNull();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test("current is null when no story active", () => {
|
|
237
|
-
const snapshot = buildStatusSnapshot(makeRunState({ currentStory: null }));
|
|
238
|
-
expect(snapshot.current).toBeNull();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test("current story info populated when story is active", () => {
|
|
242
|
-
const current = {
|
|
243
|
-
storyId: "US-008",
|
|
244
|
-
title: "Add retry logic",
|
|
245
|
-
complexity: "medium",
|
|
246
|
-
tddStrategy: "tdd-lite",
|
|
247
|
-
model: "claude-sonnet-4-5-20250514",
|
|
248
|
-
attempt: 1,
|
|
249
|
-
phase: "implement",
|
|
250
|
-
};
|
|
251
|
-
const snapshot = buildStatusSnapshot(makeRunState({ currentStory: current }));
|
|
252
|
-
|
|
253
|
-
expect(snapshot.current).not.toBeNull();
|
|
254
|
-
expect(snapshot.current?.storyId).toBe("US-008");
|
|
255
|
-
expect(snapshot.current?.title).toBe("Add retry logic");
|
|
256
|
-
expect(snapshot.current?.complexity).toBe("medium");
|
|
257
|
-
expect(snapshot.current?.tddStrategy).toBe("tdd-lite");
|
|
258
|
-
expect(snapshot.current?.model).toBe("claude-sonnet-4-5-20250514");
|
|
259
|
-
expect(snapshot.current?.attempt).toBe(1);
|
|
260
|
-
expect(snapshot.current?.phase).toBe("implement");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("iterations and timing fields are set", () => {
|
|
264
|
-
const startTimeMs = Date.now() - 5000;
|
|
265
|
-
const snapshot = buildStatusSnapshot(makeRunState({ iterations: 7, startTimeMs }));
|
|
266
|
-
|
|
267
|
-
expect(snapshot.iterations).toBe(7);
|
|
268
|
-
expect(snapshot.durationMs).toBeGreaterThanOrEqual(5000);
|
|
269
|
-
expect(snapshot.updatedAt).toBeTruthy();
|
|
270
|
-
// updatedAt should be a valid ISO 8601 string
|
|
271
|
-
expect(() => new Date(snapshot.updatedAt)).not.toThrow();
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
test("all run status values are accepted", () => {
|
|
275
|
-
const statuses: NaxStatusFile["run"]["status"][] = ["running", "completed", "failed", "stalled"];
|
|
276
|
-
for (const runStatus of statuses) {
|
|
277
|
-
const snapshot = buildStatusSnapshot(makeRunState({ runStatus }));
|
|
278
|
-
expect(snapshot.run.status).toBe(runStatus);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
// ============================================================================
|
|
284
|
-
// writeStatusFile
|
|
285
|
-
// ============================================================================
|
|
286
|
-
|
|
287
|
-
describe("writeStatusFile", () => {
|
|
288
|
-
let tmpDir: string;
|
|
289
|
-
|
|
290
|
-
beforeEach(async () => {
|
|
291
|
-
tmpDir = await mkdtemp(join(tmpdir(), "nax-status-test-"));
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
afterEach(async () => {
|
|
295
|
-
await rm(tmpDir, { recursive: true, force: true });
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
test("writes valid JSON to the target path", async () => {
|
|
299
|
-
const outPath = join(tmpDir, "status.json");
|
|
300
|
-
const snapshot = buildStatusSnapshot(makeRunState());
|
|
301
|
-
|
|
302
|
-
await writeStatusFile(outPath, snapshot);
|
|
303
|
-
|
|
304
|
-
expect(existsSync(outPath)).toBe(true);
|
|
305
|
-
const raw = readFileSync(outPath, "utf8");
|
|
306
|
-
const parsed = JSON.parse(raw) as NaxStatusFile;
|
|
307
|
-
expect(parsed.version).toBe(1);
|
|
308
|
-
expect(parsed.run.id).toBe(snapshot.run.id);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test("does NOT leave a .tmp file after successful write", async () => {
|
|
312
|
-
const outPath = join(tmpDir, "status.json");
|
|
313
|
-
await writeStatusFile(outPath, buildStatusSnapshot(makeRunState()));
|
|
314
|
-
|
|
315
|
-
expect(existsSync(`${outPath}.tmp`)).toBe(false);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
test("atomic rename: final file appears complete", async () => {
|
|
319
|
-
const outPath = join(tmpDir, "status.json");
|
|
320
|
-
const state = makeRunState({
|
|
321
|
-
prd: makePrd([makeStory("US-001", "passed"), makeStory("US-002", "failed"), makeStory("US-003", "pending")]),
|
|
322
|
-
totalCost: 1.5,
|
|
323
|
-
costLimit: 5.0,
|
|
324
|
-
iterations: 3,
|
|
325
|
-
});
|
|
326
|
-
const snapshot = buildStatusSnapshot(state);
|
|
327
|
-
await writeStatusFile(outPath, snapshot);
|
|
328
|
-
|
|
329
|
-
const content = JSON.parse(readFileSync(outPath, "utf8")) as NaxStatusFile;
|
|
330
|
-
expect(content.progress.passed).toBe(1);
|
|
331
|
-
expect(content.progress.failed).toBe(1);
|
|
332
|
-
expect(content.progress.pending).toBe(1);
|
|
333
|
-
expect(content.cost.spent).toBe(1.5);
|
|
334
|
-
expect(content.iterations).toBe(3);
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
test("overwrites an existing status file", async () => {
|
|
338
|
-
const outPath = join(tmpDir, "status.json");
|
|
339
|
-
|
|
340
|
-
// First write
|
|
341
|
-
await writeStatusFile(outPath, buildStatusSnapshot(makeRunState({ runStatus: "running", iterations: 1 })));
|
|
342
|
-
|
|
343
|
-
// Second write with updated state
|
|
344
|
-
await writeStatusFile(outPath, buildStatusSnapshot(makeRunState({ runStatus: "completed", iterations: 5 })));
|
|
345
|
-
|
|
346
|
-
const content = JSON.parse(readFileSync(outPath, "utf8")) as NaxStatusFile;
|
|
347
|
-
expect(content.run.status).toBe("completed");
|
|
348
|
-
expect(content.iterations).toBe(5);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
test("writes null current when no active story", async () => {
|
|
352
|
-
const outPath = join(tmpDir, "status.json");
|
|
353
|
-
await writeStatusFile(outPath, buildStatusSnapshot(makeRunState({ currentStory: null })));
|
|
354
|
-
|
|
355
|
-
const content = JSON.parse(readFileSync(outPath, "utf8")) as NaxStatusFile;
|
|
356
|
-
expect(content.current).toBeNull();
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
test("written JSON is pretty-printed (2-space indent)", async () => {
|
|
360
|
-
const outPath = join(tmpDir, "status.json");
|
|
361
|
-
await writeStatusFile(outPath, buildStatusSnapshot(makeRunState()));
|
|
362
|
-
|
|
363
|
-
const raw = readFileSync(outPath, "utf8");
|
|
364
|
-
// Pretty-printed JSON has lines beyond just a single line
|
|
365
|
-
expect(raw.split("\n").length).toBeGreaterThan(1);
|
|
366
|
-
// Check for 2-space indent on top-level keys
|
|
367
|
-
expect(raw).toContain(' "version"');
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
test("PID is persisted to status file for crash detection", async () => {
|
|
371
|
-
const outPath = join(tmpDir, "status.json");
|
|
372
|
-
const testPid = 54321;
|
|
373
|
-
const snapshot = buildStatusSnapshot(makeRunState({ pid: testPid }));
|
|
374
|
-
|
|
375
|
-
await writeStatusFile(outPath, snapshot);
|
|
376
|
-
|
|
377
|
-
const content = JSON.parse(readFileSync(outPath, "utf8")) as NaxStatusFile;
|
|
378
|
-
expect(content.run.pid).toBe(testPid);
|
|
379
|
-
});
|
|
380
|
-
});
|