@biffo/cli 0.301.8 → 0.301.10

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.
package/dist/index.js CHANGED
@@ -12719,7 +12719,7 @@ async function runOrphanRatchetCheck(opts = {}) {
12719
12719
  const baseline = readOrphanBaseline(instanceDir);
12720
12720
  const ratchet = checkOrphanRatchet(plan.orphaned.length, baseline);
12721
12721
  console.log(
12722
- `examined ${label}: ${plan.orphaned.length} unsanctioned file(s) under a template-owned path (baseline ${baseline === null ? "none recorded" : String(baseline.count)}), against template tree ${theirsDir}`
12722
+ `examined ${label}: ${plan.entries.length} template-owned path(s) considered, ${plan.orphaned.length} unsanctioned file(s) found (baseline ${baseline === null ? "none recorded" : String(baseline.count)}), against template tree ${theirsDir}`
12723
12723
  );
12724
12724
  if (plan.orphaned.length === 0) {
12725
12725
  console.log(`\u2713 orphan-ratchet guard (${label}): no unsanctioned files`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.301.8",
3
+ "version": "0.301.10",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/scripts/claim.sh CHANGED
@@ -43,6 +43,7 @@
43
43
  # sh scripts/claim.sh 1234 --as <token> --check # report only, change nothing
44
44
  # sh scripts/claim.sh 1234 --as <token> -R owner/repo
45
45
  # sh scripts/claim.sh 1234 --release <token> # only the holder may clear it
46
+ # sh scripts/claim.sh 1234 --reaffirm <token> # keep a claim alive past session-stop
46
47
  # sh scripts/claim.sh --guard <branch> # pre-push gate — see below
47
48
  #
48
49
  # 0 free — and claimed, unless --check
@@ -148,6 +149,29 @@
148
149
  # collision caught early (see "What it cannot do" above). Set
149
150
  # `BIFFO_CLAIM_STRICT=1` to make this script itself collapse cannot-tell
150
151
  # into exit 1 instead, for anyone who would rather block than guess.
152
+ #
153
+ # ## `--reaffirm <token>` — keep a claim alive past this session's own stop (#1849)
154
+ #
155
+ # AGENTS.md's own convention is "release it... on merge, or if you stop" —
156
+ # every session, unconditionally, regardless of what it just shipped. That is
157
+ # right for the overwhelming majority of sessions, and wrong for the one that
158
+ # ships a `Refs`-only PR whose whole point is a multi-day review window during
159
+ # which the issue must stay claimed. Nothing distinguished the two: a PR could
160
+ # write, in its own body, "nothing here touches that label or that claim", and
161
+ # the same session's ordinary end-of-session `--release` fired seconds later
162
+ # regardless — the written promise and the actual mechanism disagreed, and
163
+ # nothing reconciled them (biffo-template#1849; the same guard-vs-authority
164
+ # shape already tracked with 8 other instances in this estate).
165
+ #
166
+ # `--reaffirm` gives that session something to actually RUN as a required last
167
+ # step, instead of a promise the next reader has to take on faith. It is
168
+ # deliberately not a fresh claim: it always re-applies the label and posts a
169
+ # comment for `$HOLDER`, whether or not the four signals below would call the
170
+ # issue free — that is the point, the caller is asserting "stays taken", not
171
+ # asking "is this taken". The one thing it refuses is overwriting a DIFFERENT
172
+ # live holder's claim: if the label is already present and the claim-holder
173
+ # comment names someone other than `$HOLDER`, it exits 1 exactly like a
174
+ # mismatched `--release`, rather than silently taking over.
151
175
 
152
176
  set -u
153
177
 
@@ -155,6 +179,7 @@ ISSUE=""
155
179
  REPO=""
156
180
  HOLDER=""
157
181
  RELEASE=""
182
+ REAFFIRM=""
158
183
  HOLDER_MARK="claim-holder:"
159
184
  BRANCH_MARK="claim-branch:"
160
185
  CHECK_ONLY=""
@@ -237,6 +262,17 @@ while [ $# -gt 0 ]; do
237
262
  *) HOLDER="$2"; shift 2 ;;
238
263
  esac
239
264
  ;;
265
+ --reaffirm)
266
+ # Mirrors --release's own parsing exactly, and for the identical reason
267
+ # (#826, the FLAG-IS-NOT-A-TOKEN fix above): `--reaffirm --as <token>`
268
+ # must not swallow `--as` as the token and push the real token into
269
+ # ISSUE's positional slot.
270
+ REAFFIRM=1
271
+ case "${2:-}" in
272
+ -*|'') shift ;;
273
+ *) HOLDER="$2"; shift 2 ;;
274
+ esac
275
+ ;;
240
276
  --guard)
241
277
  [ $# -ge 2 ] || missing_value "$1"
242
278
  GUARD_BRANCH="$2"
@@ -255,7 +291,7 @@ while [ $# -gt 0 ]; do
255
291
  # Refusing here, at the point the flag is actually unrecognized, says
256
292
  # what is really wrong instead of a confusing knock-on error.
257
293
  echo "${RED}claim: unrecognized flag '$1'${OFF}" >&2
258
- echo "${DIM} Known flags: -R/--repo, --check, --as, --release, --guard, -h/--help.${OFF}" >&2
294
+ echo "${DIM} Known flags: -R/--repo, --check, --as, --release, --reaffirm, --guard, -h/--help.${OFF}" >&2
259
295
  exit 2
260
296
  ;;
261
297
  *)
@@ -1029,6 +1065,65 @@ if [ "$state" != "OPEN" ]; then
1029
1065
  exit 1
1030
1066
  fi
1031
1067
 
1068
+ # --- --reaffirm: keep the claim taken, regardless of what the four signals
1069
+ # below would say (#1849) --------------------------------------------------
1070
+ #
1071
+ # Runs here rather than as an early short-circuit like --release/--guard,
1072
+ # specifically so it gets the SAME "--as <token> is required" gate those two
1073
+ # are exempted from (above) and the same OPEN-issue check just above: a
1074
+ # reaffirm with no identifying token, or of an issue that is already closed,
1075
+ # should fail exactly the way a fresh claim would, not slip through on a
1076
+ # lighter check because it front-ran the validation.
1077
+ #
1078
+ # Deliberately does NOT consult the lease/label/PR/branch signals below to
1079
+ # decide whether to act — a reaffirm is an assertion ("this stays taken"),
1080
+ # not a question ("is this taken"). The one thing it will not do is clobber
1081
+ # a claim that already names a DIFFERENT live holder: that would turn
1082
+ # "restore my own claim" into "silently steal someone else's".
1083
+ if [ -n "$REAFFIRM" ]; then
1084
+ case ",$labels," in
1085
+ *",$LABEL,"*)
1086
+ claim_held_by "$ISSUE" "$HOLDER"
1087
+ _reaffirm_held=$?
1088
+ if [ "$_reaffirm_held" -eq 1 ]; then
1089
+ echo "${RED}claim: #$ISSUE is already labeled '$LABEL', held by someone other than '$HOLDER'.${OFF}" >&2
1090
+ echo "${DIM} --reaffirm restores YOUR OWN claim; it does not take over someone else's.${OFF}" >&2
1091
+ echo "${DIM} If that claim is genuinely stale, say so in a comment and steal it via${OFF}" >&2
1092
+ echo "${DIM} the ordinary claim path instead (AGENTS.md: over an hour, no activity).${OFF}" >&2
1093
+ exit 1
1094
+ fi
1095
+ if [ "$_reaffirm_held" -eq 2 ]; then
1096
+ echo "${RED}claim: cannot tell whether #$ISSUE's '$LABEL' label is yours${OFF} — comments unreadable." >&2
1097
+ echo "${DIM} Not reaffirming on an unreadable read: that could overwrite someone else's claim.${OFF}" >&2
1098
+ exit 2
1099
+ fi
1100
+ ;;
1101
+ esac
1102
+
1103
+ # Make sure the label exists before applying it — same idempotent,
1104
+ # non-fatal create as the fresh-claim path below.
1105
+ gh_label create "$LABEL" \
1106
+ -c FBCA04 \
1107
+ -d "Claimed by a running agent session -- do not start work on this" \
1108
+ >/dev/null 2>&1 || true
1109
+
1110
+ _claim_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo '')
1111
+ case "$_claim_branch" in
1112
+ '' | HEAD) _claim_branch='' ;;
1113
+ esac
1114
+ gh_issue edit "$ISSUE" --add-label "$LABEL" >/dev/null 2>&1 || {
1115
+ echo "${RED}claim: could not apply the '$LABEL' label.${OFF}" >&2
1116
+ echo "${DIM} Not reaffirmed — do not treat #$ISSUE as still claimed.${OFF}" >&2
1117
+ exit 2
1118
+ }
1119
+ gh_issue comment "$ISSUE" \
1120
+ --body "Reaffirmed at $(date -u +%FT%TZ) by \`$(git config user.name 2>/dev/null || echo agent)\`. ${HOLDER_MARK}${HOLDER}${_claim_branch:+ ${BRANCH_MARK}${_claim_branch}} This is a REAFFIRMED claim, not a fresh one and not a release: a PR or session referencing this issue has stated it must stay claimed beyond this session's own lifetime (e.g. a review-window experiment, or a Refs-only PR that is not yet finished). Do not run --release on ordinary session-stop while that stated condition holds — release only once it genuinely resolves." \
1121
+ >/dev/null 2>&1
1122
+
1123
+ echo "${GREEN}Reaffirmed.${OFF} ${DIM}(#$ISSUE stays claimed by $HOLDER)${OFF}"
1124
+ exit 0
1125
+ fi
1126
+
1032
1127
  # --- 0.5. THE LEASE. The one authority for "is this being worked on" ---------
1033
1128
  #
1034
1129
  # ADR-0008: "The lease decides. A unit with no live lease is available, whatever