Skip to content

Refactor shopify search to query the dev-assistant vector store as JSON#7770

Draft
nelsonwittwer wants to merge 1 commit into
telemetry-app-context-everywherefrom
search-vector-store-json
Draft

Refactor shopify search to query the dev-assistant vector store as JSON#7770
nelsonwittwer wants to merge 1 commit into
telemetry-app-context-everywherefrom
search-vector-store-json

Conversation

@nelsonwittwer

@nelsonwittwer nelsonwittwer commented Jun 9, 2026

Copy link
Copy Markdown

What

Repurposes shopify search from a (now-broken) browser launcher into an agent-facing JSON tool that queries the shopify.dev dev-assistant vector store and prints matching documentation chunks as JSON to stdout.

Why

search opened a browser at https://shopify.dev?search=<query>. That URL now 301-redirects to the docs SPA, which ignores the ?search= param — so users land on the docs home with no results. The command has effectively been broken for a long time (I think when we moved to ReactRouter 7 from Rails/React).

Monorail shows it's still invoked ~70–100×/month (and rising), so the broken experience keeps getting exposure. Curious on product's take on this -- I defaulted to repurposing this command for agents to get at context the same way we do in skills/MCP: vector store search results.

This complements fetch-doc (verbatim full-document retrieval) as the "chunked discovery" half: search finds the relevant pieces, fetch-doc pulls a whole document.

How

  • Queries GET https://shopify.dev/assistant/search (public, no auth) and passes the raw JSON response body straight through to stdout — agents JSON.parse it directly.
  • query is now required (no browser fallback).
  • Adds two optional filters, passed through to the server:
    • --api-name (e.g. admin, storefront, hydrogen, functions) — unknown values are ignored server-side.
    • --api-version (e.g. 2025-10, latest, current).
  • A non-ok response surfaces the server's {error} message (e.g. an invalid api_version lists the available versions) via AbortError; stdout stays empty and the exit code is non-zero.

Behavior change

This is a behavior change for an existing command, hence a minor bump: search no longer opens a browser, query is now required, and output is JSON on stdout -- see the why section above.

@nelsonwittwer nelsonwittwer requested review from a team as code owners June 9, 2026 18:21
@nelsonwittwer nelsonwittwer marked this pull request as draft June 9, 2026 18:22
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Jun 9, 2026
*/
export interface search {
/**
* Limit results to a specific API (for example: admin, storefront, hydrogen, functions). Unrecognized values are ignored.

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.

❤️

Comment thread packages/cli/README.md
Starts a search on shopify.dev.
Query the shopify.dev vector store and print the most relevant documentation chunks as JSON. Best for programmatic
discovery — surfacing the relevant pieces of documentation for a topic, rather than retrieving a whole document. To
download a full document verbatim, use `fetch-doc`.

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.

Should discuss this contract with @nickwesselman . I'd assume that shopify search could just have a --fetch-doc param rather than a whole separate command for that case.

Copy link
Copy Markdown
Contributor

Having second thoughts about using shopify search for this.

I'm sure use of shopify search is near-zero, but should we stick to our SemVer committment, and create a new command? We could fix the existing command or just deprecate it.

This would also give us an opportunity to apply our CLI design guidelines to a new command. e.g. The shopify search use of positional arguments is against those guidelines.

…JSON

The `search` command opened a browser at shopify.dev?search=<query>, which
now redirects to the docs SPA and silently drops the query — so it has been
broken for users while still being invoked ~70-100x/month.

Repurpose it as an agent-facing JSON tool: it queries the dev-assistant
vector store (GET https://shopify.dev/assistant/search) and prints the
matching documentation chunks as JSON to stdout. No browser. This complements
`fetch-doc` (verbatim full-document retrieval) as the "chunked discovery" half.

- `query` is now required.
- Adds `--api-name` and `--api-version` filters, passed through to the server.
- 400 responses surface the server's error message (e.g. valid api_version list).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nelsonwittwer nelsonwittwer force-pushed the search-vector-store-json branch from 2f4b95a to b8d45bd Compare June 9, 2026 20:01
@nelsonwittwer nelsonwittwer changed the base branch from main to telemetry-app-context-everywhere June 9, 2026 20:04
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/session.d.ts
@@ -47,6 +47,22 @@ export declare function isUserAccount(account: AccountInfo): account is UserAcco
  * @returns True if the account is a ServiceAccount.
  */
 export declare function isServiceAccount(account: AccountInfo): account is ServiceAccountInfo;
+/**
+ * Reports whether the CLI already has stored credentials, without prompting the
+ * user, opening a browser, or making any network request.
+ *
+ * This is a passive, side-effect-free check: it reads the local session store and
+ * returns  when at least one valid session is present. Unlike the
+ *  functions, it never triggers a login flow and never logs
+ * the user out. Because it does not contact the network, it cannot tell whether the
+ * stored token is currently valid/unexpired — only that credentials exist locally.
+ *
+ * Intended for best-effort, opportunistic behaviour (for example, enriching
+ * telemetry only for users who are already logged in).
+ *
+ * @returns True if local credentials exist, false otherwise.
+ */
+export declare function sessionExists(): Promise<boolean>;
 /**
  * Ensure that we have a valid session with no particular scopes.
  *

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

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants