Add an entrypoint for workflow cli for dev

This commit is contained in:
kagami 2024-04-16 22:06:40 +08:00
parent 4196d902a4
commit 66da2dfc80
4 changed files with 43 additions and 0 deletions

View File

@ -686,6 +686,11 @@
"title": "Install slash commands", "title": "Install slash commands",
"category": "DevChat" "category": "DevChat"
}, },
{
"command": "DevChat.TryWF",
"title": "Run workflow cli",
"category": "DevChat"
},
{ {
"command": "DevChat.UpdataChatModels", "command": "DevChat.UpdataChatModels",
"title": "Update Chat Models", "title": "Update Chat Models",

View File

@ -223,6 +223,21 @@ export function registerInstallCommandsCommand(
context.subscriptions.push(disposable); context.subscriptions.push(disposable);
} }
export function registerTryWF(
context: vscode.ExtensionContext
) {
let disposable = vscode.commands.registerCommand(
"DevChat.TryWF",
async () => {
const devchat = new DevChat();
await devchat.tryWF();
}
);
context.subscriptions.push(disposable);
}
export function registerDevChatChatCommand(context: vscode.ExtensionContext) { export function registerDevChatChatCommand(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand( let disposable = vscode.commands.registerCommand(

View File

@ -16,6 +16,8 @@ import {
registerFixCommand, registerFixCommand,
registerExplainCommand, registerExplainCommand,
registerQuickFixCommand, registerQuickFixCommand,
registerTryWF,
} from './contributes/commands'; } from './contributes/commands';
import { regLanguageContext } from './contributes/context'; import { regLanguageContext } from './contributes/context';
import { regDevChatView } from './contributes/views'; import { regDevChatView } from './contributes/views';
@ -150,6 +152,7 @@ async function activate(context: vscode.ExtensionContext) {
registerInstallCommandsCommand(context); registerInstallCommandsCommand(context);
registerTryWF(context);
createStatusBarItem(context); createStatusBarItem(context);
regApplyDiffResultCommand(context); regApplyDiffResultCommand(context);

View File

@ -516,6 +516,26 @@ class DevChat {
return ""; return "";
} }
} }
async tryWF(): Promise<string> {
try {
const args = ["-m", "devchat", "workflow", "env", "remove", "--all"];
// const args = ["-m", "mamba", "--version"];
const {code, stdout, stderr} = await this.runCommand(args);
assertValue(code !== 0, stderr || `Command exited with ${code}`);
if (stderr.trim() !== "") {
logger.channel()?.warn(`${stderr}`);
}
logger.channel()?.info(`${stdout}`);
return stdout;
} catch (error: any) {
logger.channel()?.error(`Error: ${error.message}`);
logger.channel()?.show();
return "";
}
}
async topics(): Promise<TopicEntry[]> { async topics(): Promise<TopicEntry[]> {
try { try {