- Implement tests for random ID generation, ensuring preference for crypto.randomUUID. - Create tests for runtime context capabilities, validating the injection of enabled skill capabilities. - Add tests for skill capability parsing, including classification and command example extraction. - Introduce tests for the skill planner, verifying tool call planning based on user requests and attachment requirements. - Establish tests for UV setup, ensuring proper handling of Python installation scenarios and environment checks.
86 lines
2.4 KiB
TypeScript
86 lines
2.4 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { parseSkillCapability } from '../electron/gateway/skill-capability-parser';
|
|
|
|
describe('skill capability parser', () => {
|
|
it('classifies office-style document skills as document-analysis capabilities', () => {
|
|
const capability = parseSkillCapability({
|
|
skillKey: 'docx',
|
|
manifestContent: `---
|
|
name: docx
|
|
description: Use this skill whenever the user wants to create, read, edit, or analyze .docx files.
|
|
---
|
|
|
|
# DOCX
|
|
|
|
Read and analyze .docx files.`,
|
|
});
|
|
|
|
expect(capability.category).toBe('document');
|
|
expect(capability.inputExtensions).toContain('.docx');
|
|
expect(capability.renderHints).toEqual(expect.objectContaining({
|
|
card: 'document-analysis',
|
|
preferredView: 'summary',
|
|
skillType: 'document',
|
|
}));
|
|
});
|
|
|
|
it('ignores URL-like pseudo extensions when inferring file inputs', () => {
|
|
const capability = parseSkillCapability({
|
|
skillKey: 'brave-web-search',
|
|
manifestContent: `---
|
|
name: web-search
|
|
description: USE FOR web search. Returns ranked results with snippets, URLs, thumbnails.
|
|
---
|
|
|
|
GET https://api.search.brave.com/res/v1/web/search
|
|
POST https://api.search.brave.com/res/v1/web/search`,
|
|
});
|
|
|
|
expect(capability.inputExtensions).toEqual([]);
|
|
expect(capability.requiresAuth).toBe(false);
|
|
});
|
|
|
|
it('detects env-driven auth without false-positives from unrelated auth substrings', () => {
|
|
const capability = parseSkillCapability({
|
|
skillKey: 'search-cli',
|
|
manifestContent: `---
|
|
name: search-cli
|
|
description: Search the web with your API key.
|
|
author: ZN AI
|
|
---
|
|
|
|
curl -H "X-Subscription-Token: \${BRAVE_SEARCH_API_KEY}" https://example.com/search`,
|
|
});
|
|
|
|
expect(capability.requiredEnvVars).toEqual(['BRAVE_SEARCH_API_KEY']);
|
|
expect(capability.requiresAuth).toBe(true);
|
|
});
|
|
|
|
it('extracts safe command examples from shell fences while skipping setup commands', () => {
|
|
const capability = parseSkillCapability({
|
|
skillKey: 'find-skills',
|
|
manifestContent: `---
|
|
name: find-skills
|
|
description: Discover skills for a task.
|
|
---
|
|
|
|
\`\`\`bash
|
|
curl -fsSL https://example.com/install.sh | bash && tool login
|
|
npx skills find [query]
|
|
\`\`\`
|
|
|
|
\`\`\`bash
|
|
tvly search "your query" --json
|
|
\`\`\``,
|
|
});
|
|
|
|
expect(capability.commandExamples).toEqual([
|
|
'npx skills find [query]',
|
|
'tvly search "your query" --json',
|
|
]);
|
|
});
|
|
});
|