Stability release after v1.3.0 covering safer RAG/KB routing, stronger
embedding validation, more reliable Docker/TutorBot restarts, Web UX
fixes, and Windows/encoding hardening. See assets/releases/ver1-3-1.md
for the full notes.
Made-with: Cursor
Two independent issues that block `python scripts/start_web.py` after a
clean install on Windows:
1. UnicodeDecodeError when streaming subprocess output
`_spawn()` opened the backend / frontend stdout pipe with `text=True`
but no explicit encoding. On Windows this defaults to the system
ANSI codepage (e.g. `gbk` on Chinese Windows), which raises
`UnicodeDecodeError` as soon as the child process emits a UTF-8 byte.
Fix: pin `encoding="utf-8"` and `errors="replace"` so any locale
produces clean, lossless output.
2. Missing runtime dependencies in requirements/server.txt
`deeptutor/services/llm/provider_core/__init__.py` unconditionally
imports `AnthropicProvider`, `OpenAICompatProvider`, and
`OpenAIResponses`, which in turn import:
- `loguru` (provider_core/base.py, openai_codex_provider.py,
openai_responses/parsing.py)
- `json_repair` (anthropic_provider.py, openai_compat_provider.py,
openai_responses/parsing.py)
These are declared only in `requirements/tutorbot.txt`, so
`pip install -r requirements/server.txt && pip install -e .` followed
by `python scripts/start_web.py` crashes with `ModuleNotFoundError`
before the API server can serve a single request.
Fix: declare both packages in `server.txt` with the same version
bounds used by `tutorbot.txt`.
Reproduced and verified on Windows 11 + Python 3.12 + a fresh venv.
On Windows, npm is installed as npm.cmd rather than a plain executable.
subprocess.run(['npm', '--version']) without shell=True raises
FileNotFoundError, causing the Node.js detection step to always report
npm as missing even when it is properly installed.
Reuse the existing _get_npm_command() helper (which already returns
npm.cmd on Windows) for the version-detection call, consistent with
how npm is invoked later during npm install.
uv-managed .venv environments may have pip disabled (PEP 668 / uv's
default hardening). Running `python -m pip install` inside such a venv
raises a CalledProcessError even though uv itself is available.
Introduce `_resolve_pip_cmd()` which checks `shutil.which("uv")` at startup:
- uv found → use ["uv", "pip"] (uv auto-detects the active venv)
- uv absent → fall back to [_PYTHON, "-m", "pip"] (no regression)
All pip invocations in `_bootstrap()` and `_install_commands()` now use
`_PIP_CMD` instead of the hard-coded `[_PYTHON, "-m", "pip"]` prefix.
On macOS with Homebrew Python, `Path(sys.executable).resolve()` follows
the venv symlink back to the system interpreter. PEP 668 then blocks
pip installs with "externally-managed-environment", causing the setup
tour to fail.
Swap the check order so the unresolved venv path is preferred when it
exists, falling back to the resolved path only when necessary.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add _get_npm_command() helper to resolve npm path on Windows
- Use shell=True in _run_cmd() on Windows to support .cmd files
- Fix FileNotFoundError when running npm install on Windows
This fixes the issue where shutil.which('npm') fails to find npm.cmd
on Windows, causing the setup tour to fail during dependency installation.