mod all_tools;
mod listing;
mod types;
pub use all_tools::{all_tools as all_tools_vec, PROFILE_NAMES};
pub use listing::{
all_tools as all_tools_list, available_profiles, compact_input_schema, compact_output_schema,
find_close_match, get_tool, input_schema_for, is_route_critical, list_modern_tool_values,
list_tool_definitions, mcp_tool_definitions, output_schema_for, tool_count, tool_handler_for,
tool_names, tool_names_for_profile_audience, tools_for_profile, tools_for_profile_audience,
ToolListAudience, ToolListOptions, ROUTE_CRITICAL_TOOLS,
};
pub use types::{
annotations_for_spec, modern_tool_value, ToolAnnotations, ToolCost, ToolDefinition,
ToolExposure, ToolHandler, ToolSpec, ToolStability,
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn exposure_enum_serializes_to_expected_strings() {
assert_eq!(ToolExposure::Default.as_str(), "default");
assert_eq!(ToolExposure::Contextual.as_str(), "contextual");
assert_eq!(ToolExposure::ExpertOnly.as_str(), "expert_only");
assert_eq!(ToolExposure::HarnessOnly.as_str(), "harness_only");
assert_eq!(ToolExposure::Hidden.as_str(), "hidden");
}
#[test]
fn cost_enum_serializes_to_expected_strings() {
assert_eq!(ToolCost::Cheap.as_str(), "cheap");
assert_eq!(ToolCost::Moderate.as_str(), "moderate");
assert_eq!(ToolCost::Heavy.as_str(), "heavy");
}
#[test]
fn stability_enum_serializes_to_expected_strings() {
assert_eq!(ToolStability::Stable.as_str(), "stable");
assert_eq!(ToolStability::Deprecated.as_str(), "deprecated");
assert_eq!(ToolStability::Experimental.as_str(), "experimental");
}
#[test]
fn all_tools_have_valid_exposure() {
for spec in all_tools_vec() {
let _ = spec.exposure.as_str();
}
}
#[test]
fn tool_count_matches_documented_registry_size() {
assert_eq!(tool_count(), 86);
}
#[test]
fn utility_categories_append_to_the_legacy_registration_prefix() {
let names = tool_names();
assert_eq!(
&names[80..],
&[
"ip_inspect",
"cidr_inspect",
"codec_convert",
"radix_convert",
"datetime_convert",
"cron_inspect"
]
);
assert_eq!(names.len(), 86);
}
#[test]
fn hidden_tools_excluded_from_mcp_definitions() {
let definitions = mcp_tool_definitions();
for tool in &definitions {
assert_ne!(tool.llm_exposure.as_deref(), Some("hidden"));
}
}
#[test]
fn full_profile_excludes_hidden_tools() {
let tools = tools_for_profile("full");
for spec in tools {
assert_ne!(spec.exposure, ToolExposure::Hidden);
}
}
#[test]
fn harness_only_excluded_from_model_audience_default() {
let model_tools = tool_names_for_profile_audience("default", ToolListAudience::Model);
for spec in all_tools_vec() {
if spec.exposure == ToolExposure::HarnessOnly && spec.profiles.contains(&"default") {
assert!(
!model_tools.contains(&spec.name),
"harness_only tool '{}' should not appear in default model audience",
spec.name
);
}
}
}
#[test]
fn harness_only_excluded_from_model_audience_codegg_core_min() {
let model_tools =
tool_names_for_profile_audience("codegg_core_min", ToolListAudience::Model);
for spec in all_tools_vec() {
if spec.exposure == ToolExposure::HarnessOnly
&& spec.profiles.contains(&"codegg_core_min")
{
assert!(
!model_tools.contains(&spec.name),
"harness_only tool '{}' should not appear in codegg_core_min model audience",
spec.name
);
}
}
}
#[test]
fn harness_only_excluded_from_model_audience_codegg_core() {
let model_tools = tool_names_for_profile_audience("codegg_core", ToolListAudience::Model);
for spec in all_tools_vec() {
if spec.exposure == ToolExposure::HarnessOnly && spec.profiles.contains(&"codegg_core")
{
assert!(
!model_tools.contains(&spec.name),
"harness_only tool '{}' should not appear in codegg_core model audience",
spec.name
);
}
}
}
#[test]
fn harness_only_excluded_from_model_audience_full() {
let model_tools = tool_names_for_profile_audience("full", ToolListAudience::Model);
for spec in all_tools_vec() {
if spec.exposure == ToolExposure::HarnessOnly {
assert!(
!model_tools.contains(&spec.name),
"harness_only tool '{}' should not appear in full model audience",
spec.name
);
}
}
}
#[test]
fn harness_audience_includes_harness_only_tools() {
let harness_tools =
tool_names_for_profile_audience("codegg_preflight", ToolListAudience::Harness);
let harness_only_in_profile: Vec<&str> = all_tools_vec()
.iter()
.filter(|t| {
t.exposure == ToolExposure::HarnessOnly && t.profiles.contains(&"codegg_preflight")
})
.map(|t| t.name)
.collect();
for name in &harness_only_in_profile {
assert!(
harness_tools.contains(name),
"harness audience for codegg_preflight should include '{}'",
name
);
}
}
fn snapshot_names(profile: &str, audience: ToolListAudience) -> Vec<String> {
let mut names: Vec<String> = tool_names_for_profile_audience(profile, audience)
.into_iter()
.map(String::from)
.collect();
names.sort();
names
}
#[test]
fn profile_snapshot_codegg_core_min_model() {
let actual = snapshot_names("codegg_core_min", ToolListAudience::Model);
let expected = vec![
"command_preflight",
"config_preflight",
"edit_preflight",
"text_replace_check",
"text_security_inspect",
"validate_json",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_core_model() {
let actual = snapshot_names("codegg_core", ToolListAudience::Model);
let expected = vec![
"cargo_toml_inspect",
"code_block_map",
"command_preflight",
"config_preflight",
"edit_preflight",
"identifier_inspect",
"import_export_inspect",
"path_normalize",
"repo_language_detect",
"structured_data_compare",
"test_command_suggest",
"text_diff_explain",
"text_equal",
"text_fingerprint",
"text_inspect",
"text_replace_check",
"text_security_inspect",
"validate_json",
"validate_toml",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_preflight_harness() {
let actual = snapshot_names("codegg_preflight", ToolListAudience::Harness);
let expected = vec![
"command_preflight",
"config_preflight",
"dependency_edit_preflight",
"edit_preflight",
"lockfile_inspect",
"patch_apply_check",
"patch_contract_check",
"path_batch_scope_check",
"path_scope_check",
"prompt_input_inspect",
"shell_split",
"text_security_inspect",
"unicode_policy_check",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_patch_model() {
let actual = snapshot_names("codegg_patch", ToolListAudience::Model);
let expected = vec![
"diff_risk_classify",
"edit_preflight",
"line_range_compare",
"line_range_extract",
"lockfile_inspect",
"patch_contract_check",
"patch_summary",
"symbol_name_diff",
"text_diff_explain",
"text_replace_check",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_patch_harness() {
let actual = snapshot_names("codegg_patch", ToolListAudience::Harness);
let expected = vec![
"diff_risk_classify",
"edit_preflight",
"line_range_compare",
"line_range_extract",
"lockfile_inspect",
"patch_apply_check",
"patch_contract_check",
"patch_summary",
"path_batch_scope_check",
"symbol_name_diff",
"text_diff_explain",
"text_replace_check",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_config_model() {
let actual = snapshot_names("codegg_config", ToolListAudience::Model);
let expected = vec![
"config_file_inspect",
"config_preflight",
"dependency_edit_preflight",
"dotenv_validate",
"ini_validate",
"json_canonicalize",
"json_compare",
"json_extract",
"structured_data_compare",
"toml_shape",
"validate_json",
"validate_schema_light",
"validate_toml",
"version_compare",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_config_harness() {
let actual = snapshot_names("codegg_config", ToolListAudience::Harness);
let expected = vec![
"config_file_inspect",
"config_preflight",
"dependency_edit_preflight",
"dotenv_validate",
"ini_validate",
"json_canonicalize",
"json_compare",
"json_extract",
"structured_data_compare",
"toml_shape",
"validate_json",
"validate_schema_light",
"validate_toml",
"version_compare",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_shell_model() {
let actual = snapshot_names("codegg_shell", ToolListAudience::Model);
let expected = vec![
"argv_compare",
"command_preflight",
"regex_safety_check",
"shell_quote_join",
"test_command_suggest",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_shell_harness() {
let actual = snapshot_names("codegg_shell", ToolListAudience::Harness);
let expected = vec![
"argv_compare",
"command_preflight",
"regex_safety_check",
"shell_quote_join",
"shell_split",
"test_command_suggest",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_unicode_security_model() {
let actual = snapshot_names("codegg_unicode_security", ToolListAudience::Model);
let expected = vec![
"canonicalize_text",
"identifier_inspect",
"text_inspect",
"text_position",
"text_security_inspect",
"text_transform",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_unicode_security_harness() {
let actual = snapshot_names("codegg_unicode_security", ToolListAudience::Harness);
let expected = vec![
"canonicalize_text",
"identifier_inspect",
"prompt_input_inspect",
"text_inspect",
"text_position",
"text_security_inspect",
"text_transform",
"unicode_policy_check",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_codegg_repo_audit_model() {
let actual = snapshot_names("codegg_repo_audit", ToolListAudience::Model);
let expected = vec![
"cargo_toml_inspect",
"code_block_map",
"code_fence_extract",
"config_file_inspect",
"dependency_edit_preflight",
"diff_risk_classify",
"identifier_table_inspect",
"import_export_inspect",
"json_shape",
"lockfile_inspect",
"markdown_structure",
"patch_contract_check",
"repo_language_detect",
"repo_manifest_inspect",
"repo_tree_summarize",
"symbol_name_diff",
"test_command_suggest",
"text_fingerprint",
];
assert_eq!(
actual,
expected.into_iter().map(String::from).collect::<Vec<_>>()
);
}
#[test]
fn profile_snapshot_human_math_model() {
let names = snapshot_names("human_math", ToolListAudience::Model);
assert!(!names.is_empty(), "human_math model should have tools");
}
#[test]
fn profile_snapshot_default_model() {
let names = snapshot_names("default", ToolListAudience::Model);
assert!(!names.is_empty(), "default model should have tools");
for name in &names {
let spec = get_tool(name).expect("tool should exist");
assert_ne!(spec.exposure, ToolExposure::HarnessOnly);
}
}
#[test]
fn preflight_exposure_policy_is_intentional() {
let model_preflight_tools = ["edit_preflight", "command_preflight", "config_preflight"];
for name in &model_preflight_tools {
let spec = get_tool(name).expect("tool should exist");
assert_eq!(
spec.exposure,
ToolExposure::Default,
"{} should be Default exposure (model-visible advisory)",
name
);
}
let harness_only_tools = [
"patch_apply_check",
"path_scope_check",
"prompt_input_inspect",
"unicode_policy_check",
"shell_split",
];
for name in &harness_only_tools {
let spec = get_tool(name).expect("tool should exist");
assert_eq!(
spec.exposure,
ToolExposure::HarnessOnly,
"{} should be HarnessOnly exposure (enforcement tool)",
name
);
}
let spec = get_tool("text_security_inspect").expect("tool should exist");
assert_eq!(
spec.exposure,
ToolExposure::Default,
"text_security_inspect should be Default (model-visible composite)"
);
}
}