All jobs

Migrate a Deno 1 App to Deno 2

Yes. An agent moves a Deno 1 app to Deno 2: fixes what the new type checker rejects, moves URL imports into deno.json, updates CI and opens a PR with proof.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent first finds out which Deno the project claims to run on, and in an app like ryo-ma/github-profile-trophy there are four answers. .github/workflows/testing.yml tests on a matrix of one version, 1.44.4, installed with denoland/setup-deno@v1. action.yml, the composite action the repository publishes, installs v1.x. CONTRIBUTING.md says Deno 1.36.1 or later. The Dockerfile starts FROM denoland/deno:latest, which is already a Deno 2 image. The container can be on a major version that CI has never tested, so the migration begins by making those four agree.

Then it installs a current Deno 2 in the sandbox and asks the tools what breaks, before reading a migration guide. deno check reports three kinds of error on code that the pinned 1.44.4 workflow type-checks on every push. The four error classes in src/error_page.ts redeclare status and message without the override modifier. src/config/cache.ts reads e.message in two catch blocks, where the caught value is now typed unknown. src/StaticRenderRegeneration/index.ts passes the bytes from Deno.readFileSync straight to new Response, and the newer TypeScript does not accept that Uint8Array as a body. None of the four test files imports those three modules, so deno task test can pass while the server's entry point does not type-check, which is why the agent checks main.ts and render_svg.ts by name. It fixes each error at its source: adds override, narrows with instanceof Error, and hands the response a body type it accepts.

Imports come next. deps.ts pulls soxa@1.4 and redis@v0.31.0 from deno.land/x and the assert and mock helpers from std@0.203.0. main.ts imports serve from std@0.224.0/http/server.ts. render_svg.ts loads deno.land/x/dotenv@v0.5.0, while api/index.ts loads @std/dotenv from JSR through the import map in deno.json. Pinned URL imports still resolve under Deno 2, but deno lint now reports inline ones under no-import-prefix. The agent moves the standard library imports to JSR entries in deno.json, replaces serve(handler, { port }) with the built-in Deno.serve, settles on one dotenv, and keeps soxa and redis as URL imports mapped in deno.json unless you ask for replacements. .gitignore lists deno.lock; it removes that line and commits the lockfile.

Last it updates everything that installs Deno: the workflow's matrix and setup-deno major, the deno-version in action.yml, the version line in CONTRIBUTING.md and a pinned tag in the Dockerfile. vercel.json names the community runtime vercel-deno@3.1.1 for api/**, which chooses the Deno version on Vercel separately from all of the above, so the agent reports that and changes it only if asked. As proof it runs deno fmt --check, deno lint, deno check and deno task test, then starts deno task start and requests the root path with no username, which should answer with the HTML error page and needs no GitHub token.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Migrate this app from Deno 1 to the current Deno 2 release. Read deno.json, deps.ts, main.ts, render_svg.ts, api/index.ts, .gitignore, every workflow under .github/workflows, action.yml, the Dockerfile, docker-compose.yml, vercel.json and CONTRIBUTING.md first, and list every place that states or installs a Deno version. Install the current Deno 2 and, before changing anything, run deno fmt --check, deno lint, deno check on the entry points and tests, and deno task test, keeping the output as the baseline. Fix every type error at its source; do not add --no-check, a ts-ignore comment or a looser compiler option. Move standard library URL imports to jsr: entries with version ranges in deno.json, replace the std http serve import with Deno.serve, use one dotenv module, and keep third-party deno.land/x modules as URL imports mapped in deno.json. Keep deps.ts exporting the same names. Stop ignoring deno.lock and commit it. Update the Deno version in the test workflow, action.yml, the Dockerfile and CONTRIBUTING.md so they agree, and report what the Vercel runtime in vercel.json uses without changing it. Run the same four commands again, then start the server and request / with no query string. Do not call the GitHub API. Open a pull request with the before and after output of each command, the import map changes as a table, and a list of what was not exercised.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request changes deno.json, deps.ts, main.ts, render_svg.ts, the three source files with type errors, the test workflow, action.yml, the Dockerfile, CONTRIBUTING.md and .gitignore, and adds deno.lock. Its description has a before-and-after block for each of deno fmt --check, deno lint, deno check and deno task test on the new version. The reviewer sees the type errors that were there, that they are gone, and what the local server answered.

