@vite-hub/codemods 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,21 +6,31 @@
6
6
 
7
7
  `@vite-hub/codemods` moves an application to ViteHub. Each codemod edits the source files that it can change safely and ends with a report: the files it changed and a numbered list of manual follow-ups, with `file:line` where it applies.
8
8
 
9
- The package requires Node.js 24.15 or newer. Read the [Codemods docs](https://vitehub.dev/docs/codemods) for a tutorial and what each codemod changes.
9
+ The package requires Node.js 22.12 or newer. The migrated app needs Node.js 24.15 or newer for `vite-hub`, and the report says so when the shell runs an older Node.js. Read the [Codemods docs](https://vitehub.dev/docs/codemods) for a tutorial and what each codemod changes.
10
10
 
11
11
  ## Migrate an app
12
12
 
13
13
  ```sh
14
- npx @vite-hub/codemods [dir] [--dry-run]
14
+ npx @vite-hub/codemods [dir] [--dry-run] [--nuxt-nightly]
15
15
  ```
16
16
 
17
17
  The command finds every module in the app that a codemod supports and runs those codemods one after another, so each one sees the edits of the ones before it. `dir` is the application directory. It defaults to the current directory. `--dry-run` prints the combined edits as diffs and the report, and writes nothing.
18
18
 
19
- The report lists, for each codemod, why it ran and what it did, then the files it changed, a numbered list of manual follow-ups with `file:line`, notes, and the commands to run next. A codemod that cannot migrate the app changes nothing and says why; the others still run. The report also warns when `package.json` requires a Nuxt version before 5, directly or through a pnpm `catalog:` in `pnpm-workspace.yaml`, because ViteHub supports Nuxt 5 and Nitro 3 only. The codemods do not upgrade Nuxt or install packages. Nuxt 5 also stops auto-importing Nitro helpers such as `defineEventHandler` in server code. Set `experimental: { nitroAutoImports: true }` to keep them, or import them as the Nuxt 5 build error lists.
19
+ The report lists, for each codemod, why it ran and what it did, then the files it changed, a numbered list of manual follow-ups with `file:line`, notes, and the commands to run next. A codemod that cannot migrate the app changes nothing and says why; the others still run.
20
+
21
+ The codemods that add `vite-hub/nuxt`, such as `nuxt-safe-runtime-config` and `nuxthub`, need Nitro 3, which runs on Nuxt 4.7 with the `nitro` package, or on Nuxt 5. The command reads the `nuxt` range in `package.json`, directly or through a pnpm `catalog:` in `pnpm-workspace.yaml`:
22
+
23
+ - Only Nuxt 5, such as `npm:nuxt-nightly@5x`: no change.
24
+ - Nuxt 4.7 and no earlier version, such as `^4.7.0` or `>=4.7.0 <6`: it adds `"nitro": "^3.0.261103-rc"` to `dependencies` when `package.json` does not list `nitro`, or replaces a `nitro` range outside it, such as `2.2.28`. The report notes the change.
25
+ - A range that allows a version before 4.7, such as `^4.2.0`: it stops before it writes anything, also with `--dry-run`, and exits with `1`. Upgrade with `pnpm add nuxt@^4.7.0 nitro`, or add `--nuxt-nightly` to set `"nuxt": "npm:nuxt-nightly@5x"` in `package.json` and migrate in the same run.
26
+
27
+ Each codemod also adds `vite-hub` and the packages of each ViteHub feature that it turns on to `package.json`, such as `@vite-hub/email` for `resend`, and `@vite-hub/schedule` and `@vite-hub/kv` for `nuxt-cron` on Node. Without them, the build stops with `VITE_HUB_R0136`. Run the install command that the report lists. The codemods do not change the Nuxt version without `--nuxt-nightly`, and do not install packages. Nuxt 5 stops auto-importing Nitro helpers such as `defineEventHandler` in server code. Set `experimental: { nitroAutoImports: true }` to keep them, or import them as the Nuxt 5 build error lists.
28
+
29
+ New feature packages use the app's existing `vite-hub` version, range, or matching ViteHub preview. If the codemod cannot match that dependency, it stops before writing the migration and asks you to update the `vite-hub` entry.
20
30
 
21
31
  The migration uses a unique scratch directory and preserves existing `.vitehub-migrate` directories. If a codemod would edit a symbolic link or a file inside a linked directory, it stops without applying that codemod's edits. Running one codemod does the same. Replace the link with a local file or directory before retrying.
22
32
 
23
- The command exits with `0` when every codemod completes, also when they report follow-ups, and when no codemod applies. A plain Vite or Node app needs no `nuxt.config`. It exits with `1` when a codemod could not migrate, when the folder has neither `package.json` nor `nuxt.config`, or when `nuxt.config` does not parse.
33
+ The command exits with `0` when every codemod completes, also when they report follow-ups, and when no codemod applies. A plain Vite or Node app needs no `nuxt.config`. It exits with `1` when a codemod could not migrate, when a codemod that adds `vite-hub/nuxt` finds a Nuxt version before 4.7 without `--nuxt-nightly`, when the folder has neither `package.json` nor `nuxt.config`, or when `nuxt.config` does not parse.
24
34
 
25
35
  ## Upgrade ViteHub
26
36
 
@@ -28,15 +38,15 @@ The command exits with `0` when every codemod completes, also when they report f
28
38
  vitehub migrate [dir] [--dry-run]
29
39
  ```
30
40
 
31
- `vitehub migrate` runs the upgrade codemods, the ones that move an app from an older ViteHub API, in this order: `vitehub-options`, `define-forms`, `runtime-contracts`, `root-accessors`, `one-entry-imports`, `queue-workflow-verbs`, `queue-durations`, `result-tuples`, `agent-surface`, `driver-key`, `renamed-apis`, `tsconfig-paths`, `shell-driver`, `access-spellings`, `auth-sign-in`, `channels`, `auth-accessors`, `workspace-repo`, `kv-list-prefix`, `cli-url-flag`, `cli-yes-flag`, `cms-roles`, and `choices-package`. Each one sees the edits of the ones before it, and the report is the same as above. Install `@vite-hub/codemods` as a development dependency first. The codemods that move an app from another module, such as `nuxthub`, do not run. The report ends with a reminder to run Vite Doctor: rule `VHUB0003` finds Result calls, such as `await email.send(...)`, whose error the code drops.
41
+ `vitehub migrate` runs the upgrade codemods, the ones that move an app from an older ViteHub API, in this order: `vitehub-options`, `define-forms`, `runtime-contracts`, `root-accessors`, `one-entry-imports`, `queue-workflow-verbs`, `queue-durations`, `result-tuples`, `agent-surface`, `driver-key`, `renamed-apis`, `tsconfig-paths`, `shell-driver`, `access-spellings`, `auth-sign-in`, `channels`, `auth-accessors`, `workspace-repo`, `kv-list-prefix`, `cli-url-flag`, `cli-yes-flag`, `cms-roles`, `choices-package`, `cli-get-list`, `cli-agent-tree`, and `nuxt-server-imports`. Each one sees the edits of the ones before it, and the report is the same as above. Install `@vite-hub/codemods` as a development dependency first. The codemods that move an app from another module, such as `nuxthub`, do not run. The report ends with a reminder to run Vite Doctor: rule `VHUB0003` finds Result calls, such as `await email.send(...)`, whose error the code drops.
32
42
 
33
43
  ## Run one codemod
34
44
 
35
45
  ```sh
36
- npx @vite-hub/codemods nuxt-safe-runtime-config [dir] [--dry-run]
46
+ npx @vite-hub/codemods nuxt-safe-runtime-config [dir] [--dry-run] [--nuxt-nightly]
37
47
  ```
38
48
 
39
- The command runs only the named codemod. Run it with `--help` to list the codemods. It exits with `1` when the codemod cannot migrate, for example when it cannot find or parse `nuxt.config`.
49
+ The command runs only the named codemod. Run it with `--help` to list the codemods. It exits with `1` when the codemod cannot migrate, for example when it cannot find or parse `nuxt.config`. It checks the Nuxt version the same way as the full migration, and `--nuxt-nightly` works the same way.
40
50
 
41
51
  | Codemod | Moves |
42
52
  | --- | --- |
@@ -63,7 +73,7 @@ The command runs only the named codemod. Run it with `--help` to list the codemo
63
73
  | `shell-driver` | The Shell `provider` names to `driver`: `createShellRuntime({ driver })`, `ShellDriver`, and `createJustBashDriver()`. `vitehub migrate` runs it. |
64
74
  | `access-spellings` | Realtime `auth: true` to `authorize: true`, and MCP `public: true` to `access: "public"`. `vitehub migrate` runs it. |
65
75
  | `auth-sign-in` | `vitehub({ auth: { redirects } })` and `access.signIn.callbackURL` to `access: { signIn, afterSignIn }` in `server/auth.ts`. `vitehub migrate` runs it. |
66
- | `channels` | Agent `http()` calls to `channelAdapter("http", options)` where safe, and webhook secrets and signatures to the names of Webhooks. `vitehub migrate` runs it. |
76
+ | `channels` | Imports of `vite-hub/agent/channels` to `vite-hub/channels/adapters` and `vite-hub/channels`, Agent `http()` calls to `channelAdapter("http", options)` where safe, and webhook secrets and signatures to the names of Webhooks. `vitehub migrate` runs it. |
67
77
  | `auth-accessors` | Auth `auth` and `getAuth()` to `useAuth()`, and `isGitHubOrgMember()` to `checkGitHubOrgMember()`. `vitehub migrate` runs it. |
68
78
  | `workspace-repo` | The GitHub Workspace Store option `repository` to `repo`. `vitehub migrate` runs it. |
69
79
  | `kv-list-prefix` | `kv.keys(base)` to `kv.list({ prefix })`, and `kv.clear(base)` to `kv.clear({ prefix })`. `vitehub migrate` runs it. |
@@ -71,6 +81,9 @@ The command runs only the named codemod. Run it with `--help` to list the codemo
71
81
  | `cli-url-flag` | `vitehub` calls in scripts and CI: `--server` to `--url`, the app URL. `vitehub migrate` runs it. |
72
82
  | `cms-roles` | The `cms` preset option `access: "roles"` to `roles: true`. `vitehub migrate` runs it. |
73
83
  | `choices-package` | `@vite-hub/decisions` and `vite-hub/decisions` imports and the `vitehub decisions` command to `choices`. `vitehub migrate` runs it. |
84
+ | `cli-get-list` | `vitehub` read commands in scripts and CI: `show` and `info` to `get`, `env inspect` and `env status` to `env list`, `schedule runs` to `runs list`. `vitehub migrate` runs it. |
85
+ | `cli-agent-tree` | `vitehub` Agent calls in scripts and CI: `agents …`, `invocations …`, and `conversations export` move under `vitehub agent`. `vitehub migrate` runs it. |
86
+ | `nuxt-server-imports` | ViteHub server helpers, such as `kv` and `sendQueue`, that Nuxt server files used as auto-imports, to explicit imports from `vite-hub/*`. `vitehub migrate` runs it last. |
74
87
 
75
88
  ## `runtime-contracts`
76
89
 
@@ -225,13 +238,14 @@ npx @vite-hub/codemods queue-durations [dir] [--dry-run]
225
238
 
226
239
  ## `nuxthub`
227
240
 
228
- The codemod runs when `package.json` or `modules` lists `@nuxthub/core`, or when `nuxt.config` sets `hub`. It follows [Migrate from NuxtHub](https://vitehub.dev/docs/getting-started/migrate-from-nuxthub) and makes only the edits that keep the same behavior:
241
+ The codemod runs when `package.json` or `modules` lists `@nuxthub/core`, or when `nuxt.config` sets `hub`. It follows [Migrate from NuxtHub](https://vitehub.dev/docs/compare/nuxthub#migrate-from-nuxthub) and makes only the edits that keep the same behavior:
229
242
 
230
243
  - `nuxt.config`: `'@nuxthub/core'` becomes `'vite-hub/nuxt'`, and `hub` becomes `vitehub` in place. `db: 'sqlite'` becomes `database: true`, and `kv`, `blob`, and `cache` stay `true`. The host comes from `nitro.preset`, then `cloudflare` when the app has a Wrangler config, then `node`. Driver options and other `hub` keys become follow-ups. MySQL stops the codemod, because ViteHub does not support it.
231
244
  - `package.json`: removes `@nuxthub/core` and adds `vite-hub`. With a database, it adds `@vite-hub/database` and brings `drizzle-orm` and `drizzle-kit` to at least `^1.0.0-rc.5`, the lowest version that `@vite-hub/database` accepts.
232
245
  - Schema: moves `server/db/schema.ts`, `server/db/schema.<dialect>.ts`, or the `server/db/schema/` folder to `server/databases/default/`, and writes `server/databases/default/index.ts` with `defineDatabase({ schema })`. Like NuxtHub, it reads only the top-level files of the folder, and skips files for another dialect, such as `users.sqlite.ts` in a Postgres app. Static, dynamic, CommonJS, and type imports follow the moved files. An aggregate exports every schema file, including an existing index; the report asks you to check conflicting exports. Legacy `relations()` declarations and each `db.query` use become follow-ups: rewrite them with Drizzle 1.0's `defineRelations()`, pass them to the Database Definition, and update relational filters before running the app. A query with a `where` function gets its own follow-up, because Drizzle 1.0 reads `where` as an object.
233
246
  - Database options: for Postgres, the Definition reads `POSTGRES_URL`, then `POSTGRESQL_URL`, then `DATABASE_URL`, as NuxtHub did. `connection.hyperdriveId` becomes `cloudflare.hyperdriveId`. `driver: 'd1-http'` becomes `cloudflare: { databaseId, http: true }`, and the report lists the `NUXT_HUB_CLOUDFLARE_*` variables to rename. `casing` becomes a follow-up, because Drizzle 1.0 sets casing per table. Schema files in local layers (`layers/*` and relative `extends`) become follow-ups too.
234
247
  - Imports: `hub:db` and `@nuxthub/db` become `vite-hub/database`, which exports `db` and `schema`. `hub:kv` and `hub:blob` become `vite-hub/kv` and `vite-hub/blob`. `hub:db:schema` becomes a relative import of the moved schema.
248
+ - Auto-imports: NuxtHub auto-imported `kv`, `blob`, `db`, and `schema` in server code, and Nuxt 5 does not. Each server file that uses one of them without an import gets an import from `vite-hub/*`. A name that the app gives from `server/utils/` stays as it is.
235
249
  - KV and Blob calls: tuple-returning methods such as `const x = await kv.get(k)` and `await blob.del(p)` get a tuple and `if (error) throw error`, also for returns in async functions. `blob.delete()` becomes `blob.del()`. `blob.serve()` returns a Response unchanged; in an H3 handler the event argument becomes `event.req`. An unknown event or an unsupported use of a tuple becomes a follow-up with `file:line`.
236
250
  - Wrangler config: the D1 `migrations_table: "_hub_migrations"` goes, because ViteHub must not reuse it. On Cloudflare, KV, cache, and Blob options keep the resource that matches the original binding or its `KV`, `CACHE`, or `BLOB` default. R2 options keep the bucket's jurisdiction too. Unrelated bindings stay in place. The report lists the matched entries to remove after checking the generated options, and the D1 options to set by hand.
237
251
  - Modules that expect NuxtHub: ViteHub does not emulate NuxtHub's module APIs, so the codemod reports them as follow-ups and changes nothing. It finds the `hub:db:schema:extend`, `hub:db:migrations:dirs`, and `hub:db:queries:paths` hooks in `nuxt.config`, in the `modules/` folder, and in local layers (`layers/*` and relative `extends` paths), and points to `vitehub.databases` contributions or a custom migration. It also reports `studio.media.external` of nuxt-studio, and each installed dependency whose `package.json` lists `@nuxthub/core` in `peerDependencies` or `dependencies`, such as `@evlog/nuxthub`.
@@ -243,7 +257,7 @@ The codemod does not move local data or baseline the database. The follow-ups li
243
257
  The codemod reads one of the two schema sources of the module:
244
258
 
245
259
  - `safeRuntimeConfig.envSchema` points at a `.env.example` with `@env-spec` annotations. The codemod replaces it with `envSchema(new URL("./.env.example", import.meta.url), { prefix: "NUXT_" })` from `@vite-hub/env/vite`. With the `NUXT_` prefix, `NUXT_PUBLIC_*` keys become Public Env and other `NUXT_*` keys become Server Env, with the same names and variables. Server `paths` stay the same. Public Env is flat, so a nested public path falls back to its flat name.
246
- - `safeRuntimeConfig.$schema` is a Valibot, Zod 3, Zod 4, or ArkType schema, inline or in a module. For Zod 4 before 4.2, the codemod calls `toJSONSchema()` from the app's own Zod. The codemod converts it to JSON Schema and writes `env()`, `env.number()`, `env.boolean()`, and `env.enum()` declarations under `vitehub.env`. Each declaration reads its `NUXT_*` variable with `env.source()`. A `process.env.NAME || fallback` value reads `NAME` with `env.source()` and keeps `fallback` as the default. Env treats an empty variable as unset, as `||` did. Literal `runtimeConfig` values, including empty strings, become defaults, and keys under `runtimeConfig.public` become Public Env with `mode: "build"`. Credential-like server names become `secret: true`.
260
+ - `safeRuntimeConfig.$schema` is a Valibot, Zod 3, Zod 4, or ArkType schema, inline or in a module. For Zod 4 before 4.2, the codemod calls `toJSONSchema()` from the app's own Zod. The codemod converts it to JSON Schema and writes `env()`, `env.number()`, `env.boolean()`, and `env.enum()` declarations under `vitehub.env`. Each declaration reads its `NUXT_*` variable with `env.source()`. A `process.env.NAME || fallback` value reads `NAME` with `env.source()` and keeps `fallback` as the default. Env treats an empty variable as unset, as `||` did. Literal `runtimeConfig` values, including empty strings, become defaults. The codemod checks each default against its field schema, applying the source module’s input coercion for runtime validation. A rejected value, such as `""` for `v.minLength(16)`, is dropped when validation is fatal, so Env requires its variable. Nonfatal `onError` modes do not drop a default solely because validation rejects it. The checks follow the installed module version. Before 0.4.0, the module checked only at build unless `validateAtRuntime: true`. From 0.4.0, it also checks when the server starts unless `validateAtRuntime: false`, so `validateAtBuild: false` alone still rejects. When the codemod cannot read the version, it uses the 0.4.0 rules. Keys under `runtimeConfig.public` become Public Env with `mode: "build"`. Credential-like server names become `secret: true`.
247
261
 
248
262
  When `safeRuntimeConfig` declares neither and the app has no layers, the module validates nothing, so the codemod removes it from `modules`, `nuxt.config`, and `package.json`. It stops instead when code still calls `useSafeRuntimeConfig()`. Schema-free removal also stops when the config extends layers, uses a root spread, or has automatic `layers/` directories: inherited schemas and composable calls are unknown. Review those layers and remove the module by hand, or declare the schema in the app config before retrying.
249
263
 
@@ -447,9 +461,31 @@ npx @vite-hub/codemods auth-sign-in [dir] [--dry-run]
447
461
 
448
462
  ## `channels`
449
463
 
450
- `http()` is removed. Use `webhook()` from `vite-hub/channels` for an HTTP sender. Use `channelAdapter("http", options)` from `vite-hub/agent/channels` to keep the Channel kind and State.
464
+ `vite-hub/agent/channels` is removed, and so is `http()`:
465
+
466
+ | Old | New |
467
+ | --- | --- |
468
+ | `import { slack, webChat } from "vite-hub/agent/channels"` | `import { slack, webChat } from "vite-hub/channels/adapters"` |
469
+ | `import { defineChannelTrigger, ignored } from "vite-hub/agent/channels"` | `import { defineChannelTrigger, ignored } from "vite-hub/channels"` |
470
+ | `import { webhook } from "vite-hub/channels"` | `import { webhook } from "vite-hub/channels/adapters"` |
471
+ | `http(options)` | `channelAdapter("http", options)` |
472
+
473
+ `vite-hub/channels` has `defineChannel()`, `defineChannelTrigger()`, `ignored()`, `retryLater()`, and `rejected()`, and needs no `@vite-hub/agent`. Every adapter, also `webhook()` and `stripe()`, comes from `vite-hub/channels/adapters`. A namespace import, a re-export, an `import()` call, and a `vi.mock()` path move to `vite-hub/channels/adapters`, and the report lists each mock. The owner path `@vite-hub/agent/channels` stays.
474
+
475
+ The codemod rewrites `http()` calls without options or with a literal Boolean `route` option. The report flags references, typed or complex calls, namespace imports, dynamic loads, re-exports of `http`, and mocks for manual review. To preserve the kind on a typed route, use `channelAdapter("http", options)` and type callback parameters explicitly. Use `webChat()` only if changing the kind is acceptable.
476
+
477
+ It also moves webhook secrets and signatures to the names of Webhooks:
478
+
479
+ | Old | New |
480
+ | --- | --- |
481
+ | `secretToken: process.env.X` in a `webhooks` registration | `secret: "X"` |
482
+ | `secretToken: () => …` in a `webhooks` registration | `secret: () => …` |
483
+ | `secret: process.env.X` in `webhook()` or `stripe()` | `secret: "X"` |
484
+ | `signature: "github-sha256"` or `"stripe-sha256"` | `signature: "github"` or `"stripe"` |
485
+ | `signature: { preset: "hmac-sha256", … }` | `signature: { type: "hmac-sha256", … }` |
486
+ | `{ preset: "stripe-sha256", toleranceSeconds: 600 }`, `stripe({ toleranceSeconds: 600 })` | `{ type: "stripe", tolerance: "600s" }`, `stripe({ tolerance: "600s" })` |
451
487
 
452
- The codemod rewrites direct calls without options or with a literal Boolean `route` option. Import paths stay the same. The report flags references, typed or complex calls, namespace imports, dynamic loads, re-exports of `http`, and mocks for manual review. To preserve the kind on a typed route, use `channelAdapter("http", options)` and type callback parameters explicitly. Use `webChat()` only if changing the kind is acceptable.
488
+ A string `secret` is the name of the server variable that holds the secret, in `webhook()`, `stripe()`, and every `webhooks` registration of `channelAdapter()`, `defineChannelTrigger()`, and the chat adapters. A direct read like `useServerEnv().github.webhookSecret` moves into a function. Existing resolvers stay intact. The report lists expressions the codemod cannot classify, `secretToken` strings, and possible hard-coded secrets on `stripe()` or with an old signature. Move hard-coded secrets to server variables and set `secret` to the variable name.
453
489
 
454
490
  It also moves webhook secrets and signatures to the names of Webhooks:
455
491
 
@@ -490,8 +526,72 @@ npx @vite-hub/codemods auth-accessors [dir] [--dry-run]
490
526
 
491
527
  ```sh
492
528
  npx @vite-hub/codemods cli-url-flag [dir] [--dry-run]
529
+ ## `cli-get-list`
530
+
531
+ `get` reads one record and `list` reads many. The codemod renames the `vitehub` calls in `package.json` scripts, `.github/workflows/*.yml`, and `*.sh` files:
532
+
533
+ | Old | New |
534
+ | --- | --- |
535
+ | `vitehub agent info` | `vitehub agent get` |
536
+ | `vitehub agent invocations show` | `vitehub agent invocations get` |
537
+ | `vitehub content show`, `vitehub workspace show` | `get` |
538
+ | `vitehub email outbox show`, `vitehub queue jobs show` | `outbox get`, `jobs get` |
539
+ | `vitehub workflow get` | `vitehub workflow runs get --json` |
540
+ | `vitehub workflow runs show` | `vitehub workflow runs get` (use `--run-id` for `--id`) |
541
+ | `vitehub schedule runs <schedule>` | `vitehub schedule runs list <schedule>` |
542
+ | `vitehub schedule attempts <run>` | `vitehub schedule runs get <run>` |
543
+ | `vitehub env inspect` | `vitehub env list` |
544
+ | `vitehub env status --url <app>` | `vitehub env list --url <app> --json` |
545
+ | `vitehub project info` | `vitehub project get` |
546
+ | `vitehub definitions list` | `vitehub inspect definitions --kind <kind>` for local definitions; use the Console for runtime records |
547
+
548
+ The codemod updates simple shell invocations. It skips scripts and steps with complex shell syntax, such as command substitutions or parameter defaults, to avoid editing text that is not a command. It reports recognized calls that need a manual change. `env status` without `--url` asked the dev server; pass that URL explicitly rather than reading the local stage. Review old `env status` calls using `--timeout` or `--input`, which `env list` does not accept. For `workflow runs show --input`, rename `id` to `runId` in the JSON. Review `definitions list` calls to choose between local inspection and the Console.
549
+
550
+ ```sh
551
+ npx @vite-hub/codemods cli-get-list [dir] [--dry-run]
552
+ ```
553
+
554
+ ## `cli-agent-tree`
555
+
556
+ Every Agent command is under `vitehub agent`. The codemod moves the `vitehub` calls in `package.json` scripts, `.github/workflows/*.yml`, and `*.sh` files:
557
+
558
+ | Old | New |
559
+ | --- | --- |
560
+ | `vitehub agents list`, `vitehub agents invoke <agent>` | `vitehub agent list`, `vitehub agent invoke <agent>` |
561
+ | `vitehub agents status --agent <name>`, `vitehub agent get --agent <name>` | `vitehub agent get <name>` |
562
+ | `vitehub invocations list\|get\|cancel\|undo\|delete\|capabilities\|workspace` | `vitehub agent invocations …` |
563
+ | `vitehub conversations export` | `vitehub agent conversations export` |
564
+
565
+ The codemod leaves old Console deletes untouched. Migrate them by hand to `vitehub agent invocations delete <id> --url <app>` with the same app, and use `--yes` in scripts. Without `--url` the new command deletes from the journal file.
566
+
567
+ Migrate old `invocations list` and `get` calls by hand. Check the new command's `--help` for supported inputs. The CLI list output no longer includes the Console cursor, and get emits a flat record with `--json` and does not accept observation paging options. The Console RPC still supports the old contracts. For Agent inspection, `--url` selects the Console unless you add `--dev` to select the Dev Loop.
568
+
569
+ ```sh
570
+ npx @vite-hub/codemods cli-agent-tree [dir] [--dry-run]
493
571
  ```
494
572
 
573
+ ## `nuxt-server-imports`
574
+
575
+ On Nuxt 5, `vite-hub/nuxt` auto-imports its server helpers only when the app sets `experimental.nitroAutoImports: true` or `nitroLegacy`. This codemod adds an explicit import to each Nuxt server file that uses a helper without one:
576
+
577
+ ```diff [server/api/welcome.post.ts]
578
+ import { defineEventHandler, readBody } from "nitro/h3"
579
+ +import { kv } from "vite-hub/kv"
580
+ +import { sendQueue } from "vite-hub/queue"
581
+
582
+ export default defineEventHandler(async (event) => {
583
+ const { email } = await readBody<{ email: string }>(event)
584
+ const [error] = await sendQueue("welcome", { email })
585
+ ```
586
+
587
+ - It reads the server directory (`serverDir`) of the app and of each local layer, and the helper list of `vite-hub/nuxt`.
588
+ - It joins a name with an existing value import of the same `vite-hub/*` entry. It leaves a name that the file declares or imports.
589
+ - It preserves app-owned server auto-imports, including utility re-exports and names set in `nitro.imports`. The report lists the preserved names.
590
+ - It leaves files alone when Nuxt still injects the ViteHub helpers. If it cannot resolve the effective config or an auto-import source statically, it reports what to check instead of guessing.
591
+ - The report names the files that still use Nitro and H3 helpers, such as `defineEventHandler`, without an import. The Nuxt 5 build error lists their import paths.
592
+
593
+ `vitehub migrate` runs it last, so it imports the names that the other codemods write, such as `useAuth` and `sendQueue`.
594
+
495
595
  ## Check real apps
496
596
 
497
597
  `test/real-world/projects.json` pins open source Nuxt apps that use the supported modules. The runner clones each app outside the repository, installs it when its codemod loads app code, runs the migration, and checks which codemods ran and what the report says: