From 3d4f77b2ee37d6a530b7122146c2a66a9fc0f47d Mon Sep 17 00:00:00 2001 From: Jeremy McSpadden Date: Tue, 17 Mar 2026 22:59:25 -0500 Subject: [PATCH] fix: inline compareSemver in gsd extension to fix broken relative import (#1058) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /gsd update command imported compareSemver from ../../../update-check.js, a relative path that resolves correctly in the source tree (src/resources/ extensions/gsd/ → src/update-check.js) but breaks when extensions are synced to ~/.gsd/agent/extensions/gsd/ (where ../../../ points to ~/.gsd/ which has no update-check.js). This caused the error: Extension "command:gsd" error: Cannot find module '../../../update-check.js' Fix: inline a local compareSemverLocal() function in commands.ts, eliminating the cross-tree import. The function is small (10 lines) and already well-tested via update-check.test.ts. --- src/resources/extensions/gsd/commands.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/resources/extensions/gsd/commands.ts b/src/resources/extensions/gsd/commands.ts index 1a1d17f27..82270e32e 100644 --- a/src/resources/extensions/gsd/commands.ts +++ b/src/resources/extensions/gsd/commands.ts @@ -2283,9 +2283,20 @@ Examples: // ─── Self-update handler ──────────────────────────────────────────────────── +function compareSemverLocal(a: string, b: string): number { + const pa = a.split('.').map(Number) + const pb = b.split('.').map(Number) + for (let i = 0; i < Math.max(pa.length, pb.length); i++) { + const va = pa[i] || 0 + const vb = pb[i] || 0 + if (va > vb) return 1 + if (va < vb) return -1 + } + return 0 +} + async function handleUpdate(ctx: ExtensionCommandContext): Promise { const { execSync } = await import("node:child_process"); - const { compareSemver } = await import("../../../update-check.js"); const NPM_PACKAGE = "gsd-pi"; const current = process.env.GSD_VERSION || "0.0.0"; @@ -2303,7 +2314,7 @@ async function handleUpdate(ctx: ExtensionCommandContext): Promise { return; } - if (compareSemver(latest, current) <= 0) { + if (compareSemverLocal(latest, current) <= 0) { ctx.ui.notify(`Already up to date (v${current}).`, "info"); return; }