Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

docs: add a user guide and shorten the README

Erena7059187bb61
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45b7bf8..574a165 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- A user guide in `docs/guide/`: getting started, the map, reading the lineage, pull requests, teams and git, recording and cost, privacy, settings and troubleshooting. The README is now a short page with a feature list that links into it. `docs/guide/settings.md` is generated from the same texts as the panel's "?", and a test fails when it drifts.
+- `cogit config --help` also explains the settings only the CLI changes: inbox age, big change, trailer age and server port, besides git policy and agents.
+
### Changed
- `cogit init` needs a git repository and says to run `git init` first: the record is tied to commits (`Thought:` trailers, `blame`, `why`, `pr`) and travels through git, so outside a repository only half of cogit worked. The setup offer at session start stays quiet outside a repository.
diff --git a/README.md b/README.md
index 53f6b07..9083481 100644
--- a/README.md
+++ b/README.md
@@ -10,45 +10,46 @@ Git remembers what changed. cogit remembers why.
![The map: sessions, branches and the thoughts behind them](docs/images/map.png)
-cogit records every message you send to an AI coding agent as a *thought commit*, with what
-came of it and the message it answered. Code commits point back to the thought through a
-`Thought:` trailer, so `git log` and `cogit log` tell two halves of one story. Your agent reads
-the lineage with `cogit log`, `show`, `blame` and `search`; you read it as a map of sessions,
-branches and decisions.
+cogit records every message you send to an AI coding agent as a *thought commit*: what you
+asked, what came of it, and the message it answered. Your code commits point back to the
+thought behind them, so `git log` tells you what changed and cogit tells you why. It works with
+Claude Code today.
+
+## What it does
+
+- **Every message becomes a thought commit**: the question, the outcome, the decisions with
+ their reasons and the options that were rejected, and which earlier message it continues.
+- **A map of your sessions**: a git graph of your conversations with branches, decisions, a
+ "Your turn" inbox and a one-click command to resume any chat.
+- **Commits point back to their reason**: a `Thought:` trailer on each commit;
+ `cogit show <sha>`, `cogit blame` and `cogit why` follow it back.
+- **Pull request descriptions with the decisions**: `cogit pr` writes the goal, the
+ decisions and the rejected options, never the raw chat.
+- **Teams share the record through git**: after a pull, your teammates' sessions are on the
+ map too, with who ran them and what changed most.
+- **The agent remembers**: a new session starts where the last one left off, and before
+ editing a file the agent hears what was already tried and rejected there.
+- **Cheap by default**: a small side model records in the background; in our sessions it
+ cost about 1–2% of a session's tokens.
+- **Private by default**: no server, no account. The raw conversation stays on your machine
+ and keys are redacted.
## Why
-AI made writing code faster and moved the bottleneck to review. In a Harvard job-market
-working paper (Chen and Stratton, 4 August 2026; not peer-reviewed) covering 718 firms and
-725,938 workers, AI coding agents wrote 30% more lines of code, made 20% more commits and
-opened 23% more pull requests, while resolved Jira issues and epics showed no statistically
-significant gain — the paper rules out an increase larger than 12% of the baseline mean. The
-review absorbed the difference: average review time rose 49%, comments per pull request 35%,
-the share of pull requests with changes requested nearly doubled (0.13 to 0.25), and the share
-of workers doing reviews rose 14%. Pull requests did not get larger, so size does not explain
-it.
-
-A reviewer reading a diff sees what changed, not why: the goal, the decisions, and the options
-that were tried and rejected. That intent stays in the conversation with the coding agent,
-where the reviewer cannot see it. cogit keeps it in the record and hands it over: the
-`Thought:` trailer links each code commit to the message behind it, `cogit show <sha>` opens
-that thought, and `cogit pr` turns a branch into a review-ready description. It does not
-promise a faster review — nothing has measured that yet; it gives the reviewer the intent they
-would otherwise have to ask for in comments.
-
-Sources: [Chen & Stratton, *Artificial Intelligence in the Firm: Bottlenecks in Software
-Production* (working paper, 4 August 2026)](https://fion.ac/jellyfish.pdf) ·
-[InfoQ's report](https://www.infoq.com/news/2026/10/jellyfish-ai-productivity/)
+AI coding agents made writing code faster and moved the bottleneck to review: in a study of
+718 firms, they opened 23% more pull requests while review time rose 49% and finished work did
+not measurably grow. A reviewer sees what changed, not why; the why stays in a chat nobody else
+reads. cogit keeps it next to the code. [More, with sources](docs/guide/why.md).
## Install
+You need Node 22.13+, Claude Code 2.1.275+ and a git repository.
+
```bash
-npm install -g cogit # the CLI; Node >= 22.13
-npx cogit --help # or run it without installing
+npm install -g cogit
```
-The Claude Code plugin adds the skill that keeps the record and the hooks that maintain it
-(Claude Code 2.1.275 or later):
+Then, in Claude Code:
```text
/plugin install cogit --marketplace sainthardrock/cogit
@@ -58,146 +59,33 @@ The Claude Code plugin adds the skill that keeps the record and the hooks that m
```bash
cd your-project
-cogit init # asks about git, transcript retention, team setup and summary language
-cogit open # builds the map and serves it on 127.0.0.1
+cogit init # a few questions: git, transcript retention, team setup, language
```
-Then work as usual. The skill updates the record every few turns (`updateEveryTurns`, default
-5) and at session end; the hooks write `.cogit/HEAD`, rebuild the map and, if `recordCommit`
-is `auto`, commit the record. Nothing in the plugin can block a prompt or a commit: every
-hook failure is silent and exits 0.
-
-By default (`recorder: mixed`) a small side model records every few turns outside the chat and
-the session's own agent only checks in every 15 turns, which cost us about 1–2% of a session's
-tokens. With `recorder: agent` the agent writes the record itself, which added about 3–7% to a
-session's token cost in our sessions, more in short ones; `recorder: side` never interrupts the
-agent at all. In any mode, raise the turn counts to record less often.
-
-If you agree to the team setup, `init` also writes the project's `.claude/settings.json`
-(commit it to share): it turns the plugin on for everyone who opens the repository, and adds a
-small hook that stops the first message of a session that started without the plugin, once,
-with the install command, since such a session records nothing. Send the message again to go
-on without recording. Headless runs (`claude -p`) are never stopped.
-
-## Read the lineage
+Work with Claude Code as usual; recording needs nothing from you. Then open the map:
```bash
-cogit log # like git log: messages and branches, newest first
-cogit log --branches # only the branch summaries
-cogit log --file src/auth.ts # the thoughts that touched this file
-cogit show h3f9c2a1b4d6e # one message: the turn, what came of it, its commits
-cogit blame src/auth.ts:42 # which recorded message produced this line
-cogit why src/auth.ts # what earlier thoughts decided about this file, and rejected
-cogit search "refresh token" # titles, summaries, decisions and the stored conversation
+cogit open .
```
-Each takes `[dir]` (or `-C <dir>`), the list verbs take `-n <count>` and `--json`. A message is
-addressed by its hash (`h` plus 12 hex), `<session-id-prefix>:mN`, or — for `show` — a commit
-hash with a `Thought:` trailer.
-
-`cogit why <file>` runs the chain backwards: file → the commits that touched it → their
-`Thought:` messages → the decisions and rejected alternatives those messages recorded, newest
-first, each with its message hash and date. The lookup is exact, but the wording is the agent's
-summary from the record, so it is only as good as the record. The Claude Code plugin also uses
-it before an edit: when the file has rejected alternatives and the session has not been told
-about that file yet, the agent gets a short "earlier, for this file" note (at most five options,
-`tryBeforeNotes`). It is information, not a rule — the note never blocks the edit.
+## Guide
-## Review a PR with cogit
-
-On the branch, before opening the pull request:
-
-```bash
-cogit pr main --copy # Markdown on stdout, also copied to the clipboard
-```
+- [Getting started](docs/guide/getting-started.md): what `init` asks, your first session,
+ setting up a team
+- [The map](docs/guide/map.md): sessions, branches, the inbox, unread work, files, search
+- [Reading the lineage](docs/guide/reading-the-lineage.md): `log`, `show`, `blame`, `why`,
+ `search`
+- [Pull requests](docs/guide/pull-requests.md): `cogit pr`
+- [Teams and git](docs/guide/teams-and-git.md): what is committed, the trailer, the hooks
+- [Recording and cost](docs/guide/recording-and-cost.md): who writes the record, what it
+ costs
+- [Privacy](docs/guide/privacy.md): what is recorded and what never leaves your machine
+- [Settings](docs/guide/settings.md): every setting, explained
+- [Troubleshooting](docs/guide/troubleshooting.md)
+- [Why cogit](docs/guide/why.md): AI made code faster and review slower
-Open the pull request on github.com and paste it into the description (`gh pr create --body
-"$(cogit pr)"` works too if you use `gh`). It prints the goal, the sessions the work came
-from, each thought with its decisions and rejected options, and its commits and files — for
-example:
+The record format is in [docs/format.md](docs/format.md).
-```markdown
-## Goal
-- Add refresh-token rotation — Refresh tokens (9c32ab18)
-
-## Sessions
-Open a whole session with `cogit log --session <id>` or the map.
-- Refresh tokens (9c32ab18) · m12–m29 · 2026-10-24 09:12 → 2026-10-24 11:40
-
-## Thoughts
-
-### `hb7a9882` 9c32ab18:m24 — Rotate refresh tokens on use
-
-- Why: A leaked refresh token should stop working as soon as it is used.
-- Decided by: agreed
-- considered and rejected: shorten the token lifetime — it logs people out too often
-
-Commits:
-- `a1b2c3d` feat(auth): rotate refresh tokens on use
- - `src/auth/tokens.ts`
-
-## Commits without a recorded thought
-- `e4f5a6b` chore: bump deps — thought `h9c8b7a6` not recorded yet
-
-## Dig deeper
-- `cogit show <message-hash>` opens a thought: its decisions, the options it rejected, and the conversation turn for whoever has it locally.
-- `cogit show <sha>` opens the thought behind a commit.
-- This branch commits its record, so a reviewer who checks it out gets the same `cogit show` output.
-```
+## Licence
-`cogit pr` reads only the record's titles, summaries and decisions — never the conversation
-text or your raw prompts — so the description is safe on a public pull request. Under the
-default commit policy the record travels with the branch and a reviewer can run `cogit show`;
-under `gitPolicy: ignore` the description says the hashes resolve only on the author's machine.
-
-## What git sees
-
-- `.cogit/sessions/` and `.cogit/project.json` are committed by default, so the record travels
- with a clone. `cogit config git commit|ignore` switches an existing project; local state
- (conversations, locks, inbox, map, `HEAD`) is always ignored.
-- A `pre-commit` hook stages the current session's record with your next code commit. It never
- creates a record-only commit. `recordCommit` decides what happens to messages recorded after
- the last commit: `ask` (default), `auto` or `off`.
-- A `prepare-commit-msg` hook adds `Thought: h<id>` to a commit it can attribute — skipped for
- merges and squashes, and when `.cogit/HEAD` is older than `trailerMaxAgeHours`. `build`,
- `log`, `blame` and the Files view read the trailers back with `git log`.
-
-## Privacy
-
-- The raw conversation stays on this machine. `.cogit/conversations/` holds a local copy of the
- transcript so the panel keeps working after Claude Code deletes it; `.cogit/.gitignore` keeps
- it out of git unless `shareConversations` is on.
-- The record holds titles, summaries, decisions and work items — never tool output.
-- A redaction pass for keys and token patterns runs over everything the map writes or shows.
-- Claude Code keeps transcripts for `cleanupPeriodDays` (30 days by default); `init` offers to
- raise it and never changes it silently.
-
-## Settings
-
-`cogit config get [key]` and `cogit config set <key> <value>`, or **Settings** in the map.
-
-| Key | Default | What it does |
-|---|---|---|
-| `recorder` | `mixed` | Who records: a side model and the agent (`mixed`), the agent only (`agent`), or the side model only (`side`) |
-| `language` | `auto` | Summary language: the conversation's, or a fixed one |
-| `updateEveryTurns` | `15` | Turns between the main agent's record updates |
-| `sideEveryTurns` | `5` | Turns between the side model's background records |
-| `sessionEndCatchUp` | `true` | Summarize the last messages when a session ends |
-| `sideModel` | `haiku` | The side model: records every few turns outside the chat and at session end |
-| `messageSummaries` | `false` | A summary on every message, not just every branch |
-| `startupContext` | `true` | Hand the agent the previous session's lineage at session start |
-| `tryBeforeNotes` | `true` | Tell the agent, before an edit, what earlier thoughts rejected for that file |
-| `gitPolicy` | `commit` | Whether new projects commit the record |
-| `shareConversations` | `false` | Commit the raw conversation too |
-| `recordCommit` | `ask` | What to do with messages after the last code commit |
-| `inboxMaxAgeDays` | `1` | Days a waiting session stays in the "Your turn" inbox; older ones are hidden, not deleted |
-| `trailerMaxAgeHours` | `6` | How old `.cogit/HEAD` may be for a `Thought:` trailer |
-| `serverPort` | `4747` | Port for the local map server |
-
-## Docs and licence
-
-The record format — `.cogit/` layout, message ids, events, the `Thought:` trailer — is
-[docs/format.md](docs/format.md), with generated JSON Schemas in
-[docs/schema/](docs/schema/). The design and the full CLI surface are in
-[specs/cogit-mvp.md](specs/cogit-mvp.md), kept up to date with the code. MIT —
-see [LICENSE](LICENSE).
+MIT — see [LICENSE](LICENSE).
diff --git a/docs/guide/README.md b/docs/guide/README.md
new file mode 100644
index 0000000..013c527
--- /dev/null
+++ b/docs/guide/README.md
@@ -0,0 +1,20 @@
+# cogit guide
+
+The [README](../../README.md) shows what cogit is and how to start. This guide explains each
+part in detail.
+
+| Page | What it covers |
+|---|---|
+| [Getting started](getting-started.md) | Install, what `cogit init` asks, your first session, setting up a team |
+| [The map](map.md) | Sessions, branches, the "Your turn" inbox, unread work, files, search, resuming a session |
+| [Reading the lineage](reading-the-lineage.md) | `log`, `show`, `blame`, `why`, `search` in the terminal, and how the agent uses them |
+| [Pull requests](pull-requests.md) | `cogit pr`: a review-ready description with the decisions behind the code |
+| [Teams and git](teams-and-git.md) | What is committed, the `Thought:` trailer, the git hooks, teammates' records |
+| [Recording and cost](recording-and-cost.md) | Who writes the record, the side model, what it costs |
+| [Privacy](privacy.md) | What is recorded, what never is, what leaves your machine |
+| [Settings](settings.md) | Every setting with a plain-language explanation |
+| [Troubleshooting](troubleshooting.md) | Nothing is recorded, the map looks old, the port is taken, and more |
+| [Why cogit](why.md) | The review bottleneck AI coding created, with sources |
+
+The record format itself (the `.cogit/` layout, message ids, events, the trailer) is in
+[docs/format.md](../format.md), with JSON Schemas in [docs/schema/](../schema/).
diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md
new file mode 100644
index 0000000..4fa26f2
--- /dev/null
+++ b/docs/guide/getting-started.md
@@ -0,0 +1,92 @@
+# Getting started
+
+## Requirements
+
+- Node 22.13 or later
+- Claude Code 2.1.275 or later
+- A git repository: cogit ties its record to your commits, so `cogit init` stops in a
+ directory that is not in one. Run `git init` first.
+
+## Install
+
+```bash
+npm install -g cogit # the CLI
+npx cogit --help # or run it without installing
+```
+
+The Claude Code plugin adds the skill that keeps the record and the hooks that maintain it:
+
+```text
+/plugin install cogit --marketplace sainthardrock/cogit
+```
+
+A plugin update reaches a running session only after `/reload-plugins` or a new chat.
+
+## Set up a project
+
+```bash
+cd your-project
+cogit init
+```
+
+`init` asks a few questions. Every one has a flag, so `cogit init --yes` with flags runs
+without asking.
+
+| Question | Default | Flag |
+|---|---|---|
+| Project name | the directory name | `--name` |
+| Commit the session records to git? | yes | `--git commit\|ignore` |
+| Keep Claude Code transcripts longer? Claude Code deletes them after 30 days by default. | keep as is | `--retention <days\|keep>` |
+| Let the agent update the record without asking each time? | yes | `--allow-skill` / `--no-allow-skill` |
+| Turn the plugin on for everyone who opens this repository? | yes | `--project-settings` / `--no-project-settings` |
+| Summary language | the conversation's | `--language <lang\|auto>` |
+
+`init` changes your Claude Code settings only for the questions you agreed to. It backs up
+`~/.claude/settings.json` before the first change and prints what it changed.
+
+Running `init` again in a set-up project changes nothing except what you pass as flags, and
+refreshes the git hooks.
+
+## Your first session
+
+Open Claude Code in the project and work as usual. Nothing needs to be started by hand:
+
+- Every message you send becomes a node in the record, with the message it answered.
+- The record is written outside the chat by a small side model, and the agent itself checks in
+ every 15 turns to add its own decisions. See [Recording and cost](recording-and-cost.md).
+- When the session ends, whatever was left unrecorded is recorded.
+- Each code commit gets a `Thought:` trailer naming the message it came from.
+
+Then open the map:
+
+```bash
+cogit open . # this project's map
+cogit open # the panel: every project on this machine
+```
+
+It runs a small server on `127.0.0.1:4747` and the page refreshes itself while you work. See
+[The map](map.md).
+
+In the next session the agent gets a short note on where the previous one left off, and before
+it edits a file it is told what earlier sessions tried and rejected there.
+
+## Set up a team
+
+If you agreed to turn the plugin on for the repository, `init` wrote the project's
+`.claude/settings.json`. Commit it. Then for everyone who opens the repository:
+
+- Claude Code offers to install the cogit plugin.
+- A session that started without the plugin records nothing, so a small hook stops its first
+ message once, with the install command. Send the message again to go on without recording.
+ Headless runs (`claude -p`) are never stopped.
+
+Each teammate runs `npm install -g cogit` and `cogit init` once on their machine; `init` sees
+the project is already set up, registers it on their machine and installs the git hooks in
+their clone. With the default commit policy,
+everyone's records travel with the branch. See [Teams and git](teams-and-git.md).
+
+## Stop recording
+
+- For one session: start Claude Code with `COGIT_DISABLE=1`.
+- For a project: remove `.cogit/` (and `.claude/settings.json`'s cogit lines if you added
+ them). `cogit hooks uninstall` removes the git hooks.
diff --git a/docs/guide/map.md b/docs/guide/map.md
new file mode 100644
index 0000000..74f8e63
--- /dev/null
+++ b/docs/guide/map.md
@@ -0,0 +1,92 @@
+# The map
+
+```bash
+cogit open . # this project's map
+cogit open # the panel: every project on this machine
+```
+
+`cogit open` builds the page and serves it on `127.0.0.1` (port 4747, `serverPort`), starting
+the server in the background if it is not running. The page refreshes itself whenever the
+record changes and keeps your place: the selected message, the unfolded branches, the scroll
+and the zoom. Nothing is sent anywhere; the server answers only this machine.
+
+![The map](../images/map.png)
+
+## Sessions and branches
+
+The map reads like a git graph of your conversations. Time runs down the page.
+
+- **A session** is one Claude Code chat. Its header shows the title, the feature it belongs
+ to (an *epoch*) and when it ran.
+- **A row** is one message you sent, titled in your words and saying what came of it.
+- **A branch** is a chain of messages that answer each other. It gets its own coloured lane;
+ its first message is a hollow ring carrying the branch's title. A new topic in the same chat
+ starts a new branch, and a message that goes back to an older thread curves out of that
+ thread.
+- **A return** to an earlier message without continuing it is a dashed arrow, marked
+ `↩ m22` on the row.
+- **Long branches fold** to their first and last message and a "⋮ N more" row. "Unfold all"
+ and "Fold all" open and close every branch at once.
+- **"Left off here"** marks the newest message you sent. The map opens there.
+
+A message with commits carries them as small chips with the commit subject, and a
+`+1 240 −80 · 14 files` chip saying how much code landed after it.
+
+## Message details
+
+Click a row to open its details on the right:
+
+- the branch it belongs to, with the branch summary: what was asked, what came of it, what is
+ still open
+- what was decided, who decided (you, the agent, or both), why, and the options considered
+ and rejected
+- what the agent did and decided on its own
+- the commits and files, each one opening git's own diff
+- the conversation turn itself: your message as written and the agent's written replies (tool
+ output is left out). This comes from your machine only; see [Privacy](privacy.md).
+- previous and next message buttons, and a **Copy resume command** button:
+ `cd '<project>' && claude --resume <session-id>` reopens that chat where it was.
+
+## "Your turn"
+
+Above the panel's project cards, and folded in a project map's head, the "Your turn" inbox
+lists the sessions waiting on you: the agent wrote last, or the record says it needs your
+answer. Each row shows the project, the session and the agent's last words, with a link
+straight to that message. The × hides a row until the agent writes in that session again.
+Sessions older than a day (`inboxMaxAgeDays`) leave the inbox; the map still has them.
+
+## Unread
+
+"Unread, most code first" lists the messages with commits you have not opened yet, the ones
+that changed the most code first. It is the quickest way to catch up on what a teammate's
+sessions did. Messages past `bigChangeLines` get a quiet highlight. Read state stays on your
+machine. In the terminal: `cogit log --unread`.
+
+## Files
+
+The Files view lists every file a recorded message touched, most recently first, with a
+count. Opening a file lists the messages that changed it; opening one of those jumps to it on
+the map. In the terminal: `cogit log --file <path>` and `cogit why <path>`.
+
+## Search
+
+The search box in the top bar (Ctrl+F or Cmd+F) finds text in message titles, decisions,
+branch summaries, session titles and the stored conversation, ignoring case and accents. Enter
+and Shift+Enter step through the hits, Esc clears. A pasted message hash jumps straight to that
+message. In the terminal: `cogit search "<text>"`.
+
+## Switching projects
+
+Under the project's name, a strip of the most recently active projects and
+**Switch project** (Ctrl+K, Cmd+K on macOS) search every project on this machine. Each shows
+where it left off. "← All projects" goes to the panel.
+
+## Settings
+
+**Settings** in the top bar changes the global settings. A "?" next to each one explains it;
+there is one Save for all changes. See [Settings](settings.md).
+
+## Without the server
+
+`.cogit/map.html` is a single file and opens without the server too, read-only. It is never
+committed: it can contain conversation text.
diff --git a/docs/guide/privacy.md b/docs/guide/privacy.md
new file mode 100644
index 0000000..8892dc8
--- /dev/null
+++ b/docs/guide/privacy.md
@@ -0,0 +1,36 @@
+# Privacy
+
+cogit has no server and no account. Everything runs on your machine; the only network calls
+are the ones your own Claude Code login makes for the side model.
+
+## What is recorded
+
+The record (`.cogit/sessions/`) holds titles, short summaries, decisions with their reasons
+and rejected options, the agent's work items, commit hashes and file paths. Never tool output,
+never file contents. The agent is told never to record secrets, credentials or personal data,
+and a redaction pass for key and token patterns runs over everything the map writes or shows.
+
+## What stays on your machine
+
+- **The raw conversation.** `.cogit/conversations/` keeps a copy of each transcript so the map
+ still works after Claude Code deletes it. It stays out of git unless you turn
+ `shareConversations` on. Turn it on only if everyone who can read the repository may read
+ your chats, and never in a public repository.
+- **The map** (`.cogit/map.html`) shows the conversation, so it is never committed.
+- **Local state:** read marks, the inbox, locks.
+
+## What git carries
+
+Under the default commit policy, the record travels with your branch. Anyone who can read the
+repository can read the titles, decisions and reasons. If the repository is public, so is the
+record. Choose the ignore policy for a project where that is not wanted; see
+[Teams and git](teams-and-git.md).
+
+`cogit pr` reads only the record, never the conversation, so its output is safe to paste into
+a public pull request.
+
+## Transcripts
+
+Claude Code deletes transcripts after `cleanupPeriodDays` (30 days by default). `init` offers
+to raise it and never changes it without asking. The conversation store keeps what cogit
+already read either way.
diff --git a/docs/guide/pull-requests.md b/docs/guide/pull-requests.md
new file mode 100644
index 0000000..7782254
--- /dev/null
+++ b/docs/guide/pull-requests.md
@@ -0,0 +1,66 @@
+# Pull requests
+
+A reviewer reading a diff sees what changed, not why. `cogit pr` turns a branch into a
+description with the goal, the decisions behind the code and the options that were rejected.
+
+On the branch, before opening the pull request:
+
+```bash
+cogit pr main --copy # Markdown on stdout, also copied to the clipboard
+```
+
+Without a base it uses the branch's upstream merge base, else `main`, else `master`. Paste the output into
+the pull request description on github.com, or with the GitHub CLI:
+
+```bash
+gh pr create --body "$(cogit pr)"
+```
+
+## What it prints
+
+The goal, the sessions the work came from, each message with its decisions and rejected
+options, and its commits and files. For example:
+
+```markdown
+## Goal
+- Add refresh-token rotation — Refresh tokens (9c32ab18)
+
+## Sessions
+Open a whole session with `cogit log --session <id>` or the map.
+- Refresh tokens (9c32ab18) · m12–m29 · 2026-10-24 09:12 → 2026-10-24 11:40
+
+## Thoughts
+
+### `hb7a9882` 9c32ab18:m24 — Rotate refresh tokens on use
+
+- Why: A leaked refresh token should stop working as soon as it is used.
+- Decided by: agreed
+- considered and rejected: shorten the token lifetime — it logs people out too often
+
+Commits:
+- `a1b2c3d` feat(auth): rotate refresh tokens on use
+ - `src/auth/tokens.ts`
+
+## Commits without a recorded thought
+- `e4f5a6b` chore: bump deps — thought `h9c8b7a6` not recorded yet
+
+## Dig deeper
+- `cogit show <message-hash>` opens a thought: its decisions, the options it rejected, and the conversation turn for whoever has it locally.
+- `cogit show <sha>` opens the thought behind a commit.
+- This branch commits its record, so a reviewer who checks it out gets the same `cogit show` output.
+```
+
+## Safe on a public pull request
+
+`cogit pr` reads only the record's titles, summaries and decisions, never the conversation
+text or your prompts as written.
+
+## For the reviewer
+
+Under the default commit policy the record travels with the branch, so a reviewer who checks
+it out and has cogit installed can run `cogit show <hash>` or open the map on the same
+messages. Under the ignore policy the description says the hashes resolve only on the author's
+machine.
+
+cogit does not promise a faster review; nothing has measured that yet. It hands the reviewer
+the intent they would otherwise have to ask for in comments.
diff --git a/docs/guide/reading-the-lineage.md b/docs/guide/reading-the-lineage.md
new file mode 100644
index 0000000..e6d2772
--- /dev/null
+++ b/docs/guide/reading-the-lineage.md
@@ -0,0 +1,47 @@
+# Reading the lineage
+
+The map is for you; the terminal commands are for you and for the agent. Each takes a project
+directory as `[dir]` or `-C <dir>`.
+
+```bash
+cogit log # like git log: messages and branches, newest first
+cogit log --branches # only the branch summaries
+cogit log --file src/auth.ts # the messages that touched this file
+cogit log --unread # messages with commits you have not opened, most code first
+cogit show h3f9c2a1b4d6e # one message: what came of it, its decisions, its commits
+cogit show a1b2c3d # the message behind a commit (through its Thought: trailer)
+cogit blame src/auth.ts:42 # which recorded message produced this line
+cogit why src/auth.ts # what earlier messages decided about this file, and rejected
+cogit search "refresh token" # titles, decisions, summaries and the stored conversation
+```
+
+`log` and `search` take `-n <count>` and `--session <id>`; `log`, `show` and `search` take
+`--json`; `show --no-chat` leaves out the conversation turn.
+
+## Addressing a message
+
+A message has a stable hash: `h` and 12 hex characters, like `h3f9c2a1b4d6e`. Any unique
+prefix of at least six characters after the `h` works. `<session-id-prefix>:mN` works too:
+`9c32ab18:m24` is the 24th message of that session. `show` also accepts a commit hash and
+opens the message in its `Thought:` trailer.
+
+## `cogit why`
+
+`why` runs the chain backwards: the file → the commits that touched it → the messages in their
+`Thought:` trailers → the decisions and rejected options those messages recorded. Newest first,
+each with its message hash and date.
+
+The lookup is exact, but the wording is the record's summary, so it is only as good as the
+record.
+
+## How the agent uses it
+
+The agent reads the same commands:
+
+- **At session start** it gets a short note on where the previous session left off, and how
+ to read the record (`startupContext`).
+- **Before it edits a file** that has rejected options on record, it gets a short "earlier,
+ for this file" note listing at most five of them, once per file per session
+ (`tryBeforeNotes`). It is information, not a rule: the note never blocks the edit.
+- **When you ask** "why did we do this?" or "did we try X before?", it can run `why`, `show`
+ or `search` itself.
diff --git a/docs/guide/recording-and-cost.md b/docs/guide/recording-and-cost.md
new file mode 100644
index 0000000..906b748
--- /dev/null
+++ b/docs/guide/recording-and-cost.md
@@ -0,0 +1,43 @@
+# Recording and cost
+
+## Who writes the record
+
+Two writers share the record, and `recorder` decides which ones run:
+
+- **The side model** runs outside the chat, in the background: a headless `claude -p` with a
+ small model (`sideModel`, Haiku by default) and no session of its own. It reads the
+ conversation and writes a node for every message: the title, the message it answers, and
+ the decisions you made. It never interrupts the agent.
+- **The main agent**, the one you are talking to, records through the cogit skill when the
+ Stop hook asks it to. It knows things the side model cannot see from the outside: why it
+ chose one approach, what it rejected, how a branch turned out.
+
+Each writer owns its own fields: the side model fills what is empty and never overwrites what
+the agent wrote.
+
+| `recorder` | What happens | Cost in our sessions |
+|---|---|---|
+| `mixed` (default) | The side model records every 5 turns (`sideEveryTurns`); the agent checks in every 15 (`updateEveryTurns`) to add its decisions | about 1–2% of a session's tokens |
+| `agent` | The agent records everything itself every `updateEveryTurns` turns | about 3–7%, more in short sessions |
+| `side` | Only the side model records; the agent is never asked | the side model's runs only |
+
+When a session ends, the side model records whatever is still unrecorded
+(`sessionEndCatchUp`). Nothing in the chat waits for it.
+
+## What it costs
+
+The side model runs with your own Claude Code login, like any `claude -p` run, so it uses
+your plan or API account. Haiku is about thirty times cheaper than the main model per token.
+In an A/B over three real sessions (109 messages) Haiku matched the main agent on message
+parents in 94% of cases and was good on titles and your decisions; it was weaker on the
+agent's own technical decisions and branch summaries, which is why `mixed` still asks the
+agent every 15 turns.
+
+To record less often, raise `sideEveryTurns` and `updateEveryTurns`. To spend nothing on
+recording during the session, use `recorder: side` and turn `sessionEndCatchUp` off; the
+messages then wait until you record them.
+
+## When something is not recorded
+
+A turn the side model has not reached yet shows on the map without a title for a while. If
+it stays that way, see [Troubleshooting](troubleshooting.md).
diff --git a/docs/guide/settings.md b/docs/guide/settings.md
new file mode 100644
index 0000000..7857096
--- /dev/null
+++ b/docs/guide/settings.md
@@ -0,0 +1,149 @@
+<!-- Generated from packages/cli/src/view/settings.ts; edit the texts there. -->
+
+# Settings
+
+Settings are global: one file for every project on this machine
+(`~/.config/cogit/config.json`). Change them under **Settings** in the map or the panel,
+or with `cogit config set <key> <value>`; `cogit config get` lists them all.
+
+## In the panel
+
+### Recording mode
+
+`recorder` · default `mixed`
+
+**Who writes the record: a side model, the main agent, or both.**
+
+Who writes the record. Mixed (recommended): a small side model records every few turns and the main agent still checks in every 15 turns to record its own decisions; measured on real sessions this costs about 1–2% of a session. Main agent: the agent records its own work every few turns, which costs about 5% of a session but catches its technical decisions best. Side model only: a small model records everything in the background and the agent is never interrupted.
+
+### Message summaries
+
+`messageSummaries` · default `false`
+
+**Write a one-line summary for each recorded message.**
+
+A one-sentence summary under each message title, so a skim reads better. Off keeps the record shorter and cheaper.
+
+### Lineage at session start
+
+`startupContext` · default `true`
+
+**Hand the agent the previous session's lineage when a chat starts.**
+
+When a chat starts, the agent gets a short summary of where the previous session left off and how to read the record. It costs a few tokens; turn it off if your projects are unrelated.
+
+### Tried-before notes
+
+`tryBeforeNotes` · default `true`
+
+**Before the agent edits a file, tell it which options earlier thoughts rejected for it.**
+
+Before the agent edits a file, it hears which options earlier thoughts tried and rejected for that file. These are notes from the record, never rules; they can make the agent ask before repeating a dead end.
+
+### Language
+
+`language` · default `auto`
+
+**Language the agent writes records in; `auto` follows the chat.**
+
+The language the record is written in. With auto, it follows the language of the conversation.
+
+### Record every N turns
+
+`updateEveryTurns` · default `15`
+
+**Ask the agent to record after this many turns.**
+
+How often the main agent is asked to update the record inside the chat. In mixed mode the side model records in between, so this can be rare (15 turns by default).
+
+### Side model every N turns
+
+`sideEveryTurns` · default `5`
+
+**How often the background recorder writes in mixed or side mode.**
+
+How often the small side model records in the background. A lower number keeps the map fresher and costs a little more; a higher number is quieter.
+
+### Side model at session end
+
+`sessionEndCatchUp` · default `true`
+
+**When a session ends, the side model records the messages still unrecorded.**
+
+When a session ends, the side model records whatever nobody got to. It runs outside the chat, so it does not spend the session's tokens.
+
+### Side model
+
+`sideModel` · default `haiku`
+
+**The small model that records outside the chat.**
+
+The small model behind every side record: every few turns in mixed mode, all the time in side mode, and at session end. Haiku is cheap and good enough for titles, parents and short decisions.
+
+### Share conversations
+
+`shareConversations` · default `false`
+
+**Commit the raw chat text too, not only the session record (off: chat stays local).**
+
+Also commit the raw chat text, not only the record. Leave it off to keep conversations on your machine while the record still travels with the branch.
+
+### Commit the record
+
+`recordCommit` · default `ask`
+
+**ask, auto or off: what to do with the last messages after the last code commit.**
+
+What happens to record changes made after your last code commit: ask you next time, commit them automatically, or leave them for you to commit.
+
+## Only through `cogit config`
+
+These are set up once, per project, or rarely touched, so the panel leaves them out.
+
+### Git policy
+
+`gitPolicy` · default `commit`
+
+**What `cogit init` offers a new project: commit the record to git, or ignore it.**
+
+Only the default for new projects: each project answers it during `cogit init`. `cogit config git` shows the current project's policy and `cogit config git commit` or `ignore` switches it.
+
+### Agents
+
+`agents` · default `claude-code`
+
+**Which agents record lineage; change it with `cogit config set`.**
+
+Which AI agents in this project should record what they are asked and what they decide. Claude Code is the only one today.
+
+### Inbox age
+
+`inboxMaxAgeDays` · default `1`
+
+**Days a waiting session stays in the "Your turn" inbox.**
+
+A session that waits on you longer than this leaves the inbox. It is hidden, not deleted: the map still has it.
+
+### Big change
+
+`bigChangeLines` · default `300`
+
+**Lines of code after which a message counts as a big change on the map.**
+
+Messages whose commits changed at least this many lines get a quiet highlight in the unread list. It never hides or ranks anything by itself.
+
+### Trailer age
+
+`trailerMaxAgeHours` · default `6`
+
+**How old the last message may be for a commit to get its `Thought:` trailer.**
+
+A commit made hours after the last message is probably not about that message, so past this age the commit gets no trailer instead of a wrong one.
+
+### Server port
+
+`serverPort` · default `4747`
+
+**Port of the local map server on 127.0.0.1.**
+
+Change it only when another program already uses the port.
diff --git a/docs/guide/teams-and-git.md b/docs/guide/teams-and-git.md
new file mode 100644
index 0000000..754dba5
--- /dev/null
+++ b/docs/guide/teams-and-git.md
@@ -0,0 +1,62 @@
+# Teams and git
+
+cogit keeps its record in `.cogit/` next to your code and ties it to your commits.
+
+## What is committed
+
+`init` asks whether to commit the record. The answer is per project.
+
+| | Commit (default) | Ignore |
+|---|---|---|
+| `.cogit/sessions/`, `.cogit/project.json` (the record) | committed | ignored |
+| `.cogit/conversations/` (raw chat) | ignored, unless `shareConversations` is on | ignored |
+| Local state: map, inbox, locks, `HEAD`, read marks | ignored | ignored |
+
+Under the commit policy, `.cogit/.gitignore` decides what stays local. Under the ignore policy,
+one `/.cogit/` line in the root `.gitignore` hides all of it.
+
+```bash
+cogit config git # this project's policy
+cogit config git commit # switch it
+cogit config git ignore
+```
+
+Switching never deletes a record; switching to ignore leaves what git already tracks alone.
+
+## The git hooks
+
+`init` adds a block to two git hooks in your clone (and follows `core.hooksPath`, so Husky
+setups work). The block never fails a commit.
+
+- **`prepare-commit-msg`** adds a `Thought: h<id>` trailer naming the message the commit came
+ from: the newest message of the current session. It is skipped for merges and squashes, and
+ when the last message is older than `trailerMaxAgeHours` (6 hours), since such a commit is
+ probably not about that message.
+- **`pre-commit`** stages the current session's record with your code commit. It never creates
+ a record-only commit.
+
+`recordCommit` decides what happens to messages recorded after your last code commit: `ask`
+(the next session start offers to commit them), `auto`, or `off`.
+
+```bash
+cogit hooks install # add or refresh the block
+cogit hooks uninstall # remove only the cogit block
+```
+
+## Working as a team
+
+1. One person runs `cogit init` with the team setup and commits `.cogit/` and
+ `.claude/settings.json`.
+2. Everyone installs the CLI and runs `cogit init` once in their clone. It sees the project is
+ set up, registers it on their machine and installs the git hooks.
+3. Each person's sessions are committed with their code. After a pull, teammates' sessions
+ appear on the map with their author, and "Unread" lists what changed most.
+
+Raw conversations stay on each author's machine unless they turn `shareConversations` on, so
+teammates see the record (titles, decisions, reasons) but not the chat itself.
+
+## Worktrees
+
+Sessions in a linked git worktree (`claude -w`) record into the main checkout's `.cogit/`
+under the ignore policy, and into the worktree's own copy under the commit policy. The
+details show which worktree and branch a session ran in.
diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md
new file mode 100644
index 0000000..f02e022
--- /dev/null
+++ b/docs/guide/troubleshooting.md
@@ -0,0 +1,59 @@
+# Troubleshooting
+
+## `cogit init` says the directory is not in a git repository
+
+cogit ties its record to commits, so it needs git. Run `git init` (or work in a clone), then
+`cogit init` again.
+
+## Nothing is recorded
+
+1. **Is the plugin on in this session?** Run `/plugin` in Claude Code and look for cogit. A
+ session that started before the plugin was installed or updated records nothing until
+ `/reload-plugins` or a new chat.
+2. **Is recording switched off?** `COGIT_DISABLE=1` in the environment turns every hook off.
+3. **Is the project set up?** `.cogit/project.json` must exist in the project (or in the main
+ checkout, for a worktree).
+4. **Did the side model fail?** Its output goes to `.cogit/state/detached.log`. The usual
+ causes: `claude` is not on the `PATH` of the hook, or it is not logged in.
+
+A message without a record yet is picked up by the next side run or at the session end. With
+`sessionEndCatchUp` off, the map says how many messages of a session are not recorded.
+
+## The map looks old after an upgrade
+
+The map server keeps running in the background with the version it started with, and it
+rebuilds the map with that version. Stop it (it listens on `127.0.0.1:4747`) and run
+`cogit open .` again.
+
+## The port is taken
+
+```bash
+cogit config set serverPort 4848
+```
+
+## The agent asks permission every time it records
+
+`init` offers to allow the cogit skill in `~/.claude/settings.json`. Run
+`cogit init --allow-skill` in the project to add it later.
+
+## A sandbox or container loses the settings
+
+cogit keeps its global settings and project list in `~/.config/cogit/` (or `$COGIT_HOME`). A
+sandbox that does not write through to that directory loses them after each run; bind it into
+the sandbox or set `COGIT_HOME` to a directory that persists. Project records in `.cogit/` are
+not affected.
+
+## A setup hint keeps appearing
+
+In a repository without cogit, a new session mentions once that cogit is not set up. To stop
+it in that project:
+
+```bash
+cogit config hint-off
+```
+
+## Something else
+
+Open an issue at <https://github.com/sainthardrock/cogit/issues> with the output of
+`cogit --version`, what you ran and, if it is about recording, the end of
+`.cogit/state/detached.log`.
diff --git a/docs/guide/why.md b/docs/guide/why.md
new file mode 100644
index 0000000..fc78c28
--- /dev/null
+++ b/docs/guide/why.md
@@ -0,0 +1,35 @@
+# Why cogit
+
+AI made writing code faster and moved the bottleneck to review. In a Harvard job-market
+working paper (Chen and Stratton, 4 August 2026; not peer-reviewed) covering 718 firms and
+725,938 workers, AI coding agents wrote 30% more lines of code, made 20% more commits and
+opened 23% more pull requests, while resolved Jira issues and epics showed no statistically
+significant gain. The paper rules out an increase larger than 12% of the baseline mean. The
+review absorbed the difference: average review time rose 49%, comments per pull request 35%,
+the share of pull requests with changes requested nearly doubled (0.13 to 0.25), and the share
+of workers doing reviews rose 14%. Pull requests did not get larger, so size does not explain
+it.
+
+A reviewer reading a diff sees what changed, not why: the goal, the decisions, and the options
+that were tried and rejected. That intent stays in the conversation with the coding agent,
+where the reviewer cannot see it. The author forgets it too: three weeks later, nobody
+remembers why the code went one way and not the other, and the agent starts every session
+knowing nothing about the last one.
+
+cogit keeps that intent in the record and hands it over:
+
+- the `Thought:` trailer links each code commit to the message behind it, and
+ `cogit show <sha>` opens that message
+- `cogit why <file>` lists what earlier sessions decided and rejected for a file
+- `cogit pr` turns a branch into a review-ready description
+- the agent gets the same record at session start and before it edits a file
+
+It does not promise a faster review; nothing has measured that yet. It gives the reviewer the
+intent they would otherwise have to ask for in comments, and gives the next session the
+context the last one ended with.
+
+## Sources
+
+- Chen & Stratton, [*Artificial Intelligence in the Firm: Bottlenecks in Software
+ Production*](https://fion.ac/jellyfish.pdf) (working paper, 4 August 2026)
+- [InfoQ's report](https://www.infoq.com/news/2026/10/jellyfish-ai-productivity/)
diff --git a/packages/cli/src/view/settings-doc.ts b/packages/cli/src/view/settings-doc.ts
new file mode 100644
index 0000000..c25c769
--- /dev/null
+++ b/packages/cli/src/view/settings-doc.ts
@@ -0,0 +1,45 @@
+import { Config } from "../schema/config.js";
+import { CLI_ONLY, panelSettingFields } from "./settings.js";
+
+/** How a default reads in the guide. */
+function formatDefault(value: unknown): string {
+ return `\`${Array.isArray(value) ? value.join(", ") : String(value)}\``;
+}
+
+/**
+ * `docs/guide/settings.md`, generated from the same texts as the panel's "?" and
+ * `cogit config --help`, with the defaults from the config schema. A test keeps
+ * the committed file equal to this, so the guide cannot drift from the code.
+ */
+export function settingsMarkdown(): string {
+ const defaults = Config.parse({ schema: 1 }) as Record<string, unknown>;
+ const section = (rows: { key: string; label: string; help: string; details: string }[]) =>
+ rows.flatMap((row) => [
+ `### ${row.label}`,
+ "",
+ `\`${row.key}\` · default ${formatDefault(defaults[row.key])}`,
+ "",
+ `**${row.help}**`,
+ "",
+ row.details,
+ "",
+ ]);
+ return [
+ "<!-- Generated from packages/cli/src/view/settings.ts; edit the texts there. -->",
+ "",
+ "# Settings",
+ "",
+ "Settings are global: one file for every project on this machine",
+ "(`~/.config/cogit/config.json`). Change them under **Settings** in the map or the panel,",
+ "or with `cogit config set <key> <value>`; `cogit config get` lists them all.",
+ "",
+ "## In the panel",
+ "",
+ ...section([...panelSettingFields()]),
+ "## Only through `cogit config`",
+ "",
+ "These are set up once, per project, or rarely touched, so the panel leaves them out.",
+ "",
+ ...section(CLI_ONLY),
+ ].join("\n");
+}
diff --git a/packages/cli/src/view/settings.ts b/packages/cli/src/view/settings.ts
index b3b9a0f..2c6788f 100644
--- a/packages/cli/src/view/settings.ts
+++ b/packages/cli/src/view/settings.ts
@@ -38,7 +38,7 @@ export interface SettingsSection {
fields: SettingField[];
}
-interface FieldSpec {
+export interface FieldSpec {
key: keyof PanelSettings;
label: string;
help: string;
@@ -161,7 +161,16 @@ const EDITABLE: FieldSpec[] = [
},
];
-const READ_ONLY: FieldSpec[] = [
+/** A setting only `cogit config` changes: per project, set up once, or rarely touched. */
+export interface CliSetting {
+ key: string;
+ label: string;
+ help: string;
+ details: string;
+}
+
+/** The settings the panel leaves out; `cogit config --help` and the guide explain them. */
+export const CLI_ONLY: CliSetting[] = [
{
key: "gitPolicy",
label: "Git policy",
@@ -170,7 +179,6 @@ const READ_ONLY: FieldSpec[] = [
"Only the default for new projects: each project answers it during `cogit init`. " +
"`cogit config git` shows the current project's policy and `cogit config git commit` " +
"or `ignore` switches it.",
- kind: "text",
},
{
key: "agents",
@@ -178,17 +186,51 @@ const READ_ONLY: FieldSpec[] = [
help: "Which agents record lineage; change it with `cogit config set`.",
details:
"Which AI agents in this project should record what they are asked and what they " +
- "decide. Change it with a config command or when you set the project up.",
- kind: "text",
+ "decide. Claude Code is the only one today.",
+ },
+ {
+ key: "inboxMaxAgeDays",
+ label: "Inbox age",
+ help: 'Days a waiting session stays in the "Your turn" inbox.',
+ details:
+ "A session that waits on you longer than this leaves the inbox. It is hidden, not " +
+ "deleted: the map still has it.",
+ },
+ {
+ key: "bigChangeLines",
+ label: "Big change",
+ help: "Lines of code after which a message counts as a big change on the map.",
+ details:
+ "Messages whose commits changed at least this many lines get a quiet highlight in " +
+ "the unread list. It never hides or ranks anything by itself.",
+ },
+ {
+ key: "trailerMaxAgeHours",
+ label: "Trailer age",
+ help: "How old the last message may be for a commit to get its `Thought:` trailer.",
+ details:
+ "A commit made hours after the last message is probably not about that message, so " +
+ "past this age the commit gets no trailer instead of a wrong one.",
+ },
+ {
+ key: "serverPort",
+ label: "Server port",
+ help: "Port of the local map server on 127.0.0.1.",
+ details: "Change it only when another program already uses the port.",
},
];
/**
* One section today, "Recording", so later groups slot in without a redesign.
* Over `file://` (`canEdit` false) the editable fields still appear, read-only,
- * with the build-time values. The CLI-only settings (`READ_ONLY`) stay out of
- * the panel: they are per project or have one choice, so `cogit config` shows them.
+ * with the build-time values. The CLI-only settings (`CLI_ONLY`) stay out of
+ * the panel: they are per project, set up once or rarely touched.
*/
+/** The panel's settings in their order, for the guide. */
+export function panelSettingFields(): readonly FieldSpec[] {
+ return EDITABLE;
+}
+
export function settingsSections(canEdit: boolean): SettingsSection[] {
return [
{
@@ -200,7 +242,7 @@ export function settingsSections(canEdit: boolean): SettingsSection[] {
/** The long plain-language text of one setting, for `cogit config --help`. */
export function configHelpLines(): string[] {
- return [...EDITABLE, ...READ_ONLY].map(
+ return [...EDITABLE, ...CLI_ONLY].map(
(field) => ` ${field.key}\n ${field.label}: ${field.help}\n ${field.details}`,
);
}
diff --git a/packages/cli/test/plugin-manifest.test.ts b/packages/cli/test/plugin-manifest.test.ts
index ae7aaff..4b698ad 100644
--- a/packages/cli/test/plugin-manifest.test.ts
+++ b/packages/cli/test/plugin-manifest.test.ts
@@ -1,4 +1,4 @@
-import { access, readFile } from "node:fs/promises";
+import { access, readdir, readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
const read = async (path: string) =>
@@ -52,11 +52,11 @@ describe("plugin packaging", () => {
expect(pkg.keywords).toEqual(expect.arrayContaining(["git", "claude-code", "lineage"]));
});
- it("keeps a README that shows the map and points at the spec and licence", async () => {
+ it("keeps a README that shows the map and points at the guide and licence", async () => {
const readme = await readFile(new URL("../../../README.md", import.meta.url), "utf8");
expect(readme).toContain("![The map");
expect(readme).toContain("(docs/images/map.png)");
- expect(readme).toContain("(specs/cogit-mvp.md)");
+ expect(readme).toContain("(docs/guide/getting-started.md)");
expect(readme).toContain("(LICENSE)");
// A relative image only renders when the file it names is in the repository.
await expect(
@@ -64,19 +64,27 @@ describe("plugin packaging", () => {
).resolves.toBeUndefined();
});
- it("points every relative README link at a file that exists (Story 10.2)", async () => {
- const readme = await readFile(new URL("../../../README.md", import.meta.url), "utf8");
- const root = new URL("../../../", import.meta.url);
- const links = [...readme.matchAll(/!?\[[^\]]*\]\(([^)\s]+)\)/g)]
- .map((match) => match[1] ?? "")
- .filter((href) => href !== "" && !/^[a-z]+:/i.test(href) && !href.startsWith("#"));
- expect(links.length).toBeGreaterThan(0);
- for (const href of links) {
- await expect(
- access(new URL(href.replace(/#.*$/, ""), root)),
- `README links to ${href}`,
- ).resolves.toBeUndefined();
+ it("points every relative link of the README and the guide at a file that exists", async () => {
+ const guide = new URL("../../../docs/guide/", import.meta.url);
+ const pages = [
+ new URL("../../../README.md", import.meta.url),
+ ...(await readdir(guide)).filter((f) => f.endsWith(".md")).map((f) => new URL(f, guide)),
+ ];
+ let checked = 0;
+ for (const page of pages) {
+ const text = await readFile(page, "utf8");
+ const links = [...text.matchAll(/!?\[[^\]]*\]\(([^)\s]+)\)/g)]
+ .map((match) => match[1] ?? "")
+ .filter((href) => href !== "" && !/^[a-z]+:/i.test(href) && !href.startsWith("#"));
+ for (const href of links) {
+ await expect(
+ access(new URL(href.replace(/#.*$/, ""), page)),
+ `${page.pathname} links to ${href}`,
+ ).resolves.toBeUndefined();
+ checked += 1;
+ }
}
+ expect(checked).toBeGreaterThan(10);
});
it("ships no runtime dependencies, since the CLI is bundled into one file", async () => {
diff --git a/packages/cli/test/settings-doc.test.ts b/packages/cli/test/settings-doc.test.ts
new file mode 100644
index 0000000..63caf1c
--- /dev/null
+++ b/packages/cli/test/settings-doc.test.ts
@@ -0,0 +1,9 @@
+import { describe, expect, it } from "vitest";
+import { settingsMarkdown } from "../src/view/settings-doc.js";
+
+describe("the settings guide", () => {
+ // `npx vitest run packages/cli/test/settings-doc.test.ts -u` rewrites it after a change.
+ it("is generated from the settings texts", async () => {
+ await expect(settingsMarkdown()).toMatchFileSnapshot("../../../docs/guide/settings.md");
+ });
+});
diff --git a/packages/cli/test/settings.test.ts b/packages/cli/test/settings.test.ts
index 34b7f72..4255cd1 100644
--- a/packages/cli/test/settings.test.ts
+++ b/packages/cli/test/settings.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import { CONFIG_SCHEMA, Config } from "../src/schema/config.js";
import { PANEL_EDITABLE_KEYS } from "../src/view/model.js";
import {
+ CLI_ONLY,
configHelpLines,
DEFAULT_SETTINGS,
editableSettings,
@@ -80,7 +81,7 @@ describe("settings model", () => {
it("prints the same long explanations in `cogit config --help` (Story 12.1)", () => {
const lines = configHelpLines();
- expect(lines.length).toBe(PANEL_EDITABLE_KEYS.length + 2);
+ expect(lines.length).toBe(PANEL_EDITABLE_KEYS.length + CLI_ONLY.length);
const text = lines.join("\n");
for (const field of settingsSections(true).flatMap((section) => section.fields)) {
expect(text).toContain(field.details);