deterministic-recipe-scaffolder 0.0.0-stage → 0.5.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Furkan
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.
package/README.md CHANGED
@@ -1,3 +1,318 @@
1
- # Temporary Holding Version
1
+ # repocraft
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![PyPI](https://img.shields.io/pypi/v/repocraft)](https://pypi.org/project/repocraft/)
4
+
5
+ Deterministic Python generation from validated input.
6
+
7
+ `repocraft` has four paths:
8
+
9
+ - a short request such as `triangle` selects a built-in recipe and writes one
10
+ `.py` file plus one `unittest` file;
11
+ - a small YAML spec becomes a complete Python project with packaging metadata,
12
+ a `src/` layout, tests, lint and type-check configuration, CI, CodeQL,
13
+ Dependabot, and a JUnit gate that rejects skipped tests;
14
+ - an optional `ask` path where a model only proposes a strict
15
+ `{recipe, parameters}` intent, which repocraft validates before writing;
16
+ - an optional `craft` path where a model writes the snippet and repocraft
17
+ verifies it through deterministic gates before anything is written.
18
+
19
+ The first two paths are deterministic: the same input and the same `repocraft`
20
+ version always produce byte-identical output. GitHub repository creation is a
21
+ roadmap item.
22
+
23
+ ## Status
24
+
25
+ Version 0.5.0 hardens the craft gates: every gate subprocess runs inside the
26
+ proposal's temporary directory with a 60-second timeout, a runaway proposal is
27
+ killed and rejected (fail-closed), and the generated tests run under an
28
+ isolated interpreter (`-E -s -B`). This is confinement, not a security sandbox.
29
+
30
+ Version 0.4.1 moves the determinism matrix to v0.3.0, makes the cross-OS gate
31
+ mandatory, covers recipe rendering and the locale/timezone axes, and gates PyPI
32
+ publishing on a matching tag plus a passing test suite. No runtime behavior
33
+ changes.
34
+
35
+ Version 0.4.0 adds the `craft` path: a model writes a free-form snippet and
36
+ repocraft verifies it — python syntax, that the generated tests import the
37
+ module, ruff when it is installed, and the generated tests themselves — before
38
+ the confirmation prompt and the no-overwrite rules apply.
39
+
40
+ Version 0.3.0 adds the optional AI intent layer and three new recipes:
41
+
42
+ - `repocraft ask` sends a free-form request to an OpenAI-compatible endpoint
43
+ and turns the reply into a strict `{recipe, parameters}` intent;
44
+ - the model never writes code or files; the intent is validated against the
45
+ recipe catalog with the same rules as `make`;
46
+ - configuration through `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `REPOCRAFT_MODEL`,
47
+ or `--endpoint` and `--model`;
48
+ - new recipes: `fizzbuzz`, `pascal`, and `password`.
49
+
50
+ Version 0.2.0 added the deterministic snippet mode:
51
+
52
+ - strict JSON Schema validation for specs and recipes, plus duplicate-key
53
+ rejection in YAML;
54
+ - four built-in recipes: `fibonacci`, `factorial`, `prime_sieve`, and
55
+ `triangle`;
56
+ - deterministic English matching with case, accent, and suffix normalization;
57
+ - confirmation before writing, `--dry-run`, `--param`, and refusal to overwrite;
58
+ - golden snapshots and smoke tests for every generated snippet.
59
+
60
+ The project mode from 0.1.0 is unchanged: library and CLI scaffolds with
61
+ golden-tested templates, CI, CodeQL, Dependabot, and coverage/skip gates.
62
+
63
+ The deterministic commands (`validate`, `render`, `recipes`, `make`) have no
64
+ model or network dependency; only `ask` uses the network.
65
+
66
+ ## Requirements
67
+
68
+ - Python 3.10 or newer.
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ python -m pip install repocraft
74
+ ```
75
+
76
+ Or from this checkout:
77
+
78
+ ```bash
79
+ python -m pip install .
80
+ ```
81
+
82
+ ## Snippet mode
83
+
84
+ List the closed recipe catalog:
85
+
86
+ ```bash
87
+ repocraft recipes
88
+ ```
89
+
90
+ Ask for a snippet. The command shows the selected recipe, its parameters, and
91
+ the target files, then asks for confirmation:
92
+
93
+ ```bash
94
+ repocraft make "triangle" # triangle.py and test_triangle.py
95
+ repocraft make "factorial"
96
+ repocraft make "prime numbers"
97
+ ```
98
+
99
+ Preview without writing anything:
100
+
101
+ ```bash
102
+ repocraft make "fibonacci" --dry-run
103
+ ```
104
+
105
+ Override a declared integer parameter. Free-text numbers are not interpreted:
106
+
107
+ ```bash
108
+ repocraft make "fibonacci" --param count=20 --yes
109
+ ```
110
+
111
+ Rules:
112
+
113
+ - only the built-in catalog is matched; unknown or ambiguous requests stop
114
+ without writing anything;
115
+ - requests containing standalone digits are refused; use `--param` instead;
116
+ - parameters are bounded integers and are validated before rendering;
117
+ - existing target files are never overwritten;
118
+ - `--yes` skips the confirmation prompt;
119
+ - generated tests use the standard library: `python test_<recipe>.py`.
120
+
121
+ The matcher normalizes case and accents and matches word prefixes, so
122
+ `Triangles` and `draw a triangle` both select the triangle recipe. It never
123
+ calls a model.
124
+
125
+ ## Ask mode (optional)
126
+
127
+ `ask` is the only command that calls a model. It turns a free-form request
128
+ into a validated intent and then reuses the snippet path end to end:
129
+
130
+ ```bash
131
+ export OPENAI_API_KEY=sk-... # required
132
+ repocraft ask "a tall triangle" # proposes triangle with its default height
133
+ repocraft ask "first 20 fibonacci numbers" --yes
134
+ ```
135
+
136
+ Rules:
137
+
138
+ - the model replies with JSON only: a recipe id and integer parameters, or
139
+ `null` with a reason when nothing fits;
140
+ - repocraft validates the reply against the catalog; unknown recipes, invalid
141
+ parameters, and malformed replies are rejected;
142
+ - the confirmation prompt, `--dry-run`, `--param`, and the refusal to
143
+ overwrite behave exactly as in `make`;
144
+ - `--endpoint` selects any OpenAI-compatible base URL; `--model` or
145
+ `REPOCRAFT_MODEL` selects the model;
146
+ - without `OPENAI_API_KEY` in the environment the command refuses to run.
147
+
148
+ ## Craft mode (optional)
149
+
150
+ `craft` is the path where the model writes the code and repocraft stays in
151
+ control of quality. The model proposes a module, its source, and a unittest
152
+ file; repocraft then runs deterministic gates on the proposal before anything
153
+ is written:
154
+
155
+ ```bash
156
+ export OPENAI_API_KEY=sk-... # required
157
+ repocraft craft "binary search" # proposes, verifies, asks, writes
158
+ ```
159
+
160
+ Gates, in order:
161
+
162
+ 1. python syntax of the code and the test;
163
+ 2. the test must import the proposed module by name;
164
+ 3. ruff on the generated files, when ruff is installed; fixable findings are
165
+ auto-fixed first and the check is marked accordingly;
166
+ 4. the generated unittest file must run and pass at least one test;
167
+ 5. the confirmation prompt shows the code and every check that passed.
168
+
169
+ Rules:
170
+
171
+ - `--endpoint`, `--model`, `REPOCRAFT_MODEL`, and `OPENAI_BASE_URL` configure
172
+ the endpoint exactly as in `ask`;
173
+ - the module name must be a lowercase snake_case identifier;
174
+ - only the standard library is allowed in the prompt, but the gates verify
175
+ what actually runs;
176
+ - every gate subprocess is confined to a fresh temporary directory and killed
177
+ after a 60-second timeout; a timeout rejects the proposal (fail-closed);
178
+ - `--dry-run` lists the planned files after verification; the no-overwrite
179
+ rule applies;
180
+ - without `OPENAI_API_KEY` in the environment the command refuses to run.
181
+
182
+ Unlike the deterministic paths, the written content depends on the model;
183
+ repocraft guarantees only that every gate passed and that you saw the code
184
+ before it was written.
185
+
186
+ ## Project mode
187
+
188
+ Write a spec:
189
+
190
+ ```yaml
191
+ schema_version: 1
192
+ project:
193
+ name: example-cli
194
+ package: example_cli
195
+ description: An example command-line application.
196
+ type: cli
197
+ license: Apache-2.0
198
+ author: Your Name
199
+ version: 0.1.0
200
+ python: ">=3.10"
201
+ cli:
202
+ command: example-cli
203
+ repository:
204
+ owner: your-user
205
+ name: example-cli
206
+ private: true
207
+ ```
208
+
209
+ Validate it:
210
+
211
+ ```bash
212
+ repocraft validate spec.yaml
213
+ ```
214
+
215
+ Plan the output without writing anything:
216
+
217
+ ```bash
218
+ repocraft render spec.yaml example-cli --dry-run
219
+ ```
220
+
221
+ Render it:
222
+
223
+ ```bash
224
+ repocraft render spec.yaml example-cli
225
+ ```
226
+
227
+ `render` refuses an output directory that already contains files. It never
228
+ overwrites or merges into existing work.
229
+
230
+ ### Spec fields
231
+
232
+ | Field | Required | Meaning |
233
+ |---|---|---|
234
+ | `schema_version` | yes | Must be `1`. |
235
+ | `project.name` | yes | Distribution name, lowercase letters, digits, and hyphens. |
236
+ | `project.package` | yes | Import package name, lowercase letters, digits, and underscores. |
237
+ | `project.description` | yes | One-line description, 10 to 200 characters. |
238
+ | `project.type` | yes | `library` or `cli`. |
239
+ | `project.license` | yes | `MIT` or `Apache-2.0`. |
240
+ | `project.author` | yes | Copyright holder and package author. |
241
+ | `project.version` | no | Semantic version, default `0.1.0`. |
242
+ | `project.python` | no | `>=3.10` through `>=3.14`, default `>=3.10`. |
243
+ | `project.cli.command` | for `cli` | Console script name. Forbidden for `library`. |
244
+ | `project.repository` | no | `owner`, `name`, and `private` (default `true`). |
245
+
246
+ ## Determinism contract
247
+
248
+ For fixed input and a fixed `repocraft` version:
249
+
250
+ - output paths and file contents are byte-identical;
251
+ - recipe output depends only on the recipe version and validated parameters;
252
+ - recipe matching and error ordering are deterministic;
253
+ - entries are rendered in sorted order;
254
+ - files use LF line endings and a trailing newline;
255
+ - no timestamps, random identifiers, model output, or environment values are
256
+ embedded;
257
+ - the generated MIT copyright line carries the author but no year.
258
+
259
+ The golden tests in `tests/golden/` enforce the contract file by file,
260
+ including the built-in recipe snapshots.
261
+
262
+ The `ask` command adds a model, but the contract still holds: the model only
263
+ proposes an intent, and a confirmed intent renders exactly like `make`. The
264
+ `craft` command goes further — the model writes the code — so its output is
265
+ not part of the contract; its gates, the confirmation prompt, and the
266
+ no-overwrite rule are.
267
+
268
+ ## Development
269
+
270
+ ```bash
271
+ python -m venv .venv
272
+ . .venv/bin/activate # Windows: .venv\Scripts\activate
273
+ python -m pip install -e ".[dev]"
274
+ python -m ruff check .
275
+ python -m mypy
276
+ python -m pytest --cov=repocraft --cov-branch --cov-fail-under=100
277
+ ```
278
+
279
+ The smoke tests install the rendered fixtures into temporary target directories
280
+ with `--no-deps --no-build-isolation`, then run the generated projects' own
281
+ quality gates. Hatchling is a dev dependency for exactly that reason.
282
+
283
+ CI runs the suite on Python 3.10 through 3.14 and rejects skipped tests through
284
+ `scripts/check_junit.py`.
285
+
286
+ ## Roadmap
287
+
288
+ 1. Interactive wizard for people who do not want to write project YAML.
289
+ 2. Free-form natural language to a full project spec through an
290
+ OpenAI-compatible endpoint, with a confirmation step before any file is
291
+ written.
292
+ 3. GitHub repository creation and push, private by default.
293
+ 4. MCP server exposing the same validated core.
294
+
295
+ ## Related projects
296
+
297
+ Part of the Furox scientific-computing portfolio: independently versioned projects that pair agent-facing interfaces (MCP servers and Agent Skills) with deterministic, fail-closed verification.
298
+
299
+ - [scientific-computing-system](https://github.com/Furox-Art/scientific-computing-system) — zero-dependency Python numerics with run manifests.
300
+ - [scientific-computing-system-2.0](https://github.com/Furox-Art/scientific-computing-system-2.0) — NumPy/SciPy/pandas build with replayable fit records.
301
+ - [scientific-toolkit](https://github.com/Furox-Art/scientific-toolkit) — MCP gateway over nine research tools.
302
+ - [axiomize](https://github.com/Furox-Art/axiomize) — unit-checked modeling engine with SBML, CellML and Modelica export.
303
+ - [axiomize-quantum-skills-2.0](https://github.com/Furox-Art/axiomize-quantum-skills-2.0) — modeling engine plus quantum-inspired reasoning bundle.
304
+ - [quantum-reasoning-skill](https://github.com/Furox-Art/quantum-reasoning-skill) — agent skill that keeps competing hypotheses alive.
305
+ - [plan-auditor](https://github.com/Furox-Art/plan-auditor) — evidence-based completion gate for coding agents.
306
+ - [nomosguard](https://github.com/Furox-Art/evidence-ledger-policy-gate) — deterministic security decision layer with a hash-chained ledger.
307
+ - [eq-layer](https://github.com/Furox-Art/eq-layer) — interaction-policy layer that decides how an agent speaks.
308
+ - [literature-evidence-mcp](https://github.com/Furox-Art/literature-evidence-mcp) — literature MCP server with a hash-chained evidence ledger.
309
+
310
+ ## npm command
311
+
312
+ Install the matching `repocraft` Python release in an active environment,
313
+ then run `npm install -g deterministic-recipe-scaffolder`. The npm command launches
314
+ the Python CLI. Set `REPOCRAFT_PYTHON` to its Python executable when needed.
315
+
316
+ ## License
317
+
318
+ MIT. See `LICENSE`.
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('node:child_process');
5
+ const { name, version } = require('../../package.json');
6
+ const pythonPackage = 'repocraft';
7
+
8
+ const override = process.env.REPOCRAFT_PYTHON;
9
+ const interpreters = override
10
+ ? [[override]]
11
+ : process.platform === 'win32'
12
+ ? [['python'], ['python3'], ['py', '-3']]
13
+ : [['python3'], ['python']];
14
+ const versionCheck = [
15
+ 'from importlib.metadata import version',
16
+ 'import sys',
17
+ 'raise SystemExit(version(sys.argv[1]) != sys.argv[2])',
18
+ ].join('\n');
19
+
20
+ function main(args) {
21
+ for (const [python, ...prefix] of interpreters) {
22
+ const probe = spawnSync(python, [...prefix, '-c', versionCheck, pythonPackage, version], {
23
+ stdio: 'ignore',
24
+ timeout: 5000,
25
+ });
26
+ if (probe.error || probe.status !== 0) continue;
27
+
28
+ const result = spawnSync(python, [...prefix, '-m', 'repocraft', ...args], {
29
+ stdio: 'inherit',
30
+ });
31
+ if (result.error) console.error(name + ': ' + result.error.message);
32
+ return result.status ?? 1;
33
+ }
34
+
35
+ console.error(name + ': install the matching Python package in an active environment.');
36
+ console.error('python -m pip install ' + pythonPackage + '==' + version);
37
+ console.error('Set REPOCRAFT_PYTHON to select a Python executable.');
38
+ return 1;
39
+ }
40
+
41
+ process.exitCode = main(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "deterministic-recipe-scaffolder",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.0",
4
+ "description": "CLI wrapper for RepoCraft's deterministic Python project scaffolding",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "repocraft": "npm/bin/repocraft.cjs"
8
+ },
9
+ "files": [
10
+ "npm/bin/repocraft.cjs"
11
+ ],
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Furox-Art/deterministic-recipe-scaffolder.git"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ }
22
+ }