Skip to content

fix(package): scope version script git staging to package.json only - #339

Merged
avifenesh merged 1 commit into
agent-sh:mainfrom
xiaolai:fix/nlpm-version-script-git-add
Apr 23, 2026
Merged

fix(package): scope version script git staging to package.json only#339
avifenesh merged 1 commit into
agent-sh:mainfrom
xiaolai:fix/nlpm-version-script-git-add

Conversation

@xiaolai

@xiaolai xiaolai commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Automated audit: This PR was generated by NLPM, a natural language programming linter, running via claude-code-action. Please evaluate the diff on its merits.

Security Finding (Low)

package.json line 40: the version lifecycle script runs git add -A after stamping the version, which stages all working-tree changes — not just the version bump.

If a developer has unrelated uncommitted changes in their working tree at the time they run npm version, those changes will be silently included in the version bump commit. This can inadvertently publish in-progress work, debug code, or sensitive scratchpad content.

Fix

Replace git add -A with git add package.json to stage only the file that was actually changed by the version stamp script.

If scripts/stamp-version.js also writes to other files (e.g., a VERSION file or changelog), those specific files should be added explicitly rather than using the catch-all -A.

Copilot AI review requested due to automatic review settings April 23, 2026 06:46
@xiaolai
xiaolai requested a review from avifenesh as a code owner April 23, 2026 06:46

@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 updates the version script in package.json to stage only the package.json file instead of using git add -A. Feedback indicates that this change will cause an inconsistent repository state because the version stamping script modifies several other files that would no longer be included in the version commit. It is recommended to explicitly stage all files modified by the script.

Comment thread package.json Outdated

Copilot AI 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.

Pull request overview

This PR adjusts the npm version lifecycle script to avoid staging unrelated working-tree changes during version bumps, reducing the risk of accidentally committing in-progress or sensitive files.

Changes:

  • Replaced git add -A with git add package.json in the version lifecycle script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json Outdated
@avifenesh

Copy link
Copy Markdown
Collaborator

Thanks @xiaolai! Took your patch and broadened the allowlist in 30a78e9 to cover every file stamp-version.js writes plus npm's own package-lock.json. Preserves the PR's original intent (don't sweep unrelated working-tree changes) while keeping all version manifests in sync after npm version. Merging.

Replaces 'git add -A' in the npm version lifecycle script with an
explicit allowlist:
- package.json
- package-lock.json (npm version writes this)
- .claude-plugin/plugin.json
- .claude-plugin/marketplace.json
- site/content.json

Original PR agent-sh#339 from xiaolai (NLPM audit) flagged that 'git add -A'
sweeps any unrelated working-tree changes into the version commit.
This is the broadened-allowlist version per Copilot's review suggestion -
preserves the intent (no working-tree sweep) while keeping all version
manifests in sync.

Co-authored-by: xiaolai <xiaolai@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 13:27
@avifenesh
avifenesh force-pushed the fix/nlpm-version-script-git-add branch from 30a78e9 to bcdff00 Compare April 23, 2026 13:27
@avifenesh
avifenesh merged commit 8295196 into agent-sh:main Apr 23, 2026
5 checks passed

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
"detect": "node bin/dev-cli.js detect",
"verify": "node bin/dev-cli.js verify",
"version": "node scripts/stamp-version.js && git add -A",
"version": "node scripts/stamp-version.js && git add package.json package-lock.json .claude-plugin/plugin.json .claude-plugin/marketplace.json site/content.json",

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

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

The PR title/description suggests scoping staging to package.json only, but the updated version script stages an explicit allowlist of 5 files (including package-lock.json, .claude-plugin/*, and site/content.json). Consider updating the PR title/description to reflect the allowlist approach (or, if the intent truly is package.json-only, remove the extra paths).

Copilot uses AI. Check for mistakes.
@avifenesh avifenesh mentioned this pull request Apr 23, 2026
5 tasks
avifenesh added a commit that referenced this pull request Apr 23, 2026
Bot review caught that CHANGELOG.md is part of the release prep flow
(developer manually edits it before running `npm version`), so it must
be in the lifecycle script's `git add` allowlist - otherwise
`npm version`'s auto-commit drops the changelog entry, leaving the
version bump committed but the changelog entry stranded as unstaged.

Updates the CHANGELOG #339/#342 description to reflect the new file.
avifenesh added a commit that referenced this pull request Apr 23, 2026
* chore: release v5.8.5

* fix: include CHANGELOG.md in npm version allowlist

Bot review caught that CHANGELOG.md is part of the release prep flow
(developer manually edits it before running `npm version`), so it must
be in the lifecycle script's `git add` allowlist - otherwise
`npm version`'s auto-commit drops the changelog entry, leaving the
version bump committed but the changelog entry stranded as unstaged.

Updates the CHANGELOG #339/#342 description to reflect the new file.
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.

3 participants