First off, thank you for considering contributing to JoySafeter! It's people like you that make this project better for everyone.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Pull Request Process
- Coding Standards
- Commit Guidelines
- Issue Guidelines
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/JoySafeter.git cd JoySafeter - Add the upstream remote:
git remote add upstream https://github.com/jd-opensource/JoySafeter.git
- Python 3.12+
- Node.js 20+
- PostgreSQL 15+
- Redis (optional)
- Git
cd backend
# Create virtual environment
uv venv
source .venv/bin/activate
# Install dependencies including dev tools
uv sync --dev
# Copy and configure environment
cp env.example .env
# Set up database
createdb joysafeter
alembic upgrade head
# Run tests to verify setup
pytestcd frontend
# Install dependencies
bun install # or npm install
# Copy and configure environment
cp env.example .env.local
# Run development server
bun run devBefore creating bug reports, please check existing issues to avoid duplicates. When creating a bug report, include:
- Clear title describing the issue
- Steps to reproduce the behavior
- Expected behavior vs actual behavior
- Screenshots if applicable
- Environment details (OS, Python/Node versions, etc.)
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
- Clear title describing the suggestion
- Detailed description of the proposed functionality
- Use case explaining why this would be useful
- Possible implementation approach (optional)
Unsure where to begin? Look for issues labeled:
good first issue- Simple issues for newcomershelp wanted- Issues needing community helpdocumentation- Documentation improvements
-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes following our coding standards
-
Write/update tests for your changes
-
Run the test suite:
# Backend cd backend && pytest # Frontend cd frontend && npm run test
-
Run linters:
# Backend cd backend && ruff check . && mypy . # Frontend cd frontend && pnpm run lint
-
Set up Pre-commit Hooks(必须):
项目配置了 pre-commit hooks,提交前会自动运行代码检查。必须在仓库根目录执行以下脚本(依赖后端 UV 环境):
# 在仓库根目录执行(需已安装 uv) ./scripts/setup-pre-commit.sh # 或: bash scripts/setup-pre-commit.sh
该脚本会使用 backend 的 UV 环境安装 pre-commit 依赖并安装 Git hooks,无需单独执行
pip install pre-commit。安装后,每次
git commit时会自动:- 运行后端 Ruff 检查(
uv run ruff check .) - 运行前端 ESLint 检查(
pnpm run lint) - 运行其他代码质量检查
如果检查失败,提交会被阻止,需要先修复错误。未安装 hooks 或跳过提交时,CI 也会运行相同校验,不通过则 PR 无法合并。
更多信息请参考 Development Guide - Pre-commit Hooks。
- 运行后端 Ruff 检查(
-
Commit your changes following our commit guidelines
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request with:
- Clear description of changes
- Link to related issue(s)
- Screenshots for UI changes
- Follow PEP 8 style guide
- Use type hints for all functions
- Write docstrings for public functions and classes
- Keep functions focused and under 50 lines when possible
- Use
rufffor linting and formatting
# Good example
def process_message(message: str, user_id: int) -> ProcessedMessage:
"""
Process an incoming message from a user.
Args:
message: The raw message content
user_id: The ID of the user sending the message
Returns:
A ProcessedMessage object with parsed content
Raises:
ValidationError: If the message format is invalid
"""
# Implementation- Use TypeScript strict mode
- Define interfaces for all props and state
- Use functional components with hooks
- Follow React best practices
- Use ESLint and Prettier for code quality
// Good example
interface MessageProps {
content: string;
timestamp: number;
onAction?: (action: string) => void;
}
export function Message({ content, timestamp, onAction }: MessageProps) {
// Implementation
}- Write self-documenting code with clear variable/function names
- Add comments for complex logic, not obvious code
- Keep files focused and under 500 lines when possible
- Don't commit commented-out code
- Remove console.log/print statements before committing
We follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
# Feature
feat(agent): add memory summarization strategy
# Bug fix
fix(api): handle null response in chat endpoint
# Documentation
docs(readme): update installation instructions
# Refactor
refactor(core): extract common validation logic**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce:
1. Go to '...'
2. Click on '...'
3. See error
**Expected behavior**
What you expected to happen.
**Screenshots**
If applicable, add screenshots.
**Environment:**
- OS: [e.g., macOS 14.0]
- Browser: [e.g., Chrome 120]
- Python: [e.g., 3.12.1]
- Node: [e.g., 20.10.0]**Is your feature request related to a problem?**
A clear description of the problem.
**Describe the solution you'd like**
A clear description of what you want to happen.
**Describe alternatives you've considered**
Alternative solutions or features you've considered.
**Additional context**
Any other context or screenshots.Feel free to open a discussion or reach out to the maintainers if you have questions about contributing.
Thank you for contributing! 🎉