agentleFS
seznamseznam/jailoc/AGENTS.md

jailoc

AGENTS.md44 starsChanged 5 days agoMITView on GitHub

jailoc — CLI tool that runs coding agents (OpenCode 1/2, Claude Code, GitHub Copilot CLI, OmO, Antigravity CLI; one per workspace) in sandboxed libkrun micro-VMs. Each workspace gets its own VM with virtio-fs directory shares, a host-side userspace network broker that denies private networks, and SSH-based agent sessions. Module: github.com/seznam/jailoc Language: Go 1.26+ Key deps: stacklok/go-microvm (libkrun), gvisor.dev/gvisor (netbroker stack), docker/docker (image builds, migrate), google/go-containerregistry, golang.org/x/crypto/ssh, BurntSushi/toml, spf13/cobra Hosts: darwin/arm64 (Hypervisor.framework), linux/amd64 and experimental linux/arm64 (KVM). Release builds embed the…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 32,671 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the VM is already running, up reloads it instead (internal/cmd/vmreload_unix.go).

    line 51
  2. Very specific:

    Always wrap: fmt.Errorf("context: %w", err) — never return bare err

    line 60
  3. Very specific:

    No custom error types — fmt.Errorf wrapping everywhere

    line 61
  4. Very specific:

    No logging library — fmt.Printf for user output, errors propagate up the stack

    line 62
  5. Very specific:

    All packages under internal/ — nothing exported

    line 67
  6. Very specific:

    Prefer Go SDKs over exec.Command shellouts.

    line 68
  7. Very specific:

    No external dependencies for stdlib-solvable problems (e.g.

    line 69
  8. Very specific:

    When plugin/opencode1.jsx or plugin/opencode2.jsx changes, rebuild and update the embedded copies:

    line 86
  9. Distinctive:

    No mocks, fixtures, or testdata directories

    line 99
  10. Very specific:

    Run go build, go test ./..., and golangci-lint run inside as usual.

    line 118
  11. Distinctive:

    Run these locally and fix all failures before staging a commit:

    line 135
  12. Very specific:

    When adding or changing user-facing features, update the corresponding docs in docs/:

    line 152
  13. Distinctive:

    Keep docs in sync with code changes — a feature without updated docs is incomplete.

    line 158

≈ “Common” is an estimate: at least 1 in 5 of the 41,581 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Project Overview

jailoc — CLI tool that runs coding agents (OpenCode 1/2, Claude Code, GitHub Copilot CLI, OmO, Antigravity CLI; one per workspace) in sandboxed libkrun micro-VMs. Each workspace gets its own VM with virtio-fs directory shares, a host-side userspace network broker that denies private networks, and SSH-based agent sessions.

Module: github.com/seznam/jailoc Language: Go 1.26+ Key deps: stacklok/go-microvm (libkrun), gvisor.dev/gvisor (netbroker stack), docker/docker (image builds, migrate), google/go-containerregistry, golang.org/x/crypto/ssh, BurntSushi/toml, spf13/cobra

Hosts: darwin/arm64 (Hypervisor.framework), linux/amd64 and experimental linux/arm64 (KVM). Release builds embed the go-microvm runner + libkrun + libkrunfw runtime (internal/vm/runtime.go, internal/vm/runtimebin/); other builds need [vm] runner / lib_dir. The Nix package builds the VM runtime from source on Linux (x86_64, aarch64) and links its paths into jailoc; on aarch64-darwin it has no runtime.

Architecture

cmd/jailoc/main.go          Entry point → cmd.Execute(version, commit, date)
cmd/jailoc-guest/           VM init + SSH server inside the guest (embedded via internal/guestbin)
cmd/jailoc-netbroker/       Host-side network broker process, one per workspace VM
internal/
  cmd/                       Cobra CLI: root (attach/new/continue sessions) + add, config, down, list, logs, migrate, reload, restart, sessions, status, up
  agent/                     Built-in coding agent harnesses (opencode1, opencode2, claude, copilot, omo, agy; opencode = alias of opencode2): npm package or GitHub release binary, session flags, env, persisted dirs, default mounts
  config/                    TOML config parsing, validation (rejects v1 settings), mutation (~/.config/jailoc/config.toml), default config content
  workspace/                 Workspace name → resolved paths, allowed hosts/networks, CWD matching
  docker/                    Docker Engine SDK — image resolution/build on the host, v1 volume export for migrate
  embed/                     go:embed assets (Dockerfile, TUI plugin)
  vm/                        go-microvm/libkrun VM lifecycle, embedded runtime unpacking, image export into rootfs
  guest/                     jailoc-guest: init, SSH sessions, secrets, Docker in the VM
  guestbin/                  go:generate-embedded jailoc-guest binaries
  netbroker/                 gVisor userspace network stack + IPv4/IPv6 egress policy + filtered DNS
  brokerproc/                Starts a jailoc-netbroker process for one workspace
  vmnet/, logging/, update/  Supporting packages
  vmintegration/             //go:build vmintegration — boots real VMs
docs/                        MkDocs documentation (Diátaxis framework, see docs/AGENTS.md)
flake.nix                    Nix flake: systems, formatter, apps, dev shells; packages come from nix/
nix/
  default.nix                Dependency map: runtime recipes → jailoc (VM runtime on Linux only)
  jailoc.nix                 jailoc package, vendorHash, runtime paths via -X defaultVMRunner/defaultVMLibDir
  runtime/                   sources.nix (pins), libkrun-init, libkrunfw, libkrun, go-microvm-runner recipes

Data flow (jailoc up)

  1. config.Load → read ~/.config/jailoc/config.toml; v1 settings fail validation with a hint to run jailoc migrate
  2. workspace.Resolve → name → paths, mounts, snapshots, allowed hosts/networks
  3. Validate secret sources, prepare CA bundle and TUI plugin config, compute virtio-fs shares and staged snapshots
  4. vmRuntime → configured [vm] runner, else the package-provided runtime (for example, the Nix package's), else unpack the embedded runtime
  5. buildWorkspaceImage → build the image with host Docker (or a builder VM with isolated_build) and convert its layers into EROFS images in the VM image cache
  6. startSupervisor → boot the workspace VM (jailoc-guest as init) with its netbroker; persistent home under ~/.cache/jailoc-vm/workspaces/<ws>/home
  7. secretsPayload (read on the host before boot, incl. from_command) → deliverSecrets over SSH; the guest writes file secrets to /run/secrets (tmpfs) and env secrets to the session environment

If the VM is already running, up reloads it instead (internal/cmd/vmreload_unix.go). Sessions attach over SSH; there is no published agent port or server password.

Network

Guest IPv4 192.168.127.2/24 (gateway .1), IPv6 fd00:127::2/64. All traffic goes through the netbroker: public destinations allowed, private/reserved denied unless listed in allowed_networks or resolved from allowed_hosts. See internal/netbroker/policy.go and policy_ipv6.go.

Conventions

Error handling

  • Always wrap: fmt.Errorf("context: %w", err) — never return bare err
  • No custom error types — fmt.Errorf wrapping everywhere
  • No logging library — fmt.Printf for user output, errors propagate up the stack

Code organization

  • One file per package concern: docker.go, workspace.go, config.go
  • Separate files for distinct concerns within a package (e.g. fetch.go for HTTP fetching in docker/)
  • All packages under internal/ — nothing exported
  • Prefer Go SDKs over exec.Command shellouts; shellouts are limited to the VM runner, broker process, guest-side tools, host CLI tools without a Go SDK (git, gpg, gpgconf), and host /usr/bin/security on macOS
  • No external dependencies for stdlib-solvable problems (e.g. net/http for fetching, not a third-party client)

Validation rules

  • Workspace names: ^[a-z0-9-]+$
  • Forbidden mount prefixes: /home/agent, /usr, /etc, /var, /bin, /sbin, /lib, /lib64
  • CIDR validation via net.ParseCIDR
  • URL fields (e.g. dockerfile): validate scheme (http/https) and non-empty host — reject malformed URLs like http:///path
  • Path expansion: ~ → $HOME on the host, or /home/agent in mount/snapshot guest destinations (skip URL fields — they must not be expanded)

Embedded assets (internal/embed/assets/)

  • Dockerfile — embedded fallback base image for the VM rootfs (no entrypoint/CMD; jailoc-guest is the init)
  • docker.Dockerfile — Docker layer stages (pinned, checksum-verified Docker CE, buildx, compose); jailoc appends the final stage and builds it on top of the base only for enable_docker workspaces
  • tui-opencode1.js, tui-opencode2.js — built TUI plugin JS for OpenCode 1 and 2 (from plugin/opencode1.jsx, plugin/opencode2.jsx via the Babel-based Solid transform in plugin/build.mjs)
  • tui-plugin.json — minimal package.json for the embedded TUI plugin
  • omo.js — OmO extension, statusline.mjs — Claude Code status line script (workspace indicator, not built)

TUI plugin rebuild

When plugin/opencode1.jsx or plugin/opencode2.jsx changes, rebuild and update the embedded copies:

npm run build
cp dist/tui-opencode1.js dist/tui-opencode2.js internal/embed/assets/

npm run build runs the Node-based Babel/Solid pipeline in plugin/build.mjs. The embedded tui-*.js must stay in sync with the plugin sources — go:embed picks it up at compile time.

Testing

  • Unit tests: *_test.go beside source, t.Parallel(), table-driven with t.Run
  • Docker integration tests: build tag //go:build integration (e.g. internal/docker/docker_integration_test.go), need a Docker daemon, not run in CI
  • VM integration tests: internal/vmintegration/, build tag vmintegration, need KVM or macOS plus a go-microvm runtime (JAILOC_VM_RUNNER, JAILOC_VM_LIBDIR); run by .github/workflows/vm-integration.yml
  • Custom assertContains helper — no testify
  • No mocks, fixtures, or testdata directories
  • t.Setenv() is incompatible with t.Parallel() — tests using t.Setenv must NOT be parallel
  • httptest.NewServer in parallel subtests: use t.Cleanup(ts.Close), NOT defer ts.Close() (defer runs before parallel subtests start)

Development environment

dev/Dockerfile.jailoc is a workspace overlay for developing jailoc inside a jailoc workspace. It extends the base image with the Go toolchain, gopls, and golangci-lint matching CI.

Add to ~/.config/jailoc/config.toml:

[workspaces.jailoc]
paths = ["/path/to/jailoc"]
dockerfile = "https://raw.githubusercontent.com/seznam/jailoc/main/dev/Dockerfile.jailoc"

jailoc up jailoc starts a VM with Go, gopls, and golangci-lint on PATH. Run go build, go test ./..., and golangci-lint run inside as usual.

CI/CD

GitHub Actions workflows:

  • CI (.github/workflows/ci.yml): runs on push/PR to main — go test, golangci-lint v2.15.0, and a TUI plugin sync check (dist/tui-*.js vs embedded copies)
  • Security (.github/workflows/security.yml): push/PR to main and weekly — CodeQL (Go, JS/TS, Actions) and govulncheck, both reporting to GitHub code scanning (govulncheck findings don't fail the job)
  • VM Integration (.github/workflows/vm-integration.yml): PRs/pushes to main touching VM code — boots real workspace VMs on an x64 Linux runner with KVM
  • VM runtime (.github/workflows/vm-runtime.yml): reusable workflow called by the release, re-release and prerelease workflows, plus PRs touching scripts/vm-runtime/ — builds runtime artifacts for darwin/arm64, linux/amd64, linux/arm64 (libkrun with a musl guest init), the libkrunfw GPL source tarball and runtime license notices (artifacts uploaded only for releases)
  • Release (.github/workflows/release-please.yml): runs on push to main — Release Please opens a Release PR; on merge, creates v* tag + GitHub Release, builds the VM runtimes into internal/vm/runtimebin/ and notices/source into build/vm-runtime/, then GoReleaser runs go generate ./internal/guestbin, generates THIRD_PARTY_NOTICES and publishes binaries (darwin/arm64, linux/amd64, linux/arm64, CGO_ENABLED=0) plus jailoc_<version>_vm-runtime-source.tar and syft SPDX SBOMs, pushes the Homebrew cask to seznam/homebrew-tap (HOMEBREW_TAP_DEPLOY_KEY deploy-key secret in the homebrew-tap environment; skipped for pre-releases), and attests build provenance of all checksummed assets
  • Nix (.github/workflows/nix.yml): push/PR to main — nix fmt check and nix flake check --all-systems, plus nix build .#jailoc on x86_64 and aarch64 Linux runners
  • Nix vendorHash (.github/workflows/nix-vendor-hash.yml): go.mod/go.sum pushes to main, Dependabot PRs, manual — recomputes vendorHash in nix/jailoc.nix in a cache-free read-only job and commits it from a separate write job
  • Re-release (.github/workflows/release.yml): manual workflow_dispatch fallback — re-runs GoReleaser for an existing tag
  • Docs (.github/workflows/release-please.yml): runs as part of the release process — zensical + mkdocs-macros-plugin → GitHub Pages

Before committing

Run these locally and fix all failures before staging a commit:

go build ./...
go test ./...
go vet ./...
golangci-lint run

Commits

type(scope): description — types: feat, fix, docs, chore, refactor, test. Imperative mood.

Documentation

Docs follow the Diátaxis framework. See docs/AGENTS.md for conventions.

When adding or changing user-facing features, update the corresponding docs in docs/:

  • docs/tutorials/ — learning-oriented walkthroughs (Getting Started)
  • docs/how-to/ — goal-oriented guides (installation, workspace config, custom images, network access, sessions, migration from v1)
  • docs/reference/ — exact technical descriptions (CLI, configuration fields, image resolution)
  • docs/explanation/ — understanding-oriented context (overview, threat model, architecture, network isolation, secrets)

Keep docs in sync with code changes — a feature without updated docs is incomplete.

docs/llms.txt is an llmstxt.org file listing all doc pages with descriptions. When adding, removing, or renaming a doc page, update llms.txt to match.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.