feat: support non-interactive use for CI and AI agents#227
Conversation
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`).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis change adds non-interactive and agent-aware behavior to the create and migrate CLIs. 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)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/migrate/src/cli.js (1)
88-96: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
isAgent()duplicated verbatim increate/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
📒 Files selected for processing (4)
packages/create/README.mdpackages/create/src/cli.jspackages/migrate/README.mdpackages/migrate/src/cli.js
Evaluate the TTY/CI/agent check inside run() rather than at module import, so it reflects the current stdin/CI state, matching @marko/create.
@marko/createand@marko/migratehung 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