bmsdna-devtools 1.6.0__tar.gz → 1.8.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.
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/PKG-INFO +14 -2
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/README.md +13 -1
- bmsdna_devtools-1.8.0/bmsdna/devtools/cleanup_claude.py +227 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/cleanup_scan.py +11 -6
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/cli.py +71 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_build.py +23 -1
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/pyproject.toml +1 -1
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/skills/bmsdna-devtools/SKILL.md +3 -0
- bmsdna_devtools-1.8.0/tests/test_cleanup_claude.py +230 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cleanup_scan.py +18 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_build.py +95 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/uv.lock +1 -1
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/.github/workflows/auto-release.yml +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/.github/workflows/python-publish.yml +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/.github/workflows/python-test.yml +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/.gitignore +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/.python-version +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/__init__.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/_api_dump.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/ado_auth.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/ado_issue.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/agent_mentions.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/api_usage.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/app_service_logs.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/azure_arm.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/azure_auth.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/bdt_config.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/business_user.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/ci_plan.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/ci_plan_env.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/cli_tools.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/commit.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/dead_code.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/__init__.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/advisories.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/cli.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/cooldown.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/lockfiles.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/osv.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/deps/versions.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/env_config.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/env_files.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/find_injection.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/find_repo.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/gh_args.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/gh_issue.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/gh_pr.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/github_api.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/gitrepo.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/injection_frontend.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/injection_python.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/issue_do.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/issue_show.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/issue_watch.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_findings.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_models.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_sql.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_sql_files.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_tooling.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/lint_typescript.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/logs.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_cancel.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_choice.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_create_args.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_drift.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_info.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_issue_link.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_labels.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_list.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_markdown.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pr_ref.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/pull.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/testdb.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/translate.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/__init__.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/cli.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/pipeline.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/pricing.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/report.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/bmsdna/devtools/worktree.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/justfile +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/prek.toml +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/conftest.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/fake_github.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_ado_auth.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_ado_issue.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_ado_issue_flow.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_agent_mentions.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_api_usage.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_app_service_logs.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_azure_arm.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_bdt_config.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_business_user.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_ci_plan.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_ci_plan_env.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_cleanup.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_commit.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_deps.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_issue.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_pr_create.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_pr_id.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_pull.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_tools.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_cli_version.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_commit.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_deps_advisories.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_deps_cooldown.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_deps_lockfiles.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_deps_osv.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_deps_versions.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_env_config.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_env_files.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_find_injection.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_find_repo.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_gh_issue.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_gh_pr.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_github_api.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_gitrepo.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_issue_do.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_issue_for_me.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_issue_show.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_issue_watch.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint_models.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint_sql.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint_sql_files.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint_tooling.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_lint_typescript.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_logs.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_build_create_options.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_build_flow.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_cancel_build.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_choice.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_create_args.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_description_not_truncated.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_drift.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_info.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_issue_link.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_labels.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_list.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_markdown.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_pull.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_testdb.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_translate.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_usage.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_wait_timeout.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.0}/tests/test_worktree_clean.py +0 -0
- {bmsdna_devtools-1.6.0 → bmsdna_devtools-1.8.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
|
+
Version: 1.8.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
|
|
@@ -808,9 +808,11 @@ directly.
|
|
|
808
808
|
bdt cleanup caches [--min-mb 50] [--json]
|
|
809
809
|
bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
|
|
810
810
|
bdt cleanup inspect [root] [--idle-hours 24] [--json]
|
|
811
|
+
bdt cleanup claude-home [root] [--depth 2] [--json]
|
|
812
|
+
bdt cleanup claude-plugins [PATH ...] [--yes]
|
|
811
813
|
```
|
|
812
814
|
|
|
813
|
-
|
|
815
|
+
`caches`, `stale-envs`, `inspect` (and `claude-home`, below) delete nothing; they feed the `dev-cleanup` skill's overview. `caches` lists the size of the
|
|
814
816
|
podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
|
|
815
817
|
Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
|
|
816
818
|
`node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
|
|
@@ -818,6 +820,16 @@ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports ev
|
|
|
818
820
|
(default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
|
|
819
821
|
verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
|
|
820
822
|
|
|
823
|
+
`claude-home` covers what Claude Code leaves behind (it honours `CLAUDE_CONFIG_DIR`; `root` defaults to the
|
|
824
|
+
`bdt find-repo` work dir): every cached plugin version in `~/.claude/plugins/cache` that `installed_plugins.json`
|
|
825
|
+
does not reference is `stale` (or `review` when a live process registered itself in its `.in_use/<pid>`), and every
|
|
826
|
+
dir under `<repo>/.claude/worktrees` that git no longer knows is an `orphan` (the files there are the only copy).
|
|
827
|
+
`claude-plugins` is the only one of these that deletes: a dry run until `--yes`, only the given version dirs if any,
|
|
828
|
+
re-checking installed/live state right before removing. Liveness is probed without signalling the process (on
|
|
829
|
+
Windows `os.kill(pid, 0)` would terminate it), and where running processes cannot be listed (no `lsof` or `/proc`,
|
|
830
|
+
i.e. Windows) no `.claude/worktrees` dir is marked `orphan`, and `cleanup inspect` rows say they cannot tell instead
|
|
831
|
+
of reporting "no active process".
|
|
832
|
+
|
|
821
833
|
The DB-naming algorithm and orphan detection are entirely
|
|
822
834
|
[pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
|
|
823
835
|
(`pgdevkit.testdb.workspace_db_names()` /
|
|
@@ -789,9 +789,11 @@ directly.
|
|
|
789
789
|
bdt cleanup caches [--min-mb 50] [--json]
|
|
790
790
|
bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
|
|
791
791
|
bdt cleanup inspect [root] [--idle-hours 24] [--json]
|
|
792
|
+
bdt cleanup claude-home [root] [--depth 2] [--json]
|
|
793
|
+
bdt cleanup claude-plugins [PATH ...] [--yes]
|
|
792
794
|
```
|
|
793
795
|
|
|
794
|
-
|
|
796
|
+
`caches`, `stale-envs`, `inspect` (and `claude-home`, below) delete nothing; they feed the `dev-cleanup` skill's overview. `caches` lists the size of the
|
|
795
797
|
podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
|
|
796
798
|
Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
|
|
797
799
|
`node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
|
|
@@ -799,6 +801,16 @@ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports ev
|
|
|
799
801
|
(default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
|
|
800
802
|
verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
|
|
801
803
|
|
|
804
|
+
`claude-home` covers what Claude Code leaves behind (it honours `CLAUDE_CONFIG_DIR`; `root` defaults to the
|
|
805
|
+
`bdt find-repo` work dir): every cached plugin version in `~/.claude/plugins/cache` that `installed_plugins.json`
|
|
806
|
+
does not reference is `stale` (or `review` when a live process registered itself in its `.in_use/<pid>`), and every
|
|
807
|
+
dir under `<repo>/.claude/worktrees` that git no longer knows is an `orphan` (the files there are the only copy).
|
|
808
|
+
`claude-plugins` is the only one of these that deletes: a dry run until `--yes`, only the given version dirs if any,
|
|
809
|
+
re-checking installed/live state right before removing. Liveness is probed without signalling the process (on
|
|
810
|
+
Windows `os.kill(pid, 0)` would terminate it), and where running processes cannot be listed (no `lsof` or `/proc`,
|
|
811
|
+
i.e. Windows) no `.claude/worktrees` dir is marked `orphan`, and `cleanup inspect` rows say they cannot tell instead
|
|
812
|
+
of reporting "no active process".
|
|
813
|
+
|
|
802
814
|
The DB-naming algorithm and orphan detection are entirely
|
|
803
815
|
[pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
|
|
804
816
|
(`pgdevkit.testdb.workspace_db_names()` /
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""Claude Code leftovers behind `bdt cleanup claude-home` and `bdt cleanup claude-plugins`: old plugin versions in
|
|
2
|
+
`~/.claude/plugins/cache` and stale `<repo>/.claude/worktrees/*` dirs.
|
|
3
|
+
|
|
4
|
+
Claude Code installs every plugin update into a new `cache/<marketplace>/<plugin>/<version>/` dir and never removes
|
|
5
|
+
the old ones. A version is `stale` when no entry in installed_plugins.json points at it and no live process is
|
|
6
|
+
registered in its `.in_use/<pid>` files (`.orphaned_at` is Claude's own marker, shown as the age).
|
|
7
|
+
|
|
8
|
+
Worktrees that git still knows are covered by `bdt cleanup inspect|worktrees|worktree`. `unregistered_claude_worktrees`
|
|
9
|
+
lists only dirs under `.claude/worktrees` that git does NOT know (`orphan`: gitdir gone), which those cannot see.
|
|
10
|
+
Only `delete_stale_plugins` deletes anything.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import contextlib
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import shutil
|
|
19
|
+
import sys
|
|
20
|
+
import time
|
|
21
|
+
from dataclasses import dataclass, field
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
from bmsdna.devtools import cleanup_scan
|
|
25
|
+
from bmsdna.devtools import worktree as worktree_mod
|
|
26
|
+
|
|
27
|
+
_WIN_ERROR_ACCESS_DENIED = 5
|
|
28
|
+
_WIN_ERROR_INVALID_PARAMETER = 87 # OpenProcess for a pid that does not exist
|
|
29
|
+
_WIN_STILL_ACTIVE = 259
|
|
30
|
+
_WIN_PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def claude_dir() -> Path:
|
|
34
|
+
return Path(os.environ.get("CLAUDE_CONFIG_DIR", "~/.claude")).expanduser()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _pid_alive_windows(pid: int) -> bool:
|
|
38
|
+
"""Probe without signalling: on Windows `os.kill(pid, 0)` calls TerminateProcess and kills the process."""
|
|
39
|
+
if sys.platform != "win32":
|
|
40
|
+
return True
|
|
41
|
+
import ctypes
|
|
42
|
+
from ctypes import wintypes
|
|
43
|
+
|
|
44
|
+
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
45
|
+
kernel32.OpenProcess.restype = wintypes.HANDLE
|
|
46
|
+
kernel32.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD]
|
|
47
|
+
kernel32.GetExitCodeProcess.argtypes = [wintypes.HANDLE, ctypes.POINTER(wintypes.DWORD)]
|
|
48
|
+
kernel32.CloseHandle.argtypes = [wintypes.HANDLE]
|
|
49
|
+
handle = kernel32.OpenProcess(_WIN_PROCESS_QUERY_LIMITED_INFORMATION, False, pid)
|
|
50
|
+
if not handle:
|
|
51
|
+
return ctypes.get_last_error() != _WIN_ERROR_INVALID_PARAMETER # access denied etc.: cannot tell, assume alive
|
|
52
|
+
try:
|
|
53
|
+
code = wintypes.DWORD()
|
|
54
|
+
if not kernel32.GetExitCodeProcess(handle, ctypes.byref(code)):
|
|
55
|
+
return True
|
|
56
|
+
return code.value == _WIN_STILL_ACTIVE
|
|
57
|
+
finally:
|
|
58
|
+
kernel32.CloseHandle(handle)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def pid_alive(pid: int) -> bool:
|
|
62
|
+
"""Whether a process with this pid runs; "cannot tell" counts as alive, so nothing live is ever cleaned up."""
|
|
63
|
+
if sys.platform == "win32":
|
|
64
|
+
return _pid_alive_windows(pid)
|
|
65
|
+
try:
|
|
66
|
+
os.kill(pid, 0)
|
|
67
|
+
except ProcessLookupError:
|
|
68
|
+
return False
|
|
69
|
+
except OSError: # PermissionError: it exists, owned by someone else
|
|
70
|
+
return True
|
|
71
|
+
return True
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass
|
|
75
|
+
class PluginVersion:
|
|
76
|
+
path: Path
|
|
77
|
+
plugin: str
|
|
78
|
+
version: str
|
|
79
|
+
orphaned_days: int | None
|
|
80
|
+
live_pids: list[str]
|
|
81
|
+
size_mb: float
|
|
82
|
+
verdict: str
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ClaudeWorktree:
|
|
87
|
+
path: Path
|
|
88
|
+
repo: Path
|
|
89
|
+
why: str
|
|
90
|
+
size_mb: float
|
|
91
|
+
idle_days: int
|
|
92
|
+
verdict: str
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@dataclass
|
|
96
|
+
class ClaudeHomeReport:
|
|
97
|
+
plugins: list[PluginVersion] = field(default_factory=list)
|
|
98
|
+
worktrees: list[ClaudeWorktree] = field(default_factory=list)
|
|
99
|
+
process_check_available: bool = True
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _really_inside(path: Path, root: Path) -> bool:
|
|
103
|
+
"""False when a symlink among the folders below `root` leads out of it: `delete_stale_plugins` would otherwise
|
|
104
|
+
`rmtree` whatever the link points at."""
|
|
105
|
+
return Path(os.path.realpath(path)) == Path(os.path.realpath(root)) / path.relative_to(root)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def plugin_versions(claude: Path, with_size: bool = True) -> list[PluginVersion]:
|
|
109
|
+
"""Every cached plugin version that is not installed anywhere, with a verdict (re-read each call)."""
|
|
110
|
+
plugins = claude / "plugins"
|
|
111
|
+
try:
|
|
112
|
+
installed = json.loads((plugins / "installed_plugins.json").read_text(encoding="utf-8"))["plugins"]
|
|
113
|
+
except OSError, ValueError, KeyError:
|
|
114
|
+
return [] # without the index we cannot tell what is installed: report nothing rather than guess
|
|
115
|
+
keep = {Path(e["installPath"]).resolve() for entries in installed.values() for e in entries}
|
|
116
|
+
cache = plugins / "cache"
|
|
117
|
+
rows = []
|
|
118
|
+
for ver in cache.glob("*/*/*"):
|
|
119
|
+
if not ver.is_dir() or ver.resolve() in keep or not _really_inside(ver, cache):
|
|
120
|
+
continue
|
|
121
|
+
in_use = ver / ".in_use"
|
|
122
|
+
live = (
|
|
123
|
+
[p.name for p in in_use.iterdir() if p.name.isdigit() and pid_alive(int(p.name))] if in_use.is_dir() else []
|
|
124
|
+
)
|
|
125
|
+
marker = ver / ".orphaned_at"
|
|
126
|
+
age_d = None
|
|
127
|
+
with contextlib.suppress(OSError, ValueError):
|
|
128
|
+
if marker.is_file():
|
|
129
|
+
age_d = (time.time() - int(marker.read_text(encoding="utf-8").strip() or 0) / 1000) / 86400
|
|
130
|
+
rows.append(
|
|
131
|
+
PluginVersion(
|
|
132
|
+
path=ver,
|
|
133
|
+
plugin=f"{ver.parent.name}@{ver.parent.parent.name}",
|
|
134
|
+
version=ver.name,
|
|
135
|
+
orphaned_days=round(age_d) if age_d is not None else None,
|
|
136
|
+
live_pids=live,
|
|
137
|
+
size_mb=round(cleanup_scan.size_mb(ver)) if with_size else 0,
|
|
138
|
+
verdict="review: used by a live process" if live else "stale",
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
return sorted(rows, key=lambda r: -r.size_mb)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def delete_stale_plugins(claude: Path, only: list[Path]) -> int:
|
|
145
|
+
"""Re-checks installed/live state right now (no size scan in between), then removes the stale versions (only
|
|
146
|
+
the `only` paths if given). Returns how many versions were removed."""
|
|
147
|
+
removed, wanted = 0, {p.resolve() for p in only}
|
|
148
|
+
for row in plugin_versions(claude, with_size=False):
|
|
149
|
+
if row.verdict == "stale" and (not wanted or row.path.resolve() in wanted):
|
|
150
|
+
shutil.rmtree(row.path, ignore_errors=True)
|
|
151
|
+
removed += 1
|
|
152
|
+
for plugin_dir in sorted((claude / "plugins" / "cache").glob("*/*")): # plugin dirs left with no version at all
|
|
153
|
+
if plugin_dir.is_dir() and not any(plugin_dir.iterdir()):
|
|
154
|
+
plugin_dir.rmdir()
|
|
155
|
+
return removed
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _registered_worktrees(repo: Path) -> set[Path]:
|
|
159
|
+
return {Path(e["path"]).resolve() for e in worktree_mod._parse_worktree_list(repo)}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _newest_mtime(w: Path) -> float:
|
|
163
|
+
"""Newest mtime among the dir and its entries two levels deep (node_modules/.git skipped): a cheap 'last used'."""
|
|
164
|
+
skip = {"node_modules", ".git", ".venv"}
|
|
165
|
+
times = [w.stat().st_mtime]
|
|
166
|
+
for c in w.iterdir():
|
|
167
|
+
if c.name in skip:
|
|
168
|
+
continue
|
|
169
|
+
with contextlib.suppress(OSError):
|
|
170
|
+
times.append(c.stat().st_mtime)
|
|
171
|
+
if c.is_dir() and not c.is_symlink():
|
|
172
|
+
times += [g.stat().st_mtime for g in list(c.iterdir())[:200]]
|
|
173
|
+
return max(times)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _verdict(w: Path, cwds: list[str] | None) -> tuple[str, str]:
|
|
177
|
+
gitfile = w / ".git"
|
|
178
|
+
ptr = gitfile.read_text(encoding="utf-8").strip().removeprefix("gitdir:").strip() if gitfile.is_file() else ""
|
|
179
|
+
missing = "gitdir missing" if ptr else "no .git file"
|
|
180
|
+
if gitfile.is_dir():
|
|
181
|
+
return "review: standalone clone", ".git is a directory"
|
|
182
|
+
if ptr and (w / ptr).exists(): # relative pointers resolve against the worktree; absolute ones ignore `w`
|
|
183
|
+
return "review: owned by another clone", f"gitdir {ptr}"
|
|
184
|
+
if cwds is None:
|
|
185
|
+
return "review: cannot tell if a process is inside (no lsof or /proc)", missing
|
|
186
|
+
if any(c == str(w) or c.startswith(str(w) + os.sep) for c in cwds):
|
|
187
|
+
return "review: active process inside", missing
|
|
188
|
+
return "orphan", missing
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def unregistered_claude_worktrees(root: Path, depth: int, cwds: list[str] | None) -> list[ClaudeWorktree]:
|
|
192
|
+
"""`cwds` as from `cleanup_scan.active_cwds()`; None (unknown) keeps dirs out of the `orphan` verdict."""
|
|
193
|
+
rows: list[ClaudeWorktree] = []
|
|
194
|
+
stack = [(root, 0)]
|
|
195
|
+
while stack:
|
|
196
|
+
d, n = stack.pop()
|
|
197
|
+
if (d / ".git").is_dir():
|
|
198
|
+
wt_dir = d / ".claude" / "worktrees"
|
|
199
|
+
known = _registered_worktrees(d) if wt_dir.is_dir() else set()
|
|
200
|
+
for w in sorted(wt_dir.iterdir()) if wt_dir.is_dir() else []:
|
|
201
|
+
if not w.is_dir() or w.resolve() in known:
|
|
202
|
+
continue
|
|
203
|
+
verdict, why = _verdict(w, cwds)
|
|
204
|
+
rows.append(
|
|
205
|
+
ClaudeWorktree(
|
|
206
|
+
path=w,
|
|
207
|
+
repo=d,
|
|
208
|
+
why=why,
|
|
209
|
+
size_mb=round(cleanup_scan.size_mb(w)),
|
|
210
|
+
idle_days=round((time.time() - _newest_mtime(w)) / 86400),
|
|
211
|
+
verdict=verdict,
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
continue
|
|
215
|
+
if n < depth:
|
|
216
|
+
with contextlib.suppress(PermissionError):
|
|
217
|
+
stack += [(c, n + 1) for c in d.iterdir() if c.is_dir() and not c.name.startswith(".")]
|
|
218
|
+
return sorted(rows, key=lambda r: -r.size_mb)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def scan(claude: Path, root: Path, depth: int) -> ClaudeHomeReport:
|
|
222
|
+
cwds = cleanup_scan.active_cwds()
|
|
223
|
+
return ClaudeHomeReport(
|
|
224
|
+
plugins=plugin_versions(claude),
|
|
225
|
+
worktrees=unregistered_claude_worktrees(root, depth, cwds),
|
|
226
|
+
process_check_available=cwds is not None,
|
|
227
|
+
)
|
|
@@ -286,13 +286,17 @@ def _git_out(path: Path, *args: str) -> str | None:
|
|
|
286
286
|
return result.stdout if result.returncode == 0 else None
|
|
287
287
|
|
|
288
288
|
|
|
289
|
-
def active_cwds() -> list[str]:
|
|
290
|
-
"""Working dirs of all running processes (a per-worktree `lsof +D` is far too slow)
|
|
289
|
+
def active_cwds() -> list[str] | None:
|
|
290
|
+
"""Working dirs of all running processes (a per-worktree `lsof +D` is far too slow), or None when this
|
|
291
|
+
platform offers no way to list them (Windows): callers must not read that as "nothing is running"."""
|
|
291
292
|
if shutil.which("lsof"):
|
|
292
|
-
|
|
293
|
+
# at least this process has a cwd: an empty listing means lsof failed or timed out, not "nothing runs"
|
|
294
|
+
cwds = [line[1:] for line in _run_out(["lsof", "-w", "-d", "cwd", "-Fn"], 120).splitlines() if line[:2] == "n/"]
|
|
295
|
+
if cwds:
|
|
296
|
+
return cwds
|
|
293
297
|
proc = Path("/proc")
|
|
294
298
|
if not proc.is_dir():
|
|
295
|
-
return
|
|
299
|
+
return None
|
|
296
300
|
cwds = []
|
|
297
301
|
for p in proc.glob("[0-9]*/cwd"):
|
|
298
302
|
with contextlib.suppress(OSError):
|
|
@@ -300,7 +304,7 @@ def active_cwds() -> list[str]:
|
|
|
300
304
|
return cwds
|
|
301
305
|
|
|
302
306
|
|
|
303
|
-
def _inspect(wt: WorktreeRow, cwds: list[str], idle_hours: float) -> WorktreeRow:
|
|
307
|
+
def _inspect(wt: WorktreeRow, cwds: list[str] | None, idle_hours: float) -> WorktreeRow:
|
|
304
308
|
if not wt.path.is_dir():
|
|
305
309
|
wt.verdict = "prunable (dir missing): git worktree prune"
|
|
306
310
|
return wt
|
|
@@ -311,7 +315,7 @@ def _inspect(wt: WorktreeRow, cwds: list[str], idle_hours: float) -> WorktreeRow
|
|
|
311
315
|
unpushed = _git_out(wt.path, "log", "--oneline", "HEAD", "--not", "--remotes")
|
|
312
316
|
wt.unpushed = len((unpushed or "").splitlines())
|
|
313
317
|
p = str(wt.path)
|
|
314
|
-
wt.active = any(c == p or c.startswith(p + os.sep) for c in cwds)
|
|
318
|
+
wt.active = any(c == p or c.startswith(p + os.sep) for c in cwds or [])
|
|
315
319
|
last_commit = _git_out(wt.path, "log", "-1", "--format=%ct")
|
|
316
320
|
touched = [wt.path.stat().st_mtime, int((last_commit or "").strip() or 0)]
|
|
317
321
|
top_level = [f for f in wt.path.iterdir() if f.name != "node_modules"][:200]
|
|
@@ -327,6 +331,7 @@ def _inspect(wt: WorktreeRow, cwds: list[str], idle_hours: float) -> WorktreeRow
|
|
|
327
331
|
(f"{wt.unpushed} unpushed", wt.unpushed),
|
|
328
332
|
("locked", wt.locked),
|
|
329
333
|
("active process", wt.active),
|
|
334
|
+
("cannot tell if a process is inside (no lsof or /proc)", cwds is None),
|
|
330
335
|
(f"touched {wt.idle_h:.0f}h ago", wt.idle_h < idle_hours),
|
|
331
336
|
]
|
|
332
337
|
if bad
|
|
@@ -40,6 +40,7 @@ from bmsdna.devtools import (
|
|
|
40
40
|
)
|
|
41
41
|
from bmsdna.devtools import api_usage as api_usage_mod
|
|
42
42
|
from bmsdna.devtools import business_user as business_user_mod
|
|
43
|
+
from bmsdna.devtools import cleanup_claude as cleanup_claude_mod
|
|
43
44
|
from bmsdna.devtools import cleanup_scan as cleanup_scan_mod
|
|
44
45
|
from bmsdna.devtools import commit as commit_mod
|
|
45
46
|
from bmsdna.devtools import dead_code as dead_code_mod
|
|
@@ -2571,6 +2572,76 @@ def cleanup_inspect(
|
|
|
2571
2572
|
typer.echo(f"{r.size_mb / 1024:6.2f} GB {r.repo.name}:{r.branch:<35} {r.verdict}\n {r.path}")
|
|
2572
2573
|
|
|
2573
2574
|
|
|
2575
|
+
@cleanup_app.command("claude-home")
|
|
2576
|
+
def cleanup_claude_home(
|
|
2577
|
+
root: Path | None = typer.Argument(
|
|
2578
|
+
None, help="Root folder to scan for repos with a .claude/worktrees dir (default: the `bdt find-repo` work dir)"
|
|
2579
|
+
),
|
|
2580
|
+
depth: int = typer.Option(2, "--depth", help="How many folder levels below root to look for repos"),
|
|
2581
|
+
as_json: bool = _AS_JSON_OPTION,
|
|
2582
|
+
) -> None:
|
|
2583
|
+
"""Read-only: Claude Code leftovers: old plugin versions and `.claude/worktrees` dirs git no longer knows.
|
|
2584
|
+
|
|
2585
|
+
Claude Code never removes old versions from ~/.claude/plugins/cache (honours CLAUDE_CONFIG_DIR). A version is
|
|
2586
|
+
`stale` when installed_plugins.json does not point at it and no live process is registered in its `.in_use`.
|
|
2587
|
+
`orphan` = a dir under `<repo>/.claude/worktrees` whose gitdir is gone (the files are the only copy; rows with
|
|
2588
|
+
a process inside, or where processes cannot be listed, are `review`). Worktrees git still knows show up in
|
|
2589
|
+
`bdt cleanup inspect`. Deletes nothing: `bdt cleanup claude-plugins --yes` removes stale plugin versions.
|
|
2590
|
+
"""
|
|
2591
|
+
report = cleanup_claude_mod.scan(
|
|
2592
|
+
cleanup_claude_mod.claude_dir(), (root or find_repo_mod.work_dir()).expanduser().resolve(), depth
|
|
2593
|
+
)
|
|
2594
|
+
if as_json:
|
|
2595
|
+
_echo_json(asdict(report))
|
|
2596
|
+
return
|
|
2597
|
+
stale = [r for r in report.plugins if r.verdict == "stale"]
|
|
2598
|
+
typer.echo(
|
|
2599
|
+
f"Plugin cache: {len(stale)} stale versions ({sum(r.size_mb for r in stale) / 1024:.1f} GB) "
|
|
2600
|
+
f"in {cleanup_claude_mod.claude_dir() / 'plugins' / 'cache'}"
|
|
2601
|
+
)
|
|
2602
|
+
for r in report.plugins:
|
|
2603
|
+
age = f"orphaned {r.orphaned_days}d ago" if r.orphaned_days is not None else "not installed"
|
|
2604
|
+
typer.echo(f"{r.size_mb / 1024:6.2f} GB {r.plugin:<45} {r.version:<14} {age}; {r.verdict}")
|
|
2605
|
+
orphans = [r for r in report.worktrees if r.verdict == "orphan"]
|
|
2606
|
+
typer.echo(
|
|
2607
|
+
f"\n.claude/worktrees dirs unknown to git: {len(orphans)} orphan "
|
|
2608
|
+
f"({sum(r.size_mb for r in orphans) / 1024:.1f} GB), {len(report.worktrees) - len(orphans)} to review"
|
|
2609
|
+
)
|
|
2610
|
+
if not report.process_check_available:
|
|
2611
|
+
typer.echo("note: running processes cannot be listed on this platform, so none of these is marked `orphan`")
|
|
2612
|
+
for r in report.worktrees:
|
|
2613
|
+
typer.echo(
|
|
2614
|
+
f"{r.size_mb / 1024:6.2f} GB {r.repo.name}: {r.path.name:<35} {r.verdict} ({r.why}, touched {r.idle_days}d ago)\n"
|
|
2615
|
+
f" {r.path}"
|
|
2616
|
+
)
|
|
2617
|
+
|
|
2618
|
+
|
|
2619
|
+
@cleanup_app.command("claude-plugins")
|
|
2620
|
+
def cleanup_claude_plugins(
|
|
2621
|
+
paths: list[Path] = typer.Argument(None, help="Only these plugin version dirs (default: every stale one)"),
|
|
2622
|
+
yes: bool = typer.Option(False, "--yes", help="Actually delete; without it only list what would go"),
|
|
2623
|
+
) -> None:
|
|
2624
|
+
"""Remove `stale` Claude Code plugin versions from ~/.claude/plugins/cache (see `bdt cleanup claude-home`).
|
|
2625
|
+
|
|
2626
|
+
Installed versions, `data/` and installed_plugins.json are never touched; installed/live state is re-checked
|
|
2627
|
+
at delete time, so a version a live session registered in the meantime is skipped.
|
|
2628
|
+
"""
|
|
2629
|
+
claude = cleanup_claude_mod.claude_dir()
|
|
2630
|
+
wanted = {p.resolve() for p in paths or []}
|
|
2631
|
+
stale = [
|
|
2632
|
+
r
|
|
2633
|
+
for r in cleanup_claude_mod.plugin_versions(claude, with_size=False)
|
|
2634
|
+
if r.verdict == "stale" and (not wanted or r.path.resolve() in wanted)
|
|
2635
|
+
]
|
|
2636
|
+
if not yes:
|
|
2637
|
+
for r in stale:
|
|
2638
|
+
typer.echo(f"would remove {r.plugin} {r.version} {r.path}")
|
|
2639
|
+
typer.echo(f"\n{len(stale)} stale plugin versions; re-run with --yes to remove")
|
|
2640
|
+
return
|
|
2641
|
+
removed = cleanup_claude_mod.delete_stale_plugins(claude, list(wanted))
|
|
2642
|
+
typer.echo(f"removed {removed} stale plugin versions")
|
|
2643
|
+
|
|
2644
|
+
|
|
2574
2645
|
def _draft_feat_pr(target: str | None, pat: str | None) -> None:
|
|
2575
2646
|
"""A 'feat' commit landing on an already-published PR forces it back to draft --
|
|
2576
2647
|
a feature needs a fresh review pass before CI/merge, not just whatever review
|
|
@@ -1277,6 +1277,22 @@ def cancelled_for_current_push(build: dict, pr: dict) -> bool:
|
|
|
1277
1277
|
return current is None or build.get("sourceVersion") == current
|
|
1278
1278
|
|
|
1279
1279
|
|
|
1280
|
+
def build_is_current(build: dict, pr: dict, source_head: str | None) -> bool:
|
|
1281
|
+
"""A build of what the PR is at right now, so the answer to `--wait` even when it finished before `--wait` started
|
|
1282
|
+
(one of an older push is a leftover to wait past). `source_head` is what the source branch points at now; None
|
|
1283
|
+
(unknown) means not current. A build of exactly that commit (a branch build) is current. A PR validation build is
|
|
1284
|
+
one of the PR's merge commit, and that only counts once Azure DevOps has seen the newest push, i.e. the PR's merge
|
|
1285
|
+
was computed from `source_head`: before that, `lastMergeCommit` still belongs to the previous push."""
|
|
1286
|
+
if not source_head:
|
|
1287
|
+
return False
|
|
1288
|
+
if build.get("sourceVersion") == source_head:
|
|
1289
|
+
return True
|
|
1290
|
+
merged_from = (pr.get("lastMergeSourceCommit") or {}).get("commitId")
|
|
1291
|
+
return merged_from == source_head and build.get("sourceVersion") == (pr.get("lastMergeCommit") or {}).get(
|
|
1292
|
+
"commitId"
|
|
1293
|
+
)
|
|
1294
|
+
|
|
1295
|
+
|
|
1280
1296
|
def print_build(session: requests.Session, remote: AdoRemote, build: dict) -> None:
|
|
1281
1297
|
build_id = build["id"]
|
|
1282
1298
|
status = build.get("status", "unknown")
|
|
@@ -1390,7 +1406,8 @@ def _status(
|
|
|
1390
1406
|
|
|
1391
1407
|
# When waiting, a pipeline's "latest" build may already be a *completed* run from before
|
|
1392
1408
|
# this invocation (CI hasn't registered a new build for the current push yet). Only accept
|
|
1393
|
-
# a fresh build in that case, so --wait doesn't immediately report that stale old result.
|
|
1409
|
+
# a fresh build in that case, so --wait doesn't immediately report that stale old result. Unless it is a build of the
|
|
1410
|
+
# PR's current head (`build_is_current`, judged on every poll): nothing newer is coming, waiting would hang forever.
|
|
1394
1411
|
# Only builds already completed at this snapshot go in here -- one that's inProgress here
|
|
1395
1412
|
# (whether just-started or long-running) is genuinely the current build for the current
|
|
1396
1413
|
# HEAD, not a stale leftover, and must be watched rather than waited past: recording it too
|
|
@@ -1451,11 +1468,16 @@ def _status(
|
|
|
1451
1468
|
if builds:
|
|
1452
1469
|
pipeline_builds = latest_per_pipeline(builds)
|
|
1453
1470
|
if wait:
|
|
1471
|
+
try:
|
|
1472
|
+
source_head = target_tip(session, remote, source_branch)
|
|
1473
|
+
except requests.RequestException:
|
|
1474
|
+
source_head = None # unknown: a build from before `--wait` stays a leftover, as before
|
|
1454
1475
|
stale = [
|
|
1455
1476
|
b
|
|
1456
1477
|
for b in pipeline_builds
|
|
1457
1478
|
if b["id"] <= baseline_completed_ids.get(b.get("definition", {}).get("id"), 0)
|
|
1458
1479
|
and not cancelled_for_current_push(b, pr)
|
|
1480
|
+
and not build_is_current(b, pr, source_head)
|
|
1459
1481
|
]
|
|
1460
1482
|
if stale:
|
|
1461
1483
|
msg += " | waiting for new build(s) to start: " + ", ".join(
|
|
@@ -10,7 +10,7 @@ packages = ["bmsdna"]
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "bmsdna-devtools"
|
|
13
|
-
version = "1.
|
|
13
|
+
version = "1.8.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
|
|
@@ -200,6 +200,9 @@ copies an env file in (auto-detects `.local_env` then `.env`), and runs
|
|
|
200
200
|
`bdt cleanup caches`, `bdt cleanup stale-envs [root]` and `bdt cleanup inspect [root]` (all `--json`-capable) are
|
|
201
201
|
read-only overviews of caches, stale `node_modules`/`.venv`/Rust `target`/.NET `bin`+`obj` and every worktree with
|
|
202
202
|
a `safe` / `review` verdict. They are the scan step of the `dev-cleanup` skill, next to `bdt cleanup worktrees`.
|
|
203
|
+
`bdt cleanup claude-home [root]` is the read-only report for Claude Code leftovers (old plugin versions in
|
|
204
|
+
`~/.claude/plugins/cache`, `.claude/worktrees` dirs git no longer knows); `bdt cleanup claude-plugins [PATH ...] [--yes]`
|
|
205
|
+
removes the stale plugin versions (without `--yes` it only lists them). Both work on Windows.
|
|
203
206
|
|
|
204
207
|
## Listing all repos
|
|
205
208
|
|