- ClayJS
- Reference
- Plugins
- ai-edit
ai-edit
Comment-to-edit AI editing built on the wire: select text, describe the change, keep or revert it.
Comment-to-edit AI editing, built on the wire. Hover a heading or paragraph for the chip, press ⌘J with the caret in one (a selection rides along as a quote), click bare section padding for the nearest unit, or use the bottom-right bubble for the whole page. The comment goes to the host’s ai-edit helper as a named wire request and comes back as that element’s HTML, morphed in place: Keep saves it, Revert puts the snapshot back. @file.ext in the comment adds context, and @page saves the page first so the helper reads it from disk.
Loading#
<script src="https://clayjs.com/v1/clay.js?plugins=ai-edit"></script>
Check “AI editing” in the configurator, or add ?plugins=ai-edit yourself. Asking for ai-edit loads wire with it. It is dormant unless the host lists a ready ai-edit helper, so a page on HTML Clay loads it and does nothing with it. Edit mode only. The host side is Hyperclay Local with AI editing turned on.
Rewrite a paragraph#
The rewrite replaces the original paragraph on the page. You can read it before deciding whether to save it.
- Select the sentence you want changed, such as “Visitors arriving late will not be admitted”. Keep the selection inside one paragraph.
- Press ⌘J on macOS or Ctrl+J on Windows and Linux. You can also click the small AI chip at the end of the selection. The selected words stay highlighted. A panel opens under them with one box and a Send button. Escape closes the panel. Clicking outside it also closes it. Your unsent request stays as a draft for that part of the page.
- In the “Describe the change” box, type “Make this friendlier. Keep the rule that late arrivals cannot enter”. Shift+Enter adds a line to your request.
- Press Enter or click Send. The panel closes and a bottom bar shows progress and Stop. Stop or Escape cancels the running request and restores the original paragraph. When the reply arrives, the rewrite replaces the paragraph and the bar offers Keep and Revert.
- Check that the rewrite still says what you mean. Revert restores the original paragraph. Keep or Escape keeps the rewrite and saves it into the file. Check the bar for a save confirmation or an error.
Every save waits while you review the rewrite, including autosave and ⌘S. Revert runs any waiting save with the original paragraph back. Keep saves the rewrite instead.
After Keep, open the file in your text editor. If you kept the example rewrite, the paragraph now contains:
<p>Please arrive on time, as we're unable to admit late arrivals.</p>
The earlier version is in Backups in HTML Clay’s tray menu. Hyperclay Local keeps earlier versions in .hyperclay/versions/ inside the served folder.