From e6e32d345ec320685970a520492cd67a2ee42508 Mon Sep 17 00:00:00 2001 From: acamq <179265037+acamq@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:28:04 -0600 Subject: [PATCH] fix(auto-update): expand semver regex to support hyphenated prerelease tags The previous pattern `(-[\w.]+)?` used `\w` which excludes hyphens, causing versions like `1.2.3-alpha-1` and `1.2.3-rc-test` to be misclassified as unpinned tags. Updated both plugin-entry.ts and sync-package-json.ts (which share the definition) to the spec-compliant pattern that allows dot-separated identifiers using [0-9A-Za-z-] and optional build metadata. Also adds String() coercion before .trim() in sync-package-json.ts to guard against a TypeError if the parsed JSON value for currentVersion is non-string at runtime. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/hooks/auto-update-checker/checker/plugin-entry.ts | 2 +- src/hooks/auto-update-checker/checker/sync-package-json.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/auto-update-checker/checker/plugin-entry.ts b/src/hooks/auto-update-checker/checker/plugin-entry.ts index 61c7a65bc..f204d61f1 100644 --- a/src/hooks/auto-update-checker/checker/plugin-entry.ts +++ b/src/hooks/auto-update-checker/checker/plugin-entry.ts @@ -11,7 +11,7 @@ export interface PluginEntryInfo { configPath: string } -const EXACT_SEMVER_REGEX = /^\d+\.\d+\.\d+(-[\w.]+)?$/ +const EXACT_SEMVER_REGEX = /^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/ export function findPluginEntry(directory: string): PluginEntryInfo | null { for (const configPath of getConfigPaths(directory)) { diff --git a/src/hooks/auto-update-checker/checker/sync-package-json.ts b/src/hooks/auto-update-checker/checker/sync-package-json.ts index 841e307fc..443cbc97e 100644 --- a/src/hooks/auto-update-checker/checker/sync-package-json.ts +++ b/src/hooks/auto-update-checker/checker/sync-package-json.ts @@ -15,7 +15,7 @@ export interface SyncResult { message?: string } -const EXACT_SEMVER_REGEX = /^\d+\.\d+\.\d+(-[\w.]+)?$/ +const EXACT_SEMVER_REGEX = /^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/ function safeUnlink(filePath: string): void { try { @@ -71,7 +71,7 @@ export function syncCachePackageJsonToIntent(pluginInfo: PluginEntryInfo): SyncR } const intentIsTag = !EXACT_SEMVER_REGEX.test(intentVersion.trim()) - const currentIsSemver = EXACT_SEMVER_REGEX.test(currentVersion.trim()) + const currentIsSemver = EXACT_SEMVER_REGEX.test(String(currentVersion).trim()) if (intentIsTag && currentIsSemver) { log(