Skip to content

chore: pre-shape repo into pnpm-workspace monorepo layout - #1254

Merged
BYK merged 7 commits into
mainfrom
chore/preshape-monorepo
Jul 31, 2026
Merged

chore: pre-shape repo into pnpm-workspace monorepo layout#1254
BYK merged 7 commits into
mainfrom
chore/preshape-monorepo

Conversation

@BYK

@BYK BYK commented Jul 15, 2026

Copy link
Copy Markdown
Member

Pre-shape the CLI repo into a pnpm-workspace monorepo

Part of the sentry-cli + sentry-mcp → getsentry/toolkit merge.
Closes #1238 · Master: #1248

This reshapes the repo into a pnpm workspace so it can be cleanly
git subtree-imported into the renamed toolkit repo (#1239), while keeping
this repo fully operational (CI, releases, nightlies) throughout the
transition
— which the dual-source CLI upgrade (#1244) depends on.

Layout

  • CLI package → packages/cli/ (src, test, script, patches, plugins, install, configs, package.json)
  • docs/apps/cli-docs/
  • Root keeps GitHub/Craft-read files: .github/, .craft.yml, LICENSE, CHANGELOG, .gitignore, .nojekyll
  • New pnpm-workspace.yaml (packages/* + apps/*) and a thin delegating root package.json that forwards scripts to the sentry package and hoists the pnpm block
  • New minimal root README; CLI README → packages/cli/README.md

Internal path fixes

  • Shared script/paths.ts (DOCS_ROOT etc.) for cross-package doc paths
  • Re-pointed apps/cli-docs public symlinks (install, skill files) to packages/cli/
  • build.ts/bundle.ts resolve the @sentry/symbolic WASM via module resolution and invoke fossilize via pnpm exec (both hoist to the workspace root)
  • biome.jsonc + packages/cli/.gitignore so Biome finds an ignore file
  • .gitignore path-anchored entries updated for the nested layout

Workflows / release (root-relative where GitHub/Craft require it)

  • ci.yml, docs-preview.yml, eval-skill-fork.yml: paths-filter globs, node_modules cache paths, patches hashFiles glob, artifact paths (packages/cli/dist-bin, apps/cli-docs/dist), docs working-directory, version reads, npm pack dir
  • .craft.yml pre/post-release commands cd packages/cli

node-linker=isolated (was hoisted)

Under the workspace, hoisted let an unpatched transitive
@sentry/core@10.65.0 (via @spotlightjs/spotlight@sentry/node) win the
flat hoist over the patched direct @sentry/core@10.63.0, so the CLI
bundled the unpatched copy (masked only by esbuild tree-shaking). isolated
mode (pnpm default) keeps per-package variants so the patched copy is used.
check-patches.ts now reads patchedDependencies from the workspace root and
resolves the copy the CLI actually links via require.resolve.
The patch files themselves are unchanged (they apply cleanly);
catalog:-based dedup is deferred to #1240.

Verification (local)

  • typecheck, lint, all check:* scripts
  • build (+ Linux binary smoke test, WASM asset loads, patched bundle verified)
  • bundle (npm library)
  • ✅ full unit suite — 399 files, 8474 passed, 13 skipped

CI on this PR is the authoritative check for the cross-platform binary matrix
and release paths.

Comment thread .github/workflows/ci.yml
@BYK
BYK force-pushed the chore/preshape-monorepo branch from 20669e5 to e11da2e Compare July 15, 2026 14:55
@github-actions github-actions Bot added the risk: high PR risk score: high label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-31 13:58 UTC

Comment thread .github/workflows/ci.yml
BYK added a commit that referenced this pull request Jul 15, 2026
Follow-ups from the PR #1254 review (no behavior change to shipped CLI):

- check-patches.ts: harden resolvePackageFile() to derive the package
  root from the FIRST `<pkgName>/` after the last `node_modules/`
  boundary, instead of `lastIndexOf('/<pkgName>/')`. A package that
  vendors a nested copy of itself would otherwise truncate at the wrong
  inner segment. Also refresh the stale `node-linker=hoisted` comment.
- biome.jsonc / packages/cli/.gitignore: reconcile the contradictory
  comments about which .gitignore Biome reads. Biome honors the
  workspace-root .gitignore via `vcs.root: "../.."`; the package-level
  .gitignore is for plain git only. Drop the dead `!docs` ignore
  (no packages/cli/docs after the move).
- build.ts / bundle.ts: fix comments that still claimed deps are
  "hoisted to the workspace-root node_modules" — under node-linker=isolated
  they live in the isolated store; the code (module resolution / `pnpm
  exec`) is unchanged and correct.
- packages/cli/AGENTS.md: replace stale Bun-era guidance with the current
  pnpm/Node/Vitest reality — command reference, "Use Node.js APIs"
  section, test-runner isolation notes (VITEST_POOL_ID), vitest imports
  and `vi.mock`, moved docs path (apps/cli-docs), and removed the dangling
  `.cursor/rules/bun-cli.mdc` reference.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke).
Comment thread packages/cli/script/build.ts
BYK added a commit that referenced this pull request Jul 30, 2026
Follow-ups from the PR #1254 review (no behavior change to shipped CLI):

- check-patches.ts: harden resolvePackageFile() to derive the package
  root from the FIRST `<pkgName>/` after the last `node_modules/`
  boundary, instead of `lastIndexOf('/<pkgName>/')`. A package that
  vendors a nested copy of itself would otherwise truncate at the wrong
  inner segment. Also refresh the stale `node-linker=hoisted` comment.
- biome.jsonc / packages/cli/.gitignore: reconcile the contradictory
  comments about which .gitignore Biome reads. Biome honors the
  workspace-root .gitignore via `vcs.root: "../.."`; the package-level
  .gitignore is for plain git only. Drop the dead `!docs` ignore
  (no packages/cli/docs after the move).
- build.ts / bundle.ts: fix comments that still claimed deps are
  "hoisted to the workspace-root node_modules" — under node-linker=isolated
  they live in the isolated store; the code (module resolution / `pnpm
  exec`) is unchanged and correct.
- packages/cli/AGENTS.md: replace stale Bun-era guidance with the current
  pnpm/Node/Vitest reality — command reference, "Use Node.js APIs"
  section, test-runner isolation notes (VITEST_POOL_ID), vitest imports
  and `vi.mock`, moved docs path (apps/cli-docs), and removed the dangling
  `.cursor/rules/bun-cli.mdc` reference.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke).
@BYK
BYK force-pushed the chore/preshape-monorepo branch from 27b35bb to 4bd6a82 Compare July 30, 2026 22:55
BYK added a commit that referenced this pull request Jul 30, 2026
Follow-ups from the PR #1254 review (no behavior change to shipped CLI):

- check-patches.ts: harden resolvePackageFile() to derive the package
  root from the FIRST `<pkgName>/` after the last `node_modules/`
  boundary, instead of `lastIndexOf('/<pkgName>/')`. A package that
  vendors a nested copy of itself would otherwise truncate at the wrong
  inner segment. Also refresh the stale `node-linker=hoisted` comment.
- biome.jsonc / packages/cli/.gitignore: reconcile the contradictory
  comments about which .gitignore Biome reads. Biome honors the
  workspace-root .gitignore via `vcs.root: "../.."`; the package-level
  .gitignore is for plain git only. Drop the dead `!docs` ignore
  (no packages/cli/docs after the move).
- build.ts / bundle.ts: fix comments that still claimed deps are
  "hoisted to the workspace-root node_modules" — under node-linker=isolated
  they live in the isolated store; the code (module resolution / `pnpm
  exec`) is unchanged and correct.
- packages/cli/AGENTS.md: replace stale Bun-era guidance with the current
  pnpm/Node/Vitest reality — command reference, "Use Node.js APIs"
  section, test-runner isolation notes (VITEST_POOL_ID), vitest imports
  and `vi.mock`, moved docs path (apps/cli-docs), and removed the dangling
  `.cursor/rules/bun-cli.mdc` reference.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke).
@BYK
BYK force-pushed the chore/preshape-monorepo branch from 4bd6a82 to faa626b Compare July 30, 2026 22:56
Comment thread .github/workflows/ci.yml
Comment thread packages/cli/package.json
Comment thread pnpm-lock.yaml
Comment thread pnpm-lock.yaml
Comment thread pnpm-lock.yaml
BYK added a commit that referenced this pull request Jul 31, 2026
Follow-ups from the PR #1254 review (no behavior change to shipped CLI):

- check-patches.ts: harden resolvePackageFile() to derive the package
  root from the FIRST `<pkgName>/` after the last `node_modules/`
  boundary, instead of `lastIndexOf('/<pkgName>/')`. A package that
  vendors a nested copy of itself would otherwise truncate at the wrong
  inner segment. Also refresh the stale `node-linker=hoisted` comment.
- biome.jsonc / packages/cli/.gitignore: reconcile the contradictory
  comments about which .gitignore Biome reads. Biome honors the
  workspace-root .gitignore via `vcs.root: "../.."`; the package-level
  .gitignore is for plain git only. Drop the dead `!docs` ignore
  (no packages/cli/docs after the move).
- build.ts / bundle.ts: fix comments that still claimed deps are
  "hoisted to the workspace-root node_modules" — under node-linker=isolated
  they live in the isolated store; the code (module resolution / `pnpm
  exec`) is unchanged and correct.
- packages/cli/AGENTS.md: replace stale Bun-era guidance with the current
  pnpm/Node/Vitest reality — command reference, "Use Node.js APIs"
  section, test-runner isolation notes (VITEST_POOL_ID), vitest imports
  and `vi.mock`, moved docs path (apps/cli-docs), and removed the dangling
  `.cursor/rules/bun-cli.mdc` reference.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke).
@BYK
BYK force-pushed the chore/preshape-monorepo branch from bc99a18 to 6e72f45 Compare July 31, 2026 11:57

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6e72f45. Configure here.

Comment thread packages/cli/package.json Outdated
Comment thread packages/cli/package.json Outdated
Comment thread packages/cli/package.json Outdated
Comment thread packages/cli/script/bundle.ts
BYK added a commit that referenced this pull request Jul 31, 2026
Re-applies the three substantive commits (sync-scripts, move-eval-common,
bugbot B1+B2+B3) that the rebase dropped, plus the feedback files that
git's rename detector did not relocate on its own.

- packages/cli/package.json: take origin/main's `scripts` block verbatim
  so future drift lands via rebase, not by manual sync. Rebuild root
  delegating scripts from `pnpm --filter sentry run <name>`.
- Move `test/eval-common/anthropic-client.ts` into
  `packages/cli/test/eval-common/anthropic-client.ts` so the importing
  `packages/cli/test/script/eval-provider.test.ts` can resolve
  `../eval-common/anthropic-client.js`.
- Relocate `src/commands/feedback/{index,list,utils,view}.ts` and
  `test/commands/feedback/{list,utils,view}.test.ts` into
  `packages/cli/`. Other feedback files (`feedback.ts` in
  `src/lib/api`, `src/lib/formatters`, `src/types`, etc.) were already
  in the package thanks to git's rename detection during rebase; the
  remaining ones slipped through as newly added files.
- ci.yml: remove the duplicate bare `run: npm pack` step (the correct
  one with `working-directory: packages/cli` at line 874 stays).
  Paths-filter to `packages/cli/**` was preserved from the earlier
  B1 fix.
- packages/cli/LICENSE.md: copy + extend `files` to include LICENSE.md
  and README.md, so `npm pack` ships the license text and the
  README `LICENSE.md` link resolves inside the package.

Verified: typecheck, lint (950 files), check:patches, check:deps,
check:errors, check:stale-refs, check:fragments, check:docs-sections,
build (0.40.0-dev.0), feedback unit tests (15 files, 156 tests pass).
Comment thread apps/cli-docs/package.json
Comment thread .github/workflows/eval-skill-fork.yml
BYK added 6 commits July 31, 2026 13:37
Reshape the CLI repo into a pnpm workspace so it can be cleanly
git-subtree-imported into the future getsentry/toolkit monorepo
(#1238, part of #1248).

Layout:
- Move the CLI package into packages/cli/ (src, test, script, patches,
  plugins, install, configs, package.json).
- Move docs/ into apps/cli-docs/.
- Keep GitHub/Craft-read files at the repo root (.github/, .craft.yml,
  LICENSE, CHANGELOG, .gitignore, .nojekyll) so the repo stays fully
  operational (releases + nightlies) through and after the merge.
- Add pnpm-workspace.yaml (packages/* + apps/*) and a thin delegating
  root package.json that forwards scripts to the sentry package and
  hoists the pnpm block (patchedDependencies now reference
  packages/cli/patches/**).
- Add a minimal root README; the CLI README moves to packages/cli/.

Internal path fixes:
- Shared script/paths.ts (DOCS_ROOT etc.) for cross-package doc paths;
  generate/check scripts updated to use it.
- Re-point apps/cli-docs public symlinks (install, skill files) to the
  new packages/cli/ locations.
- build.ts / bundle.ts resolve @sentry/symbolic WASM via module
  resolution and invoke fossilize via `pnpm exec` (both hoist to the
  workspace root now).
- biome.jsonc + packages/cli/.gitignore so Biome finds an ignore file.
- .gitignore path-anchored entries updated to the nested layout.

Workflows / release (kept root-relative where GitHub/Craft require it):
- ci.yml, docs-preview.yml, eval-skill-fork.yml: paths-filter globs,
  node_modules cache paths, patches hashFiles glob, artifact paths
  (packages/cli/dist-bin, apps/cli-docs/dist), docs working-directory,
  package.json version reads, npm pack dir.
- .craft.yml pre/post release commands cd into packages/cli.

node-linker=isolated (was hoisted): under the workspace, hoisted mode
let an unpatched transitive @sentry/core@10.65.0 (via
@spotlightjs/spotlight -> @sentry/node) win the flat hoist over the
patched direct @sentry/core@10.63.0, so the CLI bundled the unpatched
copy (masked only by esbuild tree-shaking). isolated mode keeps
per-package variants so the patched copy is used. check-patches.ts now
reads patchedDependencies from the workspace root and resolves the
package copy the CLI actually links via require.resolve.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke,
patched bundle), and the full unit suite (399 files, 8474 passed).
The check-generated job's skill/docs-section verification steps still
referenced pre-move root-relative paths (plugins/, README.md,
DEVELOPMENT.md, docs/src/content/docs/*). After the packages/cli +
apps/cli-docs move those paths no longer exist, so `git diff --quiet
<nonexistent-path>` exits 128 (fatal), failing the "Validate generated
files" check even though the committed generated content is current.

Repoint all three references (check-skill, check-sections,
auto-commit) to:
- packages/cli/plugins/sentry-cli/skills/sentry-cli/
- packages/cli/README.md, packages/cli/DEVELOPMENT.md
- apps/cli-docs/src/content/docs/{contributing.md,self-hosted.md,getting-started.mdx}

Verified: `pnpm --filter sentry run generate:schema && generate:docs`
produces no diff against the committed files, and the git diff --quiet
commands now exit 0 instead of 128.
Follow-ups from the PR #1254 review (no behavior change to shipped CLI):

- check-patches.ts: harden resolvePackageFile() to derive the package
  root from the FIRST `<pkgName>/` after the last `node_modules/`
  boundary, instead of `lastIndexOf('/<pkgName>/')`. A package that
  vendors a nested copy of itself would otherwise truncate at the wrong
  inner segment. Also refresh the stale `node-linker=hoisted` comment.
- biome.jsonc / packages/cli/.gitignore: reconcile the contradictory
  comments about which .gitignore Biome reads. Biome honors the
  workspace-root .gitignore via `vcs.root: "../.."`; the package-level
  .gitignore is for plain git only. Drop the dead `!docs` ignore
  (no packages/cli/docs after the move).
- build.ts / bundle.ts: fix comments that still claimed deps are
  "hoisted to the workspace-root node_modules" — under node-linker=isolated
  they live in the isolated store; the code (module resolution / `pnpm
  exec`) is unchanged and correct.
- packages/cli/AGENTS.md: replace stale Bun-era guidance with the current
  pnpm/Node/Vitest reality — command reference, "Use Node.js APIs"
  section, test-runner isolation notes (VITEST_POOL_ID), vitest imports
  and `vi.mock`, moved docs path (apps/cli-docs), and removed the dangling
  `.cursor/rules/bun-cli.mdc` reference.

Verified: typecheck, lint, all check:* scripts, build (+ binary smoke).
Re-applies the three substantive commits (sync-scripts, move-eval-common,
bugbot B1+B2+B3) that the rebase dropped, plus the feedback files that
git's rename detector did not relocate on its own.

- packages/cli/package.json: take origin/main's `scripts` block verbatim
  so future drift lands via rebase, not by manual sync. Rebuild root
  delegating scripts from `pnpm --filter sentry run <name>`.
- Move `test/eval-common/anthropic-client.ts` into
  `packages/cli/test/eval-common/anthropic-client.ts` so the importing
  `packages/cli/test/script/eval-provider.test.ts` can resolve
  `../eval-common/anthropic-client.js`.
- Relocate `src/commands/feedback/{index,list,utils,view}.ts` and
  `test/commands/feedback/{list,utils,view}.test.ts` into
  `packages/cli/`. Other feedback files (`feedback.ts` in
  `src/lib/api`, `src/lib/formatters`, `src/types`, etc.) were already
  in the package thanks to git's rename detection during rebase; the
  remaining ones slipped through as newly added files.
- ci.yml: remove the duplicate bare `run: npm pack` step (the correct
  one with `working-directory: packages/cli` at line 874 stays).
  Paths-filter to `packages/cli/**` was preserved from the earlier
  B1 fix.
- packages/cli/LICENSE.md: copy + extend `files` to include LICENSE.md
  and README.md, so `npm pack` ships the license text and the
  README `LICENSE.md` link resolves inside the package.

Verified: typecheck, lint (950 files), check:patches, check:deps,
check:errors, check:stale-refs, check:fragments, check:docs-sections,
build (0.40.0-dev.0), feedback unit tests (15 files, 156 tests pass).
`packages/cli/script/bundle.ts` used a hardcoded
`./node_modules/node-sqlite3-wasm/dist/node-sqlite3-wasm.wasm` path,
inconsistent with how `@sentry/symbolic/symbolic_bg.wasm` is resolved a
few lines above via `createRequire(import.meta.url).resolve(...)`. Under
pnpm's isolated node-linker, the package may live in the isolated store
rather than this package's node_modules; the hardcoded path would crash
with raw ENOENT in that case.

Resolve the wasm via module resolution and add a `try/catch +
existsSync` guard with a clear `Run: pnpm install` error — matching the
pattern already in `script/build.ts`.

Verified: `pnpm run bundle` produces both `dist/node-sqlite3-wasm.wasm`
and `dist/vendor/symbolic_bg.wasm`. Typecheck clean.
@BYK
BYK force-pushed the chore/preshape-monorepo branch from c20f606 to 30ad8b0 Compare July 31, 2026 13:38
@BYK
BYK merged commit 96390e5 into main Jul 31, 2026
31 of 32 checks passed
@BYK
BYK deleted the chore/preshape-monorepo branch July 31, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toolkit merge: pre-shape CLI into packages/cli + apps/cli-docs

1 participant