fix(framework): install deps on worktree bootstrap + legible deps-preflight at gate seam (#856)
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
Worker git-worktrees under a fresh `git worktree add` have empty node_modules/.bin (pnpm workspaces do not share node_modules across worktrees), so every gate binary (tsc/eslint/prettier/vitest) fails with a raw `sh: 1: <tool>: not found` before the QA gate suite ever runs a real check. That failure is indistinguishable from a genuine test/lint failure -- a false-red gate that was responsible for 131/147 fleet tool-errors. - plugins/mosaic-framework/src/index.ts: the injected "Git Worktree Requirement" instructions now direct every worker to run `pnpm install --frozen-lockfile --prefer-offline` immediately after `git worktree add`/`cd`, before any gate is invoked. - packages/mosaic/framework/tools/qa/qa-hook-stdin.sh: the common gate-entry seam (registered as the PostToolUse hook for every Edit/Write/MultiEdit in runtime/claude/settings.json) now preflights node_modules/.bin presence for JS/TS files and fails with an explicit "deps not installed -- run pnpm install" sentinel instead of silently letting a raw not-found surface downstream. - packages/mosaic/framework/tools/qa/test-deps-preflight.sh: new regression harness (wired into test:framework-shell) covering missing node_modules/.bin, empty node_modules/.bin, populated node_modules/.bin, and non-JS/TS skip behavior. Closes #856.
This commit is contained in:
@@ -50,6 +50,21 @@ if ! [[ "$FILE_PATH" =~ \.(ts|tsx|js|jsx|mjs|cjs)$ ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Deps preflight (#856): this hook is the common gate-entry seam the delivery
|
||||
# cycle invokes on every Edit/Write/MultiEdit — it fires before any pnpm-based
|
||||
# gate (test/lint/typecheck/format:check) runs against the edited file. In a
|
||||
# freshly created git worktree (pnpm workspaces do NOT share node_modules
|
||||
# across worktrees), node_modules/.bin is empty until `pnpm install` has run,
|
||||
# so gate binaries (tsc/eslint/prettier/vitest) fail with a raw, illegible
|
||||
# `sh: 1: <tool>: not found` that is indistinguishable from a real failure.
|
||||
# Fail legibly here instead, before that raw error has a chance to surface.
|
||||
BIN_DIR="$PROJECT_ROOT/node_modules/.bin"
|
||||
if [ ! -d "$BIN_DIR" ] || [ -z "$(ls -A "$BIN_DIR" 2>/dev/null)" ]; then
|
||||
echo "deps not installed — run pnpm install" >&2
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [ERROR] deps not installed — run pnpm install ($BIN_DIR is missing or empty)" >> "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Call the main QA handler with extracted parameters
|
||||
if [ -f ~/.config/mosaic/tools/qa/qa-hook-handler.sh ]; then
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Calling QA handler for $FILE_PATH" >> "$LOG_FILE"
|
||||
|
||||
Reference in New Issue
Block a user