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
5 changes: 0 additions & 5 deletions .changeset/fix-macos-cli-spawn-path.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/giant-buckets-clap.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hungry-lands-sin.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/large-jars-train.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/olive-carpets-swim.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/petite-moose-wish.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/salty-shirts-guess.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/session-title-generated-event.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/small-towns-march.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/stale-towns-bathe.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/tricky-glasses-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Added model selection support below prompt for Z.ai
5 changes: 0 additions & 5 deletions .changeset/vast-results-cheat.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/yellow-plants-work.md

This file was deleted.

32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# kilo-code

## 4.140.1

### Patch Changes

- [#4615](https://github.com/Kilo-Org/kilocode/pull/4615) [`6909640`](https://github.com/Kilo-Org/kilocode/commit/690964040770cd21248e1bea964c995d8620d8e8) Thanks [@marius-kilocode](https://github.com/marius-kilocode)! - Add Agent Manager terminal switching so existing session terminals are revealed when changing sessions.

- [#4586](https://github.com/Kilo-Org/kilocode/pull/4586) [`a3988cd`](https://github.com/Kilo-Org/kilocode/commit/a3988cd201f21f7b7616d68cb2bb2c0387dd91c2) Thanks [@marius-kilocode](https://github.com/marius-kilocode)! - Fix Agent Manager failing to start on macOS when launched from Finder/Spotlight

- [#4561](https://github.com/Kilo-Org/kilocode/pull/4561) [`3c18860`](https://github.com/Kilo-Org/kilocode/commit/3c188603cc4d8375be4abf6e1bb9217b64e9cd2b) Thanks [@jrf0110](https://github.com/jrf0110)! - Introduces AI contribution tracking so users can better understand agentic coding impact

- [#4526](https://github.com/Kilo-Org/kilocode/pull/4526) [`10b4d6c`](https://github.com/Kilo-Org/kilocode/commit/10b4d6c02f5b310dd6e44204fa40675ca4d3d99b) Thanks [@chrarnoldus](https://github.com/chrarnoldus)! - Reduce the incidence of read_file errors when using Claude models.

- [#4560](https://github.com/Kilo-Org/kilocode/pull/4560) [`5bdfe6b`](https://github.com/Kilo-Org/kilocode/commit/5bdfe6b9b68acf345e302791c15291c05a043204) Thanks [@crazyrabbit0](https://github.com/crazyrabbit0)! - chore: update Gemini Cli models and metadata

- Added gemini-3-flash-preview model configuration.
- Updated maxThinkingTokens for gemini-3-pro-preview to 32,768.
- Reordered model definitions to prioritize newer versions.

- [#4596](https://github.com/Kilo-Org/kilocode/pull/4596) [`1c33884`](https://github.com/Kilo-Org/kilocode/commit/1c3388442bd9a06dcb8aed29431c138726dbedc8) Thanks [@hank9999](https://github.com/hank9999)! - Fix duplicate tool use in Anthropic

- [#4620](https://github.com/Kilo-Org/kilocode/pull/4620) [`ae6818b`](https://github.com/Kilo-Org/kilocode/commit/ae6818b5ea2d5504f9ee5eff9bdd963d9d82c51e) Thanks [@chrarnoldus](https://github.com/chrarnoldus)! - Fix duplictate tool call processing in Chutes, DeepInfra, LiteLLM and xAI providers.

- [#4597](https://github.com/Kilo-Org/kilocode/pull/4597) [`e2bb5c1`](https://github.com/Kilo-Org/kilocode/commit/e2bb5c1891b6319954b46fcca3b35807fc1f8f90) Thanks [@marius-kilocode](https://github.com/marius-kilocode)! - Fix Agent Manager not showing error when CLI is misconfigured. When the CLI exits with a configuration error (e.g., missing kilocodeToken), the extension now detects this and shows an error popup with options to run `kilocode auth` or `kilocode config`.

- [#4590](https://github.com/Kilo-Org/kilocode/pull/4590) [`f2cc065`](https://github.com/Kilo-Org/kilocode/commit/f2cc0657870ae77a5720a872c9cd11b8315799b7) Thanks [@kiloconnect](https://github.com/apps/kiloconnect)! - feat: add session_title_generated event emission to CLI

- [#4523](https://github.com/Kilo-Org/kilocode/pull/4523) [`e259b04`](https://github.com/Kilo-Org/kilocode/commit/e259b04037c71a9bdd9e53c174b70a975e772833) Thanks [@markijbema](https://github.com/markijbema)! - Add chat autocomplete telemetry

- [#4582](https://github.com/Kilo-Org/kilocode/pull/4582) [`3de2547`](https://github.com/Kilo-Org/kilocode/commit/3de254757049d08d3c0c100768acc564d6de4888) Thanks [@catrielmuller](https://github.com/catrielmuller)! - Jetbrains - Autocomplete Telemetry

- [#4488](https://github.com/Kilo-Org/kilocode/pull/4488) [`f7c3715`](https://github.com/Kilo-Org/kilocode/commit/f7c3715b4b7fea9fcd363d12bfb9467e9f169729) Thanks [@lifesized](https://github.com/lifesized)! - fix(ollama): fix model not found error and context window display

## 4.140.0

### Minor Changes
Expand Down
10 changes: 10 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @kilocode/cli

## 0.18.0

### Minor Changes

- [#4583](https://github.com/Kilo-Org/kilocode/pull/4583) [`845f8c1`](https://github.com/Kilo-Org/kilocode/commit/845f8c13b23496bf4aaf0792be9d52bf26645b64) Thanks [@kiloconnect](https://github.com/apps/kiloconnect)! - Add markdown theming support for Reasoning box content

### Patch Changes

- [#4590](https://github.com/Kilo-Org/kilocode/pull/4590) [`f2cc065`](https://github.com/Kilo-Org/kilocode/commit/f2cc0657870ae77a5720a872c9cd11b8315799b7) Thanks [@kiloconnect](https://github.com/apps/kiloconnect)! - feat: add session_title_generated event emission to CLI

## 0.17.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion cli/package.dist.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kilocode/cli",
"version": "0.17.1",
"version": "0.18.0",
"description": "Terminal User Interface for Kilo Code",
"type": "module",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kilocode/cli",
"version": "0.17.1",
"version": "0.18.0",
"description": "Terminal User Interface for Kilo Code",
"type": "module",
"main": "dist/index.js",
Expand Down
29 changes: 29 additions & 0 deletions src/api/providers/kilocode/chunk-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as z from "zod/v4"

export const OpenRouterChunkSchema = z.object({
provider: z.string().optional(),
})

export const VercelAiGatewayChunkSchema = z.object({
choices: z.array(
z.object({
delta: z.object({
provider_metadata: z
.object({
gateway: z
.object({
routing: z
.object({
resolvedProvider: z.string().optional(),
})
.optional(),
})
.optional(),
})
.optional(),
}),
}),
),
})

export const KiloCodeChunkSchema = OpenRouterChunkSchema.and(VercelAiGatewayChunkSchema)
10 changes: 6 additions & 4 deletions src/api/providers/openrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { isAnyRecognizedKiloCodeError } from "../../shared/kilocode/errorUtils"
import type { ApiHandlerCreateMessageMetadata, SingleCompletionHandler } from "../index"
import { handleOpenAIError } from "./utils/openai-error-handler"
import { generateImageWithProvider, ImageGenerationResult } from "./utils/image-generation"
import { KiloCodeChunkSchema } from "./kilocode/chunk-schema"

// Add custom interface for OpenRouter params.
type OpenRouterChatCompletionParams = OpenAI.Chat.ChatCompletionCreateParams & {
Expand Down Expand Up @@ -341,7 +342,6 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH

let lastUsage: CompletionUsage | undefined = undefined
let inferenceProvider: string | undefined // kilocode_change
const toolCallAccumulator = new Map<number, { id: string; name: string; arguments: string }>()
// Accumulator for reasoning_details: accumulate text by type-index key
const reasoningDetailsAccumulator = new Map<
string,
Expand All @@ -364,9 +364,11 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
}

// kilocode_change start
if ("provider" in chunk && typeof chunk.provider === "string") {
inferenceProvider = chunk.provider
}
const kiloCodeChunk = KiloCodeChunkSchema.safeParse(chunk).data
inferenceProvider =
kiloCodeChunk?.choices?.[0]?.delta?.provider_metadata?.gateway?.routing?.resolvedProvider ??
kiloCodeChunk?.provider ??
inferenceProvider
// kilocode_change end

verifyFinishReason(chunk.choices[0]) // kilocode_change
Expand Down
39 changes: 37 additions & 2 deletions src/core/kilocode/agent-manager/AgentManagerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { t } from "i18next"
import { AgentRegistry } from "./AgentRegistry"
import { renameMapKey } from "./mapUtils"
import {
buildParallelModeWorktreePath,
parseParallelModeBranch,
parseParallelModeWorktreePath,
isParallelModeCompletionMessage,
Expand Down Expand Up @@ -38,6 +39,7 @@ import type { ClineProvider } from "../../webview/ClineProvider"
import { extractSessionConfigs, MAX_VERSION_COUNT } from "./multiVersionUtils"
import { SessionManager } from "../../../shared/kilocode/cli-sessions/core/SessionManager"
import { WorkspaceGitService } from "./WorkspaceGitService"
import { SessionTerminalManager } from "./SessionTerminalManager"

/**
* AgentManagerProvider
Expand All @@ -54,6 +56,7 @@ export class AgentManagerProvider implements vscode.Disposable {
private remoteSessionService: RemoteSessionService
private processHandler: CliProcessHandler
private eventProcessor: KilocodeEventProcessor
private terminalManager: SessionTerminalManager
private sessionMessages: Map<string, ClineMessage[]> = new Map()
// Track first api_req_started per session to filter user-input echoes
private firstApiReqStarted: Map<string, boolean> = new Map()
Expand All @@ -72,6 +75,7 @@ export class AgentManagerProvider implements vscode.Disposable {
) {
this.registry = new AgentRegistry()
this.remoteSessionService = new RemoteSessionService({ outputChannel })
this.terminalManager = new SessionTerminalManager(this.registry, this.outputChannel)

// Initialize currentGitUrl from workspace
void this.initializeCurrentGitUrl()
Expand Down Expand Up @@ -288,6 +292,9 @@ export class AgentManagerProvider implements vscode.Disposable {
case "agentManager.refreshSessionMessages":
void this.refreshSessionMessages(message.sessionId as string)
break
case "agentManager.showTerminal":
this.terminalManager.showTerminal(message.sessionId as string)
break
case "agentManager.sessionShare":
SessionManager.init()
?.shareSession(message.sessionId as string)
Expand Down Expand Up @@ -669,17 +676,42 @@ export class AgentManagerProvider implements vscode.Disposable {
}

/**
* Handle welcome event from CLI - extracts worktree branch for parallel mode sessions
* Handle welcome event from CLI - extracts worktree branch and path for parallel mode sessions
*/
private handleWelcomeEvent(sessionId: string, event: WelcomeStreamEvent): void {
let updated = false
const session = this.registry.getSession(sessionId)
const existingWorktreePath = session?.parallelMode?.worktreePath

if (event.worktreeBranch) {
this.outputChannel.appendLine(
`[AgentManager] Session ${sessionId} worktree branch: ${event.worktreeBranch}`,
)
if (this.registry.updateParallelModeInfo(sessionId, { branch: event.worktreeBranch })) {
this.postStateToWebview()
updated = true
}
}

if (event.worktreePath) {
this.outputChannel.appendLine(`[AgentManager] Session ${sessionId} worktree path: ${event.worktreePath}`)
if (this.registry.updateParallelModeInfo(sessionId, { worktreePath: event.worktreePath })) {
updated = true
}
}

if (!event.worktreePath && event.worktreeBranch && !existingWorktreePath) {
const derivedWorktreePath = buildParallelModeWorktreePath(event.worktreeBranch)
this.outputChannel.appendLine(
`[AgentManager] Session ${sessionId} derived worktree path: ${derivedWorktreePath}`,
)
if (this.registry.updateParallelModeInfo(sessionId, { worktreePath: derivedWorktreePath })) {
updated = true
}
}

if (updated) {
this.postStateToWebview()
}
}

private handleKilocodeEvent(sessionId: string, event: KilocodeStreamEvent): void {
Expand All @@ -699,6 +731,8 @@ export class AgentManagerProvider implements vscode.Disposable {

if (!sessionId) return

this.terminalManager.showExistingTerminal(sessionId)

// Check if we have cached messages to send immediately
const cachedMessages = this.sessionMessages.get(sessionId)
if (cachedMessages) {
Expand Down Expand Up @@ -1165,6 +1199,7 @@ export class AgentManagerProvider implements vscode.Disposable {

public dispose(): void {
this.processHandler.dispose()
this.terminalManager.dispose()
this.sessionMessages.clear()
this.firstApiReqStarted.clear()

Expand Down
34 changes: 22 additions & 12 deletions src/core/kilocode/agent-manager/AgentRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ export class AgentRegistry {
info: Partial<Omit<ParallelModeInfo, "enabled">>,
): AgentSession | undefined {
const session = this.sessions.get(id)
if (!session || !session.parallelMode?.enabled) {
if (!session) {
return undefined
}

const currentParallelMode = session.parallelMode ?? { enabled: true }

session.parallelMode = {
...session.parallelMode,
...currentParallelMode,
...info,
enabled: true,
}

return session
Expand Down Expand Up @@ -214,19 +217,26 @@ export class AgentRegistry {
* Used when upgrading a provisional session to a real session ID.
*/
public renameSession(oldId: string, newId: string): boolean {
const session = this.sessions.get(oldId)
if (!session) {
return false
if (oldId === newId) {
return this.sessions.has(oldId)
}

// Update the session's internal ID
session.sessionId = newId

// Move in the map
this.sessions.delete(oldId)
this.sessions.set(newId, session)
const oldSession = this.sessions.get(oldId)
if (!oldSession) {
return false
}

// Update selectedId if it was pointing to the old ID
const targetSession = this.sessions.get(newId)
if (targetSession) {
// Prefer keeping the target session object (e.g. resuming an existing session),
// but merge in any provisional logs so early streaming isn't lost.
targetSession.logs = [...oldSession.logs, ...targetSession.logs]
this.sessions.delete(oldId)
} else {
this.sessions.delete(oldId)
oldSession.sessionId = newId
this.sessions.set(newId, oldSession)
}
if (this._selectedId === oldId) {
this._selectedId = newId
}
Expand Down
Loading