Skip to content

Commit 2b7e775

Browse files
committed
Initial commit
0 parents  commit 2b7e775

195 files changed

Lines changed: 50833 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.

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
*.egg-info
6+
dist/
7+
build/
8+
.git
9+
.env
10+
.assets
11+
node_modules/
12+
bridge/dist/
13+
workspace/

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches: [ main, nightly ]
6+
pull_request:
7+
branches: [ main, nightly ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- name: Install system dependencies
28+
run: sudo apt-get update && sudo apt-get install -y libolm-dev build-essential
29+
30+
- name: Install all dependencies
31+
run: uv sync --all-extras
32+
33+
- name: Run tests
34+
run: uv run pytest tests/

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.worktrees/
2+
.assets
3+
.docs
4+
.env
5+
*.pyc
6+
dist/
7+
build/
8+
*.egg-info/
9+
*.egg
10+
*.pycs
11+
*.pyo
12+
*.pyd
13+
*.pyw
14+
*.pyz
15+
*.pywz
16+
*.pyzz
17+
.venv/
18+
venv/
19+
__pycache__/
20+
poetry.lock
21+
.pytest_cache/
22+
botpy.log
23+
nano.*.save
24+
.DS_Store
25+
uv.lock
26+
.runtime/
27+
console/.uploads/
28+
console/serve.log
29+
workspace/sessions/
30+
workspace/memory/daily_conversations/
31+
workspace/memory/daily_memory/
32+
workspace/memory/weekly_memory/
33+
workspace/memory/graphs/

COMMUNICATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
We provide QR codes for joining the HKUDS discussion groups on **WeChat** and **Feishu**.
2+
3+
You can join by scanning the QR codes below:
4+
5+
<img src="https://github.com/HKUDS/.github/blob/main/profile/QR.png" alt="WeChat QR Code" width="400"/>

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Contributing to nanobot
2+
3+
Thank you for being here.
4+
5+
nanobot is built with a simple belief: good tools should feel calm, clear, and humane.
6+
We care deeply about useful features, but we also believe in achieving more with less:
7+
solutions should be powerful without becoming heavy, and ambitious without becoming
8+
needlessly complicated.
9+
10+
This guide is not only about how to open a PR. It is also about how we hope to build
11+
software together: with care, clarity, and respect for the next person reading the code.
12+
13+
## Maintainers
14+
15+
| Maintainer | Focus |
16+
|------------|-------|
17+
| [@re-bin](https://github.com/re-bin) | Project lead, `main` branch |
18+
| [@chengyongru](https://github.com/chengyongru) | `nightly` branch, experimental features |
19+
20+
## Branching Strategy
21+
22+
We use a two-branch model to balance stability and exploration:
23+
24+
| Branch | Purpose | Stability |
25+
|--------|---------|-----------|
26+
| `main` | Stable releases | Production-ready |
27+
| `nightly` | Experimental features | May have bugs or breaking changes |
28+
29+
### Which Branch Should I Target?
30+
31+
**Target `nightly` if your PR includes:**
32+
33+
- New features or functionality
34+
- Refactoring that may affect existing behavior
35+
- Changes to APIs or configuration
36+
37+
**Target `main` if your PR includes:**
38+
39+
- Bug fixes with no behavior changes
40+
- Documentation improvements
41+
- Minor tweaks that don't affect functionality
42+
43+
**When in doubt, target `nightly`.** It is easier to move a stable idea from `nightly`
44+
to `main` than to undo a risky change after it lands in the stable branch.
45+
46+
### How Does Nightly Get Merged to Main?
47+
48+
We don't merge the entire `nightly` branch. Instead, stable features are **cherry-picked** from `nightly` into individual PRs targeting `main`:
49+
50+
```
51+
nightly ──┬── feature A (stable) ──► PR ──► main
52+
├── feature B (testing)
53+
└── feature C (stable) ──► PR ──► main
54+
```
55+
56+
This happens approximately **once a week**, but the timing depends on when features become stable enough.
57+
58+
### Quick Summary
59+
60+
| Your Change | Target Branch |
61+
|-------------|---------------|
62+
| New feature | `nightly` |
63+
| Bug fix | `main` |
64+
| Documentation | `main` |
65+
| Refactoring | `nightly` |
66+
| Unsure | `nightly` |
67+
68+
## Development Setup
69+
70+
Keep setup boring and reliable. The goal is to get you into the code quickly:
71+
72+
```bash
73+
# Clone the repository
74+
git clone https://github.com/HKUDS/nanobot.git
75+
cd nanobot
76+
77+
# Install with dev dependencies
78+
pip install -e ".[dev]"
79+
80+
# Run tests
81+
pytest
82+
83+
# Lint code
84+
ruff check nanobot/
85+
86+
# Format code
87+
ruff format nanobot/
88+
```
89+
90+
## Code Style
91+
92+
We care about more than passing lint. We want nanobot to stay small, calm, and readable.
93+
94+
When contributing, please aim for code that feels:
95+
96+
- Simple: prefer the smallest change that solves the real problem
97+
- Clear: optimize for the next reader, not for cleverness
98+
- Decoupled: keep boundaries clean and avoid unnecessary new abstractions
99+
- Honest: do not hide complexity, but do not create extra complexity either
100+
- Durable: choose solutions that are easy to maintain, test, and extend
101+
102+
In practice:
103+
104+
- Line length: 100 characters (`ruff`)
105+
- Target: Python 3.11+
106+
- Linting: `ruff` with rules E, F, I, N, W (E501 ignored)
107+
- Async: uses `asyncio` throughout; pytest with `asyncio_mode = "auto"`
108+
- Prefer readable code over magical code
109+
- Prefer focused patches over broad rewrites
110+
- If a new abstraction is introduced, it should clearly reduce complexity rather than move it around
111+
112+
## Questions?
113+
114+
If you have questions, ideas, or half-formed insights, you are warmly welcome here.
115+
116+
Please feel free to open an [issue](https://github.com/HKUDS/nanobot/issues), join the community, or simply reach out:
117+
118+
- [Discord](https://discord.gg/MnCvHqpUGB)
119+
- [Feishu/WeChat](./COMMUNICATION.md)
120+
- Email: Xubin Ren (@Re-bin) — <xubinrencs@gmail.com>
121+
122+
Thank you for spending your time and care on nanobot. We would love for more people to participate in this community, and we genuinely welcome contributions of all sizes.

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2+
3+
# Install Node.js 20 for the WhatsApp bridge
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends curl ca-certificates gnupg git openssh-client && \
6+
mkdir -p /etc/apt/keyrings && \
7+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
8+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
9+
apt-get update && \
10+
apt-get install -y --no-install-recommends nodejs && \
11+
apt-get purge -y gnupg && \
12+
apt-get autoremove -y && \
13+
rm -rf /var/lib/apt/lists/*
14+
15+
WORKDIR /app
16+
17+
# Install Python dependencies first (cached layer)
18+
COPY pyproject.toml README.md LICENSE ./
19+
RUN mkdir -p nanobot bridge && touch nanobot/__init__.py && \
20+
uv pip install --system --no-cache . && \
21+
rm -rf nanobot bridge
22+
23+
# Copy the full source and install
24+
COPY nanobot/ nanobot/
25+
COPY bridge/ bridge/
26+
RUN uv pip install --system --no-cache .
27+
28+
# Build the WhatsApp bridge
29+
RUN git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
30+
31+
WORKDIR /app/bridge
32+
RUN npm install && npm run build
33+
WORKDIR /app
34+
35+
# Create config directory
36+
RUN mkdir -p /root/.nanobot
37+
38+
# Gateway default port
39+
EXPOSE 18790
40+
41+
ENTRYPOINT ["nanobot"]
42+
CMD ["status"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 nanobot contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)