made-refine 0.2.11 → 0.2.13

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/dist/index.mjs CHANGED
@@ -2900,7 +2900,7 @@ function buildExportInstruction(profile) {
2900
2900
  return hasComments ? "Address this feedback on the UI. Use the provided source location and selector to find each element in the codebase." : "";
2901
2901
  }
2902
2902
  const parts = [];
2903
- if (hasCssEdits) parts.push("Apply the CSS changes to the targeted elements using the project's existing styling approach (Tailwind, CSS modules, etc.).");
2903
+ if (hasCssEdits) parts.push("Apply the CSS changes to the targeted elements using the project's existing styling approach (Tailwind, CSS modules, etc.). Map values to existing CSS variables, design tokens, or utility classes already used in the project whenever possible.");
2904
2904
  if (hasTextEdits) parts.push("Update the text content as specified.");
2905
2905
  if (hasMoves) parts.push("Implement the move plan below directly in source code. For `structural_move`, reorder/reparent elements using the target anchors. For `layout_refactor`, apply the listed flex/grid refactor steps. Do NOT simulate movement with absolute positioning, left/top offsets, transform, or margin hacks.");
2906
2906
  if (hasComments) parts.push("Address the comments on the relevant elements.");
@@ -3612,11 +3612,6 @@ function useStyleUpdaters({
3612
3612
  import * as React3 from "react";
3613
3613
 
3614
3614
  // src/clipboard.ts
3615
- function buildAgentClipboardText(markdown) {
3616
- return `implement the visual edits
3617
-
3618
- ${markdown}`;
3619
- }
3620
3615
  function tryRestoreFocus(element) {
3621
3616
  if (!(element instanceof HTMLElement)) return;
3622
3617
  try {
@@ -5314,6 +5309,12 @@ async function checkAgentConnection() {
5314
5309
  }
5315
5310
 
5316
5311
  // src/use-agent-comms.ts
5312
+ function withInstruction(profile, markdown) {
5313
+ const instruction = buildExportInstruction(profile);
5314
+ return instruction ? `${instruction}
5315
+
5316
+ ${markdown}` : markdown;
5317
+ }
5317
5318
  function buildLocatorPayload(locator) {
5318
5319
  return {
5319
5320
  element: {
@@ -5406,6 +5407,11 @@ function useAgentComms({ stateRef, sessionEditsRef, getSessionItems, saveCurrent
5406
5407
  const movePlan = includeBatchMoveEnvelope ? resolvedPlanContext.movePlan : null;
5407
5408
  const hasMeaningfulPayload = changes.length > 0 || sessionEdit.textEdit != null || moveIntent != null;
5408
5409
  if (!hasMeaningfulPayload) return true;
5410
+ const profile = getExportContentProfile(
5411
+ [sessionEdit],
5412
+ [],
5413
+ resolvedPlanContext
5414
+ );
5409
5415
  try {
5410
5416
  const result = await sendEditToAgent({
5411
5417
  ...buildLocatorPayload(locator),
@@ -5413,7 +5419,7 @@ function useAgentComms({ stateRef, sessionEditsRef, getSessionItems, saveCurrent
5413
5419
  textChange: sessionEdit.textEdit ?? null,
5414
5420
  moveIntent,
5415
5421
  ...movePlan ? { movePlan } : {},
5416
- exportMarkdown
5422
+ exportMarkdown: withInstruction(profile, exportMarkdown)
5417
5423
  });
5418
5424
  if (result.ok) {
5419
5425
  removeSessionEdit(sessionEdit.element);
@@ -5425,12 +5431,13 @@ function useAgentComms({ stateRef, sessionEditsRef, getSessionItems, saveCurrent
5425
5431
  }, [updateAgentAvailability, removeSessionEdit]);
5426
5432
  const sendSessionCommentToAgent = React5.useCallback(async (comment) => {
5427
5433
  const exportMarkdown = buildCommentExport(comment.locator, comment.text, comment.replies);
5434
+ const commentProfile = { hasCssEdits: false, hasTextEdits: false, hasMoves: false, hasComments: true };
5428
5435
  try {
5429
5436
  const result = await sendCommentToAgent({
5430
5437
  ...buildLocatorPayload(comment.locator),
5431
5438
  commentText: comment.text,
5432
5439
  replies: comment.replies,
5433
- exportMarkdown
5440
+ exportMarkdown: withInstruction(commentProfile, exportMarkdown)
5434
5441
  });
5435
5442
  if (result.ok) {
5436
5443
  deleteComment(comment.id);
@@ -5450,12 +5457,14 @@ function useAgentComms({ stateRef, sessionEditsRef, getSessionItems, saveCurrent
5450
5457
  );
5451
5458
  if (editsWithChanges.length === 0 && contextBlocks.length === 0) return false;
5452
5459
  const markdownParts = [];
5460
+ let movePlanCtx = null;
5453
5461
  if (editsWithChanges.length > 0) {
5454
- const movePlanContext = buildMovePlanContext(editsWithChanges);
5455
- markdownParts.push(buildSessionExport(editsWithChanges, [], { movePlanContext }));
5462
+ movePlanCtx = buildMovePlanContext(editsWithChanges);
5463
+ markdownParts.push(buildSessionExport(editsWithChanges, [], { movePlanContext: movePlanCtx }));
5456
5464
  }
5457
5465
  markdownParts.push(...contextBlocks);
5458
5466
  const exportMarkdown = markdownParts.join("\n\n");
5467
+ const multiProfile = getExportContentProfile(editsWithChanges, [], movePlanCtx);
5459
5468
  const primaryEl = current.selectedElements.find((el) => el.isConnected);
5460
5469
  if (!primaryEl) return false;
5461
5470
  const primary = getElementLocator(primaryEl);
@@ -5465,7 +5474,7 @@ function useAgentComms({ stateRef, sessionEditsRef, getSessionItems, saveCurrent
5465
5474
  changes: [],
5466
5475
  textChange: null,
5467
5476
  moveIntent: null,
5468
- exportMarkdown
5477
+ exportMarkdown: withInstruction(multiProfile, exportMarkdown)
5469
5478
  });
5470
5479
  if (result.ok) {
5471
5480
  for (const el of current.selectedElements) {
@@ -6414,9 +6423,10 @@ function DirectEditProvider({ children }) {
6414
6423
  enterCanvas();
6415
6424
  }
6416
6425
  if (wasActive) {
6426
+ clearSelection();
6417
6427
  closePanel();
6418
6428
  }
6419
- }, [toggleEditModeBase, stateRef, exitCanvas, enterCanvas, closePanel]);
6429
+ }, [toggleEditModeBase, stateRef, exitCanvas, enterCanvas, clearSelection, closePanel]);
6420
6430
  const toggleCanvasWithPreference = React8.useCallback(() => {
6421
6431
  const willBeActive = !stateRef.current.canvas.active;
6422
6432
  toggleCanvas();
@@ -14805,7 +14815,10 @@ function DirectEditDemo() {
14805
14815
  const handleExportEdits = async () => {
14806
14816
  if (Object.keys(pendingStyles).length === 0) return false;
14807
14817
  const exportMarkdown = buildEditExport(DEMO_LOCATOR, pendingStyles);
14808
- return copyText(buildAgentClipboardText(exportMarkdown));
14818
+ const instruction = buildExportInstruction({ hasCssEdits: true, hasTextEdits: false, hasMoves: false, hasComments: false });
14819
+ return copyText(`${instruction}
14820
+
14821
+ ${exportMarkdown}`);
14809
14822
  };
14810
14823
  return /* @__PURE__ */ jsx36("div", { className: "min-h-screen p-8", children: /* @__PURE__ */ jsxs29("div", { className: "mx-auto max-w-4xl", children: [
14811
14824
  /* @__PURE__ */ jsx36("h1", { className: "mb-2 text-2xl font-bold", children: "Direct Edit Panel" }),