Core without documents: no slugs; a node's top; targets by titles from the library root
The model has no slug any more (field, ops, canonical row, slugFor, freeSlug, RESERVED, findDoc). The child of the root a node is under is a derived relation, topOf (docOf and documents stay as deprecated aliases for the UI until step 2); ancestorsInDoc becomes ancestorsBelowRoot. Slug keys and a target's old `doc` in stored libraries are ignored. A node target's path is the titles down from the library root; `rel` marks a path read below a top (a file being imported, what the agent or a person typed). Where two sections share a title, the one the link is written in wins. The text format writes /Top title/…, and ./… inside the exported subtree. The agent may give a node id as a target. renderContext renders the top's outline in an <outline> tag, and steps down the focus path when even titles are over budget. Prompts, the reviewer and the scanner speak of the library, trees and tops; the scanner's unit is the top, with the same behaviour (scripts/linkEval.ts gives identical metrics). src/core/library.ts keeps a slug-free shim for the UI's document features (names made from titles) until step 2 removes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
626dc19e1b
commit
44d2e437eb
32 files changed
+634
-577
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Every starter document in library/ parses and builds. A failure names the file, the line, the
|
||||
* Every starter file in library/ parses and builds. A failure names the file, the line, the
|
||||
* section and the quote, all of them at once, so the files can be fixed in one pass.
|
||||
*/
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
@@ -10,7 +10,6 @@ import { writeText } from "../src/core/seed";
|
||||
import { slugify } from "../src/core/text";
|
||||
|
||||
const dir = new URL("../library/", import.meta.url);
|
||||
const id0 = (f: string) => slugify(f.slice(0, -3));
|
||||
const files = (() => {
|
||||
try {
|
||||
return readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
|
||||
@@ -27,11 +26,11 @@ describe("library", () => {
|
||||
const id = f.slice(0, -3);
|
||||
if (slugify(id) !== id) failures.push(`${f}: the file name is not a valid id (lowercase letters, digits, hyphens); it would be imported as "${slugify(id)}"`);
|
||||
try {
|
||||
const id = writeText(lib, readFileSync(new URL(f, dir), "utf8"), f, { slug: id0(f) });
|
||||
const id = writeText(lib, readFileSync(new URL(f, dir), "utf8"), f);
|
||||
const snap = lib.snap();
|
||||
const stale = [id, ...descendants(snap, id)].filter((n) => isStale(snap, n));
|
||||
if (stale.length) failures.push(`${f}: ${stale.length} nodes start out stale`);
|
||||
if (!snap.nodes[id].title) failures.push(`${f}: the document has no title`);
|
||||
if (!snap.nodes[id].title) failures.push(`${f}: the file has no title`);
|
||||
} catch (err) {
|
||||
if (!(err instanceof FormatError)) throw err;
|
||||
failures.push(...err.problems);
|
||||
|
||||
Reference in new issue
Block a user