Skip to content

feat(source): add Kilo Code adapter #64

@ayagmar

Description

@ayagmar

Objective

Add a kilocode source adapter for Kilo Code task logs, reusing the same parsing path as Roo Code instead of introducing duplicate logic.

Source shape to support

  • directory-backed task source under .../kilocode.kilo-code/tasks/**/ui_messages.json
  • log shape mirrors Roo Code task logs
  • sibling api_conversation_history.json can provide model/agent metadata
  • task log payloads can include explicit cost and token counts

Implementation plan

  1. Adapter file

    • add src/sources/kilocode/kilocode-source-adapter.ts
    • implement SourceAdapter with id = 'kilocode'
  2. Shared parser strategy

    • do not copy/paste Roo Code parsing logic
    • either reuse a helper owned by the Roo Code source implementation or extract a small shared helper for Roo Code + Kilo Code task-log parsing
    • keep one decisive parsing path so future fixes land once
  3. Discovery

    • discover ui_messages.json task files deterministically
    • keep the source directory-backed via --source-dir kilocode=...
  4. Parsing

    • parse api_req_started task log entries only
    • preserve explicit cost and token counts
    • resolve sessionId from the task directory name
    • load sibling api_conversation_history.json when available for model/agent metadata
    • if shared helper uses sibling metadata, make sure parse dependencies include that file so cache invalidation remains correct
  5. Wiring

    • register kilocode in src/sources/create-default-adapters.ts
    • update supported-source count/order/help expectations
  6. Tests and docs

    • add tests/sources/kilocode-source-adapter.test.ts
    • prove shared-parser behavior with Roo Code rather than parallel implementations drifting over time
    • update shared registry/help tests and README.md

Code paths to touch

  • src/sources/kilocode/kilocode-source-adapter.ts
  • shared parser/helper used by Roo Code + Kilo Code
  • src/sources/create-default-adapters.ts
  • src/utils/discover-files.ts
  • src/domain/usage-event.ts
  • tests/sources/kilocode-source-adapter.test.ts
  • tests/sources/roocode-source-adapter.test.ts or shared-helper coverage
  • tests/sources/create-default-adapters.test.ts
  • tests/cli/create-cli.test.ts
  • README.md

Verification

  • parser fixtures cover:
    • valid Kilo task logs
    • reuse of the shared task-log parser
    • sibling metadata extraction
    • explicit cost preservation
    • malformed/irrelevant entries skipped cleanly
  • Roo Code and Kilo Code fixtures both pass through the same parser path
  • llm-usage daily --source kilocode --source-dir kilocode=<fixture-dir> works
  • full validation passes:
    • pnpm run lint
    • pnpm run typecheck
    • pnpm run test
    • pnpm run format:check

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions