# TrapOS

A small in-game operating system for ComputerCraft / CC:Tweaked, built around a single-threaded event loop and a routed networking layer.

## Installation

One command installs everything — it bootstraps `ccpm`, syncs the default
registry (`guillaumearm/cc-libs`), and installs the full TrapOS:
```
wget run https://os.trapcloud.fr/install
```

When it finishes, run `cloud --help` to get started, or `trapos-upgrade` to
update later.

Install only the package manager (no full OS) with `--cpm-only`, then
cherry-pick packages yourself:
```
wget run https://os.trapcloud.fr/install --cpm-only
ccpm update
ccpm install trapos-ui
```

After install, every boot shows a colored MOTD with the installed version.

## Packages

TrapOS is split into packages, each described by a `packages/<name>/ccpm.json`:

- `trapos-core`: the package manager (`ccpm`), event loop, `trapos-upgrade`, `trapos-postinstall`, `events`.
- `trapos-test`: the test framework (`libtest`) and suite runner (`runtest`).
- `trapos-boot`: the startup MOTD and autostart daemon launcher.
- `trapos-ui`: the terminal UI toolkit (`libtui`, `tuidemo`).
- `trapos-ai`: the AI client for `opencode serve`.
- `trapos`: full TrapOS meta-package (`trapos-boot`, `trapos-ui`, `trapos-test`, `trapos-ai`, `trapos-cloud`).

The `trapos` meta-package is the user-facing full install. Package descriptors list
files and autostart daemons; installed state is tracked under `/trapos`.

## ccpm

`ccpm` is the TrapOS package manager. `install-trapos.lua` installs it by installing
the required `trapos-core` package and configures the default registry
(`guillaumearm/cc-libs`), then (unless `--cpm-only`) installs the full `trapos`
meta-package.

```
ccpm install <package>     ccpm reinstall <package>   ccpm uninstall <package>
ccpm update                ccpm upgrade
ccpm ls                    ccpm available [term]      ccpm search [term]
ccpm info <package>
ccpm registry ls           ccpm registry add <name> [--branch <b>] [--type gitea|http]
ccpm registry rm <name>
```

`ccpm update` fetches registry package indexes into `/trapos/ccpm.cache.json`.
`ccpm available` lists cached packages and marks installed packages as up-to-date or
updatable. `ccpm upgrade` upgrades installed packages based on that cache.

Registries default to gitea (`owner/repo` resolved against
`git.trapcloud.fr/<owner>/<repo>`); `http`/`https` base URLs are also
supported. State lives in `/trapos/ccpm.json` (registries),
`/trapos/ccpm.lock.json` (installed packages), and `/trapos/ccpm.cache.json`
(available packages). See [ADR-0010](docs/adrs/adr-0010-ccpm-package-manager.md).

## APIs
- `/apis/eventloop`: a simple event loop API.

## Servers
Servers listed in `manifest.autostart` are launched at boot by `startup/boot.lua`.

## Programs
- `events`: emits and logs computer events.
- `trapos-upgrade`: runs `ccpm update` then `ccpm upgrade`; pass `--reboot`/`-r` to reboot after upgrading.
- `trapos-postinstall`: prints the post-install welcome and next steps (run automatically by the installer).

## Development
See [DEVELOPMENT.md](./DEVELOPMENT.md) for local development installation.
