@@ -7,6 +7,7 @@ import { Log } from "../util/log"
77
88declare global {
99 const OPENCODE_VERSION : string
10+ const OPENCODE_CHANNEL : string
1011}
1112
1213export namespace Installation {
@@ -40,7 +41,7 @@ export namespace Installation {
4041 }
4142 }
4243
43- export function isSnapshot ( ) {
44+ export function isPreview ( ) {
4445 return VERSION . startsWith ( "0.0.0" )
4546 }
4647
@@ -137,17 +138,15 @@ export namespace Installation {
137138 }
138139
139140 export const VERSION = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "dev"
140- export const USER_AGENT = `opencode/${ VERSION } `
141+ export const CHANNEL = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "dev"
142+ export const USER_AGENT = `opencode/${ CHANNEL } /${ VERSION } `
141143
142144 export async function latest ( ) {
143- return fetch ( "https://api.github.com/repos/sst/opencode/releases/latest" )
144- . then ( ( res ) => res . json ( ) )
145- . then ( ( data ) => {
146- if ( typeof data . tag_name !== "string" ) {
147- log . error ( "GitHub API error" , data )
148- throw new Error ( "failed to fetch latest version" )
149- }
150- return data . tag_name . slice ( 1 ) as string
145+ return fetch ( `https://registry.npmjs.org/opencode-ai/${ CHANNEL } ` )
146+ . then ( ( res ) => {
147+ if ( ! res . ok ) throw new Error ( res . statusText )
148+ return res . json ( )
151149 } )
150+ . then ( ( data : any ) => data . version )
152151 }
153152}
0 commit comments