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

ProductivityTopics: factory, orchestrator, priority-queue, signals, autopilot, github, planning, dashboard, multi-project, events

License
Published
November 23, 2026
Pinned commit
5e5f668
Rating
No ratings yet
Forks
0
Adaptation effort
—

README

Agent docs

@kody/kody-factory

A forkable software factory for one or many projects. Signals come in (GitHub issues, Sentry, friction, CI failures, webhooks), land on one board as cards, get triaged and planned, and go out to agents that open PRs. Agent runners (such as @kody/devin) and sources (such as @kody/sentry-events and @kody/github) reach the factory through Kody events, so it holds no runner or Sentry keys. Ship-pr shepherds each PR to merge. The factory never merges on its own.

What it does

  1. Intake: signals arrive via webhooks, backfill, or manual entry.
  2. Triage: model-assisted classification (Clef on Workers AI) decides whether to autopilot or hold for a human.
  3. Plan: each piece of work gets a card on the board. Plans (long-lived goals) get their own board.
  4. Build: the sweep job asks a runner package for a session by event (@kody/factory.agent.start.requested). One session per card, one PR per session.
  5. Ship: ship-pr checks the PR, triggers Bugbot, sorts reviews, replies to feedback, and squash-merges when ready. After merge, the factory watches main CI and asks the implementer to fix red.
  6. Record: every state change, PR link, merge, and outcome is on the card. Flow metrics (throughput, cycle time, stalls) are computed live.
  7. Report: audits and scheduled reviews (like the weekly CI review) post a report. A report is recorded even when nothing needs doing, and it can file zero, one, or many cards that link back to it.

Quick status

Ask "what is the factory doing?" with one call: kody execute --org kody --context cloud --invoke kody:@kody/kody-factory/status/now. It returns health, in-progress work with agent, repo, age, and last activity, stalled items, and anything waiting on Kent, from stored state.

App pages

PathWhat it shows
/Overview: key numbers, stalled items, up-next queue, projects
/boardKanban board: Intake through Shipped with stall indicators, drag and drop, category filter
/plansPlans board: Exploring through Shipped, create/edit, markdown body, progress notes
/workWork queue: searchable, filterable list of every work item
/reportsReports from audits and reviews (filter by source, has something or quiet), then /reports/:id with the summary, numbers, findings, and the cards it filed
/projectsProjects list with health sparklines, then /projects/:id for detail (agents, runs, flow, PRs)
/notificationsNotification list with filters by project, severity, category, and read/unread status; unread badge in nav
/signalsSignal sources, inbound records, routing config
/factory-healthError intake, reconcile, wake switches, fingerprint list
/settingsShadow mode, merge policy, connections, appearance, templates, config export/import

Quick start (fork)

  1. Fork and publish this package in your org.
  2. Map credentials (names only; values stay in Kody Connect):
NeedWhat it isHost
modelCloudflare API token for triage and routing (Workers AI)api.cloudflare.com
githubOwnerOwner's GitHub account, used only for branch pushes and PR creation (./friction/push-branch)api.github.com
webPushSigning credential (provider web-push) holding a VAPID ES256 key; Kody signs the VAPID JWT. Set webPushVapidPublicKey to its public keypush services

Imported packages bring their own needs, which show on the same approval page as inherited:

  • @kody/github: github (the bot GitHub connection). Every factory GitHub read and bot write goes through kody:@kody/github/request.
  • @kody/clef: cloudflareApiToken (same Workers AI token as model).
  • @kody/cursor: cursorApiKey and githubPersonalAccessToken, only for the cleanup jobs that launch Cursor agents. Leave them unmapped if you do not use those jobs.

Packages that talk to the factory by events keep their own keys:

  • @kody/devin: the Devin key (devin). See "Agent runners as packages".
  • @kody/sentry-events: sentryWebhookSecret and sentry. See "Sentry issues to cards".
  • @kody/bugbot: map github to a credential for the GitHub login that matches your Cursor account. Set bugbotCursorLogin in factory settings.
  1. Set non-secret settings via configure-settings:
    await configureSettings({
      cloudflareAccountId: '<32 hex>',
      pilotScope: { mode: 'allowlist', projectIds: ['my-project'], repoRefs: ['owner/repo'] },
    })
  2. Add a project: use seed-projects, upsert-project, or import the Basic OSS repo template from /settings (Templates card).
  3. Register a signal source at /signals/sources and point the sender (a CI pipeline, a custom webhook) at the signals webhook URL. Sentry goes to @kody/sentry-events instead.
  4. Connect GitHub through events: mint and approve the github webhook on @kody/github, point your GitHub repo or org hook at it, and turn on this package's @kody/github.* subscriptions (see "GitHub as events"). The factory's own github-* webhooks are a legacy path you can skip.
  5. Turn on jobs one by one: the sweep is on by default. All others (friction-daily, cleanup jobs, friction-cluster) start disabled. Enable each from the platform jobs page after verifying its credential mapping.

Safety defaults

  • Shadow mode is on. The sweep triages and plans but does not start agents until you turn shadow mode off.
  • Kill switch is off. When on, the sweep stops starting new runs and merges.
  • All new jobs are declared disabled. Enable them individually.
  • Issue write-back is off. When on, the factory writes status comments and labels back to source GitHub issues.
  • Pilot scope defaults to an empty allowlist. The sweep, backfill, and issue-webhook intake act on no project until you name one.
  • Merge policy: agents open PRs; merges are human (or attested by a pipeline). The factory never merges on its own.

Notifications

The factory has an in-app notification system at /notifications. Notifications are created by factory events (stalls, state changes, errors, PR updates).

Per-project rules control which categories and severities create notifications. Rules are stored in package storage and included in config export/import.

Outputs (all off by default):

  • Discord: posts to a configured channel via @kody/discord. Requires discordNotificationsEnabled: true and discordNotificationsChannelId in settings. Fails closed when the credential is not mapped.
  • Bot wakes: asks @kody/wake-relay to wake Patch. Requires wakeEnabled: true in the project's notification rules.
  • Web push (on by default for new Sentry and signal cards and anything that needs you): open /settings, "Push notifications", and choose "Allow on this device" on each phone or computer. "Send test push" checks it. Tapping a notification opens the card. Nothing is sent until a device subscribes. Rules: pushEnabled, pushLabels, pushNeedsAttention.

Agents report on the card

When an agent finishes a card (or parks it, or gets blocked), it reports on the card itself:

npx -y @kodycodes/cli@latest execute --local --org kody --code 'import report from "kody:@kody/kody-factory/cards/report"; export default (p) => report(p)' --params '{"cardId":"wi_123","outcome":"shipped","summary":"Merged and deployed.","prUrl":"https://github.com/kody-hq/kody/pull/123"}'

The report shows under "Agent reports" on the card, and you get a push notification that opens https://<your app>/c/<card id>. Factory dispatch prompts, card wakes, and the ship-pr report step all point agents here, so there is no separate chat post. notify: false keeps a report quiet.

Reference cards in pull requests

Every card has a short, stable link: https://<your app>/c/<card id> (the card dialog shows it as "Card link"; /cards/<card id> keeps working). Cards stay private: the link opens only for people who can open the factory app.

Reference cards in a PR body the same way you reference GitHub issues:

Closes https://factory.kody.build/c/wi_0123456789abcdef
Fixes https://factory.kody.build/c/wi_fedcba9876543210
Related: https://factory.kody.build/c/wi_00112233aabbccdd
  • close, closes, closed, fix, fixes, fixed, resolve, resolves, or resolved (an optional colon is fine) before a card link marks the card shipped when the PR merges, with a timeline note and a link to the PR.
  • A card link with no keyword links the PR on the card when it merges and leaves the card where it is.
  • factory:<card id> is a short form of the same reference (Closes factory:wi_0123456789abcdef).
  • References inside HTML comments and code are ignored, so template examples never match. Replays change nothing.

The factory sees merged PRs two ways: each sweep tick reads recently merged PRs in your project repos, and the @kody/github.pr.merged event does the same work once githubEventsMode is live. Agents the factory starts are told to reference their card this way.

Custom domain

