fix(skill): isolate injected skill discovery
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -4,13 +4,10 @@ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:te
|
||||
import type { ToolContext } from "@opencode-ai/plugin/tool"
|
||||
import type { LoadedSkill } from "../../features/opencode-skill-loader/types"
|
||||
import * as skillContent from "../../features/opencode-skill-loader/skill-content"
|
||||
import * as commandDiscovery from "../slashcommand/command-discovery"
|
||||
|
||||
const discoverCommandsSync = mock(() => [])
|
||||
|
||||
mock.module("../slashcommand/command-discovery", () => ({
|
||||
discoverCommandsSync,
|
||||
}))
|
||||
|
||||
function createMockSkill(name: string): LoadedSkill {
|
||||
return {
|
||||
name,
|
||||
@@ -50,6 +47,7 @@ function createMockContext(sessionID: string): ToolContext {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(commandDiscovery, "discoverCommandsSync").mockImplementation(discoverCommandsSync)
|
||||
spyOn(skillContent, "getAllSkills").mockImplementation(getAllSkills)
|
||||
spyOn(skillContent, "clearSkillCache").mockImplementation(clearSkillCache)
|
||||
})
|
||||
|
||||
@@ -37,14 +37,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
disabledSkills: options?.disabledSkills,
|
||||
browserProvider: options?.browserProvider,
|
||||
})) ?? []
|
||||
const allSkills = !options.skills
|
||||
? discovered
|
||||
: [
|
||||
...discovered,
|
||||
...options.skills.filter(
|
||||
(skill) => !new Set(discovered.map((discoveredSkill) => discoveredSkill.name)).has(skill.name)
|
||||
),
|
||||
]
|
||||
const allSkills = options.skills ? [...options.skills] : discovered
|
||||
|
||||
if (options.nativeSkills) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user