Build with the vibelang CLI
vibelang replaces tsc. It checks .vibe, .vibex, and .ts files as one program, emits JavaScript and compatibility declarations, and accepts TypeScript's compiler flags. Install the packages with Add VibeLang to an existing project first.
- Missing runtime: If emitted code needs
vibelang-runtimeand it cannot be resolved, compilation reports oneTS2307namingvibelang-runtime(independent source errors still report). - TypeScript 7 options: Removed options like
moduleResolution: "node"/"node10"andbaseUrlreportTS5108/TS5102(TypeScript 7 migration notes). - Cancellation & startup:
SIGINT/SIGTERMexits non-zero and printsvibelang: compilation cancelled. Exportingmainadds no startup call — invoke a top-level runner explicitly. - Formatting: Use
vibelang format --write/--check(--helplists options; see Format with dprint). Existing literal paths (quote globs like'src/[id]/page.vibe') take precedence over glob expansion; missing files, unmatched globs, or combining--checkand--writefail before modifying anything.
1. Configure tsconfig.json
VibeLang discovers vibe.config.json, tsconfig.json, then jsconfig.json per directory. vibe.config.json accepts every tsconfig field plus a top-level "vibe" object. Starter config for Node ESM:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"sourceMap": true,
"rootDir": "src",
"outDir": "dist",
"noEmitOnError": true,
"rewriteRelativeImportExtensions": true,
"skipLibCheck": true,
"types": []
},
"include": ["src/**/*.vibe"]
}- Include & discovery: A directory entry (
"src") selects.vibefiles; a glob like"src/**/*.ts"needs"src/**/*.vibe"beside it. Wildcard discovery prefers.ts,.tsx,.vibe,.vibexbefore.d.tsand.js. - Paths & scope:
${configDir}resolves to the extending project's config directory. Every.vibefile is always a module regardless ofmoduleDetection. Top-levelawaitfollows ES module/target rules (TS1378/TS1309). Standalone services without a package name need an explicitstatic readonly key.
Inspect or initialize configuration
| Command | Behavior |
|---|---|
vibelang --init | Creates TypeScript's generic tsconfig.json (set "type": "module" in package.json for ESM and adapt include/output options). |
vibelang --showConfig | Prints effective inherited JSON config (including "vibe") without compiling; config errors fail exit status, warnings keep JSON output intact. Use -p for another project. |
vibelang --noEmit --module nodenext --target es2022 src/hello.vibe | Checks explicit files directly, bypassing config discovery (--ignoreConfig is optional; combining file arguments with -p/--project is an error). |
Diagnostic severities
TypeScript's own lexical, syntax and static errors keep their TS codes, including errors inside embedded expressions and types. VibeLang's productions, placement rules and adopted proposal restrictions use the owning VIP's EK codes, regardless of the parser helper used. A specific diagnostic takes priority for the same rejection; independent native errors still report.
Configure warning codes and assigned imported EK38xx lint codes under vibe.severities ("error", "warning", "suggestion", or "off"; keep leading zeroes like EK0508):
{ "vibe": { "severities": { "EK0508": "off", "EK0801": "error", "EK4609": "off", "EK3801": "warning" } } }- Validation &
extendsrecovery:extendsmergesvibeby key andseveritiesby code (left to right for array bases; child wins). Severity entries are validated after merging: invalid effective entries reportEK3006and are ignored as overrides while valid entries still apply. An invalid child entry does not restore the displaced base entry for that code (lower-precedence Effect language-service config or the rule's default applies instead). Unknown or wrong-typedvibekeys reportEK3007. Context-dependent error/warning codes likeEK4402are nonconfigurable. - Exit behavior: VibeLang's own warnings print without failing builds or
noEmitOnError(set"error"to fail CI); own"suggestion"entries appear only in the language server. ImportedEK38xxwarnings fail builds by default (see Lint Effect code). - Legacy maps: Root
vibelang.diagnosticsandcompilerOptions.vibelang.diagnosticsare recognized invibe.config.json,tsconfig.json,jsconfig.json, and extended configs. Their supported legacy settings keep applying until migrated, with modernvibe.severitiesentries (or explicitly mapped ports, e.g.EK4801→EK3801,EK4823→EK38123) taking precedence. Each legacy map warns withEK3009("off"hides the warning while leaving legacy settings active). An explicit child legacy section replaces the inherited one whole (an empty object ornullclears inherited legacy entries while leaving modernvibesettings intact). PlaintscrejectscompilerOptions.vibelangwithTS5023. - Retired keys:
declarationImportStyle(EK3011) andtrustedPackages(EK3010) are ignored with deprecation warnings; remove them.
An import a declaration file adds, such as import { Effect } from 'effect' for a file that writes number!!, takes the quotes of the file's first written import or export specifier, as an import the TypeScript language service adds does; a file with none gets double quotes. Module types written through the file's own import keep that import, and an added Effect joins it. Public .d.ts output rewrites .vibe/.vibex re-export specifiers to .ts/.tsx, while adjacent .d.vibe.ts keeps .vibe.
Experimental features
Open proposals (VIPs 55–73: task, workflow, and Experimental.Durable, Human, Eval, Scorer, Memory, Fuzz, FuzzSimulation, Test, Patterns) require opting in:
{ "vibe": { "experimental": ["builtins"] } }Without this opt-in, the first use (including aliases, destructuring, typeof, re-exports, or subpath import()) reports EK3013. VIP-33 platform modules (Experimental.FileSystem, Experimental.Encoding, etc.) are core and need no opt-in. Invalid values report EK3007; a child experimental array replaces its base's.
2. Replace tsc in the scripts
Replace tsc with vibelang in package.json:
{
"scripts": {
"build": "vibelang",
"start": "vibelang && node --enable-source-maps dist/main.js",
"test": "vitest run"
}
}- Build modes:
vibelangchecks and emits;vibelang --noEmitonly checks;vibelang --watchrebuilds when a compilation input of the selected project changes;vibelang -bbuilds project references. For monorepos, watch the reference graph with:
vibelang -b -w packages/app- Upgrading existing
.vibecode: Replace stale./Leaf.tsimports pointing atLeaf.vibewith./Leaf.jsor./Leaf.vibe(Migrating retired forms); use(try Users).find(id)for service members andtry FileSystem.FileSystemwithout(); runtry yieldNow(ortry Effect.yieldNowWith(priority)); usePlatformError.PlatformErrorfor the failure type; and run Effects passed to plain generics explicitly (expect(try awaited())) whenEK4802fires.
Lint Effect code
vibelang runs Effect's type-aware effecttsgo/* rules from @effect/tsgo inside the compiler, language server, and vibelang lint on selected .ts and .vibe inputs (VIP-38), keeping the pinned upstream rule/file eligibility and declaration/library exclusions. VibeLang-specific language checks remain confined to .vibe. Configure rules via the repository's existing Effect language-service configuration in tsconfig.json (enabled in the starter):
{
"compilerOptions": {
"plugins": [{ "name": "@effect/language-service", "diagnosticSeverity": { "unstableApiUsage": "off" } }]
}
}{
"scripts": {
"lint": "vibelang lint -p tsconfig.json"
}
}- CLI & options:
vibelang lintaccepts compiler options (-p/--project, file args) and ignores.oxlintrc.json/oxlint.config.ts. Unsupported flags (--config,-c,--deny-warnings,--ignore-path,--ignore-pattern,--no-ignore) reportTS5023.vibelang lintnever writes or deletes files (--build --cleanand--initrun as dry-runs). It exits1on errors (never on warnings alone). - Exit codes & loaders: Imported Effect warnings fail
vibelangbuilds and blocknoEmitOnErrorby default (unlessignoreEffectWarningsInTscExitCode: trueis set; similarly forignoreEffectErrorsInTscExitCode,includeSuggestionsInTsc, andignoreEffectSuggestionsInTscExitCode). Module loaders (vibelang/register,vibelang/bun, bundler plugins) andvibelang/projectprint warnings without failing loads.NodeRuntime.runMainand@effect/vitest'sittriggerunstableApiUsage(EK38130);lazyEffect(EK3858) suggests a constant for exported zero-argeffect functions. - Rules & directives:
vibe.severitiesoverrides rules of the resolved plugin (it does not enable an absent plugin or overridediagnostics: false/diagnosticSeverity: null). Use// @effect-diagnostics-next-line schemaSync:offfor line overrides. See Effect language service rules and the imported lint diagnostic reference. - Bridging throwing helpers (
EK0402/EK0403): Wrap throwing TS helpers (includingvoidvalidators) withEffect.orDie(Effect.try({ try: () => check(), catch: (e) => e }))orEffect.orDie(Effect.tryPromise({ try: (signal) => fetchPage(signal), catch: (e) => e }))rather than mislabeling them@nothrow.
3. Compile a first module
Create src/hello.vibe:
// src/hello.vibe
export effect function hello(name: string) {
return `Hello, ${name}!`
}
// Run in an effect function: try Console.log(try hello("VibeLang"))
// Output: Hello, VibeLang!Run npx vibelang to emit dist/hello.js and adjacent .d.vibe.ts declarations (written even with --noEmit). Import local .vibe files by source name (./hello.vibe) with rewriteRelativeImportExtensions (which rewrites them to ./hello.js on emit; .ts importers in CLI builds can also write ./hello.js, whereas Vite/Vitest use ./hello.vibe — see Vite setup).
Module resolution & .vibex
| Import | Source lookup order |
|---|---|
./App, ./App.js | App.ts, App.tsx, App.vibe, App.vibex |
./App.jsx | App.tsx, App.ts, App.vibex, App.vibe |
./App.vibe | App.vibe, App.vibex |
./App.vibex | App.vibex, App.vibe |
- Source extensions: Importing a live
.ts/.tsx/.vibe/.vibexsource requiresallowImportingTsExtensionsorrewriteRelativeImportExtensions(otherwiseTS5097;allowArbitraryExtensionsapplies only to declaration sidecars). - JSX (
.vibex): Emits.jsx/.jsx.mapunderjsx: "preserve"and.js/.js.mapin other JSX modes (inlinemodule view { ... }bodies follow the same rule asmain.vibex.view.jsx/.js). Malformed JSX reports TypeScript syntax errors rather than trailing-blockEK1101. - Legacy trailing blocks (
EK1101): Rewrite explicitly aseffect { ... }(Effect program),effect () => { ... }(Effect callback), or() => { ... }(plain callback) depending on execution semantics.
4. Add an entry point
Create src/main.vibe:
// src/main.vibe
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
import { hello } from "./hello.vibe"
export effect function main() {
try Console.log(try hello("VibeLang"))
}
NodeRuntime.runMain(main())
// Output: Hello, VibeLang!Run npm run start or bun run start:
Hello, VibeLang!Keep reusable functions in separate modules so importing them does not start the runner.
5. Test with Vitest
Avoid # in the absolute project path (Vitest 5.1.0 fails to resolve test modules under paths containing #). Create vitest.config.ts and src/hello.test.vibe:
// TypeScript (.ts)
// vitest.config.ts
import { defineConfig } from "vitest/config"
import vibelang from "vibelang-vite"
export default defineConfig({
plugins: [vibelang()],
test: { include: ["src/**/*.test.vibe"] }
})// src/hello.test.vibe
import { assert, it } from "@effect/vitest"
import { hello } from "./hello.vibe"
it.effect("says hello", () => effect {
const message = try hello("VibeLang")
try Effect.try(() => assert.strictEqual(message, "Hello, VibeLang!"))
})Run npx vitest run:
Test Files 1 passed (1)
Tests 1 passed (1)Let TypeScript tools read .vibe modules
Stock tsc, tsrs, TypeDoc, and other TypeScript checkers cannot read .vibe directly, so vibelang emits compatibility declarations (src/greet.d.vibe.ts plus a forwarding src/greet.d.ts, and src/main.vibe.parse.d.ts for inline module parse bodies) on every build, --watch, -b, and --noEmit (VIP-27, VIP-40; rewritten only on change). The retired declarationSidecars option is an error — remove it.
- Stock TypeScript configuration: Enable
allowArbitraryExtensionsin any non-vibelangproject:
{ "compilerOptions": { "allowArbitraryExtensions": true } }Without it, importing ./greet.vibe in stock tsc reports TS6263. For .ts importers using ./greet.js, ./greet, or ./greet.ts, the compiler also emits a forwarding greet.d.ts (never overwriting a hand-written .d.ts — it reports TS5055 instead):
export * from "./greet.vibe";
export { default } from "./greet.vibe";- Declaration surface: Published declarations retain the corresponding TypeScript class surface: generated matcher members and runtime reference directives are not added. Generated matchers remain in JavaScript; VibeLang consumers load the protocol from their own runtime prelude.
schemaJSDoc emits on the constant only; cyclic inferred types use/*elided*/ anyrather than TS 7.1TS5088(Declaration output). - Unprintable exports: In projects with
declarationorcomposite, unprintable types (TS4094,TS2883) are errors. In projects with neither, sidecars may referencenode_modulespaths. What it still cannot print there, such asTS4094, is an error only where a.tsfile of the project imports the module, as for the same TypeScript undertsc, since that file reads the sidecar: it is reported at that import. - Bun checking: When a
checkscript is declared,bun checkruns the project'scheckscript; a script that invokes a TypeScript checker uses that checker's sidecar resolution.bun check --no-script(Bun 1.4.4+) invokes Bun's native checker, which the runtime preload does not replace; usevibelang -bor"check": "vibelang -b"for native.vibechecking. - Ordering: Stock checkers read only sidecars and do not check
.vibebodies — runvibelangfirst:
vibelang --noEmit && tsrs -bKeep the sidecars in one directory
Set vibe.sidecarDir (and add it to rootDirs) to keep generated sidecars out of src/ (e.g. for tools that glob *.ts):
{
"compilerOptions": { "allowArbitraryExtensions": true, "rootDir": ".", "rootDirs": [".", ".vibe/declarations"] },
"vibe": { "sidecarDir": ".vibe/declarations" }
}src/greet.vibe emits .vibe/declarations/src/greet.d.vibe.ts (mirrored under rootDir or inferred source root; use ${configDir}/.vibe/declarations in shared base configs, and keep the directory inside the package for node_modules resolution). Switching vibe.sidecarDir on or off prunes unchanged sidecars owned solely by this project (tracked via hidden .vibelang-sidecar-*.owner receipts — ignore them in VCS alongside .vibe/declarations/). Do not list sidecars explicitly in files (they are outputs and would trigger TS5055).
Run sources with Node
Load the vibelang/register hook to run .ts/.vibe sources directly without building dist/:
node --import vibelang/register src/start.tsYou can also call import "vibelang/register" in TypeScript config files. .vibex works when jsx emits JS (react-jsx, react-jsxdev, react); under jsx: "preserve", Node reports ERR_VIBELANG_JSX (use Bun or a bundler instead).
- Resolution & caching: Compiles using the nearest config (
vibe.config.json→tsconfig.json→jsconfig.json), enables thevibelang-sourceexport condition, supports extensionless imports,require()/createRequire(), and caches on disk (invalidated on source, config, dependency, or compiler changes; sidecar changes do not invalidate). Configure withVIBELANG_CACHE_DIR,VIBELANG_DISABLE_CACHE=1, andVIBELANG_REGISTER_DEBUG=1. Failed checks leave existing sidecars intact. - Playwright: Preload via
NODE_OPTIONS(also reaches child Node processes and barenode src/main.vibe; pass--config playwright.config.vibefor a.vibeconfig and keep.spec.tstest files):
NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--import=vibelang/register" npx playwright test- Programmatic tools (
vibelang/source,vibelang/project):
import { readFileSync } from "node:fs"
import { listSources, resolveSource } from "vibelang/source"
const files = listSources("snippets")
const file = resolveSource("snippets/example.ts")
if (file === undefined) throw new Error("Missing snippet")
const text = readFileSync(file, "utf8")listSources(dir) returns sorted immediate .ts/.tsx/.vibe/.vibex files (excluding sidecars and virtual NUL-byte IDs). resolveSource(file) falls back from an absent .ts/.tsx to its .vibe/.vibex sibling. compileProjectSync and projectBackend().compile(project) (vibelang/project) check all project inputs (call await close() when done).
Run sources with Bun
Use Bun 1.4.2 or later for the runtime loader (1.3.13/1.4.0 have resolver and Unicode bugs). Preload vibelang/bun in bunfig.toml (or --preload vibelang/bun):
preload = ["vibelang/bun"]
[test]
preload = ["vibelang/bun"]- Resolution & features: Compiles
.vibeand.vibex(forwarding preserved JSX to Bun's JSX loader) via the nearest tsconfig (override withVIBELANG_PROJECT), supports extensionless imports, tsconfigpaths,./x.jsand missing./x.tsimports, Unicode/space/#/%filenames, CommonJSrequire,--define/[define], and live bindings for.vibelang/js/exports. - Stack frames: A stack frame names
.vibesource lines when the module's emitted JavaScript is ASCII and needs nothing from Bun's transpiler; otherwise it names the.vibefile with the line of its compiled JavaScript (Source maps: Limits). Running prebuiltbun dist/main.jsleaves frames unmapped — usenode --enable-source-maps dist/main.js(Debug stack traces). - Computed dynamic imports: Use relative/absolute source paths (
const p = "./src/feature.vibe"; await import(p)). Computed bare aliases to migrated.vibesiblings require literal imports; for computed extensionless bare aliases, Bun does not invoke runtime resolver hooks (Bun issue #40579). Bun.buildinside scripts/tests:vibelang/bundoes not hookBun.build; installvibelang-unpluginand preloadvibelang-unplugin/bun/registerin bothpreloadand[test].preload(Bun build plugin).- Child
bun testprocesses:bun testreads only[test].preloadfrom its own working directory (fixture subdirectories need their ownbunfig.toml) and discovers.test.ts/.test.jsfiles (use Vitest for.test.vibe).
Watch source modules in Bun
With the vibelang/bun preload configured, bun test --watch reruns tests after an imported .vibe source changes, including through re-exports. bun --watch --preload vibelang/bun src/main.ts restarts an application after those changes. Each restart reads the changed source and reuses a cached compile only while its inputs remain unchanged. Use bun test --timeout 30000 when service-init tests exceed Bun's 5 s default.
Bun test types
Install @types/bun and enable "bun" in your test tsconfig (keeping any existing entries):
bun add -d @types/bun{ "compilerOptions": { "types": ["bun"] } }In bunfig.toml:
[test]
preload = ["vibelang/bun"]Write src/greeting.test.ts and run bun test (use Effect.runPromise for async Effects):
// TypeScript (.ts)
import { expect, test } from "bun:test"
import { Effect } from "effect"
import { greeting } from "./greeting.vibe"
test("greeting", () => {
expect(Effect.runSync(greeting("Bun"))).toBe("Hello, Bun!")
})Run vibelang -p tsconfig.json for full type-checking (the preload only emits .vibe modules and reports errors in loaded .vibe files plus project-wide errors).
Upgrading legacy VibeLang code
| Legacy pattern | Current VibeLang form |
|---|---|
readonly defaults on schema / service fields | Write explicit readonly where needed (checking now uses shallow mutability unless marked readonly). |
Empty package "name": "" service keys | Write an explicit static readonly key to retain older directory-derived keys. |
f(throw error, next) (EK1010) | Parenthesize before a comma: f((throw error), next). |
forkIn(scope, program) | Native argument order: forkIn(program, scope) (and import sync/callback explicitly when vibe.effectGlobals: false). |
uninterruptible / restore outside effect code (EK2201) | Remove the keyword or move into an effect block. |
do { … } used as an Effect argument | Wrap in effect { return do { … } }. |
EK38xx in vibe.severities without plugin (EK3012) | Add the @effect/language-service plugin to tsconfig.json. |
Profile compilation
| Flag | Output |
|---|---|
vibelang --generateCpuProfile compiler.cpuprofile | Chrome CPU-profile JSON (works with --build and on error; cannot combine with --pprofDir). |
vibelang --pprofDir profiles | Go CPU and memory profiles (fails command on write error). |
vibelang --build --generateTrace traces | Writes trace.json, types_*.json, and legend.json per compiled project under traces/project-*. |
vibelang --lsp --help / --stdio | Inspect LSP flags or run over stdio (--pipe and --socket are reserved/unsupported). |
Build-mode profile/trace paths resolve relative to the working directory.
Next
Set up your editor: VS Code and Cursor, Neovim, Zed, or other editors. Then verify with step 4 of Set up VibeLang.