kojo

module
v0.1.1 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.

Agents that triage issues, fix bugs, build features, review pull requests and audit security,
each in a sandbox, checked against what your repository says "done" means, published as a pull request.

CI Latest release Docs Go version

Quick start · Concepts · Skills · Security model · Deploy · kojo.yaml

工場 (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ō runs in your own infrastructure as one Go binary plus Postgres, works with any model, and keeps the definition of "done" as code in your repositories. A mention on an issue, a message in chat or a schedule starts a session. An orchestrator hands the work to skills, each run by a subagent in its own sandbox. A goal critic checks the result against the skill's goals, and a merge policy decides how far it goes: a draft pull request by default.

How it works

flowchart LR
  subgraph requests [Requests]
    forge["GitHub · GitLab · Forgejo"]
    chat["Slack · Mattermost · Discord · Teams"]
    cli["CLI · MCP · schedules"]
  end
  subgraph core [kōjō]
    orch[Orchestrator]
    sub["Skill subagents<br/>(fresh context each)"]
    critic[Goal critic]
    policy[Merge policy]
    orch --> sub --> critic --> policy
    critic -. "rejected: try again" .-> sub
  end
  sandbox[("Sandbox<br/>deny-all egress")]
  proxy[kojo-proxy]
  pr["Pull request<br/>(draft by default)"]
  requests --> orch
  sub <-->|every command| sandbox
  sandbox -->|allowlisted hosts| proxy
  policy --> pr

The core holds the credentials and never runs a repository command. Everything a repository or a model wants to run happens in the sandbox, which reaches the network only through kojo-proxy: it allows the hosts a skill names and adds credentials on the way out, so no secret is ever inside. Pushes are made by the core, through the forge's API, to kojo/* branches.


Every session is recorded step by step: what was asked, what each subagent ran, what the critic decided, and what it cost.

What it does

"Done" is code. A skill is three files in .factory/skills/<name>/: instructions and tool limits (SKILL.md), what has to be true at the end (goals.yaml: commands that must pass, limits on the diff, a rubric), and the sandbox (kit.yaml). Rejected work goes back to the subagent; work that still falls short is published as a draft with the report.

Isolated by default. Untrusted code runs in a microVM or gVisor sandbox with deny-all egress. Credentials stay outside and are added on the way out, only for the hosts a skill names. A request from someone without the repository's trigger permission (write, by default) never changes code.

Any model. Two tiers, fast and strong, map to Anthropic, OpenAI, Google, OpenRouter or a local Ollama, with fallbacks, rate limits and budgets, or to any OpenAI-compatible gateway. Air-gapped installs work with local models.

Merge policy. Draft pull requests by default. A repository can opt into asking a person in chat first, or merging low-risk changes once required checks are green. A merge is pinned to the commit whose checks were read.

Talk to it while it works. A mention on the issue, or a reply in the chat thread, reaches the running session at its next step. On its own pull requests, a mention (or a failed check, if the repository opts in) adds commits to the same branch.

Every line traced. Each changed block in a pull request links to the step that wrote it. Sessions have OpenTelemetry traces, Prometheus metrics, an append-only audit log, and per-session and per-day spend caps.

Measured before it goes live. Skills move from draft to test to eval to active. Evals run on fixture repositories, or on issues your repository already fixed, judged by the tests each fix added.

Operated from the dashboard. Skills, repositories, schedules, models, budgets, the merge policy and access change live, each change a versioned revision with rollback. kojo config export and apply keep GitOps possible.

It learns. Team and personal memory, and lessons from maintainers' reviews of its pull requests. Optionally it proposes changes to its own skills, measured by evals and approved by a person.

Products in several repositories. Link the repositories of one product, such as an API, its web client and its SDKs: one session changes them together and opens one pull request per repository.

Works with

Code platforms GitHub (App), GitLab, Forgejo and Gitea
Chat Slack, Mattermost, Discord, Microsoft Teams
Clients The kojo CLI, MCP for editors and coding agents, the HTTP API, the dashboard
Models Anthropic, OpenAI, Google, OpenRouter, Ollama, or any OpenAI-compatible gateway such as hikyaku
Sandboxes Docker Sandboxes (sbx) on one VM, Kubernetes Agent Sandbox with gVisor or Kata, E2B; plain Docker for development
Deploy A Helm chart, or docker compose plus the binary on one VM

Quick start

Kubernetes, with sandboxes through Agent Sandbox:

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

One VM, with sandboxes through Docker Sandboxes:

curl -fsSL https://xavidop.github.io/kojo/install.sh | sh    # the kojo binary, checksum checked
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
kojo serve -f kojo.yaml
kojo doctor --remote                                         # isolation, egress, permissions, branch protection

Then mention the bot on an issue: @kojo fix this. The quick start goes from the binary to a first draft pull request, and the install guide covers both paths with a sample kojo.yaml.

Try it from a checkout, with no cloud account and no model key
git clone https://github.com/xavidop/kojo && cd kojo
make build
make eval          # every skill against its 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

Then comment @kojo-bot fix this on the demo repository's issue in Forgejo (http://localhost:3000), or use the CLI:

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

make dev-kind brings up the Kubernetes stack on kind instead, with gVisor and Cilium. See Development.

A skill

# .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. kojo eval fix-bug measures a skill on fixture repositories, and kojo eval fix-bug --history github/acme/api on issues that repository already fixed.

Twelve skills are built in, in skills/, in the same format. A repository overrides one by adding a skill of the same name; the org's skills sit in between.

Changing code Reviews and audits On a schedule
fix-bug: a minimal, tested fix triage: category, duplicates, missing information daily-digest: the repository's last day
reproduce-bug: a failing test, nothing fixed review-pr: correctness, security, missing tests stale-issue-triage: old issues against the current code
build-feature: plan, code, tests, docs security-audit: findings with evidence and a fix flaky-test-hunt: tests that fail intermittently
port-sdk: a change carried to another SDK dependency-review: safe upgrades applied release-watch: upstream releases worth acting on
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. The CLI reference has every flag.

Documentation

Start Build Run
Quick start Skills Deploy
Concepts Built-in skills Managing kōjō
Install Evals Observability
Security model Merge policy Sandboxes
Surfaces Memory CLI reference
Models Linked repositories kojo.yaml reference

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

Contributing

Contributions are welcome: see CONTRIBUTING.md. Commits follow Conventional Commits and are signed off (DCO); there is no CLA. Report security issues 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