Skip to content

Add typed JSON output to doc search - #8798

Open
isaacroldan wants to merge 2 commits into
codex/doc-fetch-jsonfrom
codex/doc-search-json
Open

isaacroldan wants to merge 2 commits into
codex/doc-fetch-jsonfrom
codex/doc-search-json

Conversation

@isaacroldan

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

doc search prints the search response but has no JSON flag or discoverable result contract. This PR is stacked on the doc fetch change.

WHAT is this pull request doing?

Add --json and schema discovery for documentation matches. JSON mode returns a named results collection and records unknown pagination metadata. Preserve the raw response in default mode, including successful responses that do not match the JSON schema; JSON mode reports those responses through the standard fatal-error path.

The examples show the same response excerpt. Other matches and the remaining chunk content are omitted.

Default output:

[
  {
    "score": 0.8255787,
    "content": "Manage webhook subscriptions",
    "url": "https://shopify.dev/docs/apps/build/webhooks/subscribe",
    "title": "Manage webhook subscriptions",
    "domain": "webhooks"
  }
]

JSON output:

{
  "results": [
    {
      "score": 0.8255787,
      "content": "Manage webhook subscriptions",
      "url": "https://shopify.dev/docs/apps/build/webhooks/subscribe",
      "title": "Manage webhook subscriptions",
      "domain": "webhooks"
    }
  ],
  "pageInfo": {
    "hasNextPage": null
  }
}

Validation: 73 documentation tests, build, type-check, lint, and Knip pass. Live command checks and adversarial review cover result projection, raw-response bytes, schema discovery, output channels, and failure exits.

How to manually test your changes?

pnpm shopify doc search --query "subscribe to webhooks"
pnpm shopify doc search --query "subscribe to webhooks" --json
pnpm shopify doc search --query "products" --api-name admin --api-version invalid --json
pnpm shopify doc search --json-schema

Compare the raw response with the typed JSON object. The invalid API version should return one error document and a nonzero exit code.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • Added a minor changeset for the new JSON flag.

@isaacroldan
isaacroldan requested review from a team as code owners October 6, 2026 13:17
@isaacroldan
isaacroldan added this pull request to stack #8799 October 6, 2026 13:18
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@isaacroldan isaacroldan added Area: @shopify/cli @shopify/cli package issues shopify.dev preview labels Oct 6, 2026
@isaacroldan

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm.

Built from 498fdad6965b6263fe6a1aee0fe880420b6e3be5. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006142201

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Comment thread packages/cli/src/cli/services/commands/doc/types.ts Outdated

@Suleimanlatrsh Suleimanlatrsh left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I tried a bunch of real searches with --json and everything lined up with the normal output. The errors look clean too. Heads up, this one will probably need the same rebase as #8797 once that merges.

@isaacroldan
isaacroldan force-pushed the codex/doc-search-json branch from 498fdad to eea8f93 Compare October 7, 2026 16:01
@isaacroldan
isaacroldan added this pull request to the merge queue Oct 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Oct 7, 2026
Comment on lines +49 to +51
.object({
results: zod.array(documentationSearchEntrySchema).describe('The top matching chunks from one search request.'),
pageInfo: PageInfoSchema,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for consistency, would we not want the document object itself named e.g.:

results: {
  document: {
    score:,
    content:, 
    ...
  }
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants