pycastle 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.
Files changed (66) hide show
  1. pycastle-0.1.0/.github/workflows/publish.yml +89 -0
  2. pycastle-0.1.0/.gitignore +210 -0
  3. pycastle-0.1.0/.python-version +1 -0
  4. pycastle-0.1.0/LICENSE +21 -0
  5. pycastle-0.1.0/PKG-INFO +89 -0
  6. pycastle-0.1.0/README.md +45 -0
  7. pycastle-0.1.0/UBIQUITOUS_LANGUAGE.md +215 -0
  8. pycastle-0.1.0/pycastle/.gitignore +3 -0
  9. pycastle-0.1.0/pycastle/Dockerfile +34 -0
  10. pycastle-0.1.0/pycastle/config.py +45 -0
  11. pycastle-0.1.0/pycastle/prompts/CODING_STANDARDS.md +83 -0
  12. pycastle-0.1.0/pycastle/prompts/implement-prompt.md +126 -0
  13. pycastle-0.1.0/pycastle/prompts/merge-prompt.md +18 -0
  14. pycastle-0.1.0/pycastle/prompts/plan-prompt.md +35 -0
  15. pycastle-0.1.0/pycastle/prompts/preflight-issue.md +102 -0
  16. pycastle-0.1.0/pycastle/prompts/review-prompt.md +87 -0
  17. pycastle-0.1.0/pyproject.toml +67 -0
  18. pycastle-0.1.0/setup.cfg +4 -0
  19. pycastle-0.1.0/src/pycastle/__init__.py +0 -0
  20. pycastle-0.1.0/src/pycastle/build_command.py +34 -0
  21. pycastle-0.1.0/src/pycastle/claude_service.py +28 -0
  22. pycastle-0.1.0/src/pycastle/config.py +34 -0
  23. pycastle-0.1.0/src/pycastle/container_runner.py +465 -0
  24. pycastle-0.1.0/src/pycastle/defaults/.gitignore +3 -0
  25. pycastle-0.1.0/src/pycastle/defaults/Dockerfile +34 -0
  26. pycastle-0.1.0/src/pycastle/defaults/config.py +47 -0
  27. pycastle-0.1.0/src/pycastle/defaults/prompts/CODING_STANDARDS.md +83 -0
  28. pycastle-0.1.0/src/pycastle/defaults/prompts/implement-prompt.md +126 -0
  29. pycastle-0.1.0/src/pycastle/defaults/prompts/merge-prompt.md +18 -0
  30. pycastle-0.1.0/src/pycastle/defaults/prompts/plan-prompt.md +35 -0
  31. pycastle-0.1.0/src/pycastle/defaults/prompts/preflight-issue.md +102 -0
  32. pycastle-0.1.0/src/pycastle/defaults/prompts/review-prompt.md +87 -0
  33. pycastle-0.1.0/src/pycastle/docker_service.py +42 -0
  34. pycastle-0.1.0/src/pycastle/errors.py +75 -0
  35. pycastle-0.1.0/src/pycastle/git_service.py +209 -0
  36. pycastle-0.1.0/src/pycastle/github_service.py +261 -0
  37. pycastle-0.1.0/src/pycastle/init_command.py +116 -0
  38. pycastle-0.1.0/src/pycastle/labels.py +176 -0
  39. pycastle-0.1.0/src/pycastle/main.py +73 -0
  40. pycastle-0.1.0/src/pycastle/orchestrator.py +504 -0
  41. pycastle-0.1.0/src/pycastle/prompt_pipeline.py +42 -0
  42. pycastle-0.1.0/src/pycastle/validate.py +99 -0
  43. pycastle-0.1.0/src/pycastle/worktree.py +117 -0
  44. pycastle-0.1.0/src/pycastle.egg-info/PKG-INFO +89 -0
  45. pycastle-0.1.0/src/pycastle.egg-info/SOURCES.txt +64 -0
  46. pycastle-0.1.0/src/pycastle.egg-info/dependency_links.txt +1 -0
  47. pycastle-0.1.0/src/pycastle.egg-info/entry_points.txt +2 -0
  48. pycastle-0.1.0/src/pycastle.egg-info/requires.txt +9 -0
  49. pycastle-0.1.0/src/pycastle.egg-info/top_level.txt +1 -0
  50. pycastle-0.1.0/tests/__init__.py +0 -0
  51. pycastle-0.1.0/tests/conftest.py +29 -0
  52. pycastle-0.1.0/tests/test_build_command.py +173 -0
  53. pycastle-0.1.0/tests/test_claude_service.py +136 -0
  54. pycastle-0.1.0/tests/test_config.py +68 -0
  55. pycastle-0.1.0/tests/test_container_runner.py +2214 -0
  56. pycastle-0.1.0/tests/test_docker_service.py +239 -0
  57. pycastle-0.1.0/tests/test_errors.py +154 -0
  58. pycastle-0.1.0/tests/test_git_service.py +757 -0
  59. pycastle-0.1.0/tests/test_github_service.py +699 -0
  60. pycastle-0.1.0/tests/test_integration.py +1 -0
  61. pycastle-0.1.0/tests/test_labels.py +83 -0
  62. pycastle-0.1.0/tests/test_orchestrator.py +2515 -0
  63. pycastle-0.1.0/tests/test_prompt_pipeline.py +70 -0
  64. pycastle-0.1.0/tests/test_prompt_templates.py +117 -0
  65. pycastle-0.1.0/tests/test_validate.py +412 -0
  66. pycastle-0.1.0/tests/test_worktree.py +485 -0
