Skip to content

feat: support non-interactive use for CI and AI agents#227

Open
LuLaValva wants to merge 3 commits into
mainfrom
claude/cli-agents-setup-z0wkt9
Open

feat: support non-interactive use for CI and AI agents#227
LuLaValva wants to merge 3 commits into
mainfrom
claude/cli-agents-setup-z0wkt9

Conversation

@LuLaValva

Copy link
Copy Markdown
Member

@marko/create and @marko/migrate hung on interactive prompts under CI/AI agents/piped input. They now detect non-interactive sessions and fall back to defaults (or clear guidance) instead of blocking. Interactive terminal behavior is unchanged.


Generated by Claude Code

LuLaValva added 2 commits July 3, 2026 04:19
The CLI previously hung when no human was available to answer prompts:
`@marko/create` opened interactive enquirer prompts (project name / template)
and `@marko/migrate` prompted for unsafe migrations, blocking forever under an
AI agent, CI job, or piped input.

- create: skip prompts and use defaults (name "my-app", starter template) when
  an agent is detected (e.g. CLAUDECODE / CURSOR_TRACE_ID / AGENT env vars),
  `CI` is set, or `--yes`/`-y` is passed, even when a pseudo-TTY is attached.
  If stdin is not a TTY and none of those apply, exit with actionable guidance
  instead of silently guessing. Set a non-zero exit code on failure.
- migrate: in agent/CI/non-TTY sessions, run the automatic migrations and fail
  with clear guidance (re-run with `--safe`) instead of hanging on a prompt.
- Document the non-interactive behavior in both package READMEs.
The matrix ran on Node 12/14/15, which ship npm 6. npm 6 predates
workspaces, so the root `npm install` never installed the per-package
dependencies and the test suite failed to resolve them (e.g. `mz/fs`).
These versions also no longer satisfy the `@marko/*` engine requirements
(`18 || 20 || >=22`).
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e117c90-1a8c-4365-afc0-c32b181e4759

📥 Commits

Reviewing files that changed from the base of the PR and between 701e94c and 2350e12.

📒 Files selected for processing (1)
  • packages/migrate/src/cli.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/migrate/src/cli.js

Walkthrough

This change adds non-interactive and agent-aware behavior to the create and migrate CLIs. packages/create/src/cli.js now supports --yes/-y, skips prompts in CI or detected agent environments, fills defaults when needed, and returns guided errors when non-interactive execution lacks required inputs. packages/migrate/src/cli.js now chooses between Enquirer prompts and a fail-fast fallback based on TTY, CI, agent detection, and --safe. Both READMEs document the new behavior, and the CI workflow updates the Node.js test matrix to 18.x, 20.x, and 22.x.

Related PRs: None identified from provided information.

Suggested labels: cli, documentation, ci

Suggested reviewers: None identified from provided information.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: non-interactive support for CI and AI agents.
Description check ✅ Passed The description directly matches the changeset by describing non-interactive behavior for create and migrate CLIs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 claude/cli-agents-setup-z0wkt9

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

@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

🧹 Nitpick comments (1)
packages/migrate/src/cli.js (1)

88-96: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

isAgent() duplicated verbatim in create/cli.js.

Same implementation exists in packages/create/src/cli.js (per context snippet 2). Could be extracted to a shared internal utility if a common location exists, though low priority given the small size.

🤖 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/migrate/src/cli.js` around lines 88 - 96, The isAgent() helper is
duplicated verbatim in both CLI entrypoints, so extract the shared environment
check into a common internal utility and reuse it from
packages/migrate/src/cli.js and packages/create/src/cli.js. Keep the boolean
logic and env var list in one place, then update both call sites to import the
shared helper so the two CLIs stay in sync.
🤖 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/migrate/src/cli.js`:
- Around line 103-104: Move the interactive check into run() in cli.js instead
of keeping it as a module-level constant, since Boolean(process.stdin.isTTY) &&
!process.env.CI && !isAgent() is currently evaluated only at import time. Update
the run() flow to compute interactive at call time, mirroring
packages/create/src/cli.js, so repeated run() calls and tests respect the
current stdin and CI state.

---

Nitpick comments:
In `@packages/migrate/src/cli.js`:
- Around line 88-96: The isAgent() helper is duplicated verbatim in both CLI
entrypoints, so extract the shared environment check into a common internal
utility and reuse it from packages/migrate/src/cli.js and
packages/create/src/cli.js. Keep the boolean logic and env var list in one
place, then update both call sites to import the shared helper so the two CLIs
stay in sync.
🪄 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: 7cb9c44c-f958-42dd-b354-5275d51897e7

📥 Commits

Reviewing files that changed from the base of the PR and between c66d735 and 2004647.

📒 Files selected for processing (4)
  • packages/create/README.md
  • packages/create/src/cli.js
  • packages/migrate/README.md
  • packages/migrate/src/cli.js

Comment thread packages/migrate/src/cli.js Outdated
Evaluate the TTY/CI/agent check inside run() rather than at module import,
so it reflects the current stdin/CI state, matching @marko/create.
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