@carecard/jwt-read 3.1.17 → 3.1.18
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/.agents/skills/github-pr-create-update/SKILL.md +63 -84
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +103 -79
- package/.agents/skills/pkg-jwt-read-jwt-middleware-library/SKILL.md +11 -1
- package/index.d.ts +123 -9
- package/index.js +4 -0
- package/lib/jwtLib.js +256 -34
- package/package.json +1 -1
- package/readme.md +41 -0
|
@@ -1,70 +1,57 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: github-pr-create-update
|
|
3
|
-
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating or updating a PR, or marking a PR ready from the current repository branch.'
|
|
3
|
+
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating or updating a PR, or marking a PR ready from the current repository branch into development or main.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Pull Request Create
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
After the user explicitly asks for remote Git or GitHub PR work, create,
|
|
10
|
+
After the user explicitly asks for remote Git or GitHub PR work, create,
|
|
11
|
+
update, verify, push, and mark ready a GitHub pull request from the current
|
|
12
|
+
repository branch into `development`, or into `main` when `development` is
|
|
13
|
+
absent.
|
|
11
14
|
|
|
12
15
|
## When To Use
|
|
13
16
|
|
|
14
|
-
- Use only when the user explicitly asks to create, update, push for, or mark
|
|
17
|
+
- Use only when the user explicitly asks to create, update, push for, or mark
|
|
18
|
+
ready a GitHub pull request from the current repository branch.
|
|
15
19
|
|
|
16
20
|
## When Not To Use
|
|
17
21
|
|
|
18
|
-
- Do not use for merging or deleting an already-approved pull request; use the
|
|
22
|
+
- Do not use for merging or deleting an already-approved pull request; use the
|
|
23
|
+
merge cleanup skill.
|
|
19
24
|
- Do not use for ordinary local commits that do not involve GitHub PR work.
|
|
20
25
|
|
|
21
26
|
## Remote Git Operations Guardrail
|
|
22
27
|
|
|
23
|
-
Do not run remote Git or GitHub operations unless the current user request
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Coding Principles
|
|
32
|
-
|
|
33
|
-
- Preserve the repository structure, naming style, module system, and local helper patterns.
|
|
34
|
-
- Prefer readable, maintainable code with meaningful function, variable, file, and test names.
|
|
35
|
-
- Avoid new dependencies unless the existing stack cannot reasonably solve the task and the user confirms the tradeoff.
|
|
36
|
-
|
|
37
|
-
## Testing Expectations
|
|
38
|
-
|
|
39
|
-
- Run repository validation before PR creation or merge when code behavior changed.
|
|
40
|
-
- Confirm the branch is clean except intended changes before finishing.
|
|
41
|
-
|
|
42
|
-
## Safety Constraints
|
|
43
|
-
|
|
44
|
-
- Do not edit generated output, dependency folders, logs, coverage, dist, or build artifacts unless the task requires it.
|
|
45
|
-
- Do not revert or overwrite user changes; stage only requested skill or instruction files.
|
|
46
|
-
- Never suppress errors, lint failures, type failures, security failures, or failing tests; fix the underlying issue or report the blocker.
|
|
47
|
-
|
|
48
|
-
## Commit Continuation Rule
|
|
49
|
-
|
|
50
|
-
Do not amend commits unless the user explicitly asks. If
|
|
51
|
-
hook, formatter, documentation, skill, validation, or review follow-up changes
|
|
52
|
-
appear after a commit, stage only the intended files and make a new commit with
|
|
53
|
-
a clear message.
|
|
28
|
+
Do not run remote Git or GitHub operations unless the current user request
|
|
29
|
+
explicitly asks for them. This includes `git fetch`, `git pull`, `git push`,
|
|
30
|
+
`git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr`
|
|
31
|
+
command that creates, updates, readies, merges, closes, or cleans up a pull
|
|
32
|
+
request. Do not infer permission from branch names, validation needs, prior
|
|
33
|
+
workflow habits, or convenience; ask first when remote state would help but was
|
|
34
|
+
not requested.
|
|
54
35
|
|
|
55
36
|
## Scope
|
|
56
37
|
|
|
57
38
|
Use this skill from the root of the repository whose current branch contains
|
|
58
|
-
the intended PR changes. The repository must have `origin/development
|
|
59
|
-
GitHub CLI must be available and authenticated.
|
|
39
|
+
the intended PR changes. The repository must have `origin/development` or
|
|
40
|
+
`origin/main`, and GitHub CLI must be available and authenticated.
|
|
41
|
+
|
|
42
|
+
Default terms:
|
|
43
|
+
|
|
44
|
+
- Base branch: `development` when `origin/development` exists; otherwise
|
|
45
|
+
`main` when `origin/main` exists.
|
|
46
|
+
- Source branch: the current branch unless the user names another branch.
|
|
60
47
|
|
|
61
48
|
Do not continue automatically when:
|
|
62
49
|
|
|
63
|
-
- The
|
|
50
|
+
- The source branch is `development`, `main`, `master`, or detached.
|
|
64
51
|
- The working tree has uncommitted changes. Explain that a PR only includes
|
|
65
52
|
committed changes and ask the user whether to commit or stash them.
|
|
66
53
|
- `gh auth status` fails.
|
|
67
|
-
- `origin/development`
|
|
54
|
+
- Neither `origin/development` nor `origin/main` exists.
|
|
68
55
|
|
|
69
56
|
## Workflow
|
|
70
57
|
|
|
@@ -80,30 +67,26 @@ Do not continue automatically when:
|
|
|
80
67
|
gh auth status
|
|
81
68
|
```
|
|
82
69
|
|
|
83
|
-
2.
|
|
84
|
-
|
|
70
|
+
2. Select the pull request base branch. Prefer `development`; use `main` only
|
|
71
|
+
when `origin/development` is absent:
|
|
85
72
|
|
|
86
73
|
```sh
|
|
87
|
-
git
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
git fetch origin
|
|
74
|
+
if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then
|
|
75
|
+
base="development"
|
|
76
|
+
elif git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
|
|
77
|
+
base="main"
|
|
78
|
+
else
|
|
79
|
+
echo "No origin/development or origin/main branch exists."
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|
|
82
|
+
git fetch origin "$base" --prune
|
|
96
83
|
```
|
|
97
84
|
|
|
98
|
-
|
|
99
|
-
checked out in another worktree, do not force it. Continue using
|
|
100
|
-
`origin/development` for validation.
|
|
101
|
-
|
|
102
|
-
3. Check whether the current branch can merge with latest development without
|
|
85
|
+
3. Check whether the current branch can merge with the latest base without
|
|
103
86
|
changing the worktree:
|
|
104
87
|
|
|
105
88
|
```sh
|
|
106
|
-
if git merge-tree --write-tree HEAD origin
|
|
89
|
+
if git merge-tree --write-tree HEAD "origin/$base" >/tmp/pull-request-create-merge-tree.out
|
|
107
90
|
then
|
|
108
91
|
merge_conflict_detected=false
|
|
109
92
|
else
|
|
@@ -111,11 +94,11 @@ Do not continue automatically when:
|
|
|
111
94
|
fi
|
|
112
95
|
```
|
|
113
96
|
|
|
114
|
-
4. If a merge conflict is detected, try rebasing on latest
|
|
97
|
+
4. If a merge conflict is detected, try rebasing on the latest base:
|
|
115
98
|
|
|
116
99
|
```sh
|
|
117
100
|
if [ "$merge_conflict_detected" = true ]; then
|
|
118
|
-
if git rebase origin
|
|
101
|
+
if git rebase "origin/$base"; then
|
|
119
102
|
git push --force-with-lease -u origin "$branch"
|
|
120
103
|
else
|
|
121
104
|
git rebase --abort
|
|
@@ -127,62 +110,58 @@ Do not continue automatically when:
|
|
|
127
110
|
fi
|
|
128
111
|
```
|
|
129
112
|
|
|
130
|
-
Do not
|
|
131
|
-
|
|
113
|
+
Do not use `--no-verify`; pre-push hooks must run. Do not resolve rebase
|
|
114
|
+
conflicts unless the user explicitly asks.
|
|
132
115
|
|
|
133
|
-
5.
|
|
116
|
+
5. Verify the remote branch matches local `HEAD`:
|
|
134
117
|
|
|
135
118
|
```sh
|
|
136
|
-
git
|
|
137
|
-
git
|
|
119
|
+
local_sha="$(git rev-parse HEAD)"
|
|
120
|
+
remote_sha="$(git ls-remote --heads origin "$branch" | awk '{print $1}')"
|
|
121
|
+
test "$local_sha" = "$remote_sha"
|
|
138
122
|
```
|
|
139
123
|
|
|
140
|
-
|
|
141
|
-
such as `draft`, `[draft]`, `Draft:`, and `WIP`. Do not leave a generic title
|
|
142
|
-
such as "updates", "changes", or "draft PR".
|
|
124
|
+
6. Inspect the branch changes before writing the PR title:
|
|
143
125
|
|
|
144
|
-
|
|
126
|
+
```sh
|
|
127
|
+
git log --reverse --format='%s' "origin/$base..HEAD"
|
|
128
|
+
git diff --stat "origin/$base...HEAD"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
7. Reuse an existing open PR for this exact branch/base pair when present:
|
|
145
132
|
|
|
146
133
|
```sh
|
|
147
134
|
pr_number="$(gh pr list \
|
|
148
135
|
--head "$branch" \
|
|
149
|
-
--base
|
|
136
|
+
--base "$base" \
|
|
150
137
|
--state open \
|
|
151
138
|
--json number \
|
|
152
139
|
--jq '.[0].number // empty')"
|
|
153
140
|
```
|
|
154
141
|
|
|
155
|
-
|
|
156
|
-
number:
|
|
142
|
+
8. If there is no PR, create one against the selected base and capture the new
|
|
143
|
+
PR number:
|
|
157
144
|
|
|
158
145
|
```sh
|
|
159
146
|
pr_url="$(gh pr create \
|
|
160
|
-
--base
|
|
147
|
+
--base "$base" \
|
|
161
148
|
--head "$branch" \
|
|
162
149
|
--title "$title" \
|
|
163
150
|
--body "$body")"
|
|
164
151
|
pr_number="$(gh pr view "$pr_url" --json number --jq '.number')"
|
|
165
152
|
```
|
|
166
153
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
8. If a PR exists, mark it ready when it is a draft:
|
|
154
|
+
9. If a PR exists, mark it ready when it is a draft, then keep the title
|
|
155
|
+
descriptive:
|
|
171
156
|
|
|
172
157
|
```sh
|
|
173
158
|
is_draft="$(gh pr view "$pr_number" --json isDraft --jq '.isDraft')"
|
|
174
159
|
if [ "$is_draft" = "true" ]; then
|
|
175
160
|
gh pr ready "$pr_number"
|
|
176
161
|
fi
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
9. Update the PR title after create/reuse so it is descriptive and contains no
|
|
180
|
-
draft wording:
|
|
181
|
-
|
|
182
|
-
```sh
|
|
183
162
|
gh pr edit "$pr_number" --title "$title"
|
|
184
163
|
```
|
|
185
164
|
|
|
186
|
-
10. Final response should include the PR URL,
|
|
187
|
-
whether an existing PR was reused or marked ready,
|
|
188
|
-
could not be run.
|
|
165
|
+
10. Final response should include the PR URL, selected base branch, whether a
|
|
166
|
+
rebase was performed, whether an existing PR was reused or marked ready,
|
|
167
|
+
and any validation that could not be run.
|
|
@@ -1,56 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: github-pr-merge-cleanup
|
|
3
|
-
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: reviewing
|
|
3
|
+
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating a missing PR, reviewing mergeability, validating, merging, deleting, or cleaning up a pull request branch.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Pull Request Merge Close
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
After the user explicitly asks for remote Git or GitHub PR work,
|
|
10
|
+
After the user explicitly asks for remote Git or GitHub PR work, push the
|
|
11
|
+
branch, create a missing PR when needed, review, validate, merge, delete the
|
|
12
|
+
branch when allowed, and clean local state for a GitHub pull request targeting
|
|
13
|
+
`development`, or `main` when `development` is absent.
|
|
11
14
|
|
|
12
15
|
## When To Use
|
|
13
16
|
|
|
14
|
-
- Use only when the user explicitly asks to review mergeability,
|
|
17
|
+
- Use only when the user explicitly asks to push, review mergeability,
|
|
18
|
+
validate, merge, close, or clean up a GitHub pull request branch.
|
|
15
19
|
|
|
16
20
|
## When Not To Use
|
|
17
21
|
|
|
18
|
-
- Do not use for
|
|
19
|
-
|
|
22
|
+
- Do not use for PR-only creation/update work without a merge request; use the
|
|
23
|
+
PR create/update skill.
|
|
24
|
+
- Do not use when the user only asks for local code changes without PR merge
|
|
25
|
+
work.
|
|
20
26
|
|
|
21
27
|
## Remote Git Operations Guardrail
|
|
22
28
|
|
|
23
|
-
Do not run remote Git or GitHub operations unless the current user request
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Coding Principles
|
|
32
|
-
|
|
33
|
-
- Preserve the repository structure, naming style, module system, and local helper patterns.
|
|
34
|
-
- Prefer readable, maintainable code with meaningful function, variable, file, and test names.
|
|
35
|
-
- Avoid new dependencies unless the existing stack cannot reasonably solve the task and the user confirms the tradeoff.
|
|
36
|
-
|
|
37
|
-
## Testing Expectations
|
|
38
|
-
|
|
39
|
-
- Run repository validation before PR creation or merge when code behavior changed.
|
|
40
|
-
- Confirm the branch is clean except intended changes before finishing.
|
|
41
|
-
|
|
42
|
-
## Safety Constraints
|
|
43
|
-
|
|
44
|
-
- Do not edit generated output, dependency folders, logs, coverage, dist, or build artifacts unless the task requires it.
|
|
45
|
-
- Do not revert or overwrite user changes; stage only requested skill or instruction files.
|
|
46
|
-
- Never suppress errors, lint failures, type failures, security failures, or failing tests; fix the underlying issue or report the blocker.
|
|
47
|
-
|
|
48
|
-
## Commit Continuation Rule
|
|
49
|
-
|
|
50
|
-
Do not amend commits unless the user explicitly asks. If
|
|
51
|
-
hook, formatter, documentation, skill, validation, or review follow-up changes
|
|
52
|
-
appear after a commit, stage only the intended files and make a new commit with
|
|
53
|
-
a clear message.
|
|
29
|
+
Do not run remote Git or GitHub operations unless the current user request
|
|
30
|
+
explicitly asks for them. This includes `git fetch`, `git pull`, `git push`,
|
|
31
|
+
`git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr`
|
|
32
|
+
command that creates, updates, readies, merges, closes, or cleans up a pull
|
|
33
|
+
request. Do not infer permission from branch names, validation needs, prior
|
|
34
|
+
workflow habits, or convenience; ask first when remote state would help but was
|
|
35
|
+
not requested.
|
|
54
36
|
|
|
55
37
|
## Scope
|
|
56
38
|
|
|
@@ -60,8 +42,8 @@ branch available locally or on `origin`.
|
|
|
60
42
|
|
|
61
43
|
Default terms:
|
|
62
44
|
|
|
63
|
-
- Base branch: `development` when `origin/development` exists, otherwise
|
|
64
|
-
|
|
45
|
+
- Base branch: `development` when `origin/development` exists, otherwise
|
|
46
|
+
`main` when `origin/main` exists.
|
|
65
47
|
- Target branch: the current branch unless the user names another branch.
|
|
66
48
|
- Pull request: the open PR whose head is the target branch and whose base is
|
|
67
49
|
the base branch.
|
|
@@ -72,35 +54,86 @@ Do not continue automatically when:
|
|
|
72
54
|
- The target branch is detached or is the base branch.
|
|
73
55
|
- The working tree has uncommitted changes that are not part of the requested
|
|
74
56
|
PR cleanup.
|
|
75
|
-
-
|
|
57
|
+
- Neither `origin/development` nor `origin/main` exists.
|
|
76
58
|
- A rebase or validation fix would require behavior changes instead of coding
|
|
77
59
|
criteria cleanup.
|
|
78
60
|
|
|
61
|
+
If no open pull request exists for the target branch and selected base, create
|
|
62
|
+
one as part of the merge workflow when the user requested push/PR/merge
|
|
63
|
+
completion.
|
|
64
|
+
|
|
79
65
|
## Workflow
|
|
80
66
|
|
|
81
|
-
1. Capture the base branch, target branch,
|
|
67
|
+
1. Capture the base branch, target branch, and authentication state:
|
|
82
68
|
|
|
83
69
|
```sh
|
|
84
70
|
gh auth status
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then
|
|
72
|
+
base="development"
|
|
73
|
+
elif git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
|
|
74
|
+
base="main"
|
|
75
|
+
else
|
|
76
|
+
echo "No origin/development or origin/main branch exists."
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
88
79
|
target_branch="$(git branch --show-current)"
|
|
89
80
|
test -n "$target_branch"
|
|
90
81
|
test "$target_branch" != "$base"
|
|
91
82
|
git status --short
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If the user names a target branch, use that branch instead of the current
|
|
86
|
+
branch. If the target branch is not local but exists on `origin`, create a
|
|
87
|
+
local branch from the remote head before continuing:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
if ! git show-ref --verify --quiet "refs/heads/$target_branch"; then
|
|
91
|
+
git fetch origin "$target_branch:$target_branch"
|
|
92
|
+
fi
|
|
93
|
+
git switch "$target_branch"
|
|
92
94
|
git fetch origin "$base" --prune
|
|
93
|
-
pr_number="$(gh pr list --head "$target_branch" --base "$base" --state open --json number --jq '.[0].number // empty')"
|
|
94
|
-
test -n "$pr_number"
|
|
95
|
-
protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected' 2>/dev/null || echo false)"
|
|
96
95
|
```
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
2. Push the target branch to the same remote branch name. Do not use
|
|
98
|
+
`--no-verify`; pre-push hooks must run.
|
|
100
99
|
|
|
101
|
-
|
|
100
|
+
```sh
|
|
101
|
+
git push -u origin "$target_branch"
|
|
102
|
+
local_sha="$(git rev-parse HEAD)"
|
|
103
|
+
remote_sha="$(git ls-remote --heads origin "$target_branch" | awk '{print $1}')"
|
|
104
|
+
test "$local_sha" = "$remote_sha"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
3. Reuse an existing open PR for this exact branch/base pair, or create one
|
|
108
|
+
when none exists:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
pr_number="$(gh pr list \
|
|
112
|
+
--head "$target_branch" \
|
|
113
|
+
--base "$base" \
|
|
114
|
+
--state open \
|
|
115
|
+
--json number \
|
|
116
|
+
--jq '.[0].number // empty')"
|
|
117
|
+
|
|
118
|
+
if [ -z "$pr_number" ]; then
|
|
119
|
+
git log --reverse --format='%s' "origin/$base..HEAD"
|
|
120
|
+
git diff --stat "origin/$base...HEAD"
|
|
121
|
+
pr_url="$(gh pr create \
|
|
122
|
+
--base "$base" \
|
|
123
|
+
--head "$target_branch" \
|
|
124
|
+
--title "$title" \
|
|
125
|
+
--body "$body")"
|
|
126
|
+
pr_number="$(gh pr view "$pr_url" --json number --jq '.number')"
|
|
127
|
+
fi
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
4. Mark draft PRs ready and check mergeability before changing history:
|
|
102
131
|
|
|
103
132
|
```sh
|
|
133
|
+
is_draft="$(gh pr view "$pr_number" --json isDraft --jq '.isDraft')"
|
|
134
|
+
if [ "$is_draft" = "true" ]; then
|
|
135
|
+
gh pr ready "$pr_number"
|
|
136
|
+
fi
|
|
104
137
|
gh pr view "$pr_number" --json mergeStateStatus,mergeable,headRefName,baseRefName
|
|
105
138
|
if git merge-tree --write-tree HEAD "origin/$base" >/tmp/pull-request-merge-close-merge-tree.out
|
|
106
139
|
then
|
|
@@ -110,7 +143,7 @@ Do not continue automatically when:
|
|
|
110
143
|
fi
|
|
111
144
|
```
|
|
112
145
|
|
|
113
|
-
|
|
146
|
+
5. If a merge conflict is detected, rebase the target branch on the fresh base
|
|
114
147
|
branch. Abort and stop if the rebase conflicts:
|
|
115
148
|
|
|
116
149
|
```sh
|
|
@@ -125,33 +158,14 @@ Do not continue automatically when:
|
|
|
125
158
|
fi
|
|
126
159
|
```
|
|
127
160
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
4. Load and apply all relevant repository skills before merging:
|
|
131
|
-
- Read the repository's `.agents/skills/**/SKILL.md` files that apply to the
|
|
132
|
-
changed code, plus shared workspace standards when present.
|
|
133
|
-
- Compare the target branch against the base with
|
|
134
|
-
`git diff --stat "origin/$base...HEAD"` and inspect changed files.
|
|
135
|
-
- Check whether the target branch satisfies the applicable coding,
|
|
136
|
-
architecture, validation, security, and style criteria from those skills.
|
|
137
|
-
- Run the validation commands required by the skills and repository hooks.
|
|
138
|
-
- If criteria are not met and the fix does not change functionality, make the
|
|
139
|
-
minimal cleanup, stage only intended files, commit to the target branch,
|
|
140
|
-
and push the target branch.
|
|
141
|
-
- If meeting the criteria would change behavior, stop and report the gap.
|
|
142
|
-
|
|
143
|
-
5. Confirm the PR is still mergeable after validation changes:
|
|
144
|
-
|
|
145
|
-
```sh
|
|
146
|
-
git fetch origin "$base" --prune
|
|
147
|
-
git merge-tree --write-tree HEAD "origin/$base" >/tmp/pull-request-merge-close-final-merge-tree.out
|
|
148
|
-
gh pr checks "$pr_number"
|
|
149
|
-
```
|
|
161
|
+
6. Load and apply all relevant repository skills before merging, then confirm
|
|
162
|
+
the PR is still mergeable after any validation changes.
|
|
150
163
|
|
|
151
|
-
|
|
164
|
+
7. Merge the PR with GitHub CLI. Delete the remote target branch only when it is
|
|
152
165
|
not protected:
|
|
153
166
|
|
|
154
167
|
```sh
|
|
168
|
+
protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected' 2>/dev/null || echo false)"
|
|
155
169
|
if [ "$protected" = true ]; then
|
|
156
170
|
gh pr merge "$pr_number" --squash --admin
|
|
157
171
|
else
|
|
@@ -159,17 +173,27 @@ Do not continue automatically when:
|
|
|
159
173
|
fi
|
|
160
174
|
```
|
|
161
175
|
|
|
162
|
-
|
|
176
|
+
8. If the merge succeeded and the remote branch still exists while unprotected,
|
|
177
|
+
delete it explicitly:
|
|
163
178
|
|
|
164
179
|
```sh
|
|
165
|
-
git
|
|
180
|
+
if [ "$protected" != true ] && git ls-remote --exit-code --heads origin "$target_branch" >/dev/null 2>&1; then
|
|
181
|
+
git push origin --delete "$target_branch"
|
|
182
|
+
fi
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
9. Clean up the local repository after merge:
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
git fetch origin --prune
|
|
166
189
|
git switch "$base"
|
|
167
190
|
git pull --ff-only origin "$base"
|
|
168
191
|
git branch -d "$target_branch" || git branch -D "$target_branch"
|
|
169
192
|
git ls-remote --heads origin "$target_branch"
|
|
170
193
|
```
|
|
171
194
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
195
|
+
10. Final response should include the PR URL, selected base branch, whether a
|
|
196
|
+
rebase was performed, what validation and skill checks ran, whether any
|
|
197
|
+
cleanup commit was added, whether the remote target branch was deleted or
|
|
198
|
+
protected, whether the local target branch was deleted, and whether local
|
|
199
|
+
base branch is up to date.
|
|
@@ -104,6 +104,8 @@ depend on those folders being present.
|
|
|
104
104
|
- Extraction of `sub`/clientId and other claims from JWT objects.
|
|
105
105
|
- Expiration checks and TTL calculations.
|
|
106
106
|
- Request attachment behavior for authenticated JWT objects and visitor tokens.
|
|
107
|
+
- Request attachment behavior for compact scoped authorization-context JWTs
|
|
108
|
+
from `X-Authorization-Context` as `req.userAuthorization`.
|
|
107
109
|
- Server-auth request attachment behavior that normalizes introspected claims
|
|
108
110
|
into `req.jwt.payload` with `authMode: "server-auth"` and
|
|
109
111
|
`auth_mode: "server-auth"`.
|
|
@@ -130,6 +132,13 @@ must check expected issuer, audience, subject, and lifetime. Do not add
|
|
|
130
132
|
CareCard-specific replacement claims when a registered JWT claim covers the
|
|
131
133
|
same meaning.
|
|
132
134
|
|
|
135
|
+
Scoped authorization-context JWTs from `X-Authorization-Context` are independent
|
|
136
|
+
from the primary `Authorization` JWT. They must attach to
|
|
137
|
+
`req.userAuthorization`, not `req.jwt`, and they should be read as raw JWT
|
|
138
|
+
header values rather than `Bearer` tokens. Existing JWT and server-auth
|
|
139
|
+
middleware may accept an optional trailing `userAuthorization` options object;
|
|
140
|
+
preserve legacy behavior when that option is omitted.
|
|
141
|
+
|
|
133
142
|
## Role Mapping Layer
|
|
134
143
|
|
|
135
144
|
`lib/jwtRoles.js` owns translation between internal role codes and human-readable
|
|
@@ -171,7 +180,8 @@ role names, such as `ad` and `admin`.
|
|
|
171
180
|
## Types And API Contracts
|
|
172
181
|
|
|
173
182
|
- Model JWT header, payload, server-auth introspection claims, request
|
|
174
|
-
attachment, visitor attachment, role, and
|
|
183
|
+
attachment, visitor attachment, user authorization attachment, role, and
|
|
184
|
+
context shapes explicitly in
|
|
175
185
|
`index.d.ts`.
|
|
176
186
|
- Prefer `AuthenticatedRequest`, `JwtHeader`, `JwtPayload`, `JwtParts`,
|
|
177
187
|
`JwtRequestObject`, `VisitorRequestObject`, and `JwtContext` over loose
|