Imports:
  - Types:
      - EntityContract
      - RoutineContract
    Usages:
      - contract_data
    From: goga/contract/data

Usages:
  conventions: .goga/usages/conventions.md
  tree-sitter-kotlin: .goga/usages/cooks/tree-sitter-kotlin.md

Annotations: |
  During development and testing, use practice `conventions`.
  For parsing Kotlin files, use practice `tree-sitter-kotlin`.

---

"kotlin_contract(cell_path: str) -> contracts:list[EntityContract | RoutineContract]":
  location: kotlin.py
  annotations: |
    Collect all exported objects from the Kotlin package facade at the specified path.
    Use practice `contract_data` to form the results.

    `cell_path`: path to the Kotlin package (directory with .kt files)

    Algorithm:
    - find all .kt files in the directory
    - for each file — parse the AST via practice `tree-sitter-kotlin`
    - extract public declarations:
      - class/data class/sealed class/interface/enum class → EntityContract (constructor params → signature, properties, methods)
      - top-level fun → RoutineContract
      - object declaration → EntityContract
    - for EntityContract (class) — find extension/member functions with the corresponding receiver
    - collect signatures: parameters (name + type), return types

    Requirements:
    - only public declarations are included in the contract (internal/private are skipped)
    - Kotlin type annotations are included in the contract
    - argument order matters
    - nullability (T?) is included in the type
    - camelCase for function/property names, PascalCase for classes
    - EntityContract for class gets signature from primary constructor

---

Author: Goga
CreatedAt: 21/05/26

Description: |
  Contract extraction from the Kotlin package facade via tree-sitter-kotlin
