Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
`nx init` mixes NDJSON events with `Fetching nx...`, `CREATE`/`UPDATE`
file lines, `output.log` titles, and a trailing `---USER_NEXT_STEPS---`
block — agents must parse stdout line-by-line with brittle heuristics.
Under any agent detected by `isAiAgent()`, stdout is pure NDJSON. Sets
`NX_AI_AGENT_INIT=1` early in `initHandler` so it survives the
tmp-install re-entry and the `nx g <plugin>:init` subprocess. `output.*`
methods, `printChanges()` (dot-nx + generate), and the `Fetching ${pkg}`
log all gate on it. `userNextSteps` already lives in the `complete`
event, so the trailing human block is dropped. Human TTY behavior
unchanged.
Fixes NXC-4368
# Conflicts: # packages/nx/src/utils/output.ts
|
View your CI Pipeline Execution ↗ for commit 12955ae
☁️ Nx Cloud last updated this comment at |
Co-authored-by: jaysoo <jaysoo@users.noreply.github.com>
There was a problem hiding this comment.
✅ The fix from Nx Cloud was applied automatically
We ran Prettier on astro-docs/src/content/docs/reference/environment-variables.mdoc to fix the astro-docs:format failure. The PR's documentation commit added a new NX_AI_AGENT_INIT table row whose description exceeded the existing Markdown table column width, causing Prettier's alignment check to fail. Expanding all Description column cells to the new maximum width resolves the formatting error.
Tip
✅ We verified this fix by re-running astro-docs:format.
Warning
The suggested diff is too large to display here, but you can view it on Nx Cloud ↗
View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Co-authored-by: jaysoo <jaysoo@users.noreply.github.com>
Current Behavior
nx initinterleaves three styles of stdout under an AI agent:Agents have to do line-by-line heuristics, and the trailing
---USER_NEXT_STEPS---block duplicatesuserNextStepsalready in thecompleteJSON event.Expected Behavior
When
isAiAgent()is true, stdout is pure NDJSON — one JSON object per line, nothing else.Implementation:
initHandlersetsprocess.env.NX_AI_AGENT_INIT=trueearly. The sentinel survives the tmp-install re-entry into the subprocess and is inherited bynx g <plugin>:initviarunNxSync.CLIOutput(utils/output.ts) gateswriteToStdOut/overwriteLineon the sentinel — alloutput.log/note/success/warn/errorbecomes a no-op. Errors still surface to agents through the structurederrorNDJSON event emitted byrecordInitError(and via process exit code).console.log('Fetching ${pkg}...')(utils/package-json.ts),printChanges()for dot-nx setup (add-nx-scripts.ts), andprintChanges()ingenerate.ts(plugin init subprocess) gate on the same sentinel.console.log('')aftergenerateDotNxSetupis now suppressed under agent mode.writeAiOutputno longer appends the---USER_NEXT_STEPS---...---END---block — agents renderuserNextStepsfrom the structuredcompleteevent.Human TTY behavior is unchanged. Detection logic in
ai.rsis untouched (relies on existing CLAUDECODE / Cursor / OpenCode / Gemini / Replit signals).Smoke tests:
Related Issue(s)
Fixes NXC-4368