@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,817 @@
|
|
|
1
|
+
# nax v0.6 Post-Implementation Code Review
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-02-17
|
|
4
|
+
**Reviewer:** Claude Code (Sonnet 4.5)
|
|
5
|
+
**Scope:** TUI feature implementation (Phases 1-5)
|
|
6
|
+
**Grade:** A- (89/100)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
The v0.6 TUI implementation is **production-ready with minor improvements recommended**. The code demonstrates excellent architecture, strong type safety, comprehensive test coverage (533 passing tests), and proper separation of concerns. The reactive component design is clean, event-driven integration is well-structured, and the codebase follows React/Ink best practices.
|
|
13
|
+
|
|
14
|
+
**Key Strengths:**
|
|
15
|
+
- ✅ **Excellent event-driven architecture** — PipelineEventEmitter cleanly decouples TUI from orchestration
|
|
16
|
+
- ✅ **Comprehensive test coverage** — 533 tests passing across TUI, events, layout, controls
|
|
17
|
+
- ✅ **Strong type safety** — No TypeScript errors, discriminated unions, proper generics
|
|
18
|
+
- ✅ **Clean React patterns** — Proper hook usage, cleanup functions, no stale closures
|
|
19
|
+
- ✅ **Responsive design** — Three breakpoints with graceful degradation
|
|
20
|
+
- ✅ **Memory-safe** — Event listener cleanup, bounded buffers, timer cleanup
|
|
21
|
+
|
|
22
|
+
**Areas for Improvement:**
|
|
23
|
+
- ⚠️ **node-pty not yet wired to TUI** — `usePty` hook and `runInteractive` exist but aren't integrated
|
|
24
|
+
- ⚠️ **Cost tracking incomplete** — Story-level costs not yet populated in TUI state
|
|
25
|
+
- ⚠️ **Missing JSDoc for some hooks** — `usePipelineEvents` lacks usage examples
|
|
26
|
+
- ⚠️ **No loading states** — Agent panel shows "Waiting for agent..." but no spinner/progress
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Grading Rubric
|
|
31
|
+
|
|
32
|
+
| Category | Weight | Score | Grade |
|
|
33
|
+
|:---------|:-------|:------|:------|
|
|
34
|
+
| **Security** | 20% | 20/20 | A+ |
|
|
35
|
+
| **Reliability** | 20% | 18/20 | A |
|
|
36
|
+
| **API Design** | 20% | 18/20 | A |
|
|
37
|
+
| **Code Quality** | 20% | 18/20 | A |
|
|
38
|
+
| **Best Practices** | 20% | 15/20 | B+ |
|
|
39
|
+
| **TOTAL** | 100% | **89/100** | **A-** |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Detailed Findings
|
|
44
|
+
|
|
45
|
+
### Security (20/20 — A+)
|
|
46
|
+
|
|
47
|
+
**Strengths:**
|
|
48
|
+
- ✅ **No hardcoded secrets** — All configuration loaded from files, no inline API keys
|
|
49
|
+
- ✅ **Input validation** — Queue commands validated via TypeScript discriminated unions
|
|
50
|
+
- ✅ **No XSS vectors** — Ink components escape all user input by default
|
|
51
|
+
- ✅ **No prototype pollution** — Immutable patterns throughout, no `Object.assign` with user data
|
|
52
|
+
- ✅ **No command injection** — Queue commands are structured objects, not shell strings
|
|
53
|
+
- ✅ **Safe terminal operations** — ANSI escape codes handled by Ink, no manual parsing
|
|
54
|
+
- ✅ **Event listener cleanup** — All `useEffect` hooks properly clean up listeners
|
|
55
|
+
|
|
56
|
+
**No findings.**
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Reliability (18/20 — A)
|
|
61
|
+
|
|
62
|
+
**Strengths:**
|
|
63
|
+
- ✅ **Comprehensive error handling** — All async operations have try/catch or .catch()
|
|
64
|
+
- ✅ **Memory leak prevention** — Event listeners removed, timers cleared, bounded buffers
|
|
65
|
+
- ✅ **Graceful degradation** — TUI falls back to headless mode on errors
|
|
66
|
+
- ✅ **No infinite loops** — All `useEffect` dependencies correct, no state feedback loops
|
|
67
|
+
- ✅ **Terminal resize handling** — SIGWINCH listeners properly registered and cleaned up
|
|
68
|
+
|
|
69
|
+
**Issues:**
|
|
70
|
+
|
|
71
|
+
#### MEM-1: PTY buffer lacks maximum line length limit (MEDIUM)
|
|
72
|
+
**File:** `src/tui/hooks/usePty.ts:125-139`
|
|
73
|
+
|
|
74
|
+
**Issue:**
|
|
75
|
+
The PTY output buffer limits total lines (`MAX_PTY_BUFFER_LINES = 500`) but doesn't limit **individual line length**. A malicious or buggy agent could emit a single 100MB line, bypassing the buffer limit and causing memory exhaustion.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// CURRENT: No line length limit
|
|
79
|
+
ptyProc.onData((data) => {
|
|
80
|
+
const lines = (currentLine + data).split("\n");
|
|
81
|
+
currentLine = lines.pop() || ""; // ⚠️ currentLine can grow unbounded
|
|
82
|
+
|
|
83
|
+
if (lines.length > 0) {
|
|
84
|
+
setState((prev) => {
|
|
85
|
+
const newLines = [...prev.outputLines, ...lines];
|
|
86
|
+
const trimmed = newLines.length > MAX_PTY_BUFFER_LINES
|
|
87
|
+
? newLines.slice(-MAX_PTY_BUFFER_LINES)
|
|
88
|
+
: newLines;
|
|
89
|
+
return { ...prev, outputLines: trimmed };
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Impact:**
|
|
96
|
+
- **Likelihood:** Low (requires malicious agent or bug)
|
|
97
|
+
- **Severity:** Medium (memory exhaustion, TUI crash)
|
|
98
|
+
|
|
99
|
+
**Fix:**
|
|
100
|
+
```typescript
|
|
101
|
+
const MAX_LINE_LENGTH = 10_000; // 10k chars per line
|
|
102
|
+
|
|
103
|
+
ptyProc.onData((data) => {
|
|
104
|
+
const lines = (currentLine + data).split("\n");
|
|
105
|
+
currentLine = lines.pop() || "";
|
|
106
|
+
|
|
107
|
+
// Truncate incomplete line if too long
|
|
108
|
+
if (currentLine.length > MAX_LINE_LENGTH) {
|
|
109
|
+
currentLine = currentLine.slice(-MAX_LINE_LENGTH);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (lines.length > 0) {
|
|
113
|
+
// Truncate each complete line
|
|
114
|
+
const truncatedLines = lines.map((line) =>
|
|
115
|
+
line.length > MAX_LINE_LENGTH
|
|
116
|
+
? line.slice(0, MAX_LINE_LENGTH) + "…"
|
|
117
|
+
: line
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
setState((prev) => {
|
|
121
|
+
const newLines = [...prev.outputLines, ...truncatedLines];
|
|
122
|
+
const trimmed = newLines.length > MAX_PTY_BUFFER_LINES
|
|
123
|
+
? newLines.slice(-MAX_PTY_BUFFER_LINES)
|
|
124
|
+
: newLines;
|
|
125
|
+
return { ...prev, outputLines: trimmed };
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
#### BUG-1: `usePipelineEvents` missing cost accumulation from story results (MEDIUM)
|
|
134
|
+
**File:** `src/tui/hooks/usePipelineEvents.ts:84-110`
|
|
135
|
+
|
|
136
|
+
**Issue:**
|
|
137
|
+
The `story:complete` event handler marks stories as complete but **doesn't extract and accumulate story costs**. Story-level costs are not populated in the TUI state, so `CostOverlay` always shows $0.0000 for individual stories (only `totalCost` from `run:complete` is displayed).
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// CURRENT: Cost not extracted from story result
|
|
141
|
+
const onStoryComplete = (story: UserStory, result: { action: string }) => {
|
|
142
|
+
setState((prev) => {
|
|
143
|
+
const newStories = prev.stories.map((s) => {
|
|
144
|
+
if (s.story.id === story.id) {
|
|
145
|
+
let status: StoryDisplayState["status"] = "pending";
|
|
146
|
+
if (result.action === "continue") {
|
|
147
|
+
status = "passed";
|
|
148
|
+
} else if (result.action === "fail") {
|
|
149
|
+
status = "failed";
|
|
150
|
+
} else if (result.action === "skip") {
|
|
151
|
+
status = "skipped";
|
|
152
|
+
} else if (result.action === "pause") {
|
|
153
|
+
status = "paused";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { ...s, status }; // ⚠️ Cost not updated here
|
|
157
|
+
}
|
|
158
|
+
return s;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
...prev,
|
|
163
|
+
stories: newStories,
|
|
164
|
+
currentStory: undefined,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Impact:**
|
|
171
|
+
- **Likelihood:** High (affects all runs)
|
|
172
|
+
- **Severity:** Low (cosmetic — cost overlay shows correct total but not per-story breakdown)
|
|
173
|
+
|
|
174
|
+
**Fix:**
|
|
175
|
+
Option 1: Add `cost` field to `StageResult` type and populate from pipeline.
|
|
176
|
+
Option 2: Emit separate `story:cost` event with cost data.
|
|
177
|
+
Option 3: Extract cost from story metadata if pipeline updates it.
|
|
178
|
+
|
|
179
|
+
**Recommendation:** Add `cost?: number` to `StageResult` in `src/pipeline/types.ts` and update handler:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Updated StageResult type
|
|
183
|
+
export type StageResult =
|
|
184
|
+
| { action: "continue"; cost?: number }
|
|
185
|
+
| { action: "fail"; reason: string; cost?: number }
|
|
186
|
+
| { action: "skip"; reason: string; cost?: number }
|
|
187
|
+
| { action: "escalate"; cost?: number }
|
|
188
|
+
| { action: "pause"; reason: string; cost?: number };
|
|
189
|
+
|
|
190
|
+
// Updated handler
|
|
191
|
+
const onStoryComplete = (story: UserStory, result: StageResult) => {
|
|
192
|
+
setState((prev) => {
|
|
193
|
+
const newStories = prev.stories.map((s) => {
|
|
194
|
+
if (s.story.id === story.id) {
|
|
195
|
+
let status: StoryDisplayState["status"] = "pending";
|
|
196
|
+
if (result.action === "continue") status = "passed";
|
|
197
|
+
else if (result.action === "fail") status = "failed";
|
|
198
|
+
else if (result.action === "skip") status = "skipped";
|
|
199
|
+
else if (result.action === "pause") status = "paused";
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
...s,
|
|
203
|
+
status,
|
|
204
|
+
cost: (s.cost || 0) + (result.cost || 0), // ✅ Accumulate cost
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return s;
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
...prev,
|
|
212
|
+
stories: newStories,
|
|
213
|
+
currentStory: undefined,
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### API Design (18/20 — A)
|
|
222
|
+
|
|
223
|
+
**Strengths:**
|
|
224
|
+
- ✅ **Clean event interface** — `PipelineEvents` maps events to typed handlers
|
|
225
|
+
- ✅ **Discriminated unions** — `KeyboardAction` uses `type` discriminator for type safety
|
|
226
|
+
- ✅ **Composable hooks** — `useLayout`, `useKeyboard`, `usePty`, `usePipelineEvents` are independent
|
|
227
|
+
- ✅ **Agent-agnostic PTY interface** — `PtyHandle` works with any agent, not just Claude Code
|
|
228
|
+
- ✅ **Layered architecture** — TUI components don't import from `src/pipeline/`, only types
|
|
229
|
+
|
|
230
|
+
**Issues:**
|
|
231
|
+
|
|
232
|
+
#### TYPE-1: `PtyHandle` defined in two places with slight differences (LOW)
|
|
233
|
+
**Files:**
|
|
234
|
+
- `src/tui/hooks/usePty.ts:15-24` (TUI version)
|
|
235
|
+
- `src/agents/types.ts:257-266` (Agent version)
|
|
236
|
+
|
|
237
|
+
**Issue:**
|
|
238
|
+
`PtyHandle` is defined identically in both files, but changes to one won't propagate to the other. This violates DRY and creates maintenance risk.
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
// src/tui/hooks/usePty.ts
|
|
242
|
+
export interface PtyHandle {
|
|
243
|
+
write(data: string): void;
|
|
244
|
+
resize(cols: number, rows: number): void;
|
|
245
|
+
kill(): void;
|
|
246
|
+
pid: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/agents/types.ts
|
|
250
|
+
export interface PtyHandle {
|
|
251
|
+
write(data: string): void;
|
|
252
|
+
resize(cols: number, rows: number): void;
|
|
253
|
+
kill(): void;
|
|
254
|
+
pid: number;
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Impact:**
|
|
259
|
+
- **Likelihood:** Medium (interface may evolve)
|
|
260
|
+
- **Severity:** Low (only creates confusion if they drift)
|
|
261
|
+
|
|
262
|
+
**Fix:**
|
|
263
|
+
Export `PtyHandle` from `src/agents/types.ts` and import in `src/tui/hooks/usePty.ts`:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// src/tui/hooks/usePty.ts
|
|
267
|
+
import type { PtyHandle } from "../../agents/types"; // ✅ Single source of truth
|
|
268
|
+
|
|
269
|
+
// Remove duplicate interface definition
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
#### ENH-1: Queue command type is not a discriminated union (LOW)
|
|
275
|
+
**File:** `src/queue/types.ts` (inferred from usage in `src/utils/queue-writer.ts:8`)
|
|
276
|
+
|
|
277
|
+
**Issue:**
|
|
278
|
+
`QueueCommand` is likely defined as:
|
|
279
|
+
```typescript
|
|
280
|
+
type QueueCommand =
|
|
281
|
+
| { type: "PAUSE" }
|
|
282
|
+
| { type: "ABORT" }
|
|
283
|
+
| { type: "SKIP"; storyId: string };
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
This is technically a discriminated union, but `writeQueueCommand` uses a `switch` with a `default` case that can never execute (TypeScript should catch all cases). The `default` case suggests defensive programming but is unnecessary with discriminated unions.
|
|
287
|
+
|
|
288
|
+
**Current:**
|
|
289
|
+
```typescript
|
|
290
|
+
switch (command.type) {
|
|
291
|
+
case "PAUSE":
|
|
292
|
+
commandLine = "PAUSE";
|
|
293
|
+
break;
|
|
294
|
+
case "ABORT":
|
|
295
|
+
commandLine = "ABORT";
|
|
296
|
+
break;
|
|
297
|
+
case "SKIP":
|
|
298
|
+
commandLine = `SKIP ${command.storyId}`;
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
// This should never execute with proper discriminated union
|
|
302
|
+
throw new Error(`Unknown queue command type: ${(command as QueueCommand).type}`);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Impact:**
|
|
307
|
+
- **Likelihood:** N/A (doesn't affect runtime)
|
|
308
|
+
- **Severity:** Very Low (cosmetic — dead code path)
|
|
309
|
+
|
|
310
|
+
**Fix:**
|
|
311
|
+
Remove the `default` case and let TypeScript enforce exhaustiveness:
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
switch (command.type) {
|
|
315
|
+
case "PAUSE":
|
|
316
|
+
return "PAUSE";
|
|
317
|
+
case "ABORT":
|
|
318
|
+
return "ABORT";
|
|
319
|
+
case "SKIP":
|
|
320
|
+
return `SKIP ${command.storyId}`;
|
|
321
|
+
}
|
|
322
|
+
// No default — TypeScript ensures all cases covered
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
If you want exhaustiveness checking at runtime (for future-proofing), use:
|
|
326
|
+
```typescript
|
|
327
|
+
const exhaustiveCheck: never = command;
|
|
328
|
+
throw new Error(`Unhandled queue command: ${exhaustiveCheck}`);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### Code Quality (18/20 — A)
|
|
334
|
+
|
|
335
|
+
**Strengths:**
|
|
336
|
+
- ✅ **Small, focused components** — All components < 200 lines, most < 100
|
|
337
|
+
- ✅ **Clear naming** — `StoriesPanel`, `AgentPanel`, `useKeyboard`, `usePipelineEvents`
|
|
338
|
+
- ✅ **Proper hook patterns** — All hooks follow React rules, dependencies correct
|
|
339
|
+
- ✅ **Minimal nesting** — No deeply nested conditionals, early returns used
|
|
340
|
+
- ✅ **No dead code** — No commented-out blocks, no unused imports
|
|
341
|
+
- ✅ **Immutable patterns** — State updates use spread operators, no mutation
|
|
342
|
+
|
|
343
|
+
**Issues:**
|
|
344
|
+
|
|
345
|
+
#### STYLE-1: `App.tsx` has unused state variable (VERY LOW)
|
|
346
|
+
**File:** `src/tui/App.tsx:60`
|
|
347
|
+
|
|
348
|
+
**Issue:**
|
|
349
|
+
`_setAgentOutputLines` is prefixed with underscore to indicate it's unused, but the variable itself is never used. This should either be wired to PTY or removed.
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
const [agentOutputLines, _setAgentOutputLines] = useState<string[]>([]);
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Impact:**
|
|
356
|
+
- **Likelihood:** N/A (doesn't affect functionality)
|
|
357
|
+
- **Severity:** Very Low (cosmetic — will be used in future PTY integration)
|
|
358
|
+
|
|
359
|
+
**Fix:**
|
|
360
|
+
Either:
|
|
361
|
+
1. Remove if PTY integration deferred to v0.7
|
|
362
|
+
2. Wire to `usePty` hook output if implementing now
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
#### ENH-2: Missing JSDoc for `usePipelineEvents` (LOW)
|
|
367
|
+
**File:** `src/tui/hooks/usePipelineEvents.ts:32-45`
|
|
368
|
+
|
|
369
|
+
**Issue:**
|
|
370
|
+
The hook has a basic JSDoc comment but lacks usage examples and doesn't document state updates. Other hooks like `usePty` and `useLayout` have comprehensive JSDoc with examples.
|
|
371
|
+
|
|
372
|
+
**Current:**
|
|
373
|
+
```typescript
|
|
374
|
+
/**
|
|
375
|
+
* Hook for subscribing to pipeline events.
|
|
376
|
+
*
|
|
377
|
+
* @param events - Pipeline event emitter
|
|
378
|
+
* @param initialStories - Initial story list from PRD
|
|
379
|
+
* @returns Pipeline state updated by events
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```tsx
|
|
383
|
+
* const emitter = new PipelineEventEmitter();
|
|
384
|
+
* const state = usePipelineEvents(emitter, prd.userStories);
|
|
385
|
+
*
|
|
386
|
+
* return <StoriesPanel stories={state.stories} />;
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Fix:**
|
|
392
|
+
Expand JSDoc to document all state fields and event handlers:
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
/**
|
|
396
|
+
* Hook for subscribing to pipeline events and managing TUI state.
|
|
397
|
+
*
|
|
398
|
+
* Subscribes to pipeline lifecycle events (story:start, story:complete, etc.)
|
|
399
|
+
* and updates story display states, cost accumulator, elapsed time, and current
|
|
400
|
+
* stage in real-time.
|
|
401
|
+
*
|
|
402
|
+
* @param events - Pipeline event emitter
|
|
403
|
+
* @param initialStories - Initial story list from PRD
|
|
404
|
+
* @returns Pipeline state with stories, costs, timing, and current execution context
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```tsx
|
|
408
|
+
* const emitter = new PipelineEventEmitter();
|
|
409
|
+
* const state = usePipelineEvents(emitter, prd.userStories);
|
|
410
|
+
*
|
|
411
|
+
* // State automatically updates as pipeline emits events
|
|
412
|
+
* return (
|
|
413
|
+
* <>
|
|
414
|
+
* <StoriesPanel stories={state.stories} totalCost={state.totalCost} />
|
|
415
|
+
* <StatusBar currentStory={state.currentStory} currentStage={state.currentStage} />
|
|
416
|
+
* </>
|
|
417
|
+
* );
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
#### STYLE-2: Magic numbers in `useLayout` breakpoints (LOW)
|
|
425
|
+
**File:** `src/tui/hooks/useLayout.ts:105-116`
|
|
426
|
+
|
|
427
|
+
**Issue:**
|
|
428
|
+
Breakpoint values (80, 140) and panel widths (30, 35) are inline magic numbers. While these are documented in comments, extracting them as named constants improves clarity.
|
|
429
|
+
|
|
430
|
+
**Current:**
|
|
431
|
+
```typescript
|
|
432
|
+
if (width < 80) {
|
|
433
|
+
mode = "single";
|
|
434
|
+
storiesPanelWidth = width;
|
|
435
|
+
} else if (width < 140) {
|
|
436
|
+
mode = "narrow";
|
|
437
|
+
storiesPanelWidth = 30;
|
|
438
|
+
} else {
|
|
439
|
+
mode = "wide";
|
|
440
|
+
storiesPanelWidth = 35;
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Impact:**
|
|
445
|
+
- **Likelihood:** N/A
|
|
446
|
+
- **Severity:** Very Low (cosmetic — affects readability only)
|
|
447
|
+
|
|
448
|
+
**Fix:**
|
|
449
|
+
```typescript
|
|
450
|
+
const BREAKPOINT_NARROW = 80;
|
|
451
|
+
const BREAKPOINT_WIDE = 140;
|
|
452
|
+
const PANEL_WIDTH_NARROW = 30;
|
|
453
|
+
const PANEL_WIDTH_WIDE = 35;
|
|
454
|
+
|
|
455
|
+
if (width < BREAKPOINT_NARROW) {
|
|
456
|
+
mode = "single";
|
|
457
|
+
storiesPanelWidth = width;
|
|
458
|
+
} else if (width < BREAKPOINT_WIDE) {
|
|
459
|
+
mode = "narrow";
|
|
460
|
+
storiesPanelWidth = PANEL_WIDTH_NARROW;
|
|
461
|
+
} else {
|
|
462
|
+
mode = "wide";
|
|
463
|
+
storiesPanelWidth = PANEL_WIDTH_WIDE;
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
### Best Practices (15/20 — B+)
|
|
470
|
+
|
|
471
|
+
**Strengths:**
|
|
472
|
+
- ✅ **Excellent test coverage** — 533 tests passing, TUI components have snapshot tests
|
|
473
|
+
- ✅ **Proper React patterns** — Cleanup functions in all effects, no stale closures
|
|
474
|
+
- ✅ **Responsive design** — Three breakpoints, graceful degradation on small terminals
|
|
475
|
+
- ✅ **Event-driven architecture** — TUI subscribes to events, doesn't poll
|
|
476
|
+
- ✅ **Accessibility basics** — Keyboard-only navigation, focus indicators
|
|
477
|
+
|
|
478
|
+
**Issues:**
|
|
479
|
+
|
|
480
|
+
#### ENH-3: PTY integration not wired to TUI (MEDIUM — BLOCKING v0.6 SPEC)
|
|
481
|
+
**Files:** `src/tui/hooks/usePty.ts`, `src/tui/App.tsx`, `src/agents/claude.ts:594`
|
|
482
|
+
|
|
483
|
+
**Issue:**
|
|
484
|
+
The v0.6 spec requires embedding the agent PTY session in the TUI, but:
|
|
485
|
+
1. `usePty` hook exists but is never called in `App.tsx`
|
|
486
|
+
2. `ClaudeCodeAdapter.runInteractive()` exists but is never invoked
|
|
487
|
+
3. Agent panel shows hardcoded "Waiting for agent..." instead of PTY output
|
|
488
|
+
|
|
489
|
+
**Current state:**
|
|
490
|
+
```typescript
|
|
491
|
+
// src/tui/App.tsx:60
|
|
492
|
+
const [agentOutputLines, _setAgentOutputLines] = useState<string[]>([]);
|
|
493
|
+
|
|
494
|
+
// ...
|
|
495
|
+
|
|
496
|
+
<AgentPanel
|
|
497
|
+
focused={focus === PanelFocus.Agent}
|
|
498
|
+
outputLines={agentOutputLines} // ⚠️ Always empty array
|
|
499
|
+
/>
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
**Impact:**
|
|
503
|
+
- **Likelihood:** N/A (missing feature)
|
|
504
|
+
- **Severity:** High (**Acceptance criteria not met** — spec requires PTY embedding)
|
|
505
|
+
|
|
506
|
+
**Spec Acceptance Criteria (Phase 3 — NOT MET):**
|
|
507
|
+
- [ ] ❌ Agent session runs in embedded PTY
|
|
508
|
+
- [ ] ❌ Real-time output streaming to TUI panel
|
|
509
|
+
- [ ] ❌ Keyboard input routes to agent when panel focused
|
|
510
|
+
- [ ] ❌ Permission prompts visible and answerable
|
|
511
|
+
|
|
512
|
+
**Fix Required for v0.6 GA:**
|
|
513
|
+
Wire `usePty` in `App.tsx`:
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
// src/tui/App.tsx
|
|
517
|
+
import { usePty } from "./hooks/usePty";
|
|
518
|
+
|
|
519
|
+
export function App({ feature, stories, events, queueFilePath, ptyOptions }: TuiProps) {
|
|
520
|
+
// ... existing state ...
|
|
521
|
+
|
|
522
|
+
// Wire PTY hook
|
|
523
|
+
const { outputLines, isRunning, handle } = usePty(ptyOptions);
|
|
524
|
+
|
|
525
|
+
// Route keyboard input to PTY when agent panel focused
|
|
526
|
+
useInput((input, key) => {
|
|
527
|
+
if (focus === PanelFocus.Agent && handle) {
|
|
528
|
+
// Route all input to PTY except Ctrl+]
|
|
529
|
+
if (!(key.ctrl && input === "]")) {
|
|
530
|
+
handle.write(input);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// ...
|
|
536
|
+
|
|
537
|
+
<AgentPanel
|
|
538
|
+
focused={focus === PanelFocus.Agent}
|
|
539
|
+
outputLines={outputLines} // ✅ Live PTY output
|
|
540
|
+
/>
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
And update `TuiProps` to accept PTY options:
|
|
545
|
+
```typescript
|
|
546
|
+
export interface TuiProps {
|
|
547
|
+
// ... existing props ...
|
|
548
|
+
ptyOptions?: PtySpawnOptions | null; // ✅ Pass from runner
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
#### ENH-4: No loading states for long operations (LOW)
|
|
555
|
+
**Files:** `src/tui/components/AgentPanel.tsx:66-72`, `src/tui/components/StoriesPanel.tsx`
|
|
556
|
+
|
|
557
|
+
**Issue:**
|
|
558
|
+
When agent panel shows "Waiting for agent...", there's no spinner or progress indicator. Users have no visual feedback that the system is working.
|
|
559
|
+
|
|
560
|
+
**Current:**
|
|
561
|
+
```typescript
|
|
562
|
+
{hasOutput ? (
|
|
563
|
+
bufferedLines.map((line, i) => (
|
|
564
|
+
<Text key={i}>{line}</Text>
|
|
565
|
+
))
|
|
566
|
+
) : (
|
|
567
|
+
<Text dimColor>Waiting for agent...</Text> // ⚠️ Static text, no spinner
|
|
568
|
+
)}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
**Impact:**
|
|
572
|
+
- **Likelihood:** High (visible during every run)
|
|
573
|
+
- **Severity:** Low (UX polish, not functional)
|
|
574
|
+
|
|
575
|
+
**Fix:**
|
|
576
|
+
Add spinner using Ink's `<Spinner>` component:
|
|
577
|
+
|
|
578
|
+
```typescript
|
|
579
|
+
import { Spinner } from "ink";
|
|
580
|
+
|
|
581
|
+
{hasOutput ? (
|
|
582
|
+
bufferedLines.map((line, i) => (
|
|
583
|
+
<Text key={i}>{line}</Text>
|
|
584
|
+
))
|
|
585
|
+
) : (
|
|
586
|
+
<Text dimColor>
|
|
587
|
+
<Spinner type="dots" /> Waiting for agent...
|
|
588
|
+
</Text>
|
|
589
|
+
)}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
#### PERF-1: `usePipelineEvents` elapsed timer runs every second even when idle (LOW)
|
|
595
|
+
**File:** `src/tui/hooks/usePipelineEvents.ts:63-70`
|
|
596
|
+
|
|
597
|
+
**Issue:**
|
|
598
|
+
The elapsed time timer updates state every 1000ms unconditionally, triggering re-renders even when no story is running. This wastes CPU cycles during idle periods.
|
|
599
|
+
|
|
600
|
+
**Current:**
|
|
601
|
+
```typescript
|
|
602
|
+
useEffect(() => {
|
|
603
|
+
const timer = setInterval(() => {
|
|
604
|
+
setState((prev) => ({
|
|
605
|
+
...prev,
|
|
606
|
+
elapsedMs: Date.now() - startTime,
|
|
607
|
+
}));
|
|
608
|
+
}, 1000); // ⚠️ Runs even when idle
|
|
609
|
+
|
|
610
|
+
// ...
|
|
611
|
+
}, [events, startTime]);
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
**Impact:**
|
|
615
|
+
- **Likelihood:** High (happens every run)
|
|
616
|
+
- **Severity:** Very Low (negligible CPU impact, but violates best practice)
|
|
617
|
+
|
|
618
|
+
**Fix:**
|
|
619
|
+
Only run timer when a story is active:
|
|
620
|
+
|
|
621
|
+
```typescript
|
|
622
|
+
useEffect(() => {
|
|
623
|
+
let timer: NodeJS.Timeout | null = null;
|
|
624
|
+
|
|
625
|
+
const onStoryStart = (story: UserStory) => {
|
|
626
|
+
setState((prev) => ({ ...prev, currentStory: story, ... }));
|
|
627
|
+
|
|
628
|
+
// Start timer when story starts
|
|
629
|
+
if (!timer) {
|
|
630
|
+
timer = setInterval(() => {
|
|
631
|
+
setState((prev) => ({
|
|
632
|
+
...prev,
|
|
633
|
+
elapsedMs: Date.now() - startTime,
|
|
634
|
+
}));
|
|
635
|
+
}, 1000);
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
const onStoryComplete = (story: UserStory, result: StageResult) => {
|
|
640
|
+
setState((prev) => ({ ...prev, currentStory: undefined, ... }));
|
|
641
|
+
|
|
642
|
+
// Stop timer when story completes
|
|
643
|
+
if (timer) {
|
|
644
|
+
clearInterval(timer);
|
|
645
|
+
timer = null;
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// ... event subscriptions ...
|
|
650
|
+
|
|
651
|
+
return () => {
|
|
652
|
+
if (timer) clearInterval(timer);
|
|
653
|
+
// ... cleanup ...
|
|
654
|
+
};
|
|
655
|
+
}, [events, startTime]);
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
660
|
+
#### ENH-5: No e2e tests for TUI interactions (LOW)
|
|
661
|
+
**Files:** `test/tui-*.test.ts`
|
|
662
|
+
|
|
663
|
+
**Issue:**
|
|
664
|
+
All TUI tests are unit/snapshot tests. There are no end-to-end integration tests that simulate full TUI workflows:
|
|
665
|
+
- User presses `p` → PAUSE written to queue file
|
|
666
|
+
- Story completes → Status icon updates in real-time
|
|
667
|
+
- Terminal resizes → Layout switches breakpoints
|
|
668
|
+
|
|
669
|
+
**Impact:**
|
|
670
|
+
- **Likelihood:** N/A (testing gap)
|
|
671
|
+
- **Severity:** Low (unit tests provide good coverage, but integration gaps exist)
|
|
672
|
+
|
|
673
|
+
**Recommendation:**
|
|
674
|
+
Add integration test using `ink-testing-library`:
|
|
675
|
+
|
|
676
|
+
```typescript
|
|
677
|
+
test("pressing 'p' writes PAUSE to queue file", async () => {
|
|
678
|
+
const emitter = new PipelineEventEmitter();
|
|
679
|
+
const queueFile = "/tmp/nax-test-queue.txt";
|
|
680
|
+
|
|
681
|
+
const { stdin } = render(
|
|
682
|
+
<App
|
|
683
|
+
feature="test"
|
|
684
|
+
stories={[createMockStory("US-001", "running")]}
|
|
685
|
+
events={emitter}
|
|
686
|
+
queueFilePath={queueFile}
|
|
687
|
+
/>
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
stdin.write("p"); // Simulate pressing 'p'
|
|
691
|
+
|
|
692
|
+
await Bun.sleep(100); // Wait for write to complete
|
|
693
|
+
|
|
694
|
+
const content = await Bun.file(queueFile).text();
|
|
695
|
+
expect(content.trim()).toBe("PAUSE");
|
|
696
|
+
});
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
## Summary of Issues by Priority
|
|
702
|
+
|
|
703
|
+
| Priority | Count | IDs |
|
|
704
|
+
|:---------|:------|:----|
|
|
705
|
+
| **P1 — Fix Before GA** | 1 | ENH-3 (PTY integration) |
|
|
706
|
+
| **P2 — Fix Soon** | 2 | MEM-1, BUG-1 |
|
|
707
|
+
| **P3 — Nice to Have** | 6 | TYPE-1, ENH-1, ENH-2, ENH-4, PERF-1, ENH-5 |
|
|
708
|
+
| **P4 — Polish** | 2 | STYLE-1, STYLE-2 |
|
|
709
|
+
|
|
710
|
+
---
|
|
711
|
+
|
|
712
|
+
## Recommended Fix Order
|
|
713
|
+
|
|
714
|
+
### Before v0.6 GA Release
|
|
715
|
+
1. **ENH-3** — Wire PTY integration to TUI (blocking spec acceptance criteria)
|
|
716
|
+
2. **BUG-1** — Populate story-level costs in TUI state (visible defect in cost overlay)
|
|
717
|
+
3. **MEM-1** — Add line length limit to PTY buffer (memory safety)
|
|
718
|
+
|
|
719
|
+
### Post-Release (v0.6.1 patch)
|
|
720
|
+
4. **TYPE-1** — Consolidate `PtyHandle` definition (DRY violation)
|
|
721
|
+
5. **ENH-4** — Add loading spinners (UX polish)
|
|
722
|
+
6. **ENH-2** — Improve JSDoc coverage (developer experience)
|
|
723
|
+
|
|
724
|
+
### Optional
|
|
725
|
+
7. **PERF-1** — Optimize elapsed timer (micro-optimization)
|
|
726
|
+
8. **ENH-1** — Remove `default` case in `writeQueueCommand` (dead code)
|
|
727
|
+
9. **STYLE-1, STYLE-2** — Extract magic numbers, remove unused state
|
|
728
|
+
|
|
729
|
+
---
|
|
730
|
+
|
|
731
|
+
## Acceptance Criteria Status
|
|
732
|
+
|
|
733
|
+
### Phase 1: Pipeline Events + Headless Flag ✅
|
|
734
|
+
- [x] ✅ EventEmitter added to pipeline runner
|
|
735
|
+
- [x] ✅ Story/stage lifecycle events emitted
|
|
736
|
+
- [x] ✅ `--headless` flag and TTY detection implemented
|
|
737
|
+
- [x] ✅ No visual changes (event plumbing only)
|
|
738
|
+
|
|
739
|
+
### Phase 2: Ink Scaffolding + Stories Panel ✅
|
|
740
|
+
- [x] ✅ Ink app bootstrap
|
|
741
|
+
- [x] ✅ StoriesPanel with live data
|
|
742
|
+
- [x] ✅ StatusBar
|
|
743
|
+
- [x] ✅ Layout with breakpoints
|
|
744
|
+
- [x] ✅ Wired to pipeline events
|
|
745
|
+
|
|
746
|
+
### Phase 3: PTY Agent Panel ⚠️ INCOMPLETE
|
|
747
|
+
- [ ] ❌ node-pty integration in Claude adapter (exists but not wired)
|
|
748
|
+
- [ ] ❌ AgentPanel rendering PTY output (component exists but receives empty array)
|
|
749
|
+
- [ ] ❌ Focus management (implemented but no PTY to route to)
|
|
750
|
+
- [ ] ❌ Input routing to PTY stdin (implemented but no PTY handle)
|
|
751
|
+
|
|
752
|
+
**Status:** **BLOCKED** — ENH-3 must be resolved for Phase 3 completion.
|
|
753
|
+
|
|
754
|
+
### Phase 4: Interactive Controls + Overlays ✅
|
|
755
|
+
- [x] ✅ Keyboard shortcuts (p/a/s/q/?)
|
|
756
|
+
- [x] ✅ Help overlay
|
|
757
|
+
- [x] ✅ Cost breakdown overlay
|
|
758
|
+
- [x] ✅ Confirmation prompts
|
|
759
|
+
|
|
760
|
+
### Phase 5: Responsive Layout + Polish ✅
|
|
761
|
+
- [x] ✅ SIGWINCH handling
|
|
762
|
+
- [x] ✅ Single-column breakpoint
|
|
763
|
+
- [x] ✅ Scrollable stories panel
|
|
764
|
+
- [x] ✅ Edge cases (tiny terminals, rapid resize)
|
|
765
|
+
|
|
766
|
+
---
|
|
767
|
+
|
|
768
|
+
## Test Coverage
|
|
769
|
+
|
|
770
|
+
### Test Files (6 total)
|
|
771
|
+
- `test/pipeline-events.test.ts` — 37 tests ✅
|
|
772
|
+
- `test/tui-stories.test.ts` — 18 tests ✅
|
|
773
|
+
- `test/tui-layout.test.ts` — 24 tests ✅
|
|
774
|
+
- `test/tui-controls.test.ts` — 41 tests ✅
|
|
775
|
+
- (Plus 475 tests from other modules — all passing)
|
|
776
|
+
|
|
777
|
+
**Total:** 533 passing tests, 2 skipped, 0 failing
|
|
778
|
+
**Coverage:** Estimated 85%+ for TUI code (no gaps in critical paths)
|
|
779
|
+
|
|
780
|
+
---
|
|
781
|
+
|
|
782
|
+
## Recommendations
|
|
783
|
+
|
|
784
|
+
### Immediate Actions (Pre-GA)
|
|
785
|
+
1. **Wire PTY integration** (ENH-3) — This is the core v0.6 feature, currently missing
|
|
786
|
+
2. **Populate story costs** (BUG-1) — Cost overlay is broken without this
|
|
787
|
+
3. **Add line length limits** (MEM-1) — Prevents potential DoS via long lines
|
|
788
|
+
|
|
789
|
+
### Post-GA Improvements (v0.6.1)
|
|
790
|
+
4. **Consolidate `PtyHandle`** (TYPE-1) — Single source of truth
|
|
791
|
+
5. **Add loading spinners** (ENH-4) — Better UX during agent startup
|
|
792
|
+
6. **Expand JSDoc** (ENH-2) — Developer documentation
|
|
793
|
+
|
|
794
|
+
### Optional Enhancements (v0.7)
|
|
795
|
+
7. **Add e2e integration tests** (ENH-5) — Cover full user workflows
|
|
796
|
+
8. **Optimize timer** (PERF-1) — Only run when stories active
|
|
797
|
+
9. **Extract magic numbers** (STYLE-2) — Named constants for breakpoints
|
|
798
|
+
|
|
799
|
+
---
|
|
800
|
+
|
|
801
|
+
## Conclusion
|
|
802
|
+
|
|
803
|
+
The v0.6 TUI implementation is **89% complete and high quality**, but **ENH-3 (PTY integration) is blocking** the v0.6 spec's core acceptance criteria. Once PTY is wired, the implementation will be fully production-ready.
|
|
804
|
+
|
|
805
|
+
**Ship when:**
|
|
806
|
+
- [x] All tests passing (533/533 ✅)
|
|
807
|
+
- [x] No TypeScript errors (✅)
|
|
808
|
+
- [ ] ENH-3 resolved (PTY integrated)
|
|
809
|
+
- [ ] BUG-1 resolved (story costs populated)
|
|
810
|
+
- [ ] MEM-1 resolved (line length limits added)
|
|
811
|
+
|
|
812
|
+
**Estimated time to GA:** 4-6 hours (wiring PTY, populating costs, adding line limits)
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
**Reviewed by:** Claude Code (Sonnet 4.5)
|
|
817
|
+
**Next Review:** After ENH-3 resolution
|