2026-04-06 09:00:47 +00:00
|
|
|
|
# hello plugin
|
|
|
|
|
|
|
|
|
|
|
|
Phase C Step 9 — proof-of-life plugin used by `Server/plugin/plugin_test.go`.
|
|
|
|
|
|
|
|
|
|
|
|
## Manifest
|
|
|
|
|
|
|
|
|
|
|
|
`plugin.json` declares the `commands`, `events`, and `storage` capabilities.
|
|
|
|
|
|
The manifest is the only file the default (no-`-tags wazero`) build needs —
|
|
|
|
|
|
the registry persists it into the plugins table without executing the .wasm.
|
|
|
|
|
|
|
|
|
|
|
|
## Building the WASM
|
|
|
|
|
|
|
2026-04-07 10:13:47 +02:00
|
|
|
|
`main.go` in this directory implements the full plugin ABI
|
|
|
|
|
|
(`allocate`, `deallocate`, `list_commands`, `command_dispatch`, `on_event`).
|
|
|
|
|
|
The pre-built `hello.wasm` (925 KiB) is checked in, but you can rebuild it:
|
2026-04-06 09:00:47 +00:00
|
|
|
|
|
2026-04-07 10:13:47 +02:00
|
|
|
|
### Prerequisites
|
|
|
|
|
|
|
|
|
|
|
|
| Tool | Version | Notes |
|
|
|
|
|
|
|------|---------|-------|
|
|
|
|
|
|
| TinyGo | 0.40.1 | Supports Go 1.19–1.25 only |
|
|
|
|
|
|
| Go | 1.25.x | TinyGo 0.40.1 rejects Go 1.26+ |
|
|
|
|
|
|
| wasm-opt | Binaryen 129 | Required by TinyGo for the `wasi` target |
|
|
|
|
|
|
|
|
|
|
|
|
On Windows, extract TinyGo to e.g. `D:\Local-Lab\Coding\Software\tinygo` and
|
|
|
|
|
|
add `<tinygo>\bin` plus `<binaryen>\bin` to `PATH`. Then point TinyGo at the
|
|
|
|
|
|
compatible Go SDK:
|
|
|
|
|
|
|
|
|
|
|
|
```pwsh
|
|
|
|
|
|
$env:GOROOT = "$env:USERPROFILE\sdk\go1.25.3" # installed via: go install golang.org/dl/go1.25.3@latest
|
|
|
|
|
|
$env:PATH = "$env:GOROOT\bin;$env:PATH"
|
2026-04-06 09:00:47 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-07 10:13:47 +02:00
|
|
|
|
### Build command
|
|
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
|
# Run from this directory (Server/plugin/examples/hello/)
|
|
|
|
|
|
tinygo build -o hello.wasm -target wasi ./main.go
|
|
|
|
|
|
```
|
2026-04-06 09:00:47 +00:00
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
|
|
|
|
|
|
|
`Server/plugin/plugin_test.go` exercises the manifest parser and the loader
|
|
|
|
|
|
against this directory. It does not require the .wasm to be present —
|
|
|
|
|
|
manifest-only validation is the default-build coverage path.
|