@moku-labs/common
Shared plugins: log, env, branded CLI.
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 asctx.logandctx.env. - A node-free browser entry.
@moku-labs/common/browsernever pulls anode:*module into a client bundle. A CI gate proves it.
| Export | What it does |
|---|---|
logPlugin | In-memory trace and an expect() DSL for testable workflows. Injected as ctx.log. |
envPlugin | Validated, frozen environment from several providers. Injected as ctx.env. |
dotenv, processEnv, cloudflareBindings | Env providers for Node and Workers. |
browserEnv | Env provider for the browser, from @moku-labs/common/browser. |
createBrandConsole, createBrandPrompts | The branded terminal kit, from @moku-labs/common/cli. |
Install
bun add @moku-labs/common @moku-labs/coreQuick start
Register the plugins in your framework's createCoreConfig. Every plugin then gets ctx.log and
ctx.env.
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 })
})
});- 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-freeStart 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