@createlex/figgen 1.4.9 → 1.5.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/companion/mcp-server.mjs +13 -5
- package/package.json +1 -1
package/companion/mcp-server.mjs
CHANGED
|
@@ -828,8 +828,18 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
828
828
|
includeImages: true,
|
|
829
829
|
});
|
|
830
830
|
|
|
831
|
-
|
|
832
|
-
const
|
|
831
|
+
const images = Array.isArray(generated.images) ? generated.images : [];
|
|
832
|
+
const imageNames = images.map((img) => img.name);
|
|
833
|
+
|
|
834
|
+
// If the hosted provider returned a generic template that doesn't reference any exported
|
|
835
|
+
// assets, fall back to the plugin-generated code which has correct Image("name") calls.
|
|
836
|
+
const hostedMissedAssets =
|
|
837
|
+
imageNames.length > 0 &&
|
|
838
|
+
llmCode &&
|
|
839
|
+
!imageNames.some((n) => llmCode.includes(`Image("${n}")`));
|
|
840
|
+
|
|
841
|
+
// Prefer LLM-generated code only when it actually wires up the exported assets.
|
|
842
|
+
const finalCode = hostedMissedAssets ? (generated.code || llmCode) : (llmCode || generated.code);
|
|
833
843
|
|
|
834
844
|
const effectiveStructName = inferStructName({
|
|
835
845
|
code: finalCode,
|
|
@@ -840,7 +850,7 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
840
850
|
targetDir,
|
|
841
851
|
code: finalCode,
|
|
842
852
|
structName: effectiveStructName,
|
|
843
|
-
images
|
|
853
|
+
images,
|
|
844
854
|
additionalFiles: llmAdditionalFiles,
|
|
845
855
|
});
|
|
846
856
|
|
|
@@ -860,8 +870,6 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
860
870
|
filePath: result.results?.swiftFile ?? null,
|
|
861
871
|
});
|
|
862
872
|
|
|
863
|
-
const imageNames = (generated.images ?? []).map((img) => img.name);
|
|
864
|
-
|
|
865
873
|
return jsonResult(buildCompactResponse({
|
|
866
874
|
result,
|
|
867
875
|
structName: effectiveStructName,
|