Refine comments
This commit is contained in:
parent
6ccfa14824
commit
fdc65c998c
@ -83,7 +83,7 @@ DevChat is the way developers interact and collaborate with AI.
|
|||||||
<img width="220" alt="image" src="https://github.com/covespace/devchat-vscode/assets/592493/c30f76fe-321a-4145-88fa-a0ef3d36bde5">
|
<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.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
<img width="400" alt="image" src="https://github.com/covespace/devchat-vscode/assets/592493/56f261c0-3aae-4df6-b699-c9e757bd91c1">
|
<img width="400" alt="image" src="https://github.com/covespace/devchat-vscode/assets/592493/56f261c0-3aae-4df6-b699-c9e757bd91c1">
|
||||||
|
@ -10,26 +10,26 @@ import * as process from 'process';
|
|||||||
|
|
||||||
export function checkDevChatDependency(): boolean {
|
export function checkDevChatDependency(): boolean {
|
||||||
try {
|
try {
|
||||||
// 获取pipx环境信息
|
// Get pipx environment
|
||||||
const pipxEnvOutput = childProcess.execSync('python3 -m pipx environment').toString();
|
const pipxEnvOutput = childProcess.execSync('python3 -m pipx environment').toString();
|
||||||
const binPathRegex = /PIPX_BIN_DIR=\s*(.*)/;
|
const binPathRegex = /PIPX_BIN_DIR=\s*(.*)/;
|
||||||
|
|
||||||
// 提取BIN路径
|
// Get BIN path from pipx environment
|
||||||
const match = pipxEnvOutput.match(binPathRegex);
|
const match = pipxEnvOutput.match(binPathRegex);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
const binPath = match[1];
|
const binPath = match[1];
|
||||||
|
|
||||||
// 将BIN路径添加到环境变量中
|
// Add BIN path to PATH
|
||||||
process.env.PATH = `${binPath}:${process.env.PATH}`;
|
process.env.PATH = `${binPath}:${process.env.PATH}`;
|
||||||
|
|
||||||
// 检查devchat是否已经安装
|
// Check if DevChat is installed
|
||||||
childProcess.execSync('devchat --help');
|
childProcess.execSync('devchat --help');
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 命令执行失败,依赖程序未安装或其他异常
|
// DevChat dependency check failed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,12 +55,12 @@ function checkOpenAIKey() {
|
|||||||
openaiApiKey = process.env.OPENAI_API_KEY;
|
openaiApiKey = process.env.OPENAI_API_KEY;
|
||||||
}
|
}
|
||||||
if (!openaiApiKey) {
|
if (!openaiApiKey) {
|
||||||
// openAI key 未设置,请用户输入API Key
|
// OpenAI key not set
|
||||||
vscode.window.showInputBox({
|
vscode.window.showInputBox({
|
||||||
placeHolder: 'Please input your openAI API Key'
|
placeHolder: 'Please input your openAI API Key'
|
||||||
}).then((value) => {
|
}).then((value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
// 设置用户输入的API Key
|
// Set API Key
|
||||||
vscode.workspace.getConfiguration('DevChat').update('OpenAI.apiKey', value, true);
|
vscode.workspace.getConfiguration('DevChat').update('OpenAI.apiKey', value, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -15,55 +15,53 @@ import { contextDetail } from './contextDetail';
|
|||||||
import { listAllMessages } from './listMessages';
|
import { listAllMessages } from './listMessages';
|
||||||
|
|
||||||
|
|
||||||
// 根据用户选择的context菜单,添加对应的context文件
|
// According to the context menu selected by the user, add the corresponding context file
|
||||||
// 应答消息:
|
// Response: { command: 'appendContext', context: <context file> }
|
||||||
// 添加上下文文件信息: { command: 'appendContext', context: <context file> }
|
|
||||||
messageHandler.registerHandler('addContext', addConext);
|
messageHandler.registerHandler('addContext', addConext);
|
||||||
// 将AI应答的代码块应用到当前激活视图中
|
// Apply the code block replied by AI to the currently active view
|
||||||
// 应答消息: 无
|
// Response: none
|
||||||
messageHandler.registerHandler('code_apply', codeApply);
|
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);
|
messageHandler.registerHandler('code_file_apply', codeFileApply);
|
||||||
// 将command输入,转换为发送给AI的自然语言描述
|
// Convert the command input into a natural language description sent to AI
|
||||||
// 应答消息: { command: 'convertCommand', result: <自然语言描述> }
|
// Response: { command: 'convertCommand', result: <natural language description> }
|
||||||
messageHandler.registerHandler('convertCommand', convertCommand);
|
messageHandler.registerHandler('convertCommand', convertCommand);
|
||||||
// 执行提交操作
|
// Perform commit operation
|
||||||
// 应答消息: 无
|
// Response: none
|
||||||
messageHandler.registerHandler('doCommit', doCommit);
|
messageHandler.registerHandler('doCommit', doCommit);
|
||||||
// 获取历史消息,用户视图显示时调用
|
// Get the history messages, called when the user view is displayed
|
||||||
// 应答消息: { command: 'historyMessages', result: <历史消息> }
|
// 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);
|
messageHandler.registerHandler('historyMessages', historyMessages);
|
||||||
// 注册命令列表
|
// Register the command list
|
||||||
// 应答消息: { command: 'regCommandList', result: <命令列表> }
|
// Response: { command: 'regCommandList', result: <command list> }
|
||||||
messageHandler.registerHandler('regCommandList', regCommandList);
|
messageHandler.registerHandler('regCommandList', regCommandList);
|
||||||
// 注册context列表
|
// Register the context list
|
||||||
// 应答消息: { command: 'regContextList', result: <context列表> }
|
// Response: { command: 'regContextList', result: <context list> }
|
||||||
messageHandler.registerHandler('regContextList', regContextList);
|
messageHandler.registerHandler('regContextList', regContextList);
|
||||||
// 发送消息,将用户输入的消息发送给AI
|
// Send a message, send the message entered by the user to AI
|
||||||
// 应答消息:
|
// Response:
|
||||||
// { command: 'receiveMessagePartial', text: <应答消息文本>, user: <user>, date: <date> }
|
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
|
||||||
// { command: 'receiveMessage', hash: <消息hash>, text: text: <应答消息文本>, user: <user>, date: <date> }
|
// { command: 'receiveMessagePartial', text: <response message text>, user: <user>, date: <date> }
|
||||||
messageHandler.registerHandler('sendMessage', sendMessage);
|
messageHandler.registerHandler('sendMessage', sendMessage);
|
||||||
// 停止devchat,用于用户主动停止devchat
|
// Stop devchat, used to stop devchat by the user
|
||||||
// 应答消息: 无
|
// Response: none
|
||||||
messageHandler.registerHandler('stopDevChat', stopDevChat);
|
messageHandler.registerHandler('stopDevChat', stopDevChat);
|
||||||
// 显示diff
|
// Show diff
|
||||||
// 应答消息: 无
|
// Response: none
|
||||||
messageHandler.registerHandler('block_apply', blockApply);
|
messageHandler.registerHandler('block_apply', blockApply);
|
||||||
// 显示diff,由于历史原因,同上
|
// Show diff, for historical reasons, the same as above
|
||||||
// 应答消息: 无
|
|
||||||
messageHandler.registerHandler('show_diff', showDiff);
|
messageHandler.registerHandler('show_diff', showDiff);
|
||||||
// 处理用户输入的ref命令
|
// Process the ref command entered by the user
|
||||||
// 应答消息: { command: 'appendContext', context: <context file> }
|
// Response: { command: 'appendContext', context: <context file> }
|
||||||
messageHandler.registerHandler('addRefCommandContext', addRefCommandContext);
|
messageHandler.registerHandler('addRefCommandContext', addRefCommandContext);
|
||||||
// 获取context详情
|
// Get context details
|
||||||
// 应答消息: { command: 'contextDetailResponse', 'file':<context file>, result: <context file content> }
|
// Response: { command: 'contextDetailResponse', 'file':<context file>, result: <context file content> }
|
||||||
// <context file content>是一个JSON字符串
|
// <context file content> is a JSON string
|
||||||
messageHandler.registerHandler('contextDetail', contextDetail);
|
messageHandler.registerHandler('contextDetail', contextDetail);
|
||||||
// Debug handler
|
// Debug handler
|
||||||
messageHandler.registerHandler('listAllMessages', listAllMessages);
|
messageHandler.registerHandler('listAllMessages', listAllMessages);
|
||||||
// regeneration
|
// Regeneration
|
||||||
// 应答与sendMessage相同
|
// The response is the same as sendMessage
|
||||||
messageHandler.registerHandler('regeneration', regeneration);
|
messageHandler.registerHandler('regeneration', regeneration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user