Skip to content
Open
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
4 changes: 3 additions & 1 deletion docs/providers/kimicode.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_*/<session-dir>/
$HOME/sessions/<workspace-id>/<session-dir>/
├── state.json
└── agents/<agent-id>/wire.jsonl
```

Implicit workspaces use `wd_<slug>_<hash>` and managed workspaces use `wm_<uuid>`.

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.
Expand Down
4 changes: 3 additions & 1 deletion src/daily-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/providers/kimicode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async function discoverSources(root: string): Promise<SessionSource[]> {
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_*,
Expand Down
10 changes: 7 additions & 3 deletions tests/providers/kimicode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ async function writeSession(
sessionId: string,
agents: FixtureAgent[],
workDir = '/workspace/neutral-project',
workspaceId = 'wd_neutral-project_0123456789ab',
): Promise<string[]> {
const sessionDir = join(
fixtureHome,
'sessions',
'wd_neutral-project_0123456789ab',
workspaceId,
`session_${sessionId}`,
)
await mkdir(sessionDir, { recursive: true })
Expand Down Expand Up @@ -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),
Expand All @@ -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<string>()
Expand Down
Loading