- 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.
62 lines
1.8 KiB
TypeScript
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'])
|
|
);
|
|
});
|
|
});
|