fix: pre-commit stages only originally-staged files; add .npmrc#538
Merged
fix: pre-commit stages only originally-staged files; add .npmrc#538
Conversation
Bug 1: .husky/pre-commit line 21 ran: git diff --name-only --diff-filter=M | xargs -r git add which stages EVERY modified tracked file in the worktree. If a contributor has unstaged WIP elsewhere, it gets silently swept into the commit. Fix: capture `git diff --name-only --cached` before running build/prettier, then only re-add that set. src/generated/ is staged explicitly since build:all regenerates it from spec.types.ts. Bug 2: no repo-local .npmrc meant the maintainer's global artifactory registry leaked into package-lock.json, requiring the Docker regen dance. Committing .npmrc with registry=https://registry.npmjs.org/ overrides user-global config. Docker regen is now optional (still useful for linux-amd64 optionalDeps).
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-preact
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-solid
@modelcontextprotocol/server-basic-svelte
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-basic-vue
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-debug
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
jonathanhefner
approved these changes
Mar 6, 2026
Member
jonathanhefner
left a comment
There was a problem hiding this comment.
.husky/pre-commit doesn't account for partially staged files (i.e., staged chunks), but that's no worse than before.
(Personally, I find .husky/pre-commit to be too invasive, so I disable it on my machine.)
ochafik
added a commit
that referenced
this pull request
Mar 10, 2026
Changes since 1.2.0: - fix: bundle SDK+zod in react-with-deps (was byte-identical to ./react) (#539) - fix(build): copy schema.json to dist and externalize zod (#534) - fix: skip debug log for high-frequency tool-input-partial notifications (#546) - fix(deps): drop @hono/node-server override to patch GHSA-wc8c-qw6v-h7f6 (#535) - fix(readme): use picture element for theme-aware logo (#545) - fix(ci): require maintainer association for /update-snapshots trigger (#532) - fix: pre-commit stages only originally-staged files; add .npmrc (#538) - ci: use npm ci with caching, validate typedoc links, align Node versions (#533) - test: exclude screenshot-gen from default E2E run; wire pdf-server tests (#537)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug 1: Pre-commit hook stages unrelated WIP
.husky/pre-commitline 21 ran:git diff --name-only --diff-filter=M | xargs -r git addThis stages every modified tracked file in the worktree, not just files that
prettier:fixorbuild:alltouched. If a contributor has unstaged WIP in other files, it gets silently swept into the commit.Fix: Capture
git diff --name-only --cachedbefore running build/prettier, then only re-add that set.src/generated/is staged explicitly sincebuild:allregenerates it fromspec.types.ts.Manual test
The OLD line 21 would have staged
src/app.tstoo (confirmed: it appears ingit diff --name-only --diff-filter=Moutput).Bug 2: No committed
.npmrcThe maintainer's global npm config points to an internal registry, so a naive
npm installwrites non-public URLs intopackage-lock.json. The pre-commit hook detects this (line 11) but doesn't prevent it — hence the Docker regen dance in CLAUDE.md.Fix: Commit a repo-root
.npmrcwithregistry=https://registry.npmjs.org/. This overrides user-global config, so a plainnpm iis now safe regardless of global settings.The Docker regen remains useful for locking linux-amd64
optionalDependencies(sharp, rollup, bun) for CI, but is no longer required for registry purity. AGENTS.md updated to note this (CLAUDE.md is a symlink to AGENTS.md).Files changed
.husky/pre-commit— capture staged set before build, re-stage only that +src/generated/.npmrc— new, pins registry to npmjs.orgAGENTS.md— note that.npmrcmakes Docker regen optional