Merge branch 'main' into new_unified

This commit is contained in:
Daniel
2025-01-15 11:53:27 -05:00
committed by GitHub
116 changed files with 16285 additions and 2361 deletions

View File

@@ -1,9 +1,10 @@
// type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonClicked' or 'settingsButtonClicked' or 'hello'
import { ApiConfiguration, ModelInfo } from "./api"
import { ApiConfiguration, ApiProvider, ModelInfo } from "./api"
import { HistoryItem } from "./HistoryItem"
import { McpServer } from "./mcp"
import { GitCommit } from "../utils/git"
import { Mode, CustomPrompts } from "./modes"
// webview will hold state
export interface ExtensionMessage {
@@ -23,12 +24,16 @@ export interface ExtensionMessage {
| "mcpServers"
| "enhancedPrompt"
| "commitSearchResults"
| "listApiConfig"
| "updatePrompt"
| "systemPrompt"
text?: string
action?:
| "chatButtonClicked"
| "mcpButtonClicked"
| "settingsButtonClicked"
| "historyButtonClicked"
| "promptsButtonClicked"
| "didBecomeVisible"
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
state?: ExtensionState
@@ -42,6 +47,14 @@ export interface ExtensionMessage {
openAiModels?: string[]
mcpServers?: McpServer[]
commits?: GitCommit[]
listApiConfig?: ApiConfigMeta[]
mode?: Mode
}
export interface ApiConfigMeta {
id: string
name: string
apiProvider?: ApiProvider
}
export interface ExtensionState {
@@ -50,7 +63,10 @@ export interface ExtensionState {
taskHistory: HistoryItem[]
shouldShowAnnouncement: boolean
apiConfiguration?: ApiConfiguration
currentApiConfigName?: string
listApiConfigMeta?: ApiConfigMeta[]
customInstructions?: string
customPrompts?: CustomPrompts
alwaysAllowReadOnly?: boolean
alwaysAllowWrite?: boolean
alwaysAllowExecute?: boolean
@@ -70,7 +86,10 @@ export interface ExtensionState {
writeDelayMs: number
terminalOutputLineLimit?: number
mcpEnabled: boolean
experimentalDiffStrategy?: boolean
mode: Mode
modeApiConfigs?: Record<Mode, string>
enhancementApiConfigId?: string
experimentalDiffStrategy?: boolean
}
export interface ClineMessage {

View File

@@ -1,10 +1,19 @@
import { ApiConfiguration, ApiProvider } from "./api"
import { Mode, PromptComponent } from "./modes"
export type PromptMode = Mode | 'enhance'
export type AudioType = "notification" | "celebration" | "progress_loop"
export interface WebviewMessage {
type:
| "apiConfiguration"
| "currentApiConfigName"
| "upsertApiConfiguration"
| "deleteApiConfiguration"
| "loadApiConfiguration"
| "renameApiConfiguration"
| "getListApiConfiguration"
| "customInstructions"
| "allowedCommands"
| "alwaysAllowReadOnly"
@@ -54,7 +63,15 @@ export interface WebviewMessage {
| "searchCommits"
| "alwaysApproveResubmit"
| "requestDelaySeconds"
| "experimentalDiffStrategy"
| "setApiConfigPassword"
| "mode"
| "updatePrompt"
| "updateEnhancedPrompt"
| "getSystemPrompt"
| "systemPrompt"
| "enhancementApiConfigId"
| "experimentalDiffStrategy"
text?: string
disabled?: boolean
askResponse?: ClineAskResponse
@@ -67,6 +84,9 @@ export interface WebviewMessage {
serverName?: string
toolName?: string
alwaysAllow?: boolean
mode?: Mode
promptMode?: PromptMode
customPrompt?: PromptComponent
dataUrls?: string[]
values?: Record<string, any>
query?: string

View File

@@ -51,6 +51,7 @@ export interface ApiHandlerOptions {
export type ApiConfiguration = ApiHandlerOptions & {
apiProvider?: ApiProvider
id?: string // stable unique identifier
}
// Models

View File

@@ -0,0 +1,19 @@
import { ApiConfiguration } from "../shared/api";
export function checkExistKey(config: ApiConfiguration | undefined) {
return config
? [
config.apiKey,
config.glamaApiKey,
config.openRouterApiKey,
config.awsRegion,
config.vertexProjectId,
config.openAiApiKey,
config.ollamaModelId,
config.lmStudioModelId,
config.geminiApiKey,
config.openAiNativeApiKey,
config.deepSeekApiKey
].some((key) => key !== undefined)
: false;
}

30
src/shared/modes.ts Normal file
View File

@@ -0,0 +1,30 @@
export const codeMode = 'code' as const;
export const architectMode = 'architect' as const;
export const askMode = 'ask' as const;
export type Mode = typeof codeMode | typeof architectMode | typeof askMode;
export type PromptComponent = {
roleDefinition?: string;
customInstructions?: string;
}
export type CustomPrompts = {
ask?: PromptComponent;
code?: PromptComponent;
architect?: PromptComponent;
enhance?: string;
}
export const defaultPrompts = {
[askMode]: {
roleDefinition: "You are Cline, a knowledgeable technical assistant focused on answering questions and providing information about software development, technology, and related topics. You can analyze code, explain concepts, and access external resources while maintaining a read-only approach to the codebase. Make sure to answer the user's questions and don't rush to switch to implementing code.",
},
[codeMode]: {
roleDefinition: "You are Cline, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.",
},
[architectMode]: {
roleDefinition: "You are Cline, a software architecture expert specializing in analyzing codebases, identifying patterns, and providing high-level technical guidance. You excel at understanding complex systems, evaluating architectural decisions, and suggesting improvements while maintaining a read-only approach to the codebase. Make sure to help the user come up with a solid implementation plan for their project and don't rush to switch to implementing code.",
},
enhance: "Generate an enhanced version of this prompt (reply with only the enhanced prompt - no conversation, explanations, lead-in, bullet points, placeholders, or surrounding quotes):"
} as const;