@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,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schema Definitions
|
|
3
|
+
*
|
|
4
|
+
* Runtime validation schemas for nax configuration.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
/** Zod schema for runtime validation */
|
|
10
|
+
const TokenPricingSchema = z.object({
|
|
11
|
+
inputPer1M: z.number().min(0),
|
|
12
|
+
outputPer1M: z.number().min(0),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ModelDefSchema = z.object({
|
|
16
|
+
provider: z.string().min(1, "Provider must be non-empty"),
|
|
17
|
+
model: z.string().min(1, "Model must be non-empty"),
|
|
18
|
+
pricing: TokenPricingSchema.optional(),
|
|
19
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const ModelEntrySchema = z.union([z.string().min(1, "Model identifier must be non-empty"), ModelDefSchema]);
|
|
23
|
+
|
|
24
|
+
const ModelMapSchema = z.object({
|
|
25
|
+
fast: ModelEntrySchema,
|
|
26
|
+
balanced: ModelEntrySchema,
|
|
27
|
+
powerful: ModelEntrySchema,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const ModelTierSchema = z.string().min(1, "Tier name must be non-empty");
|
|
31
|
+
|
|
32
|
+
const TierConfigSchema = z.object({
|
|
33
|
+
tier: z.string().min(1, "Tier name must be non-empty"),
|
|
34
|
+
attempts: z.number().int().min(1).max(20, { message: "attempts must be 1-20" }),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const AutoModeConfigSchema = z.object({
|
|
38
|
+
enabled: z.boolean(),
|
|
39
|
+
defaultAgent: z.string().trim().min(1, "defaultAgent must be non-empty"),
|
|
40
|
+
fallbackOrder: z.array(z.string()),
|
|
41
|
+
complexityRouting: z.object({
|
|
42
|
+
simple: ModelTierSchema,
|
|
43
|
+
medium: ModelTierSchema,
|
|
44
|
+
complex: ModelTierSchema,
|
|
45
|
+
expert: ModelTierSchema,
|
|
46
|
+
}),
|
|
47
|
+
escalation: z.object({
|
|
48
|
+
enabled: z.boolean(),
|
|
49
|
+
tierOrder: z.array(TierConfigSchema).min(1, { message: "tierOrder must have at least one tier" }),
|
|
50
|
+
escalateEntireBatch: z.boolean().optional(),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const RectificationConfigSchema = z.object({
|
|
55
|
+
enabled: z.boolean().default(true),
|
|
56
|
+
maxRetries: z.number().int().min(0).max(10).default(2),
|
|
57
|
+
fullSuiteTimeoutSeconds: z.number().int().min(10).max(600).default(120),
|
|
58
|
+
maxFailureSummaryChars: z.number().int().min(500).max(10000).default(2000),
|
|
59
|
+
abortOnIncreasingFailures: z.boolean().default(true),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const RegressionGateConfigSchema = z.object({
|
|
63
|
+
enabled: z.boolean().default(true),
|
|
64
|
+
timeoutSeconds: z.number().int().min(10).max(600).default(120),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const ExecutionConfigSchema = z.object({
|
|
68
|
+
maxIterations: z.number().int().positive({ message: "maxIterations must be > 0" }),
|
|
69
|
+
iterationDelayMs: z.number().int().nonnegative(),
|
|
70
|
+
costLimit: z.number().positive({ message: "costLimit must be > 0" }),
|
|
71
|
+
sessionTimeoutSeconds: z.number().int().positive({ message: "sessionTimeoutSeconds must be > 0" }),
|
|
72
|
+
verificationTimeoutSeconds: z.number().int().min(1).max(3600).default(300),
|
|
73
|
+
maxStoriesPerFeature: z.number().int().positive(),
|
|
74
|
+
rectification: RectificationConfigSchema,
|
|
75
|
+
regressionGate: RegressionGateConfigSchema,
|
|
76
|
+
contextProviderTokenBudget: z
|
|
77
|
+
.number()
|
|
78
|
+
.int()
|
|
79
|
+
.positive({ message: "contextProviderTokenBudget must be > 0" })
|
|
80
|
+
.default(2000),
|
|
81
|
+
lintCommand: z.string().nullable().optional(),
|
|
82
|
+
typecheckCommand: z.string().nullable().optional(),
|
|
83
|
+
dangerouslySkipPermissions: z.boolean().default(true),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const QualityConfigSchema = z.object({
|
|
87
|
+
requireTypecheck: z.boolean(),
|
|
88
|
+
requireLint: z.boolean(),
|
|
89
|
+
requireTests: z.boolean(),
|
|
90
|
+
commands: z.object({
|
|
91
|
+
typecheck: z.string().optional(),
|
|
92
|
+
lint: z.string().optional(),
|
|
93
|
+
test: z.string().optional(),
|
|
94
|
+
}),
|
|
95
|
+
forceExit: z.boolean().default(false),
|
|
96
|
+
detectOpenHandles: z.boolean().default(true),
|
|
97
|
+
detectOpenHandlesRetries: z.number().int().min(0).max(5).default(1),
|
|
98
|
+
gracePeriodMs: z.number().int().min(500).max(30000).default(5000),
|
|
99
|
+
drainTimeoutMs: z.number().int().min(0).max(10000).default(2000),
|
|
100
|
+
shell: z.string().default("/bin/sh"),
|
|
101
|
+
stripEnvVars: z.array(z.string()).default(["CLAUDECODE", "REPL_ID", "AGENT"]),
|
|
102
|
+
environmentalEscalationDivisor: z.number().min(1).max(10).default(2),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const TddConfigSchema = z.object({
|
|
106
|
+
maxRetries: z.number().int().nonnegative(),
|
|
107
|
+
autoVerifyIsolation: z.boolean(),
|
|
108
|
+
autoApproveVerifier: z.boolean(),
|
|
109
|
+
strategy: z.enum(["auto", "strict", "lite", "off"]).default("auto"),
|
|
110
|
+
sessionTiers: z
|
|
111
|
+
.object({
|
|
112
|
+
testWriter: z.string().optional(),
|
|
113
|
+
implementer: z.string().optional(),
|
|
114
|
+
verifier: z.string().optional(),
|
|
115
|
+
})
|
|
116
|
+
.optional(),
|
|
117
|
+
testWriterAllowedPaths: z.array(z.string()).optional(),
|
|
118
|
+
rollbackOnFailure: z.boolean().optional(),
|
|
119
|
+
greenfieldDetection: z.boolean().optional(),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const ConstitutionConfigSchema = z.object({
|
|
123
|
+
enabled: z.boolean(),
|
|
124
|
+
path: z.string().min(1, "constitution.path must be non-empty"),
|
|
125
|
+
maxTokens: z.number().int().positive({ message: "constitution.maxTokens must be > 0" }),
|
|
126
|
+
skipGlobal: z.boolean().optional(),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const AnalyzeConfigSchema = z.object({
|
|
130
|
+
llmEnhanced: z.boolean(),
|
|
131
|
+
model: ModelTierSchema,
|
|
132
|
+
fallbackToKeywords: z.boolean(),
|
|
133
|
+
maxCodebaseSummaryTokens: z.number().int().positive(),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const ReviewConfigSchema = z.object({
|
|
137
|
+
enabled: z.boolean(),
|
|
138
|
+
checks: z.array(z.enum(["typecheck", "lint", "test"])),
|
|
139
|
+
commands: z.object({
|
|
140
|
+
typecheck: z.string().optional(),
|
|
141
|
+
lint: z.string().optional(),
|
|
142
|
+
test: z.string().optional(),
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const PlanConfigSchema = z.object({
|
|
147
|
+
model: ModelTierSchema,
|
|
148
|
+
outputPath: z.string().min(1, "plan.outputPath must be non-empty"),
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const AcceptanceConfigSchema = z.object({
|
|
152
|
+
enabled: z.boolean(),
|
|
153
|
+
maxRetries: z.number().int().nonnegative(),
|
|
154
|
+
generateTests: z.boolean(),
|
|
155
|
+
testPath: z.string().min(1, "acceptance.testPath must be non-empty"),
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const TestCoverageConfigSchema = z.object({
|
|
159
|
+
enabled: z.boolean().default(true),
|
|
160
|
+
detail: z.enum(["names-only", "names-and-counts", "describe-blocks"]).default("names-and-counts"),
|
|
161
|
+
maxTokens: z.number().int().min(50).max(5000).default(500),
|
|
162
|
+
testDir: z.string().optional(),
|
|
163
|
+
testPattern: z.string().default("**/*.test.{ts,js,tsx,jsx}"),
|
|
164
|
+
scopeToStory: z.boolean().default(true),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const ContextAutoDetectConfigSchema = z.object({
|
|
168
|
+
enabled: z.boolean().default(true),
|
|
169
|
+
maxFiles: z.number().int().min(1).max(20).default(5),
|
|
170
|
+
traceImports: z.boolean().default(false),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const ContextConfigSchema = z.object({
|
|
174
|
+
testCoverage: TestCoverageConfigSchema,
|
|
175
|
+
autoDetect: ContextAutoDetectConfigSchema,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const AdaptiveRoutingConfigSchema = z.object({
|
|
179
|
+
minSamples: z.number().int().positive({ message: "adaptive.minSamples must be > 0" }),
|
|
180
|
+
costThreshold: z.number().min(0).max(1, { message: "adaptive.costThreshold must be 0-1" }),
|
|
181
|
+
fallbackStrategy: z.enum(["keyword", "llm", "manual"]),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const LlmRoutingConfigSchema = z.object({
|
|
185
|
+
model: z.string().optional(),
|
|
186
|
+
fallbackToKeywords: z.boolean().optional(),
|
|
187
|
+
cacheDecisions: z.boolean().optional(),
|
|
188
|
+
mode: z.enum(["one-shot", "per-story", "hybrid"]).optional(),
|
|
189
|
+
batchMode: z.boolean().optional(), // deprecated, for backward compat
|
|
190
|
+
timeoutMs: z.number().int().positive({ message: "llm.timeoutMs must be > 0" }).optional(),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const RoutingConfigSchema = z
|
|
194
|
+
.object({
|
|
195
|
+
strategy: z.enum(["keyword", "llm", "manual", "adaptive", "custom"]),
|
|
196
|
+
customStrategyPath: z.string().optional(),
|
|
197
|
+
adaptive: AdaptiveRoutingConfigSchema.optional(),
|
|
198
|
+
llm: LlmRoutingConfigSchema.optional(),
|
|
199
|
+
})
|
|
200
|
+
.refine(
|
|
201
|
+
(data) => {
|
|
202
|
+
// If strategy is "custom", customStrategyPath is required
|
|
203
|
+
if (data.strategy === "custom" && !data.customStrategyPath) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
message: "routing.customStrategyPath is required when strategy is 'custom'",
|
|
210
|
+
path: ["customStrategyPath"],
|
|
211
|
+
},
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const OptimizerConfigSchema = z.object({
|
|
215
|
+
enabled: z.boolean(),
|
|
216
|
+
strategy: z.enum(["rule-based", "llm", "noop"]).optional(),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const PluginConfigEntrySchema = z.object({
|
|
220
|
+
module: z.string().min(1, "plugin.module must be non-empty"),
|
|
221
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const HooksConfigSchema = z.object({
|
|
225
|
+
skipGlobal: z.boolean().optional(),
|
|
226
|
+
hooks: z.record(z.string(), z.unknown()),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const InteractionConfigSchema = z.object({
|
|
230
|
+
plugin: z.string().default("cli"),
|
|
231
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
232
|
+
defaults: z.object({
|
|
233
|
+
timeout: z.number().int().min(1000).max(3600000).default(600000),
|
|
234
|
+
fallback: z.enum(["continue", "skip", "escalate", "abort"]).default("escalate"),
|
|
235
|
+
}),
|
|
236
|
+
triggers: z
|
|
237
|
+
.record(
|
|
238
|
+
z.string(),
|
|
239
|
+
z.union([
|
|
240
|
+
z.boolean(),
|
|
241
|
+
z.object({
|
|
242
|
+
enabled: z.boolean(),
|
|
243
|
+
fallback: z.string().optional(),
|
|
244
|
+
timeout: z.number().optional(),
|
|
245
|
+
}),
|
|
246
|
+
]),
|
|
247
|
+
)
|
|
248
|
+
.default({}),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const StorySizeGateConfigSchema = z.object({
|
|
252
|
+
enabled: z.boolean().default(true),
|
|
253
|
+
maxAcCount: z.number().int().min(1).max(50).default(6),
|
|
254
|
+
maxDescriptionLength: z.number().int().min(100).max(10000).default(2000),
|
|
255
|
+
maxBulletPoints: z.number().int().min(1).max(100).default(8),
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const PrecheckConfigSchema = z.object({
|
|
259
|
+
storySizeGate: StorySizeGateConfigSchema,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
export const NaxConfigSchema = z
|
|
263
|
+
.object({
|
|
264
|
+
version: z.number(),
|
|
265
|
+
models: ModelMapSchema,
|
|
266
|
+
autoMode: AutoModeConfigSchema,
|
|
267
|
+
routing: RoutingConfigSchema,
|
|
268
|
+
execution: ExecutionConfigSchema,
|
|
269
|
+
quality: QualityConfigSchema,
|
|
270
|
+
tdd: TddConfigSchema,
|
|
271
|
+
constitution: ConstitutionConfigSchema,
|
|
272
|
+
analyze: AnalyzeConfigSchema,
|
|
273
|
+
review: ReviewConfigSchema,
|
|
274
|
+
plan: PlanConfigSchema,
|
|
275
|
+
acceptance: AcceptanceConfigSchema,
|
|
276
|
+
context: ContextConfigSchema,
|
|
277
|
+
optimizer: OptimizerConfigSchema.optional(),
|
|
278
|
+
plugins: z.array(PluginConfigEntrySchema).optional(),
|
|
279
|
+
hooks: HooksConfigSchema.optional(),
|
|
280
|
+
interaction: InteractionConfigSchema.optional(),
|
|
281
|
+
precheck: PrecheckConfigSchema.optional(),
|
|
282
|
+
})
|
|
283
|
+
.refine((data) => data.version === 1, {
|
|
284
|
+
message: "Invalid version: expected 1",
|
|
285
|
+
path: ["version"],
|
|
286
|
+
});
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* All TypeScript interfaces, type aliases, and utility functions
|
|
5
|
+
* for the nax configuration system.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type Complexity = "simple" | "medium" | "complex" | "expert";
|
|
9
|
+
export type TestStrategy = "test-after" | "three-session-tdd" | "three-session-tdd-lite";
|
|
10
|
+
export type TddStrategy = "auto" | "strict" | "lite" | "off";
|
|
11
|
+
|
|
12
|
+
export interface EscalationEntry {
|
|
13
|
+
from: string;
|
|
14
|
+
to: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Model tier names — extensible (TYPE-3 fix: preserve autocomplete for known tiers) */
|
|
18
|
+
export type ModelTier = "fast" | "balanced" | "powerful" | (string & {});
|
|
19
|
+
|
|
20
|
+
export interface TokenPricing {
|
|
21
|
+
inputPer1M: number;
|
|
22
|
+
outputPer1M: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ModelDef {
|
|
26
|
+
provider: string;
|
|
27
|
+
model: string;
|
|
28
|
+
pricing?: TokenPricing;
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type ModelEntry = ModelDef | string;
|
|
33
|
+
export type ModelMap = Record<ModelTier, ModelEntry>;
|
|
34
|
+
|
|
35
|
+
export interface TierConfig {
|
|
36
|
+
tier: string;
|
|
37
|
+
attempts: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Auto mode configuration */
|
|
41
|
+
export interface AutoModeConfig {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
/** Default agent to use */
|
|
44
|
+
defaultAgent: string;
|
|
45
|
+
/** Fallback order when agent is rate-limited */
|
|
46
|
+
fallbackOrder: string[];
|
|
47
|
+
/** Model tier per complexity */
|
|
48
|
+
complexityRouting: Record<Complexity, ModelTier>;
|
|
49
|
+
/** Escalation config */
|
|
50
|
+
escalation: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
/** Ordered tier escalation with per-tier attempt budgets */
|
|
53
|
+
tierOrder: TierConfig[];
|
|
54
|
+
/** When a batch fails, escalate all stories in the batch (default: true) */
|
|
55
|
+
escalateEntireBatch?: boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Rectification config (v0.11) */
|
|
60
|
+
export interface RectificationConfig {
|
|
61
|
+
/** Enable rectification loop (retry failed tests with failure context) */
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
/** Max retry attempts per story (default: 2) */
|
|
64
|
+
maxRetries: number;
|
|
65
|
+
/** Timeout for full test suite run in seconds (default: 120) */
|
|
66
|
+
fullSuiteTimeoutSeconds: number;
|
|
67
|
+
/** Max characters in failure summary sent to agent (default: 2000) */
|
|
68
|
+
maxFailureSummaryChars: number;
|
|
69
|
+
/** Abort rectification if failure count increases (default: true) */
|
|
70
|
+
abortOnIncreasingFailures: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Regression gate config (BUG-009) */
|
|
74
|
+
export interface RegressionGateConfig {
|
|
75
|
+
/** Enable full-suite regression gate after scoped verification (default: true) */
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
/** Timeout for full-suite regression run in seconds (default: 120) */
|
|
78
|
+
timeoutSeconds: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Execution limits */
|
|
82
|
+
export interface ExecutionConfig {
|
|
83
|
+
/** Max iterations per feature run (auto-calculated from tierOrder sum if not set) */
|
|
84
|
+
maxIterations: number;
|
|
85
|
+
/** Delay between iterations (ms) */
|
|
86
|
+
iterationDelayMs: number;
|
|
87
|
+
/** Max cost (USD) before pausing */
|
|
88
|
+
costLimit: number;
|
|
89
|
+
/** Timeout per agent coding session (seconds) */
|
|
90
|
+
sessionTimeoutSeconds: number;
|
|
91
|
+
/** Verification subprocess timeout in seconds (ADR-003 Decision 4) */
|
|
92
|
+
verificationTimeoutSeconds: number;
|
|
93
|
+
/** Max stories per feature (prevents memory exhaustion) */
|
|
94
|
+
maxStoriesPerFeature: number;
|
|
95
|
+
/** Rectification loop settings (v0.11) */
|
|
96
|
+
rectification: RectificationConfig;
|
|
97
|
+
/** Regression gate settings (BUG-009) */
|
|
98
|
+
regressionGate: RegressionGateConfig;
|
|
99
|
+
/** Token budget for plugin context providers (default: 2000) */
|
|
100
|
+
contextProviderTokenBudget: number;
|
|
101
|
+
/** Test command override (null = disabled, undefined = auto-detect from package.json) */
|
|
102
|
+
testCommand?: string | null;
|
|
103
|
+
/** Lint command override (null = disabled, undefined = auto-detect from package.json) */
|
|
104
|
+
lintCommand?: string | null;
|
|
105
|
+
/** Typecheck command override (null = disabled, undefined = auto-detect from package.json) */
|
|
106
|
+
typecheckCommand?: string | null;
|
|
107
|
+
/** Use --dangerously-skip-permissions flag for agent (default: true for backward compat, SEC-1 fix) */
|
|
108
|
+
dangerouslySkipPermissions?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Quality gate config */
|
|
112
|
+
export interface QualityConfig {
|
|
113
|
+
/** Require typecheck to pass */
|
|
114
|
+
requireTypecheck: boolean;
|
|
115
|
+
/** Require lint to pass */
|
|
116
|
+
requireLint: boolean;
|
|
117
|
+
/** Require tests to pass */
|
|
118
|
+
requireTests: boolean;
|
|
119
|
+
/** Custom quality commands */
|
|
120
|
+
commands: {
|
|
121
|
+
typecheck?: string;
|
|
122
|
+
lint?: string;
|
|
123
|
+
test?: string;
|
|
124
|
+
};
|
|
125
|
+
/** Append --forceExit to test command to prevent open handle hangs (default: false) */
|
|
126
|
+
forceExit: boolean;
|
|
127
|
+
/** Append --detectOpenHandles on timeout retry to diagnose hangs (default: true) */
|
|
128
|
+
detectOpenHandles: boolean;
|
|
129
|
+
/** Max retries with --detectOpenHandles before falling back to --forceExit (default: 1) */
|
|
130
|
+
detectOpenHandlesRetries: number;
|
|
131
|
+
/** Grace period in ms after SIGTERM before sending SIGKILL (default: 5000) */
|
|
132
|
+
gracePeriodMs: number;
|
|
133
|
+
/** Deadline in ms to drain stdout/stderr after killing process (Bun stream workaround, default: 2000) */
|
|
134
|
+
drainTimeoutMs: number;
|
|
135
|
+
/** Shell to use for running verification commands (default: /bin/sh) */
|
|
136
|
+
shell: string;
|
|
137
|
+
/** Environment variables to strip during verification (prevents AI-optimized output) */
|
|
138
|
+
stripEnvVars: string[];
|
|
139
|
+
/** Divisor for environmental failure early escalation (default: 2 = half the tier budget) */
|
|
140
|
+
environmentalEscalationDivisor: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** TDD config */
|
|
144
|
+
export interface TddConfig {
|
|
145
|
+
/** Max retries for each session before escalating */
|
|
146
|
+
maxRetries: number;
|
|
147
|
+
/** Auto-verify isolation between sessions */
|
|
148
|
+
autoVerifyIsolation: boolean;
|
|
149
|
+
/** TDD strategy override (default: 'auto') */
|
|
150
|
+
strategy: TddStrategy;
|
|
151
|
+
/** Session 3 verifier: auto-approve legitimate fixes */
|
|
152
|
+
autoApproveVerifier: boolean;
|
|
153
|
+
/** Per-session model tier overrides. Defaults: test-writer=balanced, implementer=story tier, verifier=fast */
|
|
154
|
+
sessionTiers?: {
|
|
155
|
+
/** Model tier for test-writer session (default: "balanced") */
|
|
156
|
+
testWriter?: ModelTier;
|
|
157
|
+
/** Model tier for implementer session (default: uses story's routed tier) */
|
|
158
|
+
implementer?: ModelTier;
|
|
159
|
+
/** Model tier for verifier session (default: "fast") */
|
|
160
|
+
verifier?: ModelTier;
|
|
161
|
+
};
|
|
162
|
+
/** Glob patterns for files test-writer can modify (soft violations, logged as warnings) */
|
|
163
|
+
testWriterAllowedPaths?: string[];
|
|
164
|
+
/** Rollback git changes when TDD fails (default: true). Prevents partial commits when TDD fails. */
|
|
165
|
+
rollbackOnFailure?: boolean;
|
|
166
|
+
/** Enable greenfield detection to force test-after on projects with no test files (default: true, BUG-010) */
|
|
167
|
+
greenfieldDetection?: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Constitution config */
|
|
171
|
+
export interface ConstitutionConfig {
|
|
172
|
+
/** Enable constitution loading and injection */
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
/** Path to constitution file relative to nax/ directory */
|
|
175
|
+
path: string;
|
|
176
|
+
/** Maximum tokens allowed for constitution content */
|
|
177
|
+
maxTokens: number;
|
|
178
|
+
/** Skip loading global constitution (default: false) */
|
|
179
|
+
skipGlobal?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Analyze config */
|
|
183
|
+
export interface AnalyzeConfig {
|
|
184
|
+
/** Enable LLM-enhanced analysis */
|
|
185
|
+
llmEnhanced: boolean;
|
|
186
|
+
/** Model tier for decompose+classify (default: balanced) */
|
|
187
|
+
model: ModelTier;
|
|
188
|
+
/** Fall back to keyword matching on LLM failure */
|
|
189
|
+
fallbackToKeywords: boolean;
|
|
190
|
+
/** Max tokens for codebase summary */
|
|
191
|
+
maxCodebaseSummaryTokens: number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Review config */
|
|
195
|
+
export interface ReviewConfig {
|
|
196
|
+
/** Enable review phase */
|
|
197
|
+
enabled: boolean;
|
|
198
|
+
/** List of checks to run */
|
|
199
|
+
checks: Array<"typecheck" | "lint" | "test">;
|
|
200
|
+
/** Custom commands per check */
|
|
201
|
+
commands: {
|
|
202
|
+
typecheck?: string;
|
|
203
|
+
lint?: string;
|
|
204
|
+
test?: string;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Plan config */
|
|
209
|
+
export interface PlanConfig {
|
|
210
|
+
/** Model tier for planning (default: balanced) */
|
|
211
|
+
model: ModelTier;
|
|
212
|
+
/** Output path for generated spec (relative to nax/ directory) */
|
|
213
|
+
outputPath: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Acceptance validation config */
|
|
217
|
+
export interface AcceptanceConfig {
|
|
218
|
+
/** Enable acceptance test generation and validation */
|
|
219
|
+
enabled: boolean;
|
|
220
|
+
/** Maximum retry loops for fix stories (default: 2) */
|
|
221
|
+
maxRetries: number;
|
|
222
|
+
/** Generate acceptance tests during analyze (default: true) */
|
|
223
|
+
generateTests: boolean;
|
|
224
|
+
/** Path to acceptance test file (relative to feature directory) */
|
|
225
|
+
testPath: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Optimizer config (v0.10) */
|
|
229
|
+
export interface OptimizerConfig {
|
|
230
|
+
/** Enable prompt optimizer */
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
/** Optimization strategy: "rule-based" | "llm" | "noop" */
|
|
233
|
+
strategy?: "rule-based" | "llm" | "noop";
|
|
234
|
+
/** Strategy-specific configurations */
|
|
235
|
+
strategies?: {
|
|
236
|
+
"rule-based"?: {
|
|
237
|
+
stripWhitespace?: boolean;
|
|
238
|
+
compactCriteria?: boolean;
|
|
239
|
+
deduplicateContext?: boolean;
|
|
240
|
+
maxPromptTokens?: number;
|
|
241
|
+
};
|
|
242
|
+
llm?: {
|
|
243
|
+
model?: ModelTier;
|
|
244
|
+
targetReduction?: number;
|
|
245
|
+
minPromptTokens?: number;
|
|
246
|
+
};
|
|
247
|
+
custom?: {
|
|
248
|
+
module?: string;
|
|
249
|
+
options?: Record<string, unknown>;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface PluginConfigEntry {
|
|
255
|
+
module: string;
|
|
256
|
+
config?: Record<string, unknown>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface HooksConfig {
|
|
260
|
+
skipGlobal?: boolean;
|
|
261
|
+
hooks: Record<string, unknown>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Interaction config (v0.15.0) */
|
|
265
|
+
export interface InteractionConfig {
|
|
266
|
+
/** Plugin to use for interactions (default: "cli") */
|
|
267
|
+
plugin: string;
|
|
268
|
+
/** Plugin-specific configuration */
|
|
269
|
+
config?: Record<string, unknown>;
|
|
270
|
+
/** Default settings */
|
|
271
|
+
defaults: {
|
|
272
|
+
/** Default timeout in milliseconds (default: 600000 = 10 minutes) */
|
|
273
|
+
timeout: number;
|
|
274
|
+
/** Default fallback behavior (default: "escalate") */
|
|
275
|
+
fallback: "continue" | "skip" | "escalate" | "abort";
|
|
276
|
+
};
|
|
277
|
+
/** Enable/disable built-in triggers */
|
|
278
|
+
triggers: Partial<Record<string, boolean | { enabled: boolean; fallback?: string; timeout?: number }>>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Test coverage context config */
|
|
282
|
+
export interface TestCoverageConfig {
|
|
283
|
+
/** Enable test coverage context injection (default: true) */
|
|
284
|
+
enabled: boolean;
|
|
285
|
+
/** Detail level for test summary */
|
|
286
|
+
detail: "names-only" | "names-and-counts" | "describe-blocks";
|
|
287
|
+
/** Max tokens for the summary (default: 500) */
|
|
288
|
+
maxTokens: number;
|
|
289
|
+
/** Test directory relative to workdir (default: auto-detect) */
|
|
290
|
+
testDir?: string;
|
|
291
|
+
/** Glob pattern for test files */
|
|
292
|
+
testPattern: string;
|
|
293
|
+
/** Scope test coverage to story-relevant files only (default: true) */
|
|
294
|
+
scopeToStory: boolean;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface ContextAutoDetectConfig {
|
|
298
|
+
enabled: boolean;
|
|
299
|
+
maxFiles: number;
|
|
300
|
+
traceImports: boolean;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ContextConfig {
|
|
304
|
+
testCoverage: TestCoverageConfig;
|
|
305
|
+
autoDetect: ContextAutoDetectConfig;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Story size gate thresholds (v0.16.0) */
|
|
309
|
+
export interface StorySizeGateConfig {
|
|
310
|
+
/** Enable story size gate (default: true) */
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
/** Max acceptance criteria count before flagging (default: 6) */
|
|
313
|
+
maxAcCount: number;
|
|
314
|
+
/** Max description character length before flagging (default: 2000) */
|
|
315
|
+
maxDescriptionLength: number;
|
|
316
|
+
/** Max bullet point count before flagging (default: 8) */
|
|
317
|
+
maxBulletPoints: number;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Precheck configuration (v0.16.0) */
|
|
321
|
+
export interface PrecheckConfig {
|
|
322
|
+
/** Story size gate settings */
|
|
323
|
+
storySizeGate: StorySizeGateConfig;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export type RoutingStrategyName = "keyword" | "llm" | "manual" | "adaptive" | "custom";
|
|
327
|
+
|
|
328
|
+
export interface AdaptiveRoutingConfig {
|
|
329
|
+
minSamples: number;
|
|
330
|
+
costThreshold: number;
|
|
331
|
+
fallbackStrategy: "keyword" | "llm" | "manual";
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export type LlmRoutingMode = "one-shot" | "per-story" | "hybrid";
|
|
335
|
+
|
|
336
|
+
/** LLM routing config */
|
|
337
|
+
export interface LlmRoutingConfig {
|
|
338
|
+
/** Model tier for routing call (default: "fast") */
|
|
339
|
+
model?: string;
|
|
340
|
+
/** Fall back to keyword strategy on LLM failure (default: true) */
|
|
341
|
+
fallbackToKeywords?: boolean;
|
|
342
|
+
/** Max input tokens for story context (default: 2000) */
|
|
343
|
+
/** Cache routing decisions per story ID (default: true) */
|
|
344
|
+
cacheDecisions?: boolean;
|
|
345
|
+
/** Routing mode (default: "hybrid")
|
|
346
|
+
* - "one-shot": batch-route ALL pending stories once at run start, use keyword fallback on cache miss
|
|
347
|
+
* - "per-story": route each story individually just before execution (max LLM calls = N stories)
|
|
348
|
+
* - "hybrid": batch-route upfront, re-route individually on retry/failure (best quality + cost balance)
|
|
349
|
+
*/
|
|
350
|
+
mode?: LlmRoutingMode;
|
|
351
|
+
/** @deprecated Use mode instead. Will be removed in v1.0 */
|
|
352
|
+
batchMode?: boolean;
|
|
353
|
+
/** Timeout for LLM call in milliseconds (default: 15000) */
|
|
354
|
+
timeoutMs?: number;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Routing config */
|
|
358
|
+
export interface RoutingConfig {
|
|
359
|
+
/** Strategy to use (default: "keyword") */
|
|
360
|
+
strategy: RoutingStrategyName;
|
|
361
|
+
/** Path to custom strategy file (required if strategy = "custom") */
|
|
362
|
+
customStrategyPath?: string;
|
|
363
|
+
/** Adaptive routing settings (used when strategy = "adaptive") */
|
|
364
|
+
adaptive?: AdaptiveRoutingConfig;
|
|
365
|
+
/** LLM routing settings (used when strategy = "llm") */
|
|
366
|
+
llm?: LlmRoutingConfig;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Full nax configuration */
|
|
370
|
+
export interface NaxConfig {
|
|
371
|
+
/** Schema version */
|
|
372
|
+
version: 1;
|
|
373
|
+
/** Model mapping — abstract tiers to actual model identifiers */
|
|
374
|
+
models: ModelMap;
|
|
375
|
+
/** Auto mode / routing config */
|
|
376
|
+
autoMode: AutoModeConfig;
|
|
377
|
+
/** Routing strategy config */
|
|
378
|
+
routing: RoutingConfig;
|
|
379
|
+
/** Execution limits */
|
|
380
|
+
execution: ExecutionConfig;
|
|
381
|
+
/** Quality gates */
|
|
382
|
+
quality: QualityConfig;
|
|
383
|
+
/** TDD settings */
|
|
384
|
+
tdd: TddConfig;
|
|
385
|
+
/** Constitution settings */
|
|
386
|
+
constitution: ConstitutionConfig;
|
|
387
|
+
/** Analyze settings */
|
|
388
|
+
analyze: AnalyzeConfig;
|
|
389
|
+
/** Review settings */
|
|
390
|
+
review: ReviewConfig;
|
|
391
|
+
/** Plan settings */
|
|
392
|
+
plan: PlanConfig;
|
|
393
|
+
/** Acceptance validation settings */
|
|
394
|
+
acceptance: AcceptanceConfig;
|
|
395
|
+
/** Context injection settings */
|
|
396
|
+
context: ContextConfig;
|
|
397
|
+
/** Optimizer settings (v0.10) */
|
|
398
|
+
optimizer?: OptimizerConfig;
|
|
399
|
+
/** Plugin configurations (v0.10) */
|
|
400
|
+
plugins?: PluginConfigEntry[];
|
|
401
|
+
/** Hooks configuration (v0.10) */
|
|
402
|
+
hooks?: HooksConfig;
|
|
403
|
+
/** Interaction settings (v0.15.0) */
|
|
404
|
+
interaction?: InteractionConfig;
|
|
405
|
+
/** Precheck settings (v0.16.0) */
|
|
406
|
+
precheck?: PrecheckConfig;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Resolve a ModelEntry (string shorthand or full object) into a ModelDef */
|
|
410
|
+
export function resolveModel(entry: ModelEntry): ModelDef {
|
|
411
|
+
if (typeof entry === "string") {
|
|
412
|
+
// Infer provider from model name
|
|
413
|
+
const provider = entry.startsWith("claude")
|
|
414
|
+
? "anthropic"
|
|
415
|
+
: entry.startsWith("gpt") || entry.startsWith("o1") || entry.startsWith("o3")
|
|
416
|
+
? "openai"
|
|
417
|
+
: entry.startsWith("gemini")
|
|
418
|
+
? "google"
|
|
419
|
+
: "unknown";
|
|
420
|
+
return { provider, model: entry };
|
|
421
|
+
}
|
|
422
|
+
return entry;
|
|
423
|
+
}
|