import chalk from "chalk"; import { fetchVersions } from "../lib/registry-client.js"; export async function versionsCommand(skillName: string): Promise { if (!skillName.match(/^@[a-z0-9-]+\/[a-z0-9-]+$/)) { console.error( chalk.red( `Error: skill name must be @namespace/skill-name (got: ${skillName})` ) ); process.exit(1); } console.log(chalk.bold(`Fetching versions for ${chalk.cyan(skillName)}...`)); const versions = await fetchVersions(skillName); if (!versions.length) { console.log(chalk.dim("No versions published yet.")); return; } console.log(chalk.bold(`\n ${versions.length} version(s) found:\n`)); console.log( chalk.dim( " " + "VERSION".padEnd(16) + "PUBLISHED".padEnd(28) + "CONTENT HASH" ) ); console.log(chalk.dim(" " + "─".repeat(72))); for (const v of versions) { const date = new Date(v.publishedAt).toLocaleString(); const hash = v.contentHash.slice(0, 12) + "..."; console.log(` ${v.version.padEnd(16)}${date.padEnd(28)}${chalk.dim(hash)}`); } console.log(); }