Refactor shopify search to query the dev-assistant vector store as JSON#7770
Refactor shopify search to query the dev-assistant vector store as JSON#7770nelsonwittwer wants to merge 1 commit into
shopify search to query the dev-assistant vector store as JSON#7770Conversation
| */ | ||
| export interface search { | ||
| /** | ||
| * Limit results to a specific API (for example: admin, storefront, hydrogen, functions). Unrecognized values are ignored. |
| 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`. |
There was a problem hiding this comment.
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.
|
Having second thoughts about using I'm sure use of This would also give us an opportunity to apply our CLI design guidelines to a new command. e.g. The |
…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>
2f4b95a to
b8d45bd
Compare
Differences in type declarationsWe 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:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/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.
*
|
What
Repurposes
shopify searchfrom 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
searchopened a browser athttps://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:searchfinds the relevant pieces,fetch-docpulls a whole document.How
GET https://shopify.dev/assistant/search(public, no auth) and passes the raw JSON response body straight through to stdout — agentsJSON.parseit directly.queryis now required (no browser fallback).--api-name(e.g.admin,storefront,hydrogen,functions) — unknown values are ignored server-side.--api-version(e.g.2025-10,latest,current).{error}message (e.g. an invalidapi_versionlists the available versions) viaAbortError; stdout stays empty and the exit code is non-zero.Behavior change
This is a behavior change for an existing command, hence a
minorbump:searchno longer opens a browser,queryis now required, and output is JSON on stdout -- see thewhysection above.