-
Notifications
You must be signed in to change notification settings - Fork 0
Overhaul docs IA, ship AGENTS.md for bundled docs, add eval harness #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1ab770d
Improve docs UX with /docs landing, agent .md, and live components
KayleeWilliams d91e7b7
Restructure docs around two hero paths and add concept layer
KayleeWilliams 26fbb7b
Style Steps as connected numbered circles
KayleeWilliams 69e5148
Tighten Steps typography and align title with circle
KayleeWilliams 71c9da5
Drop Package manager legend from CommandTabs
KayleeWilliams 66fc08b
Append charset=utf-8 to text/markdown responses
KayleeWilliams e7239c7
Document charset=utf-8 requirement in Connect a docs site
KayleeWilliams 05174ee
Inline reference code instead of pointing at apps/example
KayleeWilliams ac4711b
Ship AGENTS.md instead of llms.txt for npm-bundled docs
KayleeWilliams be8b4a6
Replace agent-eval with custom AI SDK eval harness
KayleeWilliams 86eec4e
Address code review feedback (8 fixes)
KayleeWilliams 680cca8
Replace dynamic fs import in archiveTranscript with top-level imports
KayleeWilliams fd59e7e
Ignore generated package docs
KayleeWilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,132 +1,88 @@ | ||
| # leadtype | ||
|
|
||
| Shared docs tooling for any docs app: framework-neutral MDX-to-markdown conversion, LLM bundles, validation, and static search. | ||
| A docs pipeline. Write MDX once. Get a website for humans, an `llms.txt` for HTTP agents, an `AGENTS.md`-fronted bundle for offline coding agents, and a static search index — all from a single source. | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| src["docs/*.mdx"] | ||
| site_run["leadtype generate"] | ||
| bundle_run["leadtype generate --bundle"] | ||
| site_out["public/<br/>llms.txt · llms-full/<br/>docs/*.md · search-index.json"] | ||
| bundle_out["packages/<name>/<br/>AGENTS.md · docs/*.md"] | ||
| humans["humans (browser)"] | ||
| http_agents["HTTP agents<br/>(/llms.txt or<br/>Accept: text/markdown)"] | ||
| search["search UI · AI answers"] | ||
| offline_agents["coding agents<br/>(Claude Code, Codex, Cursor,<br/>Copilot…) read<br/>node_modules/<pkg>/AGENTS.md"] | ||
| src --> site_run | ||
| src --> bundle_run | ||
| site_run --> site_out | ||
| bundle_run --> bundle_out | ||
| site_out --> humans | ||
| site_out --> http_agents | ||
| site_out --> search | ||
| bundle_out --> offline_agents | ||
| ``` | ||
|
|
||
| leadtype is **not a docs website framework**. Bring your own UI — Next.js, TanStack Start, Astro, anything — and let leadtype handle conversion, validation, search, and the agent-facing outputs that website frameworks don't ship. | ||
|
|
||
| `leadtype` is split into focused public entry points: | ||
| ## Choose your path | ||
|
|
||
| - `leadtype/remark`: remark plugins plus `defaultRemarkPlugins` | ||
| - `leadtype/convert`: MDX-to-markdown conversion APIs | ||
| - `leadtype/llm`: `llms.txt` and topic-scoped full-context generation | ||
| - `leadtype/search`: search runtime, content readers, guards, and rate limiter helpers | ||
| - `leadtype/search/node`: Node-only search index generation | ||
| - `leadtype/search/vercel`: Vercel AI Gateway / AI SDK answer streaming and bash tools | ||
| - `leadtype/search/tanstack`: TanStack AI answer streaming and bash tools | ||
| - `leadtype/search/cloudflare`: Cloudflare AI Gateway / Workers AI adapter helpers and bash tools | ||
| - `leadtype/lint`: docs validation and the `leadtype lint` CLI | ||
| - **[Build a docs site](https://docs.example.com/docs/build/connect-docs-site)** — wire leadtype into your build to convert MDX, index search, and serve markdown to agents. | ||
| - **[Bundle docs into your package](https://docs.example.com/docs/build/bundle-package-docs)** — ship `AGENTS.md` plus topic markdown inside the npm tarball so coding agents auto-discover them from `node_modules/<your-package>/AGENTS.md`. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| pnpm add leadtype | ||
| ``` | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| ### Own MDX components in your app | ||
|
|
||
| `leadtype` does not export prebuilt React, Vue, Nuxt, Svelte, or Astro components. Define the MDX component map in the docs app that renders your pages. | ||
|
|
||
| ## Live Example App | ||
| ## 30-second example | ||
|
|
||
| The repo includes a canonical consumer demo at `apps/example`. | ||
|
|
||
| - Renders real `.mdx` fixture files through app-owned `mdxComponents`. | ||
| - Uses TanStack Start for SSR and hydration coverage. | ||
| - Shows extracted `ExtractedTypeTable` output while keeping pipeline fixtures in the validation path. | ||
|
|
||
| Local workflow: | ||
| For a hosted docs site: | ||
|
|
||
| ```bash | ||
| bun install | ||
| bun run dev | ||
| npx leadtype generate --src . --out public --base-url https://docs.example.com | ||
| ``` | ||
|
|
||
| Pipeline and browser checks: | ||
| For an npm-bundled doc set: | ||
|
|
||
| ```bash | ||
| bun run --filter example pipeline:build | ||
| bun run --filter example pipeline:test | ||
| bun run --filter example test:e2e | ||
| npx leadtype generate --bundle --src . --out packages/my-package | ||
| ``` | ||
|
|
||
| Validation layers: | ||
|
|
||
| - Package unit tests in `packages/leadtype/src/**/*.test.ts*` cover framework-neutral conversion, search, linting, and generated docs behavior. | ||
| - Pipeline fixtures in `apps/example/scripts` and `apps/example/content` cover MDX conversion, LLM generation, and `ExtractedTypeTable`. | ||
| - The TanStack Start demo app in `apps/example/src` covers real browser rendering and hydration. | ||
|
|
||
| ## Where This Fits | ||
| The first produces `public/llms.txt`, `public/docs/llms-full/*.txt`, `public/docs/search-index.json`, and `public/docs/*.md`. The second produces `packages/my-package/AGENTS.md` and `packages/my-package/docs/*.md` — auto-discoverable by [25+ coding agents](https://agents.md) once the package is installed. | ||
|
|
||
| `leadtype` is not a hosted docs platform or a complete docs-site framework. Use tools such as Mintlify, Fumadocs, or Starlight when the primary job is shipping a polished docs website quickly. | ||
| ## Documentation | ||
|
|
||
| Use this package when the primary job is shared docs infrastructure: MDX-to-markdown conversion, LLM bundles, linting, static search artifacts, answer helpers, and agent-facing docs output that can feed multiple apps and tools. | ||
| Full docs at [docs.example.com](https://docs.example.com/docs): | ||
|
|
||
| The pipeline entry points are framework-neutral. React, Vue, Nuxt, Svelte, Astro, and other stacks can use conversion, LLM, lint, and search APIs while owning their own runtime component rendering. | ||
| - [Quickstart](https://docs.example.com/docs/quickstart) | ||
| - [How it works](https://docs.example.com/docs/how-it-works) | ||
| - [Frontmatter](https://docs.example.com/docs/authoring/frontmatter) | ||
| - [CLI reference](https://docs.example.com/docs/reference/cli) | ||
| - [Methodology](https://docs.example.com/docs/methodology) — how leadtype differs from Fumadocs, Starlight, and Mintlify | ||
|
|
||
| ## Wiring It Into An App | ||
| ## Repo layout | ||
|
|
||
| In a c15t-style repo with a top-level `docs/` directory, wire `leadtype` into the docs app and docs scripts: | ||
| - `packages/leadtype/` — the npm package (CLI + library entry points). | ||
| - `apps/example/` — production docs site and reference template, on TanStack Start. | ||
| - `docs/` — the source MDX rendered by both this site and the package's bundled docs. | ||
|
|
||
| - The docs app owns `mdxComponents` if it renders MDX directly. | ||
| - A conversion script runs `convertAllMdx({ srcDir: process.cwd(), outDir: "public" })`. | ||
| - LLM and search scripts read the converted markdown under `public/docs/`. | ||
| - Product code does not import `leadtype` unless it also renders docs pages. | ||
|
|
||
| ### Convert MDX to markdown | ||
|
|
||
| ```ts | ||
| import { convertAllMdx } from "leadtype/convert"; | ||
| import { defaultRemarkPlugins, remarkInclude } from "leadtype/remark"; | ||
|
|
||
| await convertAllMdx({ | ||
| srcDir: "content", | ||
| outDir: "public", | ||
| remarkPlugins: [remarkInclude, ...defaultRemarkPlugins], | ||
| }); | ||
| ``` | ||
|
|
||
| ### Generate agent-facing docs bundles | ||
|
|
||
| ```ts | ||
| import { generateLLMFullContextFiles, generateLlmsTxt } from "leadtype/llm"; | ||
| ``` | ||
|
|
||
| Source MDX for the package's own docs lives at the repo root in `/docs` (with `meta.json`). Run the docs generator locally with: | ||
| ## Local workflow | ||
|
|
||
| ```bash | ||
| LEADTYPE_AGENT_BASE_URL=https://docs.example.com/leadtype bun run --filter leadtype docs:generate | ||
| bun install | ||
| bun run dev # build the package, run the pipeline, start the example app | ||
| ``` | ||
|
|
||
| This converts `/docs/*.mdx` into `packages/leadtype/docs/` (markdown, `llms.txt`, `llms-full.txt`, `llms-full/`). The output folder is gitignored and produced fresh at build time; only the converted output ships in the published tarball — the `.mdx` source does not. | ||
|
|
||
| ### Generate a static search index | ||
| Pipeline checks: | ||
|
|
||
| ```ts | ||
| import { generateDocsSearchFiles } from "leadtype/search/node"; | ||
|
|
||
| await generateDocsSearchFiles({ | ||
| outDir: "public", | ||
| baseUrl: "https://docs.example.com", | ||
| }); | ||
| ```bash | ||
| bun run --filter example pipeline:build | ||
| bun run --filter example pipeline:test | ||
| bun run --filter example test:e2e | ||
| ``` | ||
|
|
||
| At runtime, query the generated JSON with `leadtype/search`. Add a provider entrypoint such as `leadtype/search/vercel` only when a user explicitly asks for a source-grounded answer. | ||
|
|
||
| ## Agent Docs | ||
|
|
||
| The package ships a small, topic-scoped agent reference bundle in `docs/`: | ||
|
|
||
| - `docs/llms.txt`: routing index | ||
| - `docs/components.md` | ||
| - `docs/convert.md` | ||
| - `docs/remark.md` | ||
| - `docs/llm.md` | ||
| - `docs/search.md` | ||
| - `docs/lint.md` | ||
|
|
||
| Set `LEADTYPE_AGENT_BASE_URL` to the hosted docs base before generating publishable `llms*.txt` files. | ||
| For the example app generator, base URL precedence is `LEADTYPE_AGENT_BASE_URL`, then generic deployment `BASE_URL`, then `PORTLESS_URL`, then the local default. | ||
|
|
||
| ## Repo Skill | ||
| ## License | ||
|
|
||
| This repo also includes a local agent skill at `.agents/skills/leadtype/SKILL.md`. It routes agents to the packaged `docs` bundle in `node_modules/leadtype/docs` and falls back to the local workspace copy at `packages/leadtype/docs/` when the package is not installed. | ||
| MIT. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,20 @@ | ||
| "use client"; | ||
|
|
||
| import { mermaid } from "@streamdown/mermaid"; | ||
| import type { ReactNode } from "react"; | ||
| import { Streamdown } from "streamdown"; | ||
|
|
||
| export interface MermaidProps { | ||
| chart?: string; | ||
| children?: ReactNode; | ||
| } | ||
|
|
||
| /** | ||
| * Placeholder Mermaid renderer. Emits a `<pre data-mermaid>` block so | ||
| * consumer apps can hydrate it with their preferred mermaid client | ||
| * (mermaid.js, react-mermaid2, etc.) or style it as-is. | ||
| */ | ||
| export function Mermaid({ chart, children }: MermaidProps) { | ||
| const source = chart ?? (typeof children === "string" ? children : ""); | ||
| const markdown = `\`\`\`mermaid\n${source}\n\`\`\``; | ||
| return ( | ||
| <pre data-leadtype-mermaid=""> | ||
| <code>{source}</code> | ||
| </pre> | ||
| <div data-leadtype-mermaid=""> | ||
| <Streamdown plugins={{ mermaid }}>{markdown}</Streamdown> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Link } from "@tanstack/react-router"; | ||
| import { SiteFooter } from "@/components/site-footer"; | ||
| import { SiteHeader } from "@/components/site-header"; | ||
|
|
||
| export function NotFound() { | ||
| return ( | ||
| <div className="flex min-h-svh flex-col"> | ||
| <SiteHeader /> | ||
| <main className="mx-auto flex w-full max-w-7xl flex-1 flex-col items-start justify-center gap-4 px-4 py-7 sm:px-6"> | ||
| <p className="font-medium text-accent-strong text-sm">404</p> | ||
| <h1 className="font-heading font-medium text-3xl text-foreground tracking-tight sm:text-4xl"> | ||
| Page not found | ||
| </h1> | ||
| <p className="max-w-xl text-muted-foreground text-sm leading-7"> | ||
| We couldn't find that page. Check the URL, or head back to the | ||
| reference app. | ||
| </p> | ||
| <Link | ||
| className="rounded-md bg-primary px-3 py-2 font-medium text-primary-foreground text-sm transition-opacity hover:opacity-90" | ||
| to="/docs" | ||
| > | ||
| Back to docs | ||
| </Link> | ||
| </main> | ||
| <SiteFooter /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace placeholder docs host in user-facing links
Lines 30-63 use
https://docs.example.com/...as primary documentation links. If that host isn’t live for this project, users will hit dead links from the README.Use the real docs origin (or repository-relative links) before merge so the README remains navigable.
🤖 Prompt for AI Agents