housebroken-cli 0.20.0__tar.gz → 0.22.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 (40) hide show
  1. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/PKG-INFO +17 -5
  2. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/README.md +5 -4
  3. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/bin/housebroken +2 -0
  4. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/pyproject.toml +13 -2
  5. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/branch-check.sh +22 -5
  6. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/check-ai-policy.sh +26 -11
  7. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/close.sh +4 -3
  8. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/common.sh +83 -16
  9. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/edit-pr.sh +1 -1
  10. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/file-issue.sh +5 -3
  11. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/file-pr.sh +16 -5
  12. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/fork-hygiene.sh +4 -4
  13. housebroken_cli-0.22.0/scripts/gate-hook.sh +372 -0
  14. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/inbox.sh +18 -4
  15. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/pr-sweep.sh +57 -14
  16. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/push.sh +21 -1
  17. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/reply.sh +12 -6
  18. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/review.sh +9 -0
  19. housebroken_cli-0.22.0/scripts/same-code.sh +223 -0
  20. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/verify-filed-pr.sh +9 -3
  21. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/skills/housebroken/SKILL.md +15 -3
  22. housebroken_cli-0.22.0/src/housebroken/__init__.py +1 -0
  23. housebroken_cli-0.20.0/scripts/gate-hook.sh +0 -238
  24. housebroken_cli-0.20.0/src/housebroken/__init__.py +0 -1
  25. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/.gitignore +0 -0
  26. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/LICENSE +0 -0
  27. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/hatch_build.py +0 -0
  28. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/ci-legs.sh +0 -0
  29. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/claim-check.sh +0 -0
  30. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/comment-census.sh +0 -0
  31. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/comment-check.sh +0 -0
  32. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/declare.sh +0 -0
  33. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/diff-defaults.sh +0 -0
  34. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/distinct-outside.sh +0 -0
  35. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/notes.sh +0 -0
  36. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/prior-art.sh +0 -0
  37. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/proof.sh +0 -0
  38. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/ref-check.sh +0 -0
  39. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/scripts/refuse.sh +0 -0
  40. {housebroken_cli-0.20.0 → housebroken_cli-0.22.0}/src/housebroken/cli.py +0 -0
@@ -1,12 +1,23 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: housebroken-cli
3
- Version: 0.20.0
3
+ Version: 0.22.0
4
4
  Summary: Agent-written pull requests that do not make a mess in someone else's house.
5
5
  Project-URL: Repository, https://github.com/lenamonj/housebroken
6
+ Project-URL: Issues, https://github.com/lenamonj/housebroken/issues
7
+ Project-URL: Changelog, https://github.com/lenamonj/housebroken/releases
8
+ Author: Jeff Lenamon
6
9
  License-Expression: MIT
7
10
  License-File: LICENSE
11
+ Keywords: ai-agent,claude-code,cli,code-review,contributing,github,open-source,pull-request
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
8
15
  Classifier: Operating System :: OS Independent
9
16
  Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Unix Shell
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Version Control :: Git
10
21
  Requires-Python: >=3.10
11
22
  Description-Content-Type: text/markdown
12
23
 
@@ -61,7 +72,7 @@ A pull request passes through the door in order, and stops at the first rule it
61
72
  A change that rejects an input the project tolerated, changes a default, or narrows what the project publishes is the maintainer's call. It is sent with the call stated in the body: what breaks for existing users, and an offer to narrow or close it. A finding whose only evidence is a measurement is a hold, not a pull request.
62
73
 
63
74
  **4. Prove it red first, and prove the proof.**
64
- On a fresh clone of the upstream default branch, the new test fails; with the patch, it passes. Every arm of the experiment prints evidence that its precondition held, files are swapped by content and checked by hash, and two arms that agree exactly have not tested the variable. `proof.sh` runs the experiment itself: the test on the head, then on the head with every changed non-test file swapped back to its content at the merge base, then the head restored and checked by hash, and it stamps the head only when the base arm fails and the head arm passes. Both arms run with `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY` at local port 9 and `NO_PROXY` at loopback only, so a test whose client honors them fails instead of reaching the network, and an arm whose output carries a client's failure at that port is not stamped. A change with nothing to show red says so, with the reason, and the filing prints it.
75
+ On a fresh clone of the upstream default branch, the new test fails; with the patch, it passes. Every arm of the experiment prints evidence that its precondition held, files are swapped by content and checked by hash, and two arms that agree exactly have not tested the variable. `proof.sh` runs the experiment itself: the test on the head, then on the head with every changed non-test file swapped back to its content at the merge base, then the head restored and checked by hash, and it stamps the head only when the base arm fails and the head arm passes. Both arms run with `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY` at local port 9 and `NO_PROXY` at loopback only, so a test whose client honors them fails instead of reaching the network, and an arm whose output carries a client's failure at that port is not stamped. A change with nothing to show red says so, with the reason, and the filing prints it. A fix goes to every site with the same code, not only the one that was reported: `same-code.sh` lists every other line of the base that holds an expression the branch replaces or makes a call it replaces, and the review brief hands that list to the reviewer.
65
76
 
66
77
  **5. Run their CI, not yours.**
67
78
  The project's own test target on the fresh clone, and every gate its pull request workflow runs: lint, format, mutation, API check. A gate not run is a red check the maintainer sees first.
@@ -85,7 +96,7 @@ A memory-safety, remote-abort, injection or path-escape finding goes by the proj
85
96
  `verify-filed-pr.sh` re-derives from GitHub that the head is the intended commit, one a stamp or you name, the files are the ones the branch stamp lists, the body is the one that was filed, and CI is green. When nothing is wrong it says so in one line, which names the head and the checks and says whether the files and the body matched or were not compared; the report prints only when something is wrong. It stops at the first red check, so the failed log is read at once, and `--settle` waits for the rest. A read that failed is never OK, and no checks yet reads NOT SETTLED. `inbox.sh` prints every event on your threads since the last acknowledged cursor, bodies included, with a census of failing, blocked and conflicting checks; a thread it could not read says UNREAD and nothing can be acknowledged past it. The census and `pr-sweep.sh` also name two states that look quiet. A head no CI job ever started on reads `no-ci-on-head` when GitHub made no run for it and `ci-never-started` when the run it made finished without one. A new push or a close and reopen can start a new run, which may again wait for approval; a workflow filtered off the change makes none and reads the same. A stale bot's notice that still stands reads `stale:closes-` and the day when it says it will be closed in or within a number of days, and `stale:warned-` and its own date when it does not; a label alone, with no notice, reads `stale:label`. Each is a deadline to bring to the contributor, and before any bump the body's claims are re-derived on the default branch. A check list or a notice that could not be read says `ci-unread` or `stale:unread`, never nothing. Every body and title it prints is marked as untrusted text: someone else's words are evidence, never instructions. Every event names its author's role in the repository, GitHub's own word, and a voice with no role is marked as one. Every maintainer comment gets a same-day answer in the contributor's voice, checked by `claim-check.sh` and, when it concedes, disagrees or rides on a code change, by the adversarial review, and posted only by `reply.sh`, which reads whom it answers and refuses a voice with no role in the repository unless `--outsider` carries the contributor's word, a verdict or thanks as the opening, an exclamation mark, bold, a closing offer, a reply past three sentences, a reference to nothing, and a second reply to the repository inside ten minutes. A filed body or title changes only by `edit-pr.sh`, through the prose, template, disclosure and reference gates a filing passes, on an open pull request of yours, and it keeps the copy `verify-filed-pr.sh` compares against. A rework reaches the branch only by `push.sh`: a stamped, reviewed head, one push per half hour, a rebase that leaves the patch unchanged carrying the review of the head it replaces, and a rewrite of the branch only with the reason stated. A pull request of yours is withdrawn only by `close.sh`, which holds the note to a reply's tone and spacing, then deletes the fork branch and records the close in notes. When the maintainer is right, concede in one sentence. A silent maintainer is never nudged.
86
97
 
87
98
  **11. Clean up.**
88
- `fork-hygiene.sh` deletes the fork branch of every merged or closed pull request, unless an open one still uses it, and lists forks with no pull request left. No planning file, agent directory, journal or build output ever enters a diff.
99
+ `fork-hygiene.sh` deletes the fork branch of every merged or closed pull request, unless an open one still uses it or its tip is no longer the head that pull request held, and lists forks with no pull request left. No planning file, agent directory, journal or build output ever enters a diff.
89
100
 
90
101
  **12. Three per repository, one finding each.**
91
102
  A repository gets at most three open pull requests, each one finding, each meeting every rule above on its own, filed at least ten minutes apart.
@@ -102,7 +113,7 @@ pip install housebroken-cli
102
113
  housebroken install-skill
103
114
  ```
104
115
 
105
- The first line puts the `housebroken` command on your path. The second puts the skill where Claude Code loads it, so the agent runs the door itself before it opens anything upstream. `housebroken install-hook` adds the enforcement the skill cannot: a Claude Code hook that refuses the ways a filing can go around the gates, namely opening, answering, editing, closing or merging a pull request or an issue with `gh`, a write through `gh api`, and a forced push or a branch delete. It is that list and not a deny-all: `gh repo delete`, `gh release create` and a plain `git push` pass it. It prints the settings entry to add; it does not edit your settings. It judges each command in a line by itself, and it reads text, so a write behind `bash -c`, `eval`, a script file or a full path to `gh` passes it: it holds the accident, not the intent. Writes to your own repositories pass once their owners are listed in `~/.housebroken/own`, one per line; a forced push is refused everywhere, since a fork carries your name too. To run the main branch between releases, install from the repository instead:
116
+ The first line puts the `housebroken` command on your path. The second puts the skill where Claude Code loads it, so the agent runs the door itself before it opens anything upstream. `housebroken install-hook` adds the enforcement the skill cannot: a Claude Code hook that refuses the ways a filing can go around the gates, namely opening, answering, editing, closing or merging a pull request or an issue with `gh`, a write through `gh api`, and a forced push or a branch delete. It is that list and not a deny-all: `gh repo delete`, `gh release create` and a plain `git push` pass it. It prints the settings entry to add; it does not edit your settings. The entry covers both shells Claude Code runs commands in, Bash and on Windows PowerShell, and a hook that times out or cannot start blocks the command; an entry added before 0.21.0 names Bash alone and needs replacing. It judges each command in a line by itself, one inside `$(...)` included, and it reads text, so a write behind `bash -c`, `eval`, `xargs`, a script file, an alias or a quoted path to `gh` passes it (one behind `timeout`, `nohup`, `env`, `sudo` or `nice`, by a path to `gh`, or as `gh.exe` does not): it holds the accident, not the intent. Writes to your own repositories pass once their owners are listed in `~/.housebroken/own`, one per line, and every repository the command names must be one of them (a link in a body alone makes nothing yours, and a command that sets `GH_REPO` never passes this way); a forced push is refused everywhere, since a fork carries your name too. To run the main branch between releases, install from the repository instead:
106
117
 
107
118
  ```
108
119
  uv tool install git+https://github.com/lenamonj/housebroken
@@ -122,6 +133,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
122
133
  | `scripts/comment-check.sh` | refuses a comment added to code nobody asked for |
123
134
  | `scripts/comment-census.sh` | added code versus added comments, per branch, of one clone or of every clone under a directory |
124
135
  | `scripts/diff-defaults.sh` | default arguments and one-line wrappers added to keep call sites untouched |
136
+ | `scripts/same-code.sh` | every other place the base holds an expression the branch replaces, or makes a call it replaces |
125
137
  | `scripts/claim-check.sh` | every falsifiable claim in a body or a reply, listed to re-derive |
126
138
  | `scripts/proof.sh` | the red-first experiment, run and stamped: red on the base, green on the head |
127
139
  | `scripts/ci-legs.sh` | the jobs a project's CI runs: the ones this machine cannot run, and the ones already red on its default branch |
@@ -132,7 +144,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
132
144
  | `scripts/file-pr.sh` | the only way a pull request gets filed: every gate above in front of `gh pr create` |
133
145
  | `scripts/file-issue.sh` | the only way an issue gets filed: the same printouts and prose, and a fix offered is a fix linked |
134
146
  | `scripts/verify-filed-pr.sh` | the filed pull request is what was meant, and CI is green: one line when it is, the report when it is not |
135
- | `scripts/pr-sweep.sh` | every open pull request where the ball is in your court, a head CI never started on and a standing stale notice among them, and every merged or closed one whose fork branch is still there, repeated each run until it is gone |
147
+ | `scripts/pr-sweep.sh` | every open pull request where the ball is in your court, a head CI never started on and a standing stale notice among them, and every merged or closed one whose fork branch is still there, repeated each run until it is gone (one used again for other work is named once and left alone) |
136
148
  | `scripts/inbox.sh` | what GitHub has to tell you since you last looked, bodies included, with a census of every open pull request |
137
149
  | `scripts/notes.sh` | what this repository's maintainers have asked for before |
138
150
  | `scripts/reply.sh` | the only way an answer on a thread gets posted, and only to a voice with a role in the repository unless the user says otherwise |
@@ -49,7 +49,7 @@ A pull request passes through the door in order, and stops at the first rule it
49
49
  A change that rejects an input the project tolerated, changes a default, or narrows what the project publishes is the maintainer's call. It is sent with the call stated in the body: what breaks for existing users, and an offer to narrow or close it. A finding whose only evidence is a measurement is a hold, not a pull request.
50
50
 
51
51
  **4. Prove it red first, and prove the proof.**
52
- On a fresh clone of the upstream default branch, the new test fails; with the patch, it passes. Every arm of the experiment prints evidence that its precondition held, files are swapped by content and checked by hash, and two arms that agree exactly have not tested the variable. `proof.sh` runs the experiment itself: the test on the head, then on the head with every changed non-test file swapped back to its content at the merge base, then the head restored and checked by hash, and it stamps the head only when the base arm fails and the head arm passes. Both arms run with `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY` at local port 9 and `NO_PROXY` at loopback only, so a test whose client honors them fails instead of reaching the network, and an arm whose output carries a client's failure at that port is not stamped. A change with nothing to show red says so, with the reason, and the filing prints it.
52
+ On a fresh clone of the upstream default branch, the new test fails; with the patch, it passes. Every arm of the experiment prints evidence that its precondition held, files are swapped by content and checked by hash, and two arms that agree exactly have not tested the variable. `proof.sh` runs the experiment itself: the test on the head, then on the head with every changed non-test file swapped back to its content at the merge base, then the head restored and checked by hash, and it stamps the head only when the base arm fails and the head arm passes. Both arms run with `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY` at local port 9 and `NO_PROXY` at loopback only, so a test whose client honors them fails instead of reaching the network, and an arm whose output carries a client's failure at that port is not stamped. A change with nothing to show red says so, with the reason, and the filing prints it. A fix goes to every site with the same code, not only the one that was reported: `same-code.sh` lists every other line of the base that holds an expression the branch replaces or makes a call it replaces, and the review brief hands that list to the reviewer.
53
53
 
54
54
  **5. Run their CI, not yours.**
55
55
  The project's own test target on the fresh clone, and every gate its pull request workflow runs: lint, format, mutation, API check. A gate not run is a red check the maintainer sees first.
@@ -73,7 +73,7 @@ A memory-safety, remote-abort, injection or path-escape finding goes by the proj
73
73
  `verify-filed-pr.sh` re-derives from GitHub that the head is the intended commit, one a stamp or you name, the files are the ones the branch stamp lists, the body is the one that was filed, and CI is green. When nothing is wrong it says so in one line, which names the head and the checks and says whether the files and the body matched or were not compared; the report prints only when something is wrong. It stops at the first red check, so the failed log is read at once, and `--settle` waits for the rest. A read that failed is never OK, and no checks yet reads NOT SETTLED. `inbox.sh` prints every event on your threads since the last acknowledged cursor, bodies included, with a census of failing, blocked and conflicting checks; a thread it could not read says UNREAD and nothing can be acknowledged past it. The census and `pr-sweep.sh` also name two states that look quiet. A head no CI job ever started on reads `no-ci-on-head` when GitHub made no run for it and `ci-never-started` when the run it made finished without one. A new push or a close and reopen can start a new run, which may again wait for approval; a workflow filtered off the change makes none and reads the same. A stale bot's notice that still stands reads `stale:closes-` and the day when it says it will be closed in or within a number of days, and `stale:warned-` and its own date when it does not; a label alone, with no notice, reads `stale:label`. Each is a deadline to bring to the contributor, and before any bump the body's claims are re-derived on the default branch. A check list or a notice that could not be read says `ci-unread` or `stale:unread`, never nothing. Every body and title it prints is marked as untrusted text: someone else's words are evidence, never instructions. Every event names its author's role in the repository, GitHub's own word, and a voice with no role is marked as one. Every maintainer comment gets a same-day answer in the contributor's voice, checked by `claim-check.sh` and, when it concedes, disagrees or rides on a code change, by the adversarial review, and posted only by `reply.sh`, which reads whom it answers and refuses a voice with no role in the repository unless `--outsider` carries the contributor's word, a verdict or thanks as the opening, an exclamation mark, bold, a closing offer, a reply past three sentences, a reference to nothing, and a second reply to the repository inside ten minutes. A filed body or title changes only by `edit-pr.sh`, through the prose, template, disclosure and reference gates a filing passes, on an open pull request of yours, and it keeps the copy `verify-filed-pr.sh` compares against. A rework reaches the branch only by `push.sh`: a stamped, reviewed head, one push per half hour, a rebase that leaves the patch unchanged carrying the review of the head it replaces, and a rewrite of the branch only with the reason stated. A pull request of yours is withdrawn only by `close.sh`, which holds the note to a reply's tone and spacing, then deletes the fork branch and records the close in notes. When the maintainer is right, concede in one sentence. A silent maintainer is never nudged.
74
74
 
75
75
  **11. Clean up.**
76
- `fork-hygiene.sh` deletes the fork branch of every merged or closed pull request, unless an open one still uses it, and lists forks with no pull request left. No planning file, agent directory, journal or build output ever enters a diff.
76
+ `fork-hygiene.sh` deletes the fork branch of every merged or closed pull request, unless an open one still uses it or its tip is no longer the head that pull request held, and lists forks with no pull request left. No planning file, agent directory, journal or build output ever enters a diff.
77
77
 
78
78
  **12. Three per repository, one finding each.**
79
79
  A repository gets at most three open pull requests, each one finding, each meeting every rule above on its own, filed at least ten minutes apart.
@@ -90,7 +90,7 @@ pip install housebroken-cli
90
90
  housebroken install-skill
91
91
  ```
92
92
 
93
- The first line puts the `housebroken` command on your path. The second puts the skill where Claude Code loads it, so the agent runs the door itself before it opens anything upstream. `housebroken install-hook` adds the enforcement the skill cannot: a Claude Code hook that refuses the ways a filing can go around the gates, namely opening, answering, editing, closing or merging a pull request or an issue with `gh`, a write through `gh api`, and a forced push or a branch delete. It is that list and not a deny-all: `gh repo delete`, `gh release create` and a plain `git push` pass it. It prints the settings entry to add; it does not edit your settings. It judges each command in a line by itself, and it reads text, so a write behind `bash -c`, `eval`, a script file or a full path to `gh` passes it: it holds the accident, not the intent. Writes to your own repositories pass once their owners are listed in `~/.housebroken/own`, one per line; a forced push is refused everywhere, since a fork carries your name too. To run the main branch between releases, install from the repository instead:
93
+ The first line puts the `housebroken` command on your path. The second puts the skill where Claude Code loads it, so the agent runs the door itself before it opens anything upstream. `housebroken install-hook` adds the enforcement the skill cannot: a Claude Code hook that refuses the ways a filing can go around the gates, namely opening, answering, editing, closing or merging a pull request or an issue with `gh`, a write through `gh api`, and a forced push or a branch delete. It is that list and not a deny-all: `gh repo delete`, `gh release create` and a plain `git push` pass it. It prints the settings entry to add; it does not edit your settings. The entry covers both shells Claude Code runs commands in, Bash and on Windows PowerShell, and a hook that times out or cannot start blocks the command; an entry added before 0.21.0 names Bash alone and needs replacing. It judges each command in a line by itself, one inside `$(...)` included, and it reads text, so a write behind `bash -c`, `eval`, `xargs`, a script file, an alias or a quoted path to `gh` passes it (one behind `timeout`, `nohup`, `env`, `sudo` or `nice`, by a path to `gh`, or as `gh.exe` does not): it holds the accident, not the intent. Writes to your own repositories pass once their owners are listed in `~/.housebroken/own`, one per line, and every repository the command names must be one of them (a link in a body alone makes nothing yours, and a command that sets `GH_REPO` never passes this way); a forced push is refused everywhere, since a fork carries your name too. To run the main branch between releases, install from the repository instead:
94
94
 
95
95
  ```
96
96
  uv tool install git+https://github.com/lenamonj/housebroken
@@ -110,6 +110,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
110
110
  | `scripts/comment-check.sh` | refuses a comment added to code nobody asked for |
111
111
  | `scripts/comment-census.sh` | added code versus added comments, per branch, of one clone or of every clone under a directory |
112
112
  | `scripts/diff-defaults.sh` | default arguments and one-line wrappers added to keep call sites untouched |
113
+ | `scripts/same-code.sh` | every other place the base holds an expression the branch replaces, or makes a call it replaces |
113
114
  | `scripts/claim-check.sh` | every falsifiable claim in a body or a reply, listed to re-derive |
114
115
  | `scripts/proof.sh` | the red-first experiment, run and stamped: red on the base, green on the head |
115
116
  | `scripts/ci-legs.sh` | the jobs a project's CI runs: the ones this machine cannot run, and the ones already red on its default branch |
@@ -120,7 +121,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
120
121
  | `scripts/file-pr.sh` | the only way a pull request gets filed: every gate above in front of `gh pr create` |
121
122
  | `scripts/file-issue.sh` | the only way an issue gets filed: the same printouts and prose, and a fix offered is a fix linked |
122
123
  | `scripts/verify-filed-pr.sh` | the filed pull request is what was meant, and CI is green: one line when it is, the report when it is not |
123
- | `scripts/pr-sweep.sh` | every open pull request where the ball is in your court, a head CI never started on and a standing stale notice among them, and every merged or closed one whose fork branch is still there, repeated each run until it is gone |
124
+ | `scripts/pr-sweep.sh` | every open pull request where the ball is in your court, a head CI never started on and a standing stale notice among them, and every merged or closed one whose fork branch is still there, repeated each run until it is gone (one used again for other work is named once and left alone) |
124
125
  | `scripts/inbox.sh` | what GitHub has to tell you since you last looked, bodies included, with a census of every open pull request |
125
126
  | `scripts/notes.sh` | what this repository's maintainers have asked for before |
126
127
  | `scripts/reply.sh` | the only way an answer on a thread gets posted, and only to a voice with a role in the repository unless the user says otherwise |
@@ -47,6 +47,7 @@ usage: housebroken <subcommand> [args...]
47
47
  1 policy read the repository's AI-contribution policy where it lives
48
48
  1 outside count outside contributors merged in the last 120 days
49
49
  2 prior-art issues and pull requests on the touched files, rulings quoted
50
+ 4 sites every other place the base holds the code the branch replaces
50
51
  4 proof run the test on the base and the head, and stamp red then green
51
52
  5 ci their CI's jobs: those this machine cannot run, those red on main
52
53
  6 census added code lines against added comment lines, per branch
@@ -110,6 +111,7 @@ case "$cmd" in
110
111
  comments) script=comment-check.sh ;;
111
112
  claims) script=claim-check.sh ;;
112
113
  refs) script=ref-check.sh ;;
114
+ sites) script=same-code.sh ;;
113
115
  proof) script=proof.sh ;;
114
116
  ci) script=ci-legs.sh ;;
115
117
  declare) script=declare.sh ;;
@@ -4,15 +4,24 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "housebroken-cli"
7
- version = "0.20.0"
7
+ version = "0.22.0"
8
8
  description = "Agent-written pull requests that do not make a mess in someone else's house."
9
9
  dynamic = ["readme"]
10
10
  license = "MIT"
11
+ authors = [{ name = "Jeff Lenamon" }]
11
12
  requires-python = ">=3.10"
12
13
  dependencies = []
14
+ keywords = ["pull-request", "github", "open-source", "contributing", "ai-agent", "claude-code", "code-review", "cli"]
13
15
  classifiers = [
14
- "Programming Language :: Python :: 3",
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
15
19
  "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Unix Shell",
23
+ "Topic :: Software Development :: Quality Assurance",
24
+ "Topic :: Software Development :: Version Control :: Git",
16
25
  ]
17
26
 
18
27
  [project.scripts]
@@ -20,6 +29,8 @@ housebroken = "housebroken.cli:main"
20
29
 
21
30
  [project.urls]
22
31
  Repository = "https://github.com/lenamonj/housebroken"
32
+ Issues = "https://github.com/lenamonj/housebroken/issues"
33
+ Changelog = "https://github.com/lenamonj/housebroken/releases"
23
34
 
24
35
  [tool.hatch.build.targets.wheel]
25
36
  packages = ["src/housebroken"]
@@ -43,6 +43,10 @@
43
43
  #
44
44
  # Exits 0 when nothing blocks, 1 on a refusal, 2 on a usage error.
45
45
  set -u
46
+ # A diff is bytes. In a UTF-8 locale Apple's cut stops at the first byte that
47
+ # is not UTF-8 and its grep reads such a line as no match, so every scan below
48
+ # would read only the diff up to a Latin-1 accent. In the C locale they read bytes.
49
+ export LC_ALL=C
46
50
  # shellcheck source=scripts/refuse.sh
47
51
  . "$(cd "$(dirname "$0")" && pwd)/refuse.sh"
48
52
 
@@ -115,6 +119,15 @@ if [ -z "$base" ]; then
115
119
  fi
116
120
  [ -n "$base" ] || { refused branch-check-no-base-resolved "no base ref resolved - pass --base REF" >&2; exit 2; }
117
121
  git rev-parse --verify -q "$base" >/dev/null 2>&1 || { refused branch-check-base-unresolvable "base $base does not resolve" >&2; exit 2; }
122
+ # From here the run is the answer: a stamp an earlier run left for this head
123
+ # does not outlive a refusal. A head that already went out, filed (its body is
124
+ # kept under filed/) or pushed (a line in a push log), keeps its stamp:
125
+ # verify-filed-pr.sh and push.sh read it, and nothing waits to be filed on it.
126
+ now_head=$(git rev-parse --verify -q HEAD 2>/dev/null) || now_head=""
127
+ if [ -n "$now_head" ] && ! compgen -G "$home/filed/*-$now_head.md" >/dev/null \
128
+ && ! grep -qs " $now_head " "$home"/pushes/*.log; then
129
+ rm -f "$home/branch-checks/$now_head"
130
+ fi
118
131
  # What the branch changed, read from where it left the base. Two unrelated
119
132
  # histories have no merge base: that is refused below, before any scan reads
120
133
  # an unrelated tree as the branch's change.
@@ -298,14 +311,18 @@ added=$(gdiff -U0 "$mb..HEAD" -- . ':(exclude)*.md' ':(exclude)*.rst' ':(exclude
298
311
  supp_re='UnconditionalSuppressMessage|SuppressMessage\(|#pragma warning disable|pragma warning *\( *disable|<NoWarn>|@SuppressWarnings|@SuppressLint|@Suppress\(|#!?\[allow\(|nolint|NOLINT|NOSONAR|noqa|eslint-disable|@ts-ignore|@ts-expect-error|type: *ignore|pylint: *disable|rubocop:disable|swiftlint:disable|phpstan-ignore|psalm-suppress'
299
312
  # A suppression the edited line already carried is the maintainer's: each
300
313
  # removed line answers for one added line with the same suppression text.
314
+ # Both reach awk on its input, marked - and +, never in its environment, where
315
+ # Linux caps one string at 128 KB and a larger removal would stop awk running.
301
316
  removed=$(gdiff -U0 "$mb..HEAD" -- . ':(exclude)*.md' ':(exclude)*.rst' ':(exclude)*.txt' 2>/dev/null \
302
317
  | awk '/^@@ / { n = (index($2, ",") ? substr($2, index($2, ",") + 1) : 1) + 0; next }
303
318
  n > 0 && /^-/ { print substr($0, 2); n--; next }')
304
- suppressions=$(printf '%s\n' "$added" | grep -E "$supp_re" | SUPP_RE="$supp_re" REMOVED="$removed" awk '
305
- BEGIN { re = ENVIRON["SUPP_RE"]; n = split(ENVIRON["REMOVED"], r, "\n")
306
- for (i = 1; i <= n; i++) if (match(r[i], re)) kept[substr(r[i], RSTART)]++ }
307
- match($0, re) && kept[substr($0, RSTART)]-- > 0 { next }
308
- { print }')
319
+ suppressions=$({ printf '%s\n' "$removed" | sed 's/^/-/'; printf '%s\n' "$added" | grep -E "$supp_re" | sed 's/^/+/'; } \
320
+ | SUPP_RE="$supp_re" awk '
321
+ BEGIN { re = ENVIRON["SUPP_RE"] }
322
+ { line = substr($0, 2) }
323
+ /^-/ { if (match(line, re)) kept[substr(line, RSTART)]++; next }
324
+ match(line, re) && kept[substr(line, RSTART)]-- > 0 { next }
325
+ { print line }')
309
326
  if [ -n "$suppressions" ]; then
310
327
  # Each suppression names what it hides: a code such as IL2075 or C4996, else
311
328
  # the rule names after its keyword (errcheck, no-unused-vars). One that names
@@ -62,7 +62,8 @@
62
62
  # HOUSEBROKEN_HOME work directory, default $HOME/.housebroken; --out writes
63
63
  # to its policy/ subdirectory, created if missing.
64
64
  #
65
- # Assumes gh is installed and authenticated. Read-only: GET calls only.
65
+ # Assumes gh is installed and authenticated, and jq is on PATH. Read-only: GET
66
+ # calls only.
66
67
  set -u
67
68
 
68
69
  usage() { awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0"; }
@@ -145,6 +146,9 @@ if [ -z "$reading" ] && [ -n "$disclosure" ]; then
145
146
  fi
146
147
 
147
148
  command -v gh >/dev/null 2>&1 || { echo "check-ai-policy.sh: gh is not on PATH" >&2; exit 1; }
149
+ # Without jq the tree listing parses to nothing, no file is read, and a
150
+ # repository that bans AI would read CLEAN.
151
+ command -v jq >/dev/null 2>&1 || { echo "check-ai-policy.sh: jq is not on PATH" >&2; exit 1; }
148
152
  # shellcheck source=scripts/common.sh
149
153
  . "$(cd "$(dirname "$0")" && pwd)/common.sh"
150
154
  home="${HOUSEBROKEN_HOME:-$HOME/.housebroken}"
@@ -153,6 +157,17 @@ tmpl_repo=$(mktemp)
153
157
  tmpl_org=$(mktemp)
154
158
  trap 'rm -f "$errfile" "$tmpl_repo" "$tmpl_org"' EXIT
155
159
 
160
+ # The word after the first RESULT: in a printout on stdin, and how much it holds.
161
+ result_word() { awk '{ sub(/\r$/, "") } /^RESULT: / { print $2; exit }'; }
162
+ rank() {
163
+ case "$1" in
164
+ BAN) echo 3 ;;
165
+ UNREAD) echo 2 ;;
166
+ DISCLOSE|MENTION) echo 1 ;;
167
+ *) echo 0 ;;
168
+ esac
169
+ }
170
+
156
171
  # Policy text on stdin as sentences, one per line, each "LINE:SENTENCE". Lines
157
172
  # join into paragraphs and a list item starts its own; a heading is carried onto
158
173
  # the sentences of the paragraph under it, so "## AI policy" reads with the rule
@@ -315,18 +330,18 @@ for repo in "${repos[@]}"; do
315
330
  if [ "$out" -eq 1 ]; then
316
331
  mkdir -p "$home/policy"
317
332
  saved="$home/policy/policy-${repo%%/*}-${repo##*/}.md"
318
- # One printout per repository, and a ban on one branch is a ban: a clean read
319
- # of another branch today does not replace it. A reread of that branch does.
320
- if [ -f "$saved" ] && grep -q '^RESULT: BAN' "$saved" && [ "$(file_age "$saved" || echo 86401)" -le 86400 ]; then
333
+ # One printout per repository, and a hold on one branch is a hold: a lesser
334
+ # read of another branch today does not replace it, nor its recorded call or
335
+ # template. A reread of that branch does. BAN outranks UNREAD, which outranks
336
+ # DISCLOSE and MENTION, which outrank CLEAN.
337
+ if [ -f "$saved" ] && [ "$(file_age "$saved" || echo 86401)" -le 86400 ]; then
321
338
  was=$(sed -n 's/^branch: //p' "$saved" | head -1 | tr -d '\r')
322
339
  now=$(printf '%s\n' "$report" | sed -n 's/^branch: //p' | head -1)
323
- case "$report" in
324
- *"RESULT: BAN"*) ;;
325
- *) if [ "$was" != "$now" ]; then
326
- echo "kept $saved: the BAN read on $was stands; this read of $now does not replace it"
327
- continue
328
- fi ;;
329
- esac
340
+ held=$(result_word < "$saved")
341
+ if [ "$was" != "$now" ] && [ "$(rank "$held")" -gt "$(rank "$(printf '%s\n' "$report" | result_word)")" ]; then
342
+ echo "kept $saved: the $held read on $was stands; this read of $now does not replace it"
343
+ continue
344
+ fi
330
345
  fi
331
346
  printf '%s\n' "$report" "$legs" > "$saved"
332
347
  echo "saved: $saved"
@@ -81,13 +81,14 @@ fi
81
81
 
82
82
  user="${HOUSEBROKEN_USER:-$(gh api user --jq .login 2>/dev/null)}"
83
83
  [ -n "$user" ] || { refused close-gh-unauthenticated "gh is not authenticated, so whose pull request this is cannot be read" >&2; exit 2; }
84
- fork_owner=""; fork=""; branch=""
85
- if pr=$(gh pr view "$num" --repo "$repo" --json author,state,headRefName,headRepository,headRepositoryOwner 2>/dev/null); then
84
+ fork_owner=""; fork=""; branch=""; oid=""
85
+ if pr=$(gh pr view "$num" --repo "$repo" --json author,state,headRefName,headRepository,headRepositoryOwner,headRefOid 2>/dev/null); then
86
86
  author=$(printf '%s' "$pr" | jq -r '.author.login // "?"' | tr -d '\r')
87
87
  state=$(printf '%s' "$pr" | jq -r '.state // "?"' | tr -d '\r')
88
88
  fork_owner=$(printf '%s' "$pr" | jq -r '.headRepositoryOwner.login // ""' | tr -d '\r')
89
89
  fork=$(printf '%s' "$pr" | jq -r '.headRepository.name // ""' | tr -d '\r')
90
90
  branch=$(printf '%s' "$pr" | jq -r '.headRefName // ""' | tr -d '\r')
91
+ oid=$(printf '%s' "$pr" | jq -r '.headRefOid // ""' | tr -d '\r')
91
92
  [ "$author" = "$user" ] || refuse close-not-yours "$repo#$num is $author's, not yours"
92
93
  [ "$state" = "OPEN" ] || refuse close-not-open "$repo#$num is $state; only an open pull request is closed"
93
94
  else
@@ -128,7 +129,7 @@ fi
128
129
  rc=0
129
130
  bash "$here/notes.sh" "$repo" add "we closed #$num: $(printf '%s' "$own" | clean_line | cut -c1-200)" || rc=1
130
131
  if [ "$fork_owner" = "$user" ] && [ -n "$fork" ] && [ -n "$branch" ]; then
131
- if ! drop_fork_branch "$user" "$fork" "$branch" "CLOSED $repo#$num" 0; then
132
+ if ! drop_fork_branch "$user" "$fork" "$branch" "CLOSED $repo#$num" 0 "$oid"; then
132
133
  echo "housebroken hygiene deletes it on its next run" >&2
133
134
  rc=1
134
135
  fi
@@ -32,8 +32,10 @@ renamed_from() { printf '%s\n' "${renames:-}" | awk -F'\t' -v n="$1" '$2 == n {p
32
32
 
33
33
  # Whether a path is a test by where it lives or what it is called. A substring
34
34
  # is not enough: latest.c, inspect.go and special_cases.py say test or spec too.
35
+ # A file named tests.py, tests.rs or test.js is a test too (Django, Rust, JS),
36
+ # and so is Java's TestPager.java and SwiftPM's Tests/ directory.
35
37
  is_test_path() {
36
- printf '%s\n' "$1" | grep -qE '(^|/)(tests?|specs?|__tests__|testdata)/|(^|/)test_[^/]*$|[._-](test|spec)s?\.[^/]+$|[a-z0-9]Tests?\.[^/]+$|(^|/)conftest\.py$'
38
+ printf '%s\n' "$1" | grep -qE '(^|/)([Tt]ests?|[Ss]pecs?|__tests__|testdata)/|(^|/)test_[^/]*$|(^|/|[._-])(test|spec)s?\.[^/]+$|(^|/|[A-Za-z0-9])Tests?\.[^/]+$|(^|/)Test[A-Z][^/]*\.[^/]+$|(^|/)conftest\.py$'
37
39
  }
38
40
 
39
41
  # Seconds since a file last changed. stat differs between GNU and BSD.
@@ -136,6 +138,37 @@ check_text() {
136
138
  fi
137
139
  }
138
140
 
141
+ # Git Bash rewrites an argument that starts with a slash into a path under its
142
+ # own directory on the way to a Windows program, and gh is one: "/healthz
143
+ # returns 500" would be filed as "C:/Program Files/Git/healthz returns 500".
144
+ # True under Git Bash for a value that starts with a slash, as typed or as it
145
+ # arrives already rewritten; sets slash_root to that directory.
146
+ rewritten_by_git_bash() { # value
147
+ case "$(uname -s 2>/dev/null)" in MINGW*|MSYS*) ;; *) return 1 ;; esac
148
+ slash_root=$(cygpath -m / 2>/dev/null) || slash_root=""
149
+ case "$1" in
150
+ /*|"${slash_root:-/}"*) return 0 ;;
151
+ esac
152
+ return 1
153
+ }
154
+
155
+ # A title, held to what any text is and to one thing more: under Git Bash it
156
+ # does not start with a slash.
157
+ check_title() {
158
+ check_text "--title" "$1"
159
+ rewritten_by_git_bash "$1" || return 0
160
+ refused common-title-leading-slash "the title starts with a slash, which Git Bash turns into a path under ${slash_root:-its own directory} before gh reads it - start the title with a word" >&2
161
+ exit 2
162
+ }
163
+
164
+ # A label, a milestone or a project is free text gh takes by name, and Git Bash
165
+ # rewrites it as it does a title.
166
+ check_value() { # flag value
167
+ rewritten_by_git_bash "$2" || return 0
168
+ refused common-value-leading-slash "$1 $2 starts with a slash, which Git Bash turns into a path under ${slash_root:-its own directory} before gh reads it - give it without the slash" >&2
169
+ exit 2
170
+ }
171
+
139
172
  # The project's own template text is kept verbatim and is not ours to count:
140
173
  # HTML comments and every line the saved template carries, a ticked box read
141
174
  # as its unticked line, are left out before the words are counted. The
@@ -221,19 +254,45 @@ dropped_boxes() { # template-file body-file
221
254
  END { for (i = 1; i <= boxes; i++) { k = order[i]; if (have[k] > 0) have[k]--; else print k } }' "$2"
222
255
  }
223
256
 
224
- # Whether a body says AI was used, in its own words: a ticked box naming it, or
225
- # a line that is not the project's template. An unanswered template question
226
- # says nothing, and "Home Assistant" names no tool.
257
+ # Whether a body says AI was used, in its own words: a ticked box or a line that
258
+ # names a tool beside its use ("written with Claude", "An AI tool (Claude)
259
+ # helped", "AI-generated") or after a label ("AI disclosure: Claude Code",
260
+ # "Tool used:", "Assisted-by:", "Generated-by:"), or a tool named in answer to a
261
+ # template line that asks about AI. A name alone is the code's subject as often as not: a cursor is a
262
+ # database's, ai/ is a path, "the LLM client" and "Home Assistant" say nothing.
263
+ # So names are matched as written, and fenced code, code spans, quoted lines and
264
+ # HTML comments are not the body's words. An unanswered template question says
265
+ # nothing.
227
266
  discloses() { # body-file template-file
228
- local names='\bAI\b|\bLLMs?\b|Claude|Copilot|ChatGPT|Gemini|Codex|Cursor|language model'
229
- grep -qiE "^[[:space:]]*[-*] \[x\].*($names)" "$1" && return 0
230
- sed 's/<!--.*-->//' "$1" | awk -v T="$2" '
267
+ local names='AI|LLMs?|Claude|Copilot|ChatGPT|Gemini|Codex|Cursor|([Ll]arge )?[Ll]anguage [Mm]odels?'
268
+ local said='\b('"$names"')( Code| CLI| tools?| assistance| assistants?)?\)?(( (has|have|had))?[ -](wrote|written|generated|drafted|assisted|authored|helped|suggested)| (was|were|is|are) used)\b|\b(use|used|using|use of|with|by|via|help of|help from|assistance of|assistance from)( an?)?( [A-Z][A-Za-z]*)? ('"$names"')\b|\b([Dd]isclos[a-z]*|[Aa]ssisted-[Bb]y|[Gg]enerated-[Bb]y|[Tt]ools? used):[[:space:]]*(an? )?('"$names"')\b'
269
+ local own
270
+ # shellcheck disable=SC2016 # the backticks are markdown, matched literally
271
+ own=$(awk '
272
+ /^[[:space:]]*(```|~~~)/ { f = !f; next }
273
+ f { next }
274
+ { s = $0; out = ""
275
+ while (s != "") {
276
+ if (cs) { i = index(s, "-->"); if (!i) break; s = substr(s, i + 3); cs = 0 }
277
+ else { i = index(s, "<!--"); if (!i) { out = out s; break }; out = out substr(s, 1, i - 1); s = substr(s, i + 4); cs = 1 }
278
+ }
279
+ if (out ~ /^[[:space:]]*>/) next
280
+ gsub(/`[^`]*`/, "", out)
281
+ print out }' "$1")
282
+ printf '%s\n' "$own" | grep -qE "^[[:space:]]*[-*] \[[xX]\].*($said)" && return 0
283
+ # Each line that is not the template is printed after A when it answers the
284
+ # template's AI line, where a tool's name alone is the answer, else after B.
285
+ printf '%s\n' "$own" | awk -v T="$2" '
231
286
  function norm(s) { gsub(/\[[xX]\]/, "[ ]", s); gsub(/^[[:space:]]+|[[:space:]]+$/, "", s); return s }
287
+ function asks_ai(s) { return tolower(s) ~ /(^|[^a-z])ai([^a-z]|$)|artificial intelligence|generative|llm|language model/ }
232
288
  BEGIN { while ((getline l < T) > 0) { l = norm(l); if (l != "") t[l] = 1 } }
233
- { l = norm($0); if (l in t || l ~ /^[-*] \[ \]/) next
289
+ { l = norm($0)
290
+ if (l in t) { answer = asks_ai(l); next }
291
+ if (l ~ /^[-*] \[ \]/) next
234
292
  best = ""
235
293
  for (k in t) if (index(l, k) == 1 && length(k) > length(best)) best = k
236
- print substr(l, length(best) + 1) }' | grep -qiE "$names"
294
+ if (best != "") print (asks_ai(best) ? "A " : "B ") substr(l, length(best) + 1)
295
+ else print (answer ? "A " : "B ") l }' | grep -qE "^A .*\b($names)\b|^B .*($said)"
237
296
  }
238
297
 
239
298
  # Ten minutes between filings on one repository, issues and pull requests alike.
@@ -414,23 +473,26 @@ ref_query='query($o: String!, $r: String!, $q: String!) {
414
473
  repository(owner: $o, name: $r) {
415
474
  isFork
416
475
  ref(qualifiedName: $q) {
476
+ target { oid }
417
477
  associatedPullRequests(states: OPEN, first: 20) { nodes { number repository { nameWithOwner } } }
418
478
  }
419
479
  }
420
480
  }'
421
481
 
422
- # Deletes one branch of a fork of ours once no open pull request uses it, and
423
- # says so; a repository that is not a fork, or a branch already gone, is left
424
- # without a word. Returns 1 when the ref could not be read or the delete failed.
425
- drop_fork_branch() { # user fork branch what dry
426
- local me="$1" fork="$2" branch="$3" what="$4" dry="$5" ref isfork exists users
482
+ # Deletes one branch of a fork of ours once no open pull request uses it and
483
+ # its tip is still the head the finished pull request held, and says so; a
484
+ # repository that is not a fork, or a branch already gone, is left without a
485
+ # word. A branch name used again for other work has another tip, and is kept.
486
+ # Returns 1 when the ref could not be read or the delete failed.
487
+ drop_fork_branch() { # user fork branch what dry pr-head
488
+ local me="$1" fork="$2" branch="$3" what="$4" dry="$5" head="${6:-}" ref isfork exists tip users
427
489
  if ! ref=$(gh api graphql -f query="$ref_query" -f o="$me" -f r="$fork" -f q="refs/heads/$branch" \
428
- --jq '.data.repository | [(.isFork | tostring), (if .ref then "yes" else "no" end),
490
+ --jq '.data.repository | [(.isFork | tostring), (if .ref then "yes" else "no" end), (.ref.target.oid // "-"),
429
491
  ([.ref.associatedPullRequests.nodes[]? | "\(.repository.nameWithOwner)#\(.number)"] | join(" "))] | @tsv' 2>/dev/null); then
430
492
  echo "$(basename "$0"): cannot read $me/$fork $branch; kept" >&2
431
493
  return 1
432
494
  fi
433
- IFS=$'\t' read -r isfork exists users <<< "$ref"
495
+ IFS=$'\t' read -r isfork exists tip users <<< "$ref"
434
496
  [ "$isfork" = "true" ] || return 0
435
497
  [ "$exists" = "yes" ] || return 0
436
498
  # A closed pull request refiled from the same branch still needs it, and
@@ -439,6 +501,11 @@ drop_fork_branch() { # user fork branch what dry
439
501
  echo "kept $me/$fork $branch: open pull request $users still uses it"
440
502
  return 0
441
503
  fi
504
+ # A head that was not read is "-" or empty, which no tip equals.
505
+ if [ "$tip" != "$head" ]; then
506
+ echo "kept $me/$fork $branch: its tip ${tip:0:12} is not the head the pull request held (${head:0:12}), so it may carry other work"
507
+ return 0
508
+ fi
442
509
  if [ "$dry" = 1 ]; then
443
510
  echo "would delete $me/$fork $branch ($what)"
444
511
  return 0
@@ -68,7 +68,7 @@ case "$policy_result" in
68
68
  esac
69
69
 
70
70
  check_text "body file $bodyfile" "$(cat "$bodyfile")"
71
- check_text "--title" "$title"
71
+ check_title "$title"
72
72
  prose_gate "$repo" "$bodyfile" "$home"
73
73
  # The reader's call decides whether the body is held to a disclosure. An edit
74
74
  # is not held for a reading, so a printout with no call falls back on the list.
@@ -100,8 +100,10 @@ while [ "$#" -gt 0 ]; do
100
100
  --body-file=*) bodyfile="${1#--body-file=}"; pass+=("$1") ;;
101
101
  -t|--title) title="${2:-}"; pass+=("$1" "${2:-}"); shift ;;
102
102
  --title=*) title="${1#--title=}"; pass+=("$1") ;;
103
- -l|--label|-a|--assignee|-m|--milestone|-p|--project) pass+=("$1" "${2:-}"); shift ;;
104
- --label=*|--assignee=*|--milestone=*|--project=*) pass+=("$1") ;;
103
+ -l|--label|-m|--milestone|-p|--project) check_value "$1" "${2:-}"; pass+=("$1" "${2:-}"); shift ;;
104
+ --label=*|--milestone=*|--project=*) check_value "${1%%=*}" "${1#*=}"; pass+=("$1") ;;
105
+ -a|--assignee) pass+=("$1" "${2:-}"); shift ;;
106
+ --assignee=*) pass+=("$1") ;;
105
107
  *)
106
108
  refused file-issue-argument-not-passed "file-issue.sh does not pass $1 to gh issue create: the body comes from one --body-file, the repository is the first argument" >&2
107
109
  exit 2
@@ -117,7 +119,7 @@ if [ "$bodyfile" = "-" ] || [ ! -f "$bodyfile" ]; then
117
119
  fi
118
120
  body=$(cat "$bodyfile")
119
121
  check_text "body file $bodyfile" "$body"
120
- check_text "--title" "$title"
122
+ check_title "$title"
121
123
  if [ "$disclosure_owed" -eq 1 ] && ! discloses "$bodyfile" /dev/null; then
122
124
  refused file-issue-disclosure-missing "$repo requires AI use to be disclosed ($policy) and the body does not name it" >&2
123
125
  exit 2
@@ -84,6 +84,9 @@ if [ "$#" -eq 0 ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
84
84
  fi
85
85
 
86
86
  command -v gh >/dev/null 2>&1 || { refused file-pr-gh-missing "gh is not on PATH" >&2; exit 2; }
87
+ # Without jq the open pull request count and the time of the last one read as
88
+ # nothing, and nothing is under the cap and past the ten minutes.
89
+ command -v jq >/dev/null 2>&1 || { refused file-pr-jq-missing "jq is not on PATH" >&2; exit 2; }
87
90
 
88
91
  repo="$1"
89
92
  shift
@@ -115,8 +118,10 @@ while [ "$#" -gt 0 ]; do
115
118
  --title=*) title="${1#--title=}"; pass+=("$1") ;;
116
119
  -B|--base) filebase="${2:-}"; pass+=("$1" "${2:-}"); shift ;;
117
120
  --base=*) filebase="${1#--base=}"; pass+=("$1") ;;
118
- -l|--label|-a|--assignee|-r|--reviewer|-m|--milestone|-p|--project) pass+=("$1" "${2:-}"); shift ;;
119
- --label=*|--assignee=*|--reviewer=*|--milestone=*|--project=*) pass+=("$1") ;;
121
+ -l|--label|-m|--milestone|-p|--project) check_value "$1" "${2:-}"; pass+=("$1" "${2:-}"); shift ;;
122
+ --label=*|--milestone=*|--project=*) check_value "${1%%=*}" "${1#*=}"; pass+=("$1") ;;
123
+ -a|--assignee|-r|--reviewer) pass+=("$1" "${2:-}"); shift ;;
124
+ --assignee=*|--reviewer=*) pass+=("$1") ;;
120
125
  -d|--draft|--no-maintainer-edit) pass+=("$1") ;;
121
126
  *)
122
127
  refused file-pr-argument-not-passed "file-pr.sh does not pass $1 to gh pr create: the body comes from one --body-file, the head is the branch you are on, the repository is the first argument" >&2
@@ -131,7 +136,7 @@ if [ "$bodyfile" = "-" ] || [ ! -f "$bodyfile" ]; then
131
136
  exit 2
132
137
  fi
133
138
  check_text "body file $bodyfile" "$(cat "$bodyfile")"
134
- check_text "--title" "$title"
139
+ check_title "$title"
135
140
  prose_gate "$repo" "$bodyfile" "$home"
136
141
  if [ "$disclosure_owed" -eq 1 ] && ! discloses "$bodyfile" "$template"; then
137
142
  refused file-pr-disclosure-missing "$repo requires AI use to be disclosed ($policy) and the body does not name it" >&2
@@ -228,12 +233,18 @@ if ! mine=$(gh pr list -R "$repo" --author @me --state open --json createdAt --j
228
233
  refused file-pr-open-prs-unreadable "cannot read your open pull requests on $repo" >&2
229
234
  exit 2
230
235
  fi
231
- open_count=$(printf '%s' "$mine" | jq 'length')
236
+ # A count or an age that is not a number fails every test below, so it is no
237
+ # answer at all.
238
+ open_count=$(printf '%s' "$mine" | jq 'length' 2>/dev/null | tr -d '\r')
239
+ since=$(printf '%s' "$mine" | jq -r --argjson now "$(date -u +%s)" 'if length > 0 then $now - (last | fromdateiso8601) else 99999 end' 2>/dev/null | tr -d '\r')
240
+ if ! [[ "$open_count" =~ ^[0-9]+$ && "$since" =~ ^-?[0-9]+$ ]]; then
241
+ refused file-pr-open-prs-not-a-list "your open pull requests on $repo did not read as a list of creation times" >&2
242
+ exit 2
243
+ fi
232
244
  if [ "$open_count" -ge 3 ]; then
233
245
  refused file-pr-open-pr-cap "you have $open_count open pull requests on $repo - three is the most a repository gets" >&2
234
246
  exit 2
235
247
  fi
236
- since=$(printf '%s' "$mine" | jq -r --argjson now "$(date -u +%s)" 'if length > 0 then $now - (last | fromdateiso8601) else 99999 end')
237
248
  if [ "$since" -lt 600 ]; then
238
249
  refused file-pr-too-soon-after-last "your last pull request on $repo was filed ${since}s ago - wait until ten minutes have passed" >&2
239
250
  exit 2
@@ -51,14 +51,14 @@ while read -r repo n; do
51
51
  case "$repo" in "$ME"/*) continue ;; esac
52
52
  # Tabs and @tsv: a branch name can hold a | or a #.
53
53
  # shellcheck disable=SC2016 # jq text
54
- info=$(gh pr view "$n" --repo "$repo" --json headRefName,headRepository,headRepositoryOwner,state \
55
- --jq '[(.headRepositoryOwner.login // "-"), (.headRepository.name // "-"), (.headRefName // "-"), .state] | @tsv' 2>/dev/null) || {
54
+ info=$(gh pr view "$n" --repo "$repo" --json headRefName,headRepository,headRepositoryOwner,state,headRefOid \
55
+ --jq '[(.headRepositoryOwner.login // "-"), (.headRepository.name // "-"), (.headRefName // "-"), .state, (.headRefOid // "-")] | @tsv' 2>/dev/null) || {
56
56
  echo "fork-hygiene.sh: gh pr view $repo#$n failed" >&2
57
57
  continue
58
58
  }
59
- IFS=$'\t' read -r owner fork branch state <<< "$info"
59
+ IFS=$'\t' read -r owner fork branch state oid <<< "$info"
60
60
  if [ "$owner" != "$ME" ] || [ "$fork" = "-" ] || [ "$branch" = "-" ]; then continue; fi
61
- drop_fork_branch "$ME" "$fork" "$branch" "$state $repo#$n" "$DRY"
61
+ drop_fork_branch "$ME" "$fork" "$branch" "$state $repo#$n" "$DRY" "$oid"
62
62
  done <<< "$closed"
63
63
 
64
64
  echo "--- forks with no PR (delete by hand when a wave is over):"