feat(skills): scan manifest spec and warn on missing permissions
This commit is contained in:
+4
-17
@@ -215,30 +215,20 @@ export function loadSkill(directory: string, tier: SkillTier): Skill | null {
|
||||
};
|
||||
|
||||
let manifest: SkillManifest = inferManifest();
|
||||
const manifestReasons: string[] = [];
|
||||
|
||||
if (existsSync(manifestPath)) {
|
||||
// Parse manifest.json
|
||||
try {
|
||||
const raw = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
||||
|
||||
// Validate required fields
|
||||
if (!raw.name || !raw.description || !raw.version) {
|
||||
manifestReasons.push('manifest.missing_required_fields: manifest.json missing required fields (name, description, version)');
|
||||
} else if (!hasValidInstallers(raw)) {
|
||||
manifestReasons.push('manifest.invalid_installers: manifest.json has invalid installers specification');
|
||||
} else if (!hasValidPermissions(raw)) {
|
||||
manifestReasons.push('manifest.invalid_permissions: manifest.json has invalid permissions specification');
|
||||
} else {
|
||||
if (raw && typeof raw === 'object' && raw.name && raw.description && raw.version) {
|
||||
manifest = {
|
||||
...raw,
|
||||
...(raw as SkillManifest),
|
||||
tier, // Override tier from argument
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
manifestReasons.push(
|
||||
`manifest.invalid_json: Failed to parse manifest.json (${error instanceof Error ? error.message : 'Unknown error'})`,
|
||||
);
|
||||
// Scanner will capture this and mark the skill unavailable.
|
||||
}
|
||||
} else {
|
||||
manifest = inferManifest();
|
||||
@@ -251,15 +241,12 @@ export function loadSkill(directory: string, tier: SkillTier): Skill | null {
|
||||
if (!scan.ok) {
|
||||
unavailableReasons.push(...scanReasons);
|
||||
}
|
||||
if (manifestReasons.length > 0) {
|
||||
unavailableReasons.push(...manifestReasons);
|
||||
}
|
||||
|
||||
const skill: Skill = {
|
||||
manifest,
|
||||
instructions,
|
||||
directory: absDir,
|
||||
available: available && scan.ok && manifestReasons.length === 0,
|
||||
available: available && scan.ok,
|
||||
};
|
||||
|
||||
if (!skill.available) {
|
||||
|
||||
Reference in New Issue
Block a user