@nathapp/nax 0.49.6 → 0.50.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +59 -0
  3. package/dist/nax.js +415 -106
  4. package/package.json +2 -1
  5. package/src/acceptance/generator.ts +48 -7
  6. package/src/cli/config-descriptions.ts +6 -0
  7. package/src/cli/plan.ts +46 -13
  8. package/src/config/defaults.ts +3 -0
  9. package/src/config/runtime-types.ts +21 -0
  10. package/src/config/schemas.ts +23 -0
  11. package/src/config/test-strategy.ts +17 -16
  12. package/src/config/types.ts +1 -0
  13. package/src/context/builder.ts +25 -0
  14. package/src/context/parent-context.ts +39 -0
  15. package/src/decompose/apply.ts +20 -14
  16. package/src/execution/escalation/tier-escalation.ts +1 -1
  17. package/src/execution/escalation/tier-outcome.ts +2 -2
  18. package/src/execution/iteration-runner.ts +3 -0
  19. package/src/execution/lifecycle/run-completion.ts +4 -0
  20. package/src/execution/lifecycle/run-initialization.ts +47 -13
  21. package/src/execution/lifecycle/run-regression.ts +5 -1
  22. package/src/execution/parallel-coordinator.ts +3 -3
  23. package/src/execution/pipeline-result-handler.ts +30 -1
  24. package/src/execution/runner-completion.ts +1 -0
  25. package/src/execution/sequential-executor.ts +19 -0
  26. package/src/hooks/types.ts +2 -0
  27. package/src/pipeline/event-bus.ts +9 -1
  28. package/src/pipeline/runner.ts +13 -1
  29. package/src/pipeline/stages/autofix.ts +10 -2
  30. package/src/pipeline/stages/prompt.ts +4 -2
  31. package/src/pipeline/stages/rectify.ts +1 -0
  32. package/src/pipeline/stages/routing.ts +10 -2
  33. package/src/pipeline/subscribers/events-writer.ts +14 -0
  34. package/src/pipeline/subscribers/hooks.ts +14 -0
  35. package/src/pipeline/types.ts +2 -0
  36. package/src/prd/index.ts +24 -1
  37. package/src/prd/schema.ts +8 -0
  38. package/src/prd/types.ts +11 -0
  39. package/src/precheck/checks-git.ts +3 -0
  40. package/src/prompts/builder.ts +19 -0
  41. package/src/prompts/sections/hermetic.ts +41 -0
  42. package/src/prompts/sections/index.ts +1 -0
  43. package/src/routing/router.ts +1 -1
  44. package/src/tdd/session-runner.ts +3 -0
  45. package/src/utils/git.ts +23 -0
  46. package/src/verification/rectification-loop.ts +11 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.50.0] - 2026-03-19
9
+
10
+ ### Added
11
+
12
+ - **ENH-005: Context chaining** — Dependent stories automatically receive parent story's changed files as context. After a story passes, `outputFiles` are captured via `git diff storyGitRef..HEAD` (scoped to `story.workdir` in monorepos) and injected into dependent stories' context via `getParentOutputFiles()`.
13
+ - **ENH-006: Structured plan prompt** — `nax plan` now uses a 3-step prompt (understand → analyze → generate). Analysis stored in `prd.analysis` field and injected into all story contexts. `contextFiles` populated per-story by the plan LLM. Hard ban on analysis/test-only/validation stories.
14
+ - **ENH-007: Reconciliation review gate** — Reconciliation no longer blindly auto-passes stories that failed at review stage. Stores `failureStage` on failed stories; re-runs built-in review checks before reconciling `review`/`autofix` failures.
15
+ - **ENH-008: Monorepo workdir scoping** — Decomposed sub-stories now inherit `workdir` from parent. Agent rectification runs in `story.workdir` (not repo root) and prompt includes scope constraint for out-of-package prevention.
16
+ - `prd.analysis?: string` field — planning phase analysis available to all story contexts
17
+
18
+ ### Fixed
19
+
20
+ - **BUG-071**: `COMPLEXITY_GUIDE` and `TEST_STRATEGY_GUIDE` prompt constants had inverted mappings. Corrected: `simple→tdd-simple`, `medium→three-session-tdd-lite`, `expert→three-session-tdd`. `test-after` is explicit opt-out only, never auto-assigned.
21
+
8
22
  ## [0.49.3] - 2026-03-18
