bmsdna-devtools 1.2.0__tar.gz → 1.4.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.2.0/README.md → bmsdna_devtools-1.4.0/PKG-INFO +39 -0
  2. bmsdna_devtools-1.2.0/PKG-INFO → bmsdna_devtools-1.4.0/README.md +20 -19
  3. bmsdna_devtools-1.4.0/bmsdna/devtools/cleanup_scan.py +350 -0
  4. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/cli.py +85 -2
  5. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_build.py +39 -2
  6. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/pyproject.toml +1 -1
  7. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/skills/bmsdna-devtools/SKILL.md +6 -0
  8. bmsdna_devtools-1.4.0/tests/test_cleanup_scan.py +219 -0
  9. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_build_flow.py +76 -0
  10. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/uv.lock +1 -1
  11. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/.github/workflows/auto-release.yml +0 -0
  12. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/.github/workflows/python-publish.yml +0 -0
  13. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/.github/workflows/python-test.yml +0 -0
  14. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/.gitignore +0 -0
  15. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/.python-version +0 -0
  16. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/__init__.py +0 -0
  17. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/_api_dump.py +0 -0
  18. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/ado_auth.py +0 -0
  19. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/ado_issue.py +0 -0
  20. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/agent_mentions.py +0 -0
  21. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/api_usage.py +0 -0
  22. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/app_service_logs.py +0 -0
  23. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/azure_arm.py +0 -0
  24. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/azure_auth.py +0 -0
  25. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/bdt_config.py +0 -0
  26. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/business_user.py +0 -0
  27. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/ci_plan.py +0 -0
  28. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/ci_plan_env.py +0 -0
  29. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/cli_tools.py +0 -0
  30. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/commit.py +0 -0
  31. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/dead_code.py +0 -0
  32. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/__init__.py +0 -0
  33. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/advisories.py +0 -0
  34. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/cli.py +0 -0
  35. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/cooldown.py +0 -0
  36. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/lockfiles.py +0 -0
  37. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/osv.py +0 -0
  38. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/deps/versions.py +0 -0
  39. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/env_config.py +0 -0
  40. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/env_files.py +0 -0
  41. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/find_injection.py +0 -0
  42. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/find_repo.py +0 -0
  43. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/gh_args.py +0 -0
  44. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/gh_issue.py +0 -0
  45. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/gh_pr.py +0 -0
  46. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/github_api.py +0 -0
  47. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/gitrepo.py +0 -0
  48. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/injection_frontend.py +0 -0
  49. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/injection_python.py +0 -0
  50. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/issue_do.py +0 -0
  51. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/issue_show.py +0 -0
  52. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/issue_watch.py +0 -0
  53. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint.py +0 -0
  54. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_findings.py +0 -0
  55. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_models.py +0 -0
  56. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_sql.py +0 -0
  57. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_sql_files.py +0 -0
  58. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_tooling.py +0 -0
  59. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/lint_typescript.py +0 -0
  60. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/logs.py +0 -0
  61. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_cancel.py +0 -0
  62. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_choice.py +0 -0
  63. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_create_args.py +0 -0
  64. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_drift.py +0 -0
  65. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_info.py +0 -0
  66. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_issue_link.py +0 -0
  67. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_labels.py +0 -0
  68. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_list.py +0 -0
  69. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_markdown.py +0 -0
  70. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
  71. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pr_ref.py +0 -0
  72. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/pull.py +0 -0
  73. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/testdb.py +0 -0
  74. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/translate.py +0 -0
  75. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/__init__.py +0 -0
  76. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/cli.py +0 -0
  77. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/pipeline.py +0 -0
  78. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/pricing.py +0 -0
  79. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/report.py +0 -0
  80. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  81. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  82. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  83. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  84. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  85. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  86. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  87. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/bmsdna/devtools/worktree.py +0 -0
  88. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/justfile +0 -0
  89. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/prek.toml +0 -0
  90. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/conftest.py +0 -0
  91. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/fake_github.py +0 -0
  92. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_ado_auth.py +0 -0
  93. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_ado_issue.py +0 -0
  94. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_ado_issue_flow.py +0 -0
  95. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_agent_mentions.py +0 -0
  96. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_api_usage.py +0 -0
  97. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_app_service_logs.py +0 -0
  98. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_azure_arm.py +0 -0
  99. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_bdt_config.py +0 -0
  100. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_business_user.py +0 -0
  101. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_ci_plan.py +0 -0
  102. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_ci_plan_env.py +0 -0
  103. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_cleanup.py +0 -0
  104. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_commit.py +0 -0
  105. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_deps.py +0 -0
  106. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_issue.py +0 -0
  107. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_pr_create.py +0 -0
  108. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_pr_id.py +0 -0
  109. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_pull.py +0 -0
  110. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_tools.py +0 -0
  111. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_cli_version.py +0 -0
  112. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_commit.py +0 -0
  113. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_deps_advisories.py +0 -0
  114. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_deps_cooldown.py +0 -0
  115. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_deps_lockfiles.py +0 -0
  116. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_deps_osv.py +0 -0
  117. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_deps_versions.py +0 -0
  118. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_env_config.py +0 -0
  119. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_env_files.py +0 -0
  120. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_find_injection.py +0 -0
  121. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_find_repo.py +0 -0
  122. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_gh_issue.py +0 -0
  123. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_gh_pr.py +0 -0
  124. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_github_api.py +0 -0
  125. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_gitrepo.py +0 -0
  126. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_issue_do.py +0 -0
  127. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_issue_for_me.py +0 -0
  128. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_issue_show.py +0 -0
  129. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_issue_watch.py +0 -0
  130. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint.py +0 -0
  131. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint_models.py +0 -0
  132. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint_sql.py +0 -0
  133. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint_sql_files.py +0 -0
  134. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint_tooling.py +0 -0
  135. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_lint_typescript.py +0 -0
  136. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_logs.py +0 -0
  137. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_build.py +0 -0
  138. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_build_create_options.py +0 -0
  139. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_cancel_build.py +0 -0
  140. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_choice.py +0 -0
  141. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_create_args.py +0 -0
  142. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_description_not_truncated.py +0 -0
  143. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_drift.py +0 -0
  144. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_info.py +0 -0
  145. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_issue_link.py +0 -0
  146. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_labels.py +0 -0
  147. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_list.py +0 -0
  148. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_markdown.py +0 -0
  149. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pr_merge_defaults.py +0 -0
  150. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_pull.py +0 -0
  151. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_testdb.py +0 -0
  152. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_translate.py +0 -0
  153. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_usage.py +0 -0
  154. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_wait_timeout.py +0 -0
  155. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_worktree_clean.py +0 -0
  156. {bmsdna_devtools-1.2.0 → bmsdna_devtools-1.4.0}/tests/test_worktree_create.py +0 -0
@@ -1,3 +1,22 @@
1
+ Metadata-Version: 2.5
2
+ Name: bmsdna-devtools
3
+ Version: 1.4.0
4
+ Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
+ Requires-Python: >=3.14
6
+ Requires-Dist: azure-identity>=1.19.0
7
+ Requires-Dist: packaging>=24.0
8
+ Requires-Dist: pgdevkit[db]>=0.19.0
9
+ Requires-Dist: requests>=2.32.0
10
+ Requires-Dist: rich>=13.0.0
11
+ Requires-Dist: tomli-w>=1.0.0
12
+ Requires-Dist: typer>=0.26.7
13
+ Provides-Extra: lint
14
+ Requires-Dist: sqlglot>=27.0.0; extra == 'lint'
15
+ Provides-Extra: usage
16
+ Requires-Dist: duckdb>=1.3.0; extra == 'usage'
17
+ Requires-Dist: plotly>=5.24.0; extra == 'usage'
18
+ Description-Content-Type: text/markdown
19
+
1
20
  # bmsdna-devtools
2
21
 
3
22
  Shared developer tooling for BMS projects: PR build/check status and a
@@ -57,6 +76,10 @@ interactive (an agent, CI): pass `--pr-id N` or `--target BRANCH` then. Exactly
57
76
  Only `pr create` and `pr watch-deploy`, which need a branch rather than a PR, default `--target` / `--target-branch`
58
77
  to `dev`.
59
78
 
79
+ Once the builds are done, the output says whether the PR merged (Azure DevOps): a completed PR is `PR #42 is merged into 'dev'.`;
80
+ an open one with auto-complete set gets 15 seconds to merge, then `PR #42 was merged into 'dev' by auto-complete.` or
81
+ `PR #42 is not merged yet (auto-complete is set by …); it merges once the remaining policies pass.` (or `… could not look again.` if that request fails; a conflict that appeared meanwhile is reported as an error, exit 1)
82
+
60
83
  If the PR can't be merged, that's reported immediately instead of polling
61
84
  for builds/checks that will never run — e.g. on Azure DevOps:
62
85
  `PR #42 ('feat: widgets') has merge conflicts with the target branch (mergeStatus=conflicts)`;
@@ -779,6 +802,22 @@ requires typing `yes` at an interactive prompt whenever `--pg-host` isn't
779
802
  database on a shared/remote Postgres instance without a human confirming it
780
803
  directly.
781
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
+
782
821
  The DB-naming algorithm and orphan detection are entirely
783
822
  [pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
784
823
  (`pgdevkit.testdb.workspace_db_names()` /
@@ -1,22 +1,3 @@
1
- Metadata-Version: 2.5
2
- Name: bmsdna-devtools
3
- Version: 1.2.0
4
- Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
- Requires-Python: >=3.14
6
- Requires-Dist: azure-identity>=1.19.0
7
- Requires-Dist: packaging>=24.0
8
- Requires-Dist: pgdevkit[db]>=0.19.0
9
- Requires-Dist: requests>=2.32.0
10
- Requires-Dist: rich>=13.0.0
11
- Requires-Dist: tomli-w>=1.0.0
12
- Requires-Dist: typer>=0.26.7
13
- Provides-Extra: lint
14
- Requires-Dist: sqlglot>=27.0.0; extra == 'lint'
15
- Provides-Extra: usage
16
- Requires-Dist: duckdb>=1.3.0; extra == 'usage'
17
- Requires-Dist: plotly>=5.24.0; extra == 'usage'
18
- Description-Content-Type: text/markdown
19
-
20
1
  # bmsdna-devtools
21
2
 
22
3
  Shared developer tooling for BMS projects: PR build/check status and a
@@ -76,6 +57,10 @@ interactive (an agent, CI): pass `--pr-id N` or `--target BRANCH` then. Exactly
76
57
  Only `pr create` and `pr watch-deploy`, which need a branch rather than a PR, default `--target` / `--target-branch`
77
58
  to `dev`.
78
59
 
60
+ Once the builds are done, the output says whether the PR merged (Azure DevOps): a completed PR is `PR #42 is merged into 'dev'.`;
61
+ an open one with auto-complete set gets 15 seconds to merge, then `PR #42 was merged into 'dev' by auto-complete.` or
62
+ `PR #42 is not merged yet (auto-complete is set by …); it merges once the remaining policies pass.` (or `… could not look again.` if that request fails; a conflict that appeared meanwhile is reported as an error, exit 1)
63
+
79
64
  If the PR can't be merged, that's reported immediately instead of polling
80
65
  for builds/checks that will never run — e.g. on Azure DevOps:
81
66
  `PR #42 ('feat: widgets') has merge conflicts with the target branch (mergeStatus=conflicts)`;
@@ -798,6 +783,22 @@ requires typing `yes` at an interactive prompt whenever `--pg-host` isn't
798
783
  database on a shared/remote Postgres instance without a human confirming it
799
784
  directly.
800
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
+
801
802
  The DB-naming algorithm and orphan detection are entirely
802
803
  [pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
803
804
  (`pgdevkit.testdb.workspace_db_names()` /
@@ -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
@@ -137,7 +137,7 @@ def has_build_policy(session: requests.Session, remote: AdoRemote, branch: str)
137
137
  """
138
138
  try:
139
139
  return _build_policy_lookup(session, remote, branch)
140
- except requests.RequestException, SystemExit:
140
+ except requests.RequestException:
141
141
  return False
142
142
 
143
143
 
@@ -150,7 +150,7 @@ def lacks_build_policy(session: requests.Session, remote: AdoRemote, branch: str
150
150
  """
151
151
  try:
152
152
  return not _build_policy_lookup(session, remote, branch)
153
- except requests.RequestException, SystemExit:
153
+ except requests.RequestException:
154
154
  return False
155
155
 
156
156
 
@@ -919,6 +919,40 @@ def deploy_build_hint(session: requests.Session, remote: AdoRemote, target_branc
919
919
  )
920
920
 
921
921
 
922
+ AUTO_COMPLETE_GRACE_SECS = 15 # how long Azure DevOps gets to merge a PR whose auto-complete just became satisfiable
923
+
924
+
925
+ def merge_outcome(
926
+ session: requests.Session, remote: AdoRemote, pr: dict, deadline: WaitDeadline | None = None
927
+ ) -> str | None:
928
+ """Best-effort one-line answer to "did it merge?" once the PR's builds are done, None when there is nothing to add.
929
+
930
+ A completed PR is reported as merged. An active one with auto-complete set is merged by Azure DevOps a moment after
931
+ its last policy passes, not at the same instant: give it `AUTO_COMPLETE_GRACE_SECS`, look again, and say whether
932
+ it did. A request failure looking again fails open (the build report stands on its own), like `deploy_build_hint`; a merge
933
+ conflict that appeared meanwhile is not swallowed (`get_pr_by_id` exits with it).
934
+ """
935
+ target = (pr.get("targetRefName") or "").removeprefix("refs/heads/")
936
+ into = f" into '{target}'" if target else ""
937
+ if pr.get("status") == "completed":
938
+ return f"\nPR #{pr['pullRequestId']} is merged{into}."
939
+ if pr.get("status") != "active" or not pr.get("autoCompleteSetBy"):
940
+ return None
941
+ by = (pr["autoCompleteSetBy"].get("displayName") or "").strip()
942
+ auto = f"auto-complete is set{f' by {by}' if by else ''}"
943
+ if deadline is not None:
944
+ deadline.sleep(AUTO_COMPLETE_GRACE_SECS)
945
+ else:
946
+ time.sleep(AUTO_COMPLETE_GRACE_SECS)
947
+ try:
948
+ fresh = get_pr_by_id(session, remote, pr["pullRequestId"])
949
+ except requests.RequestException:
950
+ return f"\nPR #{pr['pullRequestId']} is not merged yet ({auto}); could not look again."
951
+ if fresh.get("status") == "completed":
952
+ return f"\nPR #{pr['pullRequestId']} was merged{into} by auto-complete."
953
+ return f"\nPR #{pr['pullRequestId']} is not merged yet ({auto}); it merges once the remaining policies pass."
954
+
955
+
922
956
  def latest_per_pipeline(builds: list) -> list:
923
957
  """Reduce a build list to the single latest build per pipeline (definition)."""
924
958
  latest: dict = {}
@@ -1465,6 +1499,9 @@ def _status(
1465
1499
  # otherwise it'd claim a merge/deploy is underway before the PR's own build
1466
1500
  # has even completed.
1467
1501
  if all_done:
1502
+ outcome = merge_outcome(session, remote, pr, deadline)
1503
+ if outcome:
1504
+ print(outcome)
1468
1505
  hint = deploy_build_hint(session, remote, target_branch)
1469
1506
  if hint:
1470
1507
  print(hint)
@@ -10,7 +10,7 @@ packages = ["bmsdna"]
10
10
 
11
11
  [project]
12
12
  name = "bmsdna-devtools"
13
- version = "1.2.0"
13
+ version = "1.4.0"
14
14
  description = "Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects"
15
15
  readme = "README.md"
16
16
  requires-python = ">=3.14" # pgdevkit>=0.7.1 requires 3.14; was >=3.11 before adding it as a dependency
@@ -195,6 +195,12 @@ copies an env file in (auto-detects `.local_env` then `.env`), and runs
195
195
  `--install` inside the new worktree if given. Prefer this over raw
196
196
  `git worktree add` so env-file copying and submodule init aren't forgotten.
197
197
 
198
+ ## Disk usage reports
199
+
200
+ `bdt cleanup caches`, `bdt cleanup stale-envs [root]` and `bdt cleanup inspect [root]` (all `--json`-capable) are
201
+ read-only overviews of caches, stale `node_modules`/`.venv`/Rust `target`/.NET `bin`+`obj` and every worktree with
202
+ a `safe` / `review` verdict. They are the scan step of the `dev-cleanup` skill, next to `bdt cleanup worktrees`.
203
+
198
204
  ## Listing all repos
199
205
 
200
206
  ```bash