Skip to content

chore: add SDK command migration tooling#3723

Merged
tlowrimore-heroku merged 4 commits into
feat/heroku-sdk-integrationfrom
tl/sdk-migration-tooling
May 22, 2026
Merged

chore: add SDK command migration tooling#3723
tlowrimore-heroku merged 4 commits into
feat/heroku-sdk-integrationfrom
tl/sdk-migration-tooling

Conversation

@tlowrimore-heroku
Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/codemods/sdk-migration/, a ts-morph–based codemod that mechanically migrates a single oclif command from raw this.heroku.<verb>(path) calls to @heroku/sdk resource methods.
  • Adds .claude/skills/sdk-command-migration/, a project-local skill that orchestrates the full migration playbook (pre-flight, codemod, TODO resolution, type-check, test rewrite, verify).
  • Carves a .gitignore exception so .claude/skills/ is tracked while other .claude/ contents (settings.local.json, etc.) remain ignored.

The codemod reverse-looks-up each (verb, path) pair against @heroku/types/3.sdk/routes (the SDK's generated route metadata), so the mapping table stays in sync with the SDK without hand curation. Cases the codemod cannot safely transform (path not statically extractable, no SDK route, body shape ambiguity, etc.) are flagged with // TODO(sdk-migration): ... markers; the original call is preserved for manual resolution.

Test plan

  • Run npx tsx scripts/codemods/sdk-migration/migrate-command.ts --dry-run src/commands/apps/join.ts and verify the diff replaces both this.heroku.* calls with platform.* equivalents, drops {body:} destructure, unwraps the http-call options shape, and preserves source formatting (single quotes, no semicolons, two-space indent).
  • Run on src/commands/apps/lock.ts and verify the codemod flags the ambiguous PATCH /teams/apps/{id} case with a TODO marker and exits non-zero.
  • Apply the skill end-to-end on a small command (e.g., apps/join): codemod → resolve flagged calls → tsc → run + rewrite tests → verify.
  • Confirm .claude/settings.local.json remains gitignored after the .gitignore change (git check-ignore .claude/settings.local.json returns 0).

Adds a ts-morph–based codemod that mechanically migrates a single oclif
command from raw this.heroku.<verb>(path) calls to @heroku/sdk platform
resource methods.

The codemod reverse-looks-up each (verb, path) pair against
@heroku/types/3.sdk/routes (the SDK's generated route metadata), so the
mapping table stays in sync with the SDK without hand curation. Cases the
codemod cannot safely transform are flagged with TODO(sdk-migration)
markers and the original call is preserved.

Run with --dry-run to preview, then again without to apply in place.
Adds ts-morph and tsx as devDependencies.
Adds a project-local Claude skill that orchestrates the SDK migration playbook
for a single oclif command: pre-flight checks, source migration via the
codemod (chore: previous commit), TODO-marker resolution, type-check, and
test rewrite to stub @heroku/sdk directly instead of intercepting HTTP via
nock.

Adjusts .gitignore so that .claude/skills/ is tracked while the rest of
.claude/ (settings.local.json, etc.) remains ignored.
…owing

The codemod now indexes both @heroku/types/3.sdk/routes (Platform) and
@heroku/types/data/routes (Postgres data API). Each route is tagged with
its service so the emitted call uses platform.* or data.* as appropriate,
and the SDK destructure at the top of run() only includes services the
file actually uses (e.g., {data, platform} when a command spans both).

For data routes, the codemod silently drops a sole {hostname: ...}
options arg and strips hostname from {body, hostname} payloads — the SDK
provides the data hostname automatically. Anything else in the options
object is still flagged.

Adds a non-blocking warning when a local variable in run() would shadow
a destructured SDK service name (e.g., a local `const data = ...`
colliding with the `data` service). Migration proceeds; the agent must
rename the local before merging.

Updates the README and the sdk-command-migration skill to document
data-route support and the new shadowing warning.
Copy link
Copy Markdown
Contributor

@eablack eablack left a comment

Choose a reason for hiding this comment

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

yes, more of these please! :shipit:

@tlowrimore-heroku tlowrimore-heroku merged commit 5e710b2 into feat/heroku-sdk-integration May 22, 2026
4 of 17 checks passed
@tlowrimore-heroku tlowrimore-heroku deleted the tl/sdk-migration-tooling branch May 22, 2026 22:46
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