mirror of
https://github.com/furyhawk/ai_agent.git
synced 2026-07-20 09:45:44 +00:00
- Implemented `conversation-store` for managing conversations and messages. - Created `file-preview-store` to handle file preview state. - Added `sidebar-store` for sidebar visibility management. - Developed `theme-store` for theme persistence and management. - Introduced `kb-selection-store` for managing active knowledge base selections with persistence. chore: define API and chat types - Added types for API responses, authentication, chat messages, conversations, and projects. - Defined interfaces for various entities including users, sessions, and message ratings. build: configure TypeScript and testing setup - Set up `tsconfig.json` for TypeScript configuration. - Created `vitest.config.ts` for testing configuration with Vitest. - Added `vitest.setup.ts` for global test setup including mocks for Next.js router and media queries. - Configured Vercel deployment settings in `vercel.json`.
2.6 KiB
2.6 KiB
Contributing to ai_agent
Development setup
# Backend (uv-based)
cd backend
uv sync # install all deps including dev extras
cp .env.example .env # then fill in required vars (see ENV_VARS.md)
uv run uvicorn app.main:app --reload --port 8033
uv run alembic upgrade head # apply migrations
# Frontend (bun-based)
cd ../frontend
bun install
bun dev # http://localhost:3033
# Or everything in Docker
docker compose up
Code style
- Python: ruff (
uv run ruff check . --fix && uv run ruff format .). Line length 120. - Type hints: modern syntax (
str | None,list[X],dict[str, Any]). UseAnnotated[T, Depends(...)]for DI in route signatures. - TypeScript: strict mode, no
anyunless typed external API. ESLint + Prettier (runbun run lint). - Imports: stdlib → third-party → local, separated by blank lines. Use
TYPE_CHECKINGblock to break circular refs. - Datetime:
datetime.now(UTC)notdatetime.utcnow(). - Comparisons:
secrets.compare_digest()for tokens/keys (constant-time).
Testing
cd backend
uv run pytest # all backend tests
uv run pytest tests/test_file.py::test -v # single test
uv run pytest -k "name_substring" -v # by name pattern
uv run pytest --cov=app # with coverage
cd frontend
bun test # vitest
bunx tsc --noEmit # type-check without emit
Architecture rules
- Routes never import repositories directly. Always go through a service.
- Services raise domain exceptions (
NotFoundError,AlreadyExistsError) — never returnNonefor "not found". - Repositories use
db.flush()+db.refresh(), NEVERdb.commit()(session auto-commits inget_db_session). - Pydantic schemas: separate
*Create,*Update,*Read,*Listper operation. - Migrations: one Alembic revision per logical change; never edit a merged migration.
See docs/architecture.md for the full layered architecture rules.
Pre-commit
Configured via .pre-commit-config.yaml. Install once:
uv run pre-commit install
Will run ruff + (frontend lint if present) on every commit. Bypass with --no-verify only when fixing a hook bug.
Pull-request checklist
uv run ruff check . && uv run ruff format --check .cleancd frontend && bunx tsc --noEmitclean- Tests added for new code paths;
uv run pytestgreen - If schema changed: alembic migration committed (
uv run alembic revision --autogenerate -m "...") - Updated
ENV_VARS.mdif new env vars added - Updated
CHANGELOG.md(if applicable)