mbt-wasip1-tools
Build small MoonBit WASIp1 CLI tools using the peter-jerry-ye/wasi library, focused on simple read/write tasks (echo, cat, wc, simple file ops). Use when creating or updating CLI examples, scripts, or skills for this repo.
When & Why to Use This Skill
This Claude skill specializes in generating and optimizing MoonBit code for WASIp1-compliant CLI tools. It simplifies the development of portable WebAssembly utilities by handling complex WASI path resolution, unified standard I/O implementation, and file system operations using the peter-jerry-ye/wasi library.
Use Cases
- Case 1: Rapidly generating boilerplate for MoonBit CLI utilities such as 'cat', 'echo', or 'wc' targeting WebAssembly environments.
- Case 2: Implementing secure and portable file system operations that adhere to WASIp1 preopened directory and path resolution constraints.
- Case 3: Developing cross-platform scripts that leverage MoonBit's performance and the safety of the WebAssembly System Interface (WASI).
- Case 4: Streamlining the creation of synchronous I/O readers and writers for MoonBit projects using unified stdio interfaces.
| name | mbt-wasip1-tools |
|---|---|
| description | Build small MoonBit WASIp1 CLI tools using the peter-jerry-ye/wasi library, focused on simple read/write tasks (echo, cat, wc, simple file ops). Use when creating or updating CLI examples, scripts, or skills for this repo. |
MoonBit WASIp1 Tools
Use the examples
- Copy a project from
assets/and modify it. - Each example is a complete MoonBit project with a README.
- Build with
moon build -C <example-dir>and run withwasmtime run --dir host::guest <wasm>.
Path resolution (WASIp1)
- There is no cwd. All paths resolve against preopened directories.
- Resolution uses longest-prefix matching on preopen names.
- Relative paths must match a preopen prefix (for example,
foo/barrequires a preopen namedfoo). - Absolute paths only work when a preopen name starts with
/(for example,--dir /host::/). - If no prefix matches, fail immediately. Do not fall back to trial-and-error.
Unified stdio
@wasi/stdio.stdinimplements@sync_io.Readerand@io.Reader.@wasi/stdio.stdoutand@wasi/stdio.stderrimplement@sync_io.Writerand@io.Writer.
References
references/api.mdsummarizes the core I/O and fs APIs.