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.

900 B
Raw Blame
import { z } from "zod";
import { IsoDate, MessageRef, Slug } from "./common.js";

/**
 * Structure changes of one session, appended and never rewritten (Story 8.5).
 * The graph is the replay of this file: the last `parent` event for a message
 * wins, `link` adds a return and `unlink` removes one. Notes stay in the session
 * JSON; this file holds facts only.
 */
export const SessionEvent = z.object({
  /** When the change was recorded. */
  at: IsoDate,
  type: z.enum(["parent", "link", "unlink"]),
  /** The message the event is about, by its stable id. */
  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, the side model, or the user. */
  by: z.enum(["agent", "user", "side"]).default("agent"),
});

export type SessionEvent = z.infer<typeof SessionEvent>;