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 { ToolContext } from "@opencode-ai/plugin/tool"
|
||||||
import type { LoadedSkill } from "../../features/opencode-skill-loader/types"
|
import type { LoadedSkill } from "../../features/opencode-skill-loader/types"
|
||||||
import * as skillContent from "../../features/opencode-skill-loader/skill-content"
|
import * as skillContent from "../../features/opencode-skill-loader/skill-content"
|
||||||
|
import * as commandDiscovery from "../slashcommand/command-discovery"
|
||||||
|
|
||||||
const discoverCommandsSync = mock(() => [])
|
const discoverCommandsSync = mock(() => [])
|
||||||
|
|
||||||
mock.module("../slashcommand/command-discovery", () => ({
|
|
||||||
discoverCommandsSync,
|
|
||||||
}))
|
|
||||||
|
|
||||||
function createMockSkill(name: string): LoadedSkill {
|
function createMockSkill(name: string): LoadedSkill {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
@@ -50,6 +47,7 @@ function createMockContext(sessionID: string): ToolContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
spyOn(commandDiscovery, "discoverCommandsSync").mockImplementation(discoverCommandsSync)
|
||||||
spyOn(skillContent, "getAllSkills").mockImplementation(getAllSkills)
|
spyOn(skillContent, "getAllSkills").mockImplementation(getAllSkills)
|
||||||
spyOn(skillContent, "clearSkillCache").mockImplementation(clearSkillCache)
|
spyOn(skillContent, "clearSkillCache").mockImplementation(clearSkillCache)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -37,14 +37,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
|||||||
disabledSkills: options?.disabledSkills,
|
disabledSkills: options?.disabledSkills,
|
||||||
browserProvider: options?.browserProvider,
|
browserProvider: options?.browserProvider,
|
||||||
})) ?? []
|
})) ?? []
|
||||||
const allSkills = !options.skills
|
const allSkills = options.skills ? [...options.skills] : discovered
|
||||||
? discovered
|
|
||||||
: [
|
|
||||||
...discovered,
|
|
||||||
...options.skills.filter(
|
|
||||||
(skill) => !new Set(discovered.map((discoveredSkill) => discoveredSkill.name)).has(skill.name)
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
if (options.nativeSkills) {
|
if (options.nativeSkills) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user