Files
Pizza 52d5c368fa init: project scaffold with SmallClawPlus brain files
- Brain: STATUS, PLAN (4 milestones), ARCH (module design), CONTEXT, SESSIONS, DEPS
- Learnings: ERRORS.md, LEARNINGS.md (empty)
- Code: cli.py stub, pyproject.toml, __init__.py
- README with architecture diagram and queue format
- Queue format: EDIT/CREATE/DELETE/TEST actions
2026-04-02 21:19:38 +00:00

2.5 KiB

ARCH.md

Overview

TinyClaw orchestrates 1-4B parameter models for real project work. The driver handles everything the tiny model can't: file extraction, state management, verification, git. The model just edits code.

Flow

  1. Big model (or human) writes atomic tasks to QUEUE.md
  2. Driver reads next task from queue
  3. Extractor pulls target function from source file (Python AST)
  4. Prompt builder assembles: system prompt (~200 tokens) + function code + task instruction
  5. Model client sends to tiny model, gets edited function back
  6. Verifier checks syntax, imports, optional tests
  7. On pass: splice back into file, git commit, mark task done
  8. On fail: revert, retry (max 3), then skip with error log
  9. Repeat until queue empty

Modules

Module Owns Exposes Depends On
driver core loop, queue state run(), status() extractor, client, verifier
extractor AST parsing, function splice extract_function(), splice_function() (none)
client model API calls generate(prompt, model) (none, uses requests)
verifier syntax/import/test checks verify(filepath) (none)
webui Flask app, queue editor serve() driver

File Index

File Purpose
tinyclaw/driver.py Core loop, queue processing
tinyclaw/extractor.py AST function extraction and splicing
tinyclaw/client.py Model API client (OpenRouter, Ollama)
tinyclaw/verifier.py Syntax, import, test verification
tinyclaw/prompt.py Prompt assembly
tinyclaw/cli.py CLI entry point
tinyclaw/webui.py Web UI (milestone 3)
tinyclaw/__init__.py Package init, version

Queue Format (QUEUE.md)

EDIT <file> <function> "<instruction>"
CREATE <file> - "<description>"
DELETE <file> <function> "<reason>"
TEST <file> - "<what to verify>"

Env / Deps

  • Python 3.10+
  • requests (model API calls)
  • flask (web UI, milestone 3)
  • No other heavy deps

Decisions Log

Date Decision Reason
2026-04-02 Model never uses tools 1-4B can't reliably format tool calls
2026-04-02 AST extraction, not line-range Accurate function boundaries, handles decorators
2026-04-02 Python projects first Clean AST, expand later with tree-sitter
2026-04-02 OpenRouter as primary API Fits OpenClaw ecosystem, access to small models
2026-04-02 Max 500 token prompts Leaves room for output in 2-4k context

Forge