From 3be9d8eeba56017a259133b3f9eb5f2ddfa29d72 Mon Sep 17 00:00:00 2001 From: Jongheon Kim Date: Sun, 8 Feb 2026 13:53:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20serena=20MCP=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/settings.local.json | 9 +- .serena/.gitignore | 1 + .serena/memories/project_overview.md | 40 +++++++ .serena/memories/style_and_conventions.md | 23 ++++ .serena/memories/suggested_commands.md | 43 +++++++ .serena/memories/task_completion_checklist.md | 9 ++ .serena/project.yml | 112 ++++++++++++++++++ 7 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 .serena/.gitignore create mode 100644 .serena/memories/project_overview.md create mode 100644 .serena/memories/style_and_conventions.md create mode 100644 .serena/memories/suggested_commands.md create mode 100644 .serena/memories/task_completion_checklist.md create mode 100644 .serena/project.yml diff --git a/.claude/settings.local.json b/.claude/settings.local.json index c91dafc..b19d834 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -6,9 +6,14 @@ "Bash(git add:*)", "Bash(uv add:*)", "Bash(python test:*)", - "Bash(python:*)" + "Bash(python:*)", + "mcp__serena__list_dir", + "mcp__serena__get_symbols_overview", + "mcp__serena__write_memory", + "mcp__serena__find_symbol", + "mcp__serena__think_about_collected_information" ], "deny": [], "ask": [] } -} \ No newline at end of file +} diff --git a/.serena/.gitignore b/.serena/.gitignore new file mode 100644 index 0000000..14d86ad --- /dev/null +++ b/.serena/.gitignore @@ -0,0 +1 @@ +/cache diff --git a/.serena/memories/project_overview.md b/.serena/memories/project_overview.md new file mode 100644 index 0000000..0554190 --- /dev/null +++ b/.serena/memories/project_overview.md @@ -0,0 +1,40 @@ +# Project Overview: executor + +## Purpose +A Django-based quantitative strategy executor. It provides an API for executing quantitative trading strategies (trend following, mean reversion, volatility breakout, asset allocation) and returning results, with optional callback support. + +## Tech Stack +- **Language**: Python 3.13+ +- **Framework**: Django 5.2.7 +- **Database**: SQLite (default) +- **Dependencies**: django, yfinance (market data), gunicorn (production server), requests (HTTP callbacks) +- **Package Manager**: uv +- **Deployment**: Docker + docker-compose, gunicorn + +## Project Structure +``` +executor/ # Django project config (settings, urls, wsgi, asgi) +strategies/ # Main Django app + models.py # QuantStrategy, StrategyVersion, StrategyExecution + views.py # API views (list_strategies, execute_strategy, execution_status, send_callback) + base.py # BaseQuantStrategy abstract class, StrategyRegistry + implementations.py # Strategy registration + impls/ # Strategy implementations + trend_following.py + mean_reversion.py + volatility_breakout.py + asset_allocation.py + management/commands/ # init_strategies command + urls.py + admin.py +templates/ # Global templates (empty) +staticfiles/ # Collected static files +mediafiles/ # Media files +``` + +## Architecture +- Strategies follow a registry pattern: `BaseQuantStrategy` base class + `StrategyRegistry` for registration +- Strategy implementations live in `strategies/impls/` and register via `@strategy` decorator +- API is function-based views (not DRF), returning JSON +- Execution model tracks strategy runs with status and results +- Callback support for async notification of execution results diff --git a/.serena/memories/style_and_conventions.md b/.serena/memories/style_and_conventions.md new file mode 100644 index 0000000..45a7535 --- /dev/null +++ b/.serena/memories/style_and_conventions.md @@ -0,0 +1,23 @@ +# Code Style and Conventions + +## Python Style +- Standard Python/Django conventions +- No type hints used in existing code +- Minimal docstrings (Django-generated defaults) +- Snake_case for functions/variables, PascalCase for classes +- Single quotes for strings throughout + +## Django Patterns +- Function-based views (not class-based views, not DRF) +- JSON responses via `django.http.JsonResponse` +- Models use `Meta` inner classes for ordering/constraints +- Standard Django project layout + +## Strategy Pattern +- Base class: `BaseQuantStrategy` with abstract methods (`name`, `description`, `version`, `default_parameters`, `execute`) +- Registration via `@strategy` decorator and `StrategyRegistry` +- Implementations in `strategies/impls/` directory + +## Comments +- Korean language used in some comments (Dockerfile, etc.) +- Code comments are sparse diff --git a/.serena/memories/suggested_commands.md b/.serena/memories/suggested_commands.md new file mode 100644 index 0000000..d87e722 --- /dev/null +++ b/.serena/memories/suggested_commands.md @@ -0,0 +1,43 @@ +# Suggested Commands + +## Environment +```bash +source .venv/bin/activate +uv sync # Install/sync dependencies +``` + +## Development +```bash +python manage.py runserver # Run dev server (port 8000) +python manage.py shell # Django interactive shell +python manage.py createsuperuser # Create admin user +``` + +## Database +```bash +python manage.py makemigrations # Create migration files +python manage.py migrate # Apply migrations +python manage.py init_strategies # Initialize strategy data +``` + +## Testing +```bash +python manage.py test # Run Django tests +``` + +## Static Files +```bash +python manage.py collectstatic # Collect static files +``` + +## Docker +```bash +docker-compose up --build # Build and run with Docker +docker-compose down # Stop containers +``` + +## System Utilities (macOS/Darwin) +```bash +git status / git diff / git log # Git operations +ls / find / grep # File operations (prefer tool equivalents) +``` diff --git a/.serena/memories/task_completion_checklist.md b/.serena/memories/task_completion_checklist.md new file mode 100644 index 0000000..b171d5d --- /dev/null +++ b/.serena/memories/task_completion_checklist.md @@ -0,0 +1,9 @@ +# Task Completion Checklist + +After completing a coding task, ensure: + +1. **Migrations**: If models were changed, run `python manage.py makemigrations` and `python manage.py migrate` +2. **Tests**: Run `python manage.py test` to verify nothing is broken +3. **No linter/formatter configured**: The project does not currently have a linter or formatter set up (no ruff, black, flake8, etc. in pyproject.toml) +4. **Static files**: If templates/static files changed, run `python manage.py collectstatic` +5. **Strategy registration**: If a new strategy was added, ensure it's registered in `strategies/implementations.py` and `strategies/impls/__init__.py` diff --git a/.serena/project.yml b/.serena/project.yml new file mode 100644 index 0000000..7c0490d --- /dev/null +++ b/.serena/project.yml @@ -0,0 +1,112 @@ +# the name by which the project can be referenced within Serena +project_name: "executor" + + +# 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 +# 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" + +# whether to use project's .gitignore files to ignore files +ignore_all_files_in_gitignore: true + +# list of additional paths to ignore in all projects +# same syntax as gitignore, so you can use * and ** +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. We recommend not excluding any tools, see the readme for more details. +# 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) +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: ""