From 60d2c5b808ac954d5cf94c37f7b82ba7ed5ec659 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Mon, 13 May 2024 21:43:06 +0800 Subject: [PATCH] Update submodules and workflow commands --- gui | 2 +- src/handler/workflowCommandHandler.ts | 45 ++------------------------- src/toolwrapper/devchat.ts | 6 ++-- tools | 2 +- workflowsCommands | 2 +- 5 files changed, 7 insertions(+), 50 deletions(-) diff --git a/gui b/gui index fc781ce..fc5e916 160000 --- a/gui +++ b/gui @@ -1 +1 @@ -Subproject commit fc781cece340c22ecf301c612e64efde3313a2dc +Subproject commit fc5e916ec69fd0dcc18fe4ea92352ae8dd3d9e67 diff --git a/src/handler/workflowCommandHandler.ts b/src/handler/workflowCommandHandler.ts index 75d6866..4c99330 100644 --- a/src/handler/workflowCommandHandler.ts +++ b/src/handler/workflowCommandHandler.ts @@ -5,38 +5,6 @@ import { ApiKeyManager } from '../util/apiKey'; import DevChat from '../toolwrapper/devchat'; -export interface Command { - name: string; - pattern: string; - description: string; - path: string; - args: number; - recommend: number; - handler: (commandName: string, userInput: string) => Promise; -} - -async function getCommandListByDevChatRun(includeHide: boolean = false): Promise { - // load commands from CustomCommands - let newCommands: Command[] = []; - - const devChat = new DevChat(); - const commandList = await devChat.commands(); - commandList.forEach(command => { - const commandObj: Command = { - name: command.name, - pattern: command.name, - description: command.description, - path: command.path, - recommend: command.recommend, - args: 0, - handler: async (commandName: string, userInput: string) => { return ''; } - }; - newCommands.push(commandObj); - }); - - return newCommands; -} - let existPannel: vscode.WebviewPanel|vscode.WebviewView|undefined = undefined; regInMessage({command: 'regCommandList'}); @@ -44,17 +12,8 @@ regOutMessage({command: 'regCommandList', result: [{name: '', pattern: '', descr export async function getWorkflowCommandList(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise { existPannel = panel; - const commandList = await getCommandListByDevChatRun(); - const commandCovertedList = commandList.map(command => { - if (command.args > 0) { - // replace {{prompt}} with {{["",""]}}, count of "" is args - const prompt = Array.from({length: command.args}, () => ""); - command.pattern = command.pattern.replace('{{prompt}}', '{{' + JSON.stringify(prompt) + '}}'); - } - return command; - }); - - MessageHandler.sendMessage(panel, { command: 'regCommandList', result: commandCovertedList }); + const commandList = await new DevChat().commands(); + MessageHandler.sendMessage(panel, { command: 'regCommandList', result: commandList }); return; } diff --git a/src/toolwrapper/devchat.ts b/src/toolwrapper/devchat.ts index e1913ba..3ec5b80 100644 --- a/src/toolwrapper/devchat.ts +++ b/src/toolwrapper/devchat.ts @@ -453,7 +453,7 @@ class DevChat { } } - async commands(): Promise { + async commands(): Promise { try { const args = ["-m", "devchat", "workflow", "list", "--json"]; @@ -475,9 +475,7 @@ class DevChat { // 确保每个CommandEntry对象的recommend字段默认为-1 const recommendCommands = await this.loadRecommendCommands(); commands = commands.map((cmd: any) => ({ - name: cmd.name, - description: cmd.command_conf.description, - path: cmd.namespace, + ...cmd, recommend: recommendCommands.indexOf(cmd.name), })); diff --git a/tools b/tools index 1db2a69..a761c6a 160000 --- a/tools +++ b/tools @@ -1 +1 @@ -Subproject commit 1db2a69a5f1cd1576e582d9d7b3ae5a2d88392c2 +Subproject commit a761c6a462fb0d0e5eb8ec3328dba2015d455fe6 diff --git a/workflowsCommands b/workflowsCommands index daea79e..a9015f2 160000 --- a/workflowsCommands +++ b/workflowsCommands @@ -1 +1 @@ -Subproject commit daea79e719527e93a5262a2b8f1d1cb83c47ebe7 +Subproject commit a9015f2a37a25e324a8e9e41a9c12b75a8b78e37