The review step runs `npm ci` inside an npm workspace package, silently deleting the rest of the monorepo's dependencies

オープン 初心者向け
#1,633 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
tooling

調査の方向性

まず src/programs/posthog-integration/agent/review.md にある固定された再インストールの指示を確認し、次に issue で参照されている npm 固有のインストールと workspace の処理を読みます。review ステップがインストールコマンドをどのように選ぶか、提案されている npm ci --dry-run がそのフローに適合するかを確認してください。npm の review チェックが、他の workspace パッケージから依存関係を削除せずに lockfile の不一致を検出したら完了です。

索引モデルが issue の本文から書いたものです。

説明

What happened

I ran the wizard (3.0.0) on an npm workspaces monorepo with --install-dir apps/web. The repo has one package-lock.json and one node_modules at the root, shared tools (typescript, @biomejs/biome, @playwright/test) as root devDependencies, and four workspace packages (apps/web, apps/server, apps/desktop, packages/shared).

During Verify and review the integration, the agent ran these from apps/web:

npm add posthog-js@1
npm ci                 # "npm's clean lockfile install check before compilation"
npm run build          # passed
npm run typecheck      # sh: tsc: command not found

Afterwards the root node_modules held only apps/web's dependency graph. typescript, @biomejs/biome, @playwright/test, electron and the other workspace links were gone. package-lock.json was unchanged, so git status showed nothing. Running npm install at the root restored everything.

The run summary said "verified a clean npm ci" and reported the typecheck as "unavailable because typescript is not declared in this package".

Why

src/programs/posthog-integration/agent/review.md asks for a frozen re-install after the last install:

https://github.com/PostHog/wizard/blob/f1cc489e38aae76e5e86a7b028861cdc9b284f5e/src/programs/posthog-integration/agent/review.md#L69-L72

After your last install, run the project's install once more without changing the lockfile (pnpm install --frozen-lockfile or its equivalent)

On npm the equivalent is npm ci, and with cd unavailable it runs in the workspace package. There npm scopes the command to that one package. npm ci deletes node_modules, then reinstalls only that package's dependencies. pnpm and yarn install the whole workspace from a sub-folder, so they don't have this problem.

The agent couldn't have worked around it:

  • The integration-build skill says to work only inside the project folder.
  • bash-fence.ts refuses directory flags that point outside it, so npm --prefix <root> ci isn't possible.
  • The agent's own detection ran from apps/web and saw a single-package repo, although the wizard's discovery had logged repoType=monorepo and detect_package_manager reported "the workspace lockfile is in ".
Minimal reproduction (npm 11.19.0, Node 24, macOS)
mkdir repro && cd repro && git init -q
cat > package.json <<'EOF'
{ "name": "repro", "private": true, "workspaces": ["apps/*"], "devDependencies": { "is-number": "7.0.0" } }
EOF
mkdir -p apps/web apps/api
echo '{ "name": "@repro/web", "version": "1.0.0", "private": true, "dependencies": { "ms": "2.1.3" } }' > apps/web/package.json
echo '{ "name": "@repro/api", "version": "1.0.0", "private": true, "dependencies": { "left-pad": "1.3.0" } }' > apps/api/package.json
npm install
ls node_modules                      # @repro  is-number  left-pad  ms
(cd apps/web && npm ci --dry-run)    # "up to date", nothing removed
(cd apps/web && npm ci)
ls node_modules                      # @repro  ms   <- is-number, left-pad and @repro/api are gone
Suggested fix

On npm, use npm ci --dry-run for the frozen re-check. It runs the same lockfile sync check as npm ci: when package.json and package-lock.json disagree, it fails with EUSAGE … Missing: <pkg> from lock file. It never deletes node_modules, it is safe from any workspace folder, and the bash fence already allows it.

It is weaker than a real npm ci in one way: a dry run downloads nothing and runs no install scripts, so a package whose download or install script would fail on a fresh install gets past it. On npm that gap is small: the npm add just before it had already downloaded the same packages and run their scripts. npm 11's allowScripts policy, its counterpart to pnpm's ignored build scripts, applies to that npm add as well, so a refused install script would show up there rather than in the dry run. Closing the gap would take a real npm ci from the workspace root. bash-fence.ts refuses directory flags outside the project folder, and that command would reinstall the whole monorepo.

 the project's install once more without changing the lockfile (`pnpm install
---frozen-lockfile` or its equivalent): if it fails on a package this run added, that package
+--frozen-lockfile`, `npm ci --dry-run` on npm,  or its equivalent): if it fails on a package this run added, that package
 does not fit.

Happy to test a fix against the same monorepo.

主要言語
TypeScript
スター
208
フォーク
58
平均マージ
2日 7時間
マージ済み PR(30日)
76

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PostHog/wizard のほかの issue

PostHog/wizard の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。