Skip to content

fix(cli): advertise domain constraints for selector and path options - #9181

Merged
morluto merged 6 commits into
mainfrom
cursor/cli-schema-domain-fields-45fd
Nov 7, 2026
Merged

morluto merged 6 commits into
mainfrom
cursor/cli-schema-domain-fields-45fd

Conversation

@morluto

@morluto morluto commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Several CLI options were bare strings, so --schema accepted values the domain schema and MCP tools/list already rejected: empty Android class or method names, a relative mappingPath, an empty browser endpoint or selector, and an ADB setting key with spaces or more than 256 characters.

Those CLI fields now use the domain fields. Transforms stay on the service side: cliDomainInput keeps the inbound string so argv text is unchanged and --schema matches the input view.

Addresses #7677 and #8950. adbSelectorConstraints stays ADB-only. The content-schema walker from #7122 is unchanged.

Problem and expected behavior

Smallest trigger: rea inspect-android-class app.apk "" --schema --json advertised className with no minimum, and Ajv accepted { path: "app.apk", className: "" }. The command then failed at domain validation. read-adb-setting advertised key as only minLength: 1, so Ajv accepted key with space and a 257-character key.

Expected: the advertised CLI schema rejects those inputs the same way the domain field does. A nonempty class name, an absolute mapping path, a nonempty listener endpoint, and an identifier setting key still validate.

Change and scope

Android APK path, class name, method name, search query, and mapping path use androidInputSchemas. read-adb-setting namespace and key use adbInputSchemas.read_adb_setting. Browser, Electron, and Inspector endpoints use the inbound string of the domain endpoint field (minLength: 1, plus the existing description). Target ids and the web-listener selector use the domain min(1) strings.

cliDomainInput returns a ZodPipe field's input schema. Screenshot and observation endpoints therefore still arrive at the service as URL text; the service transform still normalizes them.

Electron page targetId repeats z.string().min(1) because inspectElectronPageInputSchema is a union and does not expose one shape. That is the same minimum the union members use.

Contribution scope: ordinary CLI/schema fix. Maintainer scope decision for new providers or target execution: not applicable.

Not included: numeric token admission (#9178) and absolute-path schema parity for the six inspection tools (#9179).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the domain Zod field owns nonempty, absolute-path, and setting-key constraints. The CLI adapts argv into that field. Handlers still perform existence and authority checks.
  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.
  • CLI and MCP/tool-catalog contract: CLI --schema for the listed options now includes the domain minimums, the mapping absolute pattern, and the setting-key pattern and maximum. MCP schemas are unchanged.
  • Provider, bridge, target-format, or platform compatibility: mapping paths use the host absolute pattern. No provider behavior change.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/cliDomainFieldSchema.test.ts loads --schema for inspect-android-class, inspect-android-method, read-adb-setting, inspect-web-event-listeners, and capture-web-screenshot, and checks Ajv. The Android class parser also rejects an empty class name.
  • Base reproduction or other evidence: [Bug] Android and browser CLI schemas omit enforced selector constraints #7677 and [Bug] read-adb-setting CLI schema omits enforced setting-key constraints #8950. The previous CLI schemas were z.string() or z.string().min(1) without the domain pattern or maximum.
  • User-visible CLI/MCP output (if applicable): a rejected token is a validation error before ADB, JADX, or a browser is contacted. Empty class names fail minLength. Relative mapping paths fail the absolute pattern. Setting keys fail the identifier pattern or maxLength: 256.
  • Remaining proof gaps: URL shape beyond minLength is still enforced by the service transform, which JSON Schema does not represent. That matches tools/list.

Boundary regression: CLI advertised input schema versus the domain parser. Lifecycle regressions are not applicable.

Validation performed

  • After merging current main and resolving overlapping schema imports, the four focused CLI suites passed (68 tests); pre-push check:fast passed.

  • npm run test:focused -- tests/boundary/cli/cliDomainFieldSchema.test.ts — 1 passed.

  • Review follow-up: empty browser, Inspector, and Electron selectors are VALIDATION_ERROR / too_small on the named field. The tests do not freeze Zod's sentence. Malformed endpoint URLs stay invalid_request. read-adb-setting key is on the ADB selector repair path, so a 257-character key keeps maximum: 256 and bad key keeps expected: "regex". npm run test:focused -- tests/boundary/cli/browserInputDiagnostics.test.ts tests/boundary/cli/electronCli.test.ts tests/boundary/cli/adbCli.test.ts tests/boundary/cli/cliDomainFieldSchema.test.ts — 68 passed. After dropping the frozen sentence, browserInputDiagnostics.test.ts and electronCli.test.ts — 24 passed. npm run check:fast passed.

  • npm run check:fast — typecheck and lint passed. Pre-push check:fast passed.

  • Schema-owned diagnostics: browser and Inspector custom messages are compared with the domain schema's own issue, and empty capture comparison requires missing before.inspection and after.inspection. npm run test:focused -- tests/boundary/cli/browserInputDiagnostics.test.ts — 15 passed. npm run check:fast passed.

  • npx oxfmt on the touched files — formatted.

Compatibility, safety, and release

  • Breaking changes or migration steps: none marked. CLI schema validation now rejects inputs the runtime already rejected. Callers pass a nonempty selector, an absolute mapping path, and an identifier setting key. No ! or BREAKING CHANGE marker.
  • Real Hopper/Ghidra, browser, or OS coverage: not required; the checks are schema admission.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: admission only. No new target interaction.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Open in Web Open in Cursor 

Android class, method, and mapping fields, ADB setting keys, and browser
endpoints used bare strings in --schema. They now reuse the domain fields,
so empty selectors, relative mapping paths, and malformed setting keys
fail in the advertised schema.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T07:26:14.182020Z c0806f9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable issues were found.

Summary

The PR makes CLI schemas advertise existing domain constraints for Android inputs, ADB setting keys, endpoints, target IDs, and selectors.

  • Android inspection commands now apply their domain input rules in the CLI.
  • Reading an ADB setting now checks its key against the domain rules.
  • Browser and runtime commands now reject empty endpoints and selectors at the CLI boundary.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  D["Domain field"] --> I["CLI input schema"]
  I --> J["Advertised JSON Schema"]
  A["Argument text"] --> I
  I --> P["Full domain parser"]
  P --> V["Validated values"]
  V --> T["Provider call"]
Loading

Reviews (6) · Last reviewed commit: "fix(cli): remove duplicate merged schema..." · Reviewed by Greptile

Comment thread src/cli/browserCommands.ts Resolved
Comment thread src/cli/adbCommands.ts Resolved
Empty browser and Electron selectors now fail in the CLI parser, so their
diagnostics are VALIDATION_ERROR with the one-character minimum. ADB
setting keys stay on the selector repair path, which restores maximum 256
and the identifier pattern.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Empty browser and Electron selectors still fail as VALIDATION_ERROR
too_small on the named field. The tests no longer copy Zod's sentence.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Browser and Inspector tests take custom issue text from the schema that
owns it, and empty capture comparison must name both missing inspection
fields.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

# Conflicts:
#	src/cli/browserAdvancedCommands.ts
#	src/cli/browserCommands.ts
#	src/cli/javascriptRuntimeCommands.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants