housebroken-cli 0.22.0__tar.gz → 0.23.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 (39) hide show
  1. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/PKG-INFO +2 -2
  2. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/README.md +1 -1
  3. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/pyproject.toml +1 -1
  4. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/common.sh +19 -0
  5. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/pr-sweep.sh +41 -2
  6. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/reply.sh +10 -8
  7. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/review.sh +8 -1
  8. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/skills/housebroken/SKILL.md +8 -1
  9. housebroken_cli-0.23.0/src/housebroken/__init__.py +1 -0
  10. housebroken_cli-0.22.0/src/housebroken/__init__.py +0 -1
  11. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/.gitignore +0 -0
  12. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/LICENSE +0 -0
  13. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/bin/housebroken +0 -0
  14. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/hatch_build.py +0 -0
  15. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/branch-check.sh +0 -0
  16. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/check-ai-policy.sh +0 -0
  17. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/ci-legs.sh +0 -0
  18. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/claim-check.sh +0 -0
  19. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/close.sh +0 -0
  20. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/comment-census.sh +0 -0
  21. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/comment-check.sh +0 -0
  22. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/declare.sh +0 -0
  23. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/diff-defaults.sh +0 -0
  24. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/distinct-outside.sh +0 -0
  25. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/edit-pr.sh +0 -0
  26. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/file-issue.sh +0 -0
  27. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/file-pr.sh +0 -0
  28. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/fork-hygiene.sh +0 -0
  29. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/gate-hook.sh +0 -0
  30. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/inbox.sh +0 -0
  31. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/notes.sh +0 -0
  32. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/prior-art.sh +0 -0
  33. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/proof.sh +0 -0
  34. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/push.sh +0 -0
  35. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/ref-check.sh +0 -0
  36. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/refuse.sh +0 -0
  37. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/same-code.sh +0 -0
  38. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/scripts/verify-filed-pr.sh +0 -0
  39. {housebroken_cli-0.22.0 → housebroken_cli-0.23.0}/src/housebroken/cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: housebroken-cli
3
- Version: 0.22.0
3
+ Version: 0.23.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
6
  Project-URL: Issues, https://github.com/lenamonj/housebroken/issues
@@ -144,7 +144,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
144
144
  | `scripts/file-pr.sh` | the only way a pull request gets filed: every gate above in front of `gh pr create` |
145
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 |
146
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 |
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) |
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); and a count of the open ones whose head this machine holds no review of under the current brief, each named on a `READ` line by `--all` |
148
148
  | `scripts/inbox.sh` | what GitHub has to tell you since you last looked, bodies included, with a census of every open pull request |
149
149
  | `scripts/notes.sh` | what this repository's maintainers have asked for before |
150
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 |
@@ -121,7 +121,7 @@ An upgrade moves the package and not those two copies, so after one run `housebr
121
121
  | `scripts/file-pr.sh` | the only way a pull request gets filed: every gate above in front of `gh pr create` |
122
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 |
123
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 |
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
+ | `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); and a count of the open ones whose head this machine holds no review of under the current brief, each named on a `READ` line by `--all` |
125
125
  | `scripts/inbox.sh` | what GitHub has to tell you since you last looked, bodies included, with a census of every open pull request |
126
126
  | `scripts/notes.sh` | what this repository's maintainers have asked for before |
127
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 |
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "housebroken-cli"
7
- version = "0.22.0"
7
+ version = "0.23.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"
@@ -419,6 +419,25 @@ is_bot() { case "$1" in *"[bot]"|Copilot|codecov-commenter|coveralls|CLAassistan
419
419
  # can type into the thread: read, never answered without the user's word.
420
420
  has_role() { case "$(printf '%s' "$1" | tr '[:lower:]' '[:upper:]')" in OWNER|MEMBER|COLLABORATOR) return 0 ;; *) return 1 ;; esac; }
421
421
 
422
+ # The review brief's number: that of the last item in a code review's brief
423
+ # (a brief with no clone stops earlier and carries the same number). review.sh
424
+ # has the reviewer write it into the report, and the sweep compares it with
425
+ # this one, so a head reviewed before an item existed is told from one
426
+ # reviewed after. Raise it with every item the brief gains.
427
+ # shellcheck disable=SC2034 # read by the scripts that source this file
428
+ review_brief_items=13
429
+
430
+ # The brief a head was reviewed under, read from the header of the report
431
+ # review.sh names for that head: its number, 0 when the header carries none or
432
+ # one no brief will reach, "unreadable" when the report cannot be read, and
433
+ # nothing when this machine holds no report for the head.
434
+ reviewed_under() { # repo head home
435
+ local report="$3/reviews/review-${1%%/*}-${1##*/}-${2:0:12}.md" n
436
+ [ -f "$report" ] || return 0
437
+ n=$(awk '{sub(/\r$/, "")} NF == 0 {exit} $1 == "brief:" {print $2; exit}' "$report" 2>/dev/null) || { echo unreadable; return 0; }
438
+ case "$n" in ''|*[!0-9]*|???????*) echo 0 ;; *) echo "$n" ;; esac
439
+ }
440
+
422
441
  # Prints stdin as someone else's words: fenced and marked, each line prefixed so
423
442
  # nothing inside can pass for the script's own output or close the fence.
