textgen

package module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

modules/textgen

Official Lesstruct module: AI text generation — the Enhancer and the Translator over OpenAI-compatible APIs.

Layout (module template)

module.go            # kernel.Module (single registry-facing file)
api/                 # browser handlers (legacy envelope) + mocks
domain/              # TextGenerationService, OpenAI provider (3.6a)
admin/               # admin-shell manifest (empty: TipTap buttons render data-driven)
testutil/            # kernel fixture for module tests

Handlers

The browser-realm api.TextGenHandler serves Enhance and Translate with the legacy error:null envelope. Media context injection degrades gracefully: without a media lister the handler generates without media context. The TipTap toolbar buttons render data-driven from the /api/health feature flags, so the module declares no admin extensions. Core mounts the handler explicitly through the structural TextGenSurface interface in routes.go (the textGenEnabled feature flag gates mounting), so routes stay module-agnostic and paths never drift.

Documentation

Overview

Package textgen is the official AI text module: the Enhancer and the Translator over OpenAI-compatible APIs.

Index

Constants

View Source
const Name = "textgen"

Name is the registry key for this module.

View Source
const Version = "0.1.0"

Version is the module version reported via Module.Version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module is the textgen kernel module.

func New

func New(opts ...Option) *Module

New builds the module, adopting the composition root's wiring. The handler is built once here so routes serve the same instance.

func (*Module) AdminManifest

func (m *Module) AdminManifest() kernel.AdminExtensionManifest

AdminManifest declares this module's admin-shell extensions. The TipTap toolbar buttons render data-driven from the /api/health feature flags, so the module declares no menu entries, settings sections, or editor extensions.

func (*Module) Handler

func (m *Module) Handler() *api.TextGenHandler

Handler exposes the text generation handler for core mounting. Core mounts it explicitly (rather than via RouteProvider) because the surface is gated by the textGenEnabled feature flag, which a single RegisterRoutes call cannot express.

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init wires the module. The handler is already built by New; Init only validates presence.

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. Media context enriches HTML prompts and the site-ssr theme bakes design tokens into them; absent either, enhance/translate still work.

func (*Module) RefreshThemeStyles added in v1.5.0

func (m *Module) RefreshThemeStyles(baseCSS, styleCSS string)

RefreshThemeStyles forwards the active theme's styles to the refresher the composition root attached (nil-safe: without one the call is a no-op).

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. Text generation degrades gracefully without media context or theme design tokens, so nothing is required.

func (*Module) Service

Service exposes the adopted text generation service. It stays valid for the module's lifetime.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases module resources. There are none beyond memory.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that serves nothing (the handler built over nil dependencies must not be invoked).

func WithLogger

func WithLogger(logger kernel.Logger) Option

WithLogger attaches the module logger. Without one handler failures are dropped (discard sink).

func WithMediaLister

func WithMediaLister(lister api.MediaLister) Option

WithMediaLister attaches the media library for AI context injection. The media domain service satisfies it structurally; without one the handler generates without media context (the legacy behavior when media is absent).

func WithService

func WithService(service textgendomain.TextGenerationService) Option

WithService adopts the text generation service (composition root, nil when unconfigured). The handler is only mounted when a service exists.

func WithThemeRefresher added in v1.5.0

func WithThemeRefresher(fn func(baseCSS, styleCSS string)) Option

WithThemeRefresher attaches the callback the edition invokes after a theme reload so AI HTML generation follows the new brand without a restart. The callback receives the active theme's minified base.css and style.css.

Directories

Path Synopsis
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for text generation.
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for text generation.
api
Package textgen is the AI text module's domain layer: the text-generation port, its result value types, and the parser that validates the model's JSON envelope.
Package textgen is the AI text module's domain layer: the text-generation port, its result value types, and the parser that validates the model's JSON envelope.
Package infrastructure adapts the text module's domain port onto OpenAI-compatible chat-completion APIs.
Package infrastructure adapts the text module's domain port onto OpenAI-compatible chat-completion APIs.
Package testutil provides the kernel fixture module tests run against.
Package testutil provides the kernel fixture module tests run against.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL