Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

fix(map): write the page's data one value per line

Erene88c48788601
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70d95b3..043d158 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- The conversation store keeps the agent's full answer. A turn stored while the agent was still answering stayed empty or partial for good, so the map showed those messages without their answer; the next build fills in what the transcript still holds.
+- `.cogit/map.html` holds its data one value per line, so a text search like `grep -r` that matches it prints far less.
## [0.31.0] - 2026-11-01
### Added
diff --git a/packages/cli/src/view/lineage.ts b/packages/cli/src/view/lineage.ts
index 75eda36..300db0b 100644
--- a/packages/cli/src/view/lineage.ts
+++ b/packages/cli/src/view/lineage.ts
@@ -406,9 +406,10 @@ export function embedViewModel(template: string, model: PageModel): string {
if (!template.includes(EMPTY_DATA_ELEMENT)) {
throw new Error(`the template has no empty <script id="${DATA_ELEMENT_ID}"> element`);
}
- const data = `<script id="${DATA_ELEMENT_ID}" type="application/json">${escapeForScript(
- JSON.stringify(model),
- )}</script>`;
+ // One value per line, so a text search in the project prints a line and not the
+ // whole record. A string in JSON has no raw newline, so every one here is layout.
+ const json = JSON.stringify(model, null, 1).replace(/\n +/g, "\n");
+ const data = `<script id="${DATA_ELEMENT_ID}" type="application/json">${escapeForScript(json)}</script>`;
// A function, not a string: a `$'` or `$&` in the data must not act as a replace pattern.
return template.replace(EMPTY_DATA_ELEMENT, () => data);
}
diff --git a/packages/cli/test/build.test.ts b/packages/cli/test/build.test.ts
index 43b90ab..3533a71 100644
--- a/packages/cli/test/build.test.ts
+++ b/packages/cli/test/build.test.ts
@@ -409,6 +409,14 @@ describe("embedViewModel", () => {
expect(embedded(html)).toEqual(model);
});
+ it("writes one value per line, so a text search prints a line and not the record", () => {
+ const long = { ...model, project: { ...model.project, name: "line one\nline two" } };
+ const html = embedViewModel(TEMPLATE, long);
+ expect(html).toContain('"name": "line one\\nline two"');
+ expect(html).toMatch(/\n"name": /);
+ expect(embedded(html)).toEqual(long);
+ });
+
it("escapes markup and line separators inside the JSON", () => {
const risky = {
...model,
diff --git a/packages/cli/test/server.test.ts b/packages/cli/test/server.test.ts
index 4b8d95d..94c59e6 100644
--- a/packages/cli/test/server.test.ts
+++ b/packages/cli/test/server.test.ts
@@ -429,7 +429,7 @@ describe("settings write", () => {
if (html.includes('"messageSummaries":true')) break;
await delay(25);
}
- expect(html).toContain('"messageSummaries":true');
+ expect(html).toContain('"messageSummaries": true');
});
it("accepts the Story 9.3 settings and validates their values", async () => {