mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 03:29:51 +00:00
Merge pull request #882 from ozymandiashh/fix/874-cline-vscode-variants
fix(cline): scan all VS Code variants for task storage
This commit is contained in:
commit
2c69516b02
5 changed files with 86 additions and 14 deletions
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
### Fixed
|
||||
- Claude Desktop and Cowork sessions are discovered for Windows Microsoft Store (MSIX) installs. (#611)
|
||||
- Cline tasks are discovered in every VS Code variant (VS Code, VS Code Insiders, VSCodium), not just stable VS Code. (#874)
|
||||
|
||||
## 0.9.19 - 2026-07-20
|
||||
|
||||
|
|
|
|||
|
|
@ -664,7 +664,7 @@ These are starting points, not verdicts. A 60% cache hit on a single experimenta
|
|||
| **Forge** | SQLite `~/.forge/.forge.db` | Queries `conversations` read-only and parses `context.messages`. Assistant usage entries provide prompt, completion, and cached counts; CodeBurn subtracts cached from prompt for input pricing, emits one call per assistant message, and extracts tool calls plus shell commands. |
|
||||
| **Pi / OMP** | `~/.pi/agent/sessions/<sanitized-cwd>/*.jsonl` (Pi), `~/.omp/agent/sessions/<sanitized-cwd>/*.jsonl` (OMP) | Each assistant message carries usage (input, output, cacheRead, cacheWrite) plus inline `toolCall` blocks. Tool names normalize to the standard set (`bash` → `Bash`, `dispatch_agent` → `Agent`); bash commands come from `toolCall.arguments.command`. |
|
||||
| **Codebuff** (formerly Manicode) | `~/.config/manicode/projects/<project>/chats/<chatId>/chat-messages.json` (honors `CODEBUFF_DATA_DIR`; walks `manicode-dev` / `manicode-staging`) | Bills in credits, so each completed assistant message is costed at the public rate of $0.01/credit via `msg.credits`. When an upstream provider's stashed RunState records token-level usage (`message.metadata.runState.sessionState.mainAgentState.messageHistory[*].providerOptions`), the real tokens and LiteLLM cost take precedence. Native tool names (`read_files`, `str_replace`, `run_terminal_command`, `spawn_agents`) normalize to `Read`, `Edit`, `Bash`, `Agent`. |
|
||||
| **Cline / Roo Code / KiloCode** | VS Code `globalStorage`: Cline at `saoudrizwan.claude-dev` and `~/.cline/data`; Roo Code and KiloCode across VS Code, VS Code Insiders, and VSCodium | Cline-family agents. CodeBurn reads `ui_messages.json` from each task directory, extracting token counts from `type: "say"` entries with `say: "api_req_started"`. |
|
||||
| **Cline / Roo Code / KiloCode** | VS Code `globalStorage` across VS Code, VS Code Insiders, and VSCodium (Cline at `saoudrizwan.claude-dev`, plus `~/.cline/data`) | Cline-family agents. CodeBurn reads `ui_messages.json` from each task directory, extracting token counts from `type: "say"` entries with `say: "api_req_started"`. |
|
||||
| **CodeWhale** | `~/.codewhale/sessions/*.json` plus unmigrated legacy `~/.deepseek/sessions/*.json`; `$CODEWHALE_HOME/sessions` is an exact override | Emits one cumulative record per saved session. CodeWhale exposes only `total_tokens`, so CodeBurn preserves that aggregate in the input column rather than inventing an input/output split. Cost is the exact stored parent-session plus subagent USD total; model pricing is used only when the cost snapshot is absent. Tool blocks, shell commands, skills, and subagent types are retained. |
|
||||
| **IBM Bob** | `User/globalStorage/ibm.bob-code/tasks/<task-id>/` (GA `IBM Bob` and preview `Bob-IDE` app folders) | Reads `ui_messages.json` for API request token/cost records and `api_conversation_history.json` for the selected model. |
|
||||
| **Kimi Code CLI** | `$KIMI_SHARE_DIR/sessions/<workdir-hash>/<session-id>/` or `~/.kimi/sessions/<workdir-hash>/<session-id>/` | Reads `wire.jsonl` `StatusUpdate.token_usage` records, mapping `input_other`, `input_cache_read`, `input_cache_creation`, and `output` into the standard token columns; includes subagents under each session's `subagents/` folder. |
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ Cline VS Code extension and Cline home-data task storage.
|
|||
|
||||
## Where it reads from
|
||||
|
||||
Two task roots are scanned:
|
||||
These task roots are scanned:
|
||||
|
||||
1. VS Code extension globalStorage for `saoudrizwan.claude-dev`.
|
||||
1. VS Code extension globalStorage for `saoudrizwan.claude-dev`, in every supported VS Code variant: stable (`Code`), Insiders (`Code - Insiders`), and VSCodium. The per-platform paths come from `getVSCodeGlobalStoragePaths` in `src/providers/vscode-cline-parser.ts`, the same helper Roo Code and KiloCode use.
|
||||
2. Cline's home-data root at `~/.cline/data`.
|
||||
|
||||
Both roots are expected to contain a `tasks/` child directory. Discovery is delegated to `discoverClineTasks` in `src/providers/vscode-cline-parser.ts`, so a task is only included when it has a `ui_messages.json` file.
|
||||
Every root is expected to contain a `tasks/` child directory. Discovery is delegated to `discoverClineTasks` in `src/providers/vscode-cline-parser.ts`, so a task is only included when it has a `ui_messages.json` file.
|
||||
|
||||
## Storage format
|
||||
|
||||
|
|
@ -35,12 +35,13 @@ None at the provider level; delegates to the shared helper and normal parser/cac
|
|||
|
||||
## Deduplication
|
||||
|
||||
Discovery deduplicates by task id across the two Cline roots so a migrated task is not scanned twice. If the same task id exists in multiple roots, the one with the newest `ui_messages.json` wins. Parsing still uses the shared per-call key: `<providerName>:<taskId>:<index>`.
|
||||
Discovery deduplicates by task id across all Cline roots so a task that exists in more than one root (a migration, or the same extension storage seen by two VS Code variants) is not scanned twice. If the same task id exists in multiple roots, the one with the newest `ui_messages.json` wins. Parsing still uses the shared per-call key: `<providerName>:<taskId>:<index>`.
|
||||
|
||||
## Quirks
|
||||
|
||||
- This provider is intentionally a thin wrapper over the shared Cline-family parser.
|
||||
- Cline can keep data in both VS Code globalStorage and `~/.cline/data`, depending on version and workflow.
|
||||
- A user can run Cline in VS Code stable, Insiders, and VSCodium at the same time; each variant has its own globalStorage tree, so all of them must be scanned.
|
||||
- If Cline changes the JSON shape, fix `vscode-cline-parser.ts` only if Roo Code and KiloCode still pass. Branch provider-specific parsing rather than duplicating the whole parser.
|
||||
|
||||
## When fixing a bug here
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { stat } from 'fs/promises'
|
|||
import { homedir } from 'os'
|
||||
import { basename, join } from 'path'
|
||||
|
||||
import { discoverClineTasks, createClineParser, getVSCodeGlobalStoragePath } from './vscode-cline-parser.js'
|
||||
import { discoverClineTasks, createClineParser, getVSCodeGlobalStoragePaths } from './vscode-cline-parser.js'
|
||||
import type { Provider, SessionSource, SessionParser } from './types.js'
|
||||
|
||||
const EXTENSION_ID = 'saoudrizwan.claude-dev'
|
||||
|
|
@ -13,7 +13,7 @@ export function getClineDataPath(): string {
|
|||
|
||||
function normalizeOverrideDirs(overrideDirs?: string | string[]): string[] | undefined {
|
||||
if (overrideDirs === undefined) return undefined
|
||||
// Cline has two default roots, so tests and future callers can override one or both.
|
||||
// Cline has several default roots, so tests and future callers can override one or all.
|
||||
return Array.isArray(overrideDirs) ? overrideDirs : [overrideDirs]
|
||||
}
|
||||
|
||||
|
|
@ -52,16 +52,15 @@ export function createClineProvider(overrideDirs?: string | string[]): Provider
|
|||
},
|
||||
|
||||
async discoverSessions(): Promise<SessionSource[]> {
|
||||
// Cline may be installed in any VS Code variant (stable, Insiders,
|
||||
// VSCodium), so every globalStorage root is scanned - same as the Roo Code
|
||||
// and KiloCode siblings - plus Cline's own home-data root.
|
||||
const baseDirs = configuredDirs ?? [
|
||||
getVSCodeGlobalStoragePath(EXTENSION_ID),
|
||||
...getVSCodeGlobalStoragePaths(EXTENSION_ID),
|
||||
getClineDataPath(),
|
||||
]
|
||||
|
||||
const sources = await Promise.all(
|
||||
baseDirs.map(dir => discoverClineTasks(EXTENSION_ID, 'cline', 'Cline', dir)),
|
||||
)
|
||||
|
||||
return dedupeTaskSources(sources.flat())
|
||||
return dedupeTaskSources(await discoverClineTasks(EXTENSION_ID, 'cline', 'Cline', baseDirs))
|
||||
},
|
||||
|
||||
createSessionParser(source: SessionSource, seenKeys: Set<string>): SessionParser {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ import { mkdtemp, mkdir, writeFile, rm, utimes } from 'fs/promises'
|
|||
import { join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
|
||||
import { cline, createClineProvider } from '../../src/providers/cline.js'
|
||||
import { cline, createClineProvider, getClineDataPath } from '../../src/providers/cline.js'
|
||||
import { getVSCodeGlobalStoragePaths } from '../../src/providers/vscode-cline-parser.js'
|
||||
import type { ParsedProviderCall } from '../../src/providers/types.js'
|
||||
|
||||
const EXTENSION_ID = 'saoudrizwan.claude-dev'
|
||||
|
||||
let tmpDir: string
|
||||
|
||||
async function writeTask(baseDir: string, taskId: string, opts?: {
|
||||
|
|
@ -93,6 +96,74 @@ describe('cline provider - discovery', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('cline provider - default roots', () => {
|
||||
let previousUserProfile: string | undefined
|
||||
|
||||
beforeEach(async () => {
|
||||
tmpDir = await mkdtemp(join(tmpdir(), 'cline-test-'))
|
||||
previousUserProfile = process.env['USERPROFILE']
|
||||
// os.homedir() reads HOME on POSIX and USERPROFILE on Windows - set both so
|
||||
// the default roots resolve inside the sandbox on every platform.
|
||||
process.env['HOME'] = tmpDir
|
||||
process.env['USERPROFILE'] = tmpDir
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
if (previousUserProfile === undefined) delete process.env['USERPROFILE']
|
||||
else process.env['USERPROFILE'] = previousUserProfile
|
||||
await rm(tmpDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('discovers tasks from every VS Code variant (stable, Insiders, VSCodium)', async () => {
|
||||
const roots = getVSCodeGlobalStoragePaths(EXTENSION_ID)
|
||||
expect(roots).toHaveLength(3)
|
||||
const [stableRoot, insidersRoot, codiumRoot] = roots
|
||||
await writeTask(stableRoot!, 'task-stable')
|
||||
await writeTask(insidersRoot!, 'task-insiders')
|
||||
await writeTask(codiumRoot!, 'task-codium')
|
||||
|
||||
const sessions = await createClineProvider().discoverSessions()
|
||||
|
||||
expect(sessions).toHaveLength(3)
|
||||
expect(sessions.every(s => s.provider === 'cline')).toBe(true)
|
||||
expect(sessions.map(s => s.path).sort()).toEqual([
|
||||
join(stableRoot!, 'tasks', 'task-stable'),
|
||||
join(insidersRoot!, 'tasks', 'task-insiders'),
|
||||
join(codiumRoot!, 'tasks', 'task-codium'),
|
||||
].sort())
|
||||
})
|
||||
|
||||
it('still scans the ~/.cline/data root alongside the VS Code variants', async () => {
|
||||
const stableRoot = getVSCodeGlobalStoragePaths(EXTENSION_ID)[0]!
|
||||
const clineDataDir = getClineDataPath()
|
||||
expect(clineDataDir).toBe(join(tmpDir, '.cline', 'data'))
|
||||
await writeTask(stableRoot, 'task-vscode')
|
||||
await writeTask(clineDataDir, 'task-home')
|
||||
|
||||
const sessions = await createClineProvider().discoverSessions()
|
||||
|
||||
expect(sessions.map(s => s.path).sort()).toEqual([
|
||||
join(stableRoot, 'tasks', 'task-vscode'),
|
||||
join(clineDataDir, 'tasks', 'task-home'),
|
||||
].sort())
|
||||
})
|
||||
|
||||
it('does not double-count a task id shared by several VS Code variants', async () => {
|
||||
const [stableRoot, insidersRoot, codiumRoot] = getVSCodeGlobalStoragePaths(EXTENSION_ID)
|
||||
const stableTask = await writeTask(stableRoot!, 'task-same')
|
||||
const insidersTask = await writeTask(insidersRoot!, 'task-same')
|
||||
const codiumTask = await writeTask(codiumRoot!, 'task-same')
|
||||
await utimes(join(stableTask, 'ui_messages.json'), new Date('2026-01-01T00:00:00Z'), new Date('2026-01-01T00:00:00Z'))
|
||||
await utimes(join(codiumTask, 'ui_messages.json'), new Date('2026-02-01T00:00:00Z'), new Date('2026-02-01T00:00:00Z'))
|
||||
await utimes(join(insidersTask, 'ui_messages.json'), new Date('2026-03-01T00:00:00Z'), new Date('2026-03-01T00:00:00Z'))
|
||||
|
||||
const sessions = await createClineProvider().discoverSessions()
|
||||
|
||||
expect(sessions).toHaveLength(1)
|
||||
expect(sessions[0]!.path).toBe(insidersTask)
|
||||
})
|
||||
})
|
||||
|
||||
describe('cline provider - parsing', () => {
|
||||
beforeEach(async () => {
|
||||
tmpDir = await mkdtemp(join(tmpdir(), 'cline-test-'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue