import { test } from 'node:test' import assert from 'node:assert/strict' import { buildKiloArgs, describeTool } from '../src/kilocode.mjs' test('buildKiloArgs emits json format and the agent', () => { const args = buildKiloArgs({ agent: 'code-design', auto: true, sessionID: 'ses_1', title: 't', prompt: 'hello' }) assert.deepEqual(args.slice(0, 3), ['run', '--format', 'json']) assert.ok(args.includes('--agent')) assert.equal(args[args.indexOf('--agent') + 1], 'code-design') assert.ok(args.includes('--auto')) assert.ok(args.includes('--session')) assert.equal(args[args.indexOf('--session') + 1], 'ses_1') assert.equal(args[args.length - 1], 'hello') }) test('buildKiloArgs omits --auto and session when not requested', () => { const args = buildKiloArgs({ agent: 'code-design', auto: false, prompt: 'p' }) assert.ok(!args.includes('--auto')) assert.ok(!args.includes('--session')) assert.ok(!args.includes('--continue')) }) test('buildKiloArgs can continue the last session', () => { const args = buildKiloArgs({ agent: 'code-design', auto: true, continueSession: true, prompt: 'p' }) assert.ok(args.includes('--continue')) }) test('describeTool renders readable section headings', () => { assert.equal(describeTool({ tool: 'read', state: { input: { filePath: '/a/b/c/deep/file.ts' } } }), 'Read deep/file.ts') assert.equal(describeTool({ tool: 'bash', state: { input: { command: 'pnpm test --watch' } } }), 'Run pnpm test --watch') assert.equal(describeTool({ tool: 'grep', state: { input: { pattern: 'TODO' } } }), 'Search /TODO/') assert.equal(describeTool({ tool: 'mystery', state: { title: 'Do a thing' } }), 'Do a thing') })