themegen

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 4 Imported by: 1 module, 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

themegen

AI theme generator: validated themes (static/base.css + static/style.css, plus opt-in templates/*.html overrides) from a natural-language brief, powered by an OpenAI-compatible API. Generated themes pass the same file/CSS/template-render gate the engine uses at boot and activation, plus a generated-content scan (no scripts, handlers, javascript: URLs, or root/ files — manual themes stay trusted); failures feed a bounded two-attempt repair loop over the original readable output before the theme is refused with its reason, and CSS is minified at install time.

  • domain/ — brief/theme types, validation (slug grammar, allowlist, size caps), envelope parser, orchestration service with the repair loop, validator.
  • infrastructure/ — OpenAI-compatible client + per-call grounded prompts (edition stylesheet and template sources + distilled contracts, including the style preset on repairs).
  • store/ — filesystem store under THEMES_DIR with theme.json manifests and stdlib zips.
  • api/ — browser handler: generate, list, download, activate, deactivate, delete, preview.
  • admin/ — admin-shell manifest (Theme Generator + Themes nav).

Activation writes [theme] active, validates the full theme (CSS plus template parse and smoke renders), and hot-applies it through the edition's reloader; a failed reload reverts the config write. Precedence: THEME_DIR > preview cookie > [theme] active > embedded. Startup never bricks: a broken active theme falls back to embedded with themeValidationFailed on /api/health.

Documentation

Overview

Package themegen is the official AI theme module: the generator over OpenAI-compatible APIs, the filesystem store, and the browser handler.

Index

Constants

View Source
const Name = "themegen"

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 themegen 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.

func (*Module) Handler

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

Handler exposes the theme generator handler for core mounting. Core mounts it explicitly (rather than via RouteProvider) because the surface is gated by the themGenEnabled 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. Theme sources enrich prompts; absent, generation uses the distilled contract alone.

func (*Module) Requires

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

Requires lists hard dependencies. Generation degrades without theme sources, so nothing is required.

func (*Module) Service

func (m *Module) Service() *themegendomain.Service

Service exposes the orchestration 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 WithActivations

func WithActivations(store api.ThemeActivationStore) Option

WithActivations adopts the active-theme store (the [theme] active value). Without one activation and deactivation stay unavailable.

func WithEdition

func WithEdition(edition themegendomain.Edition) Option

WithEdition sets the default edition the generator derives from (blog or storefront). Empty defaults to blog.

func WithLogger

func WithLogger(logger kernel.Logger) Option

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

func WithPreviewKey

func WithPreviewKey(key []byte, secure bool) Option

WithPreviewKey installs the cookie-signing key for the preview endpoints (derived from the server secret by the composition root; Secure mirrors the site origin). Without one Preview answers 503.

func WithReloader

func WithReloader(reloader api.ThemeReloader) Option

WithReloader attaches the edition's reload closure so activation hot-applies the theme without a restart. Without one activation keeps the restart-hint behavior.

func WithService

func WithService(service *themegendomain.Service) Option

WithService adopts the orchestration service (composition root, nil when unconfigured). The handler is only mounted when generation is enabled.

func WithSnapshotRenderer

func WithSnapshotRenderer(renderer api.ThemeSnapshotter) Option

WithSnapshotRenderer attaches the edition's snapshot closure so the admin panel can frame an installed theme's rendered homepage. Without one the snapshot endpoint answers 503.

Directories

Path Synopsis
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for theme generation.
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for theme generation.
api
Package themegen is the AI theme generator module's domain layer: the brief, theme, and validation value types, the generation/store ports, and the envelope parser that validates the model's JSON output.
Package themegen is the AI theme generator module's domain layer: the brief, theme, and validation value types, the generation/store ports, and the envelope parser that validates the model's JSON output.
Package infrastructure adapts the themegen domain port onto OpenAI-compatible chat-completion APIs.
Package infrastructure adapts the themegen domain port onto OpenAI-compatible chat-completion APIs.
Package store persists generated themes on disk: one directory per theme under THEMES_DIR, a theme.json manifest, and stdlib zip archives for download and manual THEME_DIR installs.
Package store persists generated themes on disk: one directory per theme under THEMES_DIR, a theme.json manifest, and stdlib zip archives for download and manual THEME_DIR installs.

Jump to

Keyboard shortcuts

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