|
| 1 | +--- |
| 2 | +allowed-tools: Bash(git commit:*), Bash(git add:*), Bash(git status:*), Bash(mkdir:*), Bash(uv:*), Read, Edit(sdk/python/**), Write(sdk/python/**), Edit(.github/workflows/python.yml), Write(.github/workflows/python.yml), Write(.github/workflows/release.yml), Edit(.github/workflows/release.yml) |
| 3 | +argument-hint: [ts-change-sha-commit] |
| 4 | +description: Generate Python SDK for agentfs based on the Typescript SDK |
| 5 | +--- |
| 6 | + |
| 7 | +## Dev rules |
| 8 | + |
| 9 | +- COMMIT your changes in the end with detailed message with the motivation of changes and traces of your actions |
| 10 | +- USE `uv` with `--directory sdk/python` command in order to avoid `cd` to the subdirectory |
| 11 | +- ALWAYS USE pathes relative to the project root |
| 12 | +- DO NOT EVER `cd` into the directories - tool permissions will not be validated properly |
| 13 | +- USE ONLY SIMPLE "ls", "grep", "find", "cat" Bash commands and native Claude Code tools - otherwise permission will be blocked |
| 14 | + |
| 15 | +## Context |
| 16 | + |
| 17 | +- You must generate Python SDK with the API similar to the current Typescript SDK located at ../../sdk/typescript |
| 18 | +- The package name is `agentfs-sdk` and import path must be `agentfs_sdk` |
| 19 | +- You must transfer all tests from Typescript SDK to the Python |
| 20 | +- Last time, python sdk was updated based on the comment $1 |
| 21 | + - If value is "unspecified" then regenerate SDK from scratch |
| 22 | + - If value is set - FOCUS on the diff between the current state and specified commit hash |
| 23 | + - The primary changes are in the Typescript SDK but changes outside of it also can contribute to the process |
| 24 | + - For example, command prompt in .claude directory influence process heavily |
| 25 | +- Use `turso.aio` python package which provide API similar to `aiosqlite` |
| 26 | +- Use simple setup with builtin uv ruff formatter |
| 27 | +- Use pytest for testing |
| 28 | +- Use ty for type checking |
| 29 | +- Maintain CI for linting and checking at .github/workflows/python.yml similar to the TS workflow at .github/workflows/typescript.yml |
| 30 | +- Maintain CI for publishing the Python package to the PyPI in the .github/workflows/release.yml |
| 31 | + - Use `PYPI_API_TOKEN` secret |
| 32 | + |
| 33 | +```py |
| 34 | +class Connection: |
| 35 | + def __init__(self, connector: Callable[[], BlockingConnection]) -> None: |
| 36 | + async def close(self) -> None: |
| 37 | + def __await__(self): |
| 38 | + async def __aenter__(self) -> "Connection": |
| 39 | + async def __aexit__(self, exc_type, exc, tb) -> None: |
| 40 | + def cursor(self, factory: Optional[Callable[[BlockingConnection], BlockingCursor]] = None) -> "Cursor": |
| 41 | + async def execute(self, sql: str, parameters: Sequence[Any] | Mapping[str, Any] = ()) -> "Cursor": |
| 42 | + async def executemany(self, sql: str, parameters: Iterable[Sequence[Any] | Mapping[str, Any]]) -> "Cursor": |
| 43 | + async def executescript(self, sql_script: str) -> "Cursor": |
| 44 | + async def commit(self) -> None: |
| 45 | + async def rollback(self) -> None: |
| 46 | +class Cursor: |
| 47 | + async def close(self) -> None: |
| 48 | + # named parameters not supported at the moment |
| 49 | + async def execute(self, sql: str, parameters: Sequence[Any] | Mapping[str, Any] = ()) -> "Cursor": |
| 50 | + async def executemany(self, sql: str, parameters: Iterable[Sequence[Any] | Mapping[str, Any]]) -> "Cursor": |
| 51 | + async def executescript(self, sql_script: str) -> "Cursor": |
| 52 | + async def fetchone(self) -> Any: |
| 53 | + async def fetchmany(self, size: Optional[int] = None) -> list[Any]: |
| 54 | + async def fetchall(self) -> list[Any]: |
| 55 | + async def __aenter__(self) -> "Cursor": |
| 56 | + async def __aexit__(self, exc_type, exc, tb) -> None: |
| 57 | + |
| 58 | +# as Connection is awaitable - caller can use await connect(...) |
| 59 | +def connect(database: str) -> Connection: |
| 60 | +``` |
0 commit comments