Skip to content

Commit 7f3583b

Browse files
committed
Add prerelease update checks and bump version to 0.4.1
Enhanced the update check logic to notify users of both stable and prerelease updates depending on their current version. Added 'semver' and its types as dependencies, and updated the version to 0.4.1 in manifest and package files.
1 parent 9d2dc97 commit 7f3583b

File tree

4 files changed

+86
-16
lines changed

4 files changed

+86
-16
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "agent-client",
33
"name": "Agent Client",
4-
"version": "0.4.0",
4+
"version": "0.4.1",
55
"minAppVersion": "0.15.0",
66
"description": "Chat with AI agents via the Agent Client Protocol directly from your vault.",
77
"author": "RAIT-09",

package-lock.json

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

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-agent-client",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Use AI coding agents via the Agent Client Protocol directly inside Obsidian",
55
"main": "main.js",
66
"scripts": {
@@ -17,6 +17,7 @@
1717
"@types/node": "^16.11.6",
1818
"@types/react": "^19.1.13",
1919
"@types/react-dom": "^19.1.9",
20+
"@types/semver": "^7.7.1",
2021
"@typescript-eslint/parser": "^8.0.0",
2122
"@typescript-eslint/utils": "^8.0.0",
2223
"builtin-modules": "3.3.0",
@@ -34,6 +35,7 @@
3435
"@codemirror/state": "^6.5.2",
3536
"@codemirror/view": "^6.38.7",
3637
"react": "^19.1.1",
37-
"react-dom": "^19.1.1"
38+
"react-dom": "^19.1.1",
39+
"semver": "^7.7.3"
3840
}
3941
}

src/plugin.ts

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Plugin, WorkspaceLeaf, Notice, requestUrl } from "obsidian";
2+
import * as semver from "semver";
23
import { ChatView, VIEW_TYPE_CHAT } from "./components/chat/ChatView";
34
import {
45
createSettingsStore,
@@ -469,18 +470,77 @@ export default class AgentClientPlugin extends Plugin {
469470
this.settingsStore.set(this.settings);
470471
}
471472

472-
async checkForUpdates(): Promise<boolean> {
473+
/**
474+
* Fetch the latest stable release version from GitHub.
475+
*/
476+
private async fetchLatestStable(): Promise<string | null> {
473477
const response = await requestUrl({
474478
url: "https://api.github.com/repos/RAIT-09/obsidian-agent-client/releases/latest",
475479
});
476480
const data = response.json as { tag_name?: string };
477-
const latestVersion = data.tag_name;
478-
const currentVersion = this.manifest.version;
481+
return data.tag_name ? semver.clean(data.tag_name) : null;
482+
}
483+
484+
/**
485+
* Fetch the latest prerelease version from GitHub.
486+
*/
487+
private async fetchLatestPrerelease(): Promise<string | null> {
488+
const response = await requestUrl({
489+
url: "https://api.github.com/repos/RAIT-09/obsidian-agent-client/releases",
490+
});
491+
const releases = response.json as Array<{
492+
tag_name: string;
493+
prerelease: boolean;
494+
}>;
495+
496+
// Find the first prerelease (releases are sorted by date descending)
497+
const latestPrerelease = releases.find((r) => r.prerelease);
498+
return latestPrerelease
499+
? semver.clean(latestPrerelease.tag_name)
500+
: null;
501+
}
479502

480-
if (latestVersion !== currentVersion) {
481-
new Notice(`[Agent Client] Update available: v${latestVersion}`);
482-
return true;
503+
/**
504+
* Check for plugin updates.
505+
* - Stable version users: compare with latest stable release
506+
* - Prerelease users: compare with both latest stable and latest prerelease
507+
*/
508+
async checkForUpdates(): Promise<boolean> {
509+
const currentVersion =
510+
semver.clean(this.manifest.version) || this.manifest.version;
511+
const isCurrentPrerelease = semver.prerelease(currentVersion) !== null;
512+
513+
if (isCurrentPrerelease) {
514+
// Prerelease user: check both stable and prerelease
515+
const [latestStable, latestPrerelease] = await Promise.all([
516+
this.fetchLatestStable(),
517+
this.fetchLatestPrerelease(),
518+
]);
519+
520+
const hasNewerStable =
521+
latestStable && semver.gt(latestStable, currentVersion);
522+
const hasNewerPrerelease =
523+
latestPrerelease && semver.gt(latestPrerelease, currentVersion);
524+
525+
if (hasNewerStable || hasNewerPrerelease) {
526+
// Prefer stable version notification if available
527+
const newestVersion = hasNewerStable
528+
? latestStable
529+
: latestPrerelease;
530+
new Notice(
531+
`[Agent Client] Update available: v${newestVersion}`,
532+
);
533+
return true;
534+
}
535+
} else {
536+
// Stable version user: check stable only
537+
const latestStable = await this.fetchLatestStable();
538+
if (latestStable && semver.gt(latestStable, currentVersion)) {
539+
new Notice(`[Agent Client] Update available: v${latestStable}`);
540+
return true;
541+
}
483542
}
543+
484544
return false;
485545
}
486546

0 commit comments

Comments
 (0)