@createlex/figgen 1.5.0 → 1.5.1
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 +6 -22
- package/package.json +1 -1
package/companion/mcp-server.mjs
CHANGED
|
@@ -828,18 +828,8 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
828
828
|
includeImages: true,
|
|
829
829
|
});
|
|
830
830
|
|
|
831
|
-
|
|
832
|
-
const
|
|
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);
|
|
831
|
+
// Prefer LLM-generated code over template-generated code
|
|
832
|
+
const finalCode = llmCode || generated.code;
|
|
843
833
|
|
|
844
834
|
const effectiveStructName = inferStructName({
|
|
845
835
|
code: finalCode,
|
|
@@ -850,7 +840,7 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
850
840
|
targetDir,
|
|
851
841
|
code: finalCode,
|
|
852
842
|
structName: effectiveStructName,
|
|
853
|
-
images,
|
|
843
|
+
images: Array.isArray(generated.images) ? generated.images : [],
|
|
854
844
|
additionalFiles: llmAdditionalFiles,
|
|
855
845
|
});
|
|
856
846
|
|
|
@@ -870,6 +860,8 @@ server.registerTool('write_selection_to_xcode', {
|
|
|
870
860
|
filePath: result.results?.swiftFile ?? null,
|
|
871
861
|
});
|
|
872
862
|
|
|
863
|
+
const imageNames = (generated.images ?? []).map((img) => img.name);
|
|
864
|
+
|
|
873
865
|
return jsonResult(buildCompactResponse({
|
|
874
866
|
result,
|
|
875
867
|
structName: effectiveStructName,
|
|
@@ -973,7 +965,6 @@ server.registerTool('figma_to_swiftui', {
|
|
|
973
965
|
context,
|
|
974
966
|
generationMode,
|
|
975
967
|
includeOverflow,
|
|
976
|
-
imageNames,
|
|
977
968
|
});
|
|
978
969
|
if (response.ok && data?.handled) {
|
|
979
970
|
llmResult = {
|
|
@@ -996,14 +987,7 @@ server.registerTool('figma_to_swiftui', {
|
|
|
996
987
|
// -------------------------------------------------------------------------
|
|
997
988
|
if (llmResult) {
|
|
998
989
|
const parsed = parseClaudeResponse(llmResult.code || '');
|
|
999
|
-
const
|
|
1000
|
-
// If the hosted provider returned a generic template that doesn't reference any exported
|
|
1001
|
-
// assets, fall back to the plugin-generated code which has correct Image("name") calls.
|
|
1002
|
-
const hostedMissedAssets =
|
|
1003
|
-
llmResult.provider === 'createlex-hosted' &&
|
|
1004
|
-
imageNames.length > 0 &&
|
|
1005
|
-
!imageNames.some((n) => llmCode.includes(`Image("${n}")`));
|
|
1006
|
-
const finalCode = hostedMissedAssets ? (generated.code || llmCode) : (llmCode || generated.code);
|
|
990
|
+
const finalCode = parsed.code || llmResult.code || generated.code;
|
|
1007
991
|
const effectiveStructName = inferStructName({
|
|
1008
992
|
code: finalCode,
|
|
1009
993
|
selectionNames: generated.selection?.names ?? [],
|