Migrate to extension-sdk v2 + polish#1
Open
0xdeafcafe wants to merge 1 commit into
Open
Conversation
Beak's realtime-values system jumped to apiVersion 2 — single `resolve`
returning a typed `ResolvedValue`, no more `getValue` + parallel
`getAssetRef`. This template now declares `apiVersion: 2`, uses
`defineExtension` + `defineVariable`, and shows the new contract.
What changed:
- Imports `@getbeak/extension-sdk` instead of the deprecated
`@getbeak/types-variables`.
- Single-variable default export replaced with
`defineExtension({ variables: [...] })` — one package can contribute
multiple variables, and we want the template to show that shape.
- `getValue(ctx, payload, depth)` → `resolve(extCtx, ctx, payload)`
returning `{ kind: 'text', text }`. `extCtx.parseValueSections`
replaces the old `beakApi` global.
- Inline JSDoc walks the reader through every relevant piece of the
contract — `id`, `resolve`'s ResolvedValue shape, `extCtx`, `ctx`,
the sink-coercion model, and the editor block — so this file alone
is enough to copy and modify.
Polish:
- package.json gains a description, keywords, repository, scripts
(typecheck, lint, format, check), and a `beak.apiVersion: 2`
manifest field.
- Major bump to 2.0.0 (template's own version, distinct from the
apiVersion).
- tsconfig.json strictened: `noUnusedLocals`, `noImplicitAny`,
`isolatedModules`, `noEmit`, `moduleResolution: Bundler`.
- esbuild: target=es2022, platform=neutral (the isolate isn't Node),
format=cjs, no more `--minify` (debugging in the sandbox is easier
with readable source).
- Biome config matching the Beak monorepo's house style.
- README rewritten to walk a new author through (a) the quickstart, (b)
the v2 contract in one sentence, (c) the sandbox model. Links the
SDK migration guide and the sibling lorem-swiftsum extension.
- GitHub Actions CI runs lint + typecheck + build on every push/PR.
- .editorconfig + tidier .gitignore.
- yarn.lock removed; pnpm is the new default but the build works under
yarn / npm too.
There was a problem hiding this comment.
Pull request overview
Updates the Beak variable extension template to the v2 @getbeak/extension-sdk API and refreshes the repo tooling (TypeScript, Biome, esbuild, CI) so forks start from a modern scaffold.
Changes:
- Migrate the example variable implementation to
defineExtension({ variables: [...] })and the v2resolve(extCtx, ctx, payload)contract. - Modernize developer tooling (Biome config, stricter TS config, updated build scripts).
- Add GitHub Actions CI and refresh template documentation.
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Removes Yarn v1 lockfile from the template. |
| tsconfig.json | Tightens TS compiler options and switches to ESNext + Bundler resolution. |
| src/index.ts | Rewrites the example variable to the v2 extension-sdk API and adds inline JSDoc guidance. |
| README.md | Replaces README with v2-focused quickstart and contract overview. |
| package.json | Updates metadata, adds scripts, switches dev deps to v2 extension-sdk + Biome. |
| biome.json | Adds Biome configuration aligned to the intended formatting/lint rules. |
| .gitignore | Expands ignores for Yarn/PNP-related artifacts and adds lockfile commentary. |
| .github/workflows/ci.yml | Adds CI workflow for lint/typecheck/build. |
| .editorconfig | Adds editor settings for indentation/line endings across file types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| on: | ||
| push: | ||
| branches: [master] |
| node-version: 22 | ||
| cache: pnpm | ||
|
|
||
| - run: pnpm install --frozen-lockfile |
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "pnpm clean && pnpm typecheck && esbuild src/index.ts --outfile=dist/index.js --bundle --target=es2022 --format=cjs --platform=neutral --main-fields=main", |
| ], | ||
| "scripts": { | ||
| "build": "pnpm clean && pnpm typecheck && esbuild src/index.ts --outfile=dist/index.js --bundle --target=es2022 --format=cjs --platform=neutral --main-fields=main", | ||
| "clean": "rm -rf dist", |
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.{json,yml,yaml,md}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to the Realtime-values v2 redesign in getbeak/beak#673. Brings the template up to the v2 SDK and modernises the tooling so anyone forking from it gets a working, current scaffold.
What this changes
@getbeak/types-variables→@getbeak/extension-sdk. Single-variable default export replaced withdefineExtension({ variables: [defineVariable(...)] })— one package can contribute many variables, and the template now shows that shape.getValue→resolvereturning{ kind: 'text', text }. The example variable still computes square roots; the body is just a couple of lines.beakApi→extCtx—extCtx.parseValueSectionsreplaces the old global.src/index.tswalks new authors through every relevant piece —id, theResolvedValueshape,extCtx,ctx, the sink-coercion model, and the editor block. The file alone is enough to copy and modify.Polish
package.jsongains a description, keywords, repository, build / lint / format / check scripts, and abeak.apiVersion: 2manifest.noUnusedLocals,isolatedModules,noEmit,moduleResolution: Bundler).target=es2022,platform=neutral,format=cjs, no--minify..editorconfig, tidier.gitignore,yarn.lockremoved (pnpm by default; yarn/npm still work).Test plan
pnpm install && pnpm buildproducesdist/index.jsfrom the example.