← 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
/**
* Board card destination: create a work item in the factory ledger.
* Uses the same create export as the manual create flow.
*/
import create from '../../exports/create.ts'
import type { DispatchResult, PromptContext } from './types.ts'
import { getTemplate, renderTemplate } from './templates.ts'
export async function dispatchBoardCard(
ctx: PromptContext,
opts: { templateId?: string | null; shadow?: boolean; dryRun?: boolean },
): Promise<DispatchResult> {
const templateId = opts.templateId ?? 'default-board-card'
const template = await getTemplate(templateId)
const body = template ? renderTemplate(template.template, ctx) : `${ctx.title}\n\n${ctx.body}`
try {
const result = await create({
projectId: ctx.projectId,
title: ctx.title.slice(0, 200) || 'Inbound signal',
body,
labels: [...ctx.labels, `signal:${ctx.source}`],
shadow: opts.shadow !== false,
dryRun: opts.dryRun,
idempotencyKey: `signal-${ctx.signalId}`,
})
return {
destination: 'board-card',
ok: true,
detail: result.replayed
? `Deduplicated to existing work item ${result.item.id}`
: `Created work item ${result.item.id}`,
workItemId: result.item.id,
}
} catch (err) {
return {
destination: 'board-card',
ok: false,
detail: err instanceof Error ? err.message : String(err),
}
}
}