99 lines
5.0 KiB
TypeScript
Raw Normal View History

2023-05-08 12:09:52 +08:00
import { messageHandler } from './messageHandler';
import { codeApply } from './codeApply';
import { codeFileApply } from './codeFileApply';
import { convertCommand } from './convertCommand';
import { doCommit } from './doCommit';
import { historyMessages } from './historyMessages';
import { regCommandList, regCommandListByDevChatRun } from './regCommandList';
2023-05-08 12:09:52 +08:00
import { regContextList } from './regContextList';
import { sendMessage, stopDevChat, regeneration, deleteChatMessage, askCode } from './sendMessage';
2023-05-08 12:09:52 +08:00
import { blockApply } from './showDiff';
import { showDiff } from './showDiff';
import { addConext } from './addContext';
2023-05-08 12:48:59 +08:00
import { addRefCommandContext } from './addRefCommandContext';
import { contextDetail } from './contextDetail';
2023-05-10 17:56:56 +08:00
import { listAllMessages } from './listMessages';
import { regActionList } from './regActionList';
import { applyAction } from './applyAction';
import { doCommand } from './doCommand';
import { getSetting, updateSetting } from './updateConfig';
import { featureToggle, featureToggles } from './featureToggle';
import { getUserAccessKey } from './userAccessKey';
2023-09-13 10:08:16 +08:00
import { regModelList } from './regValidModelList';
import { isDevChatInstalled } from './checkDevChatAsk';
2023-05-08 12:09:52 +08:00
2023-05-28 08:18:14 +08:00
// According to the context menu selected by the user, add the corresponding context file
// Response: { command: 'appendContext', context: <context file> }
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('addContext', addConext);
2023-05-28 08:18:14 +08:00
// Apply the code block replied by AI to the currently active view
// Response: none
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('code_apply', codeApply);
2023-05-28 08:18:14 +08:00
// Apply the code block replied by AI to the currently active view, replacing the current file content
// Response: none
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('code_file_apply', codeFileApply);
2023-05-28 08:18:14 +08:00
// Convert the command input into a natural language description sent to AI
// Response: { command: 'convertCommand', result: <natural language description> }
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('convertCommand', convertCommand);
2023-05-28 08:18:14 +08:00
// Perform commit operation
// Response: none
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('doCommit', doCommit);
2023-05-28 08:18:14 +08:00
// 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
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('historyMessages', historyMessages);
2023-05-28 08:18:14 +08:00
// Register the command list
// Response: { command: 'regCommandList', result: <command list> }
messageHandler.registerHandler('regCommandList', regCommandListByDevChatRun);
2023-05-28 08:18:14 +08:00
// Register the context list
// Response: { command: 'regContextList', result: <context list> }
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('regContextList', regContextList);
2023-05-28 08:18:14 +08:00
// 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> }
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('sendMessage', sendMessage);
2023-05-28 08:18:14 +08:00
// Stop devchat, used to stop devchat by the user
// Response: none
messageHandler.registerHandler('stopDevChat', stopDevChat);
2023-05-28 08:18:14 +08:00
// Show diff
// Response: none
2023-05-08 12:09:52 +08:00
messageHandler.registerHandler('block_apply', blockApply);
2023-05-28 08:18:14 +08:00
// Show diff, for historical reasons, the same as above
2023-05-08 12:48:59 +08:00
messageHandler.registerHandler('show_diff', showDiff);
2023-05-28 08:18:14 +08:00
// Process the ref command entered by the user
// Response: { command: 'appendContext', context: <context file> }
2023-05-08 12:48:59 +08:00
messageHandler.registerHandler('addRefCommandContext', addRefCommandContext);
2023-05-28 08:18:14 +08:00
// Get context details
// Response: { command: 'contextDetailResponse', 'file':<context file>, result: <context file content> }
// <context file content> is a JSON string
messageHandler.registerHandler('contextDetail', contextDetail);
2023-05-10 17:56:56 +08:00
// Debug handler
messageHandler.registerHandler('listAllMessages', listAllMessages);
2023-05-28 08:18:14 +08:00
// Regeneration
// The response is the same as sendMessage
2023-05-23 11:16:48 +08:00
messageHandler.registerHandler('regeneration', regeneration);
// Register the action list
// Response: { command: 'regActionList', result: <action list> }
messageHandler.registerHandler('regActionList', regActionList);
// Apply action for code block
// Response: none
messageHandler.registerHandler('applyAction', applyAction);
// Delete chat message
// Response: { command: 'deletedChatMessage', result: <message id> }
messageHandler.registerHandler('deleteChatMessage', deleteChatMessage);
messageHandler.registerHandler('askCode', askCode);
// Execute vscode command
// Response: none
messageHandler.registerHandler('doCommand', doCommand);
messageHandler.registerHandler('updateSetting', updateSetting);
messageHandler.registerHandler('getSetting', getSetting);
messageHandler.registerHandler('featureToggle', featureToggle);
messageHandler.registerHandler('featureToggles', featureToggles);
messageHandler.registerHandler('getUserAccessKey', getUserAccessKey);
2023-09-13 10:08:16 +08:00
messageHandler.registerHandler('regModelList', regModelList);
messageHandler.registerHandler('isDevChatInstalled', isDevChatInstalled);