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.

feat(record): record with a side model by default

Eren57f3a310962c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66640fc..3983ab6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,12 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
+- Recording modes (`recorder`): `mixed` (the default) records with a small side model every `sideEveryTurns` turns outside the chat and asks the main agent every `updateEveryTurns`; `agent` keeps the agent writing its own record; `side` never interrupts the agent. The side model runs detached behind the session lock, writes message nodes, titles, parents and user decisions, and never overwrites a field the main agent wrote (per-field ownership, and the agent's parent corrections survive later side runs). `sideModel` (renamed from `catchUpModel`, which is still read and migrated) names the model. Every setting gains a "?" in the panel with a plain-language explanation — what it does, when to change it, what it costs — and `cogit config --help` prints the same text.
- A logo: the c of cogito drawn as a git lane with commits, with a branch that leaves and merges back (`docs/images/cogit-mark.svg`). It heads the README and is the browser tab icon of the map and the panel, which used to ask the server for a missing `favicon.ico`. Under the slogan the README shows Descartes, after the Frans Hals portrait, with git branches running through his hair.
- `cogit init` can set the project up for a team (`--project-settings`): it enables the plugin in the project's `.claude/settings.json` and adds a hook that stops the first message of an interactive session that started without the plugin, once per session, with the install command. Headless `claude -p` runs pass through.
- The README states what recording costs: about 3–7% of a session's tokens in measured sessions.
### Changed
+- The main agent's record interval defaults to 15 turns (was 5), and the side model records every 5 turns in between; the README states the measured cost of each mode (about 1–2% of a session with the mixed default, 3–7% with `recorder: agent`).
- The "Your turn" inbox: each row closes with an × in its top-right corner (hidden until the agent writes in that session again), rows of different projects carry their own lane colour on the left, and on a project's map the inbox starts folded to one "Your turn" line so it no longer pushes the map off the page.
## [0.14.0] - 2026-10-27
diff --git a/README.md b/README.md
index a056548..18dc64a 100644
--- a/README.md
+++ b/README.md
@@ -67,9 +67,11 @@ Then work as usual. The skill updates the record every few turns (`updateEveryTu
is `auto`, commit the record. Nothing in the plugin can block a prompt or a commit: every
hook failure is silent and exits 0.
-The record is written by the session's own agent, so it costs tokens: in our sessions it added
-about 3–7% to a session's token cost, more in short ones. Raise `updateEveryTurns` to record
-less often.
+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
@@ -176,10 +178,12 @@ under `gitPolicy: ignore` the description says the hashes resolve only on the au
| 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` | `5` | Turns between record updates |
+| `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 |
-| `catchUpModel` | `haiku` | Model for the session-end catch-up |
+| `sideModel` | `haiku` | Model for the side records and the session-end catch-up |
| `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 |
diff --git a/docs/schema/config.json b/docs/schema/config.json
index 36df914..2ff586b 100644
--- a/docs/schema/config.json
+++ b/docs/schema/config.json
@@ -13,7 +13,7 @@
"maxLength": 32
},
"updateEveryTurns": {
- "default": 5,
+ "default": 15,
"type": "integer",
"minimum": 1,
"maximum": 100
@@ -22,12 +22,32 @@
"default": true,
"type": "boolean"
},
- "catchUpModel": {
+ "recorder": {
+ "default": "mixed",
+ "type": "string",
+ "enum": [
+ "agent",
+ "mixed",
+ "side"
+ ]
+ },
+ "sideModel": {
"default": "haiku",
"type": "string",
"minLength": 1,
"maxLength": 64
},
+ "sideEveryTurns": {
+ "default": 5,
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 100
+ },
+ "catchUpModel": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 64
+ },
"messageSummaries": {
"default": false,
"type": "boolean"
@@ -109,7 +129,9 @@
"language",
"updateEveryTurns",
"sessionEndCatchUp",
- "catchUpModel",
+ "recorder",
+ "sideModel",
+ "sideEveryTurns",
"messageSummaries",
"startupContext",
"serverPort",
diff --git a/docs/schema/hook-state.json b/docs/schema/hook-state.json
index 31ec6c5..69eb8cd 100644
--- a/docs/schema/hook-state.json
+++ b/docs/schema/hook-state.json
@@ -31,6 +31,12 @@
}
]
},
+ "turnsSinceSide": {
+ "default": 0,
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 9007199254740991
+ },
"notedFiles": {
"default": [],
"type": "array",
@@ -46,6 +52,7 @@
"turns",
"turnsSinceUpdate",
"recordUpdatedAt",
+ "turnsSinceSide",
"notedFiles"
],
"additionalProperties": false
diff --git a/docs/schema/session-event.json b/docs/schema/session-event.json
index 1a6ee8a..7007481 100644
--- a/docs/schema/session-event.json
+++ b/docs/schema/session-event.json
@@ -35,7 +35,8 @@
"type": "string",
"enum": [
"agent",
- "user"
+ "user",
+ "side"
]
}
},
diff --git a/docs/schema/session.json b/docs/schema/session.json
index 9a4de0b..2212c4b 100644
--- a/docs/schema/session.json
+++ b/docs/schema/session.json
@@ -299,6 +299,20 @@
"additionalProperties": false
}
},
+ "by": {
+ "type": "object",
+ "propertyNames": {
+ "type": "string",
+ "maxLength": 40
+ },
+ "additionalProperties": {
+ "type": "string",
+ "enum": [
+ "agent",
+ "side"
+ ]
+ }
+ },
"addedAt": {
"type": "string",
"format": "date-time",
@@ -374,6 +388,13 @@
"type": "string",
"minLength": 1,
"maxLength": 200
+ },
+ "lastRecordedBy": {
+ "type": "string",
+ "enum": [
+ "agent",
+ "side"
+ ]
}
},
"required": [
diff --git a/packages/cli/src/commands/backfill.ts b/packages/cli/src/commands/backfill.ts
index cabb6f8..5ce2571 100644
--- a/packages/cli/src/commands/backfill.ts
+++ b/packages/cli/src/commands/backfill.ts
@@ -38,25 +38,42 @@ function recordPart(record: Session | undefined): string {
const lines = record.nodes.map(
(node) => `- ${node.id} (${node.kind}) parent=${node.parent ?? "null"}: ${node.title}`,
);
- return `The record so far (reuse these topic ids):\n${lines.join("\n")}`;
+ return `The record so far (reuse these ids; a parent is an earlier message):\n${lines.join("\n")}`;
}
-function rules(language: string, messageSummaries: boolean): string {
+/** Who runs the side model and how much of the record it may write (Story 12.1). */
+export type RecordMode = "agent" | "mixed" | "side";
+
+/**
+ * The recording rules, in line with `skills/record/SKILL.md`. In `mixed` mode
+ * this is the periodic side run: messages, titles, parents and user decisions
+ * only, because the main agent owns the status, the branch summaries and its
+ * own decisions.
+ */
+function rules(language: string, messageSummaries: boolean, recorder: RecordMode): string {
const writing = language === "auto" ? "the conversation's language" : language;
- return [
+ const lines = [
"Rules (from the cogit lineage skill):",
'- Send one "message" node for every message below, with the id exactly as given; skip none, even a short "ok".',
`- kind is "message". title: a few words in the user's own wording.${
messageSummaries ? " summary: one or two sentences on what came of it." : ""
}`,
- '- parent: the id of the topic it belongs to. Reuse a topic id from the record below; otherwise add a "phase" topic with a short slug id and parent null.',
+ "- parent: an earlier message id, or null when the message starts a new thread; never a topic or phase node.",
+ "- Back to an older thread: that message is the parent and the previous one goes in links (at most 5). Unsure: use the previous message.",
'- When the message itself made a decision (the user asked for it, picked an option or approved a proposal): decidedBy ("user" or "agreed"), the reason in why, and the options not taken in alternatives [{"option": "...", "why": "..."}].',
- '- The agent\'s work goes inside the message node that caused it, never in nodes of its own: work (short items), agentDecisions ([{"title": "...", "why": "...", "alternatives": [...]}]), commits (short hashes) and files (a few paths).',
+ '- The agent\'s work belongs inside the message node that caused it, never in nodes of its own: work (short items), agentDecisions ([{"title": "...", "why": "...", "alternatives": [...]}]) only for technical choices with a reason — never for proposals or work items — commits (short hashes) and files (a few paths).',
+ "- Write a branch summary ({title, asked, outcome, open}) on the first message of a branch when the branch ends.",
'- Never send "at"; the CLI takes each message\'s time from the transcript.',
"- Replace the whole status (goal, done, pending [{text, needsUser}], next) when it changed; otherwise leave it out.",
"- Record decisions and reasons, never secrets, credentials, personal data, file contents or command output.",
`- Write titles and text in ${writing}; JSON keys stay in English.`,
- ].join("\n");
+ ];
+ if (recorder === "mixed") {
+ lines.push(
+ "- This is a periodic background run: send only message nodes with their titles, parents and user decisions. Do not send status, branch summaries or agentDecisions; the main agent owns those.",
+ );
+ }
+ return lines.join("\n");
}
/**
@@ -69,12 +86,13 @@ export function catchUpPrompt(
sessionId: string,
language: string,
messageSummaries = false,
+ recorder: RecordMode = "agent",
): string {
return [
"You add the missing part of a cogit lineage record, a map of the user's messages.",
"Below are the user's messages that have no node yet, each followed by the agent's written replies and a count of its tool calls.",
"",
- rules(language, messageSummaries),
+ rules(language, messageSummaries, recorder),
"",
recordPart(record),
"",
@@ -220,10 +238,19 @@ export async function backfillTail(dir: string, sessionId: string, io: Io): Prom
const config = await loadConfig(io.env);
const loaded = await loadSession(root, sessionId);
const record = loaded.found && loaded.ok ? loaded.data : undefined;
- const prompt = catchUpPrompt(turns, record, sessionId, config.language, config.messageSummaries);
- const stdout = await runClaude(prompt, config.catchUpModel, io.env);
+ const prompt = catchUpPrompt(
+ turns,
+ record,
+ sessionId,
+ config.language,
+ config.messageSummaries,
+ config.recorder,
+ );
+ const stdout = await runClaude(prompt, config.sideModel, io.env);
const payload = { ...agentRecord(resultText(stdout)), sessionId };
- await sessionWrite({ dir: root }, io, async () => JSON.stringify(payload));
+ // Story 12.1: a side run fills empty fields and new nodes; it never rewrites
+ // what the main agent wrote.
+ await sessionWrite({ dir: root, by: "side" }, io, async () => JSON.stringify(payload));
// The session end wrote the last messages after the last code commit; auto
// mode commits exactly those record files now (Story 9.3).
await maybeAutoCommit(root, sessionId, io.env);
diff --git a/packages/cli/src/commands/config.ts b/packages/cli/src/commands/config.ts
index 3a31578..c26f398 100644
--- a/packages/cli/src/commands/config.ts
+++ b/packages/cli/src/commands/config.ts
@@ -18,6 +18,14 @@ export const CONFIG_KEYS = Object.keys(Config.shape).filter((k) => k !== "schema
"schema"
>[];
+/** Keys `cogit config` lists; `catchUpModel` is only an accepted old alias (12.1). */
+export const LISTED_CONFIG_KEYS = CONFIG_KEYS.filter((k) => k !== "catchUpModel");
+
+/** `catchUpModel` was renamed to `sideModel` (Story 12.1); both names keep working. */
+function canonicalKey(key: string): string {
+ return key === "catchUpModel" ? "sideModel" : key;
+}
+
function assertKey(key: string): asserts key is (typeof CONFIG_KEYS)[number] {
if (!(CONFIG_KEYS as string[]).includes(key)) {
throw new CliError(`unknown key "${key}"; one of: ${CONFIG_KEYS.join(", ")}`);
@@ -42,11 +50,12 @@ function parseValue(key: string, raw: string): unknown {
export async function configGet(key: string | undefined, io: Io): Promise<void> {
const config = await loadConfig(io.env);
if (key === undefined) {
- for (const k of CONFIG_KEYS) io.out(`${k} = ${JSON.stringify(config[k])}`);
+ for (const k of LISTED_CONFIG_KEYS) io.out(`${k} = ${JSON.stringify(config[k])}`);
return;
}
assertKey(key);
- io.out(JSON.stringify(config[key]));
+ const name = canonicalKey(key);
+ io.out(JSON.stringify(config[name as keyof Config]));
}
export async function configSet(key: string, raw: string, io: Io): Promise<void> {
@@ -56,11 +65,12 @@ export async function configSet(key: string, raw: string, io: Io): Promise<void>
if (!next.success) {
throw new CliError(`invalid value for ${key}: ${next.error.issues[0]?.message ?? "rejected"}`);
}
- await updateConfig((c) => ({ ...c, [key]: next.data[key] }), io.env);
+ const name = canonicalKey(key);
+ await updateConfig((c) => ({ ...c, [name]: next.data[key] }), io.env);
// Sharing the raw chat changes the project ignore files, not just the config.
- if (key === "shareConversations")
+ if (name === "shareConversations")
await refreshShareConversations(io.env, next.data.shareConversations);
- io.out(`${key} = ${JSON.stringify(next.data[key])}`);
+ io.out(`${name} = ${JSON.stringify(next.data[key])}`);
}
/**
diff --git a/packages/cli/src/commands/session.ts b/packages/cli/src/commands/session.ts
index bacc137..d827446 100644
--- a/packages/cli/src/commands/session.ts
+++ b/packages/cli/src/commands/session.ts
@@ -18,7 +18,13 @@ import { parseMessageRef, Slug } from "../schema/common.js";
import type { SessionEvent } from "../schema/events.js";
import { mergeSession } from "../schema/merge.js";
import { MESSAGE_ID, type Session, SessionInput } from "../schema/session.js";
-import { appendEvents, applyEvents, readEvents, seedEvents } from "../store/events.js";
+import {
+ appendEvents,
+ applyEvents,
+ readEvents,
+ seedEvents,
+ sideOwnedParents,
+} from "../store/events.js";
import { projectPaths } from "../store/paths.js";
import { resolveProjectRoot } from "../store/root.js";
import {
@@ -64,6 +70,11 @@ export interface SessionWriteOptions {
file?: string;
/** Delete `file` once the record is saved; a failed write keeps it for a retry. */
consume?: boolean;
+ /**
+ * Who is writing (Story 12.1): the main agent (default) or the side model.
+ * The side model may only fill empty fields and correct its own parents.
+ */
+ by?: "agent" | "side";
}
/**
@@ -123,13 +134,16 @@ export async function sessionWrite(
const upgraded = cur && messages ? upgradeSessionIds(cur, messages) : cur;
const events = await readEvents(root, input.sessionId);
const base = upgraded ? { ...upgraded, nodes: applyEvents(upgraded.nodes, events) } : undefined;
+ const by = opts.by ?? "agent";
const merged = mergeSession(base, input, io.now(), {
...(messages ? { order: messageOrder(messages) } : {}),
labels: hashesToLabels(messages),
crossTargets,
+ by,
+ sideOwnsParent: sideOwnedParents(events),
});
warnings = merged.warnings;
- const changes = structureChanges(merged.session, base, io.now());
+ const changes = structureChanges(merged.session, base, io.now(), by);
// The first structural change on an old record seeds the facts it already
// holds, so replaying the file from then on gives the same graph.
const seed =
@@ -139,8 +153,10 @@ export async function sessionWrite(
await appendEvents(root, input.sessionId, [...seed, ...changes]);
// A write from the main checkout (e.g. after a resume) keeps the stored worktree.
const stored = worktree ? { ...merged.session, worktree } : merged.session;
+ // Story 12.1: the Stop hook tells an agent write from a side one.
+ const stamped = { ...stored, lastRecordedBy: by };
// Story 9.3: the first write stamps who recorded the session.
- return stored.author === undefined && author !== undefined ? { ...stored, author } : stored;
+ return stamped.author === undefined && author !== undefined ? { ...stamped, author } : stamped;
});
for (const w of warnings) io.warn(w);
if (opts.file && opts.consume) await rm(opts.file, { force: true });
@@ -241,6 +257,7 @@ function structureChanges(
merged: Session,
before: Session | undefined,
at: string,
+ by: "agent" | "side" = "agent",
): SessionEvent[] {
const previous = new Map(
(before?.nodes ?? [])
@@ -253,15 +270,15 @@ function structureChanges(
const old = previous.get(node.id) ?? { parent: null, links: [] };
const parent = node.parent ?? null;
if (parent !== old.parent)
- events.push({ at, type: "parent", msg: node.id, target: parent, by: "agent" });
+ events.push({ at, type: "parent", msg: node.id, target: parent, by });
const links = node.links ?? [];
for (const link of links) {
if (!old.links.includes(link))
- events.push({ at, type: "link", msg: node.id, target: link, by: "agent" });
+ events.push({ at, type: "link", msg: node.id, target: link, by });
}
for (const link of old.links) {
if (!links.includes(link))
- events.push({ at, type: "unlink", msg: node.id, target: link, by: "agent" });
+ events.push({ at, type: "unlink", msg: node.id, target: link, by });
}
}
return events;
diff --git a/packages/cli/src/hooks/pretooluse.ts b/packages/cli/src/hooks/pretooluse.ts
index dfcb529..100a57f 100644
--- a/packages/cli/src/hooks/pretooluse.ts
+++ b/packages/cli/src/hooks/pretooluse.ts
@@ -57,6 +57,7 @@ function emptyState(): HookState {
turns: 0,
turnsSinceUpdate: 0,
recordUpdatedAt: null,
+ turnsSinceSide: 0,
notedFiles: [],
};
}
diff --git a/packages/cli/src/hooks/stop.ts b/packages/cli/src/hooks/stop.ts
index 2ef273c..d50af42 100644
--- a/packages/cli/src/hooks/stop.ts
+++ b/packages/cli/src/hooks/stop.ts
@@ -17,23 +17,46 @@ export function updateRequestText(skill: string): string {
export const UPDATE_REQUEST = updateRequestText(defaultAgent().skill);
-/** One Stop: count the turn and decide whether to ask for a record update. */
+export interface TurnOptions {
+ /** How often the side model records (Story 12.1); absent: the agent-only mode. */
+ sideEveryTurns?: number;
+ /** False in `side` mode: the main agent is never asked by a hook. */
+ askAgent?: boolean;
+ /** Who wrote the record last, so a side write does not reset the agent's count. */
+ lastRecordedBy?: "agent" | "side";
+}
+
+export interface TurnPlan {
+ state: HookState;
+ request: boolean;
+ side: boolean;
+}
+
+/** One Stop: count the turn and decide who records (Story 12.1). */
export function countTurn(
state: HookState | undefined,
recordUpdatedAt: string | null,
everyTurns: number,
-): { state: HookState; request: boolean } {
+ opts: TurnOptions = {},
+): TurnPlan {
const cur: HookState = state ?? {
schema: STATE_SCHEMA,
turns: 0,
turnsSinceUpdate: 0,
recordUpdatedAt,
+ turnsSinceSide: 0,
notedFiles: [],
};
- // The record changed since the last Stop (the skill ran), so count from here.
- const since = cur.recordUpdatedAt === recordUpdatedAt ? cur.turnsSinceUpdate : 0;
- const turnsSinceUpdate = since + 1;
- const request = turnsSinceUpdate >= everyTurns;
+ // A change the agent made (the skill ran) restarts its count. A change the
+ // side model made does not: otherwise side runs would starve the agent's
+ // every-N-turns request in mixed mode.
+ const changed = cur.recordUpdatedAt !== recordUpdatedAt;
+ const agentChanged = changed && opts.lastRecordedBy !== "side";
+ const turnsSinceUpdate = (agentChanged ? 0 : cur.turnsSinceUpdate) + 1;
+ const request = (opts.askAgent ?? true) && turnsSinceUpdate >= everyTurns;
+ // Any change means the record is current, so the side model may wait again.
+ const turnsSinceSide = (changed ? 0 : cur.turnsSinceSide) + 1;
+ const side = opts.sideEveryTurns !== undefined && turnsSinceSide >= opts.sideEveryTurns;
return {
state: {
...cur,
@@ -41,8 +64,10 @@ export function countTurn(
// Reset on a request too, so an "up to date" answer is not asked again next turn.
turnsSinceUpdate: request ? 0 : turnsSinceUpdate,
recordUpdatedAt,
+ turnsSinceSide: side ? 0 : turnsSinceSide,
},
request,
+ side,
};
}
@@ -66,19 +91,30 @@ export async function onStop(ctx: HookContext): Promise<HookOutput | undefined>
const config = await loadConfig(ctx.env);
const record = await loadSession(root, sessionId);
const recordUpdatedAt = record.found && record.ok ? record.data.updatedAt : null;
+ const lastRecordedBy = record.found && record.ok ? record.data.lastRecordedBy : undefined;
let request = false;
+ let side = false;
// A busy lock means another hook is on it; skipping one count is harmless.
await updateState(
root,
sessionId,
(cur) => {
- const next = countTurn(cur, recordUpdatedAt, config.updateEveryTurns);
+ const next = countTurn(cur, recordUpdatedAt, config.updateEveryTurns, {
+ // In agent mode the side model runs only at session end (Story 12.1).
+ ...(config.recorder === "agent" ? {} : { sideEveryTurns: config.sideEveryTurns }),
+ askAgent: config.recorder !== "side",
+ ...(lastRecordedBy === undefined ? {} : { lastRecordedBy }),
+ });
request = next.request;
+ side = next.side;
return next.state;
},
{ timeoutMs: 2000 },
);
+ // The side run records outside the chat: detached, behind the session lock,
+ // and it never prints into the conversation.
+ if (side) ctx.spawnDetached(["backfill", sessionId, "--tail", "-C", root]);
if (!request) return undefined;
return ctx.agent.additionalContext("Stop", UPDATE_REQUEST);
}
diff --git a/packages/cli/src/program.ts b/packages/cli/src/program.ts
index 5e10793..aa155f7 100644
--- a/packages/cli/src/program.ts
+++ b/packages/cli/src/program.ts
@@ -28,6 +28,7 @@ import { startMapServer } from "./server.js";
import { maybeAutoCommit } from "./session-git.js";
import { takeMigrationWarnings } from "./store/migrate.js";
import { loadConfig } from "./store/stores.js";
+import { configHelpLines } from "./view/settings.js";
export type IoFactory = (interactive: boolean) => Io;
@@ -320,7 +321,11 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =
.helpGroup("Set up:")
.addHelpText(
"after",
- examples("cogit config get language", "cogit config set updateEveryTurns 3"),
+ `${examples(
+ "cogit config get language",
+ "cogit config set recorder mixed",
+ "cogit config set sideEveryTurns 3",
+ )}\n\nSettings (the same explanations the panel's ? shows):\n${configHelpLines().join("\n")}`,
);
config
.command("get")
@@ -416,10 +421,14 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =
.option("-C, --dir <dir>", "project directory", ".")
.option("-f, --file <file>", "read JSON from a file instead of stdin")
.option("--consume", "delete the file once the record is saved")
+ .option("--by <who>", "who writes: agent (default) or side (fills only empty fields)")
.action(
- run(async (opts: { dir: string; file?: string; consume?: boolean }) =>
- sessionWrite(opts, makeIo(false)),
- ),
+ run(async (opts: { dir: string; file?: string; consume?: boolean; by?: string }) => {
+ if (opts.by !== undefined && opts.by !== "agent" && opts.by !== "side")
+ throw new CliError('--by must be "agent" or "side"');
+ const { by, ...rest } = opts;
+ await sessionWrite({ ...rest, ...(by === undefined ? {} : { by }) }, makeIo(false));
+ }),
);
session
.command("show")
diff --git a/packages/cli/src/schema/config.ts b/packages/cli/src/schema/config.ts
index d04a001..c33305d 100644
--- a/packages/cli/src/schema/config.ts
+++ b/packages/cli/src/schema/config.ts
@@ -7,10 +7,28 @@ export const Config = z.object({
schema: z.literal(CONFIG_SCHEMA),
/** "auto" = the conversation's language, otherwise a fixed language name or code. */
language: z.string().min(1).max(32).default("auto"),
- updateEveryTurns: z.int().min(1).max(100).default(5),
+ /**
+ * How often the main agent is asked to record (Story 12.1). The default is the
+ * mixed mode's interval: the side model records in between, so the agent can
+ * check in rarely.
+ */
+ updateEveryTurns: z.int().min(1).max(100).default(15),
sessionEndCatchUp: z.boolean().default(true),
- /** Model for the headless catch-up (SessionEnd) and, later, backfill. */
- catchUpModel: z.string().trim().min(1).max(64).default("haiku"),
+ /**
+ * Who writes the record (Story 12.1): the main agent (`agent`), both (`mixed`,
+ * the default: a side model often, the agent rarely), or only the side model
+ * (`side`, the agent is never interrupted).
+ */
+ recorder: z.enum(["agent", "mixed", "side"]).default("mixed"),
+ /** Model the side runs use: the headless catch-up and the periodic records. */
+ sideModel: z.string().trim().min(1).max(64).default("haiku"),
+ /** How often the side model records, in turns (Story 12.1). */
+ sideEveryTurns: z.int().min(1).max(100).default(5),
+ /**
+ * @deprecated Renamed to `sideModel` in Story 12.1. Still read once and
+ * migrated, so a config written before the rename keeps its model.
+ */
+ catchUpModel: z.string().trim().min(1).max(64).optional(),
/**
* Whether the agent writes a per-message `summary`. Off by default: the branch
* summary is the outer layer and the drill-down already shows the reply.
@@ -76,3 +94,20 @@ export const Registry = z.object({
export type Config = z.infer<typeof Config>;
export type RegistryEntry = z.infer<typeof RegistryEntry>;
export type Registry = z.infer<typeof Registry>;
+
+/** The side model's default, named so the rename below can spot an untouched value. */
+export const DEFAULT_SIDE_MODEL = "haiku";
+
+/**
+ * Reads a config written before Story 12.1: `catchUpModel` became `sideModel`.
+ * The old key is dropped, so the next write stores only the new name. An
+ * explicit new name wins; the plain default yields to the old one.
+ */
+export function migrateConfig(config: Config): Config {
+ if (config.catchUpModel === undefined) return config;
+ const { catchUpModel, ...rest } = config;
+ return {
+ ...rest,
+ sideModel: config.sideModel === DEFAULT_SIDE_MODEL ? catchUpModel : config.sideModel,
+ };
+}
diff --git a/packages/cli/src/schema/events.ts b/packages/cli/src/schema/events.ts
index 83172b8..8b5d093 100644
--- a/packages/cli/src/schema/events.ts
+++ b/packages/cli/src/schema/events.ts
@@ -15,8 +15,8 @@ export const SessionEvent = z.object({
msg: Slug,
/** The parent for `parent` (null = a new root), the other message for link/unlink. */
target: MessageRef.nullable(),
- /** Who made the change: the agent's record, or the user correcting it. */
- by: z.enum(["agent", "user"]).default("agent"),
+ /** Who made the change: the agent's record, the side model, or the user. */
+ by: z.enum(["agent", "user", "side"]).default("agent"),
});
export type SessionEvent = z.infer<typeof SessionEvent>;
diff --git a/packages/cli/src/schema/merge.ts b/packages/cli/src/schema/merge.ts
index bd9ab13..81a5911 100644
--- a/packages/cli/src/schema/merge.ts
+++ b/packages/cli/src/schema/merge.ts
@@ -1,6 +1,7 @@
import { parseMessageRef } from "./common.js";
import {
type LineageNode,
+ type LineageNodeInput,
MESSAGE_ID,
SESSION_SCHEMA,
type Session,
@@ -26,6 +27,75 @@ export interface MergeOptions {
* earlier (Story 8.6). Anything else is refused like an unknown parent.
*/
crossTargets?: ReadonlySet<string>;
+ /** Who is writing (Story 12.1): the main agent (default) or the side model. */
+ by?: "agent" | "side";
+ /**
+ * Messages whose latest parent event was written by the side model (Story
+ * 12.1). The side model may correct only those parents, so an agent's
+ * correction is never undone by a later side run.
+ */
+ sideOwnsParent?: ReadonlySet<string>;
+}
+
+/**
+ * The fields the side model may fill (Story 12.1). Structure (parent, links) is
+ * handled separately because an agent correction must survive the next side run.
+ */
+const SIDE_FIELDS = [
+ "title",
+ "summary",
+ "why",
+ "decidedBy",
+ "alternatives",
+ "commits",
+ "files",
+ "branch",
+ "work",
+ "agentDecisions",
+] as const;
+
+type SideField = (typeof SIDE_FIELDS)[number];
+
+/** A field the side model may fill: missing, empty text or an empty list. */
+function isEmptyValue(value: unknown): boolean {
+ return (
+ value === undefined ||
+ value === null ||
+ value === "" ||
+ (Array.isArray(value) && value.length === 0)
+ );
+}
+
+/**
+ * Merges one side-model node into the stored one: a field is written only when
+ * empty or already the side model's, so the agent's notes are never overwritten.
+ */
+function mergeSide(prev: LineageNode, input: LineageNodeInput): LineageNode {
+ const next: LineageNode = { ...prev };
+ const marks: Record<string, "side"> = {};
+ for (const field of SIDE_FIELDS) {
+ const value = input[field];
+ if (value === undefined || (!isEmptyValue(prev[field]) && prev.by?.[field] !== "side")) {
+ continue;
+ }
+ (next as unknown as Record<SideField, unknown>)[field] = value;
+ marks[field] = "side";
+ }
+ return Object.keys(marks).length === 0 ? prev : { ...next, by: { ...(prev.by ?? {}), ...marks } };
+}
+
+/** The agent wrote these fields now, so the side model may no longer replace them. */
+function agentMarks(prev: LineageNode | undefined, input: LineageNodeInput): LineageNode["by"] {
+ const marks = { ...(prev?.by ?? {}) };
+ for (const field of SIDE_FIELDS) if (input[field] !== undefined) delete marks[field];
+ return Object.keys(marks).length > 0 ? marks : undefined;
+}
+
+/** A new node from the side model: every field it sent is its own to correct. */
+function sideMarks(input: LineageNodeInput): LineageNode["by"] {
+ const marks: Record<string, "side"> = {};
+ for (const field of SIDE_FIELDS) if (input[field] !== undefined) marks[field] = "side";
+ return Object.keys(marks).length > 0 ? marks : undefined;
}
/**
@@ -69,9 +139,26 @@ export function mergeSession(
}
const label = (id: string): string => opts.labels?.get(id) ?? id;
const messageWarnings: string[] = [];
+ const side = opts.by === "side";
for (const { parent, links, ...n } of input.nodes ?? []) {
const prev = nodes.get(n.id);
const own = n.kind === "message" ? (recorded.get(n.id) ?? null) : null;
+ if (side && prev) {
+ // The side model fills notes but never rewrites the agent's: it may only
+ // correct a parent it wrote itself (Story 12.1).
+ const merged = mergeSide(prev, n);
+ const nextParent =
+ parent !== undefined && own !== null && (opts.sideOwnsParent?.has(n.id) ?? false)
+ ? checkParent(n.id, parent, own, recorded, messageWarnings, label, opts.crossTargets)
+ : (prev.parent ?? null);
+ const next: LineageNode = { ...merged, parent: nextParent };
+ nodes.set(n.id, {
+ ...next,
+ addedAt: prev.addedAt,
+ touchedAt: sameNode(prev, next) ? prev.touchedAt : now,
+ });
+ continue;
+ }
const nextParent =
parent !== undefined && own !== null
? checkParent(n.id, parent, own, recorded, messageWarnings, label, opts.crossTargets)
@@ -88,10 +175,13 @@ export function mergeSession(
parent: nextParent,
...(nextLinks === undefined ? {} : { links: nextLinks }),
};
+ const marks = side ? sideMarks(n) : agentMarks(prev, n);
// Nodes recorded before these stamps existed keep no addedAt: their order stays as stored.
const addedAt = prev ? prev.addedAt : now;
nodes.set(n.id, {
...next,
+ // An explicit undefined clears a previous side mark: the agent owns it now.
+ by: marks,
...(addedAt === undefined ? {} : { addedAt }),
touchedAt: prev && sameNode(prev, next) ? prev.touchedAt : now,
});
diff --git a/packages/cli/src/schema/session.ts b/packages/cli/src/schema/session.ts
index e0e678b..bec7332 100644
--- a/packages/cli/src/schema/session.ts
+++ b/packages/cli/src/schema/session.ts
@@ -73,6 +73,13 @@ export const LineageNode = z.object({
work: z.array(z.string().min(1).max(300)).max(20).optional(),
/** For a message: choices the agent made on its own along the way. */
agentDecisions: z.array(AgentDecision).max(10).optional(),
+ /**
+ * Who wrote each optional field (Story 12.1): the main agent or the side
+ * model. A missing entry means the agent (every record written before the
+ * split was the agent's). The merge lets the side model fill a field only
+ * when it is empty or already the side model's own.
+ */
+ by: z.record(z.string().max(40), z.enum(["agent", "side"])).optional(),
/** When `session write` first added this node; set by the CLI, never by the agent. */
addedAt: IsoDate.optional(),
/** When `session write` last added or changed this node; set by the CLI, never by the agent. */
@@ -120,6 +127,11 @@ export const Session = z.object({
* on the first write (Story 9.3). Old records have none.
*/
author: z.string().min(1).max(200).optional(),
+ /**
+ * Who wrote the record last (Story 12.1): the Stop hook counts the main
+ * agent's turns separately when the side model keeps writing in between.
+ */
+ lastRecordedBy: z.enum(["agent", "side"]).optional(),
});
/** In input, a missing parent keeps the stored one (null for a new node). */
@@ -127,6 +139,7 @@ export const LineageNodeInput = LineageNode.omit({
addedAt: true,
touchedAt: true,
change: true,
+ by: true,
}).extend({
parent: MessageRef.nullable().optional(),
});
@@ -145,6 +158,7 @@ export const SessionInput = z.object({
});
export type LineageNode = z.infer<typeof LineageNode>;
+export type LineageNodeInput = z.infer<typeof LineageNodeInput>;
export type BranchSummary = z.infer<typeof BranchSummary>;
export type AgentDecision = z.infer<typeof AgentDecision>;
export type Status = z.infer<typeof Status>;
diff --git a/packages/cli/src/schema/state.ts b/packages/cli/src/schema/state.ts
index 3dd756b..7f42a67 100644
--- a/packages/cli/src/schema/state.ts
+++ b/packages/cli/src/schema/state.ts
@@ -15,6 +15,8 @@ export const HookState = z.object({
turnsSinceUpdate: z.number().int().min(0).default(0),
/** The record's `updatedAt` when the hook last looked; a change resets the count. */
recordUpdatedAt: IsoDate.nullable().default(null),
+ /** Turns since the side model last recorded (Story 12.1). */
+ turnsSinceSide: z.number().int().min(0).default(0),
/**
* Project-relative files the PreToolUse hook has already told this session
* about (Story 10.4): the "tried before" note is once per file per session,
diff --git a/packages/cli/src/store/events.ts b/packages/cli/src/store/events.ts
index 587affe..b484c3f 100644
--- a/packages/cli/src/store/events.ts
+++ b/packages/cli/src/store/events.ts
@@ -47,6 +47,21 @@ export async function appendEvents(
return events.length;
}
+/**
+ * Messages whose latest parent event was written by the side model (Story
+ * 12.1). A side run may correct those parents, and only those: a parent the
+ * main agent wrote stays put.
+ */
+export function sideOwnedParents(events: readonly SessionEvent[]): Set<string> {
+ const owners = new Map<string, SessionEvent["by"]>();
+ for (const event of events) {
+ if (event.type === "parent") owners.set(event.msg, event.by);
+ }
+ const owned = new Set<string>();
+ for (const [msg, by] of owners) if (by === "side") owned.add(msg);
+ return owned;
+}
+
export interface Structure {
parent: string | null;
links: string[];
diff --git a/packages/cli/src/store/stores.ts b/packages/cli/src/store/stores.ts
index cca5f0c..2f16665 100644
--- a/packages/cli/src/store/stores.ts
+++ b/packages/cli/src/store/stores.ts
@@ -1,7 +1,7 @@
import type { Dirent } from "node:fs";
import { readdir } from "node:fs/promises";
import type { z } from "zod";
-import { CONFIG_SCHEMA, Config, Registry } from "../schema/config.js";
+import { CONFIG_SCHEMA, Config, migrateConfig, Registry } from "../schema/config.js";
import { PROJECT_SCHEMA, Project } from "../schema/project.js";
import { SESSION_SCHEMA, Session } from "../schema/session.js";
import { HookState, STATE_SCHEMA } from "../schema/state.js";
@@ -157,7 +157,7 @@ export const updateSession = (
export const loadConfig = async (env?: NodeJS.ProcessEnv): Promise<Config> => {
const cur = await load(globalPaths(env).config, Config, CONFIG_SCHEMA);
- return cur.found && cur.ok ? cur.data : Config.parse({ schema: CONFIG_SCHEMA });
+ return migrateConfig(cur.found && cur.ok ? cur.data : Config.parse({ schema: CONFIG_SCHEMA }));
};
export const updateConfig = (
@@ -171,7 +171,7 @@ export const updateConfig = (
`${g.config}.lock`,
Config,
CONFIG_SCHEMA,
- (cur) => fn(cur ?? Config.parse({ schema: CONFIG_SCHEMA })),
+ (cur) => migrateConfig(fn(migrateConfig(cur ?? Config.parse({ schema: CONFIG_SCHEMA })))),
opts,
);
};
diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.ts
index 3aaccab..7f937e0 100644
--- a/packages/cli/src/view/model.ts
+++ b/packages/cli/src/view/model.ts
@@ -30,13 +30,15 @@ export const TOKEN_META_NAME = "cogit-token";
* setup-time or security-adjacent and stay on `cogit config set`.
*/
export const PANEL_EDITABLE_KEYS = [
+ "recorder",
"messageSummaries",
"startupContext",
"tryBeforeNotes",
"language",
"updateEveryTurns",
+ "sideEveryTurns",
"sessionEndCatchUp",
- "catchUpModel",
+ "sideModel",
"shareConversations",
"recordCommit",
] as const;
@@ -371,10 +373,15 @@ export interface PanelProject {
* local server (over `file://` everything stays read-only).
*/
export interface PanelSettings {
+ /** Who records: the main agent, both, or only a small side model (Story 12.1). */
+ recorder: "agent" | "mixed" | "side";
language: string;
updateEveryTurns: number;
+ /** How often the side model records, in turns (Story 12.1). */
+ sideEveryTurns: number;
sessionEndCatchUp: boolean;
- catchUpModel: string;
+ /** Model the side runs and the session-end catch-up use (Story 12.1). */
+ sideModel: string;
messageSummaries: boolean;
startupContext: boolean;
/**
diff --git a/packages/cli/src/view/panel.ts b/packages/cli/src/view/panel.ts
index f1c5d3c..b813060 100644
--- a/packages/cli/src/view/panel.ts
+++ b/packages/cli/src/view/panel.ts
@@ -59,10 +59,12 @@ const PANEL_TITLE = "<title>cogit — panel</title>";
*/
export function panelSettings(config: Config): PanelSettings {
return {
+ recorder: config.recorder,
language: config.language,
updateEveryTurns: config.updateEveryTurns,
+ sideEveryTurns: config.sideEveryTurns,
sessionEndCatchUp: config.sessionEndCatchUp,
- catchUpModel: config.catchUpModel,
+ sideModel: config.sideModel,
messageSummaries: config.messageSummaries,
startupContext: config.startupContext,
tryBeforeNotes: config.tryBeforeNotes,
diff --git a/packages/cli/src/view/settings.ts b/packages/cli/src/view/settings.ts
index bda64d0..de2fd82 100644
--- a/packages/cli/src/view/settings.ts
+++ b/packages/cli/src/view/settings.ts
@@ -5,17 +5,30 @@ import type { PanelEditableSettings, PanelSettings } from "./model.js";
* sections it is laid out in, and the values shown when the page was built
* before the current setting changed. Runtime-free so the template can import
* it and tests can check the modal without a DOM.
+ *
+ * Every field also carries a `details` text: the longer plain-language answer
+ * the "?" next to its label opens (Story 12.1). `cogit config --help` prints
+ * the same text, so the two never drift.
*/
/** What a setting's control looks like. */
-export type SettingKind = "text" | "number" | "boolean";
+export type SettingKind = "text" | "number" | "boolean" | "select";
+
+export interface SettingOption {
+ value: string;
+ label: string;
+}
export interface SettingField {
key: keyof PanelSettings;
label: string;
/** One short line under the label, so nobody has to read the docs. */
help: string;
+ /** The longer explanation behind "?" (Story 12.1). Plain language, no keys. */
+ details: string;
kind: SettingKind;
+ /** The choices of a `select`. */
+ options?: SettingOption[];
/** False over `file://` and for the setup-time keys the modal only shows. */
editable: boolean;
}
@@ -29,62 +42,120 @@ interface FieldSpec {
key: keyof PanelSettings;
label: string;
help: string;
+ details: string;
kind: SettingKind;
+ options?: SettingOption[];
}
const EDITABLE: FieldSpec[] = [
+ {
+ key: "recorder",
+ label: "Recording mode",
+ help: "Who writes the record: a side model, the main agent, or both.",
+ details:
+ "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.",
+ kind: "select",
+ options: [
+ { value: "mixed", label: "Mixed (recommended)" },
+ { value: "agent", label: "Main agent" },
+ { value: "side", label: "Side model only" },
+ ],
+ },
{
key: "messageSummaries",
label: "Message summaries",
help: "Write a one-line summary for each recorded message.",
+ details:
+ "A one-sentence summary under each message title, so a skim reads better. Off keeps " +
+ "the record shorter and cheaper.",
kind: "boolean",
},
{
key: "startupContext",
label: "Lineage at session start",
help: "Hand the agent the previous session's lineage when a chat starts.",
+ details:
+ "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.",
kind: "boolean",
},
{
key: "tryBeforeNotes",
label: "Tried-before notes",
help: "Before the agent edits a file, tell it which options earlier thoughts rejected for it.",
+ details:
+ "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.",
kind: "boolean",
},
{
key: "language",
label: "Language",
help: "Language the agent writes records in; `auto` follows the chat.",
+ details:
+ "The language the record is written in. With auto, it follows the language of the " +
+ "conversation.",
kind: "text",
},
{
key: "updateEveryTurns",
label: "Record every N turns",
help: "Ask the agent to record after this many turns.",
+ details:
+ "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).",
+ kind: "number",
+ },
+ {
+ key: "sideEveryTurns",
+ label: "Side model every N turns",
+ help: "How often the background recorder writes in mixed or side mode.",
+ details:
+ "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.",
kind: "number",
},
{
key: "sessionEndCatchUp",
label: "Catch up on session end",
help: "Record the unrecorded messages when a session ends.",
+ details:
+ "When a session ends, record whatever nobody got to. It runs outside the chat, so it " +
+ "does not spend the session's tokens.",
kind: "boolean",
},
{
- key: "catchUpModel",
+ key: "sideModel",
label: "Catch-up model",
- help: "Model the catch-up and backfill use to summarize.",
+ help: "Model the catch-up and the background records use to summarize.",
+ details:
+ "The small model the background recorder and the session-end catch-up run. Haiku is " +
+ "cheap and good enough for titles, parents and short decisions.",
kind: "text",
},
{
key: "shareConversations",
label: "Share conversations",
help: "Commit the raw chat text too, not only the session record (off: chat stays local).",
+ details:
+ "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.",
kind: "boolean",
},
{
key: "recordCommit",
label: "Commit the record",
help: "ask, auto or off: what to do with the last messages after the last code commit.",
+ details:
+ "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.",
kind: "text",
},
];
@@ -94,12 +165,18 @@ const READ_ONLY: FieldSpec[] = [
key: "gitPolicy",
label: "Git policy",
help: "Whether captures are committed to git; change it per project with `cogit config git`.",
+ details:
+ "Whether the record is committed to git with the code, so a reviewer can follow it, or " +
+ "kept out of the repository. It is set per project when you initialize it.",
kind: "text",
},
{
key: "agents",
label: "Agents",
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",
},
];
@@ -121,15 +198,24 @@ 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(
+ (field) => ` ${field.key}\n ${field.label}: ${field.help}\n ${field.details}`,
+ );
+}
+
/**
* The values a modal starts with when no server answers (a `file://` page):
* the defaults from the config schema, overridden by what the build embedded.
*/
export const DEFAULT_SETTINGS: PanelSettings = {
+ recorder: "mixed",
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
messageSummaries: false,
startupContext: true,
tryBeforeNotes: true,
@@ -147,13 +233,15 @@ export function withDefaults(settings: Partial<PanelSettings> | undefined): Pane
/** The keys `GET /api/config` returns; never the setup-time or security-adjacent ones. */
export function editableSettings(settings: PanelSettings): PanelEditableSettings {
return {
+ recorder: settings.recorder,
messageSummaries: settings.messageSummaries,
startupContext: settings.startupContext,
tryBeforeNotes: settings.tryBeforeNotes,
language: settings.language,
updateEveryTurns: settings.updateEveryTurns,
+ sideEveryTurns: settings.sideEveryTurns,
sessionEndCatchUp: settings.sessionEndCatchUp,
- catchUpModel: settings.catchUpModel,
+ sideModel: settings.sideModel,
shareConversations: settings.shareConversations,
recordCommit: settings.recordCommit,
};
diff --git a/packages/cli/test/backfill.test.ts b/packages/cli/test/backfill.test.ts
index 148c212..41547bb 100644
--- a/packages/cli/test/backfill.test.ts
+++ b/packages/cli/test/backfill.test.ts
@@ -58,6 +58,7 @@ process.stdin.on("data", (chunk) => { input += chunk; });
process.stdin.on("end", async () => {
const fs = await import("node:fs");
fs.writeFileSync(${JSON.stringify(join(dir, "prompt.txt"))}, input);
+ fs.writeFileSync(${JSON.stringify(join(dir, "argv.json"))}, JSON.stringify(process.argv.slice(2)));
process.stdout.write(JSON.stringify({ type: "result", subtype: "success", result: ${JSON.stringify(result)} }));
});`;
}
@@ -126,6 +127,22 @@ describe("catchUpPrompt", () => {
expect(prompt).toContain("1 command(s), 1 file(s) edited, 2 other tool call(s)");
expect(prompt).toContain("the conversation's language");
});
+
+ it("keeps the side prompt in line with the skill (Story 12.1)", () => {
+ const prompt = catchUpPrompt([turn], undefined, "s1", "auto");
+ expect(prompt).toContain("never a topic or phase node");
+ expect(prompt).toContain("branch summary");
+ expect(prompt).toContain("only for technical choices with a reason");
+ expect(prompt).toContain("decidedBy");
+ // The periodic mixed run writes messages and user decisions only.
+ const mixed = catchUpPrompt([turn], undefined, "s1", "auto", false, "mixed");
+ expect(mixed).toContain("periodic background run");
+ expect(mixed).toContain("Do not send status, branch summaries or agentDecisions");
+ const side = catchUpPrompt([turn], undefined, "s1", "auto", false, "side");
+ expect(side).not.toContain("periodic background run");
+ const agent = catchUpPrompt([turn], undefined, "s1", "auto", false, "agent");
+ expect(agent).not.toContain("periodic background run");
+ });
});
describe("headless output", () => {
@@ -171,6 +188,12 @@ describe("backfill --tail", () => {
summary: "Recorded it",
});
expect(io.lines).toContain("Saved session s1 (3 nodes)");
+ // A backfill is a side run: the Stop hook counts its writes separately (12.1).
+ expect(saved?.lastRecordedBy).toBe("side");
+ // The side model setting names the model the headless run uses.
+ expect(JSON.parse(await readFile(join(dir, "argv.json"), "utf8"))).toEqual(
+ expect.arrayContaining(["--model", "haiku"]),
+ );
const prompt = await readFile(join(dir, "prompt.txt"), "utf8");
expect(prompt).toContain("USER: second");
diff --git a/packages/cli/test/build.test.ts b/packages/cli/test/build.test.ts
index 217c4d3..3e78746 100644
--- a/packages/cli/test/build.test.ts
+++ b/packages/cli/test/build.test.ts
@@ -587,7 +587,8 @@ describe("cogit build", () => {
expect(model.settings).toMatchObject({
messageSummaries: true,
startupContext: true,
- updateEveryTurns: 5,
+ recorder: "mixed",
+ updateEveryTurns: 15,
shareConversations: false,
recordCommit: "ask",
gitPolicy: "commit",
diff --git a/packages/cli/test/config-epoch.test.ts b/packages/cli/test/config-epoch.test.ts
index 99e3d9e..23ce583 100644
--- a/packages/cli/test/config-epoch.test.ts
+++ b/packages/cli/test/config-epoch.test.ts
@@ -1,5 +1,5 @@
-import { mkdir, writeFile } from "node:fs/promises";
-import { join } from "node:path";
+import { mkdir, readFile, writeFile } from "node:fs/promises";
+import { dirname, join } from "node:path";
import { beforeEach, describe, expect, it } from "vitest";
import { configGet, configPrune, configSet } from "../src/commands/config.js";
import { epochAdd } from "../src/commands/epoch.js";
@@ -20,12 +20,19 @@ describe("config", () => {
it("prints all settings or one", async () => {
const io = fakeIo(env);
await configGet(undefined, io);
- expect(io.lines).toContain("updateEveryTurns = 5");
- expect(io.lines).toContain('catchUpModel = "haiku"');
+ expect(io.lines).toContain("updateEveryTurns = 15");
+ expect(io.lines).toContain('recorder = "mixed"');
+ expect(io.lines).toContain('sideModel = "haiku"');
+ expect(io.lines).toContain("sideEveryTurns = 5");
+ // The old name is an accepted alias, not a listed key (Story 12.1).
+ expect(io.lines.some((line) => line.startsWith("catchUpModel"))).toBe(false);
expect(io.lines).toContain("messageSummaries = false");
expect(io.lines).toContain("startupContext = true");
await configGet("gitPolicy", io);
expect(io.lines.at(-1)).toBe('"commit"');
+ // The old name reads as the new one (Story 12.1).
+ await configGet("catchUpModel", io);
+ expect(io.lines.at(-1)).toBe('"haiku"');
});
it("sets numbers, booleans, strings and agent lists", async () => {
@@ -41,7 +48,7 @@ describe("config", () => {
updateEveryTurns: 3,
sessionEndCatchUp: false,
language: "Turkish",
- catchUpModel: "sonnet",
+ sideModel: "sonnet",
messageSummaries: true,
startupContext: false,
agents: ["claude-code", "codex"],
@@ -50,6 +57,31 @@ describe("config", () => {
expect((await loadConfig(env)).agents).toEqual(["claude-code"]);
});
+ it("reads a config written before the rename and migrates it (Story 12.1)", async () => {
+ const file = globalPaths(env).config;
+ await mkdir(dirname(file), { recursive: true });
+ await writeFile(
+ file,
+ JSON.stringify({ schema: 1, catchUpModel: "sonnet", updateEveryTurns: 5 }),
+ );
+ const config = await loadConfig(env);
+ expect(config.sideModel).toBe("sonnet");
+ expect(config.catchUpModel).toBeUndefined();
+ expect(config.recorder).toBe("mixed");
+ // The next write stores only the new name.
+ await configSet("updateEveryTurns", "6", fakeIo(env));
+ const stored = JSON.parse(await readFile(file, "utf8")) as Record<string, unknown>;
+ expect(stored.sideModel).toBe("sonnet");
+ expect(stored).not.toHaveProperty("catchUpModel");
+ });
+
+ it("keeps an explicit new model name over the old key (Story 12.1)", async () => {
+ const file = globalPaths(env).config;
+ await mkdir(dirname(file), { recursive: true });
+ await writeFile(file, JSON.stringify({ schema: 1, catchUpModel: "sonnet", sideModel: "opus" }));
+ expect((await loadConfig(env)).sideModel).toBe("opus");
+ });
+
it("rejects unknown keys and invalid values", async () => {
await expect(configSet("schema", "2", fakeIo(env))).rejects.toThrow(/unknown key/);
await expect(configGet("nope", fakeIo(env))).rejects.toBeInstanceOf(CliError);
diff --git a/packages/cli/test/hooks.test.ts b/packages/cli/test/hooks.test.ts
index f034a69..c1c0357 100644
--- a/packages/cli/test/hooks.test.ts
+++ b/packages/cli/test/hooks.test.ts
@@ -45,6 +45,38 @@ describe("countTurn", () => {
recordUpdatedAt: "2026-10-21T10:05:00.000Z",
});
});
+
+ it("does not let a side-model write restart the agent's count (12.1)", () => {
+ const first = countTurn(undefined, "2026-10-21T10:00:00.000Z", 3).state;
+ expect(first.turnsSinceUpdate).toBe(1);
+ // The side model recorded; the agent's count keeps going.
+ const afterSide = countTurn(first, "2026-10-21T10:01:00.000Z", 3, {
+ lastRecordedBy: "side",
+ sideEveryTurns: 2,
+ });
+ expect(afterSide.state.turnsSinceUpdate).toBe(2);
+ expect(afterSide.state.turnsSinceSide).toBe(1);
+ const third = countTurn(afterSide.state, "2026-10-21T10:01:00.000Z", 3, {
+ lastRecordedBy: "side",
+ sideEveryTurns: 2,
+ });
+ expect(third.request).toBe(true);
+ expect(third.side).toBe(true);
+ });
+
+ it("never asks the agent in side mode and asks the side model on its turns", () => {
+ let state: ReturnType<typeof countTurn>["state"] | undefined;
+ const requests: boolean[] = [];
+ const sides: boolean[] = [];
+ for (let i = 0; i < 3; i++) {
+ const next = countTurn(state, null, 1, { askAgent: false, sideEveryTurns: 2 });
+ state = next.state;
+ requests.push(next.request);
+ sides.push(next.side);
+ }
+ expect(requests).toEqual([false, false, false]);
+ expect(sides).toEqual([false, true, false]);
+ });
});
describe("session start handoff", () => {
@@ -311,6 +343,35 @@ describe("runHook", () => {
expect(spawned).toEqual([["/plugin/dist/cli.js", "build", root, "--quiet"]]);
});
+ it("runs the side model on its own turns in mixed mode (Story 12.1)", async () => {
+ await initialized(10);
+ await configSet("recorder", "mixed", fakeIo(env));
+ await configSet("sideEveryTurns", "2", fakeIo(env));
+ expect(await stop()).toBeUndefined();
+ expect(spawned.filter((args) => args[1] === "backfill")).toEqual([]);
+ expect(await stop()).toBeUndefined();
+ expect(spawned.filter((args) => args[1] === "backfill")).toEqual([
+ ["/plugin/dist/cli.js", "backfill", "s1", "--tail", "-C", root],
+ ]);
+ });
+
+ it("never asks the agent in side mode, only the side model (Story 12.1)", async () => {
+ await initialized(1);
+ await configSet("recorder", "side", fakeIo(env));
+ await configSet("sideEveryTurns", "2", fakeIo(env));
+ expect(await stop()).toBeUndefined();
+ expect(await stop()).toBeUndefined();
+ expect(spawned.filter((args) => args[1] === "backfill")).toHaveLength(1);
+ });
+
+ it("leaves the side model to session end in agent mode (Story 12.1)", async () => {
+ await initialized(1);
+ await configSet("recorder", "agent", fakeIo(env));
+ expect(await stop()).toBeDefined();
+ expect(await stop()).toBeDefined();
+ expect(spawned.filter((args) => args[1] === "backfill")).toEqual([]);
+ });
+
it("skips the rebuild while a build or the session write holds the lock", async () => {
await initialized(10);
const paths = projectPaths(root);
diff --git a/packages/cli/test/panel.test.ts b/packages/cli/test/panel.test.ts
index 35385fa..f53240a 100644
--- a/packages/cli/test/panel.test.ts
+++ b/packages/cli/test/panel.test.ts
@@ -81,10 +81,12 @@ describe("buildPanel", () => {
schema: 1,
generatedAt: T0,
settings: {
+ recorder: "mixed",
language: "auto",
updateEveryTurns: 7,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
messageSummaries: false,
startupContext: true,
tryBeforeNotes: true,
diff --git a/packages/cli/test/program-commands.test.ts b/packages/cli/test/program-commands.test.ts
index 490194c..72c3f81 100644
--- a/packages/cli/test/program-commands.test.ts
+++ b/packages/cli/test/program-commands.test.ts
@@ -8,7 +8,7 @@ import { beforeEach, describe, expect, it } from "vitest";
import { readSkillAllowed } from "../src/agents/claude/settings.js";
import { createProgram } from "../src/program.js";
import { globalPaths } from "../src/store/paths.js";
-import { loadConfig, loadProject } from "../src/store/stores.js";
+import { loadConfig, loadProject, loadSession } from "../src/store/stores.js";
import { envFor, type FakeIo, fakeIo, T0, tempDir } from "./helpers.js";
let dir: string;
@@ -166,6 +166,23 @@ describe("commands through the CLI", () => {
expect(JSON.parse(io.lines.at(-1) ?? "")).toMatchObject({ initialized: true, session: null });
});
+ it("marks a session write as a side run and rejects an unknown writer (Story 12.1)", async () => {
+ await cli("init", root, "--yes", "--retention", "keep");
+ const file = join(dir, "write.json");
+ await writeFile(
+ file,
+ JSON.stringify({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", parent: null, title: "One" }],
+ }),
+ );
+ await cli("session", "write", "-C", root, "--file", file, "--by", "side");
+ const loaded = await loadSession(root, "s1");
+ expect(loaded.found && loaded.ok ? loaded.data.lastRecordedBy : undefined).toBe("side");
+ const err = await cli("session", "write", "-C", root, "--by", "robot");
+ expect(err).toContain('--by must be "agent" or "side"');
+ });
+
it("runs a hook from stdin and prints its output", async () => {
await cli("init", root, "--yes", "--retention", "keep");
await cli("config", "set", "updateEveryTurns", "1");
diff --git a/packages/cli/test/schema.test.ts b/packages/cli/test/schema.test.ts
index 600821e..cc2db70 100644
--- a/packages/cli/test/schema.test.ts
+++ b/packages/cli/test/schema.test.ts
@@ -108,7 +108,10 @@ describe("Project and Config schemas", () => {
expect(Project.parse({ schema: 1, name: "p" }).epochs).toEqual([]);
expect(Config.parse({ schema: 1 })).toMatchObject({
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ recorder: "mixed",
+ sideModel: "haiku",
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
gitPolicy: "commit",
shareConversations: false,
diff --git a/packages/cli/test/server.test.ts b/packages/cli/test/server.test.ts
index d9f6d6f..f59f934 100644
--- a/packages/cli/test/server.test.ts
+++ b/packages/cli/test/server.test.ts
@@ -547,13 +547,15 @@ describe("settings read", () => {
expect(JSON.parse(reply.body)).toEqual({
ok: true,
settings: {
+ recorder: "mixed",
messageSummaries: false,
startupContext: true,
tryBeforeNotes: true,
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
shareConversations: false,
recordCommit: "ask",
},
@@ -567,7 +569,7 @@ describe("settings read", () => {
[CONFIG_TOKEN_HEADER]: token,
});
expect(reply.status).toBe(200);
- expect(JSON.parse(reply.body).settings.updateEveryTurns).toBe(5);
+ expect(JSON.parse(reply.body).settings.updateEveryTurns).toBe(15);
});
it("shows a value changed after the page was built", async () => {
diff --git a/packages/cli/test/session.test.ts b/packages/cli/test/session.test.ts
index 12fa33b..586e8cc 100644
--- a/packages/cli/test/session.test.ts
+++ b/packages/cli/test/session.test.ts
@@ -73,6 +73,117 @@ describe("session write", () => {
await epochAdd(root, "e2e", "E2E", fakeIo(envFor(dir)));
});
+ describe("side recording (Story 12.1)", () => {
+ const side = (json: unknown) =>
+ sessionWrite({ dir: root, by: "side" }, io, async () => JSON.stringify(json));
+ const stored = async () => {
+ const loaded = await loadSession(root, "s1");
+ if (!loaded.found || !loaded.ok) throw new Error("no record");
+ return loaded.data;
+ };
+ const node = async (id: string) => (await stored()).nodes.find((n) => n.id === id);
+
+ it("fills empty fields and never overwrites the agent's notes", async () => {
+ await write({
+ sessionId: "s1",
+ nodes: [
+ { id: "m1", kind: "message", parent: null, title: "Ship it", summary: "agent words" },
+ ],
+ });
+ await side({
+ sessionId: "s1",
+ nodes: [
+ {
+ id: "m1",
+ kind: "message",
+ title: "side title",
+ summary: "side words",
+ work: ["did the thing"],
+ },
+ ],
+ });
+ const m1 = await node("m1");
+ expect(m1).toMatchObject({
+ title: "Ship it",
+ summary: "agent words",
+ work: ["did the thing"],
+ by: { work: "side" },
+ });
+ expect((await stored()).lastRecordedBy).toBe("side");
+ });
+
+ it("lets the side model fill a field the agent left empty", async () => {
+ await write({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", parent: null, title: "Ask" }],
+ });
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", title: "Ask again", why: "side reason" }],
+ });
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", title: "Ask again", why: "side reason 2" }],
+ });
+ const m1 = await node("m1");
+ // Side owns why now, so it may correct its own text; the agent's title stays.
+ expect(m1).toMatchObject({ title: "Ask", why: "side reason 2", by: { why: "side" } });
+ });
+
+ it("keeps an agent correction when a later side run disagrees", async () => {
+ await side({
+ sessionId: "s1",
+ nodes: [
+ { id: "m1", kind: "message", parent: null, title: "One" },
+ { id: "m2", kind: "message", parent: "m1", title: "Two" },
+ ],
+ });
+ expect((await node("m2"))?.parent).toBe("m1");
+ // The side model may still correct its own parent.
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m2", kind: "message", parent: null, title: "Two" }],
+ });
+ expect((await node("m2"))?.parent).toBeNull();
+ // The agent puts it back; the next side run must not undo that.
+ await write({
+ sessionId: "s1",
+ nodes: [{ id: "m2", kind: "message", parent: "m1", title: "Two" }],
+ });
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m2", kind: "message", parent: null, title: "Two" }],
+ });
+ expect((await node("m2"))?.parent).toBe("m1");
+ });
+
+ it("removes the side mark when the agent rewrites a field", async () => {
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", parent: null, title: "side title", why: "side why" }],
+ });
+ expect((await node("m1"))?.by).toEqual({ title: "side", why: "side" });
+ // The agent takes the title; the side model still owns `why`.
+ await write({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", title: "agent title" }],
+ });
+ expect((await node("m1"))?.by).toEqual({ why: "side" });
+ await side({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", title: "side again", why: "side why 2" }],
+ });
+ expect((await node("m1"))?.title).toBe("agent title");
+ expect((await node("m1"))?.why).toBe("side why 2");
+ // The agent takes the last field too: no marks left.
+ await write({
+ sessionId: "s1",
+ nodes: [{ id: "m1", kind: "message", title: "agent title", why: "agent why" }],
+ });
+ expect((await node("m1"))?.by).toBeUndefined();
+ });
+ });
+
it("creates and then merges a session", async () => {
await write({
sessionId: "s1",
diff --git a/packages/cli/test/settings.test.ts b/packages/cli/test/settings.test.ts
index fecb514..c2a0300 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 {
+ configHelpLines,
DEFAULT_SETTINGS,
editableSettings,
formatSetting,
@@ -13,10 +14,12 @@ describe("settings model", () => {
it("keeps the defaults in step with the config schema", () => {
const parsed = Config.parse({ schema: CONFIG_SCHEMA });
expect(DEFAULT_SETTINGS).toEqual({
+ recorder: parsed.recorder,
language: parsed.language,
updateEveryTurns: parsed.updateEveryTurns,
+ sideEveryTurns: parsed.sideEveryTurns,
sessionEndCatchUp: parsed.sessionEndCatchUp,
- catchUpModel: parsed.catchUpModel,
+ sideModel: parsed.sideModel,
messageSummaries: parsed.messageSummaries,
startupContext: parsed.startupContext,
tryBeforeNotes: parsed.tryBeforeNotes,
@@ -49,6 +52,8 @@ describe("settings model", () => {
for (const field of fields) {
expect(field.label).not.toBe("");
expect(field.help.length).toBeGreaterThan(10);
+ // Every field has the longer plain-language "?" text (Story 12.1).
+ expect(field.details.length).toBeGreaterThan(field.help.length);
expect(field.editable).toBe((PANEL_EDITABLE_KEYS as readonly string[]).includes(field.key));
}
});
@@ -62,19 +67,33 @@ describe("settings model", () => {
it("returns only the editable keys with their current values", () => {
const settings = { ...DEFAULT_SETTINGS, language: "tr", updateEveryTurns: 8 };
expect(editableSettings(settings)).toEqual({
+ recorder: "mixed",
messageSummaries: false,
startupContext: true,
tryBeforeNotes: true,
language: "tr",
updateEveryTurns: 8,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
shareConversations: false,
recordCommit: "ask",
});
expect(Object.keys(editableSettings(settings)).sort()).toEqual([...PANEL_EDITABLE_KEYS].sort());
});
+ 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);
+ const text = lines.join("\n");
+ for (const field of settingsSections(true).flatMap((section) => section.fields)) {
+ expect(text).toContain(field.details);
+ }
+ // The recording-mode explanation states the measured trade-off plainly.
+ expect(text).toContain("1–2%");
+ expect(text).toContain("5%");
+ });
+
it("formats a read-only value for the modal", () => {
expect(formatSetting(true)).toBe("yes");
expect(formatSetting(false)).toBe("no");
diff --git a/packages/cli/test/store.test.ts b/packages/cli/test/store.test.ts
index 31cd97b..52673ce 100644
--- a/packages/cli/test/store.test.ts
+++ b/packages/cli/test/store.test.ts
@@ -215,7 +215,7 @@ describe("stores", () => {
});
it("returns default config and persists changes", async () => {
- expect((await loadConfig(env)).updateEveryTurns).toBe(5);
+ expect((await loadConfig(env)).updateEveryTurns).toBe(15);
await updateConfig((c) => ({ ...c, updateEveryTurns: 3 }), env);
expect((await loadConfig(env)).updateEveryTurns).toBe(3);
});
diff --git a/packages/template/src/SettingsModal.tsx b/packages/template/src/SettingsModal.tsx
index 60107ad..8060598 100644
--- a/packages/template/src/SettingsModal.tsx
+++ b/packages/template/src/SettingsModal.tsx
@@ -17,6 +17,35 @@ import { isLivePage, loadSettings, pageToken, saveSetting } from "./data.js";
type SettingValue = PanelSettings[keyof PanelSettings];
+/**
+ * The "?" next to a setting's label (Story 12.1): a plain-language answer to
+ * "what is this, when do I change it, what does it cost", closed by default so
+ * the modal stays short.
+ */
+function FieldDetails({ id, field }: { id: string; field: SettingField }) {
+ const [open, setOpen] = useState(false);
+ const detailId = `${id}-details`;
+ return (
+ <>
+ <button
+ type="button"
+ className="settings-why"
+ aria-expanded={open}
+ aria-controls={detailId}
+ aria-label={`What does ${field.label} do?`}
+ onClick={() => setOpen((wasOpen) => !wasOpen)}
+ >
+ ?
+ </button>
+ {open ? (
+ <p className="settings-details" id={detailId}>
+ {field.details}
+ </p>
+ ) : null}
+ </>
+ );
+}
+
interface EditableProps {
id: string;
field: SettingField;
@@ -74,9 +103,10 @@ function EditableSetting({ id, field, value, token, onSaved }: EditableProps) {
return (
<div className="settings-field">
<div className="settings-field-text">
- <label className="settings-label" htmlFor={id}>
- {field.label}
- </label>
+ <span className="settings-label">
+ <label htmlFor={id}>{field.label}</label>
+ <FieldDetails id={id} field={field} />
+ </span>
<p className="settings-help" id={`${id}-help`}>
{field.help}
</p>
@@ -93,6 +123,22 @@ function EditableSetting({ id, field, value, token, onSaved }: EditableProps) {
edited();
}}
/>
+ ) : field.kind === "select" ? (
+ <select
+ id={id}
+ value={draft}
+ aria-describedby={`${id}-help`}
+ onChange={(event) => {
+ setDraft(event.target.value);
+ edited();
+ }}
+ >
+ {(field.options ?? []).map((option) => (
+ <option key={option.value} value={option.value}>
+ {option.label}
+ </option>
+ ))}
+ </select>
) : (
<input
id={id}
@@ -214,7 +260,10 @@ function SettingsDialog({
) : (
<div key={field.key} className="settings-field">
<div className="settings-field-text">
- <span className="settings-label">{field.label}</span>
+ <span className="settings-label">
+ {field.label}
+ <FieldDetails id={id} field={field} />
+ </span>
<p className="settings-help" id={`${id}-help`}>
{field.help}
</p>
diff --git a/packages/template/src/fixture.ts b/packages/template/src/fixture.ts
index 1285f08..42ea81b 100644
--- a/packages/template/src/fixture.ts
+++ b/packages/template/src/fixture.ts
@@ -52,10 +52,12 @@ export const fixture: LineageViewModel = {
lastActivity: "2026-10-24T11:42:00.000Z",
},
settings: {
+ recorder: "mixed",
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
messageSummaries: false,
startupContext: true,
tryBeforeNotes: true,
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index d75db29..70ca4d4 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -631,9 +631,40 @@ ul {
}
.settings-label {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
font-size: 14px;
}
+/* The "?" behind a setting's plain-language explanation (Story 12.1). */
+.settings-why {
+ width: 18px;
+ height: 18px;
+ padding: 0;
+ color: var(--muted);
+ background: var(--panel);
+ border: 1px solid var(--line);
+ border-radius: 50%;
+ font: inherit;
+ font-size: 11px;
+ line-height: 1;
+ cursor: pointer;
+}
+
+.settings-why[aria-expanded="true"] {
+ color: var(--text);
+ border-color: var(--muted);
+}
+
+.settings-details {
+ max-width: 46ch;
+ margin: 6px 0 0;
+ color: var(--text);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
.settings-help {
margin: 2px 0 0;
color: var(--muted);
@@ -2159,7 +2190,8 @@ time {
}
.setting-form input[type="text"],
-.setting-form input[type="number"] {
+.setting-form input[type="number"],
+.setting-form select {
width: 150px;
padding: 3px 6px;
color: var(--text);
diff --git a/packages/template/test/panel.test.ts b/packages/template/test/panel.test.ts
index dd2323d..2156a8a 100644
--- a/packages/template/test/panel.test.ts
+++ b/packages/template/test/panel.test.ts
@@ -9,10 +9,12 @@ const model: PanelViewModel = {
schema: 1,
generatedAt: "2026-10-26T10:00:00.000Z",
settings: {
+ recorder: "mixed",
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
messageSummaries: false,
startupContext: true,
shareConversations: false,
diff --git a/packages/template/test/unread.test.ts b/packages/template/test/unread.test.ts
index 5d549b8..746500c 100644
--- a/packages/template/test/unread.test.ts
+++ b/packages/template/test/unread.test.ts
@@ -56,10 +56,12 @@ function modelOf(current: ViewSession): LineageViewModel {
unassigned: [],
read: [],
settings: {
+ recorder: "mixed",
language: "auto",
- updateEveryTurns: 5,
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
sessionEndCatchUp: true,
- catchUpModel: "haiku",
+ sideModel: "haiku",
messageSummaries: false,
startupContext: true,
shareConversations: false,