Skip to main content

coding_tools/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Jonathan Shook
3
4//! Shared library for the `coding_tools` command-line suite.
5//!
6//! The binaries (`ct` and the `ct-*` tools it dispatches to) are thin
7//! front-ends over the reusable, doctested pieces collected here.
8//!
9//! Cross-cutting surfaces, used by several commands:
10//!
11//! * [`pattern`] — the shared substring → glob → regex promotion that every
12//!   pattern-accepting option uses.
13//! * [`walk`] — the shared file-selection predicates (`--base`/`--name`/`--type`
14//!   /`--size`/`--hidden`/`--follow`) that `ct-search`/`ct-edit`/`ct-patch`/
15//!   `ct-tree` target with.
16//! * [`verdict`] — the shared `SUCCESS`/`ERROR` outcome, its exit-status
17//!   mapping, and the count [`Expect`](verdict::Expect)ation that frames a
18//!   search/edit/patch as a pass/fail test.
19//! * [`template`] — the `{TOKEN}` substitution engine behind every `--emit`
20//!   verdict template.
21//! * [`payload`] — the `file:` / `text:` value schemes every payload-typed
22//!   option resolves through.
23//! * [`block`] — line-anchored literal block matching (and the nearest-miss
24//!   diagnostic) behind multi-line patterns in `ct-search`/`ct-view`/`ct-edit`.
25//! * [`blockdoc`] — the `.ctb` block-document parser behind `ct-edit --script`.
26//! * [`editscript`] — the `--script` batch engine: compiled edits simulated
27//!   in memory under the prepare/confirm/write standard.
28//! * [`allowlist`] — the fixed command allow-gates behind `ct-test` and
29//!   `ct-each`.
30//! * [`explain`] — the `--explain` agent-documentation format selector.
31//! * [`pulse`] — the `--timeout` watchdog and `--heartbeat` liveness pulse
32//!   every tool carries.
33//! * [`rules`] — the `.ct/rules.jsonc` invariant surface shared by
34//!   `ct-rules` and `ct-check`: store model, defs, probe gate, the external
35//!   bridge, and outcome adapters.
36//! * [`supervise`] — bounded, captured child execution for the dispatching
37//!   tools (`ct-test`, `ct-each`), including suite sibling resolution.
38//! * [`steer`] — the redirection analyzer behind `ct-steer`: classify a shell
39//!   command into the `ct` tool that serves it, the `PreToolUse` hook protocol,
40//!   and the `.claude/settings.json` install/uninstall merge.
41//! * [`update`] — the daily, non-blocking crates.io sparse-index update check
42//!   wired into the `ct` umbrella (conditional GET, detached background poll).
43//!
44//! Per-command surfaces (the pure logic each `ct-*` tool is built on):
45//!
46//! * [`deps`] — the `deps` built-in check's crate-graph queries over `cargo
47//!   metadata` (including its in-process [`deps::check`] entry point).
48//! * [`modgraph`] — the `mods` built-in check's heuristic intra-crate module-use
49//!   graph, reusing [`deps`]'s assertions at module granularity.
50//! * [`okf`] — Open Knowledge Format support: frontmatter parsing, bundle
51//!   conformance, cross-link checking, and the `okf` built-in check, shared by
52//!   `ct-okf` and the OKF-aware file/structure tools.
53//! * [`okfindex`] — the lazily-maintained fst-segment full-text index over OKF
54//!   concept files behind `ct-okf search` (incremental layering + condense).
55//! * [`okfroots`] — OKF content-root discovery (`.okf` markers, `okf_version`
56//!   index files, `.ct/okf.jsonc` config) and the concept-file feed for the index.
57//! * [`okfscript`] — the `ct-okf --script` batch engine: `.ctb` OKF mutations
58//!   simulated over an in-memory overlay under the prepare/confirm/write standard.
59//! * [`outline`] — `ct-outline`'s heuristic per-language declaration
60//!   detection.
61//! * [`view`] — `ct-view`'s range parsing and context-window merging.
62//! * [`tree`] — `ct-tree`'s line/word/character counts and grouping.
63//! * [`survey`] — `ct-survey`'s format-contextualized workspace → crate → module
64//!   survey, reusing [`deps`]'s `cargo metadata` mechanism for authoritative
65//!   crate grouping and [`modgraph`]'s module naming for the heuristic breakdown.
66//! * [`edit`] — `ct-edit`'s line-scoped, byte-preserving replacement engine.
67//! * [`patch`] — `ct-patch`'s node-path / predicate / value parsing.
68//! * [`testrun`] — `ct-test`'s `--focus` output distiller.
69
70pub mod allowlist;
71pub mod block;
72pub mod blockdoc;
73pub mod cli;
74pub mod completion;
75pub mod deps;
76pub mod edit;
77pub mod editscript;
78pub mod explain;
79pub mod jsonout;
80pub mod modgraph;
81pub mod okf;
82pub mod okfindex;
83pub mod okfroots;
84pub mod okfscript;
85pub mod outline;
86pub mod patch;
87pub mod pattern;
88pub mod payload;
89pub mod pulse;
90pub mod rules;
91pub mod steer;
92pub mod supervise;
93pub mod survey;
94pub mod template;
95pub mod testrun;
96pub mod tree;
97pub mod update;
98pub mod verdict;
99pub mod view;
100pub mod walk;