@@ -14,11 +14,13 @@ const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
1414const version = await ( async ( ) => {
1515 if ( snapshot ) return `0.0.0-${ new Date ( ) . toISOString ( ) . slice ( 0 , 16 ) . replace ( / [ - : T ] / g, "" ) } `
1616 if ( process . env [ "OPENCODE_VERSION" ] ) return process . env [ "OPENCODE_VERSION" ]
17- const [ major , minor , patch ] = ( await $ `gh release list --limit 1 --json tagName --jq '.[0].tagName'` . text ( ) )
18- . trim ( )
19- . replace ( / ^ v / , "" )
20- . split ( "." )
21- . map ( ( x ) => Number ( x ) || 0 )
17+ const npmVersion = await fetch ( "https://registry.npmjs.org/opencode-ai/latest" )
18+ . then ( ( res ) => {
19+ if ( ! res . ok ) throw new Error ( res . statusText )
20+ return res . json ( )
21+ } )
22+ . then ( ( data : any ) => data . version )
23+ const [ major , minor , patch ] = npmVersion . split ( "." ) . map ( ( x : string ) => Number ( x ) || 0 )
2224 const t = process . env [ "OPENCODE_BUMP" ] ?. toLowerCase ( )
2325 if ( t === "major" ) return `${ major + 1 } .0.0`
2426 if ( t === "minor" ) return `${ major } .${ minor + 1 } .0`
@@ -28,12 +30,12 @@ process.env["OPENCODE_VERSION"] = version
2830console . log ( "version:" , version )
2931
3032if ( ! snapshot ) {
31- const previous = await fetch ( "https://api.github.com/repos/sst/ opencode/releases /latest" )
33+ const previous = await fetch ( "https://registry.npmjs.org/ opencode-ai /latest" )
3234 . then ( ( res ) => {
3335 if ( ! res . ok ) throw new Error ( res . statusText )
3436 return res . json ( )
3537 } )
36- . then ( ( data ) => data . tag_name )
38+ . then ( ( data : any ) => data . version )
3739
3840 const opencode = await createOpencode ( )
3941 const session = await opencode . client . session . create ( )
0 commit comments