codeburn/tests/providers/kilo-code.test.ts
Resham Joshi ec2de6a642
Add OpenClaw, Roo Code, and KiloCode providers (#175)
- OpenClaw: JSONL parser with multi-path discovery, tool extraction
  (toolCall + tool_use block types), model tracking via model_change
  and custom model-snapshot events
- Roo Code + KiloCode: shared Cline-family parser extracts model from
  <model> tags in api_conversation_history.json, strips provider
  prefixes from model names
- Add cline-auto and openclaw-auto aliases and display names
- Add menubar provider filters and tab colors for all three
- Show cached data instantly instead of blocking on CLI refresh
2026-04-28 09:24:14 -07:00

62 lines
2.3 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { mkdtemp, mkdir, writeFile, rm } from 'fs/promises'
import { join } from 'path'
import { tmpdir } from 'os'
import { kiloCode, createKiloCodeProvider } from '../../src/providers/kilo-code.js'
import type { ParsedProviderCall } from '../../src/providers/types.js'
let tmpDir: string
describe('kilo-code provider - discovery path differentiation', () => {
beforeEach(async () => {
tmpDir = await mkdtemp(join(tmpdir(), 'kilo-code-test-'))
})
afterEach(async () => {
await rm(tmpDir, { recursive: true, force: true })
})
it('discovers tasks using kilo-code extension path', async () => {
const task = join(tmpDir, 'tasks', 'task-kilo-1')
await mkdir(task, { recursive: true })
await writeFile(join(task, 'ui_messages.json'), JSON.stringify([
{ type: 'say', say: 'api_req_started', text: JSON.stringify({ tokensIn: 100, tokensOut: 50 }), ts: 1700000000000 },
]))
const provider = createKiloCodeProvider(tmpDir)
const sessions = await provider.discoverSessions()
expect(sessions).toHaveLength(1)
expect(sessions[0]!.provider).toBe('kilo-code')
})
it('parses with kilo-code provider name in dedup key', async () => {
const task = join(tmpDir, 'tasks', 'task-kilo-2')
await mkdir(task, { recursive: true })
await writeFile(join(task, 'ui_messages.json'), JSON.stringify([
{ type: 'say', say: 'api_req_started', text: JSON.stringify({ tokensIn: 200, tokensOut: 100 }), ts: 1700000000000 },
]))
const source = { path: task, project: 'task-kilo-2', provider: 'kilo-code' }
const calls: ParsedProviderCall[] = []
for await (const call of kiloCode.createSessionParser(source, new Set()).parse()) calls.push(call)
expect(calls).toHaveLength(1)
expect(calls[0]!.provider).toBe('kilo-code')
expect(calls[0]!.deduplicationKey).toMatch(/^kilo-code:/)
})
})
describe('kilo-code provider - metadata', () => {
it('has correct name and displayName', () => {
expect(kiloCode.name).toBe('kilo-code')
expect(kiloCode.displayName).toBe('KiloCode')
})
it('uses different extension ID than roo-code', async () => {
const kiloProvider = createKiloCodeProvider('/tmp/kilo-test')
const sessions = await kiloProvider.discoverSessions()
expect(sessions).toHaveLength(0)
})
})