agent-ecosystem/test/main/services/extensions/SkillMetadataParser.test.ts
iliya 4b4dccd13d feat: add skills management features and integrate skills API
- Introduced skills catalog management with functionalities to list, get details, preview, and apply skill changes.
- Implemented IPC handlers for skills-related actions, enhancing communication between renderer and main processes.
- Updated the UI to include a dedicated Skills panel within the extension store, improving user access to skills management.
- Added new constants and types for skills API integration, ensuring a structured approach to skills handling.
- Enhanced state management to support skills loading, error handling, and detail fetching.
2026-03-11 21:46:56 +02:00

62 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { SkillMetadataParser } from '@main/services/extensions/skills/SkillMetadataParser';
describe('SkillMetadataParser', () => {
const parser = new SkillMetadataParser();
const root = {
scope: 'project' as const,
rootKind: 'claude' as const,
projectRoot: '/tmp/project',
rootPath: '/tmp/project/.claude/skills',
};
it('parses valid frontmatter and derives warnings', () => {
const item = parser.parseCatalogItem({
skillDir: '/tmp/project/.claude/skills/demo-skill',
folderName: 'demo-skill',
skillFile: '/tmp/project/.claude/skills/demo-skill/Skill.md',
rawContent: `---
name: demo-skill
description: Test skill
allowed-tools:
- Read
compatibility: Requires network and API key
unknown-key: true
---
# Demo`,
modifiedAt: 1,
flags: { hasScripts: true, hasReferences: false, hasAssets: false },
root,
});
expect(item.isValid).toBe(true);
expect(item.issues.map((issue) => issue.code)).toEqual(
expect.arrayContaining([
'nonstandard-file-name',
'unknown-frontmatter-keys',
'has-scripts',
'allowed-tools-advisory',
'compatibility-advisory',
])
);
});
it('marks missing frontmatter as invalid', () => {
const item = parser.parseCatalogItem({
skillDir: '/tmp/project/.claude/skills/demo-skill',
folderName: 'demo-skill',
skillFile: '/tmp/project/.claude/skills/demo-skill/SKILL.md',
rawContent: '# No frontmatter',
modifiedAt: 1,
flags: { hasScripts: false, hasReferences: false, hasAssets: false },
root,
});
expect(item.isValid).toBe(false);
expect(item.issues.map((issue) => issue.code)).toEqual(
expect.arrayContaining(['missing-frontmatter', 'missing-name', 'missing-description'])
);
});
});