CBCL / DocumentationDocs v0.3.1

Install a dialect in JavaScript

The greeting dialect adds the verb greet. This verb expands to the core verb tell.

On this page

Install the SDK

Use Node 22.6 or higher. Run this command in your project directory.

npm install --save-exact @anuna/[email protected]

Verify and examine the greeting

Save the example as greeting.mjs.

Run node greeting.mjs.

import { installDialect, parseDialect } from '@anuna/cbcl';

const source = '(define greeting () @alice (extend greet (who) (tell who "hello")))';
const installed = installDialect(source);
console.log(parseDialect(installed.dialect).name);

The program prints greeting. The parameter who identifies the recipient of the expanded message.

Change the verb name from greet to tell. Run the program again. The installer rejects the definition because the core language defines tell.

Use the SDK in a browser

Import ready from the same package. Call await ready() before the first synchronous verifier call. The package includes the WebAssembly verifier.

Use the main package to parse and install dialects. Use @anuna/cbcl/object for contracts and thread state. Use @anuna/cbcl/view for presentations.

Continue to Count a vote to use a stateful dialect.