Skip to content

chore(PLA-118): migrate to pnpm workspace (packages/cli, packages/types, packages/web)#14

Merged
dastratakos merged 6 commits into
mainfrom
dean/pla-118-issue-10-migrate-to-pnpm-workspace-packagescli-packagestypes
May 3, 2026
Merged

chore(PLA-118): migrate to pnpm workspace (packages/cli, packages/types, packages/web)#14
dastratakos merged 6 commits into
mainfrom
dean/pla-118-issue-10-migrate-to-pnpm-workspace-packagescli-packagestypes

Conversation

@dastratakos

@dastratakos dastratakos commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Restructure stage-cli into a pnpm workspace mirroring diffity's layout, replacing the @cli/types tsconfig path-alias with a real workspace package (@stage-cli/types). Pure structural change — every gate that passed before still passes.

Changes

  • Workspace root: pnpm-workspace.yaml declares packages/* and owns onlyBuiltDependencies (better-sqlite3, esbuild). Root package.json keeps Biome/husky/lint-staged/vitest and delegates package-level scripts to pnpm --filter / pnpm -r.
  • packages/cli (stagereview, the published npm package): moved src/, drizzle/, drizzle.config.ts, tsdown.config.ts, tsconfig.json into packages/cli/. tsdown's deps.alwaysBundle: [/^@stage-cli\//] inlines workspace deps into the bundle so end users never see a runtime @stage-cli/types require. prepack copies the root README into the package so the npm tarball still includes it.
  • packages/types (@stage-cli/types, private, TS-native): new package with exports map for ., ./chapters, ./view-state. Hosts HunkRef / LineRef / DIFF_SIDE so the SPA wire-format and the CLI's strict ingestion schema share one source of truth.
  • packages/web (@stage-cli/web, private): moved web/src/, vite.config.ts, tsconfig.json, components.json. Vite outputs the SPA into ../cli/web-dist. Dropped vite-tsconfig-paths; @/* is now a plain resolve.alias and @cli/types/* is gone entirely.
  • CI / tooling: .github/workflows/ci.yml uses one combined pnpm build, the drizzle-drift check points at packages/cli/drizzle/, and biome.json uses **/drizzle so the relocated migrations stay excluded.
  • Docs: AGENTS.md and TESTING.md rewritten with the new directory map and command references.

Testing

  • pnpm typecheck (per-package via pnpm -r) — green
  • pnpm test — 65/65 across both CLI and web tests
  • pnpm lint — clean (74 files)
  • pnpm build — produces packages/cli/dist/index.js (22.7 kB, no @stage-cli/types runtime imports) and packages/cli/web-dist/*
  • pnpm publish --dry-run --filter stagereview — tarball contains LICENSE, README.md, dist/, drizzle/, web-dist/, package.json
  • pnpm db:generate — no schema changes detected (config resolves correctly from packages/cli/)

Open in Stage

…es, packages/web)

Restructure stage-cli into a pnpm workspace mirroring diffity's layout.
Drops the @cli/types path-alias indirection in favor of a real workspace
package (@stage-cli/types) that tsdown inlines into the published bundle
and vite resolves natively for the SPA. Pure structural change — every
gate that passed before still passes (typecheck, lint, test, build, and
publish --dry-run).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the project from a single-package repository to a pnpm workspace, organizing the codebase into three distinct packages: packages/cli, packages/web, and packages/types. The changes include restructuring the directory layout, updating build scripts, and adjusting configuration files like tsconfig.json and vite.config.ts to handle workspace dependencies. Feedback focuses on ensuring the integrity of the published CLI package by verifying the location of runtime assets and the inclusion of a license file. Additionally, there are recommendations to fix type-resolution issues caused by the new moduleResolution settings and to expand TypeScript's scope to include configuration files.

Comment thread packages/cli/package.json
Comment thread packages/cli/tsconfig.json
Comment thread packages/cli/package.json
Comment thread packages/cli/tsconfig.json
The reference to "@stage-cli/cli" was a non-existent package name; the
strict ingestion schema lives at packages/cli/src/schema.ts.
pnpm publish rewrites workspace:* to a literal version, so the published
manifest listed @stage-cli/types@0.1.0 as a runtime dep — but that package
is private and never reaches npm, breaking consumer installs with
ERR_PNPM_FETCH_404. tsdown already inlines the package via deps.alwaysBundle
so it's only needed at build time.
…ed stage

Drops the back-compat `HunkRef as HunkReference` re-export alias from
packages/cli/src/schema.ts. Hosted stage uses HunkReference as the
canonical name; aligning here lets the DB schema import HunkReference
through the existing schema.ts re-export without an alias.
Update agent guidance files that referenced removed scripts and pre-migration paths:
- frontend-error-fixer drops `pnpm build:web` (folded into `pnpm build`)
- auto-error-resolver replaces `tsc -p web/tsconfig.json` with the per-package `pnpm typecheck` filters and corrects the "single Node package" framing
- code-architecture-reviewer points at `packages/cli/` and `packages/web/` and adds `packages/types` to the package-placement rubric
Revert the rename to stagereview-monorepo. The root is private (private:
true), so pnpm doesn't enforce uniqueness, and `pnpm --filter stagereview`
still resolves to packages/cli alone (pnpm 10 excludes the workspace root
from filter matches).
@dastratakos dastratakos marked this pull request as ready for review May 3, 2026 00:58
@dastratakos dastratakos merged commit a203718 into main May 3, 2026
5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7bfaea829

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"build": "tsdown",
"build:web": "vite build --config web/vite.config.ts",
"dev:web": "vite --config web/vite.config.ts",
"build": "pnpm --filter @stage-cli/web build && pnpm --filter stagereview build",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Disambiguate pnpm filter target for CLI package scripts

The workspace now has two packages named stagereview (/package.json and packages/cli/package.json), but these scripts still use pnpm --filter stagereview .... Per pnpm’s filtering docs, when multiple workspace packages share the same name, an unscoped name filter matches nothing; and pnpm-workspace.yaml docs state the root package is always included in the workspace. This means build (and similarly db:generate) can silently skip the CLI package, so CI/local runs may pass without actually building packages/cli or regenerating migrations.

Useful? React with 👍 / 👎.

@dastratakos dastratakos deleted the dean/pla-118-issue-10-migrate-to-pnpm-workspace-packagescli-packagestypes branch May 4, 2026 05:09
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