bmsdna-devtools 0.45.0__tar.gz → 0.47.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 (127) hide show
  1. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/PKG-INFO +53 -7
  2. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/README.md +52 -6
  3. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/ado_issue.py +28 -6
  4. bmsdna_devtools-0.47.0/bmsdna/devtools/business_user.py +144 -0
  5. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/cli.py +161 -10
  6. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/gh_pr.py +5 -0
  7. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/github_api.py +5 -0
  8. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/issue_show.py +13 -0
  9. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_build.py +19 -0
  10. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_info.py +3 -0
  11. bmsdna_devtools-0.47.0/bmsdna/devtools/pr_ref.py +90 -0
  12. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/pyproject.toml +1 -1
  13. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/skills/bmsdna-devtools/SKILL.md +14 -3
  14. bmsdna_devtools-0.47.0/tests/test_business_user.py +307 -0
  15. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_issue.py +68 -1
  16. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_info.py +335 -2
  17. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/uv.lock +1 -1
  18. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/.github/workflows/auto-release.yml +0 -0
  19. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/.github/workflows/python-publish.yml +0 -0
  20. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/.github/workflows/python-test.yml +0 -0
  21. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/.gitignore +0 -0
  22. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/.python-version +0 -0
  23. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/__init__.py +0 -0
  24. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/_api_dump.py +0 -0
  25. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/ado_auth.py +0 -0
  26. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/agent_mentions.py +0 -0
  27. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/api_usage.py +0 -0
  28. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/app_service_logs.py +0 -0
  29. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/azure_arm.py +0 -0
  30. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/azure_auth.py +0 -0
  31. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/bdt_config.py +0 -0
  32. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/cli_tools.py +0 -0
  33. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/commit.py +0 -0
  34. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/dead_code.py +0 -0
  35. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/env_config.py +0 -0
  36. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/env_files.py +0 -0
  37. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/find_injection.py +0 -0
  38. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/find_repo.py +0 -0
  39. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/gh_args.py +0 -0
  40. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/gh_issue.py +0 -0
  41. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/gitrepo.py +0 -0
  42. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/injection_frontend.py +0 -0
  43. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/injection_python.py +0 -0
  44. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/issue_do.py +0 -0
  45. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/issue_watch.py +0 -0
  46. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint.py +0 -0
  47. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_findings.py +0 -0
  48. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_models.py +0 -0
  49. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_sql.py +0 -0
  50. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_sql_files.py +0 -0
  51. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_tooling.py +0 -0
  52. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/lint_typescript.py +0 -0
  53. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/logs.py +0 -0
  54. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_choice.py +0 -0
  55. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_create_args.py +0 -0
  56. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_issue_link.py +0 -0
  57. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_labels.py +0 -0
  58. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pr_markdown.py +0 -0
  59. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/pull.py +0 -0
  60. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/testdb.py +0 -0
  61. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/translate.py +0 -0
  62. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/__init__.py +0 -0
  63. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/cli.py +0 -0
  64. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/pipeline.py +0 -0
  65. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/pricing.py +0 -0
  66. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/report.py +0 -0
  67. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  68. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  69. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  70. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  71. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  72. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  73. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  74. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/bmsdna/devtools/worktree.py +0 -0
  75. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/justfile +0 -0
  76. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/conftest.py +0 -0
  77. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/fake_github.py +0 -0
  78. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_ado_auth.py +0 -0
  79. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_ado_issue.py +0 -0
  80. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_ado_issue_flow.py +0 -0
  81. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_agent_mentions.py +0 -0
  82. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_api_usage.py +0 -0
  83. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_app_service_logs.py +0 -0
  84. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_azure_arm.py +0 -0
  85. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_bdt_config.py +0 -0
  86. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_cleanup.py +0 -0
  87. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_commit.py +0 -0
  88. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_pr_create.py +0 -0
  89. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_pr_id.py +0 -0
  90. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_pull.py +0 -0
  91. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_tools.py +0 -0
  92. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_cli_version.py +0 -0
  93. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_commit.py +0 -0
  94. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_env_config.py +0 -0
  95. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_env_files.py +0 -0
  96. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_find_injection.py +0 -0
  97. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_find_repo.py +0 -0
  98. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_gh_issue.py +0 -0
  99. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_gh_pr.py +0 -0
  100. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_github_api.py +0 -0
  101. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_gitrepo.py +0 -0
  102. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_issue_do.py +0 -0
  103. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_issue_for_me.py +0 -0
  104. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_issue_show.py +0 -0
  105. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_issue_watch.py +0 -0
  106. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint.py +0 -0
  107. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint_models.py +0 -0
  108. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint_sql.py +0 -0
  109. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint_sql_files.py +0 -0
  110. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint_tooling.py +0 -0
  111. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_lint_typescript.py +0 -0
  112. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_logs.py +0 -0
  113. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_build.py +0 -0
  114. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_build_create_options.py +0 -0
  115. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_build_flow.py +0 -0
  116. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_choice.py +0 -0
  117. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_create_args.py +0 -0
  118. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_description_not_truncated.py +0 -0
  119. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_issue_link.py +0 -0
  120. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_labels.py +0 -0
  121. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pr_markdown.py +0 -0
  122. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_pull.py +0 -0
  123. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_testdb.py +0 -0
  124. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_translate.py +0 -0
  125. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_usage.py +0 -0
  126. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_wait_timeout.py +0 -0
  127. {bmsdna_devtools-0.45.0 → bmsdna_devtools-0.47.0}/tests/test_worktree_clean.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bmsdna-devtools
