Skip to content

feat(sdk): add Effect HttpApi codegen#33445

Open
kitlangton wants to merge 1 commit into
devfrom
httpapi-codegen
Open

feat(sdk): add Effect HttpApi codegen#33445
kitlangton wants to merge 1 commit into
devfrom
httpapi-codegen

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Summary

  • add a private, generic @opencode-ai/httpapi-codegen package that reflects Effect HttpApi contracts directly, without OpenAPI or Hey API
  • generate one formatted module per group plus a single Effect client with flattened domain inputs, { data } unwrapping, direct streams, declared errors, and stable ClientError infrastructure failures
  • reject contracts that cannot be reproduced exactly, including ambiguous payload/success alternatives, custom transformations/checks, unsafe middleware, and client-name collisions
  • write through Effect FileSystem with safe paths, symlink checks, and a generator-owned manifest for stale-file cleanup
  • include a committed synthetic generated client whose source drift and strict consumer types are verified by tests

Generated API shape

const client = yield* make({ baseUrl })

const session = yield* client.session.get({ sessionID })
const sessions = yield* client.session.list()
const filtered = yield* client.session.list({ archived: true })
const events = client.event.subscribe()
const status = yield* client.status()

Ordinary methods return Effect; streaming methods return Stream directly. Exact { data: A } envelopes return A, and transport/decode failures become generated ClientError values while declared API errors remain typed.

Verification

  • bun run test from packages/httpapi-codegen: 41 passed
  • bun typecheck from packages/httpapi-codegen
  • file-scoped oxlint: 0 warnings, 0 errors
  • Prettier check for all package source and generated fixtures
  • repository pre-push bun turbo typecheck: 25 tasks passed
  • four parallel implementation reviews plus three focused re-reviews for generated API correctness, Effect semantics, test coverage, and code quality

Scope

This PR introduces the generic generator and synthetic fixtures only. It does not yet generate or publish the production OpenCode Effect SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant