eggsact 1.2.7

Deterministic MCP and in-process utility tools for coding agents
Documentation
use serde_json::Value;

pub fn validate_regex_input() -> Value {
    serde_json::json!({
        "type": "object",
        "properties": {
            "pattern": {"type": "string", "description": "Regular expression pattern", "maxLength": 1000},
            "samples": {"type": "array", "items": {"type": "string"}, "description": "List of strings to test against", "maxItems": 100},
            "flags": {"type": "array", "items": {"type": "string"}, "description": "Flag names (IGNORECASE, MULTILINE, etc.)", "maxItems": 10},
            "ignore_case": {"type": "boolean", "default": false, "description": "Use IGNORECASE flag"},
            "multiline": {"type": "boolean", "default": false, "description": "Use MULTILINE flag"},
            "dotall": {"type": "boolean", "default": false, "description": "Use DOTALL flag"},
            "ascii": {"type": "boolean", "default": false, "description": "ASCII mode (not supported by eggsact dialect; use \\d, \\w, \\s for ASCII-oriented matches)"}
        },
        "required": ["pattern", "samples"]
    })
}

pub fn regex_finditer_input() -> Value {
    serde_json::json!({
        "type": "object",
        "properties": {
            "pattern": {"type": "string", "description": "Regular expression pattern", "maxLength": 1000},
            "text": {"type": "string", "description": "Input string to search"},
            "flags": {"type": "array", "items": {"type": "string"}, "description": "Flag names (IGNORECASE, MULTILINE, DOTALL, etc.)", "maxItems": 10},
            "max_matches": {"type": "integer", "default": 100, "minimum": 0, "maximum": 1000, "description": "Maximum matches to return"},
            "include_line_column": {"type": "boolean", "default": true, "description": "Include line and column info"},
            "include_groups": {"type": "boolean", "default": true, "description": "Include capture groups"}
        },
        "required": ["pattern", "text"]
    })
}

pub fn regex_safety_check_input() -> Value {
    serde_json::json!({
        "type": "object",
        "properties": {
            "pattern": {"type": "string", "description": "Regular expression pattern to check"}
        },
        "required": ["pattern"]
    })
}

pub fn validate_regex_output() -> Value {
    serde_json::json!({"type":"object","properties":{"valid_pattern":{"type":"boolean"},"results":{"type":"array"},"error":{"type":["string","null"]},"flags_used":{"type":"object"},"engine_used":{"type":"string","description":"Backend engine used (rust-regex or fancy-regex)"},"dialect":{"type":"string","description":"Regex dialect (eggsact-regex)"},"unsupported_features":{"type":"array","items":{"type":"string"},"description":"Unsupported PCRE constructs detected in pattern"},"execution_error":{"type":["string","null"],"description":"Runtime execution error from the regex engine (distinct from compilation error)"},"policy_allowed":{"type":["boolean","null"],"description":"Whether the pattern passed safety/policy checks (null if not checked)"}}})
}

pub fn regex_finditer_output() -> Value {
    serde_json::json!({"type":"object","properties":{"valid_pattern":{"type":"boolean"},"matches":{"type":"array","description":"List of regex matches with positions and groups"},"truncated":{"type":"boolean"},"match_count":{"type":"integer"},"error":{"type":["string","null"]},"engine_used":{"type":"string","description":"Backend engine used (rust-regex or fancy-regex)"},"dialect":{"type":"string","description":"Regex dialect (eggsact-regex)"},"unsupported_features":{"type":"array","items":{"type":"string"},"description":"Unsupported PCRE constructs detected in pattern"},"execution_error":{"type":["string","null"],"description":"Runtime execution error from the regex engine (distinct from compilation error)"},"policy_allowed":{"type":["boolean","null"],"description":"Whether the pattern passed safety/policy checks (null if not checked)"}}})
}

pub fn regex_safety_check_output() -> Value {
    serde_json::json!({"type":"object","properties":{"valid_pattern":{"type":"boolean"},"risk":{"type":"string","enum":["low","medium","high"]},"findings":{"type":"array","description":"Safety findings with kind, span, and message","items":{"type":"object","properties":{"kind":{"type":"string"},"span":{"type":"array","items":{"type":"integer"}},"message":{"type":"string"}}}}}})
}