🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ev3lynx/md-analyzer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ev3lynx/md-analyzer

Markdown document analyzer for AI agents - extract metadata, headings, links, tables, tokens, and key points

Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
15
-71.15%
Maintainers
1
Weekly downloads
 
Created
Source

md-analyzer

Markdown document analyzer for AI agents - extract metadata, headings, links, tables, tokens, and key points from .md files.

md-analyzer is a lightweight, agent-ready document analysis tool designed for AI workflows. It provides single-shot document overviews, token budget tracking, and document relationship graphs — perfect for OpenCode, Hermes, OpenClaw, or any AI agent framework.

Quick Overview

FeatureDescription
KeypointsSingle-shot document overview (ideal for agents)
Token TrackingSession-based token budget with /tmp/md-analyzer-session.json
GraphDocument relationship topology (backlinks, orphans)
SearchKeyword search with relevance ranking
LogsStructured JSON logs in log/{sessionId}.json

Why md-analyzer?

  • Agent-native — Designed for AI agent workflows with single-shot outputs
  • Token-safe — Built-in limits prevent context blowout (default: 20 results)
  • Extensible — Simple TypeScript source, easy to extend for plugins
  • Zero deps — Runtime TOML parser, no external config dependencies

Pre-Requirements

System Requirements

RequirementVersionNotes
Node.js≥ 18.0.0LTS recommended
npm≥ 8.0.0Comes with Node.js

Verify Installation

node --version  # Should be >= 18.0.0
npm --version   # Should be >= 8.0.0

Dependencies

PackageVersionPurpose
micromark^4.0.0Markdown parsing
js-tiktoken^1.0.0GPT token counting

Installation

npm install -g @ev3lynx/md-analyzer
md-analyzer --help

From source

git clone https://github.com/Ev3lynx727/md-analyzer.git
cd md-analyzer
npm install
npm run build

Quick test

node md-analyzer.js . --keypoints --json

Usage

Basic CLI

# With npx (no install required)
npx @ev3lynx/md-analyzer <directory> [options]

# After global install
npm install -g @ev3lynx/md-analyzer
md-analyzer <directory> [options]

# From source (development)
node md-analyzer.js <directory> [options]

Options

FlagDescriptionExample
--jsonOutput as JSON--json
--search <kw>Search keyword in content--search "task"
--filter <k=v>Filter by metadata field--filter "category=guides"
--rankRank results by relevance--search "task" --rank
--graphDocument relationship graph--graph
--orphansFind unreferenced docs--orphans
--backlinks <doc>Find docs linking to <doc>--backlinks "adr-2026-01"
--keypointsQuick overview (single-shot)--keypoints
--sessionToken budget report--session
--budget <n>Set token budget limit--budget 50000
--max-results <n>Limit output--max-results 10

Examples

# Quick overview (single-shot for agents)
npx @ev3lynx/md-analyzer /path/to/docs --keypoints --json

# Search with ranking
md-analyzer . --search "task lifecycle" --rank --json

# Find backlinks
md-analyzer . --backlinks adr-2026-04-01 --json

# Token budget tracking
md-analyzer . --session --budget 100000 --json

# Find orphans
md-analyzer . --orphans --json

Building Extensions & Plugins

md-analyzer is designed to be extended. Here's how to build plugins for different frameworks.

1. As CLI Tool (OpenCode, Hermes, etc.)

# In your agent config
tools:
  - name: md-analyzer
    command: md-analyzer
    args: ["{{directory}}", "--keypoints", "--json"]

2. As Node.js Module

const { execSync } = require('child_process');

function analyzeDocs(directory, options = {}) {
  const args = ['md-analyzer.js', directory, '--json'];
  if (options.keypoints) args.push('--keypoints');
  if (options.search) args.push('--search', options.search);

  const result = execSync(`node ${args.join(' ')}`, { encoding: 'utf-8' });
  return JSON.parse(result);
}

// Usage
const docs = analyzeDocs('./docs', { keypoints: true });

3. As Python Module (LangGraph)

import subprocess
import json

def run_md_analyzer(directory, **kwargs):
    args = ["node", "md-analyzer.js", directory, "--json"]
    for key, value in kwargs.items():
        if value is True:
            args.append(f"--{key}")
        elif value:
            args.extend([f"--{key}", str(value)])

    result = subprocess.run(args, capture_output=True, text=True)
    return json.loads(result.stdout)

# Usage
docs = run_md_analyzer("./docs", keypoints=True)

4. Create Custom Wrapper

// src/plugins/my-plugin.ts
import { analyzeFile, extractKeyPoints } from '../md-analyzer';

interface MyPluginOptions {
  directory: string
  customField?: string
}

export function myPlugin(options: MyPluginOptions) {
  const results = scanMarkdownFiles(options.directory);
  const analyzed = results.map(analyzeFile);

  // Custom processing
  return analyzed.map(doc => ({
    ...extractKeyPoints(doc),
    customField: options.customField
  }));
}

5. Hook into Session Events

// Track token usage across plugin calls
const session = loadSession();
console.log(`Total tokens: ${session.totalTokens}`);
console.log(`Calls: ${session.calls}`);

Configuration

hooks.toml

[tool.md-analyzer.config]
# Path configuration
default_directory = "/path/to/docs"

# Token budget configuration
default_budget = 100000
max_tokens = 200000

# Output safety (prevent token blowout)
max_results_default = 20

Environment Variables

VariableDescriptionDefault
MD_ANALYZER_PATHPath to md-analyzer.jsmd-analyzer.js
MD_ANALYZER_DEFAULT_DIRDefault directory.
MD_ANALYZER_MAX_TOKENSMax token limit200000
MD_ANALYZER_DEFAULT_BUDGETDefault budget100000
MD_ANALYZER_MAX_RESULTSMax results20

Priority Chain

CLI --max-results 3
  ↓
MD_ANALYZER_MAX_RESULTS=5
  ↓
max_results_default=20 (hooks.toml)
  ↓
0 (no limit)

Session & Logging

Session File

Location: /tmp/md-analyzer-session.json

{
  "sessionId": "session-1234567890",
  "calls": 5,
  "totalTokens": 1500,
  "filesProcessed": 25,
  "startTime": "2026-05-03T12:00:00.000Z"
}

Run Logs

Location: {project}/log/{sessionId}.json

[
  {
    "timestamp": "2026-05-03T12:00:00.000Z",
    "sessionId": "session-1234567890",
    "directory": "/path/to/docs",
    "flags": ["--keypoints", "--json"],
    "filesFound": 10,
    "filesProcessed": 10,
    "tokensThisCall": 300,
    "totalSessionTokens": 1500,
    "errors": [],
    "durationMs": 450,
    "mode": "keypoints"
  }
]

Architecture

md-analyzer/
├── src/
│   └── md-analyzer.ts      # Main source (TypeScript)
├── md-analyzer.js          # Compiled output
├── hooks.toml              # Configuration
└── log/                    # Run logs

Key Functions

FunctionDescription
extractFrontmatter()YAML metadata extraction
extractHeadings()Parse H1-H6 structure
extractLinks()Internal/external link analysis
extractTables()Markdown table parsing
scanMarkdownFiles()Recursive directory scanner
buildGraph()Document relationship topology
extractKeyPoints()Single-shot overview
loadSession() / saveSession()Token budget tracking

Error Handling

ErrorDescription
permission_deniedSkip inaccessible directories
file_read_errorReturn partial results
token_count_fallbackUse charCount/4 estimation

License

MIT - See LICENSE file.

Keywords

markdown

FAQs

Package last updated on 08 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts