docmind-ai-llm
AGENTS.md155 starsChanged 5 months agoMITView on GitHub
Repo guardrails for contributors/automation. Keep aligned with code, pyproject.toml, and docs under docs/specs/ + docs/developers/adrs/. - Setup: uv sync && cp .env.example .env - Run: uv run streamlit run app.py (or ./scripts/run_app.sh) - Env: prefer uv run ... (uses the project env, typically .venv). - Verify (batch): after a batch of edits, run lint/type on touched paths + focused tests. - Format (all): uv run ruff format . - Lint (all): uv run ruff check . - Type (paths): uv…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
39 rules. About 0 are common, 8 are distinctive, and 31 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
31
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Run: uv run streamlit run app.py (or ./scripts/run_app.sh)
- Distinctive: line 28
Verify (batch): after a batch of edits, run lint/type on touched paths + focused tests.
- Very specific: line 34
Verify (final): before finishing the task/prompt, run non-mutating full lint/type checks, then full tests: uv run ruff format --check .
- Distinctive: line 63
After any material research, decisions, or implementation:
- Very specific: line 70
If you call any mcp__zen__* tool that returns a continuation_id, record it in:
- Distinctive: line 77
When resuming after compaction:
- Very specific: line 80
Read docs/developers/worklogs/continuations.json and reuse any stored continuation_id values when continuing mcp__zen__* threads.
- Very specific: line 108
Prefer from src.config import settings (exports the settings object).
- Very specific: line 110
Avoid import-time IO; use startup_init() + initialize_integrations() (src/config/integrations.py).
- Very specific: line 116
Prefer DOCMIND_OPENAI__BASE_URL + DOCMIND_OPENAI__API_KEY for OpenAI-like servers (local servers can use placeholder keys).
- Very specific: line 125
Use DOCMIND_SECURITY__ALLOW_REMOTE_ENDPOINTS=true for private/internal endpoints (e.g., Docker service hostnames), or use a loopback-only …
- Very specific: line 137
Keep page imports light. src.app, Chat, and Documents must pass scripts/check_ui_import_boundary.py without loading torch, transformers, …
- Distinctive: line 146
Keep Chat model readiness local-only and typed.
- Very specific: line 150
Treat GraphRAG package metadata as installed, not ready.
- Very specific: line 153
Use st.cache_resource for long-lived objects (DB connections, checkpointers, clients).
- Very specific: line 158
Keep the ADR-052 background JobManager process-owned behind its module lock.
- Very specific: line 161
Keep mutable job records and progress queues manager-private.
- Very specific: line 178
Treat Settings Apply as one transaction: catch any ordinary Exception, restore the exact settings and LlamaIndex globals, and let …
- Very specific: line 184
Use LlamaIndex IngestionPipeline with TokenTextSplitter and optional spaCy enrichment.
- Very specific: line 186
Use src/processing/parsing/ as the parser boundary.
- Very specific: line 221
Use scripts/qdrant_schema.py rebuild-empty only after stopping writers.
- Very specific: line 234
Run retrieval and reranking CPU work through src/retrieval/async_work.py.
- Very specific: line 252
Use DOCMIND_GRAPHRAG_CFG__ENABLED as the sole ingestion default.
- Very specific: line 287
Never delete physical Qdrant generations during online activation.
- Very specific: line 295
Use native SqliteStore and AsyncSqliteSaver for LangGraph persistence.
- Distinctive: line 297
Keep the Ops DB metadata-only.
- Very specific: line 323
No secrets/API keys; no raw prompt/doc/model output.
- Very specific: line 334
Check parser readiness: uv run python scripts/parser_health.py --check.
- Very specific: line 335
Use HF_HUB_OFFLINE=1 and TRANSFORMERS_OFFLINE=1 for offline runs.
- Distinctive: line 339
Prefer library primitives.
- Very specific: line 340
Prefer lazy imports for heavy ML deps (see src/config/integrations.py).
- Very specific: line 341
Use loguru.logger; avoid print in production code.
- Very specific: line 342
Use pathlib.Path and guard clauses.
- Very specific: line 356
Use markers: unit|integration|system|e2e|retrieval plus requires_gpu|requires_network|requires_llama.
- Very specific: line 359
Prefer patching real consumer seams, not src.app (see docs/developers/testing-notes.md).
- Distinctive: line 365
When behavior changes, update README and the owning spec/ADR.
- Very specific: line 366
Keep active docs pointing at real src/...
- Very specific: line 370
Use agent-browser for web automation.
- Distinctive: line 385
Use this source code when you need to understand how a package works internally, not just its types/interface.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DocMind AI: Agent instructions
Purpose
Repo guardrails for contributors/automation. Keep aligned with code, pyproject.toml,
and docs under docs/specs/ + docs/developers/adrs/.
Layout
app.py: Streamlit entrypointsrc/app.py: Streamlit app module (imported byapp.py)src/pages/: UI pages (chat/documents/analytics/settings)src/config/: settings + integration wiringsrc/processing/: ingestion, OCR, PDF page exportssrc/retrieval/: router, hybrid retrieval, reranking, GraphRAG helperssrc/agents/: LangGraph coordinator (graph-native supervisor viaStateGraph)src/persistence/: snapshots, hashing, locking, chat DBsrc/telemetry/+src/utils/telemetry.py: OTEL + JSONL eventssrc/prompting/templates/: bundled prompt templates and presetsdocs/specs/+docs/developers/adrs/: specs/ADRs (source-of-truth docs)scripts/+tools/: benchmarks, health checks, documentation gates, and model pull
Quick commands with uv
- Setup:
uv sync && cp .env.example .env - Run:
uv run streamlit run app.py(or./scripts/run_app.sh) - Env: prefer
uv run ...(uses the project env, typically.venv). - Verify (batch): after a batch of edits, run lint/type on touched paths + focused tests.
- Format (all):
uv run ruff format . - Lint (all):
uv run ruff check . - Type (paths):
uv run pyright --threads 4 <paths> - Tools-only (when
tools/changed):uv run pyright --threads 4 tools - Tests (focused):
uv run pytest <tests/...> -vv --no-cov(or-k <expr>for a narrow slice)
- Format (all):
- Verify (final): before finishing the task/prompt, run non-mutating full lint/type
checks, then full tests:
uv run ruff format --check . && uv run ruff check . && uv run pyright --threads 4 && uv run pytest tests/unit tests/integration -q --no-cov - Tests (unit):
uv run pytest tests/unit -q --no-cov - Tests (integration):
uv run pytest tests/integration -q --no-cov - Tests (fast/full):
uv run pytest tests/unit tests/integration -q --no-cov - Tests (GPU):
uv run pytest -m requires_gpu --no-cov - Coverage:
uv run pytest tests/unit tests/integration -q --cov=src --cov-branch --cov-report=term-missing --cov-report=html:htmlcov --cov-report=xml:coverage.xml --cov-report=json:coverage.json --cov-fail-under=80 --junitxml=junit.xml - Coverage report:
uv run python scripts/check_coverage.py --collect --report --html - Parser benchmark:
uv run python scripts/benchmark_parsing.py --generate-minimal-fixtures --output cache/benchmarks/parsing/results.json - GPU check:
uv run python scripts/test_gpu.py --quick - Prefetch default retrieval and Docling layout models:
uv run python tools/models/pull.py --all --cache_dir ./models_cache --parser-defaults --parser-cache-dir ./cache/models; RapidOCR models come from its locked wheel. - spaCy model (opt):
uv run python -m spacy download en_core_web_sm - Review triage:
uv run python scripts/analyze_github_reviews.py --json-file <path>(or setDOCMIND_REVIEW_JSON)
Non-negotiables for CI and security
- No
TODO|FIXME|XXXundersrc tests docs scripts tools. - CI expects
ruff format --checkand a clean, non-mutatingruff check. - Offline-first default: no implicit egress. Base URL validation is strict by default and includes DNS resolution of allowlisted non-loopback hosts as SSRF/DNS-rebinding hardening.
- Streamlit: no
unsafe_allow_html=Truefor untrusted content. - Logging/telemetry: metadata-only; never log secrets or raw prompt/doc/model output (use
src/utils/log_safety.py).
Compaction + continuity worklogs
This repo uses a lightweight, compaction-resilient log so we can resume work without re-researching or re-deciding.
Worklogs are local-only by default (gitignored) and should not be committed to the repo.
After any material research, decisions, or implementation:
- Update
docs/developers/worklogs/CONTEXT.mdwith:- current status + next steps
- research notes (primary links)
- key decisions + rationale
- important quirks/constraints (no secrets)
- If you call any
mcp__zen__*tool that returns acontinuation_id, record it in:docs/developers/worklogs/continuations.json
- For normative changes (architecture/policy): add or update an ADR under
docs/developers/adrs/. - For behavior changes: update the owning spec under
docs/specs/and keepdocs/specs/traceability.mdaligned.
Timing rule: write ADRs/spec updates immediately when finalized (do not batch them at the end of a long session) to avoid losing decision context during auto-compaction.
When resuming after compaction:
- Read
docs/developers/worklogs/CONTEXT.mdfirst. - Read
docs/developers/worklogs/continuations.jsonand reuse any storedcontinuation_idvalues when continuingmcp__zen__*threads.
Optional extras
uv sync --frozen --no-group cpu --extra gpu(PyTorch CUDA and CuPy; sparse FastEmbed remains CPU-based)uv sync --frozen --extra observability(LlamaIndex OpenTelemetry instrumentation)uv sync --frozen --extra eval(beir)
Dependency constraints (don’t drift)
Source of truth for exact pins: pyproject.toml + uv.lock.
- Python:
>=3.12,<3.14(primary dev/runtime: Python 3.12.13) - Keep these coupled:
- Torch 2.11.x ↔ Transformers
>=5.0,<6.0(vLLM is external-only via OpenAI-compatible HTTP) - DuckDB
<1.4.0(LlamaIndex integrations cap it) llama-index-core>=0.14.21,<0.15.0plus selected integration packages- Direct
fastembed>=0.5.1; do not restore the removed LlamaIndex FastEmbed adapter - Ollama Python client
0.6.2 - Streamlit
<2.0.0 [tool.uv]enforcesrapidfuzz>=3.14.1,<4.0.0
- Torch 2.11.x ↔ Transformers
Configuration
- Source of truth:
src/config/settings.py(Pydantic Settings v2). - Settings helpers (URL parsing/normalization + endpoint allowlist policy) live in
src/config/settings_utils.pyto keepsettings.pyfocused on typed models and validators. - Env: prefix
DOCMIND_, nested__. - Prefer
from src.config import settings(exports the settings object). - No
os.getenv/os.environoutsidesrc/config/*(env bridges live there). - Avoid import-time IO; use
startup_init()+initialize_integrations()(src/config/integrations.py).
LLM backends
- Backends:
ollama|vllm|lmstudio|llamacpp|openai_compatibleviaDOCMIND_LLM_BACKEND. - OpenAI-compatible base URLs are normalized to a single
/v1segment. - Prefer
DOCMIND_OPENAI__BASE_URL+DOCMIND_OPENAI__API_KEYfor OpenAI-like servers (local servers can use placeholder keys). - Backend-specific base URLs:
DOCMIND_LMSTUDIO_BASE_URL,DOCMIND_VLLM_BASE_URL,DOCMIND_LLAMACPP_BASE_URL. - Provider-neutral request controls use
DOCMIND_LLM_REQUEST__MODEL,DOCMIND_LLM_REQUEST__CONTEXT_WINDOW,DOCMIND_LLM_REQUEST__MAX_OUTPUT_TOKENS, andDOCMIND_LLM_REQUEST__TEMPERATURE.
Security policy
- When
DOCMIND_SECURITY__ALLOW_REMOTE_ENDPOINTS=false(default):- Loopback hosts are always allowed.
- Non-loopback hosts must be in
DOCMIND_SECURITY__ENDPOINT_ALLOWLISTand must DNS-resolve to public IPs (private/link-local/reserved ranges are rejected; fail-closed when DNS resolution fails). - Use
DOCMIND_SECURITY__ALLOW_REMOTE_ENDPOINTS=truefor private/internal endpoints (e.g., Docker service hostnames), or use a loopback-only architecture (http://localhost:...).
- Analytics page is gated by
DOCMIND_ANALYTICS_ENABLED=trueand readsdata/analytics/analytics.duckdb.
Containerization (CI-enforced)
Dockerfile: Python 3.12.13 base; finalUSERnon-root;CMD/ENTRYPOINTexec-form (nosh -c); no:latest.scripts/container_health.pyowns container health; Dockerfile and Compose call it directly..dockerignore: ignore.env(.env,.env.*, or.env*); don’t bake.envinto images.- Compose: use canonical
DOCMIND_*env vars (no legacyOLLAMA_BASE_URL/VLLM_BASE_URL/LMSTUDIO_BASE_URL); prod override setsread_only: trueandtmpfs: /tmp.
Streamlit UI
- Keep page imports light.
src.app, Chat, and Documents must passscripts/check_ui_import_boundary.pywithout loadingtorch,transformers,llama_index, orqdrant_client. Import those implementations only inside their recovery, status, cached-resource, or user-action seam; useTYPE_CHECKINGfor annotations and patch canonical owners in tests instead of page aliases. - Compute Chat snapshot status once on steady reruns. Clear/hydrate mutations
re-read once inside
admission_quiescence()before changing runtime owners; do not add a freshness TTL. - Keep Chat model readiness local-only and typed. Missing cache, incomplete local overrides, and initialization failures have distinct sanitized states; never turn model readiness into an implicit download or relabel unexpected Chat DB/persistence failures.
- Treat GraphRAG package metadata as
installed, notready. ValidatePropertyGraphIndexonly at the Settings/action seam before claiming runtime capability. - Use
st.cache_resourcefor long-lived objects (DB connections, checkpointers, clients). - Give every closeable
st.cache_resourcea typedon_releasecallback. Acquire its current value insideJobManager.foreground_runtime_activity()and retain that counted lease through the resource's last use; nested foreground callbacks are supported. - Keep the ADR-052 background
JobManagerprocess-owned behind its module lock; do not put it inst.cache_resource, because cache clearing must not replace active job or maintenance-lease ownership. - Keep mutable job records and progress queues manager-private.
get()publishes an immutable shallow view captured under the manager lock. Publish terminal payload/error before terminal status, and only after the worker future is done during normal completion. Owner consumption and TTL expiry must clear payload references before removing registry and future ownership. - Acquire
JobManager.foreground_runtime_activity()before obtaining any live Chat coordinator/router handle or vector-backed export seed. Acquireadmission_quiescence()before every runtime ownership mutation, recheck state inside the lease, and never nest a maintenance lease with a foreground lease. - A Chat analysis fragment persists result, one terminal notice, and its completed
marker before consumption, then requests
st.rerun(scope="app"). Only the full app renders and pops that notice, after the job panel transition. Deferred consumption retries without republishing; successful or missing-state cleanup also requests a full-app rerun so controls re-enable. - Manual GraphRAG export must revalidate the current session vector resource as its first action inside the foreground lease, before borrowing graph or vector indices, and retain that lease through the final file write.
- Treat Settings Apply as one transaction: catch any ordinary
Exception, restore the exact settings and LlamaIndex globals, and let process-controlBaseExceptionsubclasses propagate.
Ingestion / processing
- Use LlamaIndex
IngestionPipelinewithTokenTextSplitterand optional spaCy enrichment. Do not add a second title-extraction path. - Use
src/processing/parsing/as the parser boundary. The parser always uses local Docling, pypdfium2, and RapidOCR artifacts. Plain text and Markdown use the direct text loader. - Prefetch the app-owned Docling layout bundle before PDF parsing. Health checks hash its manifest files and report relative-path integrity issues. RapidOCR's locked wheel owns its model files and checksums; the image/test gate proves offline fixture inference.
- Searchable-PDF export is an optional, fail-open OCRmyPDF utility. It requires POSIX process groups; use WSL2 on Windows. Cancellation and timeout paths must kill and reap the whole subprocess group.
- Fail closed with
DocumentParseErrorfor every parser error. The parser service alone owns direct UTF-8 loading; do not add an ingestion-facade text fallback. - Accept in-memory ingestion as
payload_text: str; route every binary input through a source path and the parser boundary. - Snapshot finalization returns
FinalizedSnapshot(path, manifest), whose manifest was verified and captured inside the writer-lock/retention boundary. Before an ingestion worker returns, derive its bounded object-free presentation DTO from that captured manifest. Do not reopen the worker's result snapshot. Terminal handoff must persist its notice before owner-authorized consumption; retain tracking when consumption races worker completion. - Reject duplicate document IDs before ingestion I/O. Derive file document IDs
as
doc-<full lowercase SHA-256>throughsrc/utils/hashing.py. - Cache: DuckDB KV store (
DOCMIND_CACHE__DIR,DOCMIND_CACHE__FILENAME). - PDF page images: pypdfium2 rendering; optional AES-GCM (
DOCMIND_IMG_AES_KEY_BASE64,DOCMIND_IMG_DELETE_PLAINTEXT). - Multimodal artifacts: store page images/thumbnails as content-addressed
ArtifactRefin the local ArtifactStore (DOCMIND_ARTIFACTS__*). Historical chats and snapshots can retain those references; do not add automatic artifact garbage collection.
Retrieval
- Text embeddings: BGE-M3 (1024D). Sparse: FastEmbed BM42 preferred, BM25 fallback.
- Hybrid retrieval: Qdrant server-side via
PrefetchplusRrfQuery(configured k) or DBSFFusionQuery. - Named vectors:
text-dense,text-sparse(+ IDF modifier). Dedup bypage_id(default) ordoc_id. - Runtime creates a missing collection but never mutates an incompatible one.
Use
scripts/qdrant_schema.py rebuild-emptyonly after stopping writers; it requires an exact zero count and refuses nonempty or error states. - Enable server-side hybrid:
DOCMIND_RETRIEVAL__ENABLE_SERVER_HYBRID=true. - Multimodal search: SigLIP text→image fused by RRF; image collection uses
settings.database.qdrant_image_collection.
Router
- Router composes
semantic_searchplus configuredhybrid_search,keyword_search,multimodal_search, andknowledge_graphtools. - LlamaIndex's native
RouterQueryEngineowns tool selection. - Build routers via
src/retrieval/router_factory.pyto keep tool metadata/postprocessors consistent. - Close the session router before invalidating its Chat coordinator; async Qdrant clients are bound to the graph loop that first uses them.
- Run retrieval and reranking CPU work through
src/retrieval/async_work.py; do not useasyncio.to_threadfor FastEmbed, BGE, or SigLIP inference.
Reranking
- Text rerank: BGE cross-encoder (
BAAI/bge-reranker-v2-m3). - Visual rerank: SigLIP when image nodes exist.
- SigLIP Hugging Face model/processor loading is centralized in
src/utils/vision_siglip.py; do not add alternatefrom_pretrainedloaders, fallback canary flags, or duplicate revision pins. - Fail open on timeouts; respect
settings.retrieval.*_timeout_ms. - Rerankers own one queue-free worker. A timed-out call retains that worker's capacity until native inference exits. Async router close drains it; a sync-only router close rejects new work without blocking on native exit.
GraphRAG
- Use
DOCMIND_GRAPHRAG_CFG__ENABLEDas the sole ingestion default; router inclusion is owned by the presence of a healthy property graph index. - Uses LlamaIndex core's
PropertyGraphIndexandSimplePropertyGraphStore; there is no graph extra. - Exports: JSONL baseline; Parquet optional (PyArrow). Preserve
get_rel_maplabels (fallbackrelated). - Seed policy: graph retriever → vector retriever → deterministic fallback.
Snapshots
- Location:
data/storage/; write via temp workspace + atomic finalize. portalockeris required. The permanent.locksentinel's OS lock is the sole writer authority; heartbeat metadata is diagnostic only.- Manifest triad:
manifest.jsonl,manifest.meta.json,manifest.checksum. - App snapshots own the activation manifest plus optional property-graph artifacts; Qdrant backups alone own point-in-time vector data.
manifest.meta.jsonincludes physicalcollections.textandcollections.imageidentities, optional collection metadata, hashes, versions, graph type, and optionalgraph_exports.- The canonical manifest validator owns presentation-safe metadata: every version
key is a string and every value is a string, finite number, boolean, or null;
every graph export has a unique basename of at most 200 characters, a nonempty
format of at most 32 characters, a nonnegative integer size, and a lowercase
SHA-256. Graph type
nonerequires no exports. Reject invalid metadata before movingCURRENT; canonical hash preflight rejects non-finite numbers across the complete manifest before any artifact is written. CURRENTis the sole activation boundary. Never infer an active snapshot from directory ordering or promote an unreferenced snapshot during recovery.- Result presentation must use the manifest captured by finalization. Canonical
readiness and recovery checks may resolve and verify
CURRENT; that validation is not a result-snapshot presentation reload. data/.deployment-idis the stable ownership boundary for DocMind Qdrant collections. Bootstrap it atomically only before durable snapshots exist. A missing, invalid, or replaced identity with retained snapshot state fails closed.- Source promotion and quarantine journals recover under the snapshot writer lock
against exact physical collection identities. The activation journal removes an
uncommitted promoted snapshot or retires itself after
CURRENTcommits; recovery never chooses a snapshot by directory ordering. - Never delete physical Qdrant generations during online activation. After stopping
every app reader and writer, use
scripts/cleanup_collections.py(dry-run by default) and review its deployment-scoped candidates before adding--delete. - Don’t persist base64 blobs or raw filesystem paths; persist
ArtifactRefand sanitize path-like metadata to basenames. - Persist via
SnapshotManagerAPIs; do not add lease-file lock fallbacks.
SQLite and WAL
- Use native
SqliteStoreandAsyncSqliteSaverfor LangGraph persistence; do not add parallel store or checkpoint schemas. - Let each long-lived LangGraph primitive own its connection. Do not share raw connections between components.
- Keep the Ops DB metadata-only. Treat Chat DB checkpoints and memories as local user data.
Backups
- Quiesce DocMind writers before backup/restore; use SQLite online backup and
DuckDB
COPY FROM DATABASE, never raw live database-file copies. - A complete recovery point includes chat, ingestion cache, the verified
CURRENTsnapshot, authoritative uploads,data/.deployment-id, the existingArtifactStore, and exact verified single-node Qdrant snapshots. Distributed Qdrant requires its per-node procedure. Maintenance warnings do not invalidate an otherwise complete recovery point. - Retention may delete only
backup_*directories withmanifest.complete=true. Recoverability warnings produceincomplete-backup_*, which never evicts a recovery point.maintenance_warningsdo not invalidate verified recovery data. - Restore Qdrant into a fresh, writer-quiesced target using the exact physical
names in
activation.collections. Verify checksum and point count, and preserve the prior Qdrant instance as the rollback owner until acceptance.
Observability / telemetry
- OTEL is optional:
DOCMIND_OBSERVABILITY__ENABLED=true+--extra observability. - Router construction emits an OpenTelemetry
router_selectedevent with tool count and names. Local JSONL telemetry records retrieval backend/outcome,export_performed,snapshot_stale_detected, and rerank fallback events; it does not claim per-query route or graph traversal events. - Log safety:
- No secrets/API keys; no raw prompt/doc/model output.
- URLs: log origin only; sanitize exception strings before logging.
- Controls:
DOCMIND_TELEMETRY_DISABLED,DOCMIND_TELEMETRY_SAMPLE,DOCMIND_TELEMETRY_ROTATE_BYTES.
Agent budgets
- Cap every provider request timeout to the supervisor budget. Every graph run carries an absolute deadline, and no call may exceed
settings.agents.decision_timeout.
Offline-first
- Predownload BGE-M3, BM42, the BGE reranker, SigLIP, and Docling layout defaults:
uv run python tools/models/pull.py --all --cache_dir ./models_cache --parser-defaults --parser-cache-dir ./cache/models; never copy or separately prefetch RapidOCR's packaged models. - Check parser readiness:
uv run python scripts/parser_health.py --check. - Use
HF_HUB_OFFLINE=1andTRANSFORMERS_OFFLINE=1for offline runs; tests must remain deterministic/offline unless explicitly marked.
Coding standards
- Prefer library primitives; keep changes small and typed.
- Prefer lazy imports for heavy ML deps (see
src/config/integrations.py). - Use
loguru.logger; avoidprintin production code. - Use
pathlib.Pathand guard clauses; avoidAnyunless isolated behind a narrow boundary. - Device/VRAM policy: use
src/utils/core.py(resolve_device,has_cuda_vram) for business logic. - Python style (apply to all code; when editing a file, align the whole file):
4-space indent, 88-char lines; public docstrings use
"""+ 1-line summary <=80 chars and includeArgs:,Returns:/Yields:,Raises:when needed with 4-space hanging indents; absolute imports only, one per line, top of file; None checks useis (not) None, booleans useif not x(addand x is not Noneonly to distinguish False vs None); always use context managers (with open(...)orcontextlib.closing(...)); prefer generator expressions over materialized lists when possible.
Testing
- Boundary-first; keep unit tests <5s and integration <30s when possible.
- Use markers:
unit|integration|system|e2e|retrievalplusrequires_gpu|requires_network|requires_llama. - AppTest: temp cwd; reuse fixtures; deterministic stubs;
default_timeout(CI). - Prefer patching real consumer seams, not
src.app(seedocs/developers/testing-notes.md).
Docs
- Specs:
docs/specs/_index.md - ADRs:
docs/developers/adrs/(do not implement anything underdocs/developers/adrs/superseded/) - When behavior changes, update README and the owning spec/ADR.
- Keep active docs pointing at real
src/...paths (avoid doc drift).
Browser automation
Use agent-browser for web automation. Run agent-browser --help for all commands.
Core workflow:
agent-browser open <url>- Navigate to pageagent-browser snapshot -i- Get elements with refs (@e1, @e2)agent-browser click @e1/fill @e2 "text"- Interact using refs- Re-snapshot after page changes
Source code reference
Source code for deps is available in opensrc/ for deeper understanding of implementation details.
See opensrc/sources.json for the list of available packages and their versions.
Use this source code when you need to understand how a package works internally, not just its types/interface.
Fetching additional source code
To fetch source code for a package or repository you need to understand, run:
opensrc fetch --cwd . <package> # npm package (for example, zod)
opensrc fetch --cwd . pypi:<package> # Python package (for example, requests)
opensrc fetch crates:<package> # Rust crate (for example, serde)
opensrc fetch <owner>/<repo> # GitHub repository (for example, vercel/ai)Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

