.normalize_domain(domain)
Reduce a URL or bare domain to its lowercase host.
Domain-to-theme extraction: fetch a site's design signals and compose a DESIGN.md + token set from them.
Generated from the gem's source documentation. Component classes are documented on their own gallery pages — this page carries the framework surface.
module · lib/poetry/extract/runner.rb
The orchestration: fetch -> compose -> derive -> write. Never touches the theme - the printed handoff goes through poetry:design:import, where the AA gate stays the single door.
| Constant | Description |
|---|---|
| OUT_ROOT | Default output root; run! writes into <OUT_ROOT>/<domain>/. |
Reduce a URL or bare domain to its lowercase host.
Extract a domain's design system: fetch the signals, compose DESIGN.md, derive the two token stylesheets, and write all three files under out_root. Prints the poetry:design:import handoff command - importing is deliberately left to the AA gate.
domain
(String)
— the domain to extract; a URL is normalized
down to its bare host
out_root
(String)
— directory the per-domain folder lands in
signals
(Signals, nil)
— pre-fetched signals (skips the fetch)
composer
(#design_md)
— the DESIGN.md composer
io
(IO)
— progress and handoff output
Returns (String) — the written directory path
Poetry::Extract::Runner.run!("stripe.com")
# => "tmp/poetry/design_extract/stripe.com"
The composed document must at least parse as DESIGN.md; a missing frontmatter is a warning, not a failure - prose-only documents still carry the body sections, and import will say so again.
module · lib/poetry/extract.rb
The poetry namespace.
module · lib/poetry/extract.rb
The optional design-extraction gem: domain in, theme out. Produces a DESIGN.md + deterministic token stylesheets and hands them to poetry-core's AA-gated design importer - never the theme directly.
| Constant | Description |
|---|---|
| VERSION | The gem version. |
module · lib/poetry/extract/compose.rb
The one model call: compose DESIGN.md from the fetched signals. The prompt spec is adapted from an MIT-licensed source (source and license in THIRD_PARTY_NOTICES.md). Direct Anthropic Messages API over Net::HTTP - no SDK dependency; the screenshot rides as a URL-source image block.
| Constant | Description |
|---|---|
| ANTHROPIC_URL | The Messages API endpoint the compose call POSTs to. |
| ANTHROPIC_VERSION | The pinned anthropic-version header value. |
| DEFAULT_MODEL | The model used when POETRY_EXTRACT_MODEL is unset. |
| SPEC_SUMMARY | The DESIGN.md format summary embedded in every prompt. |
| SYSTEM | The system prompt for the compose call. |
Compose the DESIGN.md document for a domain from its fetched signals in one model call; the screenshot, when present, is attached as an image block.
domain
(String)
— bare host the document is written for
signals
(Signals)
— the fetched evidence (nil members allowed)
http
(#call)
— the transport: request payload hash in, parsed
response hash out
Returns (String) — the composed DESIGN.md content
class < StandardError · lib/poetry/extract.rb
The gem's one error class: fetch, compose, and write failures all raise it (missing API keys included).
module · lib/poetry/extract/fetch.rb
The fetch layer. Primary path: the context.dev SDK (the gem's one service dependency - same four calls as upstream). Degraded path (no CONTEXT_DEV_API_KEY): a plain homepage fetch for the markdown signal, nil for the rest - extraction still works, on less evidence.
| Constant | Description |
|---|---|
| STYLEGUIDE_TIMEOUT_MS | Styleguide extraction is the slow call - allow it two minutes. |
Fetch the four design signals for a domain. Without a client (CONTEXT_DEV_API_KEY unset) it takes the degraded path: homepage markdown only, every other signal nil.
domain
(String)
— bare host, e.g. "stripe.com"
client
(Object, nil)
— the context.dev SDK client; nil selects
the degraded path
homepage_fetcher
(#call)
— degraded-path fetcher (domain in,
markdown string out)
class < Rails::Railtie · lib/poetry/extract/railtie.rb
Installs the poetry:design:extract task into any Rails host the moment the gem is bundled.
class < Struct · lib/poetry/extract/fetch.rb
The four design signals for a domain. Any member may be nil - the derivers and the prompt both accept the degraded shape.
Returns the value of attribute brand
Returns (Object) — the current value of brand
Sets the attribute brand
value
(Object)
— the value to set the attribute brand to.
Returns (Object) — the newly set value
Returns the value of attribute markdown
Returns (Object) — the current value of markdown
Sets the attribute markdown
value
(Object)
— the value to set the attribute markdown to.
Returns (Object) — the newly set value
Returns the value of attribute screenshot_url
Returns (Object) — the current value of screenshot_url
Sets the attribute screenshot_url
value
(Object)
— the value to set the attribute screenshot_url to.
Returns (Object) — the newly set value
Returns the value of attribute styleguide
Returns (Object) — the current value of styleguide
Sets the attribute styleguide
value
(Object)
— the value to set the attribute styleguide to.
Returns (Object) — the newly set value