OUTPUT FORMATS:

MARKDOWN (default, -f markdown):
  Each document has YAML frontmatter followed by content:

    ---
    document:
      key: doc-a
      title: Document A
      parents:           # omitted if empty
      - key: parent-doc
        title: Parent Doc
      back-links:        # omitted if empty
      - key: other-doc
        title: Other Doc
    ---

    # Document A

    Content here...

  Multiple documents are separated by frontmatter delimiters (---).
  Two empty lines follow each document.

  Sub-documents show other parents with <- notation:

    # Child Doc

    [Child Doc](child-doc) <- [Other Parent](other-parent)

  This indicates child-doc is also embedded in other-parent, helping
  you understand where else a sub-document is used.

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

    doc-a
    child-doc
    parent-doc

JSON (-f json):
  Structured output:

    {"documents": [{"key": "...", "title": "...",
      "content": "...", "parent_documents": [...],
      "child_documents": [...], "backlinks": [...]}]}

STRUCTURAL SET SELECTOR (--in family):

  --in KEY[:DEPTH]      Restrict to sub-documents of EVERY listed key (AND).
                        Repeatable. KEY:DEPTH overrides --max-depth per entry.
  --in-any KEY[:DEPTH]  Restrict to sub-documents of AT LEAST ONE listed key (OR).
  --not-in KEY[:DEPTH]  Exclude sub-documents of any listed key (NOT).
  --max-depth N         Default depth for entries without :DEPTH. Unbounded if omitted.

EXAMPLES:

  # Retrieve all sub-documents of A AND B (intersection)
  iwe retrieve --in projects/alpha --in people/dmytro --depth 0

  # Read explicit keys but only those inside projects/alpha's subtree
  iwe retrieve -k x -k y -k z --in projects/alpha

  # Sub-documents of A within 2 hops, excluding archive
  iwe retrieve --in projects/alpha:2 --not-in archive
