golem-file-io-moonbit

Reads and writes provisioned files from MoonBit Golem agents using the SDK filesystem package.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-file-io-moonbit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-file-io-moonbit
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/moonbit/golem-file-io-moonbit
Command: npx skills add https://github.com/golemcloud/golem --skill golem-file-io-moonbit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

MoonBit Golem agents run in isolated WebAssembly environments with no global filesystem, so developers need a clear pattern for accessing provisioned files, handling preopened directories, and respecting WASI host read limits.

Core Features & Use Cases

  • File Reading and Writing: Use the @fs package convenience functions (read_string, read_bytes, write_string, write_bytes) to access provisioned files through preopened directory descriptors.
  • Directory Listing and Low-Level Access: List directory entries or open files with specific flags using re-exported WASI types like Descriptor, OpenFlags, and DescriptorFlags.
  • Use Case: Build a MoonBit agent that reads a provisioned configuration file at startup, processes its contents, and writes results back to a writable path, with state persisting across invocations.

Quick Start

Show me how to read and write a provisioned text file from my MoonBit Golem agent using the filesystem SDK.

Frequently Asked Questions about golem-file-io-moonbit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I read a file from a MoonBit Golem agent?

Add the golemcloud/golem_sdk/filesystem package to moon.pkg, obtain the root descriptor with @fs.get_root_dir(), then call @fs.read_string or @fs.read_bytes with the file path. Files must first be provisioned via golem.yaml.

How do I write files in a MoonBit Golem agent?

Use @fs.write_string or @fs.write_bytes with a descriptor from @fs.get_root_dir(). Writing only works for files provisioned with read-write permission or files in non-provisioned paths; read-only provisioned files cannot be modified.

Why does reading a large file only return 64 KiB in WASI filesystem calls?

The wasmtime host caps each Descriptor::read call at 64 KiB, silently truncating larger requests. The SDK wrappers handle chunked reads automatically, but direct Descriptor::read calls must loop with offsets until EOF.

Does each Golem agent share a filesystem with other agents?

No, the filesystem is per-agent-instance and fully isolated. Each agent has its own filesystem, and file changes persist across invocations of that agent as durable state.

Do I need to regenerate WIT bindings to use filesystem access in MoonBit?

No WIT changes or binding regeneration are needed. The golem_sdk already includes the filesystem imports, so you only add the filesystem package import to moon.pkg.