From 8becdb00aa8afd7d00841bb5429e1bc5a192fcf5 Mon Sep 17 00:00:00 2001 From: kagami Date: Mon, 8 Jul 2024 19:33:08 +0800 Subject: [PATCH] Update workflows via client --- src/contributes/commands.ts | 12 ++++++------ src/toolwrapper/devchatClient.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index e172e81..8fe0710 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -8,7 +8,7 @@ import { FilePairManager } from "../util/diffFilePairs"; import { UiUtilWrapper } from "../util/uiUtil"; import { sendCommandListByDevChatRun } from '../handler/workflowCommandHandler'; -import DevChat from "../toolwrapper/devchat"; +import { DevChatClient } from "../toolwrapper/devchatClient"; import { chatWithDevChat } from '../handler/chatHandler'; import { focusDevChatInput } from '../handler/focusHandler'; import { DevChatConfig } from '../util/config'; @@ -196,7 +196,7 @@ export function registerInstallCommandsCommand( "workflowsCommands" ); // Adjust this path as needed - const devchat = new DevChat(); + const dcClient = new DevChatClient(); if (!fs.existsSync(sysDirPath)) { await copyDirectory(pluginDirPath, sysDirPath); @@ -204,15 +204,15 @@ export function registerInstallCommandsCommand( // Check if ~/.chat/scripts directory exists if (!fs.existsSync(sysDirPath)) { - // Directory does not exist, wait for updateSysCommand to finish - await devchat.updateSysCommand(); + // Directory does not exist, wait for updateWorkflows to finish + await dcClient.updateWorkflows(); sendCommandListByDevChatRun(); } else { // Directory exists, execute sendCommandListByDevChatRun immediately await sendCommandListByDevChatRun(); - // Then asynchronously execute updateSysCommand - await devchat.updateSysCommand(); + // Then asynchronously execute updateWorkflows + await dcClient.updateWorkflows(); await sendCommandListByDevChatRun(); } } diff --git a/src/toolwrapper/devchatClient.ts b/src/toolwrapper/devchatClient.ts index a4f9ffb..336b3f8 100644 --- a/src/toolwrapper/devchatClient.ts +++ b/src/toolwrapper/devchatClient.ts @@ -142,6 +142,18 @@ export class DevChatClient { } + @timeThis + async updateWorkflows(): Promise { + const response = await this._post("/workflow/update"); + logger + .channel() + ?.debug( + `updateWorkflows response data: \n${JSON.stringify( + response.data + )}` + ); + } + @timeThis async message( message: ChatRequest,