Skip to main content

sokf_core/
lib.rs

1//! sokf core: the library half of the sokf command-line interface (CLI).
2//!
3//! The binary (`crates/app/sokf`) parses the arguments and renders the output.
4//! The logic that the binary drives lives here, so that tests can run that
5//! logic without starting a process.
6//!
7//! The core loads and validates SOKF knowledge stores, their documents, and
8//! the assets those documents describe, as the core specifications in
9//! `sokf-spec/` define them. It also runs the `sokf` command that
10//! `knowledge/contracts/` specifies. Its entry points are [`init`],
11//! [`harness_install`], [`harness_status`], [`harness_diff`], [`validate`], [`info_formats`],
12//! [`info_grammar`], [`new`], [`graph`](fn@graph), [`guide`], and [`locate`]. The harness
13//! hook is [`harness::hook`].
14//!
15//! SOKF uses the schema language of the `tramlines-md` engine. This crate
16//! re-exports the engine's modules under their old `sokf-core` paths. SOKF
17//! adds its own schema extension, dialect, and model.
18//!
19//! **This crate is unstable.** It is at a 0.x version, and its interface can
20//! change in any release.
21//!
22//! # Example
23//!
24//! ```
25//! use sokf_core::{RepoPath, markdown};
26//!
27//! let body = "# Title\n\nA paragraph.\n";
28//! let segments = markdown::segments(body, 1);
29//! let parsed = markdown::parse(body, 1, &segments);
30//! assert_eq!(parsed.headings[0].slug, "title");
31//! assert_eq!(RepoPath::parse("/knowledge/a.md").unwrap().relative(), "knowledge/a.md");
32//! ```
33
34#![warn(missing_docs)]
35
36mod api;
37mod cache;
38pub mod check;
39pub mod compare;
40mod config;
41mod error;
42pub mod fix;
43mod git;
44pub mod grammar;
45pub mod graph;
46pub mod harness;
47mod history;
48pub mod include;
49pub mod index;
50pub mod markdown;
51pub mod markers;
52pub mod model;
53mod output_schema;
54#[cfg(test)]
55mod proptest_cases;
56mod query;
57mod report;
58pub mod scaffold;
59mod source;
60mod temp_dir;
61#[cfg(test)]
62mod test_support;
63mod walk;
64
65pub use agent_harness_adapter_core::Scope as HarnessScope;
66pub use api::{
67    ALL_HARNESSES, BlockGuide, DocumentGuide, FormatEntry, FormatType, FormatsJson, GraphOptions,
68    GuideCounts, GuideLabel, GuideLimit, GuideLimitKind, GuideOptions, GuideReport, HarnessDirs,
69    HarnessOptions, HarnessReport, HarnessResult, InfoLayer, InitOptions, InitResult, KeyGuide,
70    LabelGuide, LinkGuide, Loaded, NewOptions, NewResult, PartResult, PreambleGuide, RuleLabel,
71    RuleLimit, SectionGuide, TypeMatch, ValidateOptions, check_repository, graph, guide,
72    harness_diff, harness_ids, harness_install, harness_status, info_formats, info_formats_json,
73    info_grammar, init, load_for_lookup, load_keys_for, load_model, load_repository,
74    load_with_keys, load_working, locate, new, validate,
75};
76pub use cache::{
77    CACHE_DIR, Cache, CacheMode, FileState, STORE_FILE, STORE_FORMAT, StoreView, SyncStats,
78};
79pub use config::{
80    AddedExclude, Config, ConfigText, MarkerCheck, PathArg, RepoFormats, Scope, Texts,
81    discover_root, load_config, load_repo_formats, load_texts, resolve_paths,
82};
83pub use error::{Error, Result};
84pub use grammar::{
85    Compiled, FormatRegistry, FormatSource, Grammar, compile_all, formats_text, grammar_text,
86    load_grammar,
87};
88pub use graph::{
89    Edge, EdgeKind, Entry, Graph, GraphJson, GraphQuery, GraphResult, LocateReport, Location, Node,
90    NodeKey, NodeKind, Row, Start,
91};
92pub use include::{Expected, expected};
93pub use index::{IndexEntry, Indexes};
94pub use markdown::{Body, Segments};
95pub use model::{Document, FsLoader, Knowledge, Loader, Located, Model, build};
96pub use output_schema::{Output, output_schemas};
97pub use query::Expr;
98pub use report::{
99    Finding, FixOp, Locator, Report, Severity, ValidateReport, fixable_line as report_fixable_line,
100    message as report_message, text as report_text,
101};
102pub use scaffold::IdTemplate;
103pub use source::{FileKey, LineEnding, Source, Stat, load};
104pub use tramlines_md::{RepoPath, RepoRoot, Spanned, Yaml, YamlError, yaml};
105pub use walk::{FileKind, Tree, WalkedDir, WalkedFile, collect};