openmagic 0.17.1 → 0.18.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 +34 -12
- package/dist/cli.js.map +1 -1
- package/dist/toolbar/index.global.js +18 -18
- package/dist/toolbar/index.global.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -912,35 +912,57 @@ You MUST respond with valid JSON in this exact format:
|
|
|
912
912
|
8. If you cannot make the requested change, set modifications to an empty array and explain why`;
|
|
913
913
|
function buildContextParts(context) {
|
|
914
914
|
const parts = {};
|
|
915
|
-
if (context.selectedElement)
|
|
915
|
+
if (context.selectedElement) {
|
|
916
|
+
const el = context.selectedElement;
|
|
917
|
+
parts.selectedElement = JSON.stringify({
|
|
918
|
+
cssSelector: el.cssSelector,
|
|
919
|
+
tagName: el.tagName,
|
|
920
|
+
id: el.id,
|
|
921
|
+
className: el.className,
|
|
922
|
+
outerHTML: el.outerHTML,
|
|
923
|
+
computedStyles: el.computedStyles,
|
|
924
|
+
ancestry: el.ancestry,
|
|
925
|
+
componentHint: el.componentHint
|
|
926
|
+
}, null, 2);
|
|
927
|
+
}
|
|
916
928
|
if (context.files?.length) {
|
|
917
|
-
parts.
|
|
918
|
-
parts.fileContent = context.files[0].content;
|
|
929
|
+
parts.files = context.files;
|
|
919
930
|
}
|
|
920
931
|
if (context.projectTree) parts.projectTree = context.projectTree;
|
|
932
|
+
if (context.pageUrl) parts.pageUrl = context.pageUrl;
|
|
933
|
+
if (context.pageTitle) parts.pageTitle = context.pageTitle;
|
|
921
934
|
if (context.networkLogs) parts.networkLogs = context.networkLogs.map((l) => `${l.method} ${l.url} \u2192 ${l.status || "pending"}`).join("\n");
|
|
922
935
|
if (context.consoleLogs) parts.consoleLogs = context.consoleLogs.map((l) => `[${l.level}] ${l.args.join(" ")}`).join("\n");
|
|
923
936
|
return parts;
|
|
924
937
|
}
|
|
925
938
|
function buildUserMessage(userPrompt, context) {
|
|
926
939
|
const parts = [];
|
|
940
|
+
if (context.pageUrl || context.pageTitle) {
|
|
941
|
+
parts.push(`## Page Context
|
|
942
|
+
URL: ${context.pageUrl || "unknown"}
|
|
943
|
+
Title: ${context.pageTitle || "unknown"}`);
|
|
944
|
+
}
|
|
927
945
|
if (context.projectTree) {
|
|
928
946
|
parts.push(`## Project Structure
|
|
929
947
|
\`\`\`
|
|
930
948
|
${context.projectTree}
|
|
931
949
|
\`\`\``);
|
|
932
950
|
}
|
|
933
|
-
if (context.
|
|
934
|
-
parts.push(
|
|
935
|
-
|
|
951
|
+
if (context.files?.length) {
|
|
952
|
+
parts.push(`## Grounded Source Files
|
|
953
|
+
${context.files.map((f) => `### ${f.path}
|
|
954
|
+
\`\`\`
|
|
955
|
+
${f.content}
|
|
956
|
+
\`\`\``).join("\n\n")}`);
|
|
957
|
+
} else if (context.filePath && context.fileContent) {
|
|
958
|
+
parts.push(`## Source File: ${context.filePath}
|
|
936
959
|
\`\`\`
|
|
937
960
|
${context.fileContent}
|
|
938
|
-
\`\`\``
|
|
939
|
-
);
|
|
961
|
+
\`\`\``);
|
|
940
962
|
}
|
|
941
963
|
if (context.selectedElement) {
|
|
942
|
-
parts.push(`## Selected Element
|
|
943
|
-
\`\`\`
|
|
964
|
+
parts.push(`## Selected Element
|
|
965
|
+
\`\`\`json
|
|
944
966
|
${context.selectedElement}
|
|
945
967
|
\`\`\``);
|
|
946
968
|
}
|
|
@@ -1356,7 +1378,7 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
|
|
|
1356
1378
|
}
|
|
1357
1379
|
|
|
1358
1380
|
// src/server.ts
|
|
1359
|
-
var VERSION = "0.
|
|
1381
|
+
var VERSION = "0.18.0";
|
|
1360
1382
|
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
1361
1383
|
function attachOpenMagic(httpServer, roots) {
|
|
1362
1384
|
function handleRequest(req, res) {
|
|
@@ -1889,7 +1911,7 @@ process.on("uncaughtException", (err) => {
|
|
|
1889
1911
|
process.exit(1);
|
|
1890
1912
|
});
|
|
1891
1913
|
var childProcesses = [];
|
|
1892
|
-
var VERSION2 = "0.
|
|
1914
|
+
var VERSION2 = "0.18.0";
|
|
1893
1915
|
function ask(question) {
|
|
1894
1916
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1895
1917
|
return new Promise((resolve3) => {
|