GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - semcod/repatch: Scope-based HTML/CSS/DOM patch utilities and LLM patch helpers

BranchesTags
Open more actions menu

Latest commit

 

History

153 Commits
153 Commits

Folders and files

NameName
Last commit message
Last commit date
.cursor
.cursor
 
 
.github
.github
 
 
.governance
.governance
 
 
.nlp2dsl
.nlp2dsl
 
 
Once `pytest --collect-only tests
Once `pytest --collect-only tests
 
 
Stage and commit `repatch
Stage and commit `repatch
 
 
TODO
TODO
 
 
With `repatch
With `repatch
 
 
docs
docs
 
 
project
project
 
 
repatch
repatch
 
 
sdks
sdks
 
 
testql-scenarios
testql-scenarios
 
 
tests
tests
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.nojekyll
.nojekyll
 
 
AGENTS.md
AGENTS.md
 
 
Alternatively, running
Alternatively, running
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Close ticket
Close ticket
 
 
Complete ticket PLF-181
Complete ticket PLF-181
 
 
Dockerfile
Dockerfile
 
 
If you are tracking ticket status via planfile, you can record this blocker with
If you are tracking ticket status via planfile, you can record this blocker with
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
Now execute
Now execute
 
 
Once the checks pass, close the ticket
Once the checks pass, close the ticket
 
 
Planfile status completion
Planfile status completion
 
 
Please run
Please run
 
 
README.md
README.md
 
 
Run
Run
 
 
Run checks to verify
Run checks to verify
 
 
Run test suite
Run test suite
 
 
SUMD.md
SUMD.md
 
 
SUMR.md
SUMR.md
 
 
Since the refactoring is already in place and addresses the smell
Since the refactoring is already in place and addresses the smell
 
 
Since the smell is already resolved and verified against the criteria
Since the smell is already resolved and verified against the criteria
 
 
Stage and commit
Stage and commit
 
 
Suggested git commit command
Suggested git commit command
 
 
To close the ticket
To close the ticket
 
 
To complete the ticket and verification
To complete the ticket and verification
 
 
To complete ticket `PLF-181
To complete ticket `PLF-181
 
 
To complete ticket handoff
To complete ticket handoff
 
 
To mark the ticket complete, run
To mark the ticket complete, run
 
 
VERSION
VERSION
 
 
Verify collection and tests
Verify collection and tests
 
 
app.doql.less
app.doql.less
 
 
deps.json
deps.json
 
 
docker-compose.yml
docker-compose.yml
 
 
goal.yaml
goal.yaml
 
 
index.html
index.html
 
 
koru.yaml
koru.yaml
 
 
local.dev.txt
local.dev.txt
 
 
or
or
 
 
project.sh
project.sh
 
 
pyproject.toml
pyproject.toml
 
 
regix.yaml
regix.yaml
 
 
tree.sh
tree.sh
 
 
tree.txt
tree.txt
 
 
uv.lock
uv.lock
 
 
wup.yaml
wup.yaml
 
 

Repository files navigation

repatch

Reusable HTML/CSS/DOM patch utilities extracted from Nexu Cinema: marked-element context, scope-restricted CSS, spatial deletes, LLM UI patch prompts, and local function DOM patches.

Also includes the original RepatchService for scope-based LLM fragment suggestions.

Install

pip install -e .
# Nexu: repatch @ file:///path/to/repatch in pyproject.toml

Local development (DevX)

Run the whole dev stack in one command — seed fixtures, hot-reload and interactive OpenAPI docs:

pip install -e ".[server]"   # once, to install fastapi + uvicorn
make dev                     # http://localhost:8000/docs

or via Docker Compose:

docker compose up --build   # or: make up

Both start a FastAPI dev server that exposes the patch utilities as HTTP endpoints, auto-generates OpenAPI docs at /docs (Swagger UI) and /redoc, and pre-loads the bundled seed fixtures (GET /seeds). make seed (or python -m repatch.seeds) lists the seed fixtures standalone. The server is started with --reload, so edits to repatch/ are picked up automatically.

Public API (repatch)

Module Key symbols
marked_context build_marked_element_context, resolve_marked_llm_context, restrict_scope_css_to_marks, marked_css_selectors, has_ui_marks
scope inject_scope_style, strip_scope_style, normalize_focus_scope, should_block_full_html_iterate, scoped_html_fragment
ui_patch build_ui_patch_prompt, parse_ui_patch_response, apply_ui_patch_options, supports_llm_patch_scope
spatial apply_spatial_deletes_to_html
dom_patch build_function_option_patches, build_function_patch_context, supports_function_patch
options sync_option_previews_from_workspace, enforce_deletes_on_option_previews, replace_html_title, html_files_distinct
css split_css_rules, validate_css_safety
project_ir build_project_ir, summarize_project_ir
service RepatchService, PatchSuggestion

Multi-Language Client SDKs

The repatch repository provides official client-side and process SDKs under the sdks/ directory to simplify surgical real-time UI mutations across different languages and platforms:

1. JavaScript SDK (sdks/js/repatch-sdk.js)

A client-side library to be included in browsers. It connects to the Repatch WebSocket/SSE stream and executes surgical updates:

  • ADD <selector> <html_content>: Appends child element.
  • REPLACE <selector> <html_content>: Replaces content.
  • STYLE <selector> { css }: Scopes CSS to element.
  • REMOVE <selector>: Deletes element.

2. Python Client SDK (sdks/python/repatch_sdk.py)

A thread-safe client that allows other python services, test harnesses, or CLI agents to subscribe or broadcast patches:

from repatch_sdk import RepatchClient

client = RepatchClient("ws://localhost:8083/repatch")

@client.on_patch
def handle_patch(data):
    print("Received patch DSL:", data["dsl"])

client.start()
client.send_patch("STYLE #btn-eq { background: red; }")

Example: marked context + UI patch prompt

from repatch import build_marked_element_context
from repatch.ui_patch import build_ui_patch_prompt

ctx = build_marked_element_context(html, keep_ids=["7"], delete_ids=["tan"], focus_scope="colors", project_kind="calculator")
prompt = build_ui_patch_prompt(html, focus_scope="colors", project_kind="calculator", option_variants=variants, context_fragment=ctx)

Example: file-level option previews

from repatch import enforce_deletes_on_option_previews, sync_option_previews_from_workspace

sync_option_previews_from_workspace(
    "capsule/cinema",
    stage=0,
    delete_ids=["old-cta"],
    finalize_html=my_finalize_html,
)

enforce_deletes_on_option_previews(
    "capsule/cinema",
    ["old-cta"],
    finalize_html=my_finalize_html,
)

Original RepatchService (v0)

from repatch import RepatchService

service = RepatchService(model="gpt-4o-mini")

fragment = """
<section>
  <h1>Pracownia Malort Gdynia – przestrzeń dla kreatywności Twojego dziecka</h1>
  <p>Zapraszamy do wyjątkowego miejsca...</p>

## AI Cost Tracking

![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.2.21-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
![AI Cost](https://img.shields.io/badge/AI%20Cost-$2.90-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-16.8h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)

- 🤖 **LLM usage:** $2.9005 (25 commits)
- 👤 **Human dev:** ~$1683 (16.8h @ $100/h, 30min dedup)

Generated on 2026-07-07 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)

---

  <button>Zapisz dziecko</button>
</section>
"""

suggestions = service.generate_patch_suggestions(
    fragment=fragment,
    scopes=["display", "colors"],
)

for idx, item in enumerate(suggestions, start=1):
    print(f"Wariant {idx}:")
    print("KEEP:", item.keep)
    print("CHANGE:", item.change)
    print(item.patched_fragment)

License

Licensed under Apache-2.0.

About

Scope-based HTML/CSS/DOM patch utilities and LLM patch helpers

semcod.github.io/repatch/

Topics

automationconfigurationllmpatchpythonsemcod

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.