|
| 1 | +# AGENTS.md — OpenKB map for coding agents |
| 2 | + |
| 3 | +OpenKB compiles raw documents into an interlinked wiki knowledge base using |
| 4 | +LLMs (vectorless retrieval via PageIndex). This repo is developed **agent-first**: |
| 5 | +humans steer, agents execute. Optimize changes for agent legibility. |
| 6 | + |
| 7 | +## Read next |
| 8 | +- `docs/golden-principles.md` — mechanical rules to follow (enforced where possible). |
| 9 | +- `docs/internal/superpowers/{specs,plans}/` — design history & plans *(maintainer-local, not in git)*. |
| 10 | +- `README.md` — user-facing overview and commands. |
| 11 | + |
| 12 | +## Dev commands |
| 13 | +- Install: `pip install -e ".[dev]"` (or `uv sync --extra dev` — plain `uv sync` skips the dev tools) |
| 14 | +- Run CLI: `openkb <command>` (entry point: `openkb.cli:cli`) |
| 15 | +- Test: `pytest` |
| 16 | +- Lint/format/types: `ruff check .` · `ruff format .` · `mypy openkb` |
| 17 | + |
| 18 | +## Module map (openkb/) |
| 19 | +- `cli.py` — Click CLI entry point & command wiring *(large; see tech-debt)*. |
| 20 | +- `config.py` — config loading/validation (LiteLLM passthrough, env). |
| 21 | +- `converter.py` — document → markdown conversion (markitdown). |
| 22 | +- `url_ingest.py` — fetch & ingest URLs (trafilatura). |
| 23 | +- `images.py` — figure/image extraction & handling. |
| 24 | +- `indexer.py` — PageIndex tree indexing for long docs. |
| 25 | +- `mutation.py` — crash-safe, serial KB mutations. |
| 26 | +- `locks.py` — atomic writes / file locking (`atomic_write_text`, portalocker). |
| 27 | +- `state.py` — run/session state tracking. |
| 28 | +- `frontmatter.py` — YAML frontmatter round-trip (OKF). |
| 29 | +- `schema.py` — page/content schema constants & helpers. |
| 30 | +- `lint.py` — structural wiki lint (broken links, orphans, index sync). |
| 31 | +- `tree_renderer.py`, `visualize.py`, `watcher.py` — rendering / graph / file watch. |
| 32 | +- `agent/compiler.py` — LLM wiki compiler *(large; see tech-debt)*. |
| 33 | +- `agent/linter.py` — semantic (LLM) wiki lint (contradictions, gaps, staleness). |
| 34 | +- `agent/chat.py`, `agent/chat_session.py` — chat over the wiki *(chat.py large)*. |
| 35 | +- `agent/query.py` — one-off query generator. |
| 36 | +- `agent/tools.py` — shared wiki read/write tool functions used by query/linter (and by chat indirectly via `query.build_chat_agent`). |
| 37 | +- `agent/skills.py`, `agent/skill_runner.py`, `skill/` — Skill Factory. |
| 38 | +- `deck/`, `templates/`, `prompts/` — deck output, templates, prompt assets. |
| 39 | + |
| 40 | +## Hard invariants |
| 41 | +- Deps are pinned **exactly** (supply-chain caution). Vet before bumping. |
| 42 | +- Wiki writes go through `locks.py` / `mutation.py` (never ad-hoc). |
| 43 | +- Modules stay < 800 lines (`tests/test_file_size.py`); grandfathered files are in tech-debt. |
| 44 | +- Keep this file a short map — put depth in `docs/`. |
0 commit comments