Describe the actual pre-execute proposal, additive prompt snapshot, owner-local JSON state and optional per-call identity contracts. Preserve the distinction between Native author entries, portable DSH import, compatible Claude components and manually ported Pi APIs. Add a plain ESM counter mod with scoped deny/context hook, prompt contribution, structured results, persistent state, user command and idempotent async cleanup. No new SDK, UI widget, skill-root or native DSH loader is claimed. Validation: example node --check passed; example manifest entry verified; 45 local documentation links checked. Real committed-host receipt passed activation, four owned registrations, scoped hook deny/abstain, serialized counter increments, structured identity, command output, leak-free teardown and count preservation across host restart. git diff --check passed. No Cargo, host-source or dist changes; no release or push.
1.8 KiB
Scoped counter mod
This plain ESM example uses the documented experimental host shims. It registers
one tool, one user command, one prompt section and one pre-execute listener.
The listener applies only to mod_counter; the label blocked demonstrates
denial. It does not grant approval or alter other tools.
Start Codewhale with codewhale --enable extension_host, then enter:
/plugin install ./docs/examples/plugins/mod-extension
/plugin validate mod-extension
/plugin show mod-extension
/plugin enable mod-extension
Inspect the Native capability and source. Personally run the exact trust command printed by the review, then enable the plugin again. Installation alone leaves it disabled and untrusted; the experimental feature is off by default.
Ask the model to call mod_counter with {"label":"first"}. The ordinary tool
approval gate applies. A successful call returns JSON with its saved count and
the invocation identity fields Rust supplied. Ask for {"increment":false} to
read without changing the count, or {"label":"blocked"} to exercise the hook.
Run /mod-count yourself to display the count without a model call.
/plugin disable mod-extension
Disabling removes the tool, command, listener and prompt section. The counter remains in the owner directory Rust assigned and survives reloads; disposal does not delete state. This example serializes its counter updates inside one owner. Separate processes writing the same storage key are last-writer-wins, so this is not a cross-process atomic counter.
There is no published author SDK yet. This example uses no ambient package, custom UI widget, skill-root registration or DSH bundle loader. See the extension contract and 简体中文扩展指南.