Imports:
  - Types:
      - AST
    From: goga/ast

Usages:
  conventions: .goga/usages/conventions.md
  documents: |
    Operate on the `AST` entity.
    - The caller loads the project via AST.load()
    - The caller accesses the document tree through the AST.tree property
    The caller must instantiate `AST` with the current CWD path (".").
  beautiful_json: |
    Serialize a Python object to a formatted JSON string.
    json.dumps(data, indent=4, sort_keys=True, ensure_ascii=False)

Annotations: |
  The caller applies the `conventions` practice during development and testing.
  The caller uses the `documents` practice to load the project tree.
  The caller formats output through the `beautiful_json` practice.

---

"schema(cells: list[str], max_depth: int = None, depends_on: list[str] = []) -> json:str":
  location: schema.py
  annotations: |
    Generate a JSON schema of the project from the AST entity.

    `cells`: cell paths to include in the output
    `max_depth`: maximum nesting depth of the cell tree
    `depends_on`: filter cells by their dependencies
    `json`: JSON string representing the project schema

    Algorithm:
    1. Load the project document tree using the `documents` practice
    2. Recursively build a JSON tree with nested children nodes
    3. Apply filters: `cells`, `max_depth`, `depends_on`
    4. Return the JSON string using the `beautiful_json` practice

    Node format:
    {
      "cell": <path>,
      "description": <footer description>,
      "types": [<routine and entity names>],
      "usages": [<md files from .usages/>],
      "dependencies": {<path>: {"types": [...], "usages": [...]}},
      "children": [<children nodes>]
    }

    Requirements:
    - If `max_depth` is None: return the full tree without depth limits
    - If `depends_on` is an empty list: return the full tree without dependency filtering
    - If the tree is empty: return "[]"
    - If AST.errors is non-empty after loading: raise ValueError with the error count

---

Author: Mikhail Trifonov
CreatedAt: 15/05/26

Description: |
  This manifest defines how the `schema` routine generates the CODEMANIFEST project JSON schema.
