Merge pull request #465 from devchat-ai/feat/fix-workflow

Update Devchat commands and titles
This commit is contained in:
小石头 2024-03-12 21:23:06 +08:00 committed by GitHub
commit c9146b9fd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 72 additions and 35 deletions

View File

@ -659,27 +659,27 @@
},
{
"command": "devchat.addContext",
"title": "Add to DevChat"
"title": "Devchat:Add to DevChat"
},
{
"command": "devchat.askForCode",
"title": "Add to DevChat"
"title": "Devchat:Add to DevChat"
},
{
"command": "devchat.askForFile",
"title": "Add to DevChat"
"title": "Devchat:Add to DevChat"
},
{
"command": "devchat.addConext_chinese",
"title": "添加到DevChat"
"title": "Devchat:添加到DevChat"
},
{
"command": "devchat.askForCode_chinese",
"title": "添加到DevChat"
"title": "Devchat:添加到DevChat"
},
{
"command": "devchat.askForFile_chinese",
"title": "添加到DevChat"
"title": "Devchat:添加到DevChat"
},
{
"command": "DevChat.InstallCommands",
@ -703,19 +703,27 @@
},
{
"command": "devchat.explain",
"title": "Generate Explain"
"title": "Devchat:Generate Explain"
},
{
"command": "devchat.explain_chinese",
"title": "代码解释"
"title": "Devchat:代码解释"
},
{
"command": "devchat.comments",
"title": "Generate Comments"
"title": "Devchat:Generate Comments"
},
{
"command": "devchat.comments_chinese",
"title": "生成注释"
"title": "Devchat:生成注释"
},
{
"command": "devchat.fix",
"title": "Devchat:Fix this"
},
{
"command": "devchat.fix_chinese",
"title": "Devchat:修复此"
}
],
"keybindings": [
@ -819,6 +827,16 @@
"command": "devchat.comments_chinese",
"when": "isChineseLocale && editorTextFocus && editorHasSelection",
"group": "navigation"
},
{
"command": "devchat.fix",
"when": "!isChineseLocale && editorTextFocus && editorHasSelection",
"group": "navigation"
},
{
"command": "devchat.fix_chinese",
"when": "isChineseLocale && editorTextFocus && editorHasSelection",
"group": "navigation"
}
]
}

View File

@ -470,7 +470,7 @@ export function registerCodeLensRangeCommand(context: vscode.ExtensionContext) {
if (editor) {
const range = new vscode.Range(
new vscode.Position(pos.start, 0),
new vscode.Position(pos.end+1, 0)
new vscode.Position(pos.end + 1, 0)
);
editor.selection = new vscode.Selection(range.start, range.end);
}
@ -567,11 +567,31 @@ function registerCommentCommand(context: vscode.ExtensionContext) {
);
}
function registerFixCommand(context: vscode.ExtensionContext) {
const callback = async () => {
const editor = vscode.window.activeTextEditor;
if (editor) {
if (!(await ensureChatPanel(context))) {
return;
}
chatWithDevChat(ExtensionContextHolder.provider?.view()!, "/fix");
}
};
context.subscriptions.push(
vscode.commands.registerCommand("devchat.fix", callback)
);
context.subscriptions.push(
vscode.commands.registerCommand("devchat.fix_chinese", callback)
);
}
export {
registerOpenChatPanelCommand,
registerAddContextCommand,
registerAskForCodeCommand,
registerAskForFileCommand,
registerExplainCommand,
registerFixCommand,
registerCommentCommand,
};

View File

@ -17,6 +17,7 @@ import {
registerExplainCommand,
registerCodeLensRangeCommand,
registerCommentCommand,
registerFixCommand,
} from "./contributes/commands";
import { regLanguageContext } from "./contributes/context";
import { regDevChatView } from "./contributes/views";
@ -371,9 +372,9 @@ async function configSetModelDefaultParams() {
"Model.claude-3-opus": {
max_input_tokens: 32000,
},
"Model.claude-3-sonnet": {
max_input_tokens: 32000,
},
"Model.claude-3-sonnet": {
max_input_tokens: 32000,
},
"Model.xinghuo-2": {
max_input_tokens: 6000,
},
@ -414,26 +415,23 @@ async function configSetModelDefaultParams() {
}
async function updateClaudePrivider() {
const claudeModels = [
"Model.claude-3-opus",
"Model.claude-3-sonnet",
];
const claudeModels = ["Model.claude-3-opus", "Model.claude-3-sonnet"];
for (const model of claudeModels) {
const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model);
if (modelConfig && Object.keys(modelConfig).length === 0) {
const modelProperties: any = {
"provider": "devchat"
};
try {
await vscode.workspace
.getConfiguration("devchat")
.update(model, modelProperties, vscode.ConfigurationTarget.Global);
} catch (error) {
logger.channel()?.error(`update ${model} error: ${error}`);
}
}
}
for (const model of claudeModels) {
const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model);
if (modelConfig && Object.keys(modelConfig).length === 0) {
const modelProperties: any = {
provider: "devchat",
};
try {
await vscode.workspace
.getConfiguration("devchat")
.update(model, modelProperties, vscode.ConfigurationTarget.Global);
} catch (error) {
logger.channel()?.error(`update ${model} error: ${error}`);
}
}
}
}
async function activate(context: vscode.ExtensionContext) {
@ -462,6 +460,7 @@ async function activate(context: vscode.ExtensionContext) {
registerAskForCodeCommand(context);
registerAskForFileCommand(context);
registerExplainCommand(context);
registerFixCommand(context);
registerCommentCommand(context);
registerStatusBarItemClickCommand(context);

View File

@ -54,7 +54,7 @@ export class CodeLensManager {
this.registrations = [
{
elementType: "function",
objectName: "unit tests",
objectName: "Devchat:unit tests",
promptGenerator:
"/unit_tests {__filename__}:::{__functionName__}:::{__functionStartLine__}:::{__functionEndLine__}:::{__containerStartLine__}:::{__containerEndLine__}",
},

@ -1 +1 @@
Subproject commit dbdb1ba29db3536e4ae358113f4251b78845c879
Subproject commit 874da1710f1c0e24b6c3078352919ef29b312638