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) thatct-search/ct-edit/ct-patch/ct-treetarget with.verdict— the sharedSUCCESS/ERRORoutcome, its exit-status mapping, and the countExpectation that frames a search/edit/patch as a pass/fail test.template— the{TOKEN}substitution engine behind every--emitverdict template.payload— thefile:/text:value schemes every payload-typed option resolves through.block— line-anchored literal block matching (and the nearest-miss diagnostic) behind multi-line patterns inct-search/ct-view/ct-edit.blockdoc— the.ctbblock-document parser behindct-edit --script.editscript— the--scriptbatch engine: compiled edits simulated in memory under the prepare/confirm/write standard.allowlist— the fixed command allow-gates behindct-testandct-each.explain— the--explainagent-documentation format selector.pulse— the--timeoutwatchdog and--heartbeatliveness pulse every tool carries.rules— the.ct/rules.jsoncinvariant surface shared byct-rulesandct-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.
Per-command surfaces (the pure logic each ct-* tool is built on):
deps— thedepsbuilt-in check’s crate-graph queries overcargo metadata(including its in-processdeps::checkentry point).modgraph— themodsbuilt-in check’s heuristic intra-crate module-use graph, reusingdeps’s assertions at module granularity.outline—ct-outline’s heuristic per-language declaration detection.view—ct-view’s range parsing and context-window merging.tree—ct-tree’s line/word/character counts and grouping.edit—ct-edit’s line-scoped, byte-preserving replacement engine.patch—ct-patch’s node-path / predicate / value parsing.testrun—ct-test’s--focusoutput distiller.
Modules§
- allowlist
- The command allow-gates behind the dispatching tools.
- block
- Line-anchored literal block matching, shared by
ct-search,ct-view, andct-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>.rsentry point is a thin parse-and-dispatch wrapper over theClistruct defined here; the schema-drift guard reconciles everydocs/explain/<tool>.jsonagainst the live grammar these expose (see [flags]). - deps
- The
depsbuilt-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 --scriptengine: a batch of edits applied under the prepare/confirm/write standard. - explain
- The
--explainagent-documentation format selector. - modgraph
- The intra-crate module dependency graph, built heuristically from
usestatements — the lean, pure-Rust alternative to booting a semantic engine (the same honesty class ascrate::outline). It is the single-crate analogue ofcrate::deps: it produces a [deps::Graph] whose nodes are modules (crate-relative paths likedomain::entity) and whose edges areusedependencies, so the very same [deps::forbid_path] / [deps::cycles] / [deps::layer_violations] assertions apply at module granularity. - 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
--timeoutwatchdog that keeps any run bounded, and the--heartbeatpulse 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) andct-check(verify them): the.ct/rules.jsoncstore model, upward discovery, def expansion, the probe gate, the external-tool bridge, and theexpectoutcome adapters. - supervise
- Bounded child-command execution for the dispatching tools (
ct-test,ct-each). - template
- Token substitution for
--emitverdict templates, shared by every tool. - testrun
- Pure helpers behind
ct-test’s output handling — currently the--focusdistiller, 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. - verdict
- The shared framed-verdict spine: the
SUCCESS/ERRORoutcome every tool emits, its0/1exit-status mapping, and theExpectation that turns a search’s match count into aVerdict. - view
- Pure line-selection helpers behind
ct-view’s bounded, context-aware reads: parsing a--rangespec, expanding--matchhits into context windows, and grouping the kept line indices into contiguous runs for display. - walk
- Shared file-selection traversal.