Skip to content

Support JSON flags for the theme language server - #9006

Open
gonzaloriestra wants to merge 6 commits into
mainfrom
gonzalo/language-server-protocol
Open

gonzaloriestra wants to merge 6 commits into
mainfrom
gonzalo/language-server-protocol

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/24319.

The theme language server already outputs JSON through LSP, but does not accept --json or declare its output schema. CLI errors can also corrupt its stdout when JSON output is enabled globally.

WHAT is this pull request doing?

Support --json (-j) while preserving native LSP messages and Content-Length framing. Keep CLI diagnostics and argument/startup errors on stderr, and make the shared fatal-error handler respect the command's explicit output context.

Register a schema for JSON-RPC requests, notifications, successful responses, and protocol errors. --json-schema prints the contract and exits without starting the server. Method-specific payloads follow LSP. Refresh generated help, remove the lint exception, and add schema and protocol regression coverage.

How to manually test your changes?

  1. Run pnpm shopify theme language-server --json-schema. Confirm that it prints a JSON Schema and exits without starting the server. Repeat with --json --json-schema, then with SHOPIFY_FLAG_JSON_SCHEMA=1 pnpm shopify theme language-server.
  2. Configure an LSP client/editor to launch pnpm shopify theme language-server. Initialize the session, make an editor request, then send shutdown followed by exit.
  3. Repeat with pnpm shopify theme language-server --json, then with SHOPIFY_FLAG_JSON=1. Confirm that the client receives the same framed JSON-RPC messages on stdout.
  4. Run pnpm shopify theme language-server --json --invalid > lsp.stdout 2> lsp.stderr. Confirm that the argument error appears on stderr and stdout stays empty.

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
  • The change is user-facing — I've identified the correct bump types (minor for CLI flag support and patch for CLI Kit error routing) and added a changeset.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 26, 2026
@gonzaloriestra gonzaloriestra changed the title Keep theme language server diagnostics off the LSP transport Support --json while preserving the theme language server protocol Oct 26, 2026
@gonzaloriestra gonzaloriestra changed the title Support --json while preserving the theme language server protocol Support JSON flags for the theme language server Oct 26, 2026
@gonzaloriestra

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

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

Built from 3963afa8c5da9f4104ece54404b7e8609ba6f320. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/[email protected]

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.

@gonzaloriestra
gonzaloriestra marked this pull request as ready for review October 27, 2026 12:12
@gonzaloriestra
gonzaloriestra requested review from a team as code owners October 27, 2026 12:12

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant