chore: Prettier fix formatting
This commit is contained in:
1 parent
9de7253998
commit
25cd7cc8e2
106 files changed
+1624
-5278
No files matched your search
@@ -21,12 +21,7 @@ export interface ExtensionMessage {
|
||||
| "mcpServers"
|
||||
| "relinquishControl"
|
||||
text?: string
|
||||
action?:
|
||||
| "chatButtonClicked"
|
||||
| "mcpButtonClicked"
|
||||
| "settingsButtonClicked"
|
||||
| "historyButtonClicked"
|
||||
| "didBecomeVisible"
|
||||
action?: "chatButtonClicked" | "mcpButtonClicked" | "settingsButtonClicked" | "historyButtonClicked" | "didBecomeVisible"
|
||||
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
|
||||
state?: ExtensionState
|
||||
images?: string[]
|
||||
@@ -118,14 +113,7 @@ export interface ClineSayTool {
|
||||
}
|
||||
|
||||
// must keep in sync with system prompt
|
||||
export const browserActions = [
|
||||
"launch",
|
||||
"click",
|
||||
"type",
|
||||
"scroll_down",
|
||||
"scroll_up",
|
||||
"close",
|
||||
] as const
|
||||
export const browserActions = ["launch", "click", "type", "scroll_down", "scroll_up", "close"] as const
|
||||
export type BrowserAction = (typeof browserActions)[number]
|
||||
|
||||
export interface ClineSayBrowserAction {
|
||||
|
||||
@@ -38,9 +38,6 @@ export interface WebviewMessage {
|
||||
autoApprovalSettings?: AutoApprovalSettings
|
||||
}
|
||||
|
||||
export type ClineAskResponse =
|
||||
| "yesButtonClicked"
|
||||
| "noButtonClicked"
|
||||
| "messageResponse"
|
||||
export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse"
|
||||
|
||||
export type ClineCheckpointRestore = "task" | "workspace" | "taskAndWorkspace"
|
||||
+4
-8
@@ -59,8 +59,7 @@ export interface ModelInfo {
|
||||
// Anthropic
|
||||
// https://docs.anthropic.com/en/docs/about-claude/models
|
||||
export type AnthropicModelId = keyof typeof anthropicModels
|
||||
export const anthropicDefaultModelId: AnthropicModelId =
|
||||
"claude-3-5-sonnet-20241022"
|
||||
export const anthropicDefaultModelId: AnthropicModelId = "claude-3-5-sonnet-20241022"
|
||||
export const anthropicModels = {
|
||||
"claude-3-5-sonnet-20241022": {
|
||||
maxTokens: 8192,
|
||||
@@ -108,8 +107,7 @@ export const anthropicModels = {
|
||||
// AWS Bedrock
|
||||
// https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html
|
||||
export type BedrockModelId = keyof typeof bedrockModels
|
||||
export const bedrockDefaultModelId: BedrockModelId =
|
||||
"anthropic.claude-3-5-sonnet-20241022-v2:0"
|
||||
export const bedrockDefaultModelId: BedrockModelId = "anthropic.claude-3-5-sonnet-20241022-v2:0"
|
||||
export const bedrockModels = {
|
||||
"anthropic.claude-3-5-sonnet-20241022-v2:0": {
|
||||
maxTokens: 8192,
|
||||
@@ -182,8 +180,7 @@ export const openRouterDefaultModelInfo: ModelInfo = {
|
||||
// Vertex AI
|
||||
// https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude
|
||||
export type VertexModelId = keyof typeof vertexModels
|
||||
export const vertexDefaultModelId: VertexModelId =
|
||||
"claude-3-5-sonnet-v2@20241022"
|
||||
export const vertexDefaultModelId: VertexModelId = "claude-3-5-sonnet-v2@20241022"
|
||||
export const vertexModels = {
|
||||
"claude-3-5-sonnet-v2@20241022": {
|
||||
maxTokens: 8192,
|
||||
@@ -240,8 +237,7 @@ export const openAiModelInfoSaneDefaults: ModelInfo = {
|
||||
// Gemini
|
||||
// https://ai.google.dev/gemini-api/docs/models/gemini
|
||||
export type GeminiModelId = keyof typeof geminiModels
|
||||
export const geminiDefaultModelId: GeminiModelId =
|
||||
"gemini-2.0-flash-thinking-exp-1219"
|
||||
export const geminiDefaultModelId: GeminiModelId = "gemini-2.0-flash-thinking-exp-1219"
|
||||
export const geminiModels = {
|
||||
"gemini-2.0-flash-thinking-exp-1219": {
|
||||
maxTokens: 8192,
|
||||
|
||||
+2
-8
@@ -6,10 +6,7 @@
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
|
||||
*/
|
||||
export function findLastIndex<T>(
|
||||
array: Array<T>,
|
||||
predicate: (value: T, index: number, obj: T[]) => boolean,
|
||||
): number {
|
||||
export function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number {
|
||||
let l = array.length
|
||||
while (l--) {
|
||||
if (predicate(array[l], l, array)) {
|
||||
@@ -19,10 +16,7 @@ export function findLastIndex<T>(
|
||||
return -1
|
||||
}
|
||||
|
||||
export function findLast<T>(
|
||||
array: Array<T>,
|
||||
predicate: (value: T, index: number, obj: T[]) => boolean,
|
||||
): T | undefined {
|
||||
export function findLast<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined {
|
||||
const index = findLastIndex(array, predicate)
|
||||
return index === -1 ? undefined : array[index]
|
||||
}
|
||||
@@ -22,18 +22,12 @@ export function combineApiRequests(messages: ClineMessage[]): ClineMessage[] {
|
||||
const combinedApiRequests: ClineMessage[] = []
|
||||
|
||||
for (let i = 0; i < messages.length; i++) {
|
||||
if (
|
||||
messages[i].type === "say" &&
|
||||
messages[i].say === "api_req_started"
|
||||
) {
|
||||
if (messages[i].type === "say" && messages[i].say === "api_req_started") {
|
||||
let startedRequest = JSON.parse(messages[i].text || "{}")
|
||||
let j = i + 1
|
||||
|
||||
while (j < messages.length) {
|
||||
if (
|
||||
messages[j].type === "say" &&
|
||||
messages[j].say === "api_req_finished"
|
||||
) {
|
||||
if (messages[j].type === "say" && messages[j].say === "api_req_finished") {
|
||||
let finishedRequest = JSON.parse(messages[j].text || "{}")
|
||||
let combinedRequest = {
|
||||
...startedRequest,
|
||||
@@ -60,14 +54,10 @@ export function combineApiRequests(messages: ClineMessage[]): ClineMessage[] {
|
||||
|
||||
// Replace original api_req_started and remove api_req_finished
|
||||
return messages
|
||||
.filter(
|
||||
(msg) => !(msg.type === "say" && msg.say === "api_req_finished"),
|
||||
)
|
||||
.filter((msg) => !(msg.type === "say" && msg.say === "api_req_finished"))
|
||||
.map((msg) => {
|
||||
if (msg.type === "say" && msg.say === "api_req_started") {
|
||||
const combinedRequest = combinedApiRequests.find(
|
||||
(req) => req.ts === msg.ts,
|
||||
)
|
||||
const combinedRequest = combinedApiRequests.find((req) => req.ts === msg.ts)
|
||||
return combinedRequest || msg
|
||||
}
|
||||
return msg
|
||||
|
||||
@@ -20,34 +20,22 @@ import { ClineMessage } from "./ExtensionMessage"
|
||||
* const result = simpleCombineCommandSequences(messages);
|
||||
* // Result: [{ type: 'ask', ask: 'command', text: 'ls\nfile1.txt\nfile2.txt', ts: 1625097600000 }]
|
||||
*/
|
||||
export function combineCommandSequences(
|
||||
messages: ClineMessage[],
|
||||
): ClineMessage[] {
|
||||
export function combineCommandSequences(messages: ClineMessage[]): ClineMessage[] {
|
||||
const combinedCommands: ClineMessage[] = []
|
||||
|
||||
// First pass: combine commands with their outputs
|
||||
for (let i = 0; i < messages.length; i++) {
|
||||
if (
|
||||
messages[i].type === "ask" &&
|
||||
(messages[i].ask === "command" || messages[i].say === "command")
|
||||
) {
|
||||
if (messages[i].type === "ask" && (messages[i].ask === "command" || messages[i].say === "command")) {
|
||||
let combinedText = messages[i].text || ""
|
||||
let didAddOutput = false
|
||||
let j = i + 1
|
||||
|
||||
while (j < messages.length) {
|
||||
if (
|
||||
messages[j].type === "ask" &&
|
||||
(messages[j].ask === "command" ||
|
||||
messages[j].say === "command")
|
||||
) {
|
||||
if (messages[j].type === "ask" && (messages[j].ask === "command" || messages[j].say === "command")) {
|
||||
// Stop if we encounter the next command
|
||||
break
|
||||
}
|
||||
if (
|
||||
messages[j].ask === "command_output" ||
|
||||
messages[j].say === "command_output"
|
||||
) {
|
||||
if (messages[j].ask === "command_output" || messages[j].say === "command_output") {
|
||||
if (!didAddOutput) {
|
||||
// Add a newline before the first output
|
||||
combinedText += `\n${COMMAND_OUTPUT_STRING}`
|
||||
@@ -73,18 +61,10 @@ export function combineCommandSequences(
|
||||
|
||||
// Second pass: remove command_outputs and replace original commands with combined ones
|
||||
return messages
|
||||
.filter(
|
||||
(msg) =>
|
||||
!(msg.ask === "command_output" || msg.say === "command_output"),
|
||||
)
|
||||
.filter((msg) => !(msg.ask === "command_output" || msg.say === "command_output"))
|
||||
.map((msg) => {
|
||||
if (
|
||||
msg.type === "ask" &&
|
||||
(msg.ask === "command" || msg.say === "command")
|
||||
) {
|
||||
const combinedCommand = combinedCommands.find(
|
||||
(cmd) => cmd.ts === msg.ts,
|
||||
)
|
||||
if (msg.type === "ask" && (msg.ask === "command" || msg.say === "command")) {
|
||||
const combinedCommand = combinedCommands.find((cmd) => cmd.ts === msg.ts)
|
||||
return combinedCommand || msg
|
||||
}
|
||||
return msg
|
||||
|
||||
@@ -44,6 +44,5 @@ Mention regex:
|
||||
- `mentionRegexGlobal`: Creates a global version of the `mentionRegex` to find all matches within a given string.
|
||||
|
||||
*/
|
||||
export const mentionRegex =
|
||||
/@((?:\/|\w+:\/\/)[^\s]+?|problems\b)(?=[.,;:!?]?(?=[\s\r\n]|$))/
|
||||
export const mentionRegex = /@((?:\/|\w+:\/\/)[^\s]+?|problems\b)(?=[.,;:!?]?(?=[\s\r\n]|$))/
|
||||
export const mentionRegexGlobal = new RegExp(mentionRegex.source, "g")
|
||||
@@ -35,16 +35,10 @@ export function getApiMetrics(messages: ClineMessage[]): ApiMetrics {
|
||||
}
|
||||
|
||||
messages.forEach((message) => {
|
||||
if (
|
||||
message.type === "say" &&
|
||||
(message.say === "api_req_started" ||
|
||||
message.say === "deleted_api_reqs") &&
|
||||
message.text
|
||||
) {
|
||||
if (message.type === "say" && (message.say === "api_req_started" || message.say === "deleted_api_reqs") && message.text) {
|
||||
try {
|
||||
const parsedData = JSON.parse(message.text)
|
||||
const { tokensIn, tokensOut, cacheWrites, cacheReads, cost } =
|
||||
parsedData
|
||||
const { tokensIn, tokensOut, cacheWrites, cacheReads, cost } = parsedData
|
||||
|
||||
if (typeof tokensIn === "number") {
|
||||
result.totalTokensIn += tokensIn
|
||||
@@ -53,12 +47,10 @@ export function getApiMetrics(messages: ClineMessage[]): ApiMetrics {
|
||||
result.totalTokensOut += tokensOut
|
||||
}
|
||||
if (typeof cacheWrites === "number") {
|
||||
result.totalCacheWrites =
|
||||
(result.totalCacheWrites ?? 0) + cacheWrites
|
||||
result.totalCacheWrites = (result.totalCacheWrites ?? 0) + cacheWrites
|
||||
}
|
||||
if (typeof cacheReads === "number") {
|
||||
result.totalCacheReads =
|
||||
(result.totalCacheReads ?? 0) + cacheReads
|
||||
result.totalCacheReads = (result.totalCacheReads ?? 0) + cacheReads
|
||||
}
|
||||
if (typeof cost === "number") {
|
||||
result.totalCost += cost
|
||||
|
||||
Reference in new issue
Block a user