Merge pull request #9 from covespace/support_commitmsg_block
support commitmsg code block
This commit is contained in:
commit
a4e96e1d57
@ -5,5 +5,6 @@ As a software developer assistant, your task is to provide clear and concise res
|
|||||||
3. Enclose messages in code blocks using triple backticks (```).
|
3. Enclose messages in code blocks using triple backticks (```).
|
||||||
4. Utilize the <context>, if provided, to create the summary.
|
4. Utilize the <context>, if provided, to create the summary.
|
||||||
5. Utilize the previous messages, if provided in the end of this prompt, to create the summary. Note that not all previous messages are necessarily relevant.
|
5. Utilize the previous messages, if provided in the end of this prompt, to create the summary. Note that not all previous messages are necessarily relevant.
|
||||||
|
6. Please output commit message in a markdown code block, flag as commitmsg type.
|
||||||
|
|
||||||
If you need more information, feel free to ask.
|
If you need more information, feel free to ask.
|
@ -7,6 +7,7 @@ import * as fs from 'fs';
|
|||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
import ExtensionContextHolder from './extensionContext';
|
||||||
|
|
||||||
const mkdirAsync = promisify(fs.mkdir);
|
const mkdirAsync = promisify(fs.mkdir);
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
@ -53,6 +54,9 @@ export const commitMessageCommand: Command = {
|
|||||||
const diff_file = path.join(tempDir, 'diff_output.txt');
|
const diff_file = path.join(tempDir, 'diff_output.txt');
|
||||||
await writeDiffFile(diff_file);
|
await writeDiffFile(diff_file);
|
||||||
|
|
||||||
return `[instruction|./commonInstructions.txt] [instruction|./commitMessageCommandInstructions.txt] [context|${diff_file}] Write a commit message`;
|
const commonInstructions = vscode.Uri.joinPath(ExtensionContextHolder.context?.extensionUri as vscode.Uri, 'instructions/commonInstructions.txt');
|
||||||
|
const commitMsgInstructions = vscode.Uri.joinPath(ExtensionContextHolder.context?.extensionUri as vscode.Uri, 'instructions/commitMessageCommandInstructions.txt');
|
||||||
|
|
||||||
|
return `[instruction|${commonInstructions.path}] [instruction|${commitMsgInstructions.path}] [context|${diff_file}] Write a commit message`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
const vscode = require('vscode');
|
import * as vscode from 'vscode';
|
||||||
const ChatPanel = require('./chatPanel').default;
|
const ChatPanel = require('./chatPanel').default;
|
||||||
const sendFileSelectMessage = require('./messageHandler').sendFileSelectMessage;
|
const sendFileSelectMessage = require('./messageHandler').sendFileSelectMessage;
|
||||||
const sendCodeSelectMessage = require('./messageHandler').sendCodeSelectMessage;
|
const sendCodeSelectMessage = require('./messageHandler').sendCodeSelectMessage;
|
||||||
const askAI = require('./messageHandler').askAI;
|
const askAI = require('./messageHandler').askAI;
|
||||||
|
import ExtensionContextHolder from './extensionContext';
|
||||||
|
|
||||||
|
function activate(context: vscode.ExtensionContext) {
|
||||||
function activate(context: { extensionUri: any; subscriptions: any[]; }) {
|
ExtensionContextHolder.context = context;
|
||||||
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
|
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
|
||||||
if (vscode.workspace.workspaceFolders) {
|
if (vscode.workspace.workspaceFolders) {
|
||||||
ChatPanel.createOrShow(context.extensionUri);
|
ChatPanel.createOrShow(context.extensionUri);
|
||||||
|
15
src/extensionContext.ts
Normal file
15
src/extensionContext.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
class ExtensionContextHolder {
|
||||||
|
private static _context: vscode.ExtensionContext | undefined;
|
||||||
|
|
||||||
|
static set context(context: vscode.ExtensionContext | undefined) {
|
||||||
|
this._context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get context(): vscode.ExtensionContext | undefined {
|
||||||
|
return this._context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExtensionContextHolder;
|
@ -97,7 +97,7 @@ async function handleMessage(
|
|||||||
chatOptions.context = parsedMessage.context;
|
chatOptions.context = parsedMessage.context;
|
||||||
}
|
}
|
||||||
if (parsedMessage.instruction.length > 0) {
|
if (parsedMessage.instruction.length > 0) {
|
||||||
chatOptions.instruction = parsedMessage.instruction;
|
chatOptions.header = parsedMessage.instruction;
|
||||||
}
|
}
|
||||||
if (parsedMessage.reference.length > 0) {
|
if (parsedMessage.reference.length > 0) {
|
||||||
chatOptions.reference = parsedMessage.reference;
|
chatOptions.reference = parsedMessage.reference;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user