From 32156ec03610cdf65e66d5bba4c4c669087208f6 Mon Sep 17 00:00:00 2001 From: alphinus_biosdesk Date: Wed, 11 Mar 2026 09:07:17 +0100 Subject: [PATCH] fix: sync pkg/package.json version with pi-coding-agent to prevent false update banner pkg/package.json had a hardcoded version (0.1.0) that never got updated. Since gsd-pi sets PI_PACKAGE_DIR=pkg/, pi's config.js reads VERSION from pkg/package.json. The update check compares this stale version against npm registry and always shows 'Update Available' even when the user is already on the latest release. Fix: - Update pkg/package.json to current pi-coding-agent version (0.57.1) - Add sync-pkg-version.cjs script that reads the installed pi-coding-agent version and writes it into pkg/package.json - Run the sync script in prepublishOnly so the version stays correct on every publish --- package.json | 3 ++- pkg/package.json | 2 +- scripts/sync-pkg-version.cjs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 scripts/sync-pkg-version.cjs diff --git a/package.json b/package.json index 0885f7bba..54350d911 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "test": "node --import ./src/resources/extensions/gsd/tests/resolve-ts.mjs --experimental-strip-types --test 'src/resources/extensions/gsd/tests/*.test.ts' 'src/resources/extensions/gsd/tests/*.test.mjs' 'src/tests/*.test.ts'", "dev": "tsc --watch", "postinstall": "node scripts/postinstall.js", - "prepublishOnly": "npm run build" + "sync-pkg-version": "node scripts/sync-pkg-version.cjs", + "prepublishOnly": "npm run sync-pkg-version && npm run build" }, "dependencies": { "@mariozechner/pi-coding-agent": "^0.57.1", diff --git a/pkg/package.json b/pkg/package.json index 63e03be4e..815c69232 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -1,6 +1,6 @@ { "name": "@glittercowboy/gsd", - "version": "0.1.0", + "version": "0.57.1", "piConfig": { "name": "gsd", "configDir": ".gsd" diff --git a/scripts/sync-pkg-version.cjs b/scripts/sync-pkg-version.cjs new file mode 100644 index 000000000..9424040a2 --- /dev/null +++ b/scripts/sync-pkg-version.cjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node +/** + * Sync pkg/package.json version with the installed @mariozechner/pi-coding-agent version. + * + * gsd-pi sets PI_PACKAGE_DIR=pkg/ so that pi's config.js reads piConfig from + * pkg/package.json (for branding: name="gsd", configDir=".gsd"). However, config.js + * also reads `version` from that same file and uses it for the update check + * (comparing against npm registry). If pkg/package.json has a stale version, + * pi's update banner fires even when the user is already on the latest release. + * + * This script reads the actual installed pi-coding-agent version and writes it + * into pkg/package.json so VERSION is always correct at publish time. + */ +const { readFileSync, writeFileSync } = require('fs') +const { resolve, join } = require('path') + +const root = resolve(__dirname, '..') +const piPkgPath = join(root, 'node_modules', '@mariozechner', 'pi-coding-agent', 'package.json') +const gsdPkgPath = join(root, 'pkg', 'package.json') + +const piPkg = JSON.parse(readFileSync(piPkgPath, 'utf-8')) +const gsdPkg = JSON.parse(readFileSync(gsdPkgPath, 'utf-8')) + +if (gsdPkg.version !== piPkg.version) { + console.log(`[sync-pkg-version] Updating pkg/package.json version: ${gsdPkg.version} → ${piPkg.version}`) + gsdPkg.version = piPkg.version + writeFileSync(gsdPkgPath, JSON.stringify(gsdPkg, null, 2) + '\n') +} else { + console.log(`[sync-pkg-version] pkg/package.json version already matches: ${piPkg.version}`) +}