Merge pull request #16 from RooVetGit/merge/latestCline1122

Updating Roo-Cline with the latest cline/cline (11/22)
This commit is contained in:
John Stearns
2024-11-22 15:40:43 -08:00
committed by GitHub
67 changed files with 22904 additions and 22914 deletions

View File

@@ -5,9 +5,7 @@
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
@@ -23,9 +21,5 @@
"semi": "off",
"react-hooks/exhaustive-deps": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}

View File

@@ -2,3 +2,4 @@ dist/
node_modules
webview-ui/build/
CHANGELOG.md
package-lock.json

View File

@@ -3,5 +3,5 @@
"useTabs": true,
"printWidth": 120,
"semi": false,
"jsxBracketSameLine": true
"bracketSameLine": true
}

View File

@@ -1,5 +1,5 @@
import { defineConfig } from '@vscode/test-cli';
import { defineConfig } from "@vscode/test-cli"
export default defineConfig({
files: 'out/test/**/*.test.js',
});
files: "out/test/**/*.test.js",
})

View File

@@ -1,5 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
"recommendations": [
"dbaeumer.vscode-eslint",
"connor4312.esbuild-problem-matchers",
"ms-vscode.extension-test-runner"
]
}

8
.vscode/launch.json vendored
View File

@@ -9,12 +9,8 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]

11
.vscode/tasks.json vendored
View File

@@ -5,11 +5,7 @@
"tasks": [
{
"label": "watch",
"dependsOn": [
"npm: build:webview",
"npm: watch:tsc",
"npm: watch:esbuild"
],
"dependsOn": ["npm: build:webview", "npm: watch:tsc", "npm: watch:esbuild"],
"presentation": {
"reveal": "never"
},
@@ -67,10 +63,7 @@
},
{
"label": "tasks: watch-tests",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
],
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
}
]

Binary file not shown.

View File

@@ -2,7 +2,7 @@
"name": "roo-cline",
"displayName": "Roo Cline",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, running commands, using the browser, and more with your permission every step of the way.",
"version": "2.0.3",
"version": "2.1.0",
"files": [
"bin/roo-cline-2.0.3.vsix",
"assets/icons/icon_Roo.png"

View File

@@ -36,7 +36,7 @@ export class AnthropicHandler implements ApiHandler {
*/
const userMsgIndices = messages.reduce(
(acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc),
[] as number[]
[] as number[],
)
const lastUserMsgIndex = userMsgIndices[userMsgIndices.length - 1] ?? -1
const secondLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 2] ?? -1
@@ -62,7 +62,7 @@ export class AnthropicHandler implements ApiHandler {
: message.content.map((content, contentIndex) =>
contentIndex === message.content.length - 1
? { ...content, cache_control: { type: "ephemeral" } }
: content
: content,
),
}
}
@@ -88,7 +88,7 @@ export class AnthropicHandler implements ApiHandler {
default:
return undefined
}
})()
})(),
)
break
}

View File

@@ -42,7 +42,7 @@ export class LmStudioHandler implements ApiHandler {
} catch (error) {
// LM Studio doesn't return an error code/body for now
throw new Error(
"Please check the LM Studio developer logs to debug what went wrong. You may need to load the model with a larger context length to work with Cline's prompts."
"Please check the LM Studio developer logs to debug what went wrong. You may need to load the model with a larger context length to work with Cline's prompts.",
)
}
}

View File

@@ -19,7 +19,7 @@ export function convertAnthropicContentToGemini(
| Anthropic.Messages.ImageBlockParam
| Anthropic.Messages.ToolUseBlockParam
| Anthropic.Messages.ToolResultBlockParam
>
>,
): Part[] {
if (typeof content === "string") {
return [{ text: content } as TextPart]
@@ -83,7 +83,7 @@ export function convertAnthropicContentToGemini(
data: part.source.data,
mimeType: part.source.media_type,
},
} as InlineDataPart)
}) as InlineDataPart,
),
]
}
@@ -113,7 +113,7 @@ export function convertAnthropicToolToGemini(tool: Anthropic.Messages.Tool): Fun
type: (value as any).type.toUpperCase(),
description: (value as any).description || "",
},
])
]),
),
required: (tool.input_schema.required as string[]) || [],
},
@@ -133,7 +133,7 @@ export function unescapeGeminiContent(content: string) {
}
export function convertGeminiResponseToAnthropic(
response: EnhancedGenerateContentResponse
response: EnhancedGenerateContentResponse,
): Anthropic.Messages.Message {
const content: Anthropic.Messages.ContentBlock[] = []

View File

@@ -167,7 +167,7 @@ I've analyzed the project structure, but I need more information to proceed. Let
export function convertToO1Messages(
openAiMessages: OpenAI.Chat.ChatCompletionMessageParam[],
systemPrompt: string
systemPrompt: string,
): OpenAI.Chat.ChatCompletionMessageParam[] {
const toolsReplaced = openAiMessages.reduce((acc, message) => {
if (message.role === "tool") {
@@ -360,7 +360,7 @@ function validateToolInput(toolName: string, tool_input: Record<string, string>)
// Convert OpenAI response to Anthropic format
export function convertO1ResponseToAnthropicMessage(
completion: OpenAI.Chat.Completions.ChatCompletion
completion: OpenAI.Chat.Completions.ChatCompletion,
): Anthropic.Messages.Message {
const openAiMessage = completion.choices[0].message
const { normalText, toolCalls } = parseAIResponse(openAiMessage.content || "")
@@ -405,7 +405,7 @@ export function convertO1ResponseToAnthropicMessage(
name: toolCall.tool,
input: toolCall.tool_input,
}
})
}),
)
}

View File

@@ -2,7 +2,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
import OpenAI from "openai"
export function convertToOpenAiMessages(
anthropicMessages: Anthropic.Messages.MessageParam[]
anthropicMessages: Anthropic.Messages.MessageParam[],
): OpenAI.Chat.ChatCompletionMessageParam[] {
const openAiMessages: OpenAI.Chat.ChatCompletionMessageParam[] = []
@@ -31,7 +31,7 @@ export function convertToOpenAiMessages(
} // user cannot send tool_use messages
return acc
},
{ nonToolMessages: [], toolMessages: [] }
{ nonToolMessages: [], toolMessages: [] },
)
// Process tool result messages FIRST since they must follow the tool use messages
@@ -105,7 +105,7 @@ export function convertToOpenAiMessages(
} // assistant cannot send tool_result messages
return acc
},
{ nonToolMessages: [], toolMessages: [] }
{ nonToolMessages: [], toolMessages: [] },
)
// Process non-tool messages
@@ -147,7 +147,7 @@ export function convertToOpenAiMessages(
// Convert OpenAI response to Anthropic format
export function convertToAnthropicMessage(
completion: OpenAI.Chat.Completions.ChatCompletion
completion: OpenAI.Chat.Completions.ChatCompletion,
): Anthropic.Messages.Message {
const openAiMessage = completion.choices[0].message
const anthropicMessage: Anthropic.Messages.Message = {
@@ -196,7 +196,7 @@ export function convertToAnthropicMessage(
name: toolCall.function.name,
input: parsedInput,
}
})
}),
)
}
return anthropicMessage

View File

@@ -113,7 +113,7 @@ export class Cline {
alwaysAllowBrowser?: boolean,
task?: string,
images?: string[],
historyItem?: HistoryItem
historyItem?: HistoryItem,
) {
this.providerRef = new WeakRef(provider)
this.api = buildApiHandler(apiConfiguration)
@@ -235,7 +235,7 @@ export class Cline {
this.clineMessages[
findLastIndex(
this.clineMessages,
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task")
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task"),
)
]
await this.providerRef.deref()?.updateTaskHistory({
@@ -259,7 +259,7 @@ export class Cline {
async ask(
type: ClineAsk,
text?: string,
partial?: boolean
partial?: boolean,
): Promise<{ response: ClineAskResponse; text?: string; images?: string[] }> {
// If this Cline instance was aborted by the provider, then the only thing keeping us alive is a promise still running in the background, in which case we don't want to send its result to the webview as it is attached to a new instance of Cline now. So we can safely ignore the result of any active promises, and this class will be deallocated. (Although we set Cline = undefined in provider, that simply removes the reference to this instance, but the instance is still alive until this promise resolves or rejects.)
if (this.abort) {
@@ -420,7 +420,7 @@ export class Cline {
"error",
`Cline tried to use ${toolName}${
relPath ? ` for '${relPath.toPosix()}'` : ""
} without value for required parameter '${paramName}'. Retrying...`
} without value for required parameter '${paramName}'. Retrying...`,
)
return formatResponse.toolError(formatResponse.missingToolParameterError(paramName))
}
@@ -452,7 +452,7 @@ export class Cline {
// Remove any resume messages that may have been added before
const lastRelevantMessageIndex = findLastIndex(
modifiedClineMessages,
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task")
(m) => !(m.ask === "resume_task" || m.ask === "resume_completed_task"),
)
if (lastRelevantMessageIndex !== -1) {
modifiedClineMessages.splice(lastRelevantMessageIndex + 1)
@@ -461,7 +461,7 @@ export class Cline {
// since we don't use api_req_finished anymore, we need to check if the last api_req_started has a cost value, if it doesn't and no cancellation reason to present, then we remove it since it indicates an api request without any partial content streamed
const lastApiReqStartedIndex = findLastIndex(
modifiedClineMessages,
(m) => m.type === "say" && m.say === "api_req_started"
(m) => m.type === "say" && m.say === "api_req_started",
)
if (lastApiReqStartedIndex !== -1) {
const lastApiReqStarted = modifiedClineMessages[lastApiReqStartedIndex]
@@ -566,7 +566,7 @@ export class Cline {
if (hasToolUse) {
const toolUseBlocks = content.filter(
(block) => block.type === "tool_use"
(block) => block.type === "tool_use",
) as Anthropic.Messages.ToolUseBlock[]
const toolResponses: Anthropic.ToolResultBlockParam[] = toolUseBlocks.map((block) => ({
type: "tool_result",
@@ -592,17 +592,17 @@ export class Cline {
: [{ type: "text", text: previousAssistantMessage.content }]
const toolUseBlocks = assistantContent.filter(
(block) => block.type === "tool_use"
(block) => block.type === "tool_use",
) as Anthropic.Messages.ToolUseBlock[]
if (toolUseBlocks.length > 0) {
const existingToolResults = existingUserContent.filter(
(block) => block.type === "tool_result"
(block) => block.type === "tool_result",
) as Anthropic.ToolResultBlockParam[]
const missingToolResponses: Anthropic.ToolResultBlockParam[] = toolUseBlocks
.filter(
(toolUse) => !existingToolResults.some((result) => result.tool_use_id === toolUse.id)
(toolUse) => !existingToolResults.some((result) => result.tool_use_id === toolUse.id),
)
.map((toolUse) => ({
type: "tool_result",
@@ -772,7 +772,7 @@ export class Cline {
`Command is still running in the user's terminal.${
result.length > 0 ? `\nHere's the output so far:\n${result}` : ""
}\n\nThe user provided the following feedback:\n<feedback>\n${userFeedback.text}\n</feedback>`,
userFeedback.images
userFeedback.images,
),
]
}
@@ -797,7 +797,7 @@ export class Cline {
const previousRequest = this.clineMessages[previousApiReqIndex]
if (previousRequest && previousRequest.text) {
const { tokensIn, tokensOut, cacheWrites, cacheReads }: ClineApiReqInfo = JSON.parse(
previousRequest.text
previousRequest.text,
)
const totalTokens = (tokensIn || 0) + (tokensOut || 0) + (cacheWrites || 0) + (cacheReads || 0)
const contextWindow = this.api.getModel().info.contextWindow || 128_000
@@ -820,7 +820,7 @@ export class Cline {
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
const { response } = await this.ask(
"api_req_failed",
error.message ?? JSON.stringify(serializeError(error), null, 2)
error.message ?? JSON.stringify(serializeError(error), null, 2),
)
if (response !== "yesButtonClicked") {
// this will never happen since if noButtonClicked, we will clear current task, aborting this instance
@@ -983,7 +983,7 @@ export class Cline {
if (response === "messageResponse") {
await this.say("user_feedback", text, images)
pushToolResult(
formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images)
formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images),
)
// this.userMessageContent.push({
// type: "text",
@@ -1016,7 +1016,7 @@ export class Cline {
const errorString = `Error ${action}: ${JSON.stringify(serializeError(error))}`
await this.say(
"error",
`Error ${action}:\n${error.message ?? JSON.stringify(serializeError(error), null, 2)}`
`Error ${action}:\n${error.message ?? JSON.stringify(serializeError(error), null, 2)}`,
)
// this.toolResults.push({
// type: "tool_result",
@@ -1042,7 +1042,7 @@ export class Cline {
.split("")
.map((char) => `(?:${char})?`)
.join("")}$`,
"g"
"g",
)
return text.replace(tagRegex, "")
}
@@ -1154,7 +1154,7 @@ export class Cline {
? formatResponse.createPrettyPatch(
relPath,
this.diffViewProvider.originalContent,
newContent
newContent,
)
: undefined,
} satisfies ClineSayTool)
@@ -1173,7 +1173,7 @@ export class Cline {
tool: fileExists ? "editedExistingFile" : "newFileCreated",
path: getReadablePath(cwd, relPath),
diff: userEdits,
} satisfies ClineSayTool)
} satisfies ClineSayTool),
)
pushToolResult(
`The user made the following updates to your content:\n\n${userEdits}\n\n` +
@@ -1183,11 +1183,11 @@ export class Cline {
`1. You do not need to re-write the file with these changes, as they have already been applied.\n` +
`2. Proceed with the task using this updated file content as the new baseline.\n` +
`3. If the user's edits have addressed part of the task or changed the requirements, adjust your approach accordingly.` +
`${newProblemsMessage}`
`${newProblemsMessage}`,
)
} else {
pushToolResult(
`The content was successfully saved to ${relPath.toPosix()}.${newProblemsMessage}`
`The content was successfully saved to ${relPath.toPosix()}.${newProblemsMessage}`,
)
}
await this.diffViewProvider.reset()
@@ -1319,7 +1319,7 @@ export class Cline {
if (!relDirPath) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("list_code_definition_names", "path")
await this.sayAndCreateMissingParamError("list_code_definition_names", "path"),
)
break
}
@@ -1448,7 +1448,7 @@ export class Cline {
text: removeClosingTag("text", text),
} satisfies ClineSayBrowserAction),
undefined,
block.partial
block.partial,
)
}
break
@@ -1458,7 +1458,7 @@ export class Cline {
if (!url) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("browser_action", "url")
await this.sayAndCreateMissingParamError("browser_action", "url"),
)
await this.browserSession.closeBrowser()
break
@@ -1480,7 +1480,10 @@ export class Cline {
if (!coordinate) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("browser_action", "coordinate")
await this.sayAndCreateMissingParamError(
"browser_action",
"coordinate",
),
)
await this.browserSession.closeBrowser()
break // can't be within an inner switch
@@ -1490,7 +1493,7 @@ export class Cline {
if (!text) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("browser_action", "text")
await this.sayAndCreateMissingParamError("browser_action", "text"),
)
await this.browserSession.closeBrowser()
break
@@ -1505,7 +1508,7 @@ export class Cline {
text,
} satisfies ClineSayBrowserAction),
undefined,
false
false,
)
switch (action) {
case "click":
@@ -1538,15 +1541,15 @@ export class Cline {
`The browser action has been executed. The console logs and screenshot have been captured for your analysis.\n\nConsole logs:\n${
browserActionResult.logs || "(No new logs)"
}\n\n(REMEMBER: if you need to proceed to using non-\`browser_action\` tools or launch a new browser, you MUST first close this browser. For example, if after analyzing the logs and screenshot you need to edit a file, you must first close the browser before you can use the write_to_file tool.)`,
browserActionResult.screenshot ? [browserActionResult.screenshot] : []
)
browserActionResult.screenshot ? [browserActionResult.screenshot] : [],
),
)
break
case "close":
pushToolResult(
formatResponse.toolResult(
`The browser has been closed. You may now proceed to using other tools.`
)
`The browser has been closed. You may now proceed to using other tools.`,
),
)
break
}
@@ -1574,7 +1577,7 @@ export class Cline {
if (!command) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("execute_command", "command")
await this.sayAndCreateMissingParamError("execute_command", "command"),
)
break
}
@@ -1603,14 +1606,14 @@ export class Cline {
try {
if (block.partial) {
await this.ask("followup", removeClosingTag("question", question), block.partial).catch(
() => {}
() => {},
)
break
} else {
if (!question) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("ask_followup_question", "question")
await this.sayAndCreateMissingParamError("ask_followup_question", "question"),
)
break
}
@@ -1661,7 +1664,7 @@ export class Cline {
await this.ask(
"command",
removeClosingTag("command", command),
block.partial
block.partial,
).catch(() => {})
} else {
// last message is completion_result
@@ -1670,12 +1673,12 @@ export class Cline {
"completion_result",
removeClosingTag("result", result),
undefined,
false
false,
)
await this.ask(
"command",
removeClosingTag("command", command),
block.partial
block.partial,
).catch(() => {})
}
} else {
@@ -1684,7 +1687,7 @@ export class Cline {
"completion_result",
removeClosingTag("result", result),
undefined,
block.partial
block.partial,
)
}
break
@@ -1692,7 +1695,7 @@ export class Cline {
if (!result) {
this.consecutiveMistakeCount++
pushToolResult(
await this.sayAndCreateMissingParamError("attempt_completion", "result")
await this.sayAndCreateMissingParamError("attempt_completion", "result"),
)
break
}
@@ -1793,7 +1796,7 @@ export class Cline {
async recursivelyMakeClineRequests(
userContent: UserContent,
includeFileDetails: boolean = false
includeFileDetails: boolean = false,
): Promise<boolean> {
if (this.abort) {
throw new Error("Cline instance aborted")
@@ -1804,7 +1807,7 @@ export class Cline {
"mistake_limit_reached",
this.api.getModel().id.includes("claude")
? `This may indicate a failure in his thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. "Try breaking down the task into smaller steps").`
: "Cline uses complex prompts and iterative task execution that may be challenging for less capable models. For best results, it's recommended to use Claude 3.5 Sonnet for its advanced agentic coding capabilities."
: "Cline uses complex prompts and iterative task execution that may be challenging for less capable models. For best results, it's recommended to use Claude 3.5 Sonnet for its advanced agentic coding capabilities.",
)
if (response === "messageResponse") {
userContent.push(
@@ -1814,7 +1817,7 @@ export class Cline {
text: formatResponse.tooManyMistakes(text),
} as Anthropic.Messages.TextBlockParam,
...formatResponse.imageBlocks(images),
]
],
)
}
this.consecutiveMistakeCount = 0
@@ -1830,7 +1833,7 @@ export class Cline {
JSON.stringify({
request:
userContent.map((block) => formatContentBlockToMarkdown(block)).join("\n\n") + "\n\nLoading...",
})
}),
)
const [parsedUserContent, environmentDetails] = await this.loadContext(userContent, includeFileDetails)
@@ -1872,7 +1875,7 @@ export class Cline {
inputTokens,
outputTokens,
cacheWriteTokens,
cacheReadTokens
cacheReadTokens,
),
cancelReason,
streamingFailedMessage,
@@ -1986,7 +1989,7 @@ export class Cline {
this.abortTask() // if the stream failed, there's various states the task could be in (i.e. could have streamed some tools the user may have executed), so we just resort to replicating a cancel task
await abortStream(
"streaming_failed",
error.message ?? JSON.stringify(serializeError(error), null, 2)
error.message ?? JSON.stringify(serializeError(error), null, 2),
)
const history = await this.providerRef.deref()?.getTaskWithId(this.taskId)
if (history) {
@@ -2053,7 +2056,7 @@ export class Cline {
// if there's no assistant_responses, that means we got no text or tool_use content blocks from API which we should assume is an error
await this.say(
"error",
"Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output."
"Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.",
)
await this.addToApiConversationHistory({
role: "assistant",
@@ -2099,7 +2102,7 @@ export class Cline {
}
}
return contentBlock
})
}),
)
return {
...block,
@@ -2108,7 +2111,7 @@ export class Cline {
}
}
return block
})
}),
),
this.getEnvironmentDetails(includeFileDetails),
])

View File

@@ -150,7 +150,7 @@ async function getFileOrFolderContent(mentionPath: string, cwd: string): Promise
} catch (error) {
return undefined
}
})()
})(),
)
} else if (entry.isDirectory()) {
folderContent += `${linePrefix}${entry.name}/\n`
@@ -174,7 +174,7 @@ function getWorkspaceProblems(cwd: string): string {
const result = diagnosticsToProblemsString(
diagnostics,
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning],
cwd
cwd,
)
if (!result) {
return "No errors or warnings detected."

View File

@@ -30,7 +30,7 @@ Otherwise, if you have not completed the task and do not need additional informa
toolResult: (
text: string,
images?: string[]
images?: string[],
): string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam> => {
if (images && images.length > 0) {
const textBlock: Anthropic.TextBlockParam = { type: "text", text }
@@ -76,7 +76,7 @@ Otherwise, if you have not completed the task and do not need additional informa
})
if (didHitLimit) {
return `${sorted.join(
"\n"
"\n",
)}\n\n(File list truncated. Use list_files on specific subdirectories if you need to explore further.)`
} else if (sorted.length === 0 || (sorted.length === 1 && sorted[0] === "")) {
return "No files found."

View File

@@ -6,7 +6,7 @@ import path from 'path'
export const SYSTEM_PROMPT = async (
cwd: string,
supportsComputerUse: boolean
supportsComputerUse: boolean,
) => `You are Cline, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
====

View File

@@ -9,7 +9,7 @@ Therefore, this function should only be called when absolutely necessary to fit
context limits, not as a continuous process.
*/
export function truncateHalfConversation(
messages: Anthropic.Messages.MessageParam[]
messages: Anthropic.Messages.MessageParam[],
): Anthropic.Messages.MessageParam[] {
// API expects messages to be in user-assistant order, and tool use messages must be followed by tool results. We need to maintain this structure while truncating.

View File

@@ -77,7 +77,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
private workspaceTracker?: WorkspaceTracker
private latestAnnouncementId = "oct-28-2024" // update to some unique identifier when we add a new announcement
constructor(readonly context: vscode.ExtensionContext, private readonly outputChannel: vscode.OutputChannel) {
constructor(
readonly context: vscode.ExtensionContext,
private readonly outputChannel: vscode.OutputChannel,
) {
this.outputChannel.appendLine("ClineProvider instantiated")
ClineProvider.activeInstances.add(this)
this.workspaceTracker = new WorkspaceTracker(this)
@@ -113,7 +116,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
resolveWebviewView(
webviewView: vscode.WebviewView | vscode.WebviewPanel
webviewView: vscode.WebviewView | vscode.WebviewPanel,
//context: vscode.WebviewViewResolveContext<unknown>, used to recreate a deallocated webview, but we don't need this since we use retainContextWhenHidden
//token: vscode.CancellationToken
): void | Thenable<void> {
@@ -146,7 +149,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
},
null,
this.disposables
this.disposables,
)
} else if ("onDidChangeVisibility" in webviewView) {
// sidebar
@@ -157,7 +160,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
},
null,
this.disposables
this.disposables,
)
}
@@ -168,7 +171,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.dispose()
},
null,
this.disposables
this.disposables,
)
// Listen for when color changes
@@ -180,7 +183,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
},
null,
this.disposables
this.disposables,
)
// if the extension is starting a new session, clear previous task state
@@ -234,7 +237,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
alwaysAllowBrowser,
undefined,
undefined,
historyItem
historyItem,
)
}
@@ -338,7 +341,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
this.postStateToWebview()
this.workspaceTracker?.initializeFilePaths() // don't await
getTheme().then((theme) =>
this.postMessageToWebview({ type: "theme", text: JSON.stringify(theme) })
this.postMessageToWebview({ type: "theme", text: JSON.stringify(theme) }),
)
// post last cached models in case the call to endpoint fails
this.readOpenRouterModels().then((openRouterModels) => {
@@ -356,7 +359,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
if (apiConfiguration.openRouterModelId) {
await this.updateGlobalState(
"openRouterModelInfo",
openRouterModels[apiConfiguration.openRouterModelId]
openRouterModels[apiConfiguration.openRouterModelId],
)
await this.postStateToWebview()
}
@@ -540,7 +543,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
},
null,
this.disposables
this.disposables,
)
}
@@ -626,7 +629,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
async readOpenRouterModels(): Promise<Record<string, ModelInfo> | undefined> {
const openRouterModelsFilePath = path.join(
await this.ensureCacheDirectoryExists(),
GlobalFileNames.openRouterModels
GlobalFileNames.openRouterModels,
)
const fileExists = await fileExistsAtPath(openRouterModelsFilePath)
if (fileExists) {
@@ -639,7 +642,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
async refreshOpenRouterModels() {
const openRouterModelsFilePath = path.join(
await this.ensureCacheDirectoryExists(),
GlobalFileNames.openRouterModels
GlobalFileNames.openRouterModels,
)
let models: Record<string, ModelInfo> = {}

View File

@@ -25,13 +25,13 @@ export function createClineAPI(outputChannel: vscode.OutputChannel, sidebarProvi
images: images,
})
outputChannel.appendLine(
`Task started with message: ${task ? `"${task}"` : "undefined"} and ${images?.length || 0} image(s)`
`Task started with message: ${task ? `"${task}"` : "undefined"} and ${images?.length || 0} image(s)`,
)
},
sendMessage: async (message?: string, images?: string[]) => {
outputChannel.appendLine(
`Sending message: ${message ? `"${message}"` : "undefined"} with ${images?.length || 0} image(s)`
`Sending message: ${message ? `"${message}"` : "undefined"} with ${images?.length || 0} image(s)`,
)
await sidebarProvider.postMessageToWebview({
type: "invoke",

View File

@@ -31,7 +31,7 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(ClineProvider.sideBarId, sidebarProvider, {
webviewOptions: { retainContextWhenHidden: true },
})
}),
)
context.subscriptions.push(
@@ -40,7 +40,7 @@ export function activate(context: vscode.ExtensionContext) {
await sidebarProvider.clearTask()
await sidebarProvider.postStateToWebview()
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
})
}),
)
const openClineInNewTab = async () => {
@@ -83,13 +83,13 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand("cline.settingsButtonClicked", () => {
//vscode.window.showInformationMessage(message)
sidebarProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
})
}),
)
context.subscriptions.push(
vscode.commands.registerCommand("cline.historyButtonClicked", () => {
sidebarProvider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
})
}),
)
/*
@@ -105,7 +105,7 @@ export function activate(context: vscode.ExtensionContext) {
}
})()
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(DIFF_VIEW_URI_SCHEME, diffContentProvider)
vscode.workspace.registerTextDocumentContentProvider(DIFF_VIEW_URI_SCHEME, diffContentProvider),
)
// URI Handler

View File

@@ -4,7 +4,7 @@ import deepEqual from "fast-deep-equal"
export function getNewDiagnostics(
oldDiagnostics: [vscode.Uri, vscode.Diagnostic[]][],
newDiagnostics: [vscode.Uri, vscode.Diagnostic[]][]
newDiagnostics: [vscode.Uri, vscode.Diagnostic[]][],
): [vscode.Uri, vscode.Diagnostic[]][] {
const newProblems: [vscode.Uri, vscode.Diagnostic[]][] = []
const oldMap = new Map(oldDiagnostics)
@@ -73,7 +73,7 @@ export function getNewDiagnostics(
export function diagnosticsToProblemsString(
diagnostics: [vscode.Uri, vscode.Diagnostic[]][],
severities: vscode.DiagnosticSeverity[],
cwd: string
cwd: string,
): string {
let result = ""
for (const [uri, fileDiagnostics] of diagnostics) {

View File

@@ -65,8 +65,8 @@ export class DecorationController {
this.ranges.push(
new vscode.Range(
new vscode.Position(line + 1, 0),
new vscode.Position(totalLines - 1, Number.MAX_SAFE_INTEGER)
)
new vscode.Position(totalLines - 1, Number.MAX_SAFE_INTEGER),
),
)
}

View File

@@ -34,7 +34,7 @@ export class DiffViewProvider {
// if the file is already open, ensure it's not dirty before getting its contents
if (fileExists) {
const existingDocument = vscode.workspace.textDocuments.find((doc) =>
arePathsEqual(doc.uri.fsPath, absolutePath)
arePathsEqual(doc.uri.fsPath, absolutePath),
)
if (existingDocument && existingDocument.isDirty) {
await existingDocument.save()
@@ -62,7 +62,7 @@ export class DiffViewProvider {
.map((tg) => tg.tabs)
.flat()
.filter(
(tab) => tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, absolutePath)
(tab) => tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, absolutePath),
)
for (const tab of tabs) {
if (!tab.isDirty) {
@@ -179,7 +179,7 @@ export class DiffViewProvider {
[
vscode.DiagnosticSeverity.Error, // only including errors since warnings can be distracting (if user wants to fix warnings they can use the @problems mention)
],
this.cwd
this.cwd,
) // will be empty string if no errors
const newProblemsMessage =
newProblems.length > 0 ? `\n\nNew problems detected after saving the file:\n${newProblems}` : ""
@@ -194,7 +194,7 @@ export class DiffViewProvider {
const userEdits = formatResponse.createPrettyPatch(
this.relPath.toPosix(),
normalizedNewContent,
normalizedEditedContent
normalizedEditedContent,
)
return { newProblemsMessage, userEdits, finalContent: normalizedEditedContent }
} else {
@@ -227,7 +227,7 @@ export class DiffViewProvider {
const edit = new vscode.WorkspaceEdit()
const fullRange = new vscode.Range(
updatedDocument.positionAt(0),
updatedDocument.positionAt(updatedDocument.getText().length)
updatedDocument.positionAt(updatedDocument.getText().length),
)
edit.replace(updatedDocument.uri, fullRange, this.originalContent ?? "")
// Apply the edit and save, since contents shouldnt have changed this wont show in local history unless of course the user made changes and saved during the edit
@@ -251,7 +251,8 @@ export class DiffViewProvider {
.flatMap((tg) => tg.tabs)
.filter(
(tab) =>
tab.input instanceof vscode.TabInputTextDiff && tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME
tab.input instanceof vscode.TabInputTextDiff &&
tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME,
)
for (const tab of tabs) {
// trying to close dirty views results in save popup
@@ -273,7 +274,7 @@ export class DiffViewProvider {
(tab) =>
tab.input instanceof vscode.TabInputTextDiff &&
tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME &&
arePathsEqual(tab.input.modified.fsPath, uri.fsPath)
arePathsEqual(tab.input.modified.fsPath, uri.fsPath),
)
if (diffTab && diffTab.input instanceof vscode.TabInputTextDiff) {
const editor = await vscode.window.showTextDocument(diffTab.input.modified)
@@ -295,7 +296,7 @@ export class DiffViewProvider {
query: Buffer.from(this.originalContent ?? "").toString("base64"),
}),
uri,
`${fileName}: ${fileExists ? "Original ↔ Cline's Changes" : "New File"} (Editable)`
`${fileName}: ${fileExists ? "Original ↔ Cline's Changes" : "New File"} (Editable)`,
)
// This may happen on very slow machines ie project idx
setTimeout(() => {
@@ -310,7 +311,7 @@ export class DiffViewProvider {
const scrollLine = line + 4
this.activeDiffEditor.revealRange(
new vscode.Range(scrollLine, 0, scrollLine, 0),
vscode.TextEditorRevealType.InCenter
vscode.TextEditorRevealType.InCenter,
)
}
}
@@ -327,7 +328,7 @@ export class DiffViewProvider {
// Found the first diff, scroll to it
this.activeDiffEditor.revealRange(
new vscode.Range(lineCount, 0, lineCount, 0),
vscode.TextEditorRevealType.InCenter
vscode.TextEditorRevealType.InCenter,
)
return
}

View File

@@ -43,14 +43,14 @@ export function showOmissionWarning(originalFileContent: string, newFileContent:
vscode.window
.showWarningMessage(
"Potential code truncation detected. This happens when the AI reaches its max output limit.",
"Follow this guide to fix the issue"
"Follow this guide to fix the issue",
)
.then((selection) => {
if (selection === "Follow this guide to fix the issue") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://github.com/cline/cline/wiki/Troubleshooting-%E2%80%90-Cline-Deleting-Code-with-%22Rest-of-Code-Here%22-Comments"
)
"https://github.com/cline/cline/wiki/Troubleshooting-%E2%80%90-Cline-Deleting-Code-with-%22Rest-of-Code-Here%22-Comments",
),
)
}
})

View File

@@ -46,7 +46,7 @@ export function formatContentBlockToMarkdown(
| Anthropic.TextBlockParam
| Anthropic.ImageBlockParam
| Anthropic.ToolUseBlockParam
| Anthropic.ToolResultBlockParam
| Anthropic.ToolResultBlockParam,
// messages: Anthropic.MessageParam[]
): string {
switch (block.type) {

View File

@@ -28,12 +28,13 @@ export async function openFile(absolutePath: string) {
try {
for (const group of vscode.window.tabGroups.all) {
const existingTab = group.tabs.find(
(tab) => tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, uri.fsPath)
(tab) =>
tab.input instanceof vscode.TabInputText && arePathsEqual(tab.input.uri.fsPath, uri.fsPath),
)
if (existingTab) {
const activeColumn = vscode.window.activeTextEditor?.viewColumn
const tabColumn = vscode.window.tabGroups.all.find((group) =>
group.tabs.includes(existingTab)
group.tabs.includes(existingTab),
)?.viewColumn
if (activeColumn && activeColumn !== tabColumn && !existingTab.isDirty) {
await vscode.window.tabGroups.close(existingTab)

View File

@@ -25,7 +25,7 @@ export async function selectImages(): Promise<string[]> {
const mimeType = getMimeType(imagePath)
const dataUrl = `data:${mimeType};base64,${base64}`
return dataUrl
})
}),
)
}

View File

@@ -75,7 +75,7 @@ declare module "vscode" {
onDidStartTerminalShellExecution?: (
listener: (e: any) => any,
thisArgs?: any,
disposables?: vscode.Disposable[]
disposables?: vscode.Disposable[],
) => vscode.Disposable
}
}

View File

@@ -54,7 +54,7 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
/* ddateb15026-6a64-40db-b21f-2a621a9830f0]633;CTue Sep 17 06:37:04 EDT 2024 % ]633;D;0]633;P;Cwd=/Users/saoud/Repositories/test */
// Gets output between ]633;C (command start) and ]633;D (command end)
const outputBetweenSequences = this.removeLastLineArtifacts(
data.match(/\]633;C([\s\S]*?)\]633;D/)?.[1] || ""
data.match(/\]633;C([\s\S]*?)\]633;D/)?.[1] || "",
).trim()
// Once we've retrieved any potential output between sequences, we can remove everything up to end of the last sequence
@@ -142,7 +142,7 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
() => {
this.isHot = false
},
isCompiling ? PROCESS_HOT_TIMEOUT_COMPILING : PROCESS_HOT_TIMEOUT_NORMAL
isCompiling ? PROCESS_HOT_TIMEOUT_COMPILING : PROCESS_HOT_TIMEOUT_NORMAL,
)
// For non-immediately returning commands we want to show loading spinner right away but this wouldnt happen until it emits a line break, so as soon as we get any output we emit "" to let webview know to show spinner
@@ -240,7 +240,7 @@ export type TerminalProcessResultPromise = TerminalProcess & Promise<void>
export function mergePromise(process: TerminalProcess, promise: Promise<void>): TerminalProcessResultPromise {
const nativePromisePrototype = (async () => {})().constructor.prototype
const descriptors = ["then", "catch", "finally"].map(
(property) => [property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)] as const
(property) => [property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)] as const,
)
for (const [property, descriptor] of descriptors) {
if (descriptor) {

View File

@@ -345,10 +345,7 @@
}
},
{
"scope": [
"punctuation.section.embedded.begin.php",
"punctuation.section.embedded.end.php"
],
"scope": ["punctuation.section.embedded.begin.php", "punctuation.section.embedded.end.php"],
"settings": {
"foreground": "#569cd6"
}

View File

@@ -86,10 +86,7 @@
}
},
{
"scope": [
"entity.name.tag.css",
"entity.name.tag.less"
],
"scope": ["entity.name.tag.css", "entity.name.tag.less"],
"settings": {
"foreground": "#d7ba7d"
}
@@ -173,9 +170,7 @@
},
{
"name": "brackets of XML/HTML tags",
"scope": [
"punctuation.definition.tag"
],
"scope": ["punctuation.definition.tag"],
"settings": {
"foreground": "#808080"
}
@@ -259,9 +254,7 @@
},
{
"name": "Reset JavaScript string interpolation expression",
"scope": [
"meta.template.expression"
],
"scope": ["meta.template.expression"],
"settings": {
"foreground": "#ffffff"
}
@@ -417,20 +410,14 @@
},
{
"name": "Variable and parameter name",
"scope": [
"variable",
"meta.definition.variable.name",
"support.variable"
],
"scope": ["variable", "meta.definition.variable.name", "support.variable"],
"settings": {
"foreground": "#9CDCFE"
}
},
{
"name": "Object keys, TS grammar specific",
"scope": [
"meta.object-literal.key"
],
"scope": ["meta.object-literal.key"],
"settings": {
"foreground": "#9CDCFE"
}

View File

@@ -3,11 +3,7 @@
"name": "Light High Contrast",
"tokenColors": [
{
"scope": [
"meta.embedded",
"source.groovy.embedded",
"variable.legacy.builtin.python"
],
"scope": ["meta.embedded", "source.groovy.embedded", "variable.legacy.builtin.python"],
"settings": {
"foreground": "#292929"
}
@@ -150,10 +146,7 @@
}
},
{
"scope": [
"punctuation.definition.quote.begin.markdown",
"punctuation.definition.list.begin.markdown"
],
"scope": ["punctuation.definition.quote.begin.markdown", "punctuation.definition.list.begin.markdown"],
"settings": {
"foreground": "#0451A5"
}
@@ -335,10 +328,7 @@
}
},
{
"scope": [
"punctuation.section.embedded.begin.php",
"punctuation.section.embedded.end.php"
],
"scope": ["punctuation.section.embedded.begin.php", "punctuation.section.embedded.end.php"],
"settings": {
"foreground": "#0F4A85"
}

View File

@@ -185,10 +185,7 @@
}
},
{
"scope": [
"punctuation.definition.quote.begin.markdown",
"punctuation.definition.list.begin.markdown"
],
"scope": ["punctuation.definition.quote.begin.markdown", "punctuation.definition.list.begin.markdown"],
"settings": {
"foreground": "#0451a5"
}
@@ -373,10 +370,7 @@
}
},
{
"scope": [
"punctuation.section.embedded.begin.php",
"punctuation.section.embedded.end.php"
],
"scope": ["punctuation.section.embedded.begin.php", "punctuation.section.embedded.end.php"],
"settings": {
"foreground": "#800000"
}

View File

@@ -55,7 +55,7 @@ export async function getTheme() {
const filename = `${defaultThemes[colorTheme]}.json`
currentTheme = await fs.readFile(
path.join(getExtensionUri().fsPath, "src", "integrations", "theme", "default-themes", filename),
"utf-8"
"utf-8",
)
}
@@ -65,7 +65,7 @@ export async function getTheme() {
if (parsed.include) {
const includeThemeString = await fs.readFile(
path.join(getExtensionUri().fsPath, "src", "integrations", "theme", "default-themes", parsed.include),
"utf-8"
"utf-8",
)
const includeTheme = parseThemeString(includeThemeString)
parsed = mergeJson(parsed, includeTheme)
@@ -93,7 +93,7 @@ export function mergeJson(
first: JsonObject,
second: JsonObject,
mergeBehavior?: "merge" | "overwrite",
mergeKeys?: { [key: string]: (a: any, b: any) => boolean }
mergeKeys?: { [key: string]: (a: any, b: any) => boolean },
): any {
const copyOfFirst = JSON.parse(JSON.stringify(first))

View File

@@ -52,7 +52,7 @@ class WorkspaceTracker {
await Promise.all(
event.files.map(async (file) => {
await this.addFilePath(file.fsPath)
})
}),
)
this.workspaceDidUpdate()
}
@@ -64,7 +64,7 @@ class WorkspaceTracker {
if (await this.removeFilePath(file.fsPath)) {
updated = true
}
})
}),
)
if (updated) {
this.workspaceDidUpdate()
@@ -76,7 +76,7 @@ class WorkspaceTracker {
event.files.map(async (file) => {
await this.removeFilePath(file.oldUri.fsPath)
await this.addFilePath(file.newUri.fsPath)
})
}),
)
this.workspaceDidUpdate()
}

View File

@@ -82,7 +82,7 @@ export class BrowserSession {
async doAction(action: (page: Page) => Promise<void>): Promise<BrowserActionResult> {
if (!this.page) {
throw new Error(
"Browser is not launched. This may occur if the browser was automatically closed by a non-`browser_action` tool."
"Browser is not launched. This may occur if the browser was automatically closed by a non-`browser_action` tool.",
)
}

View File

@@ -126,7 +126,7 @@ export async function regexSearchFiles(
cwd: string,
directoryPath: string,
regex: string,
filePattern?: string
filePattern?: string,
): Promise<string> {
const vscodeAppRoot = vscode.env.appRoot
const rgPath = await getBinPath(vscodeAppRoot)

View File

@@ -1,15 +1,15 @@
import * as assert from 'assert';
import * as assert from "assert"
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
import * as vscode from "vscode"
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
suite("Extension Test Suite", () => {
vscode.window.showInformationMessage("Start all tests.")
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});
test("Sample test", () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5))
assert.strictEqual(-1, [1, 2, 3].indexOf(0))
})
})

View File

@@ -5,7 +5,7 @@ export function calculateApiCost(
inputTokens: number,
outputTokens: number,
cacheCreationInputTokens?: number,
cacheReadInputTokens?: number
cacheReadInputTokens?: number,
): number {
const modelCacheWritesPrice = modelInfo.cacheWritesPrice
let cacheWritesCost = 0

View File

@@ -1,14 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
@@ -37,6 +34,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
--></body>
</html>

View File

@@ -188,7 +188,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
{!isBrowsing && messages.some((m) => m.say === "browser_action_result") && currentPageIndex === 0 && (
<BrowserActionBox action={"launch"} text={initialUrl} />
)}
</div>
</div>,
)
useEffect(() => {
@@ -381,7 +381,7 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
</div>
</div>
)}
</div>
</div>,
)
// Height change effect

View File

@@ -35,7 +35,7 @@ const ChatRow = memo(
padding: "10px 6px 10px 15px",
}}>
<ChatRowContent {...props} />
</div>
</div>,
)
useEffect(() => {
@@ -55,7 +55,7 @@ const ChatRow = memo(
return chatrow
},
// memo does shallow comparison of props, so we need to do deep comparison of arrays/objects whose properties might change
deepEqual
deepEqual,
)
export default ChatRow
@@ -707,9 +707,7 @@ export const ChatRowContent = ({
padding: `2px 8px ${isExpanded ? 0 : 8}px 8px`,
}}>
<span
className={`codicon codicon-chevron-${
isExpanded ? "down" : "right"
}`}></span>
className={`codicon codicon-chevron-${isExpanded ? "down" : "right"}`}></span>
<span style={{ fontSize: "0.8em" }}>Command Output</span>
</div>
{isExpanded && <CodeBlock source={`${"```"}shell\n${output}\n${"```"}`} />}

View File

@@ -40,7 +40,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
shouldDisableImages,
onHeightChange,
},
ref
ref,
) => {
const { filePaths } = useExtensionState()
const [isTextAreaFocused, setIsTextAreaFocused] = useState(false)
@@ -119,7 +119,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
const { newValue, mentionIndex } = insertMention(
textAreaRef.current.value,
cursorPosition,
insertValue
insertValue,
)
setInputValue(newValue)
@@ -137,7 +137,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
}, 0)
}
},
[setInputValue, cursorPosition]
[setInputValue, cursorPosition],
)
const handleKeyDown = useCallback(
@@ -163,14 +163,14 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
const selectableOptions = options.filter(
(option) =>
option.type !== ContextMenuOptionType.URL &&
option.type !== ContextMenuOptionType.NoResults
option.type !== ContextMenuOptionType.NoResults,
)
if (selectableOptions.length === 0) return -1 // No selectable options
// Find the index of the next selectable option
const currentSelectableIndex = selectableOptions.findIndex(
(option) => option === options[prevIndex]
(option) => option === options[prevIndex],
)
const newSelectableIndex =
@@ -252,7 +252,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
setInputValue,
justDeletedSpaceAfterMention,
queryItems,
]
],
)
useLayoutEffect(() => {
@@ -285,7 +285,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
setSelectedMenuIndex(-1)
}
},
[setInputValue]
[setInputValue],
)
useEffect(() => {
@@ -370,7 +370,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
}
}
},
[shouldDisableImages, setSelectedImages, cursorPosition, setInputValue, inputValue]
[shouldDisableImages, setSelectedImages, cursorPosition, setInputValue, inputValue],
)
const handleThumbnailsHeightChange = useCallback((height: number) => {
@@ -394,7 +394,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
highlightLayerRef.current.innerHTML = text
.replace(/\n$/, "\n\n")
.replace(/[<>&]/g, (c) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;" }[c] || c))
.replace(/[<>&]/g, (c) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;" })[c] || c)
.replace(mentionRegexGlobal, '<mark class="mention-context-textarea-highlight">$&</mark>')
highlightLayerRef.current.scrollTop = textAreaRef.current.scrollTop
@@ -417,7 +417,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
updateCursorPosition()
}
},
[updateCursorPosition]
[updateCursorPosition],
)
return (
@@ -594,7 +594,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
</div>
</div>
)
}
},
)
export default ChatTextArea

View File

@@ -271,7 +271,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
disableAutoScrollRef.current = false
}
},
[messages.length, clineAsk]
[messages.length, clineAsk],
)
const startNewTask = useCallback(() => {
@@ -366,7 +366,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const newImages = message.images ?? []
if (newImages.length > 0) {
setSelectedImages((prevImages) =>
[...prevImages, ...newImages].slice(0, MAX_IMAGES_PER_MESSAGE)
[...prevImages, ...newImages].slice(0, MAX_IMAGES_PER_MESSAGE),
)
}
break
@@ -392,7 +392,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
handleSendMessage,
handlePrimaryButtonClick,
handleSecondaryButtonClick,
]
],
)
useEvent("message", handleMessage)
@@ -530,9 +530,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
})
},
10,
{ immediate: true }
{ immediate: true },
),
[]
[],
)
const scrollToBottomAuto = useCallback(() => {
@@ -594,7 +594,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
}
}
},
[groupedMessages, expandedRows, scrollToBottomAuto, isAtBottom]
[groupedMessages, expandedRows, scrollToBottomAuto, isAtBottom],
)
const handleRowHeightChange = useCallback(
@@ -609,7 +609,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
}
}
},
[scrollToBottomSmooth, scrollToBottomAuto]
[scrollToBottomSmooth, scrollToBottomAuto],
)
useEffect(() => {
@@ -672,7 +672,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
/>
)
},
[expandedRows, modifiedMessages, groupedMessages.length, toggleRowExpansion, handleRowHeightChange]
[expandedRows, modifiedMessages, groupedMessages.length, toggleRowExpansion, handleRowHeightChange],
)
return (

View File

@@ -25,7 +25,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
const filteredOptions = useMemo(
() => getContextMenuOptions(searchQuery, selectedType, queryItems),
[searchQuery, selectedType, queryItems]
[searchQuery, selectedType, queryItems],
)
useEffect(() => {

View File

@@ -35,7 +35,7 @@ const CodeAccordian = ({
}: CodeAccordianProps) => {
const inferredLanguage = useMemo(
() => code && (language ?? (path ? getLanguageFromPath(path) : undefined)),
[path, language, code]
[path, language, code],
)
return (

View File

@@ -69,8 +69,19 @@ const StyledMarkdown = styled.div<{ forceWrap: boolean }>`
}
background-color: ${CODE_BLOCK_BG_COLOR};
font-family: var(--vscode-font-family), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-family:
var(--vscode-font-family),
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
font-size: var(--vscode-editor-font-size, var(--vscode-font-size, 12px));
color: var(--vscode-editor-foreground, #fff);

View File

@@ -1,4 +1,3 @@
import {
VSCodeBadge,
VSCodeButton,

View File

@@ -57,8 +57,19 @@ const StyledMarkdown = styled.div`
overflow-wrap: anywhere;
}
font-family: var(--vscode-font-family), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-family:
var(--vscode-font-family),
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
font-size: var(--vscode-font-size, 13px);
p,

View File

@@ -430,7 +430,7 @@ const ExportButton = ({ itemId }: { itemId: string }) => (
// https://gist.github.com/evenfrost/1ba123656ded32fb7a0cd4651efd4db0
export const highlight = (
fuseSearchResult: FuseResult<any>[],
highlightClassName: string = "history-item-highlight"
highlightClassName: string = "history-item-highlight",
) => {
const set = (obj: Record<string, any>, path: string, value: any) => {
const pathValue = path.split(".")

View File

@@ -266,8 +266,19 @@ const DropdownItem = styled.div<{ isSelected: boolean }>`
// Markdown
const StyledMarkdown = styled.div`
font-family: var(--vscode-font-family), system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-family:
var(--vscode-font-family),
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
font-size: 12px;
color: var(--vscode-descriptionForeground);
@@ -403,5 +414,5 @@ export const ModelDescriptionMarkdown = memo(
)} */}
</StyledMarkdown>
)
}
},
)

View File

@@ -9,7 +9,7 @@ const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement)
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
)
// If you want to start measuring performance in your app, pass a function

View File

@@ -3,7 +3,7 @@ import { mentionRegex } from "../../../src/shared/context-mentions"
export function insertMention(
text: string,
position: number,
value: string
value: string,
): { newValue: string; mentionIndex: number } {
const beforeCursor = text.slice(0, position)
const afterCursor = text.slice(position)
@@ -62,7 +62,7 @@ export interface ContextMenuQueryItem {
export function getContextMenuOptions(
query: string,
selectedType: ContextMenuOptionType | null = null,
queryItems: ContextMenuQueryItem[]
queryItems: ContextMenuQueryItem[],
): ContextMenuQueryItem[] {
if (query === "") {
if (selectedType === ContextMenuOptionType.File) {

View File

@@ -59,7 +59,7 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
export function validateModelId(
apiConfiguration?: ApiConfiguration,
openRouterModels?: Record<string, ModelInfo>
openRouterModels?: Record<string, ModelInfo>,
): string | undefined {
if (apiConfiguration) {
switch (apiConfiguration.apiProvider) {