Skip to content

feat(init): better support for agents and non interactive mode#1341

Open
posva wants to merge 1 commit into
mainfrom
feat/init-non-interactive
Open

feat(init): better support for agents and non interactive mode#1341
posva wants to merge 1 commit into
mainfrom
feat/init-non-interactive

Conversation

@posva

@posva posva commented Jun 12, 2026

Copy link
Copy Markdown
Member

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

@posva posva requested a review from danielroe as a code owner June 12, 2026 13:48
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown
  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1341
    
    npm i https://pkg.pr.new/nuxi@1341
    
    npm i https://pkg.pr.new/@nuxt/cli@1341
    

commit: 034861f

@codspeed-hq

codspeed-hq Bot commented Jun 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feat/init-non-interactive (034861f) with main (fab0173)

Open in CodSpeed

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements non-interactive mode support for the create-nuxt initializer when running in environments without a TTY. The implementation adds validation to require all CLI arguments upfront, exits with code 2 if required arguments are missing (showing usage and available templates), exits with code 1 if the target directory already exists, and skips interactive module browsing. Three test cases validate missing-argument error handling, successful project creation with all arguments, and directory-collision failures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially implements issue #1264 objectives but does not fully meet all stated requirements. The implementation is missing support for --defaults/-y and --no-interactive flags, live-fetched template listing, sensible auto-selection logic, and reason logging for non-interactive detection [#1264].
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding better support for non-interactive mode and agents to the init command.
Description check ✅ Passed The description is related to the changeset, mentioning issue #1264 and the goal of supporting non-interactive modes including agents.
Out of Scope Changes check ✅ Passed All changes are scoped to supporting non-interactive mode in the init command, which aligns with the linked issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/init-non-interactive

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Non-interactive handling depends only on hasTTY, so pseudo-TTY CI/agents can still hit interactive prompts

const isNonInteractive = !hasTTY only blocks prompts when hasTTY is false; if an agent/CI wrapper allocates a pseudo-TTY, isNonInteractive stays false and init will still call select/text/confirm for template, dir, package manager, and git init (and for the “directory already exists” flow unless --force is set). This command doesn’t expose a global --no-interactive / --defaults / -y-style escape hatch (only offline/preferOffline and modules/--no-modules reduce 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

📥 Commits

Reviewing files that changed from the base of the PR and between fab0173 and 034861f.

📒 Files selected for processing (2)
  • packages/create-nuxt/test/init.spec.ts
  • packages/nuxi/src/commands/init.ts

Comment thread packages/nuxi/src/commands/init.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant