Skip to main content

Module okfroots

Module okfroots 

Source
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:

  1. a .okf marker file in the directory (our convention — it may be empty, or carry optional JSONC directives);
  2. a bundle-root index.md declaring okf_version — the only root signal the OKF standard itself defines;
  3. an entry in the project config .ct/okf.jsonc (the explicit list managed by ct okf roots add/rm and ct 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.jsonc project 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 a FileStat keyed by project-relative path. De-duplicated when roots overlap. The result drives crate::okfindex::Index::update.
config_path
Path to .ct/okf.jsonc under project.
detect
Detect every content root in project: the union of config entries, .okf markers, and okf_version index files. Sorted by key; each carries the signals that flagged it.
index_dir
Path to the index directory .ct/okf/ under project.
load_doc
Read one concept file into a DocSource for 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, else start itself (so the tools still work in a directory without a .ct).
rel_key
Normalize dir to 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 under project is returned cleaned but unchanged in spirit.
scan_candidates
Heuristically derive candidate roots in project for onboarding: the top-most directories that either declare okf_version or 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 .okf marker in dir (no-op if one already exists).