From 74170d2613bce874c29df731993163e1c098fddb Mon Sep 17 00:00:00 2001 From: "Fredrik Liljegren (Claude Code Claude Opus 5)" Date: Tue, 25 Aug 2026 11:50:13 +0200 Subject: [PATCH] chore: bump the version in every PR, and make that possible A running instance replaces itself only when the binary's version differs from the one it registered, so merging a behaviour change without a bump leaves every open instance on the old build until someone restarts it by hand. Two merges have gone in that way. `scripts/release.ts` could not be used inside a branch: it commits and tags, and develop takes squash merges, so the commit is rewritten and the tag is left pointing at a commit that never lands. `--no-git` writes the versions and stops there. v0.9.7, which is this rule applied to the pull request that adds it. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_018PkYQzbsnMihHesafWvXKs --- AGENTS.md | 25 +++++++++++++++++++++++++ package-lock.json | 10 +++++----- packages/cli/package.json | 2 +- packages/git/package.json | 2 +- packages/github/package.json | 2 +- packages/parser/package.json | 2 +- packages/ui/package.json | 2 +- scripts/release.ts | 20 ++++++++++++++------ 8 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..884fce2 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,25 @@ +# Working on diffity + +## Bump the version in every pull request + +A running instance replaces itself only when the binary's version differs from the one it +registered (`packages/cli/src/index.ts`, `isStale`). Merge a behaviour change without a bump and +every instance already running keeps serving the old build, silently, until someone restarts it by +hand. So the version is not a release ceremony here — it is how a change reaches the people who +have diffity open. + +Bump inside the pull request, as part of the branch: + +```bash +npx tsx scripts/release.ts patch --no-git # or: minor +``` + +`--no-git` is what makes it safe in a branch. Without it the script commits and tags, and since +`develop` takes squash merges the commit is rewritten on the way in and the tag is left pointing at +a commit that never lands. + +Do not use the `release:patch` / `release:minor` npm scripts for this. They publish to npm, which +is a separate decision and, in this fork, one that is not ours to make. + +A pull request that changes nothing a user could observe — a test, a comment, a rename — does not +need a bump. Everything else does. diff --git a/package-lock.json b/package-lock.json index fac1498..3d488e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8452,7 +8452,7 @@ }, "packages/cli": { "name": "diffity", - "version": "0.9.6", + "version": "0.9.7", "license": "MIT", "dependencies": { "commander": "^14.0.3", @@ -8476,7 +8476,7 @@ }, "packages/git": { "name": "@diffity/git", - "version": "0.9.6", + "version": "0.9.7", "devDependencies": { "@types/node": "^25.5.0", "typescript": "^5.9.3", @@ -8485,7 +8485,7 @@ }, "packages/github": { "name": "@diffity/github", - "version": "0.9.6", + "version": "0.9.7", "dependencies": { "@diffity/parser": "*" }, @@ -8497,7 +8497,7 @@ }, "packages/parser": { "name": "@diffity/parser", - "version": "0.9.6", + "version": "0.9.7", "devDependencies": { "typescript": "^5.9.3", "vitest": "^4.1.0" @@ -8505,7 +8505,7 @@ }, "packages/ui": { "name": "@diffity/ui", - "version": "0.9.6", + "version": "0.9.7", "dependencies": { "@react-router/node": "^7.13.2", "@tailwindcss/vite": "^4.2.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 4681a9b..79cc535 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "diffity", - "version": "0.9.6", + "version": "0.9.7", "description": "GitHub-style git diff viewer in the browser", "type": "module", "bin": { diff --git a/packages/git/package.json b/packages/git/package.json index 3ecb838..cc33dd8 100644 --- a/packages/git/package.json +++ b/packages/git/package.json @@ -1,6 +1,6 @@ { "name": "@diffity/git", - "version": "0.9.6", + "version": "0.9.7", "private": true, "type": "module", "main": "./dist/index.js", diff --git a/packages/github/package.json b/packages/github/package.json index ba0face..606217c 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -1,6 +1,6 @@ { "name": "@diffity/github", - "version": "0.9.6", + "version": "0.9.7", "private": true, "type": "module", "main": "./dist/index.js", diff --git a/packages/parser/package.json b/packages/parser/package.json index 9cad92e..9dd16f7 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@diffity/parser", - "version": "0.9.6", + "version": "0.9.7", "private": true, "type": "module", "main": "./dist/index.js", diff --git a/packages/ui/package.json b/packages/ui/package.json index 0259a9a..0350035 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@diffity/ui", - "version": "0.9.6", + "version": "0.9.7", "type": "module", "private": true, "scripts": { diff --git a/scripts/release.ts b/scripts/release.ts index d5568ae..a6359d7 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -15,9 +15,13 @@ const packagePaths = [ 'packages/ui', ]; -const bump = process.argv[2] as 'patch' | 'minor'; +const args = process.argv.slice(2); +const bump = args.find(arg => !arg.startsWith('--')) as 'patch' | 'minor'; +// A bump that travels inside a pull request must not commit or tag: develop takes squash merges, +// so the commit this would make is rewritten and the tag is left pointing at a commit nobody has. +const noGit = args.includes('--no-git'); if (bump !== 'patch' && bump !== 'minor') { - console.error('Usage: tsx scripts/release.ts '); + console.error('Usage: tsx scripts/release.ts [--no-git]'); process.exit(1); } @@ -51,8 +55,12 @@ for (const pkgDir of packagePaths) { writeFileSync(lockPath, JSON.stringify(lockJson, null, 2) + '\n'); filesToStage.push('package-lock.json'); -execSync(`git add ${filesToStage.join(' ')}`, { cwd: root, stdio: 'inherit' }); -execSync(`git commit -m "chore: release v${newVersion}"`, { cwd: root, stdio: 'inherit' }); -execSync(`git tag v${newVersion}`, { cwd: root, stdio: 'inherit' }); +if (noGit) { + console.log(`\nBumped to ${newVersion}. Commit it with the rest of your branch.`); +} else { + execSync(`git add ${filesToStage.join(' ')}`, { cwd: root, stdio: 'inherit' }); + execSync(`git commit -m "chore: release v${newVersion}"`, { cwd: root, stdio: 'inherit' }); + execSync(`git tag v${newVersion}`, { cwd: root, stdio: 'inherit' }); -console.log(`\nTagged v${newVersion}`); + console.log(`\nTagged v${newVersion}`); +}