Procházet zdrojové kódy

fix: ensure commands listing subagent work

Aiden Cline před 1 měsícem
rodič
revize
625c9dae5c

+ 1 - 0
packages/opencode/src/session/prompt.ts

@@ -382,6 +382,7 @@ export namespace SessionPrompt {
           messageID: assistantMessage.id,
           messageID: assistantMessage.id,
           sessionID: sessionID,
           sessionID: sessionID,
           abort,
           abort,
+          extra: { bypassAgentCheck: true },
           async metadata(input) {
           async metadata(input) {
             await Session.updatePart({
             await Session.updatePart({
               ...part,
               ...part,

+ 12 - 9
packages/opencode/src/tool/task.ts

@@ -30,15 +30,18 @@ export const TaskTool = Tool.define("task", async () => {
     }),
     }),
     async execute(params, ctx) {
     async execute(params, ctx) {
       const config = await Config.get()
       const config = await Config.get()
-      await ctx.ask({
-        permission: "task",
-        patterns: [params.subagent_type],
-        always: ["*"],
-        metadata: {
-          description: params.description,
-          subagent_type: params.subagent_type,
-        },
-      })
+      // Skip permission check when invoked from a command subtask (user already approved by invoking the command)
+      if (!ctx.extra?.bypassAgentCheck) {
+        await ctx.ask({
+          permission: "task",
+          patterns: [params.subagent_type],
+          always: ["*"],
+          metadata: {
+            description: params.description,
+            subagent_type: params.subagent_type,
+          },
+        })
+      }
 
 
       const agent = await Agent.get(params.subagent_type)
       const agent = await Agent.get(params.subagent_type)
       if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
       if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)