@carecard/auth-util 3.1.16 → 3.2.0
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.
|
@@ -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.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: npm-package-flow
|
|
3
|
+
description: 'Use in pkg-* repositories when publishable package code changes require a version bump, GitHub development/main squash-merge flow, npm publication, and uncommitted consumer package updates in ms-* and app-dashboard.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# npm Package Flow
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Use this skill in a `pkg-*` repository when package code changes need to be
|
|
11
|
+
published to npm and propagated to CareCard consumers.
|
|
12
|
+
|
|
13
|
+
The package name is the `name` field in the repository `package.json`.
|
|
14
|
+
|
|
15
|
+
## Publishable vs Non-Publishable Changes
|
|
16
|
+
|
|
17
|
+
Publishable package changes include runtime source changes, public exports,
|
|
18
|
+
TypeScript declarations, package metadata that affects consumers, security
|
|
19
|
+
behavior, or dependency behavior that changes the package contract.
|
|
20
|
+
|
|
21
|
+
The following are not publishable package changes by themselves:
|
|
22
|
+
|
|
23
|
+
- Skills or `.agents` guidance.
|
|
24
|
+
- Documentation and README updates.
|
|
25
|
+
- Tests, fixtures, mocks, snapshots, or validation-only changes.
|
|
26
|
+
- Formatting-only changes and comments.
|
|
27
|
+
|
|
28
|
+
For non-publishable changes, do not bump the package version, publish to npm,
|
|
29
|
+
or update `ms-*` and `app-dashboard` package versions.
|
|
30
|
+
|
|
31
|
+
## Required Flow For Publishable Changes
|
|
32
|
+
|
|
33
|
+
Run this workflow only when the user explicitly asks for package publication,
|
|
34
|
+
remote GitHub merge work, or the full package-flow completion. Remote Git and
|
|
35
|
+
GitHub operations must not be inferred.
|
|
36
|
+
|
|
37
|
+
1. Finish package code, tests, documentation, and skill updates inside the
|
|
38
|
+
current `pkg-*` repository.
|
|
39
|
+
2. Bump the package version in `package.json` and `package-lock.json` according
|
|
40
|
+
to the user request or the package change scope.
|
|
41
|
+
3. Run the package's required tests, lint, type checks, and every direct Husky
|
|
42
|
+
script. Fix failures before continuing.
|
|
43
|
+
4. Commit the package changes to the current branch.
|
|
44
|
+
5. Push the current branch, create or reuse the PR into `development`,
|
|
45
|
+
squash-merge it with administrator privileges, and delete the merged branch.
|
|
46
|
+
6. Create a new merge branch from the updated `development` branch and use that
|
|
47
|
+
branch to open a PR into `main`.
|
|
48
|
+
7. Squash-merge the merge branch into `main` with administrator privileges and
|
|
49
|
+
delete the merge branch. This `main` merge publishes the package.
|
|
50
|
+
8. Confirm publication with `npm view <package-name>@<version> version`.
|
|
51
|
+
9. Check out a fresh local branch with the same name as the deleted working
|
|
52
|
+
branch from the updated `development` branch.
|
|
53
|
+
10. Update the new `@carecard/...` package version in `app-dashboard` and in
|
|
54
|
+
only the `ms-*` repositories that already declare the package, plus any
|
|
55
|
+
explicitly intended new consumers.
|
|
56
|
+
11. Run `npm install` and relevant validation in each updated consumer.
|
|
57
|
+
12. Do not commit the `ms-*` or `app-dashboard` consumer updates unless the user
|
|
58
|
+
explicitly asks.
|
|
59
|
+
|
|
60
|
+
## Consumer Update Rules
|
|
61
|
+
|
|
62
|
+
- Discover existing consumers by checking each target repository `package.json`
|
|
63
|
+
for the published package name.
|
|
64
|
+
- Install exact package versions, for example
|
|
65
|
+
`npm install <package-name>@<version> --save-exact`.
|
|
66
|
+
- Keep consumer updates local and uncommitted unless the user gives a separate
|
|
67
|
+
commit or PR instruction.
|
|
68
|
+
- If a consumer should become a new dependency, require explicit user intent for
|
|
69
|
+
that repository.
|
|
70
|
+
|
|
71
|
+
## Reporting
|
|
72
|
+
|
|
73
|
+
Report the package name, published version, development PR, main PR, npm
|
|
74
|
+
publication check, consumer repositories updated, validation commands run, and
|
|
75
|
+
any consumer updates intentionally left uncommitted.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: 'npm Package Flow'
|
|
3
|
+
short_description: 'Use in pkg-* repositories when publishable @carecard package code changes need npm publication and consumer updates.'
|
|
4
|
+
brand_color: '#0F766E'
|
|
5
|
+
default_prompt: 'Use $npm-package-flow when this task matches the skill scope.'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/auth-util",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"repository": "https://github.com/CareCard-ca/pkg-auth-util.git",
|
|
5
5
|
"description": "Auth utility functions",
|
|
6
6
|
"main": "index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typescript": "6.0.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@carecard/common-util": "3.
|
|
46
|
-
"@carecard/validate": "3.
|
|
45
|
+
"@carecard/common-util": "3.2.0",
|
|
46
|
+
"@carecard/validate": "3.3.0"
|
|
47
47
|
}
|
|
48
48
|
}
|