{
  "aicl_surface": "capability",
  "version": "0.1",
  "revision": "2026-10-05",
  "product_version": "0.5.0",
  "runtime": "local-only-not-hosted",
  "note": "EveGlyph Editor has no public, network-reachable API. This file declares two LOCAL surfaces that exist ONLY on an end-user's own machine. (1) \"tools\": the local bridge — a Vite plugin (vite-agent-bridge.js, declared apply:'serve') mounted by \"npm run dev\" or, in the Windows desktop app, on its own loopback-only server (which also requires a per-launch token), and never shipped in a production web build; every request is gated by isLocalRequest (Host must be localhost/127.0.0.1/::1) and every workspace-scoped operation is pinned to the single folder the user opened (confirmedWorkspace + assertWorkspace / resolveInside). (2) \"mcp\": the MCP servers — local processes the user starts against a workspace folder they choose (stdio, or HTTP bound to 127.0.0.1 with a mandatory bearer token). There is nothing here to call remotely — this file documents local capability surfaces for agents already running on a user's own machine, not a hosted service.",
  "conventions": {
    "success_envelope": { "ok": true, "result": "<tool-specific>" },
    "error_envelope": { "ok": false, "error": { "code": "STRING", "message": "STRING", "recoverable": true } },
    "scope": "All operations below are confined to the single workspace folder confirmed via open-workspace for the current session; a request whose target path or working directory falls outside that folder (or a descendant) is rejected."
  },
  "tools": [
    {
      "name": "open-workspace",
      "description": "Confirm the workspace folder (absolute path) that all subsequent file, git, and agent operations are pinned to for this session. The first agent run for a given folder requires this confirmation; it is held in the browser session only (not persisted) and is re-asked after a page reload or a folder switch.",
      "source": "vite-agent-bridge.js /api/workspace — README \"How it works\", SECURITY.md \"The local bridge\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "required": ["path"],
        "properties": {
          "path": { "type": "string", "description": "absolute path to the workspace folder on the user's own machine" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "confirmed": { "type": "boolean" },
          "path": { "type": "string" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "read-file",
      "description": "Read a file's contents from inside the confirmed workspace. The target path is resolved with resolveInside; a path that escapes the workspace root is rejected.",
      "source": "vite-agent-bridge.js file I/O — README \"How it works\", SECURITY.md \"The local bridge\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "required": ["path"],
        "properties": {
          "path": { "type": "string", "description": "path relative to the confirmed workspace root" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "content": { "type": "string" },
          "encoding": { "type": "string", "description": "e.g. utf-8, big5, gbk, shift-jis" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "write-file",
      "description": "Write a file's contents inside the confirmed workspace, preserving the file's detected or configured encoding on save. The target path is resolved with resolveInside; a path that escapes the workspace root is rejected.",
      "source": "vite-agent-bridge.js file I/O — README \"Encoding-aware\" / \"How it works\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "required": ["path", "content"],
        "properties": {
          "path": { "type": "string", "description": "path relative to the confirmed workspace root" },
          "content": { "type": "string" },
          "encoding": { "type": "string", "description": "optional; defaults to the file's detected encoding or the Settings → Default encoding fallback" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "bytesWritten": { "type": "integer" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "detect-encoding",
      "description": "Detect a file's text encoding (jschardet) so it can be preserved on save via iconv-lite (Big5 / GBK / Shift-JIS / …). Falls back to the Settings → Default encoding when detection is uncertain.",
      "source": "jschardet + iconv-lite — README \"Encoding-aware\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "required": ["path"],
        "properties": {
          "path": { "type": "string", "description": "path relative to the confirmed workspace root" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "encoding": { "type": "string" },
          "confidence": { "type": "number" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "git-snapshot",
      "description": "Git-snapshot the confirmed workspace before a local agent runs, initializing a repository first if one does not yet exist. This is the baseline the later git-diff / git-accept / git-reject calls operate against.",
      "source": "PatchMD — README \"Diff-first agent review (PatchMD)\", SECURITY.md \"Local-agent mode\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "properties": {}
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "committed": { "type": "boolean" },
          "ref": { "type": "string" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "git-diff",
      "description": "Return the real git diff of the workspace since the last snapshot, for rendering as per-file review cards with +/− line counts (the same renderer used by the agent panel and workspace replace-all).",
      "source": "src/diffview.js — README \"Diff-first agent review (PatchMD)\", CHANGELOG.md [0.4.0] \"Diff-review UX\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "properties": {}
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": { "type": "string" },
                "additions": { "type": "integer" },
                "deletions": { "type": "integer" },
                "hunk": { "type": "string", "description": "unified diff text for this file; treat as untrusted, escape before display" }
              }
            }
          }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "git-accept",
      "description": "Accept the agent's changes: commits the current working tree with message \"agent: <message>\".",
      "source": "README \"Diff-first agent review (PatchMD)\", SECURITY.md \"Local-agent mode\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "properties": {
          "message": { "type": "string", "description": "optional commit message suffix; the commit is prefixed \"agent: \"" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "committed": { "type": "boolean" },
          "commit": { "type": "string" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "git-reject",
      "description": "Reject the agent's changes: runs \"git reset --hard HEAD\" then \"git clean -fd\", discarding ALL agent edits AND any untracked files present in the workspace. Destructive to uncommitted work — not scoped to a single file.",
      "source": "README \"Diff-first agent review (PatchMD)\", SECURITY.md \"Local-agent mode\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "properties": {}
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "reverted": { "type": "boolean" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "spawn-agent",
      "description": "Spawn the selected local CLI agent (Claude Code / Codex / Gemini) in the confirmed workspace folder with auto-approve — it can read, create, edit, and delete files there without per-file confirmation. The prompt is delivered over stdin, never as command-line arguments. The permission tier maps to real CLI enforcement (Claude --permission-mode + tool allow-list, Codex exec --full-auto or sandbox bypass at Trusted, Gemini --approval-mode / --yolo). Hard 180-second timeout; the process is also killed on Stop or connection close.",
      "source": "README \"AI providers\" / \"Permission tiers\", SECURITY.md \"Local-agent mode — read this\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "required": ["agent", "prompt"],
        "properties": {
          "agent": { "type": "string", "enum": ["claude", "codex", "gemini"] },
          "prompt": { "type": "string", "description": "delivered to the agent over stdin" },
          "permissionTier": { "type": "string", "enum": ["cautious", "standard", "trusted"], "default": "standard" },
          "commandOverride": { "type": "string", "description": "optional Settings-level command override; only set to a command you trust, it runs on your machine" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "output": { "type": "string", "description": "agent stdout/stderr tail, decoded with a stateful UTF-8 decoder (fixes CJK mojibake across chunk boundaries)" },
          "exitCode": { "type": "integer" },
          "timedOut": { "type": "boolean" }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    },
    {
      "name": "read-monitor-log",
      "description": "Tail-read the local diagnostic JSONL log (last 512 KB) that records file / workspace / agent events for the back-stage Monitor panel. The log lives outside the workspace root, so this bridge endpoint is the only safe read path to it. Nothing in this log is ever sent over the network.",
      "source": "src/monitorview.js — CHANGELOG.md [0.3.0] \"Monitor tab\", SECURITY.md \"Telemetry\"",
      "permission": "local-only",
      "version": "0.1",
      "input_schema": {
        "type": "object",
        "properties": {
          "limit": { "type": "integer", "description": "max entries to return" },
          "filter": { "type": "string", "description": "substring filter" }
        }
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "category": { "type": "string", "enum": ["agent", "git", "file", "ui", "error"] },
                "ts": { "type": "string" },
                "message": { "type": "string" }
              }
            }
          }
        }
      },
      "error_schema": { "$ref": "#/conventions/error_envelope" }
    }
  ],
  "mcp": {
    "description": "Model Context Protocol servers started by the user against a workspace folder they choose. They do not depend on the dev bridge or a browser tab. Eleven tools in two groups. Nothing here is hosted.",
    "transports": [
      {
        "id": "stdio",
        "entry": "mcp-server.js",
        "command": "node mcp-server.js <absolute-workspace-path>   (or: npm run mcp -- <path>)",
        "network": "none — communicates only with the process that spawned it"
      },
      {
        "id": "http-loopback",
        "entry": "mcp-server-remote.js",
        "command": "npm run mcp:remote -- <absolute-workspace-path>   (requires EVEGLYPH_MCP_TOKEN, 16+ characters)",
        "network": "binds 127.0.0.1 only; reachable from another machine only if the user tunnels it; bearer token mandatory, constant-time comparison; stateless per request",
        "settings_toggle": "Settings → Enable remote MCP server starts and stops this process from the app"
      }
    ],
    "conventions": {
      "workspace_root": "required startup argument, never inferred from the current directory; all paths are resolved against it and anything that escapes it is rejected",
      "success_envelope": "MCP text content containing the tool's JSON result (the publication tools may additionally return a resource_link)",
      "error_envelope": { "isError": true, "content": "JSON text: { \"error\": { \"code\": \"STRING\", \"message\": \"STRING\", \"details\": \"optional\" } }" },
      "capability_mapping_status": "The \"capabilities\" arrays below come from src/capabilities/mcp-map.js and describe the authority each tool would need under the capability model (lifetime: once). This is control-plane groundwork: there is no user-facing grant-acquisition flow, and the tools keep their existing transport-level behavior (stdio: the MCP host's own approval UI; HTTP: the bearer token). It is not an OS sandbox."
    },
    "resources": [
      {
        "uri_template": "eveglyph-artifact://{artifact_id}",
        "mime_type": "application/pdf",
        "description": "Temporary PDF produced by render_document, returned as a base64 blob. Process-scoped; expires after 30 minutes."
      }
    ],
    "tools": [
      {
        "name": "list_files",
        "group": "workspace",
        "description": "List every text file (.md/.txt/.html/.json/.yaml/.yml) in the opened workspace as paths relative to the workspace root. node_modules, dist, build, .git and dotfiles are excluded.",
        "source": "mcp-tools.js — README \"MCP server\"",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [{ "capability": "workspace.read", "resource": "workspace:*" }],
        "input_schema": { "type": "object", "properties": {} },
        "output_schema": {
          "type": "object",
          "properties": {
            "workspace": { "type": "string" },
            "files": { "type": "array", "items": { "type": "string" } }
          }
        }
      },
      {
        "name": "read_file",
        "group": "workspace",
        "description": "Read one file by path relative to the workspace root. Auto-detects encoding (legacy Big5/GBK files as well as UTF-8).",
        "source": "mcp-tools.js — README \"MCP server\"",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [{ "capability": "workspace.read", "resource": "workspace:<path>" }],
        "input_schema": {
          "type": "object",
          "required": ["path"],
          "properties": { "path": { "type": "string", "description": "path relative to the workspace root" } }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "path": { "type": "string" },
            "content": { "type": "string" },
            "encoding": { "type": "string" }
          }
        }
      },
      {
        "name": "write_file",
        "group": "workspace",
        "description": "Create or overwrite one file, UTF-8 encoded, creating parent directories as needed. Writes IMMEDIATELY: there is no git snapshot, diff or Accept step of its own — the MCP host's approval UI is the gate. If the workspace is a git repository, review the change with your own git tooling afterwards.",
        "source": "mcp-tools.js — SECURITY.md \"The MCP server\"",
        "permission": "local-only",
        "mutates_workspace": true,
        "capabilities": [{ "capability": "workspace.write", "resource": "workspace:<path>" }],
        "input_schema": {
          "type": "object",
          "required": ["path", "content"],
          "properties": {
            "path": { "type": "string", "description": "path relative to the workspace root" },
            "content": { "type": "string", "description": "full new file content" }
          }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "ok": { "type": "boolean" },
            "path": { "type": "string" },
            "bytes": { "type": "integer" }
          }
        }
      },
      {
        "name": "evaluate_aimdc",
        "group": "workspace",
        "description": "Parse and evaluate every AIMD-C block (aimd-value/function/compute/assert/table/view) through the document-only capability profile, returning computed results, the dependency-evaluation ledger, capability/sandbox evidence and any type or reference errors. Pass document content directly (use read_file first if it lives on disk). Closed-grammar evaluator: no eval, no Function.",
        "source": "mcp-tools.js, src/capabilities/document-runtime.js — SECURITY.md \"Capability sandbox foundation\"",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [
          { "capability": "document.read.self", "resource": "document:self" },
          { "capability": "document.compute", "resource": "document:self" },
          { "capability": "ephemeral.output", "resource": "execution:aimdc" }
        ],
        "input_schema": {
          "type": "object",
          "required": ["content"],
          "properties": { "content": { "type": "string", "description": "EveGlyph-MD document content, or just the relevant ::: aimd-* ::: blocks" } }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "blocks": { "type": "integer" },
            "results": { "type": "object" },
            "issues": { "type": "array" },
            "ledger": { "type": "array" },
            "sandbox": { "type": "object" }
          }
        }
      },
      {
        "name": "validate_world_ir",
        "group": "workspace",
        "description": "Validate a World IR YAML document (kind: state_machine / entity / entity_list) and return structured issues — the same validator the in-app World IR views use.",
        "source": "mcp-tools.js — README \"MCP server\"",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [
          { "capability": "document.read.self", "resource": "document:self" },
          { "capability": "document.compute", "resource": "document:self" }
        ],
        "input_schema": {
          "type": "object",
          "required": ["content"],
          "properties": { "content": { "type": "string", "description": "raw YAML of a World IR document" } }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "kind": { "type": ["string", "null"] },
            "issues": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "severity": { "type": "string" },
                  "code": { "type": "string" },
                  "message": { "type": "string" }
                }
              }
            }
          }
        }
      },
      {
        "name": "get_publication_capabilities",
        "group": "publication",
        "description": "Describe the headless publication runtime: source formats (eveglyph-md, markdown), output formats (pdf), profiles, renderer backend/version, temporary-artifact limits and limitations (single-document rendering only; artifacts are process-scoped and expire; rendering does not mutate workspace files).",
        "source": "mcp-publication.js — docs/MCP-PUBLICATION-RUNTIME.md",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [{ "capability": "document.read.self", "resource": "document:self" }],
        "input_schema": { "type": "object", "properties": {} },
        "output_schema": {
          "type": "object",
          "properties": {
            "runtime": { "type": "string" },
            "version": { "type": "string" },
            "source_formats": { "type": "array", "items": { "type": "string" } },
            "output_formats": { "type": "array", "items": { "type": "string" } },
            "profiles": { "type": "array" },
            "renderer": { "type": "object" },
            "artifact_limits": { "type": "object", "description": "ttlMs 1800000, maxArtifactBytes 67108864, maxTotalBytes 268435456" },
            "limitations": { "type": "array", "items": { "type": "string" } }
          }
        }
      },
      {
        "name": "inspect_document",
        "group": "publication",
        "description": "Inspect canonical UTF-8 EveGlyph/Markdown source for headings, math, tables, images, code, metadata and EveGlyph block counts. Does not modify the source.",
        "source": "mcp-publication.js, src/publication/inspect.js",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [
          { "capability": "document.read.self", "resource": "document:self" },
          { "capability": "document.compute", "resource": "document:self" }
        ],
        "input_schema": {
          "type": "object",
          "required": ["source"],
          "properties": { "source": { "type": "string" } }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "title": { "type": ["string", "null"] },
            "metadata": { "type": "object", "description": "parsed frontmatter" },
            "headings": { "type": "array" },
            "characters": { "type": "integer" },
            "inlineMathCount": { "type": "integer" },
            "displayMathCount": { "type": "integer" },
            "tableCount": { "type": "integer" },
            "imageCount": { "type": "integer" },
            "codeBlockCount": { "type": "integer" },
            "eveglyphBlocks": { "type": "object", "description": "counts of ::: blocks by kind" },
            "notices": { "type": "array" }
          }
        }
      },
      {
        "name": "validate_document",
        "group": "publication",
        "description": "Non-destructive publication preflight: profile, canonical math delimiters, fences/blocks, and Markdown → Typst conversion.",
        "source": "mcp-publication.js, src/publication/validate.js",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [
          { "capability": "document.read.self", "resource": "document:self" },
          { "capability": "document.compute", "resource": "document:self" }
        ],
        "input_schema": {
          "type": "object",
          "required": ["source"],
          "properties": {
            "source": { "type": "string" },
            "profile": { "type": "string", "description": "evemiss-whitepaper-v1 (default) or evemiss-academic-v1" }
          }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "ok": { "type": "boolean" },
            "errors": { "type": "array", "items": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } } } },
            "warnings": { "type": "array" },
            "notices": { "type": "array" },
            "resolvedProfile": { "type": ["object", "null"] }
          }
        }
      },
      {
        "name": "render_document",
        "group": "publication",
        "description": "Render canonical UTF-8 EveGlyph/Markdown source to a TEMPORARY PDF artifact through a headless Typst compiler, without modifying the source or the workspace. Relative images/assets resolve inside the selected workspace. Returns artifact metadata with SHA-256 hashes and a resource link.",
        "source": "mcp-publication.js, src/publication/prepare.js, src/publication/node-renderer.js",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [
          { "capability": "document.read.self", "resource": "document:self" },
          { "capability": "document.compute", "resource": "document:self" },
          { "capability": "ephemeral.output", "resource": "execution:publication" }
        ],
        "input_schema": {
          "type": "object",
          "required": ["source"],
          "properties": {
            "source": { "type": "string" },
            "source_format": { "type": "string", "enum": ["eveglyph-md", "markdown"], "default": "eveglyph-md" },
            "profile": { "type": "string", "default": "evemiss-whitepaper-v1", "description": "evemiss-whitepaper-v1 (evemiss-serif-light + technical-whitepaper) or evemiss-academic-v1 (evemiss-serif-light + academic-paper)" },
            "output_format": { "type": "string", "enum": ["pdf"], "default": "pdf" },
            "filename": { "type": "string" },
            "theme": { "type": "string" },
            "layout": { "type": "string" }
          }
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "artifact_id": { "type": "string" },
            "filename": { "type": "string" },
            "mime_type": { "type": "string" },
            "resource_uri": { "type": "string" },
            "source_sha256": { "type": "string" },
            "artifact_sha256": { "type": "string" },
            "profile": { "type": "string" },
            "resolved_theme": { "type": "string" },
            "resolved_layout": { "type": "string" },
            "renderer": { "type": "object" },
            "bytes": { "type": "integer" },
            "created_at": { "type": "string" },
            "expires_at": { "type": "string" },
            "diagnostics": { "type": "array" },
            "warnings": { "type": "array" }
          }
        }
      },
      {
        "name": "get_render_artifact",
        "group": "publication",
        "description": "Resolve a temporary publication artifact and return its resource URI and metadata.",
        "source": "mcp-publication.js, src/publication/artifact-store.js",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [{ "capability": "ephemeral.output", "resource": "artifact:<artifact_id>" }],
        "input_schema": {
          "type": "object",
          "required": ["artifact_id"],
          "properties": { "artifact_id": { "type": "string" } }
        },
        "output_schema": { "type": "object", "description": "same artifact summary as render_document" }
      },
      {
        "name": "get_render_report",
        "group": "publication",
        "description": "Return source/artifact hashes, renderer and profile selection, diagnostics, warnings and artifact lifetime for a rendered document.",
        "source": "mcp-publication.js, src/publication/artifact-store.js",
        "permission": "local-only",
        "mutates_workspace": false,
        "capabilities": [{ "capability": "ephemeral.output", "resource": "artifact:<artifact_id>" }],
        "input_schema": {
          "type": "object",
          "required": ["artifact_id"],
          "properties": { "artifact_id": { "type": "string" } }
        },
        "output_schema": { "type": "object", "description": "artifact_id, source_sha256, artifact_sha256, profile, resolved_theme, resolved_layout, renderer, bytes, diagnostics, warnings, created_at, expires_at" }
      }
    ]
  }
}
