Skip to content

AI SDK 7 - #1515

Merged
n1ckoates merged 5 commits into
mainfrom
nick/ai-sdk-7
Jul 6, 2026
Merged

n1ckoates merged 5 commits into
mainfrom
nick/ai-sdk-7

Conversation

@n1ckoates

@n1ckoates n1ckoates commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

Migrated to AI SDK 7, mostly just using the migrate skill.

@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chatbot Ready Ready Preview, Comment Jul 6, 2026 6:01pm

@socket-security

socket-security Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​ai-sdk/​react@​4.0.10981007598100
Addednpm/​@​ai-sdk/​provider@​4.0.11001007698100
Addednpm/​@​ai-sdk/​otel@​1.0.97810010098100
Addednpm/​ai@​7.0.98610010099100

View full report

@n1ckoates
n1ckoates marked this pull request as ready for review July 2, 2026 20:30
This reverts commit ee3e423.

The biome.jsonc lint fix is unrelated to the AI SDK 7 upgrade and has
been moved to its own branch (nick/fix-lint). Reverting keeps this
branch scoped to the AI SDK 7 update.

Co-authored-by: Cursor <[email protected]>

@gr2m gr2m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍🏼

@n1ckoates
n1ckoates merged commit 2397c78 into main Jul 6, 2026
5 of 7 checks passed
@n1ckoates
n1ckoates deleted the nick/ai-sdk-7 branch July 6, 2026 20:44
lucasbraum added a commit to uptide-dev/uptide that referenced this pull request Oct 7, 2026
…d pack test (#39)

## Pack

`ai` `>=6 <7` → `>=7 <8` (most recent breaking major: 7.0.0,
2026-06-25). Scaffolded with `uptide pack new ai --from ">=6 <7" --to
">=7 <8"` and scored only with `uptide pack test ai`.

## Sources

- https://ai-sdk.dev/docs/migration-guides/migration-guide-7-0
-
https://github.com/vercel/ai/blob/main/content/docs/08-migration-guides/23-migration-guide-7-0.mdx
- https://github.com/vercel/ai/blob/main/packages/ai/CHANGELOG.md
(7.0.0)

## Rules and behavior notes

- Rewrites (deprecated, found by `detect` through imports from `ai`, so
another library's `system:` or `@ai-sdk/react`'s `onFinish` is never
touched): `instructions` (`system`), `on-end` (`onFinish` on
generateText/streamText/ToolLoopAgent/UI message streams),
`on-step-end`, `telemetry` (`experimental_telemetry`), `is-step-count`
(`stepCountIs`, import and references; an alias keeps its local name).
- Rewrites of check's own findings: `full-stream` (deprecated
`fullStream` → `stream`; a destructured local is renamed only where no
other `stream` is declared), `total-usage`, and
`removed-experimental-option` (breaking:
`experimental_activeTools`/`prepareStep`/`output`, matched on the
compiler's message).
- Assisted (guide to the agent): `ui-message-stream` (result helpers
become standalone functions), `telemetry-metadata` (breaking: `metadata`
→ `runtimeContext` + `includeRuntimeContext`), `tool-context` (breaking:
`context` in tool execute options).
- Behavior notes, listed for review: telemetry registration (no spans
without `registerTelemetry`), results covering every step, system
messages rejected, `prepareStep` carrying forward, redacted UI stream
errors, ESM-only/Node 22.

## `fix ai` upgrades the whole group

`ai` and the `@ai-sdk/*` packages pin the same `@ai-sdk/provider`, so
bumping `ai` alone leaves an install no real upgrade has. `check` now
takes the group `list` already draws (family, peer link, shared pin)
among the installed dependencies and moves each member to the version
that agrees with the target (`check/companions.ts`): the version the
target pins, else the installed one when it already accepts the target,
else its newest release that pins or accepts it, else one whose exact
pins agree. `fix` bumps and installs them in one step and one commit
(the lock guard allows changes inside their subtrees only), and stops
before writing anything when a member has no release that agrees.
check's plan (`↑ upgrades with …`), the fix summary (`With`) and the PR
description name each companion and why. npm and pnpm resolve the exact
version first, so `^4.0.1` keeps the 4.0.1 that ai pins rather than a
second copy at 4.0.24 (found on the end-to-end run below).

Ground-truth entries take `with`: the packages the repository's own
upgrade moved (from its package.json). `pack test` prints what check
moves and fails, and the pack is not verified, when check would leave
one behind. For both repositories check moves exactly the packages the
maintainers moved.

Tests: `check/companions.test.ts` (the case where only `ai` would move
today: `ai` 6 with `@ai-sdk/react`, `@ai-sdk/provider`, `@ai-sdk/openai`
installed → all three move, `zod` doesn't; a member with no agreeing
release is a conflict; a member that already accepts the target stays),
`fix/generic.test.ts` (one install with `also`, both manifests bumped,
commit and PR body; a conflict changes nothing), `text-lock.test.ts`
(several targets: the group may move, `ai` alone may not drag
`@ai-sdk/react`, nothing else may move), `format-check.test.ts` (the
plan line).

## Ground-truth repositories

| Repository | Pinned (before upgrade) | Upgrade commit | ai | Expected
|
| --- | --- | --- | --- | --- |
| vercel/chatbot | 77d362e596e2c624638cad5a35199c0c8785c9fd |
2397c783b505997a09968c4619ec42dc450cc705 (vercel/chatbot#1515) | 6.0.116
→ 7.0.9 | 27 |
| miurla/morphic | 989a05697d973030f2fbb4b805326bb24e68fd0d |
0ec2ca733c8cadb589d741097a2766f67e1766a3 (miurla/morphic#972) | 6.0.180
→ 7.0.66 | 34 |

Expected findings were drafted with `pnpm packs:truth` (the repo's own
TypeScript with ai and the companions its upgrade moved, versions from
its lockfile; plus the upgrade diff) and read by hand. Each entry's
`with` lists the packages its upgrade moved with ai. Excluded: morphic's
`experimental_throttle` (`@ai-sdk/react`), comments, and pure
insertions.

## `uptide pack test` output

The output for zod, stripe and ai, run on this branch after it was
merged with `main`, is in [this
comment](#39 (comment)).
ai:

```
uptide pack test ai · verified
fixtures      6 cases, 19 sites · pass
ground truth
  vercel/chatbot@77d362e596e2                  ai 6.0.116 → 7.0.9  predicted 27, expected 27, false positives 0, false negatives 0
    with @ai-sdk/provider 3.0.3 → 4.0.1, @ai-sdk/react 3.0.118 → 4.0.10
  miurla/morphic@989a05697d97                  ai 6.0.180 → 7.0.66  predicted 20, expected 34, false positives 0, false negatives 14
    with @ai-sdk/anthropic 3.0.77 → 4.0.39, @ai-sdk/gateway 3.0.114 → 4.0.52, @ai-sdk/google 3.0.73 → 4.0.46, @ai-sdk/openai 3.0.63 → 4.0.43, @ai-sdk/openai-compatible 2.0.47 → 3.0.31, @ai-sdk/react 3.0.182 → 4.0.69, ai-sdk-ollama 3.8.4 → 4.2.0
  rule                         precision  recall    tp   fp   fn
  full-stream                       100%    100%    12    0    0
  generic                           100%      0%     0    0    4
  instructions                      100%    100%    12    0    0
  is-step-count                     100%     89%     8    0    1
  on-end                            100%     43%     3    0    4
  on-step-end                       100%      0%     0    0    2
  removed-experimental-option       100%    100%     1    0    0
  telemetry                         100%    100%     3    0    0
  telemetry-metadata                100%    100%     2    0    0
  tool-context                      100%     25%     1    0    3
  total-usage                       100%    100%     2    0    0
  ui-message-stream                 100%    100%     3    0    0
  overall (sites)                   100%     77%    47    0   14
  breaking (sites)                  100%     36%     4    0    7
PASS ai: verified
```

zod and stripe still pass and stay verified, with nothing moving
alongside them (band-sdk's `@modelcontextprotocol/sdk` already accepts
zod 4, so it stays). zod's PATH entry gained 5 sites from the refined
one-site-per-change rule.

Extra end-to-end check: `uptide fix ai --target 7.0.9 --no-llm
--include-deprecated` on a copy of vercel/chatbot applied 26 sites by
rule. The rewritten files match the maintainers' own upgrade byte for
byte (e.g. `artifacts/code/server.ts` → blob `beb7f35`, the same blob as
their commit). Before the group upgrade, verification failed with 46 →
45 errors. It now passes:

```
uptide fix · ai 6.0.116 → 7.0.9 (requested) · verification passed · 2m 20s

  Risk      High: manual sites left
  Changes   27 sites in 6 files · 26 auto-fixed · 0 fixed by the agent (LLM) · 1 manual
  Types     ✅ 1 error after the bump → 0
  Behavior  ⚠️ not checked
  Tests     ⚠️ the repository: the run already failing before the change; nothing else ran · lint clean (biome)
  With      @ai-sdk/provider 3.0.3 → 4.0.1, @ai-sdk/react 3.0.118 → 4.0.10
```

Upgrade commit: `chore: upgrade ai to 7.0.9 with @ai-sdk/provider 4.0.1,
@ai-sdk/react 4.0.10`, with one `@ai-sdk/provider` (4.0.1) in the
lockfile. The PR description opens with:

```
Upgraded with ai, so the install stays consistent:

- `@ai-sdk/provider` 3.0.3 → 4.0.1 (ai 7.0.9 pins @ai-sdk/provider 4.0.1)
- `@ai-sdk/react` 3.0.118 → 4.0.10 (@ai-sdk/react 4.0.10 pins ai 7.0.9)
```

## Where the tooling or docs got in the way, and what this PR does about
it

1. ground truth install: bun repos (miurla/morphic, bun.lock) cannot be
installed; packageManager() knows npm/pnpm/yarn only.
2. contract: a rule could claim a finding only by change kind + symbol
path; a compiler-only finding (TS2353) is claimed by every rule matching
the code, whatever the message names. Added `message` to PackRule.
3. plan: a contract pack's rule without `rewrite` never shows under its
id in check's plan (sites fall back to the compiler code), so pack test
scores them `generic`. Added MigrationPack.ruleOf, implemented by
definePack, used by the plan before the zod/stripe-specific
classification.
4. fixtures: a marker could not carry the compiler message a
compiler-only finding has (rules matching on `message` could not be
fixture-tested). Added `message:"..."` to markers.
5. fixtures: after.ts had to be written by hand with nothing to show
what the rules produce, and a mismatch printed only the first differing
line. Added `pack test --update-fixtures` (writes after.ts from the
rules, reviewed in the diff like a snapshot update).
6. pack test --fixtures-only said "no repository yet: the pack ships as
a candidate" for a pack with two ground-truth repositories. Now says the
repositories were skipped.
7. rewrites by line text matched names inside trailing comments (and
fixture markers are comments): onlyOnLine now edits the code part of the
line, and the `stream` collision check reads declarations from the AST.
8. pack new rendered the registry's imports in an order biome's
organize-imports rejects when the new pack's directory sorts before
contract.ts (`ai` does), so the scaffold failed pnpm lint; the e2e test
used toy-lib, which sorts after. The renderer now sorts every import by
path, and the test scaffolds a name that sorts first.
9. packs:truth linked only the target package: its own dependencies (ai
7 → @ai-sdk/provider-utils 5) resolved to the repository's older copies,
and companions the upgrade moved together (@ai-sdk/react 4) stayed old,
which produced ~60 compiler errors no real upgrade has. It now assembles
the target with its dependencies at the versions it declares, as check
does, and --also links companions at the versions the upgrade commit
moved them to.
10. pack test's breaking recall counted every missed site, deprecated
ones included (ai showed 22% breaking recall, mostly
onFinish/onStepFinish renames that still compile). A miss now counts
toward breaking recall by its rule's severity (generic and notes count
as breaking).
11. check's summary named sites found by detect by an internal path
(`ai:instructions`, `ai:is-step-count`) instead of what the code says. A
detected site can carry the name as written (`system`, `stepCountIs`),
and check shows that.
12. the CLI's fix kept its own list of packs (status.ts SUPPORTED: zod,
stripe): `fix ai --no-llm` refused with "ai has no migration pack"
although the registry has it verified. fix now asks the registry
(activePacks); its --only help names the verified packs from it. The
no-argument overview still lists zod and stripe only (unchanged).
(core fix/isolate.ts had the same list: `['zod',
'stripe'].includes(only)`.)
13. fix upgraded `ai` alone: release groups are one scope (@aws-sdk/*),
so `ai` + `@ai-sdk/*` never formed one, and verification on
vercel/chatbot failed with ~45 errors from the install, not the code.
Fixed here (see "`fix ai` upgrades the whole group"); the pack's
"companion packages" review note is gone.
14. A `^` range bumped to a companion's agreeing version (`^4.0.1`) let
pnpm resolve the newest in range (4.0.24), a second provider copy. npm
already resolved exact-then-range; pnpm now does too.

## Checklist

- [x] Every rule and note comes from a source in `meta.sources`
- [x] Every rule that rewrites or detects has a fixture case, with a
site it must leave alone (`keep`)
- [x] Ground truth: public repositories at the commit before their
upgrade; expected findings from their own upgrade commit and compiler,
never from Uptide's output
- [x] Two public repositories: verified
- [x] `pnpm uptide pack test` passes for ai, stripe and zod on this
branch merged with `main`; `verification.json` written with `--write`
- [x] `pnpm lint && pnpm typecheck && pnpm test` pass (core 874 passed,
15 skipped; CLI 344/344)
- [x] `fix ai` upgrades the group; ground truth records what each real
upgrade moved (`with`)
- [x] Changesets added (`.changeset/ai-pack.md`,
`.changeset/companion-upgrades.md`, minor)
- [x] No private code, names or paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi

---------

Signed-off-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — b84d8ac8 Deployed Jul 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants