refactor: address high-priority debt and publish to PyPI

- Fix TOCTOU race conditions by wrapping read-modify-write cycles
  under single-file locks in execution_state, portfolio_service,
  precheck_state, state_manager, and precheck_service.
- Add missing test coverage (96 tests total):
  - test_review_service.py (15 tests)
  - test_check_api.py (6 tests)
  - test_external_gate.py main branches (+10 tests)
  - test_trade_execution.py new commands (+8 tests)
- Unify all agent-consumed JSON messages to English.
- Config-ize hardcoded values (volume filter, schema_version) via
  get_user_config with sensible defaults.
- Add 1-hour TTL to exchange cache with force_new override.
- Add ruff and mypy to dev dependencies; fix all type errors.
- Add __all__ declarations to 11 service modules.
- Sync README with new commands, config tuning docs, and PyPI badge.
- Publish package as coinhunter==1.0.0 on PyPI with MIT license.
- Deprecate coinhunter-cli==1.0.1 with runtime warning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-16 01:21:27 +08:00
parent 01bb54dee5
commit 62c40a9776
53 changed files with 2338 additions and 671 deletions

View File

@@ -1,10 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
APP_HOME="${COINHUNTER_APP_HOME:-$HOME/.local/share/coinhunter-cli}"
VENV_DIR="$APP_HOME/venv"
# Standard local install using pip editable mode.
# This creates the 'coinhunter' console script entry point as defined in pyproject.toml.
BIN_DIR="${COINHUNTER_BIN_DIR:-$HOME/.local/bin}"
LAUNCHER="$BIN_DIR/coinhunter"
PYTHON_BIN="${PYTHON:-}"
if [[ -z "$PYTHON_BIN" ]]; then
@@ -18,18 +18,13 @@ if [[ -z "$PYTHON_BIN" ]]; then
fi
fi
mkdir -p "$APP_HOME" "$BIN_DIR"
mkdir -p "$BIN_DIR"
"$PYTHON_BIN" -m venv "$VENV_DIR"
"$VENV_DIR/bin/python" -m pip install --upgrade pip setuptools wheel
"$VENV_DIR/bin/python" -m pip install --upgrade "$(pwd)"
"$PYTHON_BIN" -m pip install --upgrade pip setuptools wheel
"$PYTHON_BIN" -m pip install --upgrade -e "$(pwd)[dev]"
cat >"$LAUNCHER" <<EOF
#!/usr/bin/env bash
exec "$VENV_DIR/bin/coinhunter" "\$@"
EOF
chmod +x "$LAUNCHER"
echo "Installed coinhunter into:"
echo " venv: $VENV_DIR"
echo " launcher: $LAUNCHER"
echo "Installed coinhunter in editable mode."
echo " python: $PYTHON_BIN"
echo " entrypoint: $(command -v coinhunter || echo 'not in PATH')"
echo ""
echo "Make sure '$BIN_DIR' is in your PATH if the entrypoint is not found."