Metadata-Version: 2.4
Name: my-opencode-cli
Version: 0.2.0
Summary: A modern Python client library for OpenCode server
Project-URL: Homepage, https://github.com/iibyteCoder/my-opencode-cli
Project-URL: Documentation, https://github.com/iibyteCoder/my-opencode-cli#readme
Project-URL: Repository, https://github.com/iibyteCoder/my-opencode-cli.git
Project-URL: Issues, https://github.com/iibyteCoder/my-opencode-cli/issues
Author: iibyteCoder
License-Expression: MIT
License-File: LICENSE
Keywords: ai,async,client,llm,opencode
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: <3.13,>=3.11
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: click>=8.0.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.0.0
Provides-Extra: dev
Requires-Dist: coverage[toml]>=7.0.0; extra == 'dev'
Requires-Dist: mypy>=1.11.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.7.0; extra == 'dev'
Requires-Dist: types-aiofiles; extra == 'dev'
Requires-Dist: types-click; extra == 'dev'
Description-Content-Type: text/markdown

# OpenCode Python Client

[![Python](https://img.shields.io/badge/Python-3.11+-blue.svg)](https://www.python.org/)
[![Pydantic](https://img.shields.io/badge/Pydantic-v2-green.svg)](https://docs.pydantic.dev/)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

Python 客户端库，用于与 [OpenCode](https://opencode.ai) 服务器交互。

## 安装

```bash
uv add my-opencode-cli
# 或
pip install my-opencode-cli
```

## 快速开始

```python
import asyncio
from my_opencode_cli import AsyncOpenCode

async def main():
    async with AsyncOpenCode(start_server=True) as client:
        # 快速提问
        answer = await client.ask("什么是 Python 装饰器？")
        print(answer)

        # 流式输出
        async for event in client.ask_stream("写一个快速排序"):
            if event.type == "message.part.updated":
                text = event.properties.part.text
                if text:
                    print(text, end="")

asyncio.run(main())
```

同步客户端：

```python
from my_opencode_cli import OpenCode

with OpenCode(start_server=True) as client:
    print(client.ask("什么是闭包？"))
```

## 文档

详细文档请参阅 [docs/guide/](docs/guide/)。

## 开发

```bash
git clone https://github.com/iibyteCoder/my-opencode-cli.git
cd my-opencode-cli
uv sync --all-extras

# 测试
uv run pytest

# 类型检查
uv run mypy src/opencode_client --strict
```

## 许可证

[MIT License](LICENSE)
