Files
openchamber/packages/vscode/src/opencodeConfig.skills.test.js
T
jkker 1663185a75 fix installed skills discovery and improve editor UX (#1296)
* fix skills discovery from opencode

* Fix stale skill description after frontmatter removal

* fix: align vscode skill discovery parity
2026-05-23 20:58:12 +03:00

47 lines
1.8 KiB
JavaScript

import { describe, expect, test } from 'bun:test';
import {
BUILT_IN_SKILL_LOCATION,
getSkillSources,
mergeDiscoveredSkills,
} from './opencodeConfig';
describe('VS Code skill discovery parity', () => {
test('merges OpenCode API skills with locally discovered fallback skills', () => {
const merged = mergeDiscoveredSkills(
[
{ name: 'built-in', path: BUILT_IN_SKILL_LOCATION, scope: 'user', source: 'opencode' },
{ name: 'local-first', path: '/tmp/local-first/SKILL.md', scope: 'user', source: 'agents' },
],
[
{ name: 'local-first', path: '/tmp/local-first/SKILL.md', scope: 'user', source: 'agents' },
{ name: 'local-only', path: '/tmp/local-only/SKILL.md', scope: 'project', source: 'claude' },
],
);
expect(merged.map((skill) => skill.name)).toEqual(['built-in', 'local-first', 'local-only']);
});
test('resolves built-in skills without treating the virtual location as a file', () => {
const discoveredSkill = {
name: 'customize-opencode',
path: BUILT_IN_SKILL_LOCATION,
scope: 'user',
source: 'opencode',
description: 'Customize opencode',
content: '# Customize opencode\n\nUse for config work.',
};
const sources = getSkillSources('customize-opencode', '/tmp/openchamber-vscode-skills-test', discoveredSkill);
expect(sources.md.exists).toBe(true);
expect(sources.md.path).toBeNull();
expect(sources.md.dir).toBeNull();
expect(sources.md.scope).toBe('user');
expect(sources.md.source).toBe('opencode');
expect(sources.md.description).toBe('Customize opencode');
expect(sources.md.instructions).toBe('# Customize opencode\n\nUse for config work.');
expect(sources.md.fields).toEqual(['description', 'instructions']);
});
});