Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-06-03 11:13:26 +08:00
parent 9820834175
commit c76c8d47d1
4 changed files with 579 additions and 27 deletions

View File

@ -66,22 +66,22 @@ The project uses Python 3.10+.
Common setup:
```bash
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e ".[dev]"
uv sync --extra dev
```
If `uv` is available, it is also reasonable to use:
If `uv` is not installed on a fresh server:
```bash
uv run --extra dev pytest -q
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv sync --extra dev
```
In sandboxed environments, `uv` may need a writable cache directory:
```bash
uv --cache-dir /private/tmp/uv-cache run --extra dev pytest -q
uv --cache-dir /private/tmp/uv-cache sync --extra dev
uv --cache-dir /private/tmp/uv-cache run pytest -q
```
## Running The Server
@ -95,7 +95,7 @@ cp config.example.yaml config.yaml
Start OpenViking and EverOS first, then run:
```bash
python -m memory_system_api.server --config config.yaml --host 0.0.0.0 --port 1934
uv run memory-gateway --config config.yaml --host 0.0.0.0 --port 1934
```
The default Memory System base URL is:
@ -109,27 +109,27 @@ http://127.0.0.1:1934/memory-system
Run focused tests for touched areas whenever possible:
```bash
pytest -q tests/test_memory_system_clients.py
pytest -q tests/test_memory_system_service.py
pytest -q tests/test_memory_system_server.py
pytest -q tests/test_memory_system_store.py
pytest -q tests/test_hermes_memory_system_plugin.py
uv run pytest -q tests/test_memory_system_clients.py
uv run pytest -q tests/test_memory_system_service.py
uv run pytest -q tests/test_memory_system_server.py
uv run pytest -q tests/test_memory_system_store.py
uv run pytest -q tests/test_hermes_memory_system_plugin.py
```
Run the full suite before handing off broad changes:
```bash
pytest -q
python -m compileall -q memory_system_api plugins eval tests
uv run pytest -q
uv run python -m compileall -q memory_system_api plugins eval tests
```
If the environment lacks `pytest` and dependencies cannot be installed, at minimum run:
If dependencies cannot be installed, at minimum run:
```bash
.venv/bin/python -m compileall -q memory_system_api plugins eval tests
python3 -m compileall -q memory_system_api plugins eval tests
```
Then report the missing test dependency clearly.
Then report the missing `uv` or test dependency clearly.
## Coding Guidelines