Provide suggestions for running commands (restart/refresh/rebuild) (#62)
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
getDyadExecuteSqlTags,
|
||||
getDyadRenameTags,
|
||||
getDyadWriteTags,
|
||||
getDyadCommandTags,
|
||||
processFullResponseActions,
|
||||
} from "../processors/response_processor";
|
||||
import log from "electron-log";
|
||||
@@ -247,6 +248,24 @@ const getProposalHandler = async (
|
||||
id: "write-code-properly",
|
||||
});
|
||||
}
|
||||
|
||||
// Check for command tags and add corresponding actions
|
||||
const commandTags = getDyadCommandTags(latestAssistantMessage.content);
|
||||
if (commandTags.includes("rebuild")) {
|
||||
actions.push({
|
||||
id: "rebuild",
|
||||
});
|
||||
}
|
||||
if (commandTags.includes("restart")) {
|
||||
actions.push({
|
||||
id: "restart",
|
||||
});
|
||||
}
|
||||
if (commandTags.includes("refresh")) {
|
||||
actions.push({
|
||||
id: "refresh",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Get all chat messages to calculate token usage
|
||||
|
||||
@@ -138,6 +138,19 @@ export function getDyadExecuteSqlTags(fullResponse: string): SqlQuery[] {
|
||||
return queries;
|
||||
}
|
||||
|
||||
export function getDyadCommandTags(fullResponse: string): string[] {
|
||||
const dyadCommandRegex =
|
||||
/<dyad-command type="([^"]+)"[^>]*><\/dyad-command>/g;
|
||||
let match;
|
||||
const commands: string[] = [];
|
||||
|
||||
while ((match = dyadCommandRegex.exec(fullResponse)) !== null) {
|
||||
commands.push(match[1]);
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
interface Output {
|
||||
message: string;
|
||||
error: unknown;
|
||||
|
||||
Reference in New Issue
Block a user