Skip to content

Building & Managing Kompile Extensions (Physical JARs, Native-Image Plugins & Default Extensions) ​

Kompile organizes both its built-in capability families and your own custom commands and MCP tools through a single validated extension catalog. This walkthrough shows you:

  1. The six default built-in extensions that ship with Kompile (plus the kompile-local-runtime.jar companion overlay).
  2. How to build and install a physical drop-in Java SPI .jar (kompile extension install <file.jar> → ~/.kompile/extensions/jars/) that loads directly in-process on JVM distributions (cli-harness-any / kompile-cli.jar) via ServiceLoader.
  3. How to ship a physical runnable .jar as a Process Extension Package ("kind": "jar" in extension.json) so it also works with GraalVM native kompile binaries without rebuilding the native image.
  4. How to build GraalVM Native-Image Plugins — both compile-time in-process SPI plugins baked into a custom native kompile binary and runtime standalone native binaries ("kind": "executable") that extend pre-built native kompile binaries with zero JVM.

Reference Docs

For a concise summary of all extension mechanisms (including declarative JSON tools, custom MCP servers, skills, roles, and hooks), see Extensions & Plugins and CLI Extension Composition.


1. Exploring the Default (Built-In) Extensions ​

Every Kompile CLI ships with six default composed extensions registered in META-INF/services/ai.kompile.cli.plugin.api.CliExtension. Inspect them at any time without loading models or connecting to a server:

bash
# Human-readable list of all composed extensions (built-in + drop-in SPI JARs + installed process packages)
kompile extension

# Full machine-readable catalog (schemaVersion: kompile-cli-extensions/v1)
kompile extension --json

# Inspect a single extension by ID
kompile extension builtin.code
kompile extension inspect builtin.graph --json

Inside an interactive kompile chat session, use /extension (aliases: /extensions, /plugin, /plugins).

The Six Default Built-In Extensions ​

Extension IDProvided CapabilitiesOwned ToolsRuntime Requirement
builtin.codecode.indexcode_search, code_graph, local_code_indexWorks locally in slim cli-harness (structural indexing & symbol graph; only explicit code_graph learn requires graph.learning)
builtin.knowledgeknowledge.localknowledge_search, knowledge_status, rag_search, graph_searchRequires lib/kompile-local-runtime.jar (kompile install local-runtime) or a connected server (--url)
builtin.graphgraph.local, graph.learningknowledge_graph, ask_graph_query, ask_graph_verify, ask_graph_assert, ask_graph_retract, ask_graph_mebn, ask_graph_explain, ask_graph_explain_fused, ask_graph_synthesize, ask_graph_subscribe, ask_graph_claim, graph_reason, graph_reasoning_query, graph_import, graph_export, graph_aggregate, graph_forecast, graph_centrality, graph_bayes, graph_embeddings, graph_simulate, process_miningRequires lib/kompile-local-runtime.jar or a connected Kompile server (--url)
builtin.crawlcrawl.localcrawl_source, crawl_documents, crawl_discover, crawl_control, crawl_resultRequires lib/kompile-local-runtime.jar or a connected Kompile server (--url)
builtin.modelmodel.runtimemodel_runtime, subprocess_watchdog, vlm_model_definition (chat surface only)Requires kompile install local-runtime, kompile install model-serving, or a connected server (--url)
builtin.pipelinepipeline.localpipeline (also requires model.runtime)Requires lib/kompile-local-runtime.jar or a connected Kompile server (--url)

How kompile-local-runtime.jar Lights Up the Default Extensions

On JVM installs (cli-harness-any / kompile-cli.jar), bin/kompile (kompile.sh / kompile.cmd) automatically detects lib/kompile-local-runtime.jar (in either <dist>/lib/ or ~/.kompile/lib/) and appends it to -cp. The moment that physical JAR is present, all five local-runtime built-in extensions activate automatically on the next run.

kompile extension --json sets "runtimeReadinessChecked": false — it inspects declared ownership and capability metadata without starting subprocesses or loading models.


2. How Physical .jar Extensions Work (JVM vs. Native Binary) ​

Choose the physical JAR packaging model that matches how your users run kompile:

ModelArtifactHow It LoadsWorks on JVM (cli-harness-any)?Works on GraalVM Native kompile?Best For
Drop-In Java SPI JAR (CliToolProvider / CliExtension)Single physical .jar in ~/.kompile/extensions/jars/ or <dist>/lib/extensions/Auto-appended to -cp by kompile.sh / kompile.cmd, discovered via ServiceLoader in-processYes — drop in & runBuild-time only (GraalVM native images cannot dynamically classload JAR bytecode at runtime)In-process Java tools & Picocli commands with zero subprocess overhead on JVM installs or custom builds
Runnable JAR Process Extension (extension.json + "kind": "jar")Physical runnable .jar + extension.json (directory or .zip)Installed with kompile extension install; Kompile locates Java via JavaRuntimeLocator and runs java -jar <root>/lib/ext.jarYesYes — install at runtime, no rebuildDistributing a physical Java .jar extension that works identically on native kompile binaries and JVM installs
Native / Script Process Extension (extension.json + "kind": "executable")Executable binary/script + extension.jsonInstalled with kompile extension install; runs directly with zero JVM requirementYesYesExtensions written in Go, Rust, Python, Node, or shell

3. Walkthrough A — Build a Drop-In Physical Java SPI Extension JAR ​

When running Kompile in JVM mode (cli-harness-any / kompile-cli.jar), you can extend the harness simply by compiling a physical .jar against Kompile's lightweight SPI modules and dropping it into ~/.kompile/extensions/jars/ (per-user) or <dist>/lib/extensions/ (distribution-wide).

Both SPI modules stay tiny and never pull in kompile-cli-main, graph engines, or JNI:

  • kompile-cli-plugin-api (JDK + Picocli): CliExtension, CliExtensionDescriptor, CliToolDescriptor, CliExtensionCatalog
  • kompile-cli-tool-api (plugin-api + Jackson): CliToolProvider (extends CliExtension), ExtensionTool<ToolInvocationContext>, ProvidedTool, ToolProviderContext, ToolInvocationContext

In this walkthrough you will build release-notes-extension-1.0.0.jar, which adds:

  • A new top-level CLI command: kompile release-notes
  • A new in-process chat and MCP tool: release_notes_draft

Step 1: Create the Maven Project ​

text
release-notes-extension/
├── pom.xml
└── src/main/
    ├── java/com/example/kompile/ext/
    │   └── ReleaseNotesExtension.java
    └── resources/META-INF/services/
        └── ai.kompile.cli.plugin.api.CliExtension

pom.xml:

xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example.kompile</groupId>
  <artifactId>release-notes-extension</artifactId>
  <version>1.0.0</version>

  <properties>
    <maven.compiler.release>17</maven.compiler.release>
    <kompile.version>0.1.0-SNAPSHOT</kompile.version>
  </properties>

  <dependencies>
    <!-- Provided by kompile-cli.jar at runtime -->
    <dependency>
      <groupId>ai.kompile</groupId>
      <artifactId>kompile-cli-plugin-api</artifactId>
      <version>${kompile.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>ai.kompile</groupId>
      <artifactId>kompile-cli-tool-api</artifactId>
      <version>${kompile.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

Third-Party Dependencies Inside Your Extension JAR

If your extension depends on extra third-party libraries not already in kompile-cli.jar, shade/relocate them into your JAR with maven-shade-plugin while keeping kompile-cli-plugin-api and kompile-cli-tool-api at <scope>provided</scope>.

Step 2: Implement CliToolProvider ​

Create src/main/java/com/example/kompile/ext/ReleaseNotesExtension.java with a public no-argument constructor so ServiceLoader (and GraalVM build-time discovery if you later compile a custom native image) can instantiate it:

java
package com.example.kompile.ext;

import ai.kompile.cli.main.chat.tools.ToolExecutionException;
import ai.kompile.cli.main.chat.tools.ToolResult;
import ai.kompile.cli.plugin.api.CliExtensionDescriptor;
import ai.kompile.cli.plugin.api.CliToolDescriptor;
import ai.kompile.cli.plugin.api.tools.CliToolProvider;
import ai.kompile.cli.plugin.api.tools.ExtensionTool;
import ai.kompile.cli.plugin.api.tools.ProvidedTool;
import ai.kompile.cli.plugin.api.tools.ToolInvocationContext;
import ai.kompile.cli.plugin.api.tools.ToolProviderContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import picocli.CommandLine;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class ReleaseNotesExtension implements CliToolProvider {

    private static final CliExtensionDescriptor DESCRIPTOR = new CliExtensionDescriptor(
            "example.release-notes",
            "1.0.0",
            CliExtensionDescriptor.API_VERSION,
            Set.of("release.notes"),           // capabilities provided
            Set.of(),                          // capabilities required
            List.of(new CliToolDescriptor("release_notes_draft", Set.of(), Map.of())),
            Set.of("release-notes")            // declared Picocli subcommands
    );

    @Override
    public CliExtensionDescriptor descriptor() {
        // Must stay lightweight: never construct tools, touch files, or open sockets here.
        return DESCRIPTOR;
    }

    @Override
    public void registerCommands(CommandLine root) {
        root.addSubcommand("release-notes", (Runnable) () ->
                System.out.println("Release Notes Extension 1.0.0"));
    }

    @Override
    public List<ProvidedTool> createTools(ToolProviderContext context) {
        ObjectNode schema = context.objectMapper().createObjectNode();
        schema.put("type", "object");
        ObjectNode props = schema.putObject("properties");
        props.putObject("version").put("type", "string")
                .put("description", "Target release tag, e.g. v1.2.0");
        schema.putArray("required").add("version");

        ExtensionTool<ToolInvocationContext> tool = new ExtensionTool<>() {
            @Override public String id() { return "release_notes_draft"; }
            @Override public String description() { return "Create a release-notes Markdown template"; }
            @Override public JsonNode parameterSchema() { return schema; }
            @Override public String permissionKey() { return "write"; }

            @Override
            public ToolResult execute(JsonNode params, ToolInvocationContext invocation)
                    throws ToolExecutionException {
                invocation.checkPermission(permissionKey(), description());
                String version = params.path("version").asText("unreleased");
                Path target = invocation.resolvePath("RELEASE-" + version + ".md");
                try {
                    Files.writeString(target, "# Release " + version + "\n\n## Highlights\n\n- \n");
                    return ToolResult.success(
                            invocation.getSessionId(),
                            "Wrote release-notes template to " + target,
                            Map.of("path", target.toString()));
                } catch (Exception e) {
                    throw new ToolExecutionException("Failed to write release notes: " + e.getMessage(), e);
                }
            }
        };
        return List.of(new ProvidedTool(tool, false));
    }
}

Step 3: Register the ServiceLoader Provider ​

Create src/main/resources/META-INF/services/ai.kompile.cli.plugin.api.CliExtension:

text
com.example.kompile.ext.ReleaseNotesExtension

Step 4: Build & Install the Physical JAR ​

bash
mvn package

# Validate META-INF/services + .class entries statically and install into ~/.kompile/extensions/jars/
kompile extension install target/release-notes-extension-1.0.0.jar

# Optional: verify SHA-256 or overwrite an existing JAR with --replace (also works from https:// URLs)
kompile extension install target/release-notes-extension-1.0.0.jar --sha256 <64-hex-chars> --replace

kompile extension install <file.jar> validates the JAR structure, checks that every provider listed in META-INF/services/ai.kompile.cli.plugin.api.CliExtension has a matching .class entry inside the JAR (without executing any bytecode), and atomically copies it into ~/.kompile/extensions/jars/.

You can also drop JARs manually into ~/.kompile/extensions/jars/ (per-user) or <dist>/lib/extensions/ (bundled inside a JVM distribution, loaded in lexicographical order alongside lib/kompile-local-runtime.jar).

Step 5: Verify, Run & Remove ​

bash
# Confirm Kompile discovered and validated your JAR via CliExtensionCatalog
kompile extension
kompile extension example.release-notes --json

# Run the new top-level Picocli subcommand
kompile release-notes

# Call the new in-process tool from chat or MCP stdio
kompile chat -p "Call release_notes_draft for version v1.2.0."

# Remove cleanly by JAR filename, filename stem, descriptor ID, or provider class name
kompile extension remove release-notes-extension-1.0.0.jar
# (or: kompile extension remove release-notes-extension-1.0.0)

Recovery Escape Hatch ​

If a broken drop-in JAR causes a JVM startup error (such as a NoClassDefFoundError or bad ServiceLoader entry), kompile extension remove <jar-name> automatically bypasses drop-in JARs during launch so you can remove it cleanly — or set KOMPILE_NO_EXTENSION_JARS=1 for any command:

bash
kompile extension remove release-notes-extension-1.0.0.jar
# or bypass drop-in JARs for any command:
KOMPILE_NO_EXTENSION_JARS=1 kompile extension

Compiling the Same JAR Into a Custom GraalVM Native Image ​

Because your extension implements CliExtension / CliToolProvider with a no-argument constructor and META-INF/services/ai.kompile.cli.plugin.api.CliExtension, you can also include the exact same Maven artifact on the build classpath of a custom Kompile distribution or GraalVM native image build without changing a single line of code.


4. Walkthrough B — Ship a Physical Runnable JAR for Native & JVM Binaries ("kind": "jar") ​

If your users run the GraalVM native kompile binary (where dynamic Java classloading into the native process is impossible), package your physical runnable .jar as a Process Extension Package with "kind": "jar". Kompile locates a Java runtime automatically via JavaRuntimeLocator and runs java -jar <package>/lib/<your-ext>.jar <args...>.

Step 1: Package Layout ​

text
changelog-jar-ext/
├── extension.json
└── lib/
    └── changelog-helper-1.0.0.jar   # Executable fat JAR (with Main-Class in MANIFEST.MF)

Step 2: Write extension.json ("kind": "jar") ​

Create changelog-jar-ext/extension.json:

json
{
  "schemaVersion": 1,
  "apiVersion": 1,
  "id": "changelog-helper",
  "version": "1.0.0",
  "provides": ["git.changelog"],
  "timeoutSeconds": 30,
  "commands": {
    "changelog": {
      "kind": "jar",
      "path": "lib/changelog-helper-1.0.0.jar",
      "args": ["--cli"]
    }
  },
  "mcp": {
    "kind": "jar",
    "path": "lib/changelog-helper-1.0.0.jar",
    "args": ["--mcp"]
  },
  "tools": [
    {
      "name": "recent_commits",
      "description": "Return recent Git commits in the current working directory",
      "inputSchema": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "Number of commits to return (1-50)"
          }
        },
        "required": ["count"]
      }
    }
  ]
}

