OUTPUT FORMATS:

MARKDOWN (default, -f markdown):
  Each document is wrapped in a four-backtick fenced block with the info
  string "markdown #<key>". Inside the fence: YAML frontmatter, a blank
  line, then the rendered markdown body.

    ````markdown #doc-a
    ---
    title: Document A
    includedBy:
      - key: parent-doc
        title: Parent Doc
    ---

    # Document A

    Content here...
    ````

  Multiple documents are separated by one blank line between blocks.
  Empty edge lists (includedBy, includes, referencedBy) are omitted
  from frontmatter.

KEYS (-f keys):
  One document key per line, suitable for piping:

    doc-a
    child-doc
    parent-doc

JSON (-f json):
  Flat array of document objects:

    [{"key": "...", "title": "...", "content": "...",
      "includedBy": [...], "includes": [...],
      "referencedBy": [...]}]

YAML (-f yaml):
  Same shape as JSON, rendered as YAML.

FILTER FLAGS (narrow the result set):

  --filter "EXPR"             Inline filter expression (YAML).
  -k, --key KEY               $key match. Repeatable: 1 key uses $eq, 2+ uses $in.
  --includes KEY[:DEPTH]      $includes anchor.
  --included-by KEY[:DEPTH]   $includedBy anchor.
  --references KEY[:DIST]     $references anchor.
  --referenced-by KEY[:DIST]  $referencedBy anchor.
  --max-depth N               Default maxDepth for inclusion anchors. Default 1.
  --max-distance N            Default maxDistance for reference anchors. Default 1.

SHAPE FLAGS:

  --children                  Populate the includes array with child document edges.
  --no-content                Exclude document content (metadata only).
  -b, --backlinks             Include incoming references (referencedBy).
  -d N                        Follow block refs down N levels (default 1).
  -c N                        Include N levels of parent context (default 1).
  -l, --links                 Include inline references.

EXAMPLES:

  iwe retrieve -k doc-a                               # single document
  iwe retrieve -k doc-a -d 2                           # two levels of children
  iwe retrieve -k doc-a --children -f json             # includes array populated
  iwe retrieve -k doc-a --no-content -f json           # metadata only
  iwe retrieve -k x -k y -k z                          # multiple specific keys
  iwe retrieve --included-by projects/alpha -f keys    # keys inside alpha
  iwe retrieve -k doc-a --dry-run                      # preview: doc count and lines
