Expand description
OKF content roots: which directories ct-okf treats as knowledge
bundles, how they are discovered, and how their concept files are fed to the
crate::okfindex search index.
A directory is a content root if any of three signals holds, so a user can adopt whichever is convenient and they interoperate:
- a
.okfmarker file in the directory (our convention — it may be empty, or carry optional JSONC directives); - a bundle-root
index.mddeclaringokf_version— the only root signal the OKF standard itself defines; - an entry in the project config
.ct/okf.jsonc(the explicit list managed byct okf roots add/rmandct okf roots scan --write).
All three converge on the same set; the config is the durable record. Paths
are anchored at the project root — the nearest ancestor holding .ct
(reusing crate::rules::discover_root) — and the index lives under
.ct/okf/.
Structs§
- Config
- The
.ct/okf.jsoncproject config: the explicit list of content roots (project-relative keys). - Root
- A detected content root: its absolute directory, project-relative key, and the signals that flagged it.
Enums§
- Detection
- How a root was detected.
Constants§
- CONFIG_
FILE - The project config file, under
.ct/. - INDEX_
DIR - The index directory name, under
.ct/. - MARKER_
FILE - The per-directory root marker (our convention; OKF defines no marker).
Functions§
- concept_
files - The live concept files across
roots: every non-reserved.md, as aFileStatkeyed by project-relative path. De-duplicated when roots overlap. The result drivescrate::okfindex::Index::update. - config_
path - Path to
.ct/okf.jsoncunderproject. - detect
- Detect every content root in
project: the union of config entries,.okfmarkers, andokf_versionindex files. Sorted by key; each carries the signals that flagged it. - index_
dir - Path to the index directory
.ct/okf/underproject. - load_
doc - Read one concept file into a
DocSourcefor indexing: title/type/tags from frontmatter (title falling back to the file stem), and a searchable text of the description, resource, and body. - project_
root - The project root for
start: the nearest ancestor containing.ct, elsestartitself (so the tools still work in a directory without a.ct). - rel_key
- Normalize
dirto a project-relative,/-separated key (the form stored in config and used as a stable identity). An absolute or already-relative path that is not underprojectis returned cleaned but unchanged in spirit. - scan_
candidates - Heuristically derive candidate roots in
projectfor onboarding: the top-most directories that either declareokf_versionor directly contain an OKF concept. A directory is dropped when an ancestor already qualifies, so nested concept folders collapse into their bundle root. - write_
marker - Create an empty
.okfmarker indir(no-op if one already exists).