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.

fix(shape): read every Thought trailer, not only those since the record began

Erence7f119a3fb9
diff --git a/packages/cli/src/commands/shape.ts b/packages/cli/src/commands/shape.ts
index e914b39..926adce 100644
--- a/packages/cli/src/commands/shape.ts
+++ b/packages/cli/src/commands/shape.ts
@@ -145,9 +145,11 @@ async function shapeCommit(root: string, ref: string, config: Config, io: Io): P
await underLock(root, session.sessionId, io, async () => {
const fresh = await loadSession(root, session.sessionId);
if (!fresh.found || !fresh.ok) return;
+ // No `since`: `startedAt` is the record's first write, which often comes
+ // after the commit that is being shaped.
const [withTrailers] = attachThoughtTrailers(
[fresh.data],
- await readThoughtTrailers(root, { env: io.env, since: fresh.data.startedAt }),
+ await readThoughtTrailers(root, { env: io.env }),
);
const node = withTrailers?.nodes.find((n) => n.id === thought);
if (node === undefined || !needsShape(node)) return;
@@ -168,7 +170,7 @@ async function runShape(root: string, sessionId: string, config: Config, io: Io)
// The trailers link commits the record has not listed yet.
const [session] = attachThoughtTrailers(
[loaded.data],
- await readThoughtTrailers(root, { env: io.env, since: loaded.data.startedAt }),
+ await readThoughtTrailers(root, { env: io.env }),
);
for (const node of shapeCandidates(session?.nodes ?? [])) {
if (await shapeNode(root, gitRoot, sessionId, node, config, io)) return;
diff --git a/packages/cli/test/shape-commit.test.ts b/packages/cli/test/shape-commit.test.ts
index d1c2326..63f1c53 100644
--- a/packages/cli/test/shape-commit.test.ts
+++ b/packages/cli/test/shape-commit.test.ts
@@ -22,13 +22,17 @@ const OLDER = "h0000000000aa";
const ANSWER = JSON.stringify({ tools: [{ kind: "pseudo", text: "1. Read it\n2. Write it" }] });
+// The record's first write comes after the commits, as it does when a commit
+// lands before the Stop hook records the message.
+const LATER = "2099-01-01T00:00:00.000Z";
+
function session(nodes: Session["nodes"], id = "s1"): Session {
return {
schema: 1,
sessionId: id,
agent: "claude-code",
title: "Ship it",
- startedAt: T0,
+ startedAt: LATER,
updatedAt: T0,
status: { goal: "", done: [], pending: [], next: "" },
nodes,