@agent-native/core 0.44.4 → 0.45.0

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 (106) hide show
  1. package/dist/cli/connect.d.ts +2 -1
  2. package/dist/cli/connect.d.ts.map +1 -1
  3. package/dist/cli/connect.js +185 -5
  4. package/dist/cli/connect.js.map +1 -1
  5. package/dist/cli/index.js +27 -0
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/plan-local.d.ts +43 -0
  8. package/dist/cli/plan-local.d.ts.map +1 -0
  9. package/dist/cli/plan-local.js +477 -0
  10. package/dist/cli/plan-local.js.map +1 -0
  11. package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
  12. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  13. package/dist/cli/pr-visual-recap-workflow.js +1 -1
  14. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  15. package/dist/cli/recap.d.ts +164 -0
  16. package/dist/cli/recap.d.ts.map +1 -1
  17. package/dist/cli/recap.js +657 -10
  18. package/dist/cli/recap.js.map +1 -1
  19. package/dist/cli/skills.d.ts +2 -2
  20. package/dist/cli/skills.d.ts.map +1 -1
  21. package/dist/cli/skills.js +160 -387
  22. package/dist/cli/skills.js.map +1 -1
  23. package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
  24. package/dist/client/blocks/library/AnnotatedCodeBlock.js +4 -1
  25. package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
  26. package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
  27. package/dist/client/blocks/library/DiffBlock.js +10 -11
  28. package/dist/client/blocks/library/DiffBlock.js.map +1 -1
  29. package/dist/client/blocks/library/annotation-rail.d.ts +15 -5
  30. package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
  31. package/dist/client/blocks/library/annotation-rail.js +35 -24
  32. package/dist/client/blocks/library/annotation-rail.js.map +1 -1
  33. package/dist/client/blocks/library/code-filename-label.d.ts +8 -0
  34. package/dist/client/blocks/library/code-filename-label.d.ts.map +1 -0
  35. package/dist/client/blocks/library/code-filename-label.js +15 -0
  36. package/dist/client/blocks/library/code-filename-label.js.map +1 -0
  37. package/dist/client/blocks/library/code.d.ts.map +1 -1
  38. package/dist/client/blocks/library/code.js +3 -2
  39. package/dist/client/blocks/library/code.js.map +1 -1
  40. package/dist/client/blocks/library/diff.config.d.ts +1 -1
  41. package/dist/client/blocks/library/diff.config.js.map +1 -1
  42. package/dist/client/blocks/library/narrow-container.d.ts +4 -4
  43. package/dist/client/blocks/library/narrow-container.d.ts.map +1 -1
  44. package/dist/client/blocks/library/narrow-container.js +10 -10
  45. package/dist/client/blocks/library/narrow-container.js.map +1 -1
  46. package/dist/client/blocks/library/tabs.d.ts.map +1 -1
  47. package/dist/client/blocks/library/tabs.js +7 -2
  48. package/dist/client/blocks/library/tabs.js.map +1 -1
  49. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  50. package/dist/client/composer/TiptapComposer.js +4 -1
  51. package/dist/client/composer/TiptapComposer.js.map +1 -1
  52. package/dist/client/db-admin/TableEditor.d.ts.map +1 -1
  53. package/dist/client/db-admin/TableEditor.js +3 -1
  54. package/dist/client/db-admin/TableEditor.js.map +1 -1
  55. package/dist/db/client.d.ts +8 -0
  56. package/dist/db/client.d.ts.map +1 -1
  57. package/dist/db/client.js +23 -2
  58. package/dist/db/client.js.map +1 -1
  59. package/dist/deploy/build.d.ts.map +1 -1
  60. package/dist/deploy/build.js +8 -0
  61. package/dist/deploy/build.js.map +1 -1
  62. package/dist/extensions/html-shell.js +1 -1
  63. package/dist/extensions/html-shell.js.map +1 -1
  64. package/dist/jobs/scheduler.d.ts.map +1 -1
  65. package/dist/jobs/scheduler.js +5 -1
  66. package/dist/jobs/scheduler.js.map +1 -1
  67. package/dist/mcp/build-server.d.ts +1 -0
  68. package/dist/mcp/build-server.d.ts.map +1 -1
  69. package/dist/mcp/build-server.js +7 -3
  70. package/dist/mcp/build-server.js.map +1 -1
  71. package/dist/mcp/oauth-route.d.ts.map +1 -1
  72. package/dist/mcp/oauth-route.js +56 -19
  73. package/dist/mcp/oauth-route.js.map +1 -1
  74. package/dist/mcp/oauth-store.d.ts +1 -0
  75. package/dist/mcp/oauth-store.d.ts.map +1 -1
  76. package/dist/mcp/oauth-store.js +9 -0
  77. package/dist/mcp/oauth-store.js.map +1 -1
  78. package/dist/mcp/server.d.ts.map +1 -1
  79. package/dist/mcp/server.js +9 -4
  80. package/dist/mcp/server.js.map +1 -1
  81. package/dist/mcp-client/errors.js +3 -3
  82. package/dist/mcp-client/errors.js.map +1 -1
  83. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  84. package/dist/server/agent-chat-plugin.js +3 -1
  85. package/dist/server/agent-chat-plugin.js.map +1 -1
  86. package/dist/server/agent-teams.d.ts.map +1 -1
  87. package/dist/server/agent-teams.js +10 -2
  88. package/dist/server/agent-teams.js.map +1 -1
  89. package/dist/server/auth.d.ts.map +1 -1
  90. package/dist/server/auth.js +7 -3
  91. package/dist/server/auth.js.map +1 -1
  92. package/dist/server/recap-image-route.d.ts.map +1 -1
  93. package/dist/server/recap-image-route.js +3 -6
  94. package/dist/server/recap-image-route.js.map +1 -1
  95. package/dist/server/sentry.d.ts.map +1 -1
  96. package/dist/server/sentry.js +12 -5
  97. package/dist/server/sentry.js.map +1 -1
  98. package/dist/server/social-og-image.d.ts.map +1 -1
  99. package/dist/server/social-og-image.js +3 -1
  100. package/dist/server/social-og-image.js.map +1 -1
  101. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +22 -6
  102. package/docs/content/plan-plugin.md +18 -1
  103. package/docs/content/pr-visual-recap.md +37 -10
  104. package/docs/content/template-plan.md +45 -1
  105. package/package.json +1 -1
  106. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +22 -6
@@ -1 +1 @@
1
- {"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[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kB,CAA2B,EAC3D,KAAK,EACL,WAAW,EACX,cAAc,EACd,GAAG,EACH,SAAS,EACT,UAAU,GAAG,KAAK,GASnB;IACC,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACxC,CAAC,KAAK,CAAC,CACR,CAAC;IACF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,YACnD,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC7B,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,KAAK,EAClC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAC9C,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IANnC,IAAI,CAAC,KAAK,CAOf,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,KAA2B;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-amber-500 text-white dark:bg-amber-400 dark:text-amber-950\"\n : \"bg-amber-400/25 text-amber-700 dark:bg-amber-300/20 dark:text-amber-300\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 transition-colors\",\n active\n ? \"border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]\"\n : \"border-plan-line bg-plan-block/40 hover:border-amber-400/50\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex flex-wrap gap-x-2 gap-y-0.5\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\n/* ── Hover popover (portal, anchored RIGHT of the code) ────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nconst HOVER_CARD_WIDTH = 280;\nconst HOVER_CARD_GAP = 12;\nconst VIEWPORT_MARGIN = 8;\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right (it would overflow the viewport), it clamps\n * within the viewport, and if the right gutter is too narrow for the card it\n * falls back to BELOW the hovered line (left-aligned to the code block). The card\n * keeps itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so it\n * stays readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, else clamp into the viewport, else drop below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n\n const rightLeft = anchor.codeRight + HOVER_CARD_GAP;\n const fitsRight = rightLeft + width + VIEWPORT_MARGIN <= vw;\n\n let left: number;\n let top: number;\n if (fitsRight) {\n // Default: to the right of the code, centered on the hovered line.\n left = rightLeft;\n top = anchor.lineCenter - height / 2;\n } else {\n // No room to the right → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n // Clamp within the viewport so the card is never cut off.\n left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(left, vw - width - VIEWPORT_MARGIN),\n );\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, vh - height - VIEWPORT_MARGIN),\n );\n setPos({ top, left });\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n item.index,\n ]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent controller for the on-hover note card. Exposes `activeIndex` +\n * the captured `anchor`, plus `open`/`scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive({ index, anchor });\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
1
+ {"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,kFAAkF;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IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-amber-500 text-white dark:bg-amber-400 dark:text-amber-950\"\n : \"bg-amber-400/25 text-amber-700 dark:bg-amber-300/20 dark:text-amber-300\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 transition-colors\",\n active\n ? \"border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]\"\n : \"border-plan-line bg-plan-block/40 hover:border-amber-400/50\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex flex-wrap gap-x-2 gap-y-0.5\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\n/* ── Hover popover (portal, anchored beside the code) ──────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nconst HOVER_CARD_WIDTH = 280;\nconst HOVER_CARD_GAP = 12;\nconst VIEWPORT_MARGIN = 8;\n\nexport function resolveAnnotationHoverCardPosition(\n anchor: AnnotationAnchor,\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; left: number } {\n const rightLeft = anchor.codeRight + HOVER_CARD_GAP;\n const fitsRight = rightLeft + card.width + VIEWPORT_MARGIN <= viewport.width;\n const leftLeft = anchor.codeLeft - HOVER_CARD_GAP - card.width;\n const fitsLeft = leftLeft >= VIEWPORT_MARGIN;\n\n let left: number;\n let top: number;\n if (fitsRight) {\n // Default: to the right of the code, centered on the hovered line.\n left = rightLeft;\n top = anchor.lineCenter - card.height / 2;\n } else if (fitsLeft) {\n // Prefer the left gutter over covering the code below the hovered line.\n left = leftLeft;\n top = anchor.lineCenter - card.height / 2;\n } else {\n // No clean side gutter → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n\n // Clamp within the viewport so the card is never cut off.\n left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(left, viewport.width - card.width - VIEWPORT_MARGIN),\n );\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, viewport.height - card.height - VIEWPORT_MARGIN),\n );\n\n return { top, left };\n}\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right, it uses the LEFT of the code block when the\n * card can fit there without covering code. Only when neither side fits does it\n * fall back to BELOW the hovered line (left-aligned to the code block). The card\n * keeps itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so\n * it stays readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, then left if that side has a clean gutter, otherwise\n // below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n setPos(\n resolveAnnotationHoverCardPosition(\n anchor,\n { width, height },\n { width: vw, height: vh },\n ),\n );\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n item.index,\n ]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent controller for the on-hover note card. Exposes `activeIndex` +\n * the captured `anchor`, plus `open`/`scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive({ index, anchor });\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
@@ -0,0 +1,8 @@
1
+ export declare function CodeFilenameLabel({ filename, fallback, className, directoryClassName, basenameClassName, }: {
2
+ filename?: string | null;
3
+ fallback?: string;
4
+ className?: string;
5
+ directoryClassName?: string;
6
+ basenameClassName?: string;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=code-filename-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-filename-label.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/code-filename-label.tsx"],"names":[],"mappings":"AAcA,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAoB,EACpB,SAAS,EACT,kBAAkB,EAClB,iBAAiB,GAClB,EAAE;IACD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,2CAgCA"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../utils.js";
3
+ function splitFilename(filename) {
4
+ const value = filename?.trim() || "snippet";
5
+ const segments = value.split("/").filter(Boolean);
6
+ const basename = segments[segments.length - 1] ?? value;
7
+ const directory = segments.length > 1 ? `${segments.slice(0, -1).join("/")}/` : null;
8
+ return { basename, directory };
9
+ }
10
+ export function CodeFilenameLabel({ filename, fallback = "snippet", className, directoryClassName, basenameClassName, }) {
11
+ const value = filename?.trim() || fallback;
12
+ const { basename, directory } = splitFilename(value);
13
+ return (_jsxs("span", { className: cn("inline-flex min-w-0 flex-1 items-baseline font-mono", className), title: value, children: [directory && (_jsx("span", { "data-code-filename-directory": true, className: cn("min-w-0 shrink truncate", directoryClassName), children: directory })), _jsx("span", { "data-code-filename-basename": true, className: cn("min-w-0 truncate", directory ? "max-w-[60%] shrink-0" : "flex-1", basenameClassName), children: basename })] }));
14
+ }
15
+ //# sourceMappingURL=code-filename-label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-filename-label.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/code-filename-label.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC,SAAS,aAAa,CAAC,QAAwB;IAI7C,MAAM,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;IACxD,MAAM,SAAS,GACb,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACrE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAQ,GAAG,SAAS,EACpB,SAAS,EACT,kBAAkB,EAClB,iBAAiB,GAOlB;IACC,MAAM,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC;IAC3C,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAErD,OAAO,CACL,gBACE,SAAS,EAAE,EAAE,CACX,qDAAqD,EACrD,SAAS,CACV,EACD,KAAK,EAAE,KAAK,aAEX,SAAS,IAAI,CACZ,qDAEE,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,YAE3D,SAAS,GACL,CACR,EACD,oDAEE,SAAS,EAAE,EAAE,CACX,kBAAkB,EAClB,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,EAC7C,iBAAiB,CAClB,YAEA,QAAQ,GACJ,IACF,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { cn } from \"../../utils.js\";\n\nfunction splitFilename(filename?: string | null): {\n basename: string;\n directory: string | null;\n} {\n const value = filename?.trim() || \"snippet\";\n const segments = value.split(\"/\").filter(Boolean);\n const basename = segments[segments.length - 1] ?? value;\n const directory =\n segments.length > 1 ? `${segments.slice(0, -1).join(\"/\")}/` : null;\n return { basename, directory };\n}\n\nexport function CodeFilenameLabel({\n filename,\n fallback = \"snippet\",\n className,\n directoryClassName,\n basenameClassName,\n}: {\n filename?: string | null;\n fallback?: string;\n className?: string;\n directoryClassName?: string;\n basenameClassName?: string;\n}) {\n const value = filename?.trim() || fallback;\n const { basename, directory } = splitFilename(value);\n\n return (\n <span\n className={cn(\n \"inline-flex min-w-0 flex-1 items-baseline font-mono\",\n className,\n )}\n title={value}\n >\n {directory && (\n <span\n data-code-filename-directory\n className={cn(\"min-w-0 shrink truncate\", directoryClassName)}\n >\n {directory}\n </span>\n )}\n <span\n data-code-filename-basename\n className={cn(\n \"min-w-0 truncate\",\n directory ? \"max-w-[60%] shrink-0\" : \"flex-1\",\n basenameClassName,\n )}\n >\n {basename}\n </span>\n </span>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/code.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAmYtE,eAAO,MAAM,SAAS,2CAYpB,CAAC"}
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/code.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA2YtE,eAAO,MAAM,SAAS,2CAYpB,CAAC"}
@@ -6,6 +6,7 @@ import { Popover, PopoverContent, PopoverTrigger, } from "../../components/ui/po
6
6
  import { defineBlock } from "../types.js";
7
7
  import { CodeSurface, DEFAULT_CODE_MAX_LINES } from "./HighlightedCode.js";
8
8
  import { highlightCode, inferLanguageFromFilename, normalizeCodeLanguage, } from "./code-highlight.js";
9
+ import { CodeFilenameLabel } from "./code-filename-label.js";
9
10
  import { codeSchema, codeMdx } from "./code.config.js";
10
11
  /**
11
12
  * Standard `code` block (STANDARD core library): THE primitive single code
@@ -53,7 +54,7 @@ function CodeRead({ data, blockId }) {
53
54
  inferLanguageFromFilename(data.filename) ??
54
55
  undefined;
55
56
  const hasFilename = Boolean(data.filename?.trim());
56
- return (_jsx("section", { className: "plan-block", "data-block-id": blockId, children: _jsxs("div", { className: "plan-code group relative", children: [hasFilename && (_jsxs("div", { className: "plan-code-head", children: [_jsxs("span", { className: "plan-code-filename", children: [_jsx(IconCode, { className: "size-4 shrink-0 opacity-70" }), data.filename] }), _jsx("span", { className: "plan-code-chrome", children: _jsx(CopyButton, { value: data.code }) })] })), _jsx(CodeSurface, { code: data.code, language: language, maxLines: data.maxLines, className: data.filename ? "mt-0" : "mt-0", showLanguageLabel: hasFilename }), !hasFilename && (_jsx("span", { className: "plan-code-chrome plan-code-chrome-float", children: _jsx(CopyButton, { value: data.code }) })), data.caption && _jsx("p", { className: "plan-code-caption", children: data.caption })] }) }));
57
+ return (_jsx("section", { className: "plan-block", "data-block-id": blockId, children: _jsxs("div", { className: "plan-code group relative", children: [hasFilename && (_jsxs("div", { className: "plan-code-head", children: [_jsxs("span", { className: "plan-code-filename", children: [_jsx(IconCode, { className: "size-4 shrink-0 opacity-70" }), _jsx(CodeFilenameLabel, { filename: data.filename, directoryClassName: "text-plan-muted", basenameClassName: "text-plan-text" })] }), _jsx("span", { className: "plan-code-chrome", children: _jsx(CopyButton, { value: data.code }) })] })), _jsx(CodeSurface, { code: data.code, language: language, maxLines: data.maxLines, className: data.filename ? "mt-0" : "mt-0", showLanguageLabel: false }), !hasFilename && (_jsx("span", { className: "plan-code-chrome plan-code-chrome-float", children: _jsx(CopyButton, { value: data.code }) })), data.caption && _jsx("p", { className: "plan-code-caption", children: data.caption })] }) }));
57
58
  }
58
59
  /* ── Edit (single border, no resize, auto-grow, hover chrome) ──────────────── */
59
60
  const SETTINGS_INPUT = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
@@ -110,7 +111,7 @@ function CodeEditorSurface({ code, language, filename, maxLines, editable, onCod
110
111
  layer.scrollTop = event.currentTarget.scrollTop;
111
112
  };
112
113
  const chrome = (_jsxs(_Fragment, { children: [_jsx("label", { htmlFor: selectId, className: "sr-only", children: "Code language" }), _jsx("select", { id: selectId, "data-plan-interactive": true, disabled: !editable, className: "plan-code-lang-select", value: normalizeCodeLanguage(language) ? (language ?? "") : "", onChange: (event) => onLanguageChange(event.target.value || undefined), children: CODE_LANGUAGES.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value || "auto"))) }), editable && (_jsx(CodeSettingsPopover, { filename: filename, maxLines: maxLines, onFilenameChange: onFilenameChange, onMaxLinesChange: onMaxLinesChange })), _jsx(CopyButton, { value: code })] }));
113
- return (_jsxs("div", { className: cn("plan-code plan-code-editing group relative", !hasFilename && "plan-code-editing--unlabeled", !editable && "opacity-60"), children: [hasFilename && (_jsxs("div", { className: "plan-code-head", children: [_jsxs("span", { className: "plan-code-filename plan-code-muted", children: [_jsx(IconCode, { className: "size-4 shrink-0 opacity-70" }), filename] }), _jsx("span", { className: "plan-code-chrome", children: chrome })] })), _jsxs("div", { className: "plan-code-editor-body", children: [_jsx("pre", { ref: highlightLayerRef, "aria-hidden": "true", className: "plan-code-editor-layer", children: _jsxs("code", { children: [highlighted, code.endsWith("\n") ? " " : null] }) }), _jsx("textarea", { "data-plan-interactive": true, spellCheck: false, wrap: "off", rows: Math.max(3, rows), className: "plan-code-editor-input", value: code, disabled: !editable, onChange: (event) => onCodeChange(event.target.value), onScroll: syncScroll }), collapsed && (_jsx("div", { className: "plan-code-editor-fade", "aria-hidden": "true" }))] }), !hasFilename && (_jsx("span", { className: "plan-code-chrome plan-code-chrome-float", children: chrome })), collapsible && (_jsx("button", { type: "button", "data-plan-interactive": true, className: "plan-code-surface-toggle", onClick: () => setExpanded((value) => !value), children: collapsed
114
+ return (_jsxs("div", { className: cn("plan-code plan-code-editing group relative", !hasFilename && "plan-code-editing--unlabeled", !editable && "opacity-60"), children: [hasFilename && (_jsxs("div", { className: "plan-code-head", children: [_jsxs("span", { className: "plan-code-filename plan-code-muted", children: [_jsx(IconCode, { className: "size-4 shrink-0 opacity-70" }), _jsx(CodeFilenameLabel, { filename: filename, directoryClassName: "text-plan-muted", basenameClassName: "text-plan-text" })] }), _jsx("span", { className: "plan-code-chrome", children: chrome })] })), _jsxs("div", { className: "plan-code-editor-body", children: [_jsx("pre", { ref: highlightLayerRef, "aria-hidden": "true", className: "plan-code-editor-layer", children: _jsxs("code", { children: [highlighted, code.endsWith("\n") ? " " : null] }) }), _jsx("textarea", { "data-plan-interactive": true, spellCheck: false, wrap: "off", rows: Math.max(3, rows), className: "plan-code-editor-input", value: code, disabled: !editable, onChange: (event) => onCodeChange(event.target.value), onScroll: syncScroll }), collapsed && (_jsx("div", { className: "plan-code-editor-fade", "aria-hidden": "true" }))] }), !hasFilename && (_jsx("span", { className: "plan-code-chrome plan-code-chrome-float", children: chrome })), collapsible && (_jsx("button", { type: "button", "data-plan-interactive": true, className: "plan-code-surface-toggle", onClick: () => setExpanded((value) => !value), children: collapsed
114
115
  ? `Show ${hiddenLines} more line${hiddenLines === 1 ? "" : "s"}`
115
116
  : "Show less" }))] }));
116
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"code.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/code.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAEtE;;;;;;;;;;GAUG;AAEH,+EAA+E;AAC/E,MAAM,cAAc,GAAoD;IACtE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IAC5B,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,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EAAC,MAAM,iCAEX,SAAS,EAAC,yBAAyB,EACnC,WAAW,EAAC,SAAS,EACrB,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC,GAEjE,CACH,IACG,CACP,CAAC;AACJ,CAAC;AAED,kFAAkF;AAElF,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAW;IAC7C,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,+KAA+K;CAClL,CAAC,CAAC","sourcesContent":["import {\n useId,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type UIEvent,\n} from \"react\";\nimport { IconCheck, IconCode, IconCopy, IconPencil } from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../../components/ui/popover.js\";\nimport { defineBlock } from \"../types.js\";\nimport type { BlockReadProps, BlockEditProps } from \"../types.js\";\nimport { CodeSurface, DEFAULT_CODE_MAX_LINES } from \"./HighlightedCode.js\";\nimport {\n highlightCode,\n inferLanguageFromFilename,\n normalizeCodeLanguage,\n} from \"./code-highlight.js\";\nimport { codeSchema, codeMdx, type CodeData } from \"./code.config.js\";\n\n/**\n * Standard `code` block (STANDARD core library): THE primitive single code\n * snippet, used everywhere in plan + content. Notion-style — one border, a\n * hover-revealed language switcher + copy, and the shared collapse-to-N-lines\n * read surface. A \"file rail\" of several files is just the `tabs` primitive\n * holding `code` blocks; there is no bespoke \"code-tabs\" container.\n *\n * Read = the shared {@link CodeSurface} (Shiki, single border, language label,\n * \"Show N more lines\"). Edit = a clean, single-border editable surface (no\n * drag-to-resize; it auto-grows to its content) with the same hover chrome.\n */\n\n/** Language options for the hover switcher; \"\" is the Auto-detect sentinel. */\nconst CODE_LANGUAGES: ReadonlyArray<{ value: string; label: string }> = [\n { value: \"\", label: \"Auto\" },\n { value: \"typescript\", label: \"TypeScript\" },\n { value: \"javascript\", label: \"JavaScript\" },\n { value: \"tsx\", label: \"TSX\" },\n { value: \"jsx\", label: \"JSX\" },\n { value: \"json\", label: \"JSON\" },\n { value: \"html\", label: \"HTML\" },\n { value: \"css\", label: \"CSS\" },\n { value: \"bash\", label: \"Bash\" },\n { value: \"python\", label: \"Python\" },\n { value: \"sql\", label: \"SQL\" },\n { value: \"yaml\", label: \"YAML\" },\n { value: \"markdown\", label: \"Markdown\" },\n { value: \"graphql\", label: \"GraphQL\" },\n { value: \"go\", label: \"Go\" },\n { value: \"rust\", label: \"Rust\" },\n { value: \"diff\", label: \"Diff\" },\n];\n\nfunction CopyButton({ value }: { value: string }) {\n const [copied, setCopied] = useState(false);\n return (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n title={copied ? \"Copied\" : \"Copy code\"}\n className=\"plan-code-chip\"\n onClick={() => {\n void navigator.clipboard?.writeText(value).then(\n () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1200);\n },\n () => {},\n );\n }}\n >\n {copied ? (\n <IconCheck className=\"size-3.5\" />\n ) : (\n <IconCopy className=\"size-3.5\" />\n )}\n </button>\n );\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction CodeRead({ data, blockId }: BlockReadProps<CodeData>) {\n const language =\n normalizeCodeLanguage(data.language) ??\n inferLanguageFromFilename(data.filename) ??\n undefined;\n const hasFilename = Boolean(data.filename?.trim());\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n <div className=\"plan-code group relative\">\n {hasFilename && (\n <div className=\"plan-code-head\">\n <span className=\"plan-code-filename\">\n <IconCode className=\"size-4 shrink-0 opacity-70\" />\n {data.filename}\n </span>\n <span className=\"plan-code-chrome\">\n <CopyButton value={data.code} />\n </span>\n </div>\n )}\n <CodeSurface\n code={data.code}\n language={language}\n maxLines={data.maxLines}\n className={data.filename ? \"mt-0\" : \"mt-0\"}\n showLanguageLabel={hasFilename}\n />\n {!hasFilename && (\n <span className=\"plan-code-chrome plan-code-chrome-float\">\n <CopyButton value={data.code} />\n </span>\n )}\n {data.caption && <p className=\"plan-code-caption\">{data.caption}</p>}\n </div>\n </section>\n );\n}\n\n/* ── Edit (single border, no resize, auto-grow, hover chrome) ──────────────── */\n\nconst SETTINGS_INPUT =\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\n/** Hover \"settings\" (pencil) → popover to edit the filename + max-lines cap. */\nfunction CodeSettingsPopover({\n filename,\n maxLines,\n onFilenameChange,\n onMaxLinesChange,\n}: {\n filename?: string;\n maxLines?: number;\n onFilenameChange: (filename: string | undefined) => void;\n onMaxLinesChange: (maxLines: number | undefined) => void;\n}) {\n const [filenameDraft, setFilenameDraft] = useState(filename ?? \"\");\n\n useEffect(() => {\n setFilenameDraft(filename ?? \"\");\n }, [filename]);\n\n const commitFilename = () => {\n const next = filenameDraft.trim();\n onFilenameChange(next || undefined);\n };\n\n return (\n <Popover>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Code block settings\"\n title=\"Code block settings\"\n className=\"plan-code-chip\"\n >\n <IconPencil className=\"size-3.5\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"end\"\n side=\"bottom\"\n className=\"w-64 p-0\"\n data-plan-interactive\n >\n <div className=\"border-b border-border px-3 py-2 text-sm font-semibold text-foreground\">\n Code block\n </div>\n <div className=\"grid gap-3 p-3\">\n <label className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n Filename\n </span>\n <input\n type=\"text\"\n data-plan-interactive\n className={SETTINGS_INPUT}\n placeholder=\"src/file.ts\"\n value={filenameDraft}\n onBlur={commitFilename}\n onChange={(event) => setFilenameDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n commitFilename();\n event.currentTarget.blur();\n }\n if (event.key === \"Escape\") {\n setFilenameDraft(filename ?? \"\");\n event.currentTarget.blur();\n }\n }}\n />\n </label>\n <label className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n Max lines before expand\n </span>\n <input\n type=\"number\"\n min={0}\n step={1}\n data-plan-interactive\n className={SETTINGS_INPUT}\n placeholder={`${DEFAULT_CODE_MAX_LINES} (default) · 0 = no limit`}\n value={maxLines ?? \"\"}\n onChange={(event) => {\n const raw = event.target.value.trim();\n const parsed = raw === \"\" ? undefined : Number(raw);\n onMaxLinesChange(\n parsed === undefined || Number.isNaN(parsed)\n ? undefined\n : Math.max(0, Math.min(2000, Math.floor(parsed))),\n );\n }}\n />\n </label>\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction CodeEditorSurface({\n code,\n language,\n filename,\n maxLines,\n editable,\n onCodeChange,\n onLanguageChange,\n onFilenameChange,\n onMaxLinesChange,\n}: {\n code: string;\n language?: string;\n filename?: string;\n maxLines?: number;\n editable: boolean;\n onCodeChange: (code: string) => void;\n onLanguageChange: (language: string | undefined) => void;\n onFilenameChange: (filename: string | undefined) => void;\n onMaxLinesChange: (maxLines: number | undefined) => void;\n}) {\n const [expanded, setExpanded] = useState(false);\n const highlightLayerRef = useRef<HTMLPreElement>(null);\n const selectId = useId();\n const resolvedLanguage =\n normalizeCodeLanguage(language) ?? inferLanguageFromFilename(filename);\n const highlighted = useMemo(\n () => highlightCode(code, resolvedLanguage),\n [resolvedLanguage, code],\n );\n // Size the editor to its content by line count — deterministic, no layout\n // measurement. `wrap=\"off\"` means one row per line. Long snippets collapse to\n // `cap` lines behind a \"Show N more lines\" toggle, matching the read surface\n // and the file-tree block. `maxLines` omitted ⇒ DEFAULT (40); `0` ⇒ never\n // collapse (show everything).\n const lineCount = code ? code.split(\"\\n\").length : 1;\n const cap =\n maxLines == null ? DEFAULT_CODE_MAX_LINES : maxLines > 0 ? maxLines : null;\n const collapsible = cap != null && lineCount > cap;\n const collapsed = collapsible && !expanded;\n const hiddenLines = collapsible ? lineCount - (cap as number) : 0;\n const rows = collapsed ? (cap as number) : lineCount + 1;\n const hasFilename = Boolean(filename?.trim());\n\n const syncScroll = (event: UIEvent<HTMLTextAreaElement>) => {\n const layer = highlightLayerRef.current;\n if (!layer) return;\n layer.scrollLeft = event.currentTarget.scrollLeft;\n layer.scrollTop = event.currentTarget.scrollTop;\n };\n\n const chrome = (\n <>\n <label htmlFor={selectId} className=\"sr-only\">\n Code language\n </label>\n <select\n id={selectId}\n data-plan-interactive\n disabled={!editable}\n className=\"plan-code-lang-select\"\n value={normalizeCodeLanguage(language) ? (language ?? \"\") : \"\"}\n onChange={(event) => onLanguageChange(event.target.value || undefined)}\n >\n {CODE_LANGUAGES.map((option) => (\n <option key={option.value || \"auto\"} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n {editable && (\n <CodeSettingsPopover\n filename={filename}\n maxLines={maxLines}\n onFilenameChange={onFilenameChange}\n onMaxLinesChange={onMaxLinesChange}\n />\n )}\n <CopyButton value={code} />\n </>\n );\n\n return (\n <div\n className={cn(\n \"plan-code plan-code-editing group relative\",\n !hasFilename && \"plan-code-editing--unlabeled\",\n !editable && \"opacity-60\",\n )}\n >\n {hasFilename && (\n <div className=\"plan-code-head\">\n <span className=\"plan-code-filename plan-code-muted\">\n <IconCode className=\"size-4 shrink-0 opacity-70\" />\n {filename}\n </span>\n <span className=\"plan-code-chrome\">{chrome}</span>\n </div>\n )}\n <div className=\"plan-code-editor-body\">\n <pre\n ref={highlightLayerRef}\n aria-hidden=\"true\"\n className=\"plan-code-editor-layer\"\n >\n <code>\n {highlighted}\n {code.endsWith(\"\\n\") ? \" \" : null}\n </code>\n </pre>\n <textarea\n data-plan-interactive\n spellCheck={false}\n wrap=\"off\"\n rows={Math.max(3, rows)}\n className=\"plan-code-editor-input\"\n value={code}\n disabled={!editable}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) =>\n onCodeChange(event.target.value)\n }\n onScroll={syncScroll}\n />\n {collapsed && (\n <div className=\"plan-code-editor-fade\" aria-hidden=\"true\" />\n )}\n </div>\n {!hasFilename && (\n <span className=\"plan-code-chrome plan-code-chrome-float\">\n {chrome}\n </span>\n )}\n {collapsible && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"plan-code-surface-toggle\"\n onClick={() => setExpanded((value) => !value)}\n >\n {collapsed\n ? `Show ${hiddenLines} more line${hiddenLines === 1 ? \"\" : \"s\"}`\n : \"Show less\"}\n </button>\n )}\n </div>\n );\n}\n\nfunction CodeEdit({ data, onChange, editable }: BlockEditProps<CodeData>) {\n return (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <CodeEditorSurface\n code={data.code}\n language={data.language}\n filename={data.filename}\n maxLines={data.maxLines}\n editable={editable}\n onCodeChange={(code) => onChange({ ...data, code })}\n onLanguageChange={(language) => onChange({ ...data, language })}\n onFilenameChange={(filename) => onChange({ ...data, filename })}\n onMaxLinesChange={(maxLines) => onChange({ ...data, maxLines })}\n />\n {editable && (\n <input\n type=\"text\"\n data-plan-interactive\n className=\"plan-code-caption-input\"\n placeholder=\"Caption\"\n value={data.caption ?? \"\"}\n onChange={(event) =>\n onChange({ ...data, caption: event.target.value || undefined })\n }\n />\n )}\n </div>\n );\n}\n\n/* ── Spec ──────────────────────────────────────────────────────────────────── */\n\nexport const codeBlock = defineBlock<CodeData>({\n type: \"code\",\n schema: codeSchema,\n mdx: codeMdx,\n Read: CodeRead,\n Edit: CodeEdit,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Code\",\n icon: IconCode,\n description:\n \"A single syntax-highlighted code snippet, Notion-style: one border, a hover language switcher + copy, and collapse-to-N lines. Put several in a `tabs` block for a file rail.\",\n});\n"]}
1
+ {"version":3,"file":"code.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/code.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAEtE;;;;;;;;;;GAUG;AAEH,+EAA+E;AAC/E,MAAM,cAAc,GAAoD;IACtE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;IAC5B,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC9B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK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AC/D,EACD,QAAQ,IAAI,CACX,gBACE,IAAI,EAAC,MAAM,iCAEX,SAAS,EAAC,yBAAyB,EACnC,WAAW,EAAC,SAAS,EACrB,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC,GAEjE,CACH,IACG,CACP,CAAC;AACJ,CAAC;AAED,kFAAkF;AAElF,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAW;IAC7C,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,+KAA+K;CAClL,CAAC,CAAC","sourcesContent":["import {\n useId,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ChangeEvent,\n type UIEvent,\n} from \"react\";\nimport { IconCheck, IconCode, IconCopy, IconPencil } from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../../components/ui/popover.js\";\nimport { defineBlock } from \"../types.js\";\nimport type { BlockReadProps, BlockEditProps } from \"../types.js\";\nimport { CodeSurface, DEFAULT_CODE_MAX_LINES } from \"./HighlightedCode.js\";\nimport {\n highlightCode,\n inferLanguageFromFilename,\n normalizeCodeLanguage,\n} from \"./code-highlight.js\";\nimport { CodeFilenameLabel } from \"./code-filename-label.js\";\nimport { codeSchema, codeMdx, type CodeData } from \"./code.config.js\";\n\n/**\n * Standard `code` block (STANDARD core library): THE primitive single code\n * snippet, used everywhere in plan + content. Notion-style — one border, a\n * hover-revealed language switcher + copy, and the shared collapse-to-N-lines\n * read surface. A \"file rail\" of several files is just the `tabs` primitive\n * holding `code` blocks; there is no bespoke \"code-tabs\" container.\n *\n * Read = the shared {@link CodeSurface} (Shiki, single border, language label,\n * \"Show N more lines\"). Edit = a clean, single-border editable surface (no\n * drag-to-resize; it auto-grows to its content) with the same hover chrome.\n */\n\n/** Language options for the hover switcher; \"\" is the Auto-detect sentinel. */\nconst CODE_LANGUAGES: ReadonlyArray<{ value: string; label: string }> = [\n { value: \"\", label: \"Auto\" },\n { value: \"typescript\", label: \"TypeScript\" },\n { value: \"javascript\", label: \"JavaScript\" },\n { value: \"tsx\", label: \"TSX\" },\n { value: \"jsx\", label: \"JSX\" },\n { value: \"json\", label: \"JSON\" },\n { value: \"html\", label: \"HTML\" },\n { value: \"css\", label: \"CSS\" },\n { value: \"bash\", label: \"Bash\" },\n { value: \"python\", label: \"Python\" },\n { value: \"sql\", label: \"SQL\" },\n { value: \"yaml\", label: \"YAML\" },\n { value: \"markdown\", label: \"Markdown\" },\n { value: \"graphql\", label: \"GraphQL\" },\n { value: \"go\", label: \"Go\" },\n { value: \"rust\", label: \"Rust\" },\n { value: \"diff\", label: \"Diff\" },\n];\n\nfunction CopyButton({ value }: { value: string }) {\n const [copied, setCopied] = useState(false);\n return (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n title={copied ? \"Copied\" : \"Copy code\"}\n className=\"plan-code-chip\"\n onClick={() => {\n void navigator.clipboard?.writeText(value).then(\n () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1200);\n },\n () => {},\n );\n }}\n >\n {copied ? (\n <IconCheck className=\"size-3.5\" />\n ) : (\n <IconCopy className=\"size-3.5\" />\n )}\n </button>\n );\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction CodeRead({ data, blockId }: BlockReadProps<CodeData>) {\n const language =\n normalizeCodeLanguage(data.language) ??\n inferLanguageFromFilename(data.filename) ??\n undefined;\n const hasFilename = Boolean(data.filename?.trim());\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n <div className=\"plan-code group relative\">\n {hasFilename && (\n <div className=\"plan-code-head\">\n <span className=\"plan-code-filename\">\n <IconCode className=\"size-4 shrink-0 opacity-70\" />\n <CodeFilenameLabel\n filename={data.filename}\n directoryClassName=\"text-plan-muted\"\n basenameClassName=\"text-plan-text\"\n />\n </span>\n <span className=\"plan-code-chrome\">\n <CopyButton value={data.code} />\n </span>\n </div>\n )}\n <CodeSurface\n code={data.code}\n language={language}\n maxLines={data.maxLines}\n className={data.filename ? \"mt-0\" : \"mt-0\"}\n showLanguageLabel={false}\n />\n {!hasFilename && (\n <span className=\"plan-code-chrome plan-code-chrome-float\">\n <CopyButton value={data.code} />\n </span>\n )}\n {data.caption && <p className=\"plan-code-caption\">{data.caption}</p>}\n </div>\n </section>\n );\n}\n\n/* ── Edit (single border, no resize, auto-grow, hover chrome) ──────────────── */\n\nconst SETTINGS_INPUT =\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\n/** Hover \"settings\" (pencil) → popover to edit the filename + max-lines cap. */\nfunction CodeSettingsPopover({\n filename,\n maxLines,\n onFilenameChange,\n onMaxLinesChange,\n}: {\n filename?: string;\n maxLines?: number;\n onFilenameChange: (filename: string | undefined) => void;\n onMaxLinesChange: (maxLines: number | undefined) => void;\n}) {\n const [filenameDraft, setFilenameDraft] = useState(filename ?? \"\");\n\n useEffect(() => {\n setFilenameDraft(filename ?? \"\");\n }, [filename]);\n\n const commitFilename = () => {\n const next = filenameDraft.trim();\n onFilenameChange(next || undefined);\n };\n\n return (\n <Popover>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Code block settings\"\n title=\"Code block settings\"\n className=\"plan-code-chip\"\n >\n <IconPencil className=\"size-3.5\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"end\"\n side=\"bottom\"\n className=\"w-64 p-0\"\n data-plan-interactive\n >\n <div className=\"border-b border-border px-3 py-2 text-sm font-semibold text-foreground\">\n Code block\n </div>\n <div className=\"grid gap-3 p-3\">\n <label className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n Filename\n </span>\n <input\n type=\"text\"\n data-plan-interactive\n className={SETTINGS_INPUT}\n placeholder=\"src/file.ts\"\n value={filenameDraft}\n onBlur={commitFilename}\n onChange={(event) => setFilenameDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n commitFilename();\n event.currentTarget.blur();\n }\n if (event.key === \"Escape\") {\n setFilenameDraft(filename ?? \"\");\n event.currentTarget.blur();\n }\n }}\n />\n </label>\n <label className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n Max lines before expand\n </span>\n <input\n type=\"number\"\n min={0}\n step={1}\n data-plan-interactive\n className={SETTINGS_INPUT}\n placeholder={`${DEFAULT_CODE_MAX_LINES} (default) · 0 = no limit`}\n value={maxLines ?? \"\"}\n onChange={(event) => {\n const raw = event.target.value.trim();\n const parsed = raw === \"\" ? undefined : Number(raw);\n onMaxLinesChange(\n parsed === undefined || Number.isNaN(parsed)\n ? undefined\n : Math.max(0, Math.min(2000, Math.floor(parsed))),\n );\n }}\n />\n </label>\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction CodeEditorSurface({\n code,\n language,\n filename,\n maxLines,\n editable,\n onCodeChange,\n onLanguageChange,\n onFilenameChange,\n onMaxLinesChange,\n}: {\n code: string;\n language?: string;\n filename?: string;\n maxLines?: number;\n editable: boolean;\n onCodeChange: (code: string) => void;\n onLanguageChange: (language: string | undefined) => void;\n onFilenameChange: (filename: string | undefined) => void;\n onMaxLinesChange: (maxLines: number | undefined) => void;\n}) {\n const [expanded, setExpanded] = useState(false);\n const highlightLayerRef = useRef<HTMLPreElement>(null);\n const selectId = useId();\n const resolvedLanguage =\n normalizeCodeLanguage(language) ?? inferLanguageFromFilename(filename);\n const highlighted = useMemo(\n () => highlightCode(code, resolvedLanguage),\n [resolvedLanguage, code],\n );\n // Size the editor to its content by line count — deterministic, no layout\n // measurement. `wrap=\"off\"` means one row per line. Long snippets collapse to\n // `cap` lines behind a \"Show N more lines\" toggle, matching the read surface\n // and the file-tree block. `maxLines` omitted ⇒ DEFAULT (40); `0` ⇒ never\n // collapse (show everything).\n const lineCount = code ? code.split(\"\\n\").length : 1;\n const cap =\n maxLines == null ? DEFAULT_CODE_MAX_LINES : maxLines > 0 ? maxLines : null;\n const collapsible = cap != null && lineCount > cap;\n const collapsed = collapsible && !expanded;\n const hiddenLines = collapsible ? lineCount - (cap as number) : 0;\n const rows = collapsed ? (cap as number) : lineCount + 1;\n const hasFilename = Boolean(filename?.trim());\n\n const syncScroll = (event: UIEvent<HTMLTextAreaElement>) => {\n const layer = highlightLayerRef.current;\n if (!layer) return;\n layer.scrollLeft = event.currentTarget.scrollLeft;\n layer.scrollTop = event.currentTarget.scrollTop;\n };\n\n const chrome = (\n <>\n <label htmlFor={selectId} className=\"sr-only\">\n Code language\n </label>\n <select\n id={selectId}\n data-plan-interactive\n disabled={!editable}\n className=\"plan-code-lang-select\"\n value={normalizeCodeLanguage(language) ? (language ?? \"\") : \"\"}\n onChange={(event) => onLanguageChange(event.target.value || undefined)}\n >\n {CODE_LANGUAGES.map((option) => (\n <option key={option.value || \"auto\"} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n {editable && (\n <CodeSettingsPopover\n filename={filename}\n maxLines={maxLines}\n onFilenameChange={onFilenameChange}\n onMaxLinesChange={onMaxLinesChange}\n />\n )}\n <CopyButton value={code} />\n </>\n );\n\n return (\n <div\n className={cn(\n \"plan-code plan-code-editing group relative\",\n !hasFilename && \"plan-code-editing--unlabeled\",\n !editable && \"opacity-60\",\n )}\n >\n {hasFilename && (\n <div className=\"plan-code-head\">\n <span className=\"plan-code-filename plan-code-muted\">\n <IconCode className=\"size-4 shrink-0 opacity-70\" />\n <CodeFilenameLabel\n filename={filename}\n directoryClassName=\"text-plan-muted\"\n basenameClassName=\"text-plan-text\"\n />\n </span>\n <span className=\"plan-code-chrome\">{chrome}</span>\n </div>\n )}\n <div className=\"plan-code-editor-body\">\n <pre\n ref={highlightLayerRef}\n aria-hidden=\"true\"\n className=\"plan-code-editor-layer\"\n >\n <code>\n {highlighted}\n {code.endsWith(\"\\n\") ? \" \" : null}\n </code>\n </pre>\n <textarea\n data-plan-interactive\n spellCheck={false}\n wrap=\"off\"\n rows={Math.max(3, rows)}\n className=\"plan-code-editor-input\"\n value={code}\n disabled={!editable}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) =>\n onCodeChange(event.target.value)\n }\n onScroll={syncScroll}\n />\n {collapsed && (\n <div className=\"plan-code-editor-fade\" aria-hidden=\"true\" />\n )}\n </div>\n {!hasFilename && (\n <span className=\"plan-code-chrome plan-code-chrome-float\">\n {chrome}\n </span>\n )}\n {collapsible && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"plan-code-surface-toggle\"\n onClick={() => setExpanded((value) => !value)}\n >\n {collapsed\n ? `Show ${hiddenLines} more line${hiddenLines === 1 ? \"\" : \"s\"}`\n : \"Show less\"}\n </button>\n )}\n </div>\n );\n}\n\nfunction CodeEdit({ data, onChange, editable }: BlockEditProps<CodeData>) {\n return (\n <div className=\"flex min-w-0 flex-col gap-2\">\n <CodeEditorSurface\n code={data.code}\n language={data.language}\n filename={data.filename}\n maxLines={data.maxLines}\n editable={editable}\n onCodeChange={(code) => onChange({ ...data, code })}\n onLanguageChange={(language) => onChange({ ...data, language })}\n onFilenameChange={(filename) => onChange({ ...data, filename })}\n onMaxLinesChange={(maxLines) => onChange({ ...data, maxLines })}\n />\n {editable && (\n <input\n type=\"text\"\n data-plan-interactive\n className=\"plan-code-caption-input\"\n placeholder=\"Caption\"\n value={data.caption ?? \"\"}\n onChange={(event) =>\n onChange({ ...data, caption: event.target.value || undefined })\n }\n />\n )}\n </div>\n );\n}\n\n/* ── Spec ──────────────────────────────────────────────────────────────────── */\n\nexport const codeBlock = defineBlock<CodeData>({\n type: \"code\",\n schema: codeSchema,\n mdx: codeMdx,\n Read: CodeRead,\n Edit: CodeEdit,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Code\",\n icon: IconCode,\n description:\n \"A single syntax-highlighted code snippet, Notion-style: one border, a hover language switcher + copy, and collapse-to-N lines. Put several in a `tabs` block for a file rail.\",\n});\n"]}
@@ -42,7 +42,7 @@ export interface DiffData {
42
42
  before: string;
43
43
  /** New ("after") source. */
44
44
  after: string;
45
- /** Layout: unified (default, one column) or split (side-by-side). */
45
+ /** Layout: split (default, side-by-side) or unified (one column). */
46
46
  mode?: DiffMode;
47
47
  /** Line-anchored notes over the before/after sides. */
48
48
  annotations?: DiffAnnotation[];
@@ -1 +1 @@
1
- {"version":3,"file":"diff.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/diff.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsDxB;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,KAAK,CAAC,oBAAoB,EAAE;IAC3B,OAAO,EAAE,oDAAoD;CAC9D,CAAC;KACD,GAAG,CAAC,EAAE,CAAC,CAAC;AAEX,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5C,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EA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,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QAClC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAyB;QAClD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QACpC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAClC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAiB,aAAa,CAAC,IAAI,EAAE;KAC9D,CAAC;CACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BlockMdxConfig } from \"../types.js\";\n\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC diff block: its data schema and MDX\n * round-trip config. Shared by the server MDX adapter (`plan-mdx.ts` via\n * `plan-block-registry.ts`) and the client spec (`planBlocks.tsx`). Keeping this\n * React-free means importing it into a server module never pulls React (or the\n * `diff` line-differ used only by the renderer) into the Nitro/SSR bundle.\n *\n * The schema MUST stay data-compatible with the `diff` branch of `planBlockSchema`\n * (`plan-content.ts`), and the MDX `tag` + flat attribute shape MUST match the\n * `<Diff filename language mode before after />` self-closing encoding so stored\n * `.mdx` round-trips. The `before`/`after` source lives in ATTRIBUTES (not MDX\n * children) — the shared `prop()` encoder round-trips multiline strings cleanly,\n * and keeping them attributes avoids the code being reflowed as prose.\n */\n\n/** Rendering layout for the diff body. */\nexport type DiffMode = \"unified\" | \"split\";\n\n/**\n * One line-anchored note attached to a diff, mirroring the `annotated-code`\n * annotation shape but adding `side`. The `lines` ref is 1-based against the\n * chosen side's source: `side: \"after\"` (the default) targets the new file's\n * line numbers, `side: \"before\"` the old file's. Optional ⇒ a diff without\n * annotations renders exactly as before.\n */\nexport interface DiffAnnotation {\n /** Which side the line ref targets; defaults to \"after\". */\n side?: \"before\" | \"after\";\n /** 1-based line ref against that side's text: \"13\" or \"13-15\" (inclusive). */\n lines: string;\n /** Optional short label shown before the note (e.g. \"Validation\"). */\n label?: string;\n /** The note prose (markdown), rendered through `ctx.renderMarkdown`. */\n note: string;\n}\n\nexport interface DiffData {\n /** Optional file path shown in the header (e.g. `src/add.ts`). */\n filename?: string;\n /** Optional language label rendered as a chip (e.g. `ts`). Purely cosmetic. */\n language?: string;\n /** Original (\"before\") source. */\n before: string;\n /** New (\"after\") source. */\n after: string;\n /** Layout: unified (default, one column) or split (side-by-side). */\n mode?: DiffMode;\n /** Line-anchored notes over the before/after sides. */\n annotations?: DiffAnnotation[];\n}\n\n/**\n * A 1-based line reference: `\"3\"` or `\"3-5\"` (inclusive). Whitespace tolerant.\n * Matches the `annotated-code` line-ref schema so both blocks validate refs\n * identically.\n */\nconst lineRefSchema = z\n .string()\n .trim()\n .regex(/^\\d+(\\s*-\\s*\\d+)?$/, {\n message: 'lines must be a 1-based line ref like \"3\" or \"3-5\"',\n })\n .max(40);\n\nconst diffAnnotationSchema = z.object({\n side: z.enum([\"before\", \"after\"]).optional(),\n lines: lineRefSchema,\n label: z.string().trim().max(160).optional(),\n note: z.string().trim().min(1).max(4_000),\n}) as z.ZodType<DiffAnnotation>;\n\nexport const diffSchema = z.object({\n filename: z.string().trim().max(400).optional(),\n language: z.string().trim().max(40).optional(),\n before: z.string().max(100_000),\n after: z.string().max(100_000),\n mode: z.enum([\"unified\", \"split\"]).optional(),\n annotations: z.array(diffAnnotationSchema).max(80).optional(),\n}) as unknown as z.ZodType<DiffData>;\n\n/**\n * MDX config: `filename`, `language`, `mode`, `before`, `after`, and\n * `annotations` are flat attributes — the\n * `<Diff id … filename language mode before after annotations />` self-closing\n * form. Insertion order of `toAttrs` is the on-disk attribute order. `before`/\n * `after` are multiline string attributes (round-trip through the shared `prop()`\n * encoder); `annotations` is a JSON array attribute, encoded the same way as the\n * `annotated-code` block. `fromAttrs` mirrors a forgiving parse (`before ?? \"\"`,\n * `after ?? \"\"`, `annotations ?? []`, optional `filename`/`language`/`mode`\n * undefined when absent) so a plan missing an attribute still parses.\n */\nexport const diffMdx: BlockMdxConfig<DiffData> = {\n tag: \"Diff\",\n toAttrs: (data) => ({\n filename: data.filename,\n language: data.language,\n mode: data.mode,\n before: data.before,\n after: data.after,\n annotations: data.annotations,\n }),\n fromAttrs: (attrs) => ({\n filename: attrs.string(\"filename\"),\n language: attrs.string(\"language\"),\n mode: attrs.string(\"mode\") as DiffMode | undefined,\n before: attrs.string(\"before\") ?? \"\",\n after: attrs.string(\"after\") ?? \"\",\n annotations: attrs.array<DiffAnnotation>(\"annotations\") ?? [],\n }),\n};\n"]}
1
+ {"version":3,"file":"diff.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/diff.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsDxB;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,IAAI,EAAE;KACN,KAAK,CAAC,oBAAoB,EAAE;IAC3B,OAAO,EAAE,oDAAoD;CAC9D,CAAC;KACD,GAAG,CAAC,EAAE,CAAC,CAAC;AAEX,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5C,KAAK,EAAE,aAAa;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;CAC1C,CAA8B,CAAC;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC/C,QAAQ,EAAE,C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Aa,CAAC,IAAI,EAAE;KAC9D,CAAC;CACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BlockMdxConfig } from \"../types.js\";\n\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC diff block: its data schema and MDX\n * round-trip config. Shared by the server MDX adapter (`plan-mdx.ts` via\n * `plan-block-registry.ts`) and the client spec (`planBlocks.tsx`). Keeping this\n * React-free means importing it into a server module never pulls React (or the\n * `diff` line-differ used only by the renderer) into the Nitro/SSR bundle.\n *\n * The schema MUST stay data-compatible with the `diff` branch of `planBlockSchema`\n * (`plan-content.ts`), and the MDX `tag` + flat attribute shape MUST match the\n * `<Diff filename language mode before after />` self-closing encoding so stored\n * `.mdx` round-trips. The `before`/`after` source lives in ATTRIBUTES (not MDX\n * children) — the shared `prop()` encoder round-trips multiline strings cleanly,\n * and keeping them attributes avoids the code being reflowed as prose.\n */\n\n/** Rendering layout for the diff body. */\nexport type DiffMode = \"unified\" | \"split\";\n\n/**\n * One line-anchored note attached to a diff, mirroring the `annotated-code`\n * annotation shape but adding `side`. The `lines` ref is 1-based against the\n * chosen side's source: `side: \"after\"` (the default) targets the new file's\n * line numbers, `side: \"before\"` the old file's. Optional ⇒ a diff without\n * annotations renders exactly as before.\n */\nexport interface DiffAnnotation {\n /** Which side the line ref targets; defaults to \"after\". */\n side?: \"before\" | \"after\";\n /** 1-based line ref against that side's text: \"13\" or \"13-15\" (inclusive). */\n lines: string;\n /** Optional short label shown before the note (e.g. \"Validation\"). */\n label?: string;\n /** The note prose (markdown), rendered through `ctx.renderMarkdown`. */\n note: string;\n}\n\nexport interface DiffData {\n /** Optional file path shown in the header (e.g. `src/add.ts`). */\n filename?: string;\n /** Optional language label rendered as a chip (e.g. `ts`). Purely cosmetic. */\n language?: string;\n /** Original (\"before\") source. */\n before: string;\n /** New (\"after\") source. */\n after: string;\n /** Layout: split (default, side-by-side) or unified (one column). */\n mode?: DiffMode;\n /** Line-anchored notes over the before/after sides. */\n annotations?: DiffAnnotation[];\n}\n\n/**\n * A 1-based line reference: `\"3\"` or `\"3-5\"` (inclusive). Whitespace tolerant.\n * Matches the `annotated-code` line-ref schema so both blocks validate refs\n * identically.\n */\nconst lineRefSchema = z\n .string()\n .trim()\n .regex(/^\\d+(\\s*-\\s*\\d+)?$/, {\n message: 'lines must be a 1-based line ref like \"3\" or \"3-5\"',\n })\n .max(40);\n\nconst diffAnnotationSchema = z.object({\n side: z.enum([\"before\", \"after\"]).optional(),\n lines: lineRefSchema,\n label: z.string().trim().max(160).optional(),\n note: z.string().trim().min(1).max(4_000),\n}) as z.ZodType<DiffAnnotation>;\n\nexport const diffSchema = z.object({\n filename: z.string().trim().max(400).optional(),\n language: z.string().trim().max(40).optional(),\n before: z.string().max(100_000),\n after: z.string().max(100_000),\n mode: z.enum([\"unified\", \"split\"]).optional(),\n annotations: z.array(diffAnnotationSchema).max(80).optional(),\n}) as unknown as z.ZodType<DiffData>;\n\n/**\n * MDX config: `filename`, `language`, `mode`, `before`, `after`, and\n * `annotations` are flat attributes — the\n * `<Diff id … filename language mode before after annotations />` self-closing\n * form. Insertion order of `toAttrs` is the on-disk attribute order. `before`/\n * `after` are multiline string attributes (round-trip through the shared `prop()`\n * encoder); `annotations` is a JSON array attribute, encoded the same way as the\n * `annotated-code` block. `fromAttrs` mirrors a forgiving parse (`before ?? \"\"`,\n * `after ?? \"\"`, `annotations ?? []`, optional `filename`/`language`/`mode`\n * undefined when absent) so a plan missing an attribute still parses.\n */\nexport const diffMdx: BlockMdxConfig<DiffData> = {\n tag: \"Diff\",\n toAttrs: (data) => ({\n filename: data.filename,\n language: data.language,\n mode: data.mode,\n before: data.before,\n after: data.after,\n annotations: data.annotations,\n }),\n fromAttrs: (attrs) => ({\n filename: attrs.string(\"filename\"),\n language: attrs.string(\"language\"),\n mode: attrs.string(\"mode\") as DiffMode | undefined,\n before: attrs.string(\"before\") ?? \"\",\n after: attrs.string(\"after\") ?? \"\",\n annotations: attrs.array<DiffAnnotation>(\"annotations\") ?? [],\n }),\n};\n"]}
@@ -1,11 +1,11 @@
1
1
  import { type ReactNode } from "react";
2
- /** True when the current block renders inside a tab panel or a column cell. */
2
+ /** True when the current block renders inside a constrained tab/column cell. */
3
3
  export declare function useInNarrowContainer(): boolean;
4
4
  /**
5
5
  * Marks its subtree as living inside a width-constrained container. Wrap the
6
- * children a `tabs`/`columns` block renders so nested width-sensitive blocks can
7
- * pick a container-appropriate default. Idempotent: nesting the provider keeps
8
- * the flag `true`.
6
+ * children a vertical `tabs` or `columns` block renders so nested
7
+ * width-sensitive blocks can pick a container-appropriate default. Idempotent:
8
+ * nesting the provider keeps the flag `true`.
9
9
  */
10
10
  export declare function NarrowContainerProvider({ children }: {
11
11
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"narrow-container.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/narrow-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBlE,+EAA+E;AAC/E,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAM5E"}
1
+ {"version":3,"file":"narrow-container.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/narrow-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBlE,gFAAgF;AAChF,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAM5E"}
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext } from "react";
3
3
  /**
4
- * Flags that a block is rendered inside a WIDTH-CONSTRAINED container — a `tabs`
5
- * tab panel or a `columns`/`Column` cell. Width-sensitive blocks (today the
6
- * `diff` block) read this to pick a default layout that survives the narrower
7
- * box: e.g. a diff with NO authored `mode` defaults to `unified` inside one of
8
- * these containers instead of `split`, whose doubled line-number gutters crush
9
- * the code in a half-width or vertical-tab column.
4
+ * Flags that a block is rendered inside a WIDTH-CONSTRAINED container — a
5
+ * vertical `tabs` side rail or a `columns`/`Column` cell. Width-sensitive blocks
6
+ * (today the `diff` block) read this to pick a default layout that survives the
7
+ * narrower box: e.g. a diff with NO authored `mode` defaults to `unified` inside
8
+ * one of these containers instead of `split`, whose doubled line-number gutters
9
+ * crush the code in a half-width or vertical-tab column.
10
10
  *
11
11
  * It only nudges the DEFAULT. An explicitly authored mode (`mode="split"`) still
12
12
  * wins, and the in-block Unified/Split toggle still works in either context —
@@ -16,15 +16,15 @@ import { createContext, useContext } from "react";
16
16
  * the consumers (`DiffBlock`) share one source of truth without a new dep.
17
17
  */
18
18
  const NarrowContainerContext = createContext(false);
19
- /** True when the current block renders inside a tab panel or a column cell. */
19
+ /** True when the current block renders inside a constrained tab/column cell. */
20
20
  export function useInNarrowContainer() {
21
21
  return useContext(NarrowContainerContext);
22
22
  }
23
23
  /**
24
24
  * Marks its subtree as living inside a width-constrained container. Wrap the
25
- * children a `tabs`/`columns` block renders so nested width-sensitive blocks can
26
- * pick a container-appropriate default. Idempotent: nesting the provider keeps
27
- * the flag `true`.
25
+ * children a vertical `tabs` or `columns` block renders so nested
26
+ * width-sensitive blocks can pick a container-appropriate default. Idempotent:
27
+ * nesting the provider keeps the flag `true`.
28
28
  */
29
29
  export function NarrowContainerProvider({ children }) {
30
30
  return (_jsx(NarrowContainerContext.Provider, { value: true, children: children }));
@@ -1 +1 @@
1
- {"version":3,"file":"narrow-container.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/narrow-container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,MAAM,sBAAsB,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,UAAU,oBAAoB;IAClC,OAAO,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAE,QAAQ,EAA2B;IAC3E,OAAO,CACL,KAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YACzC,QAAQ,GACuB,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\n\n/**\n * Flags that a block is rendered inside a WIDTH-CONSTRAINED container — a `tabs`\n * tab panel or a `columns`/`Column` cell. Width-sensitive blocks (today the\n * `diff` block) read this to pick a default layout that survives the narrower\n * box: e.g. a diff with NO authored `mode` defaults to `unified` inside one of\n * these containers instead of `split`, whose doubled line-number gutters crush\n * the code in a half-width or vertical-tab column.\n *\n * It only nudges the DEFAULT. An explicitly authored mode (`mode=\"split\"`) still\n * wins, and the in-block Unified/Split toggle still works in either context —\n * this never disables side-by-side, it just changes what you get before you pick.\n *\n * Lives in core beside the blocks so both the containers (`tabs`, `columns`) and\n * the consumers (`DiffBlock`) share one source of truth without a new dep.\n */\nconst NarrowContainerContext = createContext(false);\n\n/** True when the current block renders inside a tab panel or a column cell. */\nexport function useInNarrowContainer(): boolean {\n return useContext(NarrowContainerContext);\n}\n\n/**\n * Marks its subtree as living inside a width-constrained container. Wrap the\n * children a `tabs`/`columns` block renders so nested width-sensitive blocks can\n * pick a container-appropriate default. Idempotent: nesting the provider keeps\n * the flag `true`.\n */\nexport function NarrowContainerProvider({ children }: { children: ReactNode }) {\n return (\n <NarrowContainerContext.Provider value={true}>\n {children}\n </NarrowContainerContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"narrow-container.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/narrow-container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,MAAM,sBAAsB,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAEpD,gFAAgF;AAChF,MAAM,UAAU,oBAAoB;IAClC,OAAO,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAE,QAAQ,EAA2B;IAC3E,OAAO,CACL,KAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YACzC,QAAQ,GACuB,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\n\n/**\n * Flags that a block is rendered inside a WIDTH-CONSTRAINED container — a\n * vertical `tabs` side rail or a `columns`/`Column` cell. Width-sensitive blocks\n * (today the `diff` block) read this to pick a default layout that survives the\n * narrower box: e.g. a diff with NO authored `mode` defaults to `unified` inside\n * one of these containers instead of `split`, whose doubled line-number gutters\n * crush the code in a half-width or vertical-tab column.\n *\n * It only nudges the DEFAULT. An explicitly authored mode (`mode=\"split\"`) still\n * wins, and the in-block Unified/Split toggle still works in either context —\n * this never disables side-by-side, it just changes what you get before you pick.\n *\n * Lives in core beside the blocks so both the containers (`tabs`, `columns`) and\n * the consumers (`DiffBlock`) share one source of truth without a new dep.\n */\nconst NarrowContainerContext = createContext(false);\n\n/** True when the current block renders inside a constrained tab/column cell. */\nexport function useInNarrowContainer(): boolean {\n return useContext(NarrowContainerContext);\n}\n\n/**\n * Marks its subtree as living inside a width-constrained container. Wrap the\n * children a vertical `tabs` or `columns` block renders so nested\n * width-sensitive blocks can pick a container-appropriate default. Idempotent:\n * nesting the provider keeps the flag `true`.\n */\nexport function NarrowContainerProvider({ children }: { children: ReactNode }) {\n return (\n <NarrowContainerContext.Provider value={true}>\n {children}\n </NarrowContainerContext.Provider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/tabs.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,kBAAkB,CAAC;AAwG1B,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAyC1B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAgM1B;AAuLD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,2CA0BpB,CAAC"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/tabs.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,kBAAkB,CAAC;AAwG1B,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAsD1B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAgM1B;AAuLD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,2CA0BpB,CAAC"}
@@ -66,11 +66,16 @@ export function TabsBlockReader({ data, blockId, title, ctx, }) {
66
66
  const orientation = tabOrientation(data);
67
67
  const vertical = orientation === "vertical";
68
68
  return (_jsxs("section", { className: "plan-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsx("div", { className: cn(vertical && "@container/tabs"), children: _jsxs("div", { className: cn(vertical &&
69
- "grid min-w-0 gap-5 @xl/tabs:grid-cols-[minmax(10rem,14rem)_minmax(0,1fr)] @xl/tabs:items-start"), children: [_jsx(TabRail, { tabs: data.tabs, activeId: active?.id, onSelect: setActiveId, orientation: orientation }), active && (_jsx(NarrowContainerProvider, { children: _jsx("div", { className: cn(vertical && "min-w-0"), children: active.blocks.map((child) => (_jsx("div", { children: ctx.renderBlock?.({
69
+ "grid min-w-0 gap-5 @xl/tabs:grid-cols-[minmax(10rem,14rem)_minmax(0,1fr)] @xl/tabs:items-start"), children: [_jsx(TabRail, { tabs: data.tabs, activeId: active?.id, onSelect: setActiveId, orientation: orientation }), active &&
70
+ (vertical ? (_jsx(NarrowContainerProvider, { children: _jsx("div", { className: "min-w-0", children: active.blocks.map((child) => (_jsx("div", { children: ctx.renderBlock?.({
71
+ block: child,
72
+ editing: false,
73
+ compactVisuals: compact,
74
+ }) }, child.id))) }) })) : (_jsx("div", { children: active.blocks.map((child) => (_jsx("div", { children: ctx.renderBlock?.({
70
75
  block: child,
71
76
  editing: false,
72
77
  compactVisuals: compact,
73
- }) }, child.id))) }) }))] }) })] }));
78
+ }) }, child.id))) })))] }) })] }));
74
79
  }
75
80
  /**
76
81
  * Editor: pill tabs plus tab management (add/remove/rename), with child blocks