Key extension.json Contract Rules (ProcessExtensionManifest) ​

  • schemaVersion and apiVersion must both be 1.
  • id matches [a-z][a-z0-9-]{0,62}; version matches [A-Za-z0-9][A-Za-z0-9._-]{0,63}.
  • Must declare at least one command or tool; mcp and a non-empty tools array must be declared together.
  • timeoutSeconds is 1–600 (default 60). CLI timeouts terminate the process tree and exit 124 (130 on interrupt).
  • Every launch receives KOMPILE_EXTENSION_ID, KOMPILE_EXTENSION_VERSION, and KOMPILE_EXTENSION_ROOT.
  • Strict MCP catalog verification: On every tool invocation, Kompile spawns a disposable stdio child (--mcp), calls initialize and tools/list, and verifies that every tool declared in extension.json is returned with an exact matching inputSchema.

Step 3: Implement the Runnable JAR Entry Point ​

Your Main-Class handles --cli <args...> (printing to stdout, returning an exit code) and --mcp (newline-delimited JSON-RPC 2.0 over stdin/stdout implementing initialize, tools/list, and tools/call):

java
package com.example.kompile.changelog;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;

public final class ChangelogMain {
    private static final ObjectMapper MAPPER = new ObjectMapper();

    // Must match extension.json inputSchema verbatim.
    private static final String TOOL_SCHEMA_JSON = """
            {
              "type": "object",
              "properties": {
                "count": {
                  "type": "integer",
                  "description": "Number of commits to return (1-50)"
                }
              },
              "required": ["count"]
            }
            """;

    public static void main(String[] args) throws Exception {
        if (args.length > 0 && "--mcp".equals(args[0])) {
            runMcp();
            return;
        }
        int count = 10;
        for (int i = 0; i < args.length - 1; i++) {
            if ("--count".equals(args[i])) count = Integer.parseInt(args[i + 1]);
        }
        System.out.println(gitLog(count));
    }

    private static String gitLog(int count) throws Exception {
        int bounded = Math.max(1, Math.min(count, 50));
        Process p = new ProcessBuilder("git", "log", "-n" + bounded, "--pretty=format:%h %cs %s")
                .redirectErrorStream(true).start();
        String out = new String(p.getInputStream().readAllBytes(), StandardCharsets.UTF_8).trim();
        if (p.waitFor() != 0) throw new IllegalStateException(out.isEmpty() ? "git log failed" : out);
        return out.isEmpty() ? "(no commits)" : out;
    }

    private static void runMcp() throws Exception {
        JsonNode schema = MAPPER.readTree(TOOL_SCHEMA_JSON);
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.isBlank()) continue;
                JsonNode req = MAPPER.readTree(line);
                String method = req.path("method").asText("");
                JsonNode id = req.get("id");

                if ("initialize".equals(method)) {
                    ObjectNode res = MAPPER.createObjectNode();
                    res.put("protocolVersion", "2024-11-05");
                    res.putObject("capabilities").putObject("tools");
                    res.putObject("serverInfo").put("name", "changelog-helper").put("version", "1.0.0");
                    reply(id, res, null);
                } else if ("notifications/initialized".equals(method)) {
                    continue;
                } else if ("tools/list".equals(method)) {
                    ObjectNode res = MAPPER.createObjectNode();
                    ObjectNode tool = res.putArray("tools").addObject();
                    tool.put("name", "recent_commits");
                    tool.put("description", "Return recent Git commits in the current working directory");
                    tool.set("inputSchema", schema);
                    reply(id, res, null);
                } else if ("tools/call".equals(method)) {
                    int count = req.path("params").path("arguments").path("count").asInt(10);
                    ObjectNode res = MAPPER.createObjectNode();
                    try {
                        res.putArray("content").addObject().put("type", "text").put("text", gitLog(count));
                    } catch (Exception e) {
                        res.put("isError", true);
                        res.putArray("content").addObject().put("type", "text").put("text", e.getMessage());
                    }
                    reply(id, res, null);
                } else if (id != null) {
                    ObjectNode err = MAPPER.createObjectNode()
                            .put("code", -32601).put("message", "Unknown method: " + method);
                    reply(id, null, err);
                }
            }
        }
    }

    private static void reply(JsonNode id, JsonNode result, JsonNode error) throws Exception {
        ObjectNode msg = MAPPER.createObjectNode().put("jsonrpc", "2.0");
        msg.set("id", id);
        if (error != null) msg.set("error", error);
        else msg.set("result", result);
        System.out.println(MAPPER.writeValueAsString(msg));
        System.out.flush();
    }
}

Step 4: Install, Package, Distribute & Upgrade ​

bash
# Install directly from the local directory (no code runs during installation)
kompile extension install ./changelog-jar-ext

# Verify it appears in the catalog alongside built-in extensions
kompile extension inspect changelog-helper --json

# Test both the CLI subcommand and the exported MCP tool
kompile changelog --count 5
kompile chat -p "Use mcp__extension_changelog-helper__recent_commits with count 5."

# Zip and hash for distribution (extension.json at archive root)
(cd changelog-jar-ext && zip -r ../changelog-helper-1.0.0.zip .)
sha256sum changelog-helper-1.0.0.zip

# Install with SHA-256 verification, pull from a source, upgrade, or deactivate
kompile extension install ./changelog-helper-1.0.0.zip --sha256 <64-hex-chars>
kompile extension install --from-source team-artifacts changelog-helper
kompile extension install ./changelog-helper-1.1.0.zip --sha256 <64-hex-chars> --replace
kompile extension remove changelog-helper

Inside kompile chat, manage packages interactively with /extension, /extension install ..., /extension inspect <id>, and /extension remove <id>.

Security & Recovery Guarantees ​

  • Zero code execution on install: Payloads are validated and copied into immutable ~/.kompile/extensions/packages/<id>/<version>/ directories, then activated atomically in installed.json.
  • Archive safety: .zip installs reject symlinks, absolute paths, .. traversal, > 4,096 entries, and > 512 MiB uncompressed payloads.
  • Permission & enforcer gating: Exported MCP tools are annotated WRITE, gated by permission key mcp.extension-<id>, evaluated by the shell-mandate policy, and blocked from recursively launching another process extension inside a custom MCP child.
  • Always-recoverable removal: kompile extension remove <id> runs compiled commands only and bypasses drop-in JARs so you can always deactivate a broken extension cleanly.

5. Walkthrough C — GraalVM Native-Image Plugins (Compile-Time & Runtime) ​

Because GraalVM native images use closed-world AOT compilation (they cannot dynamically load arbitrary Java .jar bytecode into the native process at runtime), Kompile supports two complementary native-image plugin models:

Native-Image Plugin ModelWhen It BindsRequires Rebuilding kompile?Requires a JVM at Runtime?Best For
Compile-Time In-Process SPI Plugin (CliExtension / CliToolProvider)At native-image build timeYes (custom native image)NoFirst-party or enterprise in-process commands & tools compiled directly into a custom native kompile binary
Runtime Native Executable Package (extension.json + "kind": "executable")At runtime via kompile extension installNoNoDistributable plugins compiled to a standalone native binary (GraalVM native-image, Go, Rust, or C) or script that extend any pre-built native kompile binary

5A. Compile-Time In-Process Native-Image Plugins ​

The exact same CliExtension / CliToolProvider JAR from Walkthrough A can be compiled directly into a custom GraalVM native kompile binary when you follow four AOT rules:

1. Register ServiceLoader With a Public No-Arg Constructor ​

Place your provider class in META-INF/services/ai.kompile.cli.plugin.api.CliExtension. When building kompile-cli-main, maven-shade-plugin's ServicesResourceTransformer automatically merges every dependency JAR's META-INF/services/ai.kompile.cli.plugin.api.CliExtension file before native-image runs, and GraalVM registers every listed provider automatically.

2. Keep Picocli Commands Native-Image Friendly ​

Pick either of two approaches for registerCommands(CommandLine root):

  • Reflection-free (zero config needed): Wrap a Callable<Integer> or Runnable directly with CommandSpec.wrapWithoutInspection(...) (the pattern verified in Kompile's NativeExtensionSmoke):
java
@Override
public void registerCommands(CommandLine root) {
    CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec
            .wrapWithoutInspection((java.util.concurrent.Callable<Integer>) () -> {
                System.out.println("Native plugin OK");
                return 0;
            })
            .name("release-notes");
    root.addSubcommand("release-notes", new CommandLine(spec));
}
  • Annotated @CommandLine.Command classes: Add info.picocli:picocli-codegen as an annotation processor in your plugin's pom.xml so Maven auto-generates META-INF/native-image/picocli-generated/<groupId>/<artifactId>/reflect-config.json inside your JAR:
xml
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <annotationProcessorPaths>
      <path>
        <groupId>info.picocli</groupId>
        <artifactId>picocli-codegen</artifactId>
        <version>4.7.7</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

3. Keep Jackson Reflection-Free (or Ship reflect-config.json) ​

Inside ExtensionTool.execute(...), prefer Jackson's tree API (JsonNode / ObjectNode), which requires zero reflection metadata in GraalVM native images. If your plugin binds custom POJOs or records with Jackson, include src/main/resources/META-INF/native-image/<groupId>/<artifactId>/reflect-config.json inside your extension JAR — kompile-cli-main passes -H:IncludeResources=META-INF/native-image/.*\.json and GraalVM automatically merges every META-INF/native-image/**/reflect-config.json on the classpath.

4. Include Your Plugin JAR in the Native Build ​

Add your plugin artifact as a dependency in your custom kompile-cli-main build (or pass it on -cp alongside the shaded CLI JAR) and run the GraalVM native build profile (native-maven-plugin):

bash
mvn -pl kompile-cli/kompile-cli-main -am -Pnative package -DskipTests

5B. Runtime Native-Binary Plugins (No Host Rebuild, Zero JVM) ​

To extend a pre-built GraalVM native kompile binary without requiring a JVM on the user's machine, compile your plugin into a standalone native binary — using GraalVM native-image on your own Java tool (e.g. ChangelogMain from Walkthrough B), or using Go, Rust, or C — and package it with "kind": "executable":

bash
# Example: compile ChangelogMain from Walkthrough B into a standalone native executable
native-image --no-fallback \
  -jar target/changelog-helper-1.0.0.jar \
  -o changelog-native-ext/bin/changelog-helper

changelog-native-ext/extension.json:

json
{
  "schemaVersion": 1,
  "apiVersion": 1,
  "id": "changelog-helper",
  "version": "1.0.0",
  "timeoutSeconds": 30,
  "commands": {
    "changelog": {
      "kind": "executable",
      "path": "bin/changelog-helper",
      "args": ["--cli"]
    }
  },
  "mcp": {
    "kind": "executable",
    "path": "bin/changelog-helper",
    "args": ["--mcp"]
  },
  "tools": [
    {
      "name": "recent_commits",
      "description": "Return recent Git commits in the current working directory",
      "inputSchema": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "Number of commits to return (1-50)"
          }
        },
        "required": ["count"]
      }
    }
  ]
}

