Skip to content

Generators outside the CLI build: loading, discovery, compatibility #8

Closed

Description

@Kinflou

Rescoped 2026-10-18. The generator architecture has changed since this was filed. core no longer carries a generator (codelib_gen was removed). This issue now covers the part that's still open: generators that aren't compiled into the CLI. The original plan is in this issue's edit history.

Current architecture

  • ComlineProject/generation (codegen, crate comline-codegen) is the shared layer: the Registry, the resolution kernel that generators share (they resolve once and render per target), and the generation modes (code / lib / dylib).
  • Each language is its own crate that registers itself: comline-codegen-rust (ComlineProject/comline-rust) and comline-codegen-typescript (ComlineProject/comline-typescript), each with register(&mut Registry).
  • The CLI links them statically behind cargo features (gen-rust, gen-typescript). Adding a language means rebuilding the CLI.
  • The compiled schema has a stable on-disk format: CBOR with name-tagged fields and a core-owned IR format stamp (core#84/chore: drop dead rmp_serde meta (de)serializer and stale allow(unused) #85).

What's still open

A third-party generator, or a newer version of one, can't be used without rebuilding the CLI.

  • Choose a loading model. The stable CBOR IR makes a process-based generator a natural fit: the CLI runs an external executable and passes the compiled schema plus the generation request, and the generator writes files. That avoids a Rust ABI. The alternatives are WASM components (sandboxed, portable) and dylib / abi_stable (fastest, but tied to Rust and to the platform).
  • Discovery: how comline.toml's [[generate.target]] names an external generator (path, package, or registry name).
  • Compatibility: a generator declares which IR format stamps it accepts, and the CLI refuses a mismatch with a clear message.
  • Guide for writing a generator outside this organisation.

Related: publishing bindings for third-party dependencies is still design-only.

Activity

  1. added this to the Core Features milestone on Jan 8, 2026
  2. Kinflou commented on Aug 29, 2026

    @Kinflou
    MemberAuthor

    Body updated: core/src/codelib_gen/{mod,rust}.rs is a real (if minimal, hardcoded, synchronous) rust generator now, not a todo!(). The older code_gen/lib_gen/rust_abi_stable design in ComlineProject/generation is unmigrated (imports removed basic_storage) and reviving it is part of this issue. The consumer comline.toml [generate] mode = code|lib|dylib sits on top of this.

  3. changed the title [-]Create Code Generation Plugin System[/-] [+]Generators outside the CLI build: loading, discovery, compatibility[/+] on Oct 18, 2026
  4. Kinflou commented on Oct 18, 2026

    @Kinflou
    MemberAuthor

    Related: #120 proposes how third-party encodings (formats and framings) plug in. It deliberately doesn't depend on loading generators at runtime: a consumer maps each encoding to a type per target in comline.toml, so built-in generators can wire third-party encodings. The two questions meet only when a third-party language wants a third-party encoding.

  5. Kinflou commented on Oct 31, 2026

    @Kinflou
    MemberAuthor

    Decided 2026-10-31:

    • Generators outside the CLI use one stdio protocol. The compiled CBOR IR and the generation request go in on stdin, and the generated files come out on stdout.
      • A generator ships as a native executable or as a WASI .wasm. The CLI runs a .wasm under wasmtime; the playground runs it through a browser WASI shim.
      • A generator declares which IR format stamps and protocol version it accepts, and the CLI refuses a mismatch.
    • The official Rust and TypeScript generators use the same request and response types, though they stay linked into the CLI.
    • An encoding package's suggested mapping carries the implementation's package name and version. Generated lib output depends on it automatically, and a consumer can override it in comline.toml.
    • Transports stay invisible to the handshake.

    The extension API and the generator protocol are part of the 1.0 promise (docs conduct/readiness.md). An implementation plan comes next.

  6. added
    extensibilityThird-party encodings and generators
    1.0-blockerMust be done before the 1.0 announcement (docs conduct/readiness.md)
    P0Now: top priority
    enhancementNew feature or request
    and removed
    P1Next
    on Oct 31, 2026
  7. modified the milestones: Core Features, 1.0 on Oct 31, 2026
  8. Kinflou commented on Oct 31, 2026

    @Kinflou
    MemberAuthor

    Done: the stdio protocol (ComlineProject/generation#85), generator binaries (ComlineProject/comline-rust#79, ComlineProject/comline-typescript#91), the CLI running external native and .wasm generators (ComlineProject/cli#104), the playground runner (ComlineProject/playground#103, #106), and the guide and protocol reference (ComlineProject/docs#105). Naming a generator by registry package waits for the registry (ComlineProject/package-registry#1).

  9. moved this from Todo to Done in Comline Development Roadmapon Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.0-blockerMust be done before the 1.0 announcement (docs conduct/readiness.md)P0Now: top prioritycodegenCode generationcompilerParser, IR, CASenhancementNew feature or requestextensibilityThird-party encodings and generators

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions