Skip to content

Commit e83e3a9

Browse files
committed
Initial commit
0 parents  commit e83e3a9

234 files changed

Lines changed: 54329 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/nllclw.mdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description: nllclw project instructions
3+
alwaysApply: true
4+
---
5+
6+
Use `AGENTS.md` as the canonical project instructions for this repository.

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
.github
3+
.zig-cache
4+
zig-out

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copilot Instructions
2+
3+
Use `AGENTS.md` as the canonical project instructions for this repository.

.github/scripts/ci.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
zig fmt --check build.zig build.zig.zon src
5+
zig build test --summary all
6+
zig build test --summary all -Dshell-tool=true
7+
zig build --release=small
8+
9+
case "$(uname -s)" in
10+
MINGW*|MSYS*|CYGWIN*)
11+
bin="./zig-out/bin/nllclw.exe"
12+
;;
13+
*)
14+
bin="./zig-out/bin/nllclw"
15+
;;
16+
esac
17+
"${bin}" --help >/dev/null
18+
19+
if command -v strings >/dev/null 2>&1; then
20+
if strings "${bin}" | grep -E 'shell_exec|NLLCLW_SHELL|NLLCLW_TOOL_TIMEOUT_MS|cmd\.exe|sh -c'; then
21+
echo "default binary contains shell-only strings"
22+
exit 1
23+
fi
24+
else
25+
echo "strings is not available; skipping shell-only string scan"
26+
fi
27+
28+
zig build --release=small -Dshell-tool=true
29+
zig build -Dtarget=x86_64-windows --release=small
30+
zig build -Dtarget=x86_64-linux --release=small
31+
zig build -Dtarget=aarch64-linux --release=small
32+
zig build -Dtarget=aarch64-macos --release=small
33+
zig build -Dtarget=wasm32-wasi --release=small

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
zig:
14+
uses: nullclaw/nullbuilder/.github/workflows/zig-ci.yml@v1
15+
permissions:
16+
contents: read
17+
with:
18+
binary_name: nllclw
19+
artifact_prefix: nllclw
20+
zig_version: "0.16.0"
21+
test_command: bash .github/scripts/ci.sh

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v20*"]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
release:
13+
uses: nullclaw/nullbuilder/.github/workflows/zig-release.yml@v1
14+
permissions:
15+
contents: write
16+
packages: write
17+
with:
18+
binary_name: nllclw
19+
artifact_prefix: nllclw
20+
zig_version: "0.16.0"
21+
source_archive: true
22+
publish_docker: true

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.zig-cache/
2+
zig-out/
3+
.env
4+
config.json
5+
USER.md
6+
BOOTSTRAP.md
7+
.nllclw-memory.jsonl
8+
.nllclw-memory.jsonl.lock
9+
.nllclw-memory.jsonl.tmp.*
10+
.nllclw-facts.jsonl
11+
.nllclw-facts.jsonl.lock
12+
.nllclw-facts.jsonl.tmp.*
13+
.nllclw-schedule.jsonl
14+
.nllclw-schedule.jsonl.lock
15+
.nllclw-schedule.jsonl.tmp.*
16+
.nllclw-user-tools.jsonl
17+
.nllclw-user-tools.jsonl.lock
18+
.nllclw-user-tools.jsonl.tmp.*
19+
.nllclw-telegram-offset
20+
.nllclw-telegram-offset.lock
21+
.nllclw-telegram-offset.tmp.*

AGENTS.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.

CODE_OF_CONDUCT.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Code of Conduct
2+
3+
## Scope
4+
5+
This code of conduct applies to the `nllclw` repository, issues, pull requests,
6+
reviews, discussions, and any maintainer-run project spaces.
7+
8+
## Expected Behavior
9+
10+
- Be respectful and direct.
11+
- Focus criticism on code, documentation, behavior, and tradeoffs.
12+
- Assume good intent when reasonable, and ask for clarification when something
13+
is ambiguous.
14+
- Keep discussions relevant to the project and its users.
15+
- Protect private information, credentials, logs, tokens, and security reports.
16+
17+
## Unacceptable Behavior
18+
19+
- Harassment, threats, personal attacks, or sustained disruption.
20+
- Discriminatory language or behavior.
21+
- Publishing private information without explicit permission.
22+
- Sexualized comments or imagery in project spaces.
23+
- Deliberately misleading reports, malicious code, or attempts to bypass project
24+
safety boundaries.
25+
26+
## Enforcement
27+
28+
Maintainers may remove comments, close issues, reject contributions, or restrict
29+
repository access when behavior violates this code of conduct.
30+
31+
If you need to report a conduct issue, contact a maintainer privately through
32+
GitHub. Include the relevant links, screenshots, or context needed to evaluate
33+
the report. Do not publish private or sensitive information in a public issue.

CONTRIBUTING.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Contributing
2+
3+
Thanks for improving `nllclw`. This project is intentionally small, stdlib-only
4+
by default, and conservative about local capabilities.
5+
6+
## Development Setup
7+
8+
Use Zig `0.16.0`.
9+
10+
```sh
11+
zig version
12+
zig build test --summary all
13+
```
14+
15+
The default binary must not require package dependencies, `curl`, Node, Python,
16+
an external runtime process, or a shell. Shell execution belongs only behind the
17+
explicit `-Dshell-tool=true` build option.
18+
19+
## Before Submitting
20+
21+
Run the repository gate:
22+
23+
```sh
24+
zig fmt build.zig build.zig.zon $(find src -name '*.zig' -type f | sort)
25+
zig build test --summary all
26+
zig build test --summary all -Dshell-tool=true
27+
zig build --release=small
28+
./zig-out/bin/nllclw --help >/dev/null
29+
strings ./zig-out/bin/nllclw | rg 'shell_exec|NLLCLW_SHELL|NLLCLW_TOOL_TIMEOUT_MS|cmd\.exe|sh -c' || true
30+
git diff --check
31+
```
32+
33+
For portability-sensitive changes, also run the cross-builds listed in
34+
`AGENTS.md`.
35+
36+
## Code Guidelines
37+
38+
- Prefer Zig stdlib APIs before adding abstractions.
39+
- Keep product tools in `src/tools/`, adapters in `src/adapters/`, channel loops
40+
in `src/channels/`, and runtime composition in `src/runtime.zig`.
41+
- Keep `src/main.zig` as the process entrypoint only.
42+
- Do not expose channel or runtime internals from `src/root.zig`.
43+
- Add focused tests near the code for new behavior.
44+
- Keep shell execution behind `-Dshell-tool=true`.
45+
- Preserve safe defaults for local files, memory, tools, Telegram, WebSocket,
46+
and compatible-provider HTTP URLs.
47+
48+
## Documentation
49+
50+
- Prefer `config.json` examples for normal setup. Use environment variables for
51+
one-off overrides, CI, or `.env` documentation.
52+
- Installation docs should recommend the latest release binary first, then
53+
source builds with Zig `0.16.0`.
54+
- When changing English documentation under `docs/en/`, apply the equivalent
55+
update to every translated language directory under `docs/`.
56+
57+
## Secrets And Local State
58+
59+
Do not commit:
60+
61+
- `.env`
62+
- `config.json`
63+
- `USER.md`
64+
- `BOOTSTRAP.md`
65+
- generated memory files
66+
- provider keys, Telegram tokens, WebSocket tokens, or private logs
67+
68+
If a contribution touches secret handling, local file access, shell execution,
69+
network endpoints, or provider configuration, call that out clearly in the pull
70+
request.

0 commit comments

Comments
 (0)