diff --git a/lib/shared/src/chat/prompts/index.ts b/lib/shared/src/chat/prompts/index.ts index cbff69d9369..e997071b3e9 100644 --- a/lib/shared/src/chat/prompts/index.ts +++ b/lib/shared/src/chat/prompts/index.ts @@ -1,5 +1,3 @@ -import { Preamble } from '../preamble' - import * as defaultPrompts from './default-prompts.json' import { toSlashCommand } from './utils' @@ -32,25 +30,12 @@ export interface MyPrompts { commands: Map // backward compatibility recipes?: Map - // Premade is a set of prompts that are added to the start of every new conversation - // --this is where we define the "identity" and "rules" for Cody - premade?: Preamble - // A conversation starter --this is added to the start of every human input sent to Cody. - starter: string } // JSON format of MyPrompts export interface MyPromptsJSON { commands: { [id: string]: Omit } recipes?: { [id: string]: CodyPrompt } - premade?: CodyPremade - starter?: string -} - -export interface CodyPremade { - actions: string - rules: string - answer: string } export interface CodyPrompt { diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index db0fcb0149a..8809b2bfd8a 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -12,6 +12,8 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi ### Changed +- Remove `starter` and `premade` fields from the configuration files for custom commands (cody.json). [pull/939](https://github.com/sourcegraph/cody/pull/939) + ## [0.10.0] ### Added diff --git a/vscode/src/chat/MessageProvider.ts b/vscode/src/chat/MessageProvider.ts index 8de5bfa1ab4..2f2e67767ef 100644 --- a/vscode/src/chat/MessageProvider.ts +++ b/vscode/src/chat/MessageProvider.ts @@ -336,13 +336,8 @@ export abstract class MessageProvider extends MessageHandler implements vscode.D default: { this.sendTranscript() - const myPremade = (await this.editor.controllers.command?.getCustomConfig())?.premade - if (myPremade) { - this.telemetryService.log('CodyVSCodeExtension:command:customPremade:applied') - } - const { prompt, contextFiles, preciseContexts } = await this.transcript.getPromptForLastInteraction( - getPreamble(this.contextProvider.context.getCodebase(), myPremade), + getPreamble(this.contextProvider.context.getCodebase()), this.maxPromptTokens ) this.transcript.setUsedContextFilesForLastInteraction(contextFiles, preciseContexts) @@ -374,13 +369,8 @@ export abstract class MessageProvider extends MessageHandler implements vscode.D } transcript.addInteraction(interaction) - const myPremade = (await this.editor.controllers.command?.getCustomConfig())?.premade - if (myPremade) { - this.telemetryService.log('CodyVSCodeExtension:command:customPremade:applied') - } - const { prompt, contextFiles } = await transcript.getPromptForLastInteraction( - getPreamble(this.contextProvider.context.getCodebase(), myPremade), + getPreamble(this.contextProvider.context.getCodebase()), this.maxPromptTokens ) transcript.setUsedContextFilesForLastInteraction(contextFiles) @@ -476,14 +466,10 @@ export abstract class MessageProvider extends MessageHandler implements vscode.D // Get prompt details from controller by title then execute prompt's command const promptText = this.editor.controllers.command?.find(title) await this.editor.controllers.command?.get('command') - logDebug('executeCustomCommand:starting', title) - if (!promptText) { - return - } - await this.executeRecipe('custom-prompt', promptText) - const starter = (await this.editor.controllers.command?.getCustomConfig())?.starter - if (starter) { - this.telemetryService.log('CodyVSCodeExtension:command:customStarter:applied') + + if (promptText) { + logDebug('executeCustomCommand:starting', title) + await this.executeRecipe('custom-prompt', promptText) } return } diff --git a/vscode/src/custom-prompts/CustomPromptsStore.ts b/vscode/src/custom-prompts/CustomPromptsStore.ts index a9ef0adc9a7..d9210b223e5 100644 --- a/vscode/src/custom-prompts/CustomPromptsStore.ts +++ b/vscode/src/custom-prompts/CustomPromptsStore.ts @@ -1,7 +1,6 @@ import { omit } from 'lodash' import * as vscode from 'vscode' -import { Preamble } from '@sourcegraph/cody-shared/src/chat/preamble' import { CodyPrompt, CodyPromptType, @@ -10,7 +9,6 @@ import { MyPromptsJSON, } from '@sourcegraph/cody-shared/src/chat/prompts' import { fromSlashCommand, toSlashCommand } from '@sourcegraph/cody-shared/src/chat/prompts/utils' -import { newPromptMixin, PromptMixin } from '@sourcegraph/cody-shared/src/prompt/prompt-mixin' import { logDebug, logError } from '../log' @@ -30,9 +28,7 @@ import { promptSizeInit } from './utils/menu' */ export class CustomPromptsStore implements vscode.Disposable { public myPromptsJSON: MyPromptsJSON | null = null - public myPremade: Preamble | undefined = undefined public myPromptsMap = new Map() - public myStarter = '' public promptSize = promptSizeInit public jsonFileUris: { user?: vscode.Uri; workspace?: vscode.Uri } @@ -89,7 +85,7 @@ export class CustomPromptsStore implements vscode.Disposable { } catch (error) { logError('CustomPromptsStore:refresh', 'failed', { verbose: error }) } - return { commands: this.myPromptsMap, premade: this.myPremade, starter: this.myStarter } + return { commands: this.myPromptsMap } } /** @@ -144,19 +140,11 @@ export class CustomPromptsStore implements vscode.Disposable { // read from the updated config file return await this.build(type) } - for (const [key, prompt] of promptEntries) { const current: CodyPrompt = { ...prompt, slashCommand: toSlashCommand(key) } current.type = type this.myPromptsMap.set(current.slashCommand, current) } - - this.myPremade = json.premade - // avoid duplicate starter prompts - if (json.starter && json?.starter !== this.myStarter) { - PromptMixin.addCustom(newPromptMixin(json.starter)) - this.myStarter = json.starter - } if (type === 'user') { this.myPromptsJSON = json } @@ -275,8 +263,6 @@ export class CustomPromptsStore implements vscode.Disposable { this.isActive = false this.myPromptsMap = new Map() this.promptSize = { ...promptSizeInit } - this.myPremade = undefined - this.myStarter = '' this.myPromptsJSON = null }