Refine comments

This commit is contained in:
Jinglei Ren 2023-05-28 08:18:14 +08:00
parent 6ccfa14824
commit fdc65c998c
3 changed files with 41 additions and 43 deletions

View File

@ -83,7 +83,7 @@ DevChat is the way developers interact and collaborate with AI.
&nbsp; &nbsp; <img width="220" alt="image" src="https://github.com/covespace/devchat-vscode/assets/592493/c30f76fe-321a-4145-88fa-a0ef3d36bde5">
- Since DevChat is designed for developers, it requires a Git repository folder to store metadata. Therefore, be sure to open a Git project.
- Set your [OpenAI API Key](https://platform.openai.com/account/api-keys) by running `export OPENAI_API_KEY="[sk-...]"` (or DevChat access key by DEVCHAT_KEY).
- Set your [OpenAI API Key](https://platform.openai.com/account/api-keys) by running `export OPENAI_API_KEY="[sk-...]"` (or use DevChat access key).
- Click on the DevChat icon in the status bar. If the API key setting is not configured, it will prompt you to enter it. Simply input the key.
&nbsp; &nbsp; <img width="400" alt="image" src="https://github.com/covespace/devchat-vscode/assets/592493/56f261c0-3aae-4df6-b699-c9e757bd91c1">

View File

@ -10,26 +10,26 @@ import * as process from 'process';
export function checkDevChatDependency(): boolean {
try {
// 获取pipx环境信息
// Get pipx environment
const pipxEnvOutput = childProcess.execSync('python3 -m pipx environment').toString();
const binPathRegex = /PIPX_BIN_DIR=\s*(.*)/;
// 提取BIN路径
// Get BIN path from pipx environment
const match = pipxEnvOutput.match(binPathRegex);
if (match && match[1]) {
const binPath = match[1];
// 将BIN路径添加到环境变量中
// Add BIN path to PATH
process.env.PATH = `${binPath}:${process.env.PATH}`;
// 检查devchat是否已经安装
// Check if DevChat is installed
childProcess.execSync('devchat --help');
return true;
} else {
return false;
}
} catch (error) {
// 命令执行失败,依赖程序未安装或其他异常
// DevChat dependency check failed
return false;
}
}
@ -55,12 +55,12 @@ function checkOpenAIKey() {
openaiApiKey = process.env.OPENAI_API_KEY;
}
if (!openaiApiKey) {
// openAI key 未设置请用户输入API Key
// OpenAI key not set
vscode.window.showInputBox({
placeHolder: 'Please input your openAI API Key'
}).then((value) => {
if (value) {
// 设置用户输入的API Key
// Set API Key
vscode.workspace.getConfiguration('DevChat').update('OpenAI.apiKey', value, true);
}
});

View File

@ -15,55 +15,53 @@ import { contextDetail } from './contextDetail';
import { listAllMessages } from './listMessages';
// 根据用户选择的context菜单添加对应的context文件
// 应答消息:
// 添加上下文文件信息: { command: 'appendContext', context: <context file> }
// According to the context menu selected by the user, add the corresponding context file
// Response: { command: 'appendContext', context: <context file> }
messageHandler.registerHandler('addContext', addConext);
// 将AI应答的代码块应用到当前激活视图中
// 应答消息: 无
// Apply the code block replied by AI to the currently active view
// Response: none
messageHandler.registerHandler('code_apply', codeApply);
// 将AI应答的代码块应用到当前激活视图中替换掉当前文件内容
// 应答消息: 无
// Apply the code block replied by AI to the currently active view, replacing the current file content
// Response: none
messageHandler.registerHandler('code_file_apply', codeFileApply);
// 将command输入转换为发送给AI的自然语言描述
// 应答消息: { command: 'convertCommand', result: <自然语言描述> }
// Convert the command input into a natural language description sent to AI
// Response: { command: 'convertCommand', result: <natural language description> }
messageHandler.registerHandler('convertCommand', convertCommand);
// 执行提交操作
// 应答消息: 无
// Perform commit operation
// Response: none
messageHandler.registerHandler('doCommit', doCommit);
// 获取历史消息,用户视图显示时调用
// 应答消息: { command: 'historyMessages', result: <历史消息> }
// <历史消息>是一个列表,具体属性信息添加接口时确定
// Get the history messages, called when the user view is displayed
// Response: { command: 'historyMessages', result: <history messages> }
// <history messages> is a list, the specific attribute information is determined when the interface is added
messageHandler.registerHandler('historyMessages', historyMessages);
// 注册命令列表
// 应答消息: { command: 'regCommandList', result: <命令列表> }
// Register the command list
// Response: { command: 'regCommandList', result: <command list> }
messageHandler.registerHandler('regCommandList', regCommandList);
// 注册context列表
// 应答消息: { command: 'regContextList', result: <context列表> }
// Register the context list
// Response: { command: 'regContextList', result: <context list> }
messageHandler.registerHandler('regContextList', regContextList);
// 发送消息,将用户输入的消息发送给AI
// 应答消息:
// { command: 'receiveMessagePartial', text: <应答消息文本>, user: <user>, date: <date> }
// { command: 'receiveMessage', hash: <消息hash>, text: text: <应答消息文本>, user: <user>, date: <date> }
// Send a message, send the message entered by the user to AI
// Response:
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
messageHandler.registerHandler('sendMessage', sendMessage);
// 停止devchat用于用户主动停止devchat
// 应答消息: 无
// Stop devchat, used to stop devchat by the user
// Response: none
messageHandler.registerHandler('stopDevChat', stopDevChat);
// 显示diff
// 应答消息: 无
// Show diff
// Response: none
messageHandler.registerHandler('block_apply', blockApply);
// 显示diff由于历史原因同上
// 应答消息: 无
// Show diff, for historical reasons, the same as above
messageHandler.registerHandler('show_diff', showDiff);
// 处理用户输入的ref命令
// 应答消息: { command: 'appendContext', context: <context file> }
// Process the ref command entered by the user
// Response: { command: 'appendContext', context: <context file> }
messageHandler.registerHandler('addRefCommandContext', addRefCommandContext);
// 获取context详情
// 应答消息: { command: 'contextDetailResponse', 'file':<context file>, result: <context file content> }
// <context file content>是一个JSON字符串
// Get context details
// Response: { command: 'contextDetailResponse', 'file':<context file>, result: <context file content> }
// <context file content> is a JSON string
messageHandler.registerHandler('contextDetail', contextDetail);
// Debug handler
messageHandler.registerHandler('listAllMessages', listAllMessages);
// regeneration
// 应答与sendMessage相同
// Regeneration
// The response is the same as sendMessage
messageHandler.registerHandler('regeneration', regeneration);