| 1 | # Scoped counter mod |
| 2 | |
| 3 | This plain ESM example uses the documented experimental host shims. It registers |
| 4 | one tool, one user command, one prompt section and one pre-execute listener. |
| 5 | The listener applies only to `mod_counter`; the label `blocked` demonstrates |
| 6 | denial. It does not grant approval or alter other tools. |
| 7 | |
| 8 | Start Codewhale with `codewhale --enable extension_host`, then enter: |
| 9 | |
| 10 | ```text |
| 11 | /plugin install ./docs/examples/plugins/mod-extension |
| 12 | /plugin validate mod-extension |
| 13 | /plugin show mod-extension |
| 14 | /plugin enable mod-extension |
| 15 | ``` |
| 16 | |
| 17 | Inspect the Native capability and source. Personally run the exact trust command |
| 18 | printed by the review, then enable the plugin again. Installation alone leaves |
| 19 | it disabled and untrusted; the experimental feature is off by default. |
| 20 | |
| 21 | Ask the model to call `mod_counter` with `{"label":"first"}`. The ordinary tool |
| 22 | approval gate applies. A successful call returns JSON with its saved count and |
| 23 | the invocation identity fields Rust supplied. Ask for `{"increment":false}` to |
| 24 | read without changing the count, or `{"label":"blocked"}` to exercise the hook. |
| 25 | Run `/mod-count` yourself to display the count without a model call. |
| 26 | |
| 27 | ```text |
| 28 | /plugin disable mod-extension |
| 29 | ``` |
| 30 | |
| 31 | Disabling removes the tool, command, listener and prompt section. The counter |
| 32 | remains in the owner directory Rust assigned and survives reloads; disposal does |
| 33 | not delete state. This example serializes its counter updates inside one owner. |
| 34 | Separate processes writing the same storage key are last-writer-wins, so this |
| 35 | is not a cross-process atomic counter. |
| 36 | |
| 37 | There is no published author SDK yet. This example uses no ambient package, |
| 38 | custom UI widget, skill-root registration or DSH bundle loader. See |
| 39 | [the extension contract](../../../EXTENSIONS.md) and |
| 40 | [简体中文扩展指南](../../../zh_hans/EXTENSIONS.md). |
| 41 |