From e8c13f0ac301aa3409cfc01e6de0c3cb9bba627f Mon Sep 17 00:00:00 2001 From: TheoDZzz Date: Sat, 14 Nov 2026 04:28:01 +0000 Subject: [PATCH] Discover Kimi Code managed workspace sessions --- docs/providers/kimicode.md | 4 +++- src/daily-cache.ts | 4 +++- src/providers/kimicode.ts | 2 +- tests/providers/kimicode.test.ts | 10 +++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/providers/kimicode.md b/docs/providers/kimicode.md index a92356bb1..84399fdac 100644 --- a/docs/providers/kimicode.md +++ b/docs/providers/kimicode.md @@ -18,11 +18,13 @@ By default the provider scans every known Kimi Code runtime store: Setting `KIMI_CODE_HOME` (or passing a home override) narrows the scan to that single home. Inside each home it scans: ```text -$HOME/sessions/wd_*// +$HOME/sessions/// ├── state.json └── agents//wire.jsonl ``` +Implicit workspaces use `wd__` and managed workspaces use `wm_`. + Session directory naming depends on the host product: the CLI uses `session_*`, embedded runtimes use `conv-*` / `ctitle-*`. Any directory is accepted; the `agents/*/wire.jsonl` probe gates real sessions. Every agent wire is a cache source. Main-agent and subagent calls share the session ID from the `session_*` directory. `state.json.workDir` supplies the project name and path. `probeRoots()` reports the resolved Kimi Code home for `codeburn doctor` even when there are no sessions. diff --git a/src/daily-cache.ts b/src/daily-cache.ts index 98ef281f5..9c13cb053 100644 --- a/src/daily-cache.ts +++ b/src/daily-cache.ts @@ -388,7 +388,9 @@ import type { DateRange, ProjectSummary } from './types.js' // 79. Qwen and Hermes tokens, Droid model ids, Cline-family recorded costs, // Antigravity output, Warp exchange shares and version-boundary pricing change // with calls unchanged or rising, which the bump alone re-derives. -export const DAILY_CACHE_VERSION = 79 +// v80: include Kimi Code managed workspaces in settled days. Discovery adds +// calls without changing existing ones, so no provider exemption is needed. +export const DAILY_CACHE_VERSION = 80 const MIN_SUPPORTED_VERSION = 28 /// Providers whose per-day CALL COUNT means something different at diff --git a/src/providers/kimicode.ts b/src/providers/kimicode.ts index 1aa62a559..664658f6e 100644 --- a/src/providers/kimicode.ts +++ b/src/providers/kimicode.ts @@ -155,7 +155,7 @@ async function discoverSources(root: string): Promise { const sessionsDir = join(root, 'sessions') const workDirs = (await directoryEntries(sessionsDir)) - .filter(e => e.isDirectory() && e.name.startsWith('wd_')) + .filter(e => e.isDirectory() && (e.name.startsWith('wd_') || e.name.startsWith('wm_'))) .map(e => ({ key: e.name, path: join(sessionsDir, e.name) })) // Session dir naming differs by host product: the CLI uses session_*, diff --git a/tests/providers/kimicode.test.ts b/tests/providers/kimicode.test.ts index 88767e263..7dec11538 100644 --- a/tests/providers/kimicode.test.ts +++ b/tests/providers/kimicode.test.ts @@ -95,11 +95,12 @@ async function writeSession( sessionId: string, agents: FixtureAgent[], workDir = '/workspace/neutral-project', + workspaceId = 'wd_neutral-project_0123456789ab', ): Promise { const sessionDir = join( fixtureHome, 'sessions', - 'wd_neutral-project_0123456789ab', + workspaceId, `session_${sessionId}`, ) await mkdir(sessionDir, { recursive: true }) @@ -368,7 +369,10 @@ describe('Kimi Code provider', () => { })).resolves.toEqual([]) }) - it('counts main and subagent usage once each under the same session', async () => { + it.each([ + 'wd_neutral-project_0123456789ab', + 'wm_00000000-0000-4000-8000-000000000001', + ])('counts main and subagent usage once each in workspace %s', async workspaceId => { await writeSession('subagent', [ { id: 'main', lines: [ prompt('Coordinate a neutral task.', 1782900400000), @@ -379,7 +383,7 @@ describe('Kimi Code provider', () => { request('0.1', 'helper-alias', 'glm-5.2', 1782900403000), usage('helper-alias', 1782900404000, { input: 15, output: 4 }), ] }, - ]) + ], '/workspace/neutral-project', workspaceId) const provider = createKimicodeProvider(fixtureHome) const sources = await provider.discoverSessions() const seen = new Set()