9
23
 
10
24
  ### Fixed
package/README.md CHANGED
@@ -397,6 +397,35 @@ Config is layered — project overrides global:
397
397
  }
398
398
  ```
399
399
 
400
+ ### Shell Operators in Commands
401
+
402
+ Review commands (`lint`, `typecheck`) are executed directly via `Bun.spawn` — **not** through a shell. This means shell operators like `&&`, `||`, `;`, and `|` are passed as literal arguments and will not work as expected.
403
+
404
+ **❌ This will NOT work:**
405
+ ```json
406
+ "typecheck": "bun run build && bun run typecheck"
407
+ ```
408
+
409
+ **✅ Workaround — wrap in a `package.json` script:**
410
+ ```json
411
+ // package.json
412
+ "scripts": {
413
+ "build-and-check": "bun run build && bun run typecheck"
414
+ }
415
+ ```
416
+ ```json
417
+ // nax/config.json
418
+ "quality": {
419
+ "commands": {
420
+ "typecheck": "bun run build-and-check"
421
+ }
422
+ }
423
+ ```
424
+
425
+ This limitation applies to all `quality.commands` entries (`test`, `lint`, `typecheck`, `lintFix`, `formatFix`).
426
+
427
+ ---
428
+
400
429
  ### Scoped Test Command
401
430
 
402
431
  By default, nax runs scoped tests (per-story verification) by appending discovered test files to the `test` command. This can produce incorrect commands when the base command includes a directory path (e.g. `bun test test/`), since the path is not replaced — it is appended alongside it.
@@ -485,6 +514,36 @@ Isolation is verified automatically via `git diff` between sessions. Violations
485
514
 
486
515
  ---
487
516
 
517
+ ## Hermetic Test Enforcement
518
+
519
+ By default, nax instructs agents to write **hermetic tests** — tests that never invoke real external processes or connect to real services. This prevents flaky tests, unintended side effects, and accidental API calls during automated runs.
520
+
521
+ The hermetic requirement is injected into all code-writing prompts (test-writer, implementer, tdd-simple, batch, single-session). It covers all I/O boundaries: HTTP/gRPC calls, CLI tool spawning (`Bun.spawn`/`exec`), database and cache clients, message queues, and file operations outside the test working directory.
522
+
523
+ ### Configuration
524
+
525
+ ```json
526
+ {
527
+ "testing": {
528
+ "hermetic": true,
529
+ "externalBoundaries": ["claude", "acpx", "redis", "grpc"],
530
+ "mockGuidance": "Use injectable deps for CLI spawning, ioredis-mock for Redis"
531
+ }
532
+ }
533
+ ```
534
+
535
+ | Field | Type | Default | Description |
536
+ |:------|:-----|:--------|:------------|
537
+ | `hermetic` | `boolean` | `true` | Inject hermetic test requirement into prompts. Set `false` to allow real external calls. |
538
+ | `externalBoundaries` | `string[]` | — | Project-specific CLI tools, clients, or services to mock (e.g. `["claude", "redis"]`). The AI uses this list to identify what to mock in your project. |
539
+ | `mockGuidance` | `string` | — | Project-specific mocking instructions injected verbatim into the prompt (e.g. which mock libraries to use). |
540
+
541
+ > **Tip:** `externalBoundaries` and `mockGuidance` complement `context.md`. nax provides the rule ("mock all I/O"), while `context.md` provides project-specific knowledge ("use `ioredis-mock` for Redis"). Use both for best results.
542
+
543
+ > **Opt-out:** Set `testing.hermetic: false` if your project requires real integration calls (e.g. live database tests against a local dev container).
544
+
545
+ ---
546
+
488
547
  ## Story Decomposition
489
548
 
490
549
  When a story is too large (complex/expert with >6 acceptance criteria), nax can automatically decompose it into smaller sub-stories. This runs during the routing stage.