mirror of
https://github.com/furyhawk/ai_agent.git
synced 2026-07-21 02:05:42 +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.1 KiB
2.1 KiB
description, globs
| description | globs | ||
|---|---|---|---|
| Code style, formatting, naming, imports, and type hints |
|
Code Style
Formatting
- Use
rufffor linting and formatting:ruff check . --fix && ruff format . - Line length: 120 characters
Type Hints
- Type hints on ALL function signatures — parameters and return types
- Use modern syntax:
str | NonenotOptional[str],list[User]notList[User] - Use
Annotated[Type, Depends(...)]for DI (defined as aliases indeps.py) - Use
dict[str, Any]for generic dicts - Use
Literal["value1", "value2"]for string enums in schemas - Use
TYPE_CHECKINGblock for circular import resolution:from typing import TYPE_CHECKING if TYPE_CHECKING: from app.db.models.session import Session
Naming
| Element | Convention | Example |
|---|---|---|
| Files | snake_case | user_repo.py, conversation_service.py |
| Classes | PascalCase | UserService, ConversationRead |
| Functions/variables | snake_case | get_by_id, user_service |
| Constants | UPPER_CASE | DEFAULT_SYSTEM_PROMPT |
| Private | _leading_underscore | _create_agent |
| DB tables | snake_case plural | users, conversations |
| API URLs | kebab-case | /api/v1/conversations |
Imports — strictly ordered, separated by blank lines
# 1. Standard library
import logging
from collections.abc import AsyncGenerator
from datetime import UTC, datetime
from typing import Annotated, Any
from uuid import UUID
# 2. Third-party
from fastapi import APIRouter, Depends, Query, status
from pydantic import BaseModel, ConfigDict, Field
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
# 3. Local application
from app.api.deps import CurrentUser, UserSvc
from app.core.exceptions import NotFoundError
from app.schemas.user import UserCreate, UserRead
Other Conventions
datetime.now(UTC)notdatetime.utcnow()secrets.compare_digest()for constant-time comparisons__repr__on all DB models- Async for PostgreSQL/MongoDB I/O, sync for SQLite
- Keyword-only args in repo functions after
dbparameter