Skip to content
Moku LabsDocs
@moku-labs/common pages

@moku-labs/common

Shared plugins: log, env, branded CLI.

common.mdllms.txt

Overview

@moku-labs/common is a catalog of shared plugins for the Moku family. You author a plugin once and reuse it in every framework. It has no createApp and no defaults of its own: you register its plugins in your framework's createCoreConfig.

  • Write once, reuse everywhere. Logging and env live here, not in every framework.
  • Core plugins. Built with createCorePlugin, so their APIs land on every plugin's context as ctx.log and ctx.env.
  • A node-free browser entry. @moku-labs/common/browser never pulls a node:* module into a client bundle. A CI gate proves it.
ExportWhat it does
logPluginIn-memory trace and an expect() DSL for testable workflows. Injected as ctx.log.
envPluginValidated, frozen environment from several providers. Injected as ctx.env.
dotenv, processEnv, cloudflareBindingsEnv providers for Node and Workers.
browserEnvEnv provider for the browser, from @moku-labs/common/browser.
createBrandConsole, createBrandPromptsThe branded terminal kit, from @moku-labs/common/cli.

Install

bun add @moku-labs/common @moku-labs/core

Quick start

Register the plugins in your framework's createCoreConfig. Every plugin then gets ctx.log and ctx.env.

my-framework/config.ts
import { envPlugin, logPlugin } from "@moku-labs/common";
import { createCoreConfig } from "@moku-labs/core";

type Config = { stage: "production" | "development" };
type Events = {};

export const coreConfig = createCoreConfig<Config, Events, [typeof logPlugin, typeof envPlugin]>(
  "my-framework",
  {
    config: { stage: "production" },
    plugins: [logPlugin, envPlugin]
  }
);

export const greeterPlugin = coreConfig.createPlugin("greeter", {
  api: ctx => ({
    greet: (name: string) => ctx.log.info("greeter:greet", { name })
  })
});
  1. ctx.log and ctx.env on every plugin.

Pick the env provider that matches each target:

import { dotenv, processEnv } from "@moku-labs/common"; // Node
import { browserEnv } from "@moku-labs/common/browser"; // browser, node-free

Start with Claude

Describe what you want. The conductor picks the packages.

Build a blog with tags and an RSS feed on @moku-labs/web

Add a D1-backed comments API with @moku-labs/worker

Make a couch quiz game: TV shows questions, phones answer

Ship this app to macOS and iOS