Skip to content

Extensions & Plugins ​

Hands-On Walkthrough

Want a step-by-step guide covering the six default built-in extensions, installing a physical Java SPI .jar (kompile extension install <file.jar>), packaging a runnable .jar Process Extension ("kind": "jar"), and building GraalVM Native-Image Plugins (both compile-time SPI and runtime native executables)? Start with Building & Managing Kompile Extensions.

Kompile provides several extension points depending on whether you want to ship new CLI commands + MCP tools, connect third-party MCP servers, wrap quick shell/HTTP helpers, add reusable skills/roles, enforce tool hooks, or package an entire persona.

Choosing the Right Extension Mechanism ​

MechanismBest forLanguage / FormatScope & PrecedenceHow it's managed
Process Extension PackagesDistributable CLI subcommands + MCP tools (any language, works in native CLI without a plugin JVM)extension.json + executable or runnable JARUser (~/.kompile/extensions/packages/)kompile extension / /extension
Java Plugin SPI (kompile-cli-plugin-api, kompile-cli-tool-api)Trusted in-process Java commands & tools — drop-in .jar on JVM (cli-harness-any) or compiled into custom native imagesPhysical .jar + ServiceLoaderUser (~/.kompile/extensions/jars/), Dist (<dist>/lib/extensions/), or build classpathkompile extension install <file.jar> / remove <jar> (KOMPILE_NO_EXTENSION_JARS=1 to bypass)
Custom MCP ServersExisting third-party or remote MCP servers (stdio, HTTP, SSE)Any MCP serverUser (~/.kompile/config/mcp-servers.json) < Project (.mcp.json)kompile mcp add|list|disable|remove
Declarative Custom ToolsLightweight bash or HTTP tools without writing an MCP serverJSON filesUser (~/.kompile/tools/) < Project (.kompile/tools/)Drop .json files + activate_tools(["custom"])
Skills & RolesReusable workflows, prompt templates, and agent personasMarkdown + YAML frontmatter / JSONBundled < Provider dirs < User (~/.kompile/) < Project (.kompile/)/skills, /roles, skill_manager, role_manager
Tool HooksPre/post tool validation, policy checks, and side-effect automationJSON + shell scriptsUser (~/.kompile/hooks.json) + Project (.kompile/hooks.json)/hooks, hooks tool
Spins & CompanionsPackaging prompts + tools + models into an installable persona, or overlaying local ML onto cli-harnessDistribution / overlayInstall rootkompile spin, kompile install local-runtime

1. Trusted Process Extension Packages (kompile extension) ​

Process extensions let you add both new top-level kompile <subcommand> commands and MCP tools from any language (Rust, Go, Python, Node, shell, or a runnable JAR) — including inside GraalVM native cli-harness binaries without dynamic Java classloading.

Installing and Managing Packages ​

bash
# Inspect all composed extensions (built-in + installed process packages)
kompile extension
kompile extension builtin.code --json

# Install from a local directory, .zip archive, https:// URL, or configured source
kompile extension install /path/to/my-extension
kompile extension install ./my-extension-1.0.zip --sha256 <64-hex-chars>
kompile extension install https://example.com/releases/my-extension-1.0.zip --sha256 <64-hex-chars>
kompile extension install --from-source team-artifacts my-extension

# Upgrade to a new immutable version
kompile extension install ./my-extension-1.1.zip --replace

# Inspect or deactivate
kompile extension inspect my-extension --json
kompile extension remove my-extension

The same operations are available inside kompile chat via /extension (aliases: /extensions, /plugin, /plugins).

Package Layout & extension.json ​

Place extension.json (max 1 MiB) at the root of the directory or .zip archive:

json
{
  "schemaVersion": 1,
  "apiVersion": 1,
  "id": "demo",
  "version": "1.0",
  "timeoutSeconds": 60,
  "commands": {
    "demo-command": {
      "kind": "executable",
      "path": "bin/demo",
      "args": ["--cli"]
    }
  },
  "mcp": {
    "kind": "executable",
    "path": "bin/demo",
    "args": ["--mcp"]
  },
  "tools": [
    {
      "name": "echo",
      "description": "Echo a message",
      "inputSchema": {
        "type": "object",
        "properties": {
          "message": { "type": "string" }
        },
        "required": ["message"]
      }
    }
  ]
}

Runtime & Security Contract ​

  • No code runs during install. Payloads are copied into immutable directories under ~/.kompile/extensions/packages/<id>/<version> and activated atomically via installed.json.
  • Archive & path safety: .zip extraction enforces entry count (≤ 4,096) and uncompressed size (≤ 512 MiB) bounds and rejects symlinks, non-regular files, absolute paths, and .. traversal. Launch argv is literal (no shell interpolation).
  • Executable vs. JAR targets: kind: "executable" runs directly with zero JVM requirement; kind: "jar" launches via Kompile's Java runtime locator. Child processes receive KOMPILE_EXTENSION_ID, KOMPILE_EXTENSION_VERSION, and KOMPILE_EXTENSION_ROOT.
  • MCP export: Declared tools are exposed as mcp__extension_<id>__<name> with permission key mcp.extension-<id>. Schemas are validated strictly against declared tools; undeclared tools returned by the subprocess are never exposed.
  • Recovery: If a broken package prevents normal startup, kompile extension remove <id> loads compiled commands only so you can always deactivate it cleanly.

2. Java Plugin SPI (kompile-cli-plugin-api & kompile-cli-tool-api) ​

For trusted in-process Java extensions — either installed as physical .jar files (kompile extension install <file.jar> / remove <jar> into ~/.kompile/extensions/jars/, or bundled in <dist>/lib/extensions/*.jar, auto-loaded by kompile.sh / kompile.cmd, bypassable with KOMPILE_NO_EXTENSION_JARS=1) or compiled into custom builds / GraalVM native images — Kompile provides two lightweight SPI modules with no dependency on kompile-cli-main, graph engines, or JNI:

  • kompile-cli-plugin-api (JDK + Picocli only):
    • CliExtension — ServiceLoader entry point supplying a CliExtensionDescriptor and optional Picocli subcommands.
    • CliExtensionDescriptor & CliToolDescriptor — immutable identity, API version, provided/required capabilities, commands, and declared tool ownership.
    • CliExtensionCatalog — validates metadata (rejecting duplicate IDs, unsupported APIs, and missing required capabilities) before any contribution factory runs.
    • CliCommandRegistrar — legacy Picocli subcommand registrar SPI (still supported).
  • kompile-cli-tool-api (plugin-api + Jackson only):
    • CliToolProvider — contributes ProvidedTool instances given a ToolProviderContext (endpoints, ObjectMapper, working directory, and CHAT/MCP surface).
    • ExtensionTool<C> & ToolInvocationContext — portable tool execution contract exposing only session ID, working directory, cancellation, permission checks, and safe path resolution.

Built-In Composed Extensions ​

Kompile organizes its own built-in capability families through the same extension catalog (inspectable via kompile extension):

Extension IDOwned Tools
builtin.codecode_search, code_graph, local_code_index
builtin.knowledgeknowledge_search, knowledge_status, rag_search, graph_search
builtin.graphKnowledge graph CRUD, grounding, reasoning (ask_graph_*), analytics (graph_*), process mining
builtin.crawlcrawl_source, crawl_documents, crawl_discover, crawl_control, crawl_result
builtin.modelmodel_runtime, subprocess_watchdog, vlm_model_definition (chat)
builtin.pipelinepipeline

See CLI Extension Composition for the full architectural and native-image verification details.


3. Custom MCP Servers (kompile mcp) ​

Connect any third-party stdio, HTTP, or SSE MCP server across standard chat, headless chat, and managed passthrough:

bash
kompile mcp add context7 -- npx -y @upstash/context7-mcp
kompile mcp add --scope user --transport http docs https://mcp.example.com/mcp
kompile mcp list
kompile mcp disable context7
kompile mcp remove context7
  • Project servers live in .mcp.json; user servers live in ~/.kompile/config/mcp-servers.json (project entries override user entries by name).
  • Tools are namespaced as mcp__<server>__<tool> and reachable through the mcp_tool_search / mcp_tool_call gateway.
  • See Custom MCP Servers for transport options, auth references, trust rules, and tool filtering.

4. Declarative Custom Tools (~/.kompile/tools/, .kompile/tools/) ​

When you only need a quick shell command or HTTP endpoint exposed as a tool, drop a .json file into ~/.kompile/tools/ (user) or .kompile/tools/ (project, overrides user by name).

Custom tools are registered as custom_<name> inside the custom dynamic MCP group (activated via activate_tools(["custom"])) and default to a 30-second timeout (timeout_seconds).

Bash-backed tool example ​

json
{
  "name": "jira_lookup",
  "description": "Look up a JIRA ticket by ID",
  "parameters": {
    "type": "object",
    "properties": {
      "ticket": { "type": "string", "description": "JIRA ticket ID" }
    },
    "required": ["ticket"]
  },
  "execute": {
    "type": "bash",
    "command": "jira view {{ticket}} --json",
    "working_dir": "."
  },
  "timeout_seconds": 30
}

HTTP-backed tool example ​

json
{
  "name": "deploy_status",
  "description": "Check deployment status for an environment",
  "parameters": {
    "type": "object",
    "properties": {
      "env": { "type": "string" }
    },
    "required": ["env"]
  },
  "execute": {
    "type": "http",
    "url": "https://deploy.internal/api/status/{{env}}",
    "method": "GET",
    "headers": {
      "Accept": "application/json"
    }
  }
}

5. Skills & Roles ​

Custom Skills ​

Skills are Markdown files with YAML frontmatter that teach agents repeatable procedures (and are also exposed through the MCP prompts endpoint).

Search order (later overrides earlier):

  1. <install>/lib/skills/ — bundled first-party defaults
  2. User provider skill directories (compatibility imports)
  3. ~/.kompile/skills/ — user-scoped skills
  4. Project provider skill directories (compatibility imports)
  5. .kompile/skills/ — project-scoped skills
markdown
---
name: deploy
description: Deploy the current branch to staging
category: devops
tools: bash, read, grep, glob
model: default
---
Deploy the current branch to staging. {{args}}

1. Verify tests pass cleanly.
2. Run the staging deployment pipeline and report the URL.

Inspect and manage skills with /skills or the skill_manager MCP tool. See Skills and Prompt Templates.

Custom Roles ​

Roles define reusable persona prompts and behavior constraints loaded with built-in < ~/.kompile/roles/ < .kompile/roles/ precedence. Per-agent role assignments are stored in ~/.kompile/roles/agent-roles.json and managed via /roles, /role <name>, or role_manager.


6. Tool Hooks (.kompile/hooks.json, ~/.kompile/hooks.json) ​

Claude-style deterministic tool hooks run before or after tool calls to enforce custom policies, block unsafe operations, or trigger automated checks. Manage hooks interactively with /hooks or programmatically via the hooks MCP tool. See Hooks for event names, matchers, and JSON schemas.


7. Spins & Runtime Overlays ​

  • Spins (kompile spin) package prompts, skills, MCP tool configurations, declarative custom tools, and optional local models into a self-contained installable persona distribution. Follow the end-to-end Building a Kompile Spin Walkthrough or read the Spins Reference.
  • Local Runtime Overlay (kompile install local-runtime) adds lib/kompile-local-runtime.jar (local embeddings, dense retrieval, and graph reasoning) onto a slim cli-harness installation while preserving base updates and release channels.

Released under the Apache-2.0 License.