Skip to main content

Structured Markdown indexing and selective reading CLI.

Project description

markdown-scope

markdown-scope is a CLI for building a structured Markdown index and reading only the parts you need.

  • Project name: markdown-scope
  • CLI name: md-scope

Install

Use uv (recommended):

uv sync
uv run md-scope --help

Use pip:

pip install .
md-scope --help
python -m markdown_scope --help

What It Generates

For one root directory, build/update writes:

  • Public index: ROOT/.md-scope-index.json
  • Lock index: ROOT/.md-scope-index.lock.json

Public index is for reading/searching.
Lock index keeps internal metadata for update reuse.

Commands

build

Build index from scratch for a root directory.

Common options:

  • --root: Markdown root directory
  • --index: custom public index path (default ROOT/.md-scope-index.json)
  • --overwrite: overwrite existing index
  • --include: file glob patterns (repeatable)
  • --config: TOML config path
  • --format: output format (json|text|markdown, mostly json)

Summary-related options:

  • --provider
  • --api-base
  • --api-key
  • --model
  • --api-timeout-seconds
  • --api-requests-per-minute
  • --system-prompt
  • --user-prompt
  • --summary-root-level
  • --include-excluded-ancestors-as-context

Example:

uv run md-scope build --root ./examples --config ./md-scope.toml

update

Incremental rebuild using lock metadata. Unchanged sections reuse id/summary when possible.

Common options are similar to build:

  • --root
  • --index
  • --include
  • --config
  • --format
  • all summary-related options

Example:

uv run md-scope update --root ./examples --config ./md-scope.toml

outline

Read index outline (tree/catalog view).
Default target behavior: if SKILL.md exists, it is preferred when no target is provided.

Options:

  • --root
  • --index
  • --target: file or directory scope
  • --format: json|text|markdown
  • --full: only for JSON, include line_count/level/start/end

Examples:

uv run md-scope outline --root ./examples --format json
uv run md-scope outline --root ./examples --target references --format text
uv run md-scope outline --root ./examples --format json --full

catalog

Alias of outline (same behavior and parameters).

search

Search sections in index by title/path/summary.

Options:

  • --root
  • --index
  • --query (required)
  • --field: all|title|path|summary
  • --target: limit to file/directory scope
  • --format
  • --full: only for JSON, include range metadata

Example:

uv run md-scope search --root ./examples --query install --field all

read-lines

Read raw Markdown by 1-based line range.

Options:

  • --root
  • --file (required): relative markdown path under root
  • --start (required)
  • --end (required)
  • --max-lines
  • --format

Example:

uv run md-scope read-lines --root ./examples --file SKILL.md --start 1 --end 40 --max-lines 60

read-section

Read section(s) by id from index.

Options:

  • --root
  • --index
  • --id (repeatable)
  • --max-lines
  • --mode: simple|contextual
  • --format

Modes:

  • simple: direct section-range read (id maps to its indexed start/end)
  • contextual: path-aware reconstruction for AI
    • returns ancestor heading + intro context
    • returns target full subtree
    • excludes unrelated siblings
    • deduplicates ancestor/descendant target overlap

Return shape:

  • Single --id: returns one object
  • Multiple --id in simple: returns { "results": [...], "errors": [...] }
  • Multiple --id in contextual: returns grouped contextual payload (single-file or files array)

Examples:

uv run md-scope read-section --root ./examples --id section-a
uv run md-scope read-section --root ./examples --id section-a --id section-b --mode simple --format json
uv run md-scope read-section --root ./examples --id section-a --id section-b --mode contextual --format text

md-files

List Markdown files under root (or subdirectory), useful for agent/tool discovery.

Options:

  • --root
  • --target: optional subdirectory
  • --format

Example:

uv run md-scope md-files --root ./examples --format json
uv run md-scope md-files --root ./examples --target references --format markdown

Hidden Compatibility Alias

  • view is kept as hidden alias for outline.

Config (md-scope.toml)

Use one [global] section for reusable defaults. CLI arguments override config values.

Example:

[global]
root = "./examples"
index = "./examples/.md-scope-index.json"
include = ["*.md", "**/*.md"]
overwrite = true

provider = "openai-compatible"
api_base = "https://api.openai.com/v1"
api_key = "YOUR_KEY"
model = "gpt-5-mini"
api_timeout_seconds = 30
api_requests_per_minute = 30
system_prompt = "You are a concise technical summarizer."
user_prompt = "Summarize in Chinese:\n{content}"

summary_root_level = 2
include_excluded_ancestors_as_context = true

format = "json"
max_lines = 200

Index Shape (Public)

{
  "files": [
    {
      "file-name": "SKILL.md",
      "path": "SKILL.md",
      "line_count": 100,
      "sections": [
        {
          "id": "intro-ab12",
          "title": "Intro",
          "level": 2,
          "start": 10,
          "end": 30,
          "summary": "..."
        }
      ]
    }
  ]
}

Development

Run tests only in project venv:

uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown_scope-0.1.0.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_scope-0.1.0-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file markdown_scope-0.1.0.tar.gz.

File metadata

  • Download URL: markdown_scope-0.1.0.tar.gz
  • Upload date:
  • Size: 56.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for markdown_scope-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54033fa3624dfc354c6d40ace452462c63dce86316265ed8cf0a1daf5b2c8fc2
MD5 f2ac69e647ef154088d73825f1536a17
BLAKE2b-256 c19c3ae2d23a2576a4f81000610c7d43a67a597853c589cec4d11bb9455956f7

See more details on using hashes here.

File details

Details for the file markdown_scope-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: markdown_scope-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for markdown_scope-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 071ffc2ba5c2abbe580e8c8e9f9442fb059c35a7d7e351e3706e10f8250a4bd5
MD5 893f05e462b02dcb9cd03c62da6c92d8
BLAKE2b-256 d5bf363b37aa37ff3474e303d7697092f2424fd0ee47f4ab703211d6df7e94a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page