It says plainly what was not exercised. No trophy was rendered against the GitHub API, because the sandbox has no GITHUB_TOKEN1. Redis was not started, so the ENABLE_REDIS path through connect in the pinned redis module was type-checked and not run. The Vercel deployment was not built. Each is one line in the description with the command a maintainer can run to close it.

A reviewer reads the import map first: every jsr: entry should carry a version range, and deps.ts should still export the same names, so the test files changed only where an import moved. Then the workflow. The lint step in testing.yml ends in || true, so lint has never been able to fail the build. The agent leaves that line alone and asks whether you want it enforced, since that is a policy change and not part of the migration.

Run it on every Monday morning

Once the app is on Deno 2 the same job is small, and a schedule keeps it small. Create an automation in the Project that holds the repository with a schedule trigger whose cron is 0 9 * * 1 in your timezone. Its prompt: compare the Deno version in the workflow with the newest release, run deno outdated against the import map, and if either is behind, update, run the four checks from this page and open a pull request with their output; if nothing is behind, end with one line saying so.

A team with several services still on Deno 1 sends this page's body once per repository to POST /o/{org}/sessions, each with that repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried script returns the runs it already started. Each run finds its own type errors and its own imports. The key's webhook_url reports each run it starts as it finishes, with a session_url to read the pull request from.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

A Deno major upgrade fails in the type checker, not at runtime, and the errors depend on the code: this repository has three kinds and yours will have others. A migration guide tells you what might break. Installing the new version in a clean sandbox and running deno check tells you what does, with file and line. The agent has that list early in the run and works from it, and the transcript keeps every command and its output.

It is also a change spread over small files that different people own: the import map, a workflow, a published action, a Dockerfile, the contributor guide. Done from a laptop, the usual result is code that compiles on the developer's new Deno while CI stays pinned to the old one. The agent changes them in one pull request and shows the same four commands passing on one version, while your checkout stays on the branch you were working on.

Frequently asked questions

Do https:// imports stop working in Deno 2?

No. A pinned URL import such as https://deno.land/std@0.203.0/assert/mod.ts still resolves. What changes is that deno lint reports inline URL, jsr: and npm: specifiers under no-import-prefix and wants them in the import map in deno.json. The agent moves them there and keeps the URL for modules that are published only on deno.land/x.

Why does code that passed on Deno 1 fail to type-check?

Deno 2 ships a newer TypeScript with stricter defaults. A caught error is unknown until it is narrowed, and a class field that redeclares one from its base class needs override. Neither is a behaviour change at runtime, which is why the fix is a few lines and why --no-check would only hide it.

Should deno.lock be committed?

For an application, yes. This repository ignores it, so every install resolves a range such as ^0.224.0 again and two machines can run different code. The agent commits the lockfile and can have CI run with --frozen-lockfile, which fails when the lockfile is out of date.

Does it keep deps.ts?

Yes, unless you ask otherwise. The source and the tests import soxa, stub, assertEquals and the Redis client from it, and one of them, soxa, is configured there with the GitHub API base URL. Changing where deps.ts gets its imports is enough; deleting it would touch every file for no gain.

What about the Vercel deployment?

The run does not deploy. vercel.json sets the vercel-deno runtime for the api functions, and that package decides which Deno the function runs on. The agent reports the runtime's version and what it would take to move it, and leaves the file unchanged so the migration can merge without a deploy risk.

More Deno jobs

More jobs like this: Upgrade dependencies weekly

Keep reading