cc-libs/CLAUDE.md

41 lines
1.8 KiB
Markdown

# CLAUDE.md
Concise guidance for agents working in this repository.
## Project
ComputerCraft / CC:Tweaked Lua APIs, servers, and programs for Minecraft 1.21. Code runs in the ComputerCraft sandbox, not standard Lua.
Use `docs/README.md` as the entrypoint for CC:Tweaked, Advanced Peripherals, and Create integration documentation links.
## Constraints
- Do not run Lua locally or add a test harness unless asked; code executes in-game or CraftOS-PC.
- After editing Lua, run `just check` and fix all `luacheck` warnings.
- Use 2-space indent, semicolons, and `local function`.
- `require` paths are absolute ComputerCraft paths, for example `require('/apis/net')()`.
- Most API modules return factories; call the required module once before use.
## Architecture
- `apis/eventloop.lua` is the single-threaded event loop around `os.pullEventRaw`.
- `apis/net.lua` builds modem packet messaging, routing, and request/response RPC on the event loop.
- `servers/` listen for requests and start loops; `programs/` are clients that send requests and exit.
- Well-known channels: `9` ping, `10` router/default routing. Keep duplicated constants in sync.
## Boot And Install
- `startup/servers.lua` starts `/programs`, the shell, and configured servers via `parallel.waitForAll`.
- Preserve `periphemu` guards used for CraftOS-PC emulation.
- `install.lua` downloads files listed in `LIST_FILES`; add shipped files there.
- Add new servers to `startup/servers.lua` as needed.
## Conventions
- Bump `local _VERSION = '...'` when changing module behavior.
- Programs support `-version`/`--version` and `-help`/`--help`; router also supports `-silent`/`--silent`.
- French or English comments are fine; match surrounding code.
- Commit messages use lightweight conventional style: `topic(scope): description` or `topic: description`.
See `DEVELOPMENT.md` for local setup.