# Package codemod catalog One section per codemod registered in `packages/worker/src/package-codemods/registry.ts`: what it rewrites, what it leaves alone, and what it reports as `needsManual`. The contract, engine, and rollout rules live in [Package codemods](./package-codemods.md). ## Codemods ### `0001-ambient-storage-to-package-storage` This permanent repair codemod converts ambient `storage` imports rejected by package publish checks to `packageStorage()` **at call sites**: - Rewrites member uses (`storage.get(...)` → `packageStorage().get(...)`) via AST range replacement; it does **not** insert a module-scope `const storage = packageStorage()` binding. - Adjusts the `kody:runtime` import: rename `storage` → `packageStorage`, or drop the `storage` specifier when `packageStorage` is already imported. - Emits `needsManual` for aliased imports, non-member uses (value-passing), re-exports, multiple runtime imports, binding sites, and post-rewrite verification failures. - Emits `needsManual` for **parse failures** on scannable module files that mention `kody:runtime` and `storage`. - **Manifest gate:** when `package.json#kody` declares any non-empty `app`, `jobs`, `subscriptions`, or `webhooks` surface, every ambient-storage candidate file gets `needsManual` — ambient `storage` and `packageStorage()` use different bucket identities on those execution surfaces, so automatic rewrite risks silent data repointing. ### `0002-static-first-invocation` This permanent repair codemod brings package source into the static-first two-rule contract enforced at publish time (see [`architecture/invocation-overhead-guardrails.md`](./architecture/invocation-overhead-guardrails.md)): - Rewrites `packages.invokeChecked(...)` member calls (including `packages?.invokeChecked`) to `packages.invoke(...)` via AST range replacement, then composes the `0006-invoke-object-to-specifier` repair over those files so safe object inputs become scoped string-first calls in the same run. - Emits `needsManual` when that second-stage object repair cannot safely derive the owner/target. That second stage is all-or-nothing: any manual finding restores the original tree and returns `changed: false`, forcing the engine's `needs_manual` stop instead of applying a partial rewrite to removed API. - Emits `needsManual` for `packages.check(...)` (its contract return value has no mechanical equivalent — `invoke` checks internally) and for literal dynamic `import("kody:@...")` (namespace semantics and `kody.dependencies` manifest changes need a human), naming the replacement in each finding. - Emits `needsManual` for parse failures on scannable module files that reference unsupported forms, and verifies post-rewrite that no detectable `packages.invokeChecked` member expressions remain. - Detection reuses the publish-check collector (`package-runtime/deprecated-invocation-usage.ts`), so parsed `detect` findings and failing publish lint results stay in lockstep. Unparseable files produce codemod-only `needsManual` findings because publish lint cannot classify them. ### `0006-invoke-object-to-specifier` This permanent repair codemod converts the publish-blocked object-only dynamic package API to an explicit owner-scoped specifier: - Rewrites `packages.invoke({ kodyId: "target", exportName, params, idempotencyKey, topic })` to `packages.invoke("kody:@owner/target", { exportName, params, idempotencyKey, topic })`. The owner scope comes from the invoking package's `package.json.name`, which preserves the old API's caller-owned lookup. - Handles direct and optional `packages?.invoke` calls and preserves option expressions and keyless/exactly-once behavior. - Rewrites complete examples in JavaScript/TypeScript Markdown fences and inline code spans. Untyped/unsupported fences, partial snippets, and matching prose remain unchanged with `needsManual`. - Leaves already string-first calls unchanged and is idempotent. - Emits `needsManual` for immutable `packageId` targets, dynamic or indirect input objects, calls without `exportName`, computed properties, spreads, comments in the removed field, parse failures, and manifests without a valid scoped package name. - Emits file-level `needsManual` findings when the `package.json` scope is not the package's org: the old bare-id lookup resolved in the package's org, so rewriting to a different manifest scope would retarget the call. - Remains registered because publish checks permanently reject object-only `packages.invoke` in JavaScript and TypeScript. Authors and operators can use this codemod as the mechanical repair path for source that predates or bypasses those checks. ### `0007-prefix-packages-invoke-specifiers` This permanent migration codemod moves string-first dynamic invocation to the preferred explicit scheme: - Rewrites literal `packages.invoke("@owner/package[/export]", options)` calls to `packages.invoke("kody:@owner/package[/export]", options)`. - Rewrites parseable non-object dynamic first arguments (identifiers, member and helper-call expressions, conditionals, and interpolated templates) through a marked inline normalizer. The original expression is passed into the IIFE and therefore evaluated exactly once. At runtime the normalizer trims strings only to detect a leading `@`, prefixes that trimmed prefixless value, and passes already-prefixed strings, other strings, and non-strings through unchanged so the existing runtime parser still canonicalizes or rejects them. - Preserves the complete options argument byte-for-byte, including `exportName`, so an export subpath keeps its existing precedence. - Handles JavaScript and TypeScript modules plus parseable JS/TS fenced and inline examples in Markdown and MDX. TypeScript uses a return assertion on the generated normalizer; JavaScript and untyped inline examples use a JSDoc expression assertion, so generated JavaScript contains no TypeScript syntax. - Leaves already-prefixed calls and marked generated normalizers unchanged and is deterministic and idempotent. - Emits fixed, privacy-safe `needsManual` messages for ambiguous bindings, spread/missing arguments, genuinely call-shaped examples outside parseable JS/TS Markdown ranges, and parse failures. Unparseable source has no textual rewrite fallback: without an AST, the codemod cannot prove either binding or argument boundaries safely. Markdown prose that merely names `packages.invoke` without a following call is ignored. Messages never interpolate a specifier, package, export, parameter, or source value. - Leaves object-only calls unchanged. Their migration remains the permanent `0006-invoke-object-to-specifier` codemod's responsibility. Prefixless calls remain publishable during this measurement phase; 0007 is a migration aid, not a publish-rejection rule. ### `0008-packages-invoke-to-static-import` This permanent migration codemod removes author-facing `packages.invoke` (decision 0037): - Rewrites literal `packages.invoke("kody:@owner/package/export", { params })` calls to a static `import export from "kody:@owner/package/export"` plus `export(params)`, and adds the package name to `package.json#kody.dependencies` when the rewrite is in a JS/TS module. Repo checks only count those static imports, so Markdown examples are rewritten without declaring unused dependencies. - Rewrites computed first arguments to `(await import(specifier)).default(...)`. That is the name-as-data path; do not use this rewrite when the name is known at write time. - Handles JavaScript and TypeScript modules plus parseable JS/TS fenced and inline examples in Markdown and MDX. - Emits `needsManual` for keyed invokes (`idempotencyKey` — use workflows), ambiguous options, and leftover prose that still names `packages.invoke`. - Leaves already-migrated static imports unchanged and is idempotent. Fleet scan `803e3045` found zero executable-source findings, drift, or errors. Its three remaining findings are private README-only documentation debt: those files cannot execute and therefore do not block later runtime/type prefix removal once the telemetry gate passes. Keep the debt tracked as an aggregate owner-action count without publishing private package ids or owners. Codemod 0007 and the local prefixless teaching error remain the repair path for those documents. ### `0010-detect-legacy-credential-patterns` This detect-only codemod lists credential placeholder patterns in package source and the root `package.json` (see [Credential slots](../use/packages.md#credential-slots-kodycredentials)). `transform` writes nothing; dry-run and apply return the findings as `needs_manual`. Run it with `adminPackageCodemodScan`. It scans JavaScript and TypeScript modules and the root `package.json`. Each finding message starts with one fixed pattern label: | Label | Matches | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `literal secret` | A complete legacy placeholder (secret, two-name Basic secret, vault provider, or integration token), or a known string passed to `createAuthenticatedFetch`, `packageSecrets.get`, `secretHeaders.basic`, or similar helpers, unless it names a declared slot of its kind | | `computed secret` | A secret placeholder built at runtime, or a secret helper called with a runtime name | | `computed integration` | `createAuthenticatedFetch`, `integrationTokenRefresh`, or a legacy integration-token placeholder with a runtime name | | `kody.mcp` | Any `kody.mcp` access, including `const { mcp } = kody` | | `\|scope=` | A `\|scope=package` or `\|scope=session` placeholder suffix, a computed scope, or a `scope` option other than `'user'` on a secret helper (`\|scope=user` is the caller's own secret) | | `secretMounts` | `package.json#kody.secretMounts`. Detected, and a manifest-only declaration is a non-failing compat finding: keep mounts stale static dependents still read (`static_dependents`) and delete a mount only once none do. `packageSecrets.get` in new source still fails the publish gate. | | `webhook secretName` | `verification.secretName` or `challenge.prove.secretName` on a `kody.webhooks` entry | | `plain http` | A `fetch` or `new Request` of an `http://` URL in a module that uses placeholders | | `packageSecrets.get` | Any `packageSecrets.get` or `kody.packageSecretGet` call | A reference that names a declared `kody.credentials` slot of its kind is not a finding. A secret name needs a `secret` slot: a legacy secret placeholder, either name of a two-name Basic placeholder, `packageSecrets.get`, and the secret helper fields. An integration name needs an `oauth` slot: a legacy integration-token placeholder, `createAuthenticatedFetch`, and `integrationTokenRefresh`. A vault reference names no slot, so it stays a finding. A known string is a literal, a top-level `const` string (including one imported from a relative module), or a template or `+` chain of those. A local binding that shadows a module constant is not treated as that constant. Placeholder-shaped text that names nothing (an angle-bracket marker such as `` in help or redaction text) is ignored. Test files (`*.test.*`, `*.spec.*`, and anything under `__tests__/`) are skipped unless a runtime entry points at them: `exports` (import/default, not types-only), `main` / `module` / `browser`, `kody.app` entries, job entries, subscription handlers, or a module those entries reach through a bundler-resolved import (`import` / `export … from`, `import()`, `require()`). Helpers are matched by name, comments are ignored, and an unparseable module falls back to a text match. The publish stamp gate reports `non_literal` for an unparseable server-runtime `.js`, `.mjs`, or `.cjs` module even if it has no credential mentions. For other extensions it reports this error when the module mentions `credential`, `credentials`, or `kody`. Rename JavaScript files that use TypeScript syntax to `.ts` or `.tsx`, or remove the TypeScript syntax. The [scan parser](../../packages/worker/src/module-source.ts) uses the compact JavaScript parser for these three JavaScript extensions and Babel for typed modules. An unsuffixed legacy secret placeholder still reads a package-scoped secret before the user one, and no static scan can see that, so `|scope=` findings undercount package-scoped buckets. Count those with the read-only `adminPackageScopedSecretReport` (live package-scope secrets by org and package) next to the 0010 fleet report. Publish seals literal credential uses into a credential stamp (issue #3836) and **fails the build** on non-literal or unstampable patterns. This module yields a publish gate failure for `index.ts` (computed integration/secret names and `|scope=`). Literal `kody.mcp.linear` is reported by this codemod as `kody.mcp` and is stampable once a `kind: "mcp"` slot is declared; dynamic `kody.mcp[variable]` in a scanned module fails the stamp gate. The [stamp scanner](../../packages/worker/src/credentials/credential-stamp.ts) skips unreferenced static assets. It also omits modules over 256 KiB under the assets directory, the app client directory (if it contains no server modules), or a build output directory (`dist`, `build`, `out`, `.output`) when no server runtime root reaches them. Larger trees are walked in throwaway isolates, and the cloud keeps each module's result (keyed by its content and `credentialScanCacheVersion`) so the next check walks only what changed. Server modules are walked whatever their size: Legacy source of this shape. These docs no longer show placeholder strings, so the sketch uses made-up helpers (`legacySecretRef`, `legacyPackageSecretRef`) where real source holds the placeholder string itself; the scan reports the string, not these helpers: ```ts import { createAuthenticatedFetch, kody } from 'kody:runtime' export default async function digest(input: { account: string; key: string }) { const google = await createAuthenticatedFetch(input.account) await kody.mcp.linear.list_issues({}) return fetch('https://api.example.com', { headers: { // legacy placeholder built from input.key 'x-api-key': legacySecretRef(input.key), // legacy placeholder with a package scope suffix authorization: `Bearer ${legacyPackageSecretRef('EXAMPLE_TOKEN')}`, }, }).then(() => google('https://www.googleapis.com/calendar/v3/users/me')) } ``` Publish error (credentials check `ok: false`): the package must be **conversion-ready**. Declare every credential as a `kody.credentials` slot with a real description, use literal keys (`credential("SLOT")` / `createAuthenticatedFetch("SLOT")` / a legacy placeholder naming `SLOT`) or names built at run time that match a declared slot, and remove `|scope=package` / `|scope=session`, `packageSecrets.get`, vault placeholders, server `eval` / `new Function` / `Function(...)` (except the exact `Function("return this")()` lookup) / non-literal `import()`, and computed `credential()` keys. A secret or integration name built at run time (from an `account` or `secretName` parameter, for example) passes when hand-written slots cover it. The check traces the name with the [0013 name tracer](#computed-credential-names) and requires each literal it can be to match a slot key, and each `-` convention to match a `prefix: true` slot keyed ``. Each slot must have a description, no kind or the kind the name fills (`secret` / `oauth`), and `prefix` only as `true`. A name a caller passes in (`secretName: "otherKey"`) is checked when the package uses it: an undeclared name is refused at run time. For the example above, these slots pass (the `|scope=package` placeholder still fails): ```json "kody": { "credentials": { "exampleApiKey": { "description": "Example API key; account \"work\" uses exampleApiKey-work.", "prefix": true }, "google": { "description": "Google OAuth; google- for more accounts.", "prefix": true } } } ``` A manifest that still declares `kody.secretMounts`, with no `packageSecrets.get` in the new source, does not fail the gate: the check stays `ok: true` and notes the aliases kept for stale static dependents. Removing a mount or deleting its secret breaks those dependents; publish warnings name them. Callers pick which saved credential fills each slot with the execute `credentials` call map (`{ "SLOT": "credential-name" }` or CLI `--credential SLOT=name`) or a stored/trigger mapping — never choose the credential name at runtime inside package code. Literal `kody.mcp.SERVER` names are stamped as `kind: "mcp"` slots; dynamic `kody.mcp[variable]` fails the stamp gate. The `kody.mcp` 0010 label lists every `kody.mcp` access, including literals the stamp gate accepts. `credential.named()` stays limited to ad hoc runs and unshared personal-org packages (not stamped). Save each scan step result as its own JSON file, then print the report over all of them: ```bash node tools/credential-pattern-report.ts .tmp/scan/ ``` It takes any number of files or directories. A directory reads its `.json` files in natural order (`step-2.json` before `step-10.json`). When a package appears more than once, the last item read wins. It counts packages and files per pattern, per org, and per package, plus `skipped_unpublished` and `skipped_drift`. The org and package tables name private packages. Keep them out of public issues; public issues get the pattern counts only. ### `0011-owner-scope-follows-registry` This codemod runs after an [org resource transfer](./org-resource-transfer.md). The transfer moves each package to the new org, but package sources still name the old scope. The engine builds `context.packageName` from the owning org's package scope and the package leaf, not from `saved_packages.name` (that column mirrors the published `package.json`, so a revert or projection refresh puts the old scope back). When the scope of the `package.json` `name` differs from the owner scope, the codemod replaces every `@/` with `@/` in every file. That covers the manifest name, `kody.dependencies` keys, `kody:@oldScope/...` imports, and docs. - A match must be followed by `/`, so `@oldScopeish/x`, a bare `@oldScope` handle, and email addresses are left alone. It shares `rewriteScopedReferences` with the community fork self-reference rewrite. - Every package in the old scope moved together, so references to sibling packages are rewritten too. - Packages whose scope already matches, unscoped names, and unparseable or missing manifests are clean. The codemod is idempotent. Once the transfer has committed, run `adminPackageCodemodDryRun`, then `adminPackageCodemodApply`, with `userIds` set to the new org id. `adminPackageCodemodRevert` undoes it like any other codemod. A revert puts the old scope back in the sources, so the next scan detects the package again. Reverting a package whose `kody:@oldScope/...` dependencies no longer exist under the old scope fails the publish checks and leaves the package applied. Re-applying after a revert can report `dry_run_new_failures` for a package whose sibling dependency is still registered under the old scope. Run apply again once the sibling is applied. ### `0012-explicit-webhook-url-secret-verification` Detect-only. Lists `package.json#kody.webhooks` entries that declare no `verification`. Omitting `verification` is a supported, permanent state: ingress treats it as `url-secret` and publish accepts it (see [Senders that cannot sign](../use/webhooks.md#senders-that-cannot-sign-url-secret)). Findings are a recommendation for owners to declare a type, not a migration. - `transform` never changes files, so dry-run and apply report `needs_manual` with the same finding and never republish a package. - Packages without `kody.webhooks`, or whose webhooks all declare `verification`, are clean. - Emits a manual-review finding for missing or invalid `package.json`, a `kody.webhooks` that is not an array of objects, and a `verification` that is not an object. - An earlier version rewrote manifests to add `"verification": { "type": "url-secret" }` (same behavior at ingress) through the published-only lane. It keeps `applyMode: 'published-only'` so `adminPackageCodemodRevert` of those runs takes the same lane. ### `0013-declare-credential-needs` This codemod adds missing fetch-gateway credential slots to `kody.credentials` and reports cases that need owner review. It supports credential-need enforcement ([#3822](https://github.com/kody-hq/kody/issues/3822)). See [computed names](#computed-credential-names) or [manual findings and runs](#manual-findings-and-runs). #### Literal names The [declaration codemod](../../packages/worker/src/package-codemods/codemods/0013-declare-credential-needs.ts) adds a `kody.credentials` slot for each name the package fills through the fetch gateway by a literal name and does not declare yet: legacy secret and integration-token placeholders, `createAuthenticatedFetch('NAME')`, and the secret fields of `secretHeaders.basic` and `oauthClientCredentials`. Names are resolved through module and imported constants, as in `0010`. A name that `kody.secretMounts` also mounts still gets a slot, because the stored needs closure reads only `kody.credentials`. #### Computed credential names Codemod `0013` traces names built at run time, declares the literal names and prefixes it finds, and flags names it still considers unbounded. It traces names through the package's own source (variables, parameters and their call sites inside the package, returned values, and object fields). A variable or parameter is read in the function that declares it, and a helper's return is read through the call being traced, so a plain string another call passes to the same helper (`hasHeader(headers, 'content-type')`) is not a name. Object fields match by spelling across every object, so a literal a field holds (`{ account: 'default' }`) counts only when it is also a `-` head. The codemod declares each literal the name can be. Where the traced value is a literal, a hyphen, then anything (`` `${DEFAULT}-${purpose}` ``, `prefix + '-' + account`, a legacy placeholder naming `stripe-${env}`), it declares that literal as a `prefix: true` slot, or sets `prefix: true` on the slot already declared. It never writes a prefix that is not a literal in the source. The [name tracer](../../packages/worker/src/package-codemods/codemods/0013-infer-credential-names.ts) uses a recognized `name.startsWith(prefix + '-')` check as a hint that an external value follows the convention; it does not prove the check always runs before use. A wrapper with a prefix convention and an unchecked override can get its prefix slot and still be reported, as can a name with only a literal default (`name || 'slack'`). #### Manual findings and runs Each new slot has no `kind` and a fixed description the owner can reword. Placeholders resolve by name whatever their slot says, so this changes nothing at run time. Helpers that resolve outside the gateway (`packageSecrets`, `secretJwtSign`, `integrationTokenRefresh`) get no slot. `credential('key')` / `credentials('key')` keys (aliased imports and `kody.credential(...)` included) get no slot. A slot's kind decides what `credential()` can resolve (a slot with no kind takes only secret, oauth, or login credentials), and the source cannot say which kind a key takes. The codemod adds no slot and reports `needs_manual` for an undeclared `credential()` key, a computed `credential()` key, a computed name its source does not bound, a vault ref, a name that is not a valid slot key, a declared slot whose kind cannot fill the use, and `credential` passed around instead of called (`typeof credential` in a type is not a use). A package whose `package.json` does not parse is reported too. For a nested package it reads the manifest at the entity source's `manifest_path` and only the files under its `source_root`. It uses `applyMode: 'published-only'`, so drifted and locked packages are updated without moving default-branch HEAD. Publishing stores the new needs closure with the approval pause skipped, as for every codemod. Run it with `filters.scope: 'credential-need-enforcement'`. A rescan with the same filter must come back clean before the enforcement flag is turned on. ### `0014-seal-credential-stamps` Fleet seal for [issue #3836](https://github.com/kody-hq/kody/issues/3836). Declares missing `kody.credentials` slots for every stampable literal use (`credential("KEY")`, placeholders, `createAuthenticatedFetch`, JWT signing names, and literal `kody.mcp.SERVER` names) and fills an inferred description when the slot has none. Existing descriptions are never overwritten. Literal MCP servers get `kind: "mcp"`; OAuth / integration names get `kind: "oauth"`; signing names get `kind: "signing"`. Packages with unstampable patterns (non-literal names, `|scope=`, `packageSecrets.get`, `credential.named`, server eval, dynamic `kody.mcp`) stay `needs_manual`. Manifest-only `kody.secretMounts` may stay for stale static dependents and does not block sealing. Prefer `0015-convert-credential-stamps` / `adminCredentialStampMigrate` for behavior-preserving conversion before leaving packages on the publish gate. It uses `applyMode: 'published-only'`. After apply (or for packages that were already seal-ready), run `adminCredentialStampBackfill` to restamp seal-ready packages that still lack a KV stamp at the current `published_commit`. A package with a stored stamp is limited at runtime to its declared credential slots, including a stamp the fleet still calls `would_restamp` (keys or dependency pins drifted). Packages this scan reports as `needs_manifest`, `unconvertible`, `deferred_scan_budget`, or `failed` have no stamp and keep the legacy credential path until a republish stores one. `missingStampPackages` counts only `would_restamp` rows. It does not include `unconvertiblePackages`, `needsManifestPackages`, `deferredScanBudgetPackages`, or `failedPackages`. The legacy path can be removed when one full dry-run (`nextCursor` null) reports every one of those counters, plus `missingStampPackages`, as zero. Only `stamped` and `skipped_unpublished` remain. ### `0015-convert-credential-stamps` Platform migration for [issue #3836](https://github.com/kody-hq/kody/issues/3836): convert other owners' published packages (including `@kody/*`) when the result is stamp-sealable without disruption. Operator surface: `adminCredentialStampMigrate` (audited admin mutation; dry-run default). Safe transforms only: - Declare allowlisted missing bare npm deps the tree already imports, including side-effect imports (today: `remix@3.0.0`). - Seal inferred `kody.credentials` descriptions (same plan as `0014`). Does **not** strip `|scope=package` (or any `|scope=`): unsuffixed secret lookup prefers session before package, so removing the suffix would widen resolution. Those packages stay on the publish gate. Package-bound Keys can fill that same package's declared needs (exact name match or sole candidate), which lets owners convert off `|scope=package` placeholders onto needs without new secrets; this codemod still does not rewrite those placeholders itself. Skips without writing when: - The package is a Kent holdout (`@kentcdodds/raycast`, `@kentcdodds/oauth-integration-health`). - Blocking stamp-gate failures remain (run-time names no slot covers, `|scope=package` / `|scope=session`, `packageSecrets.get`, vault placeholders, `server_eval`, `credential.named`, …). Manifest-only `kody.secretMounts` does not block. Never emails or notifies owners, never creates credential values, and relies on the existing republish path so job/trigger enablements stay as they are. Uses `applyMode: 'published-only'`. After apply pages finish, run `adminCredentialStampBackfill` to write KV stamps. Leftover cleanup is tracked in the linked #3836 cleanup issue. ### `0016-short-package-app-subdomain-path` Rewrites `https://{user}.kody.run/packages/{leaf}` (single-label `kody.run` subdomain, optional rest of the path, query, and hash) to `https://{user}.kody.run/{leaf}`. - Does **not** rewrite app-origin `/@user/packages/...` paths, Open API `/v1/packages/...` paths, apex `https://kody.run/packages/...`, or nested labels (`https://a.b.kody.run/...`). - Emits `needsManual` for a bare `/packages/{leaf}` mention that may mean the hosted subdomain path. ### `0017-detect-package-app-visitor-authority` Detect only (writes nothing). Package apps run as their publisher (ADR 0068), capped to `kody.app.capabilities`. This scan finds published apps that fail or change because they still assume visitor authority: - `undeclared capability` / `computed capability`: a `kody.()` call missing from `kody.app.capabilities`, or a name picked at run time. The scan reads the app's own source only; calls made by imported packages also count against the app's list at run time but are not reported here. - `kody.mcp`: an MCP server tool call from the app. - `visitor credential`: the app uses credentials and declares no `kody.app.visitorNeeds`, so signed-in visitors get the publisher's credentials. - `identity email`: the app reads `email` from `metaGetCurrentUser`, which needs the visitor's `email` consent. Findings carry fixed messages only. Count flagged apps with `adminPackageCodemodScan` (`codemodId` `0017-detect-package-app-visitor-authority`). ### `0018-declare-package-app-capabilities` One-time Phase 1 migration for apps that run as their publisher (ADR 0068). `applyMode: 'published-only'`, so drifted apps are fixed on their published tree. Adds to `package.json#kody.app.capabilities` every platform capability the app calls by a static name: - directly, in its own modules (the `0017` scanner, `collectModuleKodyCalls`); - through its import closure: each `kody:@scope/name/export` the app imports is followed from that export's entry module along relative imports and into the packages those modules import (only what an import reaches counts); - from the runtime: `capability_not_declared` call names in `package_app_authority_rejections` and the app's `package_app_capability_allowances` (gap filling for computed names the scan cannot see). Codemods stay pure. The codemod sets `hostFacts: ['package-app-capabilities']`, and the engine computes those facts with I/O before calling it (`computePackageAppCapabilityHostFacts` in `package-codemods/package-app-capability-closure.ts`) and passes them in as `PackageCodemodContext.packageAppCapabilities`. Only names in the builtin capability registry are ever added. Findings stay fixed strings. The exact names added, and per-app counts of what stays unresolved (computed names, `kody.mcp`, imports that cannot be followed, non-platform names, observed `credential.named` refusals), go in the transform's `ownerDetail`, stored on the run item as `owner_detail_json` (admin-only, never in step results). Read a run with `adminPackageAppCapabilityMigrationReport` (`runId`): apps and owners affected, capabilities added (total and per capability), and unresolved apps by package id with counts. Pass `packageId` to read one app's private list for its owner. ### `0019-detect-package-app-host-migration` Scan-only inventory for the move of package apps from `https://{user}.kody.run/{leaf}` to `https://{leaf}--{user}.kody.run` (one host per app, mounted at `/`). Only looks at packages with `kody.app`; `transform` never changes a file. `applyMode: 'published-only'`, so an app whose default branch has moved past its published commit is scanned on its published tree instead of being `skipped_drift`. Test files, `node_modules`, and lockfiles are skipped. Each finding is a file path plus one fixed message naming the pattern: - `old app url`: an absolute `{user}.kody.run/{leaf}` or `/packages/{leaf}` URL for this app (also reported in docs and READMEs). - `hardcoded mount path`: a string literal that starts with `/{leaf}`. - `build-time base`: a build config, `base`, or router basename set to `/{leaf}`. - `list-unsubscribe`, `oauth form_post`, `oauth redirect uri`, `webhook receiver`: addresses that outside services may hold. - `localStorage`, `sessionStorage`, `indexedDB`, `cache storage`, `service worker`: browser data scoped to the old origin. - `cookie path`, `cookie domain`: cookie scope tied to the mount path or host. - `origin check`: an origin or hostname comparison in a file that names a `kody.run` host. - `web app manifest`: a `start_url` or `scope`, or a service worker registered with a scope. The matchers are text patterns and deliberately broad: a finding means "review this file", not "this is broken". Count apps per pattern with `adminPackageCodemodScan` (`codemodId` `0019-detect-package-app-host-migration`). ### `0020-package-app-host-urls` Apply step of the same move. It rewrites full `https://{user}.kody.run/{leaf}` URLs (and the older `/packages/{leaf}` form) of the package's **own** app to `https://{leaf}--{user}.kody.run`, keeping the rest of the path, query, and hash. An absolute URL on the new host is right wherever the page that carries it was loaded from, so this is the one rewrite that is correct on both addresses while both still serve. - Only the package's own owner and leaf match. URLs of sibling apps, other owners, longer leaves (`/notes-archive`), and template fallbacks (`https://{user}.kody.run${appBasePath}`) are left alone. - A file that mentions origins or hostnames at all is not rewritten; it is reported as `needsManual`, because the rewrite could break a check on the old address. The guard is per file: a URL constant compared in a different file is still rewritten, so read the dry-run diff before applying. - Mentions in any other form (no `https://`, `http://`, a path in another letter case) are reported as `needsManual` and left as written. - Packages with no app, profile packages (`@{slug}/{slug}`, which keep the owner's bare host), and names with no valid `{leaf}--{handle}` label are unchanged. - Everything else `0019` reports (mount paths, build-time bases, browser storage, cookie scope, origin checks, PWA scope) stays with the owner. - Uses `applyMode: 'published-only'`. ### `0021-detect-fork-upstream-updated-subscription` Scan-only count of packages whose `package.json#kody.subscriptions` still declares `community.fork.upstream_updated`. `transform` never changes a file: the topic's payload and fan-out differ from `follow.published`, so owners move their handler by hand. `applyMode: 'published-only'`, so a package whose default branch has moved past its published commit is scanned on its published tree. Count subscribers with `adminPackageCodemodScan` (`codemodId` `0021-detect-fork-upstream-updated-subscription`); the topic is removed once a scan reports zero. See [planned breaking changes](./planned-breaking-changes.md#communityforkupstream_updated).