Refactor to support more sections in the future

This commit is contained in:
Matt Rubens
2025-01-14 07:55:16 -05:00
parent 75e308b033
commit 092a121a37
12 changed files with 116 additions and 95 deletions

View File

@@ -1,4 +1,4 @@
import { architectMode, defaultPrompts } from "../../shared/modes"
import { architectMode, defaultPrompts, PromptComponent } from "../../shared/modes"
import { getToolDescriptionsForMode } from "./tools"
import {
getRulesSection,
@@ -20,8 +20,8 @@ export const ARCHITECT_PROMPT = async (
mcpHub?: McpHub,
diffStrategy?: DiffStrategy,
browserViewportSize?: string,
customPrompt?: string,
) => `${customPrompt || defaultPrompts[architectMode]}
customPrompt?: PromptComponent,
) => `${customPrompt?.roleDefinition || defaultPrompts[architectMode].roleDefinition}
${getSharedToolUseSection()}

View File

@@ -1,4 +1,4 @@
import { Mode, askMode, defaultPrompts } from "../../shared/modes"
import { Mode, askMode, defaultPrompts, PromptComponent } from "../../shared/modes"
import { getToolDescriptionsForMode } from "./tools"
import {
getRulesSection,
@@ -21,8 +21,8 @@ export const ASK_PROMPT = async (
mcpHub?: McpHub,
diffStrategy?: DiffStrategy,
browserViewportSize?: string,
customPrompt?: string,
) => `${customPrompt || defaultPrompts[askMode]}
customPrompt?: PromptComponent,
) => `${customPrompt?.roleDefinition || defaultPrompts[askMode].roleDefinition}
${getSharedToolUseSection()}

View File

@@ -1,4 +1,4 @@
import { Mode, codeMode, defaultPrompts } from "../../shared/modes"
import { Mode, codeMode, defaultPrompts, PromptComponent } from "../../shared/modes"
import { getToolDescriptionsForMode } from "./tools"
import {
getRulesSection,
@@ -21,8 +21,8 @@ export const CODE_PROMPT = async (
mcpHub?: McpHub,
diffStrategy?: DiffStrategy,
browserViewportSize?: string,
customPrompt?: string,
) => `${customPrompt || defaultPrompts[codeMode]}
customPrompt?: PromptComponent,
) => `${customPrompt?.roleDefinition || defaultPrompts[codeMode].roleDefinition}
${getSharedToolUseSection()}

View File

@@ -4,6 +4,7 @@ import { CODE_PROMPT } from "./code"
import { ARCHITECT_PROMPT } from "./architect"
import { ASK_PROMPT } from "./ask"
import { Mode, codeMode, architectMode, askMode } from "./modes"
import { CustomPrompts } from "../../shared/modes"
import fs from 'fs/promises'
import path from 'path'
@@ -64,7 +65,7 @@ export const SYSTEM_PROMPT = async (
diffStrategy?: DiffStrategy,
browserViewportSize?: string,
mode: Mode = codeMode,
customPrompts?: { ask?: string; code?: string; architect?: string; enhance?: string },
customPrompts?: CustomPrompts,
) => {
switch (mode) {
case architectMode: