|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This is the canonical workspace instruction file for nllclw and for coding |
| 4 | +agents working on this repository. nllclw loads this file into runtime context |
| 5 | +when it is present in the current directory. Tool-specific files in this repo |
| 6 | +point here. |
| 7 | + |
| 8 | +## Project |
| 9 | + |
| 10 | +nllclw is a tiny Zig 0.16 AI assistant. It is intentionally stdlib-only by |
| 11 | +default: no package dependencies, no `curl`, no external runtime process, and no |
| 12 | +shell tool unless the binary is built with `-Dshell-tool=true`. |
| 13 | + |
| 14 | +## Architecture |
| 15 | + |
| 16 | +- `src/main.zig`: process entrypoint only. |
| 17 | +- `src/root.zig`: small public Zig package API. |
| 18 | +- `src/runtime.zig`: composition root for channels, config, adapters, memory, and tools. |
| 19 | +- `src/agent.zig`: channel-neutral Chat Completions engine. |
| 20 | +- `src/chat.zig`: OpenAI-compatible Chat Completions JSON/SSE codec. |
| 21 | +- `src/providers.zig`: OpenAI/OpenRouter/compatible endpoint and header presets. |
| 22 | +- `src/config/`: runtime config types, source mapping, and validation. |
| 23 | +- `src/channels/`: CLI, terminal REPL, local commands, Telegram, and WebSocket orchestration. |
| 24 | +- `src/tools/`: product tools: time, diagnostics, filesystem, memory, web search, scheduler, macro tools, and optional shell. |
| 25 | +- `src/ports/`: dependency ports. |
| 26 | +- `src/adapters/`: stdlib implementations of ports. |
| 27 | + |
| 28 | +Keep product capabilities in `src/tools/`, technical implementations in |
| 29 | +`src/adapters/`, and channel loops in `src/channels/`. |
| 30 | + |
| 31 | +## Build And Test |
| 32 | + |
| 33 | +Run these before handing work back: |
| 34 | + |
| 35 | +```sh |
| 36 | +zig fmt build.zig build.zig.zon $(find src -name '*.zig' -type f | sort) |
| 37 | +zig build test --summary all |
| 38 | +zig build test --summary all -Dshell-tool=true |
| 39 | +zig build --release=small |
| 40 | +./zig-out/bin/nllclw --help >/dev/null |
| 41 | +strings ./zig-out/bin/nllclw | rg 'shell_exec|NLLCLW_SHELL|NLLCLW_TOOL_TIMEOUT_MS|cmd\.exe|sh -c' || true |
| 42 | +git diff --check |
| 43 | +``` |
| 44 | + |
| 45 | +For portability-sensitive changes, also run: |
| 46 | + |
| 47 | +```sh |
| 48 | +zig build -Dtarget=x86_64-windows --release=small |
| 49 | +zig build -Dtarget=x86_64-linux --release=small |
| 50 | +zig build -Dtarget=aarch64-linux --release=small |
| 51 | +zig build -Dtarget=aarch64-macos --release=small |
| 52 | +zig build -Dtarget=wasm32-wasi --release=small |
| 53 | +``` |
| 54 | + |
| 55 | +## Rules |
| 56 | + |
| 57 | +- Use Zig stdlib APIs first. |
| 58 | +- Preserve zero external runtime dependencies in the default binary. |
| 59 | +- Keep shell execution behind `-Dshell-tool=true`. |
| 60 | +- Do not expose channel/runtime internals from `src/root.zig`. |
| 61 | +- Add tests near the code for new behavior. |
| 62 | +- Update README metrics when release binary size, test counts, source file |
| 63 | + counts, or LOC change. |
| 64 | +- When changing English documentation under `docs/en/`, apply the equivalent |
| 65 | + documentation update to every translated language directory under `docs/`. |
| 66 | +- Do not commit `.env`, `config.json`, `USER.md`, `BOOTSTRAP.md`, or generated memory files. |
0 commit comments