lean-ctx 3.8.1

Context Runtime for AI Agents with CCP. 71 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
Documentation
use rmcp::model::Tool;
use rmcp::ErrorData;
use serde_json::{json, Map, Value};

use crate::server::tool_trait::{get_str, McpTool, ToolContext, ToolOutput};
use crate::tool_defs::tool_def;

pub struct CtxSkillifyTool;

impl McpTool for CtxSkillifyTool {
    fn name(&self) -> &'static str {
        "ctx_skillify"
    }

    fn tool_def(&self) -> Tool {
        tool_def(
            "ctx_skillify",
            "Codify recurring patterns from this project's session diary + knowledge into versioned, git-committable .cursor/rules/skillify-*.mdc files. Actions: mine (distill & write/merge rules), list (show generated rules), status (config + counts), promote (copy a project rule to ~/.cursor/rules). Precision-biased; only acts when invoked; re-runs are idempotent.",
            json!({
                "type": "object",
                "properties": {
                    "action": {
                        "type": "string",
                        "enum": ["mine", "list", "status", "promote"],
                        "description": "Skillify action (default: mine)"
                    },
                    "slug": {
                        "type": "string",
                        "description": "Rule slug for the promote action (e.g. skillify-stop-before-build)"
                    }
                }
            }),
        )
    }

    fn handle(
        &self,
        args: &Map<String, Value>,
        ctx: &ToolContext,
    ) -> Result<ToolOutput, ErrorData> {
        let action = get_str(args, "action").unwrap_or_else(|| "mine".to_string());
        let slug = get_str(args, "slug");
        let result =
            crate::tools::ctx_skillify::handle(&ctx.project_root, &action, slug.as_deref());
        Ok(ToolOutput::simple(result))
    }
}