This project uses Codev for AI-assisted development.
- SPIR: Multi-phase development with consultation (
codev/protocols/spir/protocol.md) - TICK: Fast autonomous implementation (
codev/protocols/tick/protocol.md) - EXPERIMENT: Disciplined experimentation (
codev/protocols/experiment/protocol.md) - MAINTAIN: Codebase maintenance (
codev/protocols/maintain/protocol.md)
- Specs:
codev/specs/- Feature specifications (WHAT to build) - Plans:
codev/plans/- Implementation plans (HOW to build) - Reviews:
codev/reviews/- Reviews and lessons learned - Protocols:
codev/protocols/- Development protocols
- For new features, start with the Specification phase
- Create exactly THREE documents per feature: spec, plan, and review
- Follow the protocol phases as defined in the protocol files
- Use multi-agent consultation when specified
Use sequential numbering with descriptive names:
- Specification:
codev/specs/0001-feature-name.md - Plan:
codev/plans/0001-feature-name.md - Review:
codev/reviews/0001-feature-name.md
- Always create new branches from the
developbranch, NOT frommain - Use descriptive branch names that reflect the feature or fix being implemented
- Keep branches focused on a single feature or fix
- Delete branches after they're merged to keep the repository clean
- Keep the root directory clean and organized
- Place temporary files, debug scripts, and other non-production artifacts in the
tmp/directory - The
tmp/directory is gitignored, making it perfect for development-only files - Make sure scripts and tools intended for the repository are placed in appropriate subdirectories
- Do not include "Generated with Claude Code" or "Co-Authored-By: Claude" in commit messages
- Do not include "Generated with Claude Code" in PR descriptions or anywhere else
- Keep commit messages concise and descriptive
- Use imperative mood in commit messages (e.g., "Add feature" not "Added feature")
- Always run
ruff checkandruff formatbefore committing changes - Fix all linting errors - clean code is maintainable code
- All PRs should target the
developbranch, notmain - Codev commit messages format:
[Spec 0001] Description of change [Spec 0001][Phase: implement] feat: Add feature
- Consider a merged branch "done" - do not add new changes to it
- If you have changes after a branch was merged:
- Create a new branch from the latest develop branch
- Apply your new changes there
- Create a new PR with a descriptive name
- For related but separate features, use separate branches and PRs
- Delete branches after they're merged to keep the repository clean
-
Install dependencies:
uv sync- Installs all dependencies from pyproject.toml and uv.lock -
Run backend service:
- Use venv python directly:
.venv/Scripts/python.exe src/ansari/app/main_api.py
- Alternative (if uvicorn is available):
uvicorn main_api:app --reload
Note: Direct venv python path is used because
source .venv/Scripts/activatemay not properly activate the virtual environment in bash.Testing changes: Auto-reload can be unreliable. For reliable testing after code changes:
- Kill the running server (
KillShelltool) - Start new server:
.venv/Scripts/python.exe src/ansari/app/main_api.py - Wait 10 seconds for startup to complete
- Then test with curl
- Use venv python directly:
-
Run CLI version (interactive):
- Claude:
python src/ansari/app/main_stdio.py -a AnsariClaude - OpenAI:
python src/ansari/app/main_stdio.py -a Ansari
- Claude:
-
Run CLI with direct input:
python src/ansari/app/main_stdio.py -i "your question here"python src/ansari/app/main_stdio.py --input "your question here"
-
Run tests:
pytest tests/ -
Run single test:
pytest tests/path/to/test.py::test_function_name -
Run tests with specific marker:
pytest -m integration -
Lint code:
ruff check src/ -
Format code:
ruff format src/ -
Package commands:
- Build package:
python -m build - Upload to PyPI:
twine upload dist/*(requires PyPI credentials)
- Build package:
- Install dependencies:
uv sync- Installs all dependencies from pyproject.toml and uv.lock - Add new package:
uv add <package>- Adds package to dependencies and updates lock file - Add development dependency:
uv add --dev <package>- Adds package to dev dependencies - Remove package:
uv remove <package>- Removes package from dependencies - Create virtual environment:
uv venv- Creates .venv directory (if not exists) - Update dependencies:
uv lock- Updates uv.lock file with latest compatible versions
- Imports: Use absolute imports within the
ansaripackage - Formatting: Double quotes for strings, 4-space indentation
- Line length: 127 characters maximum
- Types: Use Python type hints for function parameters and return types
- Naming: Use snake_case for variables/functions, PascalCase for classes
- Error handling: Use try/except blocks with specific error types
- Prefer clean failures over unpredictable recovery attempts
- Log errors clearly and completely before failing
- Do not attempt to "fix" malformed data that could lead to unexpected behavior
- If recovery is necessary, implement it as a well-tested, dedicated fix rather than ad-hoc patches
- Avoid cascading fallbacks - throw clear errors instead
- Logging: Use the logger from
ansari.ansari_logger.get_logger() - Documentation: Add docstrings to functions, especially complex ones
- Testing: Create unit tests in
tests/unit/and integration tests intests/integration/ - Citations:
- All search tools must format document data as multilingual JSON using
format_multilingual_data - The data format must be valid JSON following the schema in
base_search.pydocumentation - Store properly formatted JSON in the
datafield of document references - Citation handling should account for both full document citations (valid JSON) and partial citations (plain text)
- All search tools must format document data as multilingual JSON using
- Test-first development: Always write tests before shipping features
- Write tests that validate both expected behavior and edge cases
- When fixing bugs, first write a test that reproduces the issue
- Run tests frequently during development to catch regressions
- Code complexity management:
- Break down complex methods into smaller, focused helpers with clear responsibilities
- Use meaningful method names that describe what the method does, not how it does it
- Add clear comments about the purpose and behavior of complex code
- Extract state machine logic into clearly defined handlers for each state
- Aim for methods that can be understood without scrolling
- Error handling philosophy: Prefer clean failures over unpredictable recovery attempts
- Log errors clearly and completely before failing
- Do not attempt to "fix" malformed data that could lead to unexpected behavior
- If recovery is necessary, implement it as a well-tested, dedicated fix rather than ad-hoc patches
- Run tests before committing:
pytest tests/ - Run specific test categories:
pytest tests/unit/orpytest tests/integration/ - Add tests for new functionality in the appropriate directory
- Use fixture factories to keep tests maintainable
- Test both happy path and error conditions
- Keep tests independent (no dependencies between test functions)
Codev provides three CLI tools:
- codev: Project management (init, adopt, update, doctor)
- af: Agent Farm orchestration (start, spawn, status, cleanup)
- consult: AI consultation for reviews (pr, spec, plan)
For complete reference, see codev/resources/commands/:
codev/resources/commands/overview.md- Quick startcodev/resources/commands/codev.md- Project commandscodev/resources/commands/agent-farm.md- Agent Farm commandscodev/resources/commands/consult.md- Consultation commands
Agent Farm is configured via af-config.json at the project root. Created during codev init or codev adopt. Override via CLI flags: --architect-cmd, --builder-cmd, --shell-cmd.
{
"shell": {
"architect": "claude",
"builder": "claude",
"shell": "bash"
}
}Read the full protocol documentation in codev/protocols/.