Skip to content

Commit 0b4cf81

Browse files
authored
Merge pull request #217 from udecode/codex/sync-convex-auth-0-11-4
2 parents ce640b5 + 10472f7 commit 0b4cf81

48 files changed

Lines changed: 2422 additions & 166 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/rules/sync-convex-auth.mdc

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
---
2+
description: Sync kitcn against upstream `convex-better-auth` changes. Use when asked to run `sync-convex-auth`, compare `zbeyens/convex-better-auth` with its upstream fork, audit commits the fork is behind on, classify relevance to kitcn auth integration, and delegate one implementation PR through `task`.
3+
---
4+
5+
# Sync Convex Auth
6+
7+
Handle $ARGUMENTS.
8+
9+
Goal: compare `https://github.com/zbeyens/convex-better-auth` with its
10+
upstream fork, extract every upstream change that matters to kitcn, then
11+
delegate one coherent implementation slice to
12+
[$task](../skills/task/SKILL.md) so it
13+
opens the PR.
14+
15+
## Rules
16+
17+
- Use evidence, not vibes. Read commits, changed files, and patches.
18+
- Treat the fork being behind upstream as signal, not proof. Pull only relevant
19+
work into kitcn.
20+
- Ignore genuinely irrelevant upstream changes. Do not mirror upstream just to
21+
feel caught up.
22+
- Pull all clearly relevant, non-conflicting fixes in the same slice when they
23+
share the same kitcn auth surface.
24+
- Stop and ask the user before importing optional additions where the tradeoff is
25+
unclear, especially slow e2e suites, broad fixture rewrites, examples,
26+
release plumbing, or dev-only test infrastructure.
27+
- Prefer deleting kitcn glue over adding more glue when upstream fixed the real
28+
problem.
29+
- If no actionable opportunity exists, stop with the evidence. Do not open a
30+
vanity PR.
31+
32+
## 1. Establish Fork, Upstream, And Refs
33+
34+
Use GitHub metadata to discover the upstream parent instead of guessing:
35+
36+
```bash
37+
gh repo view zbeyens/convex-better-auth \
38+
--json nameWithOwner,parent,defaultBranchRef \
39+
--jq '{fork: .nameWithOwner, parent: .parent.nameWithOwner, branch: .defaultBranchRef.name}'
40+
```
41+
42+
If `parent` is missing or ambiguous, stop and ask for the upstream repo.
43+
44+
Before asking, try these fallbacks in order:
45+
46+
```bash
47+
npm view @convex-dev/better-auth repository homepage --json
48+
test -d ../convex-better-auth/.git && git -C ../convex-better-auth remote -v
49+
gh repo view get-convex/better-auth --json nameWithOwner,defaultBranchRef,url
50+
```
51+
52+
If npm metadata or the local clone clearly point to one upstream repo, use that
53+
repo and continue instead of stopping.
54+
55+
Use a local clone for navigation, creating it only if missing:
56+
57+
```bash
58+
test -d ../convex-better-auth/.git || \
59+
gh repo clone zbeyens/convex-better-auth ../convex-better-auth
60+
git -C ../convex-better-auth remote get-url upstream >/dev/null 2>&1 || \
61+
git -C ../convex-better-auth remote add upstream https://github.com/<upstream-owner>/<repo-name>.git
62+
git -C ../convex-better-auth fetch origin --tags
63+
git -C ../convex-better-auth fetch upstream --tags
64+
```
65+
66+
Record:
67+
68+
- fork owner/name and default branch
69+
- upstream owner/name and default branch
70+
- fork ref and upstream ref being compared
71+
- behind count
72+
- ahead count, if any
73+
- exact commit range
74+
75+
Commands:
76+
77+
```bash
78+
git -C ../convex-better-auth rev-list --count origin/<fork-branch>..upstream/<upstream-branch>
79+
git -C ../convex-better-auth rev-list --count upstream/<upstream-branch>..origin/<fork-branch>
80+
git -C ../convex-better-auth log --oneline --decorate origin/<fork-branch>..upstream/<upstream-branch>
81+
```
82+
83+
If $ARGUMENTS names a base or target ref, use it as the bound after proving it
84+
exists.
85+
86+
## 2. Read The Upstream Diff
87+
88+
Start with a file summary:
89+
90+
```bash
91+
git -C ../convex-better-auth diff --name-status \
92+
origin/<fork-branch>..upstream/<upstream-branch>
93+
```
94+
95+
Then read patches for relevant-looking files:
96+
97+
```bash
98+
git -C ../convex-better-auth diff \
99+
origin/<fork-branch>..upstream/<upstream-branch> -- \
100+
src package.json bun.lock tsconfig.json '*.md' \
101+
':!**/dist/**' ':!**/build/**' ':!**/node_modules/**'
102+
```
103+
104+
Use `gh` compare when it gives cleaner commit/file metadata:
105+
106+
```bash
107+
gh api \
108+
repos/<upstream-owner>/<repo-name>/compare/<fork-owner>:<fork-branch>...<upstream-branch> \
109+
--jq '.commits[] | {sha: .sha, message: .commit.message}'
110+
111+
gh api \
112+
repos/<upstream-owner>/<repo-name>/compare/<fork-owner>:<fork-branch>...<upstream-branch> \
113+
--jq '.files[] | {filename,status,patch}'
114+
```
115+
116+
If the compare is too large, group by subsystem first, then inspect the patches
117+
for likely auth-runtime impact.
118+
119+
## 3. Search Kitcn For Affected Auth Surfaces
120+
121+
Search local kitcn integration points:
122+
123+
```bash
124+
rg -n "@convex-dev/better-auth|convexBetterAuth|getToken|convexClient|convex\\(|BetterAuth|better-auth|auth" \
125+
packages www .agents docs tooling fixtures example
126+
```
127+
128+
Search institutional notes before proposing work:
129+
130+
```bash
131+
rg -i --files-with-matches \
132+
"convex-better-auth|@convex-dev/better-auth|better-auth|auth|react-start|nextjs|jwt|jwks|session|cookie|schema|plugin|getToken" \
133+
docs/solutions docs/plans
134+
```
135+
136+
Read relevant hits, especially notes about:
137+
138+
- `@convex-dev/better-auth` reexports and wrappers
139+
- `kitcn/auth`, `kitcn/auth-client`, `kitcn/auth-nextjs`, and
140+
`kitcn/auth-start`
141+
- Better Auth and Convex version compatibility
142+
- token, JWT, JWKS, cookie, and session handling
143+
- schema generation, plugin reconciliation, and generated auth contracts
144+
- React, Solid, Next.js, and TanStack Start provider behavior
145+
- scaffold templates, docs, and `packages/kitcn/skills/convex/**`
146+
- local hacks that might be obsolete after upstream changes
147+
148+
## 4. Classify Every Upstream Change
149+
150+
Classify each commit or file group:
151+
152+
- `compatibility`: required work to keep kitcn working with upstream auth,
153+
Better Auth, Convex, framework, or package changes.
154+
- `security`: auth correctness or security hardening kitcn should not miss.
155+
- `bugfix`: upstream fix that maps to a kitcn runtime, provider, token, schema,
156+
routing, or scaffold issue.
157+
- `feature`: new upstream API, helper, framework support, or auth capability
158+
kitcn can expose cleanly.
159+
- `cleanup`: upstream change that lets kitcn delete a workaround, wrapper,
160+
fallback, doc warning, copied logic, or special-case patch.
161+
- `docs`: upstream change that only affects user-facing docs, setup guidance, or
162+
skills.
163+
- `tests`: upstream test coverage or harness changes.
164+
- `no-op`: interesting upstream change with no kitcn action.
165+
166+
For every non-`no-op`, include:
167+
168+
- commit evidence
169+
- diff evidence
170+
- local kitcn files affected
171+
- expected implementation surface
172+
- verification command(s)
173+
- confidence
174+
175+
Use this relevance filter:
176+
177+
- Relevant: runtime auth behavior, package exports kitcn imports or reexports,
178+
helpers kitcn wraps, version compatibility, security, framework integration,
179+
schema/plugin behavior, generated code contracts, docs/skills users rely on,
180+
and cleanup of known kitcn workarounds.
181+
- Usually irrelevant: upstream release config, repository-only CI, maintainer
182+
docs, benchmark harnesses, examples that do not map to kitcn scaffolds, and
183+
tests for behavior kitcn neither exposes nor depends on.
184+
- Ambiguous optional: added test suites, e2e harnesses, examples, fixtures,
185+
benchmark tooling, and dev-only utilities. Stop and ask before pulling these
186+
in unless they are the direct verification path for a selected required fix.
187+
188+
## 5. Choose One Implementation Slice
189+
190+
Pick the highest-leverage slice using this order:
191+
192+
1. security fix
193+
2. compatibility breakage
194+
3. bugfix that affects kitcn users
195+
4. delete dirty hack made obsolete upstream
196+
5. agentic or DX improvement for deterministic setup, CLI, or generated output
197+
6. feature kitcn can expose cleanly
198+
7. docs or skill-only update
199+
8. optional tests or examples only after user approval
200+
201+
If several relevant upstream fixes touch the same auth surface and do not
202+
conflict, delegate them together. If they touch separate surfaces, pick the
203+
highest-risk slice first.
204+
205+
If the winning slice touches published package code, the delegated task must
206+
update the active changeset and run `bun --cwd packages/kitcn build`.
207+
208+
If it touches scaffold templates, the delegated task must run
209+
`bun run fixtures:sync` and `bun run fixtures:check`.
210+
211+
If it touches auth runtime, client, provider, or query invalidation surfaces,
212+
the delegated task must follow the repo's auth verification lane. Do not import
213+
a slow upstream e2e suite unless the user explicitly approves it.
214+
215+
## 6. Delegate Through `task`
216+
217+
Load
218+
[$task](../task/SKILL.md) with a
219+
prompt in this exact shape:
220+
221+
```md
222+
Implement this convex-better-auth sync opportunity.
223+
224+
Fork: zbeyens/convex-better-auth
225+
Upstream: <upstream-owner>/<repo-name>
226+
Range: <fork-ref>..<upstream-ref>
227+
Behind: <count> commits
228+
229+
Opportunity: <one-sentence selected slice>
230+
Class: <security | compatibility | bugfix | cleanup | agentic | feature | docs | tests>
231+
232+
Evidence:
233+
- Upstream commits: <short commit list or summary>
234+
- Upstream diff: <refs and files>
235+
- Kitcn evidence: <local files and docs/solutions notes>
236+
237+
Implementation:
238+
- <specific files or surfaces to inspect first>
239+
- <expected code/doc/test shape>
240+
- <anything explicitly ignored as irrelevant>
241+
242+
Acceptance:
243+
- <focused tests/checks>
244+
- <package build if packages/kitcn changes>
245+
- <fixtures commands if scaffold output changes>
246+
- open the PR after verification
247+
248+
Do not preserve obsolete auth workarounds if the upstream change removes the
249+
need for them. Hard cut the hack.
250+
Do not add optional slow e2e suites, broad examples, or dev-only upstream test
251+
infrastructure unless the user approved that scope.
252+
```
253+
254+
Then follow `task` until the PR exists or a real blocker is proven.
255+
256+
## Output
257+
258+
Before delegation, keep the audit terse:
259+
260+
```md
261+
Fork: zbeyens/convex-better-auth
262+
Upstream: <upstream-owner>/<repo-name>
263+
Range: <fork-ref>..<upstream-ref>
264+
Behind: <count>
265+
266+
| Class | Opportunity | Evidence | Decision |
267+
| --- | --- | --- | --- |
268+
| bugfix | ... | ... | selected |
269+
270+
Delegating to task: <selected slice>
271+
```
272+
273+
If the right choice is ambiguous, stop and ask one pointed question. Example:
274+
275+
```md
276+
Upstream added a Playwright e2e suite that does not fix a current kitcn bug.
277+
Do you want that pulled in, or should I ignore it and keep this sync to runtime
278+
fixes only?
279+
```
280+
281+
After `task` finishes, use its final handoff format.

0 commit comments

Comments
 (0)