Skip to content

Add doc search command (JSON documentation search)#7770

Draft
nelsonwittwer wants to merge 2 commits into
telemetry-app-context-everywherefrom
search-vector-store-json
Draft

Add doc search command (JSON documentation search)#7770
nelsonwittwer wants to merge 2 commits into
telemetry-app-context-everywherefrom
search-vector-store-json

Conversation

@nelsonwittwer

@nelsonwittwer nelsonwittwer commented Jun 9, 2026

Copy link
Copy Markdown

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 doc namespace; the "full document" half is doc fetch (#7766). It no longer repurposes the top-level search command — 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).
  • Non-ok responses surface the server's {error} message (e.g. an invalid version lists the valid ones).
shopify doc search "subscribe to webhooks"
shopify doc search "create a product" --api-name admin --api-version latest

Notes

  • @shopify/cli: minor.
  • Lives under the doc topic (commands/doc/search.ts, registered as doc:search); adds a doc topic description.
  • The top-level search command is restored to its original browser behavior in this PR (the deprecation/URL fix lives in Deprecate and fix search #7778).
  • Generated artifacts regenerated (oclif manifest, README, dev-docs interface, e2e command-tree snapshot).
  • Branches off 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

🤖 Generated with Claude Code

@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 Outdated
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
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>
@nelsonwittwer nelsonwittwer changed the title Refactor shopify search to query the dev-assistant vector store as JSON Add doc search command (JSON documentation search) Jun 10, 2026
@github-actions

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/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.
  *

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