Metadata-Version: 2.4
Name: djust-designer
Version: 0.1.0
Summary: Visual design collaboration layer for djust / Django — point at the page, edit the source.
Author-email: szto <sztolabs@gmail.com>
License: MIT License
        
        Copyright (c) 2026 szto
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/szto/djust-designer
Project-URL: Repository, https://github.com/szto/djust-designer
Project-URL: Issues, https://github.com/szto/djust-designer/issues
Keywords: django,djust,tailwind,design,visual-editing,mcp,claude
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=5.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-django>=4.9; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: ty>=0.0.18; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0; extra == "mcp"
Provides-Extra: djust
Requires-Dist: djust>=0.1; extra == "djust"
Dynamic: license-file

# djust-designer

> **⚠️ Contributors:** read [`docs/HANDOFF.md`](docs/HANDOFF.md) before starting
> new work — the scope is being reconsidered (Framer-style no-code builder
> vs. current class editor), and the `feat/regions` branch is local-only.

Visual design collaboration layer for [djust](https://github.com/szto/djust) / Django apps.
Point at any element on your running page → see its source template + line → edit its
Tailwind classes with automatic write-back → undo with one click. No terminal, no code
editor. Ships with a Claude Code MCP bridge so an AI assistant can act on whatever the
designer just clicked.

**Runs on `DEBUG=True` only.** No traces in production.

## Install

Plain Django project:

```bash
pip install djust-designer
```

With Claude Code MCP bridge:

```bash
pip install 'djust-designer[mcp]'
```

Targeting a [djust](https://github.com/szto/djust) app (pulls djust too):

```bash
pip install 'djust-designer[djust,mcp]'
```

Local development:

```bash
pip install -e '.[dev,mcp]'
```

## Wire it up

Distribution name is `djust-designer` (hyphen) on PyPI; the Python module is
`djust_designer` (underscore) — standard Django-package convention.

```python
# settings.py
INSTALLED_APPS = [..., "djust_designer"]
MIDDLEWARE = ["djust_designer.middleware.DjustDesignerMiddleware", ...]

TEMPLATES = [{
    "BACKEND": "django.template.backends.django.DjangoTemplates",
    "DIRS": [BASE_DIR / "templates"],
    "APP_DIRS": False,
    "OPTIONS": {"loaders": [(
        "djust_designer.instrument.loader.InstrumentedFilesystemLoader",
        [str(BASE_DIR / "templates")],
    )]},
}]
```

```python
# urls.py
urlpatterns += [path("", include("djust_designer.urls"))]
```

### Using `APP_DIRS = True`

If your project relies on per-app `templates/` directories, use `InstrumentedAppDirsLoader` instead (or in addition to) the filesystem loader:

```python
TEMPLATES = [{
    "BACKEND": "django.template.backends.django.DjangoTemplates",
    "DIRS": [BASE_DIR / "templates"],
    "APP_DIRS": False,
    "OPTIONS": {"loaders": [
        ("djust_designer.instrument.loader.InstrumentedFilesystemLoader",
         [str(BASE_DIR / "templates")]),
        "djust_designer.instrument.loader.InstrumentedAppDirsLoader",
    ]},
}]
```

Every template — whether from `DIRS` or an installed app — is edit-eligible.

## Try the demo

````
cd demo && python manage.py runserver 8737
# open http://localhost:8737
````

Hover → highlight. Click → panel. Edit class → Apply → source rewritten → hot-reloaded.
Undo → previous state.

### Panel niceties

- **Tailwind autocomplete** — the class input suggests ~1,600 common Tailwind
  utilities as you type. Arrow keys navigate, Enter/Tab inserts.
- **Tag label** — the panel header shows the selected element's tag name
  (e.g. `<button>`) so you always know what you're editing.
- **Toast** — Apply/Undo produce a small feedback toast so failures are visible.

## Claude Code (MCP)

The overlay mirrors the designer's current selection to the server so an MCP
client can act on it. Install and register:

```bash
pip install -e '.[mcp]'
claude mcp add djust-designer python -m djust_designer.mcp
```

Then, with the demo (or any djust-designer-wired app) running, ask Claude Code:

> "Restyle whatever I just clicked to be rounder with a dark background."

Claude Code calls the MCP tools:

- `get_current_selection()` — what the designer just clicked (zd_id, file, line, tag, class)
- `resolve_id(zd_id)` — source location for any `data-zd-id` visible in the DOM
- `edit_class(zd_id, new_class)` — rewrite the class attribute (backup-safe)
- `undo_last()` — restore the most recent snapshot

If the app is on a non-default port, set `DJUST_DESIGNER_URL` or pass `--url`
when registering:

```bash
claude mcp add djust-designer -- python -m djust_designer.mcp --url http://127.0.0.1:9000
```

## Publishing to PyPI

Sanity check first, then build and upload:

```bash
pip install -e '.[dev]'
pytest -q && ruff check . && ruff format --check . && ty check
rm -rf dist/
python -m build         # produces dist/*.whl and dist/*.tar.gz
twine check dist/*
twine upload dist/*     # or `twine upload --repository testpypi dist/*` first
```

Version bumps live in `pyproject.toml` (`[project].version`). Tag the release
in git before uploading (`git tag v0.1.0 && git push --tags`).

## License

MIT — see `LICENSE`.

## Design docs

- Design: `docs/superpowers/specs/2026-07-09-djust-designer-design.md`
- Plan: `docs/superpowers/plans/2026-07-09-djust-designer-p1-mvp.md`
