Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
docs(review): position cogit on the review bottleneck
Erenc38f7ed69966
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d85cdfb..0f61411 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `cogit pr [base]` turns a branch into a review-ready Markdown description from the thoughts behind its commits: the sessions' goals, each thought's title, summary, decisions and rejected options, its commits and changed files, and the commits with no recorded thought (`thought h… not recorded yet` when the record has not caught up). The base is the upstream's merge base, else `main`, else `master`, with a clear error when none resolves; `--json` prints the same content as data and `--copy` puts the Markdown on the clipboard. It reads only the record — never the conversation text or the user's prompts — and stays under GitHub's body limit by dropping file lists first, then summaries, saying what was left out. The record skill hands its output over instead of writing a PR description itself.### Changed+- The help is organised for reading: `cogit --help` groups commands into Read, Map, Set up and Agent, every user-facing command carries an `Examples:` block, and the list ends with the README link. The README opens with the review bottleneck — citing Chen and Stratton's working paper on AI code output and review, with the paper's numbers — and a "Review a PR with cogit" walkthrough of `cogit pr`; `docs/format.md` states that `cogit pr` reads only the record, never conversations.- The panel uses the map's centred 8-of-12 column, and every page names the product: "cogit" with its slogan "Cogito, ergo commit." opens the top bar, and on a served map it leads back to the panel.- A calmer map head: the top bar holds only "cogit", the search and Settings; the project switcher (recent projects and Ctrl/Cmd+K, its button now "Switch project") sits under the project's name and path. On the panel a click anywhere on a project's card opens its map.- A project's map has a visible "← All projects" link under its project switcher, and opening the map, "Left off here", a search step or a file click frame the whole message row (lanes and text) in the middle of the map instead of only its dot, so the message no longer sits off to the right; a row wider than the map starts at its left edge.diff --git a/README.md b/README.mdindex 2bb75e1..b8bda03 100644--- a/README.md+++ b/README.md@@ -12,6 +12,30 @@ came of it and the message it answered. Code commits point back to the thought tthe lineage with `cogit log`, `show`, `blame` and `search`; you read it as a map of sessions,branches and decisions.+## 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/)+## Install```bash@@ -54,6 +78,53 @@ Each takes `[dir]` (or `-C <dir>`), the list verbs take `-n <count>` and `--jsonaddressed by its hash (`h` plus 12 hex), `<session-id-prefix>:mN`, or — for `show` — a commithash with a `Thought:` trailer.+## 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+```++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:++```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.+```++`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 travelsdiff --git a/docs/format.md b/docs/format.mdindex 04145ce..99bf0a0 100644--- a/docs/format.md+++ b/docs/format.md@@ -258,6 +258,14 @@ else is already staged, so a code commit carries its why and the hook nevercreates a record-only commit. `git commit -a`, `git commit <paths>` and atemporary index (`GIT_INDEX_FILE`) all work.+## Reading a branch for a pull request++`cogit pr` groups the commits of `base..HEAD` by the `Thought:` trailer and prints the+sessions' goals, each thought's title, summary, decisions and rejected options, and its+commits and changed files. It reads only the record (`project.json`, `sessions/`) — never+the conversation store and never the user's raw prompts — so its output is safe to paste into+a public pull request.+## What the schemas describe| File | Describes |diff --git a/packages/cli/src/program.ts b/packages/cli/src/program.tsindex eb34e82..ec8f634 100644--- a/packages/cli/src/program.ts+++ b/packages/cli/src/program.ts@@ -54,6 +54,11 @@ export function positiveCount(value: string): number {return count;}+/** The `Examples:` block every user-facing command carries in `--help` (Story 10.2). */+function examples(...commands: string[]): string {+ return `\nExamples:\n${commands.map((command) => ` $ ${command}`).join("\n")}\n`;+}+export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps = {}): Command {const program = new Command().name("cogit").description(pkg.description).version(pkg.version);@@ -72,45 +77,14 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =}};- program- .command("init")- .description("set up .cogit/ in a project and register it")- .argument("[dir]", "project directory", ".")- .option("--name <name>", "project name")- .addOption(- new Option("--git <policy>", "commit or ignore .cogit/").choices(["ignore", "commit"]),- )- .option("--language <lang>", 'summary language: "auto" or a language')- .option("--retention <days>", 'Claude Code transcript retention, or "keep"', retention)- .option("--allow-skill", "let the agent run the lineage skill without asking")- .option("--no-allow-skill", "leave Claude Code's permissions unchanged")- .option("-y, --yes", "accept defaults for every question")- .action(- run(async (dir: string, opts: InitOptions & { yes?: boolean }) => {- const { yes, ...rest } = opts;- // --yes never changes Claude Code's permissions on its own- if (yes) rest.allowSkill ??= false;- await init(dir, rest, makeIo(!yes && process.stdin.isTTY === true));- }),- );-- program- .command("build")- .description("regenerate .cogit/map.html")- .argument("[dir]", "project directory", ".")- .option("--quiet", "write the map without printing a success line")- .action(- run(async (dir: string, opts: { quiet?: boolean }) => {- await buildProject({ dir, io: makeIo(false), quiet: opts.quiet === true });- }),- );-program.command("blame").description("show which recorded messages produced the code in a file or line")+ .helpGroup("Read:").argument("<target>", "file, or file:line").argument("[dir]", "project directory", ".").option("-C, --dir <dir>", "project directory (same as the positional)")+ .addHelpText("after", examples("cogit blame src/auth.ts:42", "cogit blame src/auth.ts")).action(run(async (target: string, dir: string, opts: { dir?: string }) => {await blame({ dir: opts.dir ?? dir, target, io: makeIo(false) });@@ -120,6 +94,7 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("log").description("print the recorded lineage, newest first")+ .helpGroup("Read:").argument("[dir]", "project directory", ".").option("-C, --dir <dir>", "project directory (same as the positional)").option("--session <id>", "only this session (id or prefix)")@@ -127,6 +102,7 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =.option("--branches", "only the branch summaries (the compressed view)").option("--file <path>", "only messages that touched this file (its history)").option("--json", "print JSON instead of text")+ .addHelpText("after", examples("cogit log -n 10", "cogit log --file src/auth.ts")).action(run(async (@@ -165,11 +141,13 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("show").description("print one recorded message by hash, <session-id>:mN or commit hash")+ .helpGroup("Read:").argument("<ref>", "message hash, <session-id-prefix>:mN, or a commit hash").argument("[dir]", "project directory", ".").option("-C, --dir <dir>", "project directory (same as the positional)").option("--no-chat", "leave out the conversation turn").option("--json", "print JSON instead of text")+ .addHelpText("after", examples("cogit show h3f9c2a1b4d6e", "cogit show a1b2c3d")).action(run(async (@@ -188,12 +166,17 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("search").description("find recorded messages, branch summaries and conversation text")+ .helpGroup("Read:").argument("<text>", "text to look for").argument("[dir]", "project directory", ".").option("-C, --dir <dir>", "project directory (same as the positional)").option("--session <id>", "only this session (id or prefix)").option("-n, --number <count>", "at most this many hits", positiveCount).option("--json", "print JSON instead of text")+ .addHelpText(+ "after",+ examples('cogit search "refresh token"', "cogit search auth --session 9c32ab18"),+ ).action(run(async (@@ -216,6 +199,7 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("pr").description("print a review-ready description of a branch from the thoughts behind it")+ .helpGroup("Read:").argument("[base]", "base ref; default: the upstream's merge base, else main, else master").option("-C, --dir <dir>", "project directory", ".").option("--json", "print JSON instead of Markdown")@@ -246,7 +230,9 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("open").description("build and open a project map, or the global panel without a directory")+ .helpGroup("Map:").argument("[dir]", "project directory; omit to open the global panel")+ .addHelpText("after", examples("cogit open", "cogit open ../my-app")).action(run(async (dir?: string) => {const io = makeIo(false);@@ -260,27 +246,51 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =}),);- // Started detached by `open`; also useful on its own when the port is known.program- .command("serve", { hidden: true })- .description("run the local map server that `open` uses")- .option("--port <port>", "port to bind (default: serverPort from config)")+ .command("init")+ .description("set up .cogit/ in a project and register it")+ .helpGroup("Set up:")+ .argument("[dir]", "project directory", ".")+ .option("--name <name>", "project name")+ .addOption(+ new Option("--git <policy>", "commit or ignore .cogit/").choices(["ignore", "commit"]),+ )+ .option("--language <lang>", 'summary language: "auto" or a language')+ .option("--retention <days>", 'Claude Code transcript retention, or "keep"', retention)+ .option("--allow-skill", "let the agent run the lineage skill without asking")+ .option("--no-allow-skill", "leave Claude Code's permissions unchanged")+ .option("-y, --yes", "accept defaults for every question")+ .addHelpText("after", examples("cogit init", "cogit init ../my-app --git commit --yes")).action(- run(async (opts: { port?: string }) => {- const io = makeIo(false);- const port =- opts.port === undefined ? (await loadConfig(io.env)).serverPort : Number(opts.port);- if (!Number.isInteger(port) || port < 1 || port > 65535)- throw new CliError(`invalid port: ${String(opts.port)}`);- try {- await startMapServer({ env: io.env, port });- } catch (err) {- throw new CliError(`could not start the map server: ${(err as Error).message}`);- }+ run(async (dir: string, opts: InitOptions & { yes?: boolean }) => {+ const { yes, ...rest } = opts;+ // --yes never changes Claude Code's permissions on its own+ if (yes) rest.allowSkill ??= false;+ await init(dir, rest, makeIo(!yes && process.stdin.isTTY === true));+ }),+ );++ program+ .command("build")+ .description("regenerate .cogit/map.html")+ .helpGroup("Map:")+ .argument("[dir]", "project directory", ".")+ .option("--quiet", "write the map without printing a success line")+ .addHelpText("after", examples("cogit build", "cogit build ../my-app --quiet"))+ .action(+ run(async (dir: string, opts: { quiet?: boolean }) => {+ await buildProject({ dir, io: makeIo(false), quiet: opts.quiet === true });}),);- const config = program.command("config").description("read or change global settings");+ const config = program+ .command("config")+ .description("read or change global settings")+ .helpGroup("Set up:")+ .addHelpText(+ "after",+ examples("cogit config get language", "cogit config set updateEveryTurns 3"),+ );config.command("get").argument("[key]")@@ -330,9 +340,11 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =program.command("backfill").description("record the user messages a session has not summarized yet")+ .helpGroup("Agent:").argument("<session-id>", "session id").option("-C, --dir <dir>", "project directory", ".").option("--tail", "only this session's messages that have no node yet")+ .addHelpText("after", examples("cogit backfill 9c32ab18 --tail")).action(run(async (sessionId: string, opts: { dir: string; tail?: boolean }) => {if (opts.tail !== true)@@ -343,22 +355,11 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =}),);- // One-time data upgrade for records written before stable message ids (8.5).- program- .command("migrate", { hidden: true })- .description("give old records stable message ids and an events file")- .argument("[dir]", "project directory", ".")- .action(- run(async (dir: string) => {- const io = makeIo(false);- const result = await migrateIds(dir, io);- io.out(- `Migrated ${result.migrated} session(s); ${result.skipped} skipped (already migrated or unmappable).`,- );- }),- );-- const epoch = program.command("epoch").description("manage epochs (features, epics)");+ const epoch = program+ .command("epoch")+ .description("manage epochs (features, epics)")+ .helpGroup("Set up:")+ .addHelpText("after", examples('cogit epoch add e2e "End-to-end"'));epoch.command("add").argument("<id>", "short id, e.g. e2e")@@ -372,7 +373,12 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =const session = program.command("session")- .description("session records (used by the agent skill)");+ .description("session records (used by the agent skill)")+ .helpGroup("Agent:")+ .addHelpText(+ "after",+ examples("cogit session show 9c32ab18", "cogit session write --file inbox.json"),+ );session.command("write").description("merge session JSON from stdin into .cogit/sessions/")@@ -396,21 +402,11 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =),);- // Started detached by the SessionEnd hook when `recordCommit` is `auto`.- program- .command("record-commit", { hidden: true })- .description("commit the session record files without touching other staged changes")- .argument("<session-id>", "session id")- .option("-C, --dir <dir>", "project directory", ".")- .action(- run(async (sessionId: string, opts: { dir: string }) => {- await maybeAutoCommit(opts.dir, sessionId, makeIo(false).env);- }),- );-const hooks = program.command("hooks")- .description("manage the git hooks cogit adds to a project");+ .description("manage the git hooks cogit adds to a project")+ .helpGroup("Set up:")+ .addHelpText("after", examples("cogit hooks install", "cogit hooks uninstall"));hooks.command("install").description("add or refresh the cogit block in this project's git hooks")@@ -425,11 +421,14 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =// Called by the plugin's hooks.json with the hook input on stdin, and by the// git hooks cogit installs (Stories 9.3, 9.4) with git's arguments. Never fails.program- .command("hook", { hidden: true })+ .command("hook")+ .description("run one of the plugin or git hooks cogit installs (never blocks)")+ .helpGroup("Agent:").argument("<event>", "hook event, e.g. stop, sessionstart, pre-commit").argument("[args...]", "arguments git passed to its hook: $1, $2, …").option("-C, --dir <dir>", "project directory (git hooks pass theirs)").allowExcessArguments(true)+ .addHelpText("after", examples("cogit hook stop", "cogit hook pre-commit --dir ../my-app")).action(async (event: string, args: string[], opts: { dir?: string }) => {const io = makeIo(false);if (isGitHookEvent(event)) {@@ -445,5 +444,57 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =if (out !== undefined) io.out(out);});+ // Hidden commands are registered last so `help` stays at the end of the+ // top-level list: commander places a group where its first command appears.++ // Started detached by `open`; also useful on its own when the port is known.+ program+ .command("serve", { hidden: true })+ .description("run the local map server that `open` uses")+ .option("--port <port>", "port to bind (default: serverPort from config)")+ .action(+ run(async (opts: { port?: string }) => {+ const io = makeIo(false);+ const port =+ opts.port === undefined ? (await loadConfig(io.env)).serverPort : Number(opts.port);+ if (!Number.isInteger(port) || port < 1 || port > 65535)+ throw new CliError(`invalid port: ${String(opts.port)}`);+ try {+ await startMapServer({ env: io.env, port });+ } catch (err) {+ throw new CliError(`could not start the map server: ${(err as Error).message}`);+ }+ }),+ );++ // One-time data upgrade for records written before stable message ids (8.5).+ program+ .command("migrate", { hidden: true })+ .description("give old records stable message ids and an events file")+ .argument("[dir]", "project directory", ".")+ .action(+ run(async (dir: string) => {+ const io = makeIo(false);+ const result = await migrateIds(dir, io);+ io.out(+ `Migrated ${result.migrated} session(s); ${result.skipped} skipped (already migrated or unmappable).`,+ );+ }),+ );++ // Started detached by the SessionEnd hook when `recordCommit` is `auto`.+ program+ .command("record-commit", { hidden: true })+ .description("commit the session record files without touching other staged changes")+ .argument("<session-id>", "session id")+ .option("-C, --dir <dir>", "project directory", ".")+ .action(+ run(async (sessionId: string, opts: { dir: string }) => {+ await maybeAutoCommit(opts.dir, sessionId, makeIo(false).env);+ }),+ );++ program.addHelpText("after", "\nDocs: https://github.com/sainthardrock/cogit#readme\n");+return program;}diff --git a/packages/cli/test/plugin-manifest.test.ts b/packages/cli/test/plugin-manifest.test.tsindex 7a9d838..ae7aaff 100644--- a/packages/cli/test/plugin-manifest.test.ts+++ b/packages/cli/test/plugin-manifest.test.ts@@ -64,6 +64,21 @@ 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("ships no runtime dependencies, since the CLI is bundled into one file", async () => {const pkg = await read("../package.json");expect(pkg.dependencies).toBeUndefined();diff --git a/packages/cli/test/program.test.ts b/packages/cli/test/program.test.tsindex 530a7fd..9fa0df8 100644--- a/packages/cli/test/program.test.ts+++ b/packages/cli/test/program.test.ts@@ -1,12 +1,20 @@+import type { Command } from "commander";import { describe, expect, it } from "vitest";import pkg from "../package.json" with { type: "json" };import { createProgram } from "../src/program.js";function run(args: string[]): string {let out = "";- const program = createProgram()- .exitOverride()- .configureOutput({ writeOut: (s) => (out += s) });+ const program = createProgram();+ const writeOut = (s: string): void => {+ out += s;+ };+ // Help of a subcommand writes through that command's own output.+ const configure = (command: Command): void => {+ command.exitOverride().configureOutput({ writeOut });+ for (const sub of command.commands) configure(sub);+ };+ configure(program);try {program.parse(args, { from: "user" });} catch {@@ -23,4 +31,36 @@ describe("createProgram", () => {it("names the binary in help", () => {expect(run(["--help"])).toContain("Usage: cogit");});++ it("groups the top-level commands for reading (Story 10.2)", () => {+ const help = run(["--help"]);+ for (const heading of ["Read:", "Map:", "Set up:", "Agent:"]) expect(help).toContain(heading);+ const order = ["Read:", "Map:", "Set up:", "Agent:"].map((heading) => help.indexOf(heading));+ expect(order).toEqual([...order].sort((a, b) => a - b));+ expect(help).toContain("Docs: https://github.com/sainthardrock/cogit#readme");+ });++ it("gives every user-facing command an examples block (Story 10.2)", () => {+ const commands = [+ "init",+ "build",+ "blame",+ "log",+ "show",+ "search",+ "pr",+ "open",+ "config",+ "hooks",+ "epoch",+ "session",+ "backfill",+ "hook",+ ];+ for (const command of commands) {+ const help = run([command, "--help"]);+ expect(help, command).toContain("Examples:");+ expect(help, command).toContain(`$ cogit ${command}`);+ }+ });});