This guide is a practical map of the entire repository for contributors and maintainers.
It focuses on:
- What each folder is responsible for
- Which Python environment and package workflow are the defaults
- Which commands are currently valid
- What to improve next in architecture, testing, performance, and developer experience
AI Imaging Agent is a RAG plus VLM recommender for imaging software.
High-level flow:
- User uploads file(s) and enters a task.
- Retrieval stage finds candidate tools (BGE-M3 + FAISS + reranker).
- Agent/VLM stage ranks candidates with image-aware reasoning.
- UI renders ranked recommendations and optional demo links.
Primary orchestrator: src/ai_agent/api/pipeline.py
Assume development is done inside the dev container.
Source of truth:
- Dev container: .devcontainer/devcontainer.json
- Package metadata and pinned dependencies: pyproject.toml
- Secondary dependency list: requirements.txt
Default environment:
- OS: Debian Bookworm (dev container)
- Python: 3.12
- Environment manager: uv
- Virtual environment path: .venv
Recommended commands:
uv venv
uv pip install -e .
uv pip install -e ".[dev]"Run and test:
ai_agent chat
ai_agent sync
pytest tests/Important note on command drift:
- CLI officially supports
chatandsyncin src/ai_agent/cli.py. - justfile currently references
ai_agent ui, which does not match current CLI modes. - Documentation in this guide follows the actual CLI implementation.
- .github/: automation and agent instructions
- .devcontainer/: dev container build and editor defaults
- docs/: MkDocs source pages
- src/: application source code
- tests/: test suite
- data/: sample data assets
- tools/: container/tooling helpers
- CHANGELOG.md: release history
- config.yaml: model/provider configuration
- mkdocs.yml: docs site navigation and theme
- pyproject.toml: package metadata, dependencies, entrypoints
Package root: src/ai_agent/
Purpose: conversational orchestration using PydanticAI.
Key files:
- src/ai_agent/agent/agent.py: agent setup, tool wiring, response flow
- src/ai_agent/agent/models.py: state/output models
- src/ai_agent/agent/utils.py: helper utilities and guardrails
- src/ai_agent/agent/tools/: concrete tool implementations
- src/ai_agent/agent/tools/mcp/: MCP adapters
Boundary:
- Should orchestrate tools and policy, not own retrieval internals.
Purpose: pipeline orchestration between inputs, retrieval, and selection.
Key file:
Responsibilities:
- validate files
- extract metadata
- build retrieval query
- call retrieval and selection stages
- manage index refresh/reload behavior
Boundary:
- Keep UI concerns out of this module.
Purpose: deterministic retrieval stack (no LLM calls).
Key files:
- src/ai_agent/retriever/text_embedder.py
- src/ai_agent/retriever/vector_index.py
- src/ai_agent/retriever/reranker.py
- src/ai_agent/retriever/software_doc.py
Boundary:
- Retrieval quality logic should stay here.
Purpose: selection schema and prompting primitives.
Key files:
Boundary:
- Keep this layer focused on schema and prompt contracts, not transport/UI concerns.
4.5 src/ai_agent/ui/
Purpose: Gradio app and interaction handling.
Key files:
- src/ai_agent/ui/app.py
- src/ai_agent/ui/handlers.py
- src/ai_agent/ui/components.py
- src/ai_agent/ui/formatters.py
- src/ai_agent/ui/state.py
- src/ai_agent/ui/visualizations.py
Boundary:
- UI should call orchestrators, not reimplement retrieval/selection decisions.
Purpose: cross-cutting utility functions.
Key files:
- src/ai_agent/utils/config.py
- src/ai_agent/utils/file_validator.py
- src/ai_agent/utils/image_meta.py
- src/ai_agent/utils/image_io.py
- src/ai_agent/utils/previews.py
- src/ai_agent/utils/tags.py
- src/ai_agent/utils/temp_file_manager.py
Boundary:
- Keep utilities reusable and independent from UI-specific logic.
Purpose: catalog synchronization and refresh helpers.
Key file:
Boundary:
- Catalog IO and sync logic should stay isolated from ranking logic.
Purpose: shared core coordination such as pipeline registry.
Key file:
Boundary:
- Keep core primitives minimal and dependency-light.
Purpose: query assets used by catalog sync/retrieval support.
Key file:
Boundary:
- Keep query definitions versioned and testable.
4.10 src/ai_agent/cli.py
Purpose: command entry point and mode dispatch.
Current modes:
chatsync
This is the command contract docs should follow.
5.1 tests/
Contains unit/integration tests and test fixtures under tests/data/.
Improvement target:
- add more focused tests for UI handler edge cases and tool failure handling.
5.2 tools/
Container and deployment support assets.
Notable file:
- tools/image/Dockerfile (uv + Python 3.12 baseline)
5.3 docs/
Documentation source for MkDocs.
Add new pages to mkdocs.yml nav to keep docs discoverable.
- justfile uses
ai_agent ui, while src/ai_agent/cli.py defineschatandsync. - Installation docs often show pip-first flow, while dev container bootstrap is uv-first.
- requirements.txt is looser than pyproject.toml, which contains current pinned/runtime dependencies.
- Keep strict stage boundaries: retrieval logic in
retriever, selection contracts ingenerator, orchestration inapi. - Minimize cross-layer imports from
uito low-level modules. - Introduce lightweight interface contracts for tool adapters to reduce coupling in
agent/tools. - Centralize shared constants/env defaults to reduce duplicated configuration behavior.
- Add regression tests for format-token query construction and retry broadening behavior.
- Add failure-path tests for image preview generation and graceful degradation.
- Add contract tests for agent tool outputs (search, alternative search, repo info).
- Enforce formatting/lint/type checks in CI (
ruff,black --check,mypy,pytest).
- Add benchmark fixtures for retrieval latency and reranker throughput.
- Track retrieval quality with a small fixed evaluation set (top-k recall, MRR).
- Cache expensive metadata extraction where safe for repeated files in a session.
- Make index reload behavior observable with structured counters in logs.
- Align
justtasks with real CLI contract (chat/sync). - Add a docs link checker in CI to prevent markdown drift.
- Document one canonical local workflow (dev container first, optional local pip fallback).
- Add a short maintainer checklist for release prep and changelog updates.
Before opening a PR:
- Install/update in editable mode in the active environment.
- Run tests relevant to changed modules.
- Validate docs links if docs were touched.
- Update CHANGELOG.md for user-visible changes.
- Confirm command and environment docs still match real behavior.