cc-libs/README.md
2026-06-08 13:52:45 +02:00

78 lines
3.1 KiB
Markdown

# TrapOS
A small in-game operating system for ComputerCraft / CC:Tweaked, built around a single-threaded event loop and a routed networking layer.
## Installation
Full install (all packages):
```
wget run https://raw.githubusercontent.com/guillaumearm/cc-libs/master/install.lua
```
Minimal install (only `tos-core`, i.e. just the package manager) so you can cherry-pick the rest yourself:
```
wget run https://raw.githubusercontent.com/guillaumearm/cc-libs/master/install.lua --core
```
```
> ccpm install tos-net
> ccpm install tos-ui
```
Install the beta branch (one-time opt-in, asks for confirmation):
```
wget run https://raw.githubusercontent.com/guillaumearm/cc-libs/next/install.lua --beta
```
Once a machine is on beta, `upgrade` keeps it on beta — `--beta` is not needed again. Use `upgrade --stable` to go back to the stable branch.
After install, every boot shows a colored MOTD with the installed version and branch (lime for stable, orange + `[BETA]` for beta).
## Packages
TrapOS is split into packages, each described by a `packages/<name>/ccpm.json`:
- `tos-core`: the package manager (`ccpm`), event loop, `upgrade`, `events`.
- `tos-test`: the test framework (`libtest`) and suite runner (`runtest`).
- `tos-boot`: the startup MOTD and autostart server launcher.
- `tos-net`: routed modem networking (`net`, `router`, `ping`, `ping-server`).
- `tos-ui`: the terminal UI toolkit (`libtui`, `tuidemo`).
`manifest.json` at the repo root lists which packages a full install ships. The
bootstrap resolves their descriptors, downloads the files, and writes the aggregated
`/trapos/manifest.json` (version, branch, files, autostart) that drives `upgrade`,
`startup/motd.lua`, and `startup/servers.lua`.
## ccpm
`ccpm` is the TrapOS package manager (shipped in `tos-core`). It is configured at
install with a default registry (`guillaumearm/cc-libs`).
```
ccpm install <package> ccpm reinstall <package> ccpm uninstall <package>
ccpm ls ccpm search [term] ccpm info <package>
ccpm registry ls ccpm registry add <name> [--branch <b>] [--type github|http]
ccpm registry rm <name>
```
Registries default to GitHub (`owner/repo`); `http`/`https` base URLs are also
supported. State lives in `/trapos/ccpm.json` (registries) and `/trapos/ccpm.lock.json`
(installed packages). See [ADR-0010](docs/adrs/adr-0010-ccpm-package-manager.md).
## APIs
- `/apis/eventloop`: a simple event loop API.
- `/apis/net`: an API to simplify sending and receiving routed messages, based on the `eventloop` library.
## Servers
Servers listed in `manifest.autostart` are launched at boot by `startup/servers.lua`.
- `/servers/ping-server`: allows a machine to respond to a `ping` command.
## Programs
- `router`: routes messages. You need to set up a router to use all `apis/net`-based programs and libraries.
- `ping`: pings machines using `apis/net`.
- `events`: emits and logs computer events.
- `upgrade`: upgrades the machine. Reads `/trapos/manifest.json` to stay on the current branch; use `--beta` to opt in or `--stable` to opt out.
## Development
See [DEVELOPMENT.md](./DEVELOPMENT.md) for development setup and workflow.