Add doc search command (JSON documentation search)#7770
Conversation
| */ | ||
| 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
Per the doc-namespace plan, the JSON vector-store search lives at `doc search` instead of repurposing the top-level `search` command: - Add commands/doc/search.ts (class DocSearch), services/commands/doc/search.ts (docSearchService), and the colocated test; register as `doc:search`. - Add a `doc` topic description. - Revert the breaking change to top-level `search` — it goes back to the original browser behavior (handled/deprecated separately in #7778). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shopify search to query the dev-assistant vector store as JSONdoc search command (JSON documentation search)
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/common/url.d.ts@@ -12,20 +12,4 @@ export declare function isValidURL(url: string): boolean;
* @param url - The string to parse into a URL.
* @returns A URL object if the parsing is successful, undefined otherwise.
*/
-export declare function safeParseURL(url: string): URL | undefined;
-/**
- * Extracts the lowercased hostname from a URL-shaped string. Tolerates
- * bare hosts (without a scheme) and inputs that come back from APIs as
- * either or .
- *
- * @param value - A URL or bare host string, possibly null/undefined.
- * @returns The lowercased hostname, or undefined when the input is empty.
- */
-export declare function extractHost(value: string | null | undefined): string | undefined;
-/**
- * Extracts the subdomain handle from a URL or host.
- *
- * @param value - A URL or host string, possibly null/undefined.
- * @returns The myshopify subdomain handle, or undefined when the input isn't a URL.
- */
-export declare function extractMyshopifyHandle(value: string | null | undefined): string | undefined;
\ No newline at end of file
+export declare function safeParseURL(url: string): URL | undefined;
\ No newline at end of file
packages/cli-kit/dist/public/node/metadata.d.ts@@ -38,7 +38,6 @@ type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & Pic
declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
commandStartOptions: {
startTime: number;
- endTime?: number;
startCommand: string;
startTopic?: string;
startArgs: string[];
@@ -59,7 +58,6 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>, getAllSensitiveMetadata: () => Partial<{
commandStartOptions: {
startTime: number;
- endTime?: number;
startCommand: string;
startTopic?: string;
startArgs: string[];
@@ -79,7 +77,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
}, "store_", never>>, addPublicMetadata: (getData: ProvideMetadata<CmdFieldsFromMonorail>, onError?: MetadataErrorHandling) => Promise<void>, addSensitiveMetadata: (getData: ProvideMetadata<{
commandStartOptions: {
startTime: number;
- endTime?: number;
startCommand: string;
startTopic?: string;
startArgs: string[];
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.
*
|
What
Adds
shopify doc search <query>, which queries the shopify.dev vector store and prints the most relevant documentation chunks as JSON to stdout.This is the "discovery" half of the new
docnamespace; the "full document" half isdoc fetch(#7766). It no longer repurposes the top-levelsearchcommand — that stays as the human, browser-based command (and is deprecated separately in #7778).Why
Gives agents (and scripts) a way to discover relevant documentation across shopify.dev as structured JSON, without a browser. Paired with
doc fetch, an agent can find the right docs and pull them in full, entirely through the CLI.Details
shopify doc search "<query>"— required query; prints the raw JSON response.--api-name(e.g.admin,storefront,hydrogen,functions; unknown values ignored).--api-version(e.g.2025-10,latest,current).{error}message (e.g. an invalid version lists the valid ones).Notes
@shopify/cli: minor.doctopic (commands/doc/search.ts, registered asdoc:search); adds adoctopic description.searchcommand is restored to its original browser behavior in this PR (the deprecation/URL fix lives in Deprecate and fixsearch#7778).telemetry-app-context-everywhere(Capture app context (api_key/project_type) in analytics for every command #7771), so it inherits the app-context telemetry hook automatically.Related
doc fetchcommand (download docs from shopify.dev) #7766 —doc fetch(full-document retrieval).search#7778 — deprecates the old browsersearch, pointing users todoc search.🤖 Generated with Claude Code