Parcourir la source

tweak: adjust skill tool description to make it more clear which skills are available

Aiden Cline il y a 1 mois
Parent
commit
ab3d412a81
2 fichiers modifiés avec 11 ajouts et 5 suppressions
  1. 0 1
      packages/opencode/src/skill/skill.ts
  2. 11 4
      packages/opencode/src/tool/skill.ts

+ 0 - 1
packages/opencode/src/skill/skill.ts

@@ -9,7 +9,6 @@ import { Global } from "@/global"
 import { Filesystem } from "@/util/filesystem"
 import { Flag } from "@/flag/flag"
 import { Bus } from "@/bus"
-import { TuiEvent } from "@/cli/cmd/tui/event"
 import { Session } from "@/session"
 
 export namespace Skill {

+ 11 - 4
packages/opencode/src/tool/skill.ts

@@ -5,10 +5,6 @@ import { Skill } from "../skill"
 import { ConfigMarkdown } from "../config/markdown"
 import { PermissionNext } from "../permission/next"
 
-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()
 
@@ -28,6 +24,7 @@ export const SkillTool = Tool.define("skill", async (ctx) => {
           "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.",
+          "Only the skills listed here are available:",
           "<available_skills>",
           ...accessibleSkills.flatMap((skill) => [
             `  <skill>`,
@@ -38,6 +35,16 @@ export const SkillTool = Tool.define("skill", async (ctx) => {
           "</available_skills>",
         ].join(" ")
 
+  const examples = accessibleSkills
+    .map((skill) => `'${skill.name}'`)
+    .slice(0, 3)
+    .join(", ")
+  const hint = examples.length > 0 ? ` (e.g., ${examples}, ...)` : ""
+
+  const parameters = z.object({
+    name: z.string().describe(`The skill identifier from available_skills${hint}`),
+  })
+
   return {
     description,
     parameters,