feat(sdk-go): TinyGo-targeted plugin SDK with typed host call wrappers#462
Merged
Conversation
…ifest, host wrappers)
Adds packages/go/sdk as its own Go module. The SDK provides typed
wrappers over every gn_* host ABI so plugin authors write Go that
compiles via TinyGo to a wasm32-wasi target.
Pieces:
- codec.go JSON-envelope mirror of abi/hooks (action / filter payloads,
ResultStatus, PackResult, MarshalActionPayload, ...)
- hooks.go Package-level dispatch registry, RegisterAction,
RegisterFilter, DispatchHook, PluginInit
- manifest.go Plugin-author-facing Manifest + fluent ManifestBuilder
(NewManifest().WithCapability().WithAction()....Build())
- host.go Top-level Host singleton with typed sub-APIs
(HTTP / DB / KV / Cache / Media / Users / Secrets /
Audit / Cron / Metric / Event / Span / I18n / Log / Time)
- host_methods.go Typed Host.X.Y methods that marshal Go shapes into
the host wire envelopes
- host_stub.go hostCall* stubs for the stock Go toolchain (so plugin
authors can unit-test handlers without TinyGo)
- host_wasm.go //go:wasmimport bindings to every gn_* host export,
gn_alloc / gn_free / gn_handle_hook exports
(wasm32-wasi build only)
Tests: 37 codec/hook/manifest unit tests covering round-trips, error
paths, dedup, builder defaults. All pass under the stock toolchain.
The SDK is wired into go.work so `go test
./packages/go/sdk/...` runs from the repo root. The package has zero
non-stdlib deps so the TinyGo build (added in a follow-up commit)
doesn't drag in the host module's pgx / redis / asynq closure.
Refs #237.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
…ation test
Closes the user-facing surface of the Go plugin SDK:
- cli/gonext/cmd/plugin/init.go: `gonext plugin init --template=go
<dir>` scaffolds a working plugin project from the embedded
templates (main.go, manifest.json, go.mod, Makefile, .gitignore).
Slug substitution honours --name= or sanitises the project
basename to fit the manifest schema's regex.
- cli/gonext/cmd/plugin/templates/go/: the embedded templates the
scaffolder renders. The go.mod and main.go are .tmpl-suffixed so
the cli/gonext module's build doesn't accidentally try to compile
them as Go.
- examples/plugins/sdk-go-hello/: worked example exercising
posts.publish action + the_content filter + KV.Set + Audit.Emit
via the SDK surface. Includes Makefile / build.sh / unit tests
for the handler logic.
- packages/go/sdk/README.md: 10-line hello-world plus the SDK
surface inventory.
- packages/go/sdk/tinygo_integration_test.go: optional integration
test that runs `tinygo build -target=wasi` against
sdk-go-hello when tinygo is on PATH. Skips otherwise so CI
without the toolchain still passes.
Wired into go.work; all SDK + CLI + example tests pass under the
stock toolchain. The example builds cleanly under
`GOOS=wasip1 GOARCH=wasm go build` as a basic sanity check that
the SDK's wasmimport stanzas compile.
Refs #237.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
tayebmokni
pushed a commit
that referenced
this pull request
May 25, 2026
Closes #242. packages/ts/sdk-plugin: TypeScript SDK for GoNext plugin authors via Javy (JavaScript → WASM). - pluginInit + registerAction / registerFilter - Typed wrappers over every gn_* host ABI through globalThis - JSON envelope codec - Manifest builder mirroring the Go side - bin/gonext-sdk-build.js wraps esbuild + javy compile - cli/gonext/templates/typescript + 'gonext plugin init --template=typescript' - examples/plugins/sdk-ts-hello working example - 54 Vitest tests (codec + manifest + dispatch) This PR was rebased onto main after #460/#461/#462 landed; the runInit dispatch now switches on template name and embeds both templates/go and templates/typescript via the single templatesFS. Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
tayebmokni
pushed a commit
that referenced
this pull request
May 25, 2026
Closes #239. packages/rust/gonext-sdk + packages/rust/gonext-sdk-macros: Cargo crates for Rust plugin authors. - plugin_init! proc-macro generates gn_alloc/gn_free/_start/gn_handle_hook exports - Safe typed wrappers over every gn_* host ABI (env, env_net, gonext_data, env_platform) - JSON envelope codec via serde_json - Manifest builder mirroring the Go side - cli/gonext/cmd/plugin/templates/rust + 'gonext plugin init --template=rust' - examples/plugins/sdk-rust-hello: working example (action + filter + kv.set + audit.emit) Rebased onto main after #460/#461/#462 landed; init.go now switches on template name. TestRunInitUnknownTemplate updated to use a clearly-not-real template name so it stays robust as new templates land. Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
tayebmokni
pushed a commit
that referenced
this pull request
May 25, 2026
Closes #242. packages/ts/sdk-plugin: TypeScript SDK for GoNext plugin authors via Javy (JavaScript → WASM). - pluginInit + registerAction / registerFilter - Typed wrappers over every gn_* host ABI through globalThis - JSON envelope codec - Manifest builder mirroring the Go side - bin/gonext-sdk-build.js wraps esbuild + javy compile - cli/gonext/templates/typescript + 'gonext plugin init --template=typescript' - examples/plugins/sdk-ts-hello working example - 54 Vitest tests (codec + manifest + dispatch) This PR was rebased onto main after #460/#461/#462 landed; the runInit dispatch now switches on template name and embeds both templates/go and templates/typescript via the single templatesFS. Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
tayebmokni
pushed a commit
that referenced
this pull request
May 26, 2026
Closes #242. packages/ts/sdk-plugin: TypeScript SDK for GoNext plugin authors via Javy (JavaScript → WASM). - pluginInit + registerAction / registerFilter - Typed wrappers over every gn_* host ABI through globalThis - JSON envelope codec - Manifest builder mirroring the Go side - bin/gonext-sdk-build.js wraps esbuild + javy compile - cli/gonext/templates/typescript + 'gonext plugin init --template=typescript' - examples/plugins/sdk-ts-hello working example - 54 Vitest tests (codec + manifest + dispatch) This PR was rebased onto main after #460/#461/#462 landed; the runInit dispatch now switches on template name and embeds both templates/go and templates/typescript via the single templatesFS. Signed-off-by: Tayeb Mokni <tayeb.mokni@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #237.
packages/go/sdk: TinyGo-compatible Go SDK for GoNext plugin authors.PluginInit+RegisterAction/RegisterFiltergn_*host ABI (Host.HTTP/.DB/.Cache/.Audit/.Cron/.KV/.Media/.Users/.Secrets/.Metric/.Event/.Span/.I18n/.Log/.Time)NewManifest().WithCapability(...).Build())cli/gonext/templates/go/+gonext plugin init --template=goexamples/plugins/sdk-go-hellowith TinyGo build🤖 Generated with Claude Code