Repository navigation
fix(cli): validate --model on intents; add --stdin, -f/--file, and --system - #111
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
copybara/1000412110
branch
2 times, most recently
from
October 19, 2026 17:58
9cf5fda to
a93cf07
Compare
…system
Bring the generated Create intents (`generate`, `image`, `video`, `music`) and `agent run` in line with the hand-written porcelain (`tts`, `analyze`, `transcribe`) on `--model` validation and text/media input handling:
- **`--model` validation**:
- Hold an explicit `--model` override on `generate`, `image`, `video`, `music`, and `agent run` to the single-segment model ID contract (`normalizeModelFlag`), rejecting malformed model IDs with `CLI_VALIDATION` (exit 2) before any request and stripping a `models/` prefix in-place. Unset or blank flags fall back to the command's default.
- **`--stdin` and `-f`/`--file` text input**:
- Add `--stdin` to `generate`, `image`, `video`, `music`, and `analyze` to read `stdin` to EOF as prompt text rather than a JSON request body. Add `-f`/`--file` to `music` (`generate`, `image`, `video`, and `analyze` already accept text files via `-i`/`--input`).
- When supplied alone, the text becomes the prompt; alongside a positional prompt (or `analyze` question), it is placed as a text content block ahead of the positional prompt and after any `-i` media, and merges into `--body` input.
- Reject `--stdin` combined with `--body @-`, `--stdin` combined with `-f`, empty `stdin`, or unreadable files as `CLI_VALIDATION` (exit 2).
- Without `--stdin`, piped `stdin` remains the JSON request body; when piped `stdin` fails JSON unmarshaling on commands supporting `--stdin`, hint to pass `--stdin` for prompt text.
- Update the `README.md` command table to list `--stdin`, `-f`/`--file`, and `--system`, and remove the unimplemented `-f`/`--file` entry from `analyze`.
- **Request-input registration, `--resume` precedence, and `analyze` positional media hint**:
- Mark `-i`/`--input`, `--mime-type`, `-f`/`--file`, and `--stdin` as request inputs (`flagutil.MarkRequestInput`) in `attachIntentInputs` so an open, silent `stdin` pipe does not stall for 1s when input is already supplied via `-i` or `-f`.
- Check `flagutil.IsAsyncResume` in `attachIntentInputs` before resolving `-i` media or reading `--stdin` so `video --resume <id>` immediately reports conflicting create flags (`--input`, `--stdin`, `--model`) without network calls or `stdin` reads.
- When `analyze` is invoked without `--input` or `--stdin` and the first positional argument is media (`classifyMediaInput`), report that it is media rather than a question and hint `gemini-api analyze -i <path> [question]`.
- **`--system` on `generate` (OAD overlay & regenerated CLI)**:
- Declare `system` (`$.system_instruction`) on the `generate` intent in `overlays/cli/commands.yaml`.
- Trim one redundant flag summary line from the `image` and `video` command descriptions in `overlays/cli/commands.yaml` so adding `--stdin` keeps `image --help` and `video --help` within the 40-line help budget.
- Regenerate `specs/genai/openapi_cli.with-overlays.json`, `internal/cli/agent/intent_{generate,image,video}.go`, and `internal/usage/schema.go`.
- **Tests**:
- Add contract tests in `tests/contract/intent_inputs_test.go`, `tests/contract/porcelain_inputs_test.go`, `tests/contract/async_contract_test.go`, and `tests/contract/stdin_deadline_test.go`.
PiperOrigin-RevId: 1002456205
copybara-service
Bot
force-pushed
the
copybara/1000412110
branch
from
October 19, 2026 18:02
a93cf07 to
c31b06e
Compare
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.
fix(cli): validate --model on intents; add --stdin, -f/--file, and --system
Bring the generated Create intents (
generate,image,video,music) andagent runin line with the hand-written porcelain (tts,analyze,transcribe) on--modelvalidation and text/media input handling:--modelvalidation:--modeloverride ongenerate,image,video,music, andagent runto the single-segment model ID contract (normalizeModelFlag), rejecting malformed model IDs withCLI_VALIDATION(exit 2) before any request and stripping amodels/prefix in-place. Unset or blank flags fall back to the command's default.--stdinand-f/--filetext input:--stdintogenerate,image,video,music, andanalyzeto readstdinto EOF as prompt text rather than a JSON request body. Add-f/--filetomusic(generate,image,video, andanalyzealready accept text files via-i/--input).analyzequestion), it is placed as a text content block ahead of the positional prompt and after any-imedia, and merges into--bodyinput.--stdincombined with--body @-,--stdincombined with-f, emptystdin, or unreadable files asCLI_VALIDATION(exit 2).--stdin, pipedstdinremains the JSON request body; when pipedstdinfails JSON unmarshaling on commands supporting--stdin, hint to pass--stdinfor prompt text.README.mdcommand table to list--stdin,-f/--file, and--system, and remove the unimplemented-f/--fileentry fromanalyze.--resumeprecedence, andanalyzepositional media hint:-i/--input,--mime-type,-f/--file, and--stdinas request inputs (flagutil.MarkRequestInput) inattachIntentInputsso an open, silentstdinpipe does not stall for 1s when input is already supplied via-ior-f.flagutil.IsAsyncResumeinattachIntentInputsbefore resolving-imedia or reading--stdinsovideo --resume <id>immediately reports conflicting create flags (--input,--stdin,--model) without network calls orstdinreads.analyzeis invoked without--inputor--stdinand the first positional argument is media (classifyMediaInput), report that it is media rather than a question and hintgemini-api analyze -i <path> [question].--systemongenerate(OAD overlay & regenerated CLI):system($.system_instruction) on thegenerateintent inoverlays/cli/commands.yaml.imageandvideocommand descriptions inoverlays/cli/commands.yamlso adding--stdinkeepsimage --helpandvideo --helpwithin the 40-line help budget.specs/genai/openapi_cli.with-overlays.json,internal/cli/agent/intent_{generate,image,video}.go, andinternal/usage/schema.go.tests/contract/intent_inputs_test.go,tests/contract/porcelain_inputs_test.go,tests/contract/async_contract_test.go, andtests/contract/stdin_deadline_test.go.