Skip to content

Add frontmatter transformers#58

Merged
KayleeWilliams merged 2 commits into
mainfrom
KayleeWilliams/46
May 17, 2026
Merged

Add frontmatter transformers#58
KayleeWilliams merged 2 commits into
mainfrom
KayleeWilliams/46

Conversation

@KayleeWilliams
Copy link
Copy Markdown
Collaborator

Summary

  • Add first-class custom frontmatter schemas and typed transformer lifecycle hooks.
  • Thread transformers through conversion, source metadata, search indexing, LLM artifacts, and CLI generation.
  • Document the new frontmatter transformer workflow and add regression coverage.

Closes #46.

Validation

  • bun x ultracite check
  • bun run --filter leadtype check-types
  • bun run --filter leadtype build
  • bun run --filter leadtype test
  • pre-commit hook: Ultracite + repo test suite passed

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 53c78ec4-249e-4400-8cf4-29d31ac594ae

📥 Commits

Reviewing files that changed from the base of the PR and between dc1a5b1 and deb0258.

📒 Files selected for processing (13)
  • docs/reference/architecture.mdx
  • docs/reference/frontmatter-transformers.mdx
  • docs/reference/source.mdx
  • packages/leadtype/package.json
  • packages/leadtype/rollup.config.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/convert/convert.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/internal/package-surface.test.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/source/index.ts
  • packages/leadtype/src/source/source.test.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use const assertions (as const) for immutable values and literal types
Leverage TypeScript's type narrowing instead of type assertions

Files:

  • packages/leadtype/rollup.config.ts
  • packages/leadtype/src/internal/package-surface.test.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/source/index.ts
  • packages/leadtype/src/convert/convert.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use meaningful variable names instead of magic numbers - extract constants with descriptive names
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, never var
Always await promises in async functions - don't forget to use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors
Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully - don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Don't use eval() or assign directly to document.cookie
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Use descriptive names for functions, variables, and types for meaningful naming
Add comments for complex logic, but prefer self-documenting code

Files:

  • packages/leadtype/rollup.config.ts
  • packages/leadtype/src/internal/package-surface.test.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/source/index.ts
  • packages/leadtype/src/convert/convert.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,ts,jsx,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests - use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat - avoid excessive describe nesting

Files:

  • packages/leadtype/src/internal/package-surface.test.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/llm/llm.test.ts
**/index.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid barrel files (index files that re-export everything)

Files:

  • packages/leadtype/src/index.ts
  • packages/leadtype/src/source/index.ts
🔇 Additional comments (42)
docs/reference/architecture.mdx (1)

19-19: LGTM!

docs/reference/frontmatter-transformers.mdx (1)

1-97: LGTM!

docs/reference/source.mdx (1)

42-43: LGTM!

Also applies to: 67-67

packages/leadtype/src/index.ts (1)

11-11: LGTM!

packages/leadtype/package.json (1)

60-63: LGTM!

packages/leadtype/rollup.config.ts (1)

16-16: LGTM!

packages/leadtype/src/internal/package-surface.test.ts (1)

88-88: LGTM!

packages/leadtype/src/llm/llm.ts (6)

36-41: LGTM!

Also applies to: 175-175


226-269: LGTM!


292-292: LGTM!

Also applies to: 306-306, 320-320, 1923-1923


1604-1662: LGTM!


1707-1745: LGTM!


2108-2121: LGTM!

packages/leadtype/src/llm/llm.test.ts (2)

73-108: LGTM!


342-370: LGTM!

packages/leadtype/src/cli/generate.ts (9)

25-25: LGTM!

Also applies to: 49-49


173-183: LGTM!


601-608: LGTM!


865-865: LGTM!

Also applies to: 873-873


1432-1443: LGTM!


1485-1486: LGTM!


1499-1499: LGTM!


1530-1530: LGTM!

Also applies to: 1542-1542, 1551-1551, 1563-1563


1581-1581: LGTM!

Also applies to: 1592-1592, 1600-1600, 1612-1612

packages/leadtype/src/convert/convert.ts (8)

22-27: LGTM!


241-248: LGTM!


272-278: LGTM!


354-494: LGTM!


496-515: LGTM!


528-612: LGTM!


614-639: LGTM!


667-693: LGTM!

Also applies to: 737-761, 810-854

packages/leadtype/src/source/index.ts (7)

23-23: LGTM!

Also applies to: 61-61


65-103: LGTM!


104-145: LGTM!


147-171: LGTM!


213-270: LGTM!


378-474: LGTM!

Also applies to: 499-559


561-613: LGTM!

packages/leadtype/src/source/source.test.ts (3)

4-4: LGTM!


79-112: LGTM!


114-132: LGTM!


📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added transformer hooks for customizing documentation generation across frontmatter processing, markdown handling, search indexing, and LLM artifact creation.
    • Introduced typed frontmatter schema support with validation for structured custom metadata.
  • Documentation

    • Added comprehensive reference documentation for transformer lifecycle hooks and frontmatter configuration.
    • Updated API documentation for source configuration options.

Walkthrough

This pull request implements a comprehensive typed transformer lifecycle hook system enabling extensibility across Leadtype's documentation pipeline. The change spans from foundational types and execution utilities through integration into MDX conversion, source loading, search indexing, and LLM artifact generation, with full TypeScript generics support for custom frontmatter schemas.

Changes

Transformer Lifecycle Hooks

Layer / File(s) Summary
Transformer foundation types and execution
packages/leadtype/src/transformers.ts
Defines DocsFrontmatterSchema, lifecycle hook stages (beforeParse, afterFrontmatter, afterMdxAst, afterFlattenMarkdown, beforeSearchIndex, beforeSearchChunk, beforeLlmsTxt, beforeLlmsFull, beforeAgentsMd), page/artifact shapes for each stage, DocsTransformerError wrapping failures with context, and runTransformers/runTransformersSync execution utilities with optional Valibot schema validation.
MDX conversion pipeline with transformers
packages/leadtype/src/convert/convert.ts, packages/leadtype/src/convert/convert.test.ts
Adds serializeTransformedAst for AST stringification. Updates convertMdxFile to be generic over typed frontmatter and run transformer hooks at beforeParse, afterFrontmatter (with content re-parsing on mutation), afterMdxAst, and afterFlattenMarkdown stages. Introduces resolveMdxFrontmatter for frontmatter-only resolution. Tests validate schema enforcement, content mutation, and error wrapping.
Source API with typed frontmatter
packages/leadtype/src/source/index.ts, packages/leadtype/src/source/source.test.ts
Makes createDocsSource, DocsPageMeta, DocsPage, and CreateDocsSourceConfig generic over typed frontmatter. Refactors readPageMeta to use resolveMdxFrontmatter with transformer pipeline and schema validation. Updates loadPage and buildSearchIndex to pass transformers and full context. Tests verify schema and transformer integration in metadata loading.
Search index transformers
packages/leadtype/src/search/search.ts, packages/leadtype/src/search/node.ts, packages/leadtype/src/search/search.test.ts
Adds beforeSearchIndex for document-level mutations and beforeSearchChunk for per-chunk text/anchor/codeText modifications with automatic term statistic recalculation. Threads transformers through GenerateDocsSearchFilesConfig. Test validates document/chunk customization affects search results.
LLM artifact transformers
packages/leadtype/src/llm/llm.ts, packages/leadtype/src/llm/llm.test.ts
Adds beforeLlmsTxt, beforeLlmsFull, and beforeAgentsMd hooks. Makes DocsConfig and defineDocsConfig generic over typed frontmatter. Updates config types (LlmsTxtConfig, LLMFullContextConfig, AgentReadabilityConfig, AgentsMdConfig) with optional transformers. Runs hooks before writing artifacts. Tests demonstrate root artifact mutation and locale-scoped path capture.
Generate command orchestration
packages/leadtype/src/cli/generate.ts
Updates metadata resolution to capture frontmatterSchema and transformers. Threads transformers through convertAllMdx and all artifact generators for bundle and site modes including per-locale runs. Refactors group/nav inference to incorporate explicit path filters.
Public API and build configuration
packages/leadtype/src/index.ts, packages/leadtype/package.json, packages/leadtype/rollup.config.ts, packages/leadtype/src/internal/package-surface.test.ts
Re-exports transformer types from main entry point. Adds ./transformers subpath export with TypeScript and ESM targets. Includes transformers in Rollup build. Validates export in package surface test.
Reference documentation
docs/reference/frontmatter-transformers.mdx, docs/reference/source.mdx, docs/reference/architecture.mdx
Documents frontmatter transformers with Valibot schema example, transformer configuration in docs.config.ts, hook execution order and error context. Updates createDocsSource and DocsPageMeta reference. Adds transformers module to architecture overview.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • inthhq/leadtype#51: Both PRs update package export validation in package-surface.test.ts to register new subpath exports (transformers vs. adapter entry points).
  • inthhq/leadtype#32: Both PRs modify frontmatter parsing and handling in convert.ts and search/node.ts, with this PR building typed transformer-driven frontmatter on top of earlier changes to frontmatter pipeline mechanics.

Poem

🐰 A transformer hops through every stage,
From parse to search, a flexible sage,
With hooks typed strong and schemas clear,
Users extend without a fear,
The pipeline flows, deterministic and true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title "Add frontmatter transformers" clearly and concisely summarizes the main change, which is the introduction of custom frontmatter schemas and transformer lifecycle hooks throughout the codebase.
Description check ✅ Passed The PR description is directly related to the changeset, explaining the addition of custom frontmatter schemas, transformer lifecycle hooks, and their integration across the pipeline with validation details.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #46 requirements: typed transformer hooks are defined and documented, transformers are threaded through conversion/source/search/LLM pipelines, hook errors include transformer name and file path, deterministic ordering is maintained, and acceptance criteria are met.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #46 objectives: core transformer infrastructure (transformers.ts), integration with conversion/source/search/LLM pipelines, reference documentation, type exports, and regression test coverage. No out-of-scope changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch KayleeWilliams/46

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@KayleeWilliams KayleeWilliams marked this pull request as ready for review May 17, 2026 00:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc1a5b1ead

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/leadtype/src/source/index.ts Outdated
Copy link
Copy Markdown

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Mergeable as-is. The transformer pipeline lands cleanly with consistent typing across convertMdxFile, createDocsSource, search, and LLM artifacts. A few minor rough edges flagged below as informational — none block merge.

TL;DR — Custom frontmatter becomes a first-class typed surface and a DocsTransformer lifecycle is threaded through conversion, source loading, search indexing, LLM artifacts, and CLI generation. Adds the contract module, regression coverage, and reference docs.

Key changes

  • Add DocsTransformer contract and runner — new transformers.ts defines hook enum, error wrapper, sync/async runners, and validateFrontmatter.
  • Generic frontmatter in convertMdxFile — pipeline runs beforeParse → frontmatter resolution → afterFrontmatter (re-parses MDX when content changes) → afterMdxAstafterFlattenMarkdown, with schema validation after every data-touching hook.
  • Generic createDocsSourceDocsPageMeta, DocsPage, and the source factory carry TFrontmatter; readPageMeta honors beforeParse / afterFrontmatter, and buildSearchIndex forwards transformers.
  • Search hookscreateDocsSearchIndex accepts transformers, applies beforeSearchIndex over the document list and beforeSearchChunk per chunk, recomputing chunk length from the post-hook text.
  • LLM + agent artifactsbeforeLlmsTxt (root and docs-scoped), beforeLlmsFull, and beforeAgentsMd artifacts run before write; DocsFrontmatterSchema is re-exported from the transformers module.
  • CLI wiringrunGenerateCommand reads frontmatterSchema + transformers from the loaded config and threads them to convert plus every LLM / search / agent generator across default and i18n locales; needsGroupInference now also fires when explicit path filters strip nav.
  • Docs + tests — new docs/reference/frontmatter-transformers.mdx, updates to source.mdx, and tests for convert (success + error wrapping), source (typed frontmatter), search (index + chunk), and llm (root llms.txt).

Summary | 17 files | 1 commit | base: mainKayleeWilliams/46


Pipeline ordering and validation cadence

Before: convertMdxFile returned { data: Record<string, unknown>, ... } with no hook points and no schema validation.
After: Generic on TFrontmatter, validates after each data-mutating hook, and re-serializes frontmatter via stringifyFrontmatter whenever a schema or transformers are present.

Hooks run in array order; an undefined return preserves the current value; throws are wrapped with transformer name + hook + file path in DocsTransformerError. When afterFrontmatter mutates content, the MDX is re-parsed and re-processed before afterMdxAst sees it.

packages/leadtype/src/transformers.ts · packages/leadtype/src/convert/convert.ts


Source: typed metadata, double-evaluation note

Before: DocsPageMeta exposed groups, no frontmatter; DocsPage had frontmatter: Record<string, unknown>.
After: Both carry frontmatter: TFrontmatter; listPages and loadPage route through validateFrontmatter.

Worth noting (informational, no fix needed): beforeParse and afterFrontmatter execute once inside readPageMeta (driving listPages / buildSearchIndex) and again inside convertMdxFile when loadPage is invoked. Pure transformers are idempotent so behavior is correct, but expensive hooks pay the cost twice per page.

packages/leadtype/src/source/index.ts


Search hooks and synchronous contract

Before: Chunk metadata was assembled and pushed directly; index construction had no extension points.
After: beforeSearchIndex and beforeSearchChunk interpose; runTransformersSync throws if a hook returns a Promise so the synchronous indexing path stays safe.

Chunk length is recomputed from the post-hook text, matching the docs guarantee in frontmatter-transformers.mdx. The hook type signature is MaybePromise<...>; the sync-only requirement is enforced at runtime rather than at compile time, which is reasonable given the shared DocsTransformer shape.

packages/leadtype/src/search/search.ts


LLM, agents, and CLI threading

Before: Artifacts were written directly; CLI passed no schema or transformer wiring through to artifact generators.
After: Each artifact runs through beforeLlmsTxt / beforeLlmsFull / beforeAgentsMd before write; runGenerateCommand forwards frontmatterSchema + transformers to convert and every generator across the default and i18n locales.

The needsGroupInference widening (firing when explicit path filters reduce a config to nav-only) is an orthogonal fix called out in the inline comment; behavior is documented and bounded to filtered runs.

packages/leadtype/src/llm/llm.ts · packages/leadtype/src/cli/generate.ts

Pullfrog  | View workflow run | Using Claude Opus𝕏

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/reference/frontmatter-transformers.mdx`:
- Around line 35-37: Replace the OS-dependent file path check using
page.filePath with a route-relative field: update the apiArea assignment that
currently uses page.filePath.includes("/reference/") to use page.urlPath (or
page.relativePath) for deterministic matching — e.g. check
page.urlPath.startsWith("/reference") or
page.relativePath.startsWith("reference") to decide between "reference" and
"guides", keeping the existing apiArea logic and any surrounding transform in
place.

In `@docs/reference/source.mdx`:
- Around line 42-43: Update the docs to narrow the scope of the `transformers`
description: in the table row referencing `transformers` / `DocsTransformer[]`
(and the `createDocsSource` context), remove or replace "agent artifacts" and
explicitly state that transformers provide lifecycle hooks for frontmatter,
markdown, and search processing only; ensure references to `createDocsSource`
and the `DocsTransformer` concept remain so readers can locate the API and its
relevant hook types.

In `@packages/leadtype/src/cli/generate.ts`:
- Around line 857-865: The config validation is dropping frontmatterSchema and
transformers so config-driven runs lose schema/transformer wiring; update
validateDocsConfig() to preserve and return loaded.config.frontmatterSchema and
loaded.config.transformers (or merge them into the validated config object) so
that the values used in generate.ts (references: frontmatterSchema,
transformers, loaded.config, and validateDocsConfig()) are threaded through the
validation step and available to the caller.

In `@packages/leadtype/src/convert/index.ts`:
- Around line 1-9: Remove the aggregated re-export block in this index.ts and
instead export each symbol from its original module file: export DocsAstPage,
DocsFrontmatterPage, DocsMarkdownPage, DocsRawPage, DocsTransformContext, and
DocsTransformer from the module that defines the types (e.g.,
"../transformers/types"), and export DocsTransformerError from the module that
defines the error (e.g., "../transformers/error"); do not re-export everything
via the barrel "../transformers" index. Ensure each export uses the explicit
source module path and that the index.ts no longer expands the barrel
entrypoint.

In `@packages/leadtype/src/llm/llm.ts`:
- Around line 1650-1655: The hook context always passes a hard-coded
relativePath "docs/llms.txt", which is incorrect for localized outputs; update
the call to runTransformers (the call site using config.transformers,
"beforeLlmsTxt", input, { stage: "llm", relativePath: "docs/llms.txt", locale },
...) to compute a locale-aware relativePath (e.g. include locale when present so
non-default locales use "docs/<locale>/llms.txt" while default keeps
"docs/llms.txt") so transformer error contexts reflect the actual output path.

In `@packages/leadtype/src/search/index.ts`:
- Around line 1-6: Remove the new re-exports (DocsSearchChunkInput,
DocsTransformContext, DocsTransformer, DocsTransformerError) from the search
barrel export in index.ts and instead import these symbols directly from the
module that defines them (the transformers module) at call sites; locate the
export block that lists type DocsSearchChunkInput, type DocsTransformContext,
type DocsTransformer, and DocsTransformerError and delete those lines so the
barrel no longer surfaces those transformer symbols, then update any files that
currently import them from the search index to import from the transformers
module instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ef2ff294-c6d7-410d-bb77-bb79d0f57e86

📥 Commits

Reviewing files that changed from the base of the PR and between f178a7b and dc1a5b1.

📒 Files selected for processing (17)
  • docs/reference/frontmatter-transformers.mdx
  • docs/reference/source.mdx
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/convert/convert.test.ts
  • packages/leadtype/src/convert/convert.ts
  • packages/leadtype/src/convert/index.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/llm/index.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/search/index.ts
  • packages/leadtype/src/search/node.ts
  • packages/leadtype/src/search/search.test.ts
  • packages/leadtype/src/search/search.ts
  • packages/leadtype/src/source/index.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/transformers.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use const assertions (as const) for immutable values and literal types
Leverage TypeScript's type narrowing instead of type assertions

Files:

  • packages/leadtype/src/convert/index.ts
  • packages/leadtype/src/search/index.ts
  • packages/leadtype/src/search/search.test.ts
  • packages/leadtype/src/llm/index.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/convert/convert.test.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/search/node.ts
  • packages/leadtype/src/search/search.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/transformers.ts
  • packages/leadtype/src/convert/convert.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/source/index.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use meaningful variable names instead of magic numbers - extract constants with descriptive names
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, never var
Always await promises in async functions - don't forget to use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors
Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully - don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Don't use eval() or assign directly to document.cookie
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Use descriptive names for functions, variables, and types for meaningful naming
Add comments for complex logic, but prefer self-documenting code

Files:

  • packages/leadtype/src/convert/index.ts
  • packages/leadtype/src/search/index.ts
  • packages/leadtype/src/search/search.test.ts
  • packages/leadtype/src/llm/index.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/convert/convert.test.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/source/source.test.ts
  • packages/leadtype/src/search/node.ts
  • packages/leadtype/src/search/search.ts
  • packages/leadtype/src/cli/generate.ts
  • packages/leadtype/src/transformers.ts
  • packages/leadtype/src/convert/convert.ts
  • packages/leadtype/src/llm/llm.ts
  • packages/leadtype/src/source/index.ts
**/index.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid barrel files (index files that re-export everything)

Files:

  • packages/leadtype/src/convert/index.ts
  • packages/leadtype/src/search/index.ts
  • packages/leadtype/src/llm/index.ts
  • packages/leadtype/src/index.ts
  • packages/leadtype/src/source/index.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,ts,jsx,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests - use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat - avoid excessive describe nesting

Files:

  • packages/leadtype/src/search/search.test.ts
  • packages/leadtype/src/llm/llm.test.ts
  • packages/leadtype/src/convert/convert.test.ts
  • packages/leadtype/src/source/source.test.ts
🔇 Additional comments (54)
packages/leadtype/src/transformers.ts (10)

1-21: LGTM!


23-55: LGTM!


57-94: LGTM!


96-114: LGTM!


116-166: LGTM!


168-185: LGTM!


187-211: LGTM!


213-245: LGTM!


247-294: LGTM!


296-317: LGTM!

packages/leadtype/src/convert/convert.ts (12)

241-248: LGTM!


272-277: LGTM!


354-365: LGTM!


378-401: LGTM!


414-425: LGTM!


437-478: LGTM!


480-505: LGTM!


507-543: LGTM!


549-570: LGTM!


598-624: LGTM!


685-691: LGTM!


747-756: LGTM!

packages/leadtype/src/convert/convert.test.ts (4)

5-5: LGTM!


104-134: LGTM!


136-158: LGTM!


160-177: LGTM!

packages/leadtype/src/source/index.ts (12)

63-71: LGTM!


73-98: LGTM!


100-110: LGTM!


112-153: LGTM!


155-179: LGTM!


221-306: LGTM!


414-418: LGTM!


443-445: LGTM!


462-479: LGTM!


487-508: LGTM!

Also applies to: 512-518


535-537: LGTM!

Also applies to: 539-575


597-640: LGTM!

packages/leadtype/src/source/source.test.ts (2)

4-4: LGTM!


79-112: LGTM!

packages/leadtype/src/search/search.ts (5)

3-8: LGTM!


120-120: LGTM!


210-210: LGTM!


855-864: LGTM!


915-966: LGTM!

packages/leadtype/src/search/search.test.ts (1)

136-166: LGTM!

packages/leadtype/src/search/node.ts (3)

24-24: LGTM!

Also applies to: 50-50


140-140: LGTM!


310-313: LGTM!

packages/leadtype/src/llm/llm.ts (1)

36-41: LGTM!

Also applies to: 175-175, 226-233, 265-267, 292-292, 306-306, 320-320, 1920-1920

packages/leadtype/src/llm/llm.test.ts (1)

73-108: LGTM!

packages/leadtype/src/cli/generate.ts (1)

25-25: LGTM!

Also applies to: 49-49, 175-180, 1424-1435, 1477-1478, 1491-1605

packages/leadtype/src/index.ts (1)

53-66: Duplicate concern.

Same barrel-file expansion concern already raised for packages/leadtype/src/convert/index.ts.

packages/leadtype/src/llm/index.ts (1)

17-24: Duplicate concern.

Same barrel-file expansion concern already raised for packages/leadtype/src/convert/index.ts.

Comment thread docs/reference/frontmatter-transformers.mdx Outdated
Comment thread docs/reference/source.mdx Outdated
Comment thread packages/leadtype/src/cli/generate.ts
Comment thread packages/leadtype/src/convert/index.ts Outdated
Comment thread packages/leadtype/src/llm/llm.ts
Comment thread packages/leadtype/src/search/index.ts Outdated
Copy link
Copy Markdown

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new issues. Reviewed the following changes:

  • Exposed leadtype/transformers as a first-class subpath in package.json, rollup.config.ts, and the package-surface test, and pruned the transformer re-exports from the convert, search, and llm barrels so the types are sourced from one entry point.
  • Threaded frontmatterSchema and transformers through validateDocsConfig, so config-driven runs no longer drop them before reaching the generators.
  • Extracted prepareMdxConversion in convert.ts and exported resolveMdxFrontmatter; routed readPageMeta through it so synthesized frontmatter now flows through the same schema/transformer pipeline as conversion (covered by the new validates synthesized frontmatter through custom source schemas test).
  • Computed a locale-aware docsLlmsRelativePath for the beforeLlmsTxt hook so non-default locales report docs/<locale>/llms.txt in the transformer context.
  • Updated the frontmatter-transformers.mdx example to derive apiArea from context.relativePath (OS-independent) and narrowed the transformers description in source.mdx to frontmatter/markdown/search.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@KayleeWilliams KayleeWilliams merged commit 479e954 into main May 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P5] Add typed transformer lifecycle hooks

1 participant