@nathapp/nax 0.40.1 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/nax.js +1072 -268
  2. package/package.json +2 -2
  3. package/src/acceptance/fix-generator.ts +4 -35
  4. package/src/acceptance/generator.ts +4 -27
  5. package/src/agents/acp/adapter.ts +644 -0
  6. package/src/agents/acp/cost.ts +79 -0
  7. package/src/agents/acp/index.ts +9 -0
  8. package/src/agents/acp/interaction-bridge.ts +126 -0
  9. package/src/agents/acp/parser.ts +166 -0
  10. package/src/agents/acp/spawn-client.ts +309 -0
  11. package/src/agents/acp/types.ts +22 -0
  12. package/src/agents/claude-complete.ts +3 -3
  13. package/src/agents/registry.ts +83 -0
  14. package/src/agents/types-extended.ts +23 -0
  15. package/src/agents/types.ts +17 -0
  16. package/src/cli/analyze.ts +6 -2
  17. package/src/cli/plan.ts +23 -0
  18. package/src/config/defaults.ts +1 -0
  19. package/src/config/runtime-types.ts +10 -0
  20. package/src/config/schema.ts +1 -0
  21. package/src/config/schemas.ts +6 -0
  22. package/src/config/types.ts +1 -0
  23. package/src/execution/executor-types.ts +6 -0
  24. package/src/execution/iteration-runner.ts +2 -0
  25. package/src/execution/lifecycle/acceptance-loop.ts +5 -2
  26. package/src/execution/lifecycle/run-initialization.ts +16 -4
  27. package/src/execution/lifecycle/run-setup.ts +4 -0
  28. package/src/execution/runner-completion.ts +11 -1
  29. package/src/execution/runner-execution.ts +8 -0
  30. package/src/execution/runner-setup.ts +4 -0
  31. package/src/execution/runner.ts +10 -0
  32. package/src/pipeline/stages/execution.ts +33 -1
  33. package/src/pipeline/stages/routing.ts +18 -7
  34. package/src/pipeline/types.ts +10 -0
  35. package/src/tdd/orchestrator.ts +7 -0
  36. package/src/tdd/rectification-gate.ts +6 -0
  37. package/src/tdd/session-runner.ts +4 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nathapp/nax",
3
- "version": "0.40.1",
4
- "description": "AI Coding Agent Orchestrator loops until done",
3
+ "version": "0.41.0",
4
+ "description": "AI Coding Agent Orchestrator \u2014 loops until done",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "nax": "./dist/nax.js"
@@ -199,7 +199,7 @@ export async function generateFixStories(
199
199
  adapter: AgentAdapter,
200
200
  options: GenerateFixStoriesOptions,
201
201
  ): Promise<FixStory[]> {
202
- const { failedACs, testOutput, prd, specContent, workdir, modelDef } = options;
202
+ const { failedACs, testOutput, prd, specContent, modelDef } = options;
203
203
 
204
204
  const fixStories: FixStory[] = [];
205
205
 
@@ -225,42 +225,11 @@ export async function generateFixStories(
225
225
  const prompt = buildFixPrompt(failedAC, acText, testOutput, relatedStories, prd);
226
226
 
227
227
  try {
228
- // Call agent to generate fix description
229
- const skipPerms = options.config.quality?.dangerouslySkipPermissions ?? true;
230
- const permArgs = skipPerms ? ["--dangerously-skip-permissions"] : [];
231
- const cmd = [adapter.binary, "--model", modelDef.model, ...permArgs, "-p", prompt];
232
-
233
- const proc = Bun.spawn(cmd, {
234
- cwd: workdir,
235
- stdout: "pipe",
236
- stderr: "pipe",
237
- env: {
238
- ...process.env,
239
- ...(modelDef.env || {}),
240
- },
228
+ // Call adapter to generate fix description
229
+ const fixDescription = await adapter.complete(prompt, {
230
+ model: modelDef.model,
241
231
  });
242
232
 
243
- const exitCode = await proc.exited;
244
- const stdout = await new Response(proc.stdout).text();
245
- const stderr = await new Response(proc.stderr).text();
246
-
247
- if (exitCode !== 0) {
248
- logger.warn("acceptance", "⚠ Agent fix generation failed", { failedAC, stderr });
249
- // Use fallback description
250
- fixStories.push({
251
- id: `US-FIX-${String(i + 1).padStart(3, "0")}`,
252
- title: `Fix: ${failedAC}`,
253
- failedAC,
254
- testOutput,
255
- relatedStories,
256
- description: `Fix the implementation to make ${failedAC} pass. Related stories: ${relatedStories.join(", ")}.`,
257
- });
258
- continue;
259
- }
260
-
261
- // Extract fix description
262
- const fixDescription = stdout.trim();
263
-
264
233
  fixStories.push({
265
234
  id: `US-FIX-${String(i + 1).padStart(3, "0")}`,
266
235
  title: `Fix: ${failedAC} — ${acText.slice(0, 50)}`,
@@ -295,36 +295,13 @@ export async function generateAcceptanceTests(
295
295
  const prompt = buildAcceptanceTestPrompt(criteria, options.featureName, options.codebaseContext);
296
296
 
297
297
  try {
298
- // Call agent to generate tests (using decompose as pattern)
299
- const skipPerms = options.config.quality?.dangerouslySkipPermissions ?? true;
300
- const permArgs = skipPerms ? ["--dangerously-skip-permissions"] : [];
301
- const cmd = [adapter.binary, "--model", options.modelDef.model, ...permArgs, "-p", prompt];
302
-
303
- const proc = Bun.spawn(cmd, {
304
- cwd: options.workdir,
305
- stdout: "pipe",
306
- stderr: "pipe",
307
- env: {
308
- ...process.env,
309
- ...(options.modelDef.env || {}),
310
- },
298
+ // Call adapter to generate tests
299
+ const output = await adapter.complete(prompt, {
300
+ model: options.modelDef.model,
311
301
  });
312
302
 
313
- const exitCode = await proc.exited;
314
- const stdout = await new Response(proc.stdout).text();
315
- const stderr = await new Response(proc.stderr).text();
316
-
317
- if (exitCode !== 0) {
318
- logger.warn("acceptance", "⚠ Agent test generation failed", { stderr });
319
- // Fall back to skeleton
320
- return {
321
- testCode: generateSkeletonTests(options.featureName, criteria),
322
- criteria,
323
- };
324
- }
325
-
326
303
  // Extract test code from output
327
- const testCode = extractTestCode(stdout);
304
+ const testCode = extractTestCode(output);
328
305
 
329
306
  return {
330
307
  testCode,