VIP-84: Project file types (a project registers an extension and a lowering module)
Status: open — proposed 2026-12-01 from the onto and fucorytweetlang domain languages (pending Will's decision). Proposal only: no compiler change accompanies this document.
Will's words
"Understand how to make vibelang as a dsl. look at our twitter example we pushed to roninjin10/fucorytweetlang"
Motivation
Two domain languages are built on VibeLang today, the same way:
- fucorytweetlang (
roninjin10/fucorytweetlang): a.tweetfile is a VibeLang module plus six declaration forms (voice,thought,rubric,tweet,thread,schedule). - onto (
smithersai/t3code,packages/onto): a.ontofile is a VibeLang module plus seven forms (object,shape,link,lifecycle,action,derive,event) for a domain's ontology.
Both follow one pattern: a compiler written in VibeLang lowers each form to typed VibeLang on the line where the form started and leaves every other line alone, so a vibe diagnostic on line N is about line N of the domain file. The pattern works. What surrounds it is done by hand, twice:
| Job | fucorytweetlang today | onto today |
|---|---|---|
Get the lowered module to vibe | Its CLI writes .fucory/build/<name>.vibe; a second tsconfig.examples.json includes that directory | onto compile writes t3code.onto.vibe beside the source, and the file is committed |
| Keep the lowered module current | Rerun the CLI before vibe | A test (t3code.onto.test.ts) lowers the source again and fails when the committed file differs |
| Import the domain file | Import the build path | import * as Ontology from "../ontology/t3code.onto.vibe": the generated name, not the source |
| Map a diagnostic back | Line only, by the line-for-line discipline; the file name is the build file, and the column is wrong whenever the lowered line is longer | The same; lowered lines run to several thousand columns |
| Show the domain language's own errors | Only from its CLI | Only from onto check |
| Editor | None: the language service does not open .tweet | None: the language service does not open .onto |
| Loader, Vite, test runner | Each sees only the build output | Each sees only the committed .onto.vibe |
Every further domain language will rebuild this list. A generated file that is committed can also drift from its source between the edit and the test run, and a reviewer reads a diff twice the size of the change.
Decision (proposed)
A project registers a file extension and a lowering module. The compiler lowers such a file in memory, compiles the result as the VibeLang module at that path, and maps every diagnostic back to the domain file.
1. Registration
In tsconfig.json, under the existing vibe options:
{
"vibe": {
"fileTypes": {
".onto": { "lower": "@t3tools/onto/lower" },
".tweet": { "lower": "fucorytweetlang/lower" }
}
}
}- The key is the extension.
.vibe,.vibex,.ts,.tsx,.js,.jsonand their declaration forms cannot be registered (EK3020). loweris a module specifier resolved from thetsconfig.jsonthat names it, the way a plugin is. It may itself be a.vibemodule; the compiler compiles it first, and a lowering module cannot be of a registered file type (EK3021, no cycles).- Files with a registered extension are matched by
includelike any source file. A file type is active only in the project that registers it.
2. The lowering module
It exports one pure, synchronous function:
export interface LowerInput {
readonly fileName: string
readonly source: string
}
export interface LowerDiagnostic {
readonly line: number // 1-based, in the domain file
readonly column?: number // 1-based; the whole line when absent
readonly endLine?: number
readonly endColumn?: number
readonly message: string
readonly code?: string // the language's own code, shown as given
}
export interface Segment {
readonly lowered: { readonly line: number; readonly column: number; readonly length: number }
readonly source: { readonly line: number; readonly column: number; readonly length: number }
}
export interface LowerOutput {
readonly code: string // a VibeLang module
readonly diagnostics: ReadonlyArray<LowerDiagnostic>
readonly segments?: ReadonlyArray<Segment> // where lowered text was copied from the source
}
export function lower(input: LowerInput): LowerOutputlowergets one file and returns one module. It reads nothing else: no file system, no network, no clock. The compiler runs it in the sandbox compile-time evaluation already uses, and caches the result by the hash ofsourceand of the lowering module.- A lowering that returns any diagnostic produces no module; the diagnostics are the file's errors.
3. Mapping back, with line and column
The default mapping is the discipline both languages already keep: line N of code is line N of source; lines past the end of the source map to its last line. That alone gives the right file and line with no work from the language.
Columns need help, because a lowered line is longer than what the author wrote. segments supplies it: each one says "these characters of the lowered module are these characters of the domain file". A type or an expression the author wrote (it.responseCapability.type === "not_resumable") is copied through as a segment, so an error inside it lands on the exact characters. A diagnostic outside every segment is reported on the whole form's first line.
The compiler composes this map with its own, so .js.map and .d.ts.map point at the domain file, and stack traces under --enable-source-maps name t3code.onto:343.
4. Module identity
./t3code.onto resolves to the lowered module, exactly as ./Orchestrator.vibe resolves today. Declaration output is t3code.onto.d.ts. No lowered file is written beside the source; vibe --showLowered <file> prints it for debugging.
5. Language service
The language service opens registered files, runs lower on each change, and shows the lowering module's diagnostics and the mapped VibeLang diagnostics on the domain file. Hover, go-to-definition and rename work inside segments (they are VibeLang text at a known place) and are off elsewhere. Syntax colouring of the forms stays the language's own business (a TextMate grammar).
6. What does not change
.vibefiles compile exactly as before. A project that registers nothing sees no difference.- A file type is a front end only. It cannot add syntax to
.vibefiles, change a rule, or silence a diagnostic. vibelang/register,vibelang-viteandvibelang-unpluginneed no new options: they ask the compiler for a module by path and get the lowered one.
What each language deletes
- onto: the committed
t3code.onto.vibeandboard.onto.vibe, theonto compilestep, the drift test, and the "generated, do not edit" rule. ItsLower.vibealready returns code and line diagnostics; it addssegmentsfor the type and expression text it copies through. - fucorytweetlang:
.fucory/build,tsconfig.examples.json, and the rerun-before-vibestep. ItsLower.vibehas the same shape.
Both keep their CLI for what is not compiling (graph, explain, can; compose, schedule).
Testing & Verification Plan
- Cases under
typescript/vibelang/cases/: a project with a.demotype whose lowering turnsconst NAME = "text"shorthand into VibeLang; a type error in a copied expression is reported at the domain file's line and column; a lowering diagnostic is reported with its own code;EK3020andEK3021. - A fuzz target in
typescript/tsc/internal/vibelangfuzz: random segment lists never map a diagnostic outside the domain file's text. - Language-service test: diagnostics appear on the
.demodocument and move when it is edited. - Both motivating languages build with their generated files deleted.
Open Questions for Will
- Where is the registration?
tsconfig.jsonundervibe(proposed, besidevibe.syntax), orpackage.json. - May
lowerbe an Effect? Proposed: no. A pure function can be cached, sandboxed and run on every keystroke; a language that needs the network does that in its own CLI. - Is one file to one module enough? Proposed: yes for now. onto and fucorytweetlang both keep one ontology or one set of posts per file; cross-file references are ordinary VibeLang imports.
- Do registered types ship in packages? Proposed: a package publishes compiled JavaScript and declarations, as it does for
.vibe; the registration is the author's build detail.