The app can serve on a domain you own (the kody org uses factory.kody.build). Kody serves a package app at the root of a custom domain only when the app is internet-visible, and an internet-visible app is reachable by anyone, so the factory checks access itself first:

  1. Set appAccess: 'members' (./configure-settings). Signed-in members of the owning org get in; anyone else is sent to Sign in with Kody, and signed-in non-members see a no-access page.
  2. The package owner approves internet-visible serving on the package's capability approval page.
  3. Point the domain at the app (kody:@kentcdodds/cloudflare/custom-domain or Kody's custom domain settings) and wait for it to go active.
  4. Set publicBaseUrl to the domain so every link the factory hands out uses it.

Reports: results that may need no work

Audits, weekly reviews, and other scheduled checks post a report instead of a chat message or a GitHub issue:

npx -y @kodycodes/cli@latest execute --local --org kody --code 'import post from "kody:@kody/kody-factory/reports/post"; export default (p) => post(p)' --params '{"source":"docs-audit","title":"Docs audit","summary":"All pages fresh.","projectId":"kody"}'
  • No work needed: a report with no cards and no flagged findings is recorded quietly (no push). It still shows on /reports under Quiet.
  • One or many cards: pass cards. Each card has a stable key. Work cards join the queue as New and ship through the factory's runner like any other card. Cards with needsKent: true wait in Needs you as decisions; no agent starts on them until you move them to New.
  • No duplicates: a later report with the same source and card key links the card that is still open instead of filing another one.
  • Both ways: every card links to its report ("Open the report this came from" on the card), and the report lists each card with its live state.
  • One push per report, opening the report, and only when it files a new card or flags a finding.
  • idempotencyKey makes a retry return the first report; dryRun previews the report and cards and writes nothing.

Weekly CI review

Every Monday at 4:00 AM (America/Denver) the ci-review-weekly job reviews the last 7 days of GitHub Actions on kody-hq/kody. Confidence in shipping comes first; within that, faster PR feedback, fewer runner minutes, and less repeated work count equally. It posts one report:

  • Safe wins (caching, shared setup, cancelling superseded runs, flaky fixes, slow steps) become work cards. Each keeps every check, job, test, and platform, and ships through the factory as one focused PR.
  • Coverage trades (dropping or deferring a check or platform) become Needs-you cards with the numbers. They only ship if you move them to New.
  • Quiet weeks post a quiet report with the week's numbers and trends.

It reads GitHub with GET requests only and never posts to GitHub or chat. Preview it any time with npx -y @kodycodes/cli@latest execute --local --org kody --invoke kody:@kody/kody-factory/ci-review/run --params '{"dryRun":true}'. Pause with ./ci-review/pause, resume with ./ci-review/resume.

Sentry issues to cards

Sentry talks to @kody/sentry-events, not to the factory. That package holds the Sentry integration Client Secret (sentryWebhookSecret) and API token (sentry), checks each webhook signature, and emits @kody/sentry-events.issue.alerted. The factory subscribes to that event and files one card per Sentry issue (repeat alerts reuse it) and, with push on, one notification. Cards go to sentryIntakeProjectId (default kody) or a sentryProjectMap match. Events from any package other than sentryEventsSource (default sentry-events) are ignored.

The nav shows an unread badge. Mark individual or all notifications as read.

Events and wakes

The factory never posts to a bot. Every wake (health, signals, notifications, friction, new outage and DR cards) is a @kody/factory.wake.requested event, and @kody/wake-relay delivers it. If the relay reports a failure, or does not answer within wakeAlertMinutes (default 5), the factory raises a wake alert: the card gets a wake-undelivered label, /factory-health shows it under "Wake delivery", and it posts to your factory Discord channel when Discord notifications are on. Sources (@kody/dr-backup-health, @kody/status-alerts) emit events the factory turns into deduped cards. See AGENTS.md "Events".

GitHub as events

The factory knows cards and events, not GitHub. @kody/github owns the GitHub hook and publishes @kody/github.issue.*, .pr.*, .ci.completed, .release.changed, and .branch.pushed; the factory subscribes to the issue, CI, release, and pr.merged topics and turns them into the same cards its old webhooks filed (and, for merged PRs, closes the cards they reference). To run a different code host, publish the same topics from your own package and set githubEventsSource to its Kody id.

githubEventsMode picks who does the work:

  • shadow (default): the factory's own webhook still files cards and forwards each delivery to @kody/github (githubEventsBridge), and the events only record what they would do. ./github-events/report compares the two paths.
  • live: the events file the cards, and the factory's own webhooks only forward. Flip this once the report shows matches and no misses.
  • off: events are ignored.

Issue comments are not mirrored on purpose: the old webhook treated a deleted comment like a deleted issue.

Agent runners as packages

Coding agents are runner packages too. The runners setting names each runner, its package, and its start, status, message, and terminate exports (Devin: @kody/devin), plus sessionUrlTemplate. Board and card session links come from the runner (the URL it returned at start, else that template), never a hardcoded host.

Dispatch is always by event. To start work the factory emits @kody/factory.agent.start.requested (and .message.requested, .cancel.requested) with a requestId; the card holds pending_<requestId> until the runner answers with @kody/<package>.session.started carrying that requestId, then the card takes the real session id and link. .session.updated and .finished drive status. The factory holds no runner key; the cleanup and friction jobs start their sessions the same way.

./runners/self-test emits a dry start request (the runner answers with what it would start and starts nothing) and returns the requestId to look for in the runner package's subscription run.

Adopt in your org

  1. Publish this package and @kody/wake-relay in your org.
  2. Map the factory credentials above. There are no wake credentials here; bot wake URLs and keys live only on the relay.
  3. Turn on the factory subscriptions for @kody/wake-relay.wake.delivered and .wake.failed, and on the relay its @kody/factory.wake.requested subscription. Each for exactly one person.
  4. On the relay, add your bots to its roster and liveBots (see its README).
  5. Run ./events/self-test (dry), then ./events/self-test { live: true } once to prove one real wake end to end.
  6. Optional: turn on @kody/status-alerts and @kody/dr-backup-health subscriptions here and set eventCardsMode: 'live' to file their cards.
  7. Optional web push: make a P-256 key pair, save the private key (PKCS#8 PEM) as a signing credential with provider web-push and the push service hosts, and set webPushVapidPublicKey to the public key (base64url). Then allow push per device in /settings.
  8. GitHub: publish @kody/github in your org (or use the shared one), mint its github webhook, add a GitHub hook (JSON, your signing secret, the events you want), turn on this package's @kody/github.* subscriptions for exactly one person, and set githubEventsMode: 'live'.
  9. Agent runners: publish @kody/devin (or your own runner package with the same events) and configure it (its README has the settings). Turn on its @kody/factory.agent.start.requested, .message.requested, and .cancel.requested subscriptions and this package's @kody/devin.session.started, .updated, and .finished subscriptions, each for exactly one person. Then run ./runners/self-test and check the runner's subscription run shows dryRun: true for the returned requestId. A runner with another package name: add it to runners.
  10. Optional Sentry: publish @kody/sentry-events, map its sentryWebhookSecret (the Sentry internal integration Client Secret) and optionally sentry, mint and approve its sentry webhook, paste that URL into the Sentry integration as its Webhook URL (Issue and alert rule action webhooks on), and turn on this package's @kody/sentry-events.issue.alerted subscription.

Known limitations

  • Cross-org forwarders: packages in another org (e.g. @kentcdodds/) cannot import @kody/ exports. There is no sanctioned Kody runtime mechanism for cross-org package calls. The old packages stay live and unchanged until a platform path exists.
  • T3 Code threads: the factory cannot read T3 Code thread data. Work items show T3 links only when an agent records one.
  • Devin cost: the Devin v3 API does not expose ACU or cost data. The project detail page says "Cost data not available."
  • Bugbot author mismatch: Cursor Bugbot requires the commenter's GitHub account to match the PR author. The factory's GitHub credential authenticates as a bot, not as the repo owner. For owner-authored PRs, the original @kentcdodds/bugbot path still works.
  • Storage quota: the kody org is near its storage entitlement limit. Storage writes and SQL can throw EntitlementLimitError. The factory handles this in the health page and signals pipeline. Do not add large storage caches.

Offline and install (PWA)

The app is a PWA. It caches view shells and assets for offline use. Data snapshots (titles, states; no settings) are kept in localStorage. Drafts of new work survive offline and sync on reconnect with an idempotency key. Updates wait for the user to click Refresh.

Migrated from

Four packages were ported into the factory from the kentcdodds org:

  • @kentcdodds/ship-pr (5b5805c): PR status, review sort, merge, Discord summary. Now at ./ship-pr/tick, ./ship-pr/merge, ./ship-pr/decide, ./ship-pr/reply-review, ./ship-pr/reply-comment, and ./ship-pr/review-sort.
  • @kentcdodds/friction-log (efdd4b7): friction filing and daily sweep. Now at ./friction/file with job friction-daily.
  • @kentcdodds/codebase-cleanup (0a4a3cd): Cursor/Devin automation jobs. Now at ./cleanup/* with four disabled jobs.
  • @kentcdodds/ci-review (cf66617, 0.3.0): weekly CI review. Now at ./ci-review/* with job ci-review-weekly; it posts a factory report and cards instead of starting its own agent session and messaging Discord.

The original packages are still live. They share no code with the factory; each was ported independently with adapter rewrites for the kody org's credentials and packages.

Done when

After setup and credential mapping, you can: seed projects, ingest or create an item, see it on the board, have an agent open a PR (when shadow mode is off and the runner is mapped), ship-pr the PR to merge, and see the result on the project detail page with flow metrics.

Report this listing

Log in to report this listing.