Read the space link graph, find orphans, hubs, and dangling links, heal missing pages, and write a map back. Stub pages for missing internal links plus a Map of content report with a Mermaid graph and health metadata.

All guides
View source

Gardener

Read the space link graph, find orphans, hubs, and dangling links, heal missing pages, and write a map back. Stub pages for missing internal links plus a Map of content report with a Mermaid graph and health metadata.

Read the code

Before you run it

Run Write back first, and Visualize too for a richer graph.
Use a writable space so the gardener can plant stubs and refresh the map.
Re-run safely: healed links stay healed and the map refreshes.

What it does

Plant a notes page with a couple of dangling internal links.
Walk every page link and count inbound and outbound connections.
Ask the space for its broken-link report.
Create stub pages for missing targets, using record types when paths match.
Write a Map of content page with graph, orphan, hub, and healing metadata.

Core SDK calls

These are intentionally smaller than the source files. They show the backend shape to copy first.

Read the graph

const listing = await coco.spaces.pages("demo");
const pages = listing.items.filter((page) => page.path.startsWith("demo/"));

const links = await Promise.all(
  pages.map((page) => coco.pages.links(page.path)),
);

const broken = await coco.spaces.brokenLinks("demo", { limit: 100 });

Heal and map

await coco.records.create("demo", "deal-memo", {
  path: "deals/vandelay",
  title: "Vandelay Industries",
  note: "Stub planted by gardener",
});

const map = await coco.pages.upsert("demo/reports/map", {
  title: "Map of content",
  content: mermaidMap,
});

await coco.pages.patchMetadata(map.path, {
  set: { "report-kind": "map-of-content", "stubs-planted": 1 },
});

CLI companion

Use the CLI to inspect or exercise the same backend surface from a terminal while your app code uses the SDK.

coco spaces pages demo
coco page links demo/notes/partner-meeting
coco spaces broken-links demo
coco query --filter 'report-kind=map-of-content' --space demo