mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added full support for the Bot API 9.6 (#1792)
* Added full support for the Bot API 9.6 * Add support for `managed_bot` updates * Set `description_parse_mode` default to `"parse_mode"` and use `DateTime` for `addition_date` in `PollOption` * Update changelog with features and changes from Bot API 9.6 * Add changelog fragment generator and update poll parameter descriptions
This commit is contained in:
parent
00c1130938
commit
9f49c0413f
107 changed files with 3077 additions and 328 deletions
2
.serena/.gitignore
vendored
Normal file
2
.serena/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/cache
|
||||
/project.local.yml
|
||||
42
.serena/memories/code_style.md
Normal file
42
.serena/memories/code_style.md
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# Code Style & Conventions
|
||||
|
||||
## General
|
||||
- `from __future__ import annotations` at the top of every Python file
|
||||
- Full type hints on all function signatures and class fields
|
||||
- Max line length: **99** characters (ruff enforced)
|
||||
- snake_case for Python names; camelCase used only in `__api_method__` strings
|
||||
|
||||
## Pydantic models
|
||||
- All Telegram types extend `TelegramObject(BotContextController, BaseModel)` from `aiogram/types/base.py`
|
||||
- `TelegramObject` is frozen; use `MutableTelegramObject` when mutation is needed
|
||||
- Fields default to `None` for optional API parameters; use `Field(None, json_schema_extra={"deprecated": True})` for deprecated fields
|
||||
- Use `Default("key")` sentinel (from `aiogram.client.default`) for user-configurable defaults like `parse_mode`, `protect_content`
|
||||
- `TYPE_CHECKING` guards for circular imports — keep runtime imports lean
|
||||
|
||||
## API Methods
|
||||
- Each method is a class inheriting `TelegramMethod[ReturnType]` from `aiogram/methods/base.py`
|
||||
- Required class attrs: `__returning__` (return type), `__api_method__` (camelCase string)
|
||||
- Fields with `None` default = optional param
|
||||
- Method docstring format: short description + `Source: https://core.telegram.org/bots/api#methodname`
|
||||
- File name: snake_case of method name (e.g., `SendMessage` → `send_message.py`)
|
||||
|
||||
## Imports order (ruff/isort enforced)
|
||||
1. stdlib
|
||||
2. third-party
|
||||
3. `aiogram` (first-party)
|
||||
4. relative imports
|
||||
|
||||
## Ruff rules enforced
|
||||
- A (annotations), B (bugbear), C4 (comprehensions), DTZ (datetimez), E, F, I (isort), PERF, PL (pylint), Q (quotes), RET, SIM, T10, T20, UP (pyupgrade)
|
||||
- Several PLR rules disabled (Telegram API naturally has many params/methods)
|
||||
- `F401` disabled (re-exports in `__init__.py` intentional)
|
||||
|
||||
## Code generation convention
|
||||
- **Never hand-edit generated files** (`.butcher/**/entity.json`, auto-generated `aiogram/types/*.py`, `aiogram/methods/*.py`, `aiogram/enums/*.py`)
|
||||
- Add features via `.butcher` YAML config/aliases + templates, then regenerate
|
||||
- After codegen: always run lint + mypy
|
||||
|
||||
## Naming patterns
|
||||
- Enums: PascalCase class, UPPER_SNAKE members (e.g., `ContentType.TEXT`)
|
||||
- Test files: `test_<module_name>.py`
|
||||
- Test classes: `Test<ClassName>` with `async def test_<scenario>(self, bot: MockedBot)`
|
||||
84
.serena/memories/codebase_structure.md
Normal file
84
.serena/memories/codebase_structure.md
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# Codebase Structure
|
||||
|
||||
## Top-level layout
|
||||
```
|
||||
aiogram/ # Main package
|
||||
.butcher/ # Code generation inputs (DO NOT edit entity.json files)
|
||||
tests/ # Test suite
|
||||
docs/ # Sphinx documentation (RST)
|
||||
examples/ # Example bot scripts
|
||||
scripts/ # Version bump scripts
|
||||
CHANGES/ # Towncrier changelog fragments (CHANGES/<issue>.<category>.rst)
|
||||
```
|
||||
|
||||
## aiogram/ package
|
||||
```
|
||||
aiogram/
|
||||
├── __init__.py # Public API re-exports
|
||||
├── __meta__.py # Version (hatch reads this)
|
||||
├── exceptions.py # Framework exceptions
|
||||
├── loggers.py # Named loggers
|
||||
├── client/
|
||||
│ ├── bot.py # Bot class — all API methods as async shortcuts
|
||||
│ ├── session/ # HTTP session backends (aiohttp, base)
|
||||
│ ├── default.py # Default() sentinel for configurable defaults
|
||||
│ └── context_controller.py # Bot context injection into models
|
||||
├── types/
|
||||
│ ├── base.py # TelegramObject (Pydantic BaseModel), MutableTelegramObject
|
||||
│ ├── *.py # One file per Telegram type
|
||||
│ └── __init__.py # Exports all types
|
||||
├── methods/
|
||||
│ ├── base.py # TelegramMethod[T] base class
|
||||
│ ├── *.py # One file per API method (e.g., send_message.py → SendMessage)
|
||||
│ └── __init__.py
|
||||
├── enums/
|
||||
│ ├── content_type.py # ContentType enum
|
||||
│ ├── update_type.py # UpdateType enum
|
||||
│ └── *.py
|
||||
├── dispatcher/
|
||||
│ ├── dispatcher.py # Dispatcher (main update processor)
|
||||
│ ├── router.py # Router (Blueprint-style routing)
|
||||
│ ├── middlewares/ # Middleware system
|
||||
│ ├── event/ # Event observer, typed decorators
|
||||
│ └── flags/ # Handler flags
|
||||
├── filters/ # Built-in filters (Command, StateFilter, etc.)
|
||||
├── fsm/
|
||||
│ ├── context.py # FSMContext
|
||||
│ ├── state.py # State, StatesGroup
|
||||
│ └── storage/ # Memory, Redis, MongoDB storage backends
|
||||
├── handlers/ # Base handler types
|
||||
├── utils/
|
||||
│ ├── keyboard.py # Keyboard builder utilities
|
||||
│ ├── text_decorations.py # HTML/Markdown formatting
|
||||
│ └── i18n/ # Internationalization support
|
||||
└── webhook/ # Webhook integrations (aiohttp, SimpleRequestHandler, etc.)
|
||||
```
|
||||
|
||||
## .butcher/ (Code generation)
|
||||
```
|
||||
.butcher/
|
||||
├── schema/schema.json # Full Bot API schema (source of truth)
|
||||
├── types/ # Per-type entity.json + optional alias YAML overrides
|
||||
├── methods/ # Per-method entity.json + optional alias YAML overrides
|
||||
├── enums/ # Per-enum entity.json + optional YAML overrides
|
||||
└── templates/ # Jinja2 templates for generated Python files
|
||||
```
|
||||
|
||||
**Rule**: Edit `.yml` alias files or templates in `.butcher/`, never `.entity.json` files directly. Regenerate after changes.
|
||||
|
||||
## tests/ layout
|
||||
```
|
||||
tests/
|
||||
├── conftest.py # Shared fixtures (bot, dispatcher, etc.)
|
||||
├── mocked_bot.py # MockedBot for testing without real HTTP
|
||||
├── test_api/
|
||||
│ ├── test_types/ # Tests for Telegram types
|
||||
│ ├── test_methods/ # Tests for API method classes
|
||||
│ └── test_client/ # HTTP client tests
|
||||
├── test_dispatcher/ # Dispatcher/Router/Middleware tests
|
||||
├── test_filters/ # Filter tests
|
||||
├── test_fsm/ # FSM and storage tests
|
||||
├── test_handler/ # Handler tests
|
||||
├── test_utils/ # Utility tests
|
||||
└── test_webhook/ # Webhook integration tests
|
||||
```
|
||||
44
.serena/memories/codegen_workflow.md
Normal file
44
.serena/memories/codegen_workflow.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Bot API Codegen Workflow
|
||||
|
||||
## How code generation works
|
||||
aiogram uses `butcher` (via `aiogram-cli`) to auto-generate Python files from the Telegram Bot API schema.
|
||||
|
||||
### Source of truth
|
||||
- `.butcher/schema/schema.json` — full parsed Bot API schema
|
||||
- `.butcher/types/<TypeName>/entity.json` — parsed entity metadata (DO NOT edit)
|
||||
- `.butcher/methods/<MethodName>/entity.json` — parsed method metadata (DO NOT edit)
|
||||
- `.butcher/enums/<EnumName>/entity.json` — parsed enum metadata (DO NOT edit)
|
||||
- `.butcher/templates/` — Jinja2 templates that produce Python code
|
||||
- YAML alias/override files in `.butcher/types/`, `.butcher/methods/` — edit these for customizations
|
||||
|
||||
### Generated files (DO NOT hand-edit)
|
||||
- `aiogram/types/*.py` (except `base.py`, `custom.py`, `_union.py` — framework internals)
|
||||
- `aiogram/methods/*.py` (except `base.py`)
|
||||
- `aiogram/enums/*.py`
|
||||
- `aiogram/client/bot.py` (the `Bot` class shortcuts)
|
||||
- `aiogram/types/__init__.py`, `aiogram/methods/__init__.py`
|
||||
|
||||
### Regeneration commands
|
||||
```bash
|
||||
uv run --extra cli butcher parse # re-parse from API schema
|
||||
uv run --extra cli butcher refresh # refresh entity JSON from parsed schema
|
||||
uv run --extra cli butcher apply all # apply templates → generate Python files
|
||||
```
|
||||
|
||||
### Adding a new type/method/shortcut
|
||||
1. Update the `.butcher` YAML alias/config file for the entity
|
||||
2. Run regeneration (parse → refresh → apply)
|
||||
3. Run lint + mypy + tests
|
||||
4. Commit both the `.butcher` config changes AND the generated Python files
|
||||
|
||||
### API version bumps (maintainers)
|
||||
```bash
|
||||
make update-api args=patch # or minor/major
|
||||
```
|
||||
This runs butcher parse/refresh/apply + version bump scripts that update:
|
||||
- `aiogram/__meta__.py`
|
||||
- `README.rst`
|
||||
- `docs/index.rst`
|
||||
|
||||
## Key constraint
|
||||
The maintainers enforce: **never add types/methods/shortcuts by hand-editing generated files**. All changes must go through `.butcher` config so future regenerations preserve them.
|
||||
43
.serena/memories/dispatcher/adding_new_event_types.md
Normal file
43
.serena/memories/dispatcher/adding_new_event_types.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Adding a New Update/Event Type to aiogram Dispatcher
|
||||
|
||||
When Telegram Bot API adds a new update type (e.g. `managed_bot`, `purchased_paid_media`), the following files must be touched. Types, enums, and butcher configs are generated — the dispatcher integration is manual.
|
||||
|
||||
## Checklist (in order)
|
||||
|
||||
### Generated / butcher layer (run `butcher parse && butcher refresh && butcher apply all`)
|
||||
- `.butcher/types/<TypeName>/entity.json` — type definition
|
||||
- `.butcher/types/Update/entity.json` — add field to Update entity
|
||||
- `aiogram/types/<type_name>.py` — generated type class
|
||||
- `aiogram/types/__init__.py` — export
|
||||
- `aiogram/enums/update_type.py` — `NEW_TYPE = "new_type"` enum member
|
||||
- `aiogram/types/update.py` — `new_type: NewType | None = None` field + TYPE_CHECKING import + `__init__` signature
|
||||
|
||||
### Manual dispatcher integration (NOT generated)
|
||||
|
||||
1. **`aiogram/types/update.py`** — `event_type` property (lines ~161-215): add `if self.new_type: return "new_type"` before the `raise UpdateTypeLookupError` line
|
||||
|
||||
2. **`aiogram/dispatcher/router.py`** — two places in `Router.__init__`:
|
||||
- Add `self.new_type = TelegramEventObserver(router=self, event_name="new_type")` after the last observer attribute (before `self.errors`)
|
||||
- Add `"new_type": self.new_type,` to the `self.observers` dict (before `"error"`)
|
||||
|
||||
3. **`aiogram/dispatcher/middlewares/user_context.py`** — `resolve_event_context()` method: add `if event.new_type: return EventContext(user=..., chat=...)` before `return EventContext()`. Use `user` field for user-scoped events, `chat` for chat-scoped. No `business_connection_id` unless the event has one.
|
||||
|
||||
### Tests (manual)
|
||||
|
||||
4. **`tests/test_dispatcher/test_dispatcher.py`** — add `pytest.param("new_type", Update(update_id=42, new_type=NewType(...)), has_chat, has_user)` to `test_listen_update` parametrize list. Import `NewType` in the imports block.
|
||||
|
||||
5. **`tests/test_dispatcher/test_router.py`** — add `assert router.observers["new_type"] == router.new_type` to `test_observers_config`
|
||||
|
||||
### Docs (generated or manual stub)
|
||||
- `docs/api/types/<type_name>.rst` — RST stub
|
||||
- `docs/api/types/index.rst` — add to index
|
||||
|
||||
## Key invariants
|
||||
- The snake_case name must be identical across: `UpdateType` enum value, `Update` field name, `event_type` return string, Router attribute name, observers dict key, and `TelegramEventObserver(event_name=...)`.
|
||||
- `Update.event_type` uses `@lru_cache()` — never mutate Update fields after construction.
|
||||
- The routing machinery (`propagate_event`, middleware chains, sub-router propagation) requires **zero changes** — it operates on observer names looked up dynamically.
|
||||
|
||||
## Example: `managed_bot` (API 9.6)
|
||||
- Type: `ManagedBotUpdated` with fields `user: User` (creator) and `bot_user: User` (the managed bot)
|
||||
- user_context: `EventContext(user=event.managed_bot.user)` — user only, no chat
|
||||
- `has_chat=False, has_user=True` in test parametrization
|
||||
43
.serena/memories/project_overview.md
Normal file
43
.serena/memories/project_overview.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Project Overview: aiogram
|
||||
|
||||
## Purpose
|
||||
**aiogram** is a modern, fully asynchronous Python framework for the Telegram Bot API (currently supports Bot API 9.5+). It provides a high-level interface for building Telegram bots using asyncio.
|
||||
|
||||
## Tech Stack
|
||||
- **Python**: 3.10–3.14 (also supports PyPy)
|
||||
- **Async runtime**: asyncio + aiohttp (HTTP client)
|
||||
- **Data validation**: Pydantic v2
|
||||
- **Package manager**: `uv`
|
||||
- **Linter/formatter**: `ruff` (check + format)
|
||||
- **Type checker**: `mypy`
|
||||
- **Testing**: `pytest` with `pytest-asyncio`, `aresponses`
|
||||
- **Docs**: Sphinx (reStructuredText), `sphinx-autobuild`
|
||||
- **Changelog**: `towncrier`
|
||||
- **Code generation**: `butcher` (aiogram-cli) — generates types, methods, enums from Bot API schema
|
||||
|
||||
## Key Links
|
||||
- Docs (English): https://docs.aiogram.dev/en/dev-3.x/
|
||||
- GitHub: https://github.com/aiogram/aiogram/
|
||||
- Bot API schema: `.butcher/schema/schema.json`
|
||||
|
||||
## Architecture Summary
|
||||
The framework is layered:
|
||||
1. **`aiogram/client/`** — `Bot` class (all API methods as shortcuts), session management, context controller
|
||||
2. **`aiogram/types/`** — Pydantic models for all Telegram types (`TelegramObject` base)
|
||||
3. **`aiogram/methods/`** — `TelegramMethod[ReturnType]` subclasses, one per Bot API method
|
||||
4. **`aiogram/dispatcher/`** — Dispatcher, Router (blueprints), middleware, event observers
|
||||
5. **`aiogram/filters/`** — Filter classes for routing
|
||||
6. **`aiogram/fsm/`** — Finite State Machine (states, storage backends)
|
||||
7. **`aiogram/enums/`** — Enumerations (ContentType, UpdateType, etc.)
|
||||
8. **`aiogram/utils/`** — Text decoration, keyboards, i18n, etc.
|
||||
9. **`aiogram/webhook/`** — Webhook server integrations (aiohttp, FastAPI, etc.)
|
||||
10. **`.butcher/`** — Code generation inputs: YAML/JSON configs for types/methods/enums + Jinja2 templates
|
||||
|
||||
## Optional extras
|
||||
- `fast` — uvloop + aiodns
|
||||
- `redis` — Redis FSM storage
|
||||
- `mongo` — MongoDB FSM storage
|
||||
- `proxy` — SOCKS proxy support
|
||||
- `i18n` — Babel-based i18n
|
||||
- `cli` — `butcher` codegen CLI
|
||||
- `signature` — cryptographic signature verification
|
||||
66
.serena/memories/suggested_commands.md
Normal file
66
.serena/memories/suggested_commands.md
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# Suggested Commands
|
||||
|
||||
## Setup
|
||||
```bash
|
||||
uv sync --all-extras --group dev --group test
|
||||
uv run pre-commit install
|
||||
```
|
||||
|
||||
## Lint & Format (quick loop — use before every commit)
|
||||
```bash
|
||||
uv run ruff check --show-fixes --preview aiogram examples
|
||||
uv run ruff format --check --diff aiogram tests scripts examples
|
||||
uv run mypy aiogram
|
||||
```
|
||||
|
||||
## Auto-fix formatting
|
||||
```bash
|
||||
uv run ruff format aiogram tests scripts examples
|
||||
uv run ruff check --fix aiogram tests scripts examples
|
||||
```
|
||||
|
||||
## Run tests
|
||||
```bash
|
||||
uv run pytest tests # basic
|
||||
uv run pytest tests --redis redis://localhost:6379/0 # with Redis
|
||||
uv run pytest tests --mongo mongodb://mongo:mongo@localhost:27017 # with MongoDB
|
||||
```
|
||||
|
||||
## Build docs
|
||||
```bash
|
||||
# Live-reload dev server
|
||||
uv run --extra docs sphinx-autobuild --watch aiogram/ --watch CHANGES.rst --watch README.rst docs/ docs/_build/
|
||||
# One-shot build
|
||||
uv run --extra docs bash -c 'cd docs && make html'
|
||||
```
|
||||
|
||||
## Code generation (Bot API codegen)
|
||||
```bash
|
||||
# After editing .butcher/*.yml or templates:
|
||||
uv run --extra cli butcher parse
|
||||
uv run --extra cli butcher refresh
|
||||
uv run --extra cli butcher apply all
|
||||
```
|
||||
|
||||
## API version bump (maintainers only)
|
||||
```bash
|
||||
make update-api args=patch # runs butcher parse/refresh/apply + version bump
|
||||
```
|
||||
|
||||
## Changelog
|
||||
```bash
|
||||
# Preview draft
|
||||
uv run --extra docs towncrier build --draft
|
||||
# Build final
|
||||
uv run --extra docs towncrier build --yes
|
||||
```
|
||||
|
||||
## Clean build artifacts
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
## Build package
|
||||
```bash
|
||||
uv build
|
||||
```
|
||||
43
.serena/memories/task_completion.md
Normal file
43
.serena/memories/task_completion.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Task Completion Checklist
|
||||
|
||||
Run these before marking any task done or requesting review.
|
||||
|
||||
## Quick loop (every PR)
|
||||
```bash
|
||||
uv run ruff check --show-fixes --preview aiogram examples
|
||||
uv run ruff format --check --diff aiogram tests scripts examples
|
||||
uv run mypy aiogram
|
||||
uv run pytest tests
|
||||
```
|
||||
|
||||
## Codegen tasks (when touching .butcher/ or generated API files)
|
||||
```bash
|
||||
uv run --extra cli butcher parse
|
||||
uv run --extra cli butcher refresh
|
||||
uv run --extra cli butcher apply all
|
||||
# Then re-run quick loop
|
||||
```
|
||||
|
||||
## Integration tests (only if Redis/Mongo storage touched)
|
||||
```bash
|
||||
uv run pytest --redis redis://localhost:6379/0 tests
|
||||
uv run pytest --mongo mongodb://mongo:mongo@localhost:27017 tests
|
||||
```
|
||||
|
||||
## Docs (only if docs/ or public API changed)
|
||||
```bash
|
||||
uv run --extra docs bash -c 'cd docs && make html'
|
||||
```
|
||||
|
||||
## Changelog fragment (required unless PR has `skip news` label)
|
||||
- Create `CHANGES/<issue-or-pr-number>.<category>.rst`
|
||||
- Valid categories: `feature`, `bugfix`, `doc`, `removal`, `misc`
|
||||
- Content: user-visible behavior description (not internal/process details)
|
||||
- Do NOT edit `CHANGES.rst` directly
|
||||
|
||||
## PR quality checklist
|
||||
1. Tests added/updated for all behavior changes
|
||||
2. Quick loop passes (ruff + mypy + pytest)
|
||||
3. Changelog fragment added (or justified `skip news`)
|
||||
4. If codegen-related: both `.butcher` source config AND generated files updated
|
||||
5. PR body has clear reproduction/validation steps
|
||||
45
.serena/memories/testing_patterns.md
Normal file
45
.serena/memories/testing_patterns.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Testing Patterns
|
||||
|
||||
## Framework
|
||||
- pytest with async support
|
||||
- No `pytest-asyncio` explicit marks needed (configured globally in pyproject.toml)
|
||||
- `MockedBot` (tests/mocked_bot.py) — use for all bot method tests, no real HTTP
|
||||
|
||||
## MockedBot pattern
|
||||
```python
|
||||
from tests.mocked_bot import MockedBot
|
||||
from aiogram.methods import SendMessage
|
||||
from aiogram.types import Message, Chat
|
||||
import datetime
|
||||
|
||||
class TestSendMessage:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendMessage,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
text="test",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
response: Message = await bot.send_message(chat_id=42, text="test")
|
||||
bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
```
|
||||
|
||||
## Test structure
|
||||
- Class per type/method: `class TestSendMessage:`
|
||||
- One test per scenario: `async def test_<scenario>(self, ...)`
|
||||
- `bot` fixture comes from `tests/conftest.py`
|
||||
|
||||
## Integration tests
|
||||
- Redis: `uv run pytest --redis redis://localhost:6379/0 tests`
|
||||
- MongoDB: `uv run pytest --mongo mongodb://mongo:mongo@localhost:27017 tests`
|
||||
- Only run these when Redis/Mongo storage code is affected
|
||||
|
||||
## What NOT to do
|
||||
- Do not mock the database/storage in FSM tests — use real backends or memory storage
|
||||
- Do not introduce new test dependencies for small tests
|
||||
- Keep test style consistent with existing suite
|
||||
152
.serena/project.yml
Normal file
152
.serena/project.yml
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
# the name by which the project can be referenced within Serena
|
||||
project_name: "aiogram3"
|
||||
|
||||
|
||||
# list of languages for which language servers are started; choose from:
|
||||
# al bash clojure cpp csharp
|
||||
# csharp_omnisharp dart elixir elm erlang
|
||||
# fortran fsharp go groovy haskell
|
||||
# java julia kotlin lua markdown
|
||||
# matlab nix pascal perl php
|
||||
# php_phpactor powershell python python_jedi r
|
||||
# rego ruby ruby_solargraph rust scala
|
||||
# swift terraform toml typescript typescript_vts
|
||||
# vue yaml zig
|
||||
# (This list may be outdated. For the current list, see values of Language enum here:
|
||||
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
|
||||
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
|
||||
# Note:
|
||||
# - For C, use cpp
|
||||
# - For JavaScript, use typescript
|
||||
# - For Free Pascal/Lazarus, use pascal
|
||||
# Special requirements:
|
||||
# Some languages require additional setup/installations.
|
||||
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
|
||||
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
||||
# The first language is the default language and the respective language server will be used as a fallback.
|
||||
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
||||
languages:
|
||||
- python
|
||||
|
||||
# the encoding used by text files in the project
|
||||
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
||||
encoding: "utf-8"
|
||||
|
||||
# line ending convention to use when writing source files.
|
||||
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
||||
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
||||
line_ending:
|
||||
|
||||
# The language backend to use for this project.
|
||||
# If not set, the global setting from serena_config.yml is used.
|
||||
# Valid values: LSP, JetBrains
|
||||
# Note: the backend is fixed at startup. If a project with a different backend
|
||||
# is activated post-init, an error will be returned.
|
||||
language_backend:
|
||||
|
||||
# whether to use project's .gitignore files to ignore files
|
||||
ignore_all_files_in_gitignore: true
|
||||
|
||||
# advanced configuration option allowing to configure language server-specific options.
|
||||
# Maps the language key to the options.
|
||||
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
|
||||
# No documentation on options means no options are available.
|
||||
ls_specific_settings: {}
|
||||
|
||||
# list of additional paths to ignore in this project.
|
||||
# Same syntax as gitignore, so you can use * and **.
|
||||
# Note: global ignored_paths from serena_config.yml are also applied additively.
|
||||
ignored_paths: []
|
||||
|
||||
# whether the project is in read-only mode
|
||||
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||
# Added on 2025-04-18
|
||||
read_only: false
|
||||
|
||||
# list of tool names to exclude.
|
||||
# This extends the existing exclusions (e.g. from the global configuration)
|
||||
#
|
||||
# Below is the complete list of tools for convenience.
|
||||
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||
# execute `uv run scripts/print_tool_overview.py`.
|
||||
#
|
||||
# * `activate_project`: Activates a project by name.
|
||||
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||
# * `delete_lines`: Deletes a range of lines within a file.
|
||||
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
||||
# * `execute_shell_command`: Executes a shell command.
|
||||
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
||||
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
||||
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
||||
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||
# * `initial_instructions`: Gets the initial instructions for the current project.
|
||||
# Should only be used in settings where the system prompt cannot be set,
|
||||
# e.g. in clients you have no control over, like Claude Desktop.
|
||||
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||
# * `insert_at_line`: Inserts content at a given line in a file.
|
||||
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
||||
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
||||
# * `read_file`: Reads a file within the project directory.
|
||||
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
||||
# * `remove_project`: Removes a project from the Serena configuration.
|
||||
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
||||
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
||||
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
||||
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
||||
# * `switch_modes`: Activates modes by providing a list of their names
|
||||
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
||||
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||
excluded_tools: []
|
||||
|
||||
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default).
|
||||
# This extends the existing inclusions (e.g. from the global configuration).
|
||||
included_optional_tools: []
|
||||
|
||||
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
|
||||
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
|
||||
fixed_tools: []
|
||||
|
||||
# list of mode names to that are always to be included in the set of active modes
|
||||
# The full set of modes to be activated is base_modes + default_modes.
|
||||
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
|
||||
# Otherwise, this setting overrides the global configuration.
|
||||
# Set this to [] to disable base modes for this project.
|
||||
# Set this to a list of mode names to always include the respective modes for this project.
|
||||
base_modes:
|
||||
|
||||
# list of mode names that are to be activated by default.
|
||||
# The full set of modes to be activated is base_modes + default_modes.
|
||||
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
|
||||
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
|
||||
# This setting can, in turn, be overridden by CLI parameters (--mode).
|
||||
default_modes:
|
||||
|
||||
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||
# (contrary to the memories, which are loaded on demand).
|
||||
initial_prompt: ""
|
||||
|
||||
# time budget (seconds) per tool call for the retrieval of additional symbol information
|
||||
# such as docstrings or parameter information.
|
||||
# This overrides the corresponding setting in the global configuration; see the documentation there.
|
||||
# If null or missing, use the setting from the global configuration.
|
||||
symbol_info_budget:
|
||||
|
||||
# list of regex patterns which, when matched, mark a memory entry as read‑only.
|
||||
# Extends the list from the global configuration, merging the two lists.
|
||||
read_only_memory_patterns: []
|
||||
|
||||
# list of regex patterns for memories to completely ignore.
|
||||
# Matching memories will not appear in list_memories or activate_project output
|
||||
# and cannot be accessed via read_memory or write_memory.
|
||||
# To access ignored memory files, use the read_file tool on the raw file path.
|
||||
# Extends the list from the global configuration, merging the two lists.
|
||||
# Example: ["_archive/.*", "_episodes/.*"]
|
||||
ignored_memory_patterns: []
|
||||
Loading…
Add table
Add a link
Reference in a new issue