424
443
  fence() { # who indent
@@ -22,6 +22,16 @@
22
22
  # keeps it, so the sweep prints one KEPT line and stops asking. The obligation
23
23
  # is in the output, not in anyone's memory.
24
24
  #
25
+ # A gate reads a pull request when it is pushed, so one filed before a review
26
+ # item existed is never read under it, however long it stays open. A run
27
+ # counts the open pull requests, outside repositories under your own login,
28
+ # whose head this machine holds no review report for, holds one written under
29
+ # an earlier brief, or holds one it cannot read; it prints the count when
30
+ # there is any, and --all prints a READ line for each. A pull request leaves
31
+ # the count once its head has a report under the current brief. It is not
32
+ # counted as an action and changes no exit status: the reports are local, so a
33
+ # head reviewed on another machine reads the same as one never reviewed.
34
+ #
25
35
  # Usage:
26
36
  # bash pr-sweep.sh # only PRs where the ball is in our court
27
37
  # bash pr-sweep.sh --all # every open PR with its state
@@ -205,7 +215,8 @@ if ! jq -n --arg t "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
205
215
  exit 1
206
216
  fi
207
217
 
208
- n=0; act=0
218
+ home="${HOUSEBROKEN_HOME:-$HOME/.housebroken}"
219
+ n=0; act=0; nread=0; reads=""
209
220
  while IFS=$'\t' read -r repo num updated title; do
210
221
  [ -n "$repo" ] || continue
211
222
  n=$((n + 1))
@@ -221,11 +232,34 @@ while IFS=$'\t' read -r repo num updated title; do
221
232
  | sort_by(.t) | last | "\(.a // "-") \(.t // "-") \(.r // "-")"')"
222
233
  read -r la_user la_time la_role <<<"$last_actor"
223
234
  ci="$(printf '%s' "$j" | jq -r "$ci_jq"'[.statusCheckRollup[]?] | if length == 0 then "none" elif any(.[]; ci == "red" and check_state != "ACTION_REQUIRED") then "FAILING" elif any(.[]; check_state == "ACTION_REQUIRED") then "needs-approval" elif any(.[]; ci == "running") then "pending" else "green" end')"
235
+ head_oid="$(printf '%s' "$j" | jq -r '.headRefOid // ""' | tr -d '\r')"
224
236
  # An empty check list is a quiet repository or a head GitHub made no run for.
225
237
  if [ "$ci" = "none" ]; then
226
- ci="$(empty_rollup_reading "$repo" "$(printf '%s' "$j" | jq -r '.headRefOid // ""' | tr -d '\r')")"
238
+ ci="$(empty_rollup_reading "$repo" "$head_oid")"
227
239
  [ "$ci" = "needs-run-approval" ] && ci="needs-approval"
228
240
  fi
241
+ # A gate reads a pull request when it is pushed, so one filed before a review
242
+ # item existed is never read under it. The reports are this machine's, and a
243
+ # pull request in a repository of our own never went through the door.
244
+ if [ "${repo%%/*}" != "$ME" ]; then
245
+ mark=""
246
+ if [ -z "$head_oid" ]; then
247
+ mark="head-unread"
248
+ else
249
+ under="$(reviewed_under "$repo" "$head_oid" "$home")"
250
+ if [ -z "$under" ]; then mark="no-review-of-head"
251
+ elif [ "$under" = unreadable ]; then mark="review-report-unreadable"
252
+ elif [ "$under" -eq 0 ]; then mark="reviewed-under-an-unnumbered-brief"
253
+ elif [ "$under" -lt "$review_brief_items" ]; then mark="reviewed-under-brief-$under-of-$review_brief_items"
254
+ fi
255
+ [ -z "$mark" ] || mark="$mark ${head_oid:0:12}"
256
+ fi
257
+ if [ -n "$mark" ]; then
258
+ nread=$((nread + 1))
259
+ reads="$reads$(printf 'READ %-38s #%-5s %s [%s] %s' "$repo" "$num" "${title:0:60}" "$mark" "https://github.com/$repo/pull/$num")
260
+ "
261
+ fi
262
+ fi
229
263
  mergeable="$(printf '%s' "$j" | jq -r '.mergeable // "-"')"
230
264
  decision="$(printf '%s' "$j" | jq -r '.reviewDecision // "-"')"
231
265
  why=""
@@ -256,7 +290,12 @@ while IFS=$'\t' read -r repo num updated title; do
256
290
  printf 'ok %-38s #%-5s %s ci=%s mergeable=%s updated=%s\n' "$repo" "$num" "${title:0:60}" "$ci" "$mergeable" "${updated:0:10}"
257
291
  fi
258
292
  done <<< "$list"
293
+ if [ "$nread" -gt 0 ] && [ "$ALL" = 1 ]; then
294
+ echo "--- no review of the head under the current brief ($review_brief_items items) on this machine"
295
+ printf '%s' "$reads"
296
+ fi
259
297
  echo "open PRs: $n; needing action: $act"
298
+ [ "$nread" -gt 0 ] && echo "not read under the current review brief: $nread of $n (housebroken sweep --all names them)"
260
299
  [ "$ntidy" -gt 0 ] && echo "fork branches to tidy: $ntidy (housebroken hygiene)"
261
300
  if [ "$unreadable" -gt 0 ]; then
262
301
  echo "SWEEP UNREADABLE: $unreadable pull request(s) could not be read, so their state is unknown, not clean" >&2
@@ -58,13 +58,13 @@ repo="${1:-}"; num="${2:-}"
58
58
  case "$repo" in */*) ;; *) refused reply-repo-form "name the repository as owner/repo" >&2; exit 2 ;; esac
59
59
  case "$num" in ''|*[!0-9]*) refused reply-no-number "name the pull request or issue number" >&2; exit 2 ;; esac
60
60
  shift 2
61
- body=""; report=""; long=0; clone=""; thread=""; outsider=0
61
+ body=""; report=""; long=0; clone=""; thread=""; inline=0; outsider=0
62
62
  while [ "$#" -gt 0 ]; do
63
63
  case "$1" in
64
64
  --body-file) body="${2:-}"; shift ;;
65
65
  --review) report="${2:-}"; shift ;;
66
66
  --clone) clone="${2:-}"; shift ;;
67
- --in-reply-to) thread="${2:-}"; shift ;;
67
+ --in-reply-to) thread="${2:-}"; inline=1; shift ;;
68
68
  --long) long=1 ;;
69
69
  --outsider) outsider=1 ;;
70
70
  *) refused reply-unknown-argument "unknown argument $1" >&2; exit 2 ;;
@@ -72,7 +72,10 @@ while [ "$#" -gt 0 ]; do
72
72
  shift
73
73
  done
74
74
  [ -f "$body" ] || { refused reply-body-file-missing "--body-file names no file" >&2; exit 2; }
75
- case "$thread" in ''|[0-9]*) ;; *) refused reply-in-reply-to-form "--in-reply-to needs the comment id" >&2; exit 2 ;; esac
75
+ # The id is digits and nothing else, and the flag with no id is not a reply to the conversation.
76
+ if [ "$inline" -eq 1 ]; then
77
+ case "$thread" in ''|*[!0-9]*) refused reply-in-reply-to-form "--in-reply-to needs the comment id" >&2; exit 2 ;; esac
78
+ fi
76
79
  here=$(cd "$(dirname "$0")" && pwd)
77
80
  # shellcheck source=scripts/common.sh
78
81
  . "$here/common.sh"
@@ -108,11 +111,10 @@ read_all() { # endpoint file
108
111
  }
109
112
  voice=""
110
113
  if [ -n "$thread" ]; then
111
- if one=$(gh api "repos/$repo/pulls/comments/$thread" 2>/dev/null); then
112
- voice=$(printf '%s' "$one" | jq -r '"\(.user.login // "?") \(.author_association // "?")"' | tr -d '\r')
113
- else
114
- refuse reply-comment-unreadable "cannot read comment $thread, so who it answers is unknown"
115
- fi
114
+ # An answer that is not the comment leaves no voice, and no voice is not nobody to answer.
115
+ one=$(gh api "repos/$repo/pulls/comments/$thread" 2>/dev/null) &&
116
+ voice=$(printf '%s' "$one" | jq -r 'select(type == "object" and (.user.login | type) == "string") | "\(.user.login) \(.author_association // "?")"' 2>/dev/null | tr -d '\r')
117
+ [ -n "$voice" ] || refuse reply-comment-unreadable "cannot read comment $thread, so who it answers is unknown"
116
118
  else
117
119
  ok=1
118
120
  # The opening post says whether this is a pull request, and its author is a
@@ -17,7 +17,10 @@
17
17
  # The report is bound to what it read. Its header records the head it attacked
18
18
  # and the sha256 of every text, and check refuses when the branch or the text
19
19
  # has moved since, or when the verdict is anything but POST AS IS: a fix the
20
- # reviewer asked for is a new head, and a new head is reviewed again.
20
+ # reviewer asked for is a new head, and a new head is reviewed again. The
21
+ # header also records the brief it answers, by the number of the last item in
22
+ # a code review's brief, and `housebroken sweep` counts every open pull request
23
+ # whose head was never read under the current one; `sweep --all` names them.
21
24
  #
22
25
  # Usage:
23
26
  # bash review.sh reviewer MODEL
@@ -50,6 +53,8 @@ bad_usage() { echo "review.sh: $1" >&2; exit 2; }
50
53
 
51
54
  home="${HOUSEBROKEN_HOME:-$HOME/.housebroken}"
52
55
  here=$(cd "$(dirname "$0")" && pwd)
56
+ # shellcheck source=scripts/common.sh
57
+ . "$here/common.sh"
53
58
 
54
59
  # A name that mentions two families, such as "claude-haiku-4-5 (sonnet
55
60
  # floor)", belongs to neither, so it cannot pass as the one named second.
@@ -250,6 +255,8 @@ EOF
250
255
  printf 'text: sha256:%s %s\n' "$(sha256 "$t")" "$(basename "$t")"
251
256
  done
252
257
  printf 'author-model: %s\nreviewer-model: %s\n' "$author" "$reviewer"
258
+ # which brief this report answers, so the sweep can name a head read under an earlier one
259
+ printf 'brief: %s\n' "$review_brief_items"
253
260
  [ -n "$head" ] && printf 'blind-fix: %s\n' "$blind"
254
261
  printf 'skipped: none | <the item numbers you did not attack, each with why>\n'
255
262
  printf 'verdict: POST AS IS | POST WITH CHANGES | DO NOT POST\n\n'
@@ -331,7 +331,14 @@ report it in one line and do not proceed to the next step.
331
331
  pull request whose fork branch still exists, on every run until
332
332
  `housebroken hygiene` has deleted it; a branch that moved past the head
333
333
  its pull request held is other work, which hygiene keeps, so `sweep`
334
- prints one `KEPT` line for it and stops asking. Both `sweep` and the inbox census
334
+ prints one `KEPT` line for it and stops asking. A gate reads a pull
335
+ request when it is pushed, so one filed before a review item existed was
336
+ never read under it: `sweep` counts the open pull requests whose head
337
+ this machine holds no review report for under the current brief, on
338
+ every run, and `sweep --all` names each on a `READ` line, until
339
+ `housebroken review` has been run on that head and its report written.
340
+ The count is a prompt to re-read old work, not a maintainer waiting;
341
+ which ones to re-read first is the user's call. Both `sweep` and the inbox census
335
342
  name two states that look quiet. A head no CI job ever started on reads
336
343
  `no-ci-on-head` when GitHub made no run for it and `ci-never-started`
337
344
  when the run it made finished without one. A new push or a close and
@@ -0,0 +1 @@
1
+ __version__ = "0.23.0"
@@ -1 +0,0 @@
1
- __version__ = "0.22.0"