diff --git a/README.md b/README.md index e0579f2..2f658ae 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ DevChat is the way developers interact and collaborate with AI.     image - 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.     image diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index a24a866..9357d48 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -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); } }); diff --git a/src/handler/loadHandlers.ts b/src/handler/loadHandlers.ts index fb59c5a..c7913f8 100644 --- a/src/handler/loadHandlers.ts +++ b/src/handler/loadHandlers.ts @@ -15,55 +15,53 @@ import { contextDetail } from './contextDetail'; import { listAllMessages } from './listMessages'; -// 根据用户选择的context菜单,添加对应的context文件 -// 应答消息: -// 添加上下文文件信息: { command: 'appendContext', context: } +// According to the context menu selected by the user, add the corresponding context file +// Response: { command: 'appendContext', context: } 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: } 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: } +// 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: } messageHandler.registerHandler('regCommandList', regCommandList); -// 注册context列表 -// 应答消息: { command: 'regContextList', result: } +// Register the context list +// Response: { command: 'regContextList', result: } messageHandler.registerHandler('regContextList', regContextList); -// 发送消息,将用户输入的消息发送给AI -// 应答消息: -// { command: 'receiveMessagePartial', text: <应答消息文本>, user: , date: } -// { command: 'receiveMessage', hash: <消息hash>, text: text: <应答消息文本>, user: , date: } +// Send a message, send the message entered by the user to AI +// Response: +// { command: 'receiveMessagePartial', text: , user: , date: } +// { command: 'receiveMessagePartial', text: , user: , 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: } +// Process the ref command entered by the user +// Response: { command: 'appendContext', context: } messageHandler.registerHandler('addRefCommandContext', addRefCommandContext); -// 获取context详情 -// 应答消息: { command: 'contextDetailResponse', 'file':, result: } -// 是一个JSON字符串 +// Get context details +// Response: { command: 'contextDetailResponse', 'file':, result: } +// 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);