Audit your Python repo (FastAPI + Streamlit + ReportLab friendly), merge static analysis with runtime coverage, classify files, and generate a clean, deploy‑ready build.
CodeSentry crawls your repository from given entry points, builds an import graph, optionally ingests a coverage.xml report, and then classifies every file into:
core— essential runtime code (e.g.,api/,streamlit/,api/pdf_utils/*,themes/,layouts/)support— helpers and developer tools (e.g.,tools/,dev_tools/,debug_*, etc.)non_essential— docs, samples, outputsgenerated— build artifacts and temporary files
From this, it produces:
project_file_roles.json— a machine‑readable report- Safe delete scripts:
safe_delete.ps1/safe_delete.sh(move to.trash/, never hard‑delete) - Optional clean build directory
clean_build/containing only what's required to run.
Built and tested on projects that combine FastAPI, Streamlit, and ReportLab, but adaptable to other Python layouts.
- Coverage‑aware: combines static imports with real execution traces.
- Layout/theme awareness: can scan
layouts/*.jsonandthemes/*to include referenced assets and blocks. - Cross‑platform: works on Windows, Linux, macOS. Generates both
.ps1and.shhelpers. - Non‑destructive by default: everything goes to
.trash/until you confirm. - Clean deploys: produce a minimal
clean_build/for packaging or hosting.
Clone or copy the tool into your repository (common path: dev_tools/audit_files_pro.py). Ensure you have Python 3.9+.
python -m pip install --upgrade pip
python -m pip install coverage uvicorn streamlitYou do not need Docker. CodeSentry is a plain Python CLI.
- (Optional) Generate a runtime coverage report while hitting your endpoints/UI:
coverage run -m uvicorn api.main:app --host 127.0.0.1 --port 8000 & coverage xmlstreamlit run streamlit/app.py- Audit + produce reports:
python dev_tools/audit_files_pro.py --coverage-xml coverage.xml- Create a clean build:
python dev_tools/audit_files_pro.py --coverage-xml coverage.xml --make-clean-build- Move non‑essentials to
.trash/:
./safe_delete.ps1
bash ./safe_delete.sh- No hard deletes.
- Move to
.trash/only. --protectcan whitelist paths.
- CodeSentry أداة تفحص مشروعك بايثون وتُنشئ مجلد clean_build/ جاهز للنشر.
- الأوامر الأساسية:
python dev_tools/audit_files_pro.py --coverage-xml coverage.xml --make-clean-buildsafe_delete.ps1/.shلنقل الملفات الزائدة.