|
| 1 | +# Dependency Upgrade Agent |
| 2 | + |
| 3 | +**Version:** 1.0 |
| 4 | +**Created:** 2026-03-31 |
| 5 | +**Purpose:** Automate dependency upgrades with risk assessment and phased rollout |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +This agent orchestrates dependency upgrades across the pnpm monorepo. It: |
| 12 | + |
| 13 | +1. **Audits** all package.json files for upgradeable dependencies |
| 14 | +2. **Categorizes** by risk (Critical/High/Low) |
| 15 | +3. **Executes** phases in sequence (Low → High → Blocked) |
| 16 | +4. **Reports** breaking changes and migration effort |
| 17 | +5. **Tracks** progress in `UPGRADEABLE_DEPENDENCIES.md` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Execution Flow |
| 22 | + |
| 23 | +### Phase 1: Quick Win (Low-Risk Patches) |
| 24 | + |
| 25 | +```bash |
| 26 | +# ✅ No configuration changes, no tests required |
| 27 | + |
| 28 | +# Step 1: Update root package.json |
| 29 | +ncu --filter "minimatch|stylelint-order|cssnano" -u |
| 30 | + |
| 31 | +# Step 2: Update all package.json files in monorepo (each package independently) |
| 32 | +pnpm -r exec ncu --filter "minimatch|stylelint-order|cssnano" -u |
| 33 | + |
| 34 | +# Step 3: Sync lock file (resolves all versions consistently) |
| 35 | +pnpm install |
| 36 | + |
| 37 | +# Step 4: Validate consistency (no version conflicts) |
| 38 | +pnpm install --frozen-lockfile |
| 39 | +``` |
| 40 | + |
| 41 | +**Time:** ~1 hour |
| 42 | +**Risk:** VERY LOW |
| 43 | +**Validation:** pnpm-lock.yaml updated and consistent (all versions reconciled across monorepo) |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +### Phase 2: Major Upgrades (High Effort) |
| 48 | + |
| 49 | +#### 2a. Jest 26→30 + TypeScript types |
| 50 | + |
| 51 | +```bash |
| 52 | +ncu --filter "jest|@types/jest" -u |
| 53 | +pnpm -r exec ncu --filter "jest|@types/jest" -u |
| 54 | +pnpm install |
| 55 | + |
| 56 | +# ⚠️ THEN: Run full test suite |
| 57 | +pnpm -r test:unit |
| 58 | +pnpm -r test:e2e |
| 59 | +pnpm test:update:e2e |
| 60 | +``` |
| 61 | + |
| 62 | +**Breaking Changes:** |
| 63 | + |
| 64 | +- jest environment jsdom 21→26 (spec changes) |
| 65 | +- Deprecated alias methods removed |
| 66 | +- `jest.genMockFromModule()` → `jest.createMockFromModule()` |
| 67 | +- `--testPathPattern` → `--testPathPatterns` |
| 68 | + |
| 69 | +**Migration Effort:** 2-5 days |
| 70 | +**Focus:** `/packages/components/` first, then adapters |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +#### 2b. ESLint 9→10 (Config Migration) |
| 75 | + |
| 76 | +```bash |
| 77 | +ncu --filter "eslint|@eslint/js" -u |
| 78 | +pnpm install |
| 79 | + |
| 80 | +# ⚠️ THEN: Migrate config from .eslintrc.json to eslint.config.js |
| 81 | +eslint --init # (use to generate boilerplate) |
| 82 | +# Manual migration of rules from old format to new |
| 83 | + |
| 84 | +pnpm lint |
| 85 | +pnpm lint:eslint |
| 86 | +``` |
| 87 | + |
| 88 | +**Breaking Changes:** |
| 89 | + |
| 90 | +- Legacy `.eslintrc.json` removed |
| 91 | +- Must use flat config (`eslint.config.js`) |
| 92 | +- Config file lookup behavior changed (benefits monorepos) |
| 93 | + |
| 94 | +**Migration Effort:** 1-3 days |
| 95 | +**Notes:** Automation tools available via `eslint --init` |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +### Phase 3: Dependent Upgrades (after Phase 2) |
| 100 | + |
| 101 | +```bash |
| 102 | +# Only after jest + eslint are done: |
| 103 | +ncu --filter "knip|typescript" -u |
| 104 | +pnpm -r exec ncu --filter "knip|typescript" -u |
| 105 | +pnpm install |
| 106 | +``` |
| 107 | + |
| 108 | +**TypeScript 5→6:** |
| 109 | + |
| 110 | +- Config migration: `npx @andrewbranch/ts5to6` |
| 111 | +- May be automatic depending on current tsconfig.json |
| 112 | + |
| 113 | +**knip 5→6:** |
| 114 | + |
| 115 | +- Unused-code detection config changes |
| 116 | +- `--experimental-tags` → `--tags` |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +### Phase 4: Blocked Dependencies (Wait) |
| 121 | + |
| 122 | +These remain at current versions until: |
| 123 | + |
| 124 | +| Package | Current | Blocked By | Action | |
| 125 | +| ------------- | ----------- | -------------------------------------- | ---------------------------------------- | |
| 126 | +| @stencil/core | 4.43.3 | Output-targets not v5-compatible | Wait for output-target updates | |
| 127 | +| prettier | 3.8.1 | prettier-plugin-organize-imports | Wait for prettier v4 stable | |
| 128 | +| @angular/core | v19/v20/v21 | Production critical, complex migration | Track in separate angular-upgrade branch | |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## Reporting Template |
| 133 | + |
| 134 | +After each phase, update `/UPGRADEABLE_DEPENDENCIES.md`: |
| 135 | + |
| 136 | +```markdown |
| 137 | +## Upgrade History |
| 138 | + |
| 139 | +### [Date]: Phase 1 Completed ✅ |
| 140 | + |
| 141 | +- minimatch 10.2.4 → 10.2.5 ✅ |
| 142 | +- rollup 4.60.0 → 4.60.1 ✅ |
| 143 | +- stylelint-order 7.0.1 → 8.1.1 ✅ |
| 144 | +- cssnano 7.1.3 → 7.1.4 ✅ |
| 145 | +- Status: pnpm-lock.yaml synced, tests passing |
| 146 | + |
| 147 | +### [Date]: Phase 2a (Jest) — In Progress 🔄 |
| 148 | + |
| 149 | +- Current: Running test suite migration |
| 150 | +- Blockers: [if any] |
| 151 | +- ETA: [days] |
| 152 | +``` |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Error Handling |
| 157 | + |
| 158 | +### If `ncu` fails: |
| 159 | + |
| 160 | +```bash |
| 161 | +# Clear and retry |
| 162 | +rm -rf node_modules pnpm-lock.yaml |
| 163 | +pnpm install |
| 164 | +ncu --filter "PACKAGE_NAME" -u |
| 165 | +``` |
| 166 | + |
| 167 | +### If peer dependencies conflict: |
| 168 | + |
| 169 | +1. Check `ncu` output for exact peer version |
| 170 | +2. Manually edit package.json to satisfy both |
| 171 | +3. Run `pnpm install` to validate |
| 172 | + |
| 173 | +### If tests fail post-upgrade: |
| 174 | + |
| 175 | +1. Run only affected package tests first |
| 176 | +2. Review migration guides (links in UPGRADEABLE_DEPENDENCIES.md) |
| 177 | +3. Apply fixes incrementally per component/adapter |
| 178 | +4. Commit after each fix |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## Success Criteria |
| 183 | + |
| 184 | +- ✅ All phases complete or justifiably blocked |
| 185 | +- ✅ pnpm-lock.yaml clean (no duplicate entries) |
| 186 | +- ✅ Test suite passes (after Phase 2) |
| 187 | +- ✅ Lint passes (after Phase 2b) |
| 188 | +- ✅ Breaking changes documented in CHANGELOG / Migration Guide |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## Running This Agent |
| 193 | + |
| 194 | +### Interactive (Recommended) |
| 195 | + |
| 196 | +```bash |
| 197 | +# Review UPGRADEABLE_DEPENDENCIES.md for current state |
| 198 | +# Execute one phase at a time, validate, then move to next |
| 199 | +``` |
| 200 | + |
| 201 | +### Automated (Via Claude Agent) |
| 202 | + |
| 203 | +``` |
| 204 | +/team run dependency upgrades Phase 1 |
| 205 | +/team run dependency upgrades Phase 2a (Jest) |
| 206 | +/team run dependency upgrades Phase 2b (ESLint) |
| 207 | +``` |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +## References |
| 212 | + |
| 213 | +- [NPM Check Updates](https://www.npmjs.com/package/npm-check-updates) |
| 214 | +- [Jest 30 Migration](https://jestjs.io/docs/upgrading-to-jest30) |
| 215 | +- [ESLint v10 Migration](https://eslint.org/docs/latest/use/migrate-to-10.0.0) |
| 216 | +- [TypeScript 6.0 Changes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/) |
| 217 | +- [pnpm CLI](https://pnpm.io/cli/install) |
0 commit comments