Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # AGENTS.md
  2. ## Project Overview
  3. Dify is an open-source platform for developing LLM applications with an intuitive interface combining agentic AI workflows, RAG pipelines, agent capabilities, and model management.
  4. The codebase consists of:
  5. - **Backend API** (`/api`): Python Flask application with Domain-Driven Design architecture
  6. - **Frontend Web** (`/web`): Next.js 15 application with TypeScript and React 19
  7. - **Docker deployment** (`/docker`): Containerized deployment configurations
  8. ## Development Commands
  9. ### Backend (API)
  10. All Python commands must be prefixed with `uv run --project api`:
  11. ```bash
  12. # Start development servers
  13. ./dev/start-api # Start API server
  14. ./dev/start-worker # Start Celery worker
  15. # Run tests
  16. uv run --project api pytest # Run all tests
  17. uv run --project api pytest tests/unit_tests/ # Unit tests only
  18. uv run --project api pytest tests/integration_tests/ # Integration tests
  19. # Code quality
  20. ./dev/reformat # Run all formatters and linters
  21. uv run --project api ruff check --fix ./ # Fix linting issues
  22. uv run --project api ruff format ./ # Format code
  23. uv run --directory api basedpyright # Type checking
  24. ```
  25. ### Frontend (Web)
  26. ```bash
  27. cd web
  28. pnpm lint # Run ESLint
  29. pnpm eslint-fix # Fix ESLint issues
  30. pnpm test # Run Jest tests
  31. ```
  32. ## Testing Guidelines
  33. ### Backend Testing
  34. - Use `pytest` for all backend tests
  35. - Write tests first (TDD approach)
  36. - Test structure: Arrange-Act-Assert
  37. ## Code Style Requirements
  38. ### Python
  39. - Use type hints for all functions and class attributes
  40. - No `Any` types unless absolutely necessary
  41. - Implement special methods (`__repr__`, `__str__`) appropriately
  42. ### TypeScript/JavaScript
  43. - Strict TypeScript configuration
  44. - ESLint with Prettier integration
  45. - Avoid `any` type
  46. ## Important Notes
  47. - **Environment Variables**: Always use UV for Python commands: `uv run --project api <command>`
  48. - **Comments**: Only write meaningful comments that explain "why", not "what"
  49. - **File Creation**: Always prefer editing existing files over creating new ones
  50. - **Documentation**: Don't create documentation files unless explicitly requested
  51. - **Code Quality**: Always run `./dev/reformat` before committing backend changes
  52. ## Common Development Tasks
  53. ### Adding a New API Endpoint
  54. 1. Create controller in `/api/controllers/`
  55. 1. Add service logic in `/api/services/`
  56. 1. Update routes in controller's `__init__.py`
  57. 1. Write tests in `/api/tests/`
  58. ## Project-Specific Conventions
  59. - All async tasks use Celery with Redis as broker
  60. - **Internationalization**: Frontend supports multiple languages with English (`web/i18n/en-US/`) as the source. All user-facing text must use i18n keys, no hardcoded strings. Edit corresponding module files in `en-US/` directory for translations.