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:
- The six default built-in extensions that ship with Kompile (plus the
kompile-local-runtime.jarcompanion overlay). - 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) viaServiceLoader. - How to ship a physical runnable
.jaras a Process Extension Package ("kind": "jar"inextension.json) so it also works with GraalVM nativekompilebinaries without rebuilding the native image. - How to build GraalVM Native-Image Plugins — both compile-time in-process SPI plugins baked into a custom native
kompilebinary and runtime standalone native binaries ("kind": "executable") that extend pre-built nativekompilebinaries 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:
# 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 --jsonInside an interactive kompile chat session, use /extension (aliases: /extensions, /plugin, /plugins).
The Six Default Built-In Extensions
| Extension ID | Provided Capabilities | Owned Tools | Runtime Requirement |
|---|---|---|---|
builtin.code | code.index | code_search, code_graph, local_code_index | Works locally in slim cli-harness (structural indexing & symbol graph; only explicit code_graph learn requires graph.learning) |
builtin.knowledge | knowledge.local | knowledge_search, knowledge_status, rag_search, graph_search | Requires lib/kompile-local-runtime.jar (kompile install local-runtime) or a connected server (--url) |
builtin.graph | graph.local, graph.learning | knowledge_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_mining | Requires lib/kompile-local-runtime.jar or a connected Kompile server (--url) |
builtin.crawl | crawl.local | crawl_source, crawl_documents, crawl_discover, crawl_control, crawl_result | Requires lib/kompile-local-runtime.jar or a connected Kompile server (--url) |
builtin.model | model.runtime | model_runtime, subprocess_watchdog, vlm_model_definition (chat surface only) | Requires kompile install local-runtime, kompile install model-serving, or a connected server (--url) |
builtin.pipeline | pipeline.local | pipeline (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:
| Model | Artifact | How It Loads | Works 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-process | Yes — drop in & run | Build-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.jar | Yes | Yes — install at runtime, no rebuild | Distributing 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.json | Installed with kompile extension install; runs directly with zero JVM requirement | Yes | Yes | Extensions 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,CliExtensionCatalogkompile-cli-tool-api(plugin-api+ Jackson):CliToolProvider(extendsCliExtension),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
release-notes-extension/
├── pom.xml
└── src/main/
├── java/com/example/kompile/ext/
│ └── ReleaseNotesExtension.java
└── resources/META-INF/services/
└── ai.kompile.cli.plugin.api.CliExtensionpom.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:
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:
com.example.kompile.ext.ReleaseNotesExtensionStep 4: Build & Install the Physical JAR
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> --replacekompile 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
# 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:
kompile extension remove release-notes-extension-1.0.0.jar
# or bypass drop-in JARs for any command:
KOMPILE_NO_EXTENSION_JARS=1 kompile extensionCompiling 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
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:
{
"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)
schemaVersionandapiVersionmust both be1.idmatches[a-z][a-z0-9-]{0,62};versionmatches[A-Za-z0-9][A-Za-z0-9._-]{0,63}.- Must declare at least one command or tool;
mcpand a non-emptytoolsarray must be declared together. timeoutSecondsis1–600(default60). CLI timeouts terminate the process tree and exit124(130on interrupt).- Every launch receives
KOMPILE_EXTENSION_ID,KOMPILE_EXTENSION_VERSION, andKOMPILE_EXTENSION_ROOT. - Strict MCP catalog verification: On every tool invocation, Kompile spawns a disposable stdio child (
--mcp), callsinitializeandtools/list, and verifies that every tool declared inextension.jsonis returned with an exact matchinginputSchema.
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):
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
# 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-helperInside 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 ininstalled.json. - Archive safety:
.zipinstalls 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 keymcp.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 Model | When It Binds | Requires Rebuilding kompile? | Requires a JVM at Runtime? | Best For |
|---|---|---|---|---|
Compile-Time In-Process SPI Plugin (CliExtension / CliToolProvider) | At native-image build time | Yes (custom native image) | No | First-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 install | No | No | Distributable 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>orRunnabledirectly withCommandSpec.wrapWithoutInspection(...)(the pattern verified in Kompile'sNativeExtensionSmoke):
@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.Commandclasses: Addinfo.picocli:picocli-codegenas an annotation processor in your plugin'spom.xmlso Maven auto-generatesMETA-INF/native-image/picocli-generated/<groupId>/<artifactId>/reflect-config.jsoninside your JAR:
<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):
mvn -pl kompile-cli/kompile-cli-main -am -Pnative package -DskipTests5B. 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":
# 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-helperchangelog-native-ext/extension.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:
# 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 test6. Quick Alternatives When You Don't Need a Full Extension
- One-off shell or HTTP tool: Drop a
.jsonfile into.kompile/tools/(project) or~/.kompile/tools/(user) and enable it withactivate_tools(["custom"]). See Declarative Custom Tools. - Existing MCP server: Connect any stdio, HTTP, or SSE server with
kompile mcp add. See Custom MCP Servers. - Complete installable persona: Bundle prompts, skills, bundled MCP tools, hooks, and optional local models into a signed
.kspinwith Building a Kompile Spin.
7. Troubleshooting
| Error / Symptom | Cause | Fix |
|---|---|---|
Drop-in JAR in ~/.kompile/extensions/jars/ didn't load | Running a GraalVM native kompile binary, or missing META-INF/services/ai.kompile.cli.plugin.api.CliExtension | Drop-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 error | Annotated @CommandLine.Command class or Jackson DTO missing GraalVM reflection metadata | Use 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 startup | Broken class, missing transitive dependency, or bad ServiceLoader entry | Run 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.json | Ensure the JSON schema in tools/list matches extension.json verbatim |
Declared extension MCP tool is missing: <tool> | Subprocess omitted a tool listed in extension.json | Return every declared tool from tools/list |
mcp and nonempty tools must be declared together | Manifest defined mcp with empty tools, or tools without mcp | Declare 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 missing | Check "path": "lib/<name>.jar" relative to extension.json |
Extension command conflicts with host command | A key in commands matches a built-in Kompile command | Rename the subcommand in extension.json or CliExtensionDescriptor |
| Broken process extension blocks normal commands | Faulty installed package | Run kompile extension remove <id> (always runs compiled commands only) |
Next Steps
- Extensions & Plugins Reference — Summary of every extension mechanism, scope precedence, and management command.
- Building a Kompile Spin — Package prompts, bundled MCP servers, declarative JSON tools, hooks, and runtime overlays into a signed
.kspindistribution. - CLI Extension Composition Architecture — Deep dive into
CliExtensionCatalog, capability boundaries, and native-image verification. - Custom MCP Servers — Connecting external stdio, HTTP, and SSE MCP servers.