npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@reaatech/agents-markdown-parser

v1.0.0

Published

Markdown AST parser with frontmatter extraction for agents-markdown ecosystem

Readme

@reaatech/agents-markdown-parser

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Markdown AST parser with YAML frontmatter extraction for AGENTS.md and SKILL.md files. Built on remark and unified for reliable AST extraction, plus section hierarchy analysis, table parsing, and code block extraction.

Installation

npm install @reaatech/agents-markdown-parser
# or
pnpm add @reaatech/agents-markdown-parser

Feature Overview

  • Main parserparseMarkdown produces a typed AgentsMdDocument or SkillMdDocument from raw markdown
  • YAML frontmatter — Extract, validate, create, and update frontmatter with yaml parsing
  • Section hierarchy — Build a nested section tree from headings, with find/has/flatten utilities
  • Table extraction — Parse all markdown tables, extract columns, convert to objects, validate structure
  • Code blocks — Extract fenced code blocks, detect languages, flag potential secrets
  • Batch processingparseMarkdownFiles for multi-file operations

Quick Start

import { parseMarkdown, extractSections, parseTables } from "@reaatech/agents-markdown-parser";

const content = `---
agent_id: my-agent
display_name: My Agent
version: 1.0.0
description: A test agent
type: mcp
---

# My Agent

## What this is

A test agent for demonstration.

## Architecture Overview

\`\`\`text
┌────────┐    ┌──────────┐
│ Input  │───▶│ Processor │───▶ Output
└────────┘    └──────────┘
\`\`\`

| Component | Purpose |
|-----------|---------|
| Parser    | Parsing  |
`;

const doc = await parseMarkdown(content, "/path/to/AGENTS.md");
console.log(doc.frontmatter.id);        // "my-agent"
console.log(doc.title);                  // "My Agent"
console.log(doc.sections.length);        // 2

const sections = extractSections(content);
const tables = parseTables(content);

API Reference

parseMarkdown(content, path)

The main entry point. Parses raw markdown into a fully structured document.

async function parseMarkdown(
  content: string,
  path: string
): Promise<AgentsMdDocument | SkillMdDocument>

parseMarkdownFiles(files)

async function parseMarkdownFiles(
  files: string[]
): Promise<Array<AgentsMdDocument | SkillMdDocument>>

Document Navigation

| Function | Signature | Description | |----------|-----------|-------------| | getSectionTitles | (doc) => string[] | All section titles in the document | | findSection | (doc, title) => Section \| undefined | Find a section by title (case-insensitive) | | getHeadings | (doc) => Array<{title, level, line}> | All headings with metadata |

Frontmatter (extractFrontmatter)

function extractFrontmatter(content: string): {
  frontmatter: ParsedFrontmatter;
  frontmatterRange: { start: number; end: number };
  contentWithoutFrontmatter: string;
}

| Function | Description | |----------|-------------| | extractFrontmatter(content) | Extract and parse YAML frontmatter | | validateFrontmatterStructure(frontmatter) | Check required fields exist | | createFrontmatter(values, isSkill?) | Generate a frontmatter string | | updateFrontmatter(content, updates) | Merge updates into existing frontmatter |

Section Extraction (extractSections)

function extractSections(content: string, lineOffset?: number): Section[]

interface Section {
  title: string;
  level: number;
  content: string;
  location: ErrorLocation;
  subsections: Section[];
}

| Function | Description | |----------|-------------| | extractSections(content, lineOffset?) | Build section hierarchy from headings | | findSection(sections, title) | Recursive case-insensitive find | | findSectionByPath(sections, path) | Find by array path (e.g. ["A", "B"]) | | findSectionByTitle(sections, title) | Alias for findSection exported for disambiguation | | flattenSectionTitles(sections) | All titles in a flat array | | hasSection(sections, title) | Boolean existence check | | getSectionsAtLevel(sections, level) | Filter by heading level |

Table Parsing (parseTables)

function parseTables(content: string): MarkdownTable[]

interface MarkdownTable {
  headers: string[];
  rows: string[][];
  location: ErrorLocation;
}

| Function | Description | |----------|-------------| | parseTables(content) | Extract all markdown tables | | extractColumn(table, columnName) | Extract a column by header name | | tableToObjects(table) | Convert to Record<string, string>[] | | validateTableStructure(table) | Check headers, duplicates, row consistency | | formatTable(table) | Format back to markdown string |

Code Block Extraction

| Function | Description | |----------|-------------| | extractCodeBlocks(content) | Extract fenced code blocks | | hasLanguage(codeBlock) | Check if language is specified | | getCodeBlocksByLanguage(blocks, language) | Filter by language | | mightContainSecret(codeBlock) | Regex-based secret detection | | formatCodeBlock(codeBlock) | Format back to markdown | | validateCodeBlockLanguages(blocks) | Check which blocks have languages | | getUniqueLanguages(blocks) | Sorted unique language identifiers |

Related Packages

License

MIT