Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

542 B
Raw Blame
import type { MarkdownNode } from "react-native-nitro-markdown/headless";

export function nodeKey(node: MarkdownNode, index: number): string {
  return `${node.type}:${node.beg ?? index}:${node.end ?? index}`;
}

export function nodeText(node: MarkdownNode): string {
  if (node.content !== undefined) {
    return node.content;
  }

  return (node.children ?? []).map(nodeText).join("");
}

export function documentFor(node: MarkdownNode): MarkdownNode {
  return node.type === "document" ? node : { type: "document", children: [node] };
}