diff --git a/lib/version-checker.ts b/lib/version-checker.ts index 9233929..642edef 100644 --- a/lib/version-checker.ts +++ b/lib/version-checker.ts @@ -12,9 +12,22 @@ const __dirname = dirname(__filename) export function getLocalVersion(): string { try { - const pkgPath = join(__dirname, '../../package.json') - const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) - return pkg.version + // Walk up from the current module to find the project's package.json + // This works whether running from dist/lib/, lib/, or installed in node_modules + let dir = __dirname + for (let i = 0; i < 5; i++) { + const pkgPath = join(dir, 'package.json') + try { + const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) + if (pkg.name === '@tarquinen/opencode-dcp') { + return pkg.version + } + } catch { + // Not found at this level, go up + } + dir = join(dir, '..') + } + return '0.0.0' } catch { return '0.0.0' } diff --git a/package-lock.json b/package-lock.json index 8965d17..2341bd4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tarquinen/opencode-dcp", - "version": "0.4.7", + "version": "0.4.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tarquinen/opencode-dcp", - "version": "0.4.7", + "version": "0.4.8", "license": "MIT", "dependencies": { "@ai-sdk/openai-compatible": "^1.0.28", diff --git a/package.json b/package.json index 9f6ae75..8cedf2f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@tarquinen/opencode-dcp", - "version": "0.4.7", + "version": "0.4.8", "type": "module", "description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context", "main": "./dist/index.js",