Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ interface VersionEntry {
contentSha: string
}

// GET /agent/skills/version returns an object keyed by slug, not an array.
interface VersionResponse {
versions: Record<string, VersionEntry>
}

export async function updateCommand(args: string[]): Promise<void> {
const jsonFlag = args.includes('--json')

Expand All @@ -31,18 +36,20 @@ export async function updateCommand(args: string[]): Promise<void> {
const s = p.spinner()
s.start('Checking for updates...')

let remote: VersionEntry[]
let remote: VersionResponse
try {
const slugs = installed.map((sk) => sk.slug).join(',')
remote = await apiFetch<VersionEntry[]>(
remote = await apiFetch<VersionResponse>(
`/agent/skills/version?slugs=${encodeURIComponent(slugs)}`,
)
} catch (err) {
s.error('Failed to check versions')
throw err
}

const remoteMap = new Map(remote.map((r) => [r.slug, r.contentSha]))
const remoteMap = new Map(
Object.entries(remote.versions).map(([slug, v]) => [slug, v.contentSha]),
)
const outdated = installed.filter(
(sk) => remoteMap.has(sk.slug) && remoteMap.get(sk.slug) !== sk.contentSha,
)
Expand Down