use crate::mcp::registry::{ToolCost, ToolExposure, ToolSpec, ToolStability};
use crate::mcp::schemas::*;
use crate::tools::*;
pub const TEXT_TOOLS: &[ToolSpec] = &[
ToolSpec {
name: "text_measure",
description: "Measure exact text properties: UTF-8 byte length, codepoint count, words, lines, whitespace, newline style, Unicode normalization state, invisibles, and mixed-script signals.",
handler: text_measure,
input_schema: text_measure_input,
output_schema: text_measure_output,
category: "text",
tier: 0,
profiles: &["full", "default"],
tags: &["text", "measurement", "unicode", "metrics"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_equal",
description: "Compare two strings under raw, Unicode-normalized, casefolded, or trimmed modes and report exact equality evidence.",
handler: text_equal,
input_schema: text_equal_input,
output_schema: text_equal_output,
category: "text",
tier: 0,
profiles: &["full", "default", "codegg_core"],
tags: &["text", "comparison", "equality", "unicode"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_diff_explain",
description: "Explain why two strings differ, including spans, codepoints, Unicode names, normalization equivalence, confusables, invisibles, and agent-facing classification.",
handler: text_diff_explain,
input_schema: text_diff_explain_input,
output_schema: text_diff_explain_output,
category: "text",
tier: 1,
profiles: &["full", "default", "codegg_core", "codegg_patch"],
tags: &["text", "diff", "comparison", "unicode"],
exposure: ToolExposure::Default,
harness_use: &["edit_preflight"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_inspect",
description: "Inspect a string for hidden characters, Unicode confusables, mixed scripts, normalization state, and display-safe representation. Can report both original and normalized text analysis.",
handler: text_inspect,
input_schema: text_inspect_input,
output_schema: text_inspect_output,
category: "text",
tier: 1,
profiles: &["full", "default", "codegg_core", "codegg_unicode_security"],
tags: &["text", "unicode", "inspection", "security"],
exposure: ToolExposure::Default,
harness_use: &["prompt_input_preflight"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_count",
description: "Count exact characters or produce a character frequency table with codepoint positions, grapheme clusters, bytes, or substring matches.",
handler: text_count,
input_schema: text_count_input,
output_schema: text_count_output,
category: "text",
tier: 0,
profiles: &["full", "default"],
tags: &["text", "count", "character", "frequency"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_truncate",
description: "Truncate a string to a specified number of grapheme clusters (user-perceived characters). Preserves emoji, combining sequences, and flag sequences intact. Useful for AI agent prompts where visual length matters.",
handler: text_truncate,
input_schema: text_truncate_input,
output_schema: text_truncate_output,
category: "text",
tier: 3,
profiles: &["full"],
tags: &["text", "truncation", "grapheme", "unicode"],
exposure: ToolExposure::ExpertOnly,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_transform",
description: "Apply deterministic text transformations: Unicode normalization (NFC/NFD/NFKC/NFKD), casefold, trim, newline normalization, zero-width removal, bidi control stripping, and visible representation.",
handler: text_transform,
input_schema: text_transform_input,
output_schema: text_transform_output,
category: "text",
tier: 2,
profiles: &["full", "codegg_unicode_security"],
tags: &["text", "unicode", "transform", "normalization", "sanitation"],
exposure: ToolExposure::Contextual,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_position",
description: "Convert between byte offsets, codepoint indices, line/column positions, and UTF-16 offsets.",
handler: text_position,
input_schema: text_position_input,
output_schema: text_position_output,
category: "text",
tier: 2,
profiles: &["full", "codegg_unicode_security"],
tags: &["text", "position", "offset", "unicode", "lsp"],
exposure: ToolExposure::Contextual,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_hash",
description: "Compute multi-algorithm hashes of text for exact identity checking without canonicalization. Prefer text_fingerprint when Unicode, newline, or case variants should compare equal.",
handler: text_hash,
input_schema: text_hash_input,
output_schema: text_hash_output,
category: "text",
tier: 2,
profiles: &["full"],
tags: &["text", "hash", "identity", "security"],
exposure: ToolExposure::Contextual,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "escape_text",
description: "Escape text for various output formats.",
handler: escape_text,
input_schema: escape_text_input,
output_schema: escape_text_output,
category: "text",
tier: 1,
profiles: &["full", "default"],
tags: &["text", "escape", "encoding", "shell", "json", "regex"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "unescape_text",
description: "Unescape text from various formats.",
handler: unescape_text,
input_schema: unescape_text_input,
output_schema: unescape_text_output,
category: "text",
tier: 1,
profiles: &["full", "default"],
tags: &["text", "escape", "encoding", "shell", "json", "regex"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_window",
description: "Get a window around a position in text with context lines. Shows line at position with surrounding context, position metrics, and character details.",
handler: text_window,
input_schema: text_window_input,
output_schema: text_window_output,
category: "text",
tier: 1,
profiles: &["full", "default"],
tags: &["text", "position", "context", "unicode", "window"],
exposure: ToolExposure::Default,
harness_use: &["none"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_fingerprint",
description: "Compute a SHA-256 fingerprint with canonicalization for Unicode normalization, newline style, casefold, and final-newline trimming. Prefer over text_hash when equivalent texts with different encodings or line endings should share an identity.",
handler: text_fingerprint_tool,
input_schema: text_fingerprint_input,
output_schema: text_fingerprint_output,
category: "text",
tier: 0,
profiles: &["full", "default", "codegg_core", "codegg_repo_audit"],
tags: &["text", "hash", "fingerprint", "sha256", "identity", "canonicalization"],
exposure: ToolExposure::Default,
harness_use: &["edit_preflight"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_replace_check",
description: "Check whether a single-string replacement would apply cleanly, reporting match count, ambiguity, and preview. Prefer edit_preflight for patch-shaped or multi-hunk edits needing an apply verdict.",
handler: text_replace_check_tool,
input_schema: text_replace_check_input,
output_schema: text_replace_check_output,
category: "text",
tier: 1,
profiles: &["full", "default", "codegg_core", "codegg_core_min", "codegg_patch"],
tags: &["text", "replace", "edit", "safety", "check"],
exposure: ToolExposure::Default,
harness_use: &["edit_preflight"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "line_range_extract",
description: "Extract exact line ranges from text and return stable offsets, byte positions, line counts, and optional fingerprint.",
handler: line_range_extract_tool,
input_schema: line_range_extract_input,
output_schema: line_range_extract_output,
category: "text",
tier: 1,
profiles: &["full", "default", "codegg_patch"],
tags: &["text", "line", "range", "extract", "offset"],
exposure: ToolExposure::Default,
harness_use: &["edit_preflight"],
aliases: &[],
cost: ToolCost::Cheap,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "line_range_compare",
description: "Compare a line range from two text inputs with exact, trailing-whitespace-ignoring, or newline-normalizing comparison.",
handler: line_range_compare_tool,
input_schema: line_range_compare_input,
output_schema: line_range_compare_output,
category: "text",
tier: 2,
profiles: &["full", "codegg_patch"],
tags: &["text", "line", "range", "compare", "diff"],
exposure: ToolExposure::Contextual,
harness_use: &["edit_preflight"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "prompt_input_inspect",
description: "Deterministically inspect text for red flags that may influence agents or humans unexpectedly. Detects hidden Unicode characters, bidirectional controls, HTML comments, Markdown link mismatches, ANSI escapes, terminal controls, base64-like blobs, instruction-like phrases, and very long minified lines. This is NOT a prompt-injection detector -- it reports observable features only, not intent.",
handler: prompt_input_inspect_tool,
input_schema: prompt_input_inspect_input,
output_schema: prompt_input_inspect_output,
category: "text",
tier: 2,
profiles: &["full", "codegg_unicode_security", "codegg_preflight"],
tags: &["text", "security", "inspection", "prompt", "unicode", "hidden"],
exposure: ToolExposure::HarnessOnly,
harness_use: &["prompt_input_preflight"],
aliases: &[],
cost: ToolCost::Moderate,
stability: ToolStability::Stable,
composite: false,
},
ToolSpec {
name: "text_security_inspect",
description: "Screen text for security hygiene (hidden characters, confusables, risky prompt patterns) and return an allow/review/block verdict with findings. Prefer over text_inspect for a go/no-go decision and over single-purpose unicode checks when screening untrusted input. Reports observable features only, not intent.",
handler: text_security_inspect,
input_schema: text_security_inspect_input,
output_schema: text_security_inspect_output,
category: "text",
tier: 1,
profiles: &["full", "codegg_core", "codegg_core_min", "codegg_preflight", "codegg_unicode_security"],
tags: &["text", "unicode", "security", "composite", "prompt", "inspection"],
exposure: ToolExposure::Default,
harness_use: &["prompt_input_preflight"],
aliases: &[],
cost: ToolCost::Heavy,
stability: ToolStability::Stable,
composite: true,
},
];