agent-bootstrap 0.1.0__py3-none-any.whl
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.
- agent_bootstrap-0.1.0.dist-info/METADATA +171 -0
- agent_bootstrap-0.1.0.dist-info/RECORD +15 -0
- agent_bootstrap-0.1.0.dist-info/WHEEL +5 -0
- agent_bootstrap-0.1.0.dist-info/entry_points.txt +3 -0
- agent_bootstrap-0.1.0.dist-info/licenses/LICENSE +21 -0
- agent_bootstrap-0.1.0.dist-info/top_level.txt +1 -0
- bootstrapper/__init__.py +1 -0
- bootstrapper/__main__.py +3 -0
- bootstrapper/agents.py +143 -0
- bootstrapper/cli.py +424 -0
- bootstrapper/composer.py +179 -0
- bootstrapper/dirtree.py +115 -0
- bootstrapper/github_utils.py +68 -0
- bootstrapper/presets.py +242 -0
- bootstrapper/templates.py +327 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"""Curated scaffold templates rendered with string.Template.
|
|
2
|
+
|
|
3
|
+
string.Template ($name, $description, $year, $holder) is chosen deliberately
|
|
4
|
+
over str.format()/Jinja2 because Helm's Go-template syntax (``{{ .Values.x }}``)
|
|
5
|
+
and GitHub Actions' ``${{ ... }}`` expressions must pass through untouched.
|
|
6
|
+
|
|
7
|
+
To emit a literal ``$`` in a template body, write ``$`` normally: string.Template
|
|
8
|
+
only substitutes ``$identifier`` or ``${identifier}``. GitHub Actions ``${{ ... }}``
|
|
9
|
+
is safe because ``{`` is not a valid identifier char. For the rare case where a
|
|
10
|
+
body needs a literal ``$name``-looking token, escape it as ``$$``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from string import Template
|
|
16
|
+
|
|
17
|
+
# name -> {metadata, files: {path: template_body}}
|
|
18
|
+
TEMPLATES: dict[str, dict] = {
|
|
19
|
+
"python-microservice": {
|
|
20
|
+
"name": "python-microservice",
|
|
21
|
+
"description": "Python service with Dockerfile, CI, and src layout",
|
|
22
|
+
"files": {
|
|
23
|
+
"README.md": "# $name\n\n$description\n",
|
|
24
|
+
".gitignore": "__pycache__/\n*.py[cod]\n.env\n.venv/\n",
|
|
25
|
+
"pyproject.toml": (
|
|
26
|
+
"[project]\n"
|
|
27
|
+
'name = "$name"\n'
|
|
28
|
+
'version = "0.1.0"\n'
|
|
29
|
+
'description = "$description"\n'
|
|
30
|
+
'requires-python = ">=3.11"\n\n'
|
|
31
|
+
"[build-system]\n"
|
|
32
|
+
'requires = ["setuptools>=61"]\n'
|
|
33
|
+
'build-backend = "setuptools.build_meta"\n'
|
|
34
|
+
),
|
|
35
|
+
"src/main.py": (
|
|
36
|
+
'"""$name entrypoint."""\n\n\n'
|
|
37
|
+
"def main() -> None:\n"
|
|
38
|
+
" print('Hello from $name!')\n\n\n"
|
|
39
|
+
'if __name__ == "__main__":\n'
|
|
40
|
+
" main()\n"
|
|
41
|
+
),
|
|
42
|
+
"requirements.txt": (
|
|
43
|
+
"# Runtime dependencies, one per line (pip install -r requirements.txt).\n"
|
|
44
|
+
),
|
|
45
|
+
"Dockerfile": (
|
|
46
|
+
"FROM python:3.11-slim\n"
|
|
47
|
+
"WORKDIR /app\n"
|
|
48
|
+
"COPY requirements.txt ./\n"
|
|
49
|
+
"RUN pip install --no-cache-dir -r requirements.txt\n"
|
|
50
|
+
"COPY . .\n"
|
|
51
|
+
'CMD ["python", "src/main.py"]\n'
|
|
52
|
+
),
|
|
53
|
+
".github/workflows/ci.yml": (
|
|
54
|
+
"name: CI\n"
|
|
55
|
+
"on: [push]\n"
|
|
56
|
+
"jobs:\n"
|
|
57
|
+
" build:\n"
|
|
58
|
+
" runs-on: ubuntu-latest\n"
|
|
59
|
+
" steps:\n"
|
|
60
|
+
" - uses: actions/checkout@v4\n"
|
|
61
|
+
" - uses: actions/setup-python@v5\n"
|
|
62
|
+
" with:\n"
|
|
63
|
+
" python-version: '3.11'\n"
|
|
64
|
+
" - run: python src/main.py\n"
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
"helm-chart": {
|
|
69
|
+
"name": "helm-chart",
|
|
70
|
+
"description": "Helm chart scaffold (Chart.yaml, values, templates, lint CI)",
|
|
71
|
+
"files": {
|
|
72
|
+
"Chart.yaml": (
|
|
73
|
+
'apiVersion: v2\n'
|
|
74
|
+
'name: $name\n'
|
|
75
|
+
'description: $description\n'
|
|
76
|
+
'type: application\n'
|
|
77
|
+
'version: 0.1.0\n'
|
|
78
|
+
'appVersion: "1.0.0"\n'
|
|
79
|
+
),
|
|
80
|
+
"values.yaml": (
|
|
81
|
+
"replicaCount: 1\n"
|
|
82
|
+
"nameOverride: \"\"\n"
|
|
83
|
+
"fullnameOverride: \"\"\n"
|
|
84
|
+
"image:\n"
|
|
85
|
+
" repository: ghcr.io/example/$name\n"
|
|
86
|
+
" tag: \"\"\n"
|
|
87
|
+
" pullPolicy: IfNotPresent\n"
|
|
88
|
+
"service:\n"
|
|
89
|
+
" type: ClusterIP\n"
|
|
90
|
+
" port: 80\n"
|
|
91
|
+
),
|
|
92
|
+
".helmignore": "logs/\n*.tfvars\n",
|
|
93
|
+
"templates/_helpers.tpl": (
|
|
94
|
+
'{{- define "$name.chart" -}}\n'
|
|
95
|
+
'{{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}\n'
|
|
96
|
+
"{{- end }}\n\n"
|
|
97
|
+
'{{- define "$name.name" -}}\n'
|
|
98
|
+
"{{ default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix \"-\" }}\n"
|
|
99
|
+
"{{- end }}\n\n"
|
|
100
|
+
'{{- define "$name.fullname" -}}\n'
|
|
101
|
+
"{{- if .Values.fullnameOverride }}\n"
|
|
102
|
+
'{{ .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}\n'
|
|
103
|
+
"{{- else }}\n"
|
|
104
|
+
'{{ printf "%s" .Chart.Name | trunc 63 | trimSuffix "-" }}\n'
|
|
105
|
+
"{{- end }}\n"
|
|
106
|
+
"{{- end }}\n\n"
|
|
107
|
+
'{{- define "$name.selectorLabels" -}}\n'
|
|
108
|
+
"app.kubernetes.io/name: {{ include \"$name.name\" . }}\n"
|
|
109
|
+
"app.kubernetes.io/instance: {{ .Release.Name }}\n"
|
|
110
|
+
"{{- end }}\n\n"
|
|
111
|
+
'{{- define "$name.labels" -}}\n'
|
|
112
|
+
"helm.sh/chart: {{ include \"$name.chart\" . }}\n"
|
|
113
|
+
"{{ include \"$name.selectorLabels\" . }}\n"
|
|
114
|
+
"{{- if .Chart.AppVersion }}\n"
|
|
115
|
+
"app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}\n"
|
|
116
|
+
"{{- end }}\n"
|
|
117
|
+
"app.kubernetes.io/managed-by: {{ .Release.Service }}\n"
|
|
118
|
+
"{{- end }}\n"
|
|
119
|
+
),
|
|
120
|
+
"templates/deployment.yaml": (
|
|
121
|
+
"apiVersion: apps/v1\n"
|
|
122
|
+
"kind: Deployment\n"
|
|
123
|
+
"metadata:\n"
|
|
124
|
+
" name: {{ include \"$name.fullname\" . }}\n"
|
|
125
|
+
" labels:\n"
|
|
126
|
+
" {{- include \"$name.labels\" . | nindent 4 }}\n"
|
|
127
|
+
"spec:\n"
|
|
128
|
+
" replicas: {{ .Values.replicaCount }}\n"
|
|
129
|
+
" selector:\n"
|
|
130
|
+
" matchLabels:\n"
|
|
131
|
+
" {{- include \"$name.selectorLabels\" . | nindent 6 }}\n"
|
|
132
|
+
" template:\n"
|
|
133
|
+
" metadata:\n"
|
|
134
|
+
" labels:\n"
|
|
135
|
+
" {{- include \"$name.selectorLabels\" . | nindent 8 }}\n"
|
|
136
|
+
" spec:\n"
|
|
137
|
+
" containers:\n"
|
|
138
|
+
" - name: $name\n"
|
|
139
|
+
" image: \"{{ .Values.image.repository }}:{{ .Values.image.tag }}\"\n"
|
|
140
|
+
),
|
|
141
|
+
"templates/service.yaml": (
|
|
142
|
+
"apiVersion: v1\n"
|
|
143
|
+
"kind: Service\n"
|
|
144
|
+
"metadata:\n"
|
|
145
|
+
" name: {{ include \"$name.fullname\" . }}\n"
|
|
146
|
+
"spec:\n"
|
|
147
|
+
" type: {{ .Values.service.type }}\n"
|
|
148
|
+
" ports:\n"
|
|
149
|
+
" - port: {{ .Values.service.port }}\n"
|
|
150
|
+
" selector:\n"
|
|
151
|
+
" {{- include \"$name.selectorLabels\" . | nindent 4 }}\n"
|
|
152
|
+
),
|
|
153
|
+
".github/workflows/helm-lint.yml": (
|
|
154
|
+
"name: Helm Lint\n"
|
|
155
|
+
"on: [push]\n"
|
|
156
|
+
"jobs:\n"
|
|
157
|
+
" lint:\n"
|
|
158
|
+
" runs-on: ubuntu-latest\n"
|
|
159
|
+
" steps:\n"
|
|
160
|
+
" - uses: actions/checkout@v4\n"
|
|
161
|
+
" - name: Set up Helm\n"
|
|
162
|
+
" uses: azure/setup-helm@v4\n"
|
|
163
|
+
" - run: helm lint .\n"
|
|
164
|
+
" - run: helm template $name .\n"
|
|
165
|
+
),
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
"rails": {
|
|
169
|
+
"name": "rails",
|
|
170
|
+
"description": "Minimal Rails-style skeleton (base layout, not `rails new` output)",
|
|
171
|
+
"files": {
|
|
172
|
+
"README.md": "# $name\n\n$description\n",
|
|
173
|
+
"Gemfile": (
|
|
174
|
+
"source \"https://rubygems.org\"\n"
|
|
175
|
+
"gem \"rails\", \"~> 7.1\"\n"
|
|
176
|
+
"gem \"puma\"\n"
|
|
177
|
+
),
|
|
178
|
+
"config.ru": (
|
|
179
|
+
"require_relative \"config/environment\"\n"
|
|
180
|
+
"run Rails.application\n"
|
|
181
|
+
),
|
|
182
|
+
"config/application.rb": (
|
|
183
|
+
"require \"rails/all\"\n\n"
|
|
184
|
+
"module $name\n"
|
|
185
|
+
" class Application < Rails::Application\n"
|
|
186
|
+
" config.load_defaults 7.1\n"
|
|
187
|
+
" end\n"
|
|
188
|
+
"end\n"
|
|
189
|
+
),
|
|
190
|
+
"app/controllers/application_controller.rb": (
|
|
191
|
+
"class ApplicationController < ActionController::Base\n"
|
|
192
|
+
"end\n"
|
|
193
|
+
),
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
"typescript": {
|
|
197
|
+
"name": "typescript",
|
|
198
|
+
"description": "TypeScript service with package.json, tsconfig, multi-stage Dockerfile",
|
|
199
|
+
"files": {
|
|
200
|
+
"README.md": "# $name\n\n$description\n",
|
|
201
|
+
"package.json": (
|
|
202
|
+
"{\n"
|
|
203
|
+
" \"name\": \"$name\",\n"
|
|
204
|
+
" \"version\": \"0.1.0\",\n"
|
|
205
|
+
" \"description\": \"$description\",\n"
|
|
206
|
+
" \"scripts\": {\n"
|
|
207
|
+
" \"build\": \"tsc\",\n"
|
|
208
|
+
" \"start\": \"node dist/index.js\"\n"
|
|
209
|
+
" },\n"
|
|
210
|
+
" \"devDependencies\": {\n"
|
|
211
|
+
" \"typescript\": \"^5.4.0\",\n"
|
|
212
|
+
" \"@types/node\": \"^20.11.0\"\n"
|
|
213
|
+
" }\n"
|
|
214
|
+
"}\n"
|
|
215
|
+
),
|
|
216
|
+
"tsconfig.json": (
|
|
217
|
+
"{\n"
|
|
218
|
+
" \"compilerOptions\": {\n"
|
|
219
|
+
" \"target\": \"ES2022\",\n"
|
|
220
|
+
" \"outDir\": \"dist\",\n"
|
|
221
|
+
" \"rootDir\": \"src\",\n"
|
|
222
|
+
" \"strict\": true\n"
|
|
223
|
+
" },\n"
|
|
224
|
+
" \"include\": [\"src\"]\n"
|
|
225
|
+
"}\n"
|
|
226
|
+
),
|
|
227
|
+
"src/index.ts": (
|
|
228
|
+
"export function main(): void {\n"
|
|
229
|
+
" console.log('Hello from $name!');\n"
|
|
230
|
+
"}\n\n"
|
|
231
|
+
"main();\n"
|
|
232
|
+
),
|
|
233
|
+
"Dockerfile": (
|
|
234
|
+
"FROM node:20-alpine AS build\n"
|
|
235
|
+
"WORKDIR /app\n"
|
|
236
|
+
"COPY package*.json ./\n"
|
|
237
|
+
"RUN npm install\n"
|
|
238
|
+
"COPY . .\n"
|
|
239
|
+
"RUN npm run build\n\n"
|
|
240
|
+
"FROM node:20-alpine\n"
|
|
241
|
+
"WORKDIR /app\n"
|
|
242
|
+
"COPY --from=build /app/dist ./dist\n"
|
|
243
|
+
"COPY --from=build /app/package*.json ./\n"
|
|
244
|
+
"RUN npm install --omit=dev\n"
|
|
245
|
+
'CMD ["node", "dist/index.js"]\n'
|
|
246
|
+
),
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
"none": {
|
|
250
|
+
"name": "none",
|
|
251
|
+
"description": "Minimal agent-only repository (README and .gitignore only)",
|
|
252
|
+
"files": {
|
|
253
|
+
"README.md": "# $name\n\n$description\n",
|
|
254
|
+
".gitignore": ".env\n.venv/\n__pycache__/\n*.py[cod]\n",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
TEMPLATE_ALIASES: dict[str, str] = {
|
|
260
|
+
"python": "python-microservice",
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
LICENSES: dict[str, str] = {
|
|
264
|
+
"mit": (
|
|
265
|
+
"MIT License\n\n"
|
|
266
|
+
"Copyright (c) $year $holder\n\n"
|
|
267
|
+
"Permission is hereby granted, free of charge, to any person obtaining a copy\n"
|
|
268
|
+
"of this software and associated documentation files (the \"Software\"), to deal\n"
|
|
269
|
+
"in the Software without restriction, including without limitation the rights\n"
|
|
270
|
+
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n"
|
|
271
|
+
"copies of the Software, and to permit persons to whom the Software is\n"
|
|
272
|
+
"furnished to do so, subject to the following conditions:\n\n"
|
|
273
|
+
"The above copyright notice and this permission notice shall be included in all\n"
|
|
274
|
+
"copies or substantial portions of the Software.\n\n"
|
|
275
|
+
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
|
|
276
|
+
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
|
|
277
|
+
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
|
|
278
|
+
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
|
|
279
|
+
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"
|
|
280
|
+
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n"
|
|
281
|
+
"SOFTWARE.\n"
|
|
282
|
+
),
|
|
283
|
+
"apache2": (
|
|
284
|
+
"Copyright $year $holder\n\n"
|
|
285
|
+
"Licensed under the Apache License, Version 2.0 (the \"License\");\n"
|
|
286
|
+
"you may not use this file except in compliance with the License.\n"
|
|
287
|
+
"You may obtain a copy of the License at\n\n"
|
|
288
|
+
" http://www.apache.org/licenses/LICENSE-2.0\n\n"
|
|
289
|
+
"Unless required by applicable law or agreed to in writing, software\n"
|
|
290
|
+
"distributed under the License is distributed on an \"AS IS\" BASIS,\n"
|
|
291
|
+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
|
|
292
|
+
"See the License for the specific language governing permissions and\n"
|
|
293
|
+
"limitations under the License.\n"
|
|
294
|
+
),
|
|
295
|
+
"gpl3": (
|
|
296
|
+
"Copyright (C) $year $holder\n\n"
|
|
297
|
+
"This program is free software: you can redistribute it and/or modify\n"
|
|
298
|
+
"it under the terms of the GNU General Public License as published by\n"
|
|
299
|
+
"the Free Software Foundation, either version 3 of the License, or\n"
|
|
300
|
+
"(at your option) any later version.\n\n"
|
|
301
|
+
"This program is distributed in the hope that it will be useful,\n"
|
|
302
|
+
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
|
303
|
+
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
|
304
|
+
"GNU General Public License for more details.\n\n"
|
|
305
|
+
"You should have received a copy of the GNU General Public License\n"
|
|
306
|
+
"along with this program. If not, see <https://www.gnu.org/licenses/>.\n"
|
|
307
|
+
),
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def render(text: str, **variables: str) -> str:
|
|
312
|
+
"""Render a template body. Undefined ``$tokens`` are left untouched."""
|
|
313
|
+
return Template(text).safe_substitute(**variables)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def template_names() -> list[str]:
|
|
317
|
+
return sorted(TEMPLATES)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def get_template(name: str) -> dict:
|
|
321
|
+
resolved = TEMPLATE_ALIASES.get(name, name)
|
|
322
|
+
if resolved not in TEMPLATES:
|
|
323
|
+
raise KeyError(
|
|
324
|
+
f"Unknown template '{name}'. Available: {', '.join(template_names())}"
|
|
325
|
+
)
|
|
326
|
+
return TEMPLATES[resolved]
|
|
327
|
+
|