Skip to content

Commit c3eb659

Browse files
committed
Run prettier on src/
1 parent 98711d4 commit c3eb659

File tree

5 files changed

+72
-55
lines changed

5 files changed

+72
-55
lines changed

src/api/providers/fetchers/litellm.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
5858
outputPrice: modelInfo.output_cost_per_token
5959
? modelInfo.output_cost_per_token * 1000000
6060
: undefined,
61-
cacheWritesPrice: modelInfo.cache_creation_input_token_cost ? modelInfo.cache_creation_input_token_cost * 1000000 : undefined,
62-
cacheReadsPrice: modelInfo.cache_read_input_token_cost ? modelInfo.cache_read_input_token_cost * 1000000 : undefined,
61+
cacheWritesPrice: modelInfo.cache_creation_input_token_cost
62+
? modelInfo.cache_creation_input_token_cost * 1000000
63+
: undefined,
64+
cacheReadsPrice: modelInfo.cache_read_input_token_cost
65+
? modelInfo.cache_read_input_token_cost * 1000000
66+
: undefined,
6367
description: `${modelName} via LiteLLM proxy`,
6468
}
6569
}

src/api/providers/lite-llm.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
8888
cacheReadTokens: lastUsage.prompt_tokens_details?.cached_tokens || 0,
8989
}
9090

91-
usageData.totalCost = calculateApiCostOpenAI(info, usageData.inputTokens, usageData.outputTokens, usageData.cacheWriteTokens, usageData.cacheReadTokens)
91+
usageData.totalCost = calculateApiCostOpenAI(
92+
info,
93+
usageData.inputTokens,
94+
usageData.outputTokens,
95+
usageData.cacheWriteTokens,
96+
usageData.cacheReadTokens,
97+
)
9298

9399
yield usageData
94100
}
@@ -129,4 +135,4 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
129135
// LiteLLM usage may include an extra field for Anthropic use cases.
130136
interface LiteLLMUsage extends OpenAI.CompletionUsage {
131137
cache_creation_input_tokens?: number
132-
}
138+
}

src/core/tools/__tests__/readFileTool.test.ts

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ jest.mock("../../../services/tree-sitter")
3939

4040
// Then create the mock functions
4141
const addLineNumbersMock = jest.fn().mockImplementation((text, startLine = 1) => {
42-
if (!text) return ""
43-
const lines = typeof text === "string" ? text.split("\n") : [text]
44-
return lines.map((line, i) => `${startLine + i} | ${line}`).join("\n")
42+
if (!text) return ""
43+
const lines = typeof text === "string" ? text.split("\n") : [text]
44+
return lines.map((line, i) => `${startLine + i} | ${line}`).join("\n")
4545
})
4646

4747
const extractTextFromFileMock = jest.fn().mockImplementation((_filePath) => {
48-
// Call addLineNumbersMock to register the call
49-
addLineNumbersMock(mockInputContent)
50-
return Promise.resolve(addLineNumbersMock(mockInputContent))
48+
// Call addLineNumbersMock to register the call
49+
addLineNumbersMock(mockInputContent)
50+
return Promise.resolve(addLineNumbersMock(mockInputContent))
5151
})
5252

5353
// Now assign the mocks to the module
@@ -104,7 +104,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
104104
// Setup the extractTextFromFile mock implementation with the current mockInputContent
105105
// Reset the spy before each test
106106
addLineNumbersMock.mockClear()
107-
107+
108108
// Setup the extractTextFromFile mock to call our spy
109109
mockedExtractTextFromFile.mockImplementation((_filePath) => {
110110
// Call the spy and return its result
@@ -170,7 +170,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
170170
}
171171
argsContent += `</file>`
172172

173-
174173
// Create a tool use object
175174
const toolUse: ReadFileToolUse = {
176175
type: "tool_use",
@@ -190,7 +189,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
190189
(_: ToolParamName, content?: string) => content ?? "",
191190
)
192191

193-
194192
return toolResult
195193
}
196194

@@ -208,7 +206,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
208206
// Don't check exact content or exact function calls
209207
})
210208

211-
212209
it("should not show line snippet in approval message when maxReadFileLine is -1", async () => {
213210
// This test verifies the line snippet behavior for the approval message
214211
// Setup - use default mockInputContent
@@ -341,7 +338,7 @@ describe("read_file tool with maxReadFileLine setting", () => {
341338

342339
// Make sure mockCline.ask returns approval
343340
mockCline.ask = jest.fn().mockResolvedValue({ response: "yesButtonClicked" })
344-
341+
345342
// Execute - skip addLineNumbers check
346343
const result = await executeReadFileTool(
347344
{},
@@ -367,10 +364,13 @@ describe("read_file tool with maxReadFileLine setting", () => {
367364
mockedReadLines.mockResolvedValue("Line 2\nLine 3\nLine 4")
368365

369366
// Execute using executeReadFileTool with range parameters
370-
const rangeResult = await executeReadFileTool({},{
371-
start_line: "2",
372-
end_line: "4",
373-
})
367+
const rangeResult = await executeReadFileTool(
368+
{},
369+
{
370+
start_line: "2",
371+
end_line: "4",
372+
},
373+
)
374374

375375
// Verify - just check that the result contains the expected elements
376376
expect(rangeResult).toContain(`<file><path>${testFilePath}</path>`)
@@ -469,15 +469,12 @@ describe("read_file tool XML output structure", () => {
469469
mockedIsBinaryFile.mockResolvedValue(isBinary)
470470
mockCline.rooIgnoreController.validateAccess = jest.fn().mockReturnValue(validateAccess)
471471

472-
473-
474472
let argsContent = `<file><path>${options.path || testFilePath}</path>`
475473
if (options.start_line && options.end_line) {
476474
argsContent += `<line_range>${options.start_line}-${options.end_line}</line_range>`
477475
}
478476
argsContent += `</file>`
479477

480-
481478
// Create a tool use object
482479
const toolUse: ReadFileToolUse = {
483480
type: "tool_use",
@@ -486,7 +483,6 @@ describe("read_file tool XML output structure", () => {
486483
partial: false,
487484
}
488485

489-
490486
// Execute the tool
491487
await readFileTool(
492488
mockCline,
@@ -507,7 +503,7 @@ describe("read_file tool XML output structure", () => {
507503
// Skip this test for now - it requires more complex mocking
508504
// of the formatResponse module which is causing issues
509505
expect(true).toBe(true)
510-
506+
511507
mockedCountFileLines.mockResolvedValue(1)
512508

513509
// Execute
@@ -520,15 +516,15 @@ describe("read_file tool XML output structure", () => {
520516
// Skip this test for now - it requires more complex mocking
521517
// of the formatResponse module which is causing issues
522518
expect(true).toBe(true)
523-
519+
524520
// Mock the file content
525521
mockInputContent = "Test content"
526-
522+
527523
// Mock the extractTextFromFile to return numbered content
528524
mockedExtractTextFromFile.mockImplementation(() => {
529525
return Promise.resolve("1 | Test content")
530526
})
531-
527+
532528
mockedCountFileLines.mockResolvedValue(1)
533529

534530
// Execute
@@ -605,30 +601,33 @@ describe("read_file tool XML output structure", () => {
605601
// Setup
606602
const startLine = 2
607603
const endLine = 5
608-
604+
609605
// For line range tests, we need to mock both readLines and addLineNumbers
610606
const content = "Line 2\nLine 3\nLine 4\nLine 5"
611607
const numberedContent = "2 | Line 2\n3 | Line 3\n4 | Line 4\n5 | Line 5"
612-
608+
613609
// Mock readLines to return the content
614610
mockedReadLines.mockResolvedValue(content)
615-
611+
616612
// Mock addLineNumbers to return the numbered content
617613
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
618614
if (start === 2) {
619615
return numberedContent
620616
}
621617
return _text || ""
622618
})
623-
619+
624620
mockedCountFileLines.mockResolvedValue(endLine)
625621
mockProvider.getState.mockResolvedValue({ maxReadFileLine: endLine })
626622

627623
// Execute with line range parameters
628-
const result = await executeReadFileTool({}, {
629-
start_line: startLine.toString(),
630-
end_line: endLine.toString()
631-
})
624+
const result = await executeReadFileTool(
625+
{},
626+
{
627+
start_line: startLine.toString(),
628+
end_line: endLine.toString(),
629+
},
630+
)
632631

633632
// Verify
634633
expect(result).toBe(
@@ -641,27 +640,30 @@ describe("read_file tool XML output structure", () => {
641640
const endLine = 3
642641
const content = "Line 1\nLine 2\nLine 3"
643642
const numberedContent = "1 | Line 1\n2 | Line 2\n3 | Line 3"
644-
643+
645644
// Mock readLines to return the content
646645
mockedReadLines.mockResolvedValue(content)
647-
646+
648647
// Mock addLineNumbers to return the numbered content
649648
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
650649
if (start === 1) {
651650
return numberedContent
652651
}
653652
return _text || ""
654653
})
655-
654+
656655
mockedCountFileLines.mockResolvedValue(endLine)
657656
mockProvider.getState.mockResolvedValue({ maxReadFileLine: 500 })
658657

659658
// Execute with line range parameters
660-
const result = await executeReadFileTool({}, {
661-
start_line: "1",
662-
end_line: endLine.toString(),
663-
totalLines: endLine
664-
})
659+
const result = await executeReadFileTool(
660+
{},
661+
{
662+
start_line: "1",
663+
end_line: endLine.toString(),
664+
totalLines: endLine,
665+
},
666+
)
665667

666668
// Verify
667669
expect(result).toBe(
@@ -727,27 +729,30 @@ describe("read_file tool XML output structure", () => {
727729
const startLine = 3
728730
const content = "Line 3\nLine 4\nLine 5"
729731
const numberedContent = "3 | Line 3\n4 | Line 4\n5 | Line 5"
730-
732+
731733
// Mock readLines to return the content
732734
mockedReadLines.mockResolvedValue(content)
733-
735+
734736
// Mock addLineNumbers to return the numbered content
735737
addLineNumbersMock.mockImplementation((_text?: any, start?: any) => {
736738
if (start === 3) {
737739
return numberedContent
738740
}
739741
return _text || ""
740742
})
741-
743+
742744
mockedCountFileLines.mockResolvedValue(totalLines)
743745
mockProvider.getState.mockResolvedValue({ maxReadFileLine: totalLines })
744746

745747
// Execute with line range parameters
746-
const result = await executeReadFileTool({}, {
747-
start_line: startLine.toString(),
748-
end_line: totalLines.toString(),
749-
totalLines
750-
})
748+
const result = await executeReadFileTool(
749+
{},
750+
{
751+
start_line: startLine.toString(),
752+
end_line: totalLines.toString(),
753+
totalLines,
754+
},
755+
)
751756

752757
// Should adjust to actual file length
753758
expect(result).toBe(
@@ -780,11 +785,14 @@ describe("read_file tool XML output structure", () => {
780785
mockedReadLines.mockResolvedValue(rangeContent)
781786

782787
// Execute
783-
const result = await executeReadFileTool({},
788+
const result = await executeReadFileTool(
789+
{},
784790
{
785791
start_line: startLine.toString(),
786792
end_line: endLine.toString(),
787-
maxReadFileLine, totalLines },
793+
maxReadFileLine,
794+
totalLines,
795+
},
788796
)
789797

790798
// Verify

src/integrations/misc/__tests__/read-file-tool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ describe("read_file tool with maxReadFileLine setting", () => {
137137
expect(readLines).toHaveBeenCalledWith(filePath, maxReadFileLine - 1, 0)
138138
expect(addLineNumbers).toHaveBeenCalled()
139139
})
140-
})
140+
})

src/shared/__tests__/experiments.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe("experiments", () => {
1919
const experiments: Record<ExperimentId, boolean> = {
2020
powerSteering: false,
2121
concurrentFileReads: false,
22-
2322
}
2423
expect(Experiments.isEnabled(experiments, EXPERIMENT_IDS.POWER_STEERING)).toBe(false)
2524
})

0 commit comments

Comments
 (0)