# Framework-Aware Artifact Rendering Ideas Daybook currently supports a useful split between server-owned rendering and agent-owned rendering: - `markdown`: agent sends Markdown; Daybook renders and wraps it. - `html_fragment`: agent sends body-only HTML; Daybook owns the shell and theme CSS. - `html_full`: agent sends the complete HTML document and owns all presentation. - `deck`: agent sends slide sections; Daybook wraps them as a simple deck. The next design question is how to let agents use established CSS/component frameworks without making every artifact depend on arbitrary external assets or custom page shells. ## Core Principle Agents should publish content, not storage paths or app internals. For framework-aware artifacts, the preferred model is: ```text Agent sends framework-compatible body markup Daybook selects/owns the framework CSS and page shell Browser renders a consistent artifact preview ``` This preserves the Daybook principle while giving LLMs a known design vocabulary. ## Current Option: `html_full` Agents can already use any framework by posting `html_full` and including the framework assets themselves. Example with Bootstrap CDN: ```json { "persona": "athena", "kind": "html_full", "title": "Bootstrap Report", "content": "Bootstrap Report
Bootstrap artifact rendered by Daybook.
" } ``` Pros: - Works today. - Gives the agent total layout control. - Supports any CSS/JS framework. Cons: - CDN dependencies may fail offline. - External assets can change or disappear. - Agents must generate a correct full HTML document. - Visual consistency across artifacts is weaker. - Security/trust boundaries are looser if arbitrary scripts are included. ## Preferred Future Option: Framework Themes For `html_fragment` Add Daybook-owned themes that include vendored framework CSS. Example payload: ```json { "persona": "athena", "kind": "html_fragment", "theme": "bootstrap", "title": "Run Summary", "content": "
Run complete
" } ``` In this model: - Agent sends body-only framework-compatible markup. - Daybook wraps it in the HTML shell. - Daybook links local framework CSS from `static/vendor/...` or `static/themes/...`. - Daybook remains responsible for stable rendering. Pros: - Keeps artifacts self-hosted and predictable. - Lets agents use known class vocabularies. - Avoids requiring every agent to write `` boilerplate. - Preserves the current `html_fragment` contract. Cons: - Daybook must vendor and maintain selected frameworks. - Agents must know which theme/framework is selected. - Some frameworks expect JavaScript or build tooling. ## Candidate Frameworks | Framework | Best for | Fit for Daybook | |---|---|---| | Bootstrap | Reports, cards, grids, alerts, forms | Strong first candidate. Familiar to LLMs and humans. | | Pico CSS | Clean semantic documents | Excellent for low-class, readable reports. | | Bulma | CSS-only layouts/components | Good middle ground; no JS required. | | Tufte CSS | Research notes, essays, analytical reports | Good specialized report style. | | Water.css | Simple semantic HTML styling | Good for zero-effort readable HTML. | | MVP.css | Semantic HTML documents | Good for basic generated reports. | | Sakura.css | Minimal text-heavy documents | Good for simple readable pages. | | Tailwind CSS | Highly custom layouts | Powerful but less ideal without a build step. CDN possible for experiments. | | DaisyUI | Tailwind components | Useful but depends on Tailwind. Better later. | | Flowbite | Tailwind components | Useful but heavier and Tailwind-dependent. | | UIKit | Polished dashboards/docs | Possible but less common. | | Shoelace | Web components | Rich components, but requires JS custom elements. Better later. | | Reveal.js | Real slide decks | Strong future replacement/upgrade for current `deck`. | | Mermaid | Diagrams | Not CSS, but important for diagram artifacts. | | Prism.js / Highlight.js | Code artifacts | Needed for future code renderer. | | Tabulator / DataTables | CSV/table artifacts | Needed for future table renderer. | | JSON viewer libraries | JSON artifacts | Needed for future structured JSON renderer. | ## Recommended Initial Set Start small with CSS-only or mostly CSS-only frameworks: 1. `bootstrap` 2. `pico` 3. `bulma` 4. `tufte` Reasons: - No build step required. - Easy for LLMs to emit usable classes/semantic HTML. - Useful for the most common artifact types: reports, cards, summaries, dashboards, and notes. - Can be vendored locally and served through Django static files. Defer heavier or JS-dependent frameworks until there is a concrete artifact need. ## Theme Naming Idea Existing themes: - `report` - `tasks` - `deck` - `base` Potential additions: - `bootstrap` - `pico` - `bulma` - `tufte` - `water` Agents would specify the theme in the existing `theme` field for `html_fragment` and `markdown` where appropriate. ## Storage/Vendoring Idea Use local static assets rather than CDN links: ```text static/ vendor/ bootstrap/ bootstrap.min.css bulma/ bulma.min.css pico/ pico.min.css tufte/ tufte.min.css themes/ bootstrap.css bulma.css pico.css tufte.css ``` Theme files can either be the vendored framework directly or thin wrappers that import vendor CSS and add Daybook-specific print/preview fixes. Example: ```css @import url("/static/vendor/bootstrap/bootstrap.min.css"); body.artifact { background: #f8f9fa; } ``` ## CDN Policy CDN links are acceptable for quick experiments using `html_full`, but should not be the default for reliable self-hosted deployments. Recommended policy: - MVP experimentation: allow `html_full` with CDN links. - Durable/self-hosted rendering: prefer vendored local CSS themes. - Deployment docs should warn that CDN-dependent artifacts may not render offline. ## Security Notes Framework CSS is relatively safe. Framework JavaScript needs more care. Riskier artifact types: - `html_full` with arbitrary scripts. - JS component frameworks. - Web components loaded from CDNs. Current MVP assumes trusted local/self-hosted use. If Daybook later supports untrusted artifact authors or sharing, it should revisit sandboxing and CSP policies. ## Relationship To Future Renderers Framework themes are separate from future dedicated renderers. Future renderers likely need their own artifact kinds: - `json`: collapsible JSON viewer, raw source preserved. - `csv`: searchable/sortable table, raw CSV preserved. - `code`: syntax-highlighted code, raw source preserved. - `diagram`: Mermaid/Graphviz/PlantUML source rendered to SVG/HTML, raw source preserved. - `audio`: browser audio player. - `video`: browser video player. These should use established libraries rather than custom viewers: - JSON viewer library for JSON. - Tabulator or DataTables for CSV/table artifacts. - Prism.js or Highlight.js for code. - Mermaid for Mermaid diagrams. - Native `