Build a card type

Create a new interaction, grading behavior and payload contracts in a local provider project. If you only want to add cards or decks using existing interactions, follow the course-author instructions instead.

Experimental provider development kit. The workflow has been tested locally on macOS with Node 22 and 24. An independent provider-author trial has not yet been completed. The kit requires an app checkout; it is not a separately published SDK.

1. Prepare your environment

Install Node 22+, Gleam 1.18.1+ and Git. Obtain the app repository (repository access is required). In that checkout:

git clone https://github.com/vistuleB/equation-flashcards.git
cd equation-flashcards
npm ci
npm run providers:prepare

Install npm dependencies on the machine and operating system where you will run the kit. Copying macOS node_modules into Linux breaks esbuild's native executable. An offline environment must already have its compiler and dependencies provisioned.

Preparation builds the host contracts and generated schemas inside the app checkout. Repeat it when the tools report missing or stale preparation. Provider checks do not rebuild the host automatically.

2. Generate and run a provider

From the app checkout, choose a new directory outside it. Replace the example absolute path below with your own:

npm run providers:init -- /absolute/path/my-provider
(cd /absolute/path/my-provider && npm run build)
npm run providers:check -- --config /absolute/path/my-provider/playground.json
npm run dev:providers -- --config /absolute/path/my-provider/playground.json

Open localhost:3022. The starter is an exact-text echo card, using the app's real content and result boundaries. It deliberately saves no drafts; saved work is an optional capability. No account or cloud sync is involved.

3. Change the card

FileWhat you own
manifest.jsType ID, schema name and view entry; rebuild after changes
src/providers_echo_test.gleamPayload definitions and semantic requirements
provider.jsProvider registration and behavior
view.jsUI and lifecycle calls
playground.jsonSample cards, contract checks and local storage identity
export-schemas.mjsStructural schema exports

Build in the provider directory after editing contracts, then run the checker from the app checkout. The build regenerates exported schemas; the checker compiles but does not export them. Restart the preview and reload after edits; there is no hot reload yet.

Import defineCardType and boundary adapters from @flashcards/provider-sdk/v1, which the kit resolves; it is not a published npm package. Import contracts through the generated .generated/contracts.js facade. The starter pins shared dependency versions and checksums to match the host. Do not prebundle a second Gargamelle runtime.

For SDK-v1 saved work, see experiments/provider-contract-test/saved-provider.js and saved-view.js. The ordering example demonstrates autosaved reordering, but retains legacy registration wiring, compiler-output imports and unused math hooks. Use it as an interaction reference, not as the template for a new declaration.

4. Exercise failures and restoration

Historical evidence and independent tests

Add interpretations cases with a name, current sample, historical attempt and expected outcome. These exercise the historical result interpreter without binding old evidence to the current answer. Use --verbose for named checks and rejection details; negative cases can require a rejectionIncludes diagnostic substring.

Select Continue or Finish before mounting a card. With the saved echo fixture, after completion use Save current occurrence for restoration, then Restore, to verify completed-card behavior without adding another try. The minimal starter does not retain a provider payload.

Concurrent servers accept --port N and use independent build directories. Keep test ports separate from preview ports. Independent Node tests can import provider.js using PROVIDER_CONFIG=/path/playground.json node --import /path/equation-flashcards/provider-dev/register.mjs --test /path/example.test.mjs. See the complete workflow below for registration hooks and automation controls, and the Gargamelle API for contract authoring.

What this playground covers

Drafts, completion, continuation, skipping and diagnostics work through the host lifecycle. Each sample simulates one mounted card with a selectable Continue or Finish receipt. Scheduling, history digests, authentication, xAPI persistence and cloud sync are not simulated. Provider code is trusted local code, not isolated by a security sandbox.

Contract checks do not replace interaction tests or prove schema equivalence. Test both valid and invalid payloads, recovery from rejected submissions, and compatibility with saved drafts.

From experiment to integration

Keep your source, samples, schemas and tests together. Follow the repository integration guide when the provider is ready for review. Maintainer integration and deployment make a type available to course authors; uploading course JSON cannot install executable provider code.