diff --git a/CHANGELOG.md b/CHANGELOG.md index a58d2d1..4e143af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 2026-11-06 — v0.3.1 + +### Added + +- New `command` world in `wit/xfetch-runtime.wit` for CLI command addons. The + request is JSON and the response is plain text lines. +- New `xfetch-command-api` crate with the command request type, stdin/stdout + helpers and line formatting utilities. +- `docs/command-sdk.md` documents the command protocol, Rust core-module + example, component world and native command conventions. + +### Changed + +- All API crates bumped to `0.3.1`. +- `xfetch-guest-api` no longer declares an unused direct `serde` dependency. +- Removed the unused `parse_json` helper from `xfetch-command-api`. +- Updated the protocol reference, WebAssembly guest guide, README, ROADMAP and + getting-started guide for the command kind and 0.3.1. + ## 2026-11-03 — v0.3.0 ### Added diff --git a/Cargo.toml b/Cargo.toml index ea2af52..fe05e33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,6 @@ members = [ "crates/extension-api", "crates/effect-api", "crates/guest-api", + "crates/command-api", ] resolver = "2" diff --git a/README.md b/README.md index c5fd3e8..6f826fd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@
- The current release line is 0.3.0. It keeps the JSON
+ The current release line is 0.3.1. It keeps the JSON
protocol at version 1 and the WIT at
xfetch:runtime@0.1.0; the changes are additive.
crates/extension-api: shared protocol crate for xfetch extensions (config providers).crates/effect-api: shared protocol crate for xfetch effects (intro animations over the info lines).crates/guest-api: host-call helpers for WebAssembly guests (http_request, exec, log, protocol_version).wit/xfetch-runtime.wit: component-model contract (plugin, effect and extension worlds).crates/command-api: shared protocol crate for CLI command addons.wit/xfetch-runtime.wit: component-model contract (plugin, effect, extension and command worlds).docs/: focused documentation for setup, protocol, SDK usage, wasm guests, and examples.examples/: minimal plugin, effect and extension binaries that compile against the public crates.crates/*/examples/: minimal plugin, effect and extension binaries that compile against the public crates.
+ crates/command-api (xfetch-command-api) is the
+ contract for CLI command addons. Commands receive arguments and return plain
+ text lines, so a command owns its own output format. Components use the
+ command world in the WIT package; core modules use the JSON
+ request on stdin and plain text on stdout.
+
xfetch-api-common first, then xfetch-plugin-api, xfetch-extension-api and xfetch-effect-api; xfetch-guest-api is independent.xfetch-api-common first, then xfetch-plugin-api, xfetch-extension-api, xfetch-effect-api and xfetch-command-api; xfetch-guest-api is independent.with_timeout helper and runtime budgets.
- The public surface is centered on five crates:
+ The public surface is centered on six crates:
xfetch-api-common (shared protocol/IO/frame/timeout primitives),
xfetch-plugin-api, xfetch-extension-api,
- xfetch-effect-api, and xfetch-guest-api (host calls
- for WebAssembly guests). The current release line is 0.3.0.
+ xfetch-effect-api, xfetch-command-api, and
+ xfetch-guest-api (host calls for WebAssembly guests). The current
+ release line is 0.3.1.
diff --git a/docs/command-sdk.md b/docs/command-sdk.md new file mode 100644 index 0000000..bd0a6f7 --- /dev/null +++ b/docs/command-sdk.md @@ -0,0 +1,96 @@ +# Command SDK + +
+ xfetch-command-api is the contract for CLI command addons. A
+ command addon receives a JSON request with positional arguments and returns
+ plain text; the core prints the text as-is unless the user asks for a layout.
+
0 on success; non-zero on failure.{
+ "version": 1,
+ "kind": "command",
+ "command": "github",
+ "args": ["owner/repo"],
+ "cwd": "/home/user/project",
+ "env": {}
+}
+
+repo: owner/repo
+author: owner
+languages: C, JavaScript, PHP
+stars: 1234
+
+
+[dependencies]
+serde = { version = "1", features = ["derive"] }
+serde_json = "1"
+xfetch-command-api = "0.3"
+xfetch-guest-api = "0.3"
+
+use xfetch_command_api::{read_command_args_or_default, write_command_lines};
+
+fn main() {
+ let args = read_command_args_or_default().unwrap_or_default();
+ let repo = args.first().map(String::as_str).unwrap_or("owner/repo");
+ write_command_lines(&[format!("repo: {repo}")]).expect("write output");
+}
+
+
+ Wasm core modules use the same JSON request as native commands. Host calls
+ come from xfetch-guest-api and remain governed by the manifest
+ allowlist.
+
+ Component guests implement the command world in
+ wit/xfetch-runtime.wit:
+
world command {
+ import host;
+ export run: func(request: string) -> result<string, string>;
+}
+
+
+ Parse the request string, use the typed host.fetch /
+ host.exec imports as needed, and return the plain-text response.
+ Returning an error string reports a command failure.
+
+ Native command addons can read positional arguments from
+ std::env::args().skip(1) and write text to stdout. The core also
+ sends the JSON request on stdin, so a native command may use either form.
+
key: value lines for readability and future layout support.xfetch-effect-api (effects), and xfetch-guest-api
(host calls for WebAssembly guests). The component protocol lives in
wit/xfetch-runtime.wit. The current release line is
- 0.3.0.
+ 0.3.1.
info_providereffectconfig_provider (extension protocol)command (CLI command protocol; plain-text response)+ Command addons receive positional arguments and return plain text lines. The + request is JSON; the response is not. +
+ +{
+ "version": 1,
+ "kind": "command",
+ "command": "github",
+ "args": ["owner/repo"],
+ "cwd": "/home/user/project",
+ "env": {}
+}
+
+repo: owner/repo
+author: owner
+languages: C, JavaScript, PHP
+stars: 1234
+
+
+
+ The core prints the response as-is unless a layout is requested. Lines are
+ separated by \n; stderr is reserved for diagnostics.
+
diff --git a/docs/wasm-guests.md b/docs/wasm-guests.md index 4ad4682..025996f 100644 --- a/docs/wasm-guests.md +++ b/docs/wasm-guests.md @@ -1,7 +1,8 @@ # WebAssembly Guests
- xfetch can run plugins, effects and extensions compiled to WebAssembly. This
+ xfetch can run plugins, effects, extensions and command addons compiled to
+ WebAssembly. This
guide covers the authoring side; the runtime reference (manifest schema and
CLI tooling) lives in the core repository at
xfetch/docs/WASM.md.
@@ -34,6 +35,12 @@
xfetch wasm wit.
+ Command guests use the command world. The request string is JSON;
+ the response is plain text lines. Core modules read the JSON request from
+ stdin and write text to stdout.
+
diff --git a/wit/xfetch-runtime.wit b/wit/xfetch-runtime.wit
index 77241c0..5037930 100644
--- a/wit/xfetch-runtime.wit
+++ b/wit/xfetch-runtime.wit
@@ -6,9 +6,10 @@
/// only applies to the component model.
///
/// The exported `run` function receives the same JSON request documented in
-/// `api/docs/protocol.md` and must return the JSON response. The request's
-/// `kind` field selects the contract (`logo_animation`, `info_provider`,
-/// `effect` or `config_provider`).
+/// `api/docs/protocol.md` and must return the response. The request's `kind`
+/// field selects the contract (`logo_animation`, `info_provider`, `effect`,
+/// `config_provider` or `command`). Command guests return plain text lines
+/// instead of JSON.
///
/// Host capabilities are deny-by-default: a component can only call
/// `http-request` and `exec` when its manifest allowlist accepts the request.
@@ -116,3 +117,13 @@ world extension {
import host;
export run: func(request: string) -> result