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(template): add single-file map template with shared view model

Erend90ff472ac7b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9050190..ffbe28e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- Template workspace (`packages/template`): React 19 + Vite 8 + `vite-plugin-singlefile`, dev fixture and the shared lineage view-model contract (`packages/cli/src/view/model.ts`).
## [0.2.0] - 2026-10-21
### Added
diff --git a/package-lock.json b/package-lock.json
index a0f2abc..9bf543f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
"vitest": "^5.0.5"
},
"engines": {
- "node": ">=22.12.0"
+ "node": ">=22.13.0"
}
},
"node_modules/@babel/helper-string-parser": {
@@ -1125,7 +1125,6 @@
"integrity": "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"funding": {
"url": "https://github.com/sponsors/oxc-project"
}
@@ -1143,7 +1142,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1161,7 +1159,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1179,7 +1176,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1197,7 +1193,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1215,7 +1210,6 @@
"os": [
"freebsd"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1233,7 +1227,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1254,7 +1247,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1275,7 +1267,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1296,7 +1287,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1317,7 +1307,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1338,7 +1327,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1359,7 +1347,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1377,7 +1364,6 @@
"os": [
"openharmony"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1395,7 +1381,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1413,7 +1398,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
@@ -1423,8 +1407,7 @@
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
"integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.64.12",
@@ -1850,6 +1833,26 @@
"undici-types": "~6.21.0"
}
},
+ "node_modules/@types/react": {
+ "version": "19.3.0",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
+ "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "csstype": "^3.2.2"
+ }
+ },
+ "node_modules/@types/react-dom": {
+ "version": "19.3.0",
+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz",
+ "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "^19.3.0"
+ }
+ },
"node_modules/@typescript/typescript-aix-ppc64": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz",
@@ -2190,6 +2193,36 @@
"node": ">=16.20.0"
}
},
+ "node_modules/@vitejs/plugin-react": {
+ "version": "6.1.2",
+ "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.2.tgz",
+ "integrity": "sha512-fhJNGUdscQa4HkI0xFxwonWyhnVReCPDbXI7FH7jmzpnVCrFQI7PRrhWecO263610vOrs9tr2Y4xcf8uAdFxbw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@rolldown/pluginutils": "^1.0.1"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "peerDependencies": {
+ "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0",
+ "babel-plugin-react-compiler": "^1.0.0",
+ "oxc-transform-react": "^0.152.0",
+ "vite": "^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@rolldown/plugin-babel": {
+ "optional": true
+ },
+ "babel-plugin-react-compiler": {
+ "optional": true
+ },
+ "oxc-transform-react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@vitest/coverage-v8": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.5.tgz",
@@ -2430,13 +2463,19 @@
"node": "^14.18.0 || >=16.10.0"
}
},
+ "node_modules/csstype": {
+ "version": "3.2.3",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
+ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/detect-libc": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"engines": {
"node": ">=8"
}
@@ -2618,7 +2657,6 @@
"integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
"dev": true,
"license": "MPL-2.0",
- "peer": true,
"dependencies": {
"detect-libc": "^2.0.3"
},
@@ -2656,7 +2694,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2678,7 +2715,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2700,7 +2736,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2722,7 +2757,6 @@
"os": [
"freebsd"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2744,7 +2778,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2769,7 +2802,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2794,7 +2826,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2819,7 +2850,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2844,7 +2874,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2866,7 +2895,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2888,7 +2916,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">= 12.0.0"
},
@@ -2995,7 +3022,6 @@
}
],
"license": "MIT",
- "peer": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
},
@@ -3096,7 +3122,6 @@
}
],
"license": "MIT",
- "peer": true,
"dependencies": {
"nanoid": "^3.3.20",
"picocolors": "^1.1.1",
@@ -3149,6 +3174,27 @@
}
}
},
+ "node_modules/react": {
+ "version": "19.3.1",
+ "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz",
+ "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/react-dom": {
+ "version": "19.3.1",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz",
+ "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==",
+ "license": "MIT",
+ "dependencies": {
+ "scheduler": "^0.28.0"
+ },
+ "peerDependencies": {
+ "react": "^19.3.1"
+ }
+ },
"node_modules/readdirp": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz",
@@ -3179,7 +3225,6 @@
"integrity": "sha512-6odND+fel5zVw3I4Yc2e69gvguDnX0CAAGiNDZSq4ik5WUcaLrkD2GLuog0XcODbor31hZ5ayEMgVDno+KPV5g==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@oxc-project/types": "=0.155.0",
"@rolldown/pluginutils": "^1.0.0"
@@ -3260,6 +3305,12 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
+ "node_modules/scheduler": {
+ "version": "0.28.0",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz",
+ "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==",
+ "license": "MIT"
+ },
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
@@ -3312,6 +3363,10 @@
"node": ">=16 || 14 >=14.17"
}
},
+ "node_modules/template": {
+ "resolved": "packages/template",
+ "link": true
+ },
"node_modules/thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
@@ -3507,7 +3562,6 @@
"integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"lightningcss": "^1.33.0",
"picomatch": "^4.0.7",
@@ -3580,6 +3634,28 @@
}
}
},
+ "node_modules/vite-plugin-singlefile": {
+ "version": "2.3.4",
+ "resolved": "https://registry.npmjs.org/vite-plugin-singlefile/-/vite-plugin-singlefile-2.3.4.tgz",
+ "integrity": "sha512-1FAhlTCL6KJDpSUudrVU+gspapvS+tmKCg70vwNaAU6tyXn3E/C6+NnwQIze06byhBRv7VggZ78K0h+J/Rsdrg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "picomatch": "^4.0.7"
+ },
+ "engines": {
+ "node": ">18.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^4.59.0",
+ "vite": "^5.4.21 || ^6.0.0 || ^7.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ }
+ }
+ },
"node_modules/vitest": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz",
@@ -3711,7 +3787,7 @@
"tsup": "^9.0.0"
},
"engines": {
- "node": ">=22.12.0"
+ "node": ">=22.13.0"
}
},
"packages/cli/node_modules/commander": {
@@ -3722,6 +3798,20 @@
"engines": {
"node": ">=22.12.0"
}
+ },
+ "packages/template": {
+ "version": "0.0.0",
+ "dependencies": {
+ "react": "^19.3.1",
+ "react-dom": "^19.3.1"
+ },
+ "devDependencies": {
+ "@types/react": "^19.3.0",
+ "@types/react-dom": "^19.3.0",
+ "@vitejs/plugin-react": "^6.1.2",
+ "vite": "^8.3.5",
+ "vite-plugin-singlefile": "^2.3.4"
+ }
}
}
}
diff --git a/package.json b/package.json
index fe0df99..7358d7f 100644
--- a/package.json
+++ b/package.json
@@ -9,10 +9,11 @@
"node": ">=22.13.0"
},
"scripts": {
- "build": "npm run build --workspaces --if-present",
+ "build": "npm run build -w template && npm run build -w codelineage",
+ "dev:template": "npm run dev -w template",
"lint": "biome check .",
"format": "biome check --write .",
- "typecheck": "tsc -p packages/cli --noEmit",
+ "typecheck": "tsc -p packages/cli --noEmit && tsc -p packages/template --noEmit",
"test": "vitest run --coverage"
},
"devDependencies": {
diff --git a/packages/cli/src/schema/session.ts b/packages/cli/src/schema/session.ts
index 2f285d8..09836c2 100644
--- a/packages/cli/src/schema/session.ts
+++ b/packages/cli/src/schema/session.ts
@@ -4,6 +4,7 @@ import { IsoDate, Slug } from "./common.js";
export const SESSION_SCHEMA = 1;
export const NodeKind = z.enum(["phase", "step", "decision", "question"]);
+export type NodeKind = z.infer<typeof NodeKind>;
export const LineageNode = z.object({
id: Slug,
diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.ts
new file mode 100644
index 0000000..ca5d6b1
--- /dev/null
+++ b/packages/cli/src/view/model.ts
@@ -0,0 +1,77 @@
+import type { NodeKind } from "../schema/session.js";
+
+/**
+ * Serialized contract between `codelineage build` and the HTML template. The
+ * builder fills this shape, JSON-serializes it into the page's data element and
+ * the React app in `packages/template` renders it. Keep this file free of runtime
+ * dependencies so both sides can import it.
+ */
+
+/** Id of the `<script type="application/json">` that carries the model. */
+export const DATA_ELEMENT_ID = "codelineage-data";
+
+/** Version of the serialized view model (not the session schema). */
+export const VIEW_SCHEMA = 1;
+
+export interface ViewNode {
+ id: string;
+ kind: NodeKind;
+ title: string;
+ summary?: string;
+ why?: string;
+ at?: string;
+ /** Nested children, already ordered as the graph should draw them. */
+ children: ViewNode[];
+}
+
+export interface ViewPendingItem {
+ text: string;
+ needsUser: boolean;
+}
+
+export interface ViewStatus {
+ goal: string;
+ done: string[];
+ pending: ViewPendingItem[];
+ next: string;
+}
+
+/** Status card at the top of the map (merged across sessions). */
+export interface StatusCard extends ViewStatus {
+ /** `updatedAt` of the most recently updated session, or null with no sessions. */
+ lastActivity: string | null;
+}
+
+export interface ViewSession {
+ sessionId: string;
+ agent: string;
+ title: string;
+ epoch: string | null;
+ startedAt: string;
+ updatedAt: string;
+ status: ViewStatus;
+ nodes: ViewNode[];
+ /** False when the Claude Code transcript is gone, so resume cannot work. */
+ transcriptAvailable: boolean;
+}
+
+export interface ViewEpoch {
+ id: string;
+ title: string;
+ createdAt: string;
+ sessions: ViewSession[];
+}
+
+export interface LineageViewModel {
+ kind: "lineage";
+ schema: typeof VIEW_SCHEMA;
+ project: {
+ name: string;
+ path: string;
+ generatedAt: string;
+ };
+ status: StatusCard;
+ epochs: ViewEpoch[];
+ /** Sessions with no epoch, or with an epoch that no longer exists. */
+ unassigned: ViewSession[];
+}
diff --git a/packages/cli/test/view-model.test.ts b/packages/cli/test/view-model.test.ts
new file mode 100644
index 0000000..818f8cb
--- /dev/null
+++ b/packages/cli/test/view-model.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from "vitest";
+import { DATA_ELEMENT_ID, VIEW_SCHEMA } from "../src/view/model.js";
+
+describe("view model contract", () => {
+ it("pins the data element id the template reads", () => {
+ expect(DATA_ELEMENT_ID).toBe("codelineage-data");
+ });
+
+ it("pins the serialized schema version", () => {
+ expect(VIEW_SCHEMA).toBe(1);
+ });
+});
diff --git a/packages/template/index.html b/packages/template/index.html
new file mode 100644
index 0000000..dacc859
--- /dev/null
+++ b/packages/template/index.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>codelineage — lineage</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <!-- `codelineage build` replaces the empty element with the JSON view model. -->
+ <script id="codelineage-data" type="application/json"></script>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
diff --git a/packages/template/package.json b/packages/template/package.json
new file mode 100644
index 0000000..e695fcd
--- /dev/null
+++ b/packages/template/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "template",
+ "version": "0.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "react": "^19.3.1",
+ "react-dom": "^19.3.1"
+ },
+ "devDependencies": {
+ "@types/react": "^19.3.0",
+ "@types/react-dom": "^19.3.0",
+ "@vitejs/plugin-react": "^6.1.2",
+ "vite": "^8.3.5",
+ "vite-plugin-singlefile": "^2.3.4"
+ }
+}
diff --git a/packages/template/src/App.tsx b/packages/template/src/App.tsx
new file mode 100644
index 0000000..b43d952
--- /dev/null
+++ b/packages/template/src/App.tsx
@@ -0,0 +1,146 @@
+import type {
+ LineageViewModel,
+ StatusCard,
+ ViewNode,
+ ViewSession,
+} from "../../cli/src/view/model.js";
+
+function formatTime(iso: string | null): string {
+ if (!iso) return "—";
+ const date = new Date(iso);
+ return Number.isNaN(date.getTime()) ? iso : date.toLocaleString();
+}
+
+function NodeItem({ node }: { node: ViewNode }) {
+ return (
+ <li className="node">
+ <div className="node-head">
+ <span className={`kind kind-${node.kind}`}>{node.kind}</span>
+ <strong>{node.title}</strong>
+ {node.at ? <time dateTime={node.at}>{formatTime(node.at)}</time> : null}
+ </div>
+ {node.summary ? <p>{node.summary}</p> : null}
+ {node.why ? (
+ <p className="why">
+ <span>why</span> {node.why}
+ </p>
+ ) : null}
+ {node.children.length > 0 ? <NodeList nodes={node.children} /> : null}
+ </li>
+ );
+}
+
+function NodeList({ nodes }: { nodes: ViewNode[] }) {
+ if (nodes.length === 0) return <p className="empty">No steps recorded yet.</p>;
+ return (
+ <ul className="nodes">
+ {nodes.map((node) => (
+ <NodeItem key={node.id} node={node} />
+ ))}
+ </ul>
+ );
+}
+
+function StatusPanel({ status }: { status: StatusCard }) {
+ return (
+ <section className="status" aria-label="Project status">
+ <div className="status-goal">
+ <h2>Goal</h2>
+ <p>{status.goal || "No goal recorded."}</p>
+ </div>
+ <div>
+ <h3>Done</h3>
+ {status.done.length > 0 ? (
+ <ul>
+ {status.done.map((item, i) => (
+ <li key={`${i}-${item}`}>{item}</li>
+ ))}
+ </ul>
+ ) : (
+ <p className="empty">Nothing yet.</p>
+ )}
+ </div>
+ <div>
+ <h3>Pending</h3>
+ {status.pending.length > 0 ? (
+ <ul>
+ {status.pending.map((item, i) => (
+ <li key={`${i}-${item.text}`} className={item.needsUser ? "needs-user" : undefined}>
+ {item.text}
+ {item.needsUser ? <span className="badge">needs you</span> : null}
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <p className="empty">Nothing pending.</p>
+ )}
+ </div>
+ <div>
+ <h3>Next</h3>
+ <p>{status.next || "No next step recorded."}</p>
+ <h3>Last activity</h3>
+ <p>{formatTime(status.lastActivity)}</p>
+ </div>
+ </section>
+ );
+}
+
+function SessionCard({ session }: { session: ViewSession }) {
+ return (
+ <article className="session">
+ <header>
+ <h3>{session.title || session.sessionId}</h3>
+ <code>{session.sessionId}</code>
+ <span className="muted">updated {formatTime(session.updatedAt)}</span>
+ </header>
+ <p className="session-goal">{session.status.goal}</p>
+ <NodeList nodes={session.nodes} />
+ </article>
+ );
+}
+
+export function App({ model }: { model: LineageViewModel }) {
+ const sessionCount =
+ model.epochs.reduce((sum, epoch) => sum + epoch.sessions.length, 0) + model.unassigned.length;
+
+ return (
+ <main>
+ <header className="project">
+ <div>
+ <h1>{model.project.name}</h1>
+ <p className="muted">{model.project.path}</p>
+ </div>
+ <div className="meta">
+ <span>
+ {model.epochs.length} epochs · {sessionCount} sessions
+ </span>
+ <span className="muted">generated {formatTime(model.project.generatedAt)}</span>
+ </div>
+ </header>
+
+ <StatusPanel status={model.status} />
+
+ {model.epochs.map((epoch) => (
+ <section className="epoch" key={epoch.id}>
+ <h2>
+ {epoch.title} <span className="muted">({epoch.sessions.length})</span>
+ </h2>
+ {epoch.sessions.map((session) => (
+ <SessionCard key={session.sessionId} session={session} />
+ ))}
+ </section>
+ ))}
+
+ {model.unassigned.length > 0 ? (
+ <section className="epoch unassigned">
+ <h2>
+ Unassigned <span className="muted">({model.unassigned.length})</span>
+ </h2>
+ {model.unassigned.map((session) => (
+ <SessionCard key={session.sessionId} session={session} />
+ ))}
+ </section>
+ ) : null}
+ </main>
+ );
+}
diff --git a/packages/template/src/data.ts b/packages/template/src/data.ts
new file mode 100644
index 0000000..1213023
--- /dev/null
+++ b/packages/template/src/data.ts
@@ -0,0 +1,31 @@
+import { DATA_ELEMENT_ID, type LineageViewModel } from "../../cli/src/view/model.js";
+
+function parse(text: string): LineageViewModel {
+ let value: unknown;
+ try {
+ value = JSON.parse(text);
+ } catch {
+ throw new Error("The embedded codelineage data is not valid JSON.");
+ }
+ if (typeof value !== "object" || value === null || !("kind" in value)) {
+ throw new Error("The embedded codelineage data is not a view model.");
+ }
+ if (value.kind !== "lineage") {
+ throw new Error(`Unsupported codelineage view: ${String(value.kind)}`);
+ }
+ return value as LineageViewModel;
+}
+
+/**
+ * Reads the JSON contract from the page. Dev mode falls back to the fixture;
+ * production builds always embed the data, so a missing element is a real error.
+ */
+export async function loadViewModel(doc: Document = document): Promise<LineageViewModel> {
+ const raw = doc.getElementById(DATA_ELEMENT_ID)?.textContent?.trim();
+ if (raw) return parse(raw);
+ if (import.meta.env.DEV) {
+ const { fixture } = await import("./fixture.js");
+ return fixture;
+ }
+ throw new Error("No codelineage data in this page. Run `codelineage build`.");
+}
diff --git a/packages/template/src/fixture.ts b/packages/template/src/fixture.ts
new file mode 100644
index 0000000..0198aa2
--- /dev/null
+++ b/packages/template/src/fixture.ts
@@ -0,0 +1,147 @@
+import type { LineageViewModel, ViewNode, ViewSession } from "../../cli/src/view/model.js";
+
+const node = (
+ id: string,
+ kind: ViewNode["kind"],
+ title: string,
+ extra: Partial<ViewNode> = {},
+): ViewNode => ({ id, kind, title, children: [], ...extra });
+
+const session = (
+ sessionId: string,
+ title: string,
+ epoch: string | null,
+ startedAt: string,
+ updatedAt: string,
+ nodes: ViewNode[],
+ status: ViewSession["status"],
+): ViewSession => ({
+ sessionId,
+ agent: "claude-code",
+ title,
+ epoch,
+ startedAt,
+ updatedAt,
+ status,
+ nodes,
+ transcriptAvailable: true,
+});
+
+/**
+ * Dev-only sample data (`npm run dev -w template`). Mirrors the shape `codelineage
+ * build` produces: two epochs, three sessions (one unassigned) and nested nodes.
+ */
+export const fixture: LineageViewModel = {
+ kind: "lineage",
+ schema: 1,
+ project: {
+ name: "codelineage",
+ path: "/home/dev/codelineage",
+ generatedAt: "2026-10-21T12:00:00.000Z",
+ },
+ status: {
+ goal: "Ship the project map as one self-contained HTML file.",
+ done: ["Define the view-model contract", "Scaffold the template package"],
+ pending: [
+ { text: "Pick the graph layout that survives 500 nodes", needsUser: true },
+ { text: "Write the resume command copy fallback", needsUser: false },
+ ],
+ next: "Render the fixture through the template and check the single-file build.",
+ lastActivity: "2026-10-21T11:42:00.000Z",
+ },
+ epochs: [
+ {
+ id: "map",
+ title: "Project map",
+ createdAt: "2026-10-19T09:00:00.000Z",
+ sessions: [
+ session(
+ "fixture-template",
+ "Template package and single-file output",
+ "map",
+ "2026-10-21T08:00:00.000Z",
+ "2026-10-21T11:42:00.000Z",
+ [
+ node("n1", "phase", "Scaffold the template", {
+ summary: "React 19 + Vite 8, one index.html at build time.",
+ at: "2026-10-21T09:05:00.000Z",
+ children: [
+ node("n2", "step", "Wire the data contract", {
+ summary: "The page reads the JSON script element and types it once.",
+ children: [
+ node("n3", "decision", "Read data from the DOM, not a fetch", {
+ why: "A fetch would break file://; the JSON element survives inlining.",
+ }),
+ ],
+ }),
+ node("n4", "question", "Should the fixture ship in production?", {
+ summary: "No: dev-only import is tree-shaken from the build.",
+ }),
+ ],
+ }),
+ node("n5", "step", "Build the dev fixture", {
+ summary: "Two epochs, three sessions, one unassigned.",
+ }),
+ ],
+ {
+ goal: "Render a typed fixture through the template.",
+ done: ["Scaffold Vite + React", "Add the fixture"],
+ pending: [{ text: "Confirm the graph layout", needsUser: true }],
+ next: "Check the page in the browser.",
+ },
+ ),
+ ],
+ },
+ {
+ id: "capture",
+ title: "Capture pipeline",
+ createdAt: "2026-10-20T10:00:00.000Z",
+ sessions: [
+ session(
+ "fixture-capture",
+ "Session merge and redaction",
+ "capture",
+ "2026-10-20T09:00:00.000Z",
+ "2026-10-20T16:30:00.000Z",
+ [
+ node("c1", "phase", "Harden session writes", {
+ summary: "Locked read → merge → write with redaction.",
+ children: [
+ node("c2", "decision", "Keep node parents optional on input", {
+ why: "The agent can add a child without re-sending the whole tree.",
+ }),
+ ],
+ }),
+ ],
+ {
+ goal: "Make session writes safe under concurrency.",
+ done: ["Per-session lock", "redactDeep"],
+ pending: [],
+ next: "Add the turn counter.",
+ },
+ ),
+ ],
+ },
+ ],
+ unassigned: [
+ session(
+ "fixture-unassigned",
+ "Scratch notes on status cards",
+ null,
+ "2026-10-19T16:00:00.000Z",
+ "2026-10-19T18:00:00.000Z",
+ [
+ node("u1", "step", "Sketch the status card", {
+ summary: "Goal, done, pending, next and last activity.",
+ children: [node("u2", "question", "What counts as an active session?")],
+ }),
+ ],
+ {
+ goal: "Decide how the status card merges parallel sessions.",
+ done: [],
+ pending: [{ text: "Define active", needsUser: true }],
+ next: "Ask before implementing.",
+ },
+ ),
+ ],
+};
diff --git a/packages/template/src/main.tsx b/packages/template/src/main.tsx
new file mode 100644
index 0000000..b32c9e4
--- /dev/null
+++ b/packages/template/src/main.tsx
@@ -0,0 +1,23 @@
+import { StrictMode } from "react";
+import { createRoot } from "react-dom/client";
+import { App } from "./App.js";
+import { loadViewModel } from "./data.js";
+import "./styles.css";
+
+const root = document.getElementById("root");
+if (!root) throw new Error("missing #root");
+
+loadViewModel()
+ .then((model) => {
+ createRoot(root).render(
+ <StrictMode>
+ <App model={model} />
+ </StrictMode>,
+ );
+ })
+ .catch((err: unknown) => {
+ const message = document.createElement("p");
+ message.className = "error";
+ message.textContent = err instanceof Error ? err.message : String(err);
+ root.replaceChildren(message);
+ });
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
new file mode 100644
index 0000000..eded4b0
--- /dev/null
+++ b/packages/template/src/styles.css
@@ -0,0 +1,211 @@
+:root {
+ color-scheme: dark;
+ --bg: #0f1115;
+ --panel: #171a21;
+ --line: #2a2f3a;
+ --text: #e6e8ee;
+ --muted: #8b93a7;
+ --accent: #7aa2f7;
+ --warn: #e0af68;
+}
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+ background: var(--bg);
+ color: var(--text);
+ font:
+ 15px / 1.5 ui-sans-serif,
+ system-ui,
+ -apple-system,
+ "Segoe UI",
+ sans-serif;
+}
+
+main {
+ max-width: 960px;
+ margin: 0 auto;
+ padding: 32px 24px 64px;
+}
+
+h1,
+h2,
+h3 {
+ margin: 0 0 8px;
+ line-height: 1.25;
+}
+
+h1 {
+ font-size: 26px;
+}
+
+h2 {
+ font-size: 20px;
+}
+
+h3 {
+ font-size: 15px;
+}
+
+p {
+ margin: 4px 0;
+}
+
+ul {
+ margin: 6px 0;
+ padding-left: 20px;
+}
+
+.project {
+ display: flex;
+ align-items: flex-end;
+ justify-content: space-between;
+ gap: 16px;
+ border-bottom: 1px solid var(--line);
+ padding-bottom: 16px;
+}
+
+.meta {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-end;
+ gap: 2px;
+ font-size: 13px;
+}
+
+.muted {
+ color: var(--muted);
+ font-size: 13px;
+ font-weight: normal;
+}
+
+.status {
+ display: grid;
+ grid-template-columns: 1.4fr 1fr 1fr 1fr;
+ gap: 16px;
+ margin: 24px 0;
+ padding: 16px;
+ background: var(--panel);
+ border: 1px solid var(--line);
+ border-radius: 10px;
+}
+
+.status h2,
+.status h3 {
+ font-size: 12px;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--muted);
+}
+
+.needs-user {
+ color: var(--warn);
+}
+
+.badge {
+ margin-left: 6px;
+ padding: 1px 6px;
+ border: 1px solid var(--warn);
+ border-radius: 999px;
+ font-size: 11px;
+}
+
+.epoch {
+ margin-top: 28px;
+}
+
+.session {
+ margin-top: 12px;
+ padding: 14px 16px;
+ background: var(--panel);
+ border: 1px solid var(--line);
+ border-radius: 10px;
+}
+
+.session header {
+ display: flex;
+ align-items: baseline;
+ flex-wrap: wrap;
+ gap: 10px;
+}
+
+.session code {
+ color: var(--accent);
+ font-size: 12px;
+}
+
+.session-goal {
+ color: var(--muted);
+}
+
+.nodes {
+ border-left: 1px solid var(--line);
+ padding-left: 16px;
+ list-style: none;
+}
+
+.node {
+ margin: 8px 0;
+}
+
+.node-head {
+ display: flex;
+ align-items: baseline;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.kind {
+ padding: 1px 6px;
+ border-radius: 4px;
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ background: #242a36;
+ color: var(--muted);
+}
+
+.kind-decision {
+ background: #2b2440;
+ color: #c0a8ff;
+}
+
+.kind-question {
+ background: #3a2f1d;
+ color: var(--warn);
+}
+
+.why span {
+ color: var(--accent);
+ font-size: 11px;
+ text-transform: uppercase;
+}
+
+.empty,
+.error {
+ color: var(--muted);
+ font-style: italic;
+}
+
+time {
+ color: var(--muted);
+ font-size: 12px;
+}
+
+@media (max-width: 720px) {
+ .status {
+ grid-template-columns: 1fr;
+ }
+
+ .project {
+ flex-direction: column;
+ align-items: flex-start;
+ }
+
+ .meta {
+ align-items: flex-start;
+ }
+}
diff --git a/packages/template/tsconfig.json b/packages/template/tsconfig.json
new file mode 100644
index 0000000..29d88a8
--- /dev/null
+++ b/packages/template/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
+ "jsx": "react-jsx",
+ "types": ["vite/client"],
+ "noEmit": true
+ },
+ "include": ["src", "vite.config.ts"]
+}
diff --git a/packages/template/vite.config.ts b/packages/template/vite.config.ts
new file mode 100644
index 0000000..82a6172
--- /dev/null
+++ b/packages/template/vite.config.ts
@@ -0,0 +1,13 @@
+import react from "@vitejs/plugin-react";
+import { defineConfig } from "vite";
+import { viteSingleFile } from "vite-plugin-singlefile";
+
+// One self-contained index.html: no external requests, so the map works from file://.
+export default defineConfig({
+ plugins: [react(), viteSingleFile()],
+ build: {
+ outDir: "dist",
+ emptyOutDir: true,
+ reportCompressedSize: false,
+ },
+});