Skip to main content

Module write

Module write 

Source
Expand description

Writing pages into the user’s own folder (the one Library::overlay_dir reads), so an agent can keep notes that later sessions find: save a page, append to one, delete one.

Only markdown files strictly inside that folder are touched: a path must be relative, made of plain names (letters, digits, ., _, -, no leading dot), end in .md and stay within MAX_DEPTH folders; no part of it may be a symbolic link. A page needs title and description frontmatter (so it lists like any other), is at most MAX_WRITE_BYTES, and is written atomically (a temporary file in the same folder, then a rename). Each write sets an updated: YYYY-MM-DD frontmatter line.

A path that names a built-in page (or a built-in category’s _category.md) is refused unless the caller asks to replace it: the user’s page then hides the built-in one, as any overlay page does. Built-in pages cannot be deleted; deleting the user’s copy brings the built-in back.

Structs§

Written
What a write did.

Constants§

MAX_WRITE_BYTES
Largest page save and append write.

Functions§

append
Add text to the end of the user’s page path (it must exist: save makes it).
check_path
Check a page path for writing; the normalized path and its parts.
delete
Delete the user’s page path. A built-in page of the same path shows again.
save
Save content as the page path in the user’s folder dir (replacing the user’s own page of that path). lib is the library the folder overlays: a built-in path is refused unless replace_built_in.