@carecard/validate 3.1.23 → 3.1.25
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/config.toml +2 -0
- package/.agents/skills/carecard-workspace-standards/SKILL.md +401 -0
- package/.agents/skills/carecard-workspace-standards/agents/openai.yaml +4 -0
- package/.agents/skills/github-pr-create-update/SKILL.md +188 -0
- package/.agents/skills/github-pr-create-update/agents/openai.yaml +5 -0
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +175 -0
- package/.agents/skills/github-pr-merge-cleanup/agents/openai.yaml +5 -0
- package/.agents/skills/logged-in-user-profile-page/SKILL.md +33 -0
- package/.agents/skills/logged-in-user-profile-page/agents/openai.yaml +4 -0
- package/.agents/skills/pkg-validate-validation-library/SKILL.md +200 -0
- package/.agents/skills/pkg-validate-validation-library/agents/openai.yaml +4 -0
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +73 -0
- package/.codex/AGENTS.md +1 -0
- package/.codex/config.toml +2 -0
- package/.github/workflows/ci.yml +2 -2
- package/index.d.ts +21 -0
- package/index.js +2 -0
- package/lib/validate.js +6 -0
- package/lib/validateNewUserRoleRequest.js +79 -0
- package/lib/validateProperties.js +14 -0
- package/package.json +19 -7
- package/readme.md +14 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-pr-merge-cleanup
|
|
3
|
+
description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: reviewing remote mergeability, validating, merging, closing, deleting, or cleaning up a pull request branch.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pull Request Merge Close
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
After the user explicitly asks for remote Git or GitHub PR work, review, validate, merge, close, delete branch, and clean local state for a GitHub pull request targeting origin/development.
|
|
11
|
+
|
|
12
|
+
## When To Use
|
|
13
|
+
|
|
14
|
+
- Use only when the user explicitly asks to review mergeability, validate, merge, close, or clean up a GitHub pull request branch.
|
|
15
|
+
|
|
16
|
+
## When Not To Use
|
|
17
|
+
|
|
18
|
+
- Do not use for creating a new pull request; use the PR create/update skill.
|
|
19
|
+
- Do not use when the user only asks for local code changes without PR merge work.
|
|
20
|
+
|
|
21
|
+
## Remote Git Operations Guardrail
|
|
22
|
+
|
|
23
|
+
Do not run remote Git or GitHub operations unless the current user request explicitly asks for them. This includes `git fetch`, `git pull`, `git push`, `git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr` command that creates, updates, readies, merges, closes, or cleans up a pull request. Do not infer permission from branch names, validation needs, prior workflow habits, or convenience; ask first when remote state would help but was not requested.
|
|
24
|
+
|
|
25
|
+
## Relevant Files And Directories
|
|
26
|
+
|
|
27
|
+
- Git branch state in this repository
|
|
28
|
+
- GitHub pull requests viewed with `gh`
|
|
29
|
+
- repository validation commands and `.husky` scripts
|
|
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.
|
|
54
|
+
|
|
55
|
+
## Scope
|
|
56
|
+
|
|
57
|
+
Use this skill from the root of the repository that owns the pull request. The
|
|
58
|
+
repository must use GitHub CLI, have a remote base branch, and have the target
|
|
59
|
+
branch available locally or on `origin`.
|
|
60
|
+
|
|
61
|
+
Default terms:
|
|
62
|
+
|
|
63
|
+
- Base branch: `development` when `origin/development` exists, otherwise the
|
|
64
|
+
repository default branch.
|
|
65
|
+
- Target branch: the current branch unless the user names another branch.
|
|
66
|
+
- Pull request: the open PR whose head is the target branch and whose base is
|
|
67
|
+
the base branch.
|
|
68
|
+
|
|
69
|
+
Do not continue automatically when:
|
|
70
|
+
|
|
71
|
+
- `gh auth status` fails.
|
|
72
|
+
- The target branch is detached or is the base branch.
|
|
73
|
+
- The working tree has uncommitted changes that are not part of the requested
|
|
74
|
+
PR cleanup.
|
|
75
|
+
- No open PR exists for the target branch.
|
|
76
|
+
- A rebase or validation fix would require behavior changes instead of coding
|
|
77
|
+
criteria cleanup.
|
|
78
|
+
|
|
79
|
+
## Workflow
|
|
80
|
+
|
|
81
|
+
1. Capture the base branch, target branch, PR number, and protection state:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
gh auth status
|
|
85
|
+
base="development"
|
|
86
|
+
git ls-remote --exit-code --heads origin development >/dev/null 2>&1 || \
|
|
87
|
+
base="$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')"
|
|
88
|
+
target_branch="$(git branch --show-current)"
|
|
89
|
+
test -n "$target_branch"
|
|
90
|
+
test "$target_branch" != "$base"
|
|
91
|
+
git status --short
|
|
92
|
+
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
|
+
```
|
|
97
|
+
|
|
98
|
+
If the PR head branch is not local, create a local branch from the remote
|
|
99
|
+
head before continuing.
|
|
100
|
+
|
|
101
|
+
2. Check mergeability before changing history:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
gh pr view "$pr_number" --json mergeStateStatus,mergeable,headRefName,baseRefName
|
|
105
|
+
if git merge-tree --write-tree HEAD "origin/$base" >/tmp/pull-request-merge-close-merge-tree.out
|
|
106
|
+
then
|
|
107
|
+
merge_conflict_detected=false
|
|
108
|
+
else
|
|
109
|
+
merge_conflict_detected=true
|
|
110
|
+
fi
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
3. If a merge conflict is detected, rebase the target branch on the fresh base
|
|
114
|
+
branch. Abort and stop if the rebase conflicts:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
if [ "$merge_conflict_detected" = true ]; then
|
|
118
|
+
if git rebase "origin/$base"; then
|
|
119
|
+
git push --force-with-lease -u origin "$target_branch"
|
|
120
|
+
else
|
|
121
|
+
git rebase --abort
|
|
122
|
+
echo "Rebase conflicted; aborted without merging."
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
fi
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Do not resolve rebase conflicts unless the user explicitly asks.
|
|
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
|
+
```
|
|
150
|
+
|
|
151
|
+
6. Merge the PR with GitHub CLI. Delete the remote target branch only when it is
|
|
152
|
+
not protected:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
if [ "$protected" = true ]; then
|
|
156
|
+
gh pr merge "$pr_number" --squash --admin
|
|
157
|
+
else
|
|
158
|
+
gh pr merge "$pr_number" --squash --admin --delete-branch
|
|
159
|
+
fi
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
7. Clean up the local repository after merge:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
git fetch origin "$base" --prune
|
|
166
|
+
git switch "$base"
|
|
167
|
+
git pull --ff-only origin "$base"
|
|
168
|
+
git branch -d "$target_branch" || git branch -D "$target_branch"
|
|
169
|
+
git ls-remote --heads origin "$target_branch"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
8. Final response should include the PR URL, whether a rebase was performed,
|
|
173
|
+
what validation and skill checks ran, whether any cleanup commit was added,
|
|
174
|
+
whether the remote target branch was deleted or protected, and whether local
|
|
175
|
+
development is up to date.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: 'GitHub PR Merge And Cleanup'
|
|
3
|
+
short_description: 'Review, validate, merge, close, delete branch, and clean local state for a GitHub pull request targeting origin/development'
|
|
4
|
+
brand_color: '#0F766E'
|
|
5
|
+
default_prompt: 'Use $github-pr-merge-cleanup when this task matches the skill scope.'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: logged-in-user-profile-page
|
|
3
|
+
description: 'Use when changing shared validation behavior for app-dashboard logged-in profile/settings fields, especially phone number and country-code request aliases.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Logged-In User Profile Page
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Use this skill inside `pkg-validate` when dashboard profile/settings behavior
|
|
11
|
+
depends on shared validation rules.
|
|
12
|
+
|
|
13
|
+
Relevant profile/settings fields:
|
|
14
|
+
|
|
15
|
+
- Phone number: `phone_number`, `phoneNumber`
|
|
16
|
+
- Country code: `country_code`, `countryCode`
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- Keep `validateProperties` aliases in sync with `validateWhitelistProperties`
|
|
21
|
+
consumers in services such as `ms-auth`.
|
|
22
|
+
- Preserve both snake_case and camelCase aliases unless a task explicitly
|
|
23
|
+
removes one.
|
|
24
|
+
- Add focused tests for every accepted and rejected profile/settings key alias.
|
|
25
|
+
- Update `readme.md` whenever a key alias is added or removed.
|
|
26
|
+
- Do not add dashboard-specific service behavior to this package; keep it to
|
|
27
|
+
deterministic validation helpers and key-based validation contracts.
|
|
28
|
+
|
|
29
|
+
## Validation
|
|
30
|
+
|
|
31
|
+
- Run focused Mocha tests for the changed validator keys.
|
|
32
|
+
- Run `npm run test:types` when public exports or declarations are affected.
|
|
33
|
+
- Run `npm run test:All` for validator contract changes before finalizing.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pkg-validate-validation-library
|
|
3
|
+
description: 'Use when changing pkg-validate validators, sanitizers, whitelist behavior, nested path rules, bad-input errors, package exports, or tests.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Package Validate
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
CareCard validation package for deterministic validators, sanitization, whitelist validation, nested paths, error mapping, exports, and tests.
|
|
11
|
+
|
|
12
|
+
## When To Use
|
|
13
|
+
|
|
14
|
+
- Use when changing pkg-validate validators, sanitizers, whitelist behavior, nested path rules, bad-input errors, package exports, or tests.
|
|
15
|
+
- Pair with `carecard-workspace-standards` when the task affects shared CareCard conventions or cross-repository contracts.
|
|
16
|
+
|
|
17
|
+
## When Not To Use
|
|
18
|
+
|
|
19
|
+
- Do not use for service-local behavior that should remain inside one API or app.
|
|
20
|
+
- Do not change package public APIs without updating consumers and compatibility tests.
|
|
21
|
+
|
|
22
|
+
## Relevant Files And Directories
|
|
23
|
+
|
|
24
|
+
- package entry files
|
|
25
|
+
- `src` when present
|
|
26
|
+
- `test`
|
|
27
|
+
- `package.json`
|
|
28
|
+
- `package-lock.json`
|
|
29
|
+
- `.husky`
|
|
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
|
+
- Keep public exports stable and update CommonJS, ESM, TypeScript declaration, and compatibility surfaces together when present.
|
|
37
|
+
|
|
38
|
+
## Testing Expectations
|
|
39
|
+
|
|
40
|
+
- Write or update package tests before behavior or public API changes.
|
|
41
|
+
- Include type/export compatibility tests where the package already has them.
|
|
42
|
+
- Run package test, lint, type, and Husky validation commands required by the changed area.
|
|
43
|
+
|
|
44
|
+
## Safety Constraints
|
|
45
|
+
|
|
46
|
+
- Do not edit generated output, dependency folders, logs, coverage, dist, or build artifacts unless the task requires it.
|
|
47
|
+
- Do not revert or overwrite user changes; stage only requested skill or instruction files.
|
|
48
|
+
- Never suppress errors, lint failures, type failures, security failures, or failing tests; fix the underlying issue or report the blocker.
|
|
49
|
+
- Do not log or expose secrets, JWTs, passwords, credentials, private keys, sensitive personal data, SQL internals, or stack traces.
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
|
|
53
|
+
Use this skill when working inside `pkg-validate`, the `@carecard/validate`
|
|
54
|
+
package. It provides deterministic validators, key-based property sanitization,
|
|
55
|
+
and CareCard whitelist validation behavior used across services.
|
|
56
|
+
|
|
57
|
+
Use `$carecard-workspace-standards` for shared workspace, dependency, package,
|
|
58
|
+
testing, and security rules. Legacy `pkg-validate/.codex` and
|
|
59
|
+
`pkg-validate/.junie` guidance has been migrated into these skills; do not
|
|
60
|
+
depend on those folders being present.
|
|
61
|
+
|
|
62
|
+
## Non-Negotiable Rules
|
|
63
|
+
|
|
64
|
+
- Never use TypeScript type `any`. Use specific value, record, validator,
|
|
65
|
+
option, result, generic, or `unknown` types with narrowing.
|
|
66
|
+
- Follow this repository's coding style, naming conventions, and CommonJS
|
|
67
|
+
project structure.
|
|
68
|
+
- Use Test-Driven Development: add or update relevant Mocha or type tests before
|
|
69
|
+
changing behavior.
|
|
70
|
+
- Never suppress errors, linter warnings, TypeScript errors, or failing tests.
|
|
71
|
+
Handle the underlying issue.
|
|
72
|
+
- Do not add dependencies unless absolutely needed. Ask for confirmation first
|
|
73
|
+
with the reason and tradeoff.
|
|
74
|
+
- Before finalizing work, run every direct script in `.husky` and fix anything
|
|
75
|
+
they report.
|
|
76
|
+
|
|
77
|
+
## Package Shape
|
|
78
|
+
|
|
79
|
+
- Keep `index.js` as the centralized public export surface.
|
|
80
|
+
- Keep TypeScript declarations in `index.d.ts` aligned with every public export
|
|
81
|
+
in `index.js`.
|
|
82
|
+
- Keep direct validators in `lib/validate.js`.
|
|
83
|
+
- Keep key-based property sanitization in `lib/validateProperties.js`.
|
|
84
|
+
- Keep whitelist, nested-path, casing, flattening, and CareCard bad-input
|
|
85
|
+
behavior in `lib/validateWhitelistProperties.js`.
|
|
86
|
+
- Preserve the package's CommonJS module style unless the repository is
|
|
87
|
+
intentionally migrated.
|
|
88
|
+
- Keep the deprecated `validate` namespace export backward-compatible while
|
|
89
|
+
preferring direct top-level exports in new code.
|
|
90
|
+
|
|
91
|
+
## Validation Behavior
|
|
92
|
+
|
|
93
|
+
- Low-level validators should be deterministic predicate functions that return
|
|
94
|
+
`true` or `false`.
|
|
95
|
+
- Password failure-message helpers should return `null` for valid input and a
|
|
96
|
+
user-readable string for invalid input.
|
|
97
|
+
- `validateProperties` should return a new sanitized object and omit unknown or
|
|
98
|
+
invalid fields without mutating the input.
|
|
99
|
+
- `validateWhitelistProperties` should reject missing or invalid required fields
|
|
100
|
+
with CareCard `BAD_INPUT` errors through `@carecard/common-util`.
|
|
101
|
+
- Optional whitelist fields should be ignored when absent and rejected when
|
|
102
|
+
present but invalid.
|
|
103
|
+
- Preserve supported snake_case and camelCase field aliases unless a task
|
|
104
|
+
explicitly changes the API contract.
|
|
105
|
+
- Preserve nested dot-path handling, maximum nesting depth, maximum path count,
|
|
106
|
+
optional snake_case conversion, and flattening behavior.
|
|
107
|
+
- Avoid broad regular expressions or validation changes without focused tests
|
|
108
|
+
for accepted values, rejected values, length limits, and edge cases.
|
|
109
|
+
|
|
110
|
+
## Types And API Contracts
|
|
111
|
+
|
|
112
|
+
- Model input and output records, whitelist options, flattened output behavior,
|
|
113
|
+
validators, and failure-message helpers explicitly in `index.d.ts`.
|
|
114
|
+
- When existing declarations are too loose, improve them with specific types as
|
|
115
|
+
part of the touched change instead of adding new loose types.
|
|
116
|
+
- Update `test/types.test.ts` whenever public types, exports, options, return
|
|
117
|
+
values, or validators change.
|
|
118
|
+
- Keep runtime exports, README examples, and type declarations in sync.
|
|
119
|
+
- Preserve validation behavior for invalid, missing, extra, and valid fields.
|
|
120
|
+
|
|
121
|
+
## Tests And Coverage
|
|
122
|
+
|
|
123
|
+
- Use Mocha for runtime tests under `test`.
|
|
124
|
+
- Use `test/types.test.ts` for TypeScript declaration coverage through
|
|
125
|
+
`npm run test:types`.
|
|
126
|
+
- Add focused tests for valid input, invalid input, missing fields, optional
|
|
127
|
+
fields, array handling, nested paths, casing conversion, flattening, and error
|
|
128
|
+
messages when those areas change.
|
|
129
|
+
- Keep tests deterministic and avoid real external services.
|
|
130
|
+
- This package enforces 100% coverage for branches, functions, lines, and
|
|
131
|
+
statements through `nyc`; do not reduce thresholds.
|
|
132
|
+
|
|
133
|
+
## Legacy Junie Source Notes
|
|
134
|
+
|
|
135
|
+
The migrated `.junie` memory files contained no active task, feedback, or error
|
|
136
|
+
entries. `language.json` was an empty array, `memory.version` was `3.0`, and no
|
|
137
|
+
plan files were present.
|
|
138
|
+
|
|
139
|
+
## Validation
|
|
140
|
+
|
|
141
|
+
Useful commands:
|
|
142
|
+
|
|
143
|
+
- `npm run lint`
|
|
144
|
+
- `npm run lint:fix`
|
|
145
|
+
- `npm run format`
|
|
146
|
+
- `npm run format:check`
|
|
147
|
+
- `npm run test`
|
|
148
|
+
- `npm run test:types`
|
|
149
|
+
- `npm run test:coverage`
|
|
150
|
+
- `npm run test:All`
|
|
151
|
+
|
|
152
|
+
Before pushing or finalizing, run every direct `.husky` script. The current
|
|
153
|
+
`.husky/pre-commit` runs:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm run lint:fix
|
|
157
|
+
npm run format
|
|
158
|
+
npm run test:All
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If any validation command cannot run, report the exact command, failure reason,
|
|
162
|
+
and remaining risk.
|
|
163
|
+
|
|
164
|
+
## Remote Git Operations Guardrail
|
|
165
|
+
|
|
166
|
+
Do not run remote Git or GitHub operations unless the current user request explicitly asks for them. This includes `git fetch`, `git pull`, `git push`, `git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr` command that creates, updates, readies, merges, closes, or cleans up a pull request. Do not infer permission from branch names, validation needs, prior workflow habits, or convenience; ask first when remote state would help but was not requested.
|
|
167
|
+
|
|
168
|
+
## Agent Guidance Git Workflow
|
|
169
|
+
|
|
170
|
+
When this skill or any repository-owned `.agents` guidance changes, use the
|
|
171
|
+
repository's agents-only Git workflow:
|
|
172
|
+
|
|
173
|
+
1. Work from the affected repository root and confirm only intended `.agents`
|
|
174
|
+
files changed.
|
|
175
|
+
2. Use `development` as the base branch when `origin/development` exists;
|
|
176
|
+
otherwise use the repository's default base branch, usually `main`.
|
|
177
|
+
3. Create or update `feature/codex` from the updated remote base branch and
|
|
178
|
+
commit all the changed `.agents` guidance files there.
|
|
179
|
+
4. Push `feature/codex`, create or reuse a pull request into the base branch,
|
|
180
|
+
and mark the pull request ready for review with `gh pr ready <number>`.
|
|
181
|
+
5. Squash-merge with administrator privileges and delete the remote branch:
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
gh pr merge <number> --squash --admin --delete-branch
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
6. After merge, update the local base branch and remove the local feature
|
|
188
|
+
branch:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
git fetch origin <base> --prune
|
|
192
|
+
git switch <base>
|
|
193
|
+
git pull --ff-only origin <base>
|
|
194
|
+
git branch -d feature/codex
|
|
195
|
+
git ls-remote --heads origin feature/codex
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Do not commit or push `.agents` guidance changes directly from `development`
|
|
199
|
+
or `main`. Do not stage unrelated files, generated output, dependency folders,
|
|
200
|
+
build artifacts, logs, or `.DS_Store`.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: 'Package Validate Validation Library'
|
|
3
|
+
short_description: 'CareCard validation package for deterministic validators, sanitization, whitelist validation, nested paths, error mapping, exports, and t...'
|
|
4
|
+
default_prompt: 'Use $pkg-validate-validation-library when this task matches the skill scope.'
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: software-design-patterns-and-clean-code
|
|
3
|
+
description: 'Use every time before coding, refactoring, debugging, or reviewing in this repository, alongside all other applicable skills, to apply pragmatic software design patterns, SOLID, Clean Code, and testable architecture.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Software Design Patterns And Clean Code
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Use this skill with every coding, refactoring, debugging, or review task in
|
|
11
|
+
this repository. It supplements repository-specific skills; follow both, and
|
|
12
|
+
let the more specific skill decide file locations, framework conventions,
|
|
13
|
+
validation commands, and API contracts.
|
|
14
|
+
|
|
15
|
+
## Core Principles
|
|
16
|
+
|
|
17
|
+
- Prefer simple, maintainable, readable implementation over clever abstraction.
|
|
18
|
+
- Use Gang of Four design patterns only when they reduce real complexity,
|
|
19
|
+
improve clarity, or make behavior easier to test.
|
|
20
|
+
- Follow SOLID principles, especially Single Responsibility and Dependency
|
|
21
|
+
Inversion where they improve maintainability.
|
|
22
|
+
- Keep clear separation of concerns between routing, orchestration, domain
|
|
23
|
+
logic, persistence, validation, formatting, and side effects.
|
|
24
|
+
- Apply DRY, KISS, and YAGNI. Remove meaningful duplication, keep solutions
|
|
25
|
+
direct, and avoid speculative generalization.
|
|
26
|
+
- Favor small, composable functions with meaningful names and explicit inputs.
|
|
27
|
+
- Prefer pure functions for calculations, mapping, validation, and transforms
|
|
28
|
+
when practical.
|
|
29
|
+
- Keep side effects minimal, localized, and easy to identify.
|
|
30
|
+
- Use explicit error handling. Do not swallow failures or hide actionable
|
|
31
|
+
error context.
|
|
32
|
+
- Design code so behavior can be tested through focused unit, integration, or
|
|
33
|
+
service tests without fragile setup.
|
|
34
|
+
- Avoid unnecessary dependencies. Use existing language, framework, and local
|
|
35
|
+
helper capabilities before adding packages.
|
|
36
|
+
|
|
37
|
+
## Function Comments
|
|
38
|
+
|
|
39
|
+
For every new or modified function, method, or exported callback, add a short
|
|
40
|
+
comment immediately above it explaining the main pattern or principle being
|
|
41
|
+
applied. Keep the comment accurate and specific to the function.
|
|
42
|
+
|
|
43
|
+
Use the host language's normal comment syntax. Examples:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// Pattern: Single Responsibility - validates user input only.
|
|
47
|
+
function validateUserInput(...) { ... }
|
|
48
|
+
|
|
49
|
+
// Pattern: Pure Function - deterministic output with no side effects.
|
|
50
|
+
function calculateTotal(...) { ... }
|
|
51
|
+
|
|
52
|
+
// Pattern: Dependency Inversion - depends on an injected repository contract.
|
|
53
|
+
async function loadProfile(...) { ... }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Working Rules
|
|
57
|
+
|
|
58
|
+
- Do not violate these coding principles unless there is no reasonable
|
|
59
|
+
alternative.
|
|
60
|
+
- If a principle must be violated, include a short explanation in the code
|
|
61
|
+
review or final summary.
|
|
62
|
+
- Refactor touched existing code to follow these patterns and principles when
|
|
63
|
+
doing so is safe and related to the requested change.
|
|
64
|
+
- Do not use this skill as a reason for broad unrelated rewrites.
|
|
65
|
+
- Before introducing an abstraction or design pattern, confirm it removes real
|
|
66
|
+
complexity compared with a straightforward function or module.
|
|
67
|
+
- Prefer dependency inversion at boundaries such as databases, external
|
|
68
|
+
services, clocks, file systems, queues, and network calls when it improves
|
|
69
|
+
testability or substitution.
|
|
70
|
+
- Keep interfaces and abstractions narrow. Do not create generic layers that
|
|
71
|
+
only have one trivial implementation unless they clarify a boundary.
|
|
72
|
+
- Preserve the repository's existing style, naming, module system, and testing
|
|
73
|
+
approach.
|
package/.codex/AGENTS.md
CHANGED
|
@@ -92,6 +92,7 @@ The `pkg-*` directories are reusable CareCard packages. Shared API response, err
|
|
|
92
92
|
|
|
93
93
|
- Write or update tests before implementation whenever changing behavior.
|
|
94
94
|
- Testing is mandatory before finalizing code changes. Do not stop after implementation if tests, `.junie`, or `.husky` checks remain unrun.
|
|
95
|
+
- Code coverage must never be lower than the previous commit. When coverage tooling exists, compare against the previous commit or recorded baseline before finalizing, add tests to maintain or improve coverage, and never reduce coverage thresholds to make checks pass.
|
|
95
96
|
- Keep tests readable and domain-specific. Prefer explicit helper names over generic test utilities that hide important behavior.
|
|
96
97
|
- Use existing test frameworks and layouts:
|
|
97
98
|
- JavaScript `api-*`: usually Mocha, Supertest, `test/index.test.js`, and Docker-backed Postgres scripts.
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
name: CI
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
4
|
push:
|
|
6
5
|
branches:
|
|
7
6
|
- main
|
|
@@ -21,7 +20,7 @@ on:
|
|
|
21
20
|
paths-ignore:
|
|
22
21
|
- '**.md'
|
|
23
22
|
pull_request:
|
|
24
|
-
types: [
|
|
23
|
+
types: [closed]
|
|
25
24
|
branches:
|
|
26
25
|
- main
|
|
27
26
|
- develop
|
|
@@ -42,6 +41,7 @@ on:
|
|
|
42
41
|
|
|
43
42
|
jobs:
|
|
44
43
|
test:
|
|
44
|
+
if: github.event_name == 'push' || github.event.pull_request.merged == true
|
|
45
45
|
runs-on: ubuntu-latest
|
|
46
46
|
|
|
47
47
|
steps:
|
package/index.d.ts
CHANGED
|
@@ -58,6 +58,24 @@ export function validateWhitelistProperties(
|
|
|
58
58
|
options?: ValidateWhitelistPropertiesOptions,
|
|
59
59
|
): Promise<Record<string, any>>;
|
|
60
60
|
|
|
61
|
+
export const DEFAULT_USER_ROLE_REQUEST_ROLE: 'student';
|
|
62
|
+
export const REQUIRE_SCOPE_WHEN_ROLE_OR_SCOPE_PRESENT: 'whenRoleOrScopePresent';
|
|
63
|
+
|
|
64
|
+
export interface ValidateNewUserRoleRequestOptions {
|
|
65
|
+
defaultRole?: 'student' | undefined;
|
|
66
|
+
requireScope?: boolean | typeof REQUIRE_SCOPE_WHEN_ROLE_OR_SCOPE_PRESENT;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Normalizes and validates a carecard.new_user_role_request payload.
|
|
71
|
+
* Only student, intern, and volunteer are accepted. When scope is required,
|
|
72
|
+
* both institution_id and campus_id must be provided.
|
|
73
|
+
*/
|
|
74
|
+
export function validateNewUserRoleRequestObject(
|
|
75
|
+
roleRequest?: Record<string, any>,
|
|
76
|
+
options?: ValidateNewUserRoleRequestOptions,
|
|
77
|
+
): Record<string, any>;
|
|
78
|
+
|
|
61
79
|
/** Checks if the string is a valid image URL format. */
|
|
62
80
|
export function isImageUrl(imageUrl: any): boolean;
|
|
63
81
|
/** Checks if the value is an integer. */
|
|
@@ -112,6 +130,8 @@ export function isTextString(str: any): boolean;
|
|
|
112
130
|
export function isInStringArray(StringArray: string[], inputString: any): boolean;
|
|
113
131
|
/** Checks if the string is one of the supported user role request statuses. */
|
|
114
132
|
export function isUserRoleRequestStatusString(inputString: any): boolean;
|
|
133
|
+
/** Checks if the string is a supported new user role request role. */
|
|
134
|
+
export function isUserRoleRequestRoleString(inputString: any): boolean;
|
|
115
135
|
/** Checks if the string is a valid country code (e.g., +1). */
|
|
116
136
|
export function isCountryCodeString(str: any): boolean;
|
|
117
137
|
/** Checks if the string is a valid domain name. */
|
|
@@ -158,6 +178,7 @@ export const validate: {
|
|
|
158
178
|
isTextString: typeof isTextString;
|
|
159
179
|
isInStringArray: typeof isInStringArray;
|
|
160
180
|
isUserRoleRequestStatusString: typeof isUserRoleRequestStatusString;
|
|
181
|
+
isUserRoleRequestRoleString: typeof isUserRoleRequestRoleString;
|
|
161
182
|
isCountryCodeString: typeof isCountryCodeString;
|
|
162
183
|
isValidDomainName: typeof isValidDomainName;
|
|
163
184
|
isValidTimestampzString: typeof isValidTimestampzString;
|
package/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const validate = require('./lib/validate');
|
|
2
2
|
const validateProperties = require('./lib/validateProperties');
|
|
3
3
|
const validateWhitelistProperties = require('./lib/validateWhitelistProperties');
|
|
4
|
+
const validateNewUserRoleRequest = require('./lib/validateNewUserRoleRequest');
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
validate,
|
|
7
8
|
validateProperties,
|
|
8
9
|
validateWhitelistProperties,
|
|
10
|
+
...validateNewUserRoleRequest,
|
|
9
11
|
...validate,
|
|
10
12
|
...validateProperties,
|
|
11
13
|
};
|
package/lib/validate.js
CHANGED
|
@@ -173,6 +173,11 @@ const isUserRoleRequestStatusString = inputString => {
|
|
|
173
173
|
return isInStringArray(statuses, inputString);
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
+
const isUserRoleRequestRoleString = inputString => {
|
|
177
|
+
const roles = ['student', 'intern', 'volunteer'];
|
|
178
|
+
return typeof inputString === 'string' && roles.includes(inputString.trim().toLowerCase());
|
|
179
|
+
};
|
|
180
|
+
|
|
176
181
|
const isCountryCodeString = str => {
|
|
177
182
|
if (typeof str !== 'string' || str.length === 0 || str.length > 4) return false;
|
|
178
183
|
|
|
@@ -243,6 +248,7 @@ module.exports = {
|
|
|
243
248
|
isTextString,
|
|
244
249
|
isInStringArray,
|
|
245
250
|
isUserRoleRequestStatusString,
|
|
251
|
+
isUserRoleRequestRoleString,
|
|
246
252
|
isCountryCodeString,
|
|
247
253
|
isValidDomainName,
|
|
248
254
|
isValidTimestampzString,
|