transitions-refine 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/demo.html +340 -599
- package/package.json +1 -1
- package/server/relay.mjs +29 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transitions-refine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Live, agent-driven Refine panel for CSS/Motion transitions — injects a timeline + Refine UI and runs transitions.dev suggestions via your coding agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/server/relay.mjs
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
// and POSTs the result back. This is the default, install-free path.
|
|
17
17
|
// b) A headless CLI: start the relay with REFINE_AGENT_CMD set and the
|
|
18
18
|
// relay spawns it once per job (stdin = prompt, stdout = JSON).
|
|
19
|
-
// e.g. REFINE_AGENT_CMD='cursor-agent -p' npm run relay
|
|
19
|
+
// e.g. REFINE_AGENT_CMD='cursor-agent -p --trust --force' npm run relay
|
|
20
|
+
// (for cursor-agent the relay auto-appends any missing -p/--trust/--force
|
|
21
|
+
// so headless jobs don't fail the workspace-trust prompt.)
|
|
20
22
|
//
|
|
21
23
|
// Run: node server/relay.mjs (or: npm run relay)
|
|
22
24
|
|
|
@@ -31,7 +33,23 @@ import { buildInjectModule } from "./inject.mjs";
|
|
|
31
33
|
|
|
32
34
|
const PORT = Number(process.env.REFINE_RELAY_PORT) || 7331;
|
|
33
35
|
const AUTO = process.env.REFINE_AUTO !== "0";
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
// A bare `cursor-agent` goes interactive: it prints "⚠ Workspace Trust Required"
|
|
38
|
+
// and exits 1, so every headless refine/scan/apply job fails. Force the headless
|
|
39
|
+
// trio whenever the command is cursor-agent: -p (print/headless, reads the prompt
|
|
40
|
+
// from stdin), --trust (trust the workspace without prompting; only valid with
|
|
41
|
+
// --print), and --force (auto-allow tool calls so apply/scan don't hang on
|
|
42
|
+
// approval). Append only the missing flags; leave non-cursor-agent commands alone.
|
|
43
|
+
function augmentAgentCmd(cmd) {
|
|
44
|
+
if (!cmd || !/(^|\s|\/)cursor-agent(\s|$)/.test(cmd)) return cmd;
|
|
45
|
+
const has = (...flags) => flags.some((f) => new RegExp(`(^|\\s)${f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(\\s|$)`).test(cmd));
|
|
46
|
+
const extra = [];
|
|
47
|
+
if (!has("-p", "--print")) extra.push("-p");
|
|
48
|
+
if (!has("--trust")) extra.push("--trust");
|
|
49
|
+
if (!has("-f", "--force", "--yolo")) extra.push("--force");
|
|
50
|
+
return extra.length ? `${cmd} ${extra.join(" ")}` : cmd;
|
|
51
|
+
}
|
|
52
|
+
const AGENT_CMD = augmentAgentCmd(process.env.REFINE_AGENT_CMD || null);
|
|
35
53
|
const AGENT_TIMEOUT_MS = Number(process.env.REFINE_AGENT_TIMEOUT_MS) || 120000;
|
|
36
54
|
const LONGPOLL_MS = Number(process.env.REFINE_LONGPOLL_MS) || 25000;
|
|
37
55
|
// Grace window after a `/refine live` agent's last poll during which LLM mode is
|
|
@@ -109,7 +127,8 @@ function nextPendingLlm() {
|
|
|
109
127
|
|
|
110
128
|
function buildPrompt(job) {
|
|
111
129
|
const r = job.request || {};
|
|
112
|
-
const
|
|
130
|
+
const rawType = r.refineType || "small";
|
|
131
|
+
const refineType = rawType === "replace" ? "replace" : rawType === "both" ? "both" : "small";
|
|
113
132
|
const lines = [
|
|
114
133
|
"You are refining ONE CSS transition against the transitions.dev library and motion tokens.",
|
|
115
134
|
"Read the transitions-dev skill's SKILL.md (look in .agents/skills/transitions-dev/ or ~/.agents/skills/transitions-dev/) and apply its `transitions refine` behaviour, `## Motion tokens`, and `## Decision rules`.",
|
|
@@ -125,6 +144,12 @@ function buildPrompt(job) {
|
|
|
125
144
|
"refineType is \"replace\": suggest a WHOLE-TRANSITION replacement ONLY — do NOT propose motion-token tweaks (no kind \"duration\"/\"delay\"/\"easing\").",
|
|
126
145
|
"Run the skill's `## Decision rules` on the inferred usage, pick the SINGLE best-fit transitions.dev recipe, and read its reference file (e.g. 06-modal.md) for the real timings/easing. Emit ONE suggestion with kind \"replace\": set its `patch` to the recipe's recommended duration/easing for the property that already transitions (or \"all\") so Apply works live, add a `reference` field with the reference filename, and name the recipe in `title`/`reason`. Never invent timings — quote the reference file. If no recipe genuinely fits the usage, return an empty suggestions array.",
|
|
127
146
|
);
|
|
147
|
+
} else if (refineType === "both") {
|
|
148
|
+
lines.push(
|
|
149
|
+
"refineType is \"both\": produce TWO independent groups in the SAME suggestions array — the UI shows them in separate tabs, so include each group whenever it applies.",
|
|
150
|
+
"(1) Motion-token tweaks (kind \"duration\"/\"delay\"/\"easing\"): for each declaration, propose the token value only where it DIFFERS from the current one.",
|
|
151
|
+
"(2) Whole-transition replacement (kind \"replace\"): ALWAYS evaluate one — run the skill's `## Decision rules` on the inferred usage, pick the SINGLE best-fit transitions.dev recipe, and read its reference file (e.g. 06-modal.md) for the real timings/easing. Emit at most ONE \"replace\" suggestion: set its `patch` to the recipe's recommended duration/easing for the property that already transitions (or \"all\"), add a `reference` field with the reference filename, and name the recipe in `title`/`reason`. Never invent timings — quote the reference file. If no recipe genuinely fits the usage, simply omit the replace suggestion.",
|
|
152
|
+
);
|
|
128
153
|
} else {
|
|
129
154
|
lines.push(
|
|
130
155
|
"refineType is \"small\": FIRST suggest motion-token tweaks — for each declaration, propose the token value only where it DIFFERS from the current one (kind \"duration\"/\"delay\"/\"easing\").",
|
|
@@ -326,7 +351,7 @@ async function answerJob(job) {
|
|
|
326
351
|
if (!AGENT_CMD) {
|
|
327
352
|
throw new Error(
|
|
328
353
|
"LLM mode needs an agent CLI. Restart the relay with REFINE_AGENT_CMD set " +
|
|
329
|
-
"(e.g. REFINE_AGENT_CMD='cursor-agent -p' npm run relay), or switch to the Deterministic tab."
|
|
354
|
+
"(e.g. REFINE_AGENT_CMD='cursor-agent -p --trust --force' npm run relay), or switch to the Deterministic tab."
|
|
330
355
|
);
|
|
331
356
|
}
|
|
332
357
|
job.statusLog.push({ message: "Asking your agent…", at: now() });
|