|
| 1 | +--- |
| 2 | +name: sync-lexicons |
| 3 | +description: > |
| 4 | + Sync Hypercerts SDK with latest lexicons from the develop branch. Use when updating SDK dependencies, comparing |
| 5 | + lexicon versions, or reconciling changes between SDK and lexicons repository. Always check the CHANGELOG.md and diffs |
| 6 | + first to see exactly what changed between versions. |
| 7 | +--- |
| 8 | + |
| 9 | +# Sync Lexicons Skill |
| 10 | + |
| 11 | +Compare the Hypercerts lexicons repository changes between the version the SDK currently depends on and the latest |
| 12 | +develop branch, then update SDK files accordingly. |
| 13 | + |
| 14 | +## When to Use This Skill |
| 15 | + |
| 16 | +- When updating `@hypercerts-org/lexicon` dependency in SDK |
| 17 | +- When users ask "what changed in lexicons since the SDK version?" |
| 18 | +- Before SDK releases to ensure lexicon alignment |
| 19 | +- When reconciling SDK imports with new lexicons |
| 20 | + |
| 21 | +## How It Works |
| 22 | + |
| 23 | +1. **Extract current dependency**: Read SDK's `packages/sdk-core/package.json` for current `@hypercerts-org/lexicon` |
| 24 | + version |
| 25 | +2. **Fetch develop branch**: Get latest from lexicons repo develop branch |
| 26 | +3. **Compare versions**: Determine semantic version difference |
| 27 | +4. **Generate git diff**: Show changes between the two versions in lexicons repo |
| 28 | +5. **Update SDK files**: Modify SDK source files to reflect new lexicon imports/exports |
| 29 | + |
| 30 | +## Key Paths |
| 31 | + |
| 32 | +- **SDK root**: `.` (current working directory) |
| 33 | +- **SDK package.json**: `packages/sdk-core/package.json` |
| 34 | +- **SDK lexicons source**: `packages/sdk-core/src/lexicons.ts` |
| 35 | +- **Lexicons repo**: `../hypercerts-lexicon` |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +### Step 1: Check version of current dependency |
| 40 | + |
| 41 | +```bash |
| 42 | +OLD_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json) |
| 43 | +echo "Current SDK dependency: @hypercerts-org/lexicon@${OLD_VERSION}" |
| 44 | +``` |
| 45 | + |
| 46 | +**Note**: `OLD_VERSION` is extracted without the `v` prefix (e.g., `0.10.0-beta.4`). When using with git commands, |
| 47 | +prepend `v` to match git tag format. |
| 48 | + |
| 49 | +### Step 2: Fetch latest develop and tags |
| 50 | + |
| 51 | +```bash |
| 52 | +git -C ../hypercerts-lexicon fetch --tags origin |
| 53 | +``` |
| 54 | + |
| 55 | +### Step 3: Update SDK package.json to exact latest version |
| 56 | + |
| 57 | +```bash |
| 58 | +# Get the latest version tag from the lexicons repo (strip 'v' prefix for package manager) |
| 59 | +NEW_VERSION=$(git -C ../hypercerts-lexicon tag --list 'v*' --sort=-version:refname | head -1 | sed 's/^v//') |
| 60 | +echo "Latest lexicon version: ${NEW_VERSION}" |
| 61 | + |
| 62 | +# Update to exact version (no ^ operator) using pnpm add with --save-exact |
| 63 | +pnpm --filter @hypercerts-org/sdk-core add --save-exact @hypercerts-org/lexicon@${NEW_VERSION} |
| 64 | +``` |
| 65 | + |
| 66 | +**Note**: `NEW_VERSION` is now set without the `v` prefix (e.g., `0.10.0-beta.11`) for use with package managers. When |
| 67 | +using with git commands in subsequent steps, prepend `v` to match git tag format. |
| 68 | + |
| 69 | +### Step 4: Check CHANGELOG.md |
| 70 | + |
| 71 | +After updating the dependency, read the lexicons CHANGELOG to understand what changed: |
| 72 | + |
| 73 | +```bash |
| 74 | +cat packages/sdk-core/node_modules/@hypercerts-org/lexicon/CHANGELOG.md |
| 75 | +``` |
| 76 | + |
| 77 | +Look for: |
| 78 | + |
| 79 | +- Breaking changes that require SDK updates |
| 80 | +- Renamed exports (e.g., `HELPER_WORK_SCOPE_VERSION_*` → `WORK_SCOPE_VERSION_*`) |
| 81 | +- New lexicons added |
| 82 | +- Deprecated/removed constants |
| 83 | + |
| 84 | +### Step 5: Compare versions and diff |
| 85 | + |
| 86 | +```bash |
| 87 | +# NEW_VERSION already set in Step 3 from package.json (without 'v' prefix) |
| 88 | +# If running Step 5 independently, re-extract it: |
| 89 | +# NEW_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json) |
| 90 | + |
| 91 | +echo "Comparing ${OLD_VERSION} (previous) to ${NEW_VERSION} (updated)" |
| 92 | + |
| 93 | +# Show files that changed between old and new versions |
| 94 | +# Note: Prepend 'v' to version numbers to match git tag format |
| 95 | +git -C ../hypercerts-lexicon diff v${OLD_VERSION}..v${NEW_VERSION} --stat |
| 96 | + |
| 97 | +# Show detailed changes in lexicon JSON files |
| 98 | +git -C ../hypercerts-lexicon diff v${OLD_VERSION}..v${NEW_VERSION} -- '*.json' | head -200 |
| 99 | +``` |
| 100 | + |
| 101 | +### Step 6: Create structured plan and get user approval |
| 102 | + |
| 103 | +**CRITICAL: Do NOT proceed beyond this step without explicit user approval.** |
| 104 | + |
| 105 | +Based on the CHANGELOG and git diff analysis, create a detailed plan document |
| 106 | +(`specs/lexicon-sync/v{OLD_VERSION}-v{NEW_VERSION}.md`) that: |
| 107 | + |
| 108 | +1. **Groups changes by logical feature** (not by file or lexicon) |
| 109 | + - Each feature should be a self-contained unit of work |
| 110 | + - Examples: "Collection Item Weights", "Work Scope Logic Expressions", "Collection Avatar/Banner" |
| 111 | + |
| 112 | +2. **For each feature, document**: |
| 113 | + - CHANGELOG reference (PR number, version) |
| 114 | + - What changed in the lexicon |
| 115 | + - SDK tasks needed: |
| 116 | + - Documentation updates |
| 117 | + - Type exports/aliases to add |
| 118 | + - Helper types needed |
| 119 | + - Usage examples to add |
| 120 | + - Validation steps (build, test, type checking) |
| 121 | + - Changeset requirements (bump type and justification) |
| 122 | + |
| 123 | +3. **Order changes logically**: |
| 124 | + - Group related changes together |
| 125 | + - Put simpler changes before complex ones |
| 126 | + - Consider dependencies between changes |
| 127 | + |
| 128 | +4. **Write the plan to `specs/lexicon-sync/v{OLD_VERSION}-v{NEW_VERSION}.md`** |
| 129 | + - Create the `specs/lexicon-sync/` directory if it doesn't exist |
| 130 | + - Use the exact version numbers from package.json |
| 131 | + |
| 132 | +Example plan structure: |
| 133 | + |
| 134 | +```markdown |
| 135 | +# Lexicon Sync Plan: v{OLD} → v{NEW} |
| 136 | + |
| 137 | +## Current Status |
| 138 | + |
| 139 | +- Old version: ... |
| 140 | +- New version: ... |
| 141 | +- Build status: ... |
| 142 | +- Test status: ... |
| 143 | + |
| 144 | +## Changes to Implement |
| 145 | + |
| 146 | +### Change 1: [Feature Name] (beta.X) |
| 147 | + |
| 148 | +**CHANGELOG Reference**: PR #XXX - ... |
| 149 | + |
| 150 | +**What Changed**: |
| 151 | + |
| 152 | +- Bullet points describing the lexicon changes |
| 153 | + |
| 154 | +**SDK Tasks**: |
| 155 | + |
| 156 | +- [ ] Add/update documentation for X |
| 157 | +- [ ] Add type exports for Y |
| 158 | +- [ ] Add usage examples |
| 159 | +- [ ] Build and test |
| 160 | +- [ ] Create changeset (minor/major - reason) |
| 161 | + |
| 162 | +**Validation**: |
| 163 | + |
| 164 | +- [ ] Format check passes (`pnpm format:check`) |
| 165 | +- [ ] Lint passes (`pnpm lint`) |
| 166 | +- [ ] Typecheck passes (`pnpm typecheck`) |
| 167 | +- [ ] Build passes (`pnpm build`) |
| 168 | +- [ ] Tests pass (`pnpm test`) |
| 169 | +- [ ] Types export correctly |
| 170 | + |
| 171 | +**Status**: ⏳ Pending / 🚧 In Progress / ✅ Complete |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +### Change 2: [Next Feature] (beta.Y) |
| 176 | + |
| 177 | +**CHANGELOG Reference**: PR #YYY - ... |
| 178 | + |
| 179 | +**What Changed**: |
| 180 | + |
| 181 | +- ... |
| 182 | + |
| 183 | +**SDK Tasks**: |
| 184 | + |
| 185 | +- [ ] Task 1 |
| 186 | +- [ ] Task 2 |
| 187 | +- [ ] ... |
| 188 | + |
| 189 | +**Validation**: |
| 190 | + |
| 191 | +- [ ] Format check passes (`pnpm format:check`) |
| 192 | +- [ ] Lint passes (`pnpm lint`) |
| 193 | +- [ ] Typecheck passes (`pnpm typecheck`) |
| 194 | +- [ ] Build passes (`pnpm build`) |
| 195 | +- [ ] Tests pass (`pnpm test`) |
| 196 | +- [ ] Types export correctly |
| 197 | + |
| 198 | +**Status**: ⏳ Pending |
| 199 | + |
| 200 | +--- |
| 201 | +``` |
| 202 | + |
| 203 | +Present this plan to the user and ask: |
| 204 | + |
| 205 | +> "I've analyzed the changes between v{OLD_VERSION} and v{NEW_VERSION} and created a plan in |
| 206 | +> `specs/lexicon-sync/v{OLD_VERSION}-v{NEW_VERSION}.md`. |
| 207 | +> |
| 208 | +> The plan breaks down the sync into {N} logical changes that will be implemented one at a time. |
| 209 | +> |
| 210 | +> Should I proceed with implementing Change 1: [Feature Name]?" |
| 211 | +
|
| 212 | +**Wait for explicit user confirmation before proceeding to Step 7.** |
| 213 | + |
| 214 | +### Step 7: Implement ONE logical change at a time |
| 215 | + |
| 216 | +**IMPORTANT**: Only work on ONE change from the plan at a time. |
| 217 | + |
| 218 | +For the current change (e.g., "Change 1: Collection Item Weights"): |
| 219 | + |
| 220 | +1. **Update documentation** in `packages/sdk-core/src/services/hypercerts/types.ts`: |
| 221 | + - Add JSDoc comments for new/changed types |
| 222 | + - Add usage examples |
| 223 | + - Document breaking changes if any |
| 224 | + |
| 225 | +2. **Add type exports** if needed: |
| 226 | + - Add type aliases for new lexicon types |
| 227 | + - Add helper types for SDK operations |
| 228 | + - Export from appropriate modules |
| 229 | + |
| 230 | +3. **Update SDK code** if needed: |
| 231 | + - Modify operations to support new fields |
| 232 | + - Update validation logic |
| 233 | + - Add helper functions |
| 234 | + |
| 235 | +4. **Validate changes**: |
| 236 | + |
| 237 | + ```bash |
| 238 | + pnpm --filter @hypercerts-org/sdk-core format:check |
| 239 | + pnpm --filter @hypercerts-org/sdk-core lint |
| 240 | + pnpm --filter @hypercerts-org/sdk-core typecheck |
| 241 | + pnpm --filter @hypercerts-org/sdk-core build |
| 242 | + pnpm --filter @hypercerts-org/sdk-core test |
| 243 | + ``` |
| 244 | + |
| 245 | +5. **Create changeset** for this specific change (only after all validation passes): |
| 246 | + |
| 247 | + ```bash |
| 248 | + pnpm changeset |
| 249 | + ``` |
| 250 | + |
| 251 | + - Follow guidance from `writing-changesets` skill |
| 252 | + - Reference the specific feature being added |
| 253 | + - Use appropriate bump type |
| 254 | + |
| 255 | +**After completing these steps for the current change:** |
| 256 | + |
| 257 | +Ask the user: |
| 258 | + |
| 259 | +> "Change {N}: {Feature Name} is complete. |
| 260 | +> |
| 261 | +> - Documentation added: ✅ |
| 262 | +> - Types updated: ✅ |
| 263 | +> - Format check passing: ✅ |
| 264 | +> - Lint passing: ✅ |
| 265 | +> - Typecheck passing: ✅ |
| 266 | +> - Build passing: ✅ |
| 267 | +> - Tests passing: ✅ |
| 268 | +> - Changeset created: ✅ |
| 269 | +> |
| 270 | +> Should I proceed with Change {N+1}: {Next Feature Name}?" |
| 271 | +
|
| 272 | +**Repeat Step 7 for each change in the plan, getting approval between each one.** |
| 273 | + |
| 274 | +### Step 8: Final validation and cleanup |
| 275 | + |
| 276 | +After ALL changes are implemented: |
| 277 | + |
| 278 | +1. **Run full test suite**: |
| 279 | + |
| 280 | + ```bash |
| 281 | + pnpm test |
| 282 | + pnpm build |
| 283 | + ``` |
| 284 | + |
| 285 | +2. **Review all changesets**: |
| 286 | + - Check if multiple changesets should be combined |
| 287 | + - Ensure consistency in messaging |
| 288 | + - Verify bump types are correct |
| 289 | + |
| 290 | +3. **Update any top-level documentation**: |
| 291 | + - README changes if needed |
| 292 | + - AGENTS.md updates if needed |
| 293 | + |
| 294 | +4. **Mark plan as complete**: |
| 295 | + - Update the plan file with final status |
| 296 | + - All changes should show ✅ Complete |
| 297 | + |
| 298 | +5. **Present final summary** to user with: |
| 299 | + - All changes implemented |
| 300 | + - All changesets created |
| 301 | + - Build/test status |
| 302 | + - Any remaining manual steps needed |
| 303 | + |
| 304 | +## Common Anti-Patterns to Avoid |
| 305 | + |
| 306 | +### Don't Hardcode Lexicon Names |
| 307 | + |
| 308 | +- ❌ `if (lexicon === "HYPERCERTS_LEXICONS") ...` |
| 309 | +- ✅ Read dynamically from the lexicons package exports |
| 310 | + |
| 311 | +### Don't Skip the CHANGELOG |
| 312 | + |
| 313 | +- ❌ Immediately update without reviewing changes |
| 314 | +- ✅ Always check `CHANGELOG.md` first to see exactly what changed between versions |
| 315 | +- ✅ Then run `git diff` for additional context |
| 316 | + |
| 317 | +### Don't Skip the Diff Step |
| 318 | + |
| 319 | +- ❌ Immediately update without reviewing changes |
| 320 | +- ✅ Always run `git diff` to see what actually changed |
| 321 | + |
| 322 | +### Don't Forget to Rebuild |
| 323 | + |
| 324 | +- ❌ Update imports and ship |
| 325 | +- ✅ Run `pnpm build` to verify type compatibility |
| 326 | + |
| 327 | +## What Gets Synced |
| 328 | + |
| 329 | +The sync process focuses on making SDK changes visible and usable to developers. For each logical change: |
| 330 | + |
| 331 | +### Documentation Updates |
| 332 | + |
| 333 | +1. **Type documentation** - JSDoc comments explaining new features |
| 334 | +2. **Usage examples** - Code snippets showing how to use new fields/types |
| 335 | +3. **Breaking change notes** - Clear warnings about incompatible changes |
| 336 | + |
| 337 | +### Type System Updates |
| 338 | + |
| 339 | +1. **Type aliases** - Friendly names for lexicon types (e.g., `HypercertClaim = OrgHypercertsClaimActivity.Main`) |
| 340 | +2. **Helper types** - SDK-specific types for common operations (e.g., `CreateClaimParams`) |
| 341 | +3. **Union types** - Combined types for flexible APIs (e.g., `ImageInput = string | Blob`) |
| 342 | + |
| 343 | +### Code Updates (when needed) |
| 344 | + |
| 345 | +1. **New lexicons**: |
| 346 | + - Add `*_LEXICON_JSON` imports from `@hypercerts-org/lexicon` |
| 347 | + - Add to `HYPERCERT_LEXICONS` array |
| 348 | + - Add NSID to `HYPERCERT_COLLECTIONS` object if it's a record type |
| 349 | + |
| 350 | +2. **Modified lexicons**: |
| 351 | + - Update type exports if schema changed |
| 352 | + - Add helper types for new fields |
| 353 | + - Update operations to support new features |
| 354 | + |
| 355 | +3. **Removed lexicons**: |
| 356 | + - Remove imports and exports |
| 357 | + - Add deprecation notices |
| 358 | + - Maintain backward compatibility if possible |
| 359 | + |
| 360 | +### Validation |
| 361 | + |
| 362 | +Each change must pass: |
| 363 | + |
| 364 | +- Formatting (`pnpm format:check`) |
| 365 | +- Linting (`pnpm lint`) |
| 366 | +- TypeScript typechecking (`pnpm typecheck`) |
| 367 | +- TypeScript compilation (`pnpm build`) |
| 368 | +- All existing tests (`pnpm test`) |
| 369 | +- Type export verification |
| 370 | + |
| 371 | +### Changesets |
| 372 | + |
| 373 | +Each logical change gets its own changeset: |
| 374 | + |
| 375 | +- **minor** - New features, backward-compatible changes |
| 376 | +- **major** - Breaking changes (rare, requires migration guide) |
| 377 | +- **patch** - Bug fixes, documentation only (very rare for lexicon syncs) |
| 378 | + |
| 379 | +## Iterative Process Summary |
| 380 | + |
| 381 | +**DO**: Work on one logical feature at a time, validate, get approval, repeat **DON'T**: Try to sync everything at once |
| 382 | +in a big batch |
| 383 | + |
| 384 | +This ensures: |
| 385 | + |
| 386 | +- Each change is reviewable in isolation |
| 387 | +- Problems are caught early |
| 388 | +- Changesets accurately describe what changed |
| 389 | +- User has control over the process |
0 commit comments