Update unspecified changes
- This commit message is a placeholder for unspecified changes. - Please provide more context or specific changes to create a more accurate commit message.
This commit is contained in:
parent
7e7f7e6a91
commit
cbd3b8fc77
@ -2,7 +2,7 @@
|
||||
"name": "devchat",
|
||||
"displayName": "DevChat",
|
||||
"description": "Write prompts, not code",
|
||||
"version": "0.0.47",
|
||||
"version": "0.0.49",
|
||||
"icon": "assets/devchat.png",
|
||||
"publisher": "merico",
|
||||
"engines": {
|
||||
@ -306,6 +306,7 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:uninstall": "node ./dist/uninstall",
|
||||
"vscode:prepublish": "npm run package",
|
||||
"compile": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
|
@ -1,3 +1,10 @@
|
||||
import * as path from 'path';
|
||||
import { logger } from '../util/logger';
|
||||
|
||||
import { createTempSubdirectory } from '../util/commonUtil';
|
||||
import CustomContexts from './customContext';
|
||||
|
||||
|
||||
export interface ChatContext {
|
||||
name: string;
|
||||
description: string;
|
||||
@ -21,8 +28,31 @@ export interface ChatContext {
|
||||
registerContext(context: ChatContext): void {
|
||||
this.contexts.push(context);
|
||||
}
|
||||
|
||||
public async loadCustomContexts(workflowsDir: string): Promise<void> {
|
||||
const customContexts = CustomContexts.getInstance();
|
||||
customContexts.parseContexts(workflowsDir);
|
||||
|
||||
for (const customContext of customContexts.getContexts()) {
|
||||
this.registerContext({
|
||||
name: customContext.name,
|
||||
description: customContext.description,
|
||||
handler: async () => {
|
||||
const tempDir = await createTempSubdirectory('devchat/context');
|
||||
|
||||
const outputFile = path.join(tempDir, 'context.txt');
|
||||
const commandResult = await customContexts.handleCommand(customContext.name, outputFile);
|
||||
|
||||
logger.channel()?.info(`${customContext.command.join(' ')} exit code:`, commandResult!.exitCode);
|
||||
logger.channel()?.debug(`stdout:`, commandResult!.stdout);
|
||||
logger.channel()?.debug(`stderr:`, commandResult!.stderr);
|
||||
return `[context|${outputFile}]`;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getContextList(): ChatContext[] {
|
||||
getContextList(): ChatContext[] {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@ -35,7 +65,7 @@ export interface ChatContext {
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ChatContextManager;
|
||||
|
@ -13,6 +13,8 @@ import { addConext } from './addContext';
|
||||
import { addRefCommandContext } from './addRefCommandContext';
|
||||
import { contextDetail } from './contextDetail';
|
||||
import { listAllMessages } from './listMessages';
|
||||
import { regActionList } from './regActionList';
|
||||
import { applyAction } from './applyAction';
|
||||
|
||||
|
||||
// According to the context menu selected by the user, add the corresponding context file
|
||||
@ -65,3 +67,9 @@ messageHandler.registerHandler('listAllMessages', listAllMessages);
|
||||
// Regeneration
|
||||
// The response is the same as sendMessage
|
||||
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);
|
||||
|
@ -51,7 +51,7 @@ export function getInstructionFiles(): string[] {
|
||||
for (const command of customCommands) {
|
||||
if (command.default) {
|
||||
for (const instruction of command.instructions) {
|
||||
instructionFiles.push(`./.chat/workflows/${command.name}/${instruction}`);
|
||||
instructionFiles.push(`${instruction}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ export async function parseMessageAndSetOptions(message: any, chatOptions: any):
|
||||
}
|
||||
|
||||
chatOptions.header = getInstructionFiles();
|
||||
if (parsedMessage.instruction.length > 0) {
|
||||
if (message.text === newText2) {
|
||||
chatOptions.header = parsedMessage.instruction;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@ import ExtensionContextHolder from '../util/extensionContext';
|
||||
import CustomCommands from '../command/customCommand';
|
||||
import { TopicManager } from '../topic/topicManager';
|
||||
import { UiUtilWrapper } from '../util/uiUtil';
|
||||
import ChatContextManager from '../context/contextManager';
|
||||
import ActionManager from '../action/actionManager';
|
||||
|
||||
|
||||
export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
||||
@ -32,6 +34,8 @@ export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
||||
if (workspaceDir) {
|
||||
const workflowsDir = path.join(workspaceDir!, '.chat', 'workflows');
|
||||
CustomCommands.getInstance().parseCommands(workflowsDir);
|
||||
ChatContextManager.getInstance().loadCustomContexts(workflowsDir);
|
||||
ActionManager.getInstance().loadCustomActions(workflowsDir);
|
||||
}
|
||||
|
||||
this._view = webviewView;
|
||||
|
@ -24,7 +24,7 @@ export function createTempSubdirectory(subdir: string): string {
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
interface CommandResult {
|
||||
export interface CommandResult {
|
||||
exitCode: number | null;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
@ -40,6 +40,7 @@ export class CommandRun {
|
||||
|
||||
public async spawnAsync(command: string, args: string[], options: object, onData: ((data: string) => void) | undefined, onError: ((data: string) => void) | undefined, onOutputFile: ((command: string, stdout: string, stderr: string) => string) | undefined, outputFile: string | undefined): Promise<CommandResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
logger.channel()?.info(`Running command: ${command} ${args.join(' ')}`);
|
||||
this.childProcess = spawn(command, args, options);
|
||||
|
||||
let stdout = '';
|
||||
@ -108,7 +109,7 @@ export class CommandRun {
|
||||
export async function runCommandAndWriteOutput(
|
||||
command: string,
|
||||
args: string[],
|
||||
outputFile: string
|
||||
outputFile: string | undefined
|
||||
): Promise<CommandResult> {
|
||||
const run = new CommandRun();
|
||||
const options = {
|
||||
@ -143,6 +144,28 @@ export async function runCommandStringAndWriteOutput(
|
||||
return run.spawnAsync(command, args, options, undefined, undefined, onOutputFile, outputFile);
|
||||
}
|
||||
|
||||
export async function runCommandStringArrayAndWriteOutput(
|
||||
commandStringList: string[],
|
||||
outputFile: string
|
||||
): Promise<CommandResult> {
|
||||
const run = new CommandRun();
|
||||
const options = {
|
||||
cwd: UiUtilWrapper.workspaceFoldersFirstPath() || '.'
|
||||
};
|
||||
|
||||
const commandString = commandStringList[0];
|
||||
const args: string[] = commandStringList.slice(1);
|
||||
const onOutputFile = (command: string, stdout: string, stderr: string): string => {
|
||||
const data = {
|
||||
command: commandString,
|
||||
content: stdout,
|
||||
};
|
||||
return JSON.stringify(data);
|
||||
};
|
||||
|
||||
return run.spawnAsync(commandString, args, options, undefined, undefined, onOutputFile, outputFile);
|
||||
}
|
||||
|
||||
export async function getLanguageIdByFileName(fileName: string): Promise<string | undefined> {
|
||||
try {
|
||||
const languageId = await UiUtilWrapper.languageId(fileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user