Skip to content

Commit ea27096

Browse files
committed
fix: use package license for skills
1 parent e0a31c3 commit ea27096

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

server/utils/skills.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ export async function fetchSkillContent(
162162
/**
163163
* Validate skill frontmatter and return warnings.
164164
*/
165-
export function validateSkill(frontmatter: SkillFrontmatter): SkillWarning[] {
165+
export function validateSkill(
166+
frontmatter: SkillFrontmatter,
167+
packageLicense?: string,
168+
): SkillWarning[] {
166169
const warnings: SkillWarning[] = []
167-
if (!frontmatter.license) {
170+
if (!frontmatter.license && !packageLicense) {
168171
warnings.push({ type: 'warning', message: 'No license specified' })
169172
}
170173
if (!frontmatter.compatibility) {
@@ -181,17 +184,28 @@ export async function fetchSkillsList(
181184
version: string,
182185
skillDirs: SkillDirInfo[],
183186
): Promise<SkillListItem[]> {
187+
// Get package license for fallback if skill doesn't specify one
188+
let packageLicense: string | undefined
189+
try {
190+
const packument = await fetchNpmPackage(packageName)
191+
const license = packument.versions?.[version]?.license ?? packument.license
192+
packageLicense = typeof license === 'string' ? license : license?.type
193+
} catch {
194+
// If we can't fetch package info, just proceed without it
195+
}
184196
const skills = await Promise.all(
185197
skillDirs.map(async ({ name: dirName, children }) => {
186198
try {
187199
const { frontmatter } = await fetchSkillContent(packageName, version, dirName)
188-
const warnings = validateSkill(frontmatter)
200+
const warnings = validateSkill(frontmatter, packageLicense)
189201
const fileCounts = countSkillFiles(children)
202+
// Use skill license if specified, otherwise fallback to package license
203+
const license = frontmatter.license || packageLicense
190204
const item: SkillListItem = {
191205
name: frontmatter.name,
192206
description: frontmatter.description,
193207
dirName,
194-
license: frontmatter.license,
208+
license,
195209
compatibility: frontmatter.compatibility,
196210
warnings: warnings.length > 0 ? warnings : undefined,
197211
fileCounts,

0 commit comments

Comments
 (0)