craftkit 0.3.0__tar.gz → 0.3.2__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 (31) hide show
  1. craftkit-0.3.2/PKG-INFO +380 -0
  2. craftkit-0.3.2/README.md +360 -0
  3. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/__init__.py +1 -1
  4. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/agent.py +73 -13
  5. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/cli.py +30 -3
  6. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/home.py +14 -3
  7. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/tables.py +20 -2
  8. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/ui.py +12 -0
  9. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/workspace.py +6 -3
  10. craftkit-0.3.2/craftkit.egg-info/PKG-INFO +380 -0
  11. {craftkit-0.3.0 → craftkit-0.3.2}/pyproject.toml +1 -1
  12. craftkit-0.3.0/PKG-INFO +0 -174
  13. craftkit-0.3.0/README.md +0 -154
  14. craftkit-0.3.0/craftkit.egg-info/PKG-INFO +0 -174
  15. {craftkit-0.3.0 → craftkit-0.3.2}/LICENSE-APACHE +0 -0
  16. {craftkit-0.3.0 → craftkit-0.3.2}/LICENSE-MIT +0 -0
  17. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/SKILL.md +0 -0
  18. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/__main__.py +0 -0
  19. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/banner.py +0 -0
  20. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/brief.py +0 -0
  21. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/browser.py +0 -0
  22. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/checks.py +0 -0
  23. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/png.py +0 -0
  24. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/proc.py +0 -0
  25. {craftkit-0.3.0 → craftkit-0.3.2}/craft_kit/study.py +0 -0
  26. {craftkit-0.3.0 → craftkit-0.3.2}/craftkit.egg-info/SOURCES.txt +0 -0
  27. {craftkit-0.3.0 → craftkit-0.3.2}/craftkit.egg-info/dependency_links.txt +0 -0
  28. {craftkit-0.3.0 → craftkit-0.3.2}/craftkit.egg-info/entry_points.txt +0 -0
  29. {craftkit-0.3.0 → craftkit-0.3.2}/craftkit.egg-info/requires.txt +0 -0
  30. {craftkit-0.3.0 → craftkit-0.3.2}/craftkit.egg-info/top_level.txt +0 -0
  31. {craftkit-0.3.0 → craftkit-0.3.2}/setup.cfg +0 -0
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.4
2
+ Name: craftkit
3
+ Version: 0.3.2
4
+ Summary: Study → build → check → refine any software, from the terminal, with your coding agent.
5
+ License-Expression: MIT OR Apache-2.0
6
+ Keywords: cli,coding-agent,claude-code,codex,gemini,rebuild,skill
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Code Generators
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE-MIT
16
+ License-File: LICENSE-APACHE
17
+ Provides-Extra: browser
18
+ Requires-Dist: playwright>=1.40; extra == "browser"
19
+ Dynamic: license-file
20
+
21
+ # craftkit
22
+
23
+ **Rebuild any software with the coding agent you already use, and prove the result is right.**
24
+
25
+ [![npm](https://img.shields.io/npm/v/craftkit-cli?label=npm)](https://www.npmjs.com/package/craftkit-cli)
26
+ [![PyPI](https://img.shields.io/pypi/v/craftkit?label=PyPI)](https://pypi.org/project/craftkit/)
27
+ ![Python](https://img.shields.io/badge/python-3.9%2B-blue)
28
+ ![License](https://img.shields.io/badge/license-MIT%20or%20Apache--2.0-green)
29
+
30
+ [Français](README.fr.md)
31
+
32
+ `craft` is a free command-line tool. Point it at a website, a command-line program or an app (or
33
+ just describe what you want), and it has your coding agent (Claude Code, Codex or Gemini CLI) build
34
+ your own version. It then **checks the result against the original with real measurements** and
35
+ sends the differences back to the agent until every check passes.
36
+
37
+ ```sh
38
+ npm install -g craftkit-cli # or: pipx install craftkit
39
+ craft new https://example.com "recreate this landing page in React"
40
+ cd recreate-this-landing-page-in-react && craft run
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Why craft?
46
+
47
+ Coding agents write code fast, but on their own they don't know **when they're done**. Ask one to
48
+ "make a site like this one" and you get something that *looks* finished. You then spend the
49
+ afternoon comparing screenshots and pasting differences back by hand.
50
+
51
+ `craft` does that loop for you:
52
+
53
+ | Without craft | With craft |
54
+ |---------------|------------|
55
+ | You describe the original in words | `craft` captures it: screenshots at 3 screen widths, visible fonts and colours, what a program prints |
56
+ | The agent decides when it's "done" | The work is done when **measured checks pass**: it builds, it looks the same, it prints the same, its tests pass |
57
+ | You compare by eye and paste feedback | Each difference goes back to the agent automatically, up to a set budget |
58
+ | A long prompt, then you hope | A project folder with evidence, the brief, every check and every turn on disk, ready to resume anytime |
59
+ | Locked to one tool | Works with Claude Code, Codex, Gemini CLI, or any assistant (copy-paste mode) |
60
+
61
+ ### What people use it for
62
+
63
+ - **Recreate a website** you like as a starting point: same layout on desktop, tablet and phone,
64
+ built from scratch in your stack.
65
+ - **Rebuild a command-line tool** in another language, for example a Python script rewritten in
66
+ Rust that prints the same output for the same inputs.
67
+ - **Make a game or desktop app** from a description or from your own screenshots, with a
68
+ self-test that proves the core loop works.
69
+ - **Build a new tool from a plain request** ("a pomodoro timer CLI in Go"), verified by tests the
70
+ agent must write and pass.
71
+
72
+ ## How it works
73
+
74
+ ```mermaid
75
+ flowchart LR
76
+ A[1 · Study<br/>capture the original] --> B[2 · Build<br/>your agent writes app/]
77
+ B --> C[3 · Check<br/>measure the differences]
78
+ C -- not there yet --> D[4 · Refine<br/>send the differences back]
79
+ D --> B
80
+ C -- every check passes --> E[✓ Ready]
81
+ ```
82
+
83
+ 1. **Study.** `craft` gathers evidence into `capture/`. For a website, it takes full-page
84
+ screenshots at 1440, 768 and 390 px and records visible facts (title, headings, fonts,
85
+ colours). For a program, it records what it prints for a few inputs (only if you allow running
86
+ it). Pictures you add to `reference/` are included.
87
+ 2. **Build.** Your coding agent receives a clear brief and works only inside `app/`. You watch
88
+ it live: every file read, edit and command appears as it happens.
89
+ 3. **Check.** The same checks run every round: does it build? Does it look like the original at
90
+ each width? Does it print the same thing? Do its tests pass?
91
+ 4. **Refine.** Anything that fails goes back to the agent with the exact differences. This repeats
92
+ until every check passes, with a budget of 6 refinements per request. It also stops if the
93
+ agent changes nothing twice in a row.
94
+
95
+ What you see in your terminal while it works:
96
+
97
+ ```text
98
+ craft · pomodoro cli · Rust · clean room
99
+ ▍study ./pomodoro ─────────────────────────────────────────────────
100
+ ✓ runs 4 runs recorded
101
+ ▍build building · turn 1 ──────────────────────────────────────────
102
+ 0:03 ◇ read BRIEF.md
103
+ 0:05 ☰ plan 2/5 · Writing the timer
104
+ 0:41 ✚ write app/src/main.rs
105
+ 1:02 ❯ run cargo build
106
+ 1:20 ✗ failed error[E0425]: cannot find value `paused`
107
+ 1:31 ✎ edit app/src/main.rs
108
+ └ 2m14s · 14 actions: 6 edit, 4 run, 3 read, 1 plan · 1 failed
109
+ ✓ build I built the timer with pause and resume.
110
+ ▍check round 1 ────────────────────────────────────────────────────
111
+ ✗ runs 6 of 8 claims hold; output 71% alike.
112
+ │ With --help, it prints what the original prints: 52% of the words match
113
+ ▍refine refining 1/6 · turn 2 ─────────────────────────────────────
114
+ ⠼ refining 1/6 · claude · 0m48s · 3 · Edit app/src/main.rs
115
+ ```
116
+
117
+ Each stage has its own colour in the terminal.
118
+
119
+ ---
120
+
121
+ ## Installation
122
+
123
+ ### What you need
124
+
125
+ | | Required? | Why |
126
+ |---|---|---|
127
+ | **Python 3.9+** | yes | `craft` is written in Python, with no dependencies |
128
+ | **A coding agent** | yes | it writes the code: [Claude Code, Codex or Gemini CLI](#install-a-coding-agent) |
129
+ | **Node.js** | only for `npm install` | npm comes with Node.js ([nodejs.org](https://nodejs.org)) |
130
+ | **A browser** | only for websites | for screenshots: installed Chrome/Edge works; Playwright adds visible-style measurements |
131
+
132
+ Python is already installed on macOS and most Linux systems; check with `python3 --version`. On
133
+ Windows, install it from [python.org](https://www.python.org/downloads/) or with
134
+ `winget install Python.Python.3.12`.
135
+
136
+ ### Install craft (pick one)
137
+
138
+ ```sh
139
+ npm install -g craftkit-cli # with Node.js
140
+ pipx install craftkit # with pipx
141
+ uv tool install craftkit # with uv
142
+ ```
143
+
144
+ All three install the same program and the same commands: `craft` (plus the aliases `craftkit`,
145
+ `craft-new`, `craft-run`).
146
+
147
+ To try it without installing anything: `npx craftkit-cli` or `uvx craftkit`.
148
+
149
+ Check that it works:
150
+
151
+ ```sh
152
+ craft --version # craft 0.3.2
153
+ craft agents # shows which coding agents craft can find
154
+ ```
155
+
156
+ ### Install a coding agent
157
+
158
+ `craft` doesn't write code itself; your coding agent does. Install at least one, then **run it
159
+ once to sign in**:
160
+
161
+ | Agent | Install | Then |
162
+ |-------|---------|------|
163
+ | **Claude Code** | `npm install -g @anthropic-ai/claude-code`<br/>or `curl -fsSL https://claude.ai/install.sh \| bash` | run `claude` and sign in |
164
+ | **Codex** | `npm install -g @openai/codex` | run `codex` and sign in |
165
+ | **Gemini CLI** | `npm install -g @google/gemini-cli`<br/>or `brew install gemini-cli` | run `gemini` and sign in (free tier with a Google account) |
166
+
167
+ If none is installed, `craft` says so right away (on the home screen, at `craft new` and before
168
+ `craft run` starts) and prints these exact commands.
169
+
170
+ **No agent at all?** `craft brief` prints the task. Paste it into any coding assistant (Cursor,
171
+ Copilot, …) opened in the project folder, then run `craft check`.
172
+
173
+ ### Optional: better website screenshots
174
+
175
+ ```sh
176
+ pip install playwright && playwright install chromium
177
+ ```
178
+
179
+ Without it, `craft` uses an installed Chrome or Edge in headless mode, and otherwise falls back to
180
+ Playwright through `npx`.
181
+
182
+ ### Update and uninstall
183
+
184
+ | Installed with | Update | Uninstall |
185
+ |----------------|--------|-----------|
186
+ | npm | `npm update -g craftkit-cli` | `npm uninstall -g craftkit-cli` |
187
+ | pipx | `pipx upgrade craftkit` | `pipx uninstall craftkit` |
188
+ | uv | `uv tool upgrade craftkit` | `uv tool uninstall craftkit` |
189
+
190
+ Uninstalling leaves your projects alone.
191
+
192
+ ---
193
+
194
+ ## Usage
195
+
196
+ ### The easy way: the home screen
197
+
198
+ Type **`craft`**. You get your past projects and a **+ New project** entry, which asks a few
199
+ questions and creates the project in `~/craft-projects`.
200
+
201
+ | Key | Action |
202
+ |-----|--------|
203
+ | ↑ ↓ (or j k) | move |
204
+ | Enter | open a project: continue, ask for a change, open the result, re-check, show the folder |
205
+ | n | new project |
206
+ | x | remove from the list (the folder is kept) |
207
+ | q / Esc | back, or quit |
208
+
209
+ ### From the command line
210
+
211
+ ```sh
212
+ craft new https://example.com "recreate this site in React" # creates ./recreate-this-site-in-react/
213
+ cd recreate-this-site-in-react
214
+ craft run # the whole loop: study → build → check → refine
215
+ craft run "make the header sticky" # ask for a change (starts a new refinement budget)
216
+ craft open # open the result (serves a site, or runs the app)
217
+ ```
218
+
219
+ More examples:
220
+
221
+ ```sh
222
+ craft new "a pomodoro timer CLI in Go" # no original: build from the request
223
+ craft new ./my-tool "the same tool in Rust" --allow-run # record what it prints, then match it
224
+ craft new "a snake game in Python" --kind game
225
+
226
+ craft new "a todo app in Electron" # from your own mockups:
227
+ cp ~/Pictures/mockups/*.png a-todo-app-in-electron/reference/ # put them in reference/
228
+ cd a-todo-app-in-electron && craft run
229
+ ```
230
+
231
+ ### All commands
232
+
233
+ | Command | What it does |
234
+ |---------|--------------|
235
+ | `craft` | home screen: past projects, new project |
236
+ | `craft new [TARGET] [REQUEST…]` | create a project. TARGET is a web address, a file, a folder, a command, or nothing |
237
+ | `craft run [MESSAGE…]` | the whole loop; with a message, a change to the build |
238
+ | `craft study` · `build` · `check` | one step at a time |
239
+ | `craft status` | where the project is |
240
+ | `craft answer` | answer the agent's questions |
241
+ | `craft open` | open the result |
242
+ | `craft agents` | which coding agents are installed, and how to get one |
243
+ | `craft brief` | print the agent's task, to paste into any assistant |
244
+ | `craft skill [--install DIR]` | print or install the SKILL.md (see below) |
245
+
246
+ Options for `craft new`:
247
+
248
+ | Option | Meaning |
249
+ |--------|---------|
250
+ | `--kind website\|cli\|app\|game\|tool` | what you're making (guessed from your words otherwise) |
251
+ | `--stack rust\|python\|react\|html\|go\|…` | the language or framework (guessed from your words otherwise) |
252
+ | `--allow-run` | allow running the original program to record what it prints |
253
+ | `--deep` | allow looking inside the original (see [Clean room and Deep](#clean-room-and-deep)) |
254
+ | `--dir DIR` | where to create the project |
255
+
256
+ Options for `craft run` and `craft build`: `--agent claude|codex|gemini`.
257
+
258
+ ### What gets checked
259
+
260
+ | You're making | Checks |
261
+ |---------------|--------|
262
+ | website | it builds · it looks like the original at 1440, 768 and 390 px · its tests pass |
263
+ | cli | it builds · same exit code and ≥ 80% of the same words for each recorded input · tests |
264
+ | app | it builds · it starts and draws a window (`--screenshot`) · tests |
265
+ | game | it builds · a scripted self-test plays the core loop (`--self-test`) · a screenshot |
266
+ | tool / library | it builds · tests that prove each feature you asked for |
267
+
268
+ A round passes when no check fails and every score reaches 90%.
269
+
270
+ ### The project folder
271
+
272
+ ```text
273
+ my-project/
274
+ craft.json the request, target, kind, stack, mode and counters
275
+ BRIEF.md the task as given to the agent
276
+ capture/ evidence from Study (read-only for the agent)
277
+ reference/ your own pictures or files (read-only for the agent)
278
+ app/ the build: the only folder the agent changes
279
+ checks/ every check round and every agent turn, with logs
280
+ unknowns.md open questions about the original
281
+ questions.json the agent's questions, with your answers
282
+ ```
283
+
284
+ Everything is plain files, so you can stop at any time (Ctrl-C), close the terminal and carry on
285
+ later with `craft run`.
286
+
287
+ ---
288
+
289
+ ## Clean room and Deep
290
+
291
+ By default `craft` works in **clean room** mode: it uses only what a visitor or user can see
292
+ (screenshots, visible text, what a program prints). It never opens the original's source, files or
293
+ code.
294
+
295
+ With `--deep`, the agent may also look inside the original (a page's HTML, a folder's files, a
296
+ program's strings). Use it for your own software or private study.
297
+
298
+ **Use it responsibly.** Rebuilding something for learning or as a starting point is fine; shipping
299
+ someone else's brand, logos, images or text is not. The brief tells the agent to use neutral
300
+ placeholders and never to copy the original's code or assets. Respect copyrights and the terms of
301
+ the sites and programs you study.
302
+
303
+ ## Use it as a skill (Claude Code and other agents)
304
+
305
+ The method behind `craft` is also written as a standalone skill that any agent can follow, with or
306
+ without the CLI:
307
+
308
+ ```sh
309
+ craft skill --install ~/.claude/skills # Claude Code, all projects
310
+ craft skill > SKILL.md # or print it for another agent
311
+ ```
312
+
313
+ Then ask your agent: *"recreate example.com in React"*, and it follows the same
314
+ study → build → check → refine steps.
315
+
316
+ ## Configuration
317
+
318
+ Environment variables:
319
+
320
+ | Variable | Effect |
321
+ |----------|--------|
322
+ | `CRAFT_AGENT=codex` | the agent to use (default: the first installed of claude, codex, gemini) |
323
+ | `CRAFT_PROJECTS_DIR` | where the home screen creates projects (default `~/craft-projects`) |
324
+ | `CRAFT_FEED=0` | hide the live action feed and keep only the progress line |
325
+ | `NO_COLOR=1` | no colours |
326
+ | `CRAFT_TURN_TIMEOUT` / `CRAFT_IDLE_TIMEOUT` | seconds per agent turn (3 h) / without output (20 min) |
327
+ | `CRAFT_BROWSER=python\|chrome\|npx\|none` | how screenshots are taken |
328
+ | `CRAFT_CHROME` | path to Chrome or Edge |
329
+ | `CRAFT_PYTHON` | (npm install only) the Python to use |
330
+
331
+ **Add or change an agent** in `~/.config/craft/agents.json`. Any command-line agent that reads its
332
+ task from standard input works:
333
+
334
+ ```json
335
+ {"my-agent": {"argv": ["my-agent", "--non-interactive"], "stream": "text"}}
336
+ ```
337
+
338
+ Claude Code runs with `--permission-mode acceptEdits` and a fixed list of allowed tools (file
339
+ edits, npm, cargo, go, python, make…). Permissions are never bypassed.
340
+
341
+ ---
342
+
343
+ ## Troubleshooting
344
+
345
+ **"No coding agent found"**: install one of the [agents above](#install-a-coding-agent), sign in
346
+ once, then run `craft agents` to confirm it's found.
347
+
348
+ **"craft needs Python 3.9 or newer"** (npm install): install Python (see
349
+ [What you need](#what-you-need)), or point to one with `CRAFT_PYTHON=/path/to/python3`.
350
+
351
+ **`craft: command not found` after installing**:
352
+ - npm: your npm global folder isn't on your PATH. `npm prefix -g` shows it; add its `bin` folder
353
+ to PATH. Or use `npx craftkit-cli`.
354
+ - pipx: run `pipx ensurepath`, then open a new terminal.
355
+
356
+ **The agent stops and asks to sign in**: run the agent once by itself (`claude`, `codex` or
357
+ `gemini`), sign in, then `craft run` carries on where it stopped.
358
+
359
+ **No screenshots for a website**: install Chrome, or `pip install playwright && playwright install
360
+ chromium`.
361
+
362
+ **Stopped half-way?** Nothing is lost: `craft run` resumes from the project folder.
363
+
364
+ ## Limitations
365
+
366
+ - Visual comparison works on a colour grid. It catches layout and colour differences, not fine
367
+ details.
368
+ - With headless Chrome, screenshots are 2400 px tall rather than the full page; visible-style
369
+ measurements need Playwright for Python.
370
+ - The Codex and Gemini adapters haven't been tested against the real tools yet. Tested on macOS;
371
+ Linux and Windows aren't tested yet.
372
+
373
+ ## Credits and license
374
+
375
+ `craft` distils the study → build → check → refine method of
376
+ [Craft Anything](https://github.com/storytold/craft-anything) into a small terminal tool with no
377
+ dependencies.
378
+
379
+ Free and open source, under your choice of the [MIT](LICENSE-MIT) or
380
+ [Apache 2.0](LICENSE-APACHE) license.