{{ message }}
Repository navigation
Conversation
Adds packages/sdk/python — a Python SDK generated from packages/sdk/openapi.json using openapi-python-client, plus the hand-written surface and CI that keeps it in sync with the same OpenAPI document the JS SDK is generated from. Hand-written: - pyproject.toml (hatchling, Python 3.10+, deps: httpx + attrs + python-dateutil) - src/opencode_ai/__init__.py public exports - src/opencode_ai/server.py — sync ServerHandle / async AsyncServerHandle helpers mirroring createOpencodeServer in packages/sdk/js - README.md modeled on the JS SDK README - scripts/_overlay/* — source of truth for files the generator does not produce - scripts/generate.py — regenerate / --check used by CI - tests/test_unit.py + tests/test_smoke.py - examples/basic_usage.py CI (.github/workflows/python-sdk.yml) runs lint, scripts/generate.py --check (fails the build on openapi.json drift), pytest against a live opencode server spawned from the local checkout, and a hatchling distribution build, on every push/PR that touches packages/sdk/python or packages/sdk/openapi.json. The previous Python SDK was removed in 13b2cf5 ("remove outdated SDKs") for exactly this reason — without a sync CI, the generated tree drifts. This PR ships the SDK and the regen CI together so it stays current. Refs anomalyco#4031, anomalyco#2266.
Output of `python packages/sdk/python/scripts/generate.py` against the current packages/sdk/openapi.json (98 paths, 168 schemas) using openapi-python-client 0.28.x. Source of truth for these files is the OpenAPI spec; do not edit by hand. CI runs the generator with --check on every PR.
Contributor
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
nbilbeny
marked this pull request as ready for review
April 29, 2026 15:04
Two CI bugs caught before any maintainer review on PR anomalyco#24968: - The job-level `defaults.run.working-directory: packages/sdk/python` would propagate into the `setup-bun` composite action, where its `node -p` and `bun install` steps must run from the repo root. Drop the default and scope `working-directory` per step instead, matching how `test.yml` and `typecheck.yml` invoke setup-bun. - `openapi-python-client` and `ruff` were ranged dependencies. A patch release with even a one-line formatting change would cause `scripts/generate.py --check` to fail in CI weeks after merge. Pin both to the exact versions the committed tree was generated with (openapi-python-client 0.28.3, ruff 0.15.12). Bump alongside a regen commit when needed.
3 of 6 tasks
Contributor
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Issue for this PR
Closes #4031.
Type of change
What does this PR do?
Brings back a Python SDK at
packages/sdk/python, generated frompackages/sdk/openapi.jsonwithopenapi-python-client(the generator @thdxr asked for in #2266).The last attempt got removed in 13b2cf5 because it had no regen CI. This one ships the SDK and the regen step together —
python scripts/generate.py --checkruns on every PR touching python or the spec, so the tree can't drift.Hand-written bits are just
__init__.py,server.py(mirrorscreateOpencodeServerin JS, sync + async), README, pyproject, CI. Everything else is regenerable from the spec viascripts/_overlay/+scripts/generate.py.How did you verify your code works?
Locally on Python 3.13 and Bun 1.3.13:
python scripts/generate.py --check— cleanruff check+ruff format --check— cleanpython -m build— wheel + sdistpytest tests/— 9 passed (5 unit + 4 smoke against a liveopencode servespawned from this checkout)CI runs the same on 3.10 and 3.13.
Checklist