feat(create): machine-readable --json output and hidden --origin flag - #1280
Open
l2ysho wants to merge 5 commits into
Open
feat(create): machine-readable --json output and hidden --origin flag#1280l2ysho wants to merge 5 commits into
l2ysho wants to merge 5 commits into
Conversation
Base automatically changed from
1236-guided-apify-create-wizard-use-case-language-best-match-template
to
master
August 3, 2026 09:50
- Enable --json on `apify create`: prints { dir, actorJsonPath, template,
source, nextSteps }. Progress/logs stay on stderr.
- Add hidden --origin console|cli flag for funnel telemetry (default cli).
- Extract buildNextSteps(), shared by the --json output and success message.
- templates ls: render the language label ("JavaScript") not the raw category.
Refs #1238
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Child process output was inherited onto the CLI's own stdout, so `git init` and the dependency installer transcript landed ahead of the JSON payload. `apify create --json | jq` failed on every invocation that did not pass both --skip-git-init and --skip-dependency-install, including the bare --json call that agents and the Console "Clone locally" handoff actually make. Add keepStdoutClean() to route child stdout to stderr, latched by the command framework whenever --json is set, so it covers every command with enableJsonFlag rather than just this one call site. Also include postCreate in the payload: 9 templates set it and two (python-playwright, python-selenium) document hard prerequisites, so an agent following nextSteps alone ended up with a broken Actor. Add gitRepositoryInitialized so a failed git init is visible to machine callers. The tests searched for the JSON among other stdout lines, which tolerated the pollution; they now require stdout to be exactly the payload. --origin is asserted through telemetry instead of a duplicated payload check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@inquirer/core pipes to process.stdout unless handed a context, so every prompt wrote its UI escape sequences and the persisted answer line to stdout. That corrupts the payload of any command invoked with --json — reachable from `apify create` whenever the Actor name or template is omitted, and unconditionally when the target directory already exists. Prompts are UI, not command output, so route all five wrappers to stderr. Also give useSelectFromList its own errorMessageForStdin: it inherited the confirmation default and told users to pass --confirm/--no-confirm, flags that do not exist on any of the commands that use it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`--template` matched only the manifest `name`, but the new `--json` payload reports the template `id` — and 19 of 43 templates have `id !== name`, so the value the machine-readable output emits was rejected on round-trip. The `--help` example `--template js-crawlee-cheerio` was broken for the same reason. Resolve against either field. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
l2ysho
force-pushed
the
1238-apify-create-machine-readable-json-origin
branch
from
August 3, 2026 10:37
eda7653 to
bbf12e8
Compare
`--json` still fell through to the interactive wizard. In a non-interactive shell the run died late, after mkdir had already created the target directory, with a message that named no flag: "Please provide the selection using the command options." Under a pty — which some agent harnesses allocate — it hung on a prompt instead, waiting for input that never arrives. Treat --json as machine mode: a caller parsing stdout cannot answer a prompt, so reject a missing name or template up front, above the mkdir, with a message that names what to pass. Gating on the flag rather than on isTTY keeps the failure deterministic regardless of how the caller was spawned. The existing-directory branch reprompted for a new name, which emitted a second, redundant error under --json; it now throws the first one. This closes all four prompts in the create path — use-case and language are filters, unreachable once --template is required. Interactive behavior is unchanged; both gates are conditional on the flag. --json on create is unreleased, so no consumer can break. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
l2ysho
marked this pull request as ready for review
August 4, 2026 13:06
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.
Closes #1238. Stacked on #1278 — rebase onto master after that merges.
Makes
apify createmachine-readable for agents and the Console "Clone locally" handoff.What changed
--jsonis strictly non-interactive. A missing name or--templatefails beforemkdir, naming the flag to pass. Gated on the flag rather thanisTTY, so it errors deterministically instead of hanging on a prompt under a pty.--origin console|cli(defaultcli) → recorded increatetelemetry for the funnel.apify create --json | jqused to fail on any call that didn't pass both--skip-git-initand--skip-dependency-install— i.e. the bare call agents and Console actually make. Two causes:git initand the whole installer transcript ahead of the payload.keepStdoutClean()routes child stdout to stderr, latched by the command framework for every command withenableJsonFlag.@inquirer/corewrites toprocess.stdoutunless handed a context. All five prompt wrappers now render on stderr — correct independent of--json.--templateaccepts the manifestidas well asname. 19 of 43 templates haveid !== name, and the--jsonpayload reportsid, so the value the contract emitted was rejected on round-trip. The--helpexample was broken for the same reason.🤖 Generated with Claude Code