@@ -0,0 +1,89 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ tags:
8
+ - 'v*.*.*'
9
+ pull_request:
10
+ branches:
11
+ - main
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+
25
+ - name: Install
26
+ run: pip install -e ".[dev]"
27
+
28
+ - name: Lint
29
+ run: ruff check
30
+
31
+ - name: Type-check
32
+ run: mypy src
33
+
34
+ - name: Test
35
+ run: pytest
36
+
37
+ publish-testpypi:
38
+ runs-on: ubuntu-latest
39
+ needs: test
40
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
41
+ environment: testpypi
42
+ permissions:
43
+ id-token: write
44
+ contents: read
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ with:
48
+ fetch-depth: 0
49
+
50
+ - uses: actions/setup-python@v5
51
+ with:
52
+ python-version: "3.12"
53
+
54
+ - name: Install build
55
+ run: pip install build
56
+
57
+ - name: Build
58
+ run: python -m build
59
+
60
+ - name: Publish to TestPyPI
61
+ uses: pypa/gh-action-pypi-publish@release/v1
62
+ with:
63
+ repository-url: https://test.pypi.org/legacy/
64
+
65
+ publish-pypi:
66
+ runs-on: ubuntu-latest
67
+ needs: test
68
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
69
+ environment: pypi
70
+ permissions:
71
+ id-token: write
72
+ contents: read
73
+ steps:
74
+ - uses: actions/checkout@v4
75
+ with:
76
+ fetch-depth: 0
77
+
78
+ - uses: actions/setup-python@v5
79
+ with:
80
+ python-version: "3.12"
81
+
82
+ - name: Install build
83
+ run: pip install build
84
+
85
+ - name: Build
86
+ run: python -m build
87
+
88
+ - name: Publish to PyPI
89
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,210 @@
1
+ *.idea
2
+ *.claude
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[codz]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py.cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # UV
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ #uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ #poetry.lock
112
+ #poetry.toml
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118
+ #pdm.lock
119
+ #pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # pixi
124
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125
+ #pixi.lock
126
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127
+ # in the .venv directory. It is recommended not to include this directory in version control.
128
+ .pixi
129
+
130
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
131
+ __pypackages__/
132
+
133
+ # Celery stuff
134
+ celerybeat-schedule
135
+ celerybeat.pid
136
+
137
+ # SageMath parsed files
138
+ *.sage.py
139
+
140
+ # Environments
141
+ .env
142
+ .envrc
143
+ .venv
144
+ env/
145
+ venv/
146
+ ENV/
147
+ env.bak/
148
+ venv.bak/
149
+
150
+ # Spyder project settings
151
+ .spyderproject
152
+ .spyproject
153
+
154
+ # Rope project settings
155
+ .ropeproject
156
+
157
+ # mkdocs documentation
158
+ /site
159
+
160
+ # mypy
161
+ .mypy_cache/
162
+ .dmypy.json
163
+ dmypy.json
164
+
165
+ # Pyre type checker
166
+ .pyre/
167
+
168
+ # pytype static type analyzer
169
+ .pytype/
170
+
171
+ # Cython debug symbols
172
+ cython_debug/
173
+
174
+ # PyCharm
175
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
176
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
177
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
178
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
179
+ #.idea/
180
+
181
+ # Abstra
182
+ # Abstra is an AI-powered process automation framework.
183
+ # Ignore directories containing user credentials, local state, and settings.
184
+ # Learn more at https://abstra.io/docs
185
+ .abstra/
186
+
187
+ # Visual Studio Code
188
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
189
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
190
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
191
+ # you could uncomment the following to ignore the entire vscode folder
192
+ # .vscode/
193
+
194
+ # Ruff stuff:
195
+ .ruff_cache/
196
+
197
+ # PyPI configuration file
198
+ .pypirc
199
+
200
+ # Cursor
201
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
202
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
203
+ # refer to https://docs.cursor.com/context/ignore-files
204
+ .cursorignore
205
+ .cursorindexingignore
206
+
207
+ # Marimo
208
+ marimo/_static/
209
+ marimo/_lsp/
210
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.11.3
pycastle-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Matt Pocock
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,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: pycastle
3
+ Version: 0.1.0
4
+ Summary: Python orchestrator for autonomous Claude Code agents in Docker
5
+ License: MIT License
6
+
7
+ Copyright (c) Matt Pocock
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: Programming Language :: Python :: 3.11
29
+ Classifier: Programming Language :: Python :: 3.12
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Requires-Python: >=3.11.3
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: click
36
+ Requires-Dist: docker
37
+ Requires-Dist: python-dotenv
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest; extra == "dev"
40
+ Requires-Dist: mypy; extra == "dev"
41
+ Requires-Dist: ruff; extra == "dev"
42
+ Requires-Dist: types-docker; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # pycastle
46
+
47
+ pycastle is a Python orchestrator for autonomous [Claude Code](https://claude.ai/code) agents running inside Docker containers. It is inspired by [sandcastle](https://github.com/mattpocock/sandcastle) — Matt Pocock's original project — and brings the same multi-agent, worktree-based workflow to a pip-installable Python package with configurable prompts, Dockerfile, and environment.
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pip install pycastle
53
+ ```
54
+
55
+ ## Prerequisites
56
+
57
+ - Python 3.11.3 or later
58
+ - Docker (daemon must be running)
59
+ - A valid `ANTHROPIC_API_KEY` environment variable (or a `.env` file in your project root)
60
+
61
+ ## CLI Commands
62
+
63
+ ### `pycastle init`
64
+
65
+ Copies the default `pycastle/` configuration directory into your project root. This directory contains the `Dockerfile`, `config.py`, and prompt templates (`plan-prompt.md`, `implement-prompt.md`, `review-prompt.md`, `merge-prompt.md`, `CODING_STANDARDS.md`) that drive the agents. Run this once per repository, then customise the files to suit your project.
66
+
67
+ ```bash
68
+ pycastle init
69
+ ```
70
+
71
+ ### `pycastle build`
72
+
73
+ Builds the Docker image defined in `pycastle/Dockerfile`. Pass `--no-cache` to force a clean build. You must rebuild whenever you change the Dockerfile or install new dependencies.
74
+
75
+ ```bash
76
+ pycastle build [--no-cache]
77
+ ```
78
+
79
+ ### `pycastle run`
80
+
81
+ Reads a GitHub issue number and orchestrates a full agent pipeline inside Docker: a planner drafts an implementation plan, one or more implementer agents write the code on isolated git worktrees, a reviewer checks each implementation, and a merger integrates the approved changes. Progress is streamed to your terminal in real time.
82
+
83
+ ```bash
84
+ pycastle run
85
+ ```
86
+
87
+ ## Configuration
88
+
89
+ All runtime configuration lives in `pycastle/config.py`. Key settings include the GitHub repository, the Docker image name, agent model selection, and flags such as `skip_preflight`. Edit this file after running `pycastle init` to tailor the pipeline to your project.
@@ -0,0 +1,45 @@
1
+ # pycastle
2
+
3
+ pycastle is a Python orchestrator for autonomous [Claude Code](https://claude.ai/code) agents running inside Docker containers. It is inspired by [sandcastle](https://github.com/mattpocock/sandcastle) — Matt Pocock's original project — and brings the same multi-agent, worktree-based workflow to a pip-installable Python package with configurable prompts, Dockerfile, and environment.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install pycastle
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ - Python 3.11.3 or later
14
+ - Docker (daemon must be running)
15
+ - A valid `ANTHROPIC_API_KEY` environment variable (or a `.env` file in your project root)
16
+
17
+ ## CLI Commands
18
+
19
+ ### `pycastle init`
20
+
21
+ Copies the default `pycastle/` configuration directory into your project root. This directory contains the `Dockerfile`, `config.py`, and prompt templates (`plan-prompt.md`, `implement-prompt.md`, `review-prompt.md`, `merge-prompt.md`, `CODING_STANDARDS.md`) that drive the agents. Run this once per repository, then customise the files to suit your project.
22
+
23
+ ```bash
24
+ pycastle init
25
+ ```
26
+
27
+ ### `pycastle build`
28
+
29
+ Builds the Docker image defined in `pycastle/Dockerfile`. Pass `--no-cache` to force a clean build. You must rebuild whenever you change the Dockerfile or install new dependencies.
30
+
31
+ ```bash
32
+ pycastle build [--no-cache]
33
+ ```
34
+
35
+ ### `pycastle run`
36
+
37
+ Reads a GitHub issue number and orchestrates a full agent pipeline inside Docker: a planner drafts an implementation plan, one or more implementer agents write the code on isolated git worktrees, a reviewer checks each implementation, and a merger integrates the approved changes. Progress is streamed to your terminal in real time.
38
+
39
+ ```bash
40
+ pycastle run
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ All runtime configuration lives in `pycastle/config.py`. Key settings include the GitHub repository, the Docker image name, agent model selection, and flags such as `skip_preflight`. Edit this file after running `pycastle init` to tailor the pipeline to your project.