@devries-cameron20 / composio-1 / commits / eb3fb8c9d
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(release): open one release PR from a member request

Any active ComposioHQ member can request a release with the [SDK release] issue form; writers can also dispatch SDK release. The bot plans versions on protected next, regenerates the SDK reference docs, writes the changelogs, checks the diff is release-only and opens one release PR. Preparation runs without credentials and cannot change the planned batch.

jkomyno committed Nov 5, 2026 at 17:48 UTC eb3fb8c9df3fa903c59e3527e7765e31d214a940
25 files changed +2375 -18
.github/ISSUE_TEMPLATE/sdk-release.yml new
+27
@@ -0,0 +1,27 @@
1 +name: SDK release
2 +description: Request a TypeScript and Python SDK release
3 +title: '[SDK release] Request'
4 +body:
5 + - type: markdown
6 + attributes:
7 + value: |
8 + Any active ComposioHQ member can use this form, including members with repository Read access.
9 + The bot prepares one release PR. A repository writer who did not request the release approves its final head, then a person merges it.
10 + - type: dropdown
11 + id: typescript
12 + attributes:
13 + label: TypeScript
14 + description: auto uses Changesets recommendations; an explicit bump without notes selects core and slim.
15 + options: [auto, patch, minor, major, skip]
16 + default: 0
17 + validations:
18 + required: true
19 + - type: dropdown
20 + id: python
21 + attributes:
22 + label: Python
23 + description: auto uses Changesets recommendations; an explicit bump selects the synchronized Python train.
24 + options: [auto, patch, minor, major, skip]
25 + default: 0
26 + validations:
27 + required: true
.github/workflows/docs.changelog-notification.yml
+3
@@ -40,6 +40,9 @@ jobs:
40 # Get the list of added/modified changelog files across all commits in this push
41 CHANGED_FILES=$(git diff --name-only --diff-filter=AM "$BEFORE".."$AFTER" | grep '^docs/content/changelog/.*\.mdx$' || echo "")
42 fi
43 +
44 + # Skip generated SDK release entries (frontmatter `sdkRelease:`); their release PR covers them.
45 + CHANGED_FILES=$(printf '%s\n' "$CHANGED_FILES" | bash scripts/sdk-release/changelog-filter.sh)
46
47 if [ -z "$CHANGED_FILES" ]; then
48 echo "No changelog files changed in this push"
.github/workflows/docs.changelog-to-docs.yml
+3
@@ -50,6 +50,9 @@ jobs:
50 FILES=$(git diff --name-only --diff-filter=AM "$BEFORE".."$AFTER" | grep '^docs/content/changelog/.*\.mdx$' || echo "")
51 fi
52
53 + # Skip generated SDK release entries (frontmatter `sdkRelease:`); their release PR covers them.
54 + FILES=$(printf '%s\n' "$FILES" | bash scripts/sdk-release/changelog-filter.sh)
55 +
56 if [ -z "$FILES" ]; then
57 echo "found=false" >> $GITHUB_OUTPUT
58 else
.github/workflows/sdk.release.check.yml
+4
@@ -14,6 +14,7 @@ on:
14 - 'scripts/sdk-release/**'
15 - 'test/sdk-release-*'
16 - 'tsconfig.sdk-release.json'
17 + - 'docs/scripts/generate-sdk-release-notes.ts'
18 - '.github/workflows/sdk.release*.yml'
19 - 'package.json'
20 - 'pnpm-lock.yaml'
@@ -56,6 +57,9 @@ jobs:
57 with:
58 enable-caching: 'false'
59 - run: pnpm install --frozen-lockfile --ignore-scripts
60 + - name: Install the docs dependencies release preparation imports
61 + working-directory: docs
62 + run: bun install --frozen-lockfile --ignore-scripts
63 - run: pnpm run typecheck:sdk-release
64 - run: pnpm exec oxlint scripts/sdk-release test/sdk-release-*.ts
65 - run: pnpm run test:sdk-release
.github/workflows/sdk.release.yml new
+139
@@ -0,0 +1,139 @@
1 +name: SDK release
2 +run-name: SDK release (${{ github.event_name }}, ${{ github.actor }})
3 +
4 +# Stage 1 of the SDK release: a ComposioHQ member opens an `[SDK release]` issue or dispatches
5 +# this workflow, and the bot plans versions on protected next and opens one release PR.
6 +
7 +on:
8 + issues:
9 + types: [opened]
10 + workflow_dispatch:
11 + inputs:
12 + typescript:
13 + description: TypeScript bump (auto follows the changesets)
14 + type: choice
15 + options: [auto, patch, minor, major, skip]
16 + default: auto
17 + python:
18 + description: Python bump (auto follows the changesets)
19 + type: choice
20 + options: [auto, patch, minor, major, skip]
21 + default: auto
22 +
23 +permissions:
24 + contents: read
25 +
26 +jobs:
27 + # 1. request ---------------------------------------------------------------------------------
28 +
29 + plan:
30 + if: >-
31 + github.repository == 'ComposioHQ/composio' && github.ref == 'refs/heads/next' &&
32 + (github.event_name == 'workflow_dispatch' ||
33 + (github.event_name == 'issues' && startsWith(github.event.issue.title, '[SDK release]')))
34 + runs-on: ubuntu-latest
35 + environment: sdk-release-control
36 + concurrency:
37 + group: sdk-release-controller
38 + cancel-in-progress: false
39 + outputs:
40 + batch: ${{ steps.plan.outputs.batch }}
41 + steps:
42 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
43 + with:
44 + persist-credentials: false
45 + - uses: ./.github/actions/setup-node-pnpm-bun
46 + - run: pnpm install --frozen-lockfile --ignore-scripts
47 + - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510
48 + id: app
49 + with:
50 + client-id: ${{ vars.SDK_RELEASE_APP_CLIENT_ID }}
51 + private-key: ${{ secrets.SDK_RELEASE_APP_PRIVATE_KEY }}
52 + owner: ComposioHQ
53 + repositories: composio
54 + - name: Check membership and plan versions
55 + id: plan
56 + env:
57 + SDK_RELEASE_TOKEN: ${{ steps.app.outputs.token }}
58 + run: bun scripts/sdk-release/batch.ts plan
59 +
60 + # Runs the docs generators, which install third-party packages, so it gets no credentials.
61 + prepare:
62 + needs: plan
63 + if: needs.plan.outputs.batch != ''
64 + runs-on: ubuntu-latest
65 + steps:
66 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
67 + with:
68 + persist-credentials: false
69 + - uses: ./.github/actions/setup-node-pnpm-bun
70 + - uses: ./.github/actions/setup-python-uv
71 + with:
72 + cache-dependency-glob: |
73 + uv.lock
74 + pyproject.toml
75 + mise.lock
76 + python/pyproject.toml
77 + - run: pnpm install --frozen-lockfile --ignore-scripts
78 + - working-directory: docs
79 + run: bun install --frozen-lockfile --ignore-scripts
80 + - name: Apply versions, changelogs and SDK reference docs
81 + env:
82 + SDK_RELEASE_BATCH: ${{ needs.plan.outputs.batch }}
83 + run: bun scripts/sdk-release/prepare.ts /tmp/sdk-release-patch.json
84 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
85 + with:
86 + name: sdk-release-patch
87 + path: /tmp/sdk-release-patch.json
88 + retention-days: 7
89 + if-no-files-found: error
90 +
91 + release-pr:
92 + needs: [plan, prepare]
93 + runs-on: ubuntu-latest
94 + environment: sdk-release-control
95 + concurrency:
96 + group: sdk-release-controller
97 + cancel-in-progress: false
98 + steps:
99 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
100 + with:
101 + persist-credentials: false
102 + - uses: ./.github/actions/setup-node-pnpm-bun
103 + - run: pnpm install --frozen-lockfile --ignore-scripts
104 + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
105 + with:
106 + name: sdk-release-patch
107 + path: /tmp/sdk-release
108 + - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510
109 + id: app
110 + with:
111 + client-id: ${{ vars.SDK_RELEASE_APP_CLIENT_ID }}
112 + private-key: ${{ secrets.SDK_RELEASE_APP_PRIVATE_KEY }}
113 + owner: ComposioHQ
114 + repositories: composio
115 + # The batch comes from the plan job's output, which the credential-free prepare job
116 + # cannot change; the patch is checked against it before anything is committed.
117 + - name: Check the release-only diff and open the release PR
118 + env:
119 + SDK_RELEASE_TOKEN: ${{ steps.app.outputs.token }}
120 + SDK_RELEASE_BATCH: ${{ needs.plan.outputs.batch }}
121 + run: bun scripts/sdk-release/batch.ts release-pr /tmp/sdk-release/sdk-release-patch.json
122 +
123 + # Tells the request issue when planning succeeded but no release PR opened.
124 + request-failed:
125 + needs: [plan, prepare, release-pr]
126 + if: failure() && needs.plan.outputs.batch != ''
127 + runs-on: ubuntu-latest
128 + permissions:
129 + issues: write
130 + steps:
131 + - name: Comment on the request issue
132 + env:
133 + GH_TOKEN: ${{ github.token }}
134 + BATCH: ${{ needs.plan.outputs.batch }}
135 + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
136 + run: |
137 + issue=$(jq -r .issue <<< "$BATCH")
138 + gh issue comment "$issue" --repo "$GITHUB_REPOSITORY" \
139 + --body "Preparing the release PR failed. Inspect $RUN_URL, then re-run its failed jobs or request the release again."
docs/agent-guidance/context/twoslash.md
+2 -1
@@ -14,11 +14,12 @@ GITHUB_ACTIONS=true bun run build
14 ```
15
16 - Build-time Twoslash is disabled during `bun dev` to avoid its development memory cost.
17 -- `source.config.ts` configures collection-level MDX behavior. The reference collection has no Twoslash transformer; its maintained examples are checked by the standalone command instead.
17 +- `source.config.ts` configures collection-level MDX behavior. The reference and historical changelog collections have no Twoslash transformer. Maintained reference examples are checked by the standalone command; historical release examples remain inventory-only.
18 - Plain-Markdown FAQs and canonical/curated KB inputs are checked before their presentation conversion. Generated KB TypeScript stays TypeScript and is also checked when built.
19 - Generated SDK symbol-reference signatures/partial fragments and historical changelogs are inventory-only, not certified by the maintained-example gates.
20 - `.github/workflows/docs-typescript-check.yml` runs standalone regressions, the standalone gate, lint, type checking, and the production build.
21 - Imports resolve to the versions installed from `docs/package.json` and `docs/bun.lock`. This does not type-check against the local TypeScript SDK workspace.
22 +- Release notes can describe an API newer than the installed docs SDK. Keep their ordinary Markdown, Mermaid, and code themes; do not copy their checking exemption into maintained guides or examples. Merge maintained new-API examples after compatible packages are published and their normal checks pass.
23
24 ## Complete examples and hidden setup
25
docs/agent-guidance/guides/changelog.md
+8
@@ -50,6 +50,12 @@ new_code()
50
51 Use the released version in the final table column. The Python release guard reads that column from rows labelled `Python \`composio\``.
52
53 +## SDK release entries
54 +
55 +The SDK release workflow writes one entry per release to `docs/content/changelog/`, with `sdkRelease` and `sdkReleaseTargets` frontmatter, the version table, the changeset summaries, and a link to the request issue. Its prose comes from the changesets: to change it, fix the changesets on `next` and request a new release. Do not hand-edit generated entries in the release PR.
56 +
57 +The release PR also regenerates `docs/content/reference/sdk-reference/` from the released source. Changelog code fences are not type-checked, because they may describe APIs newer than the docs pins; the docs pin PR that follows each release keeps maintained guides checked against the released types.
58 +
59 ## Rules
60
61 1. **Frontmatter required** — `title` and `date` (YYYY-MM-DD format)
@@ -75,3 +81,5 @@ For any breaking change, include:
81 - [ ] Codemod (if applicable) — automated script to transform old code to new
82
83 **What's a codemod?** A script that automatically updates user code. Instead of "change X to Y manually", users run the codemod and it transforms their code. See [jscodeshift](https://github.com/facebook/jscodeshift) or [ts-morph](https://github.com/dsherret/ts-morph).
84 +
85 +Changesets summaries are authored Markdown that becomes MDX. Put prose type syntax such as `Array<Tool>` in code spans so it does not parse as an unclosed JSX element. The production docs build validates the generated entry before release approval.
docs/bun.lock
+13 -1
@@ -59,6 +59,7 @@
59 "@composio/openai-agents": "^0.11.2",
60 "@composio/typesafe": "^0.1.1",
61 "@composio/vercel": "^0.13.0",
62 + "@effect/platform-bun": "4.1.1",
63 "@google/genai": "^2.21.0",
64 "@langchain/core": "^1.2.9",
65 "@langchain/langgraph": "^1.4.14",
@@ -80,6 +81,7 @@
81 "ai": "7.0.37",
82 "ajv": "^8.20.0",
83 "ajv-draft-04": "^1.0.0",
84 + "effect": "4.1.1",
85 "github-slugger": "^2.0.0",
86 "mdast-util-mdx-jsx": "3.2.0",
87 "mdast-util-to-string": "^4.0.0",
@@ -245,6 +247,10 @@
247
248 "@composio/vercel": ["@composio/vercel@0.13.0", "", { "peerDependencies": { "@composio/core": ">=0.10.0 <1.0.0 || >=1.0.0-beta.0 <1.0.0", "ai": "^6.0.0 || ^7.0.0" } }, "sha512-GZcWWQZp/H5b3KS9v9izVK+RoP8WQwNKzpNyOKDzbOsbaul9k7+gJGLYrBp9f65+yjDZ6CmGBs6CScsyuZuzew=="],
249
250 + "@effect/platform-bun": ["@effect/platform-bun@4.1.1", "", { "dependencies": { "@effect/platform-node-shared": "^4.1.1" }, "peerDependencies": { "effect": "^4.1.1" } }, "sha512-//p0xPsbvuRfcO+cvq5JqVzR0TLUUS5yNC40xbZ08JNiszg5IxypAgrpKswKpjs2lYvybxdw5DSyVcEWW33Cbg=="],
251 +
252 + "@effect/platform-node-shared": ["@effect/platform-node-shared@4.1.2", "", { "dependencies": { "@types/ws": "^8.18.2", "ws": "^8.22.1" }, "peerDependencies": { "effect": "^4.1.2" } }, "sha512-wSwl9A/G1hcVvF8nLI+YfB3EyOIDvWS6+lsTZBkmgDnPBL7m8YWZF+1HD+mdEsb52SUGfukip46Q3gRwSdk3QA=="],
253 +
254 "@emnapi/runtime": ["@emnapi/runtime@1.11.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA=="],
255
256 "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.28.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ=="],
@@ -831,7 +837,7 @@
837
838 "@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
839
834 - "@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
840 + "@types/ws": ["@types/ws@8.18.2", "", { "dependencies": { "@types/node": "*" } }, "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w=="],
841
842 "@typesafe-ai/sdk": ["@typesafe-ai/sdk@0.6.0", "", {}, "sha512-IddX+Q0XM+VagOUZFeP7wZjaO4SHMdvnh2zEBdrZZnXedWI3BNK1lKhMx3ayrkFWvVLbVcUHJy6AVZlY+e6Jaw=="],
843
@@ -1153,6 +1159,8 @@
1159
1160 "ee-first": ["ee-first@1.1.1", "", {}, "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="],
1161
1162 + "effect": ["effect@4.1.1", "", {}, "sha512-XYu65BrcmNqu5i7PPvP4dqL+R5ma37zIsfuSPjcn78mog+6e5PkilNg7Xo+pBpjXJYlWEIpH4j91tMrfW05CMw=="],
1163 +
1164 "encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="],
1165
1166 "enhanced-resolve": ["enhanced-resolve@5.24.5", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.3" } }, "sha512-L1l8TNvomm6UVW5B253AGxQagSQr+vGwhMlrrfRS2qmhx46AMpMVJKQYLvWYbysTMY8VoicOvzHzoHMbyzB+4A=="],
@@ -2021,6 +2029,8 @@
2029
2030 "@composio/core/openai": ["openai@7.47.0", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "google-auth-library": ">=9.15.1 <12", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "google-auth-library", "undici", "ws", "zod"] }, "sha512-BYa2RYgocAv9WjPUJmNu8fICuA1fFhkTBEpiR3sC5L1K6v8Hnhc8pcnQEhu8l/+W1XKA+JUaBa7HpT+AK1s77w=="],
2031
2032 + "@effect/platform-node-shared/ws": ["ws@8.22.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g=="],
2033 +
2034 "@floating-ui/react-dom/@floating-ui/dom": ["@floating-ui/dom@1.8.0", "", { "dependencies": { "@floating-ui/core": "^1.8.0", "@floating-ui/utils": "^0.2.12" } }, "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg=="],
2035
2036 "@langchain/langgraph-sdk/p-queue": ["p-queue@9.3.3", "", { "dependencies": { "eventemitter3": "^5.0.4", "p-timeout": "^7.0.0" } }, "sha512-NXAOdnEe5FsZJfT4oK84lE1Y5cFFdWlRuOo5tww8DyNMxyRXwn39fIkUtNLKppcPC+UYU/bXujNCUGDv01y7CA=="],
@@ -2037,6 +2047,8 @@
2047
2048 "@mastra/core/p-retry": ["p-retry@7.1.1", "", { "dependencies": { "is-network-error": "^1.1.0" } }, "sha512-J5ApzjyRkkf601HpEeykoiCvzHQjWxPAHhyjFcEUP2SWq0+35NKh8TLhpLw+Dkq5TZBFvUM6UigdE9hIVYTl5w=="],
2049
2050 + "@openai/agents-realtime/@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
2051 +
2052 "@pierre/trees/@pierre/theming": ["@pierre/theming@1.0.0", "", { "peerDependencies": { "@pierre/theme": "^1.1.0", "@shikijs/themes": "^3.0.0 || ^4.0.0", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0", "shiki": "^3.0.0 || ^4.0.0" }, "optionalPeers": ["@pierre/theme", "@shikijs/themes", "react", "react-dom", "shiki"] }, "sha512-WsdrnhKfjeyXGDikZmN9pkpeZ5S/cl6EE72feiSc0tlynT1tMYqXqouhuv/foK+PY9OEnebOAVRQn3+rAstR8g=="],
2053
2054 "@scalar/json-magic/pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
docs/package.json
+2
@@ -100,6 +100,7 @@
100 "@composio/openai-agents": "^0.11.2",
101 "@composio/typesafe": "^0.1.1",
102 "@composio/vercel": "^0.13.0",
103 + "@effect/platform-bun": "4.1.1",
104 "@google/genai": "^2.21.0",
105 "@langchain/core": "^1.2.9",
106 "@langchain/langgraph": "^1.4.14",
@@ -121,6 +122,7 @@
122 "ai": "7.0.37",
123 "ajv": "^8.20.0",
124 "ajv-draft-04": "^1.0.0",
125 + "effect": "4.1.1",
126 "github-slugger": "^2.0.0",
127 "mdast-util-mdx-jsx": "3.2.0",
128 "mdast-util-to-string": "^4.0.0",
docs/scripts/generate-sdk-release-notes.ts new
+164
@@ -0,0 +1,164 @@
1 +import { Data, Effect, FileSystem, Path, Schema } from 'effect';
2 +import { ChildProcess, ChildProcessSpawner } from 'effect/process';
3 +
4 +const Language = Schema.Literals(['typescript', 'python']);
5 +type Language = typeof Language.Type;
6 +
7 +const ReleaseDocumentationPlan = Schema.Struct({
8 + releases: Schema.Array(
9 + Schema.Struct({ name: Schema.String, newVersion: Schema.String, language: Language })
10 + ),
11 + changesets: Schema.Array(Schema.Struct({ summary: Schema.String })),
12 +});
13 +export type ReleaseDocumentationPlan = typeof ReleaseDocumentationPlan.Encoded;
14 +
15 +const REQUEST_PATH = /^\/ComposioHQ\/composio\/issues\/\d+$/;
16 +const isRequestUrl = (value: string) =>
17 + URL.canParse(value) &&
18 + new URL(value).origin === 'https://github.com' &&
19 + REQUEST_PATH.test(new URL(value).pathname);
20 +
21 +const ReleaseNoteOptions = Schema.Struct({
22 + releaseId: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9_-]*$/)),
23 + date: Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/)),
24 + requestUrl: Schema.String.check(
25 + Schema.makeFilter(value =>
26 + isRequestUrl(value) ? undefined : 'The request URL must link to a repository issue'
27 + )
28 + ),
29 +});
30 +export type ReleaseNoteOptions = typeof ReleaseNoteOptions.Type;
31 +
32 +export class ReleaseNotesError extends Data.TaggedError('ReleaseNotesError')<{
33 + readonly message: string;
34 +}> {}
35 +
36 +/** How each language appears in the docs version table and how its reference docs are generated. */
37 +const LANGUAGE_DOCS: Record<
38 + Language,
39 + {
40 + readonly label: (name: string) => string;
41 + readonly reference: {
42 + readonly command: string;
43 + readonly args: ReadonlyArray<string>;
44 + readonly directory: string;
45 + };
46 + }
47 +> = {
48 + typescript: {
49 + label: name => `TypeScript \`${name}\``,
50 + reference: {
51 + command: 'pnpm',
52 + args: ['--filter', '@composio/core', 'generate:docs'],
53 + directory: '.',
54 + },
55 + },
56 + python: {
57 + label: () => 'Python `composio`',
58 + reference: {
59 + command: 'uv',
60 + args: ['run', '--with', 'griffe', 'python', 'scripts/generate-docs.py'],
61 + directory: 'python',
62 + },
63 + },
64 +};
65 +
66 +type Plan = typeof ReleaseDocumentationPlan.Type;
67 +
68 +const targets = (plan: Plan) =>
69 + Object.fromEntries(plan.releases.map(release => [release.name, release.newVersion]));
70 +
71 +const versionTable = (plan: Plan) =>
72 + [
73 + '| SDK | Version |',
74 + '| --- | --- |',
75 + ...plan.releases.map(
76 + release =>
77 + `| ${LANGUAGE_DOCS[release.language].label(release.name)} | \`${release.newVersion}\` |`
78 + ),
79 + ].join('\n');
80 +
81 +const entryPath = (options: ReleaseNoteOptions) => {
82 + const [year, month, day] = options.date.split('-');
83 + return `docs/content/changelog/${month}-${day}-${year.slice(2)}-sdk-${options.releaseId}.mdx`;
84 +};
85 +
86 +// A backtick run that is not escaped, closed by a run of the same length, as CommonMark pairs them.
87 +const CODE = /((?<![\\`])(`+)(?!`)[\s\S]*?(?<!`)\2(?!`))/;
88 +
89 +/**
90 + * Keeps a contributor's changeset summary as Markdown while disabling MDX: braces and tags
91 + * outside code become literal text, and a line cannot start an `import` or `export` statement.
92 + */
93 +export const literalMdx = (markdown: string) =>
94 + markdown
95 + .split(CODE)
96 + .map((part, index) =>
97 + index % 3 === 1
98 + ? part
99 + : index % 3 === 2
100 + ? ''
101 + : part
102 + .replace(/[{}]/g, brace => `\\${brace}`)
103 + .replaceAll('<', '&lt;')
104 + .replace(
105 + /^(\s*)(import|export)\b/gm,
106 + (_match, indent: string, word: string) =>
107 + `${indent}&#${word.charCodeAt(0)};${word.slice(1)}`
108 + )
109 + )
110 + .join('');
111 +
112 +const renderEntry = (plan: Plan, options: ReleaseNoteOptions) => {
113 + const summaries = [
114 + ...new Set(plan.changesets.map(note => literalMdx(note.summary.trim())).filter(Boolean)),
115 + ];
116 + return `---\ntitle: ${JSON.stringify(`SDK release ${options.releaseId}`)}\ndate: ${JSON.stringify(options.date)}\nsdkRelease: ${JSON.stringify(options.releaseId)}\nsdkReleaseTargets: ${JSON.stringify(targets(plan))}\n---\n\nSee the [release request](${options.requestUrl}) for publication status.\n\n### SDK Versions\n\n${versionTable(plan)}\n\n### Changes\n\n${summaries.join('\n\n')}\n`;
117 +};
118 +
119 +/** Writes the release's changelog entry; preparation always starts from a clean checkout. */
120 +export const generateSdkReleaseNotes = (
121 + cwd: string,
122 + value: ReleaseDocumentationPlan,
123 + input: ReleaseNoteOptions
124 +) =>
125 + Effect.gen(function* () {
126 + const fs = yield* FileSystem.FileSystem;
127 + const path = yield* Path.Path;
128 + const plan = yield* Schema.decodeUnknownEffect(ReleaseDocumentationPlan)(value);
129 + const options = yield* Schema.decodeUnknownEffect(ReleaseNoteOptions)(input);
130 + if (!plan.releases.length)
131 + return yield* new ReleaseNotesError({ message: 'Nothing to document' });
132 + const relativePath = entryPath(options);
133 + const absolutePath = path.resolve(cwd, relativePath);
134 + yield* fs.makeDirectory(path.dirname(absolutePath), { recursive: true });
135 + yield* fs.writeFileString(absolutePath, renderEntry(plan, options), { flag: 'wx' });
136 + return relativePath;
137 + });
138 +
139 +/** Regenerates the symbol reference for each released language, streaming generator output. */
140 +export const generateSdkReleaseReferences = (cwd: string, value: ReleaseDocumentationPlan) =>
141 + Effect.gen(function* () {
142 + const path = yield* Path.Path;
143 + const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
144 + const plan = yield* Schema.decodeUnknownEffect(ReleaseDocumentationPlan)(value);
145 + const languages = [...new Set(plan.releases.map(release => release.language))];
146 + return yield* Effect.forEach(languages, language =>
147 + Effect.gen(function* () {
148 + const { command, args, directory } = LANGUAGE_DOCS[language].reference;
149 + const exitCode = yield* spawner.exitCode(
150 + ChildProcess.make(command, args, {
151 + cwd: path.resolve(cwd, directory),
152 + stdin: 'inherit',
153 + stdout: 'inherit',
154 + stderr: 'inherit',
155 + })
156 + );
157 + if (exitCode !== 0)
158 + return yield* new ReleaseNotesError({
159 + message: `${language} reference generation failed: ${exitCode}`,
160 + });
161 + return `docs/content/reference/sdk-reference/${language}`;
162 + })
163 + );
164 + });
docs/source.config.ts
+18 -14
@@ -117,8 +117,20 @@ export const docs = defineDocs({
117 },
118 });
119
120 -// Reference docs use defineCollections with custom mdxOptions to exclude twoslash
121 -// (SDK reference docs are auto-generated and don't need type checking)
120 +// No twoslash for generated SDK reference docs and changelog entries: a release's changelog can
121 +// describe APIs newer than the SDK versions the docs pin until the docs pin PR merges.
122 +const historicalMdxOptions = applyMdxPreset({
123 + // Match the global remark plugins so mermaid diagrams in merged
124 + // api-overviews render (applyMdxPreset replaces, not merges).
125 + remarkPlugins: [remarkMdxMermaid],
126 + rehypeCodeOptions: {
127 + themes: {
128 + light: 'github-light',
129 + dark: 'github-dark',
130 + },
131 + },
132 +});
133 +
134 export const reference = defineDocs({
135 dir: 'content/reference',
136 docs: {
@@ -126,18 +138,7 @@ export const reference = defineDocs({
138 postprocess: {
139 includeProcessedMarkdown: true,
140 },
129 - mdxOptions: applyMdxPreset({
130 - // Match the global remark plugins so mermaid diagrams in merged
131 - // api-overviews render (applyMdxPreset replaces, not merges).
132 - remarkPlugins: [remarkMdxMermaid],
133 - rehypeCodeOptions: {
134 - themes: {
135 - light: 'github-light',
136 - dark: 'github-dark',
137 - },
138 - // No twoslash transformer - SDK reference docs skip type checking
139 - },
140 - }),
141 + mdxOptions: historicalMdxOptions,
142 },
143 meta: {
144 schema: metaSchema,
@@ -187,10 +188,13 @@ export const knowledgeBase = defineDocs({
188 export const changelog = defineCollections({
189 type: 'doc',
190 dir: 'content/changelog',
191 + mdxOptions: historicalMdxOptions,
192 postprocess: {
193 includeProcessedMarkdown: true,
194 },
195 schema: frontmatterSchema.extend({
196 + sdkRelease: z.string().optional(),
197 + sdkReleaseTargets: z.record(z.string(), z.string()).optional(),
198 date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, {
199 message: 'Date must be in YYYY-MM-DD format (e.g., "2025-12-29")',
200 }),
docs/tests/integration/sdk-release-docs.test.ts new
+164
@@ -0,0 +1,164 @@
1 +import { afterEach, expect, test } from 'bun:test';
2 +import { mkdtemp, mkdir, readFile, rm, symlink, writeFile } from 'node:fs/promises';
3 +import { tmpdir } from 'node:os';
4 +import { dirname, join, resolve } from 'node:path';
5 +import { fileURLToPath, pathToFileURL } from 'node:url';
6 +import { createElement } from 'react';
7 +import { renderToStaticMarkup } from 'react-dom/server';
8 +import { compile, run } from '@mdx-js/mdx';
9 +import * as runtime from 'react/jsx-runtime';
10 +import { applyMdxPreset } from 'fumadocs-mdx/config';
11 +import { frontmatter } from 'fumadocs-core/content/md/frontmatter';
12 +import { remarkLLMs } from 'fumadocs-core/mdx-plugins/remark-llms';
13 +import * as BunServices from '@effect/platform-bun/BunServices';
14 +import { Effect } from 'effect';
15 +import type {
16 + ReleaseDocumentationPlan,
17 + ReleaseNoteOptions,
18 +} from '../../scripts/generate-sdk-release-notes';
19 +
20 +const docsRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
21 +const fixtures: string[] = [];
22 +
23 +async function fixture() {
24 + const directory = await mkdtemp(join(tmpdir(), 'composio-release-docs-'));
25 + fixtures.push(directory);
26 + return directory;
27 +}
28 +
29 +afterEach(async () => {
30 + await Promise.all(
31 + fixtures.splice(0).map(directory => rm(directory, { recursive: true, force: true }))
32 + );
33 +});
34 +
35 +const plan: ReleaseDocumentationPlan = {
36 + releases: [
37 + { name: '@composio/core', language: 'typescript', newVersion: '0.28.0' },
38 + { name: '@composio/python-sdk', language: 'python', newVersion: '0.30.1' },
39 + ],
40 + changesets: [{ summary: 'Keep reviewed migration guidance.' }],
41 +};
42 +const options = {
43 + releaseId: 'request-42',
44 + date: '2026-11-03',
45 + requestUrl: 'https://github.com/ComposioHQ/composio/issues/42',
46 +};
47 +
48 +test('historical release code renders with old docs SDK pins while maintained guide code fails', async () => {
49 + const directory = await fixture();
50 + await symlink(join(docsRoot, 'node_modules'), join(directory, 'node_modules'), 'dir');
51 + await mkdir(join(directory, 'changelog'));
52 + await mkdir(join(directory, 'guides'));
53 + const content = `---\ntitle: Release fixture\ndate: '2026-11-03'\n---\n\nSee the [release request](${options.requestUrl}).\n\n\`\`\`typescript\nimport { Composio } from '@composio/core';\nconst composio = new Composio({ apiKey: 'fixture' });\ncomposio.unpublishedReleaseFixture();\n\`\`\`\n\n\`\`\`mermaid\ngraph TD\n A --> B\n\`\`\`\n`;
54 + const historical = join(directory, 'changelog/release.mdx');
55 + const guide = join(directory, 'guides/current.mdx');
56 + await writeFile(historical, content);
57 + await writeFile(guide, content);
58 + const previousDirectory = process.cwd();
59 + const previousEnvironment = process.env.NODE_ENV;
60 + process.chdir(directory);
61 + process.env.NODE_ENV = 'production';
62 + try {
63 + const source: typeof import('../../source.config') = await import(
64 + `${pathToFileURL(join(docsRoot, 'source.config.ts')).href}?release-docs=${Date.now()}`
65 + );
66 + const compileCollection = async (path: string, historical: boolean) => {
67 + const collection = historical ? source.changelog : source.docs.docs;
68 + const global = source.default.mdxOptions;
69 + const globalOptions = typeof global === 'function' ? await global() : global;
70 + const configured = collection.mdxOptions ?? applyMdxPreset(globalOptions);
71 + const mdxOptions =
72 + typeof configured === 'function' ? await configured('bundler') : configured;
73 + const matter = frontmatter(await readFile(path, 'utf8'));
74 + const file = await compile(
75 + { value: matter.content, path },
76 + {
77 + ...mdxOptions,
78 + outputFormat: 'function-body',
79 + development: false,
80 + remarkPlugins: [
81 + ...(mdxOptions.remarkPlugins ?? []),
82 + ...(collection.postprocess?.includeProcessedMarkdown ? [remarkLLMs] : []),
83 + ],
84 + }
85 + );
86 + return run(String(file), { ...runtime, baseUrl: pathToFileURL(path) });
87 + };
88 + const compiled = await compileCollection(historical, true);
89 + const html = renderToStaticMarkup(
90 + createElement(compiled.default, {
91 + components: {
92 + Mermaid: ({ chart }: { chart: string }) => createElement('pre', null, chart),
93 + },
94 + })
95 + );
96 + expect(html).toContain(`href="${options.requestUrl}"`);
97 + expect(html).toContain('unpublishedReleaseFixture');
98 + expect(html).toContain('graph TD');
99 + expect(compiled._markdown).toContain(`[release request](${options.requestUrl})`);
100 + expect(compiled._markdown).toContain('unpublishedReleaseFixture');
101 + await expect(compileCollection(guide, false)).rejects.toThrow('unpublishedReleaseFixture');
102 + } finally {
103 + process.chdir(previousDirectory);
104 + if (previousEnvironment === undefined) delete process.env.NODE_ENV;
105 + else process.env.NODE_ENV = previousEnvironment;
106 + }
107 +}, 30000);
108 +
109 +const generateSdkReleaseNotes = async (
110 + directory: string,
111 + value: ReleaseDocumentationPlan,
112 + input: ReleaseNoteOptions
113 +) => {
114 + const notes = await import('../../scripts/generate-sdk-release-notes');
115 + return Effect.runPromise(
116 + notes.generateSdkReleaseNotes(directory, value, input).pipe(Effect.provide(BunServices.layer))
117 + );
118 +};
119 +
120 +test('release notes record the planned versions and changeset summaries once', async () => {
121 + const directory = await fixture();
122 + const contents = await readFile(
123 + join(directory, await generateSdkReleaseNotes(directory, plan, options)),
124 + 'utf8'
125 + );
126 + expect(contents).toContain('sdkRelease: "request-42"');
127 + expect(contents).toContain('| Python `composio` | `0.30.1` |');
128 + expect(contents).toContain('| TypeScript `@composio/core` | `0.28.0` |');
129 + expect(contents).toContain(`[release request](${options.requestUrl})`);
130 + expect(contents.match(/Keep reviewed migration guidance\./g)).toHaveLength(1);
131 +});
132 +
133 +test('no-op plans create no changelog', async () => {
134 + const directory = await fixture();
135 + await expect(
136 + generateSdkReleaseNotes(directory, { ...plan, releases: [], changesets: [] }, options)
137 + ).rejects.toThrow('Nothing to document');
138 + expect(
139 + await Bun.file(join(directory, 'docs/content/changelog/11-03-26-sdk-request-42.mdx')).exists()
140 + ).toBe(false);
141 +});
142 +
143 +test('changeset summaries render as literal Markdown, never as MDX code', async () => {
144 + const { literalMdx } = await import('../../scripts/generate-sdk-release-notes');
145 + const summary = [
146 + 'import fs from "node:fs"',
147 + 'Adds {globalThis.injected = true} and <script>alert(1)</script>.',
148 + 'Escaped \\`{globalThis.injected = true}` and mismatched `{globalThis.injected = true}`` runs.',
149 + 'Keep `{inline}` and:',
150 + '```ts\nconst value = { a: 1 };\n```',
151 + ].join('\n\n');
152 + const file = await compile(literalMdx(summary), {
153 + outputFormat: 'function-body',
154 + development: false,
155 + });
156 + const compiled = await run(String(file), { ...runtime, baseUrl: import.meta.url });
157 + const html = renderToStaticMarkup(createElement(compiled.default));
158 + expect((globalThis as { injected?: boolean }).injected).toBeUndefined();
159 + expect(html).toContain('import fs from');
160 + expect(html).toContain('{globalThis.injected = true}');
161 + expect(html).toContain('&lt;script&gt;');
162 + expect(html).toContain('<code>{inline}</code>');
163 + expect(html).toContain('const value = { a: 1 };');
164 +});
scripts/sdk-release/batch.ts new
+331
@@ -0,0 +1,331 @@
1 +import { Cause, Config, Console, Effect, Option, Path, Schema, Stdio, Stream } from 'effect';
2 +import { Base64 } from 'effect/encoding';
3 +import {
4 + CONTENT_CONCURRENCY,
5 + CreatedSha,
6 + GitHub,
7 + PositiveInt,
8 + REPOSITORY_PATH,
9 + RunId,
10 + Sha,
11 + commentIssue,
12 + fileAtOrNull,
13 + paginateArray,
14 + request,
15 + requestOptional,
16 + requireActiveMember,
17 + runUrl,
18 +} from './github';
19 +import { createSdkReleasePlan, type SdkReleasePlan } from './plan';
20 +import { Pull, isReleasePull, releaseBranch, releasePullBody } from './release-pr';
21 +import { ReleaseRequest, parseReleaseRequest } from './request';
22 +import {
23 + appendFile,
24 + ensure,
25 + fail,
26 + readJson,
27 + runMain,
28 + sameJson,
29 + type ReleaseServices,
30 +} from './runtime';
31 +import {
32 + BATCH_PATH,
33 + ReleaseBatch,
34 + ReleasePatch,
35 + releaseOutputs,
36 + validateReleaseDiff,
37 +} from './source';
38 +
39 +const Commit = Schema.Struct({
40 + sha: Sha,
41 + tree: Schema.Struct({ sha: Sha }),
42 + parents: Schema.Array(Schema.Struct({ sha: Sha })),
43 +});
44 +const CreatedRef = Schema.Struct({ ref: Schema.String });
45 +
46 +/** The open release PR into next, if any. Only one release runs at a time. */
47 +export const activeRelease = paginateArray(
48 + `${REPOSITORY_PATH}/pulls?state=open&base=next`,
49 + Pull
50 +).pipe(Stream.filter(isReleasePull), Stream.runHead);
51 +
52 +const causeMessage = (cause: Cause.Cause<unknown>) => {
53 + const error = Cause.squash(cause);
54 + return error instanceof Error ? error.message : 'Release request failed';
55 +};
56 +
57 +// 1. request -----------------------------------------------------------------------------------
58 +
59 +export interface ReleaseRequestContext {
60 + readonly actor: string;
61 + readonly runId: string;
62 + readonly sourceSha: string;
63 + readonly issueNumber?: number;
64 +}
65 +
66 +export interface ReleaseRequestResult {
67 + readonly message: string;
68 + readonly batch?: ReleaseBatch;
69 +}
70 +
71 +/** Opens the tracking issue for a dispatch-started release; issue-form requests already have one. */
72 +const createRequestIssue = (run: string) =>
73 + Effect.map(
74 + request('POST', `${REPOSITORY_PATH}/issues`, Schema.Struct({ number: PositiveInt }), {
75 + title: `SDK release ${run}`,
76 + body: `Requested from ${runUrl(run)}. The release PR, publication result and any failure are reported here.`,
77 + }),
78 + issue => issue.number
79 + );
80 +
81 +/**
82 + * Checks that the requester is an active ComposioHQ member, plans versions, and replies on the
83 + * request issue. Returns the batch to prepare, or only a message when there is nothing to do.
84 + */
85 +export const executeReleaseRequest = <E, R>(
86 + value: ReleaseRequest,
87 + context: ReleaseRequestContext,
88 + plan: (request: ReleaseRequest) => Effect.Effect<SdkReleasePlan, E, R>
89 +) =>
90 + Effect.gen(function* () {
91 + const releaseRequest = yield* Schema.decodeUnknownEffect(ReleaseRequest)(value);
92 + yield* requireActiveMember(context.actor);
93 + const reply = (text: string) =>
94 + context.issueNumber === undefined ? Effect.void : commentIssue(context.issueNumber, text);
95 + return yield* Effect.gen(function* () {
96 + const current = yield* activeRelease;
97 + if (Option.isSome(current)) {
98 + const result: ReleaseRequestResult = {
99 + message: `Another SDK release is in progress: ${current.value.html_url}. Request this release again after it finishes.`,
100 + };
101 + yield* reply(result.message);
102 + return result;
103 + }
104 + const selected = yield* plan(releaseRequest);
105 + if (!selected.releases.length) {
106 + const result: ReleaseRequestResult = { message: 'Nothing to release.' };
107 + yield* reply(result.message);
108 + return result;
109 + }
110 + const issue = context.issueNumber ?? (yield* createRequestIssue(context.runId));
111 + const batch = yield* Schema.decodeUnknownEffect(ReleaseBatch)({
112 + id: context.runId,
113 + inputBase: context.sourceSha,
114 + requestedBy: context.actor,
115 + issue,
116 + date: new Date().toISOString().slice(0, 10),
117 + plan: selected,
118 + });
119 + // The batch travels as one environment variable, which Linux caps at 128 KiB.
120 + yield* ensure(
121 + new TextEncoder().encode(JSON.stringify(batch)).length < 120_000,
122 + 'Release batch is too large to pass between jobs'
123 + );
124 + const result: ReleaseRequestResult = {
125 + message: `Planned. The release PR opens from ${runUrl(context.runId)}.`,
126 + batch,
127 + };
128 + yield* reply(result.message);
129 + return result;
130 + }).pipe(
131 + Effect.tapCause(cause =>
132 + reply(
133 + `The release request could not complete: ${causeMessage(cause)}\n\nInspect this request run: ${runUrl(context.runId)}`
134 + ).pipe(
135 + Effect.catchCause(reportCause =>
136 + Console.error(
137 + 'Could not report the release request failure:',
138 + causeMessage(reportCause)
139 + )
140 + )
141 + )
142 + )
143 + );
144 + });
145 +
146 +// 2. release PR --------------------------------------------------------------------------------
147 +
148 +/** Commits the prepared files on top of the frozen source and points the release branch at it. */
149 +const commitReleaseBranch = (batch: ReleaseBatch, patch: ReleasePatch) =>
150 + Effect.gen(function* () {
151 + const source = yield* request(
152 + 'GET',
153 + `${REPOSITORY_PATH}/git/commits/${batch.inputBase}`,
154 + Commit
155 + );
156 + const blobs = yield* Effect.forEach(
157 + patch.files,
158 + file =>
159 + file.after === null
160 + ? Effect.succeed({
161 + path: file.path,
162 + mode: '100644',
163 + type: 'blob',
164 + sha: null as string | null,
165 + })
166 + : Effect.map(
167 + request('POST', `${REPOSITORY_PATH}/git/blobs`, CreatedSha, {
168 + content: Base64.encode(file.after),
169 + encoding: 'base64',
170 + }),
171 + blob => ({ path: file.path, mode: '100644', type: 'blob', sha: blob.sha })
172 + ),
173 + { concurrency: CONTENT_CONCURRENCY }
174 + );
175 + const tree = yield* request('POST', `${REPOSITORY_PATH}/git/trees`, CreatedSha, {
176 + base_tree: source.tree.sha,
177 + tree: blobs,
178 + });
179 + const commit = yield* request('POST', `${REPOSITORY_PATH}/git/commits`, CreatedSha, {
180 + message: 'chore(release): prepare SDK versions and documentation',
181 + parents: [batch.inputBase],
182 + tree: tree.sha,
183 + });
184 + const branch = releaseBranch(batch.id);
185 + // A re-run of this job replaces its own branch; the batch ID is unique to the request run.
186 + const existing = yield* requestOptional(
187 + `${REPOSITORY_PATH}/git/ref/heads/${branch}`,
188 + CreatedRef
189 + );
190 + if (Option.isSome(existing))
191 + yield* request('PATCH', `${REPOSITORY_PATH}/git/refs/heads/${branch}`, CreatedRef, {
192 + sha: commit.sha,
193 + force: true,
194 + });
195 + else
196 + yield* request('POST', `${REPOSITORY_PATH}/git/refs`, CreatedRef, {
197 + ref: `refs/heads/${branch}`,
198 + sha: commit.sha,
199 + });
200 + return branch;
201 + });
202 +
203 +/** Checks the prepared patch is release-only for `batch`, commits it and opens the release PR. */
204 +export const openReleasePull = (cwd: string, planned: ReleaseBatch, value: unknown) =>
205 + Effect.gen(function* () {
206 + // Decoding both sides puts their keys in schema order, so the JSON comparison below is exact.
207 + const batch = yield* Schema.decodeUnknownEffect(ReleaseBatch)(planned);
208 + const patch = yield* Schema.decodeUnknownEffect(ReleasePatch)(value);
209 + const current = yield* activeRelease;
210 + if (Option.isSome(current)) {
211 + // A re-run after the PR opened repeats the issue link in case that comment failed.
212 + if (current.value.head.ref === releaseBranch(batch.id)) {
213 + yield* commentIssue(batch.issue, `Release PR: ${current.value.html_url}`);
214 + return current.value.html_url;
215 + }
216 + // Not a failure of this run: the requester is told what to do, and nothing was created.
217 + yield* commentIssue(
218 + batch.issue,
219 + `Another SDK release is in progress: ${current.value.html_url}. Request this release again after it finishes.`
220 + );
221 + return undefined;
222 + }
223 + const frozen = yield* Effect.forEach(
224 + patch.files,
225 + file => fileAtOrNull(file.path, batch.inputBase),
226 + { concurrency: CONTENT_CONCURRENCY }
227 + );
228 + for (const [index, file] of patch.files.entries())
229 + yield* ensure(
230 + frozen[index] === file.before,
231 + `Prepared input differs from frozen source: ${file.path}`
232 + );
233 + const planFile = patch.files.find(file => file.path === BATCH_PATH)?.after;
234 + yield* ensure(
235 + planFile !== undefined &&
236 + planFile !== null &&
237 + sameJson(
238 + yield* Schema.decodeUnknownEffect(Schema.fromJsonString(ReleaseBatch))(planFile),
239 + batch
240 + ),
241 + 'Prepared release plan differs from the planned batch'
242 + );
243 + const outputs = yield* releaseOutputs(cwd, batch);
244 + yield* validateReleaseDiff(patch.files, batch.plan, outputs);
245 + const branch = yield* commitReleaseBranch(batch, patch);
246 + const pull = yield* request('POST', `${REPOSITORY_PATH}/pulls`, Pull, {
247 + title: 'chore(release): publish SDK packages',
248 + head: branch,
249 + base: 'next',
250 + body: releasePullBody(batch, branch, outputs),
251 + });
252 + yield* commentIssue(batch.issue, `Release PR: ${pull.html_url}`);
253 + return pull.html_url;
254 + });
255 +
256 +// entry point ----------------------------------------------------------------------------------
257 +
258 +const Environment = Config.all({
259 + token: Config.schema(Schema.NonEmptyString, 'SDK_RELEASE_TOKEN'),
260 + runId: Config.schema(RunId, 'GITHUB_RUN_ID'),
261 + sha: Config.schema(Sha, 'GITHUB_SHA'),
262 + eventPath: Config.String('GITHUB_EVENT_PATH'),
263 + eventName: Config.String('GITHUB_EVENT_NAME'),
264 + outputPath: Config.String('GITHUB_OUTPUT'),
265 + summaryPath: Config.String('GITHUB_STEP_SUMMARY'),
266 +});
267 +type Environment = Config.Success<typeof Environment>;
268 +
269 +const EventEnvelope = Schema.Struct({
270 + sender: Schema.Struct({ login: Schema.String }),
271 + issue: Schema.optionalKey(Schema.Struct({ number: PositiveInt })),
272 + pull_request: Schema.optionalKey(Schema.Struct({ number: PositiveInt })),
273 +});
274 +
275 +const plannedBatch = Config.schema(Schema.fromJsonString(ReleaseBatch), 'SDK_RELEASE_BATCH');
276 +
277 +type Mode = (
278 + env: Environment,
279 + event: unknown,
280 + envelope: typeof EventEnvelope.Type
281 +) => Effect.Effect<void, unknown, GitHub | ReleaseServices>;
282 +
283 +const MODES: Record<'plan' | 'release-pr', Mode> = {
284 + plan: (env: Environment, event: unknown, envelope: typeof EventEnvelope.Type) =>
285 + Effect.gen(function* () {
286 + const cwd = (yield* Path.Path).resolve('.');
287 + const releaseRequest = yield* Effect.try(() => parseReleaseRequest(env.eventName, event));
288 + const result = yield* executeReleaseRequest(
289 + releaseRequest,
290 + {
291 + actor: envelope.sender.login,
292 + runId: env.runId,
293 + sourceSha: env.sha,
294 + ...(envelope.issue ? { issueNumber: envelope.issue.number } : {}),
295 + },
296 + choices => createSdkReleasePlan(cwd, choices)
297 + );
298 + if (result.batch) {
299 + yield* appendFile(env.outputPath, `batch=${JSON.stringify(result.batch)}\n`);
300 + }
301 + yield* appendFile(env.summaryPath, `${result.message}\n`);
302 + }),
303 + 'release-pr': (env: Environment) =>
304 + Effect.gen(function* () {
305 + const [, patchPath] = yield* (yield* Stdio.Stdio).args;
306 + if (!patchPath) return yield* fail('Expected the prepared patch path');
307 + const url = yield* openReleasePull(
308 + (yield* Path.Path).resolve('.'),
309 + yield* plannedBatch,
310 + yield* readJson(Schema.Unknown, patchPath)
311 + );
312 + yield* appendFile(
313 + env.summaryPath,
314 + url ? `Release PR: ${url}\n` : 'Another SDK release is in progress.\n'
315 + );
316 + }),
317 +};
318 +
319 +/** `batch.ts plan` or `batch.ts release-pr <patch>`. */
320 +const main = Effect.gen(function* () {
321 + const [argument] = yield* (yield* Stdio.Stdio).args;
322 + const mode = yield* Schema.decodeUnknownEffect(Schema.Literals(['plan', 'release-pr']))(
323 + argument
324 + );
325 + const env = yield* Environment;
326 + const event = yield* readJson(Schema.Unknown, env.eventPath);
327 + const envelope = yield* Schema.decodeUnknownEffect(EventEnvelope)(event);
328 + yield* MODES[mode](env, event, envelope).pipe(Effect.provide(GitHub.layer(env.token)));
329 +});
330 +
331 +if (import.meta.main) runMain(main);
scripts/sdk-release/changelog-filter.sh new
+16
@@ -0,0 +1,16 @@
1 +#!/usr/bin/env bash
2 +# Reads changelog paths from stdin and prints those that are not generated SDK release entries,
3 +# which carry `sdkRelease:` in their frontmatter.
4 +set -euo pipefail
5 +
6 +while IFS= read -r path; do
7 + [ -n "$path" ] || continue
8 + if ! awk '
9 + NR == 1 { if ($0 !~ /^---\r?$/) exit 1; next }
10 + /^---\r?$/ { exit 1 }
11 + /^sdkRelease[[:space:]]*:[[:space:]]*[^[:space:]]/ { found = 1; exit 0 }
12 + END { exit !found }
13 + ' "$path"; then
14 + printf '%s\n' "$path"
15 + fi
16 +done
scripts/sdk-release/github.ts new
+219
@@ -0,0 +1,219 @@
1 +import { Context, Data, Effect, Layer, Option, Schema, Stream } from 'effect';
2 +import { FetchHttpClient, HttpClient, HttpClientRequest } from 'effect/http';
3 +import { ensure } from './runtime';
4 +
5 +export const SDK_RELEASE_REPOSITORY = 'ComposioHQ/composio';
6 +export const REPOSITORY_PATH = `/repos/${SDK_RELEASE_REPOSITORY}`;
7 +export const runUrl = (id: string | number) =>
8 + `https://github.com/${SDK_RELEASE_REPOSITORY}/actions/runs/${id}`;
9 +const PAGE_SIZE = 100;
10 +/** Bounded so large release diffs stay under GitHub's secondary rate limit. */
11 +export const CONTENT_CONCURRENCY = 8;
12 +
13 +export const RunId = Schema.String.check(Schema.isPattern(/^[1-9][0-9]*$/));
14 +export const Sha = Schema.String.check(Schema.isPattern(/^[a-f0-9]{40}$/));
15 +export const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
16 +export const PositiveIntFromString = Schema.NumberFromString.check(
17 + Schema.isInt(),
18 + Schema.isGreaterThan(0)
19 +);
20 +export const TagRef = Schema.Struct({ object: Schema.Struct({ type: Schema.String, sha: Sha }) });
21 +export const CreatedSha = Schema.Struct({ sha: Sha });
22 +const Login = Schema.String.check(Schema.isPattern(/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38})$/));
23 +
24 +export const ReleaseRun = Schema.Struct({
25 + id: PositiveInt,
26 + path: Schema.String,
27 + head_sha: Schema.optionalKey(Sha),
28 + event: Schema.optionalKey(Schema.String),
29 + repository: Schema.Struct({ full_name: Schema.String }),
30 + conclusion: Schema.NullOr(Schema.String),
31 + html_url: Schema.String.check(Schema.isPattern(/^https:\/\//)),
32 +});
33 +export type ReleaseRun = typeof ReleaseRun.Type;
34 +
35 +const ReleaseJob = Schema.Struct({
36 + name: Schema.String,
37 + status: Schema.optionalKey(Schema.String),
38 + conclusion: Schema.optionalKey(Schema.NullOr(Schema.String)),
39 + started_at: Schema.optionalKey(Schema.NullOr(Schema.String)),
40 + completed_at: Schema.optionalKey(Schema.NullOr(Schema.String)),
41 + steps: Schema.Array(
42 + Schema.Struct({
43 + name: Schema.String,
44 + conclusion: Schema.NullOr(Schema.String),
45 + started_at: Schema.optionalKey(Schema.NullOr(Schema.String)),
46 + completed_at: Schema.optionalKey(Schema.NullOr(Schema.String)),
47 + })
48 + ).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
49 +});
50 +
51 +export type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
52 +
53 +export class GitHubApiError extends Data.TaggedError('GitHubApiError')<{
54 + readonly status: number;
55 + readonly method: HttpMethod;
56 + readonly path: string;
57 + readonly message: string;
58 +}> {}
59 +
60 +const decodeBody = <S extends Schema.Top>(schema: S, text: string) =>
61 + text === ''
62 + ? Schema.decodeUnknownEffect(schema)(undefined)
63 + : Schema.decodeUnknownEffect(Schema.fromJsonString(schema))(text);
64 +
65 +const makeGitHub = (token: string) =>
66 + Effect.gen(function* () {
67 + const client = yield* HttpClient.HttpClient;
68 + const send = (
69 + method: HttpMethod,
70 + path: string,
71 + body: unknown,
72 + redirect: RequestRedirect,
73 + accept = 'application/vnd.github+json'
74 + ) =>
75 + Effect.gen(function* () {
76 + yield* ensure(path.startsWith('/') && !path.startsWith('//'), 'Expected a GitHub API path');
77 + const base = HttpClientRequest.make(method)(`https://api.github.com${path}`, {
78 + headers: {
79 + accept,
80 + authorization: `Bearer ${token}`,
81 + 'x-github-api-version': '2026-03-10',
82 + },
83 + });
84 + return yield* client.execute(
85 + body === undefined ? base : HttpClientRequest.bodyJsonUnsafe(base, body)
86 + );
87 + }).pipe(Effect.provideService(FetchHttpClient.RequestInit, { redirect }));
88 + const failure = (method: HttpMethod, path: string, status: number) =>
89 + new GitHubApiError({
90 + status,
91 + method,
92 + path,
93 + message: `GitHub ${method} ${path} failed (${status})`,
94 + });
95 + return {
96 + request: <S extends Schema.Top>(
97 + method: HttpMethod,
98 + path: string,
99 + schema: S,
100 + body?: unknown
101 + ) =>
102 + Effect.gen(function* () {
103 + const response = yield* send(method, path, body, 'error');
104 + if (response.status < 200 || response.status >= 300)
105 + return yield* failure(method, path, response.status);
106 + return yield* decodeBody(schema, yield* response.text);
107 + }),
108 + /** A file's raw contents, or `None` on 404. Raw media works for files over 1 MB. */
109 + raw: (path: string) =>
110 + Effect.gen(function* () {
111 + const response = yield* send(
112 + 'GET',
113 + path,
114 + undefined,
115 + 'error',
116 + 'application/vnd.github.raw'
117 + );
118 + if (response.status === 404) return Option.none<string>();
119 + if (response.status < 200 || response.status >= 300)
120 + return yield* failure('GET', path, response.status);
121 + return Option.some(yield* response.text);
122 + }),
123 + /** Resolves an endpoint that answers with a 302 to short-lived storage, such as an artifact archive. */
124 + redirectLocation: (path: string) =>
125 + Effect.gen(function* () {
126 + const response = yield* send('GET', path, undefined, 'manual');
127 + if (response.status !== 302) return yield* failure('GET', path, response.status);
128 + return Option.fromNullishOr(response.headers.location);
129 + }),
130 + };
131 + });
132 +
133 +/** The controller's GitHub App installation client. Only trusted controller entry points provide it. */
134 +export class GitHub extends Context.Service<
135 + GitHub,
136 + Effect.Success<ReturnType<typeof makeGitHub>>
137 +>()('sdk-release/GitHub') {
138 + static readonly layer = (token: string) => Layer.effect(GitHub, makeGitHub(token));
139 +}
140 +
141 +export const request = <S extends Schema.Top>(
142 + method: HttpMethod,
143 + path: string,
144 + schema: S,
145 + body?: unknown
146 +) =>
147 + Effect.gen(function* () {
148 + const github = yield* GitHub;
149 + return yield* github.request(method, path, schema, body);
150 + });
151 +
152 +/** Optional lookup: a 404 becomes `None`; every other failure still fails. */
153 +export const requestOptional = <S extends Schema.Top>(path: string, schema: S) =>
154 + request('GET', path, schema).pipe(
155 + Effect.map(Option.some),
156 + Effect.catchTag('GitHubApiError', error =>
157 + error.status === 404 ? Effect.succeedNone : Effect.fail(error)
158 + )
159 + );
160 +
161 +/** Streams a paginated list endpoint until GitHub returns a short page. */
162 +export const paginate = <S extends Schema.Top, A>(
163 + path: string,
164 + page: S,
165 + items: (body: S['Type']) => ReadonlyArray<A>
166 +) =>
167 + Stream.paginate(1, (index: number) =>
168 + request(
169 + 'GET',
170 + `${path}${path.includes('?') ? '&' : '?'}per_page=${PAGE_SIZE}&page=${index}`,
171 + page
172 + ).pipe(
173 + Effect.map(body => {
174 + const found = items(body);
175 + return [found, found.length < PAGE_SIZE ? Option.none() : Option.some(index + 1)] as const;
176 + })
177 + )
178 + );
179 +
180 +export const paginateArray = <S extends Schema.Top>(path: string, item: S) =>
181 + paginate(path, Schema.Array(item), body => body);
182 +
183 +export const requireActiveMember = (login: string) =>
184 + Effect.gen(function* () {
185 + const user = yield* Schema.decodeUnknownEffect(Login)(login);
186 + const membership = yield* request(
187 + 'GET',
188 + `/orgs/ComposioHQ/memberships/${encodeURIComponent(user)}`,
189 + Schema.Struct({ state: Schema.Literals(['active', 'pending']) })
190 + );
191 + yield* ensure(membership.state === 'active', 'An active ComposioHQ membership is required');
192 + });
193 +
194 +export const commentIssue = (issueNumber: number, body: string) =>
195 + Effect.gen(function* () {
196 + const issue = yield* Schema.decodeUnknownEffect(PositiveInt)(issueNumber);
197 + yield* request(
198 + 'POST',
199 + `${REPOSITORY_PATH}/issues/${issue}/comments`,
200 + Schema.Struct({ id: Schema.Number }),
201 + { body }
202 + );
203 + });
204 +
205 +/** A file's UTF-8 contents at `sha`, or `None` when it does not exist there. */
206 +export const fileAt = (path: string, sha: string) =>
207 + Effect.flatMap(GitHub, github => github.raw(`${REPOSITORY_PATH}/contents/${path}?ref=${sha}`));
208 +export const fileAtOrNull = (path: string, sha: string) =>
209 + Effect.map(fileAt(path, sha), Option.getOrNull);
210 +
211 +/** A run's jobs across pages: from every attempt, or only from the latest one. */
212 +export const jobs = (id: string, filter: 'all' | 'latest' = 'all') =>
213 + Stream.runCollect(
214 + paginate(
215 + `${REPOSITORY_PATH}/actions/runs/${id}/jobs?filter=${filter}`,
216 + Schema.Struct({ jobs: Schema.Array(ReleaseJob) }),
217 + body => body.jobs
218 + )
219 + );
scripts/sdk-release/prepare.ts new
+98
@@ -0,0 +1,98 @@
1 +import { Config, Effect, Option, Path, Schema, Stdio } from 'effect';
2 +import {
3 + generateSdkReleaseNotes,
4 + generateSdkReleaseReferences,
5 +} from '../../docs/scripts/generate-sdk-release-notes';
6 +import { applySdkReleasePlan } from './plan';
7 +import {
8 + ensure,
9 + fail,
10 + formatJson,
11 + readOptionalFile,
12 + run,
13 + runMain,
14 + spawn,
15 + withoutReleaseTokens,
16 + writeFile,
17 +} from './runtime';
18 +import {
19 + BATCH_PATH,
20 + ReleaseBatch,
21 + ReleasePatch,
22 + issueUrl,
23 + releaseOutputs,
24 + validateReleaseDiff,
25 +} from './source';
26 +
27 +const git = (cwd: string, ...args: ReadonlyArray<string>) =>
28 + run('git', args, { cwd, env: withoutReleaseTokens });
29 +
30 +const nulSeparated = (output: string) => output.split('\0').filter(Boolean);
31 +
32 +/** A changed path's contents at the frozen input base and in the prepared checkout. */
33 +const releaseFile = (cwd: string, inputBase: string, file: string) =>
34 + Effect.gen(function* () {
35 + const path = yield* Path.Path;
36 + const original = yield* spawn('git', ['show', `${inputBase}:${file}`], {
37 + cwd,
38 + env: withoutReleaseTokens,
39 + });
40 + return {
41 + path: file,
42 + before: original.exitCode === 0 ? original.stdout : null,
43 + after: Option.getOrNull(yield* readOptionalFile(path.resolve(cwd, file))),
44 + };
45 + });
46 +
47 +/** Applies a planned batch to a clean checkout of its source and returns the changed files. */
48 +export const prepareRelease = (cwd: string, batch: ReleaseBatch) =>
49 + Effect.gen(function* () {
50 + const path = yield* Path.Path;
51 + yield* ensure(
52 + (yield* git(cwd, 'rev-parse', 'HEAD')).trim() === batch.inputBase,
53 + 'Preparation checkout does not match the planned source'
54 + );
55 + yield* ensure(
56 + (yield* git(cwd, 'status', '--porcelain')).trim() === '',
57 + 'Preparation requires a clean source checkout'
58 + );
59 + yield* applySdkReleasePlan(cwd, batch.plan);
60 + yield* run('pnpm', ['install', '--lockfile-only', '--ignore-scripts'], {
61 + cwd,
62 + env: withoutReleaseTokens,
63 + });
64 + yield* generateSdkReleaseReferences(cwd, batch.plan);
65 + yield* generateSdkReleaseNotes(cwd, batch.plan, {
66 + releaseId: batch.id,
67 + date: batch.date,
68 + requestUrl: issueUrl(batch),
69 + });
70 + yield* writeFile(path.resolve(cwd, BATCH_PATH), formatJson(batch));
71 + const changed = new Set([
72 + ...nulSeparated(yield* git(cwd, 'diff', '--name-only', '-z', batch.inputBase)),
73 + ...nulSeparated(yield* git(cwd, 'ls-files', '--others', '--exclude-standard', '-z')),
74 + ]);
75 + const files = yield* Effect.forEach(
76 + [...changed].sort(),
77 + file => releaseFile(cwd, batch.inputBase, file),
78 + { concurrency: 8 }
79 + );
80 + yield* validateReleaseDiff(files, batch.plan, yield* releaseOutputs(cwd, batch));
81 + return yield* Schema.decodeUnknownEffect(ReleasePatch)({ files });
82 + });
83 +
84 +/** `prepare.ts <patch-path>` with the planned batch in `SDK_RELEASE_BATCH`. */
85 +const main = Effect.gen(function* () {
86 + const [output] = yield* (yield* Stdio.Stdio).args;
87 + if (!output) return yield* fail('Expected the patch output path');
88 + const token = yield* Config.option(Config.String('SDK_RELEASE_TOKEN'));
89 + yield* ensure(
90 + Option.isNone(token) || token.value === '',
91 + 'Preparation must not receive a controller credential'
92 + );
93 + const batch = yield* Config.schema(Schema.fromJsonString(ReleaseBatch), 'SDK_RELEASE_BATCH');
94 + const patch = yield* prepareRelease((yield* Path.Path).resolve('.'), batch);
95 + yield* writeFile(output, `${JSON.stringify(patch)}\n`);
96 +});
97 +
98 +if (import.meta.main) runMain(main);
scripts/sdk-release/release-pr.ts new
+132
@@ -0,0 +1,132 @@
1 +import { Schema } from 'effect';
2 +import { PositiveInt, SDK_RELEASE_REPOSITORY, Sha, runUrl } from './github';
3 +import { PYTHON_RELEASE_MARKER } from './lanes';
4 +import { issueUrl, type ReleaseBatch } from './source';
5 +
6 +const RELEASE_BRANCH = /^sdk-release\/batch-\d+$/;
7 +
8 +export const releaseBranch = (id: string) => `sdk-release/batch-${id}`;
9 +
10 +export const Pull = Schema.Struct({
11 + number: PositiveInt,
12 + html_url: Schema.String,
13 + state: Schema.String,
14 + merged: Schema.optionalKey(Schema.Boolean),
15 + merge_commit_sha: Schema.optionalKey(Schema.NullOr(Sha)),
16 + /** `null` when the author's account was deleted. */
17 + user: Schema.NullOr(Schema.Struct({ login: Schema.String })),
18 + head: Schema.Struct({
19 + sha: Sha,
20 + ref: Schema.String,
21 + repo: Schema.NullOr(Schema.Struct({ full_name: Schema.String })),
22 + }),
23 + base: Schema.Struct({ ref: Schema.String }),
24 +});
25 +export type Pull = typeof Pull.Type;
26 +
27 +export const isReleasePull = (pull: Pull) =>
28 + pull.head.repo?.full_name === SDK_RELEASE_REPOSITORY && RELEASE_BRANCH.test(pull.head.ref);
29 +
30 +const NOTE_EXEMPT =
31 + '<!-- sdk-release-note-exempt: This release PR applies previously reviewed SDK changes and only updates release metadata and generated documentation. -->';
32 +const SUMMARY_LIMIT = 200;
33 +
34 +type Plan = ReleaseBatch['plan'];
35 +type Changeset = Plan['changesets'][number];
36 +
37 +const repositoryUrl = `https://github.com/${SDK_RELEASE_REPOSITORY}`;
38 +const fileUrl = (branch: string, path: string) =>
39 + `${repositoryUrl}/${path.endsWith('/') ? 'tree' : 'blob'}/${branch}/${path}`;
40 +
41 +/** Shows contributor text literally, so it cannot hide or add content in the reviewed body. */
42 +const escapeMarkdown = (text: string) =>
43 + text
44 + .replaceAll('&', '&amp;')
45 + .replaceAll('<', '&lt;')
46 + .replaceAll('>', '&gt;')
47 + .replace(/[\\`*_[\]()|#!]/g, '\\$&');
48 +
49 +/** npm-valid names render as code; anything else renders as escaped text. */
50 +const SAFE_PACKAGE_NAME = /^@composio\/[a-z0-9][a-z0-9._-]*$/;
51 +export const packageLabel = (name: string) =>
52 + name === PYTHON_RELEASE_MARKER
53 + ? 'Python SDK (`composio` and every provider)'
54 + : SAFE_PACKAGE_NAME.test(name)
55 + ? `\`${name}\``
56 + : escapeMarkdown(name);
57 +
58 +/** First line of a changeset summary, short enough for one list item. */
59 +const headline = (summary: string) => {
60 + const line = summary.trim().split('\n')[0]?.trim() || '(no summary)';
61 + return escapeMarkdown(
62 + line.length > SUMMARY_LIMIT ? `${line.slice(0, SUMMARY_LIMIT - 1)}…` : line
63 + );
64 +};
65 +
66 +const changesetLine = (note: Changeset) => {
67 + const bumps = note.releases
68 + .filter(release => release.type !== 'none')
69 + .map(release => `${packageLabel(release.name)} ${release.type}`)
70 + .join(', ');
71 + return `- \`.changeset/${note.id}.md\` (${bumps || 'no version bump'}): ${headline(note.summary)}`;
72 +};
73 +
74 +const packageRows = (plan: Plan) =>
75 + plan.releases.map(release => {
76 + const recommended = plan.recommended.find(candidate => candidate.name === release.name);
77 + const override =
78 + recommended?.newVersion === release.newVersion
79 + ? ''
80 + : ` (recommended ${recommended?.newVersion ?? 'none'})`;
81 + const notes = release.changesets.map(id => `\`${id}\``).join(', ') || 'maintenance release';
82 + return `| ${packageLabel(release.name)} | ${release.oldVersion} → **${release.newVersion}**${override} | ${release.type} | ${notes} |`;
83 + });
84 +
85 +/** Lists what ships, which changesets it consumes, and which changelogs and docs it edits. */
86 +export const releasePullBody = (
87 + batch: ReleaseBatch,
88 + branch: string,
89 + outputs: ReadonlyArray<string>
90 +) => {
91 + const { plan } = batch;
92 + const changelogs = outputs.filter(path => path.endsWith('/CHANGELOG.md'));
93 + const docsChangelog = outputs.filter(path => path.startsWith('docs/content/changelog/'));
94 + const references = outputs.filter(path =>
95 + path.startsWith('docs/content/reference/sdk-reference/')
96 + );
97 + const link = (path: string) => `[\`${path}\`](${fileUrl(branch, path)})`;
98 + const sections = [
99 + NOTE_EXEMPT,
100 + '## What gets released',
101 + [
102 + '| Package | Version | Bump | Changesets |',
103 + '| --- | --- | --- | --- |',
104 + ...packageRows(plan),
105 + ].join('\n'),
106 + '## Changesets consumed',
107 + plan.changesets.map(changesetLine).join('\n') || 'None: this is a maintenance release.',
108 + ...(plan.retainedChangesets.length
109 + ? [
110 + '## Changesets left for a later release',
111 + 'These entries target a language this release skips. Their files stay in `.changeset/` with only these entries.',
112 + plan.retainedChangesets.map(changesetLine).join('\n'),
113 + ]
114 + : []),
115 + '## Changelog and docs edits',
116 + [
117 + `- Docs changelog entry: ${docsChangelog.map(link).join(', ') || 'none'}.`,
118 + `- Package changelogs: ${changelogs.map(link).join(', ') || 'none'}.`,
119 + `- Regenerated API references: ${references.map(link).join(', ') || 'none'}.`,
120 + ].join('\n'),
121 + '## How this ships',
122 + [
123 + `1. Release source is frozen at ${batch.inputBase}. Later \`next\` commits and their changesets wait for the next release.`,
124 + `2. Review the diff and approve this head. Approval must come from a writer other than the requester (@${batch.requestedBy}). Do not push to this branch: the tag step only accepts the release bot's commit. To change the notes, fix the changesets on \`next\`, close this PR and request a new release.`,
125 + `3. After approval and green checks, merge this PR. The release workflow rechecks the approval and tags this exact head \`sdk-release/${batch.id}\`; if the check fails, it creates no tag and asks you to revert this PR and request the release again.`,
126 + '4. The tag run publishes the exact files the `SDK candidate` checks built and the `SDK candidate smoke` checks installed on this PR. If a publish job fails, use "Re-run failed jobs" on that run.',
127 + '5. After publishing, the bot opens a docs PR that pins the released npm versions, so twoslash checks the docs against them.',
128 + ].join('\n'),
129 + `Request: ${issueUrl(batch)}\nPlanning run: ${runUrl(batch.id)}`,
130 + ];
131 + return sections.join('\n\n');
132 +};
scripts/sdk-release/request.ts new
+39
@@ -0,0 +1,39 @@
1 +import { Schema } from 'effect';
2 +import { autoByDefault } from './plan';
3 +
4 +/** Per-language bump choices; `auto` follows the changesets. */
5 +export const ReleaseRequest = Schema.Struct({ typescript: autoByDefault, python: autoByDefault });
6 +export type ReleaseRequest = typeof ReleaseRequest.Type;
7 +
8 +const Dispatch = Schema.Struct({
9 + inputs: Schema.Record(Schema.String, Schema.Unknown),
10 +});
11 +const Issue = Schema.Struct({ issue: Schema.Struct({ body: Schema.String }) });
12 +
13 +/** Issue-form headings and the request fields they fill. */
14 +const ISSUE_FIELDS = { TypeScript: 'typescript', Python: 'python' } as const;
15 +const ISSUE_FIELD_PATTERN = /^### (TypeScript|Python)\r?\n\r?\n([\s\S]*?)(?=^### |$(?![\s\S]))/gm;
16 +
17 +const parseIssueBody = (body: string) => {
18 + const fields = new Map<keyof typeof ISSUE_FIELDS, string>();
19 + for (const match of body.matchAll(ISSUE_FIELD_PATTERN)) {
20 + const heading = match[1] as keyof typeof ISSUE_FIELDS;
21 + if (fields.has(heading)) throw new Error(`Duplicate release field: ${heading}`);
22 + fields.set(heading, match[2].trim());
23 + }
24 + if (fields.size !== Object.keys(ISSUE_FIELDS).length)
25 + throw new Error('Use the SDK release request issue form');
26 + return Object.fromEntries([...fields].map(([heading, value]) => [ISSUE_FIELDS[heading], value]));
27 +};
28 +
29 +/** Reads the same request from a workflow dispatch or from the issue form. */
30 +export function parseReleaseRequest(eventName: string, payload: unknown): ReleaseRequest {
31 + const fields =
32 + eventName === 'workflow_dispatch'
33 + ? Schema.decodeUnknownSync(Dispatch)(payload).inputs
34 + : eventName === 'issues'
35 + ? parseIssueBody(Schema.decodeUnknownSync(Issue)(payload).issue.body)
36 + : undefined;
37 + if (!fields) throw new Error('Unsupported SDK release request event');
38 + return Schema.decodeUnknownSync(ReleaseRequest)(fields);
39 +}
scripts/sdk-release/source.ts new
+307
@@ -0,0 +1,307 @@
1 +import { Effect, Schema } from 'effect';
2 +import { getPackages } from '@manypkg/get-packages';
3 +import semver from 'semver';
4 +import { PositiveInt, RunId, SDK_RELEASE_REPOSITORY, Sha } from './github';
5 +import { PYTHON_RELEASE_MARKER, type Language } from './lanes';
6 +import { SdkReleasePlan } from './plan';
7 +import { PROJECT_VERSION, RUNTIME_VERSION, SETUP_VERSION } from './python-metadata';
8 +import { ensure, fail, fromPromise } from './runtime';
9 +
10 +/** One release request: who asked, the frozen source, and the planned versions. */
11 +export const ReleaseBatch = Schema.Struct({
12 + id: RunId,
13 + /** The protected `next` commit the release is planned from. */
14 + inputBase: Sha,
15 + /** The member who requested this release; they may not approve it. */
16 + requestedBy: Schema.String,
17 + /** The issue that tracks this release. */
18 + issue: PositiveInt,
19 + date: Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/)),
20 + plan: SdkReleasePlan,
21 +});
22 +export type ReleaseBatch = typeof ReleaseBatch.Type;
23 +export const BATCH_PATH = '.github/sdk-release-plan.json';
24 +
25 +export const issueUrl = (batch: ReleaseBatch) =>
26 + `https://github.com/${SDK_RELEASE_REPOSITORY}/issues/${batch.issue}`;
27 +
28 +export const batchLanguages = (batch: {
29 + readonly plan: { readonly releases: ReadonlyArray<{ readonly language: Language }> };
30 +}) => new Set(batch.plan.releases.map(release => release.language));
31 +
32 +export const ReleaseFile = Schema.Struct({
33 + path: Schema.String,
34 + before: Schema.NullOr(Schema.String),
35 + after: Schema.NullOr(Schema.String),
36 +});
37 +export type ReleaseFile = typeof ReleaseFile.Type;
38 +
39 +export const ReleasePatch = Schema.Struct({
40 + files: Schema.Array(ReleaseFile).check(Schema.isMinLength(1)),
41 +});
42 +export type ReleasePatch = typeof ReleasePatch.Type;
43 +
44 +type DiffPlan = Pick<SdkReleasePlan, 'releases' | 'changesets' | 'retainedChangesets'>;
45 +type Bump = SdkReleasePlan['releases'][number]['type'];
46 +
47 +const updatedDependencyRange = (range: string, version: string, type: Bump) =>
48 + Effect.gen(function* () {
49 + const workspace = range.startsWith('workspace:');
50 + const value = workspace ? range.slice('workspace:'.length) : range;
51 + const sets = new semver.Range(value).set;
52 + const comparators = sets.length === 1 ? sets[0] : [];
53 + const bounded = comparators.length === 2 && value.includes('>') && value.includes('<');
54 + const updated = bounded
55 + ? yield* boundedRange(comparators, version, type)
56 + : `${['^', '~', '>=', '<=', '>'].find(prefix => value.startsWith(prefix)) ?? ''}${version}`;
57 + return workspace ? `workspace:${updated}` : updated;
58 + });
59 +
60 +/** Moves a `>=lower <upper` range to the new version, widening the upper bound only when needed. */
61 +const boundedRange = (comparators: ReadonlyArray<semver.Comparator>, version: string, type: Bump) =>
62 + Effect.gen(function* () {
63 + const lower = comparators.find(comparator => comparator.operator.startsWith('>'));
64 + const upper = comparators.find(comparator => comparator.operator.startsWith('<'));
65 + if (!lower || !upper) return yield* fail('Unsupported SDK dependency range');
66 + const upperBound = semver.satisfies(version, upper.value)
67 + ? upper.value
68 + : `<${semver.inc(version, type)}`;
69 + return comparators[0] === lower ? `>=${version} ${upperBound}` : `${upperBound} >=${version}`;
70 + });
71 +
72 +const Manifest = Schema.StructWithRest(
73 + Schema.Struct({ name: Schema.String, version: Schema.String }),
74 + [Schema.Record(Schema.String, Schema.Unknown)]
75 +);
76 +const decodeManifest = (contents: string) =>
77 + Effect.map(Schema.decodeUnknownEffect(Schema.fromJsonString(Manifest))(contents), manifest => ({
78 + ...manifest,
79 + }));
80 +const Dependencies = Schema.Record(Schema.String, Schema.String);
81 +const DEPENDENCY_FIELDS = [
82 + 'dependencies',
83 + 'devDependencies',
84 + 'peerDependencies',
85 + 'optionalDependencies',
86 +] as const;
87 +
88 +/** A release may change only its own version and the ranges that point at released SDK packages. */
89 +const validateManifest = (before: string, after: string, plan: DiffPlan, path: string) =>
90 + Effect.gen(function* () {
91 + const old = yield* decodeManifest(before);
92 + const next: Record<string, unknown> = yield* decodeManifest(after);
93 + const release = plan.releases.find(candidate => candidate.name === old.name);
94 + if (release) {
95 + yield* ensure(
96 + old.version === release.oldVersion && next.version === release.newVersion,
97 + `Wrong target version: ${path}`
98 + );
99 + next.version = old.version;
100 + }
101 + for (const field of DEPENDENCY_FIELDS) {
102 + if (old[field] === undefined && next[field] === undefined) continue;
103 + const previous = yield* Schema.decodeUnknownEffect(Dependencies)(old[field]);
104 + const updated = { ...(yield* Schema.decodeUnknownEffect(Dependencies)(next[field])) };
105 + yield* ensure(
106 + JSON.stringify(Object.keys(previous).sort()) ===
107 + JSON.stringify(Object.keys(updated).sort()),
108 + `Release changes dependency inventory: ${path}`
109 + );
110 + for (const [name, range] of Object.entries(previous)) {
111 + if (updated[name] === range) continue;
112 + const dependency = plan.releases.find(candidate => candidate.name === name);
113 + const dependencyRange = range.replace(/^workspace:/, '');
114 + const planned =
115 + dependency !== undefined &&
116 + semver.validRange(dependencyRange) !== null &&
117 + !(
118 + field === 'peerDependencies' && semver.satisfies(dependency.newVersion, dependencyRange)
119 + ) &&
120 + updated[name] ===
121 + (yield* updatedDependencyRange(range, dependency.newVersion, dependency.type));
122 + yield* ensure(planned, `Unplanned dependency change: ${path} ${name}`);
123 + updated[name] = range;
124 + }
125 + next[field] = updated;
126 + }
127 + yield* ensure(
128 + JSON.stringify(old) === JSON.stringify(next),
129 + `Release changes package behavior: ${path}`
130 + );
131 + });
132 +
133 +/** Python files the synchronized train rewrites, and the version pattern each one carries. */
134 +const PYTHON_VERSION_FILES: ReadonlyArray<{ readonly suffix: string; readonly pattern: RegExp }> = [
135 + { suffix: 'pyproject.toml', pattern: PROJECT_VERSION },
136 + { suffix: 'setup.py', pattern: SETUP_VERSION },
137 + { suffix: '__version__.py', pattern: RUNTIME_VERSION },
138 +];
139 +const PYTHON_METADATA_PATH =
140 + /^python\/(?:providers\/[^/]+\/)?(?:pyproject\.toml|setup\.py)$|^python\/composio\/__version__\.py$/;
141 +
142 +const pythonRelease = (plan: DiffPlan) =>
143 + plan.releases.find(release => release.name === PYTHON_RELEASE_MARKER);
144 +
145 +const expectedPythonMetadata = (before: string, plan: DiffPlan, path: string) =>
146 + Effect.gen(function* () {
147 + const release = pythonRelease(plan);
148 + if (!release) return before;
149 + const { pattern } =
150 + PYTHON_VERSION_FILES.find(file => path.endsWith(file.suffix)) ?? PYTHON_VERSION_FILES[2];
151 + const current = before.match(pattern)?.[3];
152 + yield* ensure(
153 + current === undefined || current === release.oldVersion,
154 + `Python baseline changed: ${path}`
155 + );
156 + return before.replace(
157 + pattern,
158 + (_match, prefix: string, quote: string) => `${prefix}${quote}${release.newVersion}${quote}`
159 + );
160 + });
161 +
162 +const WORKSPACE_LOCK_SOURCE =
163 + /^source = \{ (?:editable|virtual) = "python(?:\/providers\/[^"/]+)?" \}$/m;
164 +const LOCK_VERSION = /^version = "([^"]+)"$/m;
165 +
166 +const expectedUvLock = (before: string, plan: DiffPlan) =>
167 + Effect.gen(function* () {
168 + const release = pythonRelease(plan);
169 + if (!release) return before;
170 + const blocks = before.split('[[package]]');
171 + const workspaceVersions = blocks
172 + .filter(block => WORKSPACE_LOCK_SOURCE.test(block))
173 + .map(block => block.match(LOCK_VERSION)?.[1])
174 + .filter(version => version !== undefined);
175 + yield* ensure(
176 + workspaceVersions.every(version => version === release.oldVersion),
177 + 'Python lock baseline changed'
178 + );
179 + return blocks
180 + .map(block =>
181 + WORKSPACE_LOCK_SOURCE.test(block)
182 + ? block.replace(LOCK_VERSION, `version = "${release.newVersion}"`)
183 + : block
184 + )
185 + .join('[[package]]');
186 + });
187 +
188 +/** Only a released package's own peer-context version may change in the pnpm lockfile. */
189 +const normalizePnpmContexts = (contents: string, plan: DiffPlan) =>
190 + plan.releases
191 + .filter(release => release.language === 'typescript')
192 + .reduce(
193 + (result, release) =>
194 + result.replaceAll(
195 + `${release.name}@${release.newVersion}`,
196 + `${release.name}@${release.oldVersion}`
197 + ),
198 + contents
199 + );
200 +
201 +const retainedNote = (note: DiffPlan['retainedChangesets'][number]) =>
202 + `---\n${note.releases.map(entry => `${JSON.stringify(entry.name)}: ${entry.type}`).join('\n')}\n---\n\n${note.summary}\n`;
203 +
204 +const GENERATED_NOTE = /^sdk-maintenance-(typescript|python)$/;
205 +
206 +const plannedVersionMetadata = (
207 + files: ReadonlyArray<ReleaseFile>,
208 + release: { name: string; newVersion: string }
209 +) =>
210 + files.some(file => {
211 + if (!file.path.endsWith('/package.json') || file.after === null) return false;
212 + const manifest = Schema.decodeUnknownOption(Manifest)(JSON.parse(file.after));
213 + return (
214 + manifest._tag === 'Some' &&
215 + manifest.value.name === release.name &&
216 + manifest.value.version === release.newVersion
217 + );
218 + });
219 +
220 +/** Checks one changed file against the release outputs it may legitimately belong to. */
221 +const validateReleaseFile = (
222 + file: ReleaseFile,
223 + plan: DiffPlan,
224 + outputs: ReadonlyArray<string>,
225 + notes: ReadonlySet<string>,
226 + selected: ReadonlySet<string>
227 +) =>
228 + Effect.gen(function* () {
229 + const { path, before, after } = file;
230 + if (path === BATCH_PATH) return;
231 + yield* ensure(
232 + !path.includes('..') && !path.startsWith('/') && !path.includes('\\'),
233 + 'Invalid release path'
234 + );
235 + if (
236 + outputs.some(output => path === output || (output.endsWith('/') && path.startsWith(output)))
237 + )
238 + return;
239 + if (notes.has(path)) {
240 + const retained = plan.retainedChangesets.find(note => path === `.changeset/${note.id}.md`);
241 + yield* ensure(
242 + after === (retained ? retainedNote(retained) : null),
243 + `Selected release note changed: ${path}`
244 + );
245 + return;
246 + }
247 + if (path === 'uv.lock' || path === 'pnpm-lock.yaml') {
248 + const unchanged =
249 + before !== null &&
250 + after !== null &&
251 + (path === 'uv.lock'
252 + ? (yield* expectedUvLock(before, plan)) === after
253 + : normalizePnpmContexts(before, plan) === normalizePnpmContexts(after, plan));
254 + yield* ensure(unchanged, `Release changes dependency resolution: ${path}`);
255 + return;
256 + }
257 + if (/^(ts\/packages\/.*|python)\/package\.json$/.test(path) && before && after)
258 + return yield* validateManifest(before, after, plan, path);
259 + if (selected.has(PYTHON_RELEASE_MARKER) && PYTHON_METADATA_PATH.test(path) && before && after) {
260 + yield* ensure(
261 + (yield* expectedPythonMetadata(before, plan, path)) === after,
262 + `Python source changed: ${path}`
263 + );
264 + return;
265 + }
266 + return yield* fail(`Not a planned release output: ${path}`);
267 + });
268 +
269 +/** Every changed file must be a planned version, note, lockfile, or generated release output. */
270 +export const validateReleaseDiff = (
271 + files: ReadonlyArray<ReleaseFile>,
272 + plan: DiffPlan,
273 + outputs: ReadonlyArray<string>
274 +) =>
275 + Effect.gen(function* () {
276 + for (const release of plan.releases)
277 + yield* ensure(
278 + plannedVersionMetadata(files, release),
279 + `Missing planned version metadata: ${release.name}`
280 + );
281 + for (const note of plan.changesets)
282 + yield* ensure(
283 + GENERATED_NOTE.test(note.id) ||
284 + files.some(file => file.path === `.changeset/${note.id}.md`),
285 + `Selected release note was not consumed: ${note.id}`
286 + );
287 + const selected = new Set(plan.releases.map(release => release.name));
288 + const notes = new Set(plan.changesets.map(note => `.changeset/${note.id}.md`));
289 + for (const file of files) yield* validateReleaseFile(file, plan, outputs, notes, selected);
290 + });
291 +
292 +/** The changelog and reference paths a release may write besides version metadata. */
293 +export const releaseOutputs = (cwd: string, batch: ReleaseBatch) =>
294 + Effect.gen(function* () {
295 + const { packages } = yield* fromPromise(() => getPackages(cwd));
296 + const names = new Set(batch.plan.releases.map(release => release.name));
297 + const [year, month, day] = batch.date.split('-');
298 + return [
299 + ...packages
300 + .filter(pkg => names.has(pkg.packageJson.name))
301 + .map(pkg => `${pkg.dir.slice(cwd.length + 1)}/CHANGELOG.md`),
302 + `docs/content/changelog/${month}-${day}-${year.slice(2)}-sdk-${batch.id}.mdx`,
303 + ...[...batchLanguages(batch)].map(
304 + language => `docs/content/reference/sdk-reference/${language}/`
305 + ),
306 + ].sort();
307 + });
test/sdk-release-batch.test.ts new
+169
@@ -0,0 +1,169 @@
1 +import { describe, expect, test } from 'bun:test';
2 +import { openReleasePull } from '../scripts/sdk-release/batch';
3 +import { BATCH_PATH, validateReleaseDiff, type ReleaseFile } from '../scripts/sdk-release/source';
4 +import {
5 + base,
6 + batch,
7 + fakeController,
8 + newManifest,
9 + oldManifest,
10 + releaseFiles,
11 +} from './sdk-release-controller-fixture';
12 +import { resolvePath, runRelease } from './sdk-release-harness';
13 +
14 +const validate = (
15 + files: ReadonlyArray<ReleaseFile>,
16 + plan: Parameters<typeof validateReleaseDiff>[1],
17 + outputs: ReadonlyArray<string>
18 +) => runRelease(validateReleaseDiff(files, plan, outputs));
19 +
20 +describe('release-only diff validation', () => {
21 + test('source edits and lock dependency changes fail release-only validation', async () => {
22 + const plan = { releases: [], changesets: [], retainedChangesets: [] };
23 + await expect(
24 + validate([{ path: 'ts/packages/core/src/index.ts', before: 'x', after: 'y' }], plan, [])
25 + ).rejects.toThrow('Not a planned release output');
26 + await expect(
27 + validate([{ path: 'pnpm-lock.yaml', before: 'dep: 1', after: 'dep: 2' }], plan, [])
28 + ).rejects.toThrow('Release changes dependency resolution');
29 + await validate(
30 + [{ path: 'docs/content/changelog/release.mdx', before: 'x', after: 'edited narrative' }],
31 + plan,
32 + ['docs/content/changelog/release.mdx']
33 + );
34 + });
35 +});
36 +
37 +describe('release PR', () => {
38 + const open = async (
39 + fetcher: ReturnType<typeof fakeController>['fetcher'],
40 + files = releaseFiles
41 + ) => runRelease(openReleasePull(await resolvePath('.'), batch, { files }), fetcher);
42 + const writePaths = (writes: ReadonlyArray<{ method: string; path: string }>) =>
43 + writes.map(write => `${write.method} ${write.path}`);
44 +
45 + test('a release-only patch is committed on the frozen source and opened as one PR', async () => {
46 + const { fetcher, writes } = fakeController();
47 + expect(await open(fetcher)).toBe('https://github.com/ComposioHQ/composio/pull/9');
48 + expect(writePaths(writes)).toEqual([
49 + 'POST /git/blobs',
50 + 'POST /git/blobs',
51 + 'POST /git/blobs',
52 + 'POST /git/trees',
53 + 'POST /git/commits',
54 + 'POST /git/refs',
55 + 'POST /pulls',
56 + 'POST /issues/8/comments',
57 + ]);
58 + expect(writes.find(write => write.path === '/git/commits')?.body).toMatchObject({
59 + parents: [base],
60 + });
61 + expect(writes.at(-1)?.body).toEqual({
62 + body: 'Release PR: https://github.com/ComposioHQ/composio/pull/9',
63 + });
64 + });
65 +
66 + test('a re-run whose branch already exists moves that branch instead of creating it', async () => {
67 + const { fetcher, writes } = fakeController({ existingBranch: true });
68 + await open(fetcher);
69 + expect(writes.find(write => write.path.startsWith('/git/refs'))).toEqual({
70 + method: 'PATCH',
71 + path: '/git/refs/heads/sdk-release/batch-8',
72 + body: { sha: 'e'.repeat(40), force: true },
73 + });
74 + });
75 +
76 + test('a prepared plan that differs from the planned batch is refused before any write', async () => {
77 + const { fetcher, writes } = fakeController();
78 + const edited = releaseFiles.map(file =>
79 + file.path === BATCH_PATH
80 + ? { ...file, after: JSON.stringify({ ...batch, requestedBy: 'someone-else' }) }
81 + : file
82 + );
83 + await expect(open(fetcher, edited)).rejects.toThrow('Prepared release plan differs');
84 + expect(writes).toEqual([]);
85 + });
86 +
87 + test('a patch that touches source outside the release outputs is refused before any write', async () => {
88 + const { fetcher, writes } = fakeController();
89 + const widened = [
90 + ...releaseFiles,
91 + { path: 'ts/packages/core/src/backdoor.ts', before: null, after: 'export {};' },
92 + ];
93 + await expect(open(fetcher, widened)).rejects.toThrow('Not a planned release output');
94 + expect(writes).toEqual([]);
95 + });
96 +
97 + test('another open release PR opens nothing and reports it once on the request issue', async () => {
98 + const { fetcher, writes } = fakeController({ openRelease: 'sdk-release/batch-7' });
99 + expect(await open(fetcher)).toBeUndefined();
100 + expect(writePaths(writes)).toEqual(['POST /issues/8/comments']);
101 + });
102 +
103 + test('a re-run after this request opened its release PR returns that PR and repeats its link', async () => {
104 + const { fetcher, writes } = fakeController({ openRelease: 'sdk-release/batch-8' });
105 + expect(await open(fetcher)).toBe('https://github.com/ComposioHQ/composio/pull/5');
106 + expect(writes).toEqual([
107 + {
108 + method: 'POST',
109 + path: '/issues/8/comments',
110 + body: { body: 'Release PR: https://github.com/ComposioHQ/composio/pull/5' },
111 + },
112 + ]);
113 + });
114 +
115 + test('major targets allow normal Changesets peer-range updates without changing unrelated fields', async () => {
116 + const plan = {
117 + ...batch.plan,
118 + releases: [
119 + { ...batch.plan.releases[0], newVersion: '2.0.0', type: 'major' as const },
120 + {
121 + ...batch.plan.releases[0],
122 + name: '@composio/provider',
123 + oldVersion: '0.1.0',
124 + newVersion: '0.1.1',
125 + },
126 + ],
127 + };
128 + const provider = {
129 + name: '@composio/provider',
130 + version: '0.1.0',
131 + peerDependencies: { '@composio/core': '>=1.0.0 <2.0.0 || >=2.0.0-beta.0 <2.0.0' },
132 + };
133 + await validate(
134 + [
135 + {
136 + path: 'ts/packages/core/package.json',
137 + before: oldManifest,
138 + after: newManifest.replace('1.0.1', '2.0.0'),
139 + },
140 + {
141 + path: 'ts/packages/providers/provider/package.json',
142 + before: JSON.stringify(provider),
143 + after: JSON.stringify({
144 + ...provider,
145 + version: '0.1.1',
146 + peerDependencies: { '@composio/core': '>=2.0.0' },
147 + }),
148 + },
149 + ],
150 + plan,
151 + []
152 + );
153 + });
154 + test('coincident client versions and Python dependency literals cannot masquerade as SDK metadata', async () => {
155 + await expect(
156 + validate(
157 + [
158 + {
159 + path: 'ts/packages/core/package.json',
160 + before: oldManifest,
161 + after: newManifest.replace('"client":"1.0.0"', '"client":"1.0.1"'),
162 + },
163 + ],
164 + batch.plan,
165 + []
166 + )
167 + ).rejects.toThrow('Unplanned dependency');
168 + });
169 +});
test/sdk-release-changelog-filter.test.ts new
+27
@@ -0,0 +1,27 @@
1 +import { afterAll, expect, test } from 'bun:test';
2 +import { run } from '../scripts/sdk-release/runtime';
3 +import { resolvePath, runRelease, temporaryDirectories, writeText } from './sdk-release-harness';
4 +
5 +const changelogs = temporaryDirectories('sdk-changelog-filter-');
6 +afterAll(() => changelogs.cleanup());
7 +
8 +test('only the SDK frontmatter marker suppresses ordinary changelog automation', async () => {
9 + const directory = await changelogs.create();
10 + const ordinary = `${directory}/ordinary.mdx`;
11 + const release = `${directory}/release.mdx`;
12 + await writeText(
13 + ordinary,
14 + '---\ntitle: Ordinary\ndate: "2026-11-03"\n---\nsdkRelease: in prose\n'
15 + );
16 + await writeText(release, '---\ntitle: Release\nsdkRelease: "51"\n---\nChanges\n');
17 + const kept = await runRelease(
18 + run('bash', [
19 + '-c',
20 + `printf '%s\\n' "$0" "$1" | bash "$2"`,
21 + ordinary,
22 + release,
23 + await resolvePath('scripts/sdk-release/changelog-filter.sh'),
24 + ])
25 + );
26 + expect(kept).toBe(`${ordinary}\n`);
27 +});
test/sdk-release-controller-fixture.ts new
+185
@@ -0,0 +1,185 @@
1 +import { BATCH_PATH, type ReleaseBatch } from '../scripts/sdk-release/source';
2 +import type { Fetch } from './sdk-release-harness';
3 +
4 +export const base = 'a'.repeat(40);
5 +export const head = 'b'.repeat(40);
6 +export const merge = 'c'.repeat(40);
7 +export const APP_SLUG = 'sdk-release-app';
8 +
9 +/** Keys follow the schema order, as a decoded batch does, so the committed plan compares equal. */
10 +export const batch: ReleaseBatch = {
11 + id: '8',
12 + inputBase: base,
13 + requestedBy: 'requester',
14 + issue: 8,
15 + date: '2026-11-03',
16 + plan: {
17 + schemaVersion: 1,
18 + inputFingerprint: 'frozen',
19 + choices: { typescript: 'auto', python: 'skip' },
20 + recommended: [],
21 + releases: [
22 + {
23 + name: '@composio/core',
24 + type: 'patch',
25 + oldVersion: '1.0.0',
26 + newVersion: '1.0.1',
27 + changesets: [],
28 + language: 'typescript',
29 + },
30 + ],
31 + changesets: [],
32 + retainedChangesets: [],
33 + },
34 +};
35 +export const oldManifest = JSON.stringify({
36 + name: '@composio/core',
37 + version: '1.0.0',
38 + dependencies: { client: '1.0.0' },
39 +});
40 +export const newManifest = JSON.stringify({
41 + name: '@composio/core',
42 + version: '1.0.1',
43 + dependencies: { client: '1.0.0' },
44 +});
45 +/** The release-only files batch 8 prepares: its plan, the core version and the docs changelog. */
46 +export const releaseFiles = [
47 + { path: BATCH_PATH, before: null, after: JSON.stringify(batch) },
48 + { path: 'ts/packages/core/package.json', before: oldManifest, after: newManifest },
49 + { path: 'docs/content/changelog/11-03-26-sdk-8.mdx', before: null, after: 'Release notes' },
50 +];
51 +
52 +export interface ControllerOptions {
53 + readonly oldReview?: boolean;
54 + readonly reviewer?: string;
55 + readonly mergeKind?: 'squash' | 'merge';
56 + readonly existingTag?: string;
57 + readonly failedCandidate?: boolean;
58 + readonly failedSmoke?: boolean;
59 + readonly closedUnmerged?: boolean;
60 + readonly existingBranch?: boolean;
61 + /** Head branch of a release PR that is already open into next. */
62 + readonly openRelease?: string;
63 + readonly docs?: 'success' | 'failure' | 'pending' | 'missing';
64 + /** Who authored the release PR head; the release App by default. */
65 + readonly headAuthor?: string;
66 + /** Who committed the release PR head; the release App by default. */
67 + readonly headCommitter?: string;
68 + readonly unverifiedHead?: boolean;
69 + /** Parent of the release PR head; the planned source by default. */
70 + readonly headParent?: string;
71 +}
72 +
73 +/** A fake GitHub API for release PR #9 of batch 8 that records every write. */
74 +export function fakeController(options: ControllerOptions = {}) {
75 + const writes: { method: string; path: string; body: unknown }[] = [];
76 + const merged = !options.closedUnmerged;
77 + const pull = () => ({
78 + number: 9,
79 + html_url: 'https://github.com/ComposioHQ/composio/pull/9',
80 + state: 'closed',
81 + merged,
82 + merge_commit_sha: merged ? merge : null,
83 + user: { login: `${APP_SLUG}[bot]` },
84 + head: { sha: head, ref: 'sdk-release/batch-8', repo: { full_name: 'ComposioHQ/composio' } },
85 + base: { ref: 'next' },
86 + });
87 + const check = (name: string, conclusion: string | null) => ({
88 + name,
89 + head_sha: head,
90 + app: { slug: 'github-actions' },
91 + conclusion,
92 + });
93 + const fetcher: Fetch = async (input, init) => {
94 + const url = new URL(String(input));
95 + const path = url.pathname.replace('/repos/ComposioHQ/composio', '') + url.search;
96 + const method = init?.method ?? 'GET';
97 + const response = (data: unknown, status = 200) =>
98 + new Response(JSON.stringify(data), { status });
99 + if (method !== 'GET') {
100 + writes.push({ method, path, body: JSON.parse(String(init?.body)) });
101 + if (/^\/git\/(blobs|trees|commits)$/.test(path)) return response({ sha: 'e'.repeat(40) });
102 + if (path.startsWith('/git/refs')) return response({ ref: 'refs/heads/sdk-release/batch-8' });
103 + if (path === '/pulls') return response({ ...pull(), state: 'open', merged: false });
104 + if (/^\/issues\/\d+\/comments$/.test(path)) return response({ id: 1 });
105 + throw new Error(`Unexpected write ${method} ${path}`);
106 + }
107 + if (path.startsWith('/pulls?'))
108 + return response(
109 + options.openRelease
110 + ? [
111 + {
112 + ...pull(),
113 + number: 5,
114 + html_url: 'https://github.com/ComposioHQ/composio/pull/5',
115 + state: 'open',
116 + merged: false,
117 + merge_commit_sha: null,
118 + head: { ...pull().head, ref: options.openRelease },
119 + },
120 + ]
121 + : []
122 + );
123 + if (path === '/pulls/9') return response(pull());
124 + if (path.startsWith('/pulls/9/reviews'))
125 + return response([
126 + {
127 + user: { login: options.reviewer ?? 'reviewer' },
128 + state: 'APPROVED',
129 + commit_id: options.oldReview ? base : head,
130 + },
131 + ]);
132 + if (path === `/collaborators/${options.reviewer ?? 'reviewer'}/permission`)
133 + return response({ permission: 'write' });
134 + if (path.startsWith(`/commits/${head}/check-runs`))
135 + return response({
136 + check_runs: [
137 + check('SDK candidate (typescript)', options.failedCandidate ? 'failure' : 'success'),
138 + check('SDK candidate smoke (typescript)', options.failedSmoke ? 'failure' : 'success'),
139 + ...(options.docs === 'missing'
140 + ? []
141 + : [
142 + check(
143 + 'typescript-check',
144 + options.docs === 'pending' ? null : (options.docs ?? 'success')
145 + ),
146 + ]),
147 + ],
148 + });
149 + if (path === `/commits/${head}`)
150 + return response({
151 + author: { login: options.headAuthor ?? `${APP_SLUG}[bot]` },
152 + committer: { login: options.headCommitter ?? `${APP_SLUG}[bot]` },
153 + commit: { verification: { verified: !options.unverifiedHead } },
154 + parents: [{ sha: options.headParent ?? base }],
155 + });
156 + if (path === `/git/commits/${base}`)
157 + return response({ sha: base, tree: { sha: base }, parents: [] });
158 + if (path === `/git/commits/${merge}`)
159 + return response({
160 + sha: merge,
161 + tree: { sha: merge },
162 + parents:
163 + options.mergeKind === 'merge'
164 + ? [{ sha: 'd'.repeat(40) }, { sha: head }]
165 + : [{ sha: 'd'.repeat(40) }],
166 + });
167 + if (path.startsWith('/contents/')) {
168 + const filename = url.pathname.split('/contents/')[1];
169 + const file = releaseFiles.find(file => file.path === filename);
170 + const data = url.searchParams.get('ref') === base ? file?.before : file?.after;
171 + if (data == null) return response({}, 404);
172 + return new Response(data);
173 + }
174 + if (path === '/git/ref/heads/sdk-release/batch-8')
175 + return options.existingBranch
176 + ? response({ ref: 'refs/heads/sdk-release/batch-8' })
177 + : response({}, 404);
178 + if (path === '/git/ref/tags/sdk-release/8')
179 + return options.existingTag
180 + ? response({ object: { type: 'commit', sha: options.existingTag } })
181 + : response({}, 404);
182 + throw new Error(`Unexpected read ${path}`);
183 + };
184 + return { fetcher, writes };
185 +}
test/sdk-release-harness.ts
+3 -2
@@ -1,13 +1,14 @@
1 import { Effect, FileSystem, Layer, Path } from 'effect';
2 import { FetchHttpClient } from 'effect/http';
3 +import { GitHub } from '../scripts/sdk-release/github';
4 import { ReleaseServices, readFile } from '../scripts/sdk-release/runtime';
5
6 export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
7
7 -const TestServices = ReleaseServices;
8 +const TestServices = Layer.provideMerge(GitHub.layer('token'), ReleaseServices);
9 type TestServices = Layer.Success<typeof TestServices>;
10
10 -/** Runs a release effect with Bun platform services and an optional fake fetch. */
11 +/** Runs a release effect with Bun platform services, a test GitHub token, and an optional fake fetch. */
12 export const runRelease = <A, E>(
13 effect: Effect.Effect<A, E, TestServices>,
14 fetch?: Fetch
test/sdk-release-release-pr.test.ts new
+125
@@ -0,0 +1,125 @@
1 +import { expect, test } from 'bun:test';
2 +import { releasePullBody } from '../scripts/sdk-release/release-pr';
3 +import type { ReleaseBatch } from '../scripts/sdk-release/source';
4 +
5 +const release = (
6 + name: string,
7 + language: 'typescript' | 'python',
8 + newVersion: string,
9 + changesets: string[]
10 +) => ({
11 + name,
12 + language,
13 + type: 'minor' as const,
14 + oldVersion: '1.0.0',
15 + newVersion,
16 + changesets,
17 +});
18 +
19 +const outputs = [
20 + 'docs/content/changelog/11-04-26-sdk-8.mdx',
21 + 'docs/content/reference/sdk-reference/typescript/',
22 + 'python/CHANGELOG.md',
23 + 'ts/packages/core/CHANGELOG.md',
24 +];
25 +
26 +const batch: ReleaseBatch = {
27 + id: '8',
28 + inputBase: 'a'.repeat(40),
29 + requestedBy: 'requester',
30 + issue: 7,
31 + date: '2026-11-04',
32 + plan: {
33 + schemaVersion: 1,
34 + inputFingerprint: 'frozen',
35 + choices: { typescript: 'auto', python: 'minor' },
36 + recommended: [
37 + release('@composio/core', 'typescript', '1.1.0', ['brave-cats']),
38 + release('@composio/python-sdk', 'python', '1.0.1', []),
39 + ],
40 + releases: [
41 + release('@composio/core', 'typescript', '1.1.0', ['brave-cats']),
42 + release('@composio/python-sdk', 'python', '1.1.0', []),
43 + ],
44 + changesets: [
45 + {
46 + id: 'brave-cats',
47 + summary: 'Add session tool filters.\n\nLonger explanation.',
48 + releases: [{ name: '@composio/core', type: 'minor' }],
49 + },
50 + ],
51 + retainedChangesets: [
52 + {
53 + id: 'quiet-dogs',
54 + summary: 'Rename an internal helper.',
55 + releases: [{ name: '@composio/slim', type: 'patch' }],
56 + },
57 + ],
58 + },
59 +};
60 +
61 +test('the release PR names every package, consumed changeset and edited changelog', () => {
62 + const body = releasePullBody(batch, 'sdk-release/batch-8', outputs);
63 + const blob = 'https://github.com/ComposioHQ/composio/blob/sdk-release/batch-8';
64 + expect(body).toContain('| `@composio/core` | 1.0.0 → **1.1.0** | minor | `brave-cats` |');
65 + expect(body).toContain(
66 + '| Python SDK (`composio` and every provider) | 1.0.0 → **1.1.0** (recommended 1.0.1) | minor | maintenance release |'
67 + );
68 + expect(body).toContain(
69 + '- `.changeset/brave-cats.md` (`@composio/core` minor): Add session tool filters.'
70 + );
71 + expect(body).toContain('## Changesets left for a later release');
72 + expect(body).toContain('- `.changeset/quiet-dogs.md` (`@composio/slim` patch)');
73 + expect(body).toContain(
74 + `- Docs changelog entry: [\`docs/content/changelog/11-04-26-sdk-8.mdx\`](${blob}/docs/content/changelog/11-04-26-sdk-8.mdx)`
75 + );
76 + expect(body).toContain(
77 + `[\`ts/packages/core/CHANGELOG.md\`](${blob}/ts/packages/core/CHANGELOG.md)`
78 + );
79 + expect(body).toContain(
80 + 'https://github.com/ComposioHQ/composio/tree/sdk-release/batch-8/docs/content/reference/sdk-reference/typescript/'
81 + );
82 + expect(body).toContain('(@requester)');
83 + expect(body).toContain('`sdk-release/8`');
84 + expect(body).toContain('https://github.com/ComposioHQ/composio/issues/7');
85 +});
86 +
87 +test('changeset text cannot hide or add content in the release PR', () => {
88 + const body = releasePullBody(
89 + {
90 + ...batch,
91 + plan: {
92 + ...batch.plan,
93 + changesets: [
94 + {
95 + id: 'sneaky',
96 + summary: 'Fix crash <!-- [click](https://evil.test) | `x`',
97 + releases: [{ name: '@composio/core', type: 'patch' }],
98 + },
99 + ],
100 + },
101 + },
102 + 'sdk-release/batch-8',
103 + outputs
104 + );
105 + expect(body).toContain('Fix crash &lt;\\!-- \\[click\\]\\(https://evil.test\\) \\| \\`x\\`');
106 + expect(body).not.toContain('<!-- [click]');
107 +});
108 +
109 +test('a package name cannot break out of its code span in the release PR', () => {
110 + const forged = '@composio/x` [click](https://evil.test)';
111 + const body = releasePullBody(
112 + {
113 + ...batch,
114 + plan: {
115 + ...batch.plan,
116 + recommended: [release(forged, 'typescript', '1.1.0', [])],
117 + releases: [release(forged, 'typescript', '1.1.0', [])],
118 + },
119 + },
120 + 'sdk-release/batch-8',
121 + outputs
122 + );
123 + expect(body).toContain('| @composio/x\\` \\[click\\]\\(https://evil.test\\) | 1.0.0 → **1.1.0**');
124 + expect(body).not.toContain('[click](https://evil.test)');
125 +});
test/sdk-release-request.test.ts new
+177
@@ -0,0 +1,177 @@
1 +import { describe, expect, test } from 'bun:test';
2 +import { Effect } from 'effect';
3 +import { executeReleaseRequest, type ReleaseRequestContext } from '../scripts/sdk-release/batch';
4 +import type { SdkReleasePlan } from '../scripts/sdk-release/plan';
5 +import { parseReleaseRequest, type ReleaseRequest } from '../scripts/sdk-release/request';
6 +import { runRelease, type Fetch } from './sdk-release-harness';
7 +
8 +const sha = 'a'.repeat(40);
9 +const context = { actor: 'member', runId: '21', sourceSha: sha, issueNumber: 7 };
10 +const plan: SdkReleasePlan = {
11 + schemaVersion: 1,
12 + inputFingerprint: 'frozen',
13 + choices: { typescript: 'auto', python: 'auto' },
14 + recommended: [],
15 + changesets: [],
16 + retainedChangesets: [],
17 + releases: [
18 + {
19 + name: '@composio/python-sdk',
20 + oldVersion: '0.31.0',
21 + newVersion: '0.31.1',
22 + type: 'patch',
23 + changesets: [],
24 + language: 'python',
25 + },
26 + ],
27 +};
28 +const request: ReleaseRequest = { typescript: 'auto', python: 'auto' };
29 +const planned = (value: SdkReleasePlan) => () => Effect.succeed(value);
30 +const failing = (message: string) => () =>
31 + Effect.sync((): SdkReleasePlan => {
32 + throw new Error(message);
33 + });
34 +const execute = (
35 + fetch: Fetch,
36 + requestContext: ReleaseRequestContext,
37 + plan: () => Effect.Effect<SdkReleasePlan>
38 +) => runRelease(executeReleaseRequest(request, requestContext, plan), fetch);
39 +
40 +const openRelease = {
41 + number: 9,
42 + html_url: 'https://github.com/ComposioHQ/composio/pull/9',
43 + state: 'open',
44 + merged: false,
45 + merge_commit_sha: null,
46 + user: { login: 'sdk-release-app[bot]' },
47 + head: { sha, ref: 'sdk-release/batch-8', repo: { full_name: 'ComposioHQ/composio' } },
48 + base: { ref: 'next' },
49 +};
50 +
51 +function client(
52 + options: { membership?: 'active' | 'pending' | 'absent' | 'error'; existing?: boolean } = {}
53 +) {
54 + const calls: { method: string; path: string; body?: unknown }[] = [];
55 + const fetcher: Fetch = async (input, init) => {
56 + const url = new URL(String(input));
57 + const method = init?.method ?? 'GET';
58 + const path = url.pathname + url.search;
59 + calls.push({ method, path, ...(init?.body ? { body: JSON.parse(String(init.body)) } : {}) });
60 + const respond = (data: unknown, status = 200) => new Response(JSON.stringify(data), { status });
61 + if (path === '/orgs/ComposioHQ/memberships/member') {
62 + if (options.membership === 'absent') return respond({}, 404);
63 + if (options.membership === 'error') return respond({}, 503);
64 + return respond({ state: options.membership ?? 'active' });
65 + }
66 + if (path.includes('/pulls?')) return respond(options.existing ? [openRelease] : []);
67 + if (method === 'POST' && path === '/repos/ComposioHQ/composio/issues')
68 + return respond({ number: 31 }, 201);
69 + if (path.endsWith('/issues/7/comments')) return respond({ id: 99 });
70 + throw new Error(`Unexpected request: ${method} ${path}`);
71 + };
72 + const writes = () => calls.filter(call => call.method !== 'GET');
73 + return { fetcher, writes };
74 +}
75 +
76 +describe('release request parsing', () => {
77 + test('the issue form and a dispatch read into the same request', () => {
78 + const issue = { issue: { body: '### TypeScript\n\nskip\n\n### Python\n\npatch\n' } };
79 + expect(parseReleaseRequest('issues', issue)).toEqual({ typescript: 'skip', python: 'patch' });
80 + expect(
81 + parseReleaseRequest('workflow_dispatch', { inputs: { typescript: 'skip', python: 'patch' } })
82 + ).toEqual({ typescript: 'skip', python: 'patch' });
83 + expect(parseReleaseRequest('workflow_dispatch', { inputs: {} })).toEqual(request);
84 + });
85 + test('a hand-written issue body and an unknown bump are refused', () => {
86 + expect(() => parseReleaseRequest('issues', { issue: { body: 'please release' } })).toThrow(
87 + 'Use the SDK release request issue form'
88 + );
89 + expect(() =>
90 + parseReleaseRequest('workflow_dispatch', { inputs: { typescript: 'huge' } })
91 + ).toThrow();
92 + });
93 +});
94 +
95 +describe('SDK release member request', () => {
96 + for (const membership of ['pending', 'absent', 'error'] as const) {
97 + test(`${membership} membership fails before planning or any write`, async () => {
98 + const { fetcher, writes } = client({ membership });
99 + let planCalls = 0;
100 + await expect(
101 + execute(fetcher, context, () =>
102 + Effect.sync(() => {
103 + planCalls += 1;
104 + return plan;
105 + })
106 + )
107 + ).rejects.toThrow();
108 + expect(planCalls).toBe(0);
109 + expect(writes()).toEqual([]);
110 + });
111 + }
112 +
113 + test('an active member gets a batch frozen at the source and a reply on the issue', async () => {
114 + const { fetcher, writes } = client();
115 + const result = await execute(fetcher, context, planned(plan));
116 + expect(result.batch).toMatchObject({
117 + id: '21',
118 + inputBase: sha,
119 + requestedBy: 'member',
120 + issue: 7,
121 + plan,
122 + });
123 + expect(writes().map(call => call.path)).toEqual([
124 + '/repos/ComposioHQ/composio/issues/7/comments',
125 + ]);
126 + });
127 +
128 + test('a planning failure is reported on the issue with the request run', async () => {
129 + const { fetcher, writes } = client();
130 + await expect(execute(fetcher, context, failing('Invalid Changesets config'))).rejects.toThrow(
131 + 'Invalid Changesets config'
132 + );
133 + expect(writes()).toEqual([
134 + {
135 + method: 'POST',
136 + path: '/repos/ComposioHQ/composio/issues/7/comments',
137 + body: { body: expect.stringContaining('/actions/runs/21') },
138 + },
139 + ]);
140 + });
141 +
142 + test('an open release PR stops the request before planning', async () => {
143 + const { fetcher, writes } = client({ existing: true });
144 + const result = await execute(fetcher, context, failing('must not plan'));
145 + expect(result.batch).toBeUndefined();
146 + expect(result.message).toContain('Another SDK release is in progress');
147 + expect(writes()).toEqual([
148 + {
149 + method: 'POST',
150 + path: '/repos/ComposioHQ/composio/issues/7/comments',
151 + body: { body: result.message },
152 + },
153 + ]);
154 + });
155 +
156 + test('an empty plan replies "Nothing to release." and plans no batch', async () => {
157 + const { fetcher, writes } = client();
158 + const result = await execute(fetcher, context, planned({ ...plan, releases: [] }));
159 + expect(result).toEqual({ message: 'Nothing to release.' });
160 + expect(writes()).toEqual([
161 + {
162 + method: 'POST',
163 + path: '/repos/ComposioHQ/composio/issues/7/comments',
164 + body: { body: 'Nothing to release.' },
165 + },
166 + ]);
167 + });
168 +
169 + test('a dispatch-started release opens its tracking issue', async () => {
170 + const { fetcher, writes } = client();
171 + const result = await execute(fetcher, { ...context, issueNumber: undefined }, planned(plan));
172 + expect(result.batch?.issue).toBe(31);
173 + expect(writes().map(call => `${call.method} ${call.path}`)).toEqual([
174 + 'POST /repos/ComposioHQ/composio/issues',
175 + ]);
176 + });
177 +});