Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
orbit
A small package manager written in MoonBit that uses any OCI registry (Gitea, GHCR, Harbor, registry:2, ...) as its repository, with ORAS as the transport.
Status: builds cleanly (no warnings) with MoonBit
moonc v1.0.0-rc1/moon 0.1.20261126, and the unit tests pass. publish, install (with dependencies), upgrade, rollback, remove and gc have been exercised end to end against a localregistry:2with ORAS 1.2.3.
What it does
- Publish:
orbit publish <dir>packs<dir>/files/intopkg.tar.gzand pushes it with<dir>/orbit.jsonas the OCI config blob. - Install with dependencies: it reads only the small config blob (
oras manifest fetch-config) to plan, then pulls the layers by digest. - Version constraints:
1.2.3,1.2,^1.2.0,~1.2.0,>=1.2,*. Prereleases match only when the constraint asks for one. - Content-addressed store: packages unpack into
~/.orbit/store/<name>/<digest>/, and their binaries are symlinked into~/.orbit/bin/. - File ownership: two packages can't provide the same binary.
- Upgrade and rollback: the previous two builds are kept, and
orbit rollback <name>switches back instantly with no network. - Remove:
orbit removerefuses to delete what other packages need, then autoremoves orphaned dependencies. - gc deletes builds that are neither current nor kept for rollback.
Package format
mypkg/
orbit.json
files/
bin/mytool
share/...
{
"name": "mytool",
"version": "1.4.0",
"description": "Does a thing",
"bin": ["bin/mytool"],
"depends": { "libfoo": "^2.1.0" }
}
In the registry this becomes <registry>/mytool:1.4.0, plus the latest tag:
| Part | Media type |
|---|---|
| config | application/vnd.latha.orbit.config.v1+json (the orbit.json) |
layer pkg.tar.gz |
application/vnd.latha.orbit.layer.v1.tar+gzip |
Because these are ordinary OCI artifacts, you can sign them with cosign or notation and attach SBOMs using the registry's own tooling.
Usage
oras login git.site.latha.org # once, with a Gitea token (needed to publish)
eval "$(orbit env)"
orbit publish examples/hello
orbit install hello
hello # -> hello from orbit
orbit upgrade
orbit rollback hello
orbit remove hello
The default registry is git.site.latha.org/nandi, so no setup is needed. Override it for one command or shell with ORBIT_REGISTRY=<host>/<owner>, or save another one with orbit init <registry>. The order is ORBIT_REGISTRY, then the saved config, then the default. Orbit doesn't record which registry a package came from, so upgrade looks in whichever one is active.
Use --plain-http (or ORBIT_PLAIN_HTTP=1) for a local registry:2 without TLS:
docker run -d -p 5000:5000 registry:2
orbit init localhost:5000/pkgs --plain-http
Building
moon build --target native --release
moon test --target native # semver / manifest unit tests
# the binary is _build/native/release/build/main/main.exe
Or run just install to build and copy the binary to ~/.local/bin/orbit.
Linux only for now: arguments come from /proc/self/cmdline. It needs oras, tar and /bin/sh on PATH.
Package Orbit with Orbit
From the repo root, build and stage the orbit package. The package version
comes from moon.mod; publishing is a separate step.
package_dir=$(sh scripts/package-orbit.sh) &&
_build/native/release/build/main/main.exe publish "$package_dir"
This publishes to the active registry (set ORBIT_REGISTRY to override the
default), so log in with oras login <host> first if needed. The
package contains a native Linux binary for the build machine's architecture.
Use the same architecture on the install machine. oras and tar are still
system prerequisites; the package does not bundle them.
To bootstrap from source, install the published package with the binary you just
built. After adding Orbit's bin directory to PATH, use the installed binary
for future upgrades and rollbacks:
bootstrap=_build/native/release/build/main/main.exe
"$bootstrap" install orbit
eval "$("$bootstrap" env)"
orbit upgrade orbit
# If needed: orbit rollback orbit
Layout
src/main/
stub.c C glue: system(), popen(), file read/write, getenv, exit
sys.mbt FFI bindings, UTF-8, string helpers, shell quoting
semver.mbt versions, constraints, tag selection (+ tests)
model.mbt orbit.json / state.json / config.json (+ tests)
registry.mbt oras wrappers: tags, resolve, fetch-config, pull, push
ops.mbt dependency planner, install/remove/upgrade/rollback/gc
main.mbt CLI
Toolchain notes
Fixes needed for current MoonBit, kept here in case you build with an older compiler:
- The project uses
moon.mod/moon.pkg(the.jsonforms are no longer accepted). suberror OrbitError { OrbitError(String) }, and@jsonis imported explicitly inmoon.pkg.Jsonvalues are built withJson::string,Json::array,Json::object,Json::boolean; the uppercase constructors are only used in patterns.- C FFI parameters are annotated
#borrow(...), matchingstub.c, which never decrefs its arguments.
Known limits
- Dependency resolution is greedy (highest satisfying version, first come), not a SAT solver.
- There's no lock file for concurrent runs, and no install hooks, by design.
searchneeds the registry's catalog API, which Gitea doesn't expose. Useorbit info <name>there.