Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ export namespace SessionPrompt {
},
})

for (const item of await ToolRegistry.tools(input.model.providerID)) {
for (const item of await ToolRegistry.tools(input.model.providerID, input.agent)) {
const schema = ProviderTransform.schema(input.model, z.toJSONSchema(item.parameters))
tools[item.id] = tool({
id: item.id as any,
Expand Down
34 changes: 16 additions & 18 deletions packages/opencode/src/tool/skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@ import z from "zod"
import { Tool } from "./tool"
import { Skill } from "../skill"
import { ConfigMarkdown } from "../config/markdown"
import { PermissionNext } from "../permission/next"

export const SkillTool = Tool.define("skill", async () => {
const parameters = z.object({
name: z.string().describe("The skill identifier from available_skills (e.g., 'code-review' or 'category/helper')"),
})

export const SkillTool = Tool.define("skill", async (ctx) => {
const skills = await Skill.all()

// Filter skills by agent permissions if agent provided
/*
let accessibleSkills = skills
if (ctx?.agent) {
const permissions = ctx.agent.permission.skill
accessibleSkills = skills.filter((skill) => {
const action = Wildcard.all(skill.name, permissions)
return action !== "deny"
const agent = ctx?.agent
const accessibleSkills = agent
? skills.filter((skill) => {
const rule = PermissionNext.evaluate("skill", skill.name, agent.permission)
return rule.action !== "deny"
})
}
*/
: skills

const description =
skills.length === 0
accessibleSkills.length === 0
? "Load a skill to get detailed instructions for a specific task. No skills are currently available."
: [
"Load a skill to get detailed instructions for a specific task.",
"Skills provide specialized knowledge and step-by-step guidance.",
"Use this when a task matches an available skill's description.",
"<available_skills>",
...skills.flatMap((skill) => [
...accessibleSkills.flatMap((skill) => [
` <skill>`,
` <name>${skill.name}</name>`,
` <description>${skill.description}</description>`,
Expand All @@ -38,12 +40,8 @@ export const SkillTool = Tool.define("skill", async () => {

return {
description,
parameters: z.object({
name: z
.string()
.describe("The skill identifier from available_skills (e.g., 'code-review' or 'category/helper')"),
}),
async execute(params, ctx) {
parameters,
async execute(params: z.infer<typeof parameters>, ctx) {
const skill = await Skill.get(params.name)

if (!skill) {
Expand Down