@@ -22,59 +22,20 @@ ${CLAUDE_PLUGIN_ROOT}/scripts/pat-scope-audit.sh
2222
2323The script prints ` key=value ` lines. Act on ` STATUS ` :
2424
25- - ` STATUS=ok ` : all scopes present. Search for an open tracking issue (see
26- "Marker handling" below); if found, close it with a comment noting the
27- scopes are now granted.
28- - ` STATUS=fine-grained ` : no ` X-OAuth-Scopes ` header. Fine-grained PATs have
29- no documented self-introspection endpoint — skip.
30- - ` STATUS=missing ` : open a tracking issue (or update an existing one matched
31- by the marker). The issue body must include the marker
32- ` <!-- tend-pat-scope-audit --> ` on its own line for dedup, list the values
33- from ` MISSING= ` , and link step 8 of the ` install-tend ` skill for
34- remediation:
25+ - ` STATUS=ok ` : all scopes present. Search open issues for a PAT scope
26+ audit tracking issue (`gh issue list --state open --search "PAT
27+ in: title "`); if found, close it with a comment noting the scopes are
28+ now granted.
29+ - ` STATUS=fine-grained ` : no ` X-OAuth-Scopes ` header. Fine-grained PATs
30+ have no documented self-introspection endpoint — skip.
31+ - ` STATUS=missing ` : open or update a tracking issue. Use a title
32+ containing "PAT" (e.g. ` Bot PAT: missing scopes ` ) so future runs can
33+ dedup by title search. Before creating, run `gh issue list --state open
34+ --search "PAT in: title "` and update the existing issue with ` gh issue
35+ edit` if one is already open. The body lists the values from ` MISSING=`
36+ and links step 8 of the ` install-tend ` skill for remediation:
3537 https://github.com/max-sixty/tend/blob/main/plugins/install-tend/skills/install-tend/SKILL.md#8-bot-pat-and-secret
3638
37- ### Marker handling — bang-escape mitigation
38-
39- The marker ` <!-- tend-pat-scope-audit --> ` contains an exclamation mark,
40- which the Bash tool rewrites to backslash-bang before bash parses the
41- command — the universal hazard documented in ` running-in-ci ` . Both
42- directions of the dedup workflow are broken if you put ` <!-- ` in any
43- Bash-tool command string:
44-
45- - ** Body composition** via ` gh issue create --body "..." ` or a Bash heredoc
46- ships the marker with the exclamation mark backslash-escaped — visible
47- corruption in the posted body, and future runs searching for the intact
48- marker will not match it.
49- - ** Search** via ` jq '... contains("<!-- tend-pat-scope-audit -->")' `
50- rewrites the exclamation mark; jq fails to parse the backslash-bang
51- sequence as an escape and the search silently returns nothing — so the
52- agent concludes no audit issue exists and opens a duplicate.
53-
54- Use the bang-safe forms instead:
55-
56- - ** Search by the bang-free substring** ` tend-pat-scope-audit ` (the
57- identifier is unique on its own — the ` <!-- ` wrapping is purely for
58- human-invisibility in the rendered issue):
59-
60- ``` bash
61- gh issue list --state open --search " tend-pat-scope-audit in:body" \
62- --json number,title,body \
63- --jq ' .[] | select(.body | contains("tend-pat-scope-audit"))'
64- ```
65-
66- - ** Compose the body with the Write tool** to a file, then pass via
67- ` --body-file ` . Authoring through the Write tool preserves ` <!-- `
68- verbatim:
69-
70- ``` bash
71- # Author /tmp/pat-scope-body.md with the Write tool. The body must
72- # include the literal marker line: <!-- tend-pat-scope-audit -->
73- gh issue create --title " ..." --body-file /tmp/pat-scope-body.md ...
74- # When updating an existing tracking issue:
75- gh issue edit < number> --body-file /tmp/pat-scope-body.md
76- ```
77-
7839## Step 2: Resolve conflicts on bot PRs
7940
8041``` bash
0 commit comments