Manages plugin lifecycle (discovery, loading, execution, unloading), marketplace connectivity (multiple marketplaces), and skill loading from multiple sources (bundled, user dir, repo dir, plugin, MCP).
PluginState— Lifecycle enum: Discovered, Loading, Active, Error(String), Uninstalled, Installing.PluginHandle— Runtime representation with name, version, state, path, commands, skills, retry_count, max_retries, verified.PluginManifest— Deserialized fromplugin.json. Identity/metadata (name,displayName,version,description,author,homepage,repository,license,keywords,defaultEnabled,metadata,$schema), Codape execution fields (min_version,commands,skills,dependencies,signature,runtime,entrypoint,env),userConfig, and the Claude component fields Codape acts on. See the field table below.PluginAuthor—{name, email?}; parses from either an object (Claude's shape) or a bare string.UserConfigField— OneuserConfigentry:type,title,description,required,default,sensitive,multiple, plusoptions/min/max, all enforced against a supplied value at resolution time.PluginSource— Install source:Marketplace { name },LocalDir(path),Git { url, rev },Github { repo, rev, sha },GitSubdir { url, path, rev, sha },Archive { url, sha256 }, andUnsupported { kind };PluginSource::detect()classifies a CLI argument.PluginPin/PluginPinStore— Trust-on-first-use record of what was installed (archive SHA-256, git commit), read from.codape-pins.jsonin the install directory.RuntimeType— Enum:Process(default),Wasm. Declares how the plugin executes.MarketplacePlugin— Marketplace listing with download URL.MarketplaceConnection— HTTP client + base URL + configurable endpoint paths per marketplace.MarketplaceError— URL validation errors: InsecureUrl, InvalidUrl, NotAllowed.SignatureCheck— Three-state result of a signature check:Verified,Unverified(no key configured). An error means a configured key did not match.PluginManager—DashMap-backed registry of plugins and marketplaces with install locks, version checks, signature verification, dependency resolution, active process tracking, and host-supplieduserConfigvalues.ReconciliationReport— Diff between local and marketplace state.MarketplaceReconciler— Background reconciliation with optional auto-install.
PluginProcess— JSON-RPC 2.0 stdio transport for external process plugins. Spawns a child process, performscodape/initializehandshake, and exposeslist_commands,execute_command,list_skills,execute_skill,ping.PluginCommandInfo— Discovered command metadata (name, description, args).PluginSkillInfo— Discovered skill metadata (name, description, hooks).JsonRpcRequest/JsonRpcResponse— JSON-RPC 2.0 message types.
PluginCommandBridge— Iterates active plugin processes and registers each discovered command as a namespacedSlashCommand(/{plugin}/{command}) in theCommandRegistry. Handlers forward toPluginManager::execute_commandviatokio::task::block_in_place.
PluginToolExecutor— Implementscodape_core::tool_executor::ToolExecutor. Routes tool calls to plugin processes as a fallback layer behind the primary tool registry.
SkillMetadata— Parsed frontmatter: name, hooks, agent, allowed_tools, description, enabled.Skill— Loaded skill with metadata, source, path, and plugin_name (for plugin-owned skills).SkillSource— Enum: Bundled, UserDir, RepoDir, Plugin, Mcp. Precedence ordering for conflict resolution.SkillFile— Parsed content: metadata + script body.SkillLoader— Loads skill files from configured directories with conflict resolution, and adds the skills compiled into the binary (add_bundled_skills). Plugin and MCP skills can be added programmatically.
- DashMap for concurrent plugin/marketplace registries and active process tracking.
- AtomicBool for refresh flag.
- YAML frontmatter parsing via
serde_yamlwith customdeserialize_string_or_listfor scalar/array fields. - Layered skill loading: bundled -> user -> repo (
.codape/skills) with precedence-based conflict resolution. - Bundled skills are compiled in (
codape_core::bundled_skills), not unpacked to the config home:code-review,commit,debug,explain,security-review,simplifyandtest-failure-triage.SkillLoader::add_bundled_skillsadds them in memory after the directory scan, so a fresh install has them without a session writing a file, and a test run cannot leave anything behind. The three readers agree because they all read the same list: the loader (adverts), theSkilltool (opening one), and/skills(listing them). A user or repo skill of the same name wins by precedence and does not appear twice. - Atomic install staging: temp directory + validation + atomic rename + cleanup on failure.
- Install locks:
DashMap<String, Arc<tokio::sync::Mutex<()>>>prevents concurrent installs. - Version compatibility: SemVer comparison of
min_versionagainst app version on load and install. - Signature verification: Ed25519 check of the downloaded archive against a detached signature fetched from
<archive-url>.sig(hex), optional and configured viaCODAPE_PLUGIN_PUBLIC_KEY. The signature cannot live inside the archive it signs. With a key configured, sources that cannot carry a detached signature (local directory, git, git-subdir) fail closed unless an existing TOFU pin matches; without a key they install asUnverifiedwith a warning. - Manifest strictness:
deny_unknown_fieldsonPluginManifestandUserConfigField, plus a warning for accepted-but-unimplemented fields. - Environment injection:
userConfigvalues and staticenvare resolved and substituted before the child is spawned. - Trust on first use: archive SHA-256 / git commit recorded in
.codape-pins.jsonand checked on later installs. - Dependency resolution: Kahn's topological sort with cycle detection for plugin load ordering.
- Error recovery: Exponential-backoff retry for Error-state plugins (re-reads manifest, re-validates). A successful retry reports
RestartRequired(or invokes a registered restart handler); the CLI acts on that signal by callingspawn_pluginagain, so recovery restores a runtime instead of only clearing the error state. Process exits are detected byreap_dead_plugins()— called before each retry pass and after a failed command/skill — so a plugin that dies while idle is moved toErrorand retried rather than stayingActivewith a dead child. - MCP skills bridge: Discovered MCP tools converted to
SkillMetadataand stored inSessionContext.mcp_skills. - Hybrid execution model: Default tier = external process (JSON-RPC over stdio). Fast tier = WASM (compiled in-process, sandboxed, and loaded by
spawn_plugin). - Plugin command registration: Dynamic
SlashCommandregistration viaBox::leakfor&'static strnames/descriptions. - Plugin tool fallback:
PluginToolExecutorchains as a tertiary fallback behind primary registry -> MCP -> plugin.
PluginManager,PluginHandle,PluginState,PluginManifest,PluginAuthor,UserConfigField,RuntimeType,MarketplacePlugin,MarketplaceConnection,MarketplaceError,ReconciliationReport,MarketplaceReconciler.PluginSource,PluginPin,PluginPinStore,PIN_FILE_NAME,sha256_hex,substitute_user_config,PLUGIN_OPTION_ENV_PREFIX,PLUGIN_PUBLIC_KEY_ENV,SignatureCheck,unsupported_source_reason.PluginProcess,PluginCommandInfo,PluginSkillInfo.PluginCommandBridge.PluginToolExecutor.SkillLoader,Skill,SkillMetadata,SkillSource,SkillFile,parse_skill_file.
Plugins declare their runtime in plugin.json via the runtime field ("process" or "wasm", default: "process").
External process plugins communicate via JSON-RPC 2.0 over stdio using the codape/ method namespace:
codape/initialize— Protocol version and capabilities exchange.codape/commands/list— Discover commands.codape/commands/execute— Execute a command by name with args.codape/skills/list— Discover skills.codape/skills/execute— Execute a skill by name with context.codape/ping— Health check.
Process plugins declare an optional entrypoint (e.g., "bin/plugin", "node index.js") and custom env variables in their manifest. The orchestrator spawns them during InitPlugins, discovers commands/skills dynamically, and wires them into the REPL via with_plugin_manager.
The WASM runtime is enabled by default: crates/plugins/Cargo.toml has
default = ["process-runtime", "wasm-runtime"], and wasm-runtime pulls in
wasmtime 20. With the feature off, PluginWasmInstance::new returns a
"WASM runtime not enabled" error instead of loading anything.
spawn_plugin loads a runtime: "wasm" plugin from its entrypoint (default
plugin.wasm) by compiling the module, running codape_initialize, and
discovering commands and skills, then keeps the instance in
active_wasm_instances. userConfig is resolved by the same code path as for
a process plugin and delivered through the host import described below. A WASM
manifest's entrypoint is a file name, so ${user_config.KEY} substitution
applies to process env/entrypoint only; the resolved values reach a WASM
module through the import.
The sandbox is enforced by the host, not by trusting the module:
- Fuel: every call gets a fresh store with 100,000,000 fuel units
(
PLUGIN_FUEL). Fuel is charged per WebAssembly instruction, so a runaway loop traps instead of pinning the thread. - Memory: a
StoreLimitsresource limiter caps guest linear memory at 64 MiB (PLUGIN_MAX_MEMORY_BYTES). It is consulted both for memory declared at instantiation and for everymemory.grow. - Shared memory: the threads proposal is disabled (
wasm_threads(false)), so a module cannot create a shared memory (which wasmtime's store limiter deliberately does not bound) or use atomics. - Minimal host interface: the only import the host provides is
codape.user_config. WASI and everything else remain unlinked, so a module importing them fails to instantiate. A module that imports nothing is still instantiated with an empty import set and runs unchanged.
The host links one function:
(import "codape" "user_config"
(func $user_config (param i32 i32) (result i32)))
;; (ptr, capacity) -> required_lenIt writes the resolved options into the plugin's exported linear memory at
ptr and returns the full JSON length, not the number of bytes written.
The JSON value is one object whose keys and values are exactly what a process
plugin receives as CODAPE_PLUGIN_OPTION_<KEY> (and what ${user_config.KEY}
substitutes). For example:
{"REGION":"eu","TOKEN":"s3cret"}- An option with no value is absent from the object. It is not
nulland not an empty string, matching the process path, where no environment variable is set. - Sensitive options are included verbatim. As with environment injection, the
host is expected to have resolved any
keyring://reference first; an unresolved one stops the spawn. The runtime does not redact the value from the plugin it is being given to. - The guest can call
(0, 0)to query the length without writing anything, then allocate a buffer and call again. If the returned length is greater than the capacity passed, the JSON was truncated (onlycapacitybytes are written), so query first or retry with a larger buffer. - No NUL terminator is written: the returned length is authoritative. (Do not assume the byte after the JSON belongs to the host.)
- The host returns
-1for a negative pointer/capacity, a missingmemoryexport, or a write that would fall outside guest memory. - Options apply to the whole instance: every call gets a fresh store, but the same serialized options are served each time.
Existing plugins must import the function to receive options. Linking is
opt-in at the module level: a plugin that does not declare the import
instantiates exactly as it did before and simply has no way to read the
options. This keeps the empty-import set working, at the cost that adding
userConfig to a plugin requires an ABI change on the plugin side (a new
import, and a rebuild) rather than being transparent.
Compilation is bounded in two layers. The first runs in-process and bounds the work, the second runs in a killable child and bounds the time. Compilation is mandatory out-of-process: there is no in-process fallback, because wasmtime 20 has no compile-time interruption.
Layer 1 — linear pre-scan (always on). Before any compiler process is
started, PluginWasmInstance::new parses the module linearly with wasmparser
and rejects it when any of these limits is exceeded:
| Limit | Constant | Value |
|---|---|---|
| Module file | PLUGIN_MAX_WASM_BYTES |
16 MiB |
| Code section bytes | PLUGIN_MAX_CODE_SECTION_BYTES |
8 MiB |
| Declared functions | PLUGIN_MAX_FUNCTIONS |
50,000 |
| Total operators (all bodies) | PLUGIN_MAX_OPERATORS |
1,000,000 |
block/loop/if nesting |
PLUGIN_MAX_NESTING_DEPTH |
256 |
| WAT text input | PLUGIN_MAX_WAT_BYTES |
1 MiB |
The file-size check runs from metadata before reading and again after reading, so an oversized file is never loaded. The pre-scan translates WAT text to the binary format first, so the text form cannot bypass the limits; every error names the limit it crossed. The scan deliberately does not validate the module — wasmtime still does that — it only measures work. The compiler process repeats the pre-scan on the bytes it receives.
Layer 2 — host-injected out-of-process compilation. The runtime takes a
compiler command from its host: a program plus leading arguments
(WasmCompilerCommand / set_compiler_command). The CLI sets it to
std::env::current_exe() --internal-wasm-compile, and handles that hidden
argument before clap parsing. The runtime appends <input> <output> and runs
the result as a child. Because the host re-executes itself, cargo run,
packaged builds with only the codape binary, and the separate
codape-wasm-compile helper all use the same path.
The helper binary is deliberately kept, not a leftover. The production CLI
path no longer needs it, but crates/plugins/tests/wasm_compile_subprocess.rs
drives a real compiler subprocess through CARGO_BIN_EXE_codape-wasm-compile,
and codape-cli depends on codape-plugins — so the plugin crate cannot
dev-depend on the CLI to exercise its own --internal-wasm-compile path.
Removing the [[bin]] would mean deleting the only test that runs the compiler
as a separate process, so it stays and is built by default.
Fail closed. When no command is configured and no helper is found next to
the executable, the load is refused with an actionable error naming
set_compiler_command. A compiler that exits non-zero, times out, or emits
bytes this runtime cannot deserialize is also an error. The runtime never
falls back to compiling untrusted code in-process.
Killing the tree. The child is spawned in its own process group
(process_group(0)), and a timeout sends SIGKILL to the whole group before
reaping the direct child. On Linux, when the compiler was actually attached to
its cgroup (see the limits below), the timeout uses cgroup.kill instead: it
also stops a descendant that called setsid and left the process group. If the
group could not be created or the attach failed, the process-group kill is
used. On Windows the compiler runs under the shared
SandboxHandle (the same one the shell tools use): a suspended child, an
AppContainer token attached after spawn, and an anonymous Job Object with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. A timeout calls TerminateJobObject via
SandboxHandle::terminate, and closing the handle kills anything left. No
helper descendant survives a timeout.
The parent also installs:
RLIMIT_CPU= 20 s (Unix, mandatory);- a 2 GiB memory limit (Unix, best-effort):
RLIMIT_ASon Linux and other Unix,RLIMIT_DATAon Darwin (see the boundary note); - on Linux, a cgroup v2 group with
memory.max= 2 GiB when a writable delegated tree exists. It is created before the spawn and the child is attached immediately after.memory.maxbounds resident use for the whole group, whileRLIMIT_ASonly bounds one process's virtual address space. There is deliberately nopids.max: that controller counts threads, and Cranelift sizes its compilation pool from the core count; - a 30 s wall-clock timer;
- on Windows, Job Object job user-time and job memory limits in addition to kill-on-close.
OS sandbox around the compiler. Where the core sandbox primitives fit, they wrap the compiler as well as the process-group/job kill:
| Platform | Applied to the compiler process | What it confines |
|---|---|---|
| macOS | sandbox-exec(1) profile from codape_core::sandbox |
reads to system roots plus the staging directory and compiler binary; writes to the staging directory only; network denied |
Linux with bwrap |
bubblewrap mount/network namespace, plus the cgroup above | read-only root, staging directory the only writable path, network namespace unshared; memory ceiling and whole-group kill when a cgroup could be created |
Linux without bwrap |
Landlock, the cgroup above when available, and a short seccomp deny-list | memory ceiling and whole-group kill; paths confined by Landlock instead of a mount namespace; network, ptrace, mount/namespace, bpf/perf/userfaultfd/io_uring and module/key syscalls refused with EPERM |
| Windows | AppContainer + Job Object (SandboxHandle) |
reads to system roots, the staging directory and the compiler directory; writes to the staging directory; execute of the compiler; network denied; CPU/memory and kill-on-close |
The shell seccomp allowlist is deliberately not applied: it is written for
shells and would reject wasmtime's syscalls. A short deny-list is installed
instead whenever bubblewrap is not wrapping the compiler: network, ptrace,
mount/namespace, bpf/perf/userfaultfd/io_uring, module, kexec/reboot and
kernel-keyring syscalls are refused with EPERM, and everything else is
allowed, so the list does not go stale as wasmtime or the loader learns new
calls. It is built before the fork and only handed to prctl in pre_exec
(nothing allocates after fork). Bubblewrap needs those syscalls itself and
inherits any filter, so the filter is not installed when it wraps the command;
the mount and network namespaces are the boundary in that layout. Bubblewrap is
skipped when the
staging directory is inside the system temp directory, because bwrap replaces
/tmp with a fresh tmpfs and the bind mount would resolve against it; in that
layout the compiler gets rlimits, Landlock path confinement, the cgroup above
when one could be created, and the process-group kill. On macOS, if
sandbox-exec is missing or profile creation fails, the compiler likewise runs
with rlimits and the process-group kill only. Those degradations are logged;
this document does not claim a sandbox that was not applied.
AOT cache. A module is compiled under the helper on first load, and
Module::serialize output is stored for later loads:
- Location:
CODAPE_WASM_CACHE_DIRif set, otherwise~/Library/Caches/codape/wasm(macOS),$XDG_CACHE_HOME/codape/wasmor~/.cache/codape/wasm(Linux),%LOCALAPPDATA%\codape\wasm(Windows). Hosts can also callset_cache_dir. - Key:
<engine-config-hash>/<module-sha256>.cwasm. The engine hash is SHA-256 over wasmtime'sprecompile_compatibility_hash(version plus every code-generation-relevant config knob) and a format tag; the module hash is SHA-256 of the exact pre-scanned bytes (WAT is translated first). - Verification: entries carry a header with both hashes and the payload
length. Before
Module::deserialize, both are compared against values recomputed for this load; a mismatch or a deserialize failure deletes the entry and recompiles. wasmtime independently rejects precompiled code built by an incompatible engine. - Write: atomically (temp file in the engine directory, then rename), with a lost race treated as success when a complete entry is already present.
- Pruning: after each write the cache is pruned oldest-first to
WASM_CACHE_MAX_BYTES(256 MiB). The newest entry is kept even if it alone exceeds the bound. Staging directories for in-flight compilations are not counted or pruned.
Honest remaining boundaries:
- On Darwin the memory bound is
RLIMIT_DATA, because Darwin rejects finiteRLIMIT_ASvalues withEINVAL.RLIMIT_DATAcaps the data segment rather than the whole address space: direct mappings, the stack and the executable image are outside it, so it is not a full address-space cap. The limit is best-effort (a failure is ignored, because it cannot be logged frompre_exec); the child still has the hard CPU limit, the wall-clock kill and the sandbox-exec profile. Since Darwin has no kernel memory ceiling, a user-space watchdog samplesproc_pid_rusage'sri_phys_footprintevery 20 ms — dirty plus compressed pages, the quantity jetsam uses — and, once it exceeds the limit,SIGSTOPs the group beforeSIGKILLing it, so the process cannot keep allocating while the signal is delivered. Other Unix platforms useRLIMIT_AS, subject to the same best-effort handling. - The Windows compiler sandbox uses
codape_core::sandbox; its Win32 calls are exercised by thetest_windowsCI job (wasm_compile_subprocess), not by a macOS host. - The Linux cgroup limit exists only when the host delegates a writable cgroup
v2 tree. An ordinary unprivileged session usually cannot create one, and the
compiler then runs with
RLIMIT_AS+ the process-group kill; the fallback is logged and never reported as cgroup-limited. The integration test uses a plain-directory stand-in for the tree, so its group directory is left behind (remove_dircannot delete the synthetic files); a real cgroupfs removes it. - The compiler child inherits this process's environment. It is the same binary/trust domain as the host, so credentials are not scrubbed from it (in contrast to third-party tool processes).
- The AOT cache trusts the user's private cache directory. The envelope checks integrity and engine/module correspondence, not authenticity; a same-user process able to write there is already inside the trust boundary.
- macOS
sandbox-execis deprecated by Apple. The runtime probes for it and falls back to rlimits + process-group kill when it is unavailable. - The helper path, timeout, and test hooks have debug-build-only environment
overrides (
CODAPE_WASM_COMPILE_HELPER,CODAPE_WASM_COMPILE_TIMEOUT_MS, and theCODAPE_WASM_COMPILE_TEST_*variables) used by the tests. Release builds neither read nor compile the test hooks. - wasmtime 20 has no compile-time fuel or epoch option;
parallel_compilation(false)only chooses single-threaded compilation (it does not reduce total work), andmax_wasm_stackbounds the guest stack at runtime, not compilation.
The manifest is parsed with deny_unknown_fields: a field that is not in the table below is a hard parse error naming the field, not something silently dropped. That was the real defect — an author could write displayName and be told nothing, because the whole field vanished at parse time. discover() likewise logs a warning for a manifest it cannot parse instead of skipping it in silence.
| Field | Status | Notes |
|---|---|---|
$schema, name, displayName, version, description, homepage, repository, license, keywords, defaultEnabled, metadata |
✅ parsed | Identity and metadata. author accepts a string or {name, email}; an object used to fail the whole manifest. |
min_version, commands, skills, dependencies, signature, runtime, entrypoint, env |
✅ acted on | Codape execution fields (pre-existing). |
userConfig |
✅ implemented | Values are validated against the declared schema (type, options, min, max, required, default) before they reach a plugin. See "userConfig injection". |
hooks |
✅ implemented | Active plugins contribute their hooks to the Plugin tier. The value may be a bare array or {"hooks":[...]}; PluginManager::plugin_hooks() merges them in plugin-name order and logs malformed values. |
agents |
✅ implemented | Active plugins contribute definitions through PluginManager::plugin_agents(); the REPL registers them as custom agents. |
outputStyles |
✅ implemented | Name-keyed registry; /style <name> applies one as extra system instructions. The three built-ins (default, explanatory, learning) come from the binary, so /style works with no plugin installed; a plugin style of the same name wins. |
themes |
✅ implemented | Name-keyed registry; ThemeManager::register_json makes them selectable via /theme. |
workflows |
✅ implemented | Named scripts registered with the Workflow tool. |
monitors |
✅ implemented | Persistent watch scripts armed with the session (PluginMonitorSupervisor). Whole-tree ownership is a process group (Unix) or Job Object (Windows), plus a cgroup on Linux; on macOS the supervisor samples descendants while the monitor runs, so one that is re-parented to launchd after its intermediate parent exits is still killed at cleanup. On Unix a guardian process holds a pipe from the host and kills the recorded tree if the host is SIGKILLed; it runs in its own process group, so a killpg of the host's group does not take it down (Windows relies on its kill-on-close Job Object). |
mcpServers |
✅ implemented | Active plugins contribute {"mcpServers": {...}} through PluginManager::plugin_mcp_servers(); the orchestrator loads them before .mcp.json (project file wins on name clashes). |
lspServers |
✅ implemented | The first configured server is the default for the LSP tool (the REPL fills the tool's shared default at startup). |
channels |
✅ implemented (delivery: webhook, MCP tool, or command) | A channel names a configured MCP server and routes that server's JSON-RPC notifications to subscribed sinks (PluginManager::subscribe_channel / route_channel_notification). /plugin components lists each channel with its live state — subscribed, idle (no subscriber), or server not configured. See "Channels". |
binaries |
✅ implemented | SHA-256-pinned HTTPS fetch into <plugin>/bin/ (fetch_plugin_binaries); CODAPE_PLUGIN_NO_BINARIES=1 skips the fetch. |
types |
✅ implemented | Validated .d.ts files are exported at startup to config_home()/plugin-types/<plugin>/ (export_plugin_types) so a plugin author has a stable include path, and read into a PluginTypeRegistry that /plugin components lists. The same export writes the host's generated surface — codape/, codape-tools/, codape-mcp/ and a tsconfig.json — from the registered tool schemas; /plugin types [name] lists or prints them. The exported tree is type-checked with a real tsc when one is available (startup, plus codape plugin-typecheck); nothing is ever executed. See "Types". |
settings |
✅ implemented (allowlisted) | A typed patch deep-merges into the resolved settings, by source: user/project values win over every plugin, and a plugin only fills a key the user left unset. permission_mode, telemetry and max_budget_usd are tighten-only; hooks, mcpServers, api_key, provider and env are never taken. Unknown keys warn and are ignored. See "Settings". |
experimental |
✅ implemented (raw) | Exposed per plugin; expansion (themes/monitors/outputStyles/…) is the caller's job. |
All declared component fields now have a runtime surface. PluginManifest::unimplemented_fields() is empty and remains as the guard against a future field silently doing nothing.
A manifest declares options, and spawn_plugin turns them into the child's environment before the process is spawned:
{
"name": "my-plugin",
"entrypoint": "bin/plugin --region ${user_config.REGION}",
"env": { "ENDPOINT": "https://${user_config.REGION}.example.com" },
"userConfig": {
"TOKEN": { "type": "string", "title": "API token", "sensitive": true, "required": true },
"REGION": { "type": "string", "default": "eu" }
}
}- Each resolved option becomes
CODAPE_PLUGIN_OPTION_<KEY>in the plugin process (Claude'sCLAUDE_PLUGIN_OPTION_<KEY>). ${user_config.KEY}is substituted in the manifest'senvvalues and in theentrypoint. An unresolved placeholder is left as written and logged, so an author can see what did not resolve.- Values are resolved in order: what the host supplied via
PluginManager::set_plugin_option, then Codape's ownCODAPE_PLUGIN_OPTION_<KEY>, then the manifest'sdefault. - A supplied value is checked against the declared schema before it is injected (
resolve_options→validate_option_value):options(an array, or{ "value": ..., "label": ... }objects) is an allowlist; a value outside it is refused.type: "number"(or a declaredmin/max) requires a number, andmin/maxare enforced inclusively.type: "boolean"requires exactlytrueorfalse.- Every rejection is an error naming the option, the value, and what was expected — the spawn stops rather than handing the plugin a value its own manifest rejects.
- Option keys must be usable as environment variable names (
[A-Za-z_][A-Za-z0-9_]*); anything else is refused, because a key with a dash or an=in it is a way to smuggle a second variable into the environment. - WASM plugins use the same resolution and the same validation errors, but the resolved values are encoded as one JSON object and served through the
codape.user_configimport rather than an environment (see "userConfigABI for WASM plugins"). A WASM plugin receives them only if it imports that function; a required option with no value still stops the spawn, even though there is no environment.
Sensitive options. There is no keychain dependency in this crate (the workspace's keychain access lives in codape-config, behind its keyring feature), so the sensitive path is strict rather than quiet:
- A
sensitiveoption may not carry a plaintextdefault— a secret inplugin.jsonis a secret in a file that gets committed. That is a load-time error. - A sensitive value that is still an unresolved
keyring://itemreference is refused: injecting the literal reference would hand the plugin a string that is not the secret, and resolving it needs the keychain. The host is expected to resolve it first (codape_config::resolve_api_keyis the existing convention). - A
requiredoption with no value stops the spawn with an error naming the variable to set. A plugin that silently runs without the secret it asked for is worse than one that does not run. - An optional option with no value is simply not injected (debug log).
- Sensitive values travel by environment variable (process plugins) or through the resolved options object (WASM plugins). Either way they are visible to the plugin that asked for them; for process plugins they are also visible in the process table of the same user, which is Claude's design too.
Honest gap: there is no interactive prompt and no plugin settings store, so options come from the host or from the environment — nothing writes a user's answers back to settings.json the way Claude does. Values are validated against the declared schema (above), but there is still no prompt to collect a missing one. For WASM plugins, options require an explicit import in the module; they are not delivered retroactively to existing plugins.
A plugin's settings is a narrow allowlist, and it is a patch, not a replacement. The patch deep-merges into the session's resolved settings by source: user and project settings outrank every plugin, so a plugin can supply a default the user never set but can never override one they did.
| Group | Keys | Rule |
|---|---|---|
| Mergeable | model, context_window, vim_mode, statusline |
Fill only a key the user left unset; the user's value wins, recursively for nested objects. |
| Tighten-only | permission_mode, telemetry_enabled, telemetry, max_budget_usd |
May only make the session stricter. permission_mode moves only toward the more restrictive end (plan < dont-ask < default/auto < accept-edits < bypass-permissions); telemetry_enabled may only go to false; max_budget_usd may only lower the ceiling. A telemetry object is refused outright. |
| Never taken | hooks, hook_layers, mcpServers, mcp_servers, api_key, provider, env, config_version |
Security-sensitive; ignored with a warning, whatever the value. |
An unknown key is warned about and ignored. A refused or loosen-only value is warned about and ignored — never applied.
A channels declaration names a configured MCP server and gives it a name:
{ "channels": [ { "server": "slack", "displayName": "Team chat" } ] }PluginManager::plugin_channel_report()returns one entry per declared channel with its live state:Subscribed(a sink is attached),Idle(the server is configured but nothing is subscribed), orServerNotConfigured. A channel naming an unconfigured server is reported as such rather than shown as working.subscribe_channel(server, sink)attaches aChannelSink;route_channel_notification(server, method, params)turns one JSON-RPC notification from that server into aPluginChannelEventand hands it to every subscribed sink, returning how many received it.0is an honest answer — nothing is bound or nothing is subscribed — not an error./plugin componentslists each channel asdisplayName -> server [state].- The MCP client does drive it:
McpManagerroutes every notification a configured server emits throughPluginChannelRouterintoroute_channel_notification, and the session subscribes a production sink to every declared channel. - Honest limit: this is routing plus an in-process fan-out, not a transport. The sink records events into a bounded session log; nothing carries a channel message out of the process (a chat product, another host) and there is no inbound path.
PluginChannelEventis deliberately transport-free.
A plugin command may return a JSON object with a ui payload instead of a
plain string:
{
"text": "optional summary printed before the panel",
"ui": {
"title": "Deploy status",
"style": "info",
"lines": ["api: ok", "web: failed"]
}
}plugin_ui::render_plugin_response turns it into a titled text panel (a
scrollable message in the TUI, the same box on the terminal). style may be
info (default), warning or error; the last two prefix the title with a
marker. Anything that is not a JSON object carrying ui is passed through
unchanged, so a plugin that prints JSON still prints JSON.
Honest limit: plugins run out-of-process, so this is a structured text
block, not a widget tree. There is no Box/Text/Button, no interaction,
and no per-surface rendering (terminal/desktop/vscode); the reference's
in-process mods get those because they run inside its UI runtime.
There are two halves to the type surface: the declarations a plugin ships, and the declarations Codape generates for its own builtin surface. Both are exported under config_home()/plugin-types/.
A plugin may export TypeScript declarations:
{ "types": ["./types/index.d.ts"] }- Every declared path is validated (relative, no
.., ends in.d.ts) and exported at startup toconfig_home()/plugin-types/<plugin>/byPluginManager::export_plugin_types, so a plugin author has a stable include path. Declared files are flattened to their file name under the plugin directory (types/index.d.tsbecomes<plugin>/index.d.ts). - They are also read into a
PluginTypeRegistry(PluginManager::plugin_type_registry()), and/plugin componentslists each file asname (plugin). - A file that cannot be read is recorded in the registry's error list (and warned about) rather than dropped.
At startup the same call writes Codape's own type surface, generated from the actual registered tool schemas. The root contains:
| Artefact | Contents |
|---|---|
codape/index.d.ts |
declare module 'codape': EngineInterface, HookContext (session id, cwd, model, permission mode, turn number), Hook, HookResult, HookEvent, and PermissionMode. |
codape-tools/index.d.ts |
declare module 'codape-tools': interface BuiltinToolInputs { <ToolName>: <input schema> } and interface BuiltinToolResults { <ToolName>: <result schema> }, one member per builtin tool. |
codape-mcp/index.d.ts |
declare module 'codape-mcp': McpServer with name, transport, command/url, headers/env, and status, plus the McpTransport and McpServerStatus unions. |
tsconfig.json |
compilerOptions with strict and noEmit, and an include array listing every emitted directory. A plugin can extend it. |
<plugin>/ |
Each active plugin's declared .d.ts files, as above. |
The generator is crates/plugins/src/declarations.rs; the four pure entry points are builtin_tools_declaration / builtin_tools_declaration_with_results, engine_declaration, mcp_declaration, and tsconfig_declaration. PluginManager::export_plugin_types is the IO half: it writes the three generated modules, the plugin-declared files, and the tsconfig.json whose include lists the directories it actually emitted.
The CLI supplies the tool schemas from the builtin tool registry (register_builtin_tools → all_descriptors). A tool's input_schema becomes its input type; its output_schema becomes its result type when one is declared, and unknown otherwise. Tool names are sorted, so the file is stable from run to run. MCP and other dynamic tools are not in the generated file: they are only known after a session connects.
The conversion is intentionally bounded. It handles the shapes the builtin schemas use and falls back to unknown rather than inventing a type:
| JSON Schema | TypeScript |
|---|---|
type: "object" + properties + required |
{ name: T; optional?: T }; members not listed in required are optional. |
type: "string" / "number" / "integer" / "boolean" / "null" |
string / number / number / boolean / null. |
type: "array" + items |
Array<T>; items absent → Array<unknown>. |
enum |
A union of literals ("a" | "b"), never when empty. |
const |
The literal value. |
anyOf / oneOf |
A union of the converted branches, with duplicates dropped. |
additionalProperties |
An index signature; an explicit property union is widened to keep the emitted signature valid. |
Anything else ($ref, unknown type, no type) |
unknown. |
Property and tool names that are not TypeScript identifiers are quoted ("run-in-background"?: boolean). Nested objects are indented from their enclosing context.
/plugin typeslists every emitted declaration with its path:codape,codape-tools,codape-mcp,tsconfig, and one entry per plugin directory./plugin types <name>prints one. The name is the listed name; a relative path such ascodape-tools/index.d.tsalso works. A name that is not in the list is an error — the resolver only matches already-listed files, so it cannot read outside the type root.
A channel binds a name to an MCP server: that server's notifications are
routed to every sink subscribed to the channel. The CLI's recorder is always
one sink; a channel may also declare one delivery target, in one of three
forms. A deliver object naming more than one form is refused rather than
silently picking one.
The first form is a webhook:
"channels": {
"ops": {
"server": "ops-server",
"displayName": "Ops alerts",
"deliver": { "url": "https://hooks.example.com/codape" }
}
}Each notification is POSTed to that URL as JSON (channel, plugin, server,
method, params, sequence).
The second transport calls a tool on another MCP server instead:
"deliver": { "server": "pager", "tool": "raise" }The event object is passed verbatim as the tool's arguments, so the target
tool declares the shape it accepts (channel, method, params, sequence).
This is for a server that already knows how to reach Slack, Jira or PagerDuty:
no webhook endpoint and no script. Delivering to the channel's own server
is refused — the delivery would feed the notifications that produced it. An
indirect cycle (A's channel delivers to B, whose notifications deliver back to
A) is not detectable statically and is the manifest author's responsibility.
The third transport runs a local program once per event, with the event as JSON on its stdin:
"deliver": { "command": "/home/me/bin/notify.sh", "args": ["--ops"] }command must be an absolute path, and it is executed directly — no shell —
so neither args nor the event can be reinterpreted as code. The environment
is cleared apart from PATH and three markers (CODAPE_CHANNEL,
CODAPE_CHANNEL_PLUGIN, CODAPE_CHANNEL_SERVER), so the session's provider
credentials do not reach the program. The program is not sandboxed: it
runs with the user's privileges. That is not a new trust decision a manifest
can make — commands, monitors and mcpServers already run code — but it
does mean the program can read and write whatever the user can. Point it at a
notification script the user wrote or reviewed. A non-zero exit counts as a
failure, and its stderr (up to 200 characters) becomes the reported reason.
The timeout kills the program Codape started; children it spawned itself are
not reaped.
Delivery is lossy on purpose for all three: the sink enqueues (256 events)
and a background task sends with a timeout (5 s for a webhook or a command,
10 s for a tool call), so a slow or hanging target cannot stall the MCP
notification path. A full queue, a non-2xx answer, an isError result, a
non-zero exit, or a timeout is counted — /plugin components shows
delivered N, dropped N, failed N and the last error next to the channel.
https is required except on a loopback host, where plain http is allowed
(a local integration or a test server). Any other scheme, or plain http to a
remote host, is refused when the manifest is read: the channel is listed as
delivery refused: … and no sink is subscribed.
The tool sink is subscribed after the MCP servers start (a notification cannot arrive before that either); a run with no MCP servers configured has no manager to call, so a tool delivery is reported as unsubscribed rather than silently dropped. A command delivery needs no MCP manager, so it is subscribed even in a run with no servers.
CODAPE_PLUGIN_NO_TYPECHECK does not affect delivery; there is no
environment switch that turns delivery off — remove the deliver block.
Exporting made the declarations readable, not correct. crates/plugins/src/typecheck.rs
runs a real TypeScript compiler over config_home()/plugin-types:
- at startup, after the export, best-effort (a warning names the first diagnostic; a missing compiler is logged at debug and nothing more);
- on demand with
codape plugin-typecheck [--dir DIR], which prints every diagnostic and exits1when the plugin's declarations have errors,2when the compiler timed out, and0when it passed or when there was no compiler to check with — "nothing checked" is not "failed".
The compiler is found at CODAPE_TSC (when set), then
<root>/node_modules/.bin/tsc, then tsc on PATH. Nothing is bundled, so a
machine without TypeScript reports that instead of pretending. The whole check
can be turned off with CODAPE_PLUGIN_NO_TYPECHECK=1.
The run is a real subprocess (tsc --noEmit --pretty false -p tsconfig.json)
with a 20-second ceiling; it reads the exported files and writes nothing.
/plugin componentscontinues to list the plugin-declared declarations asname (plugin); the generated modules are a separate artefact.
- No TypeScript execution. The Rust binary does not run a TypeScript compiler, type-check the generated output, or host a language server. "Generated" and "loaded" both mean text that is written, read into memory, and printed; it is never evaluated.
- No schema compilation for validation. TypeScript types are for plugin authors' editors and builds; Codape's own runtime validation is unchanged.
- No invented types. A schema feature the converter does not understand is
unknown, not a guess. In particular$refis not resolved across documents.
Marketplaces are configured in settings.json under marketplaces ([{"name": …, "url": …}]). Writing that key by hand used to be the only way to add one, so an install run from a script had to know both the key's shape and the file's location. Both surfaces now exist and share one validator (MarketplaceSetting::validated, crates/config/src/settings.rs):
codape plugin marketplace list
codape plugin marketplace add <name> <https-url>
codape plugin marketplace remove <name>
and, in a session, /plugin marketplace [list|add <name> <https-url>|remove <name>]. The validator applies the same rules PluginManager::register_marketplace does — HTTPS only, no whitespace or / in the name — before anything is persisted, so a marketplace that would be skipped at startup is refused with a reason instead of saved. Adding a name that already exists replaces its URL rather than appending a second entry, because which URL an install resolved against otherwise depended on registration order. The CLI rewrites the file through a temporary file and a rename, keeps every other key, and refuses to touch a settings.json it could not parse.
PluginSource has seven kinds, and PluginSource::detect() classifies a CLI argument into one of them (a github:/git-subdir: prefix → that kind; an existing directory → LocalDir; a git remote → Git; an HTTPS .tar.gz/.tgz → Archive; anything else → a marketplace listing name, which is what codape plugin install <name> has always meant). install_plugin routes a listing whose url is not a marketplace URL to install_from_source, so codape plugin install ./my-plugin and codape plugin install https://github.com/acme/plugin.git work without the CLI changing its argument shape.
The in-session /plugin install <source> takes the same sources. The command handler cannot call the installer — codape-commands does not depend on codape-plugins — so it returns a CommandResult carrying CommandDeferred::PluginInstall { source }. The REPL records that in pending_deferred and drains it at the two async entry points: execute_command (headless, report appended to the command's own output) and spawn_deferred_work after process_tui_input (the install runs in a tokio::spawn and reports through the ShellCommandResult channel ! commands use, so the frame keeps drawing). A bare name that is not a marketplace plugin, with no marketplace configured, is refused with the source kinds that would work rather than a silent no-op.
| Kind | Behaviour |
|---|---|
Marketplace { name } |
The original path: HTTPS listing → download endpoint → extract → validate → atomic rename. |
LocalDir(path) |
Reads plugin.json, copies the directory into a staging directory, then renames it into place. The source is copied, not moved or linked, so it stays a working copy. |
Git { url, rev } |
Shallow clone (--depth 1, --branch <rev>); a full commit SHA as rev clones the history and checks it out. .git is dropped afterwards so the install is a snapshot, not a nested repository. The resolved commit is the plugin's pin. |
Github { repo, rev, sha } |
owner/repo is expanded to https://github.com/<owner>/<repo>.git and installed by the git path, so transport validation, GIT_TERMINAL_PROMPT=0 and commit pinning all apply unchanged. repo must be exactly owner/repo — anything with extra segments, a leading /, or a .. segment is refused before a URL is built. |
GitSubdir { url, path, rev, sha } |
Clone, then install the named subdirectory as the plugin. path is resolved inside the clone: an absolute path or a .. component is refused syntactically, and the joined path is then canonicalised and must still be under the clone root, so a committed symlink pointing outside the checkout is refused too (a committed symlink is the case the syntactic check alone misses). The clone's resolved commit is the pin, exactly as a plain git install. |
Archive { url, sha256 } |
HTTPS only. Signature-checked like a marketplace archive, and the archive's SHA-256 is recorded as a pin. |
Unsupported { kind } |
A source the reference defines but Codape does not implement. Recognised so the refusal is explicit (see "npm and command" below). |
Git transports that run commands are refused before git is spawned: ext:: and any other <name>:: transport is rejected, and only https://, ssh://, git://, file:// and user@host:path are accepted. Credential prompts are disabled (GIT_TERMINAL_PROMPT=0) so an unauthenticated clone fails with a message instead of hanging, and GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE are not inherited from the caller.
A rev and a sha are both the same knob to git, but they are not interchangeable to a caller: sha must be a full 40-character commit (anything else is refused, so a caller who asked for a commit never silently gets a branch tip of the same name), and when both are present the sha wins. Which one a spec string carries is decided by content — a 40-hex revision is a sha, anything else is a rev.
The reference's source union is structured JSON, but Codape's CLI takes one string. The two kinds a shape cannot express by inspection get a scheme: prefix; both accept an optional @<rev> suffix:
| Spec string | Detected as |
|---|---|
github:owner/repo |
Github { repo: "owner/repo", .. } |
github:owner/repo@main |
Github { .., rev: Some("main") } |
github:owner/repo@<40-hex> |
Github { .., sha: Some(..) } |
git-subdir:<clone-url>#<path> |
GitSubdir { url, path, .. } |
git-subdir:<clone-url>#<path>@v1 |
GitSubdir { .., rev: Some("v1") } |
npm:<package> |
Unsupported { kind: "npm" } |
command:<command> |
Unsupported { kind: "command" } |
For git-subdir the split is on the first # and then the last @ after it, so a scp-like clone URL (git@github.com:acme/mono.git#plugins/foo) keeps its own @ as part of the owner. A path containing @ is not expressible; use the structured variant.
Claude's marketplace entry union has eight-ish kinds. Codape implements five of the shapes and deliberately not the rest:
| Claude kind | Codape | Why |
|---|---|---|
| local path | ✅ LocalDir |
Local-first tool; this is the primary source. |
github |
✅ Github |
owner/repo shorthand plus an optional ref; resolved to a clone URL and handed to the git path. |
git-subdir |
✅ GitSubdir |
A clone narrowed to a named subdirectory, with the git path's transport validation and commit pinning carried over. |
url |
✅ via Git/Archive |
Not a separate kind: {url, ref?, sha?} is a clone (covered by Git) or, when the URL is an archive, a download (covered by Archive). detect() already picks between them from the URL itself, so adding a third spelling of the same two kinds would only be a way to get the same thing wrong twice. |
archive |
✅ Archive |
Straightforward and gives the SHA-256 pin a home. |
npm |
⚪ not implemented | Needs a Node toolchain and registry resolution; Codape plugins are not npm packages, and there is no npm registry client anywhere in the workspace. The reference is in the same state — its own source throws Error("NPM marketplace sources not yet implemented") (plugin.md:200) — so this is recorded as a gap, not built. The spec string npm: is still recognised and refused with that same message, so it is never mistaken for a plugin by that name. |
command |
⚪ not implemented | Decided against on purpose. See below. |
settings |
⚪ not implemented | The reference's settings is a marketplace that lives inside settings. Codape registers marketplaces through add_marketplace (a base URL plus endpoint paths); its settings file has no plugin or marketplace table, so there is nothing to read and no local shape for the kind to take. Claude-internal, and local-first Codape has no equivalent container. |
unsupported |
⚪ | Claude's placeholder variant; nothing to implement. |
The reference's command source runs a command and reads the absolute plugin directory path it prints. The command comes from a marketplace entry — that is, its text is chosen by a third party — and installing a plugin is not a consent step for arbitrary execution.
None of the guards this crate already has apply here:
- Transport validation (
validate_git_url) governsgittransports; it says nothing about a shell command. GIT_TERMINAL_PROMPT=0stops a prompt, not a command.timeoutbounds how long a command runs, not what it may do —rm -rf ~finishes well inside any timeout.mode: ["copy", "link"]decides how the reported directory is installed, which happens after the command has already run.validate_plugin_nameprotects the install destination, not the machine.
There is no sandbox in this crate for running an arbitrary command, and the trigger is not necessarily a user typing it: install_plugin routes any listing whose url is not a marketplace URL to install_from_source, so a marketplace listing with "url": "command:..." would reach the resolver. PluginSource::detect() therefore maps command: to Unsupported { kind: "command" }, and install_from_source refuses it — the spec is recognised, named, and never executed. A local path or a git URL expresses "the plugin is over there" without the execution, so nothing is lost.
The decision is enforced by a test that asserts a command: spec does not become an installable source and that the command's side effect never happened.
A configured signing key is the strong check, but a plugin installed with no key configured was previously Unverified with only a warning. Codape now also records what it installed, in .codape-pins.json inside the install directory:
- Archive installs record the archive's SHA-256.
- Git installs record the resolved commit.
- Directory installs record a deterministic content digest of the directory.
On a later install of the same plugin name, the recorded pin must match, or the install is refused. A pin file that exists but cannot be parsed is an error rather than an empty store — silently forgetting the pins would turn the next install into a fresh first use. A pin that cannot be written after a successful install is a warning: the plugin is in place and correct, but the protection it would have had is missing.
When a signing key is configured, an unverifiable source (directory/git/git-subdir) is refused unless a matching pin already exists — a fresh install of an unsigned directory or git checkout does not proceed unverified. With no key configured, the old warn-and-install-unverified behavior remains.
Honest gaps: the pin is trust-on-first-use, not a signature. There is no pin file a user can pre-seed to pin before the first install (the pins are created by the first install). A directory digest pins the bytes but is not a signed identity. A PluginSource::Archive { sha256 } caller can pin explicitly for that install. The detached signature must be served beside the archive as <url>.sig; there is no separate signature registry.
Why SHA-256 is implemented in-crate: sha256_hex is the published algorithm, checked against the NIST vectors. The workspace has the sha2 crate, but adding it to crates/plugins/Cargo.toml would change Cargo.lock, which is shared, so the function is vendored instead. It is integrity-only, never a signature; swap it for sha2 as soon as this crate may add dependencies.
Claude's runtime mods export register(on, options) with ($, e, next) hook callbacks — a JavaScript module loaded into the host's own runtime, sharing its event bus.
Codape plugins are a JSON-RPC 2.0 protocol over stdio (codape/initialize, codape/commands/list|execute, codape/skills/list|execute, codape/ping, codape/shutdown), spawned as separate processes. That is a deliberate, language-agnostic design: a plugin can be written in any language that can speak JSON on stdin/stdout, and it runs in its own process rather than in the host's.
Adopting the JS callback shape would mean either embedding a JS runtime (a large dependency, and a whole engine's worth of sandbox surface) or inventing a lookalike API that is not actually Claude's. Neither buys a plugin author anything the JSON-RPC contract does not already give them. Recorded here as a legitimate difference, not a gap: the capability (a plugin that reacts to events and registers commands/skills) exists, in this protocol's form.
- Plugin skills (
SkillSource::Plugin): Forwarded to their owning plugin process viaPluginManager::execute_skill. - Non-plugin skills (bundled, user, repo, MCP): Treated as prompt templates — their script path is returned for rendering into the system prompt or message context.
During startup (phase_init_plugins):
- Discover plugins from
.codape/plugins/and config homeplugins/. - Load each
plugin.jsonmanifest intoPluginManager. - For process plugins: spawn, initialize, discover commands/skills dynamically.
- Store
PluginManagerinSessionContext.
During REPL construction:
- Call
ReplLoop::with_plugin_manager(pm)to register plugin slash commands. - Layer
PluginToolFallbackExecutorbehind the primaryRegistryToolDispatcherso plugin tools act as a fallback.
- Plugin discovery from directories (reads
plugin.json). - Plugin load/unload with state tracking and version compatibility checks.
- Process plugin spawning with JSON-RPC stdio transport, initialize handshake, and dynamic command/skill discovery.
- Plugin command registration as namespaced slash commands (
/{plugin}/{command}). - Plugin tool execution via
PluginToolExecutorimplementingToolExecutor, chained as fallback. - Plugin skill execution forwarded to owning plugin process; non-plugin skills returned as prompt template paths.
- Marketplace registration with HTTPS enforcement and optional domain allowlist.
- Configurable marketplace endpoint paths (
list_endpoint,download_endpoint) with defaults. - Plugin installation: download -> temp staging -> archive extraction (tar+gzip) -> validation -> atomic rename -> cleanup.
- Archive extraction:
tar+flate2unpacksplugin.tar.gzand validatesplugin.jsonpresence. - Rollback on failed install: temp directory is deleted if any validation step fails.
- Concurrent install protection: per-plugin-name install locks via
DashMap<String, Arc<Mutex<()>>>. - Unload cleanup: removes plugin directory from disk.
- Version compatibility:
min_versioncompared against app version usingsemvercrate. - Signature verification: Ed25519 signature check (optional, configured via
set_public_key). - Dependency resolution: topological sort with cycle detection via Kahn's algorithm.
- Error recovery:
retry_failed_plugins()attempts to re-read manifests for Error-state plugins up tomax_retries. - Reconciliation: detect new, updated, removed plugins.
- Auto-install new plugins from marketplace: opt-in with
CODAPE_PLUGIN_AUTO_INSTALL=1; off by default (installing third-party code is a user decision). Signature/pin checks still apply. - Skill loading from all 5 sources with conflict resolution.
- Skill frontmatter parsing via
serde_yamlwith custom scalar/array deserializers. - Repo-specific skills from
.codape/skills/. - MCP skills bridge:
phase_init_mcpconverts discovered MCP tools toSkillMetadata. - WASM runtime enabled by default:
process-runtimeandwasm-runtimeare both default Cargo features; WASM calls run under fuel (100M per call), a 64 MiB memory limiter, disabled threads, and one optional host import (codape.user_config). Compilation is guarded by awasmparserpre-scan (16 MiB file, 8 MiB code section, 50,000 functions, 1,000,000 operators, 256 nesting levels) and always runs out-of-process through a host-injected compiler command (the CLI re-executes itself with--internal-wasm-compile) withRLIMIT_CPUand a best-effort 2 GiB memory limit (RLIMIT_AS,RLIMIT_DATAon Darwin, plus a cgroup v2memory.maxon Linux when a delegated tree is available), a wall-clock timeout, and a process-group, cgroup or Job Object kill. There is no in-process fallback: a missing or failing compiler refuses the load. Successful compilations are cached as serialized modules keyed by engine-config and module SHA-256 (256 MiB bounded). - WASM
userConfiginjection: the same resolution and validation as process plugins, delivered to a module that importscodape.user_config(ptr, capacity) -> required_lenas one JSON object in its linear memory; modules that do not import it are unchanged. - Full manifest field table with
deny_unknown_fields,PluginAuthoraccepting a string or an object, and a load-time warning for fields Codape accepts but does not implement. userConfiginjection:CODAPE_PLUGIN_OPTION_<KEY>in the child's environment and${user_config.KEY}substitution inenvandentrypoint; sensitive options refuse a plaintext default and refuse an unresolvedkeyring://reference; a required option with no value stops the spawn.- Install sources: marketplace listing, local directory, git URL, GitHub
owner/reposhorthand, a git subdirectory, and HTTPS archive — withPluginSource::detect()classifying a CLI argument, and the unimplementednpm/commandkinds recognised and refused rather than silently reinterpreted. - Pinning: trust-on-first-use SHA-256 for archives and commit pinning for git, recorded in
.codape-pins.json.
- No keychain access in this crate, so sensitive options are host-supplied or environment-supplied; nothing prompts the user or writes answers back to settings (see "userConfig Injection").
Plugin channels route notifications … but nothing drives已接线:CLI 通过route_channel_notificationfrom a live stream yetset_notification_router把每个 MCP 通知转给route_channel_notification(orchestrator.rs:2084),再由渠道的 sink 投递(2026-10-31 起可 POST 到 webhook、调用 MCP 工具,或运行本地命令)。- Pin files are created by the first install; a user cannot pre-seed a pin before installing.
- WASM plugins must import
codape.user_configto receive options; an existing module cannot be givenuserConfigwithout that ABI change. - WASM compilation always requires a host-injected compiler command (or a
codape-wasm-compilenext to the executable); with neither, loads fail closed. On Darwin the memory bound isRLIMIT_DATA, which does not cap the full address space; the Windows Job Object path is untested, and the compiler sandbox degrades to rlimits plus process-group kill wheresandbox-exec/bwrapcannot be applied (see "WASM Plugins"). npmandcommandsources are not implemented (see above for why, and for the reference citation onnpm).crates/cli/src/orchestrator.rsparsesplugin.jsonitself inphase_init_plugins; a parse error is now logged as a warning rather than silently ignored.
- 169 tests in
plugins.rs(manager ops, load/unload, marketplace, discovery, reconciler, URL validation, version checks, signature verification, dependency resolution, error recovery, custom endpoints, the manifest field table,userConfigresolution and injection end-to-end including the WASM required-option path,userConfigschema validation (options/min/max/type), plugin channels (live report states and notification routing), the plugin type registry, source detection and git URL validation, directory/git/git-subdir installs, structured source specs, thenpm/commandrefusals, SHA-256 vectors and pin enforcement). - 17 tests in
skills.rs(parsing, loader, plugin/MCP skills, repo dir, conflict resolution, precedence, quoted strings, and the bundled tree: it loads without touching the disk, it reaches the adverts, and a user skill of the same name still wins). - 7 tests in
runtime.rs(spawn, initialize, terminate, invalid command). - 20 tests in
wasm_runtime.rs, all run by the defaultcargo test -p codape-plugins: 4 core/unit tests (the loader stub, the injected command's program/leading-argument shape, helper discovery, and the platform rlimit plan), 10 sandbox tests (fuel, memory growth, initial memory, shared memory, WASI import, the 3 size-cap cases,userConfiginjection into an importing module, and an empty-import module still running), and 6 pre-scan tests (normal module, oversized code section, too many functions, too many operators, excessive nesting, nesting exactly at the cap). - Integration tests in
tests/wasm_compile_subprocess.rs: an injected command compiles, serializes, and deserializes; leading arguments are forwarded; the host-injected global command is used; a missing command fails closed with an actionable error and leaves no artifacts; a slow helper and its spawned descendant are killed at the wall-clock limit; a second load hits the AOT cache with exactly one compiler invocation; a pathological module is rejected by the pre-scan without starting the compiler; and, on Linux, the compiler is attached to a cgroup carrying the memory ceiling. - Tests use
tempfilefor filesystem operations. The git and git-subdir install tests create a throwaway repository inside atempfile::tempdir()and pin every git command with-C, so they never touch the project's own repository. The subdirectory tests usefile://clone URLs, so they need no network.