fix: discover repository-local .agents skills in Settings
Skills listing ignored the active project when the OpenCode client directory was unset, so project `.agents/skills` files were created but never shown. Prefer the active project path (matching Commands/Agents) and soft-fall back to it on skill API routes when directory is omitted. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
co-authored by
Serhii Dziupin
parent
7afec99f80
commit
049600df72
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import fsPromises from 'fs/promises';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { getSkillSources, mergeDiscoveredSkills } from './skills.js';
|
||||
import { discoverSkills, getSkillSources, mergeDiscoveredSkills } from './skills.js';
|
||||
|
||||
describe('skills', () => {
|
||||
it('merges locally discovered skills missing from OpenCode live discovery', () => {
|
||||
@@ -24,6 +24,43 @@ describe('skills', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('discovers repository-local .agents skills for the project directory', async () => {
|
||||
const tempRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-project-agents-'));
|
||||
const skillDir = path.join(tempRoot, '.agents', 'skills', 'repo-local-skill');
|
||||
const skillPath = path.join(skillDir, 'SKILL.md');
|
||||
|
||||
try {
|
||||
await fsPromises.mkdir(skillDir, { recursive: true });
|
||||
await fsPromises.mkdir(path.join(tempRoot, '.git'));
|
||||
await fsPromises.writeFile(
|
||||
skillPath,
|
||||
[
|
||||
'---',
|
||||
'name: repo-local-skill',
|
||||
'description: Repository-local agents skill',
|
||||
'---',
|
||||
'',
|
||||
'Use this skill in this repository.',
|
||||
'',
|
||||
].join('\n'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const discovered = discoverSkills(tempRoot);
|
||||
const match = discovered.find((skill) => skill.name === 'repo-local-skill');
|
||||
|
||||
expect(match).toEqual({
|
||||
name: 'repo-local-skill',
|
||||
path: skillPath,
|
||||
scope: 'project',
|
||||
source: 'agents',
|
||||
description: 'Repository-local agents skill',
|
||||
});
|
||||
} finally {
|
||||
await fsPromises.rm(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('resolves built-in OpenCode skill content without parsing virtual locations as files', () => {
|
||||
const sources = getSkillSources(
|
||||
'customize-opencode',
|
||||
|
||||
Reference in New Issue
Block a user