@agent-native/core 0.61.0 → 0.62.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/agent/engine/translate-anthropic.d.ts.map +1 -1
  2. package/dist/agent/engine/translate-anthropic.js +47 -1
  3. package/dist/agent/engine/translate-anthropic.js.map +1 -1
  4. package/dist/agent-native/index.d.ts +40 -0
  5. package/dist/agent-native/index.d.ts.map +1 -0
  6. package/dist/agent-native/index.js +100 -0
  7. package/dist/agent-native/index.js.map +1 -0
  8. package/dist/cli/templates-meta.d.ts.map +1 -1
  9. package/dist/cli/templates-meta.js +1 -0
  10. package/dist/cli/templates-meta.js.map +1 -1
  11. package/dist/client/analytics.d.ts.map +1 -1
  12. package/dist/client/analytics.js +30 -0
  13. package/dist/client/analytics.js.map +1 -1
  14. package/dist/client/blocks/SchemaBlockEditor.d.ts.map +1 -1
  15. package/dist/client/blocks/SchemaBlockEditor.js +2 -1
  16. package/dist/client/blocks/SchemaBlockEditor.js.map +1 -1
  17. package/dist/client/blocks/code-block-direction.d.ts +21 -0
  18. package/dist/client/blocks/code-block-direction.d.ts.map +1 -0
  19. package/dist/client/blocks/code-block-direction.js +20 -0
  20. package/dist/client/blocks/code-block-direction.js.map +1 -0
  21. package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
  22. package/dist/client/blocks/library/AnnotatedCodeBlock.js +2 -1
  23. package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
  24. package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -1
  25. package/dist/client/blocks/library/ApiEndpointBlock.js +2 -1
  26. package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -1
  27. package/dist/client/blocks/library/DataModelBlock.d.ts.map +1 -1
  28. package/dist/client/blocks/library/DataModelBlock.js +2 -1
  29. package/dist/client/blocks/library/DataModelBlock.js.map +1 -1
  30. package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
  31. package/dist/client/blocks/library/DiffBlock.js +2 -1
  32. package/dist/client/blocks/library/DiffBlock.js.map +1 -1
  33. package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -1
  34. package/dist/client/blocks/library/FileTreeBlock.js +2 -1
  35. package/dist/client/blocks/library/FileTreeBlock.js.map +1 -1
  36. package/dist/client/blocks/library/HighlightedCode.d.ts.map +1 -1
  37. package/dist/client/blocks/library/HighlightedCode.js +2 -1
  38. package/dist/client/blocks/library/HighlightedCode.js.map +1 -1
  39. package/dist/client/blocks/library/JsonExplorerBlock.d.ts.map +1 -1
  40. package/dist/client/blocks/library/JsonExplorerBlock.js +2 -1
  41. package/dist/client/blocks/library/JsonExplorerBlock.js.map +1 -1
  42. package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -1
  43. package/dist/client/blocks/library/MermaidBlock.js +2 -1
  44. package/dist/client/blocks/library/MermaidBlock.js.map +1 -1
  45. package/dist/client/blocks/library/OpenApiSpecBlock.d.ts.map +1 -1
  46. package/dist/client/blocks/library/OpenApiSpecBlock.js +2 -1
  47. package/dist/client/blocks/library/OpenApiSpecBlock.js.map +1 -1
  48. package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
  49. package/dist/client/blocks/library/annotation-rail.js +2 -1
  50. package/dist/client/blocks/library/annotation-rail.js.map +1 -1
  51. package/dist/client/blocks/library/code-tabs.d.ts.map +1 -1
  52. package/dist/client/blocks/library/code-tabs.js +2 -1
  53. package/dist/client/blocks/library/code-tabs.js.map +1 -1
  54. package/dist/client/blocks/library/code.d.ts.map +1 -1
  55. package/dist/client/blocks/library/code.js +3 -2
  56. package/dist/client/blocks/library/code.js.map +1 -1
  57. package/dist/client/blocks/library/diagram.d.ts.map +1 -1
  58. package/dist/client/blocks/library/diagram.js +2 -1
  59. package/dist/client/blocks/library/diagram.js.map +1 -1
  60. package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
  61. package/dist/client/blocks/library/wireframe.js +2 -1
  62. package/dist/client/blocks/library/wireframe.js.map +1 -1
  63. package/dist/db/client.d.ts +3 -3
  64. package/dist/db/client.d.ts.map +1 -1
  65. package/dist/db/client.js +8 -4
  66. package/dist/db/client.js.map +1 -1
  67. package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +26 -0
  68. package/docs/content/a2a-protocol.md +28 -0
  69. package/docs/content/agent-surfaces.md +12 -4
  70. package/docs/content/getting-started.md +136 -37
  71. package/docs/content/pure-agent-apps.md +25 -9
  72. package/docs/content/template-dispatch.md +4 -0
  73. package/package.json +5 -1
  74. package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +26 -0
@@ -1 +1 @@
1
- {"version":3,"file":"DataModelBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/DataModelBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAUpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;GAIG;AAEH,mFAAmF;AAEnF;;;;;;GAMG;AACH,MAAM,YAAY,GAAoC;IACpD,KAAK,EACH,8EAA8E;IAChF,QAAQ,EAAE,kEAAkE;IAC5E,OAAO,EAAE,8DAA8D;IACvE,OAAO,EACL,0EAA0E;CAC7E,CAAC;AAEF,uEAAuE;AACvE,MAAM,YAAY,GAAoC;IACpD,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,4EAA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IAAC,SAAS,EAAC,UAAU,GAAG,iBAE1B,CACV,IACG,KApLD,MAAM,CAAC,EAAE,CAqLV,CACP,CAAC,EAED,QAAQ,IAAI,CACX,kBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,mKAAmK,EAC7K,OAAO,EAAE,SAAS,aAElB,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,kBAExB,CACV,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n IconArrowNarrowRight,\n IconChevronRight,\n IconDatabase,\n IconKey,\n IconLink,\n IconPlus,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n DataModelChange,\n DataModelData,\n DataModelEntity,\n DataModelField,\n DataModelRelation,\n DataModelRelationKind,\n} from \"./data-model.config.js\";\nimport { DATA_MODEL_CHANGES } from \"./data-model.config.js\";\nimport { DevInput, DevSelect } from \"./dev-doc-ui.js\";\n\n/**\n * Read + Edit renderers for a `data-model` block — a dbdiagram / Prisma-style\n * entity-relationship diagram. Lives in core so any app can register the dev-doc\n * block (no shadcn import).\n */\n\n/* ── Theme-aware change tokens (shared vocabulary with `file-tree`) ─────────── */\n\n/**\n * Change-chip palette — the SAME tinted-bg + saturated-text scheme the\n * `file-tree` block uses, in BOTH the `.dark` plan theme and light mode (never a\n * dark-only palette). Keeps data-model diff chips visually consistent with the\n * file-tree change badges so a reviewer reads one vocabulary across dev-doc\n * blocks.\n */\nconst CHANGE_BADGE: Record<DataModelChange, string> = {\n added:\n \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n modified: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n removed: \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\",\n renamed:\n \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n};\n\n/** Human-readable chip label, matching the file-tree change labels. */\nconst CHANGE_LABEL: Record<DataModelChange, string> = {\n added: \"Added\",\n modified: \"Modified\",\n removed: \"Removed\",\n renamed: \"Renamed\",\n};\n\n/** Accent ink for a changed field/entity name, echoing its change color. */\nconst CHANGE_NAME_INK: Record<DataModelChange, string> = {\n added: \"text-emerald-700 dark:text-emerald-300\",\n modified: \"text-blue-700 dark:text-blue-300\",\n removed: \"text-red-600 line-through dark:text-red-300\",\n renamed: \"text-violet-700 dark:text-violet-300\",\n};\n\n/** Subtle left accent rule on a changed field row (added = green, removed = red). */\nconst CHANGE_ROW_ACCENT: Record<DataModelChange, string> = {\n added: \"border-l-2 border-l-emerald-400 dark:border-l-emerald-500/60\",\n modified: \"border-l-2 border-l-blue-400 dark:border-l-blue-500/60\",\n removed: \"border-l-2 border-l-red-400 dark:border-l-red-500/60\",\n renamed: \"border-l-2 border-l-violet-400 dark:border-l-violet-500/60\",\n};\n\n/** A small theme-aware change chip (\"Added\" / \"Modified\" / …). */\nfunction ChangeChip({\n change,\n className,\n}: {\n change: DataModelChange;\n className?: string;\n}) {\n return (\n <span\n title={CHANGE_LABEL[change]}\n aria-label={CHANGE_LABEL[change]}\n className={cn(\n \"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide leading-none\",\n CHANGE_BADGE[change],\n className,\n )}\n >\n {CHANGE_LABEL[change]}\n </span>\n );\n}\n\n/* ── Resolution helpers (shared by Read + relation inference) ──────────────── */\n\n/** Split a `fk` string like `\"User.id\"` into `{ entity: \"User\", field: \"id\" }`. */\nfunction parseFk(fk: string): { entity: string; field?: string } {\n const trimmed = fk.trim();\n const dot = trimmed.indexOf(\".\");\n if (dot === -1) return { entity: trimmed };\n return {\n entity: trimmed.slice(0, dot).trim(),\n field: trimmed.slice(dot + 1).trim() || undefined,\n };\n}\n\n/**\n * Resolve an entity reference (used by `fk` targets and `relation.from`/`to`)\n * against the entity list by `id` first, then by case-insensitive `name`. Returns\n * the matched entity or `undefined`.\n */\nfunction resolveEntity(\n entities: DataModelEntity[],\n ref: string,\n): DataModelEntity | undefined {\n const needle = ref.trim();\n return (\n entities.find((entity) => entity.id === needle) ??\n entities.find(\n (entity) => entity.name.toLowerCase() === needle.toLowerCase(),\n )\n );\n}\n\n/** A short, readable label for an entity reference (its name, or the raw ref). */\nfunction entityLabel(entities: DataModelEntity[], ref: string): string {\n return resolveEntity(entities, ref)?.name ?? ref;\n}\n\n/** The cardinality glyph shown in the relations list (1:1 / 1:n / n:n). */\nfunction relationGlyph(kind?: DataModelRelationKind): string {\n if (kind === \"1-1\") return \"1:1\";\n if (kind === \"n-n\") return \"n:n\";\n return \"1:n\";\n}\n\n/**\n * Relations to render: explicit `relations` when present, otherwise inferred —\n * every `fk` field becomes a `1-n` relation from the referenced (parent) entity\n * to the entity holding the foreign key, so the connectors list is never empty\n * when the schema clearly implies them.\n */\nfunction effectiveRelations(data: DataModelData): DataModelRelation[] {\n if (data.relations && data.relations.length > 0) return data.relations;\n const inferred: DataModelRelation[] = [];\n for (const entity of data.entities) {\n for (const field of entity.fields) {\n if (!field.fk) continue;\n const target = resolveEntity(data.entities, parseFk(field.fk).entity);\n if (!target) continue;\n inferred.push({\n from: target.id,\n to: entity.id,\n kind: \"1-n\",\n label: field.name,\n });\n }\n }\n return inferred;\n}\n\n/* ── Read (interactive ERD) ────────────────────────────────────────────────── */\n\n/**\n * Read-only renderer for a `data-model` block — a dbdiagram / Prisma-style\n * entity-relationship diagram. Each entity is a collapsible card: the header\n * shows the entity name + field count, and expanding it reveals a compact field\n * table (Field · Type · flags) with PK / FK / nullable indicators.\n *\n * INTERACTIVITY (the reason this is a custom block, not a plain table): hovering\n * or clicking a foreign-key field highlights the referenced entity card — it\n * scrolls into view, expands, and gets a temporary accent ring — so a reader can\n * trace a relationship across the whole model. Explicit `relations` (or relations\n * inferred from `fk` fields) render as a labeled connector list below the cards.\n *\n * Every color is theme-aware via Tailwind `dark:` variants or plan CSS vars, so\n * the diagram reads correctly in both the `.dark` plan theme and light mode.\n */\nexport function DataModelRead({\n data,\n blockId,\n title,\n summary,\n}: BlockReadProps<DataModelData>) {\n const entities = data.entities ?? [];\n const relations = useMemo(() => effectiveRelations(data), [data]);\n\n // Per-entity collapse state. Default: the first entity expanded (or all of them\n // when the model is small) so the block is useful at a glance without a click.\n const [expanded, setExpanded] = useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n const expandAll = entities.length <= 2;\n entities.forEach((entity, index) => {\n initial[entity.id] = expandAll || index === 0;\n });\n return initial;\n });\n\n // Which entity is being hovered/clicked-to via an FK — drives the accent ring.\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const cardRefs = useRef<Record<string, HTMLDivElement | null>>({});\n\n const toggle = useCallback((id: string) => {\n setExpanded((current) => ({ ...current, [id]: !current[id] }));\n }, []);\n\n // Highlight + reveal a referenced entity: expand it, ring it, and scroll it\n // into view. Used on FK hover (transient) and click (scroll).\n const focusEntity = useCallback(\n (targetId: string | undefined, scroll: boolean) => {\n if (!targetId) {\n setHighlighted(null);\n return;\n }\n setHighlighted(targetId);\n if (scroll) {\n setExpanded((current) => ({ ...current, [targetId]: true }));\n cardRefs.current[targetId]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n }\n },\n [],\n );\n\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n\n <div className=\"flex flex-col gap-3\">\n {entities.map((entity) => {\n const isOpen = expanded[entity.id] ?? false;\n const isHighlighted = highlighted === entity.id;\n return (\n <div\n key={entity.id}\n ref={(node) => {\n cardRefs.current[entity.id] = node;\n }}\n data-entity-id={entity.id}\n className={cn(\n \"overflow-hidden rounded-xl border bg-plan-block transition-shadow\",\n isHighlighted\n ? \"border-blue-400 ring-2 ring-blue-400/60 dark:border-blue-400 dark:ring-blue-400/50\"\n : \"border-plan-line\",\n )}\n >\n {/* Entity header — always visible, toggles the field table. */}\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={isOpen}\n onClick={() => toggle(entity.id)}\n className=\"flex w-full items-center gap-2 px-4 py-2.5 text-left transition-colors hover:bg-accent/40\"\n >\n <IconChevronRight\n className={cn(\n \"size-4 shrink-0 text-plan-muted transition-transform\",\n isOpen && \"rotate-90\",\n )}\n />\n <IconDatabase className=\"size-4 shrink-0 text-blue-600 dark:text-blue-300\" />\n <span\n className={cn(\n \"min-w-0 truncate font-mono text-sm font-semibold\",\n entity.change\n ? CHANGE_NAME_INK[entity.change]\n : \"text-plan-text\",\n )}\n >\n {entity.name}\n </span>\n {entity.change && <ChangeChip change={entity.change} />}\n <span className=\"ml-auto shrink-0 rounded-full bg-accent/50 px-2 py-0.5 text-[11px] font-medium text-plan-muted\">\n {entity.fields.length}{\" \"}\n {entity.fields.length === 1 ? \"field\" : \"fields\"}\n </span>\n </button>\n\n {/* Expanded field table. */}\n {isOpen && (\n <div className=\"border-t border-plan-line\">\n {entity.note && (\n <p className=\"px-4 pt-2 text-xs italic text-plan-muted\">\n {entity.note}\n </p>\n )}\n <table className=\"w-full border-collapse text-sm\">\n <tbody>\n {entity.fields.map((field, index) => {\n const fkTarget = field.fk\n ? resolveEntity(entities, parseFk(field.fk).entity)\n : undefined;\n return (\n <tr\n key={`${field.name}-${index}`}\n className={cn(\n \"border-t border-plan-line/70 align-top first:border-t-0\",\n field.fk && \"cursor-pointer hover:bg-blue-500/5\",\n field.change && CHANGE_ROW_ACCENT[field.change],\n )}\n // FK interactivity: hovering rings the referenced\n // entity card; clicking also scrolls it into view.\n onMouseEnter={\n fkTarget\n ? () => focusEntity(fkTarget.id, false)\n : undefined\n }\n onMouseLeave={\n fkTarget\n ? () => focusEntity(undefined, false)\n : undefined\n }\n onClick={\n fkTarget\n ? () => focusEntity(fkTarget.id, true)\n : undefined\n }\n >\n <td className=\"w-px whitespace-nowrap py-1.5 pl-4 pr-2\">\n <div className=\"flex items-center gap-1.5\">\n {field.pk && (\n <IconKey\n className=\"size-3.5 shrink-0 text-amber-500 dark:text-amber-300\"\n aria-label=\"Primary key\"\n />\n )}\n {field.fk && (\n <IconLink\n className=\"size-3.5 shrink-0 text-blue-500 dark:text-blue-300\"\n aria-label=\"Foreign key\"\n />\n )}\n <span\n className={cn(\n \"font-mono text-xs\",\n field.pk && \"font-semibold\",\n field.change\n ? CHANGE_NAME_INK[field.change]\n : \"text-plan-text\",\n )}\n >\n {field.name}\n </span>\n </div>\n </td>\n <td className=\"py-1.5 pr-2\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {/* Prior value (`was`) for a modified field —\n struck through ahead of the current type. */}\n {field.change === \"modified\" && field.was && (\n <>\n <span className=\"inline-block rounded bg-accent/30 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted line-through\">\n {field.was}\n </span>\n <IconArrowNarrowRight\n className=\"size-3 shrink-0 text-plan-muted\"\n aria-hidden\n />\n </>\n )}\n {field.type && (\n <span\n className={cn(\n \"inline-block rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px]\",\n field.change === \"removed\"\n ? \"text-plan-muted line-through\"\n : \"text-plan-muted\",\n )}\n >\n {field.type}\n </span>\n )}\n </div>\n </td>\n <td className=\"py-1.5 pr-4 text-right\">\n <div className=\"flex flex-wrap items-center justify-end gap-1\">\n {field.change && (\n <ChangeChip change={field.change} />\n )}\n {field.pk && (\n <span className=\"rounded px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-600 dark:text-amber-300 bg-amber-100 dark:bg-amber-500/15\">\n PK\n </span>\n )}\n {field.fk && (\n <span className=\"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-semibold text-blue-700 dark:text-blue-300 bg-blue-100 dark:bg-blue-500/15\">\n FK\n <span className=\"font-mono font-normal opacity-90\">\n {fkTarget\n ? `${fkTarget.name}${\n parseFk(field.fk).field\n ? `.${parseFk(field.fk).field}`\n : \"\"\n }`\n : field.fk}\n </span>\n </span>\n )}\n {field.nullable && (\n <span className=\"rounded px-1.5 py-0.5 text-[10px] font-medium text-plan-muted bg-accent/50\">\n nullable\n </span>\n )}\n {field.default != null &&\n field.default !== \"\" && (\n <span className=\"rounded px-1.5 py-0.5 font-mono text-[10px] text-plan-muted bg-accent/40\">\n = {field.default}\n </span>\n )}\n </div>\n {field.note && (\n <div className=\"mt-0.5 text-[11px] italic text-plan-muted\">\n {field.note}\n </div>\n )}\n </td>\n </tr>\n );\n })}\n {entity.fields.length === 0 && (\n <tr>\n <td className=\"px-4 py-2 text-xs text-plan-muted\">\n No fields yet.\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n )}\n </div>\n );\n })}\n </div>\n\n {/* Relations / connectors list. */}\n {relations.length > 0 && (\n <div className=\"mt-4\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Relations\n </div>\n <div className=\"mt-2 flex flex-col gap-1.5\">\n {relations.map((relation, index) => {\n const fromEntity = resolveEntity(entities, relation.from);\n const toEntity = resolveEntity(entities, relation.to);\n return (\n <button\n key={`${relation.from}-${relation.to}-${index}`}\n type=\"button\"\n data-plan-interactive\n className=\"group flex w-fit items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors hover:bg-accent/40\"\n onMouseEnter={() => focusEntity(toEntity?.id, false)}\n onMouseLeave={() => focusEntity(undefined, false)}\n onClick={() => focusEntity(toEntity?.id, true)}\n >\n <span className=\"font-mono text-xs font-semibold text-plan-text\">\n {entityLabel(entities, relation.from)}\n </span>\n <span className=\"flex items-center gap-1 rounded bg-blue-100 px-1.5 py-0.5 font-mono text-[10px] font-bold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\">\n {relationGlyph(relation.kind)}\n <IconArrowNarrowRight className=\"size-3\" />\n </span>\n <span className=\"font-mono text-xs font-semibold text-plan-text\">\n {entityLabel(entities, relation.to)}\n </span>\n {relation.label && (\n <span className=\"text-xs text-plan-muted\">\n · {relation.label}\n </span>\n )}\n {!fromEntity || !toEntity ? (\n <span className=\"text-[10px] text-amber-600 dark:text-amber-300\">\n (unresolved)\n </span>\n ) : null}\n </button>\n );\n })}\n </div>\n </div>\n )}\n\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/* ── Edit (panel form) ─────────────────────────────────────────────────────── */\n\nlet entitySeq = 0;\n/** Stable-enough new entity id for a freshly-added entity in the editor. */\nfunction newEntityId(): string {\n entitySeq += 1;\n return `e_${Date.now().toString(36)}_${entitySeq}`;\n}\n\n/**\n * Panel editor for a `data-model` block. A structured form: a list of entities\n * (add/remove), each with a name Input, an optional note, and repeatable field\n * rows (add/remove) carrying name / type / PK checkbox / FK input / nullable\n * checkbox. Relations are derived from `fk` in v1, so the form focuses on the\n * entities + fields. Renders BARE content (no `<section>`); the registry's panel\n * surface supplies the popover chrome.\n */\nexport function DataModelEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<DataModelData>) {\n const entities = data.entities ?? [];\n\n const patchEntities = (next: DataModelEntity[]) =>\n onChange({ ...data, entities: next });\n\n const updateEntity = (index: number, next: Partial<DataModelEntity>) =>\n patchEntities(\n entities.map((entity, i) =>\n i === index ? { ...entity, ...next } : entity,\n ),\n );\n\n const removeEntity = (index: number) =>\n patchEntities(entities.filter((_, i) => i !== index));\n\n const addEntity = () =>\n patchEntities([\n ...entities,\n {\n id: newEntityId(),\n name: \"NewEntity\",\n fields: [{ name: \"id\", pk: true }],\n },\n ]);\n\n const updateField = (\n entityIndex: number,\n fieldIndex: number,\n next: Partial<DataModelField>,\n ) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: entity.fields.map((field, i) =>\n i === fieldIndex ? { ...field, ...next } : field,\n ),\n });\n };\n\n const removeField = (entityIndex: number, fieldIndex: number) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: entity.fields.filter((_, i) => i !== fieldIndex),\n });\n };\n\n const addField = (entityIndex: number) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: [...entity.fields, { name: \"field\" }],\n });\n };\n\n return (\n <div className=\"flex flex-col gap-4\" data-plan-interactive>\n {entities.map((entity, entityIndex) => (\n <div\n key={entity.id}\n className=\"flex flex-col gap-2 rounded-lg border border-input p-3\"\n >\n <div className=\"flex items-center gap-2\">\n <IconDatabase className=\"size-4 shrink-0 text-muted-foreground\" />\n <DevInput\n className=\"h-8 font-mono text-sm font-semibold\"\n value={entity.name}\n disabled={!editable}\n placeholder=\"EntityName\"\n onChange={(event) =>\n updateEntity(entityIndex, { name: event.target.value })\n }\n />\n <DevSelect\n className=\"h-8 w-[120px] shrink-0\"\n value={entity.change ?? \"none\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateEntity(entityIndex, {\n change:\n value === \"none\" ? undefined : (value as DataModelChange),\n })\n }\n options={[\n { value: \"none\", label: \"No change\" },\n ...DATA_MODEL_CHANGES.map((change) => ({\n value: change,\n label: CHANGE_LABEL[change],\n })),\n ]}\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove entity\"\n className=\"flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeEntity(entityIndex)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n\n {/* Field rows. */}\n <div className=\"flex flex-col gap-1.5\">\n {entity.fields.map((field, fieldIndex) => (\n <div\n key={fieldIndex}\n className=\"flex flex-col gap-1.5 rounded-md border border-input/60 bg-accent/20 p-2\"\n >\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-1.5\">\n <DevInput\n className=\"h-7 font-mono text-xs\"\n value={field.name}\n disabled={!editable}\n placeholder=\"name\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n name: event.target.value,\n })\n }\n />\n <DevInput\n className=\"h-7 font-mono text-xs\"\n value={field.type ?? \"\"}\n disabled={!editable}\n placeholder=\"type (e.g. uuid)\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n type: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove field\"\n className=\"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeField(entityIndex, fieldIndex)}\n >\n <IconTrash className=\"size-3.5\" />\n </button>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-3\">\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(field.pk)}\n disabled={!editable}\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n pk: event.target.checked || undefined,\n })\n }\n />\n PK\n </label>\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(field.nullable)}\n disabled={!editable}\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n nullable: event.target.checked || undefined,\n })\n }\n />\n Nullable\n </label>\n <DevInput\n className=\"h-7 flex-1 font-mono text-xs\"\n value={field.fk ?? \"\"}\n disabled={!editable}\n placeholder=\"FK → Entity.field\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n fk: event.target.value || undefined,\n })\n }\n />\n </div>\n {/* Diff row: change kind + the prior value (`was`) when the\n field is \"modified\", so before/after renders in Read. */}\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <DevSelect\n className=\"h-7 w-[120px] shrink-0\"\n value={field.change ?? \"none\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateField(entityIndex, fieldIndex, {\n change:\n value === \"none\"\n ? undefined\n : (value as DataModelChange),\n // Drop a stale `was` when leaving the modified state.\n ...(value === \"modified\" ? {} : { was: undefined }),\n })\n }\n options={[\n { value: \"none\", label: \"No change\" },\n ...DATA_MODEL_CHANGES.map((change) => ({\n value: change,\n label: CHANGE_LABEL[change],\n })),\n ]}\n />\n {field.change === \"modified\" && (\n <DevInput\n className=\"h-7 flex-1 font-mono text-xs\"\n value={field.was ?? \"\"}\n disabled={!editable}\n placeholder=\"was (prior value, e.g. old type)\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n was: event.target.value || undefined,\n })\n }\n />\n )}\n </div>\n </div>\n ))}\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex w-fit items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => addField(entityIndex)}\n >\n <IconPlus className=\"size-3.5\" />\n Add field\n </button>\n )}\n </div>\n </div>\n ))}\n\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center justify-center gap-1.5 rounded-md border border-dashed border-input py-2 text-sm text-muted-foreground hover:bg-accent/40 hover:text-foreground\"\n onClick={addEntity}\n >\n <IconPlus className=\"size-4\" />\n Add entity\n </button>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"DataModelBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/DataModelBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAU/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;GAIG;AAEH,mFAAmF;AAEnF;;;;;;GAMG;AACH,MAAM,YAAY,GA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E,UAAU,EAAE;oDACnC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS;iDACrC,CAAC,GAEJ,CACH,IACG,KArHD,UAAU,CAsHX,CACP,CAAC,EACD,QAAQ,IAAI,CACX,kBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,2HAA2H,EACrI,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,aAEpC,KAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,GAAG,iBAE1B,CACV,IACG,KApLD,MAAM,CAAC,EAAE,CAqLV,CACP,CAAC,EAED,QAAQ,IAAI,CACX,kBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,mKAAmK,EAC7K,OAAO,EAAE,SAAS,aAElB,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,kBAExB,CACV,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef, useState } from \"react\";\nimport {\n IconArrowNarrowRight,\n IconChevronRight,\n IconDatabase,\n IconKey,\n IconLink,\n IconPlus,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n DataModelChange,\n DataModelData,\n DataModelEntity,\n DataModelField,\n DataModelRelation,\n DataModelRelationKind,\n} from \"./data-model.config.js\";\nimport { DATA_MODEL_CHANGES } from \"./data-model.config.js\";\nimport { DevInput, DevSelect } from \"./dev-doc-ui.js\";\n\n/**\n * Read + Edit renderers for a `data-model` block — a dbdiagram / Prisma-style\n * entity-relationship diagram. Lives in core so any app can register the dev-doc\n * block (no shadcn import).\n */\n\n/* ── Theme-aware change tokens (shared vocabulary with `file-tree`) ─────────── */\n\n/**\n * Change-chip palette — the SAME tinted-bg + saturated-text scheme the\n * `file-tree` block uses, in BOTH the `.dark` plan theme and light mode (never a\n * dark-only palette). Keeps data-model diff chips visually consistent with the\n * file-tree change badges so a reviewer reads one vocabulary across dev-doc\n * blocks.\n */\nconst CHANGE_BADGE: Record<DataModelChange, string> = {\n added:\n \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n modified: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n removed: \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\",\n renamed:\n \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n};\n\n/** Human-readable chip label, matching the file-tree change labels. */\nconst CHANGE_LABEL: Record<DataModelChange, string> = {\n added: \"Added\",\n modified: \"Modified\",\n removed: \"Removed\",\n renamed: \"Renamed\",\n};\n\n/** Accent ink for a changed field/entity name, echoing its change color. */\nconst CHANGE_NAME_INK: Record<DataModelChange, string> = {\n added: \"text-emerald-700 dark:text-emerald-300\",\n modified: \"text-blue-700 dark:text-blue-300\",\n removed: \"text-red-600 line-through dark:text-red-300\",\n renamed: \"text-violet-700 dark:text-violet-300\",\n};\n\n/** Subtle left accent rule on a changed field row (added = green, removed = red). */\nconst CHANGE_ROW_ACCENT: Record<DataModelChange, string> = {\n added: \"border-l-2 border-l-emerald-400 dark:border-l-emerald-500/60\",\n modified: \"border-l-2 border-l-blue-400 dark:border-l-blue-500/60\",\n removed: \"border-l-2 border-l-red-400 dark:border-l-red-500/60\",\n renamed: \"border-l-2 border-l-violet-400 dark:border-l-violet-500/60\",\n};\n\n/** A small theme-aware change chip (\"Added\" / \"Modified\" / …). */\nfunction ChangeChip({\n change,\n className,\n}: {\n change: DataModelChange;\n className?: string;\n}) {\n return (\n <span\n title={CHANGE_LABEL[change]}\n aria-label={CHANGE_LABEL[change]}\n className={cn(\n \"rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide leading-none\",\n CHANGE_BADGE[change],\n className,\n )}\n >\n {CHANGE_LABEL[change]}\n </span>\n );\n}\n\n/* ── Resolution helpers (shared by Read + relation inference) ──────────────── */\n\n/** Split a `fk` string like `\"User.id\"` into `{ entity: \"User\", field: \"id\" }`. */\nfunction parseFk(fk: string): { entity: string; field?: string } {\n const trimmed = fk.trim();\n const dot = trimmed.indexOf(\".\");\n if (dot === -1) return { entity: trimmed };\n return {\n entity: trimmed.slice(0, dot).trim(),\n field: trimmed.slice(dot + 1).trim() || undefined,\n };\n}\n\n/**\n * Resolve an entity reference (used by `fk` targets and `relation.from`/`to`)\n * against the entity list by `id` first, then by case-insensitive `name`. Returns\n * the matched entity or `undefined`.\n */\nfunction resolveEntity(\n entities: DataModelEntity[],\n ref: string,\n): DataModelEntity | undefined {\n const needle = ref.trim();\n return (\n entities.find((entity) => entity.id === needle) ??\n entities.find(\n (entity) => entity.name.toLowerCase() === needle.toLowerCase(),\n )\n );\n}\n\n/** A short, readable label for an entity reference (its name, or the raw ref). */\nfunction entityLabel(entities: DataModelEntity[], ref: string): string {\n return resolveEntity(entities, ref)?.name ?? ref;\n}\n\n/** The cardinality glyph shown in the relations list (1:1 / 1:n / n:n). */\nfunction relationGlyph(kind?: DataModelRelationKind): string {\n if (kind === \"1-1\") return \"1:1\";\n if (kind === \"n-n\") return \"n:n\";\n return \"1:n\";\n}\n\n/**\n * Relations to render: explicit `relations` when present, otherwise inferred —\n * every `fk` field becomes a `1-n` relation from the referenced (parent) entity\n * to the entity holding the foreign key, so the connectors list is never empty\n * when the schema clearly implies them.\n */\nfunction effectiveRelations(data: DataModelData): DataModelRelation[] {\n if (data.relations && data.relations.length > 0) return data.relations;\n const inferred: DataModelRelation[] = [];\n for (const entity of data.entities) {\n for (const field of entity.fields) {\n if (!field.fk) continue;\n const target = resolveEntity(data.entities, parseFk(field.fk).entity);\n if (!target) continue;\n inferred.push({\n from: target.id,\n to: entity.id,\n kind: \"1-n\",\n label: field.name,\n });\n }\n }\n return inferred;\n}\n\n/* ── Read (interactive ERD) ────────────────────────────────────────────────── */\n\n/**\n * Read-only renderer for a `data-model` block — a dbdiagram / Prisma-style\n * entity-relationship diagram. Each entity is a collapsible card: the header\n * shows the entity name + field count, and expanding it reveals a compact field\n * table (Field · Type · flags) with PK / FK / nullable indicators.\n *\n * INTERACTIVITY (the reason this is a custom block, not a plain table): hovering\n * or clicking a foreign-key field highlights the referenced entity card — it\n * scrolls into view, expands, and gets a temporary accent ring — so a reader can\n * trace a relationship across the whole model. Explicit `relations` (or relations\n * inferred from `fk` fields) render as a labeled connector list below the cards.\n *\n * Every color is theme-aware via Tailwind `dark:` variants or plan CSS vars, so\n * the diagram reads correctly in both the `.dark` plan theme and light mode.\n */\nexport function DataModelRead({\n data,\n blockId,\n title,\n summary,\n}: BlockReadProps<DataModelData>) {\n const entities = data.entities ?? [];\n const relations = useMemo(() => effectiveRelations(data), [data]);\n\n // Per-entity collapse state. Default: the first entity expanded (or all of them\n // when the model is small) so the block is useful at a glance without a click.\n const [expanded, setExpanded] = useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n const expandAll = entities.length <= 2;\n entities.forEach((entity, index) => {\n initial[entity.id] = expandAll || index === 0;\n });\n return initial;\n });\n\n // Which entity is being hovered/clicked-to via an FK — drives the accent ring.\n const [highlighted, setHighlighted] = useState<string | null>(null);\n const cardRefs = useRef<Record<string, HTMLDivElement | null>>({});\n\n const toggle = useCallback((id: string) => {\n setExpanded((current) => ({ ...current, [id]: !current[id] }));\n }, []);\n\n // Highlight + reveal a referenced entity: expand it, ring it, and scroll it\n // into view. Used on FK hover (transient) and click (scroll).\n const focusEntity = useCallback(\n (targetId: string | undefined, scroll: boolean) => {\n if (!targetId) {\n setHighlighted(null);\n return;\n }\n setHighlighted(targetId);\n if (scroll) {\n setExpanded((current) => ({ ...current, [targetId]: true }));\n cardRefs.current[targetId]?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n });\n }\n },\n [],\n );\n\n return (\n <section\n {...ltrCodeBlockProps}\n className=\"plan-block\"\n data-block-id={blockId}\n >\n {title && <div className=\"plan-block-label\">{title}</div>}\n\n <div className=\"flex flex-col gap-3\">\n {entities.map((entity) => {\n const isOpen = expanded[entity.id] ?? false;\n const isHighlighted = highlighted === entity.id;\n return (\n <div\n key={entity.id}\n ref={(node) => {\n cardRefs.current[entity.id] = node;\n }}\n data-entity-id={entity.id}\n className={cn(\n \"overflow-hidden rounded-xl border bg-plan-block transition-shadow\",\n isHighlighted\n ? \"border-blue-400 ring-2 ring-blue-400/60 dark:border-blue-400 dark:ring-blue-400/50\"\n : \"border-plan-line\",\n )}\n >\n {/* Entity header — always visible, toggles the field table. */}\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={isOpen}\n onClick={() => toggle(entity.id)}\n className=\"flex w-full items-center gap-2 px-4 py-2.5 text-left transition-colors hover:bg-accent/40\"\n >\n <IconChevronRight\n className={cn(\n \"size-4 shrink-0 text-plan-muted transition-transform\",\n isOpen && \"rotate-90\",\n )}\n />\n <IconDatabase className=\"size-4 shrink-0 text-blue-600 dark:text-blue-300\" />\n <span\n className={cn(\n \"min-w-0 truncate font-mono text-sm font-semibold\",\n entity.change\n ? CHANGE_NAME_INK[entity.change]\n : \"text-plan-text\",\n )}\n >\n {entity.name}\n </span>\n {entity.change && <ChangeChip change={entity.change} />}\n <span className=\"ml-auto shrink-0 rounded-full bg-accent/50 px-2 py-0.5 text-[11px] font-medium text-plan-muted\">\n {entity.fields.length}{\" \"}\n {entity.fields.length === 1 ? \"field\" : \"fields\"}\n </span>\n </button>\n\n {/* Expanded field table. */}\n {isOpen && (\n <div className=\"border-t border-plan-line\">\n {entity.note && (\n <p className=\"px-4 pt-2 text-xs italic text-plan-muted\">\n {entity.note}\n </p>\n )}\n <table className=\"w-full border-collapse text-sm\">\n <tbody>\n {entity.fields.map((field, index) => {\n const fkTarget = field.fk\n ? resolveEntity(entities, parseFk(field.fk).entity)\n : undefined;\n return (\n <tr\n key={`${field.name}-${index}`}\n className={cn(\n \"border-t border-plan-line/70 align-top first:border-t-0\",\n field.fk && \"cursor-pointer hover:bg-blue-500/5\",\n field.change && CHANGE_ROW_ACCENT[field.change],\n )}\n // FK interactivity: hovering rings the referenced\n // entity card; clicking also scrolls it into view.\n onMouseEnter={\n fkTarget\n ? () => focusEntity(fkTarget.id, false)\n : undefined\n }\n onMouseLeave={\n fkTarget\n ? () => focusEntity(undefined, false)\n : undefined\n }\n onClick={\n fkTarget\n ? () => focusEntity(fkTarget.id, true)\n : undefined\n }\n >\n <td className=\"w-px whitespace-nowrap py-1.5 pl-4 pr-2\">\n <div className=\"flex items-center gap-1.5\">\n {field.pk && (\n <IconKey\n className=\"size-3.5 shrink-0 text-amber-500 dark:text-amber-300\"\n aria-label=\"Primary key\"\n />\n )}\n {field.fk && (\n <IconLink\n className=\"size-3.5 shrink-0 text-blue-500 dark:text-blue-300\"\n aria-label=\"Foreign key\"\n />\n )}\n <span\n className={cn(\n \"font-mono text-xs\",\n field.pk && \"font-semibold\",\n field.change\n ? CHANGE_NAME_INK[field.change]\n : \"text-plan-text\",\n )}\n >\n {field.name}\n </span>\n </div>\n </td>\n <td className=\"py-1.5 pr-2\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {/* Prior value (`was`) for a modified field —\n struck through ahead of the current type. */}\n {field.change === \"modified\" && field.was && (\n <>\n <span className=\"inline-block rounded bg-accent/30 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted line-through\">\n {field.was}\n </span>\n <IconArrowNarrowRight\n className=\"size-3 shrink-0 text-plan-muted\"\n aria-hidden\n />\n </>\n )}\n {field.type && (\n <span\n className={cn(\n \"inline-block rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px]\",\n field.change === \"removed\"\n ? \"text-plan-muted line-through\"\n : \"text-plan-muted\",\n )}\n >\n {field.type}\n </span>\n )}\n </div>\n </td>\n <td className=\"py-1.5 pr-4 text-right\">\n <div className=\"flex flex-wrap items-center justify-end gap-1\">\n {field.change && (\n <ChangeChip change={field.change} />\n )}\n {field.pk && (\n <span className=\"rounded px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-600 dark:text-amber-300 bg-amber-100 dark:bg-amber-500/15\">\n PK\n </span>\n )}\n {field.fk && (\n <span className=\"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-semibold text-blue-700 dark:text-blue-300 bg-blue-100 dark:bg-blue-500/15\">\n FK\n <span className=\"font-mono font-normal opacity-90\">\n {fkTarget\n ? `${fkTarget.name}${\n parseFk(field.fk).field\n ? `.${parseFk(field.fk).field}`\n : \"\"\n }`\n : field.fk}\n </span>\n </span>\n )}\n {field.nullable && (\n <span className=\"rounded px-1.5 py-0.5 text-[10px] font-medium text-plan-muted bg-accent/50\">\n nullable\n </span>\n )}\n {field.default != null &&\n field.default !== \"\" && (\n <span className=\"rounded px-1.5 py-0.5 font-mono text-[10px] text-plan-muted bg-accent/40\">\n = {field.default}\n </span>\n )}\n </div>\n {field.note && (\n <div className=\"mt-0.5 text-[11px] italic text-plan-muted\">\n {field.note}\n </div>\n )}\n </td>\n </tr>\n );\n })}\n {entity.fields.length === 0 && (\n <tr>\n <td className=\"px-4 py-2 text-xs text-plan-muted\">\n No fields yet.\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n )}\n </div>\n );\n })}\n </div>\n\n {/* Relations / connectors list. */}\n {relations.length > 0 && (\n <div className=\"mt-4\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Relations\n </div>\n <div className=\"mt-2 flex flex-col gap-1.5\">\n {relations.map((relation, index) => {\n const fromEntity = resolveEntity(entities, relation.from);\n const toEntity = resolveEntity(entities, relation.to);\n return (\n <button\n key={`${relation.from}-${relation.to}-${index}`}\n type=\"button\"\n data-plan-interactive\n className=\"group flex w-fit items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors hover:bg-accent/40\"\n onMouseEnter={() => focusEntity(toEntity?.id, false)}\n onMouseLeave={() => focusEntity(undefined, false)}\n onClick={() => focusEntity(toEntity?.id, true)}\n >\n <span className=\"font-mono text-xs font-semibold text-plan-text\">\n {entityLabel(entities, relation.from)}\n </span>\n <span className=\"flex items-center gap-1 rounded bg-blue-100 px-1.5 py-0.5 font-mono text-[10px] font-bold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\">\n {relationGlyph(relation.kind)}\n <IconArrowNarrowRight className=\"size-3\" />\n </span>\n <span className=\"font-mono text-xs font-semibold text-plan-text\">\n {entityLabel(entities, relation.to)}\n </span>\n {relation.label && (\n <span className=\"text-xs text-plan-muted\">\n · {relation.label}\n </span>\n )}\n {!fromEntity || !toEntity ? (\n <span className=\"text-[10px] text-amber-600 dark:text-amber-300\">\n (unresolved)\n </span>\n ) : null}\n </button>\n );\n })}\n </div>\n </div>\n )}\n\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/* ── Edit (panel form) ─────────────────────────────────────────────────────── */\n\nlet entitySeq = 0;\n/** Stable-enough new entity id for a freshly-added entity in the editor. */\nfunction newEntityId(): string {\n entitySeq += 1;\n return `e_${Date.now().toString(36)}_${entitySeq}`;\n}\n\n/**\n * Panel editor for a `data-model` block. A structured form: a list of entities\n * (add/remove), each with a name Input, an optional note, and repeatable field\n * rows (add/remove) carrying name / type / PK checkbox / FK input / nullable\n * checkbox. Relations are derived from `fk` in v1, so the form focuses on the\n * entities + fields. Renders BARE content (no `<section>`); the registry's panel\n * surface supplies the popover chrome.\n */\nexport function DataModelEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<DataModelData>) {\n const entities = data.entities ?? [];\n\n const patchEntities = (next: DataModelEntity[]) =>\n onChange({ ...data, entities: next });\n\n const updateEntity = (index: number, next: Partial<DataModelEntity>) =>\n patchEntities(\n entities.map((entity, i) =>\n i === index ? { ...entity, ...next } : entity,\n ),\n );\n\n const removeEntity = (index: number) =>\n patchEntities(entities.filter((_, i) => i !== index));\n\n const addEntity = () =>\n patchEntities([\n ...entities,\n {\n id: newEntityId(),\n name: \"NewEntity\",\n fields: [{ name: \"id\", pk: true }],\n },\n ]);\n\n const updateField = (\n entityIndex: number,\n fieldIndex: number,\n next: Partial<DataModelField>,\n ) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: entity.fields.map((field, i) =>\n i === fieldIndex ? { ...field, ...next } : field,\n ),\n });\n };\n\n const removeField = (entityIndex: number, fieldIndex: number) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: entity.fields.filter((_, i) => i !== fieldIndex),\n });\n };\n\n const addField = (entityIndex: number) => {\n const entity = entities[entityIndex];\n if (!entity) return;\n updateEntity(entityIndex, {\n fields: [...entity.fields, { name: \"field\" }],\n });\n };\n\n return (\n <div className=\"flex flex-col gap-4\" data-plan-interactive>\n {entities.map((entity, entityIndex) => (\n <div\n key={entity.id}\n className=\"flex flex-col gap-2 rounded-lg border border-input p-3\"\n >\n <div className=\"flex items-center gap-2\">\n <IconDatabase className=\"size-4 shrink-0 text-muted-foreground\" />\n <DevInput\n className=\"h-8 font-mono text-sm font-semibold\"\n value={entity.name}\n disabled={!editable}\n placeholder=\"EntityName\"\n onChange={(event) =>\n updateEntity(entityIndex, { name: event.target.value })\n }\n />\n <DevSelect\n className=\"h-8 w-[120px] shrink-0\"\n value={entity.change ?? \"none\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateEntity(entityIndex, {\n change:\n value === \"none\" ? undefined : (value as DataModelChange),\n })\n }\n options={[\n { value: \"none\", label: \"No change\" },\n ...DATA_MODEL_CHANGES.map((change) => ({\n value: change,\n label: CHANGE_LABEL[change],\n })),\n ]}\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove entity\"\n className=\"flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeEntity(entityIndex)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n\n {/* Field rows. */}\n <div className=\"flex flex-col gap-1.5\">\n {entity.fields.map((field, fieldIndex) => (\n <div\n key={fieldIndex}\n className=\"flex flex-col gap-1.5 rounded-md border border-input/60 bg-accent/20 p-2\"\n >\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-1.5\">\n <DevInput\n className=\"h-7 font-mono text-xs\"\n value={field.name}\n disabled={!editable}\n placeholder=\"name\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n name: event.target.value,\n })\n }\n />\n <DevInput\n className=\"h-7 font-mono text-xs\"\n value={field.type ?? \"\"}\n disabled={!editable}\n placeholder=\"type (e.g. uuid)\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n type: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove field\"\n className=\"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeField(entityIndex, fieldIndex)}\n >\n <IconTrash className=\"size-3.5\" />\n </button>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-3\">\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(field.pk)}\n disabled={!editable}\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n pk: event.target.checked || undefined,\n })\n }\n />\n PK\n </label>\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(field.nullable)}\n disabled={!editable}\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n nullable: event.target.checked || undefined,\n })\n }\n />\n Nullable\n </label>\n <DevInput\n className=\"h-7 flex-1 font-mono text-xs\"\n value={field.fk ?? \"\"}\n disabled={!editable}\n placeholder=\"FK → Entity.field\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n fk: event.target.value || undefined,\n })\n }\n />\n </div>\n {/* Diff row: change kind + the prior value (`was`) when the\n field is \"modified\", so before/after renders in Read. */}\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <DevSelect\n className=\"h-7 w-[120px] shrink-0\"\n value={field.change ?? \"none\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateField(entityIndex, fieldIndex, {\n change:\n value === \"none\"\n ? undefined\n : (value as DataModelChange),\n // Drop a stale `was` when leaving the modified state.\n ...(value === \"modified\" ? {} : { was: undefined }),\n })\n }\n options={[\n { value: \"none\", label: \"No change\" },\n ...DATA_MODEL_CHANGES.map((change) => ({\n value: change,\n label: CHANGE_LABEL[change],\n })),\n ]}\n />\n {field.change === \"modified\" && (\n <DevInput\n className=\"h-7 flex-1 font-mono text-xs\"\n value={field.was ?? \"\"}\n disabled={!editable}\n placeholder=\"was (prior value, e.g. old type)\"\n onChange={(event) =>\n updateField(entityIndex, fieldIndex, {\n was: event.target.value || undefined,\n })\n }\n />\n )}\n </div>\n </div>\n ))}\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex w-fit items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => addField(entityIndex)}\n >\n <IconPlus className=\"size-3.5\" />\n Add field\n </button>\n )}\n </div>\n </div>\n ))}\n\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center justify-center gap-1.5 rounded-md border border-dashed border-input py-2 text-sm text-muted-foreground hover:bg-accent/40 hover:text-foreground\"\n onClick={addEntity}\n >\n <IconPlus className=\"size-4\" />\n Add entity\n </button>\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DiffBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAkB,QAAQ,EAAY,MAAM,kBAAkB,CAAC;AAmB3E;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AQ,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CA2LvE;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
3
3
  import { IconChevronRight, IconColumns, IconDotsVertical, IconFileDiff, IconList, IconPlus, IconTrash, } from "@tabler/icons-react";
4
4
  import { common, createLowlight } from "lowlight";
5
5
  import { cn } from "../../utils.js";
6
+ import { ltrCodeBlockProps } from "../code-block-direction.js";
6
7
  import { AnnotationGutterMarker, AnnotationHiddenStack, AnnotationHoverCard, AnnotationInlineOverlayStack, anchorFromElements, buildLineMarkerMap, hasRailAnnotations, resolveAnnotations, useAnnotationMarginNotesAvailable, useAnnotationHover, } from "./annotation-rail.js";
7
8
  import { DevInput, DevLabel, DevTextarea, DevSelect } from "./dev-doc-ui.js";
8
9
  import { useInNarrowContainer } from "./narrow-container.js";
@@ -634,7 +635,7 @@ function DiffRead({ data, blockId, title, summary, ctx, }) {
634
635
  const diffBox = (_jsxs("div", { ref: codeRef, className: "overflow-hidden rounded-md border border-border bg-background", children: [_jsxs("div", { className: "flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5", children: [_jsx(IconFileDiff, { className: "size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-1 items-baseline gap-1.5 font-mono", title: data.filename || undefined, children: [_jsx("span", { className: "min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground", children: fileParts.basename }), fileParts.directory && (_jsx("span", { className: "min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70", children: fileParts.directory }))] }), _jsxs("span", { className: "ml-1 flex shrink-0 items-center gap-2 font-mono text-xs", children: [_jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: ["+", added] }), _jsxs("span", { className: "text-destructive", children: ["\u2212", removed] })] }), canSplit && (_jsxs("div", { className: "pointer-events-none ml-auto flex shrink-0 items-center overflow-hidden rounded-md border border-border bg-background opacity-0 transition-opacity group-hover/diff-block:pointer-events-auto group-hover/diff-block:opacity-100 group-focus-within/diff-block:pointer-events-auto group-focus-within/diff-block:opacity-100", children: [_jsx(ModeButton, { active: mode === "unified", onClick: () => setMode("unified"), icon: _jsx(IconList, { className: "size-3.5" }), label: "Unified" }), _jsx(ModeButton, { active: mode === "split", onClick: () => setMode("split"), icon: _jsx(IconColumns, { className: "size-3.5" }), label: "Split" })] }))] }), unchanged ? (_jsx("div", { className: "px-4 py-6 text-center font-mono text-sm text-muted-foreground", children: "No changes" })) : effectiveMode === "split" ? (_jsx(SplitView, { rows: rows, language: language, rowLimit: rowLimit, markersForRow: markersForRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showPersistentAnnotations, annotationOverlayMode: showAnnotationOverlays ? "capture" : "margin", annotationOverlaySide: showAnnotationOverlays ? "right" : annotationMarginSide, annotationOverlayPreferredSide: annotationHoverSide, annotationOverlayContainerRef: codeRef, captureOverlayAnnotationIndex: captureOverlayAnnotationIndex, ctx: ctx })) : (_jsx(UnifiedView, { rows: displayedRows, language: language, expanded: expanded, onToggleRun: toggleRun, markersForRow: markersForRow, anchoredRow: anchoredRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showPersistentAnnotations, annotationOverlayMode: showAnnotationOverlays ? "capture" : "margin", annotationOverlaySide: showAnnotationOverlays ? "right" : annotationMarginSide, annotationOverlayPreferredSide: annotationHoverSide, annotationOverlayContainerRef: codeRef, captureOverlayAnnotationIndex: captureOverlayAnnotationIndex, ctx: ctx })), !unchanged && shouldLimitRows && (_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": showAllRows, onClick: () => setShowAllRows((current) => !current), className: "flex h-7 w-full items-center justify-center gap-1.5 border-t border-border bg-background px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground", children: [_jsx(IconChevronRight, { className: cn("size-3 shrink-0 transition-transform", showAllRows ? "-rotate-90" : "rotate-90") }), showAllRows
635
636
  ? "Show fewer"
636
637
  : `Show all ${totalVisibleLineCount} lines`] }))] }));
637
- return (_jsxs("section", { ref: containerRef, className: "relative plan-block group/diff-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), summary && (_jsx("p", { className: "mb-3 text-sm leading-relaxed text-plan-muted", children: summary })), diffBox, hasAnnotations && (_jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx, showMarker: true })), hasAnnotations &&
638
+ return (_jsxs("section", { ...ltrCodeBlockProps, ref: containerRef, className: "relative plan-block group/diff-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), summary && (_jsx("p", { className: "mb-3 text-sm leading-relaxed text-plan-muted", children: summary })), diffBox, hasAnnotations && (_jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx, showMarker: true })), hasAnnotations &&
638
639
  !showPersistentAnnotations &&
639
640
  activeItem &&
640
641
  hover.anchor && (_jsx(AnnotationHoverCard, { item: activeItem, anchor: hover.anchor, ctx: ctx, showMarker: true, preferredSide: annotationHoverSide, hoverFallbackSide: annotationHoverFallbackSide, onMouseEnter: hover.cancelClose, onMouseLeave: hover.scheduleClose, onClose: hover.closeForScroll }))] }));