-- pmacs-mcp-ai/init.lua --- T M9.8 AI-assistance example package. -- -- Public API: -- -- local ai = require("pmacs-mcp-ai") -- ai.configure { -- server_label = "claude-mcp", -- the label of an MCP server already -- -- spawned via pmacs.mcp.spawn -- prompts = { -- fn = "review_function", -- which advertised prompt handles -- -- the function-context flow -- project = "review_project", -- ... project-context flow -- ask = "ask_freeform", -- ... freeform-question flow -- }, -- } -- ai.unconfigure() -- drop commands; no server change -- -- The package's three commands (defined on first configure): -- -- ai.ask-about-function -- selects the enclosing function via tree-sitter -- and sends as code-context -- ai.ask-about-project -- collects all file-backed buffers and sends -- as a structured `files: [{path, content}, ...]` -- array (Q5: explicit JSON beats separator -- encoding) -- ai.ask -- prompts for a question, sends with no buffer -- context -- -- Architectural commitment (the M9.8 ship gate): -- -- * Zero direct calls into the Rust core. Everything reaches the -- Rust side through the public Lua surface (`pmacs.mcp.*`, -- `pmacs.parse.*`, `pmacs.command.*`, etc.). -- * Zero model-specific code. The package speaks MCP; the model -- behind the configured server is interchangeable. The -- `m9_8_server_pluggability_*` tests pin this by configure'ing -- two distinct fake servers and verifying the same command -- routes to whichever is currently configured. -- -- Composition story: -- -- * Rendering: composes with `pmacs-mcp-prompts.render(label, -- prompt_name, response)` (promoted from internal to public on -- M9.8's request as the second consumer). Result buffers land -- in the M9.7 `*mcp: