Kompile Spins
Hands-On Walkthrough
Want a step-by-step guide covering kompile spin, bundled MCP tool servers, declarative JSON custom tools, process extension packages, signing, and self-extracting installers? Start with Building a Kompile Spin.
A spin is an installable Kompile persona with its own system prompt, role/tool policy, MCP sidecars, optional local models, and persistent project workspace. It reuses the normal Kompile chat/runtime rather than rebuilding a native image for every prompt.
The implementation is available through kompile spin when invoked from the main CLI and as kompile-agent spin / kompile agent spin through the delegated agent CLI.
Quick start
kompile spin init my-assistant
cd my-assistant
# Edit prompt.md, instructions.md, agent.yaml, and spin.yaml.
kompile spin validate .
# Keep publisher keys outside the source so the private key cannot be bundled.
kompile spin keygen --private-key ../publisher-private.pem \
--public-key ../publisher-public.pem
kompile spin build . -o ../my-assistant-0.1.0.kspin \
--signing-key ../publisher-private.pem
kompile spin validate ../my-assistant-0.1.0.kspin \
--trusted-key ../publisher-public.pem
kompile spin install ../my-assistant-0.1.0.kspin \
--trusted-key ../publisher-public.pem
~/.my-assistant/bin/my-assistant
~/.my-assistant/bin/my-assistant exec "Perform one task"
~/.my-assistant/bin/my-assistant doctorA spin installs into a dedicated ~/.<spin-id> home by default. Immutable payloads are checksum-verified and stored under components/<spin-id>/releases/<version>-<digest>/; workspace/ remains stable across upgrades. Model and tool payloads stay in the immutable release, and generated workspace configuration points to them, avoiding a multi-gigabyte copy per run. New spins disable global conversation-memory injection by default so the packaged persona starts from its own prompt and workspace. Pass --memory to a launch/exec command when deliberately opting into the user's Kompile memory.
Files
A spin source is also a valid agent-bundle directory:
my-assistant/
├── spin.yaml
├── agent.yaml
├── prompt.md
├── instructions.md
├── tools/
│ └── my-mcp-server
├── models/
│ ├── model.gguf
│ └── tokenizer.json
├── skills/
│ └── lookup/SKILL.md
└── workspace/
└── data/input_documents/spin.yaml owns distribution metadata:
schemaVersion: '1'
metadata:
id: my-assistant
version: 1.0.0
displayName: My Assistant
command: my-assistant
runtime:
delivery: thin # thin or embeddedagent.yaml owns runtime behavior:
schemaVersion: '1'
metadata:
name: my-assistant
description: A packaged assistant
engine: cli-loop
systemPrompt:
path: prompt.md
instructions:
- instructions.md
skills:
- path: skills/lookup/SKILL.md
name: lookup
role:
name: my-assistant
canSpawn: false
tools:
- mcp_tool_search
- mcp_tool_call
models:
- id: bundled-model
path: models/model.gguf
tokenizer: models/tokenizer.json
provider: kompile-local
default: true
mcp:
servers:
- id: assistant-tools
command: tools/my-mcp-server
bundled: true
executable: true
required: true
includeTools: [lookup]Bundled MCP tools
A bundled MCP server must use the stdio protocol and declare a bundle-relative command with bundled: true. During installation the command remains inside the versioned release, is made executable, and its generated .mcp.json entry receives an absolute path. The normal MCP fields—including required, timeoutSeconds, includeTools, excludeTools, args, cwd, and env—are preserved.
MCP env entries whose names indicate credentials must not contain literal secrets. They accept references such as ${API_TOKEN} or %API_TOKEN%; the credential value is supplied by the user at launch time. The placeholders ${SPIN_ROOT}, ${SPIN_HOME}, and ${SPIN_WORKSPACE} are resolved by the installer.
Bundled models
Any number of model assets may be listed. One may be marked default. A default kompile-local model automatically configures project-local chat and exports KOMPILE_CHAT_MODEL_PATH plus KOMPILE_CHAT_TOKENIZER_PATH to Kompile. GGUF and SDZ models therefore use the distribution's normal model-serving subprocess. Validation fails closed when an embedded default local model is packaged without kompile-model-serving; thin spins perform the same preflight against the selected external Kompile installation. Raw GGUF/ONNX/SafeTensors conversions are cached under the persistent workspace/.kompile/model-cache directory, never beside the source in the immutable release.
A per-model sha256 may be declared in agent.yaml. The complete .kspin also has a required manifest.sha256, so tools, prompts, models, and an embedded runtime are all verified before an installation is published.
Publisher signatures
manifest.sha256 proves internal integrity but is not publisher authentication. Public releases can add a detached Ed25519 signature over a domain-separated SHA-256 digest that covers every byte of the .kspin archive. Digest signing keeps memory bounded for multi-gigabyte model bundles:
# Generate once. Store the private key securely and publish the public key separately.
kompile spin keygen \
--private-key /secure/publisher-private.pem \
--public-key publisher-public.pem
# Build and sign in one operation; this writes release.kspin.sig by default.
kompile spin build . -o release.kspin \
--signing-key /secure/publisher-private.pem
# Consumers obtain publisher-public.pem through an independently trusted channel.
kompile spin validate release.kspin --trusted-key publisher-public.pem
kompile spin install release.kspin --trusted-key publisher-public.pem--trusted-key makes the signature mandatory and defaults its location to <archive>.sig; use --signature PATH for another sidecar name. A signature without an explicitly trusted public key is rejected. Existing private or internal workflows may still build and install unsigned spins, but should not treat checksums as publisher identity. kompile spin sign ARCHIVE --private-key KEY can sign an already-built archive. Build rejects signing keys inside the source tree to prevent accidentally shipping private key material. Validation and installation stream the source into a private temporary archive while verifying, then parse and extract only that exact authenticated copy so a path replacement cannot race signature verification.
Thin and embedded delivery
thinresolves a compatiblekompile/kompile-agentfromKOMPILE_CLI,KOMPILE_INSTALL_DIR,~/.kompile, orPATH.embeddedcarries an extracted canonical Kompile distribution underruntime/. Build it with--runtime-dir /path/to/extracted/kompile-dist; the installed launcher prefers this pinned runtime. It must containkompile-agent; a spin whose default model useskompile-localmust also containkompile-model-serving.
Set runtime.delivery: embedded in spin.yaml, then build:
kompile spin build . --runtime-dir /opt/build/kompile-dist -o my-assistant.kspinCredentials are never copied from the base distribution into a spin. User auth and provider configuration remain external unless the spin selects a bundled local model. Checksums detect corruption or payload changes; public spin archives should use the detached publisher-signature flow above.
Project-backed spins (schemaVersion 2) and components
For complete products that bundle Kompile runtime components, curated models/pipelines, custom software, web panels, targets, or a custom product entrypoint, use a v2 project-backed spin (kompile.project.json is the canonical composition authority):
# Scaffold a v2 project-backed spin (native, mixed, or jar delivery)
kompile spin init my-product --project --delivery jar --runtime-dir /opt/build/kompile-dist
# Register Kompile runtime components (all components present in --runtime-dir)
kompile spin component add my-product --type kompile-runtime --runtime-dir /opt/build/kompile-dist --all
# Add domain software, bundled MCP servers, skills, models, pipelines, targets, or web panels
kompile spin component add my-product --type software --id engine --source ./engine.jar --version 1.0.0
kompile spin component add my-product --type mcp --id tools --source ./my-mcp-server --bundled --required
kompile spin component add my-product --type skill --id triage --source ./triage.md
kompile spin component add my-product --type model --id chat --source ./model.sdz --tokenizer ./tokenizer.json --default
kompile spin component add my-product --type target --id linux-x64-cuda --os linux --arch x86_64 --backend nd4j-cuda-12.9 --source ./cuda-jars/
kompile spin component add my-product --type web-panel --id panels --source ./web-dist/ --version 1.0.0
# Add vertical harness primitives (multi-agent roles, hooks, workflows, enforcer policies, knowledge packs)
kompile spin component add my-product --type role --id reviewer --source ./reviewer-role.json
kompile spin component add my-product --type hook --id pre-commit --source ./pre-commit.sh
kompile spin component add my-product --type workflow --id audit --source ./audit-workflow.py
kompile spin component add my-product --type enforcer --source ./enforcer-config.json
kompile spin component add my-product --type permissions --source ./permissions.json
kompile spin component add my-product --type knowledge-pack --id docs --source ./curated-docs/
# Inspect, validate, and build (generates deterministic spin-lock.json, spin-sbom.cdx.json, and manifest.sha256)
kompile spin component list my-product
kompile spin validate my-product --runtime-dir /opt/build/kompile-dist
kompile spin build my-product --runtime-dir /opt/build/kompile-dist -o my-product-0.1.0.kspin
# Generate zero-prerequisite end-user self-extracting installers (.sh and .ps1)
kompile spin bundle-installer my-product-0.1.0.kspin --format sh -o my-product-0.1.0-installer.sh \
--trusted-key ../publisher-public.pem --signature my-product-0.1.0.kspin.sig
kompile spin bundle-installer my-product-0.1.0.kspin --format ps1 -o my-product-0.1.0-installer.ps1 \
--trusted-key ../publisher-public.pem --signature my-product-0.1.0.kspin.sigInstalled spin lifecycle and operations
Every installed spin supports atomic release management, qualification receipts, pinned asset provisioning, and redacted support diagnostics without mutating immutable releases:
# List installed spins (or releases under a specific spin home)
kompile spin list
kompile spin list --home ~/.my-product
# Upgrade from a local archive or verified HTTPS/file URL (remote URLs require --sha256 or --trusted-key)
kompile spin upgrade https://releases.example.com/my-product-0.2.0.kspin \
--home ~/.my-product --trusted-key publisher-public.pem
# Atomically roll back to the previous (or named) verified release
kompile spin rollback --home ~/.my-product
kompile spin rollback --home ~/.my-product --release 0.1.0-abcdef123456
# Run qualification checks and emit <home>/receipts/<release>.qualification.json
kompile spin qualify --home ~/.my-product
# Download and SHA-256-verify pinned large/optional assets into <home>/installation-assets/<release>/
kompile spin provision --home ~/.my-product
# Export a redacted support bundle (.zip) scrubbing tokens, API keys, passwords, and private keys
kompile spin support-bundle --home ~/.my-product -o my-product-support.zip
# Cleanly uninstall (preserves user workspace unless --purge-workspace is explicitly passed)
kompile spin uninstall --home ~/.my-productDeclarative vertical web chat (ProductChatPolicy)
Vertical products that ship --web --single-chat can configure their domain proxy routes and product-chat UI surface declaratively in their product profile policy JSON (no Java or Angular edits required):
nativeActionPolicy: validated policy id (kompile.content.v1,<vertical>.content.v1, etc.)domainProxy: optional{ runtimeHeader, connectionSchema, routes: [{ path, methods, queryParams }] }routing/api/agents/chat/product/domain/**to a loopback domain service specified inruntimeHeader.ui: optional{ subtitle, panelProtocol, panelTitle, sessionLabel, approvalsLabel, scopeFields: [{ key, label, type }] }.- Nested SPA assets under the product's
webdirectory are served recursively via/api/agents/chat/product/assets/**with strict non-symlink containment checks.
Inside kompile chat, use /spin (or the spin tool) to inspect the active spin workspace or manage spin components and lifecycle (status, init, component list|add|remove, validate, build, bundle_installer, list, upgrade, rollback, qualify, provision, support_bundle, doctor).