3.2 KiB
name, type, agent
| name | type | agent |
|---|---|---|
| repo | repo | CodeActAgent |
This repository contains the code for OpenHands, an automated AI software engineer. It has a Python backend
(in the openhands directory) and React frontend (in the frontend directory).
General Setup:
To set up the entire repo, including frontend and backend, run make build.
You don't need to do this unless the user asks you to, or if you're trying to run the entire application.
IMPORTANT: Before making any changes to the codebase, ALWAYS run make install-pre-commit-hooks to ensure pre-commit hooks are properly installed.
Before pushing any changes, you MUST ensure that any lint errors or simple test errors have been fixed.
- If you've made changes to the backend, you should run
pre-commit run --config ./dev_config/python/.pre-commit-config.yaml(this will run on staged files). - If you've made changes to the frontend, you should run
cd frontend && npm run lint:fix && npm run build ; cd ..
The pre-commit hooks MUST pass successfully before pushing any changes to the repository. This is a mandatory requirement to maintain code quality and consistency.
If either command fails, it may have automatically fixed some issues. You should fix any issues that weren't automatically fixed, then re-run the command to ensure it passes. Common issues include:
- Mypy type errors
- Ruff formatting issues
- Trailing whitespace
- Missing newlines at end of files
Repository Structure
Backend:
- Located in the
openhandsdirectory - Testing:
- All tests are in
tests/unit/test_*.py - To test new code, run
poetry run pytest tests/unit/test_xxx.pywherexxxis the appropriate file for the current functionality - Write all tests with pytest
- All tests are in
Frontend:
- Located in the
frontenddirectory - Prerequisites: A recent version of NodeJS / NPM
- Setup: Run
npm installin the frontend directory - Testing:
- Run tests:
npm run test - To run specific tests:
npm run test -- -t "TestName" - Our test framework is vitest
- Run tests:
- Building:
- Build for production:
npm run build
- Build for production:
- Environment Variables:
- Set in
frontend/.envor as environment variables - Available variables: VITE_BACKEND_HOST, VITE_USE_TLS, VITE_INSECURE_SKIP_VERIFY, VITE_FRONTEND_PORT
- Set in
- Internationalization:
- Generate i18n declaration file:
npm run make-i18n
- Generate i18n declaration file:
Template for Github Pull Request
If you are starting a pull request (PR), please follow the template in .github/pull_request_template.md.
Implementation Details
These details may or may not be useful for your current task.
Frontend
Action Handling:
- Actions are defined in
frontend/src/types/action-type.ts - The
HANDLED_ACTIONSarray infrontend/src/state/chat-slice.tsdetermines which actions are displayed as collapsible UI elements - To add a new action type to the UI:
- Add the action type to the
HANDLED_ACTIONSarray - Implement the action handling in
addAssistantActionfunction in chat-slice.ts - Add a translation key in the format
ACTION_MESSAGE$ACTION_NAMEto the i18n files
- Add the action type to the
- Actions with
thoughtproperty are displayed in the UI based on their action type:- Regular actions (like "run", "edit") display the thought as a separate message
- Special actions (like "think") are displayed as collapsible elements only