Update workflows via client

This commit is contained in:
kagami 2024-07-08 19:33:08 +08:00
parent b9df28d20d
commit 8becdb00aa
2 changed files with 18 additions and 6 deletions

View File

@ -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();
}
}

View File

@ -142,6 +142,18 @@ export class DevChatClient {
}
@timeThis
async updateWorkflows(): Promise<void> {
const response = await this._post("/workflow/update");
logger
.channel()
?.debug(
`updateWorkflows response data: \n${JSON.stringify(
response.data
)}`
);
}
@timeThis
async message(
message: ChatRequest,