@@ -21,7 +21,6 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2121import { homedir } from "node:os" ;
2222import { isAbsolute , join , relative , resolve , sep } from "node:path" ;
2323import { promisify } from "node:util" ;
24- import { VERSION } from "../version.js" ;
2524
2625const execFileAsync = promisify ( execFile ) ;
2726
@@ -624,16 +623,16 @@ async function remoteRefSha(repoSlug: string, ref: string): Promise<string | nul
624623}
625624
626625/** The release tag (`v<version>`) of a published CLI build; null for a dev or pre-release build. */
627- export function cliReleaseTag ( version : string = VERSION ) : string | null {
626+ export function cliReleaseTag ( version : string ) : string | null {
628627 return / ^ \d + \. \d + \. \d + $ / . test ( version ) ? `v${ version } ` : null ;
629628}
630629
631630/** Where skills install from and are checked against: this CLI's release tag, else `main`. */
632631export async function skillsSourceRef (
632+ cliVersion : string ,
633633 repoSlug : string = DEFAULT_REPO_SLUG ,
634- version : string = VERSION ,
635634) : Promise < string > {
636- const tag = cliReleaseTag ( version ) ;
635+ const tag = cliReleaseTag ( cliVersion ) ;
637636 if ( ! tag ) return "main" ;
638637 return ( await remoteRefSha ( repoSlug , `refs/tags/${ tag } ` ) ) ? tag : "main" ;
639638}
@@ -654,11 +653,11 @@ function resolveLocalManifest(source: string): SkillsManifest {
654653 * moves), `main` SHA-pinned via `git ls-remote` to dodge raw-CDN lag, falling
655654 * back to the branch URL when git is unavailable.
656655 */
657- async function fetchRemoteManifest ( source ?: string ) : Promise < SkillsManifest > {
656+ async function fetchRemoteManifest ( source ?: string , cliVersion ?: string ) : Promise < SkillsManifest > {
658657 if ( source ?. startsWith ( "http" ) ) return fetchManifest ( source ) ;
659658
660659 const repoSlug = source ?? DEFAULT_REPO_SLUG ;
661- const ref = await skillsSourceRef ( repoSlug ) ;
660+ const ref = cliVersion ? await skillsSourceRef ( cliVersion , repoSlug ) : "main" ;
662661 if ( ref !== "main" ) {
663662 return fetchManifest ( `https://raw.githubusercontent.com/${ repoSlug } /${ ref } /${ MANIFEST_FILE } ` ) ;
664663 }
@@ -693,7 +692,7 @@ async function fetchRemoteManifest(source?: string): Promise<SkillsManifest> {
693692async function resolveLatestManifest (
694693 source ?: string ,
695694 cwd = process . cwd ( ) ,
696- opts : { canonical ?: boolean } = { } ,
695+ opts : { canonical ?: boolean ; cliVersion ?: string } = { } ,
697696) : Promise < SkillsManifest > {
698697 // A local path is a relative one (./ ../) or an absolute one — isAbsolute
699698 // covers POSIX `/…` and Windows `C:\…` / `\…` on their respective platforms.
@@ -704,7 +703,7 @@ async function resolveLatestManifest(
704703 const repoManifest = findRepoManifest ( cwd ) ;
705704 if ( repoManifest ) return JSON . parse ( readFileSync ( repoManifest , "utf8" ) ) as SkillsManifest ;
706705 }
707- return fetchRemoteManifest ( source ) ;
706+ return fetchRemoteManifest ( source , opts . cliVersion ) ;
708707}
709708
710709/**
@@ -719,9 +718,14 @@ export async function checkSkills(
719718 home ?: string ;
720719 /** See resolveLatestManifest — bypass the in-repo manifest shortcut. */
721720 canonical ?: boolean ;
721+ /** Read the remote manifest at this CLI version's release tag (see skillsSourceRef). */
722+ cliVersion ?: string ;
722723 } = { } ,
723724) : Promise < SkillsCheckResult > {
724- const latest = await resolveLatestManifest ( opts . source , opts . cwd , { canonical : opts . canonical } ) ;
725+ const latest = await resolveLatestManifest ( opts . source , opts . cwd , {
726+ canonical : opts . canonical ,
727+ cliVersion : opts . cliVersion ,
728+ } ) ;
725729 const skillNames = Object . keys ( latest . skills ) ;
726730 const root = locateInstall ( skillNames , { dir : opts . dir , cwd : opts . cwd , home : opts . home } ) ;
727731 // A directory sharing a name with one of ours can belong to another publisher.
0 commit comments