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

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

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

---

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

    `cell_path`: path to the Go package (directory with .go files)

    Algorithm:
    - find all .go files in the directory (excluding _test.go)
    - for each file — parse AST via the practice `tree-sitter`
    - extract exported declarations (capitalized):
      - function_declaration → RoutineContract
      - struct_type → EntityContract (fields → properties, methods → methods)
      - interface_type → EntityContract (method specs → methods)
    - for EntityContract (struct) — find method_declaration with the corresponding receiver
    - collect signatures: parameters (name + type), return types

    Requirements:
    - only exported (capitalized) declarations
    - type annotations from Go code are included in the contract
    - argument order matters
    - _test.go files are skipped
    - normalize via sorting for stable order
    - EntityContract for struct/interface always gets signature="()": Go has no explicit constructors,
      instance creation is zero-value or struct literal, which is semantically equivalent to an empty parameter list

---

Author: Goga
CreatedAt: 19/05/26

Description: |
  Extract contract from the facade of a Go package via tree-sitter
