Getting started
PMF Harness adds a Suggest a change button to your app. When a user asks for a change, it:
- records the request, the element they pointed at (selector, text, current styles) and a text outline of the screen;
- drafts a small copy or layout change, with the built-in rules or your server's AI drafter;
- applies it for that user only and asks "Is this better?";
- keeps or undoes it, and records the verdict so you can see which changes win.
Requests it can't turn into a safe copy or layout change (bugs, new features, account issues, anything vague) go to a developer queue instead.
Add the script
<script src="https://cdn.jsdelivr.net/gh/theguysaccount/pmf-harness-self-evolving-app@v0.1.0/dist/pmf-harness.js" data-app="my-app" defer></script>
That is local mode: rule-based drafting, and every request, change and verdict kept in the user's own browser. It's the quickest way to try the loop on a real app. For AI drafting and verdicts from all your users in one place, run the server and add data-endpoint.
Prefer a package? Install it straight from GitHub (no registry account involved) and import it:
npm install github:theguysaccount/pmf-harness-self-evolving-app#v0.1.0
import PMFHarness from "pmf-harness";
PMFHarness.init({ appId: "my-app", endpoint: "/pmf" });
Options
As data- attributes on the script tag, or as PMFHarness.init({...}) options:
| Attribute | Option | Default | What it does |
|---|---|---|---|
data-app | appId | the hostname | Names this app's storage, so two apps on one domain don't mix |
data-endpoint | endpoint | none | Your server's base URL, e.g. https://api.example.com/pmf |
data-drafter="rules" | drafter | "auto" | auto uses your server when there is one and falls back to the rules; rules never calls the server to draft; or pass an async function |
data-position="left" | position | right | Which corner the button sits in |
data-label | label | Suggest a change | The button's text |
data-accent | accent | #4f46e5 | The widget's accent colour |
data-badge="off" | badge | on | The small "Built with PMF Harness" link in the panel |
data-screenshot="on" | capture.screenshot | off | Lets users attach a screenshot for your AI drafter (the browser asks each time; needs an endpoint) |
data-manual | Don't start until you call PMFHarness.init() | ||
user | random per browser | Your own user id, so verdicts follow a signed-in user across devices | |
root | document | Where changes may apply | |
onEvent(type, payload) | Called on open, change, verdict and queue |
Add ?pmf=off to a URL to load the page without the widget, and mark anything sensitive with data-pmf-private: its text is never read.
JavaScript API
PMFHarness.init(options); // once; returns the widget
await PMFHarness.suggest("make this bigger", { target: element }); // { change } or { queue }
PMFHarness.verdict(changeId, true); // the same as the user pressing "Yes, keep it"
PMFHarness.changes(); // this user's changes and their status
PMFHarness.undo(changeId);
PMFHarness.open(); PMFHarness.close();
PMFHarness.admin(); // the developer view (see below)
PMFHarness.reset(); // revert and forget this user's changes
The widget also dispatches DOM events on its host element: pmf:open, pmf:change, pmf:verdict and pmf:queue, with the details in event.detail.
Custom drafters
PMFHarness.init({
drafter: async (request) => {
// request: { text, target: { selector, text, styles, prevSelector, nextSelector, ... }, context: { outline, viewport }, page }
return { change: { summary: "Made it bigger", ops: [{ op: "style", selector: request.target.selector, props: { "font-size": "18px" } }] } };
// or: return { queue: { kind: "feature", reason: "Needs a developer" } };
},
});
Whatever a drafter returns is validated against the change format and checked against the page before it's applied.
The developer view
Open your app with ?pmf-admin=1, or call PMFHarness.admin() in the console. In local mode it shows the current browser's data. With a server, pass your admin token to see everyone's:
PMFHarness.init({ endpoint: "https://api.example.com/pmf", adminToken: "…" }); // in a dev build or the console only
PMFHarness.admin();
Never put the admin token in code you ship to users. For each change you see how many users kept it, the operations it makes, and two actions: Roll out to everyone and Copy as a coding-agent brief (to make it permanent in your source).
Next
- Run the server: AI drafting with your own key, shared verdicts, rollouts.
- Safety model: what a change can and can't do.
- Change format: the JSON your drafter returns.