Skip to content

feat(doctor): add cleanup check and --dry-run support#66

Merged
SepineTam merged 2 commits intodev/1.16.0from
codex/add-cleanup-check-to-doctor-command
Apr 19, 2026
Merged

feat(doctor): add cleanup check and --dry-run support#66
SepineTam merged 2 commits intodev/1.16.0from
codex/add-cleanup-check-to-doctor-command

Conversation

@SepineTam
Copy link
Copy Markdown
Owner

Motivation

  • Provide a built-in cleanup for old timestamp-prefixed files under the project stata-mcp-folder to avoid accumulation of legacy logs/tmp/do files.
  • Make cleanup configurable via project/env (CLEAN_LOG_DAYS) and safe to preview with a --dry-run option.

Description

  • Add src/stata_mcp/utils/clean_log.py implementing scan_old_files() and clean_log_files() with support for 14-digit (%Y%m%d%H%M%S) and 20-digit (%Y%m%d%H%M%S%f) leading timestamps, non-recursive scanning, dry-run reporting, and per-file error accounting.
  • Add Config.CLEAN_LOG_DAYS in src/stata_mcp/config.py that reads STATA_MCP__CLEAN_LOG_DAYS / config file / default -1 using existing _get_config_value semantics.
  • Extend CLI in src/stata_mcp/cli/_parsers.py to accept --dry-run for the doctor subcommand and forward the flag through src/stata_mcp/cli/_handlers.py into run_doctor.
  • Implement check_cleanup() in src/stata_mcp/utils/doctor.py, add _format_size() helper, register cleanup in AVAILABLE_CHECKS, and propagate dry_run through _all_checks() and run_doctor() to control scan vs delete behavior and reporting.

Testing

  • Ran the test suite with PYTHONPATH=src pytest -q and all tests passed locally (10 passed, several warnings unrelated to changes).
  • Verified code compiles with PYTHONPATH=src python -m compileall -q src with no errors.
  • Exercised the new cleanup paths via unit test iterations during development (scan + dry-run + deletion flows) and the doctor flow was confirmed to forward --dry-run correctly.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 19, 2026

Deploying stata-mcp with  Cloudflare Pages  Cloudflare Pages

Latest commit: c82251c
Status: ✅  Deploy successful!
Preview URL: https://8be31252.stata-mcp.pages.dev
Branch Preview URL: https://codex-add-cleanup-check-to-d.stata-mcp.pages.dev

View logs

@SepineTam SepineTam merged commit 933aab4 into dev/1.16.0 Apr 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant