feat(init): better support for agents and non interactive mode#1341
feat(init): better support for agents and non interactive mode#1341posva wants to merge 1 commit into
Conversation
commit: |
📝 WalkthroughWalkthroughThis PR implements non-interactive mode support for the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/nuxi/src/commands/init.ts (1)
57-111:⚠️ Potential issue | 🟠 MajorNon-interactive handling depends only on
hasTTY, so pseudo-TTY CI/agents can still hit interactive prompts
const isNonInteractive = !hasTTYonly blocks prompts whenhasTTYis false; if an agent/CI wrapper allocates a pseudo-TTY,isNonInteractivestays false andinitwill still callselect/text/confirmfor template, dir, package manager, and git init (and for the “directory already exists” flow unless--forceis set). This command doesn’t expose a global--no-interactive/--defaults/-y-style escape hatch (onlyoffline/preferOfflineandmodules/--no-modulesreduce some prompts).
Also applies to: 146-150🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nuxi/src/commands/init.ts` around lines 57 - 111, The init command currently treats non-interactive only via hasTTY (const isNonInteractive = !hasTTY), so CI agents with pseudo-TTYs still trigger select/text/confirm prompts; add an explicit non-interactive switch (e.g. --yes / --no-interactive / -y) to args and update the isNonInteractive check to consider that flag (and optionally common envs like process.env.CI), then short-circuit all interactive calls (select, text, confirm) in the init flow when isNonInteractive is true and ensure the "directory exists" branch respects non-interactive semantics (fail or use --force) instead of prompting; update references to isNonInteractive, select, text, confirm, and the dir/force handling to use the new flag.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nuxi/src/commands/init.ts`:
- Around line 48-50: The array nonInteractiveRequiredArgs is incorrectly forcing
defaultable inputs ('dir', 'template', 'packageManager', 'gitInit') to be
mandatory in non-interactive mode; remove those keys from
nonInteractiveRequiredArgs (and the duplicate array at the later occurrence
around lines 151-156) so only truly required options remain, and ensure the
existing defaulting logic for init (e.g., defaulting to 'minimal',
template.defaultDir, detecting 'npm' or using 'npm', and gitInit = false) runs
when prompts are unavailable; update any validation that checks
nonInteractiveRequiredArgs to rely on those defaults instead of failing.
---
Outside diff comments:
In `@packages/nuxi/src/commands/init.ts`:
- Around line 57-111: The init command currently treats non-interactive only via
hasTTY (const isNonInteractive = !hasTTY), so CI agents with pseudo-TTYs still
trigger select/text/confirm prompts; add an explicit non-interactive switch
(e.g. --yes / --no-interactive / -y) to args and update the isNonInteractive
check to consider that flag (and optionally common envs like process.env.CI),
then short-circuit all interactive calls (select, text, confirm) in the init
flow when isNonInteractive is true and ensure the "directory exists" branch
respects non-interactive semantics (fail or use --force) instead of prompting;
update references to isNonInteractive, select, text, confirm, and the dir/force
handling to use the new flag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 668f59bc-fa84-4323-b8b9-91d2c78f0abb
📒 Files selected for processing (2)
packages/create-nuxt/test/init.spec.tspackages/nuxi/src/commands/init.ts
Close #1264
This contains what I believe to be a simpler but complete version to support any non interactive mode (including agents). It makes the CLI better