Install identically on any native or JVM kompile binary (kompile extension install ./changelog-native-ext or .zip --sha256 <hex>). The exact same "kind": "executable" contract also works for Python, Node, or shell scripts (chmod +x).

5C. Native-Image Plugin Qualification Gates ​

Kompile ships opt-in --no-fallback GraalVM native-image tests that verify both compile-time SPI plugins and runtime native process plugins in isolation:

bash
# 1. Qualify compile-time ServiceLoader CliExtension discovery + Picocli command execution
mvn -o -pl :kompile-cli-main \
  -Dtest=CliExtensionNativeImageTest \
  -Dkompile.nativeImageExecutable=/path/to/graalvm/bin/native-image \
  -Dexec.skip=true test

# 2. Qualify standalone CliToolProvider across CHAT & MCP surfaces (verifies zero host/runtime leakage)
mvn -o -pl :kompile-cli-tool-api \
  -Dtest=ToolProviderNativeImageTest \
  -Dkompile.nativeImageExecutable=/path/to/graalvm/bin/native-image \
  test

# 3. Qualify runtime native binary installation & execution on a pre-built native host (no rebuild)
mvn -o -pl :kompile-cli-main \
  -Dtest=ProcessExtensionNativeImageTest \
  -Dkompile.nativeImageExecutable=/path/to/graalvm/bin/native-image \
  -Dexec.skip=true test

6. Quick Alternatives When You Don't Need a Full Extension ​


7. Troubleshooting ​

Error / SymptomCauseFix
Drop-in JAR in ~/.kompile/extensions/jars/ didn't loadRunning a GraalVM native kompile binary, or missing META-INF/services/ai.kompile.cli.plugin.api.CliExtensionDrop-in SPI JARs load in JVM mode (cli-harness-any / kompile.sh / kompile.cmd); for pre-built native binaries, package as "kind": "jar" (Section 4) or "kind": "executable" (Section 5B), or compile into a custom native image (Section 5A)
Custom native-image SPI command fails with reflection errorAnnotated @CommandLine.Command class or Jackson DTO missing GraalVM reflection metadataUse CommandSpec.wrapWithoutInspection(...) / JsonNode, or add picocli-codegen and META-INF/native-image/<groupId>/<artifactId>/reflect-config.json (Section 5A)
Drop-in SPI JAR crashes JVM startupBroken class, missing transitive dependency, or bad ServiceLoader entryRun with KOMPILE_NO_EXTENSION_JARS=1 and remove or fix the offending .jar in ~/.kompile/extensions/jars/
Extension MCP input schema mismatch: <tool>Subprocess tools/list returned a different inputSchema than extension.jsonEnsure the JSON schema in tools/list matches extension.json verbatim
Declared extension MCP tool is missing: <tool>Subprocess omitted a tool listed in extension.jsonReturn every declared tool from tools/list
mcp and nonempty tools must be declared togetherManifest defined mcp with empty tools, or tools without mcpDeclare both mcp and at least one tool, or omit both for a CLI-only extension
Jar launch requires a readable .jar file"kind": "jar" path does not end with .jar or file is missingCheck "path": "lib/<name>.jar" relative to extension.json
Extension command conflicts with host commandA key in commands matches a built-in Kompile commandRename the subcommand in extension.json or CliExtensionDescriptor
Broken process extension blocks normal commandsFaulty installed packageRun kompile extension remove <id> (always runs compiled commands only)

Next Steps ​

Released under the Apache-2.0 License.