paseo-plugin-mermaid 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.client.tsx CHANGED
@@ -47,7 +47,7 @@ export default function contribute(client: PluginClientContext) {
47
47
  client.addTimelineTransformer({
48
48
  id: "mermaid-assistant",
49
49
  query: { itemType: "assistant_message" },
50
- transform: ({ item, phase }) => split(item.text, phase, { hostMarkdown: hostMarkdownAvailable, skew: canSkew }),
50
+ transform: ({ item, phase }) => split(item.text, phase, { hostMarkdown: hostMarkdownAvailable, skew: canSkew, deferToGenerativeUi: true }),
51
51
  });
52
52
  client.addTimelineTransformer({
53
53
  id: "mermaid-user",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-mermaid",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Render Mermaid diagrams inside the Paseo chat timeline",
5
5
  "license": "MIT",
6
6
  "author": "dutchakdev",
@@ -28,16 +28,16 @@
28
28
  "@getpaseo/client": "0.13.2",
29
29
  "@getpaseo/plugin": "0.13.2",
30
30
  "@getpaseo/protocol": "0.13.2",
31
- "@tanstack/react-query": "^5.90.11",
31
+ "@tanstack/react-query": "^5.107.1",
32
32
  "@types/node": "22.20.5",
33
33
  "@types/react": "~19.2.0",
34
34
  "react": "19.1.0",
35
35
  "react-native": "0.81.5",
36
- "semver": "7.8.5",
36
+ "semver": "7.8.6",
37
37
  "tsx": "^4.23.13",
38
38
  "typescript": "^7.0.2",
39
- "vite": "^8.3.5",
40
- "vitest": "^5.0.5",
39
+ "vite": "^8.3.8",
40
+ "vitest": "^5.1.0",
41
41
  "zod": "^4.4.3"
42
42
  },
43
43
  "files": [
package/shared/segment.ts CHANGED
@@ -42,7 +42,7 @@ type Block =
42
42
  * marker gets that right. Every line lands in exactly one block, as written, so the
43
43
  * blocks put back together give the message.
44
44
  */
45
- function fenceBlocks(text: string): Block[] {
45
+ export function fenceBlocks(text: string): Block[] {
46
46
  const blocks: Block[] = [];
47
47
  let lines: string[] = [];
48
48
  let fence: Extract<Block, { kind: "fence" }> | null = null;
@@ -2,7 +2,7 @@ import type { PluginTimelineItem } from "@getpaseo/plugin";
2
2
  import { classicShapes } from "./classic-shapes";
3
3
  import { drawable } from "./drawable";
4
4
  import { mermaidFence } from "./fence";
5
- import { mapMermaidSources, type Segment, segmentMessage } from "./segment";
5
+ import { fenceBlocks, mapMermaidSources, type Segment, segmentMessage } from "./segment";
6
6
 
7
7
  type MermaidSegment = Extract<Segment, { kind: "mermaid" }>;
8
8
 
@@ -17,6 +17,7 @@ export interface SplitOptions {
17
17
  * own text item. Off by default, which leaves such a message to Paseo.
18
18
  */
19
19
  hostMarkdown?: boolean;
20
+ deferToGenerativeUi?: boolean;
20
21
  /** Whether the app can shear a View; see `DrawableOptions`. True by default. */
21
22
  skew?: boolean;
22
23
  }
@@ -34,6 +35,14 @@ export function split(
34
35
  ): { items: PluginTimelineItem[] } | undefined {
35
36
  const hostMarkdown = options.hostMarkdown ?? false;
36
37
  const judge = { skew: options.skew ?? true };
38
+ // A ```ui/```app fence belongs to a live-UI renderer (genui). Paseo offers the
39
+ // message to transformers first-wins in plugin-name order and mermaid sorts
40
+ // before genui, so claiming a reply that carries one would show the widgets
41
+ // as code. Leave the whole message to the chain; genui draws the mermaid
42
+ // fences inside its Diagram components itself.
43
+ if (hostMarkdown && options.deferToGenerativeUi && fenceBlocks(text).some(
44
+ (block) => block.kind === "fence" && (block.language === "ui" || block.language === "app"),
45
+ )) return undefined;
37
46
  const segments = segmentMessage(text);
38
47
  // Leave the entry alone unless there is a diagram to draw: Paseo renders
39
48
  // ordinary Markdown better than this plugin does.