bmsdna-devtools 1.3.0__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/PKG-INFO +31 -8
  2. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/README.md +30 -7
  3. bmsdna_devtools-1.5.0/bmsdna/devtools/cleanup_scan.py +350 -0
  4. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/cli.py +85 -2
  5. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/__init__.py +2 -1
  6. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/advisories.py +34 -5
  7. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/cli.py +18 -10
  8. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/cooldown.py +4 -2
  9. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/lockfiles.py +84 -5
  10. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/osv.py +34 -1
  11. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/deps/versions.py +56 -9
  12. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/pyproject.toml +1 -1
  13. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/skills/bmsdna-devtools/SKILL.md +6 -0
  14. bmsdna_devtools-1.5.0/tests/test_cleanup_scan.py +219 -0
  15. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_deps_advisories.py +61 -0
  16. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_deps_lockfiles.py +120 -0
  17. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_deps_osv.py +31 -0
  18. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_deps_versions.py +32 -0
  19. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/uv.lock +1 -1
  20. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/.github/workflows/auto-release.yml +0 -0
  21. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/.github/workflows/python-publish.yml +0 -0
  22. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/.github/workflows/python-test.yml +0 -0
  23. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/.gitignore +0 -0
  24. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/.python-version +0 -0
  25. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/__init__.py +0 -0
  26. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/_api_dump.py +0 -0
  27. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ado_auth.py +0 -0
  28. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ado_issue.py +0 -0
  29. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/agent_mentions.py +0 -0
  30. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/api_usage.py +0 -0
  31. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/app_service_logs.py +0 -0
  32. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/azure_arm.py +0 -0
  33. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/azure_auth.py +0 -0
  34. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/bdt_config.py +0 -0
  35. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/business_user.py +0 -0
  36. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ci_plan.py +0 -0
  37. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/ci_plan_env.py +0 -0
  38. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/cli_tools.py +0 -0
  39. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/commit.py +0 -0
  40. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/dead_code.py +0 -0
  41. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/env_config.py +0 -0
  42. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/env_files.py +0 -0
  43. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/find_injection.py +0 -0
  44. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/find_repo.py +0 -0
  45. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_args.py +0 -0
  46. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_issue.py +0 -0
  47. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gh_pr.py +0 -0
  48. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/github_api.py +0 -0
  49. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/gitrepo.py +0 -0
  50. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/injection_frontend.py +0 -0
  51. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/injection_python.py +0 -0
  52. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_do.py +0 -0
  53. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_show.py +0 -0
  54. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/issue_watch.py +0 -0
  55. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint.py +0 -0
  56. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_findings.py +0 -0
  57. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_models.py +0 -0
  58. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_sql.py +0 -0
  59. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_sql_files.py +0 -0
  60. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_tooling.py +0 -0
  61. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/lint_typescript.py +0 -0
  62. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/logs.py +0 -0
  63. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_build.py +0 -0
  64. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_cancel.py +0 -0
  65. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_choice.py +0 -0
  66. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_create_args.py +0 -0
  67. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_drift.py +0 -0
  68. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_info.py +0 -0
  69. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_issue_link.py +0 -0
  70. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_labels.py +0 -0
  71. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_list.py +0 -0
  72. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_markdown.py +0 -0
  73. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
  74. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pr_ref.py +0 -0
  75. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/pull.py +0 -0
  76. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/testdb.py +0 -0
  77. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/translate.py +0 -0
  78. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/__init__.py +0 -0
  79. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/cli.py +0 -0
  80. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/pipeline.py +0 -0
  81. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/pricing.py +0 -0
  82. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/report.py +0 -0
  83. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  84. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  85. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  86. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  87. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  88. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  89. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  90. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/bmsdna/devtools/worktree.py +0 -0
  91. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/justfile +0 -0
  92. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/prek.toml +0 -0
  93. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/conftest.py +0 -0
  94. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/fake_github.py +0 -0
  95. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_ado_auth.py +0 -0
  96. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_ado_issue.py +0 -0
  97. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_ado_issue_flow.py +0 -0
  98. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_agent_mentions.py +0 -0
  99. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_api_usage.py +0 -0
  100. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_app_service_logs.py +0 -0
  101. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_azure_arm.py +0 -0
  102. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_bdt_config.py +0 -0
  103. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_business_user.py +0 -0
  104. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_ci_plan.py +0 -0
  105. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_ci_plan_env.py +0 -0
  106. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_cleanup.py +0 -0
  107. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_commit.py +0 -0
  108. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_deps.py +0 -0
  109. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_issue.py +0 -0
  110. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pr_create.py +0 -0
  111. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pr_id.py +0 -0
  112. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_pull.py +0 -0
  113. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_tools.py +0 -0
  114. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_cli_version.py +0 -0
  115. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_commit.py +0 -0
  116. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_deps_cooldown.py +0 -0
  117. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_env_config.py +0 -0
  118. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_env_files.py +0 -0
  119. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_find_injection.py +0 -0
  120. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_find_repo.py +0 -0
  121. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_gh_issue.py +0 -0
  122. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_gh_pr.py +0 -0
  123. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_github_api.py +0 -0
  124. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_gitrepo.py +0 -0
  125. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_issue_do.py +0 -0
  126. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_issue_for_me.py +0 -0
  127. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_issue_show.py +0 -0
  128. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_issue_watch.py +0 -0
  129. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint.py +0 -0
  130. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint_models.py +0 -0
  131. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint_sql.py +0 -0
  132. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint_sql_files.py +0 -0
  133. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint_tooling.py +0 -0
  134. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_lint_typescript.py +0 -0
  135. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_logs.py +0 -0
  136. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build.py +0 -0
  137. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build_create_options.py +0 -0
  138. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_build_flow.py +0 -0
  139. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_cancel_build.py +0 -0
  140. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_choice.py +0 -0
  141. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_create_args.py +0 -0
  142. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_description_not_truncated.py +0 -0
  143. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_drift.py +0 -0
  144. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_info.py +0 -0
  145. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_issue_link.py +0 -0
  146. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_labels.py +0 -0
  147. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_list.py +0 -0
  148. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_markdown.py +0 -0
  149. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pr_merge_defaults.py +0 -0
  150. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_pull.py +0 -0
  151. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_testdb.py +0 -0
  152. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_translate.py +0 -0
  153. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_usage.py +0 -0
  154. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_wait_timeout.py +0 -0
  155. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_worktree_clean.py +0 -0
  156. {bmsdna_devtools-1.3.0 → bmsdna_devtools-1.5.0}/tests/test_worktree_create.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bmsdna-devtools
3
- Version: 1.3.0
3
+ Version: 1.5.0
4
4
  Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
5
  Requires-Python: >=3.14
6
6
  Requires-Dist: azure-identity>=1.19.0
@@ -802,6 +802,22 @@ requires typing `yes` at an interactive prompt whenever `--pg-host` isn't
802
802
  database on a shared/remote Postgres instance without a human confirming it
803
803
  directly.
804
804
 
805
+ ### Read-only disk-usage reports
806
+
807
+ ```bash
808
+ bdt cleanup caches [--min-mb 50] [--json]
809
+ bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
810
+ bdt cleanup inspect [root] [--idle-hours 24] [--json]
811
+ ```
812
+
813
+ These three delete nothing; they feed the `dev-cleanup` skill's overview. `caches` lists the size of the
814
+ podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
815
+ Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
816
+ `node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
817
+ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports every linked worktree under `root`
818
+ (default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
819
+ verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
820
+
805
821
  The DB-naming algorithm and orphan detection are entirely
806
822
  [pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
807
823
  (`pgdevkit.testdb.workspace_db_names()` /
@@ -1297,9 +1313,12 @@ used is reported as `api-route-baseline-stale`, so the list can only shrink.
1297
1313
  ## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
1298
1314
 
1299
1315
  Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
1300
- commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
1301
- Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
1302
- current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
1316
+ commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm),
1317
+ Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`), `Cargo.lock` (crates.io) and NuGet's
1318
+ `packages.lock.json` below each `--path` (default: the current directory; `node_modules`, virtualenvs, `.git`, `.gradle`,
1319
+ Rust `target` and `.worktrees` are skipped). Cargo and NuGet are read from the lockfile only: the version ranges live in
1320
+ `Cargo.toml` / the project files, so a `blocked` status (fix outside the declared range) is not computed for them. A NuGet
1321
+ project needs `RestorePackagesWithLockFile` to have a `packages.lock.json`.
1303
1322
  Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
1304
1323
  range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
1305
1324
  dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
@@ -1309,6 +1328,7 @@ bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --pat
1309
1328
  bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
1310
1329
  bdt deps advisories --json # machine-readable
1311
1330
  bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
1331
+ bdt deps cooldown --ecosystem NuGet --base origin/main # same for packages.lock.json; Cargo >= 1.100 enforces it itself
1312
1332
  ```
1313
1333
 
1314
1334
  `affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
@@ -1317,9 +1337,12 @@ none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable
1317
1337
  git/path/alias source of that name could not be matched).
1318
1338
 
1319
1339
  `cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
1320
- (`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
1321
- pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
1322
- Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
1340
+ (`exclude-newer`), bun (`minimumReleaseAge`) and Cargo >= 1.100 (`[registry] global-min-publish-age = "5 days"` in
1341
+ `.cargo/config.toml`) enforce the cooldown while resolving; Gradle has no such setting and NuGet's (`minPublishAgeHours`
1342
+ per source in `nuget.config`) does not gate a pinned restore, so this is their check. It also works for a Cargo project
1343
+ on an older toolchain. The release time is the upload time of the POM (`Last-Modified`) on Maven Central,
1344
+ Google Maven or the Gradle plugin portal, `created_at` on crates.io, and `published` on nuget.org (an unlisted package,
1345
+ which nuget.org dates 1900, counts as unknown). `--base REV` looks only at versions the file does not have at `REV`
1323
1346
  (use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
1324
1347
  up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
1325
1348
  security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
@@ -1341,7 +1364,7 @@ cooldown exception flow (`references/audit.md`) acts on it:
1341
1364
 
1342
1365
  The target version is the lowest one the advisory data shows to be outside every affected range of the urgent
1343
1366
  advisories (all of them when none is urgent), never "latest". Lower-severity advisories that need a newer version stay open until a normal bump, and the finding names them. `next:` lines give the per-invocation commands. Unsupported sources are listed but don't change the exit code. The fix's age
1344
- comes from the registry (PyPI: youngest file; npm: `time[version]`); `--cooldown-days` (default 5) is the project's
1367
+ comes from the registry (PyPI: youngest file; npm: `time[version]`; crates.io and NuGet: the release date above); `--cooldown-days` (default 5) is the project's
1345
1368
  cooldown. Compatibility with the parents' ranges of a *transitive* dependency isn't known here: re-run after the bump.
1346
1369
 
1347
1370
  It fails closed: OSV, KEV or an advisory record that can't be read is reported as `incomplete` with exit 3, never as
@@ -783,6 +783,22 @@ requires typing `yes` at an interactive prompt whenever `--pg-host` isn't
783
783
  database on a shared/remote Postgres instance without a human confirming it
784
784
  directly.
785
785
 
786
+ ### Read-only disk-usage reports
787
+
788
+ ```bash
789
+ bdt cleanup caches [--min-mb 50] [--json]
790
+ bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
791
+ bdt cleanup inspect [root] [--idle-hours 24] [--json]
792
+ ```
793
+
794
+ These three delete nothing; they feed the `dev-cleanup` skill's overview. `caches` lists the size of the
795
+ podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
796
+ Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
797
+ `node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
798
+ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports every linked worktree under `root`
799
+ (default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
800
+ verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
801
+
786
802
  The DB-naming algorithm and orphan detection are entirely
787
803
  [pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
788
804
  (`pgdevkit.testdb.workspace_db_names()` /
@@ -1278,9 +1294,12 @@ used is reported as `api-route-baseline-stale`, so the list can only shrink.
1278
1294
  ## `bdt deps affected` / `bdt deps advisories` / `bdt deps cooldown`
1279
1295
 
1280
1296
  Security incidents and supply chain attacks (bmsuisse/devtools#113): which locked dependencies are touched? All
1281
- commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm) and
1282
- Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`) below each `--path` (default: the
1283
- current directory; `node_modules`, virtualenvs, `.git`, `.gradle` and `.worktrees` are skipped).
1297
+ commands only read: they never edit a file, a lock or an environment. They cover `uv.lock` (PyPI), `bun.lock` (npm),
1298
+ Gradle (Maven: `gradle.lockfile` and the version catalog `gradle/libs.versions.toml`), `Cargo.lock` (crates.io) and NuGet's
1299
+ `packages.lock.json` below each `--path` (default: the current directory; `node_modules`, virtualenvs, `.git`, `.gradle`,
1300
+ Rust `target` and `.worktrees` are skipped). Cargo and NuGet are read from the lockfile only: the version ranges live in
1301
+ `Cargo.toml` / the project files, so a `blocked` status (fix outside the declared range) is not computed for them. A NuGet
1302
+ project needs `RestorePackagesWithLockFile` to have a `packages.lock.json`.
1284
1303
  Git, path, alias and workspace sources, and Gradle entries without an exact version in the catalog (managed by a BOM, or a
1285
1304
  range), can't be matched against an advisory: they are listed as `unsupported`, never skipped. A catalog lists the direct
1286
1305
  dependencies only; transitive ones need Gradle dependency locking (`gradle.lockfile`).
@@ -1290,6 +1309,7 @@ bdt deps affected lodash --version-spec "<4.17.21" --path ~/projects/CCMT2 --pat
1290
1309
  bdt deps advisories --path . # OSV lookup of every locked version, one status per affected package
1291
1310
  bdt deps advisories --json # machine-readable
1292
1311
  bdt deps cooldown --ecosystem Maven --base origin/dev # CI: no Gradle version added or changed within the cooldown