3
- Version: 0.45.0
3
+ Version: 0.47.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
@@ -19,7 +19,7 @@ Description-Content-Type: text/markdown
19
19
  # bmsdna-devtools
20
20
 
21
21
  Shared developer tooling for BMS projects: PR build/check status and a
22
- one-shot PR summary (`bdt pr info`), PR creation, claiming an issue (`bdt issue take`), issue/work item creation and comments, finding issues addressed to an agent (`bdt issue search --for-me`) and waiting for new comments (`bdt issue watch`), git worktrees (creation and
22
+ one-shot PR summary (`bdt pr info`), PR creation, claiming an issue (`bdt issue take`), issue/work item creation and comments, finding issues addressed to an agent (`bdt issue search --for-me`), finding issues filed by business users (`bdt issue search --business-user`) and waiting for new comments (`bdt issue watch`), git worktrees (creation and
23
23
  merged-worktree/orphaned-test-DB cleanup), a commit-and-push helper with
24
24
  pre-flight checks, Azure log queries, and static checks (`bdt lint`) for
25
25
  postgres/psycopg (and arrowbricks) SQL rules, pydantic-model placement, hand-wired HTTP access in
@@ -122,7 +122,7 @@ it watches a branch-triggered build/workflow run, not any particular PR.)
122
122
  ## `bdt pr info`
123
123
 
124
124
  ```bash
125
- bdt pr info [--json] [--pr-id N] [--target-branch BRANCH]
125
+ bdt pr info [--json] [--pr-id PR]... [--target-branch BRANCH] [--all]
126
126
  ```
127
127
 
128
128
  One-shot summary of the current branch's PR: link, state (open/merged/closed, draft), aggregate
