Skip to content

Commit b9df046

Browse files
authored
Merge pull request #14 from Tarquinen/feat/version-check-logging
Add logging to version checker for better observability
2 parents 4cf3a47 + 832833b commit b9df046

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ If you want to ensure a specific version is always used or update your version,
7878
```json
7979
{
8080
"plugin": [
81-
"@tarquinen/[email protected].12"
81+
"@tarquinen/[email protected].13"
8282
]
8383
}
8484
```

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const plugin: Plugin = (async (ctx) => {
147147
})
148148

149149
// Check for updates on launch (fire and forget)
150-
checkForUpdates(ctx.client).catch(() => {})
150+
checkForUpdates(ctx.client, logger).catch(() => {})
151151

152152
return {
153153
/**

lib/version-checker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,23 @@ export function isOutdated(local: string, remote: string): boolean {
6565
* Checks for updates and shows a toast if outdated.
6666
* Fire-and-forget: does not throw, logs errors silently.
6767
*/
68-
export async function checkForUpdates(client: any): Promise<void> {
68+
export async function checkForUpdates(client: any, logger?: { info: (component: string, message: string, data?: any) => void }): Promise<void> {
6969
try {
7070
const local = getLocalVersion()
7171
const npm = await getNpmVersion()
7272

73-
if (!npm || !isOutdated(local, npm)) {
74-
return // Up to date or couldn't fetch
73+
if (!npm) {
74+
logger?.info("version", "Version check skipped", { reason: "npm fetch failed" })
75+
return
7576
}
7677

78+
if (!isOutdated(local, npm)) {
79+
logger?.info("version", "Up to date", { local, npm })
80+
return
81+
}
82+
83+
logger?.info("version", "Update available", { local, npm })
84+
7785
await client.tui.showToast({
7886
body: {
7987
title: "DCP: Update available",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@tarquinen/opencode-dcp",
4-
"version": "0.3.12",
4+
"version": "0.3.13",
55
"type": "module",
66
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
77
"main": "./dist/index.js",

0 commit comments

Comments
 (0)