@nathapp/nax 0.18.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/.gitlab-ci.yml +96 -0
- package/BRIEF.md +140 -0
- package/CHANGELOG.md +60 -0
- package/CLAUDE.md +159 -0
- package/README.md +373 -0
- package/US-007-IMPLEMENTATION.md +139 -0
- package/bin/nax.ts +930 -0
- package/biome.json +14 -0
- package/bun.lock +168 -0
- package/bunfig.toml +11 -0
- package/docs/20260216-fix-plan-context-review.md +56 -0
- package/docs/20260216-relentless-vs-ngent-comparison.md +208 -0
- package/docs/20260216-v02-plan.md +136 -0
- package/docs/20260216-v02-review.md +685 -0
- package/docs/20260217-dogfood-findings.md +56 -0
- package/docs/20260217-p2-plus-plan.md +117 -0
- package/docs/20260217-partial-fixes-plan.md +62 -0
- package/docs/20260217-plan-analyze-spec.md +117 -0
- package/docs/20260217-post-impl-review.md +1137 -0
- package/docs/20260217-quick-wins-plan.md +66 -0
- package/docs/20260217-split-runner-plan.md +75 -0
- package/docs/20260217-v03-impl-plan.md +80 -0
- package/docs/20260217-v03-post-impl-review.md +589 -0
- package/docs/20260217-v04-impl-plan.md +86 -0
- package/docs/20260217-v05-post-impl-review.md +850 -0
- package/docs/20260217-v06-post-impl-review.md +817 -0
- package/docs/20260218-adr003-port-plan.md +151 -0
- package/docs/20260218-review-adr003-verification.md +175 -0
- package/docs/20260219-fix-plan-bug16-19.md +79 -0
- package/docs/20260219-fix-plan-bug20-22.md +114 -0
- package/docs/20260219-plan-llm-routing.md +116 -0
- package/docs/20260219-review-bug20-22-fixes.md +135 -0
- package/docs/20260219-routing-baseline-keyword.md +63 -0
- package/docs/20260220-plan-structured-logging-p1.md +80 -0
- package/docs/20260220-plan-structured-logging-p2.md +37 -0
- package/docs/20260220-review-llm-routing.md +180 -0
- package/docs/20260220-review-post-fix-llm-routing.md +70 -0
- package/docs/20260221-fix-plan-relevantfiles-split.md +101 -0
- package/docs/20260221-fix-plan-routing-mode.md +125 -0
- package/docs/20260221-review-v0.9-implementation.md +379 -0
- package/docs/20260222-fix-plan-v091-routing-isolation.md +197 -0
- package/docs/20260223-fix-plan-prompt-audit.md +62 -0
- package/docs/20260224-nax-roadmap-phases.md +189 -0
- package/docs/20260225-phase2-llm-service-layer.md +401 -0
- package/docs/20260225-review-v0.10.1.md +187 -0
- package/docs/20260303-v010-implementation-plan.md +165 -0
- package/docs/CLAUDE.md.bak +191 -0
- package/docs/ROADMAP.md +165 -0
- package/docs/SPEC-rectification.md +0 -0
- package/docs/SPEC.md +324 -0
- package/docs/US-001-plugin-loading-verification.md +152 -0
- package/docs/architecture-analysis.md +1076 -0
- package/docs/bugs/BUG-21-escalation-null-attempts.md +48 -0
- package/docs/bugs-from-dogfood-run-c.md +243 -0
- package/docs/code-review-20260228.md +612 -0
- package/docs/code-review-v0.15.0.md +629 -0
- package/docs/hook-lifecycle-test-plan.md +149 -0
- package/docs/releases/v0.11.0-and-earlier.md +20 -0
- package/docs/releases/v0.12.0.md +15 -0
- package/docs/releases/v0.13.0.md +14 -0
- package/docs/releases/v0.14.0.md +20 -0
- package/docs/releases/v0.14.1.md +36 -0
- package/docs/releases/v0.14.2.md +51 -0
- package/docs/releases/v0.14.3.md +174 -0
- package/docs/releases/v0.14.4.md +94 -0
- package/docs/releases/v0.15.0.md +502 -0
- package/docs/releases/v0.15.1.md +170 -0
- package/docs/releases/v0.15.3.md +193 -0
- package/docs/specs/status-file-v0.10.1.md +812 -0
- package/docs/v0.10-global-config.md +206 -0
- package/docs/v0.10-plugin-system.md +415 -0
- package/docs/v0.10-prompt-optimizer.md +234 -0
- package/docs/v0.3-spec.md +244 -0
- package/docs/v0.4-spec.md +140 -0
- package/docs/v0.5-spec.md +237 -0
- package/docs/v0.6-spec.md +371 -0
- package/docs/v0.7-spec.md +177 -0
- package/docs/v0.8-llm-routing.md +206 -0
- package/docs/v0.8-structured-logging.md +132 -0
- package/docs/v0.9.3-prompt-audit.md +112 -0
- package/examples/plugins/console-reporter/index.test.ts +207 -0
- package/examples/plugins/console-reporter/index.ts +110 -0
- package/nax/config.json +147 -0
- package/nax/features/bugfix-v0171/prd.json +52 -0
- package/nax/features/config-management/prd.json +108 -0
- package/nax/features/config-management/progress.txt +5 -0
- package/nax/features/diagnose/acceptance.test.ts +412 -0
- package/nax/features/diagnose/prd.json +41 -0
- package/nax/features/orchestration-fixes/prd.json +89 -0
- package/nax/features/orchestration-fixes/progress.txt +1 -0
- package/nax/features/plugin-integration/US-007-VERIFICATION.md +259 -0
- package/nax/features/plugin-integration/prd.json +208 -0
- package/nax/features/plugin-integration/progress.txt +5 -0
- package/nax/features/precheck/prd.json +205 -0
- package/nax/features/precheck/progress.txt +15 -0
- package/nax/features/structured-logging/prd.json +199 -0
- package/nax/features/unlock/prd.json +36 -0
- package/package.json +47 -0
- package/src/acceptance/fix-generator.ts +348 -0
- package/src/acceptance/generator.ts +282 -0
- package/src/acceptance/index.ts +30 -0
- package/src/acceptance/types.ts +79 -0
- package/src/agents/claude-decompose.ts +169 -0
- package/src/agents/claude-plan.ts +139 -0
- package/src/agents/claude.ts +324 -0
- package/src/agents/cost.ts +268 -0
- package/src/agents/index.ts +13 -0
- package/src/agents/registry.ts +48 -0
- package/src/agents/types-extended.ts +133 -0
- package/src/agents/types.ts +113 -0
- package/src/agents/validation.ts +69 -0
- package/src/analyze/classifier.ts +305 -0
- package/src/analyze/index.ts +16 -0
- package/src/analyze/scanner.ts +175 -0
- package/src/analyze/types.ts +51 -0
- package/src/cli/accept.ts +108 -0
- package/src/cli/analyze-parser.ts +284 -0
- package/src/cli/analyze.ts +207 -0
- package/src/cli/config.ts +561 -0
- package/src/cli/constitution.ts +109 -0
- package/src/cli/diagnose-analysis.ts +159 -0
- package/src/cli/diagnose-formatter.ts +87 -0
- package/src/cli/diagnose.ts +203 -0
- package/src/cli/generate.ts +127 -0
- package/src/cli/index.ts +37 -0
- package/src/cli/init.ts +188 -0
- package/src/cli/interact.ts +295 -0
- package/src/cli/plan.ts +198 -0
- package/src/cli/plugins.ts +111 -0
- package/src/cli/prompts.ts +295 -0
- package/src/cli/runs.ts +174 -0
- package/src/cli/status-cost.ts +151 -0
- package/src/cli/status-features.ts +338 -0
- package/src/cli/status.ts +13 -0
- package/src/commands/common.ts +171 -0
- package/src/commands/diagnose.ts +17 -0
- package/src/commands/index.ts +8 -0
- package/src/commands/logs.ts +384 -0
- package/src/commands/precheck.ts +86 -0
- package/src/commands/unlock.ts +96 -0
- package/src/config/defaults.ts +160 -0
- package/src/config/index.ts +22 -0
- package/src/config/loader.ts +121 -0
- package/src/config/merger.ts +147 -0
- package/src/config/path-security.ts +121 -0
- package/src/config/paths.ts +27 -0
- package/src/config/schema.ts +56 -0
- package/src/config/schemas.ts +286 -0
- package/src/config/types.ts +423 -0
- package/src/config/validate.ts +103 -0
- package/src/constitution/generator.ts +191 -0
- package/src/constitution/generators/aider.ts +41 -0
- package/src/constitution/generators/claude.ts +35 -0
- package/src/constitution/generators/cursor.ts +36 -0
- package/src/constitution/generators/opencode.ts +38 -0
- package/src/constitution/generators/types.ts +33 -0
- package/src/constitution/generators/windsurf.ts +36 -0
- package/src/constitution/index.ts +10 -0
- package/src/constitution/loader.ts +133 -0
- package/src/constitution/types.ts +31 -0
- package/src/context/auto-detect.ts +227 -0
- package/src/context/builder.ts +246 -0
- package/src/context/elements.ts +83 -0
- package/src/context/formatter.ts +107 -0
- package/src/context/generator.ts +129 -0
- package/src/context/generators/aider.ts +34 -0
- package/src/context/generators/claude.ts +28 -0
- package/src/context/generators/cursor.ts +28 -0
- package/src/context/generators/opencode.ts +30 -0
- package/src/context/generators/windsurf.ts +28 -0
- package/src/context/greenfield.ts +114 -0
- package/src/context/index.ts +33 -0
- package/src/context/injector.ts +279 -0
- package/src/context/test-scanner.ts +370 -0
- package/src/context/types.ts +98 -0
- package/src/errors.ts +67 -0
- package/src/execution/batching.ts +157 -0
- package/src/execution/crash-recovery.ts +373 -0
- package/src/execution/escalation/escalation.ts +44 -0
- package/src/execution/escalation/index.ts +13 -0
- package/src/execution/escalation/tier-escalation.ts +295 -0
- package/src/execution/escalation/tier-outcome.ts +158 -0
- package/src/execution/helpers.ts +38 -0
- package/src/execution/index.ts +45 -0
- package/src/execution/lifecycle/acceptance-loop.ts +272 -0
- package/src/execution/lifecycle/headless-formatter.ts +85 -0
- package/src/execution/lifecycle/index.ts +12 -0
- package/src/execution/lifecycle/parallel-lifecycle.ts +101 -0
- package/src/execution/lifecycle/precheck-runner.ts +140 -0
- package/src/execution/lifecycle/run-cleanup.ts +81 -0
- package/src/execution/lifecycle/run-completion.ts +129 -0
- package/src/execution/lifecycle/run-initialization.ts +141 -0
- package/src/execution/lifecycle/run-lifecycle.ts +312 -0
- package/src/execution/lifecycle/run-setup.ts +204 -0
- package/src/execution/lifecycle/story-hooks.ts +38 -0
- package/src/execution/lifecycle/story-size-prompts.ts +123 -0
- package/src/execution/lock.ts +115 -0
- package/src/execution/parallel-executor.ts +216 -0
- package/src/execution/parallel.ts +400 -0
- package/src/execution/pid-registry.ts +280 -0
- package/src/execution/pipeline-result-handler.ts +388 -0
- package/src/execution/post-verify-rectification.ts +188 -0
- package/src/execution/post-verify.ts +274 -0
- package/src/execution/progress.ts +25 -0
- package/src/execution/prompts.ts +127 -0
- package/src/execution/queue-handler.ts +109 -0
- package/src/execution/rectification.ts +13 -0
- package/src/execution/runner.ts +377 -0
- package/src/execution/sequential-executor.ts +388 -0
- package/src/execution/status-file.ts +264 -0
- package/src/execution/status-writer.ts +139 -0
- package/src/execution/story-context.ts +229 -0
- package/src/execution/test-output-parser.ts +14 -0
- package/src/execution/verification.ts +72 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/runner.ts +286 -0
- package/src/hooks/types.ts +67 -0
- package/src/interaction/chain.ts +154 -0
- package/src/interaction/index.ts +60 -0
- package/src/interaction/init.ts +83 -0
- package/src/interaction/plugins/auto.ts +217 -0
- package/src/interaction/plugins/cli.ts +300 -0
- package/src/interaction/plugins/telegram.ts +384 -0
- package/src/interaction/plugins/webhook.ts +258 -0
- package/src/interaction/state.ts +171 -0
- package/src/interaction/triggers.ts +229 -0
- package/src/interaction/types.ts +163 -0
- package/src/logger/formatters.ts +84 -0
- package/src/logger/index.ts +16 -0
- package/src/logger/logger.ts +298 -0
- package/src/logger/types.ts +48 -0
- package/src/logging/formatter.ts +355 -0
- package/src/logging/index.ts +22 -0
- package/src/logging/types.ts +93 -0
- package/src/metrics/aggregator.ts +190 -0
- package/src/metrics/index.ts +14 -0
- package/src/metrics/tracker.ts +200 -0
- package/src/metrics/types.ts +109 -0
- package/src/optimizer/index.ts +62 -0
- package/src/optimizer/noop.optimizer.ts +24 -0
- package/src/optimizer/rule-based.optimizer.ts +248 -0
- package/src/optimizer/types.ts +53 -0
- package/src/pipeline/events.ts +130 -0
- package/src/pipeline/index.ts +19 -0
- package/src/pipeline/runner.ts +161 -0
- package/src/pipeline/stages/acceptance.ts +197 -0
- package/src/pipeline/stages/completion.ts +99 -0
- package/src/pipeline/stages/constitution.ts +63 -0
- package/src/pipeline/stages/context.ts +117 -0
- package/src/pipeline/stages/execution.ts +194 -0
- package/src/pipeline/stages/index.ts +62 -0
- package/src/pipeline/stages/optimizer.ts +74 -0
- package/src/pipeline/stages/prompt.ts +57 -0
- package/src/pipeline/stages/queue-check.ts +103 -0
- package/src/pipeline/stages/review.ts +181 -0
- package/src/pipeline/stages/routing.ts +81 -0
- package/src/pipeline/stages/verify.ts +100 -0
- package/src/pipeline/types.ts +167 -0
- package/src/plugins/index.ts +31 -0
- package/src/plugins/loader.ts +287 -0
- package/src/plugins/registry.ts +168 -0
- package/src/plugins/types.ts +327 -0
- package/src/plugins/validator.ts +352 -0
- package/src/prd/index.ts +172 -0
- package/src/prd/types.ts +202 -0
- package/src/precheck/checks-blockers.ts +391 -0
- package/src/precheck/checks-warnings.ts +142 -0
- package/src/precheck/checks.ts +30 -0
- package/src/precheck/index.ts +247 -0
- package/src/precheck/story-size-gate.ts +144 -0
- package/src/precheck/types.ts +31 -0
- package/src/queue/index.ts +2 -0
- package/src/queue/manager.ts +254 -0
- package/src/queue/types.ts +54 -0
- package/src/review/index.ts +8 -0
- package/src/review/runner.ts +172 -0
- package/src/review/types.ts +66 -0
- package/src/routing/builder.ts +81 -0
- package/src/routing/chain.ts +74 -0
- package/src/routing/index.ts +16 -0
- package/src/routing/loader.ts +58 -0
- package/src/routing/router.ts +303 -0
- package/src/routing/strategies/adaptive.ts +215 -0
- package/src/routing/strategies/index.ts +8 -0
- package/src/routing/strategies/keyword.ts +163 -0
- package/src/routing/strategies/llm-prompts.ts +209 -0
- package/src/routing/strategies/llm.ts +235 -0
- package/src/routing/strategies/manual.ts +50 -0
- package/src/routing/strategy.ts +99 -0
- package/src/tdd/cleanup.ts +111 -0
- package/src/tdd/index.ts +23 -0
- package/src/tdd/isolation.ts +123 -0
- package/src/tdd/orchestrator.ts +383 -0
- package/src/tdd/prompts.ts +270 -0
- package/src/tdd/rectification-gate.ts +183 -0
- package/src/tdd/session-runner.ts +179 -0
- package/src/tdd/types.ts +81 -0
- package/src/tdd/verdict.ts +271 -0
- package/src/tui/App.tsx +265 -0
- package/src/tui/components/AgentPanel.tsx +75 -0
- package/src/tui/components/CostOverlay.tsx +118 -0
- package/src/tui/components/HelpOverlay.tsx +107 -0
- package/src/tui/components/StatusBar.tsx +63 -0
- package/src/tui/components/StoriesPanel.tsx +177 -0
- package/src/tui/hooks/useKeyboard.ts +142 -0
- package/src/tui/hooks/useLayout.ts +137 -0
- package/src/tui/hooks/usePipelineEvents.ts +183 -0
- package/src/tui/hooks/usePty.ts +194 -0
- package/src/tui/index.tsx +38 -0
- package/src/tui/types.ts +76 -0
- package/src/utils/git.ts +83 -0
- package/src/utils/queue-writer.ts +54 -0
- package/src/verification/executor.ts +235 -0
- package/src/verification/gate.ts +207 -0
- package/src/verification/index.ts +12 -0
- package/src/verification/parser.ts +230 -0
- package/src/verification/rectification.ts +108 -0
- package/src/verification/types.ts +113 -0
- package/src/worktree/dispatcher.ts +65 -0
- package/src/worktree/index.ts +2 -0
- package/src/worktree/manager.ts +187 -0
- package/src/worktree/merge.ts +301 -0
- package/src/worktree/types.ts +4 -0
- package/test/TEST_COVERAGE_US001.md +217 -0
- package/test/TEST_COVERAGE_US003.md +84 -0
- package/test/TEST_COVERAGE_US005.md +86 -0
- package/test/US-002-orchestrator.test.ts +246 -0
- package/test/acceptance/cm-003-default-view.test.ts +194 -0
- package/test/execution/pid-registry.test.ts +240 -0
- package/test/execution/post-verify.test.ts +224 -0
- package/test/helpers/timeout.ts +42 -0
- package/test/integration/US-002-TEST-SUMMARY.md +107 -0
- package/test/integration/US-003-TEST-SUMMARY.md +149 -0
- package/test/integration/US-004-TEST-SUMMARY.md +106 -0
- package/test/integration/US-005-TEST-SUMMARY.md +138 -0
- package/test/integration/US-007-TEST-SUMMARY.md +100 -0
- package/test/integration/agent-validation.test.ts +439 -0
- package/test/integration/analyze-integration.test.ts +261 -0
- package/test/integration/analyze-scanner.test.ts +131 -0
- package/test/integration/cli-config-default-edge-cases.test.ts +222 -0
- package/test/integration/cli-config-default-view.test.ts +229 -0
- package/test/integration/cli-config-diff.test.ts +460 -0
- package/test/integration/cli-config.test.ts +736 -0
- package/test/integration/cli-diagnose.test.ts +592 -0
- package/test/integration/cli-logs.test.ts +314 -0
- package/test/integration/cli-plugins.test.ts +678 -0
- package/test/integration/cli-precheck.test.ts +371 -0
- package/test/integration/cli-run-headless.test.ts +173 -0
- package/test/integration/cli.test.ts +75 -0
- package/test/integration/config/merger.test.ts +465 -0
- package/test/integration/config/paths.test.ts +51 -0
- package/test/integration/config-loader.test.ts +265 -0
- package/test/integration/config.test.ts +444 -0
- package/test/integration/context-integration.test.ts +702 -0
- package/test/integration/context-provider-injection.test.ts +506 -0
- package/test/integration/context-verification-integration.test.ts +295 -0
- package/test/integration/e2e.test.ts +896 -0
- package/test/integration/execution.test.ts +625 -0
- package/test/integration/helpers.test.ts +295 -0
- package/test/integration/hooks.test.ts +361 -0
- package/test/integration/interaction-chain-pipeline.test.ts +464 -0
- package/test/integration/isolation.test.ts +143 -0
- package/test/integration/logger.test.ts +461 -0
- package/test/integration/parallel.test.ts +250 -0
- package/test/integration/path-security.test.ts +173 -0
- package/test/integration/pipeline-acceptance.test.ts +302 -0
- package/test/integration/pipeline-events.test.ts +475 -0
- package/test/integration/pipeline.test.ts +658 -0
- package/test/integration/plan.test.ts +157 -0
- package/test/integration/plugin-routing.test.ts +921 -0
- package/test/integration/plugins/config-integration.test.ts +172 -0
- package/test/integration/plugins/config-resolution.test.ts +522 -0
- package/test/integration/plugins/loader.test.ts +641 -0
- package/test/integration/plugins/registry.test.ts +746 -0
- package/test/integration/plugins/validator.test.ts +563 -0
- package/test/integration/prd-pause.test.ts +205 -0
- package/test/integration/prd-resolvers.test.ts +185 -0
- package/test/integration/precheck-integration.test.ts +468 -0
- package/test/integration/precheck.test.ts +805 -0
- package/test/integration/progress.test.ts +34 -0
- package/test/integration/rectification-flow.test.ts +512 -0
- package/test/integration/reporter-lifecycle.test.ts +860 -0
- package/test/integration/review-config-commands.test.ts +319 -0
- package/test/integration/review-config-schema.test.ts +116 -0
- package/test/integration/review-plugin-integration.test.ts +722 -0
- package/test/integration/review.test.ts +149 -0
- package/test/integration/routing-stage-bug-021.test.ts +274 -0
- package/test/integration/routing-stage-greenfield.test.ts +286 -0
- package/test/integration/runner-config-plugins.test.ts +461 -0
- package/test/integration/runner-fixes.test.ts +399 -0
- package/test/integration/runner-plugin-integration.test.ts +543 -0
- package/test/integration/runner.test.ts +1679 -0
- package/test/integration/s5-greenfield-fallback.test.ts +297 -0
- package/test/integration/status-file-integration.test.ts +325 -0
- package/test/integration/status-file.test.ts +379 -0
- package/test/integration/status-writer.test.ts +345 -0
- package/test/integration/story-id-in-events.test.ts +273 -0
- package/test/integration/tdd-cleanup.test.ts +246 -0
- package/test/integration/tdd-orchestrator.test.ts +1762 -0
- package/test/integration/test-scanner.test.ts +403 -0
- package/test/integration/verification-asset-check.test.ts +142 -0
- package/test/integration/verify-stage.test.ts +275 -0
- package/test/integration/worktree/manager.test.ts +218 -0
- package/test/integration/worktree/merge.test.ts +341 -0
- package/test/manual/logging-formatter-demo.ts +158 -0
- package/test/ui/tui-agent-panel.test.tsx +99 -0
- package/test/ui/tui-controls.test.ts +334 -0
- package/test/ui/tui-cost-and-pty.test.ts +189 -0
- package/test/ui/tui-layout.test.ts +378 -0
- package/test/ui/tui-pty-integration.test.tsx +159 -0
- package/test/ui/tui-stories.test.ts +332 -0
- package/test/unit/acceptance.test.ts +186 -0
- package/test/unit/agent-stderr-capture.test.ts +146 -0
- package/test/unit/analyze-classifier.test.ts +215 -0
- package/test/unit/analyze.test.ts +224 -0
- package/test/unit/auto-detect.test.ts +249 -0
- package/test/unit/cli-status.test.ts +417 -0
- package/test/unit/commands/common.test.ts +320 -0
- package/test/unit/commands/logs.test.ts +416 -0
- package/test/unit/commands/unlock.test.ts +319 -0
- package/test/unit/constitution-generators.test.ts +160 -0
- package/test/unit/constitution.test.ts +209 -0
- package/test/unit/context.test.ts +1722 -0
- package/test/unit/cost.test.ts +231 -0
- package/test/unit/crash-recovery.test.ts +308 -0
- package/test/unit/escalation.test.ts +126 -0
- package/test/unit/execution-logging-stderr.test.ts +156 -0
- package/test/unit/execution-stage.test.ts +122 -0
- package/test/unit/fix-generator.test.ts +275 -0
- package/test/unit/formatters.test.ts +469 -0
- package/test/unit/greenfield.test.ts +179 -0
- package/test/unit/helpers.test.ts +317 -0
- package/test/unit/interaction/human-review-trigger.test.ts +164 -0
- package/test/unit/interaction-network-failures.test.ts +389 -0
- package/test/unit/interaction-plugins.test.ts +164 -0
- package/test/unit/isolation.test.ts +134 -0
- package/test/unit/logging/formatter.test.ts +455 -0
- package/test/unit/merge.test.ts +268 -0
- package/test/unit/metrics.test.ts +276 -0
- package/test/unit/optimizer/noop.optimizer.test.ts +125 -0
- package/test/unit/optimizer/rule-based.optimizer.test.ts +358 -0
- package/test/unit/prd-auto-default.test.ts +290 -0
- package/test/unit/prd-failure-category.test.ts +176 -0
- package/test/unit/prd-get-next-story.test.ts +186 -0
- package/test/unit/precheck-checks.test.ts +840 -0
- package/test/unit/precheck-story-size-gate.test.ts +287 -0
- package/test/unit/precheck-types.test.ts +142 -0
- package/test/unit/prompts.test.ts +475 -0
- package/test/unit/queue.test.ts +237 -0
- package/test/unit/rectification.test.ts +284 -0
- package/test/unit/registry.test.ts +287 -0
- package/test/unit/routing.test.ts +937 -0
- package/test/unit/run-lifecycle.test.ts +140 -0
- package/test/unit/storyid-events.test.ts +224 -0
- package/test/unit/tdd-verdict.test.ts +492 -0
- package/test/unit/test-output-parser.test.ts +377 -0
- package/test/unit/verdict.test.ts +324 -0
- package/test/unit/worktree-manager.test.ts +158 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Command Integration Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for `nax config` command with --explain flag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
|
|
8
|
+
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { configCommand } from "../../src/cli/config";
|
|
12
|
+
import { loadConfig } from "../../src/config/loader";
|
|
13
|
+
|
|
14
|
+
describe("Config Command", () => {
|
|
15
|
+
let tempDir: string;
|
|
16
|
+
let originalCwd: string;
|
|
17
|
+
let consoleOutput: string[];
|
|
18
|
+
let originalConsoleLog: typeof console.log;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
// Create temp directory
|
|
22
|
+
tempDir = mkdtempSync(join(tmpdir(), "nax-config-test-"));
|
|
23
|
+
originalCwd = process.cwd();
|
|
24
|
+
|
|
25
|
+
// Capture console output
|
|
26
|
+
consoleOutput = [];
|
|
27
|
+
originalConsoleLog = console.log;
|
|
28
|
+
console.log = (...args: unknown[]) => {
|
|
29
|
+
consoleOutput.push(args.map((a) => String(a)).join(" "));
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
// Restore console
|
|
35
|
+
console.log = originalConsoleLog;
|
|
36
|
+
|
|
37
|
+
// Cleanup
|
|
38
|
+
process.chdir(originalCwd);
|
|
39
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("Basic functionality", () => {
|
|
43
|
+
test("displays config as JSON when explain=false", async () => {
|
|
44
|
+
// Load default config
|
|
45
|
+
const config = await loadConfig(tempDir);
|
|
46
|
+
|
|
47
|
+
// Run command without explain
|
|
48
|
+
await configCommand(config, { explain: false });
|
|
49
|
+
|
|
50
|
+
// Should output valid JSON (after the header lines)
|
|
51
|
+
const output = consoleOutput.join("\n");
|
|
52
|
+
|
|
53
|
+
// Find where JSON starts (after header comments and blank line)
|
|
54
|
+
const lines = output.split("\n");
|
|
55
|
+
const jsonStartIndex = lines.findIndex((line) => line.startsWith("{"));
|
|
56
|
+
expect(jsonStartIndex).toBeGreaterThan(0);
|
|
57
|
+
|
|
58
|
+
const jsonOutput = lines.slice(jsonStartIndex).join("\n");
|
|
59
|
+
expect(() => JSON.parse(jsonOutput)).not.toThrow();
|
|
60
|
+
|
|
61
|
+
const parsed = JSON.parse(jsonOutput);
|
|
62
|
+
expect(parsed.version).toBe(1);
|
|
63
|
+
expect(parsed.models).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("displays config with explanations when explain=true", async () => {
|
|
67
|
+
// Load default config
|
|
68
|
+
const config = await loadConfig(tempDir);
|
|
69
|
+
|
|
70
|
+
// Run command with explain
|
|
71
|
+
await configCommand(config, { explain: true });
|
|
72
|
+
|
|
73
|
+
const output = consoleOutput.join("\n");
|
|
74
|
+
|
|
75
|
+
// Should have header
|
|
76
|
+
expect(output).toContain("# nax Configuration");
|
|
77
|
+
expect(output).toContain("# Resolution order: defaults → global → project → CLI overrides");
|
|
78
|
+
|
|
79
|
+
// Should have field descriptions
|
|
80
|
+
expect(output).toContain("# Configuration schema version");
|
|
81
|
+
expect(output).toContain("# Model tier definitions");
|
|
82
|
+
expect(output).toContain("# Auto mode configuration");
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("Default view (without --explain)", () => {
|
|
87
|
+
test("shows header with config sources", async () => {
|
|
88
|
+
const config = await loadConfig(tempDir);
|
|
89
|
+
await configCommand(config, { explain: false });
|
|
90
|
+
|
|
91
|
+
const output = consoleOutput.join("\n");
|
|
92
|
+
|
|
93
|
+
// Should have header comments
|
|
94
|
+
expect(output).toContain("// nax Configuration");
|
|
95
|
+
expect(output).toContain("// Resolution order: defaults → global → project → CLI overrides");
|
|
96
|
+
expect(output).toContain("// Global config:");
|
|
97
|
+
expect(output).toContain("// Project config:");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("shows global config path when found", async () => {
|
|
101
|
+
const config = await loadConfig(tempDir);
|
|
102
|
+
await configCommand(config, { explain: false });
|
|
103
|
+
|
|
104
|
+
const output = consoleOutput.join("\n");
|
|
105
|
+
|
|
106
|
+
// Global config path is in the output
|
|
107
|
+
expect(output).toContain("// Global config:");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("shows (not found) for missing project config", async () => {
|
|
111
|
+
// Use an isolated directory without nax/config.json
|
|
112
|
+
const isolatedDir = join(tempDir, "isolated");
|
|
113
|
+
mkdirSync(isolatedDir, { recursive: true });
|
|
114
|
+
process.chdir(isolatedDir);
|
|
115
|
+
|
|
116
|
+
const config = await loadConfig(isolatedDir);
|
|
117
|
+
await configCommand(config, { explain: false });
|
|
118
|
+
|
|
119
|
+
const output = consoleOutput.join("\n");
|
|
120
|
+
|
|
121
|
+
// Project config should show as not found in the isolated directory
|
|
122
|
+
expect(output).toContain("// Project config: (not found)");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("shows project config path when present", async () => {
|
|
126
|
+
// Create project config
|
|
127
|
+
const naxDir = join(tempDir, "nax");
|
|
128
|
+
mkdirSync(naxDir, { recursive: true });
|
|
129
|
+
writeFileSync(
|
|
130
|
+
join(naxDir, "config.json"),
|
|
131
|
+
JSON.stringify({
|
|
132
|
+
execution: {
|
|
133
|
+
maxIterations: 20,
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
process.chdir(tempDir);
|
|
139
|
+
|
|
140
|
+
const config = await loadConfig(tempDir);
|
|
141
|
+
await configCommand(config, { explain: false });
|
|
142
|
+
|
|
143
|
+
const output = consoleOutput.join("\n");
|
|
144
|
+
|
|
145
|
+
// Should show project config path
|
|
146
|
+
expect(output).toContain("// Project config:");
|
|
147
|
+
expect(output).toContain("config.json");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("header precedes JSON output", async () => {
|
|
151
|
+
const config = await loadConfig(tempDir);
|
|
152
|
+
await configCommand(config, { explain: false });
|
|
153
|
+
|
|
154
|
+
const output = consoleOutput.join("\n");
|
|
155
|
+
const lines = output.split("\n");
|
|
156
|
+
|
|
157
|
+
// Find header and JSON start
|
|
158
|
+
const headerLineIndex = lines.findIndex((line) => line.includes("// nax Configuration"));
|
|
159
|
+
const jsonLineIndex = lines.findIndex((line) => line.startsWith("{"));
|
|
160
|
+
|
|
161
|
+
expect(headerLineIndex).toBeGreaterThanOrEqual(0);
|
|
162
|
+
expect(jsonLineIndex).toBeGreaterThan(headerLineIndex);
|
|
163
|
+
|
|
164
|
+
// Should have blank line between header and JSON
|
|
165
|
+
expect(lines[jsonLineIndex - 1]).toBe("");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("Field descriptions", () => {
|
|
170
|
+
test("includes descriptions for top-level sections", async () => {
|
|
171
|
+
const config = await loadConfig(tempDir);
|
|
172
|
+
await configCommand(config, { explain: true });
|
|
173
|
+
|
|
174
|
+
const output = consoleOutput.join("\n");
|
|
175
|
+
|
|
176
|
+
expect(output).toContain("# Model tier definitions");
|
|
177
|
+
expect(output).toContain("# Auto mode configuration");
|
|
178
|
+
expect(output).toContain("# Model routing strategy");
|
|
179
|
+
expect(output).toContain("# Execution limits");
|
|
180
|
+
expect(output).toContain("# Quality gate configuration");
|
|
181
|
+
expect(output).toContain("# Test-driven development configuration");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("includes descriptions for nested fields", async () => {
|
|
185
|
+
const config = await loadConfig(tempDir);
|
|
186
|
+
await configCommand(config, { explain: true });
|
|
187
|
+
|
|
188
|
+
const output = consoleOutput.join("\n");
|
|
189
|
+
|
|
190
|
+
expect(output).toContain("# Enable automatic agent selection");
|
|
191
|
+
expect(output).toContain("# Max iterations per feature run");
|
|
192
|
+
expect(output).toContain("# Require typecheck to pass");
|
|
193
|
+
expect(output).toContain("# TDD strategy: auto | strict | lite | off");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("includes descriptions for deeply nested fields", async () => {
|
|
197
|
+
const config = await loadConfig(tempDir);
|
|
198
|
+
await configCommand(config, { explain: true });
|
|
199
|
+
|
|
200
|
+
const output = consoleOutput.join("\n");
|
|
201
|
+
|
|
202
|
+
expect(output).toContain("# Enable tier escalation on failure");
|
|
203
|
+
expect(output).toContain("# Model tier for test-writer session");
|
|
204
|
+
expect(output).toContain("# Enable test coverage context injection");
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe("Source annotations", () => {
|
|
209
|
+
test("shows global config path when present", async () => {
|
|
210
|
+
const config = await loadConfig(tempDir);
|
|
211
|
+
await configCommand(config, { explain: true });
|
|
212
|
+
|
|
213
|
+
const output = consoleOutput.join("\n");
|
|
214
|
+
|
|
215
|
+
// Should show global config line (may be "not found" or a path)
|
|
216
|
+
expect(output).toContain("# Global config:");
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("shows project config path when present", async () => {
|
|
220
|
+
// Create project config
|
|
221
|
+
const naxDir = join(tempDir, "nax");
|
|
222
|
+
mkdirSync(naxDir, { recursive: true });
|
|
223
|
+
writeFileSync(
|
|
224
|
+
join(naxDir, "config.json"),
|
|
225
|
+
JSON.stringify({
|
|
226
|
+
execution: {
|
|
227
|
+
maxIterations: 20,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
process.chdir(tempDir);
|
|
233
|
+
|
|
234
|
+
const config = await loadConfig(tempDir);
|
|
235
|
+
await configCommand(config, { explain: true });
|
|
236
|
+
|
|
237
|
+
const output = consoleOutput.join("\n");
|
|
238
|
+
|
|
239
|
+
// Should show project config path
|
|
240
|
+
expect(output).toContain("# Project config:");
|
|
241
|
+
expect(output).toContain("config.json");
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test('shows "(not found)" when no project config exists', async () => {
|
|
245
|
+
// Use a directory without nax/config.json
|
|
246
|
+
const isolatedDir = join(tempDir, "isolated");
|
|
247
|
+
mkdirSync(isolatedDir, { recursive: true });
|
|
248
|
+
process.chdir(isolatedDir);
|
|
249
|
+
|
|
250
|
+
const config = await loadConfig(isolatedDir);
|
|
251
|
+
await configCommand(config, { explain: true });
|
|
252
|
+
|
|
253
|
+
const output = consoleOutput.join("\n");
|
|
254
|
+
|
|
255
|
+
expect(output).toContain("# Project config: (not found)");
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe("Value formatting", () => {
|
|
260
|
+
test("formats strings with quotes", async () => {
|
|
261
|
+
const config = await loadConfig(tempDir);
|
|
262
|
+
await configCommand(config, { explain: true });
|
|
263
|
+
|
|
264
|
+
const output = consoleOutput.join("\n");
|
|
265
|
+
|
|
266
|
+
// Models have string values
|
|
267
|
+
expect(output).toMatch(/model: "haiku"|model: "sonnet"|model: "opus"/);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("formats booleans without quotes", async () => {
|
|
271
|
+
const config = await loadConfig(tempDir);
|
|
272
|
+
await configCommand(config, { explain: true });
|
|
273
|
+
|
|
274
|
+
const output = consoleOutput.join("\n");
|
|
275
|
+
|
|
276
|
+
expect(output).toContain("enabled: true");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("formats numbers without quotes", async () => {
|
|
280
|
+
const config = await loadConfig(tempDir);
|
|
281
|
+
await configCommand(config, { explain: true });
|
|
282
|
+
|
|
283
|
+
const output = consoleOutput.join("\n");
|
|
284
|
+
|
|
285
|
+
expect(output).toContain("version: 1");
|
|
286
|
+
expect(output).toMatch(/maxIterations: \d+/);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test("formats arrays compactly", async () => {
|
|
290
|
+
const config = await loadConfig(tempDir);
|
|
291
|
+
await configCommand(config, { explain: true });
|
|
292
|
+
|
|
293
|
+
const output = consoleOutput.join("\n");
|
|
294
|
+
|
|
295
|
+
// Should format small arrays inline
|
|
296
|
+
expect(output).toMatch(/fallbackOrder: \[/);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test("truncates long arrays", async () => {
|
|
300
|
+
const config = await loadConfig(tempDir);
|
|
301
|
+
|
|
302
|
+
// Override with a long array
|
|
303
|
+
config.quality.stripEnvVars = ["VAR1", "VAR2", "VAR3", "VAR4", "VAR5"];
|
|
304
|
+
|
|
305
|
+
await configCommand(config, { explain: true });
|
|
306
|
+
|
|
307
|
+
const output = consoleOutput.join("\n");
|
|
308
|
+
|
|
309
|
+
// Should show truncation for arrays > 3 items
|
|
310
|
+
expect(output).toMatch(/stripEnvVars:.*\.\.\./);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
describe("All config sections", () => {
|
|
315
|
+
test("covers models section", async () => {
|
|
316
|
+
const config = await loadConfig(tempDir);
|
|
317
|
+
await configCommand(config, { explain: true });
|
|
318
|
+
|
|
319
|
+
const output = consoleOutput.join("\n");
|
|
320
|
+
|
|
321
|
+
expect(output).toContain("models:");
|
|
322
|
+
expect(output).toContain("fast:");
|
|
323
|
+
expect(output).toContain("balanced:");
|
|
324
|
+
expect(output).toContain("powerful:");
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("covers autoMode section", async () => {
|
|
328
|
+
const config = await loadConfig(tempDir);
|
|
329
|
+
await configCommand(config, { explain: true });
|
|
330
|
+
|
|
331
|
+
const output = consoleOutput.join("\n");
|
|
332
|
+
|
|
333
|
+
expect(output).toContain("autoMode:");
|
|
334
|
+
expect(output).toContain("enabled:");
|
|
335
|
+
expect(output).toContain("defaultAgent:");
|
|
336
|
+
expect(output).toContain("complexityRouting:");
|
|
337
|
+
expect(output).toContain("escalation:");
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("covers routing section", async () => {
|
|
341
|
+
const config = await loadConfig(tempDir);
|
|
342
|
+
await configCommand(config, { explain: true });
|
|
343
|
+
|
|
344
|
+
const output = consoleOutput.join("\n");
|
|
345
|
+
|
|
346
|
+
expect(output).toContain("routing:");
|
|
347
|
+
expect(output).toContain("strategy:");
|
|
348
|
+
expect(output).toContain("adaptive:");
|
|
349
|
+
expect(output).toContain("llm:");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("covers execution section", async () => {
|
|
353
|
+
const config = await loadConfig(tempDir);
|
|
354
|
+
await configCommand(config, { explain: true });
|
|
355
|
+
|
|
356
|
+
const output = consoleOutput.join("\n");
|
|
357
|
+
|
|
358
|
+
expect(output).toContain("execution:");
|
|
359
|
+
expect(output).toContain("maxIterations:");
|
|
360
|
+
expect(output).toContain("rectification:");
|
|
361
|
+
expect(output).toContain("regressionGate:");
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("covers quality section", async () => {
|
|
365
|
+
const config = await loadConfig(tempDir);
|
|
366
|
+
await configCommand(config, { explain: true });
|
|
367
|
+
|
|
368
|
+
const output = consoleOutput.join("\n");
|
|
369
|
+
|
|
370
|
+
expect(output).toContain("quality:");
|
|
371
|
+
expect(output).toContain("requireTypecheck:");
|
|
372
|
+
expect(output).toContain("requireLint:");
|
|
373
|
+
expect(output).toContain("requireTests:");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test("covers tdd section", async () => {
|
|
377
|
+
const config = await loadConfig(tempDir);
|
|
378
|
+
await configCommand(config, { explain: true });
|
|
379
|
+
|
|
380
|
+
const output = consoleOutput.join("\n");
|
|
381
|
+
|
|
382
|
+
expect(output).toContain("tdd:");
|
|
383
|
+
expect(output).toContain("strategy:");
|
|
384
|
+
expect(output).toContain("sessionTiers:");
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test("covers constitution section", async () => {
|
|
388
|
+
const config = await loadConfig(tempDir);
|
|
389
|
+
await configCommand(config, { explain: true });
|
|
390
|
+
|
|
391
|
+
const output = consoleOutput.join("\n");
|
|
392
|
+
|
|
393
|
+
expect(output).toContain("constitution:");
|
|
394
|
+
expect(output).toContain("enabled:");
|
|
395
|
+
expect(output).toContain("path:");
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
test("covers analyze section", async () => {
|
|
399
|
+
const config = await loadConfig(tempDir);
|
|
400
|
+
await configCommand(config, { explain: true });
|
|
401
|
+
|
|
402
|
+
const output = consoleOutput.join("\n");
|
|
403
|
+
|
|
404
|
+
expect(output).toContain("analyze:");
|
|
405
|
+
expect(output).toContain("llmEnhanced:");
|
|
406
|
+
expect(output).toContain("model:");
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
test("covers review section", async () => {
|
|
410
|
+
const config = await loadConfig(tempDir);
|
|
411
|
+
await configCommand(config, { explain: true });
|
|
412
|
+
|
|
413
|
+
const output = consoleOutput.join("\n");
|
|
414
|
+
|
|
415
|
+
expect(output).toContain("review:");
|
|
416
|
+
expect(output).toContain("enabled:");
|
|
417
|
+
expect(output).toContain("checks:");
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
test("covers plan section", async () => {
|
|
421
|
+
const config = await loadConfig(tempDir);
|
|
422
|
+
await configCommand(config, { explain: true });
|
|
423
|
+
|
|
424
|
+
const output = consoleOutput.join("\n");
|
|
425
|
+
|
|
426
|
+
expect(output).toContain("plan:");
|
|
427
|
+
expect(output).toContain("model:");
|
|
428
|
+
expect(output).toContain("outputPath:");
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("covers acceptance section", async () => {
|
|
432
|
+
const config = await loadConfig(tempDir);
|
|
433
|
+
await configCommand(config, { explain: true });
|
|
434
|
+
|
|
435
|
+
const output = consoleOutput.join("\n");
|
|
436
|
+
|
|
437
|
+
expect(output).toContain("acceptance:");
|
|
438
|
+
expect(output).toContain("enabled:");
|
|
439
|
+
expect(output).toContain("generateTests:");
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
test("covers context section", async () => {
|
|
443
|
+
const config = await loadConfig(tempDir);
|
|
444
|
+
await configCommand(config, { explain: true });
|
|
445
|
+
|
|
446
|
+
const output = consoleOutput.join("\n");
|
|
447
|
+
|
|
448
|
+
expect(output).toContain("context:");
|
|
449
|
+
expect(output).toContain("testCoverage:");
|
|
450
|
+
expect(output).toContain("autoDetect:");
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
test("covers interaction section", async () => {
|
|
454
|
+
const config = await loadConfig(tempDir);
|
|
455
|
+
await configCommand(config, { explain: true });
|
|
456
|
+
|
|
457
|
+
const output = consoleOutput.join("\n");
|
|
458
|
+
|
|
459
|
+
expect(output).toContain("interaction:");
|
|
460
|
+
expect(output).toContain("plugin:");
|
|
461
|
+
expect(output).toContain("defaults:");
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test("covers precheck section", async () => {
|
|
465
|
+
const config = await loadConfig(tempDir);
|
|
466
|
+
await configCommand(config, { explain: true });
|
|
467
|
+
|
|
468
|
+
const output = consoleOutput.join("\n");
|
|
469
|
+
|
|
470
|
+
expect(output).toContain("precheck:");
|
|
471
|
+
expect(output).toContain("storySizeGate:");
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
describe("Works from any directory", () => {
|
|
476
|
+
test("works when run from project root", async () => {
|
|
477
|
+
// Create project config
|
|
478
|
+
const naxDir = join(tempDir, "nax");
|
|
479
|
+
mkdirSync(naxDir, { recursive: true });
|
|
480
|
+
writeFileSync(
|
|
481
|
+
join(naxDir, "config.json"),
|
|
482
|
+
JSON.stringify({
|
|
483
|
+
execution: {
|
|
484
|
+
maxIterations: 25,
|
|
485
|
+
},
|
|
486
|
+
}),
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
process.chdir(tempDir);
|
|
490
|
+
|
|
491
|
+
const config = await loadConfig();
|
|
492
|
+
await configCommand(config, { explain: true });
|
|
493
|
+
|
|
494
|
+
const output = consoleOutput.join("\n");
|
|
495
|
+
|
|
496
|
+
expect(output).toContain("# nax Configuration");
|
|
497
|
+
expect(output).toContain("maxIterations: 25");
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
test("works when run from subdirectory", async () => {
|
|
501
|
+
// Create project config
|
|
502
|
+
const naxDir = join(tempDir, "nax");
|
|
503
|
+
mkdirSync(naxDir, { recursive: true });
|
|
504
|
+
writeFileSync(
|
|
505
|
+
join(naxDir, "config.json"),
|
|
506
|
+
JSON.stringify({
|
|
507
|
+
execution: {
|
|
508
|
+
maxIterations: 30,
|
|
509
|
+
},
|
|
510
|
+
}),
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
// Create subdirectory
|
|
514
|
+
const subdir = join(tempDir, "src", "components");
|
|
515
|
+
mkdirSync(subdir, { recursive: true });
|
|
516
|
+
process.chdir(subdir);
|
|
517
|
+
|
|
518
|
+
const config = await loadConfig();
|
|
519
|
+
await configCommand(config, { explain: true });
|
|
520
|
+
|
|
521
|
+
const output = consoleOutput.join("\n");
|
|
522
|
+
|
|
523
|
+
expect(output).toContain("# nax Configuration");
|
|
524
|
+
expect(output).toContain("maxIterations: 30");
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
test("works when no project config exists", async () => {
|
|
528
|
+
process.chdir(tempDir);
|
|
529
|
+
|
|
530
|
+
const config = await loadConfig();
|
|
531
|
+
await configCommand(config, { explain: true });
|
|
532
|
+
|
|
533
|
+
const output = consoleOutput.join("\n");
|
|
534
|
+
|
|
535
|
+
expect(output).toContain("# nax Configuration");
|
|
536
|
+
expect(output).toContain("# Project config: (not found)");
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
describe("Diff mode (--diff)", () => {
|
|
541
|
+
test("shows message when no project config exists", async () => {
|
|
542
|
+
process.chdir(tempDir);
|
|
543
|
+
|
|
544
|
+
const config = await loadConfig();
|
|
545
|
+
await configCommand(config, { diff: true });
|
|
546
|
+
|
|
547
|
+
const output = consoleOutput.join("\n");
|
|
548
|
+
|
|
549
|
+
expect(output).toContain("No project config found — using global defaults");
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
test("shows message when project config has no differences", async () => {
|
|
553
|
+
// Create empty project config
|
|
554
|
+
const naxDir = join(tempDir, "nax");
|
|
555
|
+
mkdirSync(naxDir, { recursive: true });
|
|
556
|
+
writeFileSync(join(naxDir, "config.json"), JSON.stringify({}));
|
|
557
|
+
|
|
558
|
+
process.chdir(tempDir);
|
|
559
|
+
|
|
560
|
+
const config = await loadConfig();
|
|
561
|
+
await configCommand(config, { diff: true });
|
|
562
|
+
|
|
563
|
+
const output = consoleOutput.join("\n");
|
|
564
|
+
|
|
565
|
+
expect(output).toContain("No differences between project and global config");
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
test("shows differences in table format", async () => {
|
|
569
|
+
// Create project config with overrides
|
|
570
|
+
const naxDir = join(tempDir, "nax");
|
|
571
|
+
mkdirSync(naxDir, { recursive: true });
|
|
572
|
+
writeFileSync(
|
|
573
|
+
join(naxDir, "config.json"),
|
|
574
|
+
JSON.stringify({
|
|
575
|
+
execution: {
|
|
576
|
+
maxIterations: 25,
|
|
577
|
+
costLimit: 10.0,
|
|
578
|
+
},
|
|
579
|
+
}),
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
process.chdir(tempDir);
|
|
583
|
+
|
|
584
|
+
const config = await loadConfig();
|
|
585
|
+
await configCommand(config, { diff: true });
|
|
586
|
+
|
|
587
|
+
const output = consoleOutput.join("\n");
|
|
588
|
+
|
|
589
|
+
// Should show header
|
|
590
|
+
expect(output).toContain("# Config Differences (Project overrides Global)");
|
|
591
|
+
|
|
592
|
+
// Should show table with field, project value, global value
|
|
593
|
+
expect(output).toContain("Field");
|
|
594
|
+
expect(output).toContain("Project Value");
|
|
595
|
+
expect(output).toContain("Global Value");
|
|
596
|
+
|
|
597
|
+
// Should show the specific differences
|
|
598
|
+
expect(output).toContain("execution.maxIterations");
|
|
599
|
+
expect(output).toContain("25");
|
|
600
|
+
expect(output).toContain("execution.costLimit");
|
|
601
|
+
expect(output).toContain("10");
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
test("shows field descriptions for differences", async () => {
|
|
605
|
+
// Create project config with overrides
|
|
606
|
+
const naxDir = join(tempDir, "nax");
|
|
607
|
+
mkdirSync(naxDir, { recursive: true });
|
|
608
|
+
writeFileSync(
|
|
609
|
+
join(naxDir, "config.json"),
|
|
610
|
+
JSON.stringify({
|
|
611
|
+
execution: {
|
|
612
|
+
maxIterations: 25,
|
|
613
|
+
},
|
|
614
|
+
}),
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
process.chdir(tempDir);
|
|
618
|
+
|
|
619
|
+
const config = await loadConfig();
|
|
620
|
+
await configCommand(config, { diff: true });
|
|
621
|
+
|
|
622
|
+
const output = consoleOutput.join("\n");
|
|
623
|
+
|
|
624
|
+
// Should show description for the field
|
|
625
|
+
expect(output).toContain("↳ Max iterations per feature run");
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
test("only shows fields that differ", async () => {
|
|
629
|
+
// Create project config with overrides
|
|
630
|
+
const naxDir = join(tempDir, "nax");
|
|
631
|
+
mkdirSync(naxDir, { recursive: true });
|
|
632
|
+
writeFileSync(
|
|
633
|
+
join(naxDir, "config.json"),
|
|
634
|
+
JSON.stringify({
|
|
635
|
+
execution: {
|
|
636
|
+
maxIterations: 25,
|
|
637
|
+
},
|
|
638
|
+
}),
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
process.chdir(tempDir);
|
|
642
|
+
|
|
643
|
+
const config = await loadConfig();
|
|
644
|
+
await configCommand(config, { diff: true });
|
|
645
|
+
|
|
646
|
+
const output = consoleOutput.join("\n");
|
|
647
|
+
|
|
648
|
+
// Should show maxIterations
|
|
649
|
+
expect(output).toContain("execution.maxIterations");
|
|
650
|
+
|
|
651
|
+
// Should NOT show fields that aren't overridden
|
|
652
|
+
expect(output).not.toContain("execution.iterationDelayMs");
|
|
653
|
+
expect(output).not.toContain("quality.requireTypecheck");
|
|
654
|
+
expect(output).not.toContain("models.fast");
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
test("handles nested object differences", async () => {
|
|
658
|
+
// Create project config with nested overrides
|
|
659
|
+
const naxDir = join(tempDir, "nax");
|
|
660
|
+
mkdirSync(naxDir, { recursive: true });
|
|
661
|
+
writeFileSync(
|
|
662
|
+
join(naxDir, "config.json"),
|
|
663
|
+
JSON.stringify({
|
|
664
|
+
routing: {
|
|
665
|
+
llm: {
|
|
666
|
+
timeoutMs: 30000,
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
}),
|
|
670
|
+
);
|
|
671
|
+
|
|
672
|
+
process.chdir(tempDir);
|
|
673
|
+
|
|
674
|
+
const config = await loadConfig();
|
|
675
|
+
await configCommand(config, { diff: true });
|
|
676
|
+
|
|
677
|
+
const output = consoleOutput.join("\n");
|
|
678
|
+
|
|
679
|
+
// Should show nested field path
|
|
680
|
+
expect(output).toContain("routing.llm.timeoutMs");
|
|
681
|
+
expect(output).toContain("30000");
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
test("handles array differences", async () => {
|
|
685
|
+
// Create project config with array overrides
|
|
686
|
+
const naxDir = join(tempDir, "nax");
|
|
687
|
+
mkdirSync(naxDir, { recursive: true });
|
|
688
|
+
writeFileSync(
|
|
689
|
+
join(naxDir, "config.json"),
|
|
690
|
+
JSON.stringify({
|
|
691
|
+
autoMode: {
|
|
692
|
+
fallbackOrder: ["codex", "claude"],
|
|
693
|
+
},
|
|
694
|
+
}),
|
|
695
|
+
);
|
|
696
|
+
|
|
697
|
+
process.chdir(tempDir);
|
|
698
|
+
|
|
699
|
+
const config = await loadConfig();
|
|
700
|
+
await configCommand(config, { diff: true });
|
|
701
|
+
|
|
702
|
+
const output = consoleOutput.join("\n");
|
|
703
|
+
|
|
704
|
+
// Should show array field
|
|
705
|
+
expect(output).toContain("autoMode.fallbackOrder");
|
|
706
|
+
expect(output).toContain("[...2]"); // Compact array format
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
test("mutually exclusive with --explain", async () => {
|
|
710
|
+
// Capture console.error
|
|
711
|
+
const consoleErrors: string[] = [];
|
|
712
|
+
const originalConsoleError = console.error;
|
|
713
|
+
console.error = (...args: unknown[]) => {
|
|
714
|
+
consoleErrors.push(args.map((a) => String(a)).join(" "));
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// Mock process.exit to prevent test exit
|
|
718
|
+
const originalExit = process.exit;
|
|
719
|
+
let exitCode: number | undefined;
|
|
720
|
+
process.exit = ((code?: number) => {
|
|
721
|
+
exitCode = code;
|
|
722
|
+
}) as typeof process.exit;
|
|
723
|
+
|
|
724
|
+
try {
|
|
725
|
+
const config = await loadConfig();
|
|
726
|
+
await configCommand(config, { explain: true, diff: true });
|
|
727
|
+
|
|
728
|
+
expect(exitCode).toBe(1);
|
|
729
|
+
expect(consoleErrors.join("\n")).toContain("--explain and --diff are mutually exclusive");
|
|
730
|
+
} finally {
|
|
731
|
+
console.error = originalConsoleError;
|
|
732
|
+
process.exit = originalExit;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
});
|