@@ -133,6 +133,24 @@ the check rollup (only a failed check fails it; skipped/cancelled ones don't cou
133
133
  from the latest build of each pipeline (any failed result fails it; unfinished builds are pending, or
134
134
  `waiting` when a stage needs approval). `unknown` if Azure DevOps can't be asked.
135
135
 
136
+ `--all` lists every open PR from the current branch (e.g. one into `dev` and one into `main`, which plain
137
+ `bdt pr info` refuses to pick between): with `--json` an array of the same objects, `[]` (exit 0) when there is
138
+ none; `--target-branch` narrows it, `--pr-id` can't be combined with it. Only open PRs are listed, and a PR with
139
+ merge conflicts is listed like any other (plain `pr info` on Azure DevOps errors on it).
140
+
141
+ `--pr-id` takes several PRs, also of other repos: repeat it and/or comma-separate (`--pr-id 12,34 --pr-id owner/repo#5`).
142
+ Each entry is a bare number (a PR of the current repo), `owner/repo#N` (GitHub), `project/repo#N` or
143
+ `org/project/repo#N` (Azure DevOps; the host is the current repo's, and the org is its org unless given), or the PR's
144
+ URL (GitHub, `dev.azure.com` or `*.visualstudio.com`; the only form that needs no git checkout). One plain number
145
+ behaves as before: the single object. One `owner/repo#N` is a single object too; two or more entries print a list in the
146
+ order given (duplicates once), as `--json` an array like `--all`'s, as text with the repo in each header. A failing entry
147
+ (unknown number, no access) doesn't hide the others: it is reported as `error: <entry>: <reason>` on stderr, the rest is
148
+ still printed, and the exit code is 1. An unreadable entry is a usage error before anything is looked up. `--pr-id` can't
149
+ be combined with `--all`; `--target-branch` is ignored for it, as before. Azure DevOps entries use one PAT/`az login` for
150
+ every org, and a PR with merge conflicts is an error entry there.
151
+
152
+ Every JSON object has a `repo` (`owner/repo` on GitHub, `org/project/repo` on Azure DevOps).
153
+
136
154
  Azure DevOps limits: the PR is found by the current branch (into `--target-branch` if given, else any target),
137
155
  a PR with merge conflicts is reported as an error (exit 1) like `pr status` does, and the closed
138
156
  work items are only those whose URL is in the PR description -- not ones linked via
@@ -290,8 +308,7 @@ bdt pr comment --message "Looks good" [--screenshot shot.png] [--file report.pdf
290
308
  bdt pr comment --message-file plan.md # post a file's text as the comment (`-` = stdin)
291
309
  ```
292
310
 
293
- `--file` links the file as an *attachment* (a download link in the comment); it does not post the file's
294
- content. To post a markdown document (an implementation plan, review findings) use `--message-file`.
311
+ Use `--message-file` to post a markdown document (an implementation plan, review findings) as the comment.
295
312
 
296
313
  ## `bdt issue create` / `show` / `update` / `delete`, `bdt issue comment add` / `update` / `delete`
297
314
 
@@ -316,8 +333,10 @@ adds/edits/deletes comments on one, auto-detected from `origin` like `bdt pr
316
333
  `issue show NUMBER` prints one issue / work item: state, title, URL, description, tags, links to other
317
334
  issues (parent, children, blocked by, blocks; related on Azure DevOps), the Azure DevOps Type / Area /
318
335
  Iteration / Assigned to (GitHub: assignees, milestone) and all comments (Azure DevOps HTML is shown as plain
319
- text). `--json` prints the same as one JSON document (`number, title, state, url, body, tags, fields,
320
- parent, children, blocked_by, blocks, related, comments`).
336
+ text). On Azure DevOps it also prints `Created by:` with whether the creator is a business user (see
337
+ [`bdt issue search --business-user`](#bdt-issue-search---business-user)). `--json` prints the same as one JSON
338
+ document (`number, title, state, url, body, tags, fields, parent, children, blocked_by, blocks, related,
339
+ comments, created_by, business_user, business_user_reason`; the last three are `null` on GitHub).
321
340
 
322
341
  `--parent ID` and `--blocked-by ID` (repeatable) on `create` and `update` link the item to its parent and to
323
342
  the issues / work items that block it, on both backends. On `update` only the links that are missing are
@@ -519,6 +538,33 @@ bdt issue watch 84 --since-comment 123 --skip-own --json --timeout 1800
519
538
  - A single failed poll (network blip, API error) is retried; three in a row abort with the error.
520
539
  - On Azure DevOps only the newest 100 comments of a work item are looked at per poll.
521
540
 
541
+ ## `bdt issue search --business-user`
542
+
543
+ Business users file work items too, often with vague wording, and those need a different handling than a
544
+ developer's. `--business-user` (Azure DevOps only) keeps the work items **created by a business user**:
545
+
546
+ ```bash
547
+ bdt issue search --business-user [--commit-depth 1000] [--tag needs-techie] [--for-me] [--state open] ...
548
+ bdt issue show 1234 # also prints: Created by: Sam Sales (business user: Stakeholder license)
549
+ ```
550
+
551
+ A creator is a business user when
552
+
553
+ 1. their license is **Stakeholder** (Member Entitlement API; needs a PAT with the *Member Entitlement
554
+ Management (read)* scope), or
555
+ 2. they authored **none of the last `--commit-depth` commits** (default 1000) of the repo you run `bdt` in. This
556
+ also decides when the license can't be read (missing PAT scope, ...) -- the license is then "unknown"; it is
557
+ not an error.
558
+
559
+ The commit check matches the creator's email, else display name (a heuristic: two people sharing a name are
560
+ taken for one), against the authors and committers of those commits (`.mailmap` applied). Identities that are
561
+ not a person (build service, service accounts: no email as `uniqueName`) stay "unknown". A developer whose last commit is older than that window, or who works in other
562
+ repos, counts as a business user here. A shallow clone with less history than `--commit-depth` can't say who never
563
+ committed, so the creator stays "unknown" and is not returned by `--business-user`. `issue show` prints the reason
564
+ next to the creator -- `business user`, `developer` or `unknown` -- and `--json` has `created_by`, `business_user`
565
+ and `business_user_reason`. `--business-user` can't be combined with `--org-wide` (the commit check is about this
566
+ repo's history).
567
+
522
568
  ## `bdt env get-keys`
523
569
 
524
570
  Lists the variable **names** (never the values) defined in `.env`, `*.env` and `.env.*` files under the
@@ -1,7 +1,7 @@
1
1
  # bmsdna-devtools
2
2
 
3
3
  Shared developer tooling for BMS projects: PR build/check status and a
4
- one-shot PR summary (`bdt pr info`), PR creation, claiming an issue (`bdt issue take`), issue/work item creation and comments, finding issues addressed to an agent (`bdt issue search --for-me`) and waiting for new comments (`bdt issue watch`), git worktrees (creation and
4
+ one-shot PR summary (`bdt pr info`), PR creation, claiming an issue (`bdt issue take`), issue/work item creation and comments, finding issues addressed to an agent (`bdt issue search --for-me`), finding issues filed by business users (`bdt issue search --business-user`) and waiting for new comments (`bdt issue watch`), git worktrees (creation and
5
5
  merged-worktree/orphaned-test-DB cleanup), a commit-and-push helper with
6
6
  pre-flight checks, Azure log queries, and static checks (`bdt lint`) for
7
7
  postgres/psycopg (and arrowbricks) SQL rules, pydantic-model placement, hand-wired HTTP access in
@@ -104,7 +104,7 @@ it watches a branch-triggered build/workflow run, not any particular PR.)
104
104
  ## `bdt pr info`
105
105
 
106
106
  ```bash
107
- bdt pr info [--json] [--pr-id N] [--target-branch BRANCH]
107
+ bdt pr info [--json] [--pr-id PR]... [--target-branch BRANCH] [--all]
108
108
  ```
109
109
 
110
110
  One-shot summary of the current branch's PR: link, state (open/merged/closed, draft), aggregate
@@ -115,6 +115,24 @@ the check rollup (only a failed check fails it; skipped/cancelled ones don't cou
115
115
  from the latest build of each pipeline (any failed result fails it; unfinished builds are pending, or
116
116
  `waiting` when a stage needs approval). `unknown` if Azure DevOps can't be asked.
117
117
 
118
+ `--all` lists every open PR from the current branch (e.g. one into `dev` and one into `main`, which plain
119
+ `bdt pr info` refuses to pick between): with `--json` an array of the same objects, `[]` (exit 0) when there is
120
+ none; `--target-branch` narrows it, `--pr-id` can't be combined with it. Only open PRs are listed, and a PR with
121
+ merge conflicts is listed like any other (plain `pr info` on Azure DevOps errors on it).
122
+
123
+ `--pr-id` takes several PRs, also of other repos: repeat it and/or comma-separate (`--pr-id 12,34 --pr-id owner/repo#5`).
124
+ Each entry is a bare number (a PR of the current repo), `owner/repo#N` (GitHub), `project/repo#N` or
125
+ `org/project/repo#N` (Azure DevOps; the host is the current repo's, and the org is its org unless given), or the PR's
126
+ URL (GitHub, `dev.azure.com` or `*.visualstudio.com`; the only form that needs no git checkout). One plain number
127
+ behaves as before: the single object. One `owner/repo#N` is a single object too; two or more entries print a list in the
128
+ order given (duplicates once), as `--json` an array like `--all`'s, as text with the repo in each header. A failing entry
129
+ (unknown number, no access) doesn't hide the others: it is reported as `error: <entry>: <reason>` on stderr, the rest is
130
+ still printed, and the exit code is 1. An unreadable entry is a usage error before anything is looked up. `--pr-id` can't
131
+ be combined with `--all`; `--target-branch` is ignored for it, as before. Azure DevOps entries use one PAT/`az login` for
132
+ every org, and a PR with merge conflicts is an error entry there.
133
+
134
+ Every JSON object has a `repo` (`owner/repo` on GitHub, `org/project/repo` on Azure DevOps).
135
+
118
136
  Azure DevOps limits: the PR is found by the current branch (into `--target-branch` if given, else any target),
119
137
  a PR with merge conflicts is reported as an error (exit 1) like `pr status` does, and the closed
120
138
  work items are only those whose URL is in the PR description -- not ones linked via
@@ -272,8 +290,7 @@ bdt pr comment --message "Looks good" [--screenshot shot.png] [--file report.pdf
272
290
  bdt pr comment --message-file plan.md # post a file's text as the comment (`-` = stdin)
273
291
  ```
274
292
 
275
- `--file` links the file as an *attachment* (a download link in the comment); it does not post the file's
276
- content. To post a markdown document (an implementation plan, review findings) use `--message-file`.
293
+ Use `--message-file` to post a markdown document (an implementation plan, review findings) as the comment.
277
294
 
278
295
  ## `bdt issue create` / `show` / `update` / `delete`, `bdt issue comment add` / `update` / `delete`
279
296
 
@@ -298,8 +315,10 @@ adds/edits/deletes comments on one, auto-detected from `origin` like `bdt pr
298
315
  `issue show NUMBER` prints one issue / work item: state, title, URL, description, tags, links to other
299
316
  issues (parent, children, blocked by, blocks; related on Azure DevOps), the Azure DevOps Type / Area /
300
317
  Iteration / Assigned to (GitHub: assignees, milestone) and all comments (Azure DevOps HTML is shown as plain
301
- text). `--json` prints the same as one JSON document (`number, title, state, url, body, tags, fields,
302
- parent, children, blocked_by, blocks, related, comments`).
318
+ text). On Azure DevOps it also prints `Created by:` with whether the creator is a business user (see
319
+ [`bdt issue search --business-user`](#bdt-issue-search---business-user)). `--json` prints the same as one JSON
320
+ document (`number, title, state, url, body, tags, fields, parent, children, blocked_by, blocks, related,
321
+ comments, created_by, business_user, business_user_reason`; the last three are `null` on GitHub).
303
322
 
304
323
  `--parent ID` and `--blocked-by ID` (repeatable) on `create` and `update` link the item to its parent and to
305
324
  the issues / work items that block it, on both backends. On `update` only the links that are missing are
@@ -501,6 +520,33 @@ bdt issue watch 84 --since-comment 123 --skip-own --json --timeout 1800
501
520
  - A single failed poll (network blip, API error) is retried; three in a row abort with the error.
502
521
  - On Azure DevOps only the newest 100 comments of a work item are looked at per poll.
503
522
 
523
+ ## `bdt issue search --business-user`
524
+
525
+ Business users file work items too, often with vague wording, and those need a different handling than a
526
+ developer's. `--business-user` (Azure DevOps only) keeps the work items **created by a business user**:
527
+
528
+ ```bash
529
+ bdt issue search --business-user [--commit-depth 1000] [--tag needs-techie] [--for-me] [--state open] ...
530
+ bdt issue show 1234 # also prints: Created by: Sam Sales (business user: Stakeholder license)
531
+ ```
532
+
533
+ A creator is a business user when
534
+
535
+ 1. their license is **Stakeholder** (Member Entitlement API; needs a PAT with the *Member Entitlement
536
+ Management (read)* scope), or
537
+ 2. they authored **none of the last `--commit-depth` commits** (default 1000) of the repo you run `bdt` in. This
538
+ also decides when the license can't be read (missing PAT scope, ...) -- the license is then "unknown"; it is
539
+ not an error.
540
+
541
+ The commit check matches the creator's email, else display name (a heuristic: two people sharing a name are
542
+ taken for one), against the authors and committers of those commits (`.mailmap` applied). Identities that are
543
+ not a person (build service, service accounts: no email as `uniqueName`) stay "unknown". A developer whose last commit is older than that window, or who works in other
544
+ repos, counts as a business user here. A shallow clone with less history than `--commit-depth` can't say who never
545
+ committed, so the creator stays "unknown" and is not returned by `--business-user`. `issue show` prints the reason
546
+ next to the creator -- `business user`, `developer` or `unknown` -- and `--json` has `created_by`, `business_user`
547
+ and `business_user_reason`. `--business-user` can't be combined with `--org-wide` (the commit check is about this
548
+ repo's history).
549
+
504
550
  ## `bdt env get-keys`
505
551
 
506
552
  Lists the variable **names** (never the values) defined in `.env`, `*.env` and `.env.*` files under the
@@ -50,6 +50,7 @@ from urllib.parse import quote
50
50
  import requests
51
51
 
52
52
  from .bdt_config import load_bdt_table
53
+ from .business_user import BusinessUserDetector
53
54
  from .cli_tools import ensure_agent_session_note
54
55
  from .gitrepo import AdoRemote
55
56
  from .issue_show import IssueDetails
@@ -324,9 +325,12 @@ def get_work_item(session: requests.Session, remote: AdoRemote, work_item_id: in
324
325
  return r.json()
325
326
 
326
327
 
327
- def get_details(session: requests.Session, remote: AdoRemote, work_item_id: int) -> IssueDetails:
328
+ def get_details(
329
+ session: requests.Session, remote: AdoRemote, work_item_id: int, business_users: BusinessUserDetector | None = None
330
+ ) -> IssueDetails:
328
331
  """What `bdt issue show` prints for a work item: its fields, links and comments. Long text
329
- (Description, comments) is HTML as stored; it is shown as plain text."""
332
+ (Description, comments) is HTML as stored; it is shown as plain text. With `business_users`, also who
333
+ created it and whether that is a business user."""
330
334
  work_item = get_work_item(session, remote, work_item_id)
331
335
  fields = work_item.get("fields", {})
332
336
  relations = work_item.get("relations") or []
@@ -338,6 +342,8 @@ def get_details(session: requests.Session, remote: AdoRemote, work_item_id: int)
338
342
  if isinstance(assigned_to, dict):
339
343
  assigned_to = assigned_to.get("displayName")
340
344
  parents = linked(PARENT_REL)
345
+ creator = fields.get("System.CreatedBy")
346
+ verdict = business_users.verdict(creator) if business_users else None
341
347
  return IssueDetails(
342
348
  number=work_item_id,
343
349
  title=fields.get("System.Title", ""),
@@ -357,6 +363,9 @@ def get_details(session: requests.Session, remote: AdoRemote, work_item_id: int)
357
363
  blocks=linked(BLOCKS_REL),
358
364
  related=linked(RELATED_REL),
359
365
  comments=to_comments(list_all_comments(session, remote, work_item_id), is_html=True),
366
+ created_by=creator.get("displayName") if isinstance(creator, dict) else None,
367
+ business_user=verdict.business_user if verdict else None,
368
+ business_user_reason=verdict.reason if verdict else None,
360
369
  )
361
370
 
362
371
 
@@ -700,7 +709,9 @@ def run_wiql(session: requests.Session, remote: AdoRemote, wiql: str, top: int,
700
709
  return [wi["id"] for wi in r.json()["workItems"]]
701
710
 
702
711
 
703
- def get_work_items(session: requests.Session, remote: AdoRemote, ids: list[int], org_wide: bool = False) -> list[dict]:
712
+ def get_work_items(
713
+ session: requests.Session, remote: AdoRemote, ids: list[int], org_wide: bool = False, with_creator: bool = False
714
+ ) -> list[dict]:
704
715
  """Batch-fetch Title/State (plus TeamProject when `org_wide`) for a set of work item ids, in
705
716
  the given `ids` order — WIQL only returns ids (not field values), and this batch endpoint
706
717
  doesn't guarantee it echoes them back in the order they were requested, so the caller's WIQL
@@ -708,12 +719,14 @@ def get_work_items(session: requests.Session, remote: AdoRemote, ids: list[int],
708
719
 
709
720
  `org_wide` fetches via the org-level endpoint (ids from an org-wide `run_wiql` may belong to
710
721
  a project other than `remote.project`) and also asks for `System.TeamProject`, so `search()`
711
- can show which project each result came from.
722
+ can show which project each result came from. `with_creator` also asks for `System.CreatedBy`.
712
723
  """
713
724
  if not ids:
714
725
  return []
715
726
  base = _org_url(remote) if org_wide else _base_url(remote)
716
727
  fields = "System.Title,System.State,System.TeamProject" if org_wide else "System.Title,System.State"
728
+ if with_creator:
729
+ fields += ",System.CreatedBy"
717
730
  r = session.get(
718
731
  f"{base}/_apis/wit/workitems",
719
732
  params={"ids": ",".join(map(str, ids)), "fields": fields, "api-version": "7.1"},
@@ -756,6 +769,7 @@ def search(
756
769
  tags: list[str] | None = None,
757
770
  comment_filter: Callable[[str | None], bool] | None = None,
758
771
  scan_limit: int | None = None,
772
+ business_users: BusinessUserDetector | None = None,
759
773
  ) -> list[dict]:
760
774
  """Search (or, with no keywords, just list) work items by keywords (ANDed, matched against
761
775
  Title or Description) and state, most recently changed first. `board` is an Azure Boards team
@@ -771,13 +785,21 @@ def search(
771
785
  e.g. `bdt issue search --for-me`. WIQL can't query comments, so up to `_COMMENT_FILTER_POOL`
772
786
  candidates are fetched and checked one by one, stopping once `top` have matched. `scan_limit` sizes that
773
787
  pool as if it were `top` (default: `top`), for a caller that wants few results out of a wide scan.
788
+
789
+ `business_users` keeps only work items created by a business user (see `business_user.py`), checked before
790
+ `comment_filter` since it costs no request per work item.
774
791
  """
775
792
  if org_wide and board:
776
793
  sys.exit("--board can't be combined with --org-wide (a board's Area Path is scoped to a single project).")
777
794
  area_path = get_team_area_path(session, remote, board) if board else None
778
795
  wiql = build_search_wiql(keywords, since, area_path, state, org_wide=org_wide, tags=tags)
779
- ids = run_wiql(session, remote, wiql, min((scan_limit or top) * 10, _COMMENT_FILTER_POOL) if comment_filter else top, org_wide=org_wide)
780
- items = get_work_items(session, remote, ids, org_wide=org_wide)
796
+ filtered = comment_filter or business_users
797
+ ids = run_wiql(session, remote, wiql, min((scan_limit or top) * 10, _COMMENT_FILTER_POOL) if filtered else top, org_wide=org_wide)
798
+ items = get_work_items(session, remote, ids, org_wide=org_wide, with_creator=business_users is not None)
799
+ if business_users:
800
+ items = [i for i in items if business_users.verdict(i["fields"].get("System.CreatedBy")).business_user]
801
+ if not comment_filter:
802
+ items = items[:top]
781
803
  if comment_filter:
782
804
  items = _filter_by_last_comment(session, remote, items, top, comment_filter)
783
805
  for item in items:
@@ -0,0 +1,144 @@
1
+ """Is the creator of an Azure DevOps work item a business user (as opposed to a developer)?
2
+
3
+ Backs `bdt issue search --business-user` and the `Created by` line of `bdt issue show`. A creator is a
4
+ business user when
5
+
6
+ 1. their Azure DevOps license is `Stakeholder` (Member Entitlement API), or
7
+ 2. they authored none of the last `DEFAULT_COMMIT_DEPTH` commits of the local repo.
8
+
9
+ The entitlement API needs a PAT with the "Member Entitlement Management (read)" scope; when it is not
10
+ reachable the license is treated as unknown and only the commit check decides.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import subprocess
16
+ from collections.abc import Callable
17
+ from dataclasses import dataclass
18
+ from functools import cached_property
19
+ from pathlib import Path
20
+ from urllib.parse import quote
21
+
22
+ import requests
23
+
24
+ from .gitrepo import AdoRemote
25
+
26
+ DEFAULT_COMMIT_DEPTH = 1000
27
+ STAKEHOLDER = "stakeholder"
28
+ _ENTITLEMENT_API_VERSION = "7.1-preview.3"
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class Verdict:
33
+ """`business_user` is None when neither check could tell (no license info, no usable git history)."""
34
+
35
+ business_user: bool | None
36
+ reason: str
37
+
38
+
39
+ @dataclass(frozen=True)
40
+ class CommitAuthors:
41
+ """Lowercased emails and names of the authors and committers of the last `depth` commits."""
42
+
43
+ emails: frozenset[str]
44
+ names: frozenset[str]
45
+ depth: int
46
+
47
+ def contains(self, email: str | None, name: str | None) -> bool:
48
+ return bool(email and email.casefold() in self.emails) or bool(name and name.casefold() in self.names)
49
+
50
+
51
+ def read_commit_authors(depth: int = DEFAULT_COMMIT_DEPTH, cwd: Path | None = None) -> CommitAuthors | None:
52
+ """The authors of the last `depth` commits of the repo at `cwd`, or None when that history can't tell who never
53
+ committed: not a git repo, or a shallow clone that has fewer than `depth` commits."""
54
+ # %aE/%aN/%cE/%cN honour .mailmap; \x1f can't occur in a name, and a name can't hold a newline
55
+ log = subprocess.run(
56
+ ["git", "log", "-n", str(depth), "--format=%aE%x1f%aN%x1f%cE%x1f%cN"],
57
+ capture_output=True,
58
+ encoding="utf-8",
59
+ errors="replace",
60
+ cwd=cwd,
61
+ check=False,
62
+ )
63
+ if log.returncode != 0:
64
+ return None
65
+ rows = [fields for line in log.stdout.split("\n") if len(fields := line.split("\x1f")) == 4]
66
+ # `--is-shallow-repository` needs git 2.15; the shallow file's presence works everywhere
67
+ shallow_file = subprocess.run(["git", "rev-parse", "--git-path", "shallow"], capture_output=True, text=True, cwd=cwd, check=False)
68
+ if shallow_file.returncode == 0 and (cwd or Path()).joinpath(shallow_file.stdout.strip()).exists() and len(rows) < depth:
69
+ return None
70
+ return CommitAuthors(
71
+ emails=frozenset(v.casefold() for row in rows for v in (row[0], row[2]) if v),
72
+ names=frozenset(v.casefold() for row in rows for v in (row[1], row[3]) if v),
73
+ depth=depth,
74
+ )
75
+
76
+
77
+ def get_license(session: requests.Session, remote: AdoRemote, identity_id: str) -> str | None:
78
+ """The account license type of an identity, lowercased (`stakeholder`, `express`, `advanced`, `none`, ...), or None
79
+ when the entitlement API doesn't answer (missing PAT scope, user not in the org, outage, ...): the license is
80
+ optional enrichment, and the commit check still has a say without it."""
81
+ try:
82
+ r = session.get(
83
+ f"https://vsaex.dev.azure.com/{remote.org}/_apis/userentitlements/{quote(identity_id, safe='')}",
84
+ params={"api-version": _ENTITLEMENT_API_VERSION},
85
+ )
86
+ except requests.RequestException:
87
+ return None
88
+ if r.status_code != 200:
89
+ return None
90
+ try:
91
+ body = r.json()
92
+ except ValueError: # e.g. an HTML sign-in page for a PAT that may not use this API
93
+ return None
94
+ license_type = ((body.get("accessLevel") if isinstance(body, dict) else None) or {}).get("accountLicenseType")
95
+ return license_type.casefold() if isinstance(license_type, str) else None
96
+
97
+
98
+ def classify(
99
+ license_type: str | None, read_authors: Callable[[], CommitAuthors | None], email: str | None, name: str | None
100
+ ) -> Verdict:
101
+ """Stakeholder license -> business user; else, no commit by this person in `read_authors()` (only called when the
102
+ license doesn't settle it) -> business user."""
103
+ if license_type == STAKEHOLDER:
104
+ return Verdict(True, "Stakeholder license")
105
+ authors = read_authors()
106
+ known_license = f"{license_type} license" if license_type else "license unknown"
107
+ if authors is None:
108
+ return Verdict(None, f"{known_license}, commit history unavailable")
109
+ if authors.contains(email, name):
110
+ return Verdict(False, f"{known_license}, has commits")
111
+ return Verdict(True, f"{known_license}, no commits in the last {authors.depth} of this repo")
112
+
113
+
114
+ class BusinessUserDetector:
115
+ """Judges work item creators (the `System.CreatedBy` identity dict), looking up each license once and reading
116
+ the git history of the current directory's repo once per detector."""
117
+
118
+ def __init__(self, session: requests.Session, remote: AdoRemote, commit_depth: int = DEFAULT_COMMIT_DEPTH) -> None:
119
+ self._session = session
120
+ self._remote = remote
121
+ self._commit_depth = commit_depth
122
+ self._licenses: dict[str, str | None] = {}
123
+
124
+ @cached_property
125
+ def _commit_authors(self) -> CommitAuthors | None:
126
+ return read_commit_authors(self._commit_depth)
127
+
128
+ def _license(self, identity_id: str | None) -> str | None:
129
+ if not identity_id:
130
+ return None
131
+ if identity_id not in self._licenses:
132
+ self._licenses[identity_id] = get_license(self._session, self._remote, identity_id)
133
+ return self._licenses[identity_id]
134
+
135
+ def verdict(self, creator: dict | None) -> Verdict:
136
+ """`creator` is the `System.CreatedBy` field: an identity dict (`id`, `uniqueName`, `displayName`)."""
137
+ if not isinstance(creator, dict):
138
+ return Verdict(None, "creator unknown")
139
+ if "@" not in (creator.get("uniqueName") or ""):
140
+ # build service, service accounts, ...: no license, no commits, and not someone to ask questions
141
+ return Verdict(None, "not a person")
142
+ identity_id = creator.get("id")
143
+ license_type = self._license(identity_id if isinstance(identity_id, str) else None)
144
+ return classify(license_type, lambda: self._commit_authors, creator.get("uniqueName"), creator.get("displayName"))