pyclaudecli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Suriya Ravichandran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.5
2
+ Name: pyclaudecli
3
+ Version: 0.1.0
4
+ Summary: Python library wrapping the Claude Code CLI: prompts, background agents, auth, MCP, plugins, and more
5
+ Author-email: Suriya Ravichandran <suriyaravichandran@itrendsolution.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: anthropic,automation,claude,claude-code,cli,sdk,wrapper
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+
24
+ # pyclaudecli
25
+
26
+ A Python library that wraps the [Claude Code](https://claude.com/claude-code) CLI (`claude`) so you can drive it from Python instead of shelling out by hand: one-shot prompts, JSON/streaming output, background agents, authentication, MCP servers, plugins, and the rest of the CLI's surface.
27
+
28
+ It's a thin wrapper, not a reimplementation — every call runs the real `claude` binary, so it always reflects whatever version, auth, and config you have installed locally.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install pyclaudecli
34
+ ```
35
+
36
+ Requires the `claude` CLI itself to be installed and on `PATH` (see the [Claude Code docs](https://claude.com/claude-code)).
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ from pyclaudecli import ClaudeCLI
42
+
43
+ claude = ClaudeCLI()
44
+
45
+ # One-shot prompt
46
+ print(claude.prompt("Summarize this repo's README.", model="haiku"))
47
+
48
+ # Structured result (cost, session id, etc.)
49
+ result = claude.prompt_json("What's 2+2?", model="haiku")
50
+ print(result["result"], result["total_cost_usd"])
51
+
52
+ # Live streaming events
53
+ for event in claude.prompt_stream("Write a haiku about tests.", model="haiku"):
54
+ print(event["type"])
55
+ ```
56
+
57
+ ## Background agents
58
+
59
+ ```python
60
+ session_id = claude.start_background("Refactor the auth module", model="sonnet")
61
+ claude.list_agents()
62
+ claude.logs(session_id, strip_ansi=True)
63
+ claude.stop(session_id)
64
+ claude.rm(session_id)
65
+ ```
66
+
67
+ ## Auth
68
+
69
+ ```python
70
+ claude.auth_status() # {"loggedIn": True, "email": "...", ...}
71
+
72
+ # Prints the sign-in URL, then forwards the pasted code to finish login
73
+ claude.auth_login()
74
+ ```
75
+
76
+ ## MCP servers and plugins
77
+
78
+ ```python
79
+ claude.mcp_add("sentry", "https://mcp.sentry.dev/mcp", transport="http")
80
+ claude.mcp_list()
81
+
82
+ claude.plugin_install("some-plugin", yes=True)
83
+ claude.plugin_list(as_json=True)
84
+ ```
85
+
86
+ See `ClaudeCLI`'s docstrings for the full method list — it covers every top-level `claude` command (`auth`, `mcp`, `plugin`, `project`, `agents`/background sessions, `auto-mode`, `doctor`, `update`, `install`, `import`, `ultrareview`, `gateway`) plus the main prompt flags. Anything not exposed as a named parameter can still be passed through via each method's `extra_flags` dict.
87
+
88
+ ## Errors
89
+
90
+ All CLI failures raise `ClaudeCLIError` (or `ClaudeNotFoundError` / `ClaudeTimeoutError`), carrying `returncode`, `stdout`, and `stderr`.
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,71 @@
1
+ # pyclaudecli
2
+
3
+ A Python library that wraps the [Claude Code](https://claude.com/claude-code) CLI (`claude`) so you can drive it from Python instead of shelling out by hand: one-shot prompts, JSON/streaming output, background agents, authentication, MCP servers, plugins, and the rest of the CLI's surface.
4
+
5
+ It's a thin wrapper, not a reimplementation — every call runs the real `claude` binary, so it always reflects whatever version, auth, and config you have installed locally.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install pyclaudecli
11
+ ```
12
+
13
+ Requires the `claude` CLI itself to be installed and on `PATH` (see the [Claude Code docs](https://claude.com/claude-code)).
14
+
15
+ ## Quickstart
16
+
17
+ ```python
18
+ from pyclaudecli import ClaudeCLI
19
+
20
+ claude = ClaudeCLI()
21
+
22
+ # One-shot prompt
23
+ print(claude.prompt("Summarize this repo's README.", model="haiku"))
24
+
25
+ # Structured result (cost, session id, etc.)
26
+ result = claude.prompt_json("What's 2+2?", model="haiku")
27
+ print(result["result"], result["total_cost_usd"])
28
+
29
+ # Live streaming events
30
+ for event in claude.prompt_stream("Write a haiku about tests.", model="haiku"):
31
+ print(event["type"])
32
+ ```
33
+
34
+ ## Background agents
35
+
36
+ ```python
37
+ session_id = claude.start_background("Refactor the auth module", model="sonnet")
38
+ claude.list_agents()
39
+ claude.logs(session_id, strip_ansi=True)
40
+ claude.stop(session_id)
41
+ claude.rm(session_id)
42
+ ```
43
+
44
+ ## Auth
45
+
46
+ ```python
47
+ claude.auth_status() # {"loggedIn": True, "email": "...", ...}
48
+
49
+ # Prints the sign-in URL, then forwards the pasted code to finish login
50
+ claude.auth_login()
51
+ ```
52
+
53
+ ## MCP servers and plugins
54
+
55
+ ```python
56
+ claude.mcp_add("sentry", "https://mcp.sentry.dev/mcp", transport="http")
57
+ claude.mcp_list()
58
+
59
+ claude.plugin_install("some-plugin", yes=True)
60
+ claude.plugin_list(as_json=True)
61
+ ```
62
+
63
+ See `ClaudeCLI`'s docstrings for the full method list — it covers every top-level `claude` command (`auth`, `mcp`, `plugin`, `project`, `agents`/background sessions, `auto-mode`, `doctor`, `update`, `install`, `import`, `ultrareview`, `gateway`) plus the main prompt flags. Anything not exposed as a named parameter can still be passed through via each method's `extra_flags` dict.
64
+
65
+ ## Errors
66
+
67
+ All CLI failures raise `ClaudeCLIError` (or `ClaudeNotFoundError` / `ClaudeTimeoutError`), carrying `returncode`, `stdout`, and `stderr`.
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pyclaudecli"
7
+ version = "0.1.0"
8
+ description = "Python library wrapping the Claude Code CLI: prompts, background agents, auth, MCP, plugins, and more"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Suriya Ravichandran", email = "suriyaravichandran@itrendsolution.com" },
14
+ ]
15
+ keywords = ["claude", "claude-code", "cli", "automation", "anthropic", "wrapper", "sdk"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ]
30
+
31
+ [project.scripts]
32
+ pyclaudecli = "pyclaudecli.__main__:main"
33
+
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["src/pyclaudecli"]
@@ -0,0 +1,14 @@
1
+ """pyclaudecli: a Python library that wraps the `claude` CLI (Claude Code)."""
2
+
3
+ from .client import ClaudeCLI, build_flags
4
+ from .exceptions import ClaudeCLIError, ClaudeNotFoundError, ClaudeTimeoutError
5
+
6
+ __version__ = "0.1.0"
7
+
8
+ __all__ = [
9
+ "ClaudeCLI",
10
+ "build_flags",
11
+ "ClaudeCLIError",
12
+ "ClaudeNotFoundError",
13
+ "ClaudeTimeoutError",
14
+ ]
@@ -0,0 +1,61 @@
1
+ """`python -m pyclaudecli` — a minimal CLI wrapper for quick scripting.
2
+
3
+ For anything beyond a one-off prompt, use `pyclaudecli.ClaudeCLI` directly.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import sys
9
+ from typing import List, Optional, Tuple
10
+
11
+ from .client import ClaudeCLI
12
+
13
+
14
+ def parse_args(argv: List[str]) -> Tuple[str, str]:
15
+ model = "haiku"
16
+ prompt_parts = []
17
+ index = 0
18
+
19
+ while index < len(argv):
20
+ arg = argv[index]
21
+
22
+ if arg in {"--model", "-m"}:
23
+ if index + 1 >= len(argv):
24
+ raise SystemExit("Missing value for --model.")
25
+ model = argv[index + 1]
26
+ index += 2
27
+ continue
28
+
29
+ if arg.startswith("--model="):
30
+ model = arg.split("=", 1)[1]
31
+ index += 1
32
+ continue
33
+
34
+ prompt_parts.append(arg)
35
+ index += 1
36
+
37
+ prompt = " ".join(prompt_parts).strip() if prompt_parts else "Hello, Claude!"
38
+ return model, prompt
39
+
40
+
41
+ def main(argv: Optional[List[str]] = None) -> int:
42
+ if argv is None:
43
+ argv = sys.argv[1:]
44
+
45
+ model, prompt = parse_args(argv)
46
+ client = ClaudeCLI()
47
+ try:
48
+ result = client.run(["--print", "--model", model, prompt], check=False)
49
+ except Exception as exc: # ClaudeNotFoundError, etc.
50
+ print(str(exc), file=sys.stderr)
51
+ return 1
52
+
53
+ if result.stdout:
54
+ print(result.stdout, end="")
55
+ if result.stderr:
56
+ print(result.stderr, file=sys.stderr, end="")
57
+ return result.returncode
58
+
59
+
60
+ if __name__ == "__main__":
61
+ raise SystemExit(main())