craft
by FSMaker77
README.md
<p align="center">
<img src="installer/assets/craft.png" width="96" alt="OpenCode Craft Anything icon">
</p>
<h1 align="center">OpenCode Craft Anything</h1>
<p align="center">
<b>Study any website, app or game. Rebuild your own with OpenCode. Compare, refine, ship.</b>
</p>
<p align="center">
<b>English</b> · <a href="README.it.md">Italiano</a>
</p>
<p align="center">
<a href="https://github.com/FSMaker77/opencode-craft-anything/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/FSMaker77/opencode-craft-anything?style=flat-square&color=4f8cff"></a>
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-2f6b4f?style=flat-square">
<img alt="OpenCode 2.x" src="https://img.shields.io/badge/OpenCode-2.x-4f8cff?style=flat-square">
<img alt="Python 3.10+" src="https://img.shields.io/badge/Python-3.10%2B-3776ab?style=flat-square&logo=python&logoColor=white">
<img alt="Windows x64" src="https://img.shields.io/badge/Windows-x64-0078d4?style=flat-square&logo=windows&logoColor=white">
</p>

OpenCode Craft Anything is a native **OpenCode** implementation of the Craft Anything workflow: a deterministic engine captures the original, an OpenCode agent builds a new project, an automated check measures how close the result is, and the agent refines it.
It is **not a fork** of [storytold/craft-anything](https://github.com/storytold/craft-anything) and does not include its Rust engine. It is a compact, self-contained alternative for people who work inside OpenCode:
- **No Claude Code required.** The builder is your own OpenCode, with the model and provider you already use.
- **Study and comparison without an LLM.** Playwright captures screenshots, text, geometry, palette and fonts; scoring combines pixels, text and layout.
- **Three ways to use it.** `/craft` in the OpenCode TUI, `craft_*` MCP tools for any agent, and the `craft-opencode` CLI for headless runs.
- **Clean room or Deep.** Clean room uses only what a visitor can see. Deep reads a local target's structure and strings (and can use REA for code-level inspection).
> The CLI currently prints Italian messages. The agent and the workflow respond in the language you use.
---
## What it does
| | |
| --- | --- |
| **Study** | Captures up to 5 same-origin pages at 1440, 834 and 390 px: screenshots, visible text, headings, navigation, landmark geometry, computed styles, palette, fonts and console errors. For local files/folders in Deep mode: format, hashes, sections, imports/exports, strings, manifests and source inventory. |
| **Build** | The `craft` agent reads `evidence/study.md` and the measured data, then builds a complete project in `app/` using your OpenCode model. |
| **Check** | Serves the build (static or a declared dev server), captures the same pages and widths, and scores visual similarity, text and layout. Writes `checks/round-N/report.json`, `report.md`, diff images and a local dashboard. |
| **Refine** | Below the threshold, the engine hands the agent a prioritized mismatch brief. The agent fixes the build and calls `craft_check` again. |
---
## Features
- Deterministic website capture with Playwright using system Microsoft Edge or Google Chrome.
- Responsive evidence at three widths, with full-page desktop screenshots.
- Text, heading, navigation, palette, font and landmark extraction.
- Screenshot diff images and per-width scores.
- Text similarity, vocabulary coverage, sequence similarity and layout/style scoring.
- Local target profiling for PE, ELF, Mach-O, ZIP/APK/JAR/ASAR, .NET, Electron and source trees.
- Clean-room and Deep modes.
- Project tracking: `craft.json`, steps, rounds, best score and notes.
- Optional deep code inspection through the REA MCP server already present in OpenCode.
- Windows installer with embedded Python, post-install setup wizard and clean uninstaller.
- English/Italian README and a local HTML dashboard.
---
## How it works
```
┌──────────────┐ ┌──────────────────┐ ┌───────────────┐
target ───▶ │ STUDY │ ───▶ │ BUILD │ ───▶ │ CHECK │
(URL/file) │ Playwright │ │ OpenCode agent │ │ screenshots │
│ + analysis │ │ (your model) │ │ + text │
└──────────────┘ └──────────────────┘ │ + layout │
│ │ └───────┬───────┘
▼ ▼ │
capture/ + study.md app/ checks/round-N/
│
┌────────────────────────┘
▼
score + mismatches
│
┌────────┴────────┐
▼ ▼
below threshold above threshold
│ │
refine ready
```
1. **Study** — captured evidence is saved under `capture/` and summarized in `evidence/study.md`.
2. **Build** — `opencode run --standalone --auto --agent craft` builds in `app/`.
3. **Check** — the engine serves the build, recaptures it, compares it with the original and writes a report.
4. **Refine** — the builder receives the report and fixes the highest-impact differences.
The builder can call `craft_check` itself during a run; the loop does not depend on an external orchestrator.
---
## Requirements
- **OpenCode 2.x** (`opencode --version`). The `opencode-ai` 1.x package is not supported.
- **Python 3.10+** for a source install. The Windows installer bundles Python 3.12.
- **Microsoft Edge or Google Chrome** for captures. If neither is installed, Playwright can install Chromium.
- A working OpenCode model. If you do not choose one, OpenCode uses its configured default.
---
## Install
### Windows installer (recommended)
Download the latest installer from **[Releases](https://github.com/FSMaker77/opencode-craft-anything/releases/latest)**:
```text
CraftAnythingOpenCode-Setup-0.1.0.exe
```
What it does:
- Installs per user in `%LOCALAPPDATA%\Programs\Craft Anything OpenCode` — **no administrator rights**.
- Bundles Python 3.12.10, Playwright and Pillow.
- Optionally adds `craft-opencode` to the user PATH.
- Creates Start Menu shortcuts: Craft, Configure OpenCode, README, Projects folder and Uninstall.
- Opens a post-install wizard to detect OpenCode 2.x, choose a model, register the agent/commands/skill/MCP server, run `doctor`, reconnect the server and optionally install Chromium for Playwright.
- The uninstaller removes the integration, PATH entry and shortcuts, but **never touches your projects** in `Documents\Craft Anything OpenCode`.
Requirements: **OpenCode 2.x** and Edge/Chrome.
The installer is currently **unsigned**, so Windows SmartScreen shows “Unknown publisher”. Choose **More info → Run anyway**. A public distribution should be signed with an Authenticode certificate.
Silent install:
```powershell
.\CraftAnythingOpenCode-Setup-0.1.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
```
Install files without touching the OpenCode configuration or PATH:
```powershell
.\CraftAnythingOpenCode-Setup-0.1.0.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /MERGETASKS="!configure,!addtopath"
```
SHA256 checksums are published with every release.
### From source (developers)
```powershell
git clone https://github.com/FSMaker77/opencode-craft-anything.git
cd opencode-craft-anything
python -m pip install -r requirements.txt
python -m pip install -e .
craft-opencode install --model <provider/model>
craft-opencode doctor
```
`--model` is optional; without it, OpenCode uses its default model. On macOS/Linux, use `python3` and, if no system browser is available:
```bash
python3 -m playwright install chromium
```
`craft-opencode install` writes only to your user configuration:
```text
~/.config/opencode/agents/craft.md
~/.config/opencode/commands/craft.md
~/.config/opencode/commands/craft-look.md
~/.config/opencode/skills/craft-anything/SKILL.md
~/.config/opencode/craft-anything.json
```
and registers the `craft` MCP server in `~/.config/opencode/opencode.json` with a 900-second timeout.
Do not move the source folder after installation: the MCP configuration points to it. If you move it, run `craft-opencode install` again.
---
## Use inside OpenCode
```text
/craft https://example.com "Recreate the landing page"
```
The command selects the `craft` agent, which:
1. creates or opens a project in `~/Documents/Craft Anything OpenCode/` (or the folder you name);
2. calls `craft_study`;
3. builds in `app/`;
4. calls `craft_check`, reads the report and refines;
5. reports the score, folder and preview instructions.
Local target:
```text
/craft C:\path\to\app "Recreate this app in Tauri"
/craft C:\path\to\game.exe "Rebuild the gameplay in Godot" --deep
```
From scratch:
```text
/craft - "A snake game in Rust with macroquad"
```
Study only, without building:
```text
/craft-look https://example.com
```
If OpenCode has just been installed or updated and the MCP tools are missing:
```powershell
craft-opencode reconnect
```
---
## CLI
```powershell
# Full loop: study → build → check → refine
craft-opencode rebuild https://example.com "Recreate the landing page"
# Choose a project folder
craft-opencode rebuild https://example.com "Recreate the landing page" --out C:\work\example-clone
# Local target in Deep mode
craft-opencode rebuild C:\Tools\sample.exe "Recreate the UI in Electron" --mode deep
# From scratch
craft-opencode rebuild - "A snake game in Rust" --rounds 3 --threshold 70
# Individual phases
craft-opencode study C:\work\example-clone --max-pages 5
craft-opencode build C:\work\example-clone --model <provider/model>
craft-opencode check C:\work\example-clone
# Preview and dashboard
craft-opencode preview C:\work\example-clone --open
craft-opencode report C:\work\example-clone --open
craft-opencode status C:\work\example-clone
craft-opencode list
craft-opencode reconnect
craft-opencode uninstall
```
| Option | Default | Meaning |
| --- | --- | --- |
| `--mode clean\|deep` | `clean` | Clean room or deep inspection. |
| `--model provider/model` | config | Model used by the builder. |
| `--agent ID` | `craft` | OpenCode agent used to build. |
| `--rounds N` | `2` | Refinements after the first check. |
| `--threshold N` | `75` | Passing score. |
| `--max-pages N` | `5` | Pages captured during study. |
| `--skip-study` / `--skip-build` | off | Skip a phase. |
| `--timeout SECONDS` | `2400` | Timeout per builder turn. |
| `--open` | off | Open the dashboard at the end. |
The builder runs in a private OpenCode session (`opencode run --standalone --auto`) using the same model and providers configured in OpenCode. The session is reused between build and refinement. A complete build can take from a few minutes to about half an hour depending on the model and target.
---
## MCP tools
| Tool | What it does |
| --- | --- |
| `craft_project_create` | Create or open a project; returns the exact project and app paths. |
| `craft_study` | Capture the original and write `evidence/study.md`. |
| `craft_brief` | Return the current brief: request, paths, steps, next action. |
| `craft_check` | Serve, capture, compare and write the check report. |
| `craft_status` | Read steps, scores and rounds. |
| `craft_preview` / `craft_preview_stop` | Start/stop the build preview. |
| `craft_note` | Record a decision or question in `inbox/`. |
Any OpenCode agent can use them, not only `craft`. Study and comparison consume no model tokens.
---
## Clean room vs Deep
**Clean room (default)** — The engine stores only rendered evidence for websites: screenshots, visible text, computed styles, geometry, palette, fonts. For a local target it does not read files; it only records a note, and the builder works from user-provided screenshots or descriptions.
**Deep** — For a local target or website:
- file: format, hash, sections, imports/exports, strings, entropy, metadata;
- folder: tree, manifests, dependencies, framework markers, source inventory;
- the builder may use the REA tools already available in OpenCode (`tools.rea.*`) for functions, pseudocode, strings and references.
Clean room is a **rule of the engine and the agent**, not an OS sandbox. The agent runs with your permissions. Likewise, a shell command can still write anywhere; do not point the agent at a target you do not want read.
---
## Project layout
```
<project>/
craft.json request, target, mode, steps, scores
capture/
site.json index of captured pages
pages/home/ page.json, visible.txt, desktop.png, tablet.png, mobile.png, desktop-full.png
native/ profile.json for local targets in Deep mode
evidence/
study.md readable brief for the agent
app/ the build
checks/
round-1/
report.json
report.md
build/ recaptured build
diff/ original | build | difference images
inbox/ notes and questions
logs/ builder and preview logs
report.html local dashboard
```
The agent must not modify `craft.json`, `capture/`, `checks/` or `evidence/`: those are the engine's record. Edit permissions block the write tools; a shell command still runs with your permissions.
---
## How scoring works
The overall score is a weighted average of pages (home page weighs 2×):
```
overall = 0.45 × visual + 0.30 × text + 0.25 × layout
```
- **Visual**: mean pixel difference, colour histogram similarity, edge correlation, block similarity.
- **Text**: vocabulary coverage, Jaccard, sequence similarity over the first 12k characters.
- **Layout**: presence and geometry of header/nav/main/footer/h1/h2/button/form, heading match, palette, fonts.
| Score | Meaning |
| ---: | --- |
| 85–100 | Very close. Fix only clear differences. |
| 70–84 | Recognizable. Structure, palette, type or spacing are off. |
| 50–69 | Same idea, wrong proportions. Rework the layout before details. |
| < 50 | Reconsider the approach. |
The score is a guide, not a target to game: copying text without rebuilding the structure still looks wrong.
---
## Local targets, apps and games
For a local file or folder in **Deep mode** the engine produces a static profile:
- PE: machine, subsystem, sections, entropy, imports/exports, CLR/.NET, entry point;
- ELF/Mach-O: class, machine, type, entry, libraries, sections;
- ZIP/APK/JAR/ASAR: inventory, `package.json`, Electron/Android/.NET markers;
- folders: trees, manifests, dependencies, frameworks, source counts and sampled lines;
- interesting strings: URLs, paths, versions, errors, licenses.
For runtime behaviour of apps and games the program is deliberately honest: it does not launch the executable automatically, record input or run behavior checks. You can:
- launch the app yourself and put screenshots in `capture/manual/` (the agent reads them);
- use REA for code inspection;
- ask the agent to build a deterministic self-test;
- use `craft_check` as a self-check: preview answers, files exist, no 404 or console errors.
For websites the visual check is complete. For desktop apps, the visual side depends on the screenshots you provide.
---
## Tested
On Windows x64, 2026-12-04:
- `examples/demo-site` studied at 1440/834/390; built with `opencode-go/deepseek-v4.1-flash` and the `craft` agent; **99.7/100** after self-refinement (visual 99.4, text 100, layout 100).
- A second test on `examples/mini`: **98.4/100** (visual 99.3, text 100, layout 95).
- Identical capture control: **100/100**.
- Unit tests: **5/5**.
- Installer: silent install/uninstall, PATH add/remove, integration configure/remove, embedded Python/Pillow/Playwright and `doctor` all verified.
---
## Limitations
- **No native desktop GUI.** The interface is OpenCode plus the HTML dashboard; there is no egui app.
- **No bundled reverse-engineering engine.** Local binaries use Python static analysis and, in Deep mode, the REA MCP server already configured in OpenCode. No decompiler is included.
- **App/game behavior checks are not automated.** Self-check and screenshot comparison are supported.
- **Sites behind login, anti-bot or canvas** may need manual screenshots. Capture errors are recorded and the run continues.
- **Clean room is not an OS sandbox.**
- **Copyright**: the builder recreates layout, style and behavior; it must not copy logos, photos, illustrations, code or long text without permission. The prompt enforces this; responsibility remains with the operator.
- **CLI messages are Italian** in this release.
- **The Windows installer is unsigned.**
---
## Troubleshooting
| Problem | Fix |
| --- | --- |
| `craft` MCP tools missing | `craft-opencode reconnect`, then reopen the session. |
| `opencode mcp list` says craft failed but sessions use it | It is a stale shared-service connection; `craft-opencode reconnect` replaces it. `craft-opencode doctor` checks the live status. |
| Model quota error | Choose another model with `craft-opencode install --model ...` or `--model` on the command. |
| No preview | Add `app/index.html` or `app/craft.preview.json` with `command`, `url` and `ready_timeout`. |
| Blank build or 404s | Use relative asset paths and make sure the preview serves the right folder. |
| Site capture fails | Use manual screenshots in `capture/manual/` or Deep mode for a local target. |
| Playwright cannot find a browser | `python -m playwright install chromium` (or use the installer wizard). |
| SmartScreen blocks the installer | More info → Run anyway; the build is unsigned. |
---
## Build the Windows installer
Requirements on the build machine:
- Windows x64;
- Python 3.12 with pip (only to stage the payload);
- Inno Setup 6:
```powershell
winget install JRSoftware.InnoSetup
```
- Internet access on the first build (embeddable Python and Playwright/Pillow wheels).
```powershell
powershell -ExecutionPolicy Bypass -File installer\build.ps1
```
Output:
```text
dist\CraftAnythingOpenCode-Setup-0.1.0.exe
dist\SHA256SUMS.txt
```
The script verifies the Python zip SHA256, installs binary wheels into the embedded runtime, cleans caches, tests the payload and compiles the installer with Inno Setup. See [`installer/README.md`](installer/README.md).
---
## Repository layout
```
craft_opencode/ engine, CLI, MCP server, templates
installer/ Inno Setup script, build script, post-install wizard, icon
examples/ demo-site and mini test targets
docs/ dashboard screenshot
tests/ comparison unit tests
pyproject.toml Python package
craft-opencode.cmd launcher for a source checkout
```
---
## Credits and license
Original idea and workflow: [Craft Anything](https://github.com/storytold/craft-anything) by ArtCraft (MIT/Apache-2.0). This implementation is independent and not affiliated with the original project; it does not use its trademarks, logo or assets.
REA (Reverse Engineering Agent) is a separate MCP server already present in the environment; this project uses it only when the agent chooses to call it in Deep mode.
MIT — see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues