Objective
Add a kimi source adapter for Kimi CLI wire logs.
Source shape to support
- directory-backed source under
~/.kimi/sessions/**/wire.jsonl
- token usage arrives on
StatusUpdate messages inside the wire stream
- nearby config can improve model metadata
- repeated status messages may need deduplication
Implementation plan
-
Adapter file
- add
src/sources/kimi/kimi-source-adapter.ts
- implement
SourceAdapter with id = 'kimi'
-
Discovery
- discover only
wire.jsonl files rather than every JSONL in the tree
- keep the adapter directory-backed and reachable via
--source-dir kimi=...
-
Parsing
- stream JSONL rows and process
StatusUpdate messages only
- derive
sessionId from the path when the wire format does not supply a better stable identifier
- if nearby config provides model metadata, load it in a narrow/safe way
- expose that config file through
getParseDependencies() so parse-cache invalidation stays correct when model config changes
- normalize timestamps from numeric/float wire timestamps and fall back to file mtime when needed
- skip zero-token updates
- if the format can repeat identical message usage, deduplicate on a stable key rather than double counting
- cost should stay estimated unless the source provides explicit cost
-
Wiring
- register
kimi in src/sources/create-default-adapters.ts
- keep source selection/help output in sync with the new source id
- use generic
--source-dir support; no dedicated flag needed
-
Tests and docs
- add
tests/sources/kimi-source-adapter.test.ts
- update registry/help tests and
README.md
Code paths to touch
src/sources/kimi/kimi-source-adapter.ts
src/sources/create-default-adapters.ts
src/utils/discover-files.ts
src/utils/read-jsonl-objects.ts
src/sources/parsing-utils.ts
src/domain/usage-event.ts
tests/sources/kimi-source-adapter.test.ts
tests/sources/create-default-adapters.test.ts
tests/cli/create-cli.test.ts
README.md
Verification
- parser fixtures cover:
- single-turn and multi-turn
StatusUpdate streams
- zero-token updates skipped
- numeric/float timestamp normalization
- config-assisted model resolution
- parse dependency invalidation for the nearby config file
- deduplication if the same message usage repeats
llm-usage daily --source kimi --source-dir kimi=<fixture-dir> works
- full validation passes:
pnpm run lint
pnpm run typecheck
pnpm run test
pnpm run format:check
Objective
Add a
kimisource adapter for Kimi CLI wire logs.Source shape to support
~/.kimi/sessions/**/wire.jsonlStatusUpdatemessages inside the wire streamImplementation plan
Adapter file
src/sources/kimi/kimi-source-adapter.tsSourceAdapterwithid = 'kimi'Discovery
wire.jsonlfiles rather than every JSONL in the tree--source-dir kimi=...Parsing
StatusUpdatemessages onlysessionIdfrom the path when the wire format does not supply a better stable identifiergetParseDependencies()so parse-cache invalidation stays correct when model config changesWiring
kimiinsrc/sources/create-default-adapters.ts--source-dirsupport; no dedicated flag neededTests and docs
tests/sources/kimi-source-adapter.test.tsREADME.mdCode paths to touch
src/sources/kimi/kimi-source-adapter.tssrc/sources/create-default-adapters.tssrc/utils/discover-files.tssrc/utils/read-jsonl-objects.tssrc/sources/parsing-utils.tssrc/domain/usage-event.tstests/sources/kimi-source-adapter.test.tstests/sources/create-default-adapters.test.tstests/cli/create-cli.test.tsREADME.mdVerification
StatusUpdatestreamsllm-usage daily --source kimi --source-dir kimi=<fixture-dir>workspnpm run lintpnpm run typecheckpnpm run testpnpm run format:check