singularity-forge/scripts/sync-pkg-version.cjs
Lex Christopherson c80d640d35 feat: vendor Pi source into workspace monorepo
Vendor all 4 Pi packages (tui, ai, agent-core, coding-agent) from
pi-mono v0.57.1 as @gsd/* workspace packages under packages/. This
replaces the compiled npm dependency (@mariozechner/pi-coding-agent)
and patch-package workflow, giving direct source access for
modifications.

- Copy Pi source from pi-mono v0.57.1 into packages/
- Create workspace package.json + tsconfig.json for each package
- Rename ~240 imports from @mariozechner/pi-* to @gsd/pi-*
- Apply existing patches as source edits (setModel persist, VT input)
- Remove @mariozechner/pi-coding-agent dep and patch-package
- Update build pipeline to build packages in dependency order
- Add pi-upstream git remote for future selective syncing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 21:55:17 -06:00

30 lines
1.4 KiB
JavaScript

#!/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, 'packages', '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}`)
}