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:
ismeth
2026-02-20 21:53:05 +01:00
committed by YeonGyu-Kim
parent a9b2da802f
commit 45a850afc0
9 changed files with 16 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ const COUNCIL_CANDIDATES: Array<{
},
{
provider: (a) => a.kimiForCoding,
model: "kimi-for-coding/k2p5",
model: "kimi-for-coding/kimi-k2.5",
name: "Kimi 2.5",
}
]

View File

@@ -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)
@@ -286,7 +286,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)
@@ -357,7 +357,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)

View File

@@ -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

View File

@@ -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
}

View File

@@ -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>()

View File

@@ -3,7 +3,7 @@ import { resolveMultipleSkillsAsync, getAllSkills } from "../../features/opencod
export async function resolveSkillContent(
skills: string[],
options: { gitMasterConfig?: GitMasterConfig; browserProvider?: BrowserAutomationProvider; disabledSkills?: Set<string>; directory?: string }
options: { gitMasterConfig?: GitMasterConfig; browserProvider?: BrowserAutomationProvider; disabledSkills?: Set<string>; directory: string }
): Promise<{ content: string | undefined; error: string | null }> {
if (skills.length === 0) {
return { content: undefined, error: null }

View File

@@ -1,3 +1,3 @@
export * from "./constants"
export * from "./types"
export { skill, createSkillTool } from "./tools"
export { createSkillTool } from "./tools"

View File

@@ -181,7 +181,7 @@ async function formatMcpCapabilities(
return sections.join("\n")
}
export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition {
export function createSkillTool(options: SkillLoadOptions): ToolDefinition {
let cachedSkills: LoadedSkill[] | null = null
let cachedCommands: CommandInfo[] | null = options.commands ?? null
let cachedDescription: string | null = null
@@ -250,7 +250,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
body = injectGitMasterConfig(body, options.gitMasterConfig)
}
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || options.directory || process.cwd()
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || options.directory
const output = [
`## Skill: ${matchedSkill.name}`,
@@ -309,5 +309,3 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
},
})
}
export const skill: ToolDefinition = createSkillTool()

View File

@@ -33,6 +33,6 @@ export interface SkillLoadOptions {
/** Git master configuration for watermark/co-author settings */
gitMasterConfig?: GitMasterConfig
disabledSkills?: Set<string>
/** Project directory for skill discovery and base directory resolution. Should be ctx.directory from PluginContext. */
directory?: string
/** Project directory for skill discovery and base directory resolution. Must be ctx.directory from PluginContext — process.cwd() is unsafe in OpenCode. */
directory: string
}