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:
@@ -4,7 +4,7 @@ import { discoverSkills } from "../../features/opencode-skill-loader"
|
||||
|
||||
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; contents: string[]; error: string | null }> {
|
||||
if (skills.length === 0) {
|
||||
return { content: undefined, contents: [], error: null }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from "./constants"
|
||||
export * from "./types"
|
||||
export { skill, createSkillTool } from "./tools"
|
||||
export { createSkillTool } from "./tools"
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
mergeNativeSkills,
|
||||
} from "./native-skills"
|
||||
|
||||
export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition {
|
||||
export function createSkillTool(options: SkillLoadOptions): ToolDefinition {
|
||||
let cachedDescription: string | null = null
|
||||
|
||||
const getSkills = async (): Promise<LoadedSkill[]> => {
|
||||
@@ -32,6 +32,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
const discovered = await getAllSkills({
|
||||
disabledSkills: options?.disabledSkills,
|
||||
browserProvider: options?.browserProvider,
|
||||
directory: options.directory,
|
||||
})
|
||||
const allSkills = !options.skills
|
||||
? discovered
|
||||
@@ -138,7 +139,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}`,
|
||||
@@ -192,5 +193,3 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const skill: ToolDefinition = createSkillTool()
|
||||
|
||||
@@ -45,6 +45,6 @@ export interface SkillLoadOptions {
|
||||
get(name: string): { name: string; description: string; location: string; content: string } | undefined | Promise<{ name: string; description: string; location: string; content: string } | undefined>
|
||||
dirs(): string[] | Promise<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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user