Fix orchestration skill coverage for provider-home skill roots (#8256) (#8510)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-13 18:13:36 -07:00
committed by GitHub
co-authored by Orca
parent 2f660a6028
commit 5886ffab63
4 changed files with 213 additions and 3 deletions
+47
View File
@@ -57,6 +57,32 @@ describe('skill discovery', () => {
expect(rootPaths).toContain('/workspace/current/.claude/skills')
})
it('scans each provider home skill root that npx skills --global writes to', () => {
const roots = buildSkillDiscoverySources({
homeDir: '/home/test',
cwd: '/workspace/current'
})
const rootPaths = roots.map((root) => root.path.replace(/\\/g, '/'))
expect(rootPaths).toEqual(
expect.arrayContaining([
'/home/test/.grok/skills',
'/home/test/.config/opencode/skills',
'/home/test/.pi/agent/skills',
'/home/test/.gemini/skills',
'/home/test/.gemini/antigravity/skills',
'/home/test/.cursor/skills'
])
)
// Why: these live outside ~/.agents/skills, so they must carry the shared
// agent-skills provider to feed per-agent orchestration coverage.
for (const root of roots) {
if (root.path.replace(/\\/g, '/') === '/home/test/.grok/skills') {
expect(root.providers).toEqual(['agent-skills'])
}
}
})
it('discovers skill packages through symlinked skill directories', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-skills-'))
const home = join(root, 'home')
@@ -77,6 +103,27 @@ describe('skill discovery', () => {
expect(skill?.directoryPath).toBe(linkedSkill)
})
it('discovers a symlinked skill inside a provider home root (#8256/#8503)', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-skills-'))
const home = join(root, 'home')
const realSkill = join(root, 'central-skills', 'orchestration')
const linkedSkill = join(home, '.pi', 'agent', 'skills', 'orchestration')
await mkdir(realSkill, { recursive: true })
await mkdir(join(home, '.pi', 'agent', 'skills'), { recursive: true })
await writeFile(join(realSkill, 'SKILL.md'), '# orchestration\n\nCoordinate agents.')
await symlink(realSkill, linkedSkill, process.platform === 'win32' ? 'junction' : 'dir')
const result = await discoverSkills({
homeDir: home,
cwd: join(root, 'missing-cwd')
})
const skill = result.skills.find((entry) => entry.name === 'orchestration')
expect(skill?.sourceKind).toBe('home')
expect(skill?.directoryPath).toBe(linkedSkill)
expect(skill?.providers).toEqual(['agent-skills'])
})
it('discovers worktree .agents skill symlinks from the requested cwd', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-skills-'))
const home = join(root, 'home')
+17 -1
View File
@@ -41,7 +41,23 @@ export function buildSkillDiscoverySources(
join(home, '.codex', 'plugins', 'cache'),
'plugin',
['codex', 'agent-skills']
)
),
// Why: `npx skills add --global` writes into each agent's own home skills
// directory, so coverage misses them unless we scan every provider root.
source('home-grok', 'Grok home', join(home, '.grok', 'skills'), 'home', ['agent-skills']),
source('home-opencode', 'OpenCode home', join(home, '.config', 'opencode', 'skills'), 'home', [
'agent-skills'
]),
source('home-pi', 'Pi home', join(home, '.pi', 'agent', 'skills'), 'home', ['agent-skills']),
source('home-gemini', 'Gemini home', join(home, '.gemini', 'skills'), 'home', ['agent-skills']),
source(
'home-antigravity',
'Antigravity home',
join(home, '.gemini', 'antigravity', 'skills'),
'home',
['agent-skills']
),
source('home-cursor', 'Cursor home', join(home, '.cursor', 'skills'), 'home', ['agent-skills'])
]
const projectPaths = new Set<string>()
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest'
import type { DiscoveredSkill } from '../../../shared/skills'
import type { TuiAgent } from '../../../shared/types'
import {
agentHasOrchestrationSkill,
getOrchestrationSkillAgentStatuses
@@ -97,7 +98,102 @@ describe('orchestration skill agent coverage', () => {
).toBe(true)
})
it('matches Windows skill paths', () => {
it('marks each provider-home agent from its own global skills location', () => {
const cases: { agent: TuiAgent; rootPath: string; directoryPath: string }[] = [
{
agent: 'grok',
rootPath: '/Users/test/.grok/skills',
directoryPath: '/Users/test/.grok/skills/orchestration'
},
{
agent: 'opencode',
rootPath: '/Users/test/.config/opencode/skills',
directoryPath: '/Users/test/.config/opencode/skills/orchestration'
},
{
agent: 'pi',
rootPath: '/Users/test/.pi/agent/skills',
directoryPath: '/Users/test/.pi/agent/skills/orchestration'
},
{
agent: 'gemini',
rootPath: '/Users/test/.gemini/skills',
directoryPath: '/Users/test/.gemini/skills/orchestration'
},
{
agent: 'antigravity',
rootPath: '/Users/test/.gemini/antigravity/skills',
directoryPath: '/Users/test/.gemini/antigravity/skills/orchestration'
},
{
agent: 'cursor',
rootPath: '/Users/test/.cursor/skills',
directoryPath: '/Users/test/.cursor/skills/orchestration'
}
]
for (const { agent, rootPath, directoryPath } of cases) {
const skills = [
skill({ providers: ['agent-skills'], sourceKind: 'home', rootPath, directoryPath })
]
expect(agentHasOrchestrationSkill(agent, skills)).toBe(true)
// Why: a provider-home install must not leak coverage to unrelated agents.
expect(agentHasOrchestrationSkill('claude', skills)).toBe(false)
}
})
it('marks a multi-segment provider-home agent from a Windows-style path', () => {
expect(
agentHasOrchestrationSkill('opencode', [
skill({
providers: ['agent-skills'],
sourceKind: 'home',
rootPath: 'C:\\Users\\test\\.config\\opencode\\skills',
directoryPath: 'C:\\Users\\test\\.config\\opencode\\skills\\orchestration'
})
])
).toBe(true)
})
it('keeps Gemini and Antigravity distinct despite sharing the ~/.gemini root', () => {
const geminiInstall = [
skill({
providers: ['agent-skills'],
sourceKind: 'home',
rootPath: '/Users/test/.gemini/skills',
directoryPath: '/Users/test/.gemini/skills/orchestration'
})
]
const antigravityInstall = [
skill({
providers: ['agent-skills'],
sourceKind: 'home',
rootPath: '/Users/test/.gemini/antigravity/skills',
directoryPath: '/Users/test/.gemini/antigravity/skills/orchestration'
})
]
// Why: `.gemini/skills` and `.gemini/antigravity/skills` are siblings, so a
// segment matcher must not let one provider's install mark the other.
expect(agentHasOrchestrationSkill('gemini', geminiInstall)).toBe(true)
expect(agentHasOrchestrationSkill('antigravity', geminiInstall)).toBe(false)
expect(agentHasOrchestrationSkill('antigravity', antigravityInstall)).toBe(true)
expect(agentHasOrchestrationSkill('gemini', antigravityInstall)).toBe(false)
})
it('marks Claude Agent Teams from ~/.claude/skills like Claude Code', () => {
const skills = [
skill({
providers: ['claude'],
sourceKind: 'home',
rootPath: '/Users/test/.claude/skills',
directoryPath: '/Users/test/.claude/skills/orchestration'
})
]
expect(agentHasOrchestrationSkill('claude-agent-teams', skills)).toBe(true)
})
it('marks Windows skill paths', () => {
expect(
agentHasOrchestrationSkill('codex', [
skill({
@@ -9,6 +9,12 @@ export type OrchestrationSkillLocationId =
| 'codex-home'
| 'codex-plugin-cache'
| 'agents-home'
| 'grok-home'
| 'opencode-home'
| 'pi-home'
| 'gemini-home'
| 'antigravity-home'
| 'cursor-home'
export type OrchestrationSkillAgentStatus = {
agent: TuiAgent
@@ -45,6 +51,43 @@ const ORCHESTRATION_SKILL_LOCATIONS: readonly OrchestrationSkillLocationDefiniti
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.agents', 'skills'])
},
{
id: 'grok-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) && pathContainsSegments(skill.rootPath, ['.grok', 'skills'])
},
{
id: 'opencode-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.config', 'opencode', 'skills'])
},
{
id: 'pi-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.pi', 'agent', 'skills'])
},
{
// Why: segment matching keeps `.gemini/skills` (Gemini CLI) distinct from the
// sibling `.gemini/antigravity/skills`, so the two never cross-mark each other.
id: 'gemini-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.gemini', 'skills'])
},
{
id: 'antigravity-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.gemini', 'antigravity', 'skills'])
},
{
id: 'cursor-home',
matchesSkill: (skill) =>
isGlobalOrchestrationSkill(skill) &&
pathContainsSegments(skill.rootPath, ['.cursor', 'skills'])
}
]
@@ -52,8 +95,16 @@ const ORCHESTRATION_SKILL_LOCATION_IDS_BY_AGENT: Partial<
Record<TuiAgent, readonly OrchestrationSkillLocationId[]>
> = {
claude: ['claude-home', 'agents-home'],
// Why: Agent Teams runs Claude Code, so it reads the same ~/.claude skills.
'claude-agent-teams': ['claude-home', 'agents-home'],
openclaude: ['claude-home', 'agents-home'],
codex: ['codex-home', 'codex-plugin-cache', 'agents-home']
codex: ['codex-home', 'codex-plugin-cache', 'agents-home'],
grok: ['grok-home', 'agents-home'],
opencode: ['opencode-home', 'agents-home'],
pi: ['pi-home', 'agents-home'],
gemini: ['gemini-home', 'agents-home'],
antigravity: ['antigravity-home', 'agents-home'],
cursor: ['cursor-home', 'agents-home']
}
function normalizeSkillName(value: string): string {