Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lib/version-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down