Skip to content
← 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.

FollowFork

Files

post.ts

36 lines · 2.0 KB · TypeScript
/**
 * Post a report onto the factory: what an audit, weekly review, or scheduled
 * check found, recorded even when nothing needs doing. A report can file zero,
 * one, or many cards that link back to it. Work cards join the queue as New;
 * cards with `needsKent: true` wait in Needs you as decisions or
 * recommendations. A card `key` that matches an open card from an earlier
 * report links that card instead of filing a duplicate.
 *
 * One push per report, opening the report, and only when it files a new card
 * or flags a finding. A quiet report is recorded without a push.
 *
 * Run it in the kody org, e.g. `npx -y @kodycodes/cli@latest execute --local --org kody --code '…'`.
 *
 * @param input - `source`, `title`, `summary` (markdown); optional `projectId` (required with cards), `period`, `findings`, `cards`, `metrics`, `links`, `idempotencyKey`, `notify`, `dryRun`
 * @returns The report id and link, whether it is noteworthy, each card (created or existing) with its link, and the push result
 *
 * @example
 * import postReport from 'kody:@kody/kody-factory/reports/post'
 * await postReport({
 *   source: 'ci-review',
 *   title: 'Weekly CI review: kody-hq/kody',
 *   projectId: 'kody',
 *   period: { start: '2026-11-16', end: '2026-11-23', label: 'Week of 2026-11-23' },
 *   summary: 'Typical PR is 16 min to green. Two safe wins and one coverage trade.',
 *   findings: [{ id: 'cache-setup:validate', title: 'Cache node_modules in Validate', severity: 'notice' }],
 *   cards: [{ key: 'cache-setup:validate', title: 'Cache node_modules in Validate', body: '…', findingId: 'cache-setup:validate' }],
 *   idempotencyKey: 'ci-review-2026-11-23',
 * })
 * // => { ok: true, reportId: 'rp_…', reportUrl: 'https://kody-factory--kody.kody.run/reports/rp_…', noteworthy: true, cards: [{ cardId: 'wi_…', relation: 'created', … }], push: { sent: 1, … } }
 */
import { postReport } from '../../reports/post.ts'
import type { PostReportInput } from '../../reports/model.ts'

export default async function post(input: PostReportInput) {
	return postReport(input)
}