ai: rich-output blocks via lazy-fetched typed-fence protocol

Assistant replies can now emit typed fenced blocks that render as
@crema/*-ui components inline at their position in the reply.

- message-body.tsx: segmented rendering — alternating prose chunks and
  block dispatch (was: all blocks appended at end). Renderers for kpi,
  table, chart-bar/-line/-donut/-spark, code, diff, flowchart, orgchart,
  steps, checklist, welcome, hint, plus the legacy card kinds.
- block-schemas.ts: single source of truth — BLOCK_INDEX (one-line
  purpose per kind, always in prompt) + SCHEMAS (full JSON shape +
  example, fetched on demand).
- admin-tools.ts: new get_block_schema(kind) tool the model calls once
  per kind per thread to fetch the exact schema. Keeps the always-on
  prompt small (~110 tokens vs ~400 inline).
- assistant.tsx: replaces the inline schema dump with the generated
  thin index.
- ai.tsx: empty-state preview button injects a synthetic assistant
  message exercising every block, for renderer/theme smoke-testing.
- console.css + ai.tsx: shrink ATLAS headline so it doesn't slip under
  the composer with the added preview button.
- tsconfig.json + app.css: wire lib-data-ui, lib-code-ui, lib-diagram-ui,
  lib-onboarding-ui as siblings.

Adding a new block kind = add the lib paths, add a renderer case, add
a schema entry. No prompt edits required.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
jules
2026-05-02 22:47:36 +10:00
parent cdb96499be
commit 9cbe921db7
8 changed files with 966 additions and 143 deletions

View File

@@ -54,6 +54,14 @@
"@crema/map-ui/*": ["../lib-map-ui/src/*"],
"@crema/status-ui": ["../lib-status-ui/src/index.tsx"],
"@crema/status-ui/*": ["../lib-status-ui/src/*"],
"@crema/data-ui": ["../lib-data-ui/src/index.tsx"],
"@crema/data-ui/*": ["../lib-data-ui/src/*"],
"@crema/code-ui": ["../lib-code-ui/src/index.tsx"],
"@crema/code-ui/*": ["../lib-code-ui/src/*"],
"@crema/diagram-ui": ["../lib-diagram-ui/src/index.tsx"],
"@crema/diagram-ui/*": ["../lib-diagram-ui/src/*"],
"@crema/onboarding-ui": ["../lib-onboarding-ui/src/index.tsx"],
"@crema/onboarding-ui/*": ["../lib-onboarding-ui/src/*"],
"// CREMA:PATHS": [""],
"react": ["./node_modules/@types/react"],
"react/*": ["./node_modules/@types/react/*"],