Skip to main content

Crate coding_tools

Crate coding_tools 

Source
Expand description

Shared library for the coding_tools command-line suite.

The binaries (ct and the ct-* tools it dispatches to) are thin front-ends over the reusable, doctested pieces collected here.

Cross-cutting surfaces, used by several commands:

  • pattern — the shared substring → glob → regex promotion that every pattern-accepting option uses.
  • walk — the shared file-selection predicates (--base/--name/--type /--size/--hidden/--follow) that ct-search/ct-edit/ct-patch/ ct-tree target with.
  • verdict — the shared SUCCESS/ERROR outcome, its exit-status mapping, and the count Expectation that frames a search/edit/patch as a pass/fail test.
  • template — the {TOKEN} substitution engine behind every --emit verdict template.
  • payload — the file: / text: value schemes every payload-typed option resolves through.
  • block — line-anchored literal block matching (and the nearest-miss diagnostic) behind multi-line patterns in ct-search/ct-view/ct-edit.
  • blockdoc — the .ctb block-document parser behind ct-edit --script.
  • editscript — the --script batch engine: compiled edits simulated in memory under the prepare/confirm/write standard.
  • allowlist — the fixed command allow-gates behind ct-test and ct-each.
  • explain — the --explain agent-documentation format selector.
  • pulse — the --timeout watchdog and --heartbeat liveness pulse every tool carries.
  • rules — the .ct/rules.jsonc invariant surface shared by ct-rules and ct-check: store model, defs, probe gate, the external bridge, and outcome adapters.
  • supervise — bounded, captured child execution for the dispatching tools (ct-test, ct-each), including suite sibling resolution.
  • steer — the redirection analyzer behind ct-steer: classify a shell command into the ct tool that serves it, the PreToolUse hook protocol, and the .claude/settings.json install/uninstall merge.
  • update — the daily, non-blocking crates.io sparse-index update check wired into the ct umbrella (conditional GET, detached background poll).

Per-command surfaces (the pure logic each ct-* tool is built on):

  • deps — the deps built-in check’s crate-graph queries over cargo metadata (including its in-process deps::check entry point).
  • modgraph — the mods built-in check’s heuristic intra-crate module-use graph, reusing deps’s assertions at module granularity.
  • okf — Open Knowledge Format support: frontmatter parsing, bundle conformance, cross-link checking, and the okf built-in check, shared by ct-okf and the OKF-aware file/structure tools.
  • okfindex — the lazily-maintained fst-segment full-text index over OKF concept files behind ct-okf search (incremental layering + condense).
  • okfroots — OKF content-root discovery (.okf markers, okf_version index files, .ct/okf.jsonc config) and the concept-file feed for the index.
  • okfscript — the ct-okf --script batch engine: .ctb OKF mutations simulated over an in-memory overlay under the prepare/confirm/write standard.
  • outlinect-outline’s heuristic per-language declaration detection.
  • viewct-view’s range parsing and context-window merging.
  • treect-tree’s line/word/character counts and grouping.
  • surveyct-survey’s format-contextualized workspace → crate → module survey, reusing deps’s cargo metadata mechanism for authoritative crate grouping and modgraph’s module naming for the heuristic breakdown.
  • editct-edit’s line-scoped, byte-preserving replacement engine.
  • patchct-patch’s node-path / predicate / value parsing.
  • testrunct-test’s --focus output distiller.

Modules§

allowlist
The command allow-gates behind the dispatching tools.
block
Line-anchored literal block matching, shared by ct-search, ct-view, and ct-edit.
blockdoc
The ct block document (.ctb) — the suite’s one script format for batched operations whose payloads are verbatim text.
cli
CLI grammars for the leaf tools, hosted in the lib so each tool’s clap definition is introspectable and reusable. Each src/bin/<tool>.rs entry point is a thin parse-and-dispatch wrapper over the Cli struct defined here; the schema-drift guard reconciles every docs/explain/<tool>.json against the live grammar these expose (see [flags]).
completion
Dynamic shell completion for the ct umbrella, via veks-completion.
deps
The deps built-in check’s crate-graph queries.
edit
The per-file replacement engine behind ct-edit: a line-scoped find/replace that preserves every untouched byte (line terminators, indentation, and surrounding text) and records the changed lines.
editscript
The ct-edit --script engine: a batch of edits applied under the prepare/confirm/write standard.
explain
The --explain agent-documentation format selector.
jsonout
Shared JSON result output for the --json / --json-pretty tools: one place that decides compact (the default, one line for piping into jq) vs. pretty-printed (indented, for reading). --json-pretty implies --json.
modgraph
The intra-crate module dependency graph, built heuristically from use statements — the lean, pure-Rust alternative to booting a semantic engine (the same honesty class as crate::outline). It is the single-crate analogue of crate::deps: it produces a [deps::Graph] whose nodes are modules (crate-relative paths like domain::entity) and whose edges are use dependencies, so the very same [deps::forbid_path] / [deps::cycles] / [deps::layer_violations] assertions apply at module granularity.
okf
Open Knowledge Format (OKF) support shared across the suite.
okfindex
A lazily-maintained full-text index over OKF concept files, built on BurntSushi’s fst crate — the same immutable finite-state-transducer machinery search engines like tantivy use for their term dictionaries.
okfroots
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.
okfscript
The ct-okf --script engine: a batch of OKF mutations applied under the prepare/confirm/write standard.
outline
ct-outline’s heuristic declaration detection.
patch
ct-patch’s structured-edit engine for JSON / JSONC / JSONL / YAML.
pattern
Substring → glob → regex pattern promotion, shared by every tool option that accepts a pattern.
payload
The file: / text: value schemes shared by every payload-typed option.
pulse
Run-bounding and liveness, shared by every tool: the --timeout watchdog that keeps any run bounded, and the --heartbeat pulse that gives an agent a sign of life during a long one.
rules
The rule surface shared by ct-rules (say what the rules are) and ct-check (verify them): the .ct/rules.jsonc store model, upward discovery, def expansion, the probe gate, the external-tool bridge, and the expect outcome adapters.
steer
Redirection steering: recognise the ad-hoc shell idioms a ct tool serves better, and (as a Claude Code PreToolUse hook) steer the agent to the ct equivalent instead.
supervise
Bounded child-command execution for the dispatching tools (ct-test, ct-each).
survey
ct-survey’s format-contextualized codebase survey.
template
Token substitution for --emit verdict templates, shared by every tool.
testrun
Pure helpers behind ct-test’s output handling — currently the --focus distiller, which reduces a captured stream to the lines that matter.
tree
Pure helpers behind ct-tree’s reporting: per-file line/word/character counts, the metric-bound predicate, and the immediate-parent grouping used by the per-folder predicate and the directory summary.
update
Best-effort “is there a newer release?” check against the crates.io sparse index, wired into the ct umbrella so the suite can tell you when an update is available without ever getting in your way.
verdict
The shared framed-verdict spine: the SUCCESS/ERROR outcome every tool emits, its 0/1 exit-status mapping, and the Expectation that turns a search’s match count into a Verdict.
view
Pure line-selection helpers behind ct-view’s bounded, context-aware reads: parsing a --range spec, expanding --match hits into context windows, and grouping the kept line indices into contiguous runs for display.
walk
Shared file-selection traversal.