koment

module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT

README

koment

Keep the why next to your code — checked, so it can't quietly rot.

CI Release Demo License

Readable code answers what. It cannot answer why this and not the obvious alternative, what bit us here before, or what breaks if you "simplify" this. Comments are the usual home for that and they rot — they duplicate the code, drift from it silently, and nothing ever tells you they have stopped being true.

koment puts that reasoning beside the code instead: prose anchored to a verbatim snippet, stored in .koment/ in git, reviewable in the same pull request as the change that motivated it. Then it checks the anchor. When the annotated code changes, koment check fails the build rather than serving a note that no longer describes anything.

Your agents read it too. One MCP server gives Claude Code, Cursor, Codex, Zed, Hermes and the rest the same reasoning through the same interface — because an agent that cannot see why something was built a certain way will happily refactor the reason away.

See it running → — that is koment's own annotations, rendered by koment.

How it works

  1. You annotate a snippet. koment records the prose, the excerpt and its SHA-256, the commit you were on, and who you are.

  2. The record lands in .koment/annotations/<mirrored path>.yaml, one file per annotated source file. It is YAML, it is in git, and it diffs line by line.

  3. Resolution searches the current file for that excerpt and produces exactly one status:

    meaning build
    ok found where it was last seen passes
    moved still there, different line passes
    drifted file exists, the annotated code is gone fails
    orphaned the file is gone fails
  4. koment check exits non-zero on drifted or orphaned. That is the whole mechanism: an annotation nobody revisited is worse than no annotation, so it has to be impossible to ignore.

  5. When it fails, koment reanchor <id> --excerpt '<new text>' repoints it — keeping its id and creation date, recomputing the hash and line for you. Nothing re-attaches automatically; a person confirms the reasoning still holds.

Anchoring is by excerpt, never by line number — line numbers rot on the next edit above them. The commit hash is recorded, but only to reconstruct history; it never decides whether an annotation still applies. Two questions, two mechanisms (ADR 0014).

koment is read-only over the network. The UI and the MCP server serve; they never write. Annotations are created by the CLI, by a person or an agent with a checkout — so a published instance exposes no way for a visitor to change anything.

Quick start

go install github.com/janpuc/koment/cmd/koment@latest

cd ~/your-project
koment add src/auth.go \
  --excerpt 'if token.Expiry.Before(now.Add(-clockSkew)) {' \
  --kind gotcha \
  --body 'The skew subtraction is deliberate. Without it, clients whose clock
          runs fast get logged out mid-request. Bit us in #412.'

koment check   # green
koment ui      # look at it

Now edit that line and run koment check again. It fails — because the reasoning you wrote no longer describes the code, and silently keeping it is exactly how comments rot.

Or run the viewer against a checkout with the container:

docker run --rm -p 8080:8080 -v "$PWD:/repo:ro" ghcr.io/janpuc/koment:latest

Kubernetes

koment publishes an OCI Helm chart to oci://ghcr.io/janpuc/charts/koment:

helm install koment oci://ghcr.io/janpuc/charts/koment \
  --set repository.clone.enabled=true \
  --set repository.clone.url=https://github.com/you/your-repo \
  --set metrics.enabled=true \
  --set metrics.serviceMonitor.enabled=true \
  --set metrics.dashboard.enabled=true

Metrics land on a separate port from the serving one — the serving port is unauthenticated and ingress-facing, and /metrics must not inherit that (ADR 0020). The chart ships a Grafana dashboard the sidecar discovers by label. Its headline panel is drift over time, which is the one question koment check cannot answer, because it only ever sees one moment.

Configuration

Every flag can be set from the environment, which is how you configure the container. --flag-name becomes KOMENT_FLAG_NAME, and an explicit flag always wins.

KOMENT_REPO repository to serve; defaults to the working directory
KOMENT_LISTEN address for koment ui
KOMENT_HTTP address for koment mcp --http
KOMENT_STREAMABLE_HTTP address for koment mcp --streamable-http
KOMENT_METRICS address for the metrics listener; off unless set
KOMENT_OUT output directory for koment export
KOMENT_INDEX SQLite index file; defaults to the cache directory
KOMENT_DATABASE_URL use Postgres for the index, which makes the service stateless

koment <command> --help lists every flag alongside its variable.

Give it to your agents

koment mcp        # stdio; also --http / --streamable-http for remote agents

Two tools: koment_get(file) for the file an agent is about to edit, and koment_search(query) to find reasoning by topic. Every annotation arrives with its resolution status, so a stale one is never presented as current.

Claude Code Cursor VS Code
Zed Codex opencode
Hermes OpenClaw Anything else

CI

- run: koment check

Documentation

What koment is not

  • Not a replacement for ADRs. Project-wide decisions belong in a decision record; koment holds knowledge bound to a place in the code.
  • Not a memory system. A consolidating store paraphrases, merges and eventually forgets. koment is a record, not a belief (ADR 0004).
  • Not line-precise. Anchors are snippets (ADR 0003).

Prior art

Codetations / Magic Markup is the closest existing work — document-external annotations with LLM re-anchoring. The anchoring problem dates to Microsoft Research, 2001 and is still unsolved in the general case. The UI owes its shape to konflate, which makes an invisible layer visible for Flux the way koment tries to for rationale.

License

MIT

Directories

Path Synopsis
cmd
koment command
demo
src
internal
anchor
Package anchor decides where an annotation still applies, and says so when it no longer does.
Package anchor decides where an annotation still applies, and says so when it no longer does.
cli
Package cli implements the koment commands a human or a shell hook runs.
Package cli implements the koment commands a human or a shell hook runs.
config
Package config lets every flag be set from the environment, which is how a container is configured.
Package config lets every flag be set from the environment, which is how a container is configured.
index
Package index holds a queryable copy of the annotations that live in git.
Package index holds a queryable copy of the annotations that live in git.
listen
Package listen resolves the address a local koment server binds to.
Package listen resolves the address a local koment server binds to.
mcp
Package mcp serves koment annotations to agents over stdio or HTTP.
Package mcp serves koment annotations to agents over stdio or HTTP.
metrics
Package metrics reports how a long-lived koment is doing: how much drift the repository carries, whether anyone is reading, and how often an agent is handed an annotation that no longer applies.
Package metrics reports how a long-lived koment is doing: how much drift the repository carries, whether anyone is reading, and how often an agent is handed an annotation that no longer applies.
provenance
Package provenance captures where an annotation came from: the git state it was written against, and who wrote it.
Package provenance captures where an annotation came from: the git state it was written against, and who wrote it.
store
Package store reads and writes the annotation records that live in .koment.
Package store reads and writes the annotation records that live in .koment.
ui
Package ui serves a local read-only view where code and its annotations converge on one screen (ADR 0013).
Package ui serves a local read-only view where code and its annotations converge on one screen (ADR 0013).

Jump to

Keyboard shortcuts

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