Metadata-Version: 2.4
Name: scienith-command-catalog
Version: 0.1.0
Summary: Read versioned App command declarations from contract packages.
Author: Scienith
License-Expression: LicenseRef-Proprietary
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: PyYAML<7,>=6
Requires-Dist: referencing<1,>=0.37

# Scienith Command Catalog

供 App 的 Python SDK 和后端读取契约包里的命令声明。支持列出命令、按声明中的执行方式过滤、按 `commandType` 查详情，以及解析参数 Schema。

## 安装

本地开发用 uv 创建虚拟环境并可编辑安装。

```sh
uv venv .venv
source .venv/bin/activate
uv pip install -e .
python -m unittest discover -s tests -v
uv build --wheel
```

正式发布使用 Python wheel，发布到组织私有 PyPI 后由 App SDK 固定版本依赖，例如 `scienith-command-catalog==0.1.0`。

## 使用

App SDK 将已安装契约包里的目录路径传给读取器。契约根目录包含 `command-catalog/` 和声明引用的 Schema 文件。

```python
from pathlib import Path

from scienith_command_catalog import CommandCatalog

contract_root = Path("path/to/installed/app-contract")
catalog = CommandCatalog.load(contract_root)
commands = catalog.list_commands(execution_path="approved_proposal")
command = catalog.get_command("report.publish")
parameters = catalog.get_input_schema(command["commandType"])
print(parameters.contents)
```

这里的过滤依据是契约里声明的执行方式。获取当前用户实际可用的命令时，App SDK 调用所属 App 后端，由后端核对权限和业务状态。

如果参数模型内部还有 `$ref`，使用 `parameters.reference` 和 `catalog.schema_registry` 调用现有 JSON Schema 校验器，可以保留相对引用的解析位置。完整的接口及失败行为见 [命令目录读取规格](spec/catalog-reader.md)。

## 发布

`main` 上通过 CI 的提交用 `vX.Y.Z` 发布，标签版本与 `pyproject.toml` 一致。工作流验证测试、构建 wheel、发布到组织私有 PyPI，并从私有源重新安装执行测试。
