@mochabug/adaptkit
Adaptkit is the command-line tool for Adapt applications. It creates projects, adds vertices, installs the agent skills, runs the local emulator, and uploads your application.
Install Adaptkit
Section titled “Install Adaptkit”Adaptkit needs Node.js 24 or newer.
npm install --global @mochabug/adaptkit@latestOr run it without installing: npx --yes --package @mochabug/adaptkit@latest adaptkit <command>. Generated projects also include Adaptkit, and their npm scripts use that copy.
Adaptkit tells you once a day when a new version exists. To turn this off, set NO_UPDATE_NOTIFIER=1 or pass --no-update-check. After an update, refresh the agent skills with adaptkit skill.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
adaptkit init |
Creates an application with its first vertex. |
adaptkit add |
Adds a vertex. |
adaptkit skill |
Installs or refreshes the agent skills. |
adaptkit emulator |
Starts the emulator. Also setup, stop, and logs. |
adaptkit emulate |
Uploads a build to the emulator. |
adaptkit publish |
Publishes a build to Adapt. |
adaptkit version |
Raises the version in manifest.json. |
Each command has --help.
adaptkit init
Section titled “adaptkit init”Creates a project and its first vertex, installs the dependencies, and installs the agent skills. Without options, a wizard asks for each choice.
adaptkit init --dir ./ticket_form --name ticket_form --vertex ticket_form \ --capabilities browser configurator --endpoints http --api http \ --frontend react --ssg --no-interactive| Option | Description |
|---|---|
-d, --dir <directory> |
Project folder. Default: the current folder. |
--name <name> |
Application name. |
--vertex <name> |
First vertex name. |
--capabilities <values...> |
browser, configurator, cron, external, or none alone. |
--endpoints <values...> |
http, tcp, datagram. Required with browser or external. |
--api <protocol> |
http or connect. Required for HTTP: Browser pages, settings pages, and External HTTP. |
--frontend <framework> |
typescript or react. Required with browser or configurator. |
--ssg, --no-ssg |
Render pages at build time, or not. Required with pages. |
--no-interactive |
Never ask. Fail when a choice is missing. |
Names use letters, numbers, and underscores, and start with a letter or underscore. Adaptkit makes them lowercase.
Which options to choose
Section titled “Which options to choose”Capabilities decide what the vertex can do. See Capabilities.
| Capability | The vertex gets |
|---|---|
none |
Nothing extra. It runs when the flow reaches it. |
browser |
A page that people use while it runs. |
configurator |
A settings page. |
cron |
Calls on a schedule. |
external |
Endpoints for callers outside Adapt, such as webhooks. |
Endpoints: browser needs http. tcp gives raw TCP connections, and datagram, which needs external, gives QUIC datagrams.
API: http gives plain routes. connect gives Connect RPC services from Protocol Buffers, which also accept gRPC and gRPC-Web. Adaptkit sets up Buf and generates the code.
Frontend and SSG: pages in plain TypeScript or React. With --ssg, the build renders each page’s first HTML, so people see content before JavaScript runs. See Browser pages.
adaptkit add
Section titled “adaptkit add”Adds a vertex to an existing project. It takes the same options as init, except --vertex, plus these:
| Option | Description |
|---|---|
--name <name> |
Vertex name. |
--folder <path> |
Folder under src/. Default: src/<name>. |
--executor-program <number|new> |
Executor program in runtime.json, counted from 1, or new. Required without the wizard. |
--configurator-program <number|new> |
Configurator program, for vertices with a settings page. Required without the wizard. |
adaptkit add --name ticket_status --capabilities none --executor-program 1 --no-interactiveA new program gets the default runtime and limits: 64 MB of memory, 30 seconds of wall time, and 100 ms of CPU time. See Programs.
adaptkit skill
Section titled “adaptkit skill”Installs the agent skills, or replaces them with the versions in your Adaptkit. Use --dir for another folder.
adaptkit emulator
Section titled “adaptkit emulator”adaptkit emulator setup # once per user: certificates and local trustadaptkit emulator # start, and open http://localhost:51001adaptkit emulator logs # follow the logsadaptkit emulator stop # stop, and discard the emulator's state| Option | Description |
|---|---|
--tag <tag> |
Image tag. Default: latest, which checks Docker Hub for updates. |
--no-open |
Do not open a browser. |
See Local emulator.
adaptkit emulate
Section titled “adaptkit emulate”Uploads an emulator build to the running emulator. npm run emulate builds and uploads in one step. Use -d, --dir for another project folder, and --upload <file> for another upload description. The default is dist/upload.json.
adaptkit publish
Section titled “adaptkit publish”Publishes a production build. npm run publish builds and publishes in one step.
Adaptkit opens your browser to sign in, and prints a link in case the browser does not open. You have 10 minutes. Press Ctrl+C to cancel.
| Option | Description |
|---|---|
-d, --dir <directory> |
Project folder. |
--upload <file> |
Upload description. Default: dist/upload.json. |
--staging |
Publish to the staging services. Needs a staging build. |
-c, --client <id> |
OAuth client ID for sign-in. Only with --staging. |
adaptkit version
Section titled “adaptkit version”adaptkit version patch # 1.2.3 → 1.2.4adaptkit version minor # 1.2.3 → 1.3.0adaptkit version major # 1.2.3 → 2.0.0Only manifest.json changes.
npm scripts
Section titled “npm scripts”Generated projects have these scripts:
| Script | What it does |
|---|---|
npm run dev |
Starts the development server, with the mock API. |
npm run build |
Installs, type-checks, and builds for production. |
npm run emulator |
Starts the emulator. Also emulator:logs and emulator:stop. |
npm run emulate |
Builds for the emulator, and uploads. |
npm run publish |
Builds for production, and publishes. |
npm run add |
Runs adaptkit add. |
build:emulate, build:staging, and publish:staging build and publish for the other environments. Connect projects also have npm run generate for the Protocol Buffers code. There is no test script yet. See Unit tests.
Environments
Section titled “Environments”Each build targets one environment, and each upload command accepts only builds for its own.
| Script | Uploads to | Sign-in |
|---|---|---|
npm run publish |
Production: https://adapt.mochabugapis.com |
Yes |
npm run publish:staging |
Staging: https://adapt-dev.mochabugapis.com |
Yes |
npm run emulate |
The emulator: http://localhost:51001 |
No |
All builds use the real APIs. Only npm run dev uses the mock API.
What an upload checks
Section titled “What an upload checks”Before it uploads, Adaptkit checks that the build is for the right environment, and validates manifest.json, each vertex.json, and each vertex’s metadata. It never builds your application.
It also resizes logos: the application logo to 80 × 80 pixels, and vertex logos to 40 × 40. SVG files are sent as they are. Each logo must end up at most 25,600 bytes.
Validate in CI
Section titled “Validate in CI”Run the same checks without uploading, after npm run build:
import { readUploadArtifact } from "@mochabug/adaptkit/upload";
await readUploadArtifact({ root: ".", upload: "dist/upload.json", expectedEnvironment: "production",});console.log("dist/upload.json is valid");Troubleshooting
Section titled “Troubleshooting”| Problem | Solution |
|---|---|
| Adaptkit refuses your Node.js version. | Install Node.js 24 or newer. |
--endpoints is required for Browser or External capability |
Give every option that your capabilities need, or leave out --no-interactive. |
--name: Use letters, numbers, and underscores; start with a letter or underscore |
Use a name such as ticket_form. |
| The upload rejects the build’s environment. | Use the matching script: npm run publish or npm run emulate. |
| The upload rejects the organization. | You changed organization after the build. Build again. |
| A logo is too large. | Use a smaller image, or an SVG file. |
| The emulator does not start. | See emulator troubleshooting. |