Skip to content

feat(version): keep every version field in sync with package.json - #174

Merged
ramarivera merged 2 commits into
mainfrom
feat/version-sync-guard
Jul 28, 2026
Merged

feat(version): keep every version field in sync with package.json#174
ramarivera merged 2 commits into
mainfrom
feat/version-sync-guard

Conversation

@ramarivera

@ramarivera ramarivera commented Jul 28, 2026

Copy link
Copy Markdown
Owner

package.json was the only version that moved. The plugin manifests fell three minors behind and the MCP handshake fell further still. #173 corrected those by hand — this stops it happening again.

  • scripts/sync-version.ts rewrites drifted manifest fields, or under --check reports them and exits 1.
  • CI runs --check, so drift cannot land.
  • The npm version lifecycle runs the fixer and git-adds .claude-plugin, so a bump updates the manifests in the same commit as package.json.
  • server/index.ts imports pkg.version instead of a literal — strictly better than syncing one. A test asserts no hardcoded semver returns to that call.

Verified both directions

Not just "it passes":

$ # inject 0.1.0 into plugin.json
$ bun run sync-version --check
DRIFT: .claude-plugin/plugin.json :: version 0.1.0 -> 0.9.3
sync-version: version fields are out of sync with package.json.
exit 1

$ bun run sync-version
sync: .claude-plugin/plugin.json :: version 0.1.0 -> 0.9.3
exit 0

The fixer restores the file byte-identicallygit diff is empty afterwards, so the 4-space manifest formatting round-trips.

bun test475 pass, 0 fail (4 new). bun run typecheck clean.

Credit

Design and the original implementation are from #110 by @grlee. That PR now conflicts with main and lives on a fork, so it could not be rebased — this reimplements the same approach. #110 should be closed in favour of this one, with thanks.

🤖 Created with the help of AI (Claude Opus 5).


Open in Devin Review

Note

Keep version fields in .claude-plugin manifests and MCP server in sync with package.json

  • Adds scripts/sync-version.ts to detect and fix version drift between package.json and the .claude-plugin/plugin.json and .claude-plugin/marketplace.json manifests.
  • Wires the script into a sync-version npm script and a version lifecycle hook that stages manifest changes automatically on npm version.
  • Replaces the hardcoded version string in server/index.ts with pkg.version imported from package.json.
  • Adds a CI step that runs bun run sync-version --check to fail the build on any drift.
  • Enables resolveJsonModule in tsconfig.json and includes scripts/**/*.ts to support the new script and JSON import.

Macroscope summarized 0d5d417.

package.json was the only version that moved. The plugin manifests fell three
minors behind and the MCP handshake fell further still, which #173 corrected by
hand — this stops it recurring.

- scripts/sync-version.ts rewrites drifted manifest fields, or reports them and
  exits 1 under --check.
- CI runs --check, so drift cannot land.
- The npm `version` lifecycle runs the fixer and git-adds .claude-plugin, so a
  bump updates the manifests in the same commit.
- server/index.ts imports pkg.version instead of a literal, which is better than
  syncing it — a test asserts no hardcoded semver returns to that call.

Design and the original implementation are from #110 by @grlee. That PR now
conflicts with main and lives on a fork, so it could not be rebased; this
reimplements it and #110 should be closed in its favour.

Verified both directions: injecting 0.1.0 into plugin.json makes --check exit 1
with an exact report, and the fixer restores the file byte-identically.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2GXsqpMvUhxBSNabSqZdk
Copilot AI review requested due to automatic review settings July 28, 2026 03:44
@github-project-automation github-project-automation Bot moved this to Todo in Kanban Jul 28, 2026
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b7fade68-7877-4196-aeb3-8e3f7e02a951

📥 Commits

Reviewing files that changed from the base of the PR and between 27bf369 and 0d5d417.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • package.json
  • scripts/sync-version.test.ts
  • scripts/sync-version.ts
  • server/index.ts
  • tsconfig.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-sync-guard

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 3 potential issues.

Open in Devin Review

Comment thread server/index.ts
Comment thread scripts/sync-version.ts
Comment thread scripts/sync-version.ts

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

Pull request overview

This PR makes package.json the single source of truth for the project version and prevents drift across the Claude plugin manifests and the MCP server’s advertised handshake version by adding an automated sync/check workflow.

Changes:

  • Added scripts/sync-version.ts to detect and fix version-field drift across .claude-plugin/*, with a --check mode for CI.
  • Updated MCP server handshake to read version from package.json instead of a hardcoded literal, and added tests to prevent regressions.
  • Wired the version sync into both CI and the npm version lifecycle so version bumps update related manifests in the same commit.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/index.ts Imports pkg.version and uses it in the MCP server handshake instead of a literal.
scripts/sync-version.ts New script to detect and optionally rewrite drifted manifest version fields based on package.json.
scripts/sync-version.test.ts Adds tests asserting versions are in sync and preventing reintroduction of a hardcoded handshake semver.
package.json Adds sync-version script and hooks it into the version lifecycle to auto-stage manifest updates.
.github/workflows/ci.yml Adds a CI guard that runs sync-version --check to block version drift from landing.

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

Comment thread package.json
Comment thread scripts/sync-version.test.ts Outdated

@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: 0ffd32d290

ℹ️ 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 scripts/sync-version.ts Outdated
…urce assertion

Review round 1 (Copilot, Devin):

- tsconfig `include` did not cover scripts/, so sync-version.ts was never
  typechecked despite CI now running it. Added scripts/**/*.ts, and set
  resolveJsonModule explicitly since server/index.ts now imports package.json.
  Verified with --listFilesOnly that both the script and package.json are in
  the program.
- The marketplace metadata.version setter was guarded by `if (doc.metadata)`,
  so an absent metadata block would be reported as drift the fixer could never
  resolve. It now creates the block. Verified by deleting the field: --check
  reports it, the fixer restores it.
- The "no hardcoded semver" assertion scanned all of server/index.ts. Scoped to
  the new McpServer(...) options object so an unrelated literal cannot fail it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2GXsqpMvUhxBSNabSqZdk
@ramarivera
ramarivera merged commit dd66c49 into main Jul 28, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Kanban Jul 28, 2026
@ramarivera
ramarivera deleted the feat/version-sync-guard branch July 28, 2026 03:58
ramarivera added a commit that referenced this pull request Jul 28, 2026
0.9.3 was published from the release commit, before the version-field fixes
merged, so its tarball still carried plugin manifests at 0.8.0 and an MCP
handshake at 0.6.0. Nothing consuming the published package could see correct
versions. This ships them.

Contents since 0.9.3:
- #173 synced the plugin manifests and the MCP handshake version.
- #174 added scripts/sync-version.ts, a CI drift check, and the npm version
  lifecycle hook, so this bump updated all three manifests in one command.


Claude-Session: https://claude.ai/code/session_01H2GXsqpMvUhxBSNabSqZdk

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

2 participants