Repository navigation
feat: add apify agent setup command with auto-detection and non-interactive flag (#1451) - #1471
Open
kuntal1461 wants to merge 2 commits into
Open
kuntal1461 wants to merge 2 commits into
kuntal1461 wants to merge 2 commits into
Conversation
Fixes apify#1451 (prompt hang in pseudo-TTY environments) and apify#1354 (phantom --confirm flags). P0 — global --non-interactive flag: - New `src/lib/nonInteractiveMode.ts`: single source of truth with `isNonInteractive()`, `setNonInteractiveFlag()`, and `resetNonInteractiveFlag()` - Registered `--non-interactive` in `_buildParseArgsOption()` alongside `--help` and `--user-agent`; env var `APIFY_CLI_NON_INTERACTIVE=1` is equivalent - Activated early in `runCLI()` before version-check middleware; reset+re-applied at the start of every `_run()` for test isolation - All three divergent interactivity decision points now converge on `isNonInteractive()`: `_stdinCheckWrapper`, `create.ts`, and `detectIsInteractive()` in telemetry - Skipped prompt with no programmatic answer exits non-zero with an actionable message naming the exact flag to pass (fixes phantom `--confirm/--no-confirm` bug apify#1354) - Added GLOBAL OPTIONS section to main `--help` output - Added actionable `errorMessageForStdin` to previously unguarded prompts in `useActorConfig.ts` and `auth/login.ts` P1 — agent env var auto-detection and skill update: - `AGENT_ENV_VARS` (9 known agent runtimes) moved to `nonInteractiveMode.ts` and exported; `isNonInteractive()` returns true when any agent env var is set - `detectEnvironment.ts` refactored to import `AGENT_ENV_VARS` from the single source (no duplication, no circular import) - `skills/apify/SKILL.md`: added required "always pass --non-interactive" line - `test/setup.ts` + `vitest.config.ts`: global Vitest setup clears agent env vars before each test file so host environment (e.g. CLAUDECODE) does not leak into tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds apify agent setup -- auto-detects installed AI coding agents (Claude Code, Cursor, VS Code, Kiro, Codex, Antigravity) by env var and home-path heuristics, then configures them via MCP. Includes tier ladder, idempotency via state file, --client override, --json output, and 89 tests covering unit, integration, security, and edge cases.
kuntal1461
force-pushed
the
feat/global-non-interactive-flag
branch
from
October 5, 2026 12:38
12649ed to
1f3136c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #1451
Related to #1445
Summary
apify agent setup— auto-detects installed AI coding agents by env var and home-path heuristics, then configures them to use Apify tools via MCP--non-interactiveflag (isNonInteractive()) so commands can detect CI/script context without checking TTY themselvesWhat's included
New command:
apify agent setupCLAUDECODE,CURSOR_AGENT,CODEX_SANDBOX,CODEX_THREAD_ID,OPENCLAW_SHELL, etc.) and home-path markers (~/.claude,~/.cursor/mcp.json,~/.kiro,~/.gemini/antigravity, etc.)plugin > skills+mcp > mcp > manualwith graceful fallback when a higher tier has no published artifactagent-state.jsonbefore applying; skips already-configured clients and reportsalready_configuredoutcome--client <name>to target a specific client, bypassing auto-detection--yesto skip the confirmation prompt (CI / scripted use)--jsonoutput:{ clients: [{ client, tier, outcome }] }withreasonstripped from machine-readable output?client=apify-clifor attribution analyticsNew supporting modules:
src/lib/agent/catalog.json+catalog.ts— client capability catalog with tier ordering helperssrc/lib/agent/detection.ts— env-var and filesystem-based client detectionsrc/lib/agent/state.ts—agent-state.jsonread/write with atomic write patternsrc/lib/consts.ts—AGENT_STATE_FILE_PATHconstantGlobal
--non-interactiveflag (part of #1451):isNonInteractive()helper insrc/lib/nonInteractiveMode.tsstdinCheckWrapperautomatically gates interactive promptsAPIFY_CLI_NON_INTERACTIVE=1env var equivalentTests: 89 tests across 4 files
catalog.test.ts— schema validation, tier ordering, URL builder, prototype poisoning guarddetection.test.ts— all env signals, negative cases (unsupported clients), home-path markers, ordering (env before path), deduplicationstate.test.ts— null on missing/malformed file, round-trip fidelity, atomic write (no .tmp left), security (no token in state file), case sensitivitysetup.test.ts— detection flow,--clientflag, auth gating, confirmation prompt, happy path, MCP URL attribution, idempotency (5 scenarios),--jsonshape, security, error handlingTest plan
pnpm run buildpassespnpm run lintpassespnpm run test:local— 725 tests pass (2 pre-existing Python pip failures unrelated to this change)apify agent setup --client cursor --yeswrites~/.cursor/mcp.jsonwith Apify MCP server entryalready_configuredwithout overwriting the config🤖 Generated with Claude Code