bmsdna-devtools 1.7.0__tar.gz → 1.9.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.7.0 → bmsdna_devtools-1.9.0}/PKG-INFO +36 -2
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/README.md +35 -1
- bmsdna_devtools-1.9.0/bmsdna/devtools/cleanup_claude.py +227 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/cleanup_scan.py +11 -6
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/cli.py +139 -0
- bmsdna_devtools-1.9.0/bmsdna/devtools/pr_logs.py +274 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/pyproject.toml +1 -1
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/skills/bmsdna-devtools/SKILL.md +15 -0
- bmsdna_devtools-1.9.0/tests/test_cleanup_claude.py +230 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cleanup_scan.py +18 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_info.py +1 -0
- bmsdna_devtools-1.9.0/tests/test_pr_logs.py +201 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/uv.lock +1 -1
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/.github/workflows/auto-release.yml +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/.github/workflows/python-publish.yml +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/.github/workflows/python-test.yml +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/.gitignore +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/.python-version +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/__init__.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/_api_dump.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/ado_auth.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/ado_issue.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/agent_mentions.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/api_usage.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/app_service_logs.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/azure_arm.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/azure_auth.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/bdt_config.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/business_user.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/ci_plan.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/ci_plan_env.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/cli_tools.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/commit.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/dead_code.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/__init__.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/advisories.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/cli.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/cooldown.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/lockfiles.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/osv.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/deps/versions.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/env_config.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/env_files.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/find_injection.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/find_repo.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/gh_args.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/gh_issue.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/gh_pr.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/github_api.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/gitrepo.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/injection_frontend.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/injection_python.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/issue_do.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/issue_show.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/issue_watch.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_findings.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_models.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_sql.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_sql_files.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_tooling.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/lint_typescript.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/logs.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_build.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_cancel.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_choice.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_create_args.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_drift.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_info.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_issue_link.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_labels.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_list.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_markdown.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pr_ref.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/pull.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/testdb.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/translate.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/__init__.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/cli.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/pipeline.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/pricing.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/report.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/bmsdna/devtools/worktree.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/justfile +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/prek.toml +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/conftest.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/fake_github.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_ado_auth.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_ado_issue.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_ado_issue_flow.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_agent_mentions.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_api_usage.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_app_service_logs.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_azure_arm.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_bdt_config.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_business_user.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_ci_plan.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_ci_plan_env.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_cleanup.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_commit.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_deps.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_issue.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_pr_create.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_pr_id.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_pull.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_tools.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_cli_version.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_commit.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_deps_advisories.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_deps_cooldown.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_deps_lockfiles.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_deps_osv.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_deps_versions.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_env_config.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_env_files.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_find_injection.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_find_repo.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_gh_issue.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_gh_pr.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_github_api.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_gitrepo.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_issue_do.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_issue_for_me.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_issue_show.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_issue_watch.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint_models.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint_sql.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint_sql_files.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint_tooling.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_lint_typescript.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_logs.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_build.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_build_create_options.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_build_flow.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_cancel_build.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_choice.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_create_args.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_description_not_truncated.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_drift.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_issue_link.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_labels.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_list.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_markdown.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pr_merge_defaults.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_pull.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_testdb.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_translate.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_usage.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_wait_timeout.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.0}/tests/test_worktree_clean.py +0 -0
- {bmsdna_devtools-1.7.0 → bmsdna_devtools-1.9.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.9.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
|
|
@@ -136,6 +136,28 @@ locally at all (it also settles which PR when several are open for the branch).
|
|
|
136
136
|
all accept the same option, for the same reason. (`pr watch-deploy` doesn't:
|
|
137
137
|
it watches a branch-triggered build/workflow run, not any particular PR.)
|
|
138
138
|
|
|
139
|
+
## `bdt pr logs`
|
|
140
|
+
|
|
141
|
+
Print the logs of a PR's builds (Azure DevOps) or workflow runs (GitHub) — the dedicated viewer behind the
|
|
142
|
+
failed-step output of `bdt pr status`.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
bdt pr logs [BUILD_ID] [--pr-id N] [--build-id N] [--all] [--step TEXT] [--tail N] [--list] [--json] [--timestamps]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- Lists **every** step (Azure DevOps: tasks, as `Stage / Job / Task`) of the latest build per pipeline of the PR
|
|
149
|
+
opened from the current branch (or `--pr-id`). Succeeded/skipped steps are **one line** (`[succeeded] Test / unit / uv sync`);
|
|
150
|
+
only **failed** steps print their log. GitHub keeps one log per *job*, so there the failed jobs print their log, with
|
|
151
|
+
their failed step names in the title.
|
|
152
|
+
- `--all`: print the logs of succeeded steps too, also for builds that are still running (partial logs).
|
|
153
|
+
- `--step TEXT`: only steps whose name contains `TEXT` (case-insensitive; GitHub: job names); their logs are printed, succeeded or not.
|
|
154
|
+
- `--tail N`: only the last `N` lines of each printed log (0 = everything, the default).
|
|
155
|
+
- `--list`: only the steps/jobs and their result, never a log (to find the `--step` you want).
|
|
156
|
+
- `--json`: one JSON document, a list of builds `{id, name, result, url, steps: [{name, result, log}]}`; `log` is null for
|
|
157
|
+
steps whose log is not printed (same rules as the text output).
|
|
158
|
+
- `BUILD_ID` or `--build-id N` (alias `--run-id`): one Azure DevOps build / GitHub Actions run directly instead of the PR's latest.
|
|
159
|
+
- Azure Pipelines' per-line timestamps are stripped unless `--timestamps` is given.
|
|
160
|
+
|
|
139
161
|
## `bdt pr list`
|
|
140
162
|
|
|
141
163
|
```bash
|
|
@@ -808,9 +830,11 @@ directly.
|
|
|
808
830
|
bdt cleanup caches [--min-mb 50] [--json]
|
|
809
831
|
bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
|
|
810
832
|
bdt cleanup inspect [root] [--idle-hours 24] [--json]
|
|
833
|
+
bdt cleanup claude-home [root] [--depth 2] [--json]
|
|
834
|
+
bdt cleanup claude-plugins [PATH ...] [--yes]
|
|
811
835
|
```
|
|
812
836
|
|
|
813
|
-
|
|
837
|
+
`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
838
|
podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
|
|
815
839
|
Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
|
|
816
840
|
`node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
|
|
@@ -818,6 +842,16 @@ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports ev
|
|
|
818
842
|
(default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
|
|
819
843
|
verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
|
|
820
844
|
|
|
845
|
+
`claude-home` covers what Claude Code leaves behind (it honours `CLAUDE_CONFIG_DIR`; `root` defaults to the
|
|
846
|
+
`bdt find-repo` work dir): every cached plugin version in `~/.claude/plugins/cache` that `installed_plugins.json`
|
|
847
|
+
does not reference is `stale` (or `review` when a live process registered itself in its `.in_use/<pid>`), and every
|
|
848
|
+
dir under `<repo>/.claude/worktrees` that git no longer knows is an `orphan` (the files there are the only copy).
|
|
849
|
+
`claude-plugins` is the only one of these that deletes: a dry run until `--yes`, only the given version dirs if any,
|
|
850
|
+
re-checking installed/live state right before removing. Liveness is probed without signalling the process (on
|
|
851
|
+
Windows `os.kill(pid, 0)` would terminate it), and where running processes cannot be listed (no `lsof` or `/proc`,
|
|
852
|
+
i.e. Windows) no `.claude/worktrees` dir is marked `orphan`, and `cleanup inspect` rows say they cannot tell instead
|
|
853
|
+
of reporting "no active process".
|
|
854
|
+
|
|
821
855
|
The DB-naming algorithm and orphan detection are entirely
|
|
822
856
|
[pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
|
|
823
857
|
(`pgdevkit.testdb.workspace_db_names()` /
|
|
@@ -117,6 +117,28 @@ locally at all (it also settles which PR when several are open for the branch).
|
|
|
117
117
|
all accept the same option, for the same reason. (`pr watch-deploy` doesn't:
|
|
118
118
|
it watches a branch-triggered build/workflow run, not any particular PR.)
|
|
119
119
|
|
|
120
|
+
## `bdt pr logs`
|
|
121
|
+
|
|
122
|
+
Print the logs of a PR's builds (Azure DevOps) or workflow runs (GitHub) — the dedicated viewer behind the
|
|
123
|
+
failed-step output of `bdt pr status`.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
bdt pr logs [BUILD_ID] [--pr-id N] [--build-id N] [--all] [--step TEXT] [--tail N] [--list] [--json] [--timestamps]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- Lists **every** step (Azure DevOps: tasks, as `Stage / Job / Task`) of the latest build per pipeline of the PR
|
|
130
|
+
opened from the current branch (or `--pr-id`). Succeeded/skipped steps are **one line** (`[succeeded] Test / unit / uv sync`);
|
|
131
|
+
only **failed** steps print their log. GitHub keeps one log per *job*, so there the failed jobs print their log, with
|
|
132
|
+
their failed step names in the title.
|
|
133
|
+
- `--all`: print the logs of succeeded steps too, also for builds that are still running (partial logs).
|
|
134
|
+
- `--step TEXT`: only steps whose name contains `TEXT` (case-insensitive; GitHub: job names); their logs are printed, succeeded or not.
|
|
135
|
+
- `--tail N`: only the last `N` lines of each printed log (0 = everything, the default).
|
|
136
|
+
- `--list`: only the steps/jobs and their result, never a log (to find the `--step` you want).
|
|
137
|
+
- `--json`: one JSON document, a list of builds `{id, name, result, url, steps: [{name, result, log}]}`; `log` is null for
|
|
138
|
+
steps whose log is not printed (same rules as the text output).
|
|
139
|
+
- `BUILD_ID` or `--build-id N` (alias `--run-id`): one Azure DevOps build / GitHub Actions run directly instead of the PR's latest.
|
|
140
|
+
- Azure Pipelines' per-line timestamps are stripped unless `--timestamps` is given.
|
|
141
|
+
|
|
120
142
|
## `bdt pr list`
|
|
121
143
|
|
|
122
144
|
```bash
|
|
@@ -789,9 +811,11 @@ directly.
|
|
|
789
811
|
bdt cleanup caches [--min-mb 50] [--json]
|
|
790
812
|
bdt cleanup stale-envs [root] [--days 30] [--min-mb 100] [--json]
|
|
791
813
|
bdt cleanup inspect [root] [--idle-hours 24] [--json]
|
|
814
|
+
bdt cleanup claude-home [root] [--depth 2] [--json]
|
|
815
|
+
bdt cleanup claude-plugins [PATH ...] [--yes]
|
|
792
816
|
```
|
|
793
817
|
|
|
794
|
-
|
|
818
|
+
`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
819
|
podman/docker, uv/npm/bun/pnpm/pip, cargo/sccache/rustup, NuGet, gradle, HuggingFace, Playwright, Homebrew and
|
|
796
820
|
Xcode caches (plus each `~/Library/Caches` app) with the command that cleans it and its risk. `stale-envs` finds
|
|
797
821
|
`node_modules`, `.venv`, `.next`/`.turbo`, Rust `target/` (next to a `Cargo.toml`) and .NET `bin/`/`obj/` (next
|
|
@@ -799,6 +823,16 @@ to a `.csproj`/`.fsproj`/`.vbproj`) untouched for `--days`. `inspect` reports ev
|
|
|
799
823
|
(default `.`) with size, dirty, unpushed, locked, active-process and idle status and a `safe` / `review: ...`
|
|
800
824
|
verdict; unlike `cleanup worktrees` it ignores merge status, so it is how you judge unmerged worktrees.
|
|
801
825
|
|
|
826
|
+
`claude-home` covers what Claude Code leaves behind (it honours `CLAUDE_CONFIG_DIR`; `root` defaults to the
|
|
827
|
+
`bdt find-repo` work dir): every cached plugin version in `~/.claude/plugins/cache` that `installed_plugins.json`
|
|
828
|
+
does not reference is `stale` (or `review` when a live process registered itself in its `.in_use/<pid>`), and every
|
|
829
|
+
dir under `<repo>/.claude/worktrees` that git no longer knows is an `orphan` (the files there are the only copy).
|
|
830
|
+
`claude-plugins` is the only one of these that deletes: a dry run until `--yes`, only the given version dirs if any,
|
|
831
|
+
re-checking installed/live state right before removing. Liveness is probed without signalling the process (on
|
|
832
|
+
Windows `os.kill(pid, 0)` would terminate it), and where running processes cannot be listed (no `lsof` or `/proc`,
|
|
833
|
+
i.e. Windows) no `.claude/worktrees` dir is marked `orphan`, and `cleanup inspect` rows say they cannot tell instead
|
|
834
|
+
of reporting "no active process".
|
|
835
|
+
|
|
802
836
|
The DB-naming algorithm and orphan detection are entirely
|
|
803
837
|
[pgdevkit](https://github.com/bmsuisse/pgdevkit)'s own
|
|
804
838
|
(`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
|
|
@@ -53,6 +54,7 @@ from bmsdna.devtools import lint as lint_mod
|
|
|
53
54
|
from bmsdna.devtools import logs as logs_mod
|
|
54
55
|
from bmsdna.devtools import pr_info as pr_info_mod
|
|
55
56
|
from bmsdna.devtools import pr_list as pr_list_mod
|
|
57
|
+
from bmsdna.devtools import pr_logs as pr_logs_mod
|
|
56
58
|
from bmsdna.devtools import pull as pull_mod
|
|
57
59
|
from bmsdna.devtools import translate as translate_mod
|
|
58
60
|
from bmsdna.devtools import worktree as worktree_mod
|
|
@@ -743,6 +745,73 @@ def _echo_infos(infos: list[pr_info_mod.PrInfo], as_json: bool, with_repo: bool)
|
|
|
743
745
|
typer.echo("\n\n".join(_info_text(i, with_repo) for i in infos))
|
|
744
746
|
|
|
745
747
|
|
|
748
|
+
@pr_app.command("logs")
|
|
749
|
+
def pr_logs(
|
|
750
|
+
build_id_arg: int | None = typer.Argument(
|
|
751
|
+
None, metavar="[BUILD_ID]", help="Same as --build-id (default: the PR's latest build per pipeline)"
|
|
752
|
+
),
|
|
753
|
+
target_branch: str | None = typer.Option(None, "--target-branch", help=_LOOKUP_TARGET_HELP),
|
|
754
|
+
pr_id: int | None = typer.Option(None, "--pr-id", help=_PR_ID_HELP),
|
|
755
|
+
build_id: int | None = typer.Option(
|
|
756
|
+
None,
|
|
757
|
+
"--build-id",
|
|
758
|
+
"--run-id",
|
|
759
|
+
help="Show this Azure DevOps build / GitHub Actions run directly instead of the PR's latest ones",
|
|
760
|
+
),
|
|
761
|
+
show_all: bool = typer.Option(
|
|
762
|
+
False, "--all", help="Print the log of succeeded steps too (they are one line each by default)"
|
|
763
|
+
),
|
|
764
|
+
step: str | None = typer.Option(
|
|
765
|
+
None,
|
|
766
|
+
"--step",
|
|
767
|
+
help="Only steps/jobs whose name (Stage / Job / Task on Azure DevOps) contains this text; their logs are printed, "
|
|
768
|
+
"succeeded or not",
|
|
769
|
+
),
|
|
770
|
+
tail: int = typer.Option(0, "--tail", help="Only the last N lines of each log (0 = everything, the default)"),
|
|
771
|
+
list_only: bool = typer.Option(False, "--list", help="Only list the steps/jobs and their result, without logs"),
|
|
772
|
+
as_json: bool = typer.Option(False, "--json", help="Print machine-readable JSON instead of text"),
|
|
773
|
+
timestamps: bool = typer.Option(False, "--timestamps", help="Keep the per-line timestamps (stripped by default)"),
|
|
774
|
+
pat: str | None = typer.Option(
|
|
775
|
+
None,
|
|
776
|
+
"--pat",
|
|
777
|
+
envvar=["AZURE_DEVOPS_EXT_PAT", "AZURE_DEVOPS_PAT"],
|
|
778
|
+
help="Azure DevOps PAT (else uses DefaultAzureCredential, e.g. your `az login`)",
|
|
779
|
+
),
|
|
780
|
+
) -> None:
|
|
781
|
+
"""Print the logs of the PR's builds (Azure DevOps) / workflow runs (GitHub, auto-detected):
|
|
782
|
+
every step is listed, but only failed steps print their log (succeeded ones are one line;
|
|
783
|
+
`--all` or `--step` print theirs too). The PR is the one opened from the
|
|
784
|
+
current branch, or --pr-id; --build-id picks one build/run directly.
|
|
785
|
+
GitHub keeps one log per job, so there `--step` filters jobs.
|
|
786
|
+
"""
|
|
787
|
+
if tail < 0:
|
|
788
|
+
raise typer.BadParameter("must be >= 0", param_hint="--tail")
|
|
789
|
+
if build_id_arg is not None and build_id is not None and build_id_arg != build_id:
|
|
790
|
+
raise typer.BadParameter("BUILD_ID and --build-id differ; give only one", param_hint="--build-id")
|
|
791
|
+
build_id = build_id if build_id is not None else build_id_arg
|
|
792
|
+
opts = pr_logs_mod.Options(
|
|
793
|
+
show_all=show_all, step=step, tail=tail, list_only=list_only, timestamps=timestamps, as_json=as_json
|
|
794
|
+
)
|
|
795
|
+
remote = current_remote()
|
|
796
|
+
if isinstance(remote, GitHubRemote):
|
|
797
|
+
gh = require_gh()
|
|
798
|
+
pr_logs_mod.run_github(
|
|
799
|
+
gh,
|
|
800
|
+
pr_id=None if build_id else gh_pr.resolve_pr_id(gh, pr_id, target_branch),
|
|
801
|
+
build_id=build_id,
|
|
802
|
+
opts=opts,
|
|
803
|
+
)
|
|
804
|
+
return
|
|
805
|
+
pr_logs_mod.run_ado(
|
|
806
|
+
remote,
|
|
807
|
+
pat,
|
|
808
|
+
target_branch,
|
|
809
|
+
pr_id=pr_id,
|
|
810
|
+
build_id=build_id,
|
|
811
|
+
opts=opts,
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
|
|
746
815
|
@pr_app.command("info")
|
|
747
816
|
def pr_info(
|
|
748
817
|
as_json: bool = typer.Option(
|
|
@@ -2571,6 +2640,76 @@ def cleanup_inspect(
|
|
|
2571
2640
|
typer.echo(f"{r.size_mb / 1024:6.2f} GB {r.repo.name}:{r.branch:<35} {r.verdict}\n {r.path}")
|
|
2572
2641
|
|
|
2573
2642
|
|
|
2643
|
+
@cleanup_app.command("claude-home")
|
|
2644
|
+
def cleanup_claude_home(
|
|
2645
|
+
root: Path | None = typer.Argument(
|
|
2646
|
+
None, help="Root folder to scan for repos with a .claude/worktrees dir (default: the `bdt find-repo` work dir)"
|
|
2647
|
+
),
|
|
2648
|
+
depth: int = typer.Option(2, "--depth", help="How many folder levels below root to look for repos"),
|
|
2649
|
+
as_json: bool = _AS_JSON_OPTION,
|
|
2650
|
+
) -> None:
|
|
2651
|
+
"""Read-only: Claude Code leftovers: old plugin versions and `.claude/worktrees` dirs git no longer knows.
|
|
2652
|
+
|
|
2653
|
+
Claude Code never removes old versions from ~/.claude/plugins/cache (honours CLAUDE_CONFIG_DIR). A version is
|
|
2654
|
+
`stale` when installed_plugins.json does not point at it and no live process is registered in its `.in_use`.
|
|
2655
|
+
`orphan` = a dir under `<repo>/.claude/worktrees` whose gitdir is gone (the files are the only copy; rows with
|
|
2656
|
+
a process inside, or where processes cannot be listed, are `review`). Worktrees git still knows show up in
|
|
2657
|
+
`bdt cleanup inspect`. Deletes nothing: `bdt cleanup claude-plugins --yes` removes stale plugin versions.
|
|
2658
|
+
"""
|
|
2659
|
+
report = cleanup_claude_mod.scan(
|
|
2660
|
+
cleanup_claude_mod.claude_dir(), (root or find_repo_mod.work_dir()).expanduser().resolve(), depth
|
|
2661
|
+
)
|
|
2662
|
+
if as_json:
|
|
2663
|
+
_echo_json(asdict(report))
|
|
2664
|
+
return
|
|
2665
|
+
stale = [r for r in report.plugins if r.verdict == "stale"]
|
|
2666
|
+
typer.echo(
|
|
2667
|
+
f"Plugin cache: {len(stale)} stale versions ({sum(r.size_mb for r in stale) / 1024:.1f} GB) "
|
|
2668
|
+
f"in {cleanup_claude_mod.claude_dir() / 'plugins' / 'cache'}"
|
|
2669
|
+
)
|
|
2670
|
+
for r in report.plugins:
|
|
2671
|
+
age = f"orphaned {r.orphaned_days}d ago" if r.orphaned_days is not None else "not installed"
|
|
2672
|
+
typer.echo(f"{r.size_mb / 1024:6.2f} GB {r.plugin:<45} {r.version:<14} {age}; {r.verdict}")
|
|
2673
|
+
orphans = [r for r in report.worktrees if r.verdict == "orphan"]
|
|
2674
|
+
typer.echo(
|
|
2675
|
+
f"\n.claude/worktrees dirs unknown to git: {len(orphans)} orphan "
|
|
2676
|
+
f"({sum(r.size_mb for r in orphans) / 1024:.1f} GB), {len(report.worktrees) - len(orphans)} to review"
|
|
2677
|
+
)
|
|
2678
|
+
if not report.process_check_available:
|
|
2679
|
+
typer.echo("note: running processes cannot be listed on this platform, so none of these is marked `orphan`")
|
|
2680
|
+
for r in report.worktrees:
|
|
2681
|
+
typer.echo(
|
|
2682
|
+
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"
|
|
2683
|
+
f" {r.path}"
|
|
2684
|
+
)
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
@cleanup_app.command("claude-plugins")
|
|
2688
|
+
def cleanup_claude_plugins(
|
|
2689
|
+
paths: list[Path] = typer.Argument(None, help="Only these plugin version dirs (default: every stale one)"),
|
|
2690
|
+
yes: bool = typer.Option(False, "--yes", help="Actually delete; without it only list what would go"),
|
|
2691
|
+
) -> None:
|
|
2692
|
+
"""Remove `stale` Claude Code plugin versions from ~/.claude/plugins/cache (see `bdt cleanup claude-home`).
|
|
2693
|
+
|
|
2694
|
+
Installed versions, `data/` and installed_plugins.json are never touched; installed/live state is re-checked
|
|
2695
|
+
at delete time, so a version a live session registered in the meantime is skipped.
|
|
2696
|
+
"""
|
|
2697
|
+
claude = cleanup_claude_mod.claude_dir()
|
|
2698
|
+
wanted = {p.resolve() for p in paths or []}
|
|
2699
|
+
stale = [
|
|
2700
|
+
r
|
|
2701
|
+
for r in cleanup_claude_mod.plugin_versions(claude, with_size=False)
|
|
2702
|
+
if r.verdict == "stale" and (not wanted or r.path.resolve() in wanted)
|
|
2703
|
+
]
|
|
2704
|
+
if not yes:
|
|
2705
|
+
for r in stale:
|
|
2706
|
+
typer.echo(f"would remove {r.plugin} {r.version} {r.path}")
|
|
2707
|
+
typer.echo(f"\n{len(stale)} stale plugin versions; re-run with --yes to remove")
|
|
2708
|
+
return
|
|
2709
|
+
removed = cleanup_claude_mod.delete_stale_plugins(claude, list(wanted))
|
|
2710
|
+
typer.echo(f"removed {removed} stale plugin versions")
|
|
2711
|
+
|
|
2712
|
+
|
|
2574
2713
|
def _draft_feat_pr(target: str | None, pat: str | None) -> None:
|
|
2575
2714
|
"""A 'feat' commit landing on an already-published PR forces it back to draft --
|
|
2576
2715
|
a feature needs a fresh review pass before CI/merge, not just whatever review
|