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:
parent
a9b2da802f
commit
45a850afc0
@ -27,7 +27,7 @@ const COUNCIL_CANDIDATES: Array<{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
provider: (a) => a.kimiForCoding,
|
provider: (a) => a.kimiForCoding,
|
||||||
model: "kimi-for-coding/k2p5",
|
model: "kimi-for-coding/kimi-k2.5",
|
||||||
name: "Kimi 2.5",
|
name: "Kimi 2.5",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -185,7 +185,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
|||||||
const skillNames = ["playwright", "git-master"]
|
const skillNames = ["playwright", "git-master"]
|
||||||
|
|
||||||
// when: resolving multiple skills async
|
// when: resolving multiple skills async
|
||||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||||
|
|
||||||
// then: all builtin skills resolved
|
// then: all builtin skills resolved
|
||||||
expect(result.resolved.size).toBe(2)
|
expect(result.resolved.size).toBe(2)
|
||||||
@ -199,7 +199,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
|||||||
const skillNames = ["playwright", "nonexistent-skill-12345"]
|
const skillNames = ["playwright", "nonexistent-skill-12345"]
|
||||||
|
|
||||||
// when: resolving multiple skills async
|
// 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
|
// then: existing skills resolved, non-existing in notFound
|
||||||
expect(result.resolved.size).toBe(1)
|
expect(result.resolved.size).toBe(1)
|
||||||
@ -286,7 +286,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
|||||||
const skillNames = ["git-master"]
|
const skillNames = ["git-master"]
|
||||||
|
|
||||||
// when: resolving without any gitMasterConfig
|
// 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)
|
// then: watermark is injected (default is ON)
|
||||||
expect(result.resolved.size).toBe(1)
|
expect(result.resolved.size).toBe(1)
|
||||||
@ -357,7 +357,7 @@ describe("resolveMultipleSkillsAsync", () => {
|
|||||||
const skillNames: string[] = []
|
const skillNames: string[] = []
|
||||||
|
|
||||||
// when: resolving multiple skills async
|
// when: resolving multiple skills async
|
||||||
const result = await resolveMultipleSkillsAsync(skillNames)
|
const result = await resolveMultipleSkillsAsync(skillNames, { directory: process.cwd() })
|
||||||
|
|
||||||
// then: empty results
|
// then: empty results
|
||||||
expect(result.resolved.size).toBe(0)
|
expect(result.resolved.size).toBe(0)
|
||||||
|
|||||||
@ -9,8 +9,8 @@ export function clearSkillCache(): void {
|
|||||||
skillCache.clear()
|
skillCache.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllSkills(options?: SkillResolutionOptions): Promise<LoadedSkill[]> {
|
export async function getAllSkills(options: SkillResolutionOptions & { directory: string }): Promise<LoadedSkill[]> {
|
||||||
const directory = options?.directory ?? process.cwd()
|
const directory = options.directory
|
||||||
const cacheKey = `${options?.browserProvider ?? "playwright"}:${directory}`
|
const cacheKey = `${options?.browserProvider ?? "playwright"}:${directory}`
|
||||||
const hasDisabledSkills = options?.disabledSkills && options.disabledSkills.size > 0
|
const hasDisabledSkills = options?.disabledSkills && options.disabledSkills.size > 0
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,6 @@ export interface SkillResolutionOptions {
|
|||||||
gitMasterConfig?: GitMasterConfig
|
gitMasterConfig?: GitMasterConfig
|
||||||
browserProvider?: BrowserAutomationProvider
|
browserProvider?: BrowserAutomationProvider
|
||||||
disabledSkills?: Set<string>
|
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
|
directory?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export function resolveMultipleSkills(
|
|||||||
|
|
||||||
export async function resolveSkillContentAsync(
|
export async function resolveSkillContentAsync(
|
||||||
skillName: string,
|
skillName: string,
|
||||||
options?: SkillResolutionOptions
|
options: SkillResolutionOptions & { directory: string }
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const allSkills = await getAllSkills(options)
|
const allSkills = await getAllSkills(options)
|
||||||
const skill = allSkills.find((loadedSkill) => loadedSkill.name === skillName)
|
const skill = allSkills.find((loadedSkill) => loadedSkill.name === skillName)
|
||||||
@ -68,7 +68,7 @@ export async function resolveSkillContentAsync(
|
|||||||
|
|
||||||
export async function resolveMultipleSkillsAsync(
|
export async function resolveMultipleSkillsAsync(
|
||||||
skillNames: string[],
|
skillNames: string[],
|
||||||
options?: SkillResolutionOptions
|
options: SkillResolutionOptions & { directory: string }
|
||||||
): Promise<{ resolved: Map<string, string>; notFound: string[] }> {
|
): Promise<{ resolved: Map<string, string>; notFound: string[] }> {
|
||||||
const allSkills = await getAllSkills(options)
|
const allSkills = await getAllSkills(options)
|
||||||
const skillMap = new Map<string, LoadedSkill>()
|
const skillMap = new Map<string, LoadedSkill>()
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { resolveMultipleSkillsAsync, getAllSkills } from "../../features/opencod
|
|||||||
|
|
||||||
export async function resolveSkillContent(
|
export async function resolveSkillContent(
|
||||||
skills: string[],
|
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 }> {
|
): Promise<{ content: string | undefined; error: string | null }> {
|
||||||
if (skills.length === 0) {
|
if (skills.length === 0) {
|
||||||
return { content: undefined, error: null }
|
return { content: undefined, error: null }
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export * from "./constants"
|
export * from "./constants"
|
||||||
export * from "./types"
|
export * from "./types"
|
||||||
export { skill, createSkillTool } from "./tools"
|
export { createSkillTool } from "./tools"
|
||||||
|
|||||||
@ -181,7 +181,7 @@ async function formatMcpCapabilities(
|
|||||||
return sections.join("\n")
|
return sections.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition {
|
export function createSkillTool(options: SkillLoadOptions): ToolDefinition {
|
||||||
let cachedSkills: LoadedSkill[] | null = null
|
let cachedSkills: LoadedSkill[] | null = null
|
||||||
let cachedCommands: CommandInfo[] | null = options.commands ?? null
|
let cachedCommands: CommandInfo[] | null = options.commands ?? null
|
||||||
let cachedDescription: string | null = null
|
let cachedDescription: string | null = null
|
||||||
@ -250,7 +250,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
|||||||
body = injectGitMasterConfig(body, options.gitMasterConfig)
|
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 = [
|
const output = [
|
||||||
`## Skill: ${matchedSkill.name}`,
|
`## Skill: ${matchedSkill.name}`,
|
||||||
@ -309,5 +309,3 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const skill: ToolDefinition = createSkillTool()
|
|
||||||
|
|||||||
@ -33,6 +33,6 @@ export interface SkillLoadOptions {
|
|||||||
/** Git master configuration for watermark/co-author settings */
|
/** Git master configuration for watermark/co-author settings */
|
||||||
gitMasterConfig?: GitMasterConfig
|
gitMasterConfig?: GitMasterConfig
|
||||||
disabledSkills?: Set<string>
|
disabledSkills?: Set<string>
|
||||||
/** Project directory for skill discovery and base directory resolution. Should be ctx.directory from PluginContext. */
|
/** Project directory for skill discovery and base directory resolution. Must be ctx.directory from PluginContext — process.cwd() is unsafe in OpenCode. */
|
||||||
directory?: string
|
directory: string
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user