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

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

Annotations: |
  During development and testing, use the practice `conventions`.
  For parsing Swift files, use the practice `tree-sitter-swift`.

---

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

    `cell_path`: path to the Swift module (directory with .swift files)

    Algorithm:
    - find all .swift files in the directory
    - for each file — parse AST via the practice `tree-sitter-swift`
    - extract public declarations:
      - public class/struct/actor/enum → EntityContract (init params → signature, properties, methods)
      - top-level public func → RoutineContract
      - public protocol → EntityContract (only methods, without properties)
    - collect signatures: parameters (name + type), return types

    Requirements:
    - only public declarations are included in the contract (internal/private are skipped)
    - Swift type annotations are included in the contract
    - argument order matters
    - optionals (T?) are included in the type
    - camelCase for function/property names, PascalCase for types
    - EntityContract for class/struct gets signature from init

---

Author: Goga
CreatedAt: 21/05/26

Description: |
  Extracting the contract from the Swift module facade via tree-sitter-swift
