mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Merge branch 'main' into aws-profile-support
This commit is contained in:
18
.vscode/launch.json
vendored
18
.vscode/launch.json
vendored
@@ -9,9 +9,21 @@
|
|||||||
"name": "Run Extension",
|
"name": "Run Extension",
|
||||||
"type": "extensionHost",
|
"type": "extensionHost",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
|
"runtimeExecutable": "${execPath}",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||||
|
],
|
||||||
|
"sourceMaps": true,
|
||||||
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
||||||
"preLaunchTask": "${defaultBuildTask}"
|
"preLaunchTask": "compile",
|
||||||
}
|
"env": {
|
||||||
|
"NODE_ENV": "development",
|
||||||
|
"VSCODE_DEBUG_MODE": "true"
|
||||||
|
},
|
||||||
|
"resolveSourceMapLocations": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"!**/node_modules/**"
|
||||||
|
]
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
17
.vscode/tasks.json
vendored
17
.vscode/tasks.json
vendored
@@ -3,6 +3,21 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "compile",
|
||||||
|
"type": "npm",
|
||||||
|
"script": "compile",
|
||||||
|
"dependsOn": ["npm: build:webview"],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "silent",
|
||||||
|
"panel": "shared"
|
||||||
|
},
|
||||||
|
"problemMatcher": ["$tsc", "$eslint-stylish"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "watch",
|
"label": "watch",
|
||||||
"dependsOn": ["npm: build:webview", "npm: watch:tsc", "npm: watch:esbuild"],
|
"dependsOn": ["npm: build:webview", "npm: watch:tsc", "npm: watch:esbuild"],
|
||||||
@@ -11,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# Roo Cline Changelog
|
# Roo Cline Changelog
|
||||||
|
|
||||||
|
## [3.1.7]
|
||||||
|
|
||||||
|
- DeepSeek-R1 support (thanks @philipnext!)
|
||||||
|
- Experimental new unified diff algorithm can be enabled in settings (thanks @daniel-lxs!)
|
||||||
|
- More fixes to configuration profiles (thanks @samhvw8!)
|
||||||
|
|
||||||
## [3.1.6]
|
## [3.1.6]
|
||||||
|
|
||||||
- Add Mistral (thanks Cline!)
|
- Add Mistral (thanks Cline!)
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "roo-cline",
|
"name": "roo-cline",
|
||||||
"version": "3.1.6",
|
"version": "3.1.7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "roo-cline",
|
"name": "roo-cline",
|
||||||
"version": "3.1.6",
|
"version": "3.1.7",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/bedrock-sdk": "^0.10.2",
|
"@anthropic-ai/bedrock-sdk": "^0.10.2",
|
||||||
"@anthropic-ai/sdk": "^0.26.0",
|
"@anthropic-ai/sdk": "^0.26.0",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"displayName": "Roo Cline",
|
"displayName": "Roo Cline",
|
||||||
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
|
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
|
||||||
"publisher": "RooVeterinaryInc",
|
"publisher": "RooVeterinaryInc",
|
||||||
"version": "3.1.6",
|
"version": "3.1.7",
|
||||||
"icon": "assets/icons/rocket.png",
|
"icon": "assets/icons/rocket.png",
|
||||||
"galleryBanner": {
|
"galleryBanner": {
|
||||||
"color": "#617A91",
|
"color": "#617A91",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockOptions = {
|
mockOptions = {
|
||||||
deepSeekApiKey: "test-api-key",
|
deepSeekApiKey: "test-api-key",
|
||||||
deepSeekModelId: "deepseek-chat",
|
apiModelId: "deepseek-chat",
|
||||||
deepSeekBaseUrl: "https://api.deepseek.com/v1",
|
deepSeekBaseUrl: "https://api.deepseek.com/v1",
|
||||||
}
|
}
|
||||||
handler = new DeepSeekHandler(mockOptions)
|
handler = new DeepSeekHandler(mockOptions)
|
||||||
@@ -81,7 +81,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
describe("constructor", () => {
|
describe("constructor", () => {
|
||||||
it("should initialize with provided options", () => {
|
it("should initialize with provided options", () => {
|
||||||
expect(handler).toBeInstanceOf(DeepSeekHandler)
|
expect(handler).toBeInstanceOf(DeepSeekHandler)
|
||||||
expect(handler.getModel().id).toBe(mockOptions.deepSeekModelId)
|
expect(handler.getModel().id).toBe(mockOptions.apiModelId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw error if API key is missing", () => {
|
it("should throw error if API key is missing", () => {
|
||||||
@@ -96,7 +96,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
it("should use default model ID if not provided", () => {
|
it("should use default model ID if not provided", () => {
|
||||||
const handlerWithoutModel = new DeepSeekHandler({
|
const handlerWithoutModel = new DeepSeekHandler({
|
||||||
...mockOptions,
|
...mockOptions,
|
||||||
deepSeekModelId: undefined,
|
apiModelId: undefined,
|
||||||
})
|
})
|
||||||
expect(handlerWithoutModel.getModel().id).toBe(deepSeekDefaultModelId)
|
expect(handlerWithoutModel.getModel().id).toBe(deepSeekDefaultModelId)
|
||||||
})
|
})
|
||||||
@@ -144,7 +144,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
describe("getModel", () => {
|
describe("getModel", () => {
|
||||||
it("should return model info for valid model ID", () => {
|
it("should return model info for valid model ID", () => {
|
||||||
const model = handler.getModel()
|
const model = handler.getModel()
|
||||||
expect(model.id).toBe(mockOptions.deepSeekModelId)
|
expect(model.id).toBe(mockOptions.apiModelId)
|
||||||
expect(model.info).toBeDefined()
|
expect(model.info).toBeDefined()
|
||||||
expect(model.info.maxTokens).toBe(8192)
|
expect(model.info.maxTokens).toBe(8192)
|
||||||
expect(model.info.contextWindow).toBe(64_000)
|
expect(model.info.contextWindow).toBe(64_000)
|
||||||
@@ -155,7 +155,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
it("should return provided model ID with default model info if model does not exist", () => {
|
it("should return provided model ID with default model info if model does not exist", () => {
|
||||||
const handlerWithInvalidModel = new DeepSeekHandler({
|
const handlerWithInvalidModel = new DeepSeekHandler({
|
||||||
...mockOptions,
|
...mockOptions,
|
||||||
deepSeekModelId: "invalid-model",
|
apiModelId: "invalid-model",
|
||||||
})
|
})
|
||||||
const model = handlerWithInvalidModel.getModel()
|
const model = handlerWithInvalidModel.getModel()
|
||||||
expect(model.id).toBe("invalid-model") // Returns provided ID
|
expect(model.id).toBe("invalid-model") // Returns provided ID
|
||||||
@@ -166,7 +166,7 @@ describe("DeepSeekHandler", () => {
|
|||||||
it("should return default model if no model ID is provided", () => {
|
it("should return default model if no model ID is provided", () => {
|
||||||
const handlerWithoutModel = new DeepSeekHandler({
|
const handlerWithoutModel = new DeepSeekHandler({
|
||||||
...mockOptions,
|
...mockOptions,
|
||||||
deepSeekModelId: undefined,
|
apiModelId: undefined,
|
||||||
})
|
})
|
||||||
const model = handlerWithoutModel.getModel()
|
const model = handlerWithoutModel.getModel()
|
||||||
expect(model.id).toBe(deepSeekDefaultModelId)
|
expect(model.id).toBe(deepSeekDefaultModelId)
|
||||||
|
|||||||
@@ -193,7 +193,6 @@ describe("OpenAiHandler", () => {
|
|||||||
expect(mockCreate).toHaveBeenCalledWith({
|
expect(mockCreate).toHaveBeenCalledWith({
|
||||||
model: mockOptions.openAiModelId,
|
model: mockOptions.openAiModelId,
|
||||||
messages: [{ role: "user", content: "Test prompt" }],
|
messages: [{ role: "user", content: "Test prompt" }],
|
||||||
temperature: 0,
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ export class DeepSeekHandler extends OpenAiHandler {
|
|||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
openAiApiKey: options.deepSeekApiKey,
|
openAiApiKey: options.deepSeekApiKey,
|
||||||
openAiModelId: options.deepSeekModelId ?? deepSeekDefaultModelId,
|
openAiModelId: options.apiModelId ?? deepSeekDefaultModelId,
|
||||||
openAiBaseUrl: options.deepSeekBaseUrl ?? "https://api.deepseek.com/v1",
|
openAiBaseUrl: options.deepSeekBaseUrl ?? "https://api.deepseek.com/v1",
|
||||||
|
openAiStreamingEnabled: true,
|
||||||
includeMaxTokens: true,
|
includeMaxTokens: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override getModel(): { id: string; info: ModelInfo } {
|
override getModel(): { id: string; info: ModelInfo } {
|
||||||
const modelId = this.options.deepSeekModelId ?? deepSeekDefaultModelId
|
const modelId = this.options.apiModelId ?? deepSeekDefaultModelId
|
||||||
return {
|
return {
|
||||||
id: modelId,
|
id: modelId,
|
||||||
info: deepSeekModels[modelId as keyof typeof deepSeekModels] || deepSeekModels[deepSeekDefaultModelId],
|
info: deepSeekModels[modelId as keyof typeof deepSeekModels] || deepSeekModels[deepSeekDefaultModelId],
|
||||||
|
|||||||
@@ -101,6 +101,14 @@ export class GlamaHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.options.glamaApiKey}`,
|
Authorization: `Bearer ${this.options.glamaApiKey}`,
|
||||||
|
"X-Glama-Metadata": JSON.stringify({
|
||||||
|
labels: [
|
||||||
|
{
|
||||||
|
key: "app",
|
||||||
|
value: "vscode.rooveterinaryinc.roo-cline",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
const modelInfo = this.getModel().info
|
const modelInfo = this.getModel().info
|
||||||
const modelId = this.options.openAiModelId ?? ""
|
const modelId = this.options.openAiModelId ?? ""
|
||||||
|
|
||||||
if (this.options.openAiStreamingEnabled ?? true) {
|
const deepseekReasoner = modelId.includes("deepseek-reasoner")
|
||||||
|
|
||||||
|
if (!deepseekReasoner && (this.options.openAiStreamingEnabled ?? true)) {
|
||||||
const systemMessage: OpenAI.Chat.ChatCompletionSystemMessageParam = {
|
const systemMessage: OpenAI.Chat.ChatCompletionSystemMessageParam = {
|
||||||
role: "system",
|
role: "system",
|
||||||
content: systemPrompt,
|
content: systemPrompt,
|
||||||
@@ -71,11 +73,20 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let systemMessage: OpenAI.Chat.ChatCompletionUserMessageParam | OpenAI.Chat.ChatCompletionSystemMessageParam
|
||||||
|
|
||||||
// o1 for instance doesnt support streaming, non-1 temp, or system prompt
|
// o1 for instance doesnt support streaming, non-1 temp, or system prompt
|
||||||
const systemMessage: OpenAI.Chat.ChatCompletionUserMessageParam = {
|
// deepseek reasoner supports system prompt
|
||||||
|
systemMessage = deepseekReasoner
|
||||||
|
? {
|
||||||
|
role: "system",
|
||||||
|
content: systemPrompt,
|
||||||
|
}
|
||||||
|
: {
|
||||||
role: "user",
|
role: "user",
|
||||||
content: systemPrompt,
|
content: systemPrompt,
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = {
|
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = {
|
||||||
model: modelId,
|
model: modelId,
|
||||||
messages: [systemMessage, ...convertToOpenAiMessages(messages)],
|
messages: [systemMessage, ...convertToOpenAiMessages(messages)],
|
||||||
@@ -106,7 +117,6 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = {
|
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = {
|
||||||
model: this.getModel().id,
|
model: this.getModel().id,
|
||||||
messages: [{ role: "user", content: prompt }],
|
messages: [{ role: "user", content: prompt }],
|
||||||
temperature: 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.client.chat.completions.create(requestOptions)
|
const response = await this.client.chat.completions.create(requestOptions)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* List all available configs with metadata
|
* List all available configs with metadata
|
||||||
*/
|
*/
|
||||||
async ListConfig(): Promise<ApiConfigMeta[]> {
|
async listConfig(): Promise<ApiConfigMeta[]> {
|
||||||
try {
|
try {
|
||||||
const config = await this.readConfig()
|
const config = await this.readConfig()
|
||||||
return Object.entries(config.apiConfigs).map(([name, apiConfig]) => ({
|
return Object.entries(config.apiConfigs).map(([name, apiConfig]) => ({
|
||||||
@@ -80,7 +80,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Save a config with the given name
|
* Save a config with the given name
|
||||||
*/
|
*/
|
||||||
async SaveConfig(name: string, config: ApiConfiguration): Promise<void> {
|
async saveConfig(name: string, config: ApiConfiguration): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const currentConfig = await this.readConfig()
|
const currentConfig = await this.readConfig()
|
||||||
const existingConfig = currentConfig.apiConfigs[name]
|
const existingConfig = currentConfig.apiConfigs[name]
|
||||||
@@ -97,7 +97,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Load a config by name
|
* Load a config by name
|
||||||
*/
|
*/
|
||||||
async LoadConfig(name: string): Promise<ApiConfiguration> {
|
async loadConfig(name: string): Promise<ApiConfiguration> {
|
||||||
try {
|
try {
|
||||||
const config = await this.readConfig()
|
const config = await this.readConfig()
|
||||||
const apiConfig = config.apiConfigs[name]
|
const apiConfig = config.apiConfigs[name]
|
||||||
@@ -118,7 +118,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Delete a config by name
|
* Delete a config by name
|
||||||
*/
|
*/
|
||||||
async DeleteConfig(name: string): Promise<void> {
|
async deleteConfig(name: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const currentConfig = await this.readConfig()
|
const currentConfig = await this.readConfig()
|
||||||
if (!currentConfig.apiConfigs[name]) {
|
if (!currentConfig.apiConfigs[name]) {
|
||||||
@@ -140,7 +140,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Set the current active API configuration
|
* Set the current active API configuration
|
||||||
*/
|
*/
|
||||||
async SetCurrentConfig(name: string): Promise<void> {
|
async setCurrentConfig(name: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const currentConfig = await this.readConfig()
|
const currentConfig = await this.readConfig()
|
||||||
if (!currentConfig.apiConfigs[name]) {
|
if (!currentConfig.apiConfigs[name]) {
|
||||||
@@ -157,7 +157,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Check if a config exists by name
|
* Check if a config exists by name
|
||||||
*/
|
*/
|
||||||
async HasConfig(name: string): Promise<boolean> {
|
async hasConfig(name: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const config = await this.readConfig()
|
const config = await this.readConfig()
|
||||||
return name in config.apiConfigs
|
return name in config.apiConfigs
|
||||||
@@ -169,7 +169,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Set the API config for a specific mode
|
* Set the API config for a specific mode
|
||||||
*/
|
*/
|
||||||
async SetModeConfig(mode: Mode, configId: string): Promise<void> {
|
async setModeConfig(mode: Mode, configId: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const currentConfig = await this.readConfig()
|
const currentConfig = await this.readConfig()
|
||||||
if (!currentConfig.modeApiConfigs) {
|
if (!currentConfig.modeApiConfigs) {
|
||||||
@@ -185,7 +185,7 @@ export class ConfigManager {
|
|||||||
/**
|
/**
|
||||||
* Get the API config ID for a specific mode
|
* Get the API config ID for a specific mode
|
||||||
*/
|
*/
|
||||||
async GetModeConfigId(mode: Mode): Promise<string | undefined> {
|
async getModeConfigId(mode: Mode): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
const config = await this.readConfig()
|
const config = await this.readConfig()
|
||||||
return config.modeApiConfigs?.[mode]
|
return config.modeApiConfigs?.[mode]
|
||||||
@@ -194,10 +194,23 @@ export class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the key used for storing config in secrets
|
||||||
|
*/
|
||||||
|
private getConfigKey(): string {
|
||||||
|
return `${this.SCOPE_PREFIX}api_config`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all configuration by deleting the stored config from secrets
|
||||||
|
*/
|
||||||
|
public async resetAllConfigs(): Promise<void> {
|
||||||
|
await this.context.secrets.delete(this.getConfigKey())
|
||||||
|
}
|
||||||
|
|
||||||
private async readConfig(): Promise<ApiConfigData> {
|
private async readConfig(): Promise<ApiConfigData> {
|
||||||
try {
|
try {
|
||||||
const configKey = `${this.SCOPE_PREFIX}api_config`
|
const content = await this.context.secrets.get(this.getConfigKey())
|
||||||
const content = await this.context.secrets.get(configKey)
|
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return this.defaultConfig
|
return this.defaultConfig
|
||||||
@@ -211,9 +224,8 @@ export class ConfigManager {
|
|||||||
|
|
||||||
private async writeConfig(config: ApiConfigData): Promise<void> {
|
private async writeConfig(config: ApiConfigData): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const configKey = `${this.SCOPE_PREFIX}api_config`
|
|
||||||
const content = JSON.stringify(config, null, 2)
|
const content = JSON.stringify(config, null, 2)
|
||||||
await this.context.secrets.store(configKey, content)
|
await this.context.secrets.store(this.getConfigKey(), content)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to write config to secrets: ${error}`)
|
throw new Error(`Failed to write config to secrets: ${error}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
||||||
|
|
||||||
const configs = await configManager.ListConfig()
|
const configs = await configManager.listConfig()
|
||||||
expect(configs).toEqual([
|
expect(configs).toEqual([
|
||||||
{ name: "default", id: "default", apiProvider: undefined },
|
{ name: "default", id: "default", apiProvider: undefined },
|
||||||
{ name: "test", id: "test-id", apiProvider: "anthropic" },
|
{ name: "test", id: "test-id", apiProvider: "anthropic" },
|
||||||
@@ -126,14 +126,14 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(emptyConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(emptyConfig))
|
||||||
|
|
||||||
const configs = await configManager.ListConfig()
|
const configs = await configManager.listConfig()
|
||||||
expect(configs).toEqual([])
|
expect(configs).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw error if reading from secrets fails", async () => {
|
it("should throw error if reading from secrets fails", async () => {
|
||||||
mockSecrets.get.mockRejectedValue(new Error("Read failed"))
|
mockSecrets.get.mockRejectedValue(new Error("Read failed"))
|
||||||
|
|
||||||
await expect(configManager.ListConfig()).rejects.toThrow(
|
await expect(configManager.listConfig()).rejects.toThrow(
|
||||||
"Failed to list configs: Error: Failed to read config from secrets: Error: Read failed",
|
"Failed to list configs: Error: Failed to read config from secrets: Error: Read failed",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -160,7 +160,7 @@ describe("ConfigManager", () => {
|
|||||||
apiKey: "test-key",
|
apiKey: "test-key",
|
||||||
}
|
}
|
||||||
|
|
||||||
await configManager.SaveConfig("test", newConfig)
|
await configManager.saveConfig("test", newConfig)
|
||||||
|
|
||||||
// Get the actual stored config to check the generated ID
|
// Get the actual stored config to check the generated ID
|
||||||
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
||||||
@@ -207,7 +207,7 @@ describe("ConfigManager", () => {
|
|||||||
apiKey: "new-key",
|
apiKey: "new-key",
|
||||||
}
|
}
|
||||||
|
|
||||||
await configManager.SaveConfig("test", updatedConfig)
|
await configManager.saveConfig("test", updatedConfig)
|
||||||
|
|
||||||
const expectedConfig = {
|
const expectedConfig = {
|
||||||
currentApiConfigName: "default",
|
currentApiConfigName: "default",
|
||||||
@@ -235,7 +235,7 @@ describe("ConfigManager", () => {
|
|||||||
)
|
)
|
||||||
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
||||||
|
|
||||||
await expect(configManager.SaveConfig("test", {})).rejects.toThrow(
|
await expect(configManager.saveConfig("test", {})).rejects.toThrow(
|
||||||
"Failed to save config: Error: Failed to write config to secrets: Error: Storage failed",
|
"Failed to save config: Error: Failed to write config to secrets: Error: Storage failed",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -258,7 +258,7 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
||||||
|
|
||||||
await configManager.DeleteConfig("test")
|
await configManager.deleteConfig("test")
|
||||||
|
|
||||||
// Get the stored config to check the ID
|
// Get the stored config to check the ID
|
||||||
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
||||||
@@ -275,7 +275,7 @@ describe("ConfigManager", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
await expect(configManager.DeleteConfig("nonexistent")).rejects.toThrow("Config 'nonexistent' not found")
|
await expect(configManager.deleteConfig("nonexistent")).rejects.toThrow("Config 'nonexistent' not found")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw error when trying to delete last remaining config", async () => {
|
it("should throw error when trying to delete last remaining config", async () => {
|
||||||
@@ -290,7 +290,7 @@ describe("ConfigManager", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
await expect(configManager.DeleteConfig("default")).rejects.toThrow(
|
await expect(configManager.deleteConfig("default")).rejects.toThrow(
|
||||||
"Cannot delete the last remaining configuration.",
|
"Cannot delete the last remaining configuration.",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -311,7 +311,7 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
||||||
|
|
||||||
const config = await configManager.LoadConfig("test")
|
const config = await configManager.loadConfig("test")
|
||||||
|
|
||||||
expect(config).toEqual({
|
expect(config).toEqual({
|
||||||
apiProvider: "anthropic",
|
apiProvider: "anthropic",
|
||||||
@@ -342,7 +342,7 @@ describe("ConfigManager", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
await expect(configManager.LoadConfig("nonexistent")).rejects.toThrow("Config 'nonexistent' not found")
|
await expect(configManager.loadConfig("nonexistent")).rejects.toThrow("Config 'nonexistent' not found")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw error if secrets storage fails", async () => {
|
it("should throw error if secrets storage fails", async () => {
|
||||||
@@ -361,7 +361,7 @@ describe("ConfigManager", () => {
|
|||||||
)
|
)
|
||||||
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
||||||
|
|
||||||
await expect(configManager.LoadConfig("test")).rejects.toThrow(
|
await expect(configManager.loadConfig("test")).rejects.toThrow(
|
||||||
"Failed to load config: Error: Failed to write config to secrets: Error: Storage failed",
|
"Failed to load config: Error: Failed to write config to secrets: Error: Storage failed",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -384,7 +384,7 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
||||||
|
|
||||||
await configManager.SetCurrentConfig("test")
|
await configManager.setCurrentConfig("test")
|
||||||
|
|
||||||
// Get the stored config to check the structure
|
// Get the stored config to check the structure
|
||||||
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
const storedConfig = JSON.parse(mockSecrets.store.mock.calls[0][1])
|
||||||
@@ -404,7 +404,7 @@ describe("ConfigManager", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
await expect(configManager.SetCurrentConfig("nonexistent")).rejects.toThrow(
|
await expect(configManager.setCurrentConfig("nonexistent")).rejects.toThrow(
|
||||||
"Config 'nonexistent' not found",
|
"Config 'nonexistent' not found",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -420,12 +420,34 @@ describe("ConfigManager", () => {
|
|||||||
)
|
)
|
||||||
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
mockSecrets.store.mockRejectedValueOnce(new Error("Storage failed"))
|
||||||
|
|
||||||
await expect(configManager.SetCurrentConfig("test")).rejects.toThrow(
|
await expect(configManager.setCurrentConfig("test")).rejects.toThrow(
|
||||||
"Failed to set current config: Error: Failed to write config to secrets: Error: Storage failed",
|
"Failed to set current config: Error: Failed to write config to secrets: Error: Storage failed",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("ResetAllConfigs", () => {
|
||||||
|
it("should delete all stored configs", async () => {
|
||||||
|
// Setup initial config
|
||||||
|
mockSecrets.get.mockResolvedValue(
|
||||||
|
JSON.stringify({
|
||||||
|
currentApiConfigName: "test",
|
||||||
|
apiConfigs: {
|
||||||
|
test: {
|
||||||
|
apiProvider: "anthropic",
|
||||||
|
id: "test-id",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
await configManager.resetAllConfigs()
|
||||||
|
|
||||||
|
// Should have called delete with the correct config key
|
||||||
|
expect(mockSecrets.delete).toHaveBeenCalledWith("roo_cline_config_api_config")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("HasConfig", () => {
|
describe("HasConfig", () => {
|
||||||
it("should return true for existing config", async () => {
|
it("should return true for existing config", async () => {
|
||||||
const existingConfig: ApiConfigData = {
|
const existingConfig: ApiConfigData = {
|
||||||
@@ -443,7 +465,7 @@ describe("ConfigManager", () => {
|
|||||||
|
|
||||||
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
mockSecrets.get.mockResolvedValue(JSON.stringify(existingConfig))
|
||||||
|
|
||||||
const hasConfig = await configManager.HasConfig("test")
|
const hasConfig = await configManager.hasConfig("test")
|
||||||
expect(hasConfig).toBe(true)
|
expect(hasConfig).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -455,14 +477,14 @@ describe("ConfigManager", () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const hasConfig = await configManager.HasConfig("nonexistent")
|
const hasConfig = await configManager.hasConfig("nonexistent")
|
||||||
expect(hasConfig).toBe(false)
|
expect(hasConfig).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw error if secrets storage fails", async () => {
|
it("should throw error if secrets storage fails", async () => {
|
||||||
mockSecrets.get.mockRejectedValue(new Error("Storage failed"))
|
mockSecrets.get.mockRejectedValue(new Error("Storage failed"))
|
||||||
|
|
||||||
await expect(configManager.HasConfig("test")).rejects.toThrow(
|
await expect(configManager.hasConfig("test")).rejects.toThrow(
|
||||||
"Failed to check config existence: Error: Failed to read config from secrets: Error: Storage failed",
|
"Failed to check config existence: Error: Failed to read config from secrets: Error: Storage failed",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ describe("main", () => {
|
|||||||
const cwd = "/test/path"
|
const cwd = "/test/path"
|
||||||
const description = strategy.getToolDescription({ cwd })
|
const description = strategy.getToolDescription({ cwd })
|
||||||
|
|
||||||
expect(description).toContain("apply_diff")
|
expect(description).toContain("apply_diff Tool - Generate Precise Code Changes")
|
||||||
expect(description).toContain(cwd)
|
expect(description).toContain(cwd)
|
||||||
|
expect(description).toContain("Step-by-Step Instructions")
|
||||||
|
expect(description).toContain("Requirements")
|
||||||
|
expect(description).toContain("Examples")
|
||||||
expect(description).toContain("Parameters:")
|
expect(description).toContain("Parameters:")
|
||||||
expect(description).toContain("Format Requirements:")
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -108,77 +108,68 @@ export class NewUnifiedDiffStrategy implements DiffStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
|
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
|
||||||
return `# apply_diff Tool Rules:
|
return `# apply_diff Tool - Generate Precise Code Changes
|
||||||
|
|
||||||
Generate a unified diff similar to what "diff -U0" would produce.
|
Generate a unified diff that can be cleanly applied to modify code files.
|
||||||
|
|
||||||
The first two lines must include the file paths, starting with "---" for the original file and "+++" for the updated file. Do not include timestamps with the file paths.
|
## Step-by-Step Instructions:
|
||||||
|
|
||||||
Each hunk of changes must start with a line containing only "@@ ... @@". Do not include line numbers or ranges in the "@@ ... @@" lines. These are not necessary for the user's patch tool.
|
1. Start with file headers:
|
||||||
|
- First line: "--- {original_file_path}"
|
||||||
|
- Second line: "+++ {new_file_path}"
|
||||||
|
|
||||||
Your output must be a correct, clean patch that applies successfully against the current file contents. Mark all lines that need to be removed or changed with "-". Mark all new or modified lines with "+". Ensure you include all necessary changes; missing or unmarked lines will result in a broken patch.
|
2. For each change section:
|
||||||
|
- Begin with "@@ ... @@" separator line without line numbers
|
||||||
|
- Include 2-3 lines of context before and after changes
|
||||||
|
- Mark removed lines with "-"
|
||||||
|
- Mark added lines with "+"
|
||||||
|
- Preserve exact indentation
|
||||||
|
|
||||||
Indentation matters! Make sure to preserve the exact indentation of both removed and added lines.
|
3. Group related changes:
|
||||||
|
- Keep related modifications in the same hunk
|
||||||
|
- Start new hunks for logically separate changes
|
||||||
|
- When modifying functions/methods, include the entire block
|
||||||
|
|
||||||
Start a new hunk for each section of the file that requires changes. However, include only the hunks that contain actual changes. If a hunk consists entirely of unchanged lines, skip it.
|
## Requirements:
|
||||||
|
|
||||||
Group related changes together in the same hunk whenever possible. Output hunks in whatever logical order makes the most sense.
|
1. MUST include exact indentation
|
||||||
|
2. MUST include sufficient context for unique matching
|
||||||
|
3. MUST group related changes together
|
||||||
|
4. MUST use proper unified diff format
|
||||||
|
5. MUST NOT include timestamps in file headers
|
||||||
|
6. MUST NOT include line numbers in the @@ header
|
||||||
|
|
||||||
When editing a function, method, loop, or similar code block, replace the *entire* block in one hunk. Use "-" lines to delete the existing block and "+" lines to add the updated block. This ensures accuracy in your diffs.
|
## Examples:
|
||||||
|
|
||||||
If you need to move code within a file, create two hunks: one to delete the code from its original location and another to insert it at the new location.
|
|
||||||
|
|
||||||
To create a new file, show a diff from "--- /dev/null" to "+++ path/to/new/file.ext".
|
|
||||||
|
|
||||||
Format Requirements:
|
|
||||||
|
|
||||||
|
✅ Good diff (follows all requirements):
|
||||||
\`\`\`diff
|
\`\`\`diff
|
||||||
--- mathweb/flask/app.py
|
--- src/utils.ts
|
||||||
+++ mathweb/flask/app.py
|
+++ src/utils.ts
|
||||||
@@ ... @@
|
@@ ... @@
|
||||||
-class MathWeb:
|
def calculate_total(items):
|
||||||
+import sympy
|
- total = 0
|
||||||
|
- for item in items:
|
||||||
+
|
- total += item.price
|
||||||
+class MathWeb:
|
+ return sum(item.price for item in items)
|
||||||
@@ ... @@
|
|
||||||
-def is_prime(x):
|
|
||||||
- if x < 2:
|
|
||||||
- return False
|
|
||||||
- for i in range(2, int(math.sqrt(x)) + 1):
|
|
||||||
- if x % i == 0:
|
|
||||||
- return False
|
|
||||||
- return True
|
|
||||||
@@ ... @@
|
|
||||||
-@app.route('/prime/<int:n>')
|
|
||||||
-def nth_prime(n):
|
|
||||||
- count = 0
|
|
||||||
- num = 1
|
|
||||||
- while count < n:
|
|
||||||
- num += 1
|
|
||||||
- if is_prime(num):
|
|
||||||
- count += 1
|
|
||||||
- return str(num)
|
|
||||||
+@app.route('/prime/<int:n>')
|
|
||||||
+def nth_prime(n):
|
|
||||||
+ count = 0
|
|
||||||
+ num = 1
|
|
||||||
+ while count < n:
|
|
||||||
+ num += 1
|
|
||||||
+ if sympy.isprime(num):
|
|
||||||
+ count += 1
|
|
||||||
+ return str(num)
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
Be precise, consistent, and follow these rules carefully to generate correct diffs!
|
❌ Bad diff (violates requirements #1 and #2):
|
||||||
|
\`\`\`diff
|
||||||
|
--- src/utils.ts
|
||||||
|
+++ src/utils.ts
|
||||||
|
@@ ... @@
|
||||||
|
-total = 0
|
||||||
|
-for item in items:
|
||||||
|
+return sum(item.price for item in items)
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- path: (required) The path of the file to apply the diff to (relative to the current working directory ${args.cwd})
|
- path: (required) File path relative to ${args.cwd}
|
||||||
- diff: (required) The diff content in unified format to apply to the file.
|
- diff: (required) Unified diff content in unified format to apply to the file.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
<apply_diff>
|
<apply_diff>
|
||||||
<path>File path here</path>
|
<path>path/to/file.ext</path>
|
||||||
<diff>
|
<diff>
|
||||||
Your diff here
|
Your diff here
|
||||||
</diff>
|
</diff>
|
||||||
@@ -242,7 +233,7 @@ Your diff here
|
|||||||
originalContent: string,
|
originalContent: string,
|
||||||
diffContent: string,
|
diffContent: string,
|
||||||
startLine?: number,
|
startLine?: number,
|
||||||
endLine?: number,
|
endLine?: number
|
||||||
): Promise<DiffResult> {
|
): Promise<DiffResult> {
|
||||||
const parsedDiff = this.parseUnifiedDiff(diffContent)
|
const parsedDiff = this.parseUnifiedDiff(diffContent)
|
||||||
const originalLines = originalContent.split("\n")
|
const originalLines = originalContent.split("\n")
|
||||||
@@ -280,7 +271,7 @@ Your diff here
|
|||||||
subHunkResult,
|
subHunkResult,
|
||||||
subSearchResult.index,
|
subSearchResult.index,
|
||||||
subSearchResult.confidence,
|
subSearchResult.confidence,
|
||||||
this.confidenceThreshold,
|
this.confidenceThreshold
|
||||||
)
|
)
|
||||||
if (subEditResult.confidence >= this.confidenceThreshold) {
|
if (subEditResult.confidence >= this.confidenceThreshold) {
|
||||||
subHunkResult = subEditResult.result
|
subHunkResult = subEditResult.result
|
||||||
@@ -302,12 +293,12 @@ Your diff here
|
|||||||
const contextRatio = contextLines / totalLines
|
const contextRatio = contextLines / totalLines
|
||||||
|
|
||||||
let errorMsg = `Failed to find a matching location in the file (${Math.floor(
|
let errorMsg = `Failed to find a matching location in the file (${Math.floor(
|
||||||
confidence * 100,
|
confidence * 100
|
||||||
)}% confidence, needs ${Math.floor(this.confidenceThreshold * 100)}%)\n\n`
|
)}% confidence, needs ${Math.floor(this.confidenceThreshold * 100)}%)\n\n`
|
||||||
errorMsg += "Debug Info:\n"
|
errorMsg += "Debug Info:\n"
|
||||||
errorMsg += `- Search Strategy Used: ${strategy}\n`
|
errorMsg += `- Search Strategy Used: ${strategy}\n`
|
||||||
errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor(
|
errorMsg += `- Context Lines: ${contextLines} out of ${totalLines} total lines (${Math.floor(
|
||||||
contextRatio * 100,
|
contextRatio * 100
|
||||||
)}%)\n`
|
)}%)\n`
|
||||||
errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n`
|
errorMsg += `- Attempted to split into ${subHunks.length} sub-hunks but still failed\n`
|
||||||
|
|
||||||
@@ -339,7 +330,7 @@ Your diff here
|
|||||||
} else {
|
} else {
|
||||||
// Edit failure - likely due to content mismatch
|
// Edit failure - likely due to content mismatch
|
||||||
let errorMsg = `Failed to apply the edit using ${editResult.strategy} strategy (${Math.floor(
|
let errorMsg = `Failed to apply the edit using ${editResult.strategy} strategy (${Math.floor(
|
||||||
editResult.confidence * 100,
|
editResult.confidence * 100
|
||||||
)}% confidence)\n\n`
|
)}% confidence)\n\n`
|
||||||
errorMsg += "Debug Info:\n"
|
errorMsg += "Debug Info:\n"
|
||||||
errorMsg += "- The location was found but the content didn't match exactly\n"
|
errorMsg += "- The location was found but the content didn't match exactly\n"
|
||||||
|
|||||||
@@ -2585,487 +2585,6 @@ By waiting for and carefully considering the user's response after each tool use
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
CAPABILITIES
|
|
||||||
|
|
||||||
- You have access to tools that let you execute CLI commands on the user's computer, list files, view source code definitions, regex search, read and write files, and ask follow-up questions. These tools help you effectively accomplish a wide range of tasks, such as writing code, making edits or improvements to existing files, understanding the current state of a project, performing system operations, and much more.
|
|
||||||
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
|
|
||||||
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
|
|
||||||
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
|
|
||||||
- For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
|
|
||||||
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
RULES
|
|
||||||
|
|
||||||
- Your current working directory is: /test/path
|
|
||||||
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
|
|
||||||
- Do not use the ~ character or $HOME to refer to the home directory.
|
|
||||||
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
|
|
||||||
- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
|
|
||||||
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
|
|
||||||
- When you want to modify a file, use the write_to_file tool directly with the desired content. You do not need to display the content before using the tool.
|
|
||||||
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
|
|
||||||
- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
|
|
||||||
- Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the attempt_completion tool to present the result to the user. The user may provide feedback, which you can use to make improvements and try again.
|
|
||||||
- You are only allowed to ask the user questions using the ask_followup_question tool. Use this tool only when you need additional details to complete a task, and be sure to use a clear and concise question that will help you move forward with the task. However if you can use the available tools to avoid having to ask the user questions, you should do so. For example, if the user mentions a file that may be in an outside directory like the Desktop, you should use the list_files tool to list the files in the Desktop and check if the file they are talking about is there, rather than asking the user to provide the file path themselves.
|
|
||||||
- When executing commands, if you don't see the expected output, assume the terminal executed the command successfully and proceed with the task. The user's terminal may be unable to stream the output back properly. If you absolutely need to see the actual terminal output, use the ask_followup_question tool to request the user to copy and paste it back to you.
|
|
||||||
- The user may provide a file's contents directly in their message, in which case you shouldn't use the read_file tool to get the file contents again since you already have it.
|
|
||||||
- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.
|
|
||||||
- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.
|
|
||||||
- You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the CSS" but instead something like "I've updated the CSS". It is important you be clear and technical in your messages.
|
|
||||||
- When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
|
|
||||||
- At the end of each user message, you will automatically receive environment_details. This information is not written by the user themselves, but is auto-generated to provide potentially relevant context about the project structure and environment. While this information can be valuable for understanding the project context, do not treat it as a direct part of the user's request or response. Use it to inform your actions and decisions, but don't assume the user is explicitly asking about or referring to this information unless they clearly do so in their message. When using environment_details, explain your actions clearly to ensure the user understands, as they may not be aware of these details.
|
|
||||||
- Before executing commands, check the "Actively Running Terminals" section in environment_details. If present, consider how these active processes might impact your task. For example, if a local development server is already running, you wouldn't need to start it again. If no active terminals are listed, proceed with command execution as normal.
|
|
||||||
- When using the write_to_file tool, ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
|
|
||||||
- MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations.
|
|
||||||
- It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
SYSTEM INFORMATION
|
|
||||||
|
|
||||||
Operating System: Linux
|
|
||||||
Default Shell: /bin/bash
|
|
||||||
Home Directory: /home/user
|
|
||||||
Current Working Directory: /test/path
|
|
||||||
|
|
||||||
When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
OBJECTIVE
|
|
||||||
|
|
||||||
You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
|
|
||||||
|
|
||||||
1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
|
|
||||||
2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process. You will be informed on the work completed and what's remaining as you go.
|
|
||||||
3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool use. BUT, if one of the values for a required parameter is missing, DO NOT invoke the tool (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters using the ask_followup_question tool. DO NOT ask for more information on optional parameters if it is not provided.
|
|
||||||
4. Once you've completed the user's task, you must use the attempt_completion tool to present the result of the task to the user. You may also provide a CLI command to showcase the result of your task; this can be particularly useful for web development tasks, where you can run e.g. \`open index.html\` to show the website you've built.
|
|
||||||
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance."
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`addCustomInstructions should generate correct prompt for code reviewer mode 1`] = `
|
|
||||||
"You are Cline, a code review expert specializing in providing detailed, actionable feedback on code quality and maintainability. You excel at: 1) Identifying potential bugs, security vulnerabilities, and performance issues, 2) Ensuring code follows project standards, patterns, and best practices, 3) Checking for proper error handling and edge cases, 4) Verifying documentation completeness and clarity, 5) Suggesting specific, actionable improvements with examples. You maintain a read-only approach to the codebase and focus on helping developers improve their code through clear, constructive feedback.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
TOOL USE
|
|
||||||
|
|
||||||
You have access to a set of tools that are executed upon the user's approval. You can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
|
|
||||||
|
|
||||||
# Tool Use Formatting
|
|
||||||
|
|
||||||
Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
|
||||||
|
|
||||||
<tool_name>
|
|
||||||
<parameter1_name>value1</parameter1_name>
|
|
||||||
<parameter2_name>value2</parameter2_name>
|
|
||||||
...
|
|
||||||
</tool_name>
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
<read_file>
|
|
||||||
<path>src/main.js</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
Always adhere to this format for the tool use to ensure proper parsing and execution.
|
|
||||||
|
|
||||||
# Tools
|
|
||||||
|
|
||||||
## read_file
|
|
||||||
Description: Request to read the contents of a file at the specified path. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. The output includes line numbers prefixed to each line (e.g. "1 | const x = 1"), making it easier to reference specific lines when creating diffs or discussing code. Automatically extracts raw text from PDF and DOCX files. May not be suitable for other types of binary files, as it returns the raw content as a string.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the file to read (relative to the current working directory /test/path)
|
|
||||||
Usage:
|
|
||||||
<read_file>
|
|
||||||
<path>File path here</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
Example: Requesting to read frontend-config.json
|
|
||||||
<read_file>
|
|
||||||
<path>frontend-config.json</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
## search_files
|
|
||||||
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory to search in (relative to the current working directory /test/path). This directory will be recursively searched.
|
|
||||||
- regex: (required) The regular expression pattern to search for. Uses Rust regex syntax.
|
|
||||||
- file_pattern: (optional) Glob pattern to filter files (e.g., '*.ts' for TypeScript files). If not provided, it will search all files (*).
|
|
||||||
Usage:
|
|
||||||
<search_files>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
<regex>Your regex pattern here</regex>
|
|
||||||
<file_pattern>file pattern here (optional)</file_pattern>
|
|
||||||
</search_files>
|
|
||||||
|
|
||||||
Example: Requesting to search for all .ts files in the current directory
|
|
||||||
<search_files>
|
|
||||||
<path>.</path>
|
|
||||||
<regex>.*</regex>
|
|
||||||
<file_pattern>*.ts</file_pattern>
|
|
||||||
</search_files>
|
|
||||||
|
|
||||||
## list_files
|
|
||||||
Description: Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/path)
|
|
||||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
|
||||||
Usage:
|
|
||||||
<list_files>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
<recursive>true or false (optional)</recursive>
|
|
||||||
</list_files>
|
|
||||||
|
|
||||||
Example: Requesting to list all files in the current directory
|
|
||||||
<list_files>
|
|
||||||
<path>.</path>
|
|
||||||
<recursive>false</recursive>
|
|
||||||
</list_files>
|
|
||||||
|
|
||||||
## list_code_definition_names
|
|
||||||
Description: Request to list definition names (classes, functions, methods, etc.) used in source code files at the top level of the specified directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory (relative to the current working directory /test/path) to list top level source code definitions for.
|
|
||||||
Usage:
|
|
||||||
<list_code_definition_names>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
</list_code_definition_names>
|
|
||||||
|
|
||||||
Example: Requesting to list all top level source code definitions in the current directory
|
|
||||||
<list_code_definition_names>
|
|
||||||
<path>.</path>
|
|
||||||
</list_code_definition_names>
|
|
||||||
|
|
||||||
## ask_followup_question
|
|
||||||
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
|
||||||
Parameters:
|
|
||||||
- question: (required) The question to ask the user. This should be a clear, specific question that addresses the information you need.
|
|
||||||
Usage:
|
|
||||||
<ask_followup_question>
|
|
||||||
<question>Your question here</question>
|
|
||||||
</ask_followup_question>
|
|
||||||
|
|
||||||
Example: Requesting to ask the user for the path to the frontend-config.json file
|
|
||||||
<ask_followup_question>
|
|
||||||
<question>What is the path to the frontend-config.json file?</question>
|
|
||||||
</ask_followup_question>
|
|
||||||
|
|
||||||
## attempt_completion
|
|
||||||
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user. Optionally you may provide a CLI command to showcase the result of your work. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
|
|
||||||
IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in <thinking></thinking> tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool.
|
|
||||||
Parameters:
|
|
||||||
- result: (required) The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.
|
|
||||||
- command: (optional) A CLI command to execute to show a live demo of the result to the user. For example, use \`open index.html\` to display a created html website, or \`open localhost:3000\` to display a locally running development server. But DO NOT use commands like \`echo\` or \`cat\` that merely print text. This command should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
|
|
||||||
Usage:
|
|
||||||
<attempt_completion>
|
|
||||||
<result>
|
|
||||||
Your final result description here
|
|
||||||
</result>
|
|
||||||
<command>Command to demonstrate result (optional)</command>
|
|
||||||
</attempt_completion>
|
|
||||||
|
|
||||||
Example: Requesting to attempt completion with a result and command
|
|
||||||
<attempt_completion>
|
|
||||||
<result>
|
|
||||||
I've updated the CSS
|
|
||||||
</result>
|
|
||||||
<command>open index.html</command>
|
|
||||||
</attempt_completion>
|
|
||||||
|
|
||||||
# Tool Use Guidelines
|
|
||||||
|
|
||||||
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
|
|
||||||
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
|
|
||||||
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
|
|
||||||
4. Formulate your tool use using the XML format specified for each tool.
|
|
||||||
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
|
|
||||||
- Information about whether the tool succeeded or failed, along with any reasons for failure.
|
|
||||||
- Linter errors that may have arisen due to the changes you made, which you'll need to address.
|
|
||||||
- New terminal output in reaction to the changes, which you may need to consider or act upon.
|
|
||||||
- Any other relevant feedback or information related to the tool use.
|
|
||||||
6. ALWAYS wait for user confirmation after each tool use before proceeding. Never assume the success of a tool use without explicit confirmation of the result from the user.
|
|
||||||
|
|
||||||
It is crucial to proceed step-by-step, waiting for the user's message after each tool use before moving forward with the task. This approach allows you to:
|
|
||||||
1. Confirm the success of each step before proceeding.
|
|
||||||
2. Address any issues or errors that arise immediately.
|
|
||||||
3. Adapt your approach based on new information or unexpected results.
|
|
||||||
4. Ensure that each action builds correctly on the previous ones.
|
|
||||||
|
|
||||||
By waiting for and carefully considering the user's response after each tool use, you can react accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure the overall success and accuracy of your work.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
CAPABILITIES
|
|
||||||
|
|
||||||
- You have access to tools that let you execute CLI commands on the user's computer, list files, view source code definitions, regex search, read and write files, and ask follow-up questions. These tools help you effectively accomplish a wide range of tasks, such as writing code, making edits or improvements to existing files, understanding the current state of a project, performing system operations, and much more.
|
|
||||||
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
|
|
||||||
- You can use search_files to perform regex searches across files in a specified directory, outputting context-rich results that include surrounding lines. This is particularly useful for understanding code patterns, finding specific implementations, or identifying areas that need refactoring.
|
|
||||||
- You can use the list_code_definition_names tool to get an overview of source code definitions for all files at the top level of a specified directory. This can be particularly useful when you need to understand the broader context and relationships between certain parts of the code. You may need to call this tool multiple times to understand various parts of the codebase related to the task.
|
|
||||||
- For example, when asked to make edits or improvements you might analyze the file structure in the initial environment_details to get an overview of the project, then use list_code_definition_names to get further insight using source code definitions for files located in relevant directories, then read_file to examine the contents of relevant files, analyze the code and suggest improvements or make necessary edits, then use the write_to_file tool to apply the changes. If you refactored code that could affect other parts of the codebase, you could use search_files to ensure you update other files as needed.
|
|
||||||
- You can use the execute_command tool to run commands on the user's computer whenever you feel it can help accomplish the user's task. When you need to execute a CLI command, you must provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, since they are more flexible and easier to run. Interactive and long-running commands are allowed, since the commands are run in the user's VSCode terminal. The user may keep commands running in the background and you will be kept updated on their status along the way. Each command you execute is run in a new terminal instance.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
RULES
|
|
||||||
|
|
||||||
- Your current working directory is: /test/path
|
|
||||||
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '/test/path', so be sure to pass in the correct 'path' parameter when using tools that require a path.
|
|
||||||
- Do not use the ~ character or $HOME to refer to the home directory.
|
|
||||||
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run \`npm install\` in a project outside of '/test/path', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.
|
|
||||||
- When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes.
|
|
||||||
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
|
|
||||||
- When you want to modify a file, use the write_to_file tool directly with the desired content. You do not need to display the content before using the tool.
|
|
||||||
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
|
|
||||||
- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
|
|
||||||
- Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the attempt_completion tool to present the result to the user. The user may provide feedback, which you can use to make improvements and try again.
|
|
||||||
- You are only allowed to ask the user questions using the ask_followup_question tool. Use this tool only when you need additional details to complete a task, and be sure to use a clear and concise question that will help you move forward with the task. However if you can use the available tools to avoid having to ask the user questions, you should do so. For example, if the user mentions a file that may be in an outside directory like the Desktop, you should use the list_files tool to list the files in the Desktop and check if the file they are talking about is there, rather than asking the user to provide the file path themselves.
|
|
||||||
- When executing commands, if you don't see the expected output, assume the terminal executed the command successfully and proceed with the task. The user's terminal may be unable to stream the output back properly. If you absolutely need to see the actual terminal output, use the ask_followup_question tool to request the user to copy and paste it back to you.
|
|
||||||
- The user may provide a file's contents directly in their message, in which case you shouldn't use the read_file tool to get the file contents again since you already have it.
|
|
||||||
- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.
|
|
||||||
- NEVER end attempt_completion result with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.
|
|
||||||
- You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the CSS" but instead something like "I've updated the CSS". It is important you be clear and technical in your messages.
|
|
||||||
- When presented with images, utilize your vision capabilities to thoroughly examine them and extract meaningful information. Incorporate these insights into your thought process as you accomplish the user's task.
|
|
||||||
- At the end of each user message, you will automatically receive environment_details. This information is not written by the user themselves, but is auto-generated to provide potentially relevant context about the project structure and environment. While this information can be valuable for understanding the project context, do not treat it as a direct part of the user's request or response. Use it to inform your actions and decisions, but don't assume the user is explicitly asking about or referring to this information unless they clearly do so in their message. When using environment_details, explain your actions clearly to ensure the user understands, as they may not be aware of these details.
|
|
||||||
- Before executing commands, check the "Actively Running Terminals" section in environment_details. If present, consider how these active processes might impact your task. For example, if a local development server is already running, you wouldn't need to start it again. If no active terminals are listed, proceed with command execution as normal.
|
|
||||||
- When using the write_to_file tool, ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
|
|
||||||
- MCP operations should be used one at a time, similar to other tool usage. Wait for confirmation of success before proceeding with additional operations.
|
|
||||||
- It is critical you wait for the user's response after each tool use, in order to confirm the success of the tool use. For example, if asked to make a todo app, you would create a file, wait for the user's response it was created successfully, then create another file if needed, wait for the user's response it was created successfully, etc.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
SYSTEM INFORMATION
|
|
||||||
|
|
||||||
Operating System: Linux
|
|
||||||
Default Shell: /bin/bash
|
|
||||||
Home Directory: /home/user
|
|
||||||
Current Working Directory: /test/path
|
|
||||||
|
|
||||||
When the user initially gives you a task, a recursive list of all filepaths in the current working directory ('/test/path') will be included in environment_details. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the list_files tool. If you pass 'true' for the recursive parameter, it will list files recursively. Otherwise, it will list files at the top level, which is better suited for generic directories where you don't necessarily need the nested structure, like the Desktop.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
OBJECTIVE
|
|
||||||
|
|
||||||
You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
|
|
||||||
|
|
||||||
1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
|
|
||||||
2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process. You will be informed on the work completed and what's remaining as you go.
|
|
||||||
3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis within <thinking></thinking> tags. First, analyze the file structure provided in environment_details to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool use. BUT, if one of the values for a required parameter is missing, DO NOT invoke the tool (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters using the ask_followup_question tool. DO NOT ask for more information on optional parameters if it is not provided.
|
|
||||||
4. Once you've completed the user's task, you must use the attempt_completion tool to present the result of the task to the user. You may also provide a CLI command to showcase the result of your task; this can be particularly useful for web development tasks, where you can run e.g. \`open index.html\` to show the website you've built.
|
|
||||||
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance."
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`addCustomInstructions should generate correct prompt for test engineer mode 1`] = `
|
|
||||||
"You are Cline, a software test engineering expert specializing in writing comprehensive test suites and ensuring thorough test coverage. You excel at writing unit tests, integration tests, and end-to-end tests that cover all edge cases while maintaining existing behavior. You must ask the user to confirm before making ANY changes to non-test code, and before implementing any test changes, you always ask the user to confirm your test plan. You focus on: 1) Writing tests that verify functionality without changing existing behavior, 2) Ensuring comprehensive test coverage including edge cases and error conditions, 3) Following testing best practices and patterns appropriate for the language/framework, 4) Using mocks, stubs, and fixtures effectively, 5) Writing clear, maintainable test code with descriptive names and good documentation.
|
|
||||||
|
|
||||||
====
|
|
||||||
|
|
||||||
TOOL USE
|
|
||||||
|
|
||||||
You have access to a set of tools that are executed upon the user's approval. You can use one tool per message, and will receive the result of that tool use in the user's response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.
|
|
||||||
|
|
||||||
# Tool Use Formatting
|
|
||||||
|
|
||||||
Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
|
||||||
|
|
||||||
<tool_name>
|
|
||||||
<parameter1_name>value1</parameter1_name>
|
|
||||||
<parameter2_name>value2</parameter2_name>
|
|
||||||
...
|
|
||||||
</tool_name>
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
<read_file>
|
|
||||||
<path>src/main.js</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
Always adhere to this format for the tool use to ensure proper parsing and execution.
|
|
||||||
|
|
||||||
# Tools
|
|
||||||
|
|
||||||
## execute_command
|
|
||||||
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
|
|
||||||
Parameters:
|
|
||||||
- command: (required) The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
|
|
||||||
Usage:
|
|
||||||
<execute_command>
|
|
||||||
<command>Your command here</command>
|
|
||||||
</execute_command>
|
|
||||||
|
|
||||||
Example: Requesting to execute npm run dev
|
|
||||||
<execute_command>
|
|
||||||
<command>npm run dev</command>
|
|
||||||
</execute_command>
|
|
||||||
|
|
||||||
## read_file
|
|
||||||
Description: Request to read the contents of a file at the specified path. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. The output includes line numbers prefixed to each line (e.g. "1 | const x = 1"), making it easier to reference specific lines when creating diffs or discussing code. Automatically extracts raw text from PDF and DOCX files. May not be suitable for other types of binary files, as it returns the raw content as a string.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the file to read (relative to the current working directory /test/path)
|
|
||||||
Usage:
|
|
||||||
<read_file>
|
|
||||||
<path>File path here</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
Example: Requesting to read frontend-config.json
|
|
||||||
<read_file>
|
|
||||||
<path>frontend-config.json</path>
|
|
||||||
</read_file>
|
|
||||||
|
|
||||||
## write_to_file
|
|
||||||
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the file to write to (relative to the current working directory /test/path)
|
|
||||||
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
|
|
||||||
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
|
|
||||||
Usage:
|
|
||||||
<write_to_file>
|
|
||||||
<path>File path here</path>
|
|
||||||
<content>
|
|
||||||
Your file content here
|
|
||||||
</content>
|
|
||||||
<line_count>total number of lines in the file, including empty lines</line_count>
|
|
||||||
</write_to_file>
|
|
||||||
|
|
||||||
Example: Requesting to write to frontend-config.json
|
|
||||||
<write_to_file>
|
|
||||||
<path>frontend-config.json</path>
|
|
||||||
<content>
|
|
||||||
{
|
|
||||||
"apiEndpoint": "https://api.example.com",
|
|
||||||
"theme": {
|
|
||||||
"primaryColor": "#007bff",
|
|
||||||
"secondaryColor": "#6c757d",
|
|
||||||
"fontFamily": "Arial, sans-serif"
|
|
||||||
},
|
|
||||||
"features": {
|
|
||||||
"darkMode": true,
|
|
||||||
"notifications": true,
|
|
||||||
"analytics": false
|
|
||||||
},
|
|
||||||
"version": "1.0.0"
|
|
||||||
}
|
|
||||||
</content>
|
|
||||||
<line_count>14</line_count>
|
|
||||||
</write_to_file>
|
|
||||||
|
|
||||||
## search_files
|
|
||||||
Description: Request to perform a regex search across files in a specified directory, providing context-rich results. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory to search in (relative to the current working directory /test/path). This directory will be recursively searched.
|
|
||||||
- regex: (required) The regular expression pattern to search for. Uses Rust regex syntax.
|
|
||||||
- file_pattern: (optional) Glob pattern to filter files (e.g., '*.ts' for TypeScript files). If not provided, it will search all files (*).
|
|
||||||
Usage:
|
|
||||||
<search_files>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
<regex>Your regex pattern here</regex>
|
|
||||||
<file_pattern>file pattern here (optional)</file_pattern>
|
|
||||||
</search_files>
|
|
||||||
|
|
||||||
Example: Requesting to search for all .ts files in the current directory
|
|
||||||
<search_files>
|
|
||||||
<path>.</path>
|
|
||||||
<regex>.*</regex>
|
|
||||||
<file_pattern>*.ts</file_pattern>
|
|
||||||
</search_files>
|
|
||||||
|
|
||||||
## list_files
|
|
||||||
Description: Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory to list contents for (relative to the current working directory /test/path)
|
|
||||||
- recursive: (optional) Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.
|
|
||||||
Usage:
|
|
||||||
<list_files>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
<recursive>true or false (optional)</recursive>
|
|
||||||
</list_files>
|
|
||||||
|
|
||||||
Example: Requesting to list all files in the current directory
|
|
||||||
<list_files>
|
|
||||||
<path>.</path>
|
|
||||||
<recursive>false</recursive>
|
|
||||||
</list_files>
|
|
||||||
|
|
||||||
## list_code_definition_names
|
|
||||||
Description: Request to list definition names (classes, functions, methods, etc.) used in source code files at the top level of the specified directory. This tool provides insights into the codebase structure and important constructs, encapsulating high-level concepts and relationships that are crucial for understanding the overall architecture.
|
|
||||||
Parameters:
|
|
||||||
- path: (required) The path of the directory (relative to the current working directory /test/path) to list top level source code definitions for.
|
|
||||||
Usage:
|
|
||||||
<list_code_definition_names>
|
|
||||||
<path>Directory path here</path>
|
|
||||||
</list_code_definition_names>
|
|
||||||
|
|
||||||
Example: Requesting to list all top level source code definitions in the current directory
|
|
||||||
<list_code_definition_names>
|
|
||||||
<path>.</path>
|
|
||||||
</list_code_definition_names>
|
|
||||||
|
|
||||||
## ask_followup_question
|
|
||||||
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
|
||||||
Parameters:
|
|
||||||
- question: (required) The question to ask the user. This should be a clear, specific question that addresses the information you need.
|
|
||||||
Usage:
|
|
||||||
<ask_followup_question>
|
|
||||||
<question>Your question here</question>
|
|
||||||
</ask_followup_question>
|
|
||||||
|
|
||||||
Example: Requesting to ask the user for the path to the frontend-config.json file
|
|
||||||
<ask_followup_question>
|
|
||||||
<question>What is the path to the frontend-config.json file?</question>
|
|
||||||
</ask_followup_question>
|
|
||||||
|
|
||||||
## attempt_completion
|
|
||||||
Description: After each tool use, the user will respond with the result of that tool use, i.e. if it succeeded or failed, along with any reasons for failure. Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user. Optionally you may provide a CLI command to showcase the result of your work. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again.
|
|
||||||
IMPORTANT NOTE: This tool CANNOT be used until you've confirmed from the user that any previous tool uses were successful. Failure to do so will result in code corruption and system failure. Before using this tool, you must ask yourself in <thinking></thinking> tags if you've confirmed from the user that any previous tool uses were successful. If not, then DO NOT use this tool.
|
|
||||||
Parameters:
|
|
||||||
- result: (required) The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.
|
|
||||||
- command: (optional) A CLI command to execute to show a live demo of the result to the user. For example, use \`open index.html\` to display a created html website, or \`open localhost:3000\` to display a locally running development server. But DO NOT use commands like \`echo\` or \`cat\` that merely print text. This command should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
|
|
||||||
Usage:
|
|
||||||
<attempt_completion>
|
|
||||||
<result>
|
|
||||||
Your final result description here
|
|
||||||
</result>
|
|
||||||
<command>Command to demonstrate result (optional)</command>
|
|
||||||
</attempt_completion>
|
|
||||||
|
|
||||||
Example: Requesting to attempt completion with a result and command
|
|
||||||
<attempt_completion>
|
|
||||||
<result>
|
|
||||||
I've updated the CSS
|
|
||||||
</result>
|
|
||||||
<command>open index.html</command>
|
|
||||||
</attempt_completion>
|
|
||||||
|
|
||||||
# Tool Use Guidelines
|
|
||||||
|
|
||||||
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
|
|
||||||
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
|
|
||||||
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
|
|
||||||
4. Formulate your tool use using the XML format specified for each tool.
|
|
||||||
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
|
|
||||||
- Information about whether the tool succeeded or failed, along with any reasons for failure.
|
|
||||||
- Linter errors that may have arisen due to the changes you made, which you'll need to address.
|
|
||||||
- New terminal output in reaction to the changes, which you may need to consider or act upon.
|
|
||||||
- Any other relevant feedback or information related to the tool use.
|
|
||||||
6. ALWAYS wait for user confirmation after each tool use before proceeding. Never assume the success of a tool use without explicit confirmation of the result from the user.
|
|
||||||
|
|
||||||
It is crucial to proceed step-by-step, waiting for the user's message after each tool use before moving forward with the task. This approach allows you to:
|
|
||||||
1. Confirm the success of each step before proceeding.
|
|
||||||
2. Address any issues or errors that arise immediately.
|
|
||||||
3. Adapt your approach based on new information or unexpected results.
|
|
||||||
4. Ensure that each action builds correctly on the previous ones.
|
|
||||||
|
|
||||||
By waiting for and carefully considering the user's response after each tool use, you can react accordingly and make informed decisions about how to proceed with the task. This iterative process helps ensure the overall success and accuracy of your work.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
====
|
====
|
||||||
|
|
||||||
CAPABILITIES
|
CAPABILITIES
|
||||||
|
|||||||
@@ -222,24 +222,6 @@ describe("addCustomInstructions", () => {
|
|||||||
expect(instructions).toMatchSnapshot()
|
expect(instructions).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should generate correct prompt for test engineer mode", async () => {
|
|
||||||
const prompt = await SYSTEM_PROMPT("/test/path", false, undefined, undefined, undefined, "test")
|
|
||||||
|
|
||||||
// Verify test engineer role requirements
|
|
||||||
expect(prompt).toContain("must ask the user to confirm before making ANY changes to non-test code")
|
|
||||||
expect(prompt).toContain("ask the user to confirm your test plan")
|
|
||||||
expect(prompt).toMatchSnapshot()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should generate correct prompt for code reviewer mode", async () => {
|
|
||||||
const prompt = await SYSTEM_PROMPT("/test/path", false, undefined, undefined, undefined, "review")
|
|
||||||
|
|
||||||
// Verify code reviewer role constraints
|
|
||||||
expect(prompt).toContain("providing detailed, actionable feedback")
|
|
||||||
expect(prompt).toContain("maintain a read-only approach")
|
|
||||||
expect(prompt).toMatchSnapshot()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should fall back to generic rules when mode-specific rules not found", async () => {
|
it("should fall back to generic rules when mode-specific rules not found", async () => {
|
||||||
// Mock readFile to return ENOENT for mode-specific file
|
// Mock readFile to return ENOENT for mode-specific file
|
||||||
const mockReadFile = jest.fn().mockImplementation(async (path: string) => {
|
const mockReadFile = jest.fn().mockImplementation(async (path: string) => {
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.configManager
|
this.configManager
|
||||||
.ListConfig()
|
.listConfig()
|
||||||
.then(async (listApiConfig) => {
|
.then(async (listApiConfig) => {
|
||||||
if (!listApiConfig) {
|
if (!listApiConfig) {
|
||||||
return
|
return
|
||||||
@@ -458,7 +458,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
// check if first time init then sync with exist config
|
// check if first time init then sync with exist config
|
||||||
if (!checkExistKey(listApiConfig[0])) {
|
if (!checkExistKey(listApiConfig[0])) {
|
||||||
const { apiConfiguration } = await this.getState()
|
const { apiConfiguration } = await this.getState()
|
||||||
await this.configManager.SaveConfig(
|
await this.configManager.saveConfig(
|
||||||
listApiConfig[0].name ?? "default",
|
listApiConfig[0].name ?? "default",
|
||||||
apiConfiguration,
|
apiConfiguration,
|
||||||
)
|
)
|
||||||
@@ -469,11 +469,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
let currentConfigName = (await this.getGlobalState("currentApiConfigName")) as string
|
let currentConfigName = (await this.getGlobalState("currentApiConfigName")) as string
|
||||||
|
|
||||||
if (currentConfigName) {
|
if (currentConfigName) {
|
||||||
if (!(await this.configManager.HasConfig(currentConfigName))) {
|
if (!(await this.configManager.hasConfig(currentConfigName))) {
|
||||||
// current config name not valid, get first config in list
|
// current config name not valid, get first config in list
|
||||||
await this.updateGlobalState("currentApiConfigName", listApiConfig?.[0]?.name)
|
await this.updateGlobalState("currentApiConfigName", listApiConfig?.[0]?.name)
|
||||||
if (listApiConfig?.[0]?.name) {
|
if (listApiConfig?.[0]?.name) {
|
||||||
const apiConfig = await this.configManager.LoadConfig(
|
const apiConfig = await this.configManager.loadConfig(
|
||||||
listApiConfig?.[0]?.name,
|
listApiConfig?.[0]?.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -728,8 +728,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.updateGlobalState("mode", newMode)
|
await this.updateGlobalState("mode", newMode)
|
||||||
|
|
||||||
// Load the saved API config for the new mode if it exists
|
// Load the saved API config for the new mode if it exists
|
||||||
const savedConfigId = await this.configManager.GetModeConfigId(newMode)
|
const savedConfigId = await this.configManager.getModeConfigId(newMode)
|
||||||
const listApiConfig = await this.configManager.ListConfig()
|
const listApiConfig = await this.configManager.listConfig()
|
||||||
|
|
||||||
// Update listApiConfigMeta first to ensure UI has latest data
|
// Update listApiConfigMeta first to ensure UI has latest data
|
||||||
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
||||||
@@ -738,7 +738,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
if (savedConfigId) {
|
if (savedConfigId) {
|
||||||
const config = listApiConfig?.find((c) => c.id === savedConfigId)
|
const config = listApiConfig?.find((c) => c.id === savedConfigId)
|
||||||
if (config?.name) {
|
if (config?.name) {
|
||||||
const apiConfig = await this.configManager.LoadConfig(config.name)
|
const apiConfig = await this.configManager.loadConfig(config.name)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.updateGlobalState("currentApiConfigName", config.name),
|
this.updateGlobalState("currentApiConfigName", config.name),
|
||||||
this.updateApiConfiguration(apiConfig),
|
this.updateApiConfiguration(apiConfig),
|
||||||
@@ -750,7 +750,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
if (currentApiConfigName) {
|
if (currentApiConfigName) {
|
||||||
const config = listApiConfig?.find((c) => c.name === currentApiConfigName)
|
const config = listApiConfig?.find((c) => c.name === currentApiConfigName)
|
||||||
if (config?.id) {
|
if (config?.id) {
|
||||||
await this.configManager.SetModeConfig(newMode, config.id)
|
await this.configManager.setModeConfig(newMode, config.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -915,7 +915,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
if (enhancementApiConfigId) {
|
if (enhancementApiConfigId) {
|
||||||
const config = listApiConfigMeta?.find((c) => c.id === enhancementApiConfigId)
|
const config = listApiConfigMeta?.find((c) => c.id === enhancementApiConfigId)
|
||||||
if (config?.name) {
|
if (config?.name) {
|
||||||
const loadedConfig = await this.configManager.LoadConfig(config.name)
|
const loadedConfig = await this.configManager.loadConfig(config.name)
|
||||||
if (loadedConfig.apiProvider) {
|
if (loadedConfig.apiProvider) {
|
||||||
configToUse = loadedConfig
|
configToUse = loadedConfig
|
||||||
}
|
}
|
||||||
@@ -1006,8 +1006,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
case "upsertApiConfiguration":
|
case "upsertApiConfiguration":
|
||||||
if (message.text && message.apiConfiguration) {
|
if (message.text && message.apiConfiguration) {
|
||||||
try {
|
try {
|
||||||
await this.configManager.SaveConfig(message.text, message.apiConfiguration)
|
await this.configManager.saveConfig(message.text, message.apiConfiguration)
|
||||||
let listApiConfig = await this.configManager.ListConfig()
|
let listApiConfig = await this.configManager.listConfig()
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.updateGlobalState("listApiConfigMeta", listApiConfig),
|
this.updateGlobalState("listApiConfigMeta", listApiConfig),
|
||||||
@@ -1027,10 +1027,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
try {
|
try {
|
||||||
const { oldName, newName } = message.values
|
const { oldName, newName } = message.values
|
||||||
|
|
||||||
await this.configManager.SaveConfig(newName, message.apiConfiguration)
|
await this.configManager.saveConfig(newName, message.apiConfiguration)
|
||||||
await this.configManager.DeleteConfig(oldName)
|
await this.configManager.deleteConfig(oldName)
|
||||||
|
|
||||||
let listApiConfig = await this.configManager.ListConfig()
|
let listApiConfig = await this.configManager.listConfig()
|
||||||
const config = listApiConfig?.find((c) => c.name === newName)
|
const config = listApiConfig?.find((c) => c.name === newName)
|
||||||
|
|
||||||
// Update listApiConfigMeta first to ensure UI has latest data
|
// Update listApiConfigMeta first to ensure UI has latest data
|
||||||
@@ -1048,8 +1048,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
case "loadApiConfiguration":
|
case "loadApiConfiguration":
|
||||||
if (message.text) {
|
if (message.text) {
|
||||||
try {
|
try {
|
||||||
const apiConfig = await this.configManager.LoadConfig(message.text)
|
const apiConfig = await this.configManager.loadConfig(message.text)
|
||||||
const listApiConfig = await this.configManager.ListConfig()
|
const listApiConfig = await this.configManager.listConfig()
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.updateGlobalState("listApiConfigMeta", listApiConfig),
|
this.updateGlobalState("listApiConfigMeta", listApiConfig),
|
||||||
@@ -1077,8 +1077,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.configManager.DeleteConfig(message.text)
|
await this.configManager.deleteConfig(message.text)
|
||||||
const listApiConfig = await this.configManager.ListConfig()
|
const listApiConfig = await this.configManager.listConfig()
|
||||||
|
|
||||||
// Update listApiConfigMeta first to ensure UI has latest data
|
// Update listApiConfigMeta first to ensure UI has latest data
|
||||||
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
||||||
@@ -1086,7 +1086,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
// If this was the current config, switch to first available
|
// If this was the current config, switch to first available
|
||||||
let currentApiConfigName = await this.getGlobalState("currentApiConfigName")
|
let currentApiConfigName = await this.getGlobalState("currentApiConfigName")
|
||||||
if (message.text === currentApiConfigName && listApiConfig?.[0]?.name) {
|
if (message.text === currentApiConfigName && listApiConfig?.[0]?.name) {
|
||||||
const apiConfig = await this.configManager.LoadConfig(listApiConfig[0].name)
|
const apiConfig = await this.configManager.loadConfig(listApiConfig[0].name)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.updateGlobalState("currentApiConfigName", listApiConfig[0].name),
|
this.updateGlobalState("currentApiConfigName", listApiConfig[0].name),
|
||||||
this.updateApiConfiguration(apiConfig),
|
this.updateApiConfiguration(apiConfig),
|
||||||
@@ -1102,7 +1102,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
break
|
break
|
||||||
case "getListApiConfiguration":
|
case "getListApiConfiguration":
|
||||||
try {
|
try {
|
||||||
let listApiConfig = await this.configManager.ListConfig()
|
let listApiConfig = await this.configManager.listConfig()
|
||||||
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
||||||
this.postMessageToWebview({ type: "listApiConfig", listApiConfig })
|
this.postMessageToWebview({ type: "listApiConfig", listApiConfig })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1129,10 +1129,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
const { mode } = await this.getState()
|
const { mode } = await this.getState()
|
||||||
if (mode) {
|
if (mode) {
|
||||||
const currentApiConfigName = await this.getGlobalState("currentApiConfigName")
|
const currentApiConfigName = await this.getGlobalState("currentApiConfigName")
|
||||||
const listApiConfig = await this.configManager.ListConfig()
|
const listApiConfig = await this.configManager.listConfig()
|
||||||
const config = listApiConfig?.find((c) => c.name === currentApiConfigName)
|
const config = listApiConfig?.find((c) => c.name === currentApiConfigName)
|
||||||
if (config?.id) {
|
if (config?.id) {
|
||||||
await this.configManager.SetModeConfig(mode, config.id)
|
await this.configManager.setModeConfig(mode, config.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2089,7 +2089,16 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
// dev
|
// dev
|
||||||
|
|
||||||
async resetState() {
|
async resetState() {
|
||||||
vscode.window.showInformationMessage("Resetting state...")
|
const answer = await vscode.window.showInformationMessage(
|
||||||
|
"Are you sure you want to reset all state and secret storage in the extension? This cannot be undone.",
|
||||||
|
{ modal: true },
|
||||||
|
"Yes",
|
||||||
|
)
|
||||||
|
|
||||||
|
if (answer !== "Yes") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for (const key of this.context.globalState.keys()) {
|
for (const key of this.context.globalState.keys()) {
|
||||||
await this.context.globalState.update(key, undefined)
|
await this.context.globalState.update(key, undefined)
|
||||||
}
|
}
|
||||||
@@ -2109,11 +2118,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
for (const key of secretKeys) {
|
for (const key of secretKeys) {
|
||||||
await this.storeSecret(key, undefined)
|
await this.storeSecret(key, undefined)
|
||||||
}
|
}
|
||||||
|
await this.configManager.resetAllConfigs()
|
||||||
if (this.cline) {
|
if (this.cline) {
|
||||||
this.cline.abortTask()
|
this.cline.abortTask()
|
||||||
this.cline = undefined
|
this.cline = undefined
|
||||||
}
|
}
|
||||||
vscode.window.showInformationMessage("State reset")
|
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -443,18 +443,18 @@ describe("ClineProvider", () => {
|
|||||||
|
|
||||||
// Mock ConfigManager methods
|
// Mock ConfigManager methods
|
||||||
provider.configManager = {
|
provider.configManager = {
|
||||||
GetModeConfigId: jest.fn().mockResolvedValue("test-id"),
|
getModeConfigId: jest.fn().mockResolvedValue("test-id"),
|
||||||
ListConfig: jest.fn().mockResolvedValue([{ name: "test-config", id: "test-id", apiProvider: "anthropic" }]),
|
listConfig: jest.fn().mockResolvedValue([{ name: "test-config", id: "test-id", apiProvider: "anthropic" }]),
|
||||||
LoadConfig: jest.fn().mockResolvedValue({ apiProvider: "anthropic" }),
|
loadConfig: jest.fn().mockResolvedValue({ apiProvider: "anthropic" }),
|
||||||
SetModeConfig: jest.fn(),
|
setModeConfig: jest.fn(),
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
// Switch to architect mode
|
// Switch to architect mode
|
||||||
await messageHandler({ type: "mode", text: "architect" })
|
await messageHandler({ type: "mode", text: "architect" })
|
||||||
|
|
||||||
// Should load the saved config for architect mode
|
// Should load the saved config for architect mode
|
||||||
expect(provider.configManager.GetModeConfigId).toHaveBeenCalledWith("architect")
|
expect(provider.configManager.getModeConfigId).toHaveBeenCalledWith("architect")
|
||||||
expect(provider.configManager.LoadConfig).toHaveBeenCalledWith("test-config")
|
expect(provider.configManager.loadConfig).toHaveBeenCalledWith("test-config")
|
||||||
expect(mockContext.globalState.update).toHaveBeenCalledWith("currentApiConfigName", "test-config")
|
expect(mockContext.globalState.update).toHaveBeenCalledWith("currentApiConfigName", "test-config")
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -464,11 +464,11 @@ describe("ClineProvider", () => {
|
|||||||
|
|
||||||
// Mock ConfigManager methods
|
// Mock ConfigManager methods
|
||||||
provider.configManager = {
|
provider.configManager = {
|
||||||
GetModeConfigId: jest.fn().mockResolvedValue(undefined),
|
getModeConfigId: jest.fn().mockResolvedValue(undefined),
|
||||||
ListConfig: jest
|
listConfig: jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockResolvedValue([{ name: "current-config", id: "current-id", apiProvider: "anthropic" }]),
|
.mockResolvedValue([{ name: "current-config", id: "current-id", apiProvider: "anthropic" }]),
|
||||||
SetModeConfig: jest.fn(),
|
setModeConfig: jest.fn(),
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
// Mock current config name
|
// Mock current config name
|
||||||
@@ -483,7 +483,7 @@ describe("ClineProvider", () => {
|
|||||||
await messageHandler({ type: "mode", text: "architect" })
|
await messageHandler({ type: "mode", text: "architect" })
|
||||||
|
|
||||||
// Should save current config as default for architect mode
|
// Should save current config as default for architect mode
|
||||||
expect(provider.configManager.SetModeConfig).toHaveBeenCalledWith("architect", "current-id")
|
expect(provider.configManager.setModeConfig).toHaveBeenCalledWith("architect", "current-id")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("saves config as default for current mode when loading config", async () => {
|
test("saves config as default for current mode when loading config", async () => {
|
||||||
@@ -491,10 +491,10 @@ describe("ClineProvider", () => {
|
|||||||
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
|
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
|
||||||
|
|
||||||
provider.configManager = {
|
provider.configManager = {
|
||||||
LoadConfig: jest.fn().mockResolvedValue({ apiProvider: "anthropic", id: "new-id" }),
|
loadConfig: jest.fn().mockResolvedValue({ apiProvider: "anthropic", id: "new-id" }),
|
||||||
ListConfig: jest.fn().mockResolvedValue([{ name: "new-config", id: "new-id", apiProvider: "anthropic" }]),
|
listConfig: jest.fn().mockResolvedValue([{ name: "new-config", id: "new-id", apiProvider: "anthropic" }]),
|
||||||
SetModeConfig: jest.fn(),
|
setModeConfig: jest.fn(),
|
||||||
GetModeConfigId: jest.fn().mockResolvedValue(undefined),
|
getModeConfigId: jest.fn().mockResolvedValue(undefined),
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
// First set the mode
|
// First set the mode
|
||||||
@@ -504,7 +504,7 @@ describe("ClineProvider", () => {
|
|||||||
await messageHandler({ type: "loadApiConfiguration", text: "new-config" })
|
await messageHandler({ type: "loadApiConfiguration", text: "new-config" })
|
||||||
|
|
||||||
// Should save new config as default for architect mode
|
// Should save new config as default for architect mode
|
||||||
expect(provider.configManager.SetModeConfig).toHaveBeenCalledWith("architect", "new-id")
|
expect(provider.configManager.setModeConfig).toHaveBeenCalledWith("architect", "new-id")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("handles request delay settings messages", async () => {
|
test("handles request delay settings messages", async () => {
|
||||||
@@ -678,8 +678,8 @@ describe("ClineProvider", () => {
|
|||||||
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
|
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
|
||||||
|
|
||||||
provider.configManager = {
|
provider.configManager = {
|
||||||
ListConfig: jest.fn().mockResolvedValue([{ name: "test-config", id: "test-id", apiProvider: "anthropic" }]),
|
listConfig: jest.fn().mockResolvedValue([{ name: "test-config", id: "test-id", apiProvider: "anthropic" }]),
|
||||||
SetModeConfig: jest.fn(),
|
setModeConfig: jest.fn(),
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
// Update API configuration
|
// Update API configuration
|
||||||
@@ -689,7 +689,7 @@ describe("ClineProvider", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Should save config as default for current mode
|
// Should save config as default for current mode
|
||||||
expect(provider.configManager.SetModeConfig).toHaveBeenCalledWith("code", "test-id")
|
expect(provider.configManager.setModeConfig).toHaveBeenCalledWith("code", "test-id")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("file content includes line numbers", async () => {
|
test("file content includes line numbers", async () => {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ let outputChannel: vscode.OutputChannel
|
|||||||
// This method is called when your extension is activated
|
// This method is called when your extension is activated
|
||||||
// Your extension is activated the very first time the command is executed
|
// Your extension is activated the very first time the command is executed
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
outputChannel = vscode.window.createOutputChannel("Cline")
|
outputChannel = vscode.window.createOutputChannel("Roo-Cline")
|
||||||
context.subscriptions.push(outputChannel)
|
context.subscriptions.push(outputChannel)
|
||||||
|
|
||||||
outputChannel.appendLine("Cline extension activated")
|
outputChannel.appendLine("Roo-Cline extension activated")
|
||||||
|
|
||||||
// Get default commands from configuration
|
// Get default commands from configuration
|
||||||
const defaultCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
|
const defaultCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
|
||||||
@@ -163,5 +163,5 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// This method is called when your extension is deactivated
|
// This method is called when your extension is deactivated
|
||||||
export function deactivate() {
|
export function deactivate() {
|
||||||
outputChannel.appendLine("Cline extension deactivated")
|
outputChannel.appendLine("Roo-Cline extension deactivated")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ export interface ApiHandlerOptions {
|
|||||||
setAzureApiVersion?: boolean
|
setAzureApiVersion?: boolean
|
||||||
deepSeekBaseUrl?: string
|
deepSeekBaseUrl?: string
|
||||||
deepSeekApiKey?: string
|
deepSeekApiKey?: string
|
||||||
deepSeekModelId?: string
|
|
||||||
includeMaxTokens?: boolean
|
includeMaxTokens?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,6 +543,15 @@ export const deepSeekModels = {
|
|||||||
outputPrice: 0.28, // $0.28 per million tokens
|
outputPrice: 0.28, // $0.28 per million tokens
|
||||||
description: `DeepSeek-V3 achieves a significant breakthrough in inference speed over previous models. It tops the leaderboard among open-source models and rivals the most advanced closed-source models globally.`,
|
description: `DeepSeek-V3 achieves a significant breakthrough in inference speed over previous models. It tops the leaderboard among open-source models and rivals the most advanced closed-source models globally.`,
|
||||||
},
|
},
|
||||||
|
"deepseek-reasoner": {
|
||||||
|
maxTokens: 8192,
|
||||||
|
contextWindow: 64_000,
|
||||||
|
supportsImages: false,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0.55, // $0.55 per million tokens
|
||||||
|
outputPrice: 2.19, // $2.19 per million tokens
|
||||||
|
description: `DeepSeek-R1 achieves performance comparable to OpenAI-o1 across math, code, and reasoning tasks.`,
|
||||||
|
},
|
||||||
} as const satisfies Record<string, ModelInfo>
|
} as const satisfies Record<string, ModelInfo>
|
||||||
|
|
||||||
// Azure OpenAI
|
// Azure OpenAI
|
||||||
|
|||||||
@@ -82,43 +82,6 @@ export const modes: readonly ModeConfig[] = [
|
|||||||
["attempt_completion"],
|
["attempt_completion"],
|
||||||
] as const,
|
] as const,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
slug: "test",
|
|
||||||
name: "Test",
|
|
||||||
roleDefinition:
|
|
||||||
"You are Cline, a software test engineering expert specializing in writing comprehensive test suites and ensuring thorough test coverage. You excel at writing unit tests, integration tests, and end-to-end tests that cover all edge cases while maintaining existing behavior. You must ask the user to confirm before making ANY changes to non-test code, and before implementing any test changes, you always ask the user to confirm your test plan. You focus on: 1) Writing tests that verify functionality without changing existing behavior, 2) Ensuring comprehensive test coverage including edge cases and error conditions, 3) Following testing best practices and patterns appropriate for the language/framework, 4) Using mocks, stubs, and fixtures effectively, 5) Writing clear, maintainable test code with descriptive names and good documentation.",
|
|
||||||
tools: [
|
|
||||||
["execute_command"],
|
|
||||||
["read_file"],
|
|
||||||
["write_to_file"],
|
|
||||||
["apply_diff"],
|
|
||||||
["search_files"],
|
|
||||||
["list_files"],
|
|
||||||
["list_code_definition_names"],
|
|
||||||
["browser_action"],
|
|
||||||
["use_mcp_tool"],
|
|
||||||
["access_mcp_resource"],
|
|
||||||
["ask_followup_question"],
|
|
||||||
["attempt_completion"],
|
|
||||||
] as const,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
slug: "review",
|
|
||||||
name: "Review",
|
|
||||||
roleDefinition:
|
|
||||||
"You are Cline, a code review expert specializing in providing detailed, actionable feedback on code quality and maintainability. You excel at: 1) Identifying potential bugs, security vulnerabilities, and performance issues, 2) Ensuring code follows project standards, patterns, and best practices, 3) Checking for proper error handling and edge cases, 4) Verifying documentation completeness and clarity, 5) Suggesting specific, actionable improvements with examples. You maintain a read-only approach to the codebase and focus on helping developers improve their code through clear, constructive feedback.",
|
|
||||||
tools: [
|
|
||||||
["read_file"],
|
|
||||||
["search_files"],
|
|
||||||
["list_files"],
|
|
||||||
["list_code_definition_names"],
|
|
||||||
["browser_action"],
|
|
||||||
["use_mcp_tool"],
|
|
||||||
["access_mcp_resource"],
|
|
||||||
["ask_followup_question"],
|
|
||||||
["attempt_completion"],
|
|
||||||
] as const,
|
|
||||||
},
|
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
// Export the default mode slug
|
// Export the default mode slug
|
||||||
|
|||||||
@@ -714,11 +714,15 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
value={mode}
|
value={mode}
|
||||||
disabled={textAreaDisabled}
|
disabled={textAreaDisabled}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const newMode = e.target.value as Mode
|
const value = e.target.value
|
||||||
setMode(newMode)
|
if (value === "prompts-action") {
|
||||||
|
window.postMessage({ type: "action", action: "promptsButtonClicked" })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setMode(value as Mode)
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
type: "mode",
|
type: "mode",
|
||||||
text: newMode,
|
text: value,
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
@@ -737,6 +741,10 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
{mode.name}
|
{mode.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
<option disabled style={{ borderTop: "1px solid var(--vscode-dropdown-border)" }}>
|
||||||
|
────
|
||||||
|
</option>
|
||||||
|
<option value="prompts-action">Edit...</option>
|
||||||
</select>
|
</select>
|
||||||
<div style={caretContainerStyle}>
|
<div style={caretContainerStyle}>
|
||||||
<CaretIcon />
|
<CaretIcon />
|
||||||
@@ -753,20 +761,25 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}>
|
}}>
|
||||||
<select
|
<select
|
||||||
value={currentApiConfigName}
|
value={currentApiConfigName || ""}
|
||||||
disabled={textAreaDisabled}
|
disabled={textAreaDisabled}
|
||||||
onChange={(e) =>
|
onChange={(e) => {
|
||||||
|
const value = e.target.value
|
||||||
|
if (value === "settings-action") {
|
||||||
|
window.postMessage({ type: "action", action: "settingsButtonClicked" })
|
||||||
|
return
|
||||||
|
}
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
type: "loadApiConfiguration",
|
type: "loadApiConfiguration",
|
||||||
text: e.target.value,
|
text: value,
|
||||||
})
|
})
|
||||||
}
|
}}
|
||||||
style={{
|
style={{
|
||||||
...selectStyle,
|
...selectStyle,
|
||||||
width: "100%",
|
width: "100%",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
}}>
|
}}>
|
||||||
{(listApiConfigMeta || [])?.map((config) => (
|
{(listApiConfigMeta || []).map((config) => (
|
||||||
<option
|
<option
|
||||||
key={config.name}
|
key={config.name}
|
||||||
value={config.name}
|
value={config.name}
|
||||||
@@ -777,6 +790,10 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
{config.name}
|
{config.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
<option disabled style={{ borderTop: "1px solid var(--vscode-dropdown-border)" }}>
|
||||||
|
────
|
||||||
|
</option>
|
||||||
|
<option value="settings-action">Edit...</option>
|
||||||
</select>
|
</select>
|
||||||
<div style={caretContainerStyle}>
|
<div style={caretContainerStyle}>
|
||||||
<CaretIcon />
|
<CaretIcon />
|
||||||
@@ -806,14 +823,18 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
role="button"
|
role="button"
|
||||||
aria-label="enhance prompt"
|
aria-label="enhance prompt"
|
||||||
data-testid="enhance-prompt-button"
|
data-testid="enhance-prompt-button"
|
||||||
className={`input-icon-button ${textAreaDisabled ? "disabled" : ""} codicon codicon-sparkle`}
|
className={`input-icon-button ${
|
||||||
|
textAreaDisabled ? "disabled" : ""
|
||||||
|
} codicon codicon-sparkle`}
|
||||||
onClick={() => !textAreaDisabled && handleEnhancePrompt()}
|
onClick={() => !textAreaDisabled && handleEnhancePrompt()}
|
||||||
style={{ fontSize: 16.5 }}
|
style={{ fontSize: 16.5 }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
className={`input-icon-button ${shouldDisableImages ? "disabled" : ""} codicon codicon-device-camera`}
|
className={`input-icon-button ${
|
||||||
|
shouldDisableImages ? "disabled" : ""
|
||||||
|
} codicon codicon-device-camera`}
|
||||||
onClick={() => !shouldDisableImages && onSelectImages()}
|
onClick={() => !shouldDisableImages && onSelectImages()}
|
||||||
style={{ fontSize: 16.5 }}
|
style={{ fontSize: 16.5 }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||||||
mode,
|
mode,
|
||||||
customInstructions,
|
customInstructions,
|
||||||
setCustomInstructions,
|
setCustomInstructions,
|
||||||
|
preferredLanguage,
|
||||||
|
setPreferredLanguage,
|
||||||
} = useExtensionState()
|
} = useExtensionState()
|
||||||
const [testPrompt, setTestPrompt] = useState("")
|
const [testPrompt, setTestPrompt] = useState("")
|
||||||
const [isEnhancing, setIsEnhancing] = useState(false)
|
const [isEnhancing, setIsEnhancing] = useState(false)
|
||||||
@@ -146,6 +148,55 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||||||
|
|
||||||
<div style={{ flex: 1, overflow: "auto", padding: "0 20px" }}>
|
<div style={{ flex: 1, overflow: "auto", padding: "0 20px" }}>
|
||||||
<div style={{ marginBottom: "20px" }}>
|
<div style={{ marginBottom: "20px" }}>
|
||||||
|
<div style={{ marginBottom: "20px" }}>
|
||||||
|
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Preferred Language</div>
|
||||||
|
<select
|
||||||
|
value={preferredLanguage}
|
||||||
|
onChange={(e) => {
|
||||||
|
setPreferredLanguage(e.target.value)
|
||||||
|
vscode.postMessage({
|
||||||
|
type: "preferredLanguage",
|
||||||
|
text: e.target.value,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
padding: "4px 8px",
|
||||||
|
backgroundColor: "var(--vscode-input-background)",
|
||||||
|
color: "var(--vscode-input-foreground)",
|
||||||
|
border: "1px solid var(--vscode-input-border)",
|
||||||
|
borderRadius: "2px",
|
||||||
|
height: "28px",
|
||||||
|
}}>
|
||||||
|
<option value="English">English</option>
|
||||||
|
<option value="Arabic">Arabic - العربية</option>
|
||||||
|
<option value="Brazilian Portuguese">Portuguese - Português (Brasil)</option>
|
||||||
|
<option value="Czech">Czech - Čeština</option>
|
||||||
|
<option value="French">French - Français</option>
|
||||||
|
<option value="German">German - Deutsch</option>
|
||||||
|
<option value="Hindi">Hindi - हिन्दी</option>
|
||||||
|
<option value="Hungarian">Hungarian - Magyar</option>
|
||||||
|
<option value="Italian">Italian - Italiano</option>
|
||||||
|
<option value="Japanese">Japanese - 日本語</option>
|
||||||
|
<option value="Korean">Korean - 한국어</option>
|
||||||
|
<option value="Polish">Polish - Polski</option>
|
||||||
|
<option value="Portuguese">Portuguese - Português (Portugal)</option>
|
||||||
|
<option value="Russian">Russian - Русский</option>
|
||||||
|
<option value="Simplified Chinese">Simplified Chinese - 简体中文</option>
|
||||||
|
<option value="Spanish">Spanish - Español</option>
|
||||||
|
<option value="Traditional Chinese">Traditional Chinese - 繁體中文</option>
|
||||||
|
<option value="Turkish">Turkish - Türkçe</option>
|
||||||
|
</select>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: "12px",
|
||||||
|
marginTop: "5px",
|
||||||
|
color: "var(--vscode-descriptionForeground)",
|
||||||
|
}}>
|
||||||
|
Select the language that Cline should use for communication.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Custom Instructions for All Modes</div>
|
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Custom Instructions for All Modes</div>
|
||||||
<div
|
<div
|
||||||
style={{ fontSize: "13px", color: "var(--vscode-descriptionForeground)", marginBottom: "8px" }}>
|
style={{ fontSize: "13px", color: "var(--vscode-descriptionForeground)", marginBottom: "8px" }}>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ interface ApiOptionsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) => {
|
const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) => {
|
||||||
const { apiConfiguration, setApiConfiguration, uriScheme, onUpdateApiConfig } = useExtensionState()
|
const { apiConfiguration, setApiConfiguration, uriScheme, handleInputChange } = useExtensionState()
|
||||||
const [ollamaModels, setOllamaModels] = useState<string[]>([])
|
const [ollamaModels, setOllamaModels] = useState<string[]>([])
|
||||||
const [lmStudioModels, setLmStudioModels] = useState<string[]>([])
|
const [lmStudioModels, setLmStudioModels] = useState<string[]>([])
|
||||||
const [vsCodeLmModels, setVsCodeLmModels] = useState<vscodemodels.LanguageModelChatSelector[]>([])
|
const [vsCodeLmModels, setVsCodeLmModels] = useState<vscodemodels.LanguageModelChatSelector[]>([])
|
||||||
@@ -53,12 +53,6 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
const [azureApiVersionSelected, setAzureApiVersionSelected] = useState(!!apiConfiguration?.azureApiVersion)
|
const [azureApiVersionSelected, setAzureApiVersionSelected] = useState(!!apiConfiguration?.azureApiVersion)
|
||||||
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
|
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
|
||||||
|
|
||||||
const handleInputChange = (field: keyof ApiConfiguration) => (event: any) => {
|
|
||||||
const apiConfig = { ...apiConfiguration, [field]: event.target.value }
|
|
||||||
onUpdateApiConfig(apiConfig)
|
|
||||||
setApiConfiguration(apiConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
const { selectedProvider, selectedModelId, selectedModelInfo } = useMemo(() => {
|
const { selectedProvider, selectedModelId, selectedModelInfo } = useMemo(() => {
|
||||||
return normalizeApiConfiguration(apiConfiguration)
|
return normalizeApiConfiguration(apiConfiguration)
|
||||||
}, [apiConfiguration])
|
}, [apiConfiguration])
|
||||||
@@ -162,7 +156,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.apiKey || ""}
|
value={apiConfiguration?.apiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("apiKey")}
|
onChange={handleInputChange("apiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>Anthropic API Key</span>
|
<span style={{ fontWeight: 500 }}>Anthropic API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -183,7 +177,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.anthropicBaseUrl || ""}
|
value={apiConfiguration?.anthropicBaseUrl || ""}
|
||||||
style={{ width: "100%", marginTop: 3 }}
|
style={{ width: "100%", marginTop: 3 }}
|
||||||
type="url"
|
type="url"
|
||||||
onInput={handleInputChange("anthropicBaseUrl")}
|
onChange={handleInputChange("anthropicBaseUrl")}
|
||||||
placeholder="Default: https://api.anthropic.com"
|
placeholder="Default: https://api.anthropic.com"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -212,7 +206,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.glamaApiKey || ""}
|
value={apiConfiguration?.glamaApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("glamaApiKey")}
|
onChange={handleInputChange("glamaApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>Glama API Key</span>
|
<span style={{ fontWeight: 500 }}>Glama API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -241,7 +235,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.openAiNativeApiKey || ""}
|
value={apiConfiguration?.openAiNativeApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("openAiNativeApiKey")}
|
onChange={handleInputChange("openAiNativeApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>OpenAI API Key</span>
|
<span style={{ fontWeight: 500 }}>OpenAI API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -269,7 +263,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.mistralApiKey || ""}
|
value={apiConfiguration?.mistralApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("mistralApiKey")}
|
onChange={handleInputChange("mistralApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>Mistral API Key</span>
|
<span style={{ fontWeight: 500 }}>Mistral API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -300,7 +294,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.openRouterApiKey || ""}
|
value={apiConfiguration?.openRouterApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("openRouterApiKey")}
|
onChange={handleInputChange("openRouterApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>OpenRouter API Key</span>
|
<span style={{ fontWeight: 500 }}>OpenRouter API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -454,7 +448,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
<VSCodeTextField
|
<VSCodeTextField
|
||||||
value={apiConfiguration?.vertexProjectId || ""}
|
value={apiConfiguration?.vertexProjectId || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onInput={handleInputChange("vertexProjectId")}
|
onChange={handleInputChange("vertexProjectId")}
|
||||||
placeholder="Enter Project ID...">
|
placeholder="Enter Project ID...">
|
||||||
<span style={{ fontWeight: 500 }}>Google Cloud Project ID</span>
|
<span style={{ fontWeight: 500 }}>Google Cloud Project ID</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -512,7 +506,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.geminiApiKey || ""}
|
value={apiConfiguration?.geminiApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("geminiApiKey")}
|
onChange={handleInputChange("geminiApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>Gemini API Key</span>
|
<span style={{ fontWeight: 500 }}>Gemini API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -540,7 +534,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.openAiBaseUrl || ""}
|
value={apiConfiguration?.openAiBaseUrl || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="url"
|
type="url"
|
||||||
onInput={handleInputChange("openAiBaseUrl")}
|
onChange={handleInputChange("openAiBaseUrl")}
|
||||||
placeholder={"Enter base URL..."}>
|
placeholder={"Enter base URL..."}>
|
||||||
<span style={{ fontWeight: 500 }}>Base URL</span>
|
<span style={{ fontWeight: 500 }}>Base URL</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -548,7 +542,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.openAiApiKey || ""}
|
value={apiConfiguration?.openAiApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("openAiApiKey")}
|
onChange={handleInputChange("openAiApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>API Key</span>
|
<span style={{ fontWeight: 500 }}>API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -578,7 +572,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
<VSCodeTextField
|
<VSCodeTextField
|
||||||
value={apiConfiguration?.azureApiVersion || ""}
|
value={apiConfiguration?.azureApiVersion || ""}
|
||||||
style={{ width: "100%", marginTop: 3 }}
|
style={{ width: "100%", marginTop: 3 }}
|
||||||
onInput={handleInputChange("azureApiVersion")}
|
onChange={handleInputChange("azureApiVersion")}
|
||||||
placeholder={`Default: ${azureOpenAiDefaultApiVersion}`}
|
placeholder={`Default: ${azureOpenAiDefaultApiVersion}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -602,14 +596,14 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.lmStudioBaseUrl || ""}
|
value={apiConfiguration?.lmStudioBaseUrl || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="url"
|
type="url"
|
||||||
onInput={handleInputChange("lmStudioBaseUrl")}
|
onChange={handleInputChange("lmStudioBaseUrl")}
|
||||||
placeholder={"Default: http://localhost:1234"}>
|
placeholder={"Default: http://localhost:1234"}>
|
||||||
<span style={{ fontWeight: 500 }}>Base URL (optional)</span>
|
<span style={{ fontWeight: 500 }}>Base URL (optional)</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
<VSCodeTextField
|
<VSCodeTextField
|
||||||
value={apiConfiguration?.lmStudioModelId || ""}
|
value={apiConfiguration?.lmStudioModelId || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onInput={handleInputChange("lmStudioModelId")}
|
onChange={handleInputChange("lmStudioModelId")}
|
||||||
placeholder={"e.g. meta-llama-3.1-8b-instruct"}>
|
placeholder={"e.g. meta-llama-3.1-8b-instruct"}>
|
||||||
<span style={{ fontWeight: 500 }}>Model ID</span>
|
<span style={{ fontWeight: 500 }}>Model ID</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -671,7 +665,7 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.deepSeekApiKey || ""}
|
value={apiConfiguration?.deepSeekApiKey || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="password"
|
type="password"
|
||||||
onInput={handleInputChange("deepSeekApiKey")}
|
onChange={handleInputChange("deepSeekApiKey")}
|
||||||
placeholder="Enter API Key...">
|
placeholder="Enter API Key...">
|
||||||
<span style={{ fontWeight: 500 }}>DeepSeek API Key</span>
|
<span style={{ fontWeight: 500 }}>DeepSeek API Key</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
@@ -761,14 +755,14 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
value={apiConfiguration?.ollamaBaseUrl || ""}
|
value={apiConfiguration?.ollamaBaseUrl || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
type="url"
|
type="url"
|
||||||
onInput={handleInputChange("ollamaBaseUrl")}
|
onChange={handleInputChange("ollamaBaseUrl")}
|
||||||
placeholder={"Default: http://localhost:11434"}>
|
placeholder={"Default: http://localhost:11434"}>
|
||||||
<span style={{ fontWeight: 500 }}>Base URL (optional)</span>
|
<span style={{ fontWeight: 500 }}>Base URL (optional)</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
<VSCodeTextField
|
<VSCodeTextField
|
||||||
value={apiConfiguration?.ollamaModelId || ""}
|
value={apiConfiguration?.ollamaModelId || ""}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onInput={handleInputChange("ollamaModelId")}
|
onChange={handleInputChange("ollamaModelId")}
|
||||||
placeholder={"e.g. llama3.1"}>
|
placeholder={"e.g. llama3.1"}>
|
||||||
<span style={{ fontWeight: 500 }}>Model ID</span>
|
<span style={{ fontWeight: 500 }}>Model ID</span>
|
||||||
</VSCodeTextField>
|
</VSCodeTextField>
|
||||||
|
|||||||
@@ -167,9 +167,18 @@ const GlamaModelPicker: React.FC = () => {
|
|||||||
placeholder="Search and select a model..."
|
placeholder="Search and select a model..."
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
const newModelId = (e.target as HTMLInputElement)?.value?.toLowerCase()
|
||||||
|
const apiConfig = {
|
||||||
|
...apiConfiguration,
|
||||||
|
openAiModelId: newModelId,
|
||||||
|
}
|
||||||
|
setApiConfiguration(apiConfig)
|
||||||
|
setSearchTerm(newModelId)
|
||||||
setIsDropdownVisible(true)
|
setIsDropdownVisible(true)
|
||||||
}}
|
}}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
||||||
|
}}
|
||||||
onFocus={() => setIsDropdownVisible(true)}
|
onFocus={() => setIsDropdownVisible(true)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
style={{ width: "100%", zIndex: GLAMA_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
style={{ width: "100%", zIndex: GLAMA_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ const OpenAiModelPicker: React.FC = () => {
|
|||||||
}
|
}
|
||||||
setApiConfiguration(apiConfig)
|
setApiConfiguration(apiConfig)
|
||||||
onUpdateApiConfig(apiConfig)
|
onUpdateApiConfig(apiConfig)
|
||||||
|
|
||||||
setSearchTerm(newModelId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -161,9 +159,18 @@ const OpenAiModelPicker: React.FC = () => {
|
|||||||
placeholder="Search and select a model..."
|
placeholder="Search and select a model..."
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
const newModelId = (e.target as HTMLInputElement)?.value?.toLowerCase()
|
||||||
|
const apiConfig = {
|
||||||
|
...apiConfiguration,
|
||||||
|
openAiModelId: newModelId,
|
||||||
|
}
|
||||||
|
setApiConfiguration(apiConfig)
|
||||||
|
setSearchTerm(newModelId)
|
||||||
setIsDropdownVisible(true)
|
setIsDropdownVisible(true)
|
||||||
}}
|
}}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
||||||
|
}}
|
||||||
onFocus={() => setIsDropdownVisible(true)}
|
onFocus={() => setIsDropdownVisible(true)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
style={{ width: "100%", zIndex: OPENAI_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
style={{ width: "100%", zIndex: OPENAI_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
||||||
|
|||||||
@@ -167,9 +167,18 @@ const OpenRouterModelPicker: React.FC = () => {
|
|||||||
placeholder="Search and select a model..."
|
placeholder="Search and select a model..."
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
const newModelId = (e.target as HTMLInputElement)?.value?.toLowerCase()
|
||||||
|
const apiConfig = {
|
||||||
|
...apiConfiguration,
|
||||||
|
openAiModelId: newModelId,
|
||||||
|
}
|
||||||
|
setApiConfiguration(apiConfig)
|
||||||
|
setSearchTerm(newModelId)
|
||||||
setIsDropdownVisible(true)
|
setIsDropdownVisible(true)
|
||||||
}}
|
}}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleModelChange((e.target as HTMLInputElement)?.value?.toLowerCase())
|
||||||
|
}}
|
||||||
onFocus={() => setIsDropdownVisible(true)}
|
onFocus={() => setIsDropdownVisible(true)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
style={{ width: "100%", zIndex: OPENROUTER_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
style={{ width: "100%", zIndex: OPENROUTER_MODEL_PICKER_Z_INDEX, position: "relative" }}>
|
||||||
|
|||||||
@@ -1,20 +1,10 @@
|
|||||||
import {
|
import { VSCodeButton, VSCodeCheckbox, VSCodeLink, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
|
||||||
VSCodeButton,
|
|
||||||
VSCodeCheckbox,
|
|
||||||
VSCodeLink,
|
|
||||||
VSCodeTextArea,
|
|
||||||
VSCodeTextField,
|
|
||||||
} from "@vscode/webview-ui-toolkit/react"
|
|
||||||
import { memo, useEffect, useState } from "react"
|
import { memo, useEffect, useState } from "react"
|
||||||
import { useExtensionState } from "../../context/ExtensionStateContext"
|
import { useExtensionState } from "../../context/ExtensionStateContext"
|
||||||
import { validateApiConfiguration, validateModelId } from "../../utils/validate"
|
import { validateApiConfiguration, validateModelId } from "../../utils/validate"
|
||||||
import { vscode } from "../../utils/vscode"
|
import { vscode } from "../../utils/vscode"
|
||||||
import ApiOptions from "./ApiOptions"
|
import ApiOptions from "./ApiOptions"
|
||||||
import McpEnabledToggle from "../mcp/McpEnabledToggle"
|
|
||||||
import ApiConfigManager from "./ApiConfigManager"
|
import ApiConfigManager from "./ApiConfigManager"
|
||||||
import { Mode } from "../../../../src/shared/modes"
|
|
||||||
|
|
||||||
const IS_DEV = false // FIXME: use flags when packaging
|
|
||||||
|
|
||||||
type SettingsViewProps = {
|
type SettingsViewProps = {
|
||||||
onDone: () => void
|
onDone: () => void
|
||||||
@@ -24,8 +14,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
const {
|
const {
|
||||||
apiConfiguration,
|
apiConfiguration,
|
||||||
version,
|
version,
|
||||||
customInstructions,
|
|
||||||
setCustomInstructions,
|
|
||||||
alwaysAllowReadOnly,
|
alwaysAllowReadOnly,
|
||||||
setAlwaysAllowReadOnly,
|
setAlwaysAllowReadOnly,
|
||||||
alwaysAllowWrite,
|
alwaysAllowWrite,
|
||||||
@@ -50,8 +38,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
allowedCommands,
|
allowedCommands,
|
||||||
fuzzyMatchThreshold,
|
fuzzyMatchThreshold,
|
||||||
setFuzzyMatchThreshold,
|
setFuzzyMatchThreshold,
|
||||||
preferredLanguage,
|
|
||||||
setPreferredLanguage,
|
|
||||||
writeDelayMs,
|
writeDelayMs,
|
||||||
setWriteDelayMs,
|
setWriteDelayMs,
|
||||||
screenshotQuality,
|
screenshotQuality,
|
||||||
@@ -65,8 +51,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
setRequestDelaySeconds,
|
setRequestDelaySeconds,
|
||||||
currentApiConfigName,
|
currentApiConfigName,
|
||||||
listApiConfigMeta,
|
listApiConfigMeta,
|
||||||
mode,
|
|
||||||
setMode,
|
|
||||||
experimentalDiffStrategy,
|
experimentalDiffStrategy,
|
||||||
setExperimentalDiffStrategy,
|
setExperimentalDiffStrategy,
|
||||||
} = useExtensionState()
|
} = useExtensionState()
|
||||||
@@ -85,7 +69,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
type: "apiConfiguration",
|
type: "apiConfiguration",
|
||||||
apiConfiguration,
|
apiConfiguration,
|
||||||
})
|
})
|
||||||
vscode.postMessage({ type: "customInstructions", text: customInstructions })
|
|
||||||
vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly })
|
vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly })
|
||||||
vscode.postMessage({ type: "alwaysAllowWrite", bool: alwaysAllowWrite })
|
vscode.postMessage({ type: "alwaysAllowWrite", bool: alwaysAllowWrite })
|
||||||
vscode.postMessage({ type: "alwaysAllowExecute", bool: alwaysAllowExecute })
|
vscode.postMessage({ type: "alwaysAllowExecute", bool: alwaysAllowExecute })
|
||||||
@@ -97,7 +80,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
vscode.postMessage({ type: "diffEnabled", bool: diffEnabled })
|
vscode.postMessage({ type: "diffEnabled", bool: diffEnabled })
|
||||||
vscode.postMessage({ type: "browserViewportSize", text: browserViewportSize })
|
vscode.postMessage({ type: "browserViewportSize", text: browserViewportSize })
|
||||||
vscode.postMessage({ type: "fuzzyMatchThreshold", value: fuzzyMatchThreshold ?? 1.0 })
|
vscode.postMessage({ type: "fuzzyMatchThreshold", value: fuzzyMatchThreshold ?? 1.0 })
|
||||||
vscode.postMessage({ type: "preferredLanguage", text: preferredLanguage })
|
|
||||||
vscode.postMessage({ type: "writeDelayMs", value: writeDelayMs })
|
vscode.postMessage({ type: "writeDelayMs", value: writeDelayMs })
|
||||||
vscode.postMessage({ type: "screenshotQuality", value: screenshotQuality ?? 75 })
|
vscode.postMessage({ type: "screenshotQuality", value: screenshotQuality ?? 75 })
|
||||||
vscode.postMessage({ type: "terminalOutputLineLimit", value: terminalOutputLineLimit ?? 500 })
|
vscode.postMessage({ type: "terminalOutputLineLimit", value: terminalOutputLineLimit ?? 500 })
|
||||||
@@ -110,7 +92,6 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
text: currentApiConfigName,
|
text: currentApiConfigName,
|
||||||
apiConfiguration,
|
apiConfiguration,
|
||||||
})
|
})
|
||||||
vscode.postMessage({ type: "mode", text: mode })
|
|
||||||
vscode.postMessage({ type: "experimentalDiffStrategy", bool: experimentalDiffStrategy })
|
vscode.postMessage({ type: "experimentalDiffStrategy", bool: experimentalDiffStrategy })
|
||||||
onDone()
|
onDone()
|
||||||
}
|
}
|
||||||
@@ -172,10 +153,9 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style={{ flexGrow: 1, overflowY: "scroll", paddingRight: 8, display: "flex", flexDirection: "column" }}>
|
style={{ flexGrow: 1, overflowY: "scroll", paddingRight: 8, display: "flex", flexDirection: "column" }}>
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 40 }}>
|
||||||
<h3 style={{ color: "var(--vscode-foreground)", margin: 0, marginBottom: 15 }}>
|
<h3 style={{ color: "var(--vscode-foreground)", margin: "0 0 15px 0" }}>Provider Settings</h3>
|
||||||
Provider Settings
|
<div style={{ marginBottom: 15 }}>
|
||||||
</h3>
|
|
||||||
<ApiConfigManager
|
<ApiConfigManager
|
||||||
currentApiConfigName={currentApiConfigName}
|
currentApiConfigName={currentApiConfigName}
|
||||||
listApiConfigMeta={listApiConfigMeta}
|
listApiConfigMeta={listApiConfigMeta}
|
||||||
@@ -208,222 +188,17 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
/>
|
/>
|
||||||
<ApiOptions apiErrorMessage={apiErrorMessage} modelIdErrorMessage={modelIdErrorMessage} />
|
<ApiOptions apiErrorMessage={apiErrorMessage} modelIdErrorMessage={modelIdErrorMessage} />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 40 }}>
|
||||||
<div style={{ marginBottom: 15 }}>
|
<h3 style={{ color: "var(--vscode-foreground)", margin: "0 0 15px 0" }}>Auto-Approve Settings</h3>
|
||||||
<h3 style={{ color: "var(--vscode-foreground)", margin: 0, marginBottom: 15 }}>
|
<p style={{ fontSize: "12px", marginBottom: 15, color: "var(--vscode-descriptionForeground)" }}>
|
||||||
Agent Settings
|
The following settings allow Cline to automatically perform operations without requiring
|
||||||
</h3>
|
approval. Enable these settings only if you fully trust the AI and understand the associated
|
||||||
|
security risks.
|
||||||
|
</p>
|
||||||
|
|
||||||
<div style={{ marginBottom: 15 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
<label style={{ fontWeight: "500", display: "block", marginBottom: 5 }}>Agent Mode</label>
|
|
||||||
<select
|
|
||||||
value={mode}
|
|
||||||
onChange={(e) => {
|
|
||||||
const value = e.target.value as Mode
|
|
||||||
setMode(value)
|
|
||||||
vscode.postMessage({ type: "mode", text: value })
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
padding: "4px 8px",
|
|
||||||
backgroundColor: "var(--vscode-input-background)",
|
|
||||||
color: "var(--vscode-input-foreground)",
|
|
||||||
border: "1px solid var(--vscode-input-border)",
|
|
||||||
borderRadius: "2px",
|
|
||||||
height: "28px",
|
|
||||||
}}>
|
|
||||||
<option value="code">Code</option>
|
|
||||||
<option value="architect">Architect</option>
|
|
||||||
<option value="ask">Ask</option>
|
|
||||||
</select>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginTop: "5px",
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
Select the mode that best fits your needs. Code mode focuses on implementation details,
|
|
||||||
Architect mode on high-level design, and Ask mode on asking questions about the
|
|
||||||
codebase.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label style={{ fontWeight: "500", display: "block", marginBottom: 5 }}>
|
|
||||||
Preferred Language
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
value={preferredLanguage}
|
|
||||||
onChange={(e) => setPreferredLanguage(e.target.value)}
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
padding: "4px 8px",
|
|
||||||
backgroundColor: "var(--vscode-input-background)",
|
|
||||||
color: "var(--vscode-input-foreground)",
|
|
||||||
border: "1px solid var(--vscode-input-border)",
|
|
||||||
borderRadius: "2px",
|
|
||||||
height: "28px",
|
|
||||||
}}>
|
|
||||||
<option value="English">English</option>
|
|
||||||
<option value="Arabic">Arabic - العربية</option>
|
|
||||||
<option value="Brazilian Portuguese">Portuguese - Português (Brasil)</option>
|
|
||||||
<option value="Czech">Czech - Čeština</option>
|
|
||||||
<option value="French">French - Français</option>
|
|
||||||
<option value="German">German - Deutsch</option>
|
|
||||||
<option value="Hindi">Hindi - हिन्दी</option>
|
|
||||||
<option value="Hungarian">Hungarian - Magyar</option>
|
|
||||||
<option value="Italian">Italian - Italiano</option>
|
|
||||||
<option value="Japanese">Japanese - 日本語</option>
|
|
||||||
<option value="Korean">Korean - 한국어</option>
|
|
||||||
<option value="Polish">Polish - Polski</option>
|
|
||||||
<option value="Portuguese">Portuguese - Português (Portugal)</option>
|
|
||||||
<option value="Russian">Russian - Русский</option>
|
|
||||||
<option value="Simplified Chinese">Simplified Chinese - 简体中文</option>
|
|
||||||
<option value="Spanish">Spanish - Español</option>
|
|
||||||
<option value="Traditional Chinese">Traditional Chinese - 繁體中文</option>
|
|
||||||
<option value="Turkish">Turkish - Türkçe</option>
|
|
||||||
</select>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginTop: "5px",
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
Select the language that Cline should use for communication.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ marginBottom: 15 }}>
|
|
||||||
<span style={{ fontWeight: "500" }}>Custom Instructions</span>
|
|
||||||
<VSCodeTextArea
|
|
||||||
value={customInstructions ?? ""}
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
rows={4}
|
|
||||||
placeholder={
|
|
||||||
'e.g. "Run unit tests at the end", "Use TypeScript with async/await", "Speak in Spanish"'
|
|
||||||
}
|
|
||||||
onInput={(e: any) => setCustomInstructions(e.target?.value ?? "")}
|
|
||||||
/>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginTop: "5px",
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
These instructions are added to the end of the system prompt sent with every request. Custom
|
|
||||||
instructions set in .clinerules in the working directory are also included. For
|
|
||||||
mode-specific instructions, use the{" "}
|
|
||||||
<span className="codicon codicon-notebook" style={{ fontSize: "10px" }}></span> Prompts tab
|
|
||||||
in the top menu.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<McpEnabledToggle />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
|
||||||
<span style={{ fontWeight: "500", minWidth: "150px" }}>Terminal output limit</span>
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="100"
|
|
||||||
max="5000"
|
|
||||||
step="100"
|
|
||||||
value={terminalOutputLineLimit ?? 500}
|
|
||||||
onChange={(e) => setTerminalOutputLineLimit(parseInt(e.target.value))}
|
|
||||||
style={{
|
|
||||||
flexGrow: 1,
|
|
||||||
accentColor: "var(--vscode-button-background)",
|
|
||||||
height: "2px",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<span style={{ minWidth: "45px", textAlign: "left" }}>{terminalOutputLineLimit ?? 500}</span>
|
|
||||||
</div>
|
|
||||||
<p style={{ fontSize: "12px", marginTop: "5px", color: "var(--vscode-descriptionForeground)" }}>
|
|
||||||
Maximum number of lines to include in terminal output when executing commands. When exceeded
|
|
||||||
lines will be removed from the middle, saving tokens.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
|
||||||
<VSCodeCheckbox
|
|
||||||
checked={diffEnabled}
|
|
||||||
onChange={(e: any) => {
|
|
||||||
setDiffEnabled(e.target.checked)
|
|
||||||
if (!e.target.checked) {
|
|
||||||
// Reset experimental strategy when diffs are disabled
|
|
||||||
setExperimentalDiffStrategy(false)
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<span style={{ fontWeight: "500" }}>Enable editing through diffs</span>
|
|
||||||
</VSCodeCheckbox>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginTop: "5px",
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
When enabled, Cline will be able to edit files more quickly and will automatically reject
|
|
||||||
truncated full-file writes. Works best with the latest Claude 3.5 Sonnet model.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{diffEnabled && (
|
|
||||||
<div style={{ marginTop: 10 }}>
|
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
|
||||||
<span style={{ color: "var(--vscode-errorForeground)" }}>⚠️</span>
|
|
||||||
<VSCodeCheckbox
|
|
||||||
checked={experimentalDiffStrategy}
|
|
||||||
onChange={(e: any) => setExperimentalDiffStrategy(e.target.checked)}>
|
|
||||||
<span style={{ fontWeight: "500" }}>Use experimental unified diff strategy</span>
|
|
||||||
</VSCodeCheckbox>
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginBottom: 15,
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
Enable the experimental unified diff strategy. This strategy might reduce the number of
|
|
||||||
retries caused by model errors but may cause unexpected behavior or incorrect edits.
|
|
||||||
Only enable if you understand the risks and are willing to carefully review all changes.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
|
||||||
<span style={{ fontWeight: "500", minWidth: "100px" }}>Match precision</span>
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min="0.8"
|
|
||||||
max="1"
|
|
||||||
step="0.005"
|
|
||||||
value={fuzzyMatchThreshold ?? 1.0}
|
|
||||||
onChange={(e) => {
|
|
||||||
setFuzzyMatchThreshold(parseFloat(e.target.value))
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
flexGrow: 1,
|
|
||||||
accentColor: "var(--vscode-button-background)",
|
|
||||||
height: "2px",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<span style={{ minWidth: "35px", textAlign: "left" }}>
|
|
||||||
{Math.round((fuzzyMatchThreshold || 1) * 100)}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
style={{
|
|
||||||
fontSize: "12px",
|
|
||||||
marginTop: "5px",
|
|
||||||
color: "var(--vscode-descriptionForeground)",
|
|
||||||
}}>
|
|
||||||
This slider controls how precisely code sections must match when applying diffs. Lower
|
|
||||||
values allow more flexible matching but increase the risk of incorrect replacements. Use
|
|
||||||
values below 100% with extreme caution.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
|
||||||
<VSCodeCheckbox
|
<VSCodeCheckbox
|
||||||
checked={alwaysAllowReadOnly}
|
checked={alwaysAllowReadOnly}
|
||||||
onChange={(e: any) => setAlwaysAllowReadOnly(e.target.checked)}>
|
onChange={(e: any) => setAlwaysAllowReadOnly(e.target.checked)}>
|
||||||
@@ -435,28 +210,12 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
marginTop: "5px",
|
marginTop: "5px",
|
||||||
color: "var(--vscode-descriptionForeground)",
|
color: "var(--vscode-descriptionForeground)",
|
||||||
}}>
|
}}>
|
||||||
When enabled, Cline will automatically view directory contents and read files without requiring
|
When enabled, Cline will automatically view directory contents and read files without
|
||||||
you to click the Approve button.
|
requiring you to click the Approve button.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div style={{ marginBottom: 15 }}>
|
||||||
style={{
|
|
||||||
marginBottom: 15,
|
|
||||||
border: "2px solid var(--vscode-errorForeground)",
|
|
||||||
borderRadius: "4px",
|
|
||||||
padding: "10px",
|
|
||||||
}}>
|
|
||||||
<h4 style={{ fontWeight: 500, margin: "0 0 10px 0", color: "var(--vscode-errorForeground)" }}>
|
|
||||||
⚠️ High-Risk Auto-Approve Settings
|
|
||||||
</h4>
|
|
||||||
<p style={{ fontSize: "12px", marginBottom: 15, color: "var(--vscode-descriptionForeground)" }}>
|
|
||||||
The following settings allow Cline to automatically perform potentially dangerous operations
|
|
||||||
without requiring approval. Enable these settings only if you fully trust the AI and understand
|
|
||||||
the associated security risks.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
|
||||||
<VSCodeCheckbox
|
<VSCodeCheckbox
|
||||||
checked={alwaysAllowWrite}
|
checked={alwaysAllowWrite}
|
||||||
onChange={(e: any) => setAlwaysAllowWrite(e.target.checked)}>
|
onChange={(e: any) => setAlwaysAllowWrite(e.target.checked)}>
|
||||||
@@ -495,7 +254,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
<VSCodeCheckbox
|
<VSCodeCheckbox
|
||||||
checked={alwaysAllowBrowser}
|
checked={alwaysAllowBrowser}
|
||||||
onChange={(e: any) => setAlwaysAllowBrowser(e.target.checked)}>
|
onChange={(e: any) => setAlwaysAllowBrowser(e.target.checked)}>
|
||||||
@@ -508,7 +267,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
<VSCodeCheckbox
|
<VSCodeCheckbox
|
||||||
checked={alwaysApproveResubmit}
|
checked={alwaysApproveResubmit}
|
||||||
onChange={(e: any) => setAlwaysApproveResubmit(e.target.checked)}>
|
onChange={(e: any) => setAlwaysApproveResubmit(e.target.checked)}>
|
||||||
@@ -559,7 +318,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
<VSCodeCheckbox
|
<VSCodeCheckbox
|
||||||
checked={alwaysAllowExecute}
|
checked={alwaysAllowExecute}
|
||||||
onChange={(e: any) => setAlwaysAllowExecute(e.target.checked)}>
|
onChange={(e: any) => setAlwaysAllowExecute(e.target.checked)}>
|
||||||
@@ -652,15 +411,10 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 40 }}>
|
||||||
<div style={{ marginBottom: 10 }}>
|
<h3 style={{ color: "var(--vscode-foreground)", margin: "0 0 15px 0" }}>Browser Settings</h3>
|
||||||
<div style={{ marginBottom: 15 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
<h3 style={{ color: "var(--vscode-foreground)", margin: 0, marginBottom: 15 }}>
|
<label style={{ fontWeight: "500", display: "block", marginBottom: 5 }}>Viewport size</label>
|
||||||
Browser Settings
|
|
||||||
</h3>
|
|
||||||
<label style={{ fontWeight: "500", display: "block", marginBottom: 5 }}>
|
|
||||||
Viewport size
|
|
||||||
</label>
|
|
||||||
<select
|
<select
|
||||||
value={browserViewportSize}
|
value={browserViewportSize}
|
||||||
onChange={(e) => setBrowserViewportSize(e.target.value)}
|
onChange={(e) => setBrowserViewportSize(e.target.value)}
|
||||||
@@ -684,8 +438,8 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
marginTop: "5px",
|
marginTop: "5px",
|
||||||
color: "var(--vscode-descriptionForeground)",
|
color: "var(--vscode-descriptionForeground)",
|
||||||
}}>
|
}}>
|
||||||
Select the viewport size for browser interactions. This affects how websites are
|
Select the viewport size for browser interactions. This affects how websites are displayed
|
||||||
displayed and interacted with.
|
and interacted with.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -713,20 +467,16 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
marginTop: "5px",
|
marginTop: "5px",
|
||||||
color: "var(--vscode-descriptionForeground)",
|
color: "var(--vscode-descriptionForeground)",
|
||||||
}}>
|
}}>
|
||||||
Adjust the WebP quality of browser screenshots. Higher values provide clearer
|
Adjust the WebP quality of browser screenshots. Higher values provide clearer screenshots
|
||||||
screenshots but increase token usage.
|
but increase token usage.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: 5 }}>
|
<div style={{ marginBottom: 40 }}>
|
||||||
<div style={{ marginBottom: 10 }}>
|
<h3 style={{ color: "var(--vscode-foreground)", margin: "0 0 15px 0" }}>Notification Settings</h3>
|
||||||
<h3 style={{ color: "var(--vscode-foreground)", margin: 0, marginBottom: 15 }}>
|
<div style={{ marginBottom: 15 }}>
|
||||||
Notification Settings
|
<VSCodeCheckbox checked={soundEnabled} onChange={(e: any) => setSoundEnabled(e.target.checked)}>
|
||||||
</h3>
|
|
||||||
<VSCodeCheckbox
|
|
||||||
checked={soundEnabled}
|
|
||||||
onChange={(e: any) => setSoundEnabled(e.target.checked)}>
|
|
||||||
<span style={{ fontWeight: "500" }}>Enable sound effects</span>
|
<span style={{ fontWeight: "500" }}>Enable sound effects</span>
|
||||||
</VSCodeCheckbox>
|
</VSCodeCheckbox>
|
||||||
<p
|
<p
|
||||||
@@ -763,24 +513,116 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style={{ marginBottom: 40 }}>
|
||||||
|
<h3 style={{ color: "var(--vscode-foreground)", margin: "0 0 15px 0" }}>Advanced Settings</h3>
|
||||||
|
<div style={{ marginBottom: 15 }}>
|
||||||
|
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
||||||
|
<span style={{ fontWeight: "500", minWidth: "150px" }}>Terminal output limit</span>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="100"
|
||||||
|
max="5000"
|
||||||
|
step="100"
|
||||||
|
value={terminalOutputLineLimit ?? 500}
|
||||||
|
onChange={(e) => setTerminalOutputLineLimit(parseInt(e.target.value))}
|
||||||
|
style={{
|
||||||
|
flexGrow: 1,
|
||||||
|
accentColor: "var(--vscode-button-background)",
|
||||||
|
height: "2px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span style={{ minWidth: "45px", textAlign: "left" }}>
|
||||||
|
{terminalOutputLineLimit ?? 500}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p style={{ fontSize: "12px", marginTop: "5px", color: "var(--vscode-descriptionForeground)" }}>
|
||||||
|
Maximum number of lines to include in terminal output when executing commands. When exceeded
|
||||||
|
lines will be removed from the middle, saving tokens.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{IS_DEV && (
|
<div style={{ marginBottom: 15 }}>
|
||||||
<>
|
<VSCodeCheckbox
|
||||||
<div style={{ marginTop: "10px", marginBottom: "4px" }}>Debug</div>
|
checked={diffEnabled}
|
||||||
<VSCodeButton onClick={handleResetState} style={{ marginTop: "5px", width: "auto" }}>
|
onChange={(e: any) => {
|
||||||
Reset State
|
setDiffEnabled(e.target.checked)
|
||||||
</VSCodeButton>
|
if (!e.target.checked) {
|
||||||
|
// Reset experimental strategy when diffs are disabled
|
||||||
|
setExperimentalDiffStrategy(false)
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<span style={{ fontWeight: "500" }}>Enable editing through diffs</span>
|
||||||
|
</VSCodeCheckbox>
|
||||||
<p
|
<p
|
||||||
style={{
|
style={{
|
||||||
fontSize: "12px",
|
fontSize: "12px",
|
||||||
marginTop: "5px",
|
marginTop: "5px",
|
||||||
color: "var(--vscode-descriptionForeground)",
|
color: "var(--vscode-descriptionForeground)",
|
||||||
}}>
|
}}>
|
||||||
This will reset all global state and secret storage in the extension.
|
When enabled, Cline will be able to edit files more quickly and will automatically reject
|
||||||
|
truncated full-file writes. Works best with the latest Claude 3.5 Sonnet model.
|
||||||
</p>
|
</p>
|
||||||
</>
|
|
||||||
|
{diffEnabled && (
|
||||||
|
<div style={{ marginTop: 10 }}>
|
||||||
|
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
||||||
|
<span style={{ color: "var(--vscode-errorForeground)" }}>⚠️</span>
|
||||||
|
<VSCodeCheckbox
|
||||||
|
checked={experimentalDiffStrategy}
|
||||||
|
onChange={(e: any) => setExperimentalDiffStrategy(e.target.checked)}>
|
||||||
|
<span style={{ fontWeight: "500" }}>
|
||||||
|
Use experimental unified diff strategy
|
||||||
|
</span>
|
||||||
|
</VSCodeCheckbox>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: "12px",
|
||||||
|
marginBottom: 15,
|
||||||
|
color: "var(--vscode-descriptionForeground)",
|
||||||
|
}}>
|
||||||
|
Enable the experimental unified diff strategy. This strategy might reduce the number
|
||||||
|
of retries caused by model errors but may cause unexpected behavior or incorrect
|
||||||
|
edits. Only enable if you understand the risks and are willing to carefully review
|
||||||
|
all changes.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
|
||||||
|
<span style={{ fontWeight: "500", minWidth: "100px" }}>Match precision</span>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="0.8"
|
||||||
|
max="1"
|
||||||
|
step="0.005"
|
||||||
|
value={fuzzyMatchThreshold ?? 1.0}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFuzzyMatchThreshold(parseFloat(e.target.value))
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
flexGrow: 1,
|
||||||
|
accentColor: "var(--vscode-button-background)",
|
||||||
|
height: "2px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span style={{ minWidth: "35px", textAlign: "left" }}>
|
||||||
|
{Math.round((fuzzyMatchThreshold || 1) * 100)}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: "12px",
|
||||||
|
marginTop: "5px",
|
||||||
|
color: "var(--vscode-descriptionForeground)",
|
||||||
|
}}>
|
||||||
|
This slider controls how precisely code sections must match when applying diffs.
|
||||||
|
Lower values allow more flexible matching but increase the risk of incorrect
|
||||||
|
replacements. Use values below 100% with extreme caution.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -801,7 +643,25 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
|
|||||||
reddit.com/r/roocline
|
reddit.com/r/roocline
|
||||||
</VSCodeLink>
|
</VSCodeLink>
|
||||||
</p>
|
</p>
|
||||||
<p style={{ fontStyle: "italic", margin: "10px 0 0 0", padding: 0 }}>v{version}</p>
|
<p style={{ fontStyle: "italic", margin: "10px 0 0 0", padding: 0, marginBottom: 100 }}>
|
||||||
|
v{version}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: "12px",
|
||||||
|
marginTop: "5px",
|
||||||
|
color: "var(--vscode-descriptionForeground)",
|
||||||
|
}}>
|
||||||
|
This will reset all global state and secret storage in the extension.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<VSCodeButton
|
||||||
|
onClick={handleResetState}
|
||||||
|
appearance="secondary"
|
||||||
|
style={{ marginTop: "5px", width: "auto" }}>
|
||||||
|
Reset State
|
||||||
|
</VSCodeButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export interface ExtensionStateContextType extends ExtensionState {
|
|||||||
setExperimentalDiffStrategy: (value: boolean) => void
|
setExperimentalDiffStrategy: (value: boolean) => void
|
||||||
autoApprovalEnabled?: boolean
|
autoApprovalEnabled?: boolean
|
||||||
setAutoApprovalEnabled: (value: boolean) => void
|
setAutoApprovalEnabled: (value: boolean) => void
|
||||||
|
handleInputChange: (field: keyof ApiConfiguration) => (event: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
|
export const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
|
||||||
@@ -112,18 +113,32 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
|
|||||||
|
|
||||||
const setListApiConfigMeta = useCallback(
|
const setListApiConfigMeta = useCallback(
|
||||||
(value: ApiConfigMeta[]) => setState((prevState) => ({ ...prevState, listApiConfigMeta: value })),
|
(value: ApiConfigMeta[]) => setState((prevState) => ({ ...prevState, listApiConfigMeta: value })),
|
||||||
[setState],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onUpdateApiConfig = useCallback(
|
const onUpdateApiConfig = useCallback((apiConfig: ApiConfiguration) => {
|
||||||
(apiConfig: ApiConfiguration) => {
|
setState((currentState) => {
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
type: "upsertApiConfiguration",
|
type: "upsertApiConfiguration",
|
||||||
text: state.currentApiConfigName,
|
text: currentState.currentApiConfigName,
|
||||||
apiConfiguration: apiConfig,
|
apiConfiguration: apiConfig,
|
||||||
})
|
})
|
||||||
|
return currentState // No state update needed
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleInputChange = useCallback(
|
||||||
|
(field: keyof ApiConfiguration) => (event: any) => {
|
||||||
|
setState((currentState) => {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: "upsertApiConfiguration",
|
||||||
|
text: currentState.currentApiConfigName,
|
||||||
|
apiConfiguration: { ...currentState.apiConfiguration, [field]: event.target.value },
|
||||||
|
})
|
||||||
|
return currentState // No state update needed
|
||||||
|
})
|
||||||
},
|
},
|
||||||
[state],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleMessage = useCallback(
|
const handleMessage = useCallback(
|
||||||
@@ -258,6 +273,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
|
|||||||
setExperimentalDiffStrategy: (value) =>
|
setExperimentalDiffStrategy: (value) =>
|
||||||
setState((prevState) => ({ ...prevState, experimentalDiffStrategy: value })),
|
setState((prevState) => ({ ...prevState, experimentalDiffStrategy: value })),
|
||||||
setAutoApprovalEnabled: (value) => setState((prevState) => ({ ...prevState, autoApprovalEnabled: value })),
|
setAutoApprovalEnabled: (value) => setState((prevState) => ({ ...prevState, autoApprovalEnabled: value })),
|
||||||
|
handleInputChange,
|
||||||
}
|
}
|
||||||
|
|
||||||
return <ExtensionStateContext.Provider value={contextValue}>{children}</ExtensionStateContext.Provider>
|
return <ExtensionStateContext.Provider value={contextValue}>{children}</ExtensionStateContext.Provider>
|
||||||
|
|||||||
Reference in New Issue
Block a user