Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_manifest.hpp
Go to the documentation of this file.
1#pragma once
2
3// pulp::design — compiled design contract.
4//
5// A DesignManifest is the closed set of tokens and components a generated or
6// imported UI is allowed to bind to. It is compiled from the buildable sources
7// of truth — a Theme (the token allowlist) and the component catalog (each
8// widget's native class plus the exact theme tokens it paints through) — into
9// one deterministic artifact. Two consumers use it:
10//
11// 1. A binding prompt (Markdown) embedded in an importer / codegen prompt, so
12// the model that writes UI JS is told up front which tokens and widgets are
13// real. Inventing a token name or targeting an unknown widget is then a
14// visible contract break rather than a silent drift.
15// 2. An adherence check that validates already-generated UI against the same
16// manifest — the prompt and the check share one source of truth.
17//
18// The manifest is deterministic: every list is sorted by name and serialized in
19// a fixed key order, so it diffs cleanly in review and can gate CI.
20
21#include <pulp/design/design_system.hpp> // ComponentInfo, catalog()
22#include <pulp/view/theme.hpp> // Theme
23
24#include <string>
25#include <string_view>
26#include <vector>
27
28namespace pulp::design {
29
32inline constexpr std::string_view kManifestVersion = "2026.07-design-manifest-v1";
33
37 std::string name; // e.g. "color.bg", "radius.md", "font.family"
38 std::string kind; // "color" | "dimension" | "string"
39 std::string value; // "#rrggbb"/"#rrggbbaa" | trimmed number | verbatim string
40};
41
45 std::string name; // "Knob"
46 std::string category; // category_name(...)
47 std::string native_class; // "pulp::view::Knob"
48 std::string header; // "pulp/view/widgets.hpp"
49 std::string figma_component; // component-set name in the authored library
50 std::string usage; // one-line intent
51 std::vector<std::string> reskin_tokens; // token allowlist for this widget
52};
53
57 std::string manifest_version; // kManifestVersion
58 std::string source; // provenance ("ink-signal", a DESIGN.md path, ...)
59 std::string appearance; // "light" | "dark"
60 int theme_schema_version = 0; // Theme::kSchemaVersion the tokens follow
61 std::vector<ManifestToken> tokens;
62 std::vector<ManifestComponent> components;
63};
64
68 const std::vector<ComponentInfo>& components,
69 std::string source,
70 std::string appearance);
71
75
78std::string manifest_to_json(const DesignManifest& manifest);
79
84DesignManifest manifest_from_json(const std::string& json);
85
90std::string emit_binding_prompt(const DesignManifest& manifest);
91
92} // namespace pulp::design
Definition design_adherence.hpp:32
std::string emit_binding_prompt(const DesignManifest &manifest)
Emit an LLM-ready binding prompt (Markdown): the closed token allowlist and the component contracts,...
DesignManifest compile_design_manifest(const pulp::view::Theme &theme, const std::vector< ComponentInfo > &components, std::string source, std::string appearance)
Compile a manifest from an explicit theme + component set.
std::string manifest_to_json(const DesignManifest &manifest)
Serialize to stable, pretty JSON.
DesignManifest compile_ink_signal_manifest(bool dark=false)
Compile from the built-in Ink & Signal system: its theme for the requested appearance plus the full c...
constexpr std::string_view kManifestVersion
The on-disk format identifier stamped into DesignManifest::manifest_version.
Definition design_manifest.hpp:32
DesignManifest manifest_from_json(const std::string &json)
Parse a manifest back from the JSON that manifest_to_json produces.
The compiled design contract.
Definition design_manifest.hpp:56
std::string appearance
Definition design_manifest.hpp:59
std::vector< ManifestToken > tokens
Definition design_manifest.hpp:61
std::vector< ManifestComponent > components
Definition design_manifest.hpp:62
std::string manifest_version
Definition design_manifest.hpp:57
int theme_schema_version
Definition design_manifest.hpp:60
std::string source
Definition design_manifest.hpp:58
One component contract: a widget an importer may target and the exact theme tokens it legitimately pa...
Definition design_manifest.hpp:44
std::string name
Definition design_manifest.hpp:45
std::string usage
Definition design_manifest.hpp:50
std::string native_class
Definition design_manifest.hpp:47
std::string category
Definition design_manifest.hpp:46
std::string figma_component
Definition design_manifest.hpp:49
std::vector< std::string > reskin_tokens
Definition design_manifest.hpp:51
std::string header
Definition design_manifest.hpp:48
One token in the compiled allowlist: a name an importer/codegen may bind to, its kind,...
Definition design_manifest.hpp:36
std::string value
Definition design_manifest.hpp:39
std::string kind
Definition design_manifest.hpp:38
std::string name
Definition design_manifest.hpp:37
Definition theme.hpp:32