kojo

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0

README

kōjō 工場

A software factory you run yourself. Any model. One binary plus Postgres. "Done" defined as code.

Docs · Quick start · Skills · Security model · kojo.yaml reference

CI


工場 (kōjō): a factory. Work comes in, goes through stations that each do one thing, is inspected against a standard, and leaves with a record of how it was made.

kōjō is an open-source, self-hostable software factory: autonomous agents that build features, fix bugs, review pull requests, audit security and keep codebases healthy on a schedule. It runs in your own infrastructure as a single Go binary plus Postgres, works with any LLM, and lets a team define what "done" means as code in its repositories.

 GitHub · GitLab · Forgejo ─┐                          ┌─ Postgres   queue · sessions · memory · audit · config revisions
 Slack · Teams · Discord    ├─▶  kōjō core  ───────────┼─ sandbox    Docker Sandboxes (sbx) · Kubernetes Agent Sandbox · E2B
 Mattermost · CLI · MCP    ─┘    holds credentials     ├─ models     embedded gateway, or any OpenAI-compatible one
                                 never runs repo code  └─ skills     .factory/ in your repos · org · built-in

 request ▸ orchestrator ▸ skill subagents (fresh context, in a sandbox) ▸ goal critic ▸ merge policy ▸ draft pull request
  • Runs where your code is. docker compose on one VM, or a Helm chart on any Kubernetes cluster. Postgres is the only hard dependency: the queue, sessions, team memory, the audit log and the configuration all live there.
  • Any model. Tiers (fast, strong) map to models on Anthropic, OpenAI, Google, OpenRouter or a local Ollama, or to an OpenAI-compatible gateway such as hikyaku. Fully air-gapped installs work with local models.
  • Credentials never enter a sandbox. The core holds the forge tokens and never executes a repository command. Untrusted code (the repository's, and whatever a model writes) runs in a microVM or gVisor sandbox with deny-all egress. A proxy injects short-lived read-only credentials on allowlisted hosts; the sandbox only ever sees placeholders. Pushes are made by the core, through the forge's API, to kojo/* branches.
  • "Done" is code, and it is enforced. A skill is three files in .factory/skills/<name>/: instructions and tool limits (SKILL.md), acceptance criteria (goals.yaml: commands that must exit 0, limits on the diff, a rubric), and the sandbox (kit.yaml). A goal critic checks every result against them and sends rejected work back, up to max_attempts. Work that still falls short is published as a draft with the report, never dropped and never dressed up.
  • Draft pull requests by default. A merge policy decides what happens to a change. Asking a human in chat, and merging low-risk changes once required checks are green, are opt-in per repository.
  • Products in several repositories. Link the repositories of one product (an API, its web client, its SDKs): a session changes them together and opens one pull request per repository that changed. kōjō never merges such a change.
  • Deploy once, operate from the dashboard. Skills, repositories, schedules, model tiers, budgets, the merge policy and access are changed live, each change a versioned revision with one-click rollback. No redeploy. Skills go through draft → test → eval → activate. .factory/ files in git stay supported, and kojo config export / kojo config apply keep GitOps possible.
  • Every session is traced, replayable and costed. Each orchestrator turn, subagent, tool call, sandbox command and critic verdict is a recorded step. OpenTelemetry traces, Prometheus metrics, an append-only audit log, and per-session and per-day spend caps.

Built-in skills

All shipped skills live in this repository, under skills/, in the same format a repository uses for its own.

Skill What it does
triage Classifies a new issue, checks for duplicates and missing information, replies with a triage note
reproduce-bug Turns a bug report into a failing test, without fixing anything
fix-bug Writes a minimal, tested fix for a reproduced bug
build-feature Builds a feature end to end: acceptance criteria, plan, implementation, tests, docs, verification
review-pr Reviews a pull request for correctness, security and missing tests
security-audit Finds vulnerabilities with evidence, severity and a specific fix; its report stays out of public places
dependency-review Applies safe dependency upgrades and reports the ones that need a decision
daily-digest Summarises a repository's last day
stale-issue-triage Checks old issues against the current code
flaky-test-hunt Runs the suite repeatedly and reports tests that fail intermittently
release-watch Reports upstream releases worth acting on
port-sdk Ports a change from one language's SDK to another, idiomatically, with its tests; it reads the source repository next to the workspace

A repository overrides any of them by adding a skill of the same name to its .factory/skills/; the org's skills sit in between.

Install

Kubernetes (sandboxes through Agent Sandbox with Kata or gVisor):

helm install kojo oci://ghcr.io/xavidop/charts/kojo -f values.yaml

One VM (sandboxes through Docker Sandboxes, sbx): Postgres runs in docker compose, kōjō runs on the host next to sbx, which is driven through its CLI. deploy/systemd/kojo.service runs it as a service.

curl -fsSL https://xavidop.github.io/kojo/install.sh | sh    # installs the kojo binary and checks its checksum
docker compose -f deploy/compose/docker-compose.yml up -d    # Postgres with pgvector
kojo setup github --public-url https://kojo.example.com      # registers the GitHub App, writes its key to ./secrets
kojo setup slack                                             # prints the Slack app manifest
kojo serve -f kojo.yaml
kojo doctor --remote                                         # checks isolation, egress, permissions, branch protection

The install guide has the prerequisites of each path and a sample kojo.yaml; kojo config validate checks yours without starting anything.

The quick start walks through the one-VM path, from the binary to a first draft pull request.

Run it locally

A checkout runs the whole factory locally with replayed model responses: no cloud account, no model key.

git clone https://github.com/xavidop/kojo && cd kojo
make build
make eval          # every skill with fixtures, in real sandboxes, on recorded model responses
make dev-sbx       # Postgres, a throwaway Forgejo, a Slack mock and kōjō on http://localhost:8080
make e2e           # issue → draft pull request, Slack mention → reply, live config change → rollback

make dev-sbx uses Docker Sandboxes when sbx is installed and plain containers otherwise (scripts/dev-sbx.sh --docker; fine to develop with, not an isolation boundary). make dev-kind brings up the Kubernetes stack on kind, with gVisor and Cilium, through the Helm chart.

Then ask for something: comment @kojo-bot fix this on the demo repository's issue in Forgejo (http://localhost:3000), mention kōjō in Slack, or use a terminal:

export KOJO_SERVER=http://localhost:8080 KOJO_TOKEN=dev-admin-token-not-a-secret
kojo run --repo forgejo/kojo-dev/demo --issue 1 "fix this"
kojo sessions list
kojo sessions logs <session>

A skill in a repository looks like this (.factory/skills/fix-bug/):

# goals.yaml: what "done" means for this skill
max_attempts: 3
checks:
  - name: reproduction passes
    run: make test-one TEST=${REPRO_TEST}
  - name: package tests pass
    run: make test PKG=${AFFECTED_PKG}
constraints:
  max_changed_lines: 300
  forbidden_paths: ["**/*_repro_test.go", ".github/**"]
judge:
  rubric: |
    - Fix addresses the root cause described in the analysis.
    - No unrelated refactors.

kojo skills validate .factory/skills checks skill files in CI, and kojo eval fix-bug measures a skill against fixture repositories before it is allowed to go live. kojo eval fix-bug --history github/acme/api measures it on issues that repository already fixed, judged by the tests each fix added.

Commands

Command What it does
kojo serve Runs the server: dashboard, API, webhooks, chat, MCP, workers and scheduler
kojo proxy Runs the egress and credential proxy as its own process (Kubernetes)
kojo migrate Applies pending database migrations
kojo run Starts a session and follows it
kojo sessions Lists, shows, follows, messages and cancels sessions
kojo eval Runs a skill against its eval fixtures, or on issues a repository already fixed (--history)
kojo config Exports and applies the runtime config, validates kojo.yaml
kojo skills Lists the skills in use, validates skill files
kojo mcp Serves the Model Context Protocol on stdio, for editors and coding agents
kojo doctor Checks that the deployment is safe and complete
kojo setup Creates the GitHub App, the Slack app manifest, the Teams app package or the Discord invite kōjō acts through
kojo schema Prints the JSON Schemas of kojo.yaml and the .factory/ files
kojo version Prints the version

Exit codes: 0 ok, 1 the thing asked for failed (a session, an eval, a doctor check), 2 usage or configuration, 3 infrastructure.

Status

What this version covers:

Surfaces GitHub (App), GitLab, Forgejo/Gitea, Slack, Mattermost, Discord, Microsoft Teams, CLI, MCP
Sandbox drivers k8s (passes the driver conformance suite on kind with gVisor; Kata and in-sandbox Docker are not verified yet), sbx (passes the conformance suite and the end-to-end scenarios against sbx v0.55.0 on macOS; Linux with KVM is not verified yet), e2b (E2B Cloud, a self-hosted E2B or CubeSandbox; the sandboxes reach the network only through kojo-proxy), docker (plain containers, development only)
Memory Team memory, per-person memory, and lessons learned from maintainers' reviews of kōjō's pull requests
Self-improvement Proposals for changing a skill's instructions and goals, built from its evidence, measured by evals and approved by a person; off by default
Several repositories Linked repositories of one product, changed in one session, one pull request each
Not in this version ACP

The design document explains the reasoning; CLAUDE.md records where the build departs from it.

Documentation

Contributing

Contributions are welcome: see CONTRIBUTING.md. Commits are signed off (DCO); there is no CLA. Security reports go through SECURITY.md.

License

Apache-2.0.

Directories

Path Synopsis
cmd
kojo command
Command kojo is kōjō: the server, the egress proxy and the CLI in one binary.
Command kojo is kōjō: the server, the egress proxy and the CLI in one binary.
Package evals embeds the eval fixtures: small repositories with a seeded problem, one directory per case under fixtures/<skill>/<case>/, with the issues and pull requests a skill reads in case.yaml when it reads the forge.
Package evals embeds the eval fixtures: small repositories with a seeded problem, one directory per case under fixtures/<skill>/<case>/, with the issues and pull requests a skill reads in case.yaml when it reads the forge.
internal
app
Package app assembles kōjō from its deployment config: the store, the day-2 config manager, the model gateway, the sandbox driver and its proxy, the surfaces, the engine and the HTTP server.
Package app assembles kōjō from its deployment config: the store, the day-2 config manager, the model gateway, the sandbox driver and its proxy, the surfaces, the engine and the HTTP server.
cli
Package cli is the kojo command line: the server and the proxy, the commands that drive a running server (run, sessions, eval, config), and the ones that work on files (doctor, setup, skills validate, schema).
Package cli is the kojo command line: the server and the proxy, the commands that drive a running server (run, sessions, eval, config), and the ones that work on files (doctor, setup, skills validate, schema).
client
Package client is the HTTP client of kōjō's API.
Package client is the HTTP client of kōjō's API.
config
Package config holds kōjō's two kinds of configuration.
Package config holds kōjō's two kinds of configuration.
core
Package core is the factory itself: the orchestrator that delegates to skill subagents, the goal critic that checks their work, the merge policy that decides what happens to a change, and the scheduler.
Package core is the factory itself: the orchestrator that delegates to skill subagents, the goal critic that checks their work, the merge policy that decides what happens to a change, and the scheduler.
dashboard
Package dashboard is kōjō's web UI and its API, served by the same binary as everything else.
Package dashboard is kōjō's web UI and its API, served by the same binary as everything else.
doctor
Package doctor checks that a kōjō deployment is safe and complete: the database, the sandbox driver and its isolation, that egress is really blocked, the replicas of a remote kojo-proxy, the forges and their branch protection, chat, the model gateway, budgets, sign-in and the activation gate.
Package doctor checks that a kōjō deployment is safe and complete: the database, the sandbox driver and its isolation, that egress is really blocked, the replicas of a remote kojo-proxy, the forges and their branch protection, chat, the model gateway, budgets, sign-in and the activation gate.
eval
Package eval runs skills against fixture repositories (design §10).
Package eval runs skills against fixture repositories (design §10).
models
Package models is kōjō's model gateway client.
Package models is kōjō's model gateway client.
proxy
Package proxy is kojo-proxy: the egress proxy every sandbox must go through.
Package proxy is kojo-proxy: the egress proxy every sandbox must go through.
sandbox
Package sandbox defines the driver interface the core uses to run untrusted code (repo code, model-written code) away from its own credentials.
Package sandbox defines the driver interface the core uses to run untrusted code (repo code, model-written code) away from its own credentials.
sandbox/docker
Package docker is the sandbox driver that runs each sandbox as a plain Docker container.
Package docker is the sandbox driver that runs each sandbox as a plain Docker container.
sandbox/e2b
Package e2b is the sandbox driver for E2B-compatible services: E2B Cloud, a self-hosted E2B, and CubeSandbox, which serves the same API.
Package e2b is the sandbox driver for E2B-compatible services: E2B Cloud, a self-hosted E2B, and CubeSandbox, which serves the same API.
sandbox/e2b/e2btest
Package e2btest is an in-process E2B-compatible service for tests: the control API and envd behind one HTTP server, as far as the e2b driver uses them (see internal/sandbox/e2b/api.go).
Package e2btest is an in-process E2B-compatible service for tests: the control API and envd behind one HTTP server, as far as the e2b driver uses them (see internal/sandbox/e2b/api.go).
sandbox/fake
Package fake is the sandbox driver unit tests use.
Package fake is the sandbox driver unit tests use.
sandbox/k8s
Package k8s is the sandbox driver for Kubernetes Agent Sandbox (kubernetes-sigs/agent-sandbox): one claim per session, isolated by the cluster's Kata or gVisor RuntimeClass.
Package k8s is the sandbox driver for Kubernetes Agent Sandbox (kubernetes-sigs/agent-sandbox): one claim per session, isolated by the cluster's Kata or gVisor RuntimeClass.
sandbox/sbx
Package sbx is the sandbox driver for Docker Sandboxes: one microVM per session, each with its own kernel and a private Docker daemon.
Package sbx is the sandbox driver for Docker Sandboxes: one microVM per session, each with its own kernel and a private Docker daemon.
skills
Package skills loads factory-as-code: the .factory/ files of a repository, the org's skills, and the built-in skills, layered in that order.
Package skills loads factory-as-code: the .factory/ files of a repository, the org's skills, and the built-in skills, layered in that order.
store
Package store is kōjō's persistence: the job queue, sessions and their checkpoints, the audit log, day-2 config revisions, skill drafts, team memory, eval results and the proposals kōjō makes for its own skills.
Package store is kōjō's persistence: the job queue, sessions and their checkpoints, the audit log, day-2 config revisions, skill drafts, team memory, eval results and the proposals kōjō makes for its own skills.
store/memory
Package memory is an in-process store.Store for unit tests and for `kojo eval --local`.
Package memory is an in-process store.Store for unit tests and for `kojo eval --local`.
store/postgres
Package postgres is kōjō's production store: one Postgres database holds the queue (FOR UPDATE SKIP LOCKED), sessions and checkpoints (JSONB), team memory (pgvector, with a full-text fallback), the append-only audit log, config revisions (hot reload through LISTEN/NOTIFY) and everything else.
Package postgres is kōjō's production store: one Postgres database holds the queue (FOR UPDATE SKIP LOCKED), sessions and checkpoints (JSONB), team memory (pgvector, with a full-text fallback), the append-only audit log, config revisions (hot reload through LISTEN/NOTIFY) and everything else.
store/storetest
Package storetest is the behaviour every store.Store must have.
Package storetest is the behaviour every store.Store must have.
surfaces/chat
Package chat is the interface every chat surface implements: Slack, Microsoft Teams, Discord and Mattermost.
Package chat is the interface every chat surface implements: Slack, Microsoft Teams, Discord and Mattermost.
surfaces/discord
Package discord is the Discord chat adapter: mentions and direct messages in, replies and approval buttons out.
Package discord is the Discord chat adapter: mentions and direct messages in, replies and approval buttons out.
surfaces/forge
Package forge is the interface the core uses to talk to a code forge (GitHub, GitLab, Forgejo/Gitea).
Package forge is the interface the core uses to talk to a code forge (GitHub, GitLab, Forgejo/Gitea).
surfaces/forge/forgetest
Package forgetest is an in-memory forge.Forge for the core's unit tests and for dev stacks that run without a real forge.
Package forgetest is an in-memory forge.Forge for the core's unit tests and for dev stacks that run without a real forge.
surfaces/forgejo
Package forgejo is the forge adapter for Forgejo and Gitea, which share one API (config.Forgejo.BaseURL is the instance root).
Package forgejo is the forge adapter for Forgejo and Gitea, which share one API (config.Forgejo.BaseURL is the instance root).
surfaces/github
Package github is the forge adapter for GitHub: github.com, GitHub Enterprise Cloud with data residency (api.<tenant>.ghe.com) and GitHub Enterprise Server (config.GitHub.BaseURL, https://ghe.example.com/api/v3).
Package github is the forge adapter for GitHub: github.com, GitHub Enterprise Cloud with data residency (api.<tenant>.ghe.com) and GitHub Enterprise Server (config.GitHub.BaseURL, https://ghe.example.com/api/v3).
surfaces/gitlab
Package gitlab is the forge adapter for GitLab: gitlab.com or a self-managed instance (config.GitLab.BaseURL).
Package gitlab is the forge adapter for GitLab: gitlab.com or a self-managed instance (config.GitLab.BaseURL).
surfaces/mattermost
Package mattermost is the Mattermost chat adapter: mentions and direct messages in, threaded replies and approval buttons out.
Package mattermost is the Mattermost chat adapter: mentions and direct messages in, threaded replies and approval buttons out.
surfaces/mcp
Package mcp exposes the factory to editors and other coding agents over the Model Context Protocol: start a session, follow it and read its result, and everything else the dashboard and the CLI do (skills and drafts, runtime config and its history, schedules, evals, memory, the audit log, doctor).
Package mcp exposes the factory to editors and other coding agents over the Model Context Protocol: start a session, follow it and read its result, and everything else the dashboard and the CLI do (skills and drafts, runtime config and its history, schedules, evals, memory, the audit log, doctor).
surfaces/slack
Package slack is the Slack chat adapter: mentions and DMs in, threaded replies and approval buttons out.
Package slack is the Slack chat adapter: mentions and DMs in, threaded replies and approval buttons out.
surfaces/teams
Package teams is the Microsoft Teams chat adapter: personal messages and mentions in, threaded replies and approval cards out.
Package teams is the Microsoft Teams chat adapter: personal messages and mentions in, threaded replies and approval cards out.
version
Package version holds the build's version, set by the linker at release time (see .goreleaser.yaml).
Package version holds the build's version, set by the linker at release time (see .goreleaser.yaml).
Package schemas embeds the JSON Schemas of kōjō's files: kojo.yaml and the .factory/ files of a repository.
Package schemas embeds the JSON Schemas of kōjō's files: kojo.yaml and the .factory/ files of a repository.
examples
Package examples holds the example kojo.yaml files of the configuration reference.
Package examples holds the example kojo.yaml files of the configuration reference.
gen command
Command gen writes the JSON Schemas of kōjō's files from the Go structs that load them, and the configuration reference page of the docs site.
Command gen writes the JSON Schemas of kōjō's files from the Go structs that load them, and the configuration reference page of the docs site.
Package builtin embeds the official skills: every skill kōjō ships lives in this directory, in the public repository, in the same .factory/ format a repository uses for its own.
Package builtin embeds the official skills: every skill kōjō ships lives in this directory, in the public repository, in the same .factory/ format a repository uses for its own.
test
conformance
Package conformance is the one test suite every sandbox driver must pass (design §11.3).
Package conformance is the one test suite every sandbox driver must pass (design §11.3).
dashdev command
Command dashdev serves the dashboard against an in-memory store filled with demo data, with no Postgres, no forge, no sandbox and no model keys.
Command dashdev serves the dashboard against an in-memory store filled with demo data, with no Postgres, no forge, no sandbox and no model keys.
discordmock
Package discordmock is a stand-in for Discord, for tests.
Package discordmock is a stand-in for Discord, for tests.
e2e
Package e2e holds the end-to-end scenarios: whole flows through a running kōjō, its forge and its chat surface, asserted on from the outside.
Package e2e holds the end-to-end scenarios: whole flows through a running kōjō, its forge and its chat surface, asserted on from the outside.
slackmock
Package slackmock is a stand-in for Slack, for tests and the local dev stacks.
Package slackmock is a stand-in for Slack, for tests and the local dev stacks.
slackmock/cmd/slackmock command
Command slackmock runs the Slack mock as a process, for the local dev stacks: kōjō's chat.slack.api_url points at http://<listen>/api/, and the mock delivers mentions, DMs and button clicks to kōjō when its control API (/mock/...) is called.
Command slackmock runs the Slack mock as a process, for the local dev stacks: kōjō's chat.slack.api_url points at http://<listen>/api/, and the mock delivers mentions, DMs and button clicks to kōjō when its control API (/mock/...) is called.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL