← 返回 Skills 市场
wei840222

treemd

作者 wei · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
42
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install treemd
功能描述
Markdown document analysis and navigation using the treemd CLI. Use when exploring markdown structure (heading trees, section extraction), querying markdown...
使用说明 (SKILL.md)

treemd Skill

Skill for working with the treemd markdown viewer and query tool.

Overview

treemd is a Rust-based CLI for markdown document analysis. It handles two primary workflows:

  1. Structural Navigation — Explore document hierarchy top-down
  2. Query Navigation — Navigate by asking structured questions

For scripted/agent tasks, always use CLI mode. TUI mode is reserved for human interactive viewing.

Project: https://github.com/Epistates/treemd
Install: cargo install treemd or download binary from releases


Line A: Structural Navigation

Use this when encountering an unfamiliar document. Progress from overview → locate → extract.

Step 1: Overview

Understand the document skeleton before diving in.

treemd --tree FILE.md              # Visual tree with box-drawing characters
treemd --count FILE.md             # Heading count by level (h1–h6 breakdown + total)
treemd -l FILE.md | head -20       # Quick scan of all headings

Step 2: Locate

Pinpoint the sections relevant to your goal.

treemd -l --filter "install" FILE.md        # Fuzzy heading search (case-insensitive)
treemd -l -L 2 --filter "API" FILE.md      # Narrow by heading level + keyword
treemd --at-line 150 FILE.md               # "Which heading covers line 150?"

Step 3: Extract

Pull entire sections or pipe content for downstream processing.

treemd -s "Installation" FILE.md          # Extract heading + content until next h1/h2
treemd -s "Usage" FILE.md -o json         # Structured JSON output for scripting
cat FILE.md | treemd -s "Prerequisites" -  # Pipe stdin, extract from stream

Output Format Options

Attach -o to --list, --tree, or -s only:

  • -o plain: Human-readable text (default)
  • -o json: JSON array for scripting/parsing
  • -o tree: Box-drawing tree structure

For tql (-q) queries, use --query-output instead of -o. Available formats:

  • --query-output plain: Human-readable text (default)
  • --query-output json: Compact JSON
  • --query-output json-pretty: Pretty-printed JSON
  • --query-output jsonl: Line-delimited JSON
  • --query-output md: Raw markdown rendering
  • --query-output tree: Box-drawing tree structure

Line B: Query Navigation

Use this when you already know what to look for. Jump directly to answers via the tql (treemd query language) — a jq-like markdown DOM traversal engine.

Element Selectors

Query syntax mirrors CSS/JQuery selectors operating on markdown AST:

treemd -q '.h2' FILE.md                # All h2 headings
treemd -q '.code[rust]' FILE.md        # Rust code block elements
treemd -q '.link | url' FILE.md        # All link URLs (pipe extraction)
treemd -q '.h2 | text' FILE.md         # Strip markdown syntax, get plain text

Hierarchy & Filters

Navigate parent-child relationships and apply predicate filters:

treemd -q '.h1[Features] > .h2' FILE.md           # Direct child h2 under "Features"
treemd -q '.h1 >> .code' FILE.md                  # Code blocks anywhere under h1
treemd -q '.h | select(contains("API"))' FILE.md  # Headings containing "API"
treemd -q '[.h2] | limit(5)' FILE.md              # First 5 h2 elements

Aggregation & Document Statistics

treemd -q 'stats' FILE.md              # Document metrics (headings, links, code blocks)
treemd -q 'levels' FILE.md             # Heading count per level
treemd -q 'langs' FILE.md              # Code block language distribution
treemd -q '[.h2] | count' FILE.md      # Total h2 count

Note: Aggregation functions (stats, levels, langs, types) do not require . | prefix — use them directly as shown above.

tql Query Output Formats

Use --query-output for tql results:

treemd -q '.h2 | text' --query-output json FILE.md      # Compact JSON
treemd -q '.h2 | text' --query-output json-pretty FILE.md # Pretty-printed JSON
treemd -q '.link' --query-output jsonl FILE.md          # Line-delimited JSON
treemd -q '.h2 | text' --query-output md FILE.md       # Markdown rendering
treemd -q '.h1' --query-output tree FILE.md              # Box-drawing tree

Full tql syntax reference: references/query-language.md.


Stdin & Directory Input

cat README.md | treemd -l -            # Read markdown from stdin
treemd ./docs/                         # File picker in directory
treemd *.md                            # Multi-file picker

TUI Mode

Reserved for human interactive sessions only. Not usable by agents.

treemd FILE.md          # Launch dual-pane interactive viewer

Keybindings: vim-style (j/k for up/down, h/l for collapse/expand, / for search, q for quit).

Themes: --theme \x3COceanDark|Nord|Dracula|Solarized|Monokai|Gruvbox|TokyoNight|CatppuccinMocha>

Integration Patterns

Pattern: Extract Section for Analysis

SECTION=$(treemd -s "Installation" README.md)

Pattern: Extract Heading Section Content (tql)

treemd -q '.h1["API Reference"] | content' FILE.md   # Full section under heading

Pattern: Heading Tree as JSON

treemd --tree -o json FILE.md | jq '.'

Pattern: Find Specific Headings

# Structural line
treemd -l --filter "Config" FILE.md

# Query line (equivalent)
treemd -q '.h | select(contains("Config"))' FILE.md

Pattern: Document Statistics Pipeline

treemd -q 'stats' --query-output json FILE.md | jq '.code_blocks'
treemd -q 'levels' --query-output json FILE.md | jq '.h1'

Note: Aggregation queries output plain text by default. Always add --query-output json when piping to jq.

Error Handling

  • Missing section: treemd -s "NonExistent" FILE.md exits with code 0 and prints nothing when the section is not found. Check output emptiness to detect missing sections.
  • Invalid tql syntax: Exits with a non-zero code and an error message on stderr.
  • Unsupported --query-output value: Exits with error "Unknown output format" — use supported values only (plain, json, json-pretty, jsonl, md, tree).

Notes

  • File picker filters to .md / .markdown extensions only
  • tql supports element selectors, hierarchy operators (>, >>), pipes (|), and collection/string/filter/aggregation functions
  • JSON output is compatible with jq pipelines
  • Run treemd --query-help for the complete built-in tql reference (same content as references/query-language.md)
安全使用建议
Before installing, verify the treemd CLI source and version, and use the skill only on Markdown files you intend the agent to inspect. The provided artifacts do not show hidden code, credential use, persistence, or data exfiltration.
功能分析
Type: OpenClaw Skill Name: treemd Version: 1.0.0 The treemd skill bundle provides instructions and documentation for a markdown analysis CLI tool. It facilitates structural navigation and complex queries using a custom query language (tql) to extract sections, headings, and metadata from markdown files. The instructions in SKILL.md and references/query-language.md are consistent with the stated purpose of document exploration and extraction, with no evidence of malicious intent, data exfiltration, or unauthorized execution.
能力评估
Purpose & Capability
The stated purpose is Markdown document analysis and navigation, and the provided instructions consistently focus on listing headings, extracting sections, and querying Markdown structure.
Instruction Scope
The skill instructs the agent to use the local treemd CLI against Markdown files, which is purpose-aligned but means the agent may run local commands and read selected Markdown content.
Install Mechanism
The registry has no install spec and no required binary declaration, while SKILL.md tells users to install treemd via Cargo or GitHub releases; users should verify the external tool source themselves.
Credentials
The requested environment access is limited to local Markdown files, stdin, and directory/file picker examples; no credentials, network data flows, persistence, or broad indexing are shown.
Persistence & Privilege
The artifacts do not show background services, persistence, privilege escalation, credential use, or account access.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install treemd
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /treemd 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: markdown document analysis and navigation with treemd CLI
元数据
Slug treemd
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

treemd 是什么?

Markdown document analysis and navigation using the treemd CLI. Use when exploring markdown structure (heading trees, section extraction), querying markdown... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 42 次。

如何安装 treemd?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install treemd」即可一键安装,无需额外配置。

treemd 是免费的吗?

是的,treemd 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

treemd 支持哪些平台?

treemd 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 treemd?

由 wei(@wei840222)开发并维护,当前版本 v1.0.0。

💬 留言讨论