Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1878,8 +1878,8 @@ describe("History resume delegation - parent metadata transitions", () => {

const atomicUpdatePair = vi.fn(
async (
firstId: string,
secondId: string,
_firstId: string,
_secondId: string,
firstUpdater: (h: HistoryItem) => HistoryItem,
secondUpdater: (h: HistoryItem) => HistoryItem,
) => {
Expand Down Expand Up @@ -1988,8 +1988,8 @@ describe("History resume delegation - parent metadata transitions", () => {
const taskHistoryStore = {
atomicUpdatePair: vi.fn(
async (
firstId: string,
secondId: string,
_firstId: string,
_secondId: string,
firstUpdater: (h: any) => any,
secondUpdater: (h: any) => any,
) => {
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/command-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ npm install

describe("command mention regex patterns", () => {
it("should match valid command mention patterns anywhere", () => {
const commandRegex = /\/([a-zA-Z0-9_\.-]+)(?=\s|$)/g
const commandRegex = /\/([a-zA-Z0-9_.-]+)(?=\s|$)/g

const validPatterns = ["/setup", "/build-prod", "/test_suite", "/my-command", "/command123"]

Expand All @@ -284,19 +284,19 @@ npm install
})

it("should match command patterns in middle of text", () => {
const commandRegex = /\/([a-zA-Z0-9_\.-]+)(?=\s|$)/g
const commandRegex = /\/([a-zA-Z0-9_.-]+)(?=\s|$)/g

const validPatterns = ["Please /setup", "Run /build now", "Use /deploy here"]

validPatterns.forEach((pattern) => {
const match = pattern.match(commandRegex)
expect(match).toBeTruthy()
expect(match![0]).toMatch(/^\/[a-zA-Z0-9_\.-]+$/)
expect(match![0]).toMatch(/^\/[a-zA-Z0-9_.-]+$/)
})
})

it("should match commands at start of new lines", () => {
const commandRegex = /\/([a-zA-Z0-9_\.-]+)(?=\s|$)/g
const commandRegex = /\/([a-zA-Z0-9_.-]+)(?=\s|$)/g

const multilineText = "First line\n/setup the project\nAnother line\n/deploy when ready"
const matches = multilineText.match(commandRegex)
Expand All @@ -309,7 +309,7 @@ npm install
})

it("should match multiple commands in message", () => {
const commandRegex = /(?:^|\s)\/([a-zA-Z0-9_\.-]+)(?=\s|$)/g
const commandRegex = /(?:^|\s)\/([a-zA-Z0-9_.-]+)(?=\s|$)/g

const validText = "/setup the project\nThen /deploy later"
const matches = validText.match(commandRegex)
Expand All @@ -321,7 +321,7 @@ npm install
})

it("should not match invalid command patterns", () => {
const commandRegex = /\/([a-zA-Z0-9_\.-]+)(?=\s|$)/g
const commandRegex = /\/([a-zA-Z0-9_.-]+)(?=\s|$)/g

const invalidPatterns = ["/ space", "/with space", "/with/slash", "//double", "/with@symbol"]

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/nested-delegation-resume.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { attemptCompletionTool } from "../core/tools/AttemptCompletionTool"
import { ClineProvider } from "../core/webview/ClineProvider"
import type { Task } from "../core/task/Task"
import { readTaskMessages } from "../core/task-persistence/taskMessages"
import { readApiMessages, saveApiMessages, saveTaskMessages } from "../core/task-persistence"
import { readApiMessages } from "../core/task-persistence"

describe("Nested delegation resume (A → B → C)", () => {
beforeEach(() => {
Expand Down
20 changes: 1 addition & 19 deletions src/__tests__/removeClineFromStack-delegation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// npx vitest run __tests__/removeClineFromStack-delegation.spec.ts

import { describe, it, expect, vi, type MockedFunction } from "vitest"
import { describe, it, expect, vi } from "vitest"
import { ClineProvider } from "../core/webview/ClineProvider"
import { TaskRegistry } from "../core/task/TaskRegistry"
import { PendingActionSettlementError, type Task } from "../core/task/Task"
import { makeProviderStub } from "./helpers/provider-stub"

type MockTask = Pick<Task, "taskId" | "instanceId"> &
Partial<Pick<Task, "parentTaskId" | "abort" | "abandoned">> & {
emit: ReturnType<typeof vi.fn>
abortTask: ReturnType<typeof vi.fn>
}

type PrivateClineProviderMethods = {
removeClineFromStack: (this: ClineProvider) => ReturnType<ClineProvider["removeClineFromStack"]>
cleanupFailedHistoryTask: (this: ClineProvider, task: Task, error: unknown) => Promise<void>
Expand Down Expand Up @@ -686,18 +680,6 @@ describe("onTaskCompleted callback — writes completed status before re-emittin
// Wire up the real taskCreationCallback by calling the closure that ClineProvider
// sets on `this.taskCreationCallback` during construction. We extract it from the
// prototype's init code by calling the relevant portion directly.
const listeners: Record<string, ((...args: unknown[]) => unknown)[]> = {}
const fakeTask = {
taskId: "task-1",
on: vi.fn((event: string, fn: (...args: unknown[]) => unknown) => {
listeners[event] = listeners[event] || []
listeners[event].push(fn)
}),
emit: vi.fn((event: string, ...args: unknown[]) => {
listeners[event]?.forEach((fn) => fn(...args))
}),
}

const provider = makeProviderStub({
taskHistoryStore: { get: taskHistoryStoreGet },
updateTaskHistory,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/single-open-invariant.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ describe("Single-open-task invariant", () => {
createTask,
getValues: vi.fn(() => ({})),
providerSettingsManager: { saveConfig: vi.fn() },
on: vi.fn((ev: unknown, cb: unknown) => {
on: vi.fn((ev: unknown, _cb: unknown) => {
if (ev === "taskCreated") {
// no-op for this test
}
Expand Down
4 changes: 1 addition & 3 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import delay from "delay"
import type { CommandId } from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"

import { Package } from "../shared/package"
import { getCommand } from "../utils/commands"
import { ClineProvider } from "../core/webview/ClineProvider"
import type { WebviewFocusTracker } from "../core/webview/WebviewFocusTracker"
Expand All @@ -14,7 +13,6 @@ import { handleNewTask } from "./handleTask"
import { importSettingsWithFeedback } from "../core/config/importExport"
import { MdmService } from "../services/mdm/MdmService"
import { registerRipgrepDiagnosticCommand } from "../services/ripgrep/diagnostic"
import { t } from "../i18n"

/**
* Helper to get the visible ClineProvider instance or log if not found.
Expand Down Expand Up @@ -239,7 +237,7 @@ export const openClineInNewTab = async ({ context, outputChannel, webviewFocusTr
let mdmService: MdmService | undefined
try {
mdmService = MdmService.getInstance()
} catch (error) {
} catch {
// MDM service not initialized, which is fine - extension can work without it
mdmService = undefined
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/providers/__tests__/anthropic-vertex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ describe("VertexHandler", () => {
vertexRegion: "us-central1",
})

const mockCreate = vitest.fn().mockImplementation(async (options) =>
const mockCreate = vitest.fn().mockImplementation(async (_options) =>
asyncStreamFrom([
{
type: "message_start",
Expand Down Expand Up @@ -675,7 +675,7 @@ describe("VertexHandler", () => {
]

const stream = handler.createMessage(systemPrompt, messagesWithReasoning)
const chunks = await collectStream(stream)
await collectStream(stream)

// Verify the API was called with filtered messages (no reasoning blocks)
const calledMessages = mockCreate.mock.calls[0][0].messages
Expand All @@ -702,7 +702,7 @@ describe("VertexHandler", () => {
vertexRegion: "us-central1",
})

const mockCreate = vitest.fn().mockImplementation(async (options) =>
const mockCreate = vitest.fn().mockImplementation(async (_options) =>
asyncStreamFrom([
{
type: "message_start",
Expand Down Expand Up @@ -739,7 +739,7 @@ describe("VertexHandler", () => {
]

const stream = handler.createMessage(systemPrompt, messagesWithOnlyReasoning)
const chunks = await collectStream(stream)
await collectStream(stream)

// Verify empty message was filtered out
const calledMessages = mockCreate.mock.calls[0][0].messages
Expand Down
4 changes: 2 additions & 2 deletions src/api/providers/__tests__/anthropic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ describe("AnthropicHandler", () => {
]

const stream = handler.createMessage(systemPrompt, messagesWithReasoning)
const chunks: any[] = await collectStream(stream)
await collectStream(stream)

// Verify the API was called with filtered messages (no reasoning blocks)
const calledMessages = mockCreate.mock.calls[mockCreate.mock.calls.length - 1][0].messages
Expand Down Expand Up @@ -1139,7 +1139,7 @@ describe("AnthropicHandler", () => {
]

const stream = handler.createMessage(systemPrompt, messagesWithOnlyReasoning)
const chunks: any[] = await collectStream(stream)
await collectStream(stream)

// Verify empty message was filtered out
const calledMessages = mockCreate.mock.calls[mockCreate.mock.calls.length - 1][0].messages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// npx vitest run api/providers/__tests__/base-openai-compatible-provider.spec.ts

import { Anthropic } from "@anthropic-ai/sdk"
import OpenAI from "openai"

import { type ModelInfo, openAiModelInfoSaneDefaults } from "@roo-code/types"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ describe("AwsBedrockHandler Error Handling", () => {
for await (const chunk of generator) {
chunks.push(chunk)
}
} catch (error) {
} catch {
// Expected to throw after yielding chunks
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/__tests__/bedrock-reasoning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("AwsBedrockHandler - Extended Thinking", () => {
const messages = [{ role: "user" as const, content: "Test" }]
const stream = handler.createMessage("System prompt", messages)

for await (const chunk of stream) {
for await (const _chunk of stream) {
// consume stream
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/__tests__/bedrock-vpc-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("Amazon Bedrock VPC Endpoint Functionality", () => {
// Make a request to ensure the endpoint configuration persists
try {
await handler.completePrompt("Test prompt")
} catch (error) {
} catch {
// Ignore errors, we're just testing the client configuration persistence
}

Expand Down
4 changes: 0 additions & 4 deletions src/api/providers/__tests__/bedrock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1506,12 +1506,8 @@ describe("AwsBedrockHandler", () => {
})

describe("error telemetry", () => {
let mockSend: ReturnType<typeof vi.fn>

beforeEach(() => {
mockCaptureException.mockClear()
// Get access to the mock send function from the mocked client
mockSend = vi.mocked(BedrockRuntimeClient).mock.results[0]?.value?.send
})

it("should capture telemetry on createMessage error", async () => {
Expand Down
24 changes: 12 additions & 12 deletions src/api/providers/__tests__/kimi-code.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ describe("KimiCodeHandler", () => {
it("uses API key when auth method is api-key", async () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key", kimiCodeApiKey: "my-api-key" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
const fetchSpy = vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(
vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(
new Response(JSON.stringify({ choices: [{ message: { content: "response" }, finish_reason: "stop" }] }), {
status: 200,
}),
)
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand All @@ -68,7 +68,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "oauth" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand All @@ -82,7 +82,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "oauth" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
await expect(async () => {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
}).rejects.toThrow("Not authenticated with Kimi Code")
Expand All @@ -92,7 +92,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
await expect(async () => {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
}).rejects.toThrow("Kimi Code API key is required")
Expand All @@ -109,7 +109,7 @@ describe("KimiCodeHandler", () => {
)
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand All @@ -133,10 +133,10 @@ describe("KimiCodeHandler", () => {

it("does not retry on 401 when using API key auth", async () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key", kimiCodeApiKey: "key" })
const fetchSpy = vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response(null, { status: 401 }))
vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response(null, { status: 401 }))
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
await expect(async () => {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
}).rejects.toThrow()
Expand All @@ -148,7 +148,7 @@ describe("KimiCodeHandler", () => {
vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response(null, { status: 500 }))
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
await expect(async () => {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
}).rejects.toThrow()
Expand All @@ -160,7 +160,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key", kimiCodeApiKey: "key" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand All @@ -174,7 +174,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key", kimiCodeApiKey: "key" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand Down Expand Up @@ -204,7 +204,7 @@ describe("KimiCodeHandler", () => {
const handler = new KimiCodeHandler({ kimiCodeAuthMethod: "api-key", kimiCodeApiKey: "key" })
const gen = handler.createMessage("system", [{ role: "user", content: "test" }])
try {
for await (const chunk of gen) {
for await (const _chunk of gen) {
// consume
}
} catch {
Expand Down
3 changes: 1 addition & 2 deletions src/api/providers/__tests__/lite-llm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import OpenAI from "openai"
import { Anthropic } from "@anthropic-ai/sdk"

import { LiteLLMHandler } from "../lite-llm"
Expand Down Expand Up @@ -212,7 +211,7 @@ describe("LiteLLMHandler", () => {
})

const generator = handler.createMessage(systemPrompt, messages)
const results = await collectStream(generator)
await collectStream(generator)

// Verify that create was called with max_completion_tokens instead of max_tokens
const createCall = mockCreate.mock.calls[0][0]
Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/__tests__/mimo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vi.mock("openai", () => {
return {
chat: {
completions: {
create: mockCreate.mockImplementation(async (options) =>
create: mockCreate.mockImplementation(async (_options) =>
asyncStreamFrom([
{
choices: [{ delta: { content: "Test response" }, index: 0 }],
Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/__tests__/minimax.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
import { type MinimaxModelId, minimaxDefaultModelId, minimaxModels } from "@roo-code/types"

import { MiniMaxHandler } from "../minimax"
import { asyncStreamFrom, collectStream } from "../../../test-utils/stream"
import { asyncStreamFrom } from "../../../test-utils/stream"
import { clearAllMocks } from "../../../test-utils/reset"

vitest.mock("@anthropic-ai/sdk", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/__tests__/mistral.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vi.mock("@roo-code/telemetry", () => ({
// Mock Mistral client - must come before other imports
const mockCreate = vi.fn()
const mockComplete = vi.fn()
import { asyncStreamFrom, collectStream } from "../../../test-utils/stream"
import { asyncStreamFrom } from "../../../test-utils/stream"
vi.mock("@mistralai/mistralai", () => {
return {
Mistral: vi.fn().mockImplementation(function () {
Expand Down
Loading
Loading