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(shape): show what a thought did to the code

Eren1a5c2e21725f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96ca74d..9140263 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
+- Intent, Shape and Code: a message that landed commits gets a **Shape** — numbered plain-language steps or a Mermaid diagram of what the change does — between its recorded Intent and its diff. The side panel previews it and **Open** shows the three layers with 1/2/3 tabs. The side model writes it after a commit (detached, behind its own lock) in the mixed and side modes, the agent writes it in the record skill, and `shapes` (on by default) turns it off. Release bumps, lockfiles, CHANGELOG-only changes and changes under five lines are skipped; an invalid diagram is kept as text.
- `cogit why <file>:<line>` (or `--line N`) shows only the thought behind that line: git blames the line to its commit, the commit's `Thought:` trailer names the message, and `why` prints that message's decision and rejected options. When the commit carries no thought it says so and lists the file's other thoughts; a line past the end of the file is an error.
- `cogit doctor` explains why the map may stay empty: read-only checks for Node, the Claude Code plugin and its version, git identity, the project and its hooks, the skill permission, transcripts and their retention, recorded sessions and the unrecorded tail, the map server and the close-pass log. Each line says `ok`, `warn` or `fail` with the command that fixes it; `--json` prints the report, and a failed check exits 1.
- `cogit init` warns when git has no `user.email`, since sessions are now told apart by it.
- The map tells your sessions from your teammates': a teammate's session always shows their name and yours never needs to, the side panel marks yours "(you)", and a new Everyone / You / teammate choice in the toolbar fades the other people's sessions.
### Changed
+- `cogit init` and `cogit hooks install` also add a `post-commit` block now, which queues a Shape after a commit without blocking it; `cogit doctor` flags it when missing. Existing projects get it with `cogit hooks install`.
- The README and the guide now describe what 0.20–0.25 ship: the map without epochs (row widths, open sessions remembered, the panel beside the map, one date shape, the person filter), Resume and Fork, forked sessions, `cogit doctor`, `why <file>:<line>` and the git-email identity. The map screenshots and the README demo are recorded again from the current map.
- A session records its author's git email next to their name, and people are told apart by email, as in git.
- A session only continues its author's own earlier sessions: after a pull, a teammate's sessions are no longer offered as the start of yours, and the map no longer draws a session as the continuation of someone else's.
diff --git a/README.md b/README.md
index 371cc7e..15d1cbf 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,8 @@ Claude Code today.
continue it as a new one.
- **Commits point back to their reason**: a `Thought:` trailer on each commit;
`cogit show <sha>`, `cogit blame` and `cogit why` follow it back.
+- **Intent, Shape, Code**: a message that landed commits shows why it happened, a small
+ picture of what the change does (plain steps or a diagram), and the diff, in one place.
- **Pull request descriptions with the decisions**: `cogit pr` writes the goal, the
decisions and the rejected options, never the raw chat.
- **Teams share the record through git**: after a pull, your teammates' sessions are on the
diff --git a/docs/guide/map.md b/docs/guide/map.md
index aa1b98d..fcbab9d 100644
--- a/docs/guide/map.md
+++ b/docs/guide/map.md
@@ -80,7 +80,22 @@ panel over the map.
session with the same history and the original stays as it was. On the map the fork starts from
the message it was forked at, like a session that continues another.
-## "Your turn"
+## Intent, Shape and Code
+
+A message that landed commits has three layers, in that order:
+
+- **Intent** — the record: the decision, the reason you gave, who decided, and the options
+ that were rejected. It is read as recorded, never rewritten here.
+- **Shape** — a small representation of what the change *does*: numbered plain-language
+ steps naming the functions and files, or a Mermaid diagram of the new path between them.
+ The recorder writes it, not you; the map draws the diagram in the page, offline included.
+- **Code** — the message's commits and their diffs, the same patches the panel opens.
+
+The message details show a short preview and an **Open** button. Open shows the three layers
+with 1/2/3 tabs (the number keys work too), starting on Shape. A message with nothing
+recorded yet says "being prepared"; with `shapes` off, it says so.
+
+
Above the panel's project cards, and folded in a project map's head, the "Your turn" inbox
lists the sessions waiting on you: the agent wrote last, or the record says it needs your
diff --git a/docs/guide/recording-and-cost.md b/docs/guide/recording-and-cost.md
index 3847fc1..4f61199 100644
--- a/docs/guide/recording-and-cost.md
+++ b/docs/guide/recording-and-cost.md
@@ -41,6 +41,15 @@ To record less often, raise `sideEveryTurns` and `updateEveryTurns`. To spend no
recording during the session, use `recorder: side` and turn `sessionEndCatchUp` off; the
messages then wait until you record them.
+## Shapes
+
+A message that landed commits also gets a **Shape**: numbered steps or a small diagram of
+what the change does, shown beside its Intent and its Code. Whoever records writes it — the
+agent in the record skill, or after a commit the side model, detached, so a commit never
+waits. It is one small model call per such message, reading the combined diff (cut to about
+7 KB). Release/version bumps, lockfiles, CHANGELOG-only changes and changes under five lines
+are skipped. `shapes: false` writes none and the map says so.
+
## When something is not recorded
A turn the side model has not reached yet shows on the map without a title for a while. If
diff --git a/docs/guide/settings.md b/docs/guide/settings.md
index 657b31b..ae5115d 100644
--- a/docs/guide/settings.md
+++ b/docs/guide/settings.md
@@ -48,6 +48,14 @@ Some plugins and scripts run `claude -p` in the background, often once per promp
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.
+### Intent, Shape and Code
+
+`shapes` · default `true`
+
+**A small picture of what each change does, beside its reason and its diff.**
+
+For every message that landed commits, a small representation of what the change does: numbered plain-language steps or a Mermaid diagram. It sits between the record's intent (the decision, reason and rejected options) and the code (the diff), so a reviewer sees why, what and how in one place. The recorder writes it, not you; it costs one small model call per such message. Off, the map says so and nothing is written.
+
### Language
`language` · default `auto`
diff --git a/docs/schema/config.json b/docs/schema/config.json
index 8aa3dc8..15953d3 100644
--- a/docs/schema/config.json
+++ b/docs/schema/config.json
@@ -52,6 +52,10 @@
"default": false,
"type": "boolean"
},
+ "shapes": {
+ "default": true,
+ "type": "boolean"
+ },
"startupContext": {
"default": true,
"type": "boolean"
@@ -137,6 +141,7 @@
"sideModel",
"sideEveryTurns",
"messageSummaries",
+ "shapes",
"startupContext",
"recordHeadless",
"serverPort",
diff --git a/docs/schema/session-input.json b/docs/schema/session-input.json
index 607efda..9a9d1ab 100644
--- a/docs/schema/session-input.json
+++ b/docs/schema/session-input.json
@@ -249,6 +249,48 @@
"title"
]
}
+ },
+ "shape": {
+ "type": "object",
+ "properties": {
+ "tools": {
+ "maxItems": 3,
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "kind": {
+ "type": "string",
+ "enum": [
+ "pseudo",
+ "mermaid"
+ ]
+ },
+ "text": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 4000
+ }
+ },
+ "required": [
+ "kind",
+ "text"
+ ]
+ }
+ },
+ "commits": {
+ "default": [],
+ "maxItems": 20,
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^[0-9a-f]{7,40}$"
+ }
+ }
+ },
+ "required": [
+ "tools"
+ ]
}
},
"required": [
diff --git a/docs/schema/session.json b/docs/schema/session.json
index 998d00c..f421c62 100644
--- a/docs/schema/session.json
+++ b/docs/schema/session.json
@@ -291,6 +291,67 @@
"additionalProperties": false
}
},
+ "shape": {
+ "type": "object",
+ "properties": {
+ "tools": {
+ "default": [],
+ "maxItems": 3,
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "kind": {
+ "type": "string",
+ "enum": [
+ "pseudo",
+ "mermaid"
+ ]
+ },
+ "text": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 4000
+ },
+ "valid": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "kind",
+ "text"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "by": {
+ "type": "string",
+ "enum": [
+ "agent",
+ "side"
+ ]
+ },
+ "commits": {
+ "default": [],
+ "maxItems": 20,
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^[0-9a-f]{7,40}$"
+ }
+ },
+ "at": {
+ "type": "string",
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
+ }
+ },
+ "required": [
+ "tools",
+ "commits"
+ ],
+ "additionalProperties": false
+ },
"by": {
"type": "object",
"propertyNames": {
diff --git a/package-lock.json b/package-lock.json
index ea3cde8..aa3851e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,19 @@
"node": ">=22.13.0"
}
},
+ "node_modules/@antfu/install-pkg": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@antfu/install-pkg/-/install-pkg-2.1.0.tgz",
+ "integrity": "sha512-sdg9NxU3zR4Mnawfbc/x6GB5Wf17WYud5qOuEuxXjaKpYpMkISSJEjItGebXJ2bQ4DIcly4NYH23mtkGJjvKUw==",
+ "license": "MIT",
+ "dependencies": {
+ "package-manager-detector": "^1.8.0",
+ "tinyexec": "^1.3.1"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ }
+ },
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
@@ -290,6 +303,18 @@
"node": ">=14.21.3"
}
},
+ "node_modules/@braintree/sanitize-url": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.2.tgz",
+ "integrity": "sha512-jigsZK+sMF/cuiB7sERuo9V7N9jx+dhmHHnQyDSVdpZwVutaBu7WvNYqMDLSgFgfB30n452TP3vjDAvFC973mA==",
+ "license": "MIT"
+ },
+ "node_modules/@chevrotain/types": {
+ "version": "11.1.2",
+ "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.1.2.tgz",
+ "integrity": "sha512-U+HFai5+zmJCkK86QsaJtoITlboZHBqrVketcO2ROv865xfCMSFpELQoz1GkX5GzME8pTa+3kbKrZHQtI0gdbw==",
+ "license": "Apache-2.0"
+ },
"node_modules/@cogit/cli": {
"resolved": "packages/cli",
"link": true
@@ -736,6 +761,23 @@
"node": ">=18"
}
},
+ "node_modules/@iconify/types": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
+ "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
+ "license": "MIT"
+ },
+ "node_modules/@iconify/utils": {
+ "version": "3.1.7",
+ "resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-3.1.7.tgz",
+ "integrity": "sha512-JZHlwdID+dy+lTgbYC8NEC4zeugqeYsc6jewvzb4c58kHauJn+X7rNwQjxz5p2qSjqaEeQoLkCIQ9v/H4PK0/w==",
+ "license": "MIT",
+ "dependencies": {
+ "@antfu/install-pkg": "^2.0.1",
+ "@iconify/types": "^2.0.0",
+ "import-meta-resolve": "^4.2.0"
+ }
+ },
"node_modules/@inquirer/ansi": {
"version": "2.0.9",
"resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.9.tgz",
@@ -1119,6 +1161,15 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
+ "node_modules/@mermaid-js/parser": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-1.2.1.tgz",
+ "integrity": "sha512-n12NohV3mrUyUL2o93IgG/ifeW9FTyeJn3zDxkhwa8MJ9Fxg3HQMlA3RiGmD/3UnJvheztkjjQAjA2T4LmUcpw==",
+ "license": "MIT",
+ "dependencies": {
+ "@chevrotain/types": "~11.1.2"
+ }
+ },
"node_modules/@napi-rs/lzma-linux-x64-gnu": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
@@ -1829,12 +1880,102 @@
"assertion-error": "^2.0.1"
}
},
+ "node_modules/@types/d3": {
+ "version": "7.4.3",
+ "resolved": "https://registry.npmjs.org/@types/d3/-/d3-7.4.3.tgz",
+ "integrity": "sha512-lZXZ9ckh5R8uiFVt8ogUNf+pIrK4EsWrx2Np75WvF/eTpJ0FMHNhjXk8CKEx/+gpHbNQyJWehbFaTvqmHWB3ww==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-array": "*",
+ "@types/d3-axis": "*",
+ "@types/d3-brush": "*",
+ "@types/d3-chord": "*",
+ "@types/d3-color": "*",
+ "@types/d3-contour": "*",
+ "@types/d3-delaunay": "*",
+ "@types/d3-dispatch": "*",
+ "@types/d3-drag": "*",
+ "@types/d3-dsv": "*",
+ "@types/d3-ease": "*",
+ "@types/d3-fetch": "*",
+ "@types/d3-force": "*",
+ "@types/d3-format": "*",
+ "@types/d3-geo": "*",
+ "@types/d3-hierarchy": "*",
+ "@types/d3-interpolate": "*",
+ "@types/d3-path": "*",
+ "@types/d3-polygon": "*",
+ "@types/d3-quadtree": "*",
+ "@types/d3-random": "*",
+ "@types/d3-scale": "*",
+ "@types/d3-scale-chromatic": "*",
+ "@types/d3-selection": "*",
+ "@types/d3-shape": "*",
+ "@types/d3-time": "*",
+ "@types/d3-time-format": "*",
+ "@types/d3-timer": "*",
+ "@types/d3-transition": "*",
+ "@types/d3-zoom": "*"
+ }
+ },
+ "node_modules/@types/d3-array": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz",
+ "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-axis": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-3.0.6.tgz",
+ "integrity": "sha512-pYeijfZuBd87T0hGn0FO1vQ/cgLk6E1ALJjfkC0oJ8cbwkZl3TpgS8bVBLZN+2jjGgg38epgxb2zmoGtSfvgMw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-selection": "*"
+ }
+ },
+ "node_modules/@types/d3-brush": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-3.0.6.tgz",
+ "integrity": "sha512-nH60IZNNxEcrh6L1ZSMNA28rj27ut/2ZmI3r96Zd+1jrZD++zD3LsMIjWlvg4AYrHn/Pqz4CF3veCxGjtbqt7A==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-selection": "*"
+ }
+ },
+ "node_modules/@types/d3-chord": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-3.0.6.tgz",
+ "integrity": "sha512-LFYWWd8nwfwEmTZG9PfQxd17HbNPksHBiJHaKuY1XeqscXacsS2tyoo6OdRsjf+NQYeB6XrNL3a25E3gH69lcg==",
+ "license": "MIT"
+ },
"node_modules/@types/d3-color": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz",
"integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==",
"license": "MIT"
},
+ "node_modules/@types/d3-contour": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-3.0.6.tgz",
+ "integrity": "sha512-BjzLgXGnCWjUSYGfH1cpdo41/hgdWETu4YxpezoztawmqsvCeep+8QGfiY6YbDvfgHz/DkjeIkkZVJavB4a3rg==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-array": "*",
+ "@types/geojson": "*"
+ }
+ },
+ "node_modules/@types/d3-delaunay": {
+ "version": "6.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz",
+ "integrity": "sha512-ZMaSKu4THYCU6sV64Lhg6qjf1orxBthaC161plr5KuPHo3CNm8DTHiLw/5Eq2b6TsNP0W0iJrUOFscY6Q450Hw==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-dispatch": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz",
+ "integrity": "sha512-5o9OIAdKkhN1QItV2oqaE5KMIiXAvDWBDPrD85e58Qlz1c1kI/J0NcqbEG88CoTwJrYe7ntUCVfeUl2UJKbWgA==",
+ "license": "MIT"
+ },
"node_modules/@types/d3-drag": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz",
@@ -1844,6 +1985,54 @@
"@types/d3-selection": "*"
}
},
+ "node_modules/@types/d3-dsv": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-3.0.7.tgz",
+ "integrity": "sha512-n6QBF9/+XASqcKK6waudgL0pf/S5XHPPI8APyMLLUHd8NqouBGLsU8MgtO7NINGtPBtk9Kko/W4ea0oAspwh9g==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-ease": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",
+ "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-fetch": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-3.0.7.tgz",
+ "integrity": "sha512-fTAfNmxSb9SOWNB9IoG5c8Hg6R+AzUHDRlsXsDZsNp6sxAEOP0tkP3gKkNSO/qmHPoBFTxNrjDprVHDQDvo5aA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-dsv": "*"
+ }
+ },
+ "node_modules/@types/d3-force": {
+ "version": "3.0.10",
+ "resolved": "https://registry.npmjs.org/@types/d3-force/-/d3-force-3.0.10.tgz",
+ "integrity": "sha512-ZYeSaCF3p73RdOKcjj+swRlZfnYpK1EbaDiYICEEp5Q6sUiqFaFQ9qgoshp5CzIyyb/yD09kD9o2zEltCexlgw==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-format": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-3.0.4.tgz",
+ "integrity": "sha512-fALi2aI6shfg7vM5KiR1wNJnZ7r6UuggVqtDA+xiEdPZQwy/trcQaHnwShLuLdta2rTymCNpxYTiMZX/e09F4g==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-geo": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-3.1.1.tgz",
+ "integrity": "sha512-65Emv9fQiQQqphLlRkuQ5ypPsOmWPhtBGCMv61JDPEPMvsx+gzhGf74yw1a78xFKPj6zw4AgQICJoQv0vK9M2w==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/geojson": "*"
+ }
+ },
+ "node_modules/@types/d3-hierarchy": {
+ "version": "3.1.7",
+ "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz",
+ "integrity": "sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg==",
+ "license": "MIT"
+ },
"node_modules/@types/d3-interpolate": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",
@@ -1853,12 +2042,78 @@
"@types/d3-color": "*"
}
},
+ "node_modules/@types/d3-path": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz",
+ "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-polygon": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-3.0.2.tgz",
+ "integrity": "sha512-ZuWOtMaHCkN9xoeEMr1ubW2nGWsp4nIql+OPQRstu4ypeZ+zk3YKqQT0CXVe/PYqrKpZAi+J9mTs05TKwjXSRA==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-quadtree": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz",
+ "integrity": "sha512-oUzyO1/Zm6rsxKRHA1vH0NEDG58HrT5icx/azi9MF1TWdtttWl0UIUsjEQBBh+SIkrpd21ZjEv7ptxWys1ncsg==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-random": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-random/-/d3-random-3.0.4.tgz",
+ "integrity": "sha512-UHYId5WTCx4L4YNel7NU00XUXXgvgpgZOvp10PuvsQENjMDXhh2RyFc0KBjO7B45ne4Ha1yVH7ii0vnzKkuzWA==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-scale": {
+ "version": "4.0.9",
+ "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz",
+ "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-time": "*"
+ }
+ },
+ "node_modules/@types/d3-scale-chromatic": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@types/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz",
+ "integrity": "sha512-iWMJgwkK7yTRmWqRB5plb1kadXyQ5Sj8V/zYlFGMUBbIPKQScw+Dku9cAAMgJG+z5GYDoMjWGLVOvjghDEFnKQ==",
+ "license": "MIT"
+ },
"node_modules/@types/d3-selection": {
"version": "3.0.12",
"resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.12.tgz",
"integrity": "sha512-Qe/KWYhEiIIxGs7HrAAjMfShxKldx19SJtr5zu53f3afPsdZNz7HHtdTLXo/kqeiWNXVycI24kSnfzBYkTzpgw==",
"license": "MIT"
},
+ "node_modules/@types/d3-shape": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.2.0.tgz",
+ "integrity": "sha512-kVd74ta9eof3eJOvbNd1vGKS/XERRyQbT26Og63hIsvDO84cjD5gEOhsXf26w3FSoNlPVz84DOFcKv/oou+fMw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-path": "*"
+ }
+ },
+ "node_modules/@types/d3-time": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz",
+ "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-time-format": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-4.0.3.tgz",
+ "integrity": "sha512-5xg9rC+wWL8kdDj153qZcsJ0FWiFt0J5RB6LYUNZjwSnesfblqrI/bJ1wBdJ8OQfncgbJG5+2F+qfqnqyzYxyg==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-timer": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",
+ "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==",
+ "license": "MIT"
+ },
"node_modules/@types/d3-transition": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz",
@@ -1892,6 +2147,12 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/geojson": {
+ "version": "7946.0.16",
+ "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
+ "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
+ "license": "MIT"
+ },
"node_modules/@types/node": {
"version": "22.20.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz",
@@ -1922,6 +2183,13 @@
"@types/react": "^19.3.0"
}
},
+ "node_modules/@types/trusted-types": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
+ "license": "MIT",
+ "optional": true
+ },
"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",
@@ -2262,6 +2530,16 @@
"node": ">=16.20.0"
}
},
+ "node_modules/@upsetjs/venn.js": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@upsetjs/venn.js/-/venn.js-2.0.0.tgz",
+ "integrity": "sha512-WbBhLrooyePuQ1VZxrJjtLvTc4NVfpOyKx0sKqioq9bX1C1m7Jgykkn8gLrtwumBioXIqam8DLxp88Adbue6Hw==",
+ "license": "MIT",
+ "optionalDependencies": {
+ "d3-selection": "^3.0.0",
+ "d3-transition": "^3.0.1"
+ }
+ },
"node_modules/@vitejs/plugin-react": {
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.1.2.tgz",
@@ -2578,6 +2856,15 @@
"node": "^14.18.0 || >=16.10.0"
}
},
+ "node_modules/cose-base": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz",
+ "integrity": "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==",
+ "license": "MIT",
+ "dependencies": {
+ "layout-base": "^1.0.0"
+ }
+ },
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -2585,6 +2872,144 @@
"devOptional": true,
"license": "MIT"
},
+ "node_modules/cytoscape": {
+ "version": "3.34.4",
+ "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.34.4.tgz",
+ "integrity": "sha512-msY99tMY8iWTg+sIPGfSqDcPNOt4xcj+v/K/7qUFaCUxxlqnMkUYLBjRUzn9W5CU/R2hrmtJa5+UtovrEM2ctg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10"
+ }
+ },
+ "node_modules/cytoscape-cose-bilkent": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz",
+ "integrity": "sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==",
+ "license": "MIT",
+ "dependencies": {
+ "cose-base": "^1.0.0"
+ },
+ "peerDependencies": {
+ "cytoscape": "^3.2.0"
+ }
+ },
+ "node_modules/cytoscape-fcose": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz",
+ "integrity": "sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==",
+ "license": "MIT",
+ "dependencies": {
+ "cose-base": "^2.2.0"
+ },
+ "peerDependencies": {
+ "cytoscape": "^3.2.0"
+ }
+ },
+ "node_modules/cytoscape-fcose/node_modules/cose-base": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz",
+ "integrity": "sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==",
+ "license": "MIT",
+ "dependencies": {
+ "layout-base": "^2.0.0"
+ }
+ },
+ "node_modules/cytoscape-fcose/node_modules/layout-base": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz",
+ "integrity": "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==",
+ "license": "MIT"
+ },
+ "node_modules/d3": {
+ "version": "7.9.0",
+ "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz",
+ "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "3",
+ "d3-axis": "3",
+ "d3-brush": "3",
+ "d3-chord": "3",
+ "d3-color": "3",
+ "d3-contour": "4",
+ "d3-delaunay": "6",
+ "d3-dispatch": "3",
+ "d3-drag": "3",
+ "d3-dsv": "3",
+ "d3-ease": "3",
+ "d3-fetch": "3",
+ "d3-force": "3",
+ "d3-format": "3",
+ "d3-geo": "3",
+ "d3-hierarchy": "3",
+ "d3-interpolate": "3",
+ "d3-path": "3",
+ "d3-polygon": "3",
+ "d3-quadtree": "3",
+ "d3-random": "3",
+ "d3-scale": "4",
+ "d3-scale-chromatic": "3",
+ "d3-selection": "3",
+ "d3-shape": "3",
+ "d3-time": "3",
+ "d3-time-format": "4",
+ "d3-timer": "3",
+ "d3-transition": "3",
+ "d3-zoom": "3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-array": {
+ "version": "3.2.4",
+ "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
+ "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
+ "license": "ISC",
+ "dependencies": {
+ "internmap": "1 - 2"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-axis": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz",
+ "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-brush": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz",
+ "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-dispatch": "1 - 3",
+ "d3-drag": "2 - 3",
+ "d3-interpolate": "1 - 3",
+ "d3-selection": "3",
+ "d3-transition": "3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-chord": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz",
+ "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-path": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/d3-color": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
@@ -2594,6 +3019,30 @@
"node": ">=12"
}
},
+ "node_modules/d3-contour": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz",
+ "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "^3.2.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-delaunay": {
+ "version": "6.0.4",
+ "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz",
+ "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==",
+ "license": "ISC",
+ "dependencies": {
+ "delaunator": "5"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/d3-dispatch": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz",
@@ -2616,6 +3065,52 @@
"node": ">=12"
}
},
+ "node_modules/d3-dsv": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz",
+ "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==",
+ "license": "ISC",
+ "dependencies": {
+ "commander": "7",
+ "iconv-lite": "0.6",
+ "rw": "1"
+ },
+ "bin": {
+ "csv2json": "bin/dsv2json.js",
+ "csv2tsv": "bin/dsv2dsv.js",
+ "dsv2dsv": "bin/dsv2dsv.js",
+ "dsv2json": "bin/dsv2json.js",
+ "json2csv": "bin/json2dsv.js",
+ "json2dsv": "bin/json2dsv.js",
+ "json2tsv": "bin/json2dsv.js",
+ "tsv2csv": "bin/dsv2dsv.js",
+ "tsv2json": "bin/dsv2json.js"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-dsv/node_modules/commander": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
+ "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/d3-dsv/node_modules/iconv-lite": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
+ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
+ "license": "MIT",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/d3-ease": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
@@ -2625,6 +3120,62 @@
"node": ">=12"
}
},
+ "node_modules/d3-fetch": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz",
+ "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-dsv": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-force": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz",
+ "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-dispatch": "1 - 3",
+ "d3-quadtree": "1 - 3",
+ "d3-timer": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-format": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz",
+ "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-geo": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz",
+ "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "2.5.0 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-hierarchy": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz",
+ "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/d3-interpolate": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
@@ -2637,6 +3188,111 @@
"node": ">=12"
}
},
+ "node_modules/d3-path": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",
+ "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-polygon": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz",
+ "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-quadtree": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz",
+ "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-random": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz",
+ "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-sankey": {
+ "version": "0.12.3",
+ "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz",
+ "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "d3-array": "1 - 2",
+ "d3-shape": "^1.2.0"
+ }
+ },
+ "node_modules/d3-sankey/node_modules/d3-array": {
+ "version": "2.12.1",
+ "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz",
+ "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "internmap": "^1.0.0"
+ }
+ },
+ "node_modules/d3-sankey/node_modules/d3-path": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz",
+ "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/d3-sankey/node_modules/d3-shape": {
+ "version": "1.3.7",
+ "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz",
+ "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "d3-path": "1"
+ }
+ },
+ "node_modules/d3-sankey/node_modules/internmap": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz",
+ "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==",
+ "license": "ISC"
+ },
+ "node_modules/d3-scale": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",
+ "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "2.10.0 - 3",
+ "d3-format": "1 - 3",
+ "d3-interpolate": "1.2.0 - 3",
+ "d3-time": "2.1.1 - 3",
+ "d3-time-format": "2 - 4"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-scale-chromatic": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz",
+ "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-color": "1 - 3",
+ "d3-interpolate": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/d3-selection": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
@@ -2646,6 +3302,42 @@
"node": ">=12"
}
},
+ "node_modules/d3-shape": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",
+ "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-path": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",
+ "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "2 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time-format": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz",
+ "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-time": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/d3-timer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
@@ -2690,6 +3382,31 @@
"node": ">=12"
}
},
+ "node_modules/dagre-d3-es": {
+ "version": "7.0.14",
+ "resolved": "https://registry.npmjs.org/dagre-d3-es/-/dagre-d3-es-7.0.14.tgz",
+ "integrity": "sha512-P4rFMVq9ESWqmOgK+dlXvOtLwYg0i7u0HBGJER0LZDJT2VHIPAMZ/riPxqJceWMStH5+E61QxFra9kIS3AqdMg==",
+ "license": "MIT",
+ "dependencies": {
+ "d3": "^7.9.0",
+ "lodash-es": "^4.17.21"
+ }
+ },
+ "node_modules/dayjs": {
+ "version": "1.11.23",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz",
+ "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==",
+ "license": "MIT"
+ },
+ "node_modules/delaunator": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.1.0.tgz",
+ "integrity": "sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==",
+ "license": "ISC",
+ "dependencies": {
+ "robust-predicates": "^3.0.2"
+ }
+ },
"node_modules/detect-libc": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
@@ -2700,6 +3417,15 @@
"node": ">=8"
}
},
+ "node_modules/dompurify": {
+ "version": "3.4.17",
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz",
+ "integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==",
+ "license": "(MPL-2.0 OR Apache-2.0)",
+ "optionalDependencies": {
+ "@types/trusted-types": "^2.0.7"
+ }
+ },
"node_modules/es-module-lexer": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz",
@@ -2707,6 +3433,18 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/es-toolkit": {
+ "version": "1.53.1",
+ "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.53.1.tgz",
+ "integrity": "sha512-VhMc6IXmexu8iYFfL2aaAww6IvJTdHlqBLruLoEUs33YD4IcP5DdZcLOybMsMmmLsiy1c8PsiLsrM0DdIuuRUA==",
+ "license": "MIT",
+ "workspaces": [
+ "docs",
+ "benchmarks",
+ "tests/types",
+ "tests/browser-compat"
+ ]
+ },
"node_modules/esbuild": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
@@ -2796,6 +3534,15 @@
"fast-string-width": "^3.0.2"
}
},
+ "node_modules/fastdom": {
+ "version": "1.0.12",
+ "resolved": "https://registry.npmjs.org/fastdom/-/fastdom-1.0.12.tgz",
+ "integrity": "sha512-LB+xjSTEbjHE1cWsxu+tN2Xqr1kpi+V9aADI7sVM5ZMaXyYGPHULQMzpJMYqOTULK/73pUkWVzzObFRBkPr+hg==",
+ "license": "MIT",
+ "dependencies": {
+ "strictdom": "^1.0.1"
+ }
+ },
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
@@ -2841,6 +3588,12 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
+ "node_modules/hachure-fill": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz",
+ "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==",
+ "license": "MIT"
+ },
"node_modules/iconv-lite": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
@@ -2858,6 +3611,25 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/import-meta-resolve": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz",
+ "integrity": "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
+ "node_modules/internmap": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
+ "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/joycon": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
@@ -2875,6 +3647,42 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/katex": {
+ "version": "0.16.47",
+ "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.47.tgz",
+ "integrity": "sha512-Eeo8Ys1doU1z+x8AZsPpQu+p/QcZBI5PeOo7QGQdy2x2m0MU/hYagBbGOmXwr5KVbEfVuWv9LpnQWeehogurjg==",
+ "funding": [
+ "https://opencollective.com/katex",
+ "https://github.com/sponsors/katex"
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "commander": "^8.3.0"
+ },
+ "bin": {
+ "katex": "cli.js"
+ }
+ },
+ "node_modules/katex/node_modules/commander": {
+ "version": "8.3.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
+ "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
+ "node_modules/khroma": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz",
+ "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw=="
+ },
+ "node_modules/layout-base": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz",
+ "integrity": "sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==",
+ "license": "MIT"
+ },
"node_modules/lightningcss": {
"version": "1.33.0",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
@@ -3178,6 +3986,12 @@
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
+ "node_modules/lodash-es": {
+ "version": "4.18.1",
+ "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz",
+ "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==",
+ "license": "MIT"
+ },
"node_modules/magic-string": {
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
@@ -3200,6 +4014,48 @@
"source-map-js": "^1.2.1"
}
},
+ "node_modules/marked": {
+ "version": "16.4.2",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.2.tgz",
+ "integrity": "sha512-TI3V8YYWvkVf3KJe1dRkpnjs68JUPyEa5vjKrp1XEEJUAOaQc+Qj+L1qWbPd0SJuAdQkFU0h73sXXqwDYxsiDA==",
+ "license": "MIT",
+ "bin": {
+ "marked": "bin/marked.js"
+ },
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/mermaid": {
+ "version": "11.17.2",
+ "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.17.2.tgz",
+ "integrity": "sha512-V6K3C8EBdEsPFZXSKMJe6ppQOENxuHARr9GvHX4hh47lAbhMRD9qf4oEK7LoaRQxULMa80/qt5gHO73aCleBBg==",
+ "license": "MIT",
+ "dependencies": {
+ "@braintree/sanitize-url": "^7.1.2",
+ "@iconify/utils": "^3.0.2",
+ "@mermaid-js/parser": "^1.2.1",
+ "@types/d3": "^7.4.3",
+ "@upsetjs/venn.js": "^2.0.0",
+ "cytoscape": "^3.34.0",
+ "cytoscape-cose-bilkent": "^4.1.0",
+ "cytoscape-fcose": "^2.2.0",
+ "d3": "^7.9.0",
+ "d3-sankey": "^0.12.3",
+ "dagre-d3-es": "7.0.14",
+ "dayjs": "^1.11.21",
+ "dompurify": "^3.3.3",
+ "es-toolkit": "^1.45.1",
+ "fastdom": "1.0.12",
+ "katex": "^0.16.47",
+ "khroma": "^2.1.0",
+ "marked": "^16.3.0",
+ "roughjs": "^4.6.6",
+ "stylis": "^4.3.6",
+ "ts-dedent": "^2.2.0",
+ "uuid": "^11.1.0 || ^12 || ^13 || ^14.0.0"
+ }
+ },
"node_modules/mlly": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.2.tgz",
@@ -3278,6 +4134,18 @@
"node": ">=12.20.0"
}
},
+ "node_modules/package-manager-detector": {
+ "version": "1.9.0",
+ "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.9.0.tgz",
+ "integrity": "sha512-zAMfbta9nPA8AKkA4WdmNAT8R8s6Dk0/xwPsqNnRidMFcLo1YkLuPDTgs2f64XdzS8vbLNnoJ+uUIkgbz7oRHA==",
+ "license": "MIT"
+ },
+ "node_modules/path-data-parser": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz",
+ "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==",
+ "license": "MIT"
+ },
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
@@ -3327,6 +4195,22 @@
"pathe": "^2.0.1"
}
},
+ "node_modules/points-on-curve": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz",
+ "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==",
+ "license": "MIT"
+ },
+ "node_modules/points-on-path": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz",
+ "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==",
+ "license": "MIT",
+ "dependencies": {
+ "path-data-parser": "0.1.0",
+ "points-on-curve": "0.2.0"
+ }
+ },
"node_modules/postcss": {
"version": "8.5.31",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz",
@@ -3444,6 +4328,12 @@
"node": ">=8"
}
},
+ "node_modules/robust-predicates": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz",
+ "integrity": "sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==",
+ "license": "Unlicense"
+ },
"node_modules/rolldown": {
"version": "1.2.15",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.15.tgz",
@@ -3524,11 +4414,28 @@
"fsevents": "~2.3.2"
}
},
+ "node_modules/roughjs": {
+ "version": "4.6.6",
+ "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz",
+ "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==",
+ "license": "MIT",
+ "dependencies": {
+ "hachure-fill": "^0.5.2",
+ "path-data-parser": "^0.1.0",
+ "points-on-curve": "^0.2.0",
+ "points-on-path": "^0.2.1"
+ }
+ },
+ "node_modules/rw": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz",
+ "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==",
+ "license": "BSD-3-Clause"
+ },
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
- "dev": true,
"license": "MIT"
},
"node_modules/scheduler": {
@@ -3567,6 +4474,18 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/strictdom": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/strictdom/-/strictdom-1.0.1.tgz",
+ "integrity": "sha512-cEmp9QeXXRmjj/rVp9oyiqcvyocWab/HaoN4+bwFeZ7QzykJD6L3yD4v12K1x0tHpqRqVpJevN3gW7kyM39Bqg==",
+ "license": "MIT"
+ },
+ "node_modules/stylis": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.4.0.tgz",
+ "integrity": "sha512-5Z9ZpRzfuH6l/UAvCPAPUo3665Nk2wLaZU3x+TLHKVzIz33+sbJqbtrYoC3KD4/uVOr2Zp+L0LySezP9OHV9yA==",
+ "license": "MIT"
+ },
"node_modules/sucrase": {
"version": "3.35.1",
"resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz",
@@ -3631,7 +4550,6 @@
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz",
"integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
@@ -3674,6 +4592,15 @@
"tree-kill": "cli.js"
}
},
+ "node_modules/ts-dedent": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.3.0.tgz",
+ "integrity": "sha512-JfJeIHke7y2egdGGgRAvpCwYFUsHlM2gPcrVOxFkznt/4uzQ7HFmvE63iFHVLBJNDuyDOQgijDK/tXH/f6Msjg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.10"
+ }
+ },
"node_modules/ts-interface-checker": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
@@ -3792,6 +4719,19 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
+ "node_modules/uuid": {
+ "version": "14.0.3",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.3.tgz",
+ "integrity": "sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==",
+ "funding": [
+ "https://github.com/sponsors/broofa",
+ "https://github.com/sponsors/ctavan"
+ ],
+ "license": "MIT",
+ "bin": {
+ "uuid": "dist-node/bin/uuid"
+ }
+ },
"node_modules/vite": {
"version": "8.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz",
@@ -4038,7 +4978,7 @@
},
"packages/cli": {
"name": "@cogit/cli",
- "version": "0.17.1",
+ "version": "0.24.0",
"license": "MIT",
"bin": {
"cogit": "dist/cli.js"
@@ -4067,6 +5007,7 @@
"version": "0.0.0",
"dependencies": {
"@xyflow/react": "^12.12.0",
+ "mermaid": "^11.17.2",
"react": "^19.3.1",
"react-dom": "^19.3.1"
},
diff --git a/packages/cli/skills/record/SKILL.md b/packages/cli/skills/record/SKILL.md
index 464b5d7..bc39975 100644
--- a/packages/cli/skills/record/SKILL.md
+++ b/packages/cli/skills/record/SKILL.md
@@ -78,6 +78,27 @@ Every message grows from an earlier one; a thread that starts something new is a
- Hints, not rules: `gapMinutes`, `resumed`, `commitBetween` (a real commit landed in this
repo between them), `lastMessages`, and for a first message `candidates`/`continuesHint`.
+## Shape
+
+A message that landed commits gets a `shape`: a small representation of what the change does,
+between its Intent (the decision and reason above) and its Code (the diff). Add it on that
+message's node, with the node's commit hashes:
+
+```json
+"shape": { "tools": [{ "kind": "pseudo", "text": "1. ...\n2. ..." }], "commits": ["abc1234"] }
+```
+
+Two tools:
+
+- `pseudo`: numbered plain-language steps of the new logic, naming the functions and files.
+- `mermaid`: a Mermaid `flowchart TD` (or `LR`) of the new path between files or functions,
+ at most 15 nodes. Quote labels that hold spaces or punctuation.
+
+Pick one, both, or none (`{ "tools": [] }` means nothing worth showing). Skip messages whose
+commits are only release/version bumps, lockfiles or CHANGELOG, or change fewer than 5 lines
+in total. Write it in the conversation's language; the CLI validates each output and keeps an
+invalid diagram as text.
+
## Branch summary
A branch starts at a root or where a message gets a second child. Its first message carries a
diff --git a/packages/cli/src/commands/doctor.ts b/packages/cli/src/commands/doctor.ts
index c6957b3..4c360bd 100644
--- a/packages/cli/src/commands/doctor.ts
+++ b/packages/cli/src/commands/doctor.ts
@@ -439,7 +439,7 @@ async function hookProblems(ctx: DoctorContext): Promise<string[]> {
const dir = await gitHooksDir(gitRoot);
if (dir === undefined) return ["the git hooks directory could not be found"];
const problems: string[] = [];
- for (const event of ["prepare-commit-msg", "pre-commit"] as const) {
+ for (const event of ["prepare-commit-msg", "pre-commit", "post-commit"] as const) {
const text = await readFile(join(dir, event), "utf8").catch(() => undefined);
if (text === undefined || !text.includes(BLOCK_START)) {
problems.push(`the ${event} hook is missing`);
diff --git a/packages/cli/src/commands/session.ts b/packages/cli/src/commands/session.ts
index 0eae3b6..b52d4cf 100644
--- a/packages/cli/src/commands/session.ts
+++ b/packages/cli/src/commands/session.ts
@@ -22,6 +22,7 @@ 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 { stampShape } from "../shape.js";
import {
appendEvents,
applyEvents,
@@ -92,13 +93,18 @@ export async function sessionWrite(
}
const { value: redacted, count } = redactDeep(parsed.data);
+ // Story 13.6: shapes are written only while the setting is on; the CLI owns
+ // the stamp and each tool's validation, so every writer's answer is stored
+ // the same way.
+ const config = await loadConfig(io.env);
+ const stamped = stampShapes(redacted, opts.by ?? "agent", io.now(), config.shapes, io);
// Both ids work: the agent may send the stable `h…` id, or the `m1` label it
// reads in `session show`; the CLI maps the label to the stable id.
const messages = await readSessionMessages(root, redacted.sessionId, io.env);
// The side model runs on this same transcript, so a message id it does not
// know is made up; its node is dropped instead of stored beside the real one.
const input = withForkParent(
- nameMessages(redacted, messages, io, opts.by === "side"),
+ nameMessages(stamped, messages, io, opts.by === "side"),
messages,
await forkParent(redacted.sessionId, io.env),
);
@@ -163,6 +169,41 @@ export async function sessionWrite(
}
}
+/**
+ * Stamps every Shape a writer sent (Story 13.6): who wrote it, when, and what
+ * the registry thinks of each tool's output. A refused output keeps its text
+ * and only loses its `valid` mark, so nothing is dropped silently. With shapes
+ * off, no Shape is written at all.
+ */
+function stampShapes(
+ input: SessionInput,
+ by: "agent" | "side",
+ at: string,
+ enabled: boolean,
+ io: Io,
+): SessionInput {
+ if (!input.nodes?.some((node) => node.shape !== undefined)) return input;
+ let warnedOff = false;
+ const nodes = input.nodes.map((node) => {
+ if (node.shape === undefined) return node;
+ if (!enabled) {
+ if (!warnedOff) {
+ io.warn("shapes are off; the shape was not recorded");
+ warnedOff = true;
+ }
+ const { shape: _dropped, ...rest } = node;
+ return rest;
+ }
+ const shape = stampShape(node.shape, by, at);
+ for (const tool of shape.tools) {
+ if (tool.valid === false)
+ io.warn(`shape ${tool.kind}: the output does not match the tool's format; kept as text`);
+ }
+ return { ...node, shape };
+ });
+ return { ...input, nodes };
+}
+
/**
* Turns the agent's message ids into stable ids and takes each message's time
* from the transcript, so the map's order is the order the user wrote them,
diff --git a/packages/cli/src/commands/shape.ts b/packages/cli/src/commands/shape.ts
new file mode 100644
index 0000000..849af31
--- /dev/null
+++ b/packages/cli/src/commands/shape.ts
@@ -0,0 +1,144 @@
+import { findGitRoot, readCommitChanges, readCommitPatches, readCommitSubjects } from "../git.js";
+import { CliError, type Io } from "../io.js";
+import type { Config } from "../schema/config.js";
+import type { LineageNode } from "../schema/session.js";
+import { readSessionHead } from "../session-git.js";
+import {
+ parseShapeAnswer,
+ SHAPE_DIFF_LIMIT,
+ type ShapeCommitInfo,
+ shapePrompt,
+ shapeWanted,
+} from "../shape.js";
+import { LockBusyError, withLock } from "../store/lock.js";
+import { projectPaths } from "../store/paths.js";
+import { resolveProjectRoot } from "../store/root.js";
+import { loadConfig, loadProject, loadSession } from "../store/stores.js";
+import { resultText, runClaude } from "./backfill.js";
+import { sessionWrite } from "./session.js";
+
+/**
+ * `cogit shape <session-id>` (Story 13.6): the side half of Shapes. The git
+ * post-commit hook starts this detached, behind the session's shape lock, so a
+ * commit is never held up. It writes one Shape for the newest recorded message
+ * that landed commits and does not have one yet (or has landed more since).
+ *
+ * The main agent writes its Shape in the record skill; this command is the
+ * mixed/side recorder's path, so it is a no-op in `agent` mode.
+ */
+
+/** A message earns a Shape only when its commits survive the skip rules. */
+export function needsShape(node: LineageNode): boolean {
+ if (node.kind !== "message" || node.commits === undefined || node.commits.length === 0)
+ return false;
+ if (node.shape === undefined) return true;
+ // A message that landed more commits after its Shape was written gets a new
+ // one, so the Shape covers everything the message landed.
+ return node.shape.commits.length < node.commits.length;
+}
+
+/** The newest message waiting for a Shape, by its own time then its position. */
+export function nextShapeNode(nodes: readonly LineageNode[]): LineageNode | undefined {
+ let best: LineageNode | undefined;
+ let bestAt = Number.NEGATIVE_INFINITY;
+ nodes.forEach((node, index) => {
+ if (!needsShape(node)) return;
+ const parsed = Date.parse(node.at ?? node.addedAt ?? "");
+ const at = Number.isNaN(parsed) ? index : parsed;
+ if (best === undefined || at >= bestAt) {
+ best = node;
+ bestAt = at;
+ }
+ });
+ return best;
+}
+
+export async function shapeMessage(
+ dir: string,
+ sessionId: string | undefined,
+ io: Io,
+): Promise<void> {
+ const { root } = await resolveProjectRoot(dir);
+ const project = await loadProject(root);
+ if (!project.found) throw new CliError(`${root} is not initialized; run \`cogit init\` first`);
+ if (!project.ok) throw new CliError(project.error);
+
+ const config = await loadConfig(io.env);
+ if (!config.shapes) {
+ io.out("shapes are off");
+ return;
+ }
+ // The main agent writes its own Shape in the record skill; this pass is for
+ // the side model's modes.
+ if (config.recorder === "agent") return;
+
+ const id = sessionId ?? (await readSessionHead(root))?.sessionId;
+ if (id === undefined) {
+ io.out("no session to shape");
+ return;
+ }
+ try {
+ await withLock(projectPaths(root).lock(`shape-${id}`), () => runShape(root, id, config, io), {
+ timeoutMs: 0,
+ });
+ } catch (err) {
+ if (!(err instanceof LockBusyError)) throw err;
+ io.out(`a shape for ${id} is already being written`);
+ }
+}
+
+async function runShape(root: string, sessionId: string, config: Config, io: Io): Promise<void> {
+ const loaded = await loadSession(root, sessionId);
+ if (!loaded.found || !loaded.ok) return;
+ const node = nextShapeNode(loaded.data.nodes);
+ if (node === undefined || node.commits === undefined) return;
+
+ const gitRoot = await findGitRoot(root);
+ if (gitRoot === undefined) return;
+ const [changes, subjects] = await Promise.all([
+ readCommitChanges(gitRoot, node.commits),
+ readCommitSubjects(gitRoot, node.commits),
+ ]);
+ const commits: ShapeCommitInfo[] = node.commits.flatMap((hash) => {
+ const change = changes.get(hash);
+ if (change === undefined) return [];
+ return [
+ {
+ hash: change.full,
+ subject: subjects.get(hash),
+ added: change.added,
+ removed: change.removed,
+ files: change.files,
+ },
+ ];
+ });
+ if (commits.length === 0) return;
+ const verdict = shapeWanted(commits);
+ if (!verdict.wanted) {
+ io.out(`no shape for ${node.id}: ${verdict.reason}`);
+ return;
+ }
+
+ const patches = await readCommitPatches(gitRoot, node.commits, SHAPE_DIFF_LIMIT);
+ const prompt = shapePrompt({
+ node,
+ commits,
+ diff: patches.diff,
+ diffTruncated: patches.truncated,
+ language: config.language,
+ });
+ const stdout = await runClaude(prompt, config.sideModel, io.env);
+ const answer = parseShapeAnswer(resultText(stdout)) ?? { tools: [], commits: [] };
+ const payload = {
+ sessionId,
+ nodes: [
+ {
+ id: node.id,
+ kind: "message",
+ title: node.title,
+ shape: { tools: answer.tools, commits: node.commits },
+ },
+ ],
+ };
+ await sessionWrite({ dir: root, by: "side" }, io, async () => JSON.stringify(payload));
+}
diff --git a/packages/cli/src/git-hooks.ts b/packages/cli/src/git-hooks.ts
index 9ed9097..2bfd46f 100644
--- a/packages/cli/src/git-hooks.ts
+++ b/packages/cli/src/git-hooks.ts
@@ -2,8 +2,11 @@ import { realpathSync } from "node:fs";
import { chmod, mkdir, readFile, rm, stat } from "node:fs/promises";
import { join } from "node:path";
import { findGitRoot, gitHooksDir } from "./git.js";
-import { stageSessionFiles } from "./session-git.js";
+import { spawnDetachedProcess } from "./hooks/run.js";
+import { readSessionHead, stageSessionFiles } from "./session-git.js";
import { atomicWrite } from "./store/fs.js";
+import { captureDisabled, projectPaths } from "./store/paths.js";
+import { loadConfig } from "./store/stores.js";
import { addThoughtTrailer } from "./thought.js";
/**
@@ -109,12 +112,13 @@ export async function installGitHook(root: string, event: string): Promise<boole
}
/**
- * The git-side events cogit answers (Stories 9.3, 9.4). A git hook's stdin is
- * not the Claude Code hook JSON, so these never go through `runHook`.
+ * The git-side events cogit answers (Stories 9.3, 9.4, 13.6). A git hook's stdin
+ * is not the Claude Code hook JSON, so these never go through `runHook`.
* `pre-commit` carries the session record with a code commit; `prepare-commit-msg`
- * adds the `Thought:` trailer that names the message behind it.
+ * adds the `Thought:` trailer that names the message behind it; `post-commit`
+ * queues the Shape of a message that landed commits, outside the commit.
*/
-export const GIT_HOOK_EVENTS = ["pre-commit", "prepare-commit-msg"] as const;
+export const GIT_HOOK_EVENTS = ["pre-commit", "prepare-commit-msg", "post-commit"] as const;
export type GitHookEvent = (typeof GIT_HOOK_EVENTS)[number];
export function isGitHookEvent(event: string): event is GitHookEvent {
@@ -171,6 +175,28 @@ export async function uninstallGitHooks(root: string): Promise<GitHookEvent[]> {
return removed;
}
+/**
+ * Queues the Shape of the session that just committed (Story 13.6). Detached
+ * and silent: a commit never waits for a side-model run, and a failure lands in
+ * the detached log like the session-end pass. In `agent` mode the record skill
+ * writes the Shape itself, so there is nothing to queue.
+ */
+async function queueShape(dir: string, env: NodeJS.ProcessEnv): Promise<void> {
+ if (captureDisabled(env)) return;
+ const config = await loadConfig(env).catch(() => undefined);
+ if (config === undefined || !config.shapes || config.recorder === "agent") return;
+ const head = await readSessionHead(dir);
+ if (head === undefined) return;
+ const cli = currentCliPath();
+ if (cli === undefined) return;
+ spawnDetachedProcess(
+ cli,
+ ["shape", head.sessionId, "-C", dir],
+ env,
+ projectPaths(dir).detachedLog,
+ );
+}
+
/**
* Runs one git hook. A git hook that fails would block the user's commit, so the
* CLI calls this inside its own silence: nothing here throws or prints. `args`
@@ -188,6 +214,10 @@ export async function runGitHook(
await stageSessionFiles(dir, env);
return;
}
+ if (event === "post-commit") {
+ await queueShape(dir, env);
+ return;
+ }
const [messageFile, source] = args;
if (messageFile === undefined || messageFile === "") return;
await addThoughtTrailer({
diff --git a/packages/cli/src/git.ts b/packages/cli/src/git.ts
index 7f4db69..ff32897 100644
--- a/packages/cli/src/git.ts
+++ b/packages/cli/src/git.ts
@@ -378,8 +378,73 @@ export async function readCommitChanges(
return out;
}
-/** A commit's short hash, computed when git printed only the full one. */
-function commitShort(commit: CommitFiles): string {
+/**
+ * The patches of the given commits, concatenated and cut at `limit` characters
+ * (Story 13.6: the side writer reads enough of the change to name its path). A
+ * commit git no longer knows is skipped; `truncated` says the cut happened, so
+ * the prompt can say so instead of pretending the diff is complete.
+ */
+export async function readCommitPatches(
+ root: string,
+ hashes: Iterable<string>,
+ limit: number,
+): Promise<{ diff: string; truncated: boolean }> {
+ const wanted = [...new Set(hashes)];
+ if (wanted.length === 0) return { diff: "", truncated: false };
+ const chunks: string[] = [];
+ let size = 0;
+ let truncated = false;
+ try {
+ const { stdout } = await exec("git", [
+ "-C",
+ root,
+ "log",
+ "--no-walk=unsorted",
+ "--format=commit %h %s",
+ "--patch",
+ "--no-color",
+ "--unified=3",
+ ...wanted,
+ ]);
+ const text = stdout.trim();
+ if (text.length > limit) {
+ return { diff: text.slice(0, limit), truncated: true };
+ }
+ return { diff: text, truncated: false };
+ } catch {
+ // One hash git no longer knows makes the batch fail; ask for each alone.
+ }
+ for (const hash of wanted) {
+ if (size >= limit) {
+ truncated = true;
+ break;
+ }
+ try {
+ const { stdout } = await exec("git", [
+ "-C",
+ root,
+ "show",
+ "--format=commit %h %s",
+ "--patch",
+ "--no-color",
+ "--unified=3",
+ hash,
+ ]);
+ const remaining = limit - size;
+ const text = stdout.trim();
+ chunks.push(text.length > remaining ? text.slice(0, remaining) : text);
+ if (text.length > remaining) truncated = true;
+ size += Math.min(text.length, remaining);
+ } catch {
+ // gone from this repository (rebased away, or another checkout)
+ }
+ }
+ return { diff: chunks.join("\n\n"), truncated };
+}
+
+/** A commit's short hash, computed when git printed only the full one. */ function commitShort(
+ commit: CommitFiles,
+): string {
return commit.short === "" ? commit.full.slice(0, 7) : commit.short;
}
diff --git a/packages/cli/src/program.ts b/packages/cli/src/program.ts
index 6121f77..a9af854 100644
--- a/packages/cli/src/program.ts
+++ b/packages/cli/src/program.ts
@@ -21,6 +21,7 @@ import { openPanel, openProject } from "./commands/open.js";
import { pr } from "./commands/pr.js";
import { search } from "./commands/search.js";
import { readStdin, sessionShow, sessionWrite } from "./commands/session.js";
+import { shapeMessage } from "./commands/shape.js";
import { why } from "./commands/why.js";
import { isGitHookEvent, runGitHook } from "./git-hooks.js";
import { runHook } from "./hooks/run.js";
@@ -415,6 +416,19 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =
),
);
+ program
+ .command("shape")
+ .description("write the Shape of the newest message that landed commits (side model)")
+ .helpGroup("Agent:")
+ .argument("[session-id]", "session id; defaults to the session in .cogit/HEAD")
+ .option("-C, --dir <dir>", "project directory", ".")
+ .addHelpText("after", examples("cogit shape", "cogit shape 9c32ab18"))
+ .action(
+ run(async (sessionId: string | undefined, opts: { dir: string }) =>
+ shapeMessage(opts.dir, sessionId, makeIo(false)),
+ ),
+ );
+
program
.command("backfill")
.description("record the user messages a session has not summarized yet")
diff --git a/packages/cli/src/schema/config.ts b/packages/cli/src/schema/config.ts
index c62398d..e241ffe 100644
--- a/packages/cli/src/schema/config.ts
+++ b/packages/cli/src/schema/config.ts
@@ -35,6 +35,12 @@ export const Config = z.object({
* summary is the outer layer and the drill-down already shows the reply.
*/
messageSummaries: z.boolean().default(false),
+ /**
+ * Whether a message that landed commits gets a Shape (Story 13.6): a small
+ * plain-language or diagram view of what the change does, written by whoever
+ * records. Off writes nothing; the map then says so.
+ */
+ shapes: z.boolean().default(true),
/**
* Whether SessionStart hands the agent the lineage of the previous session and
* how to read the record (`log` / `show`). On by default; costs only tokens.
diff --git a/packages/cli/src/schema/merge.ts b/packages/cli/src/schema/merge.ts
index 5022239..7541364 100644
--- a/packages/cli/src/schema/merge.ts
+++ b/packages/cli/src/schema/merge.ts
@@ -52,6 +52,7 @@ const SIDE_FIELDS = [
"branch",
"work",
"agentDecisions",
+ "shape",
] as const;
type SideField = (typeof SIDE_FIELDS)[number];
@@ -292,6 +293,7 @@ const NODE_FIELDS = [
"branch",
"work",
"agentDecisions",
+ "shape",
] as const;
/** A resent node that changed nothing keeps its touch time. */
diff --git a/packages/cli/src/schema/session.ts b/packages/cli/src/schema/session.ts
index 786a8a1..61d3f15 100644
--- a/packages/cli/src/schema/session.ts
+++ b/packages/cli/src/schema/session.ts
@@ -30,6 +30,47 @@ export const AgentDecision = z.object({
/** Message node ids follow the order of the user's messages in the transcript. */
export const MESSAGE_ID = /^m[1-9][0-9]*$/;
+/**
+ * How a Shape shows what a change does (Story 13.6). Two tools today; the
+ * registry in `shape.ts` says when each fits and validates its output.
+ */
+export const ShapeKind = z.enum(["pseudo", "mermaid"]);
+export type ShapeKind = z.infer<typeof ShapeKind>;
+
+/**
+ * One tool's answer: plain-language pseudo-code, or Mermaid source. `valid` is
+ * set by the CLI, never by a writer: an output the registry refused keeps its
+ * text (so nothing is lost) and the map shows it as text instead of drawing it.
+ */
+export const ShapeTool = z.object({
+ kind: ShapeKind,
+ text: z.string().min(1).max(4000),
+ valid: z.boolean().optional(),
+});
+
+/**
+ * What a message's change does, between its Intent (the record) and its Code
+ * (the diff). One per message, covering every commit the message landed. An
+ * empty `tools` list is a real answer: the writer saw nothing worth showing.
+ */
+export const Shape = z.object({
+ tools: z.array(ShapeTool).max(3).default([]),
+ /** Who wrote it: the main agent or the side model (the CLI stamps it). */
+ by: z.enum(["agent", "side"]).optional(),
+ /** The message's commits this Shape was written from. */
+ commits: z
+ .array(z.string().regex(/^[0-9a-f]{7,40}$/, "a commit hash"))
+ .max(20)
+ .default([]),
+ /** When it was written (the CLI stamps it). */
+ at: IsoDate.optional(),
+});
+
+/** What a writer sends for a Shape: the tools' answers and the commits they cover. */
+export const ShapeInput = Shape.omit({ by: true, at: true }).extend({
+ tools: z.array(ShapeTool.omit({ valid: true })).max(3),
+});
+
/**
* The summary a branch carries on its first message: what the thread asked,
* what came of it and what is still open.
@@ -73,6 +114,11 @@ 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(),
+ /**
+ * For a message that landed commits: a small representation of what the
+ * change does (Story 13.6). Missing means nobody wrote one yet.
+ */
+ shape: Shape.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
@@ -153,6 +199,9 @@ export const LineageNodeInput = LineageNode.omit({
by: true,
}).extend({
parent: MessageRef.nullable().optional(),
+ // The CLI stamps `by`, `at` and each tool's `valid`; a writer sends only the
+ // answers and the commits they cover.
+ shape: ShapeInput.optional(),
});
/**
@@ -173,6 +222,9 @@ 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 Shape = z.infer<typeof Shape>;
+export type ShapeTool = z.infer<typeof ShapeTool>;
+export type ShapeInput = z.infer<typeof ShapeInput>;
export type Status = z.infer<typeof Status>;
export type Session = z.infer<typeof Session>;
export type SessionInput = z.infer<typeof SessionInput>;
diff --git a/packages/cli/src/shape.ts b/packages/cli/src/shape.ts
new file mode 100644
index 0000000..e08235a
--- /dev/null
+++ b/packages/cli/src/shape.ts
@@ -0,0 +1,265 @@
+import type { LineageNode, Shape, ShapeInput, ShapeKind, ShapeTool } from "./schema/session.js";
+
+/**
+ * The Shape catalogue (Story 13.6): a Shape sits between a message's Intent
+ * (the record's decision, reason, rejected options) and its Code (the diff),
+ * and says what the change does at a glance. A writer picks one tool, both, or
+ * none ("nothing to show").
+ *
+ * The catalogue is a registry: a tool is added here with its prompt line, its
+ * output schema and its validator, and the side writer and the map pick it up
+ * from the same place. Plain-text output survives a failed validation; a
+ * Mermaid source the map cannot draw is shown as text, never dropped.
+ */
+
+export interface ShapeToolSpec {
+ kind: ShapeKind;
+ /** Short name, as it reads in the panel and in the prompt. */
+ name: string;
+ /** When the writer should reach for this tool. */
+ when: string;
+ /** True when the output can be shown as designed. */
+ validate(text: string): boolean;
+}
+
+/** Number of nodes a Mermaid flowchart may carry. */
+export const MERMAID_MAX_NODES = 15;
+
+const MERMAID_KEYWORDS = new Set([
+ "flowchart",
+ "graph",
+ "td",
+ "tb",
+ "lr",
+ "rl",
+ "bt",
+ "subgraph",
+ "end",
+ "direction",
+ "click",
+ "style",
+ "class",
+ "classdef",
+ "linkstyle",
+]);
+
+/** A rough node count: identifiers plus shapes; enough to keep a diagram small. */
+export function mermaidNodeCount(text: string): number {
+ const ids = new Set<string>();
+ for (const match of text.matchAll(/\b[A-Za-z_][\w-]*\b/g)) {
+ const word = match[0];
+ if (!MERMAID_KEYWORDS.has(word.toLowerCase())) ids.add(word);
+ }
+ return ids.size;
+}
+
+export const SHAPE_TOOLS: readonly ShapeToolSpec[] = [
+ {
+ kind: "pseudo",
+ name: "Steps",
+ when:
+ "The change is mostly logic: a new path through functions, a rule, a check. " +
+ "Numbered plain-language steps, naming the functions and files they touch.",
+ validate(text) {
+ const lines = text
+ .split("\n")
+ .map((line) => line.trim())
+ .filter((line) => line !== "");
+ if (lines.length < 2) return false;
+ if (!lines.some((line) => /^\d+[.)]\s+\S/.test(line))) return false;
+ return text.length <= 3000;
+ },
+ },
+ {
+ kind: "mermaid",
+ name: "Diagram",
+ when:
+ `The change is a flow between files or functions (a request path, a queue, a state ` +
+ `machine). A Mermaid flowchart of at most ${MERMAID_MAX_NODES} nodes.`,
+ validate(text) {
+ const source = text.trim();
+ if (!/^(flowchart|graph)\s+(TD|TB|LR|RL|BT)\b/i.test(source)) return false;
+ if (/<script/i.test(source)) return false;
+ if (!/-->|---/.test(source)) return false;
+ if (source.split("\n").length > 60) return false;
+ return mermaidNodeCount(source) <= MERMAID_MAX_NODES;
+ },
+ },
+];
+
+/** The registry entry for a kind, or undefined for a kind this CLI does not know. */
+export function shapeToolSpec(kind: string): ShapeToolSpec | undefined {
+ return SHAPE_TOOLS.find((tool) => tool.kind === kind);
+}
+
+/**
+ * Stamps each tool's validation result. The text is always kept: a diagram the
+ * map cannot draw is shown as source, which is more useful than nothing.
+ */
+export function validateShapeTools(tools: ShapeInput["tools"]): ShapeTool[] {
+ return tools.map((tool) => {
+ const spec = shapeToolSpec(tool.kind);
+ return { kind: tool.kind, text: tool.text, valid: spec?.validate(tool.text) ?? false };
+ });
+}
+
+/**
+ * A writer's Shape as the record stores it: the CLI owns `by` and `at`, and
+ * every tool carries its validation result.
+ */
+export function stampShape(shape: ShapeInput, by: "agent" | "side", at: string): Shape {
+ return {
+ tools: validateShapeTools(shape.tools),
+ commits: [...new Set(shape.commits)],
+ by,
+ at,
+ };
+}
+
+/** One commit's numbers, as the skip rules and the prompt need them. */
+export interface ShapeCommitInfo {
+ hash: string;
+ subject?: string | undefined;
+ added: number;
+ removed: number;
+ files: readonly string[];
+}
+
+/** Files whose change never needs a Shape on its own (tests, locks, notes). */
+const SKIP_FILES =
+ /(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|Cargo\.lock|poetry\.lock|Pipfile\.lock|composer\.lock|go\.sum|CHANGELOG\.md|VERSION)$/i;
+
+/** Files a release commit changes and nothing else. */
+const RELEASE_FILES = /(^|\/)(package\.json|VERSION|CHANGELOG\.md)$/i;
+
+/** "chore(release): 0.25.0", "Release 0.25.0", "v0.25.0". */
+const RELEASE_SUBJECT = /^(chore\(release\)|release\b|v?\d+\.\d+\.\d+\b)/i;
+
+/** Below this many changed lines, a Shape would be longer than the change. */
+export const SHAPE_MIN_LINES = 5;
+
+function releaseCommit(commit: ShapeCommitInfo): boolean {
+ if (commit.files.length === 0) return /^chore\(release\)/i.test(commit.subject ?? "");
+ if (commit.files.every((file) => SKIP_FILES.test(file))) return true;
+ return (
+ commit.files.every((file) => RELEASE_FILES.test(file)) &&
+ RELEASE_SUBJECT.test(commit.subject ?? "")
+ );
+}
+
+/**
+ * Whether a message's commits earn a Shape: not release/version bumps,
+ * lockfiles or CHANGELOG alone, and at least {@link SHAPE_MIN_LINES} changed
+ * lines in total. A threshold, not a judgement about the code.
+ */
+export function shapeWanted(commits: readonly ShapeCommitInfo[]): {
+ wanted: boolean;
+ reason: string;
+} {
+ if (commits.length === 0) return { wanted: false, reason: "no commits" };
+ const lines = commits.reduce((sum, commit) => sum + commit.added + commit.removed, 0);
+ if (lines < SHAPE_MIN_LINES)
+ return { wanted: false, reason: `only ${lines} changed line${lines === 1 ? "" : "s"}` };
+ if (commits.every(releaseCommit))
+ return { wanted: false, reason: "release, lockfile or changelog changes only" };
+ return { wanted: true, reason: "" };
+}
+
+/** How much of the diff the side writer reads; enough to name the path, not the file. */
+export const SHAPE_DIFF_LIMIT = 7000;
+
+/** The tool catalogue as the prompt lists it. */
+export function toolCatalogue(): string {
+ return SHAPE_TOOLS.map(
+ (tool) =>
+ `- "${tool.kind}" (${tool.name}): ${tool.when}\n Output: {"kind": "${tool.kind}", "text": "..."}`,
+ ).join("\n");
+}
+
+/** The record's Intent for one message, as plain lines. */
+function intentLines(node: LineageNode): string[] {
+ const lines = [`Title: ${node.title}`];
+ if (node.why) lines.push(`Why: ${node.why}`);
+ if (node.alternatives?.length)
+ lines.push(
+ `Rejected: ${node.alternatives
+ .map((alt) => `${alt.option}${alt.why ? ` (${alt.why})` : ""}`)
+ .join("; ")}`,
+ );
+ if (node.work?.length) lines.push(`Work: ${node.work.join("; ")}`);
+ if (node.agentDecisions?.length)
+ lines.push(
+ `Agent decisions: ${node.agentDecisions.map((decision) => decision.title).join("; ")}`,
+ );
+ return lines;
+}
+
+/** The prompt the side model answers for one message. */
+export function shapePrompt(opts: {
+ node: LineageNode;
+ commits: readonly ShapeCommitInfo[];
+ diff: string;
+ diffTruncated: boolean;
+ language: string;
+}): string {
+ const writing = opts.language === "auto" ? "the conversation's language" : opts.language;
+ const commitLines = opts.commits.map(
+ (commit) =>
+ `- ${commit.hash.slice(0, 7)} ${commit.subject ?? ""} (+${commit.added} −${commit.removed}): ${commit.files.join(", ")}`,
+ );
+ return [
+ "You write the Shape of one message in a cogit lineage record: a small representation of what its change does at a glance, so a reviewer can see the intent, the shape and the code in that order.",
+ "You get the Intent (from the record) and the Code (the commits and their diff). Write the Shape between them.",
+ "",
+ "Tools:",
+ toolCatalogue(),
+ "",
+ "Rules:",
+ "- Pick the tool that fits; both only when each adds something; none when the change is a small fix not worth a picture.",
+ `- Name real functions, files and modules from the diff. Never invent a path.`,
+ `- The Mermaid source must start with "flowchart TD" (or LR) and stay under ${MERMAID_MAX_NODES} nodes; quote labels that hold spaces or punctuation.`,
+ "- Describe what the code does now, not the steps of the conversation.",
+ `- Write the text in ${writing}; JSON keys stay English. Never write secrets, credentials or personal data.`,
+ "",
+ "Intent:",
+ ...intentLines(opts.node),
+ "",
+ "Commits:",
+ ...commitLines,
+ "",
+ `Diff${opts.diffTruncated ? " (cut to fit; the commits above are complete)" : ""}:`,
+ opts.diff,
+ "",
+ 'Return only one JSON object, no code fences: {"tools": [{"kind": "pseudo", "text": "1. ...\\n2. ..."}]}. Return {"tools": []} when nothing here is worth showing.',
+ ].join("\n");
+}
+
+/**
+ * Parses the side model's answer. Unknown tool kinds are dropped; known ones
+ * keep their text, valid or not, so an invalid diagram is never lost.
+ */
+export function parseShapeAnswer(text: string): ShapeInput | undefined {
+ const fenced = /```(?:json)?\s*([\s\S]*?)```/.exec(text)?.[1] ?? text;
+ const start = fenced.indexOf("{");
+ const end = fenced.lastIndexOf("}");
+ if (start < 0 || end <= start) return undefined;
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(fenced.slice(start, end + 1));
+ } catch {
+ return undefined;
+ }
+ if (typeof parsed !== "object" || parsed === null) return undefined;
+ const tools = (parsed as { tools?: unknown }).tools;
+ if (!Array.isArray(tools)) return undefined;
+ const known: ShapeInput["tools"] = [];
+ for (const tool of tools) {
+ if (typeof tool !== "object" || tool === null) continue;
+ const { kind, text: body } = tool as { kind?: unknown; text?: unknown };
+ if (typeof kind !== "string" || typeof body !== "string") continue;
+ if (shapeToolSpec(kind) === undefined) continue;
+ if (body.trim() === "" || body.length > 4000) continue;
+ known.push({ kind: kind as ShapeKind, text: body });
+ }
+ return { tools: known.slice(0, 3), commits: [] };
+}
diff --git a/packages/cli/src/view/lineage.ts b/packages/cli/src/view/lineage.ts
index f9d6cdd..75eda36 100644
--- a/packages/cli/src/view/lineage.ts
+++ b/packages/cli/src/view/lineage.ts
@@ -122,6 +122,8 @@ export function buildMessages(
...(node.files?.length ? { files: node.files } : {}),
...(node.work?.length ? { work: node.work } : {}),
...(node.agentDecisions?.length ? { agentDecisions: node.agentDecisions } : {}),
+ // Story 13.6: the Shape travels with the record, as written and validated.
+ ...(node.shape === undefined ? {} : { shape: node.shape }),
...(node.addedAt === undefined ? {} : { addedAt: node.addedAt }),
...(node.touchedAt === undefined ? {} : { touchedAt: node.touchedAt }),
...(node.branch === undefined ? {} : { branch: node.branch }),
diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.ts
index a1d78c1..7ff1c26 100644
--- a/packages/cli/src/view/model.ts
+++ b/packages/cli/src/view/model.ts
@@ -35,6 +35,7 @@ export const PANEL_EDITABLE_KEYS = [
"startupContext",
"recordHeadless",
"tryBeforeNotes",
+ "shapes",
"language",
"shareConversations",
"recordCommit",
@@ -74,6 +75,23 @@ export interface ViewChange {
files: number;
}
+/** What a message's change does, between Intent and Code (Story 13.6). */
+export interface ViewShapeTool {
+ kind: "pseudo" | "mermaid";
+ text: string;
+ /** False when the registry refused the output; the map shows it as text. */
+ valid?: boolean | undefined;
+}
+
+export interface ViewShape {
+ tools: ViewShapeTool[];
+ /** Who wrote it: the main agent or the side model. */
+ by?: "agent" | "side" | undefined;
+ /** The message's commits this Shape covers. */
+ commits: string[];
+ at?: string | undefined;
+}
+
export interface ViewNode {
/** Stable id (`h…`); the key of the node, never shown to the user. */
id: string;
@@ -127,6 +145,12 @@ export interface ViewNode {
addedAt?: string;
/** When the node was last added or changed; marks where the work left off. */
touchedAt?: string;
+ /**
+ * For a message that landed commits: a small representation of what the
+ * change does (Story 13.6). Missing means nobody wrote one (yet): the modal
+ * says why (queued or off).
+ */
+ shape?: ViewShape;
/** A user message the record does not hold yet: the row is not summarized. */
unsummarized?: true;
}
@@ -400,6 +424,11 @@ export interface PanelSettings {
* thoughts considered and rejected (Story 10.4).
*/
tryBeforeNotes: boolean;
+ /**
+ * Whether a message that landed commits gets a Shape (Story 13.6): a small
+ * plain-language or diagram view of what the change does.
+ */
+ shapes: boolean;
shareConversations: boolean;
recordCommit: "ask" | "auto" | "off";
gitPolicy: "ignore" | "commit";
diff --git a/packages/cli/src/view/panel.ts b/packages/cli/src/view/panel.ts
index c31229d..728f11a 100644
--- a/packages/cli/src/view/panel.ts
+++ b/packages/cli/src/view/panel.ts
@@ -69,6 +69,7 @@ export function panelSettings(config: Config): PanelSettings {
startupContext: config.startupContext,
recordHeadless: config.recordHeadless,
tryBeforeNotes: config.tryBeforeNotes,
+ shapes: config.shapes,
shareConversations: config.shareConversations,
recordCommit: config.recordCommit,
gitPolicy: config.gitPolicy,
diff --git a/packages/cli/src/view/settings.ts b/packages/cli/src/view/settings.ts
index 8fbb58a..0468682 100644
--- a/packages/cli/src/view/settings.ts
+++ b/packages/cli/src/view/settings.ts
@@ -106,6 +106,18 @@ const EDITABLE: FieldSpec[] = [
"the agent ask before repeating a dead end.",
kind: "boolean",
},
+ {
+ key: "shapes",
+ label: "Intent, Shape and Code",
+ help: "A small picture of what each change does, beside its reason and its diff.",
+ details:
+ "For every message that landed commits, a small representation of what the change does: " +
+ "numbered plain-language steps or a Mermaid diagram. It sits between the record's intent " +
+ "(the decision, reason and rejected options) and the code (the diff), so a reviewer sees " +
+ "why, what and how in one place. The recorder writes it, not you; it costs one small " +
+ "model call per such message. Off, the map says so and nothing is written.",
+ kind: "boolean",
+ },
{
key: "language",
label: "Language",
@@ -270,6 +282,7 @@ export const DEFAULT_SETTINGS: PanelSettings = {
startupContext: true,
recordHeadless: false,
tryBeforeNotes: true,
+ shapes: true,
shareConversations: false,
recordCommit: "ask",
gitPolicy: "commit",
@@ -289,6 +302,7 @@ export function editableSettings(settings: PanelSettings): PanelEditableSettings
startupContext: settings.startupContext,
recordHeadless: settings.recordHeadless,
tryBeforeNotes: settings.tryBeforeNotes,
+ shapes: settings.shapes,
language: settings.language,
shareConversations: settings.shareConversations,
recordCommit: settings.recordCommit,
diff --git a/packages/cli/src/view/shape.ts b/packages/cli/src/view/shape.ts
new file mode 100644
index 0000000..1e313f2
--- /dev/null
+++ b/packages/cli/src/view/shape.ts
@@ -0,0 +1,33 @@
+import type { ViewShape } from "./model.js";
+
+/**
+ * What the map should say about a message's Shape (Story 13.6). Kept out of the
+ * component so the three states have one name in the panel and in tests.
+ */
+export type ShapeState =
+ /** At least one tool answered; show it. */
+ | "ready"
+ /** The writer looked and found nothing worth showing. */
+ | "empty"
+ /** The setting is on but nobody has written it yet. */
+ | "queued"
+ /** The setting is off. */
+ | "off";
+
+export function shapeState(shape: ViewShape | undefined, enabled: boolean): ShapeState {
+ if (!enabled) return "off";
+ if (shape === undefined) return "queued";
+ return shape.tools.length === 0 ? "empty" : "ready";
+}
+
+/** The first lines of a pseudo-code answer, for the panel preview. */
+export function shapePreview(shape: ViewShape | undefined, lines = 3): string | undefined {
+ const pseudo = shape?.tools.find((tool) => tool.kind === "pseudo");
+ if (pseudo === undefined) return undefined;
+ const kept = pseudo.text
+ .split("\n")
+ .map((line) => line.trim())
+ .filter((line) => line !== "")
+ .slice(0, lines);
+ return kept.length === 0 ? undefined : kept.join("\n");
+}
diff --git a/packages/cli/test/panel.test.ts b/packages/cli/test/panel.test.ts
index d193acf..cbe94a7 100644
--- a/packages/cli/test/panel.test.ts
+++ b/packages/cli/test/panel.test.ts
@@ -91,6 +91,7 @@ describe("buildPanel", () => {
startupContext: true,
recordHeadless: false,
tryBeforeNotes: true,
+ shapes: true,
shareConversations: false,
recordCommit: "ask",
gitPolicy: "commit",
diff --git a/packages/cli/test/server.test.ts b/packages/cli/test/server.test.ts
index 1d6ea52..6902166 100644
--- a/packages/cli/test/server.test.ts
+++ b/packages/cli/test/server.test.ts
@@ -571,6 +571,7 @@ describe("settings read", () => {
startupContext: true,
recordHeadless: false,
tryBeforeNotes: true,
+ shapes: true,
language: "auto",
shareConversations: false,
recordCommit: "ask",
diff --git a/packages/cli/test/session-git.test.ts b/packages/cli/test/session-git.test.ts
index e46ac6e..1903c9d 100644
--- a/packages/cli/test/session-git.test.ts
+++ b/packages/cli/test/session-git.test.ts
@@ -388,7 +388,7 @@ describe("ignore files and git hooks", () => {
await hooksInstall(root, io);
await hooksInstall(root, io);
expect(io.lines).toEqual([
- "Added the cogit block to: pre-commit, prepare-commit-msg",
+ "Added the cogit block to: pre-commit, prepare-commit-msg, post-commit",
"The cogit hook blocks are already current.",
]);
await hooksUninstall(root, io);
diff --git a/packages/cli/test/settings.test.ts b/packages/cli/test/settings.test.ts
index 728672e..61b567c 100644
--- a/packages/cli/test/settings.test.ts
+++ b/packages/cli/test/settings.test.ts
@@ -25,6 +25,7 @@ describe("settings model", () => {
startupContext: parsed.startupContext,
recordHeadless: parsed.recordHeadless,
tryBeforeNotes: parsed.tryBeforeNotes,
+ shapes: parsed.shapes,
shareConversations: parsed.shareConversations,
recordCommit: parsed.recordCommit,
gitPolicy: parsed.gitPolicy,
@@ -70,6 +71,7 @@ describe("settings model", () => {
startupContext: true,
recordHeadless: false,
tryBeforeNotes: true,
+ shapes: true,
language: "tr",
shareConversations: false,
recordCommit: "ask",
diff --git a/packages/cli/test/shape.test.ts b/packages/cli/test/shape.test.ts
new file mode 100644
index 0000000..a25825d
--- /dev/null
+++ b/packages/cli/test/shape.test.ts
@@ -0,0 +1,262 @@
+import { mkdir } from "node:fs/promises";
+import { join } from "node:path";
+import { beforeEach, describe, expect, it } from "vitest";
+import { configSet } from "../src/commands/config.js";
+import { init } from "../src/commands/init.js";
+import { sessionWrite } from "../src/commands/session.js";
+import { needsShape, nextShapeNode } from "../src/commands/shape.js";
+import type { LineageNode } from "../src/schema/session.js";
+import {
+ parseShapeAnswer,
+ SHAPE_DIFF_LIMIT,
+ shapePrompt,
+ shapeWanted,
+ stampShape,
+ toolCatalogue,
+ validateShapeTools,
+} from "../src/shape.js";
+import { loadSession } from "../src/store/stores.js";
+import { envFor, fakeIo, T0, tempDir } from "./helpers.js";
+
+const PSEUDO = "1. Read the record\n2. Merge the node";
+
+function message(overrides: Partial<LineageNode> = {}): LineageNode {
+ return {
+ id: "h000000000001",
+ kind: "message",
+ title: "Do the thing",
+ parent: null,
+ ...overrides,
+ };
+}
+
+describe("the Shape tool catalogue", () => {
+ it("accepts numbered steps and rejects a paragraph", () => {
+ const [tool] = validateShapeTools([
+ { kind: "pseudo", text: PSEUDO },
+ { kind: "pseudo", text: "A single sentence." },
+ ]);
+ expect(tool?.valid).toBe(true);
+ expect(validateShapeTools([{ kind: "pseudo", text: "A single sentence." }])[0]?.valid).toBe(
+ false,
+ );
+ });
+
+ it("accepts a small flowchart and rejects a map, a script or a stamp", () => {
+ const ok = "flowchart TD\n A[User] --> B[Session]\n B --> C[Record]";
+ expect(validateShapeTools([{ kind: "mermaid", text: ok }])[0]?.valid).toBe(true);
+ for (const bad of [
+ "graph TD",
+ "not a diagram",
+ "flowchart TD\n A --> B\n<script>x</script>",
+ `flowchart TD\n${Array.from({ length: 16 }, (_, i) => ` n${i} --> n${i + 1}`).join("\n")}`,
+ ]) {
+ expect(validateShapeTools([{ kind: "mermaid", text: bad }])[0]?.valid).toBe(false);
+ }
+ });
+
+ it("names both tools and says when to use each", () => {
+ const catalogue = toolCatalogue();
+ expect(catalogue).toContain('"pseudo"');
+ expect(catalogue).toContain('"mermaid"');
+ expect(catalogue).toContain("15 nodes");
+ });
+
+ it("stamps who wrote it, when, and each answer's validity", () => {
+ const shape = stampShape(
+ {
+ tools: [
+ { kind: "pseudo", text: PSEUDO },
+ { kind: "mermaid", text: "nope" },
+ ],
+ commits: ["abc1234", "abc1234"],
+ },
+ "side",
+ T0,
+ );
+ expect(shape.by).toBe("side");
+ expect(shape.at).toBe(T0);
+ expect(shape.commits).toEqual(["abc1234"]);
+ expect(shape.tools.map((tool) => tool.valid)).toEqual([true, false]);
+ // The refused output keeps its text; the map shows it as source.
+ expect(shape.tools[1]?.text).toBe("nope");
+ });
+});
+
+describe("the Shape skip rules", () => {
+ const base = {
+ hash: "a".repeat(40),
+ subject: "feat: x",
+ added: 20,
+ removed: 2,
+ files: ["src/a.ts"],
+ };
+
+ it("wants a Shape for a normal change", () => {
+ expect(shapeWanted([base])).toEqual({ wanted: true, reason: "" });
+ });
+
+ it("skips a change under five lines", () => {
+ expect(shapeWanted([{ ...base, added: 3, removed: 1 }]).wanted).toBe(false);
+ });
+
+ it("skips lockfiles, changelog and version bumps on their own", () => {
+ expect(
+ shapeWanted([{ ...base, added: 900, files: ["package-lock.json", "yarn.lock"] }]).wanted,
+ ).toBe(false);
+ expect(shapeWanted([{ ...base, added: 30, files: ["CHANGELOG.md"] }]).wanted).toBe(false);
+ expect(
+ shapeWanted([
+ {
+ ...base,
+ subject: "chore(release): 0.26.0",
+ files: ["package.json", "VERSION", "CHANGELOG.md"],
+ },
+ ]).wanted,
+ ).toBe(false);
+ });
+
+ it("keeps a release commit when real code came with it", () => {
+ expect(
+ shapeWanted([
+ { ...base, subject: "chore(release): 0.26.0", files: ["package.json", "VERSION"] },
+ { ...base, added: 30, files: ["src/shape.ts"] },
+ ]).wanted,
+ ).toBe(true);
+ });
+});
+
+describe("the side writer's answer", () => {
+ it("parses fenced JSON and drops unknown or empty tools", () => {
+ const answer = parseShapeAnswer(
+ '```json\n{"tools":[{"kind":"pseudo","text":"1. a\\n2. b"},{"kind":"uml","text":"x"},{"kind":"mermaid","text":""}]}\n```',
+ );
+ expect(answer?.tools).toEqual([{ kind: "pseudo", text: "1. a\n2. b" }]);
+ });
+
+ it("returns undefined for text without a tools list", () => {
+ expect(parseShapeAnswer("no json here")).toBeUndefined();
+ expect(parseShapeAnswer('{"tools": "nope"}')).toBeUndefined();
+ });
+
+ it("shows the record's Intent and says when the diff was cut", () => {
+ const prompt = shapePrompt({
+ node: message({ why: "Because the queue was blind", work: ["wrote the queue"] }),
+ commits: [
+ {
+ hash: "a".repeat(40),
+ subject: "feat: queue",
+ added: 20,
+ removed: 2,
+ files: ["src/q.ts"],
+ },
+ ],
+ diff: "diff --git a/src/q.ts",
+ diffTruncated: true,
+ language: "tr",
+ });
+ expect(prompt).toContain("Because the queue was blind");
+ expect(prompt).toContain("cut to fit");
+ expect(prompt).toContain("Write the text in tr");
+ expect(prompt).toContain('"tools": []');
+ expect(SHAPE_DIFF_LIMIT).toBeGreaterThan(1000);
+ });
+});
+
+describe("which messages wait for a Shape", () => {
+ it("takes a message with commits and no shape, newest first", () => {
+ const nodes = [
+ message({ id: "h000000000001", at: "2026-10-31T10:00:00.000Z", commits: ["abc1234"] }),
+ message({ id: "h000000000002", at: "2026-10-31T11:00:00.000Z", commits: ["def5678"] }),
+ message({ id: "h000000000003" }),
+ ];
+ expect(nextShapeNode(nodes)?.id).toBe("h000000000002");
+ });
+
+ it("wants a new Shape when the message landed more commits", () => {
+ const shaped = message({
+ commits: ["abc1234", "def5678"],
+ shape: { tools: [], commits: ["abc1234"], by: "side", at: T0 },
+ });
+ expect(needsShape(shaped)).toBe(true);
+ expect(
+ needsShape({
+ ...shaped,
+ commits: ["abc1234"],
+ shape: { ...shaped.shape!, commits: ["abc1234"] },
+ }),
+ ).toBe(false);
+ });
+});
+
+describe("session write stores Shapes", () => {
+ let dir: string;
+ let env: NodeJS.ProcessEnv;
+
+ beforeEach(async () => {
+ dir = await tempDir();
+ env = envFor(dir);
+ const root = join(dir, "proj");
+ await mkdir(root, { recursive: true });
+ await init(
+ root,
+ { retention: "keep", language: "auto", allowSkill: false, projectSettings: false },
+ fakeIo(env),
+ );
+ dir = root;
+ });
+
+ it("stamps the writer and keeps an invalid diagram as text", async () => {
+ const io = fakeIo(env);
+ await sessionWrite({ dir }, io, async () =>
+ JSON.stringify({
+ sessionId: "s1",
+ nodes: [
+ {
+ id: "m1",
+ kind: "message",
+ title: "Shape it",
+ commits: ["abc1234"],
+ shape: { tools: [{ kind: "mermaid", text: "not a flowchart" }], commits: ["abc1234"] },
+ },
+ ],
+ }),
+ );
+ expect(io.warnings).toContainEqual(
+ expect.stringContaining("shape mermaid: the output does not match the tool's format"),
+ );
+ const loaded = await loadSession(dir, "s1");
+ expect(loaded.found && loaded.ok).toBe(true);
+ if (!loaded.found || !loaded.ok) return;
+ const node = loaded.data.nodes.find((candidate) => candidate.id === "m1");
+ expect(node?.shape?.by).toBe("agent");
+ expect(node?.shape?.at).toBe(T0);
+ expect(node?.shape?.tools[0]).toMatchObject({
+ kind: "mermaid",
+ text: "not a flowchart",
+ valid: false,
+ });
+ });
+
+ it("writes nothing while shapes are off", async () => {
+ const io = fakeIo(env);
+ await configSet("shapes", "false", io);
+ await sessionWrite({ dir }, io, async () =>
+ JSON.stringify({
+ sessionId: "s2",
+ nodes: [
+ {
+ id: "m1",
+ kind: "message",
+ title: "Shape it",
+ shape: { tools: [{ kind: "pseudo", text: PSEUDO }], commits: ["abc1234"] },
+ },
+ ],
+ }),
+ );
+ expect(io.warnings).toContain("shapes are off; the shape was not recorded");
+ const loaded = await loadSession(dir, "s2");
+ if (!loaded.found || !loaded.ok) throw new Error("session not written");
+ expect(loaded.data.nodes[0]?.shape).toBeUndefined();
+ });
+});
diff --git a/packages/cli/test/thought.test.ts b/packages/cli/test/thought.test.ts
index 99c776c..cb537db 100644
--- a/packages/cli/test/thought.test.ts
+++ b/packages/cli/test/thought.test.ts
@@ -447,7 +447,11 @@ describe("the thought behind a commit (Story 9.4)", () => {
const preCommit = join(root, ".git", "hooks", "pre-commit");
await writeFile(preCommit, userHook);
await chmod(preCommit, 0o755);
- expect(await installGitHooks(root)).toEqual(["pre-commit", "prepare-commit-msg"]);
+ expect(await installGitHooks(root)).toEqual([
+ "pre-commit",
+ "prepare-commit-msg",
+ "post-commit",
+ ]);
expect(await readFile(preCommit, "utf8")).toBe(
`${userHook}\n${hookBlock("pre-commit", root)}\n`,
);
@@ -456,7 +460,11 @@ describe("the thought behind a commit (Story 9.4)", () => {
);
expect(await installGitHooks(root)).toEqual([]);
- expect(await uninstallGitHooks(root)).toEqual(["pre-commit", "prepare-commit-msg"]);
+ expect(await uninstallGitHooks(root)).toEqual([
+ "pre-commit",
+ "prepare-commit-msg",
+ "post-commit",
+ ]);
expect(await readFile(preCommit, "utf8")).toBe(userHook);
// The file held nothing but cogit's shebang and block, so it is gone.
expect(existsSync(join(root, ".git", "hooks", "prepare-commit-msg"))).toBe(false);
@@ -471,7 +479,11 @@ describe("the thought behind a commit (Story 9.4)", () => {
expect(await readFile(join(root, ".husky", "prepare-commit-msg"), "utf8")).toContain(
"cogit hook prepare-commit-msg",
);
- expect(await uninstallGitHooks(root)).toEqual(["pre-commit", "prepare-commit-msg"]);
+ expect(await uninstallGitHooks(root)).toEqual([
+ "pre-commit",
+ "prepare-commit-msg",
+ "post-commit",
+ ]);
expect(await readFile(join(root, ".husky", "pre-commit"), "utf8")).toBe(userHook);
// No repository and no block: nothing to do.
@@ -501,7 +513,9 @@ describe("the thought behind a commit (Story 9.4)", () => {
const program = createProgram(() => io);
program.exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} });
await program.parseAsync(["hooks", "uninstall", root], { from: "user" });
- expect(io.lines.at(-1)).toBe("Removed the cogit block from: pre-commit, prepare-commit-msg");
+ expect(io.lines.at(-1)).toBe(
+ "Removed the cogit block from: pre-commit, prepare-commit-msg, post-commit",
+ );
await program.parseAsync(["hooks", "uninstall", root], { from: "user" });
expect(io.lines.at(-1)).toBe("No cogit hook blocks to remove.");
diff --git a/packages/template/package.json b/packages/template/package.json
index 8de85ed..7cfa68d 100644
--- a/packages/template/package.json
+++ b/packages/template/package.json
@@ -10,6 +10,7 @@
},
"dependencies": {
"@xyflow/react": "^12.12.0",
+ "mermaid": "^11.17.2",
"react": "^19.3.1",
"react-dom": "^19.3.1"
},
diff --git a/packages/template/src/MermaidDiagram.tsx b/packages/template/src/MermaidDiagram.tsx
new file mode 100644
index 0000000..320bb87
--- /dev/null
+++ b/packages/template/src/MermaidDiagram.tsx
@@ -0,0 +1,43 @@
+import { useEffect, useRef, useState } from "react";
+
+/**
+ * Draws a Mermaid flowchart without a network (Story 13.6): the library is a
+ * dependency of the template, so the page works from `file://` too. Imported
+ * only when a Shape with a diagram is first shown; the map itself does not pay
+ * for it. A source the renderer refuses falls back to the text.
+ */
+let seq = 0;
+
+export function MermaidDiagram({ source, className }: { source: string; className?: string }) {
+ const host = useRef<HTMLDivElement>(null);
+ const [failed, setFailed] = useState(false);
+
+ useEffect(() => {
+ let cancelled = false;
+ setFailed(false);
+ const id = `cogit-shape-${(seq += 1)}`;
+ void import("mermaid")
+ .then(async ({ default: mermaid }) => {
+ mermaid.initialize({
+ startOnLoad: false,
+ securityLevel: "strict",
+ theme: "neutral",
+ fontFamily: "inherit",
+ });
+ return mermaid.render(id, source);
+ })
+ .then(({ svg }) => {
+ if (!cancelled && host.current !== null) host.current.innerHTML = svg;
+ })
+ .catch(() => {
+ if (!cancelled) setFailed(true);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [source]);
+
+ if (failed)
+ return <pre className={`shape-source${className ? ` ${className}` : ""}`}>{source}</pre>;
+ return <div ref={host} className={`shape-diagram${className ? ` ${className}` : ""}`} />;
+}
diff --git a/packages/template/src/ShapeModal.tsx b/packages/template/src/ShapeModal.tsx
new file mode 100644
index 0000000..343be24
--- /dev/null
+++ b/packages/template/src/ShapeModal.tsx
@@ -0,0 +1,317 @@
+import { type ReactNode, useEffect, useRef, useState } from "react";
+import type { ViewNode } from "../../cli/src/view/model.js";
+import { shapePreview, shapeState } from "../../cli/src/view/shape.js";
+import { DiffView } from "./DiffView.js";
+import { isLivePage } from "./data.js";
+import { MermaidDiagram } from "./MermaidDiagram.js";
+
+/**
+ * Intent, Shape and Code (Story 13.6): the three layers of a message that
+ * landed commits, top to bottom, with 1/2/3 tabs. Opening on Shape shows what
+ * the change does first; Intent is the record, read but never rewritten here,
+ * and Code is the same diff the panel already shows.
+ */
+export type ShapeTab = "intent" | "shape" | "code";
+
+/** The fields the three layers read; a message node or the panel's detail both fit. */
+export interface ShapeNode {
+ title: string;
+ kind: ViewNode["kind"];
+ why?: string | undefined;
+ alternatives?: ViewNode["alternatives"];
+ agentDecisions?: ViewNode["agentDecisions"];
+ work?: ViewNode["work"];
+ decidedBy?: ViewNode["decidedBy"];
+ commits?: string[] | undefined;
+ commitTags?: ViewNode["commitTags"];
+ shape?: ViewNode["shape"];
+}
+
+const TABS: { id: ShapeTab; number: string; label: string }[] = [
+ { id: "intent", number: "1", label: "Intent" },
+ { id: "shape", number: "2", label: "Shape" },
+ { id: "code", number: "3", label: "Code" },
+];
+
+const DECIDED_LABEL = {
+ user: "You",
+ agent: "The agent, on its own",
+ agreed: "You, approving the agent's proposal",
+} as const;
+
+/** The record's Intent: the same fields the panel shows, in reading order. */
+function IntentLayer({ node }: { node: ShapeNode }) {
+ const empty =
+ !node.why &&
+ !node.alternatives?.length &&
+ !node.agentDecisions?.length &&
+ !node.work?.length &&
+ !node.decidedBy;
+ if (empty) return <p className="muted">No reason was recorded for this message.</p>;
+ return (
+ <div className="shape-intent">
+ {node.why ? (
+ <section>
+ <h4>Why</h4>
+ <p>{node.why}</p>
+ </section>
+ ) : null}
+ {node.alternatives?.length ? (
+ <section>
+ <h4>Considered and rejected</h4>
+ <ul>
+ {node.alternatives.map((alt) => (
+ <li key={alt.option}>
+ <strong>{alt.option}</strong>
+ {alt.why ? <> — {alt.why}</> : null}
+ </li>
+ ))}
+ </ul>
+ </section>
+ ) : null}
+ {node.agentDecisions?.length ? (
+ <section>
+ <h4>Decided by the agent on its own</h4>
+ <ul>
+ {node.agentDecisions.map((decision) => (
+ <li key={decision.title}>
+ <strong>{decision.title}</strong>
+ {decision.why ? <> — {decision.why}</> : null}
+ </li>
+ ))}
+ </ul>
+ </section>
+ ) : null}
+ {node.work?.length ? (
+ <section>
+ <h4>What the agent did</h4>
+ <ul>
+ {node.work.map((item) => (
+ <li key={item}>{item}</li>
+ ))}
+ </ul>
+ </section>
+ ) : null}
+ {node.decidedBy ? (
+ <p className="decided-by">Decided by: {DECIDED_LABEL[node.decidedBy]}</p>
+ ) : null}
+ </div>
+ );
+}
+
+/** The Shape layer: the tools' output, Mermaid drawn in the page. */
+function ShapeLayer({
+ node,
+ enabled,
+ renderMermaid,
+}: {
+ node: ShapeNode;
+ enabled: boolean;
+ renderMermaid: (source: string) => ReactNode;
+}) {
+ const state = shapeState(node.shape, enabled);
+ if (state === "off") {
+ return <p className="muted">Shapes are off. Turn them on in Settings → Recording.</p>;
+ }
+ if (state === "queued") {
+ return <p className="muted">This Shape is being prepared, or the message landed no commits.</p>;
+ }
+ if (state === "empty") {
+ return <p className="muted">Nothing to show: the change was too small to draw.</p>;
+ }
+ return (
+ <div className="shape-tools">
+ {node.shape?.tools.map((tool, index) =>
+ tool.kind === "mermaid" && tool.valid !== false ? (
+ <figure key={`${tool.kind}-${index}`} className="shape-figure">
+ {renderMermaid(tool.text)}
+ <figcaption>Diagram</figcaption>
+ </figure>
+ ) : (
+ <figure key={`${tool.kind}-${index}`} className="shape-figure">
+ <pre className={`shape-source is-${tool.kind}`}>{tool.text}</pre>
+ <figcaption>
+ {tool.kind === "pseudo" ? "Steps" : "Diagram source (not drawn)"}
+ </figcaption>
+ </figure>
+ ),
+ )}
+ {node.shape?.by ? (
+ <p className="shape-by">
+ Written by {node.shape.by === "side" ? "the side model" : "the agent"}.
+ </p>
+ ) : null}
+ </div>
+ );
+}
+
+/** The Code layer: the message's commits and their patches. */
+function CodeLayer({ node, root }: { node: ShapeNode; root: string }) {
+ const live = typeof document !== "undefined" && isLivePage();
+ const commits = node.commits ?? [];
+ if (commits.length === 0) return <p className="muted">No commit is linked to this message.</p>;
+ return (
+ <div className="shape-code">
+ {commits.map((commit) => (
+ <section key={commit}>
+ <h4>
+ <code>{commit.slice(0, 7)}</code>{" "}
+ {node.commitTags?.find((tag) => tag.hash === commit)?.subject ?? ""}
+ </h4>
+ {live ? <DiffView dir={root} commit={commit} /> : null}
+ </section>
+ ))}
+ {live ? null : <p className="muted">Open with `cogit open` to see the diffs.</p>}
+ </div>
+ );
+}
+
+/**
+ * The three layers with their tabs. Presentational (no state, no effects) so a
+ * render test can check the layers and the pending states without a browser;
+ * `renderMermaid` lets that test stand in for the real renderer.
+ */
+export function ShapeLayers({
+ node,
+ root,
+ tab,
+ enabled,
+ onTab,
+ renderMermaid = (source) => <MermaidDiagram source={source} />,
+}: {
+ node: ShapeNode;
+ root: string;
+ tab: ShapeTab;
+ enabled: boolean;
+ onTab: (tab: ShapeTab) => void;
+ renderMermaid?: (source: string) => ReactNode;
+}) {
+ return (
+ <div className="shape-layers">
+ <div className="shape-tabs" role="tablist" aria-label="Intent, Shape and Code">
+ {TABS.map((entry) => (
+ <button
+ key={entry.id}
+ type="button"
+ role="tab"
+ aria-selected={tab === entry.id}
+ className={tab === entry.id ? "shape-tab is-active" : "shape-tab"}
+ onClick={() => onTab(entry.id)}
+ >
+ <span className="shape-tab-no">{entry.number}</span> {entry.label}
+ </button>
+ ))}
+ </div>
+ <div
+ className="shape-layer"
+ role="tabpanel"
+ aria-label={TABS.find((entry) => entry.id === tab)?.label}
+ >
+ {tab === "intent" ? <IntentLayer node={node} /> : null}
+ {tab === "shape" ? (
+ <ShapeLayer node={node} enabled={enabled} renderMermaid={renderMermaid} />
+ ) : null}
+ {tab === "code" ? <CodeLayer node={node} root={root} /> : null}
+ </div>
+ </div>
+ );
+}
+
+/** The large modal, opened from the panel's code section. */
+export function ShapeModal({
+ node,
+ root,
+ enabled,
+ onClose,
+}: {
+ node: ShapeNode;
+ root: string;
+ enabled: boolean;
+ onClose: () => void;
+}) {
+ const [tab, setTab] = useState<ShapeTab>("shape");
+ const box = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ box.current?.focus();
+ const onKey = (event: KeyboardEvent): void => {
+ if (event.key === "Escape") {
+ event.stopPropagation();
+ onClose();
+ } else if (event.key === "1") setTab("intent");
+ else if (event.key === "2") setTab("shape");
+ else if (event.key === "3") setTab("code");
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [onClose]);
+
+ return (
+ <div className="shape-overlay" onClick={onClose}>
+ <div
+ ref={box}
+ className="shape-modal"
+ role="dialog"
+ aria-modal="true"
+ aria-label={`${node.title} — Intent, Shape and Code`}
+ tabIndex={-1}
+ onClick={(event) => event.stopPropagation()}
+ >
+ <header className="shape-head">
+ <div>
+ <span className="kind">message</span>
+ <h2>{node.title}</h2>
+ </div>
+ <button type="button" className="drilldown-close" aria-label="Close" onClick={onClose}>
+ ×
+ </button>
+ </header>
+ <ShapeLayers node={node} root={root} tab={tab} enabled={enabled} onTab={setTab} />
+ </div>
+ </div>
+ );
+}
+
+/**
+ * The panel's code section entry (Story 13.6): a short preview of the Shape and
+ * an Open button that shows the three layers. With no Shape yet it still opens,
+ * and the Shape tab explains why (queued or off).
+ */
+export function ShapeSection({
+ node,
+ root,
+ enabled,
+}: {
+ node: ShapeNode;
+ root: string;
+ enabled: boolean;
+}) {
+ const [open, setOpen] = useState(false);
+ const state = shapeState(node.shape, enabled);
+ const preview = shapePreview(node.shape);
+ const diagram = node.shape?.tools.find((tool) => tool.kind === "mermaid" && tool.valid !== false);
+ return (
+ <section className="shape-section">
+ <h3>Intent, Shape and Code</h3>
+ {state === "ready" ? (
+ preview ? (
+ <pre className="shape-preview">{preview}</pre>
+ ) : diagram ? (
+ <MermaidDiagram source={diagram.text} className="shape-preview-diagram" />
+ ) : null
+ ) : state === "off" ? (
+ <p className="muted">Shapes are off.</p>
+ ) : state === "empty" ? (
+ <p className="muted">Nothing to show for this change.</p>
+ ) : (
+ <p className="muted">Shape is being prepared.</p>
+ )}
+ <button type="button" className="shape-open" onClick={() => setOpen(true)}>
+ Open
+ </button>
+ {open ? (
+ <ShapeModal node={node} root={root} enabled={enabled} onClose={() => setOpen(false)} />
+ ) : null}
+ </section>
+ );
+}
diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsx
index 3662d46..f0c5a37 100644
--- a/packages/template/src/SidePanel.tsx
+++ b/packages/template/src/SidePanel.tsx
@@ -24,6 +24,7 @@ import {
import type { OutlineTarget } from "./Outline.js";
import { peopleOf } from "./people.js";
import { ResumeButton } from "./ResumeButton.js";
+import { ShapeSection } from "./ShapeModal.js";
/**
* What the drill-down shows: a message (with the branch it belongs to) or a
@@ -410,6 +411,13 @@ function NodeDetails({
</ul>
</section>
) : null}
+ {node.kind === "message" && node.commits?.length ? (
+ <ShapeSection
+ node={node}
+ root={model.project.path}
+ enabled={model.settings?.shapes ?? true}
+ />
+ ) : null}
{node.kind === "message" && node.change ? (
<section>
<h3>Code landed</h3>
@@ -701,7 +709,11 @@ export function DrillDown({
useEffect(() => {
if (!selection) return;
const onKey = (event: KeyboardEvent): void => {
- if (event.key === "Escape") onClose();
+ if (event.key === "Escape") {
+ // The three-layer modal sits on top; Escape closes it first.
+ if (document.querySelector(".shape-overlay") !== null) return;
+ onClose();
+ }
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
diff --git a/packages/template/src/fixture.ts b/packages/template/src/fixture.ts
index d1f6a95..c27c32d 100644
--- a/packages/template/src/fixture.ts
+++ b/packages/template/src/fixture.ts
@@ -60,6 +60,7 @@ export const fixture: LineageViewModel = {
startupContext: true,
recordHeadless: false,
tryBeforeNotes: true,
+ shapes: true,
shareConversations: false,
recordCommit: "ask",
gitPolicy: "ignore",
@@ -95,6 +96,22 @@ export const fixture: LineageViewModel = {
message("m4", "Build the dev fixture", "m3", "2026-10-24T09:41:00.000Z", {
summary: "Three sessions in start order.",
commits: ["1a2b3c4", "9f8e7d6"],
+ shape: {
+ by: "side",
+ commits: ["1a2b3c4", "9f8e7d6"],
+ tools: [
+ {
+ kind: "pseudo",
+ valid: true,
+ text: "1. Read the fixture data\n2. Render the map from it\n3. Keep the page offline",
+ },
+ {
+ kind: "mermaid",
+ valid: true,
+ text: "flowchart TD\n Fixture[fixture.ts] --> Map[App.tsx]\n Map --> DOM[cogit-data element]",
+ },
+ ],
+ },
commitTags: [
{ hash: "1a2b3c4", subject: "feat(template): add the dev fixture" },
{ hash: "9f8e7d6" },
diff --git a/packages/template/src/graph.ts b/packages/template/src/graph.ts
index b9ff823..bbe0cb1 100644
--- a/packages/template/src/graph.ts
+++ b/packages/template/src/graph.ts
@@ -22,6 +22,8 @@ export type NodeDetail = {
files?: string[];
work?: ViewNode["work"];
agentDecisions?: ViewNode["agentDecisions"];
+ /** The Shape of what the change does (Story 13.6). */
+ shape?: ViewNode["shape"];
addedAt?: string;
touchedAt?: string;
parent?: string | null;
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index ad3e3d0..6352c50 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -2512,3 +2512,186 @@ time {
color: var(--muted);
border-style: dashed;
}
+
+/* Intent, Shape and Code (Story 13.6) */
+.shape-section {
+ margin: 14px 0;
+}
+
+.shape-preview {
+ max-height: 8.5em;
+ margin: 6px 0;
+ padding: 8px 10px;
+ overflow: hidden;
+ color: var(--text);
+ font:
+ 12px / 1.5 ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ monospace;
+ white-space: pre-wrap;
+ background: var(--chip-bg);
+ border: 1px solid var(--chip-line);
+ border-radius: 6px;
+}
+
+.shape-preview-diagram {
+ max-height: 180px;
+ margin: 6px 0;
+ overflow: hidden;
+}
+
+.shape-open {
+ padding: 4px 12px;
+ color: var(--text);
+ font: inherit;
+ font-size: 12px;
+ background: var(--chip-bg);
+ border: 1px solid var(--chip-line);
+ border-radius: 4px;
+ cursor: pointer;
+}
+
+.shape-overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 40;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 4vh 4vw;
+ background: color-mix(in srgb, var(--bg) 72%, transparent);
+ backdrop-filter: blur(2px);
+}
+
+.shape-modal {
+ display: flex;
+ flex-direction: column;
+ width: min(980px, 100%);
+ max-height: 92vh;
+ background: var(--panel);
+ border: 1px solid var(--line);
+ border-radius: 12px;
+ box-shadow: 0 24px 64px var(--shadow);
+ outline: none;
+}
+
+.shape-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 18px 20px 10px;
+ border-bottom: 1px solid var(--line);
+}
+
+.shape-head h2 {
+ margin: 4px 0 0;
+ font-size: 17px;
+ font-weight: 600;
+}
+
+.shape-tabs {
+ display: flex;
+ gap: 4px;
+ padding: 10px 20px 0;
+}
+
+.shape-tab {
+ padding: 7px 14px;
+ color: var(--muted);
+ font: inherit;
+ font-size: 13px;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: 6px 6px 0 0;
+ cursor: pointer;
+}
+
+.shape-tab.is-active {
+ color: var(--text);
+ background: var(--chip-bg);
+ border-color: var(--chip-line);
+ border-bottom-color: transparent;
+}
+
+.shape-tab-no {
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.shape-layer {
+ flex: 1;
+ min-height: 0;
+ padding: 16px 20px 22px;
+ overflow: auto;
+ border-top: 1px solid var(--chip-line);
+}
+
+.shape-intent h4,
+.shape-code h4 {
+ margin: 12px 0 4px;
+ font-size: 12px;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ color: var(--muted);
+}
+
+.shape-intent ul {
+ margin: 4px 0;
+ padding-left: 18px;
+}
+
+.shape-figure {
+ margin: 0 0 16px;
+}
+
+.shape-figure figcaption {
+ margin-top: 6px;
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.shape-source {
+ margin: 0;
+ padding: 12px 14px;
+ overflow: auto;
+ color: var(--text);
+ font:
+ 12px / 1.6 ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ monospace;
+ white-space: pre-wrap;
+ background: var(--chip-bg);
+ border: 1px solid var(--chip-line);
+ border-radius: 6px;
+}
+
+.shape-diagram {
+ padding: 10px;
+ overflow: auto;
+ background: var(--chip-bg);
+ border: 1px solid var(--chip-line);
+ border-radius: 6px;
+}
+
+.shape-diagram svg {
+ display: block;
+ max-width: 100%;
+ height: auto;
+ margin: 0 auto;
+}
+
+.shape-by {
+ color: var(--muted);
+ font-size: 11px;
+}
+
+.shape-code section {
+ margin-bottom: 14px;
+}
+
+.shape-code h4 code {
+ font-size: 12px;
+}
diff --git a/packages/template/test/shape-modal.test.tsx b/packages/template/test/shape-modal.test.tsx
new file mode 100644
index 0000000..da37446
--- /dev/null
+++ b/packages/template/test/shape-modal.test.tsx
@@ -0,0 +1,92 @@
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it } from "vitest";
+import type { ViewNode } from "../../cli/src/view/model.js";
+import { ShapeLayers } from "../src/ShapeModal.js";
+
+/** The three layers render as the panel shows them (Story 13.6). */
+const node: ViewNode = {
+ id: "h000000000001",
+ kind: "message",
+ title: "Queue the side run",
+ why: "A commit must never wait for a model",
+ alternatives: [{ option: "Block the commit", why: "too slow" }],
+ commits: ["abc1234"],
+ commitTags: [{ hash: "abc1234", subject: "feat: queue" }],
+ shape: {
+ tools: [{ kind: "pseudo", text: "1. Commit lands\n2. Queue a shape", valid: true }],
+ commits: ["abc1234"],
+ by: "side",
+ },
+};
+
+function render(
+ tab: "intent" | "shape" | "code",
+ overrides: { shape?: ViewNode["shape"] | undefined } = {},
+ enabled = true,
+) {
+ return renderToStaticMarkup(
+ createElement(ShapeLayers, {
+ node: { ...node, ...overrides },
+ root: "/tmp/project",
+ tab,
+ enabled,
+ onTab: () => {},
+ renderMermaid: () => createElement("div", null, "diagram"),
+ }),
+ );
+}
+
+describe("Intent, Shape and Code", () => {
+ it("shows the record's intent, read as written", () => {
+ const html = render("intent");
+ expect(html).toContain("Why");
+ expect(html).toContain("A commit must never wait for a model");
+ expect(html).toContain("Block the commit");
+ });
+
+ it("opens on Shape with the steps and who wrote them", () => {
+ const html = render("shape");
+ expect(html).toContain("1. Commit lands");
+ expect(html).toContain("Written by the side model");
+ });
+
+ it("says the Shape is being prepared when there is none", () => {
+ const html = render("shape", { shape: undefined });
+ expect(html).toContain("being prepared");
+ });
+
+ it("says shapes are off when the setting is off", () => {
+ const html = render("shape", {}, false);
+ expect(html).toContain("Shapes are off");
+ });
+
+ it("says nothing is worth showing for an empty answer", () => {
+ const html = render("shape", { shape: { tools: [], commits: ["abc1234"] } });
+ expect(html).toContain("Nothing to show");
+ });
+
+ it("draws a valid diagram and falls back to source for an invalid one", () => {
+ const valid = render("shape", {
+ shape: {
+ tools: [{ kind: "mermaid", text: "flowchart TD\nA --> B", valid: true }],
+ commits: [],
+ },
+ });
+ expect(valid).toContain("diagram");
+ const invalid = render("shape", {
+ shape: {
+ tools: [{ kind: "mermaid", text: "flowchart TD\nA --> B", valid: false }],
+ commits: [],
+ },
+ });
+ expect(invalid).toContain("Diagram source (not drawn)");
+ });
+
+ it("has three named tabs", () => {
+ const html = render("shape");
+ expect(html).toContain("Intent");
+ expect(html).toContain("Shape");
+ expect(html).toContain("Code");
+ });
+});
diff --git a/vitest.config.ts b/vitest.config.ts
index 4ecb720..1bdae42 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -19,7 +19,7 @@ const templateAsText: Plugin = {
export default defineConfig({
plugins: [templateAsText],
test: {
- include: ["packages/*/test/**/*.test.ts"],
+ include: ["packages/*/test/**/*.test.{ts,tsx}"],
globalSetup: ["./packages/cli/test/global-setup.ts"],
coverage: {
provider: "v8",