openmagic 0.18.0 → 0.20.0

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/cli.js CHANGED
@@ -904,17 +904,18 @@ You MUST respond with valid JSON in this exact format:
904
904
  ## Rules
905
905
  1. The \`search\` field must contain the EXACT text from the source file \u2014 copy it precisely, including whitespace and indentation
906
906
  2. Keep modifications minimal \u2014 change only what's needed
907
- 3. If you need to read a file first, say so in the explanation and the developer can provide it
908
- 4. For style changes, prefer modifying existing CSS/Tailwind classes over adding inline styles
907
+ 3. If the grounded files don't contain the element you need to modify, return: {"modifications":[],"explanation":"NEED_FILE: path/to/file.tsx"} \u2014 the system will automatically read it and retry
908
+ 4. For style changes, prefer modifying existing CSS/Tailwind classes over adding inline styles. Check the dependencies to know if the project uses Tailwind, MUI, etc.
909
909
  5. Always preserve the existing code style and conventions
910
910
  6. If the change involves multiple files, include all modifications in the array
911
911
  7. ALWAYS respond with the JSON format above, even for explanations (put them in the "explanation" field)
912
- 8. If you cannot make the requested change, set modifications to an empty array and explain why`;
912
+ 8. Use the selected element's cssSelector, className, parentContainerStyles, and siblings to understand the layout context before making changes
913
+ 9. Use the page URL and componentHint to identify the correct source file`;
913
914
  function buildContextParts(context) {
914
915
  const parts = {};
915
916
  if (context.selectedElement) {
916
917
  const el = context.selectedElement;
917
- parts.selectedElement = JSON.stringify({
918
+ const elementData = {
918
919
  cssSelector: el.cssSelector,
919
920
  tagName: el.tagName,
920
921
  id: el.id,
@@ -923,7 +924,29 @@ function buildContextParts(context) {
923
924
  computedStyles: el.computedStyles,
924
925
  ancestry: el.ancestry,
925
926
  componentHint: el.componentHint
926
- }, null, 2);
927
+ };
928
+ if (el.parentStyles && Object.keys(el.parentStyles).length) {
929
+ elementData.parentContainerStyles = el.parentStyles;
930
+ }
931
+ if (el.siblings?.length) {
932
+ elementData.siblings = el.siblings;
933
+ }
934
+ if (el.matchedCssRules?.length) {
935
+ elementData.matchedCssRules = el.matchedCssRules;
936
+ }
937
+ if (el.viewport) {
938
+ elementData.viewport = el.viewport;
939
+ }
940
+ if (el.ariaAttributes && Object.keys(el.ariaAttributes).length) {
941
+ elementData.ariaAttributes = el.ariaAttributes;
942
+ }
943
+ if (el.eventHandlers?.length) {
944
+ elementData.eventHandlers = el.eventHandlers;
945
+ }
946
+ if (el.reactProps) {
947
+ elementData.reactProps = el.reactProps;
948
+ }
949
+ parts.selectedElement = JSON.stringify(elementData, null, 2);
927
950
  }
928
951
  if (context.files?.length) {
929
952
  parts.files = context.files;
@@ -1378,7 +1401,7 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
1378
1401
  }
1379
1402
 
1380
1403
  // src/server.ts
1381
- var VERSION = "0.18.0";
1404
+ var VERSION = "0.20.0";
1382
1405
  var __dirname = dirname2(fileURLToPath(import.meta.url));
1383
1406
  function attachOpenMagic(httpServer, roots) {
1384
1407
  function handleRequest(req, res) {
@@ -1911,7 +1934,7 @@ process.on("uncaughtException", (err) => {
1911
1934
  process.exit(1);
1912
1935
  });
1913
1936
  var childProcesses = [];
1914
- var VERSION2 = "0.18.0";
1937
+ var VERSION2 = "0.20.0";
1915
1938
  function ask(question) {
1916
1939
  const rl = createInterface({ input: process.stdin, output: process.stdout });
1917
1940
  return new Promise((resolve3) => {