@@ -33,7 +33,13 @@ export function isLocalDevMode(directory: string): boolean {
3333 return false
3434}
3535
36- export function findPluginEntry ( directory : string ) : string | null {
36+ export interface PluginEntryInfo {
37+ entry : string
38+ isPinned : boolean
39+ pinnedVersion : string | null
40+ }
41+
42+ export function findPluginEntry ( directory : string ) : PluginEntryInfo | null {
3743 const projectConfig = path . join ( directory , ".opencode" , "opencode.json" )
3844
3945 for ( const configPath of [ projectConfig , USER_OPENCODE_CONFIG ] ) {
@@ -44,8 +50,13 @@ export function findPluginEntry(directory: string): string | null {
4450 const plugins = config . plugin ?? [ ]
4551
4652 for ( const entry of plugins ) {
47- if ( entry === PACKAGE_NAME || entry . startsWith ( `${ PACKAGE_NAME } @` ) ) {
48- return entry
53+ if ( entry === PACKAGE_NAME ) {
54+ return { entry, isPinned : false , pinnedVersion : null }
55+ }
56+ if ( entry . startsWith ( `${ PACKAGE_NAME } @` ) ) {
57+ const pinnedVersion = entry . slice ( PACKAGE_NAME . length + 1 )
58+ const isPinned = pinnedVersion !== "latest"
59+ return { entry, isPinned, pinnedVersion : isPinned ? pinnedVersion : null }
4960 }
5061 }
5162 } catch {
@@ -91,29 +102,35 @@ export async function getLatestVersion(): Promise<string | null> {
91102export async function checkForUpdate ( directory : string ) : Promise < UpdateCheckResult > {
92103 if ( isLocalDevMode ( directory ) ) {
93104 log ( "[auto-update-checker] Local dev mode detected, skipping update check" )
94- return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : true }
105+ return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : true , isPinned : false }
95106 }
96107
97- const pluginEntry = findPluginEntry ( directory )
98- if ( ! pluginEntry ) {
108+ const pluginInfo = findPluginEntry ( directory )
109+ if ( ! pluginInfo ) {
99110 log ( "[auto-update-checker] Plugin not found in config" )
100- return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : false }
111+ return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : false , isPinned : false }
112+ }
113+
114+ // Respect version pinning
115+ if ( pluginInfo . isPinned ) {
116+ log ( `[auto-update-checker] Version pinned to ${ pluginInfo . pinnedVersion } , skipping update check` )
117+ return { needsUpdate : false , currentVersion : pluginInfo . pinnedVersion , latestVersion : null , isLocalDev : false , isPinned : true }
101118 }
102119
103120 const currentVersion = getCachedVersion ( )
104121 if ( ! currentVersion ) {
105122 log ( "[auto-update-checker] No cached version found" )
106- return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : false }
123+ return { needsUpdate : false , currentVersion : null , latestVersion : null , isLocalDev : false , isPinned : false }
107124 }
108125
109126 const latestVersion = await getLatestVersion ( )
110127 if ( ! latestVersion ) {
111128 log ( "[auto-update-checker] Failed to fetch latest version" )
112- return { needsUpdate : false , currentVersion, latestVersion : null , isLocalDev : false }
129+ return { needsUpdate : false , currentVersion, latestVersion : null , isLocalDev : false , isPinned : false }
113130 }
114131
115132 const needsUpdate = currentVersion !== latestVersion
116133 log ( `[auto-update-checker] Current: ${ currentVersion } , Latest: ${ latestVersion } , NeedsUpdate: ${ needsUpdate } ` )
117134
118- return { needsUpdate, currentVersion, latestVersion, isLocalDev : false }
135+ return { needsUpdate, currentVersion, latestVersion, isLocalDev : false , isPinned : false }
119136}
0 commit comments