fix: enforce directory param in skill resolution, replace legacy k2p5 model ID
- Make directory required in SkillLoadOptions, getAllSkills, and async skill template resolvers to prevent unsafe process.cwd() fallback - Remove dead skill export and process.cwd() fallback in skill tool - Replace kimi-for-coding/k2p5 with kimi-for-coding/kimi-k2.5 in council-members-generator
This commit is contained in:
@@ -185,7 +185,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
||||
const skillNames = ["playwright", "git-master"]
|
||||
|
||||
// when: resolving multiple skills async
|
||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
||||
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||
|
||||
// then: all builtin skills resolved
|
||||
expect(result.resolved.size).toBe(2)
|
||||
@@ -199,7 +199,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
||||
const skillNames = ["playwright", "nonexistent-skill-12345"]
|
||||
|
||||
// when: resolving multiple skills async
|
||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
||||
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||
|
||||
// then: existing skills resolved, non-existing in notFound
|
||||
expect(result.resolved.size).toBe(1)
|
||||
@@ -289,7 +289,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
||||
const skillNames = ["git-master"]
|
||||
|
||||
// when: resolving without any gitMasterConfig
|
||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
||||
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||
|
||||
// then: watermark is injected (default is ON)
|
||||
expect(result.resolved.size).toBe(1)
|
||||
@@ -363,7 +363,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
||||
const skillNames: string[] = []
|
||||
|
||||
// when: resolving multiple skills async
|
||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
||||
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||
|
||||
// then: empty results
|
||||
expect(result.resolved.size).toBe(0)
|
||||
|
||||
@@ -9,8 +9,8 @@ export function clearSkillCache(): void {
|
||||
skillCache.clear()
|
||||
}
|
||||
|
||||
export async function getAllSkills(options?: SkillResolutionOptions): Promise<LoadedSkill[]> {
|
||||
const directory = options?.directory ?? process.cwd()
|
||||
export async function getAllSkills(options: SkillResolutionOptions & { directory: string }): Promise<LoadedSkill[]> {
|
||||
const directory = options.directory
|
||||
const cacheKey = `${options?.browserProvider ?? "playwright"}:${directory}`
|
||||
const hasDisabledSkills = options?.disabledSkills && options.disabledSkills.size > 0
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@ export interface SkillResolutionOptions {
|
||||
gitMasterConfig?: GitMasterConfig
|
||||
browserProvider?: BrowserAutomationProvider
|
||||
disabledSkills?: Set<string>
|
||||
/** Project directory to discover project-level skills from. Falls back to process.cwd() if not provided. */
|
||||
/** Project directory to discover project-level skills from. Required for async resolution — process.cwd() is unsafe in OpenCode. */
|
||||
directory?: string
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function resolveMultipleSkills(
|
||||
|
||||
export async function resolveSkillContentAsync(
|
||||
skillName: string,
|
||||
options?: SkillResolutionOptions
|
||||
options: SkillResolutionOptions & { directory: string }
|
||||
): Promise<string | null> {
|
||||
const allSkills = await getAllSkills(options)
|
||||
const skill = allSkills.find((loadedSkill) => loadedSkill.name === skillName)
|
||||
@@ -68,7 +68,7 @@ export async function resolveSkillContentAsync(
|
||||
|
||||
export async function resolveMultipleSkillsAsync(
|
||||
skillNames: string[],
|
||||
options?: SkillResolutionOptions
|
||||
options: SkillResolutionOptions & { directory: string }
|
||||
): Promise<{ resolved: Map<string, string>; notFound: string[] }> {
|
||||
const allSkills = await getAllSkills(options)
|
||||
const skillMap = new Map<string, LoadedSkill>()
|
||||
|
||||
Reference in New Issue
Block a user