|
| 1 | +--- |
| 2 | +name: sync-lexicons |
| 3 | +description: Sync Hypercerts SDK with latest lexicons from the develop branch. Use when updating SDK dependencies, |
| 4 | + comparing lexicon versions, or reconciling changes between SDK and lexicons repository. |
| 5 | + |
| 6 | + **Always check the CHANGELOG.md first** - Run `cat |
| 7 | + packages/sdk-core/node_modules/@hypercerts-org/lexicon/CHANGELOG.md` to see exactly what changed between versions. |
| 8 | +--- |
| 9 | + |
| 10 | +# Sync Lexicons Skill |
| 11 | + |
| 12 | +Compare the Hypercerts lexicons repository changes between the version the SDK currently depends on and the latest |
| 13 | +develop branch, then update SDK files accordingly. |
| 14 | + |
| 15 | +## When to Use This Skill |
| 16 | + |
| 17 | +- When updating `@hypercerts-org/lexicon` dependency in SDK |
| 18 | +- When users ask "what changed in lexicons since the SDK version?" |
| 19 | +- Before SDK releases to ensure lexicon alignment |
| 20 | +- When reconciling SDK imports with new lexicons |
| 21 | + |
| 22 | +## How It Works |
| 23 | + |
| 24 | +1. **Extract current dependency**: Read SDK's `packages/sdk-core/package.json` for current `@hypercerts-org/lexicon` |
| 25 | + version |
| 26 | +2. **Fetch develop branch**: Get latest from lexicons repo develop branch |
| 27 | +3. **Compare versions**: Determine semantic version difference |
| 28 | +4. **Generate git diff**: Show changes between the two versions in lexicons repo |
| 29 | +5. **Update SDK files**: Modify SDK source files to reflect new lexicon imports/exports |
| 30 | + |
| 31 | +## Key Paths |
| 32 | + |
| 33 | +- **SDK root**: `.` (current working directory) |
| 34 | +- **SDK package.json**: `packages/sdk-core/package.json` |
| 35 | +- **SDK lexicons source**: `packages/sdk-core/src/lexicons.ts` |
| 36 | +- **Lexicons repo**: `../hypercerts-lexicon` |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +### Step 1: Check version of current dependency |
| 41 | + |
| 42 | +```bash |
| 43 | +OLD_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json) |
| 44 | +echo "Current SDK dependency: @hypercerts-org/lexicon@v${OLD_VERSION}" |
| 45 | +``` |
| 46 | + |
| 47 | +### Step 2: Fetch latest develop and tags |
| 48 | + |
| 49 | +```bash |
| 50 | +git -C ../hypercerts-lexicon fetch --tags origin |
| 51 | +``` |
| 52 | + |
| 53 | +### Step 3: Update SDK package.json to exact latest version |
| 54 | + |
| 55 | +```bash |
| 56 | +# Get the latest version tag from the lexicons repo |
| 57 | +NEW_VERSION=$(git -C ../hypercerts-lexicon tag --list 'v*' --sort=-version:refname | head -1 | sed 's/^v//') |
| 58 | +echo "Latest lexicon version: ${NEW_VERSION}" |
| 59 | + |
| 60 | +# Update to exact version (no ^ operator) using pnpm add with --save-exact |
| 61 | +pnpm --filter @hypercerts-org/sdk-core add --save-exact @hypercerts-org/lexicon@${NEW_VERSION} |
| 62 | +``` |
| 63 | + |
| 64 | +### Step 4: Check CHANGELOG.md |
| 65 | + |
| 66 | +After updating the dependency, read the lexicons CHANGELOG to understand what changed: |
| 67 | + |
| 68 | +```bash |
| 69 | +cat packages/sdk-core/node_modules/@hypercerts-org/lexicon/CHANGELOG.md |
| 70 | +``` |
| 71 | + |
| 72 | +Look for: |
| 73 | + |
| 74 | +- Breaking changes that require SDK updates |
| 75 | +- Renamed exports (e.g., `HELPER_WORK_SCOPE_VERSION_*` → `WORK_SCOPE_VERSION_*`) |
| 76 | +- New lexicons added |
| 77 | +- Deprecated/removed constants |
| 78 | + |
| 79 | +### Step 5: Compare versions and diff |
| 80 | + |
| 81 | +```bash |
| 82 | +# Extract the NEW version (after Step 3 update) |
| 83 | +NEW_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json) |
| 84 | + |
| 85 | +echo "Comparing ${OLD_VERSION} (previous) to ${NEW_VERSION} (updated)" |
| 86 | + |
| 87 | +# Show files that changed between old and new versions |
| 88 | +git -C ../hypercerts-lexicon diff ${OLD_VERSION}..${NEW_VERSION} --stat |
| 89 | + |
| 90 | +# Show detailed changes in lexicon JSON files |
| 91 | +git -C ../hypercerts-lexicon diff ${OLD_VERSION}..${NEW_VERSION} -- '*.json' | head -200 |
| 92 | +``` |
| 93 | + |
| 94 | +### Step 6: Create plan and get user approval |
| 95 | + |
| 96 | +**CRITICAL: Do NOT proceed beyond this step without explicit user approval.** |
| 97 | + |
| 98 | +Based on the CHANGELOG and git diff analysis, create a detailed plan of proposed changes: |
| 99 | + |
| 100 | +1. List all lexicons to be added (with import statements) |
| 101 | +2. List all lexicons to be modified (with specific changes) |
| 102 | +3. List all lexicons to be removed/deprecated |
| 103 | +4. List all constant renames or updates needed |
| 104 | +5. Identify test files that need updates |
| 105 | +6. Specify the changeset bump type (patch/minor/major) with justification |
| 106 | + |
| 107 | +Present this plan to the user and ask: |
| 108 | + |
| 109 | +> "I've analyzed the changes between v{OLD_VERSION} and v{NEW_VERSION}. Here's my proposed plan: |
| 110 | +> |
| 111 | +> [detailed plan] |
| 112 | +> |
| 113 | +> Does this plan look correct? Should I proceed with these changes?" |
| 114 | +
|
| 115 | +**Wait for explicit user confirmation before proceeding to Step 7.** |
| 116 | + |
| 117 | +### Step 7: Sync SDK imports |
| 118 | + |
| 119 | +Manually update `packages/sdk-core/src/lexicons.ts` based on the changes identified: |
| 120 | + |
| 121 | +1. Add new lexicon imports from `@hypercerts-org/lexicon` |
| 122 | +2. Update export arrays with new entries |
| 123 | +3. Add new NSID entries to collection constants |
| 124 | +4. Remove deprecated lexicons if applicable |
| 125 | + |
| 126 | +### Step 8: Update or add tests |
| 127 | + |
| 128 | +Review and update tests to cover lexicon changes: |
| 129 | + |
| 130 | +```bash |
| 131 | +# Check existing lexicon tests |
| 132 | +ls packages/sdk-core/tests/lexicons/ |
| 133 | + |
| 134 | +# Run existing tests to see if they still pass |
| 135 | +pnpm --filter @hypercerts-org/sdk-core test |
| 136 | +``` |
| 137 | + |
| 138 | +For new lexicons: |
| 139 | + |
| 140 | +1. Add test cases in `packages/sdk-core/tests/lexicons/` or relevant service tests |
| 141 | +2. Verify new imports are registered correctly |
| 142 | +3. Test validation with new schemas |
| 143 | + |
| 144 | +For modified lexicons: |
| 145 | + |
| 146 | +1. Update existing test fixtures if schemas changed |
| 147 | +2. Add tests for new fields or validation rules |
| 148 | +3. Ensure backward compatibility tests still pass |
| 149 | + |
| 150 | +For removed/deprecated lexicons: |
| 151 | + |
| 152 | +1. Update tests to handle deprecation gracefully |
| 153 | +2. Add migration tests if needed |
| 154 | + |
| 155 | +### Step 9: Run full test suite |
| 156 | + |
| 157 | +Ensure all tests pass before committing: |
| 158 | + |
| 159 | +```bash |
| 160 | +# Run all tests |
| 161 | +pnpm test |
| 162 | + |
| 163 | +# Check coverage if needed |
| 164 | +pnpm test:coverage |
| 165 | +``` |
| 166 | + |
| 167 | +Fix any failing tests before proceeding. |
| 168 | + |
| 169 | +### Step 10: Create a changeset |
| 170 | + |
| 171 | +Use the `writing-changesets` skill to document the lexicon sync: |
| 172 | + |
| 173 | +```bash |
| 174 | +# Load the skill for guidance |
| 175 | +skill writing-changesets |
| 176 | +``` |
| 177 | + |
| 178 | +The changeset should: |
| 179 | + |
| 180 | +1. Include `@hypercerts-org/sdk-core` (always affected) |
| 181 | +2. Include `@hypercerts-org/sdk-react` if React hooks are affected |
| 182 | +3. Use appropriate bump type: |
| 183 | + - **patch**: Bug fixes, internal updates with no API changes |
| 184 | + - **minor**: New lexicons added, backward-compatible changes |
| 185 | + - **major**: Breaking changes (renamed exports, removed lexicons, schema changes affecting types) |
| 186 | +4. Reference the lexicon version being synced |
| 187 | +5. List key changes from the CHANGELOG |
| 188 | + |
| 189 | +Example changeset content: |
| 190 | + |
| 191 | +```markdown |
| 192 | +--- |
| 193 | +"@hypercerts-org/sdk-core": minor |
| 194 | +--- |
| 195 | + |
| 196 | +Sync with @hypercerts-org/lexicon@X.Y.Z |
| 197 | + |
| 198 | +- Add new org.hypercerts.project.\* lexicons |
| 199 | +- Update WORK_SCOPE_VERSION constants (renamed from HELPER_WORK_SCOPE_VERSION) |
| 200 | +- Add support for project attachments |
| 201 | +``` |
| 202 | + |
| 203 | +## Common Anti-Patterns to Avoid |
| 204 | + |
| 205 | +### Don't Hardcode Lexicon Names |
| 206 | + |
| 207 | +- ❌ `if (lexicon === "HYPERCERTS_LEXICONS") ...` |
| 208 | +- ✅ Read dynamically from the lexicons package exports |
| 209 | + |
| 210 | +### Don't Skip the CHANGELOG |
| 211 | + |
| 212 | +- ❌ Immediately update without reviewing changes |
| 213 | +- ✅ Always check `CHANGELOG.md` first to see exactly what changed between versions |
| 214 | +- ✅ Then run `git diff` for additional context |
| 215 | + |
| 216 | +### Don't Skip the Diff Step |
| 217 | + |
| 218 | +- ❌ Immediately update without reviewing changes |
| 219 | +- ✅ Always run `git diff` to see what actually changed |
| 220 | + |
| 221 | +### Don't Forget to Rebuild |
| 222 | + |
| 223 | +- ❌ Update imports and ship |
| 224 | +- ✅ Run `pnpm build` to verify type compatibility |
| 225 | + |
| 226 | +## What Gets Synced |
| 227 | + |
| 228 | +When new lexicons are added: |
| 229 | + |
| 230 | +1. **Import statements** - New `*_LEXICON_JSON` imports from `@hypercerts-org/lexicon` |
| 231 | +2. **Export arrays** - New entries added to `HYPERCERT_LEXICONS` array |
| 232 | +3. **Collection constants** - New NSID entries added to `HYPERCERT_COLLECTIONS` object |
| 233 | + |
| 234 | +When lexicons are modified: |
| 235 | + |
| 236 | +1. Review changes to understand schema updates |
| 237 | +2. Update corresponding type exports if needed |
| 238 | +3. Run tests to verify compatibility |
| 239 | + |
| 240 | +When lexicons are removed: |
| 241 | + |
| 242 | +1. Remove corresponding imports |
| 243 | +2. Remove from export arrays and collection constants |
| 244 | +3. Deprecate gracefully if SDK still needs backward compatibility |
0 commit comments