Added AskCode functionality to DevChat

- Added new settings for Python virtual environment and supported file types in package.json.
- Added new commands for starting and stopping AskCode Index in package.json.
- Registered new 'ask-code' command in CommandManager.
- Registered AskCode Index start and stop commands in extension.ts.
- Added 'askCode' handler in loadHandlers.ts and messageHandler.ts.
- Updated messageHandler to check for '/ask-code' in message text and call 'askCode' command.
This commit is contained in:
bobo.yang 2023-08-21 11:52:00 +08:00
parent 59d2c057c5
commit fd011ee265
5 changed files with 41 additions and 1 deletions

View File

@ -155,6 +155,16 @@
"default": false,
"description": "Enable/Disable function calling for GPT.",
"when": "DevChat.llmModel == 'OpenAI'"
},
"DevChat.PythonVirtualEnv": {
"type": "string",
"default": "",
"description": "Path to the Python virtual environment for AskCode."
},
"DevChat.askcode.supportedFileTypes": {
"type": "string",
"default": ".+\\.js$, .+\\.ts$, .+\\.jsx$, .+\\.tsx$, .+\\.java$, .+\\.py$, .+\\.go$, .+\\.rb$, .+\\.php$, .+\\.cpp$, .+\\.c$, .+\\.cs$, .+\\.swift$, .+\\.rs$, .+\\.sh$, .+\\.bash$, .+\\.zsh$, .+\\.m$, .+\\.mm$, .+\\.h$, .+\\.hpp$, .+\\.hh$, .+\\.html$, .+\\.htm$, .+\\.xhtml$, .+\\.xml$, .+\\.css$, .+\\.scss$, .+\\.sass$, .+\\.less$, .+\\.json$, .+\\.yaml$, .+\\.yml$, .+\\.toml$, .+\\.ini$, .+\\.md$, .+\\.markdown$, .+\\.txt$, .+\\.csv$, .+\\.sql$, .+\\.sqlite$, .+\\.db$, .+\\.hql$, .+\\.psql$, .+\\.pgsql$, .+\\.plpgsql$",
"description": "Comma-separated list of regular expressions for supported file types for analysis."
}
}
},
@ -257,6 +267,16 @@
{
"command": "devchat.askForFile_chinese",
"title": "添加到DevChat"
},
{
"command": "DevChat.AskCodeIndexStart",
"title": "Start AskCode Index",
"category": "DevChat"
},
{
"command": "DevChat.AskCodeIndexStop",
"title": "Stop AskCode Index",
"category": "DevChat"
}
],
"menus": {

View File

@ -17,6 +17,15 @@ class CommandManager {
public static getInstance(): CommandManager {
if (!CommandManager.instance) {
CommandManager.instance = new CommandManager();
CommandManager.instance.registerCommand({
name: 'ask-code',
pattern: 'ask-code',
description: 'ask code',
args: 0,
handler: async (commandName: string, userInput: string) => {
return;
}
});
}
return CommandManager.instance;

View File

@ -15,6 +15,8 @@ import {
regApplyDiffResultCommand,
registerStatusBarItemClickCommand,
regPythonPathCommand,
registerAskCodeIndexStartCommand,
registerAskCodeIndexStopCommand,
} from './contributes/commands';
import { regLanguageContext } from './contributes/context';
import { regDevChatView, regTopicView } from './contributes/views';
@ -56,5 +58,7 @@ function activate(context: vscode.ExtensionContext) {
regApplyDiffResultCommand(context);
regPythonPathCommand(context);
registerAskCodeIndexStartCommand(context);
registerAskCodeIndexStopCommand(context);
}
exports.activate = activate;

View File

@ -6,7 +6,7 @@ import { doCommit } from './doCommit';
import { historyMessages } from './historyMessages';
import { regCommandList } from './regCommandList';
import { regContextList } from './regContextList';
import { sendMessage, stopDevChat, regeneration, deleteChatMessage } from './sendMessage';
import { sendMessage, stopDevChat, regeneration, deleteChatMessage, askCode } from './sendMessage';
import { blockApply } from './showDiff';
import { showDiff } from './showDiff';
import { addConext } from './addContext';
@ -76,3 +76,5 @@ messageHandler.registerHandler('applyAction', applyAction);
// Delete chat message
// Response: { command: 'deletedChatMessage', result: <message id> }
messageHandler.registerHandler('deleteChatMessage', deleteChatMessage);
messageHandler.registerHandler('askCode', askCode);

View File

@ -52,6 +52,11 @@ export class MessageHandler {
if (message.text.indexOf('/autox') !== -1) {
autox = true;
}
// if "/ask-code" in message.text, then call devchat-ask to get result
if (message.text.indexOf('/ask-code') !== -1) {
message.command = 'askCode';
message.text = message.text.replace('/ask-code', '');
}
}
const handler = this.handlers[message.command];