1312
+ bdt deps cooldown --ecosystem NuGet --base origin/main # same for packages.lock.json; Cargo >= 1.100 enforces it itself
1293
1313
  ```
1294
1314
 
1295
1315
  `affected PACKAGE` lists the locked versions of one package (PyPI names are normalised, npm names exact; `--ecosystem`
@@ -1298,9 +1318,12 @@ none matches, 1 a locked version matches, 2 setup error (no lockfile, unreadable
1298
1318
  git/path/alias source of that name could not be matched).
1299
1319
 
1300
1320
  `cooldown` answers "is a locked version younger than the dependency cooldown?" (`--cooldown-days`, default 5). uv
1301
- (`exclude-newer`) and bun (`minimumReleaseAge`) enforce the cooldown while resolving; Gradle has no such setting and
1302
- pins exact versions, so this is its check. The release time is the upload time of the POM (`Last-Modified`) on Maven
1303
- Central, Google Maven or the Gradle plugin portal. `--base REV` looks only at versions the file does not have at `REV`
1321
+ (`exclude-newer`), bun (`minimumReleaseAge`) and Cargo >= 1.100 (`[registry] global-min-publish-age = "5 days"` in
1322
+ `.cargo/config.toml`) enforce the cooldown while resolving; Gradle has no such setting and NuGet's (`minPublishAgeHours`
1323
+ per source in `nuget.config`) does not gate a pinned restore, so this is their check. It also works for a Cargo project
1324
+ on an older toolchain. The release time is the upload time of the POM (`Last-Modified`) on Maven Central,
1325
+ Google Maven or the Gradle plugin portal, `created_at` on crates.io, and `published` on nuget.org (an unlisted package,
1326
+ which nuget.org dates 1900, counts as unknown). `--base REV` looks only at versions the file does not have at `REV`
1304
1327
  (use the target branch in CI, so an old pin never fails a later pull request); without it every locked version is looked
1305
1328
  up. `--exempt NAME` (repeatable, `group:artifact` for Maven) lets one package through: the per-invocation exception for a
1306
1329
  security fix younger than the cooldown, as for uv and bun. Exit 0 none inside the cooldown (or all exempt), 1 a version
@@ -1322,7 +1345,7 @@ cooldown exception flow (`references/audit.md`) acts on it:
1322
1345
 
1323
1346
  The target version is the lowest one the advisory data shows to be outside every affected range of the urgent
1324
1347
  advisories (all of them when none is urgent), never "latest". Lower-severity advisories that need a newer version stay open until a normal bump, and the finding names them. `next:` lines give the per-invocation commands. Unsupported sources are listed but don't change the exit code. The fix's age
1325
- comes from the registry (PyPI: youngest file; npm: `time[version]`); `--cooldown-days` (default 5) is the project's
1348
+ comes from the registry (PyPI: youngest file; npm: `time[version]`; crates.io and NuGet: the release date above); `--cooldown-days` (default 5) is the project's
1326
1349
  cooldown. Compatibility with the parents' ranges of a *transitive* dependency isn't known here: re-run after the bump.
1327
1350
 
1328
1351
  It fails closed: OSV, KEV or an advisory record that can't be read is reported as `incomplete` with exit 3, never as
@@ -0,0 +1,350 @@
1
+ """Read-only disk-usage reports behind `bdt cleanup caches`, `bdt cleanup stale-envs` and `bdt cleanup inspect`.
2
+
3
+ Nothing here deletes anything: each row carries the command that would clean it, for the caller to run after the
4
+ user picked it (see the dev-cleanup skill). Sizes come from `du -sk` where available (it counts hard links once,
5
+ which matters for the uv/pnpm stores), else from a plain directory walk.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import contextlib
11
+ import os
12
+ import shlex
13
+ import shutil
14
+ import subprocess
15
+ import time
16
+ from concurrent.futures import ThreadPoolExecutor
17
+ from dataclasses import dataclass
18
+ from pathlib import Path
19
+
20
+ from bmsdna.devtools import worktree as worktree_mod
21
+
22
+ # `target`, `bin` and `obj` are common names: they only count next to the manifest that makes them build output.
23
+ _ENV_DIR_NAMES = frozenset({"node_modules", ".venv", "target", "bin", "obj", ".next", ".turbo"})
24
+ _DOTNET_PROJECTS = (".csproj", ".fsproj", ".vbproj")
25
+
26
+
27
+ def _run_out(cmd: list[str], timeout: float = 30) -> str:
28
+ try:
29
+ return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout, check=False).stdout.strip()
30
+ except OSError, subprocess.TimeoutExpired:
31
+ return ""
32
+
33
+
34
+ def _walk_size_mb(path: Path) -> float:
35
+ total, seen = 0, set()
36
+ for dp, _, files in os.walk(path):
37
+ for f in files:
38
+ with contextlib.suppress(OSError):
39
+ st = Path(dp, f).lstat()
40
+ if st.st_nlink > 1:
41
+ if (st.st_dev, st.st_ino) in seen:
42
+ continue
43
+ seen.add((st.st_dev, st.st_ino))
44
+ total += st.st_size
45
+ return total / 2**20
46
+
47
+
48
+ def size_mb(path: Path) -> float:
49
+ if not path.exists():
50
+ return 0.0
51
+ if shutil.which("du"):
52
+ out = _run_out(["du", "-sk", str(path)], timeout=300).split()
53
+ if out and out[0].isdigit():
54
+ return int(out[0]) / 1024
55
+ return _walk_size_mb(path)
56
+
57
+
58
+ # --- caches ---------------------------------------------------------------
59
+
60
+
61
+ @dataclass
62
+ class CacheRow:
63
+ id: str
64
+ label: str
65
+ path: Path
66
+ clean: str
67
+ risk: str
68
+ size_mb: float = 0.0
69
+
70
+
71
+ def _first_existing(*paths: Path) -> Path:
72
+ return next((p for p in paths if p.exists()), paths[0])
73
+
74
+
75
+ def _rm(path: Path) -> str:
76
+ return f"rm -rf {shlex.quote(str(path))}"
77
+
78
+
79
+ def _podman_content() -> str:
80
+ """`podman system df` shows real content; the folder size is the VM's raw disk, which never shrinks by itself."""
81
+ out = _run_out(["podman", "system", "df", "--format", "{{.Type}}: {{.Size}} ({{.Reclaimable}} reclaimable)"])
82
+ return (
83
+ " | ".join(out.splitlines()) if out else "podman not reachable (start `podman machine`) - real content unknown"
84
+ )
85
+
86
+
87
+ def _dir_of(tool: str, *args: str, fallback: Path) -> Path:
88
+ out = _run_out([tool, *args]) if shutil.which(tool) else ""
89
+ return Path(out.splitlines()[-1]) if out else fallback
90
+
91
+
92
+ def cache_specs(home: Path) -> list[CacheRow]:
93
+ lib = home / "Library"
94
+ sccache = _first_existing(lib / "Caches/Mozilla.sccache", home / ".cache/sccache")
95
+ pnpm = _first_existing(lib / "pnpm/store", home / ".local/share/pnpm/store")
96
+ pip = _first_existing(lib / "Caches/pip", home / ".cache/pip")
97
+ playwright = _first_existing(lib / "Caches/ms-playwright", home / ".cache/ms-playwright")
98
+ huggingface = home / ".cache/huggingface"
99
+ return [
100
+ CacheRow(
101
+ "podman",
102
+ "Podman VM disk file; real content inside: " + _podman_content(),
103
+ home / ".local/share/containers",
104
+ "podman machine ssh -- sudo fstrim -av (shrinks the VM disk file), then podman system prune -a -f; "
105
+ "--volumes only if user agrees",
106
+ "medium: prune -a removes every image not used by a running container; folder size is the VM disk, "
107
+ "real gain is often much smaller",
108
+ ),
109
+ CacheRow(
110
+ "docker", "Docker Desktop data", lib / "Containers/com.docker.docker", "docker system prune -a -f", "medium"
111
+ ),
112
+ CacheRow(
113
+ "uv",
114
+ "uv cache",
115
+ _dir_of("uv", "cache", "dir", fallback=home / ".cache/uv"),
116
+ "uv cache clean",
117
+ "low: re-downloaded on next sync",
118
+ ),
119
+ CacheRow("npm", "npm cache", home / ".npm", "npm cache clean --force", "low"),
120
+ CacheRow("bun", "bun install cache", home / ".bun/install/cache", "bun pm cache rm", "low"),
121
+ CacheRow("pnpm", "pnpm store", pnpm, "pnpm store prune", "low"),
122
+ CacheRow("pip", "pip cache", pip, "pip cache purge", "low"),
123
+ CacheRow(
124
+ "cargo",
125
+ "cargo registry + git checkouts",
126
+ home / ".cargo/registry",
127
+ "rm -rf ~/.cargo/registry/cache ~/.cargo/git/checkouts",
128
+ "low: re-downloaded on build",
129
+ ),
130
+ CacheRow(
131
+ "sccache",
132
+ "sccache compile cache",
133
+ sccache,
134
+ f"sccache --stop-server; {_rm(sccache)}",
135
+ "low: slower next build",
136
+ ),
137
+ CacheRow(
138
+ "rustup",
139
+ "rustup toolchains (`rustup toolchain list`)",
140
+ home / ".rustup/toolchains",
141
+ "rustup toolchain uninstall <name> # list first, keep the default",
142
+ "medium: a repo pinning that toolchain re-installs it",
143
+ ),
144
+ CacheRow(
145
+ "nuget",
146
+ "NuGet package cache",
147
+ home / ".nuget/packages",
148
+ "dotnet nuget locals all --clear",
149
+ "low: re-downloaded on restore",
150
+ ),
151
+ CacheRow("gradle", "gradle caches", home / ".gradle/caches", "rm -rf ~/.gradle/caches", "low: slow next build"),
152
+ CacheRow(
153
+ "huggingface",
154
+ "HuggingFace model cache",
155
+ huggingface,
156
+ f"rm -rf {shlex.quote(str(huggingface))}/<model> # list models first, they can be many GB",
157
+ "medium: models must be re-downloaded",
158
+ ),
159
+ CacheRow(
160
+ "playwright",
161
+ "Playwright browsers",
162
+ playwright,
163
+ _rm(playwright),
164
+ "low: `playwright install` restores",
165
+ ),
166
+ CacheRow(
167
+ "homebrew",
168
+ "Homebrew downloads",
169
+ _dir_of("brew", "--cache", fallback=lib / "Caches/Homebrew"),
170
+ "brew cleanup --prune=all",
171
+ "low",
172
+ ),
173
+ CacheRow(
174
+ "xcode-derived",
175
+ "Xcode DerivedData",
176
+ lib / "Developer/Xcode/DerivedData",
177
+ _rm(lib / "Developer/Xcode/DerivedData"),
178
+ "low: rebuilt",
179
+ ),
180
+ CacheRow(
181
+ "xcode-sim",
182
+ "Xcode simulators (unavailable)",
183
+ lib / "Developer/CoreSimulator",
184
+ "xcrun simctl delete unavailable",
185
+ "low",
186
+ ),
187
+ CacheRow("trash", "Trash", home / ".Trash", "empty Trash (user does it in Finder)", "check first"),
188
+ CacheRow("logs", "~/Library/Logs", lib / "Logs", "rm -rf ~/Library/Logs/*", "low"),
189
+ ]
190
+
191
+
192
+ def _app_caches(home: Path, known: set[Path]) -> list[CacheRow]:
193
+ """Each app cache under ~/Library/Caches as its own row, so the user can pick them one by one."""
194
+ root = home / "Library/Caches"
195
+ if not root.is_dir():
196
+ return []
197
+ return [
198
+ CacheRow(f"appcache:{d.name}", f"App cache {d.name}", d, _rm(d), "low: app rebuilds it")
199
+ for d in sorted(root.iterdir())
200
+ if d.is_dir() and d not in known
201
+ ]
202
+
203
+
204
+ def scan_caches(home: Path, min_mb: float) -> list[CacheRow]:
205
+ rows = cache_specs(home)
206
+ rows += _app_caches(home, {r.path for r in rows})
207
+ with ThreadPoolExecutor(8) as ex:
208
+ for row, mb in zip(rows, ex.map(lambda r: size_mb(r.path), rows), strict=True):
209
+ row.size_mb = mb
210
+ return sorted((r for r in rows if r.size_mb >= min_mb), key=lambda r: -r.size_mb)
211
+
212
+
213
+ # --- stale build / dependency dirs ---------------------------------------
214
+
215
+
216
+ @dataclass(frozen=True)
217
+ class StaleEnv:
218
+ path: Path
219
+ size_mb: float
220
+
221
+
222
+ def _is_env_dir(name: str, parent_files: list[str]) -> bool:
223
+ if name == "target":
224
+ return "Cargo.toml" in parent_files
225
+ if name in {"bin", "obj"}:
226
+ return any(f.endswith(_DOTNET_PROJECTS) for f in parent_files)
227
+ return name in _ENV_DIR_NAMES
228
+
229
+
230
+ def _last_touched(env_dir: Path) -> float:
231
+ """Newest mtime of the dir and its top-level entries: a dir's own mtime only moves when entries are added or
232
+ removed, so a `uv sync`/`cargo build`/`npm install` into an existing env would otherwise look untouched."""
233
+ newest = env_dir.stat().st_mtime
234
+ with contextlib.suppress(OSError):
235
+ for entry in env_dir.iterdir():
236
+ with contextlib.suppress(OSError):
237
+ newest = max(newest, entry.stat().st_mtime)
238
+ return newest
239
+
240
+
241
+ def find_stale_envs(root: Path, days: float, min_mb: float) -> list[StaleEnv]:
242
+ """node_modules, .venv, Rust `target`, .NET `bin`/`obj` (and .next/.turbo) untouched for `days` days (age: see
243
+ `_last_touched`).
244
+ They all regenerate (`bun install`, `uv sync`, `cargo build`, `dotnet build`)."""
245
+ cutoff = time.time() - days * 86400
246
+ candidates: list[Path] = []
247
+ for dp, dirs, files in os.walk(root):
248
+ keep = []
249
+ for d in dirs:
250
+ if _is_env_dir(d, files):
251
+ if _last_touched(Path(dp, d)) < cutoff:
252
+ candidates.append(Path(dp, d))
253
+ elif d != ".git":
254
+ keep.append(d)
255
+ dirs[:] = keep # never descend into the env dirs themselves
256
+ with ThreadPoolExecutor(8) as ex:
257
+ found = [StaleEnv(p, mb) for p, mb in zip(candidates, ex.map(size_mb, candidates), strict=True)]
258
+ return sorted((e for e in found if e.size_mb >= min_mb), key=lambda e: -e.size_mb)
259
+
260
+
261
+ # --- worktrees ------------------------------------------------------------
262
+
263
+
264
+ @dataclass
265
+ class WorktreeRow:
266
+ repo: Path
267
+ path: Path
268
+ branch: str
269
+ locked: bool
270
+ size_mb: float = 0.0
271
+ dirty: bool = False
272
+ unpushed: int = 0
273
+ active: bool = False
274
+ idle_h: float = 0.0
275
+ verdict: str = ""
276
+
277
+
278
+ def _git_out(path: Path, *args: str) -> str | None:
279
+ """Stdout of a git command, or None when it failed: a failed probe must not read as "clean / nothing unpushed"."""
280
+ try:
281
+ result = subprocess.run(
282
+ ["git", "-C", str(path), *args], capture_output=True, text=True, timeout=120, check=False
283
+ )
284
+ except OSError, subprocess.TimeoutExpired:
285
+ return None
286
+ return result.stdout if result.returncode == 0 else None
287
+
288
+
289
+ def active_cwds() -> list[str]:
290
+ """Working dirs of all running processes (a per-worktree `lsof +D` is far too slow)."""
291
+ if shutil.which("lsof"):
292
+ return [line[1:] for line in _run_out(["lsof", "-w", "-d", "cwd", "-Fn"], 120).splitlines() if line[:2] == "n/"]
293
+ proc = Path("/proc")
294
+ if not proc.is_dir():
295
+ return []
296
+ cwds = []
297
+ for p in proc.glob("[0-9]*/cwd"):
298
+ with contextlib.suppress(OSError):
299
+ cwds.append(str(p.readlink()))
300
+ return cwds
301
+
302
+
303
+ def _inspect(wt: WorktreeRow, cwds: list[str], idle_hours: float) -> WorktreeRow:
304
+ if not wt.path.is_dir():
305
+ wt.verdict = "prunable (dir missing): git worktree prune"
306
+ return wt
307
+ wt.size_mb = round(size_mb(wt.path))
308
+ status = _git_out(wt.path, "status", "--porcelain")
309
+ wt.dirty = bool((status or "").strip())
310
+ # commits reachable from HEAD but from no remote branch: lost if the worktree+branch were deleted
311
+ unpushed = _git_out(wt.path, "log", "--oneline", "HEAD", "--not", "--remotes")
312
+ wt.unpushed = len((unpushed or "").splitlines())
313
+ p = str(wt.path)
314
+ wt.active = any(c == p or c.startswith(p + os.sep) for c in cwds)
315
+ last_commit = _git_out(wt.path, "log", "-1", "--format=%ct")
316
+ touched = [wt.path.stat().st_mtime, int((last_commit or "").strip() or 0)]
317
+ top_level = [f for f in wt.path.iterdir() if f.name != "node_modules"][:200]
318
+ for f in top_level:
319
+ with contextlib.suppress(OSError):
320
+ touched.append(f.stat().st_mtime)
321
+ wt.idle_h = round((time.time() - max(touched)) / 3600)
322
+ why = [
323
+ w
324
+ for w, bad in [
325
+ ("git check failed", None in (status, unpushed, last_commit)),
326
+ ("dirty", wt.dirty),
327
+ (f"{wt.unpushed} unpushed", wt.unpushed),
328
+ ("locked", wt.locked),
329
+ ("active process", wt.active),
330
+ (f"touched {wt.idle_h:.0f}h ago", wt.idle_h < idle_hours),
331
+ ]
332
+ if bad
333
+ ]
334
+ wt.verdict = "safe" if not why else "review: " + ", ".join(why)
335
+ return wt
336
+
337
+
338
+ def inspect_worktrees(root: Path, idle_hours: float) -> list[WorktreeRow]:
339
+ """Every linked worktree of every repo under `root`. Verdict `safe` = clean, nothing unpushed, not locked,
340
+ no process inside, idle for at least `idle_hours`."""
341
+ rows = [
342
+ WorktreeRow(repo, Path(e["path"]), e.get("branch", "(detached)"), bool(e.get("locked")))
343
+ for repo in sorted(worktree_mod.find_repos(root))
344
+ for e in worktree_mod._parse_worktree_list(repo)[1:]
345
+ if not e.get("bare")
346
+ ]
347
+ cwds = active_cwds()
348
+ with ThreadPoolExecutor(8) as ex:
349
+ done = list(ex.map(lambda r: _inspect(r, cwds, idle_hours), rows))
350
+ return sorted(done, key=lambda r: -r.size_mb)
@@ -5,6 +5,7 @@ import io
5
5
  import json
6
6
  import math
7
7
  import re
8
+ import shutil
8
9
  import subprocess
9
10
  import sys
10
11
  import time
@@ -12,7 +13,7 @@ import tomllib
12
13
  import uuid
13
14
  import webbrowser
14
15
  from collections.abc import Callable
15
- from dataclasses import replace
16
+ from dataclasses import asdict, replace
16
17
  from datetime import UTC, datetime, timedelta
17
18
  from importlib.metadata import version as _pkg_version
18
19
  from pathlib import Path
@@ -39,6 +40,7 @@ from bmsdna.devtools import (
39
40
  )
40
41
  from bmsdna.devtools import api_usage as api_usage_mod
41
42
  from bmsdna.devtools import business_user as business_user_mod
43
+ from bmsdna.devtools import cleanup_scan as cleanup_scan_mod
42
44
  from bmsdna.devtools import commit as commit_mod
43
45
  from bmsdna.devtools import dead_code as dead_code_mod
44
46
  from bmsdna.devtools import env_files as env_files_mod
@@ -176,7 +178,7 @@ app.add_typer(ci_app, name="ci")
176
178
 
177
179
  cleanup_app = typer.Typer(
178
180
  name="cleanup",
179
- help="Prune merged git worktrees and their orphaned pgdevkit Postgres test databases",
181
+ help="Prune merged git worktrees and their orphaned pgdevkit Postgres test databases; read-only disk-usage reports",
180
182
  )
181
183
  app.add_typer(cleanup_app, name="cleanup")
182
184
 
@@ -2488,6 +2490,87 @@ def cleanup_worktree(
2488
2490
  )
2489
2491
 
2490
2492
 
2493
+ _AS_JSON_OPTION = typer.Option(False, "--json", help="Structured JSON output for AI-agent callers")
2494
+
2495
+
2496
+ def _echo_json(payload: object) -> None:
2497
+ typer.echo(json.dumps(payload, indent=2, default=str))
2498
+
2499
+
2500
+ @cleanup_app.command("caches")
2501
+ def cleanup_caches(
2502
+ min_mb: float = typer.Option(50, "--min-mb", help="Hide rows smaller than this"),
2503
+ as_json: bool = _AS_JSON_OPTION,
2504
+ ) -> None:
2505
+ """Read-only: sizes of package-manager, container and app caches, each with its clean command and risk.
2506
+
2507
+ Covers podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright,
2508
+ Homebrew, Xcode and ~/Library/Caches. Deletes nothing: run the clean command of the rows the user picked.
2509
+ """
2510
+ home = Path.home()
2511
+ free_gb = round(shutil.disk_usage(home).free / 2**30, 1)
2512
+ rows = cleanup_scan_mod.scan_caches(home, min_mb)
2513
+ if as_json:
2514
+ _echo_json({"free_gb": free_gb, "rows": [asdict(r) for r in rows]})
2515
+ return
2516
+ typer.echo(f"Free disk: {free_gb:.1f} GB (rows >= {min_mb:.0f} MB, nothing deleted)\n")
2517
+ typer.echo(f"{'GB':>6} {'id':<22} what / risk\n")
2518
+ for r in rows:
2519
+ typer.echo(f"{r.size_mb / 1024:6.1f} {r.id:<22} {r.label} [{r.risk}]")
2520
+ typer.echo(f"{'':6} {'':<22} clean: {r.clean}")
2521
+ typer.echo(f"\n{sum(r.size_mb for r in rows) / 1024:6.1f} total reclaimable candidates")
2522
+ typer.echo(
2523
+ "\nNot covered here: git worktrees -> `bdt cleanup inspect`; stale node_modules/target/obj -> `bdt cleanup stale-envs`"
2524
+ )
2525
+
2526
+
2527
+ @cleanup_app.command("stale-envs")
2528
+ def cleanup_stale_envs(
2529
+ root: Path = typer.Argument(Path(), help="Root folder to scan (recursively)"),
2530
+ days: float = typer.Option(30, "--days", help="Only dirs untouched for at least this many days"),
2531
+ min_mb: float = typer.Option(100, "--min-mb", help="Hide dirs smaller than this"),
2532
+ as_json: bool = _AS_JSON_OPTION,
2533
+ ) -> None:
2534
+ """Read-only: big node_modules / .venv / Rust target / .NET bin+obj dirs untouched for a while.
2535
+
2536
+ They regenerate (`bun install`, `uv sync`, `cargo build`, `dotnet build`). `target` only counts next to a
2537
+ Cargo.toml, `bin`/`obj` only next to a .csproj/.fsproj/.vbproj. Deletes nothing.
2538
+ """
2539
+ envs = cleanup_scan_mod.find_stale_envs(root.resolve(), days, min_mb)
2540
+ if as_json:
2541
+ _echo_json([asdict(e) for e in envs])
2542
+ return
2543
+ for e in envs:
2544
+ typer.echo(f"{e.size_mb / 1024:6.2f} GB {e.path}")
2545
+ typer.echo(f"\n{sum(e.size_mb for e in envs) / 1024:.1f} GB in {len(envs)} dirs untouched >{days:.0f}d")
2546
+
2547
+
2548
+ @cleanup_app.command("inspect")
2549
+ def cleanup_inspect(
2550
+ root: Path = typer.Argument(Path(), help="Root folder to scan for git repositories (recursively)"),
2551
+ idle_hours: float = typer.Option(
2552
+ 24, "--idle-hours", help="A worktree touched more recently than this needs review"
2553
+ ),
2554
+ as_json: bool = _AS_JSON_OPTION,
2555
+ ) -> None:
2556
+ """Read-only: every linked worktree under root with size, dirty, unpushed, locked, active and idle status.
2557
+
2558
+ Verdict `safe` = clean, nothing unpushed, not locked, no process inside, idle for --idle-hours. Unlike
2559
+ `bdt cleanup worktrees` this does not look at merge status; use it to judge unmerged worktrees. Deletes nothing.
2560
+ """
2561
+ rows = cleanup_scan_mod.inspect_worktrees(root.resolve(), idle_hours)
2562
+ if as_json:
2563
+ _echo_json([asdict(r) for r in rows])
2564
+ return
2565
+ safe = [r for r in rows if r.verdict == "safe"]
2566
+ typer.echo(
2567
+ f"{len(rows)} worktrees under {root.resolve()}: {len(safe)} safe ({sum(r.size_mb for r in safe) / 1024:.1f} GB), "
2568
+ f"{len(rows) - len(safe)} need review\n"
2569
+ )
2570
+ for r in rows:
2571
+ typer.echo(f"{r.size_mb / 1024:6.2f} GB {r.repo.name}:{r.branch:<35} {r.verdict}\n {r.path}")
2572
+
2573
+
2491
2574
  def _draft_feat_pr(target: str | None, pat: str | None) -> None:
2492
2575
  """A 'feat' commit landing on an already-published PR forces it back to draft --
2493
2576
  a feature needs a fresh review pass before CI/merge, not just whatever review
@@ -1,6 +1,7 @@
1
1
  """`bdt deps`: which locked dependencies a security advisory or supply chain incident touches (bmsuisse/devtools#113).
2
2
 
3
- - `lockfiles` -- read `uv.lock` (PyPI) and `bun.lock` (npm) into one shape
3
+ - `lockfiles` -- read `uv.lock` (PyPI), `bun.lock` (npm), Gradle (Maven), `Cargo.lock` (crates.io) and
4
+ `packages.lock.json` (NuGet) into one shape
4
5
  - `versions` -- version parsing, comparison and range matching per ecosystem
5
6
  - `osv` -- OSV / CISA KEV / registry timestamp client (the only network code)
6
7
  - `advisories` -- turns OSV records into a per-package status; pure logic, no I/O