kipu
by hundredeuk2
README.md
# kipu
**Knots of what you and your AI agents decided — tied into a map you can read like `git log --graph`.**
The Inca kept records without writing: a *khipu* (quipu) is a cord of knotted strings, where each knot's place, kind and colour holds a fact. kipu does the same for work you do with AI agents. Each work item is a string, each decision a knot, and every replaced decision stays on the cord, linked to what replaced it and why.
Working with an agent, you accept suggestions fast. A few hours later it is hard to say what you actually decided, which choices were the agent's, and where to go back to. kipu keeps that lineage in your repository and shows it beside your work: where you are, how you got there, and which point to return to.
> **한국어 소개.** AI와 일하다 보면 추천과 결과를 빨리빨리 받아들이느라, 내가 뭘 정했는지, 지금 어디까지 왔는지 놓치기 쉽습니다. kipu는 잉카의 매듭 기록(키푸)처럼 AI 에이전트와의 의사결정 계보를 엮어 둡니다. 이정표가 git graph처럼 같이 보이니, 어디까지 왔고 어디서 되돌리면 되는지 바로 알 수 있습니다.
What it keeps, per repository, as Markdown files in the repository:
- **what you are working on** — purpose, status, next action, the goal it serves, and what it waits for you to decide;
- **which decisions are current** — what replaced what, and why;
- **who decided** — `decided_by: user` is accepted only when it points at your own message in a Claude Code or Codex session log of this project (or a quote you confirm through the CLI). Otherwise the record says `agent`.
The next session, in any client, picks up where the last one stopped (`resume_context`, or the session-start hook), and the goal map draws the whole cord.
- Storage: `<repo>/.kipu/` — `work/<id>.md`, `decisions/<id>.md`. No database.
- Session logs are read, never copied. Quotes are at most 200 characters, secrets masked.
- One stdio MCP server for Claude Code, Codex and Claude Desktop; a CLI with the same operations; session-start and Stop hooks; a goal map in a browser window or a panel beside your agent.
- Node 20 or newer. Runtime dependencies: `@modelcontextprotocol/server`, `zod`.
> Status: early. Not yet published to npm; build it from this repository.
## Build
```sh
npm install && npm run build
# → dist/mcp/main.js (MCP server), dist/cli/main.js (CLI)
```
Below, `LEDGER=/absolute/path/to/kipu-mcp`.
Not published yet, so there is no `npx` command today. If it is published under the current manifest (package `@hundredeuk2/kipu-mcp`, bins `kipu` and `kipu-mcp`), the equivalents would be:
| now | after publishing |
|---|---|
| `node $LEDGER/dist/cli/main.js …` | `npx -y --package @hundredeuk2/kipu-mcp kipu …` |
| `node $LEDGER/dist/mcp/main.js` | `npx -y @hundredeuk2/kipu-mcp` |
## Quick start (CLI): first work item → first decision → resume
Run inside your repository. The commands work as pasted in both zsh and bash (a test runs this block with `zsh -f` and `bash`):
```sh
ledger() { node "$LEDGER/dist/cli/main.js" "$@"; }
ledger work set --id auth --purpose "Move login to session cookies" --next "Write the cookie expiry test"
ledger decide --work auth --choice "Session cookies instead of JWT" --reason "Revocation is simple" --alt "JWT" --ref src/auth.ts --by agent
ledger evidence pick --contains cookie
ledger resume
```
`evidence pick` lists the user's own messages from this project's session logs (it is fine if it finds none). To record a decision the user made, cite one of them with the ids it printed:
```sh
ledger decide --work auth --choice "Expire after 30 minutes" --reason "Security review" --by user \
--evidence-client claude-code --session SESSION_ID --message MESSAGE_ID
```
The same through MCP, in the order an agent would call it:
```json
{"tool": "set_work_context", "arguments": {"work_id": "auth", "purpose": "Move login to session cookies", "next_action": "Write the cookie expiry test"}}
{"tool": "record_decision", "arguments": {"work_id": "auth", "choice": "Session cookies instead of JWT", "reason": "Revocation is simple", "alternatives": ["JWT"], "refs": ["src/auth.ts"], "decided_by": "agent"}}
{"tool": "resume_context", "arguments": {}}
```
## View the recorded goal map
**One window for all projects** (like VS Code's Git Graph): `kipu view` with no input shows this project's goal map in a single local window. Run it in another project and the open window switches to that project instead of opening another tab; a **Project** picker at the top goes back to any project shown before, and **Refresh** reads the ledger again. The window redraws by itself when the shown project's records change (it checks the record files every 2 seconds and rebuilds the map only after a change). A worktree resolves to its main checkout, so sub-agents working in worktrees and branches of one project share that project's one map; another project is another map.
- A small local server serves it on `127.0.0.1` (port 47615 first, any free port if that is taken; `KIPU_VIEW_PORT` changes it). The first `view` starts it in the background; it stops itself after 30 minutes with no window open and no `view`. `view --serve` runs it in the foreground.
- It answers only requests addressed to `127.0.0.1` or `localhost`, and adding a project needs a token kept with its address in a private folder (`KIPU_LIVE_DIR`, default a temp folder). Projects are known only while it runs; nothing is saved.
- A browser is opened only when no window has checked in during the last 75 seconds (a background tab checks in about once a minute). `KIPU_NO_BROWSER=1` only prints the address (remote shells, tests).
- Building the map rechecks evidence against your session logs, as `graph` does, but only after a record changed or on Refresh. A redraw resets the map's scroll and selection.
**Beside the product** (a sidebar panel, a pane next to the chat): every such host asks the ledger one question, `kipu map [--format rows|html] [--since VERSION]`, run in the project's folder. It prints one JSON line: the map as terminal rows (`rows`, the default: the same layout and labels as the browser, as box-drawing cells) or as the map page (`html`), with the ledger's `version`; given the version it already shows, an unchanged ledger answers only `{"status":"unchanged","version":…}` after one look at the record files. Outside a repository it answers `{"status":"no_project"}`. The rows answer also lists `waiting` (what open works wait for the person, with their lane), and an open work's head row is titled with its next action instead of its purpose. It never touches the live window. Two prototype hosts use it: `integrations/orca-panel` (Orca's right sidebar, HTML) and `integrations/claude-panel` (a Claude Code pane, rows).
The rest of this section is the offline file: `view --snapshot` (or `--input`, JSON on stdin, `--no-open`) writes `.kipu/view.html` as before.
The viewer takes **graph contract v1 JSON**, including the optional v1.1 coverage and activity fields. With no input, it calls the ledger goalGraph() producer, which rechecks recorded evidence against local session logs; supplied JSON is rendered without querying logs. It does not infer missing parent links. It writes an offline snapshot to `.kipu/view.html`, adds that output and usage metadata to the ledger directory's `.gitignore`, and opens the default browser. Use `--no-open` to write only.
```sh
node "$LEDGER/dist/cli/main.js" view --input graph.json --no-open
# Generate directly, or pipe a graph snapshot:
node "$LEDGER/dist/cli/main.js" view --no-open --purpose dev
node "$LEDGER/dist/cli/main.js" graph --json | node "$LEDGER/dist/cli/main.js" view
# Development / tests are marked separately in usage.jsonl:
node "$LEDGER/dist/cli/main.js" view --input "$LEDGER/test/fixtures/graph-v1/changes.json" --no-open --purpose dev
```
Without `--input`, `view` accepts JSON on stdin, or generates the current repository graph when stdin is empty. Use `view --no-open --purpose dev` directly; `--no-activity` skips git activity for direct generation. All record text remains unchanged and is escaped; the HTML has no CDN, font downloads or network calls. Light/dark themes follow the device or the Theme selector. A snapshot does not update when reopened: generate it again for newer records.
The map reads like a git graph (VS Code's Git Graph): newest record on top, one compact row per record with its text in a column on the right, one coloured lane per goal. A work branches off its goal's lane one row before its first record (from its current goal, dotted while that link was not yet recorded); a finished work merges back into its goal one row after it ends, a dropped one stops, and a replacement continues the goal's lane from the record where the goal changed. A lane is reused once its branch has ended. The work's ID/title label sits on its latest row. A small **Information** button opens the rest. Hover or keyboard-focus a node for its title, kind, readable date and attribution (Owner with evidence status, AI, or recording client); select it to read the full supplied record. Details include choice, reason, alternatives, provenance, the stored quote and session/message IDs. Missing fields, including empty alternatives, are grouped in a closed **Not recorded** section at the end. The original session log is not embedded; quotes remain capped by the producer at 200 characters. Close details or press Escape to return to the graph. On narrow screens details occupy at most 48% of the height.
The graph shows newest records at the top and older records below. Each work is named once beside its latest point; hover or focus its name for counts of superseded decisions, goal transitions and parent changes. A child branches from its current parent at its oldest point below, including a replacement child. Completed work ends in a square without a line back to the parent, and parent paths never extend above their own endpoints. Thin dotted historical segments indicate that creation or parent linkage had not yet been recorded; they do not backdate an event. **Linked here** marks each actual parent change, with From → To in the tooltip. Creation/link nodes identify late linkage and a later-created parent; decision nodes do not inherit these warnings. Labels have space beside each lane; a directional cue appears when there is more horizontal graph content.
Only the current top-level goal path uses a thick trunk; child paths are thinner. Active endpoints are filled circles, completed endpoints squares, and dropped endpoints crosses. Superseded decisions are faded and crossed out, with a purple dotted curve beside the trunk leading to their replacement. Their tooltip names the replacement. If a work transition has no recorded time, only its connector is dotted; the new goal retains its main path.
Name tooltips start with the producer's current parent chain; an unrecorded connection is shown as `(연결 미기록)`. This is a desktop tool: at 390px, wide graphs require horizontal scrolling using the More cue, an accepted limitation.
**Information** keeps the current work cards, activity, coverage, theme, filters, branch list and source metadata available without putting them on the initial canvas. Human attribution is distinct from verification of quoted log evidence. Dates and omissions remain explicit in this panel; activity is an author-date proxy, not a missing-decision rate.
A dropped work with a replacement branches at its matching replaced_by_changed event. The replacement continues on the thick left trunk of that goal chain; the old goal ends on a faded side branch. Chains continue through A→B→C, including child goals. Earlier records of an already existing replacement remain visible as a dotted incoming branch. When the transition event is absent, the viewer does not invent a date: it connects after the old goal's last available record with a dotted line and explains this in the summary and Information.
Days with commits but no ledger events appear as dashed trunk sections only when ledger_started_at is known and the day is not before it. No pre-ledger gaps are drawn. Dashed node borders indicate late parent links or stale active/blocked records; summaries explain the mark. Unknown event kinds are omitted. Unsafe activity error text is reduced to one of five fixed categories. The offline HTML uses no external assets and record strings are inserted literally, never as markup.
## Connect a client
The server keeps the ledger in the git repository around its working directory. All worktrees of one repository share one ledger: started in a linked worktree, it uses the main worktree's `.kipu/` (a bare repository has no main worktree, so each worktree keeps its own). When a client does not start servers inside your project, set `KIPU_ROOT` to the repository path; it always wins. Outside a repository the tools answer `no_repo` and write nothing.
**Claude Code** (starts stdio servers in the project folder):
```sh
claude mcp add --transport stdio --scope project kipu -- node $LEDGER/dist/mcp/main.js
```
`--scope project` writes `.mcp.json` in the repository, and Claude Code does not start a project server until you approve it: `claude mcp list` shows it as *Pending approval*. Start `claude` in the repository and accept the prompt for `kipu` (or approve it from `/mcp`); after that it shows as connected. To skip the approval step for a server only you use, register it with `--scope local` instead.
**Codex** (`~/.codex/config.toml`):
```toml
[mcp_servers.kipu]
command = "node"
args = ["/absolute/path/to/kipu-mcp/dist/mcp/main.js"]
env = { KIPU_ROOT = "/absolute/path/to/your/repo" }
```
**Claude Desktop** (`claude_desktop_config.json`; Desktop has no project folder, so the root is required):
```json
{
"mcpServers": {
"kipu": {
"command": "node",
"args": ["/absolute/path/to/kipu-mcp/dist/mcp/main.js"],
"env": { "KIPU_ROOT": "/absolute/path/to/your/repo" }
}
}
}
```
Copies of these are in `examples/`.
## Session-start hook
Prints the resume summary of the in-progress work item (at most ~1,500 characters) when a session starts, or nothing when there is none.
The summary says when it was made (`As of 2026-11-27 19:06 +09:00; later records: resume_context`). An agent session can run for days and keep this text, so it shows how old the picture is. The summary, `resume_context` (`as_of`, `needs_update`), `doctor` and the goal graph (`works[].needs_update`, as a code) also list records that are no longer true, so the agent reading them fixes them with `set_work_context`. `set_work_context` says so too (`needs_update`) when the call that closes a work leaves it in that state. Nothing is changed automatically. There are two rules: a work is done or dropped but its `next_action` was set before the close, and a work is done or dropped but still has `waiting_on_user`. A rule for "commits kept coming but the record did not move" was checked against this repository's history and left out. Work here moves in bursts of minutes, so every threshold tried flagged the normal flow and missed the real case.
**What waits for you comes first.** `set_work_context` takes `waiting_on_user` (CLI `--waiting`): what the work waits for the person to decide or approve, such as "approve merging to main". It is kept apart from the next action, so it does not get buried in it. The summary puts it right after the `As of` line for every open work, not only the summarized one (`Waiting on you: live-view (…) — approve the merge`); `resume_context` returns it as `waiting_on_user`, and the map shows it above the graph and marks the work. Clear it (`""`) once answered.
**The hook never changes ledger records** (`work/`, `decisions/`). It does write one thing: a line in the local, gitignored `.kipu/usage.jsonl` (tool name, time, client, result count — no content), so the two-week measurement can count how often the summary was shown. It also notes when the session started, for the Stop hook, in a small file outside the repository (`CLAUDE_PLUGIN_DATA`, or a temp folder). It creates nothing when the repository has no ledger.
**Claude Code** — `.claude/settings.json` (`examples/claude-code-settings.json`):
```json
{
"hooks": {
"SessionStart": [
{ "hooks": [{ "type": "command", "command": "node /absolute/path/to/kipu-mcp/dist/cli/main.js hook session-start" }] }
]
}
}
```
**Stop hook (Claude Code)** — `hook stop` runs when the agent is about to end its turn. It looks at every commit on the current branch made since the session started (by committer date, with no count limit and no early stop at an older-dated ancestor, so a long session's early commits are not cut off) that carries a `Ledger-Work: <id>` trailer. When such a work was not written during the session, does not exist, or was closed with its old next action, the hook sends the agent back once with the list (`{"decision": "block", "reason": …}`). Each commit is brought up at most once per session. The reminder is a few short lines, and the agent may end it with `ledger: no change`, because a reminder that only a write can silence would fill the ledger with filler. The session start comes from the session-start hook, which notes it the first time it sees a session (in `CLAUDE_PLUGIN_DATA`, or a temp folder without the plugin). The transcript is not read, because its format is internal to Claude Code. Without that note the Stop hook stays quiet. It never changes records. Add it next to `SessionStart` (`examples/claude-code-settings.json` has both), or use the plugin below.
**Codex** — Codex has a `SessionStart` hook with the same input (`cwd`, `session_id`, …) and output (`hookSpecificOutput.additionalContext`). Put the same block in `~/.codex/hooks.json` or `<repo>/.codex/hooks.json` (`examples/codex-hooks.json`). This was read from the codex-cli 0.172.0 hook schema and has not been run against a live Codex session yet.
**Claude Desktop** has no hooks.
### Claude Code plugin
This package folder is also a Claude Code plugin (`.claude-plugin/plugin.json`): the MCP server plus both hooks, installed together. The core stays the MCP server, so Codex and Claude Desktop keep working as above. The plugin points at `dist/`, so build first. A local marketplace in the same folder (`.claude-plugin/marketplace.json`) loads the plugin in place:
```sh
pnpm --filter kipu build
claude plugin marketplace add /absolute/path/to/kipu-mcp
claude plugin install kipu@kipu-local --scope local
# or for one session only: claude --plugin-dir /absolute/path/to/kipu-mcp
```
If the server is already registered with `claude mcp add`, remove that registration (`claude mcp remove kipu -s local`). Likewise, remove a hand-written SessionStart hook from settings. Otherwise both run, because Claude Code matches plugin servers by command, not by name. Through the plugin, the tools are named `mcp__plugin_kipu_kipu__<tool>`. Each worktree resolves to the main checkout's ledger, so `KIPU_ROOT` is not needed.
Not verified yet:
- Whether Claude Code adds the session-start text again after compaction. The hook runs then, with `source: "compact"`, but the docs do not say whether the text is shown again. The `As of` line shows how old a summary is either way.
- Codex has no equivalent of the Stop hook here.
## Tools (MCP) and commands (CLI)
| MCP tool | CLI | What it does |
|---|---|---|
| `set_work_context` | `work set` | create/update a work item: one-line purpose, status (`active paused blocked done dropped`), next action, `parent` (the goal it serves), `replaced_by` (the work that took over a dropped one). Give `work_id` to choose the id. A status change needs a reason; old values stay in `history` |
| `record_decision` | `decide` | choice, reason, alternatives (or none recorded), refs (paths/commits), `decided_by`, evidence, `request_key` |
| `supersede_decision` | `supersede` | old decision id + new decision + why it changed; the old one stays, marked `superseded` |
| `search_records` | `search` | words, path, work id; current only unless `include_history` (`--all`); short results with id and provenance |
| `resume_context` | `resume` | purpose, the goals above it (`goal_path`), current decisions, recent supersessions, next action; says "nothing recorded" rather than guessing |
| `find_evidence` | `evidence pick` | recent user messages from this repository's Claude Code / Codex logs (short, masked) to cite |
| — | `evidence check` | look one message up by session and message id (this project's sessions only; says `human_session` when `human_session_paths` is set) |
| — | `graph [--json]` | the goal map: a tree of work items, or the full graph model with `--json` ([below](#goal-map)) |
| — | `stats` | usage summary for the two-week measurement (`docs/measure.md`) |
| — | `doctor [--fix]` | malformed files, half-finished supersedes, broken provenance seals, locks, unusable settings, an unignored `config.local.json` |
| — | `hook session-start` | the hook above |
`request_key` makes a retried call safe: the same key always maps to the same record id, so it is created once.
Read responses are bounded even when files were edited by hand to any length: each field is cut (with `…`), `resume_context` stays under 6,000 characters and `search_records` under 8,000, dropping trailing items (`more_decisions`, `omitted_for_size`).
## Goal map
Where the work was heading, how far it got, and what changed and why. The ledger is the material; `graph --json` turns it into one read-only model that any screen can draw (the HTML view, later a VS Code panel or a terminal graph).
**Goal links** on a work item, both optional:
- `parent`: the work id of the goal it serves (`work set --parent ID`). A work without one is top-level, which is how records written before this field read.
- `replaced_by`: the work that took over when this one was dropped (`work set --status dropped --reason … --replaced-by ID`). Only for status `dropped`; to reopen the work, clear it with `--replaced-by ""`.
- `top_level`: say so when a work really has no goal above it (`work set --top-level`, MCP `top_level: true`). Without it, a work with no parent reads as "goal link not recorded", not as a top-level goal. It excludes a parent; setting a parent clears it.
- A link must name a recorded work item other than itself, and following links may never come back to it (no cycles). Changes go to `history` like any other field.
- Links made by hand that point nowhere or form a cycle are cut when read (a cycle at its smallest id), so a screen can always walk up to a top-level goal; `doctor` lists them.
**The model** (`version: 1`, `minor: 1`; fields are only ever added as optional). Version 1.1 puts the gaps and the uncertainty in the data, because a clean picture of missing records is a wrong picture:
```json
{
"version": 1, "generated_at": "2026-11-26T07:05:00.000+09:00", "root": "my-repo",
"works": [{ "id": "model", "purpose": "…", "status": "active", "parent": "product", "replaced_by": null,
"next_action": "…", "created_at": "…", "updated_at": "…" }],
"decisions": [{ "id": "d-…", "work": "model", "choice": "…", "reason": "…", "decided_by": "user",
"provenance": "user·log", "status": "current", "supersedes": null, "superseded_by": null,
"alternatives": ["…"],
"created_at": "…", "evidence": [{ "client": "claude-code", "session": "…", "message": "…", "quote": "…" }] }],
"events": [{ "at": "…", "kind": "parent_changed", "work": "model", "ref": null, "from": null, "to": "product",
"reason": "…", "client": "cli" }]
}
```
**Consumer rule: ignore event kinds you do not know.** New kinds are added under this rule with only a `minor` bump, so a screen written for one version keeps working on the next. Unknown fields are optional and safe to ignore too.
- Works also carry `top_level_confirmed`, `last_event_at` and `parent_linked_late` (the current parent was attached after the work was created, or by hand).
- `last_event_at` and `coverage.last_record_at` come from everything stored (created and updated times, every history entry, every decision), not only from the exported events, so a change with no event kind or an event cut by the size limit still counts.
- `works[].needs_update` (optional): fixed codes for why the record no longer says what is true: `closed_with_old_next` (closed while the next action set before the close was left in) and `closed_still_waiting` (closed while it still waits on the user). Absent when no rule fires, which does not mean the record was checked as true. Added without a `minor` bump under the rule above.
- `works[].waiting_on_user` (optional): what the work waits for the person to decide or approve. Absent when nothing. Added without a `minor` bump under the rule above.
- `decisions[].alternatives`: the options considered, as recorded with the decision (each at most 200 characters, at most 10). Always present; `[]` means none were recorded, not that there were none. Added without a `minor` bump under the rule above.
- `coverage`: `generated_at` and `last_record_at` (a freshly made file can show old records), `ledger_started_at` (the earliest stored time: days before it are "before the ledger", not gaps), `files_read` (record files in the graph), `files_skipped` (`[{path, reason}]`), `entries_skipped` (`[{path, reason, count}]`, always present, `[]` when none), and `truncated` counts.
- Times are never made up. A work or decision whose own time cannot be read (a hand edit such as `created_at: not-a-date`) is left out of the graph and listed in `files_skipped`. A single history entry with an unreadable time is left out of events and freshness and counted in `entries_skipped`; the rest of the file is used. The graph keeps the newest 500 works, 2,000 decisions and 5,000 events; a link into what was left out becomes `null`.
- `activity` (optional): per local date over the last 30 days, `commits`, `commits_linked` (commits with a `Ledger-Work: <id>` or `Decision: <id>` trailer, as git parses trailers) and `ledger_events`. Commits are chosen and counted by their **author date** (closest to the day the work was done), read with `git log --branches --remotes` over the whole history because git can only filter by committer date. It is a stand-in signal for unrecorded work, **not a miss rate**: one goal spans many commits, one commit can serve several, and a dropped goal may have none. Without git, outside a repository or when git fails, `activity` is left out and `coverage.activity_unavailable` says why as a fixed code: `git_not_found`, `not_a_repository`, `unsafe_repository` (git does not trust the folder's owner), `git_timeout`, `git_failed`. git's own message is never copied, since it can hold absolute paths and user names and the graph is meant to be shared. The graph is still made. `graph --no-activity` skips it.
- Times are in this machine's time zone with its offset, so dates read as your day (the files store UTC).
- `provenance` is worked out again on every read, as in `resume`. Quotes are at most 200 characters, masked.
- `events`, oldest first, one per change: `work_created`, `status_changed`, `next_changed`, `parent_changed`, `purpose_changed`, `replaced_by_changed`, `top_level_changed` (`"true"`/`"false"`) from the work's history, and `decision_recorded`, `decision_superseded` (one per decision; `ref` is its id, `from`/`to` are the old and new choice).
- Reading the map re-checks provenance, so `graph` reads the cited messages in your session logs (nothing from them is printed beyond the label).
- Each `graph` run is counted in `usage.jsonl` as `goal_graph`. Add `--purpose dev` to development and test runs: `stats` leaves them out of the summary and says how many.
- Over MCP there is no map tool: the next agent gets the goals above its work through `resume_context` (`goal_path`) and the session-start hook's `Toward:` line.
## Who decided: the provenance rule
When writing:
- `decided_by: agent` — always accepted. Evidence is optional.
- `decided_by: user` — needs at least one evidence item that checks out:
- a Claude Code or Codex log message **from a session of this project** (see below), found by `session` + `message` ids (from `find_evidence`) or by a `quote` of it, whose role is **user** (not the assistant, a tool result or injected context), and whose text contains the quote if one was given; or
- `manual` evidence (`--manual-quote`) entered through the CLI. Over MCP, manual evidence is not accepted: the server cannot tell that a person confirmed it. (An agent that runs the CLI through a shell can still use it; that is outside what the tool can tell apart.)
- Anything else is **refused** with `provenance_unverified` and the reason per evidence item (`not_user`, `quote_mismatch`, `not_found`, `other_project`, `not_human_session`, `unavailable: …`, `manual_needs_cli`). `not_human_session`: the message is from a session outside `human_session_paths` (see [Settings](#settings-which-sessions-count)). Refusing (rather than saving as "unverified user") keeps the record from claiming the user decided something they did not.
When reading, the label is worked out again; the `verified` flags in the file are not trusted on their own:
| label | meaning |
|---|---|
| `user·log` | the record's seal is intact **and** a cited message still checks out now: same project, role user, same text |
| `user·manual` | seal intact; the evidence is a quote a person entered through the CLI (nothing to re-check) |
| `user·unconfirmed` | seal intact, but the cited log can no longer be read (the client pruned the session, the log moved, or its format changed), or the settings file cannot be read |
| `user·unverified` | no seal, a broken seal, or the log contradicts the evidence (wrong role, other project, outside `human_session_paths`, message changed or missing) |
| `agent` | the agent's own decision |
What the seal guarantees, and what it does not:
- At write time the record gets `seal:`, a checksum over its id, work, choice, `decided_by` and evidence; each log evidence item also keeps `text_hash`, a hash of the cited message's masked text. Editing any of those by hand turns the label into `user·unverified` (`doctor` lists it). The reason text is not sealed, so it stays freely editable.
- It is a checksum, not a signature. Someone who recomputes it on purpose can forge it; anyone who can write the files can also write the logs. It protects the meaning of the label against hand edits and mistakes, not against a person with write access who intends to fake it.
- It says the user wrote the cited message. Whether that message really is the decision is for the person reading it to judge.
- Records written before the seal existed read as `user·unverified`.
## Session logs
Read-only adapters; the formats have no official guarantee.
- Claude Code: `$CLAUDE_CONFIG_DIR` or `~/.claude`, `projects/<folder>/<session>.jsonl`; message id = the line's `uuid`.
- Codex: `$CODEX_HOME` or `~/.codex`, `sessions/**/rollout-*.jsonl`; message id = `line:<n>`. Newer Codex versions can migrate sessions to a different "thread history" store; that store is not read.
Which sessions count as this project: those whose **recorded working directory** (Claude: the `cwd` on its lines; Codex: `session_meta.cwd`)
- belongs to the same repository: the repository around it has the same git common dir (read from its `.git`). Plain subfolders and every worktree count; a separate repository below the root (`repo/child`, a submodule) or next to it (`repo-private`) does not, whatever its path looks like; or
- is inside a folder listed in `session_paths` or `human_session_paths` that is **not** part of this repository ([Settings](#settings-which-sessions-count)). Listing a folder there is an intentional addition, so another repository named there counts. Listing a folder of this repository (such as `"."`) adds nothing beyond the first rule.
Paths are compared on path boundaries and both as written and as real paths (macOS `/tmp` is `/private/tmp`). This applies to listing, to lookups by id and to the read-time check alike; evidence from another project is refused. A session whose working directory cannot be read is left out. A folder that no longer exists is judged by its nearest existing parent, so a removed worktree's sessions read as another project.
Claude Code log folders are named after the working directory as the client saw it, possibly through an alias. A folder whose name matches none of the project's known paths is judged by the working directory one of its sessions records (its first lines only).
## Settings: which sessions count
Optional. `.kipu/config.json` (committed, shared with everyone who clones) and `.kipu/config.local.json` (gitignored, yours only) take the same keys; lists from both are combined.
```json
{
"session_paths": ["~/notes/project-planning"],
"human_session_paths": ["~/notes/project-planning", "."]
}
```
- `session_paths`: other folders whose sessions count as this project, e.g. a planning folder outside the repository where you talk to an agent about it, or a separate repository inside this one that you want included.
- `human_session_paths`: when set, only user messages from sessions under these folders count as **your** words for `decided_by: user`. Messages from other sessions of the project are refused with `not_human_session`, left out of `find_evidence` (which then answers `human_sessions_only: true`), and decisions already citing them read as `user·unverified`. These folders count as this project too. List the repository itself (`"."`) if you also talk to agents there.
- Paths: `~/…` is your home folder, relative paths are against the repository root, absolute paths as written. The filesystem root and the home folder itself are refused as too broad. Unknown keys are refused (a misspelt key must not silently drop a restriction).
- If a settings file cannot be used (bad JSON, unknown key, wrong type), **no** log message counts as the user's until it is fixed: `find_evidence` and the evidence checks answer `unavailable` with the reason, and `doctor` lists it.
**Multi-agent setups.** When an orchestrator starts agents and pastes their task into the session (Orca, scripted `claude -p`, Codex workers, …), the log records that pasted text with the **user** role. The tool cannot tell it from something you typed, and it does not guess from the wording. Without `human_session_paths`, an agent can cite its own brief as "the user decided". If agents work in sessions you do not type in, set `human_session_paths` to the folders you do.
**Personal paths.** `config.json` is committed. An absolute path such as `/Users/you/...` puts your user name and folder layout in the repository, which matters for a public one. Prefer `~/…` or relative paths there, and put anything personal in `config.local.json`. That file is listed in `.kipu/.gitignore` (stores made before it existed get the line on their next write, or with `doctor --fix`). It is also why there are two files rather than one: a team can commit the rule, and each person keeps their own folders out of history.
When something cannot be read, the answer says so instead of looking empty: `find_evidence` reports `unavailable` per client, for example "1 session file(s) in an unrecognized format" or "… whose project could not be determined", next to whatever could be read. A session with no user messages, or a torn last line of a running session, is normal and not reported.
Nothing from a log is written to the repository except the short, masked quote of the cited message, its ids and a hash of its masked text.
## Files
```
.kipu/
.gitignore usage.jsonl, tmp/, locks/, config.local.json (local only)
config.json optional settings (committed)
config.local.json optional personal settings (not committed)
work/pay.md
decisions/d-7k2m9xqp.md
usage.jsonl tool, time, client, result count, ok — no content
```
A decision:
```markdown
---
id: d-7k2m9xqp
work: pay
status: current
choice: Toss로 간다
decided_by: user
alternatives:
- Stripe
refs:
- src/pay/toss.ts
supersedes: ""
superseded_by: ""
evidence:
- client: claude-code
session: 11111111-aaaa-4bbb-8ccc-000000000001
message: u-1
role: user
quote: 결제 모듈은 Stripe 말고 Toss로 가자. 키는 [REDACTED] 이거 써
verified: "true"
via: log
text_hash: 3f0c2a9d6b1e4f7a8c5d2e10
checked_at: "2026-11-26T09:00:03.000Z"
created_at: "2026-11-26T09:00:03.000Z"
client: claude-code
request_key: ""
seal: "v1:9b4f…"
---
## Reason
수수료가 낮다
```
You can edit these files by hand; they are re-read on every call. A file that does not parse is skipped and reported as a warning (`search`, `doctor`). Frontmatter is a small YAML subset: `key: value`, lists, and lists of `key: value` items.
### Several clients at once
Each client runs its own server process, all on the same files:
- writes go to a temp file and are renamed into place; new records are created with an exclusive link, so ids never collide;
- updates to one record are serialized with a lock file that names its owner (pid, host, random token). A lock is **never taken from a live owner**, however long it holds it; a waiting call gives up after 30 s with `busy` instead. Only a lock whose owner is a process on this host that no longer exists is reclaimed, and a lock is released only by the holder whose token it carries. A lock from another host (a synced or network folder) is never reclaimed automatically: `doctor` shows it, and you can delete it once no client is running there;
- supersede writes the **new** decision first (the commit point), then marks the old one. If a crash lands in between, readers already treat the old decision as superseded, and a retry with the same `request_key` or `doctor --fix` finishes the second write.
## AGENTS.md / CLAUDE.md block
Add this to your project's instructions (also in `examples/AGENTS-snippet.md`):
```markdown
## Work-context ledger (kipu)
- At the start of a task, call `resume_context` (or read what the session-start hook printed).
- Keep the work item current with `set_work_context`: purpose, status (with a reason when it changes), next action.
- When an important choice is made, call `record_decision`; when one changes, call `supersede_decision` with the reason.
- Use `decided_by: "user"` only for choices the user stated, with evidence from `find_evidence`. Otherwise use `"agent"`.
- Before changing something a decision covers, check `search_records` (by path or words).
```
## Renaming
The name `kipu` comes from `PRODUCT_NAME` in `src/name.ts`; the code derives everything else from it (CLI and MCP bin names, MCP server name, the `.kipu` folder, the `KIPU_` environment prefix). These places cannot import it and must be changed by hand:
| place | what |
|---|---|
| `package.json` | `name`, the two `bin` keys |
| `README.md` | title, commands (`claude mcp add`, `npx`), config snippets, store folder, variable names, AGENTS block heading |
| `examples/codex-config.toml`, `examples/claude_desktop_config.json` | server name, root variable |
| `examples/AGENTS-snippet.md` | heading |
| `.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json` | plugin name, MCP server name, marketplace name (`<name>-local`) |
`test/structure.test.ts` finds the name in each of these positions and compares it with `src/name.ts`, so a leftover old name fails the test.
## Design
kipu is written as small objects with one job each, so a new client, rule, tool or screen is a new class rather than an edit to an old one. `test/structure.test.ts` holds these lines.
| layer | objects | what varies by subclass or implementation |
|---|---|---|
| domain (`src/core/domain`) | `WorkItem`, `Decision` | — they keep their own rules: a status change needs a reason, a top-level work has no parent, a decision is sealed; callers get copies, never the state |
| storage (`src/core/store`) | `SnapshotReader`, `WorkReader`/`WorkWriter`, `DecisionReader`/`DecisionWriter`, `StoreHousekeeping` → `MarkdownRecordStore` | the backend; `RecordCodec` → `WorkCodec`, `DecisionCodec` per record kind |
| session logs (`src/core/logs`) | `SessionLogSource` → `ClaudeCodeLogs`, `CodexLogs`; `SessionLogs` | the client: the base holds the shared steps (template method), a subclass reads one format |
| freshness (`src/core/freshness.ts`) | `FreshnessRule` → `ClosedWithOldNext`, `ClosedStillWaiting`; `FreshnessPolicy` | the rule: a new "no longer true" case is a new class |
| services (`src/core/services`) | `WorkService`, `DecisionService`, `SearchService`, `ResumeService`, `Doctor`, `GoalGraphBuilder`, `EvidenceFinder`; `EvidenceResolver`, `ProvenanceJudge` | — each depends only on the interfaces it uses (`Clock`, `ScopeSource`, `CommitSource`, the store's readers and writers) |
| facade (`src/core/ledger.ts`) | `Ledger` | — wires the defaults; `LedgerParts` replaces any collaborator |
| MCP (`src/mcp`) | `LedgerTool` → one class per tool | the tool |
| CLI (`src/cli`) | `Cli`; `CliCommand` → `LedgerCommand` → one class per command | the command; `LedgerCommand` shares repository, usage log, errors and `--json` |
| hooks (`src/hook`) | `AgentHook` → `SessionStartHook`, `StopHook` | the event; the base guarantees a hook never throws |
| map (`src/live`) | `MapReader`; `MapRenderer` → `HtmlMapRenderer`, `RowsMapRenderer` | how the map is drawn |
The map's layout and label code (`src/view/layout.ts`, `labels.ts`) stays as self-contained functions on purpose: the browser page runs the same source, inlined.
## Package layout
- `src/core` — domain, storage, session logs, rules, services and the `Ledger` facade. No MCP, no CLI.
- `src/mcp` — the stdio server; imports only `core` (checked by a test). Exported as `@hundredeuk2/kipu-mcp/mcp` with its own bin, so the server can also be shipped alone: copy `dist/core`, `dist/mcp`, `dist/name.js` (a test does exactly this and runs it).
- `src/cli` — the CLI; imports `core` and `hook`.
- `src/hook` — the session-start and Stop hooks, run through the CLI.
- `src/live` — the map for hosts that show it live: `map.ts` (the one read every host asks: map or "unchanged" by ledger version) and the one-window live server that picks the project and serves it in a frame.
- `integrations` — prototype hosts beside the product (Orca sidebar panel, Claude Code pane); not part of the published package.
## License
Apache License 2.0. See [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues