← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
import assert from 'node:assert/strict'
import { test } from 'node:test'
import triggerBugbot from 'kody:@kody/bugbot'
import evaluate from 'kody:@kody/clef/evaluate'
import { loadSettings, patchSettings } from '../lib/settings.ts'
const g = globalThis as unknown as {
__bugbotInput?: Record<string, unknown>
__bugbotResult?: Record<string, unknown>
__clefResult?: Record<string, unknown>
}
test('bugbotCursorLogin defaults to empty string', async () => {
const settings = await loadSettings()
assert.equal(settings.bugbotCursorLogin, '')
})
test('setting bugbotCursorLogin persists', async () => {
await patchSettings({ bugbotCursorLogin: 'kentcdodds' })
const settings = await loadSettings()
assert.equal(settings.bugbotCursorLogin, 'kentcdodds')
await patchSettings({ bugbotCursorLogin: '' })
})
test('bugbot: when cursorLogin is empty, tick skips bugbot with reason', async () => {
await patchSettings({ bugbotCursorLogin: '' })
const settings = await loadSettings()
assert.equal(settings.bugbotCursorLogin, '')
})
test('bugbot: @kody/bugbot receives cursorLogin from settings', async () => {
g.__bugbotResult = { posted: true, comment: 'bugbot run', message: 'posted' }
g.__bugbotInput = null
await patchSettings({ bugbotCursorLogin: 'kentcdodds' })
const settings = await loadSettings()
const result = await triggerBugbot({ prUrl: 'https://github.com/kody-hq/kody/pull/1', cursorLogin: settings.bugbotCursorLogin })
assert.ok(g.__bugbotInput)
assert.equal((g.__bugbotInput as Record<string, unknown>).cursorLogin, 'kentcdodds')
await patchSettings({ bugbotCursorLogin: '' })
})
test('bugbot: author mismatch returns code', async () => {
g.__bugbotResult = { posted: false, code: 'github_account_mismatch', message: 'author differs' }
const result = await triggerBugbot({ prUrl: 'https://github.com/kody-hq/kody/pull/1', cursorLogin: 'kentcdodds' })
assert.equal(result.posted, false)
assert.equal(result.code, 'github_account_mismatch')
})
test('clef: model ok returns answers', async () => {
g.__clefResult = { ok: true, answers: { q1: { type: 'choice', choice: 'yes' } } }
const result = await evaluate({ state: 'test', questions: { q1: { type: 'choice' } } })
assert.equal(result.ok, true)
assert.ok('answers' in result && result.answers.q1)
})
test('clef: model failure returns ok:false', async () => {
g.__clefResult = { ok: false, error: 'timeout' }
const result = await evaluate({ state: 'test', questions: {} })
assert.equal(result.ok, false)
})