Skip to content

refactor(cli): Store docs.examples steps without the program name - #2087

Merged
BYK merged 1 commit into
mainfrom
chore/examples-without-program
Nov 7, 2026
Merged

BYK merged 1 commit into
mainfrom
chore/examples-without-program

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

docs.examples steps no longer repeat sentry . exampleForRunningProgram is deleted from src/lib/command.ts. It was the last runtime match on command text: --help used to swap a leading sentry for the running program.

Schema

type ExampleStep = string | { prefix?: string; args: string; suffix?: string };
type CommandExample = { description: string; run: ExampleStep | readonly ExampleStep[] };
  • The field is renamed command → run, so tsc flags any call site that was missed. This is a hard cutover with no shim.
  • A string step holds only the words after the program name, e.g. run: "issue list my-org/frontend".
  • exampleSteps(example, program) renders prefix + program + " " + args + suffix. Each renderer picks the program:
    • --help (prepareNativeDocs) uses getInvocationCommand(), so it shows sentry-mcp … or npx -y @sentry/mcp-server ….
    • introspect.ts, which feeds the generated command docs, skill references and check:fragments, uses "sentry". So do check:doc-examples and generate-docs-sections.

Steps that aren't a bare sentry command

Of 711 steps in 697 examples, 4 wrap the invocation in other shell text. These became { prefix, args, suffix }:

File Step
commands/cli/fix.ts sudo sentry cli fix → { prefix: "sudo ", args: "cli fix" }
commands/cli/completion.ts eval "$(sentry cli completion bash)" → { prefix: 'eval "$(', args: "cli completion bash", suffix: ')"' }
commands/wasm-split.ts BUILD_ID=$(sentry wasm-split app.wasm) → { prefix: "BUILD_ID=$(", args: "wasm-split app.wasm", suffix: ")" }
commands/monitor/run.ts SENTRY_DSN=… sentry monitor run nightly-job -- python manage.py cron → { prefix: "SENTRY_DSN=… ", args: "monitor run …" }

No step is a pipe, an npx … line, another tool, or a shell line with no sentry invocation in it. A literal { shell } form would have had no users, so I left it out. Trailing redirections such as cli completion zsh > ~/.local/share/zsh/site-functions/_sentry follow the command, so they stay in the plain string.

Behavior change: under sentry-mcp or npx, --help now names the running program inside these 4 wrapped steps too. The old swap only matched a leading sentry , so it skipped them.

Conversion and guard

  • An AST codemod (TypeScript compiler API) found each examples: [{ description, command }] entry. It renamed the key to run, stripped the leading sentry from every string step (keeping the original quotes and escapes), and converted the 4 wrapped steps above. It found no non-literal steps and no unmatched ones.
  • sentry-cli/no-hardcoded-sentry-command now rejects an example step that starts with sentry : a run string, an element of a run array, or a step's args. RuleTester cases cover each form.
  • check:doc-examples still checks every rendered step against the route tree (1649 examples in 669 files). A doubled sentry sentry … would fail there as an unknown command.

Verification

  • Byte-identical output. I ran pnpm run generate:docs on main and on this branch, then diffed recursively: apps/cli-docs/src/content (command pages, index.md, configuration.md, docs sections), plugins/sentry-cli (SKILL.md plus 42 references), .well-known/skills/index.json, src/generated/ (including skill-content.ts) and sdk.generated.*. There were no differences.
  • New test/lib/command-examples.test.ts: --help renders sentry-mcp …, sudo sentry-mcp cli fix and npx -y @sentry/mcp-server … under those identities, and exampleSteps(e, "sentry") gives the docs form.
  • pnpm run tsc and pnpm run lint (root) pass.
  • Rule tests: node --test scripts/cli-lint-rules.test.mjs passes 118 of 118.
  • check:doc-examples, check:fragments and check:docs-sections pass.
  • pnpm --filter sentry run test: 12933 passed. 5 failed, all known sandbox permission failures: completions EACCES/EPERM (2), db/resilient readonly, the dsn code-scanner unreadable file, and the upgrade lock.

Refs #2085
Refs #2050

via @BYK.

--

View Session [Sentry]

docs.examples steps now leave out `sentry`: `run: "issue list my-org/"`.
`--help` adds getInvocationCommand(), and the generated docs, skill
references and check:doc-examples add `sentry`, so nothing swaps a
leading `sentry ` at runtime anymore. A step inside other shell text
keeps it around the invocation, as `{ prefix: "sudo ", args: "cli fix" }`.

An AST codemod converted all 711 steps in 697 examples. The
no-hardcoded-sentry-command lint rule now rejects a step that starts
with `sentry `.

Refs #2085
Refs #2050

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Nov 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 7, 2026 12:29pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 7, 2026 12:34
@BYK
BYK merged commit ddeeadd into main Nov 7, 2026
44 of 46 checks passed
@BYK
BYK deleted the chore/examples-without-program branch November 7, 2026 12:39

This branch was successfully deployed

1 active deployment
Preview — 60dc3392 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant