tools tier

tools-prompt-shaper

prompt-shape: screen, correct, and structure operator input into a shaped prompt before it is sent to any model — never sends, only prints.

prompt-shape: screen, correct, and structure operator input into a shaped prompt before it is sent to any model — never sends, only prints.

Tiertools
Roleunclassified (baselined)
Pathcrates/tools/prompt-shaper
Edition2021
Targetsprompt-shape, tools_prompt_shaper
Public items19 across 4 modules
Tests40

What it is for

tools-prompt-shaper — screen, correct, and structure operator input into a shaped prompt before it is sent to any model.

Pipeline order is the design (Sprint 3.21, Gate 1.5.6): hard-rules DLP screening runs FIRST so a credential is redacted before the local model — or any model — ever sees the text. The pipeline never sends anything anywhere; it prints a shaped prompt for the operator to review.

Modules land one per TDD task:

model is unreachable or returns malformed output.

as spans, never a rewritten body.

T1 lands the crate skeleton and CLI surface only; modules are added as their task lands.

Capabilities

config (other)

T5: config plumbing. SHAPER_MODEL, OLLAMA_URL, and a hard-rules-only

Item
pub const DEFAULT_OLLAMA_URL: & str
fn parse_env_file(contents : & str) -> HashMap <String, String>

Config

T5: config plumbing. SHAPER_MODEL, OLLAMA_URL, and a hard-rules-only

Item
pub struct Config
fn resolve(cli_model : Option <& str>, cli_ollama_url : Option <& str>, cli_no_model : bool, process_env : & HashMap <String, String>, file_env : & HashMap <String, String>, default_model : & str,) -> Config

model (other)

T3: the local-model typed ask, and the degradation path when the model

Item
pub const DEFAULT_MODEL: & str
pub const SYSTEM_PROMPT: & str
async fn ask(provider : & dyn AiProvider, model : & str, redacted_text : & str,) -> Result <ModelAsk, Degraded>

Degraded

T3: the local-model typed ask, and the degradation path when the model

Item
pub enum Degraded
Degraded :: fn message(& self) -> String

Intent

T3: the local-model typed ask, and the degradation path when the model

Item
pub enum Intent

ModelAsk

T3: the local-model typed ask, and the degradation path when the model

Item
pub struct ModelAsk

TypoCorrection

T3: the local-model typed ask, and the degradation path when the model

Item
pub struct TypoCorrection

ScreenResult

T2: hard-rules DLP screening. Runs FIRST, before any model — local or

Item
pub struct ScreenResult
ScreenResult :: fn has_findings(& self) -> bool
fn screen(text : & str) -> ScreenResult

template (other)

T4: deterministic template fill.

Item
fn fill(intent : Option <Intent>, text : & str, obfuscation_suspected : bool) -> String

AppliedCorrections

T4: deterministic template fill.

Item
pub struct AppliedCorrections
fn apply_corrections(text : & str, corrections : & TypoCorrection) -> AppliedCorrections

DroppedCorrection

T4: deterministic template fill.

Item
pub struct DroppedCorrection

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

tools_prompt_shaper

flowchart TD
  n_tools_prompt_shaper["tools_prompt_shaper"]
  n_tools_prompt_shaper --> n_config["config"]
  n_tools_prompt_shaper --> n_model["model"]
  n_tools_prompt_shaper --> n_screen["screen"]
  n_tools_prompt_shaper --> n_template["template"]

Public surface

`config`

ItemWhat it is
pub const DEFAULT_OLLAMA_URL: & strDefault Ollama base URL, matching infrastructure_ai::OllamaProvider::local.
pub struct ConfigResolved configuration for one run.
fn parse_env_file(contents : & str) -> HashMap <String, String>Parse a KEY=VALUE config file in the ~/.config/claude-bridge.env convention: blank lines and #-prefixed comment lines are ignored, no quoting or escaping
fn resolve(cli_model : Option <& str>, cli_ollama_url : Option <& str>, cli_no_model : bool, process_env : & HashMap <String, String>, file_env : & HashMap <String, String>, default_model : & str,) -> ConfigResolve config from explicit sources

`model`

ItemWhat it is
pub const DEFAULT_MODEL: & strDefault local model (Sprint 3.21): general reasoning, not a coder model — intent classification and orthography are not code-shaped tasks.
pub const SYSTEM_PROMPT: & strSystem prompt for the single typed-ask call
pub enum IntentThe intent the model assigns to the (already-screened) text
pub struct TypoCorrectionOne correction as a span-and-replacement pair — never a rewritten body
pub struct ModelAskThe three typed asks the local model answers in one call.
pub enum DegradedWhy the model step did not produce a ModelAsk
Degraded :: fn message(& self) -> StringOne-line, operator-facing explanation of what was unavailable and why
async fn ask(provider : & dyn AiProvider, model : & str, redacted_text : & str,) -> Result <ModelAsk, Degraded>Ask the local model to classify intent, propose typo corrections, and flag suspected obfuscation over redacted_text

`screen`

ItemWhat it is
pub struct ScreenResultResult of the hard-rules screening pass.
ScreenResult :: fn has_findings(& self) -> boolWhether screening found anything to redact.
fn screen(text : & str) -> ScreenResultScreen text with dlp-detect's zero-config default policy and return the redacted text plus the findings that drove the redaction.

`template`

ItemWhat it is
pub struct AppliedCorrectionsResult of splicing corrections into text: which ones landed, and which were dropped (and why they don't appear in text).
pub struct DroppedCorrectionA correction that was not applied, and why.
fn apply_corrections(text : & str, corrections : & TypoCorrection) -> AppliedCorrectionsSplice each correction's replacement in place of the first exact, non-fenced occurrence of its span
fn fill(intent : Option <Intent>, text : & str, obfuscation_suspected : bool) -> StringFill the deterministic skeleton for intent around text

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into foundation, infrastructure.

Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)tools
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/tools/prompt-shaper
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_tools["tools"] --> n_foundation["foundation"]
  n_tools["tools"] --> n_infrastructure["infrastructure"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-bounded-io`foundationnoalways
`infrastructure-ai`infrastructurenoalways
`infrastructure-dlp-detect`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
clap^4derivenoalways
serde^1derive, derivenoalways
serde_json^1noalways
tokio^1full, macros, rt-multi-threadnoalways

Development, in this workspace.

CrateTierOptionalOnly on
`tools-cli-conformance`toolsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["tools-prompt-shaper"]
  SELF -->|development| n_tools_cli_conformance["tools-cli-conformance"]
  SELF -->|runtime| n_foundation_bounded_io["foundation-bounded-io"]
  SELF -->|runtime| n_infrastructure_ai["infrastructure-ai"]
  SELF -->|runtime| n_infrastructure_dlp_detect["infrastructure-dlp-detect"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
binprompt-shape`src/main.rs`
libtools_prompt_shaper`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
HOMEsrc/main.rs

No workspace crate depends on this one.

Verification

KindCount
Unit tests40
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
config400
model700
screen200
template400

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1919
Public modules with a //! block44
pie showData
    title Public items with rustdoc
    "Documented" : 19
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files6
Source lines1217
Code lines891
Public API items19
Public modules4
Tests40
Examples0
Cargo features0
Direct runtime dependencies7
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 3
    "enum" : 2
    "function" : 6
    "method" : 2
    "struct" : 6
pie showData
    title Rust source composition
    "Code" : 891
    "Blank or comment" : 326

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All tools · Manual