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 { UiUtilWrapper } from "../util/uiUtil";
import { sendCommandListByDevChatRun } from '../handler/workflowCommandHandler'; import { sendCommandListByDevChatRun } from '../handler/workflowCommandHandler';
import DevChat from "../toolwrapper/devchat"; import { DevChatClient } from "../toolwrapper/devchatClient";
import { chatWithDevChat } from '../handler/chatHandler'; import { chatWithDevChat } from '../handler/chatHandler';
import { focusDevChatInput } from '../handler/focusHandler'; import { focusDevChatInput } from '../handler/focusHandler';
import { DevChatConfig } from '../util/config'; import { DevChatConfig } from '../util/config';
@ -196,7 +196,7 @@ export function registerInstallCommandsCommand(
"workflowsCommands" "workflowsCommands"
); // Adjust this path as needed ); // Adjust this path as needed
const devchat = new DevChat(); const dcClient = new DevChatClient();
if (!fs.existsSync(sysDirPath)) { if (!fs.existsSync(sysDirPath)) {
await copyDirectory(pluginDirPath, sysDirPath); await copyDirectory(pluginDirPath, sysDirPath);
@ -204,15 +204,15 @@ export function registerInstallCommandsCommand(
// Check if ~/.chat/scripts directory exists // Check if ~/.chat/scripts directory exists
if (!fs.existsSync(sysDirPath)) { if (!fs.existsSync(sysDirPath)) {
// Directory does not exist, wait for updateSysCommand to finish // Directory does not exist, wait for updateWorkflows to finish
await devchat.updateSysCommand(); await dcClient.updateWorkflows();
sendCommandListByDevChatRun(); sendCommandListByDevChatRun();
} else { } else {
// Directory exists, execute sendCommandListByDevChatRun immediately // Directory exists, execute sendCommandListByDevChatRun immediately
await sendCommandListByDevChatRun(); await sendCommandListByDevChatRun();
// Then asynchronously execute updateSysCommand // Then asynchronously execute updateWorkflows
await devchat.updateSysCommand(); await dcClient.updateWorkflows();
await sendCommandListByDevChatRun(); 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 @timeThis
async message( async message(
message: ChatRequest, message: ChatRequest,