@carecard/auth-util 3.27.0 → 3.29.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.
- package/.agents/skills/carecard-must-do/SKILL.md +93 -0
- package/.agents/skills/carecard-workspace-standards/SKILL.md +37 -33
- package/.agents/skills/github-pr-create-update/SKILL.md +132 -167
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +206 -205
- package/.agents/skills/pkg-auth-util-auth-crypto-library/SKILL.md +33 -32
- package/.agents/skills/pkg-auth-util-coding-standards-and-best-practices/SKILL.md +10 -3
- package/.agents/skills/pkg-publish/SKILL.md +56 -7
- package/AGENTS.md +13 -1
- package/CLAUDE.md +43 -0
- package/package.json +4 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: carecard-must-do
|
|
3
|
+
description: 'Non-negotiable startup requirements for every agent, including Codex, Claude, other assistants, and delegated agents. Load first whenever beginning or resuming any task to govern questions, visible working copies, and agent-named branches.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CareCard Must Do
|
|
7
|
+
|
|
8
|
+
## Mandatory for every agent
|
|
9
|
+
|
|
10
|
+
Every agent must read and follow this skill before beginning or resuming work
|
|
11
|
+
in this repository. This applies regardless of provider, product, model, role,
|
|
12
|
+
or invocation method, including Codex, Claude, other assistants, and delegated
|
|
13
|
+
agents. Planning, questions, read-only investigation, coding, review,
|
|
14
|
+
documentation, validation, and Git operations are all covered.
|
|
15
|
+
|
|
16
|
+
Load this skill first, then the repository's mandatory engineering standards,
|
|
17
|
+
then the specialist skills relevant to the task. Continue applying these rules
|
|
18
|
+
throughout the task. When entering another repository, read its local copy.
|
|
19
|
+
When delegation is already authorized, give delegated agents this same startup
|
|
20
|
+
requirement. An agent without automatic skill discovery must open this file
|
|
21
|
+
explicitly; its lack of discovery support is not an exemption.
|
|
22
|
+
|
|
23
|
+
## Explain the issue and solutions before asking
|
|
24
|
+
|
|
25
|
+
Before every user-facing question, including a clarification, preference,
|
|
26
|
+
approval request, or question presented through a tool, explain:
|
|
27
|
+
|
|
28
|
+
- the relevant facts and what is uncertain or needs to change;
|
|
29
|
+
- the issue and why the user's answer is needed;
|
|
30
|
+
- the viable solutions or next steps and their practical consequences; and
|
|
31
|
+
- the recommended solution and the reason for that recommendation.
|
|
32
|
+
|
|
33
|
+
Make the explanation detailed enough for a first-year engineering student to
|
|
34
|
+
understand. Define necessary technical terms and distinguish observed facts
|
|
35
|
+
from assumptions. Explain concrete effects rather than relying on unexplained
|
|
36
|
+
jargon. Do not invent alternatives when only one practical next step exists.
|
|
37
|
+
|
|
38
|
+
Present the question after the explanation. Resolve discoverable facts through
|
|
39
|
+
appropriate inspection before asking the user to supply them. This requirement
|
|
40
|
+
does not create a reason to ask unnecessary questions or repeat an approval
|
|
41
|
+
already granted for the action.
|
|
42
|
+
|
|
43
|
+
## Keep the working repository visible
|
|
44
|
+
|
|
45
|
+
Make changes in the normal repository directory the user is working in. Do not
|
|
46
|
+
routinely replace it with a clone, linked worktree, detached checkout, or other
|
|
47
|
+
working copy under `/tmp`, a system temporary directory, a cache, or a hidden or
|
|
48
|
+
undisclosed location. A branch names a line of work; a worktree or clone creates
|
|
49
|
+
another working directory. Do not use either to hide where changes are made.
|
|
50
|
+
|
|
51
|
+
A separate working directory is permitted only for a compelling technical
|
|
52
|
+
reason, such as isolation that is necessary to protect unrelated active work.
|
|
53
|
+
Before creating it, explain why the normal checkout cannot safely serve the
|
|
54
|
+
task, disclose the exact directory and branch, and explain how the finished
|
|
55
|
+
work will remain accessible in the normal repository. Convenience alone is
|
|
56
|
+
not a compelling reason. This disclosure adds no separate approval step;
|
|
57
|
+
existing authorization requirements still apply.
|
|
58
|
+
|
|
59
|
+
Keep ownership and handoff explicit, preserve unrelated work, and clean up only
|
|
60
|
+
resources owned by the task when cleanup is authorized. Ordinary temporary
|
|
61
|
+
logs, build artifacts, and test fixtures are permitted when they are not used
|
|
62
|
+
as an undisclosed replacement working repository.
|
|
63
|
+
|
|
64
|
+
## Work on an agent-named branch
|
|
65
|
+
|
|
66
|
+
Before changing repository files, create and switch to a task-specific branch
|
|
67
|
+
named `<agent-name>/<task-name>` in the owning repository. Use the agent's
|
|
68
|
+
recognizable lowercase name and a descriptive task name, such as
|
|
69
|
+
`codex/carecard-must-do`, `claude/fix-login`, or `junie/update-validation`.
|
|
70
|
+
Reuse an existing agent-named branch only when continuing that same task.
|
|
71
|
+
Read-only investigation and planning do not require creating a branch.
|
|
72
|
+
|
|
73
|
+
Identify the repository directory and working branch before making changes.
|
|
74
|
+
Preserve existing commits and unrelated local changes. Start new work from
|
|
75
|
+
freshly fetched `origin/main`, or rebase continuing work onto it when needed.
|
|
76
|
+
Fetch again before every source-branch push and rebase when the branch does
|
|
77
|
+
not already contain the latest `origin/main`.
|
|
78
|
+
|
|
79
|
+
Follow the repository's remaining Git, validation, and authorization rules.
|
|
80
|
+
Branch creation does not authorize pushing, merging, or deleting branches.
|
|
81
|
+
Never delete local or remote `main`, and never force-push to remote `main`.
|
|
82
|
+
|
|
83
|
+
## Existing repository isolation contract
|
|
84
|
+
|
|
85
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky
|
|
86
|
+
hooks and tests using only files, code, fixtures, dependencies, and services
|
|
87
|
+
contained within that repository. Tests and Husky scripts must not import,
|
|
88
|
+
require, read, execute, or otherwise depend on sibling repositories or paths
|
|
89
|
+
outside the repository root. app-e2e-tests is the only exception because
|
|
90
|
+
cross-repository end-to-end testing is its explicit responsibility.
|
|
91
|
+
|
|
92
|
+
Also apply [$carecard-workspace-standards](../carecard-workspace-standards/SKILL.md)
|
|
93
|
+
for the mandatory TDD and code organization rules.
|
|
@@ -7,6 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
|
|
|
7
7
|
|
|
8
8
|
# CareCard Workspace Standards
|
|
9
9
|
|
|
10
|
+
First read [carecard-must-do](../carecard-must-do/SKILL.md); it is mandatory for every agent and task.
|
|
11
|
+
Then read the [repository engineering standards](../pkg-auth-util-coding-standards-and-best-practices/SKILL.md) before following this workflow.
|
|
12
|
+
|
|
10
13
|
Mandatory companion: load
|
|
11
14
|
`$pkg-auth-util-coding-standards-and-best-practices` before this skill for every
|
|
12
15
|
task in this repository.
|
|
@@ -53,7 +56,7 @@ Use before modifying, testing, reviewing, or debugging any CareCard workspace re
|
|
|
53
56
|
## When To Use
|
|
54
57
|
|
|
55
58
|
- Use before modifying, testing, reviewing, or debugging any CareCard workspace repository or cross-repository contract.
|
|
56
|
-
- Use as the
|
|
59
|
+
- Use as shared context after `carecard-must-do` and the repository engineering standards, before selecting narrower specialist skills.
|
|
57
60
|
|
|
58
61
|
## When Not To Use
|
|
59
62
|
|
|
@@ -172,7 +175,14 @@ config.
|
|
|
172
175
|
|
|
173
176
|
## Remote Git Operations Guardrail
|
|
174
177
|
|
|
175
|
-
|
|
178
|
+
Fetches needed to establish a fresh `origin/main` at task start and before a
|
|
179
|
+
source-branch push are authorized without a separate approval question. Commits,
|
|
180
|
+
pushes, PR mutations, and branch cleanup require an authorized task; a request
|
|
181
|
+
for local work alone does not authorize publication. An authorized squash merge
|
|
182
|
+
into `main` includes the merged-source cleanup, local `main` update, and
|
|
183
|
+
`development` synchronization below unless the user explicitly says otherwise.
|
|
184
|
+
Never delete local or remote `main`, or force-push to remote `main`, including
|
|
185
|
+
with `--force-with-lease`.
|
|
176
186
|
|
|
177
187
|
## Commit Continuation Rule
|
|
178
188
|
|
|
@@ -183,37 +193,31 @@ making a new commit in the affected repository.
|
|
|
183
193
|
|
|
184
194
|
## Agent Guidance Git Workflow
|
|
185
195
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
git ls-remote --heads origin feature/codex
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Do not commit or push `.agents` guidance changes directly from `development`
|
|
215
|
-
or `main`. Do not stage unrelated files, generated output, dependency folders,
|
|
216
|
-
build artifacts, logs, or `.DS_Store`.
|
|
196
|
+
Work from the owning repository root and stage only intended guidance changes.
|
|
197
|
+
Use freshly fetched `origin/main` as the default base. Start `<agent-name>/<task-name>`
|
|
198
|
+
from it, or rebase existing work when it does not already contain the latest
|
|
199
|
+
`origin/main`. An explicit user instruction to use the current or another
|
|
200
|
+
working branch overrides the default `<agent-name>/<task-name>` selection.
|
|
201
|
+
|
|
202
|
+
Fetch again before every source-branch push and rebase only when the branch
|
|
203
|
+
does not already contain the latest `origin/main`. Required fetches need no
|
|
204
|
+
separate approval; commits, pushes, PR mutations, and cleanup require an
|
|
205
|
+
authorized task. A local guidance edit does not authorize publishing it.
|
|
206
|
+
|
|
207
|
+
For an authorized merge, create or reuse the PR into `main`, run applicable
|
|
208
|
+
validation, and squash-merge; administrator privileges may be used without
|
|
209
|
+
GitHub reviews. Verify the merge and delete its source branch remotely and
|
|
210
|
+
locally after checking for newer unmerged work. Then fast-forward local `main`
|
|
211
|
+
and replace local and remote branches named exactly `development` with the
|
|
212
|
+
latest remote `main` commit, using an explicit observed-commit
|
|
213
|
+
`--force-with-lease` remotely. Create a missing development counterpart when
|
|
214
|
+
either existed; leave repositories with neither unchanged. If development was
|
|
215
|
+
the merged source, recreate it from the new main. Verify commit parity and
|
|
216
|
+
cleanup; preserve dirty worktrees and report conflicts or rejected leases.
|
|
217
|
+
|
|
218
|
+
Never delete local or remote `main` or force-push to remote `main`, including
|
|
219
|
+
with `--force-with-lease`. Guard exact destination refs before deleting or
|
|
220
|
+
forcing any branch. Do not amend commits or stage unrelated files.
|
|
217
221
|
|
|
218
222
|
## Shared Packages And API Contracts
|
|
219
223
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: github-pr-create-update
|
|
3
|
-
description: 'Use
|
|
3
|
+
description: 'Use when asked to push, create, update, or ready a GitHub pull request. Default to main, fetch origin/main at the start and before source pushes, rebase when needed, and preserve main from deletion or force pushes.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
@@ -17,172 +17,137 @@ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade,
|
|
|
17
17
|
|
|
18
18
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
19
19
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```sh
|
|
152
|
-
pr_number="$(gh pr list \
|
|
153
|
-
--head "$branch" \
|
|
154
|
-
--base "$base" \
|
|
155
|
-
--state open \
|
|
156
|
-
--json number \
|
|
157
|
-
--jq '.[0].number // empty')"
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
8. If there is no PR, create one against the selected base and capture the new
|
|
161
|
-
PR number:
|
|
162
|
-
|
|
163
|
-
```sh
|
|
164
|
-
pr_url="$(gh pr create \
|
|
165
|
-
--base "$base" \
|
|
166
|
-
--head "$branch" \
|
|
167
|
-
--title "$title" \
|
|
168
|
-
--body "$body")"
|
|
169
|
-
pr_number="$(gh pr view "$pr_url" --json number --jq '.number')"
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
9. If a PR exists, mark it ready when it is a draft, then keep the title
|
|
173
|
-
descriptive:
|
|
174
|
-
|
|
175
|
-
```sh
|
|
176
|
-
is_draft="$(gh pr view "$pr_number" --json isDraft --jq '.isDraft')"
|
|
177
|
-
if [ "$is_draft" = "true" ]; then
|
|
178
|
-
gh pr ready "$pr_number"
|
|
179
|
-
fi
|
|
180
|
-
gh pr edit "$pr_number" --title "$title"
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
10. Final response should include the PR URL, selected base branch, whether a
|
|
184
|
-
rebase was performed, whether an existing PR was reused or marked ready,
|
|
185
|
-
and any validation that could not be run.
|
|
20
|
+
## Default Git Policy
|
|
21
|
+
|
|
22
|
+
Apply these defaults unless the user explicitly specifies otherwise. The
|
|
23
|
+
prohibition on deleting or force-pushing `main` always applies.
|
|
24
|
+
|
|
25
|
+
1. Use `main` as the PR base and freshly fetched `origin/main` as the source of
|
|
26
|
+
truth. `origin/HEAD`, a stale local `main`, and the presence of `development`
|
|
27
|
+
do not change this default. If remote `main` is missing or cannot be fetched,
|
|
28
|
+
report the blocker instead of selecting another base.
|
|
29
|
+
2. At task start, fetch `origin/main`, then create new work from that commit or
|
|
30
|
+
rebase the existing working branch onto it when needed. Honor an explicit
|
|
31
|
+
working-branch instruction; it changes branch selection, not freshness.
|
|
32
|
+
3. Fetch again before every source-branch push. Rebase when the working branch
|
|
33
|
+
does not already contain the latest `origin/main`; a clean mergeability
|
|
34
|
+
check is not proof that rebasing is unnecessary. If it already contains that
|
|
35
|
+
commit, no rebase is needed. The direct `development` replacement below is a
|
|
36
|
+
ref synchronization, not a source-branch rebase.
|
|
37
|
+
4. Squash-merge into remote `main` after the applicable validation passes.
|
|
38
|
+
Administrator privileges may be used to merge without GitHub reviews; they
|
|
39
|
+
do not authorize bypassing required checks. Verify the merge, then delete
|
|
40
|
+
the merged source branch remotely and locally.
|
|
41
|
+
5. Fetch the latest remote `main` after merging and fast-forward local `main`
|
|
42
|
+
to that commit. Preserve divergent local work and report a blocked update
|
|
43
|
+
rather than discarding it.
|
|
44
|
+
6. Replace branches named exactly `development`, locally and remotely, with
|
|
45
|
+
the latest remote `main` commit. Use an explicit, observed-commit
|
|
46
|
+
`--force-with-lease` for a non-fast-forward remote update. Create a missing
|
|
47
|
+
counterpart when local or remote `development` exists; leave repositories
|
|
48
|
+
with neither unchanged. If `development` was the merged source, recreate
|
|
49
|
+
it from the new `main` after deleting it. Other working branches are not
|
|
50
|
+
development synchronization targets.
|
|
51
|
+
7. Never delete local or remote `main`, and never force-push to remote `main`,
|
|
52
|
+
including with `--force-with-lease`, a forced refspec, or a mirror push.
|
|
53
|
+
Check the exact destination ref before every deletion or forced update.
|
|
54
|
+
|
|
55
|
+
Fetches needed to establish a fresh `origin/main` at task start and before a
|
|
56
|
+
source-branch push are authorized without a separate approval question. Commits,
|
|
57
|
+
pushes, PR mutations, and branch cleanup require an authorized task; a request
|
|
58
|
+
for local work alone does not authorize publication. An authorized squash merge
|
|
59
|
+
into `main` includes the merged-source cleanup, local `main` update, and
|
|
60
|
+
`development` synchronization below unless the user explicitly says otherwise.
|
|
61
|
+
Never delete local or remote `main`, or force-push to remote `main`, including
|
|
62
|
+
with `--force-with-lease`.
|
|
63
|
+
|
|
64
|
+
## Prepare The Working Branch
|
|
65
|
+
|
|
66
|
+
Work from the owning repository root. Inspect status, the current branch,
|
|
67
|
+
upstream, and worktrees before changing refs. Preserve unrelated changes and
|
|
68
|
+
existing commits; do not reset a working branch to discard its work. Use the
|
|
69
|
+
user-named branch, or the current source branch for a single-repository task.
|
|
70
|
+
If starting new work while on `main`, create a task branch from fresh
|
|
71
|
+
`origin/main`. Do not use `main` or the selected base as a PR source branch.
|
|
72
|
+
Stop if the source branch cannot be resolved or HEAD is detached.
|
|
73
|
+
|
|
74
|
+
Fetch the authoritative ref explicitly:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
git fetch origin refs/heads/main:refs/remotes/origin/main
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For an existing working branch, check whether it includes the fetched commit:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
if git merge-base --is-ancestor origin/main HEAD; then
|
|
84
|
+
printf '%s\n' 'Working branch already contains the latest origin/main.'
|
|
85
|
+
else
|
|
86
|
+
ancestry_result=$?
|
|
87
|
+
if [ "$ancestry_result" -ne 1 ]; then
|
|
88
|
+
exit "$ancestry_result"
|
|
89
|
+
fi
|
|
90
|
+
git rebase origin/main
|
|
91
|
+
fi
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Repeat the fetch and ancestry check before every source-branch push, including
|
|
95
|
+
pushes after validation fixes. If rebasing changes the validated inputs, rerun
|
|
96
|
+
the affected validation. Preserve successful evidence for unchanged inputs.
|
|
97
|
+
If a rebase conflicts, abort only the rebase started by this task and report
|
|
98
|
+
the conflict; do not push or discard work. Preserve any pre-existing Git
|
|
99
|
+
operation and dirty worktree rather than trying to reset through it.
|
|
100
|
+
|
|
101
|
+
Before rebasing a published source branch, record its remote commit and verify
|
|
102
|
+
that its existing work is accounted for locally. Reconcile unincorporated
|
|
103
|
+
remote work before rewriting it. Use a normal push for a new branch or a
|
|
104
|
+
fast-forward update. When a rebase requires rewriting the remote source, use
|
|
105
|
+
an explicit lease tied to the recorded source commit:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
if [ -z "$source_branch" ] || [ "$source_branch" = main ]; then
|
|
109
|
+
printf '%s\n' 'Refusing to delete or force-update main or an unnamed branch.' >&2
|
|
110
|
+
exit 1
|
|
111
|
+
fi
|
|
112
|
+
git push --set-upstream \
|
|
113
|
+
--force-with-lease="refs/heads/$source_branch:$observed_source_commit" \
|
|
114
|
+
origin "HEAD:refs/heads/$source_branch"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Resolve `source_branch` and `observed_source_commit` from verified repository
|
|
118
|
+
state before using this example. Do not replace a rejected lease with
|
|
119
|
+
`--force` or retry against a new expected commit without inspecting the remote
|
|
120
|
+
change. Keep hooks enabled. Verify that the remote source commit equals the
|
|
121
|
+
local commit after a successful push.
|
|
122
|
+
|
|
123
|
+
## Create Or Update The Pull Request
|
|
124
|
+
|
|
125
|
+
1. Confirm GitHub authentication, the intended source branch, and the clean,
|
|
126
|
+
committed changes included in the PR. Load the owning repository skills and
|
|
127
|
+
run their applicable validation. Stage and commit only authorized changes;
|
|
128
|
+
preserve supplied branch names, titles, commit messages, and PR text.
|
|
129
|
+
2. Prepare and push the source branch using the fresh-main procedure above.
|
|
130
|
+
3. Find the open PR for that source. Reuse the exact source/base match. If
|
|
131
|
+
automation created the task PR against `development`, retarget that PR to
|
|
132
|
+
`main` and recheck its diff and checks instead of creating a duplicate.
|
|
133
|
+
Honor an explicit user-selected base; do not silently retarget that choice.
|
|
134
|
+
4. Create a missing PR against `main` when PR creation is authorized. Use a
|
|
135
|
+
file for a multiline body with `gh pr create --body-file` or
|
|
136
|
+
`gh pr edit --body-file`. Do not create an empty PR for a source already
|
|
137
|
+
represented in the base; report the no-op and perform only authorized
|
|
138
|
+
cleanup supported by merge or content-equivalence evidence.
|
|
139
|
+
5. Mark draft PRs ready in the authorized create/update/ready or merge workflow,
|
|
140
|
+
while preserving an explicit request to keep the PR as a draft. Keep the title factual and preserve exact user-supplied text.
|
|
141
|
+
A create/update-only request ends with the PR; it does not authorize merging.
|
|
142
|
+
|
|
143
|
+
## Reporting
|
|
144
|
+
|
|
145
|
+
Report the repository, working branch, fetched main commit, whether rebasing
|
|
146
|
+
was needed, validation results, push result, PR URL and state, administrator
|
|
147
|
+
merge use, source cleanup, final checkout, and main/development commit parity.
|
|
148
|
+
Distinguish merged, unchanged, not applicable, and blocked repositories. Give
|
|
149
|
+
the exact failing command and reason for an incomplete step. Do not amend
|
|
150
|
+
commits unless explicitly requested; use additive commits for follow-up work.
|
|
186
151
|
|
|
187
152
|
## TDD And Validation
|
|
188
153
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: github-pr-merge-cleanup
|
|
3
|
-
description: 'Use
|
|
3
|
+
description: 'Use for authorized GitHub PR squash merge and source cleanup. Default to fresh origin/main, rebase when needed, delete merged source branches, and synchronize main and development without deleting or force-pushing main.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Non-negotiable root-cause solution rule: Always identify and solve the verified root cause, use the stronger solution, and deliver a correct, durable, production-quality result. Never treat a temporary workaround, resource increase, retry, suppression, bypass, or symptom-only patch as completion. Validate the root-cause fix against the real failing workflow and prove the end state.
|
|
@@ -17,224 +17,225 @@ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade,
|
|
|
17
17
|
|
|
18
18
|
Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
|
|
19
19
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
is_draft="$(gh pr view "$pr_number" --json isDraft --jq '.isDraft')"
|
|
152
|
-
if [ "$is_draft" = "true" ]; then
|
|
153
|
-
gh pr ready "$pr_number"
|
|
154
|
-
fi
|
|
155
|
-
gh pr view "$pr_number" --json mergeStateStatus,mergeable,headRefName,baseRefName
|
|
156
|
-
if git merge-tree --write-tree HEAD "origin/$base" >/tmp/pull-request-merge-close-merge-tree.out
|
|
157
|
-
then
|
|
158
|
-
merge_conflict_detected=false
|
|
159
|
-
else
|
|
160
|
-
merge_conflict_detected=true
|
|
161
|
-
fi
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
5. If a merge conflict is detected, rebase the target branch on the fresh base
|
|
165
|
-
branch. Abort and stop if the rebase conflicts:
|
|
20
|
+
## Default Git Policy
|
|
21
|
+
|
|
22
|
+
Apply these defaults unless the user explicitly specifies otherwise. The
|
|
23
|
+
prohibition on deleting or force-pushing `main` always applies.
|
|
24
|
+
|
|
25
|
+
1. Use `main` as the PR base and freshly fetched `origin/main` as the source of
|
|
26
|
+
truth. `origin/HEAD`, a stale local `main`, and the presence of `development`
|
|
27
|
+
do not change this default. If remote `main` is missing or cannot be fetched,
|
|
28
|
+
report the blocker instead of selecting another base.
|
|
29
|
+
2. At task start, fetch `origin/main`, then create new work from that commit or
|
|
30
|
+
rebase the existing working branch onto it when needed. Honor an explicit
|
|
31
|
+
working-branch instruction; it changes branch selection, not freshness.
|
|
32
|
+
3. Fetch again before every source-branch push. Rebase when the working branch
|
|
33
|
+
does not already contain the latest `origin/main`; a clean mergeability
|
|
34
|
+
check is not proof that rebasing is unnecessary. If it already contains that
|
|
35
|
+
commit, no rebase is needed. The direct `development` replacement below is a
|
|
36
|
+
ref synchronization, not a source-branch rebase.
|
|
37
|
+
4. Squash-merge into remote `main` after the applicable validation passes.
|
|
38
|
+
Administrator privileges may be used to merge without GitHub reviews; they
|
|
39
|
+
do not authorize bypassing required checks. Verify the merge, then delete
|
|
40
|
+
the merged source branch remotely and locally.
|
|
41
|
+
5. Fetch the latest remote `main` after merging and fast-forward local `main`
|
|
42
|
+
to that commit. Preserve divergent local work and report a blocked update
|
|
43
|
+
rather than discarding it.
|
|
44
|
+
6. Replace branches named exactly `development`, locally and remotely, with
|
|
45
|
+
the latest remote `main` commit. Use an explicit, observed-commit
|
|
46
|
+
`--force-with-lease` for a non-fast-forward remote update. Create a missing
|
|
47
|
+
counterpart when local or remote `development` exists; leave repositories
|
|
48
|
+
with neither unchanged. If `development` was the merged source, recreate
|
|
49
|
+
it from the new `main` after deleting it. Other working branches are not
|
|
50
|
+
development synchronization targets.
|
|
51
|
+
7. Never delete local or remote `main`, and never force-push to remote `main`,
|
|
52
|
+
including with `--force-with-lease`, a forced refspec, or a mirror push.
|
|
53
|
+
Check the exact destination ref before every deletion or forced update.
|
|
54
|
+
|
|
55
|
+
Fetches needed to establish a fresh `origin/main` at task start and before a
|
|
56
|
+
source-branch push are authorized without a separate approval question. Commits,
|
|
57
|
+
pushes, PR mutations, and branch cleanup require an authorized task; a request
|
|
58
|
+
for local work alone does not authorize publication. An authorized squash merge
|
|
59
|
+
into `main` includes the merged-source cleanup, local `main` update, and
|
|
60
|
+
`development` synchronization below unless the user explicitly says otherwise.
|
|
61
|
+
Never delete local or remote `main`, or force-push to remote `main`, including
|
|
62
|
+
with `--force-with-lease`.
|
|
63
|
+
|
|
64
|
+
## Prepare The Working Branch
|
|
65
|
+
|
|
66
|
+
Work from the owning repository root. Inspect status, the current branch,
|
|
67
|
+
upstream, and worktrees before changing refs. Preserve unrelated changes and
|
|
68
|
+
existing commits; do not reset a working branch to discard its work. Use the
|
|
69
|
+
user-named branch, or the current source branch for a single-repository task.
|
|
70
|
+
If starting new work while on `main`, create a task branch from fresh
|
|
71
|
+
`origin/main`. Do not use `main` or the selected base as a PR source branch.
|
|
72
|
+
Stop if the source branch cannot be resolved or HEAD is detached.
|
|
73
|
+
|
|
74
|
+
Fetch the authoritative ref explicitly:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
git fetch origin refs/heads/main:refs/remotes/origin/main
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For an existing working branch, check whether it includes the fetched commit:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
if git merge-base --is-ancestor origin/main HEAD; then
|
|
84
|
+
printf '%s\n' 'Working branch already contains the latest origin/main.'
|
|
85
|
+
else
|
|
86
|
+
ancestry_result=$?
|
|
87
|
+
if [ "$ancestry_result" -ne 1 ]; then
|
|
88
|
+
exit "$ancestry_result"
|
|
89
|
+
fi
|
|
90
|
+
git rebase origin/main
|
|
91
|
+
fi
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Repeat the fetch and ancestry check before every source-branch push, including
|
|
95
|
+
pushes after validation fixes. If rebasing changes the validated inputs, rerun
|
|
96
|
+
the affected validation. Preserve successful evidence for unchanged inputs.
|
|
97
|
+
If a rebase conflicts, abort only the rebase started by this task and report
|
|
98
|
+
the conflict; do not push or discard work. Preserve any pre-existing Git
|
|
99
|
+
operation and dirty worktree rather than trying to reset through it.
|
|
100
|
+
|
|
101
|
+
Before rebasing a published source branch, record its remote commit and verify
|
|
102
|
+
that its existing work is accounted for locally. Reconcile unincorporated
|
|
103
|
+
remote work before rewriting it. Use a normal push for a new branch or a
|
|
104
|
+
fast-forward update. When a rebase requires rewriting the remote source, use
|
|
105
|
+
an explicit lease tied to the recorded source commit:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
if [ -z "$source_branch" ] || [ "$source_branch" = main ]; then
|
|
109
|
+
printf '%s\n' 'Refusing to delete or force-update main or an unnamed branch.' >&2
|
|
110
|
+
exit 1
|
|
111
|
+
fi
|
|
112
|
+
git push --set-upstream \
|
|
113
|
+
--force-with-lease="refs/heads/$source_branch:$observed_source_commit" \
|
|
114
|
+
origin "HEAD:refs/heads/$source_branch"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Resolve `source_branch` and `observed_source_commit` from verified repository
|
|
118
|
+
state before using this example. Do not replace a rejected lease with
|
|
119
|
+
`--force` or retry against a new expected commit without inspecting the remote
|
|
120
|
+
change. Keep hooks enabled. Verify that the remote source commit equals the
|
|
121
|
+
local commit after a successful push.
|
|
122
|
+
|
|
123
|
+
## Create Or Update The Pull Request
|
|
124
|
+
|
|
125
|
+
1. Confirm GitHub authentication, the intended source branch, and the clean,
|
|
126
|
+
committed changes included in the PR. Load the owning repository skills and
|
|
127
|
+
run their applicable validation. Stage and commit only authorized changes;
|
|
128
|
+
preserve supplied branch names, titles, commit messages, and PR text.
|
|
129
|
+
2. Prepare and push the source branch using the fresh-main procedure above.
|
|
130
|
+
3. Find the open PR for that source. Reuse the exact source/base match. If
|
|
131
|
+
automation created the task PR against `development`, retarget that PR to
|
|
132
|
+
`main` and recheck its diff and checks instead of creating a duplicate.
|
|
133
|
+
Honor an explicit user-selected base; do not silently retarget that choice.
|
|
134
|
+
4. Create a missing PR against `main` when PR creation is authorized. Use a
|
|
135
|
+
file for a multiline body with `gh pr create --body-file` or
|
|
136
|
+
`gh pr edit --body-file`. Do not create an empty PR for a source already
|
|
137
|
+
represented in the base; report the no-op and perform only authorized
|
|
138
|
+
cleanup supported by merge or content-equivalence evidence.
|
|
139
|
+
5. Mark draft PRs ready in the authorized create/update/ready or merge workflow,
|
|
140
|
+
while preserving an explicit request to keep the PR as a draft. Keep the title factual and preserve exact user-supplied text.
|
|
141
|
+
A create/update-only request ends with the PR; it does not authorize merging.
|
|
142
|
+
|
|
143
|
+
## Squash Merge And Delete The Source Branch
|
|
144
|
+
|
|
145
|
+
1. Verify the PR base, source branch, source commit, draft state, mergeability,
|
|
146
|
+
and required validation. Push any authorized changes through the fresh-main
|
|
147
|
+
procedure first. Confirm checks apply to the commit being merged. Record
|
|
148
|
+
local and remote development presence and commit IDs before source cleanup.
|
|
149
|
+
2. Squash-merge the verified source commit. Administrator privileges are
|
|
150
|
+
permitted to merge without reviews, with applicable checks still passing:
|
|
166
151
|
|
|
167
152
|
```sh
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
git push --force-with-lease -u origin "$target_branch"
|
|
171
|
-
else
|
|
172
|
-
git rebase --abort
|
|
173
|
-
echo "Rebase conflicted; aborted without merging."
|
|
174
|
-
exit 1
|
|
175
|
-
fi
|
|
176
|
-
fi
|
|
153
|
+
gh pr merge "$pr_number" --squash --admin \
|
|
154
|
+
--match-head-commit "$source_commit"
|
|
177
155
|
```
|
|
178
156
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
7. Merge the PR with GitHub CLI. Delete the remote target branch only when it is
|
|
183
|
-
not protected:
|
|
184
|
-
|
|
185
|
-
```sh
|
|
186
|
-
protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected')"
|
|
187
|
-
protection_query_status=$?
|
|
188
|
-
if [ "$protection_query_status" -ne 0 ]; then
|
|
189
|
-
printf 'Unable to inspect branch protection (exit %s).\n' "$protection_query_status" >&2
|
|
190
|
-
exit "$protection_query_status"
|
|
191
|
-
fi
|
|
192
|
-
case "$protected" in
|
|
193
|
-
true|false) ;;
|
|
194
|
-
*)
|
|
195
|
-
printf 'Unexpected branch protection value: %s\n' "$protected" >&2
|
|
196
|
-
exit 1
|
|
197
|
-
;;
|
|
198
|
-
esac
|
|
199
|
-
if [ "$protected" = true ]; then
|
|
200
|
-
gh pr merge "$pr_number" --squash --admin
|
|
201
|
-
else
|
|
202
|
-
gh pr merge "$pr_number" --squash --admin --delete-branch
|
|
203
|
-
fi
|
|
204
|
-
```
|
|
157
|
+
Preserve a supplied squash message with `--subject` and, for remaining
|
|
158
|
+
lines, `--body-file`. Do not change repository rules to make a merge pass.
|
|
205
159
|
|
|
206
|
-
|
|
207
|
-
|
|
160
|
+
3. Verify GitHub reports the PR as merged and record its squash commit. Fetch
|
|
161
|
+
`origin/main` and prove it contains that squash commit. A squash merge does
|
|
162
|
+
not preserve source commit IDs, so ordinary source ancestry alone is not
|
|
163
|
+
merge proof.
|
|
164
|
+
4. Before deleting anything, verify the source is not `main`, the local source
|
|
165
|
+
has no newer unmerged work, and the remote source still equals the merged
|
|
166
|
+
source commit. Delete an existing remote source using a lease so a
|
|
167
|
+
concurrent push is not erased:
|
|
208
168
|
|
|
209
169
|
```sh
|
|
210
|
-
if [ "$
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if [ "$remote_query_status" -ne 0 ]; then
|
|
214
|
-
printf 'Unable to inspect the remote target branch (exit %s).\n' "$remote_query_status" >&2
|
|
215
|
-
exit "$remote_query_status"
|
|
216
|
-
fi
|
|
217
|
-
if [ -n "$remote_target_ref" ]; then
|
|
218
|
-
git push origin --delete "$target_branch"
|
|
219
|
-
fi
|
|
170
|
+
if [ -z "$source_branch" ] || [ "$source_branch" = main ]; then
|
|
171
|
+
printf '%s\n' 'Refusing to delete or force-update main or an unnamed branch.' >&2
|
|
172
|
+
exit 1
|
|
220
173
|
fi
|
|
174
|
+
git push --force-with-lease="refs/heads/$source_branch:$source_commit" \
|
|
175
|
+
origin ":refs/heads/$source_branch"
|
|
221
176
|
```
|
|
222
177
|
|
|
223
|
-
|
|
178
|
+
An already-absent remote branch needs no deletion. If branch protection or
|
|
179
|
+
a changed source prevents deletion, report cleanup as blocked; do not alter
|
|
180
|
+
repository protection or discard newly added commits.
|
|
181
|
+
|
|
182
|
+
5. Switch safely off the source branch. Delete the verified merged local
|
|
183
|
+
source. `git branch -D -- "$source_branch"` is permitted only after the
|
|
184
|
+
explicit non-`main` guard and squash-merge proof; do not use an unconditional
|
|
185
|
+
`-d || -D` fallback. Preserve dirty or independently checked-out worktrees.
|
|
186
|
+
Confirm source absence locally and remotely. A merged `development` source
|
|
187
|
+
is subsequently recreated under the synchronization rule below.
|
|
188
|
+
|
|
189
|
+
## Synchronize Main And Development
|
|
190
|
+
|
|
191
|
+
Run after an authorized squash merge into `main`, unless the user explicitly
|
|
192
|
+
changes the cleanup instructions. Do not reset development after a merge into
|
|
193
|
+
an explicitly selected different base.
|
|
194
|
+
|
|
195
|
+
1. Fetch `origin/main` again. Fast-forward local `main` with
|
|
196
|
+
`git merge --ff-only origin/main` while on `main`, or create local `main`
|
|
197
|
+
from `origin/main` if missing. If local `main` diverges, preserve its commits
|
|
198
|
+
and report the blocked synchronization. Never force-push or delete `main`.
|
|
199
|
+
2. Use the old local and remote `development` commit IDs and presence recorded
|
|
200
|
+
before source cleanup. If neither existed, report development sync
|
|
201
|
+
as not applicable. Otherwise ensure both refs point to the freshly fetched
|
|
202
|
+
`origin/main` commit, creating a missing counterpart. This intentionally
|
|
203
|
+
replaces divergent development history; preserve dirty worktrees and do
|
|
204
|
+
not apply it to any other working branch.
|
|
205
|
+
3. Record `main_commit` from `origin/main` and `observed_development_commit`
|
|
206
|
+
from a successful remote query; use an empty expected value only when that
|
|
207
|
+
query proves the remote branch absent. Update the remote with an explicit
|
|
208
|
+
destination and lease:
|
|
224
209
|
|
|
225
210
|
```sh
|
|
226
|
-
git
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
git branch -d "$target_branch" || git branch -D "$target_branch"
|
|
230
|
-
git ls-remote --heads origin "$target_branch"
|
|
211
|
+
git push \
|
|
212
|
+
--force-with-lease="refs/heads/development:$observed_development_commit" \
|
|
213
|
+
origin "$main_commit:refs/heads/development"
|
|
231
214
|
```
|
|
232
215
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
216
|
+
Skip a push when the remote ref already equals `main_commit`. A rejected
|
|
217
|
+
lease requires inspecting concurrent changes before attempting another
|
|
218
|
+
update. Do not use a broad force push or mirror push.
|
|
219
|
+
|
|
220
|
+
4. From the clean `main` checkout, create or repoint local `development` at
|
|
221
|
+
`main_commit` and set it to track `origin/development`. Do not overwrite a
|
|
222
|
+
branch checked out with uncommitted work in another worktree. Keep the
|
|
223
|
+
checkout on `main` unless the user specified a different final branch.
|
|
224
|
+
5. Fetch and query the final remote refs. Verify commit equality for local
|
|
225
|
+
`main`, remote `main`, and both `development` refs where applicable, together
|
|
226
|
+
with merged-source absence, except when the source was `development` and
|
|
227
|
+
has been recreated at the new main commit. Tree equality alone is
|
|
228
|
+
insufficient for these synchronized refs. If remote `main` advanced, synchronize to its new commit
|
|
229
|
+
and recheck; report an unstable or blocked state instead of claiming parity.
|
|
230
|
+
|
|
231
|
+
## Reporting
|
|
232
|
+
|
|
233
|
+
Report the repository, working branch, fetched main commit, whether rebasing
|
|
234
|
+
was needed, validation results, push result, PR URL and state, administrator
|
|
235
|
+
merge use, source cleanup, final checkout, and main/development commit parity.
|
|
236
|
+
Distinguish merged, unchanged, not applicable, and blocked repositories. Give
|
|
237
|
+
the exact failing command and reason for an incomplete step. Do not amend
|
|
238
|
+
commits unless explicitly requested; use additive commits for follow-up work.
|
|
238
239
|
|
|
239
240
|
## TDD And Validation
|
|
240
241
|
|
|
@@ -242,41 +242,42 @@ and remaining risk.
|
|
|
242
242
|
|
|
243
243
|
## Remote Git Operations Guardrail
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
Fetches needed to establish a fresh `origin/main` at task start and before a
|
|
246
|
+
source-branch push are authorized without a separate approval question. Commits,
|
|
247
|
+
pushes, PR mutations, and branch cleanup require an authorized task; a request
|
|
248
|
+
for local work alone does not authorize publication. An authorized squash merge
|
|
249
|
+
into `main` includes the merged-source cleanup, local `main` update, and
|
|
250
|
+
`development` synchronization below unless the user explicitly says otherwise.
|
|
251
|
+
Never delete local or remote `main`, or force-push to remote `main`, including
|
|
252
|
+
with `--force-with-lease`.
|
|
246
253
|
|
|
247
254
|
## Agent Guidance Git Workflow
|
|
248
255
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
git ls-remote --heads origin feature/codex
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Do not commit or push `.agents` guidance changes directly from `development`
|
|
278
|
-
or `main`. Do not stage unrelated files, generated output, dependency folders,
|
|
279
|
-
build artifacts, logs, or `.DS_Store`.
|
|
256
|
+
Work from the owning repository root and stage only intended guidance changes.
|
|
257
|
+
Use freshly fetched `origin/main` as the default base. Start `<agent-name>/<task-name>`
|
|
258
|
+
from it, or rebase existing work when it does not already contain the latest
|
|
259
|
+
`origin/main`. An explicit user instruction to use the current or another
|
|
260
|
+
working branch overrides the default `<agent-name>/<task-name>` selection.
|
|
261
|
+
|
|
262
|
+
Fetch again before every source-branch push and rebase only when the branch
|
|
263
|
+
does not already contain the latest `origin/main`. Required fetches need no
|
|
264
|
+
separate approval; commits, pushes, PR mutations, and cleanup require an
|
|
265
|
+
authorized task. A local guidance edit does not authorize publishing it.
|
|
266
|
+
|
|
267
|
+
For an authorized merge, create or reuse the PR into `main`, run applicable
|
|
268
|
+
validation, and squash-merge; administrator privileges may be used without
|
|
269
|
+
GitHub reviews. Verify the merge and delete its source branch remotely and
|
|
270
|
+
locally after checking for newer unmerged work. Then fast-forward local `main`
|
|
271
|
+
and replace local and remote branches named exactly `development` with the
|
|
272
|
+
latest remote `main` commit, using an explicit observed-commit
|
|
273
|
+
`--force-with-lease` remotely. Create a missing development counterpart when
|
|
274
|
+
either existed; leave repositories with neither unchanged. If development was
|
|
275
|
+
the merged source, recreate it from the new main. Verify commit parity and
|
|
276
|
+
cleanup; preserve dirty worktrees and report conflicts or rejected leases.
|
|
277
|
+
|
|
278
|
+
Never delete local or remote `main` or force-push to remote `main`, including
|
|
279
|
+
with `--force-with-lease`. Guard exact destination refs before deleting or
|
|
280
|
+
forcing any branch. Do not amend commits or stage unrelated files.
|
|
280
281
|
|
|
281
282
|
## Fail-Closed Test Lifecycle Audit
|
|
282
283
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pkg-auth-util-coding-standards-and-best-practices
|
|
3
|
-
description: 'Mandatory for every pkg-auth-util task, including analysis, clarification, planning, implementation, review, debugging, documentation, public API work, skill maintenance, and validation. Use before every narrower skill.'
|
|
3
|
+
description: 'Use after carecard-must-do. Mandatory for every pkg-auth-util task, including analysis, clarification, planning, implementation, review, debugging, documentation, public API work, skill maintenance, and validation. Use before every narrower skill.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Pkg Auth Util Coding Standards And Best Practices
|
|
7
7
|
|
|
8
|
+
First read [carecard-must-do](../carecard-must-do/SKILL.md); it is mandatory for every agent and task.
|
|
9
|
+
Then apply this engineering standard before selecting narrower skills.
|
|
10
|
+
|
|
8
11
|
## JavaScript And TypeScript Style Contract
|
|
9
12
|
|
|
10
13
|
- Require braces around every optional control-flow body through ESLint core
|
|
@@ -40,7 +43,7 @@ cross-repository end-to-end testing is its explicit responsibility.
|
|
|
40
43
|
|
|
41
44
|
## Mandatory Use And Authorities
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
After `carecard-must-do`, load this skill before doing any work in `pkg-auth-util`, including read-only
|
|
44
47
|
and documentation-only work. Then load every narrower skill that owns the
|
|
45
48
|
affected package contract.
|
|
46
49
|
|
|
@@ -175,7 +178,11 @@ them unused and replaced.
|
|
|
175
178
|
none exists, run the strongest repository-native focused validation.
|
|
176
179
|
5. Fix every in-scope failure at its root cause and rerun the exact command.
|
|
177
180
|
6. Report exact commands, results, limitations, and remaining risk.
|
|
178
|
-
7.
|
|
181
|
+
7. Fetch the latest `origin/main` at task start and before every source-branch push;
|
|
182
|
+
these required fetches need no separate approval. Start new work from that
|
|
183
|
+
commit or rebase existing work when it does not already contain it. Commits,
|
|
184
|
+
pushes, PR mutations, and branch cleanup still require an authorized task.
|
|
185
|
+
Never delete local or remote `main` or force-push to remote `main`.
|
|
179
186
|
|
|
180
187
|
## TDD And Validation
|
|
181
188
|
|
|
@@ -54,30 +54,79 @@ Always publish packages in this order, one repository at a time:
|
|
|
54
54
|
5. `@carecard/telemetry`
|
|
55
55
|
|
|
56
56
|
Publish by pushing the package release branch, creating or reusing a pull
|
|
57
|
-
request into `
|
|
57
|
+
request into `main`, marking it ready, waiting for checks, squash-merging
|
|
58
58
|
with administrator privileges, and verifying npm publication with:
|
|
59
59
|
|
|
60
60
|
```sh
|
|
61
61
|
npm view <package-name>@<target-version> version
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
The package GitHub
|
|
65
|
-
|
|
64
|
+
The package GitHub workflows accept pushes to `main` and `development` and
|
|
65
|
+
publish an unpublished version. Use the `main` squash merge as the release
|
|
66
|
+
path and verify npm publication before continuing. Subsequent development
|
|
67
|
+
synchronization must reuse the same version; it is not a second release.
|
|
68
|
+
|
|
69
|
+
## Default Git Policy
|
|
70
|
+
|
|
71
|
+
Apply these defaults unless the user explicitly specifies otherwise. The
|
|
72
|
+
prohibition on deleting or force-pushing `main` always applies.
|
|
73
|
+
|
|
74
|
+
1. Use `main` as the PR base and freshly fetched `origin/main` as the source of
|
|
75
|
+
truth. `origin/HEAD`, a stale local `main`, and the presence of `development`
|
|
76
|
+
do not change this default. If remote `main` is missing or cannot be fetched,
|
|
77
|
+
report the blocker instead of selecting another base.
|
|
78
|
+
2. At task start, fetch `origin/main`, then create new work from that commit or
|
|
79
|
+
rebase the existing working branch onto it when needed. Honor an explicit
|
|
80
|
+
working-branch instruction; it changes branch selection, not freshness.
|
|
81
|
+
3. Fetch again before every source-branch push. Rebase when the working branch
|
|
82
|
+
does not already contain the latest `origin/main`; a clean mergeability
|
|
83
|
+
check is not proof that rebasing is unnecessary. If it already contains that
|
|
84
|
+
commit, no rebase is needed. The direct `development` replacement below is a
|
|
85
|
+
ref synchronization, not a source-branch rebase.
|
|
86
|
+
4. Squash-merge into remote `main` after the applicable validation passes.
|
|
87
|
+
Administrator privileges may be used to merge without GitHub reviews; they
|
|
88
|
+
do not authorize bypassing required checks. Verify the merge, then delete
|
|
89
|
+
the merged source branch remotely and locally.
|
|
90
|
+
5. Fetch the latest remote `main` after merging and fast-forward local `main`
|
|
91
|
+
to that commit. Preserve divergent local work and report a blocked update
|
|
92
|
+
rather than discarding it.
|
|
93
|
+
6. Replace branches named exactly `development`, locally and remotely, with
|
|
94
|
+
the latest remote `main` commit. Use an explicit, observed-commit
|
|
95
|
+
`--force-with-lease` for a non-fast-forward remote update. Create a missing
|
|
96
|
+
counterpart when local or remote `development` exists; leave repositories
|
|
97
|
+
with neither unchanged. If `development` was the merged source, recreate
|
|
98
|
+
it from the new `main` after deleting it. Other working branches are not
|
|
99
|
+
development synchronization targets.
|
|
100
|
+
7. Never delete local or remote `main`, and never force-push to remote `main`,
|
|
101
|
+
including with `--force-with-lease`, a forced refspec, or a mirror push.
|
|
102
|
+
Check the exact destination ref before every deletion or forced update.
|
|
103
|
+
|
|
104
|
+
Fetches needed to establish a fresh `origin/main` at task start and before a
|
|
105
|
+
source-branch push are authorized without a separate approval question. Commits,
|
|
106
|
+
pushes, PR mutations, and branch cleanup require an authorized task; a request
|
|
107
|
+
for local work alone does not authorize publication. An authorized squash merge
|
|
108
|
+
into `main` includes the merged-source cleanup, local `main` update, and
|
|
109
|
+
`development` synchronization below unless the user explicitly says otherwise.
|
|
110
|
+
Never delete local or remote `main`, or force-push to remote `main`, including
|
|
111
|
+
with `--force-with-lease`.
|
|
66
112
|
|
|
67
113
|
## Deferred Package Push
|
|
68
114
|
|
|
69
115
|
Commit coordinated version and dependency updates locally as the release sequence
|
|
70
116
|
progresses. Do not push a `pkg-*` release branch until that package is the next
|
|
71
|
-
package being published by merge into `
|
|
117
|
+
package being published by merge into `main`.
|
|
72
118
|
|
|
73
119
|
Immediately before each package's publishing turn:
|
|
74
120
|
|
|
75
121
|
1. Verify the repository is on the intended release branch and has a clean
|
|
76
122
|
working tree.
|
|
77
123
|
2. Run required validation and every direct `.husky` script for that repository.
|
|
78
|
-
3.
|
|
79
|
-
|
|
80
|
-
|
|
124
|
+
3. Fetch `origin/main` again, rebase the release branch when it does not already
|
|
125
|
+
contain that commit, and push with hooks enabled. Use an explicit observed-commit
|
|
126
|
+
lease if a rebase requires rewriting an already-pushed source branch.
|
|
127
|
+
4. Create or reuse the pull request into `main`, merge it, and wait for
|
|
128
|
+
npm publication before continuing to dependency fanout. Complete merged-source
|
|
129
|
+
cleanup and main/development synchronization under the default Git policy.
|
|
81
130
|
|
|
82
131
|
## Dependency Fanout
|
|
83
132
|
|
package/AGENTS.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Mandatory startup for every agent
|
|
4
|
+
|
|
5
|
+
Every agent, including Codex, Claude, other assistants, and delegated agents,
|
|
6
|
+
must read and follow [carecard-must-do](.agents/skills/carecard-must-do/SKILL.md)
|
|
7
|
+
before beginning or resuming any task. This includes planning, questions,
|
|
8
|
+
read-only investigation, coding, review, documentation, and validation.
|
|
9
|
+
|
|
10
|
+
Then load the [repository engineering standards](.agents/skills/pkg-auth-util-coding-standards-and-best-practices/SKILL.md)
|
|
11
|
+
and the specialist skills relevant to the task.
|
|
12
|
+
An agent without automatic skill discovery must open the skill explicitly;
|
|
13
|
+
the requirement applies regardless of the agent platform.
|
|
2
14
|
|
|
3
15
|
## Non-negotiable Codex banked-reset requirement
|
|
4
16
|
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Repository Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Mandatory startup for every agent
|
|
4
|
+
|
|
5
|
+
Every agent, including Codex, Claude, other assistants, and delegated agents,
|
|
6
|
+
must read and follow [carecard-must-do](.agents/skills/carecard-must-do/SKILL.md)
|
|
7
|
+
before beginning or resuming any task. This includes planning, questions,
|
|
8
|
+
read-only investigation, coding, review, documentation, and validation.
|
|
9
|
+
|
|
10
|
+
Then load the [repository engineering standards](.agents/skills/pkg-auth-util-coding-standards-and-best-practices/SKILL.md)
|
|
11
|
+
and the specialist skills relevant to the task.
|
|
12
|
+
An agent without automatic skill discovery must open the skill explicitly;
|
|
13
|
+
the requirement applies regardless of the agent platform.
|
|
14
|
+
|
|
15
|
+
Also read [AGENTS.md](AGENTS.md) for the full repository instructions.
|
|
16
|
+
|
|
17
|
+
## Existing repository isolation contract
|
|
18
|
+
|
|
19
|
+
Non-negotiable repository isolation rule: Every repository must run its Husky
|
|
20
|
+
hooks and tests using only files, code, fixtures, dependencies, and services
|
|
21
|
+
contained within that repository. Tests and Husky scripts must not import,
|
|
22
|
+
require, read, execute, or otherwise depend on sibling repositories or paths
|
|
23
|
+
outside the repository root. app-e2e-tests is the only exception because
|
|
24
|
+
cross-repository end-to-end testing is its explicit responsibility.
|
|
25
|
+
|
|
26
|
+
## Existing test-preservation policy
|
|
27
|
+
|
|
28
|
+
The TDD and validation requirements are non-negotiable and cannot be
|
|
29
|
+
overridden. The separate pre-existing-test protection still requires the
|
|
30
|
+
user's fresh, explicit permission for each exact proposed test modification.
|
|
31
|
+
|
|
32
|
+
A pre-existing test—defined as any test present before work on the current task
|
|
33
|
+
begins—must not be deleted, disabled, skipped, weakened, excluded from execution,
|
|
34
|
+
or otherwise removed. A pre-existing test must not be modified without the
|
|
35
|
+
user's explicit approval for the exact proposed change. If changing a
|
|
36
|
+
pre-existing test is believed necessary, stop before making the change and
|
|
37
|
+
request approval. The request must identify every affected test, describe the
|
|
38
|
+
precise proposed modification, provide detailed technical justification, and
|
|
39
|
+
explain all known or reasonably foreseeable regression risks. Until approval is
|
|
40
|
+
granted, leave every pre-existing test unchanged.
|
|
41
|
+
|
|
42
|
+
Also apply [$carecard-workspace-standards](.agents/skills/carecard-workspace-standards/SKILL.md)
|
|
43
|
+
for the mandatory TDD and code organization rules.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/auth-util",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.29.0",
|
|
4
4
|
"repository": "https://github.com/CareCard-ca/pkg-auth-util.git",
|
|
5
5
|
"description": "Auth utility functions",
|
|
6
6
|
"main": "index.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"typescript": "6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@carecard/common-util": "3.
|
|
54
|
-
"@carecard/validate": "3.
|
|
53
|
+
"@carecard/common-util": "3.29.0",
|
|
54
|
+
"@carecard/validate": "3.29.0",
|
|
55
55
|
"@types/express": "5.0.6"
|
|
56
56
|
},
|
|
57
57
|
"overrides": {
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"brace-expansion": "5.0.9",
|
|
61
61
|
"minimatch": "10.2.6",
|
|
62
62
|
"serialize-javascript": "7.0.5",
|
|
63
|
-
"js-yaml": "4.3.
|
|
63
|
+
"js-yaml": "4.3.2"
|
|
64
64
|
}
|
|
65
65
|
}
|