illustrator-mcp-server 1.3.2 → 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.
Files changed (194) hide show
  1. package/README.de.md +539 -0
  2. package/README.es.md +539 -0
  3. package/README.fr.md +539 -0
  4. package/README.ja.md +120 -10
  5. package/README.ko.md +539 -0
  6. package/README.md +119 -10
  7. package/README.pt-BR.md +539 -0
  8. package/README.zh-CN.md +539 -0
  9. package/dist/bundle.cjs +621 -328
  10. package/dist/executor/file-transport.d.ts.map +1 -1
  11. package/dist/executor/file-transport.js +11 -1
  12. package/dist/executor/file-transport.js.map +1 -1
  13. package/dist/jsx/helpers/common.jsx +63 -6
  14. package/dist/tools/export/export-pdf.d.ts.map +1 -1
  15. package/dist/tools/export/export-pdf.js +2 -1
  16. package/dist/tools/export/export-pdf.js.map +1 -1
  17. package/dist/tools/export/export.d.ts.map +1 -1
  18. package/dist/tools/export/export.js +54 -3
  19. package/dist/tools/export/export.js.map +1 -1
  20. package/dist/tools/modify/align-objects.d.ts.map +1 -1
  21. package/dist/tools/modify/align-objects.js +4 -5
  22. package/dist/tools/modify/align-objects.js.map +1 -1
  23. package/dist/tools/modify/apply-color-profile.d.ts.map +1 -1
  24. package/dist/tools/modify/apply-color-profile.js +2 -1
  25. package/dist/tools/modify/apply-color-profile.js.map +1 -1
  26. package/dist/tools/modify/apply-graphic-style.d.ts.map +1 -1
  27. package/dist/tools/modify/apply-graphic-style.js +3 -2
  28. package/dist/tools/modify/apply-graphic-style.js.map +1 -1
  29. package/dist/tools/modify/apply-text-style.d.ts.map +1 -1
  30. package/dist/tools/modify/apply-text-style.js +3 -2
  31. package/dist/tools/modify/apply-text-style.js.map +1 -1
  32. package/dist/tools/modify/close-document.d.ts.map +1 -1
  33. package/dist/tools/modify/close-document.js +2 -1
  34. package/dist/tools/modify/close-document.js.map +1 -1
  35. package/dist/tools/modify/convert-to-outlines.d.ts.map +1 -1
  36. package/dist/tools/modify/convert-to-outlines.js +2 -1
  37. package/dist/tools/modify/convert-to-outlines.js.map +1 -1
  38. package/dist/tools/modify/create-crop-marks.d.ts.map +1 -1
  39. package/dist/tools/modify/create-crop-marks.js +34 -3
  40. package/dist/tools/modify/create-crop-marks.js.map +1 -1
  41. package/dist/tools/modify/create-document.d.ts.map +1 -1
  42. package/dist/tools/modify/create-document.js +2 -1
  43. package/dist/tools/modify/create-document.js.map +1 -1
  44. package/dist/tools/modify/create-ellipse.js +1 -1
  45. package/dist/tools/modify/create-gradient.d.ts.map +1 -1
  46. package/dist/tools/modify/create-gradient.js +2 -1
  47. package/dist/tools/modify/create-gradient.js.map +1 -1
  48. package/dist/tools/modify/create-line.js +1 -1
  49. package/dist/tools/modify/create-path-text.d.ts.map +1 -1
  50. package/dist/tools/modify/create-path-text.js +2 -1
  51. package/dist/tools/modify/create-path-text.js.map +1 -1
  52. package/dist/tools/modify/create-path.js +1 -1
  53. package/dist/tools/modify/create-rectangle.js +1 -1
  54. package/dist/tools/modify/create-text-frame.d.ts.map +1 -1
  55. package/dist/tools/modify/create-text-frame.js +4 -6
  56. package/dist/tools/modify/create-text-frame.js.map +1 -1
  57. package/dist/tools/modify/duplicate-objects.d.ts.map +1 -1
  58. package/dist/tools/modify/duplicate-objects.js +17 -3
  59. package/dist/tools/modify/duplicate-objects.js.map +1 -1
  60. package/dist/tools/modify/group-objects.d.ts.map +1 -1
  61. package/dist/tools/modify/group-objects.js +2 -1
  62. package/dist/tools/modify/group-objects.js.map +1 -1
  63. package/dist/tools/modify/import-svg-as-editable.d.ts +3 -0
  64. package/dist/tools/modify/import-svg-as-editable.d.ts.map +1 -0
  65. package/dist/tools/modify/import-svg-as-editable.js +247 -0
  66. package/dist/tools/modify/import-svg-as-editable.js.map +1 -0
  67. package/dist/tools/modify/manage-artboards.d.ts.map +1 -1
  68. package/dist/tools/modify/manage-artboards.js +9 -2
  69. package/dist/tools/modify/manage-artboards.js.map +1 -1
  70. package/dist/tools/modify/manage-datasets.d.ts.map +1 -1
  71. package/dist/tools/modify/manage-datasets.js +2 -1
  72. package/dist/tools/modify/manage-datasets.js.map +1 -1
  73. package/dist/tools/modify/manage-layers.d.ts.map +1 -1
  74. package/dist/tools/modify/manage-layers.js +2 -1
  75. package/dist/tools/modify/manage-layers.js.map +1 -1
  76. package/dist/tools/modify/manage-linked-images.d.ts.map +1 -1
  77. package/dist/tools/modify/manage-linked-images.js +2 -1
  78. package/dist/tools/modify/manage-linked-images.js.map +1 -1
  79. package/dist/tools/modify/manage-swatches.d.ts.map +1 -1
  80. package/dist/tools/modify/manage-swatches.js +2 -1
  81. package/dist/tools/modify/manage-swatches.js.map +1 -1
  82. package/dist/tools/modify/modify-object.d.ts.map +1 -1
  83. package/dist/tools/modify/modify-object.js +22 -17
  84. package/dist/tools/modify/modify-object.js.map +1 -1
  85. package/dist/tools/modify/move-to-layer.d.ts.map +1 -1
  86. package/dist/tools/modify/move-to-layer.js +2 -1
  87. package/dist/tools/modify/move-to-layer.js.map +1 -1
  88. package/dist/tools/modify/open-document.d.ts.map +1 -1
  89. package/dist/tools/modify/open-document.js +2 -1
  90. package/dist/tools/modify/open-document.js.map +1 -1
  91. package/dist/tools/modify/place-color-chips.d.ts.map +1 -1
  92. package/dist/tools/modify/place-color-chips.js +4 -5
  93. package/dist/tools/modify/place-color-chips.js.map +1 -1
  94. package/dist/tools/modify/place-image.d.ts.map +1 -1
  95. package/dist/tools/modify/place-image.js +22 -8
  96. package/dist/tools/modify/place-image.js.map +1 -1
  97. package/dist/tools/modify/place-style-guide.d.ts.map +1 -1
  98. package/dist/tools/modify/place-style-guide.js +4 -5
  99. package/dist/tools/modify/place-style-guide.js.map +1 -1
  100. package/dist/tools/modify/place-symbol.d.ts.map +1 -1
  101. package/dist/tools/modify/place-symbol.js +2 -1
  102. package/dist/tools/modify/place-symbol.js.map +1 -1
  103. package/dist/tools/modify/replace-color.d.ts.map +1 -1
  104. package/dist/tools/modify/replace-color.js +2 -1
  105. package/dist/tools/modify/replace-color.js.map +1 -1
  106. package/dist/tools/modify/resize-for-variation.d.ts.map +1 -1
  107. package/dist/tools/modify/resize-for-variation.js +4 -5
  108. package/dist/tools/modify/resize-for-variation.js.map +1 -1
  109. package/dist/tools/modify/save-document.d.ts.map +1 -1
  110. package/dist/tools/modify/save-document.js +2 -1
  111. package/dist/tools/modify/save-document.js.map +1 -1
  112. package/dist/tools/modify/select-objects.d.ts.map +1 -1
  113. package/dist/tools/modify/select-objects.js +2 -1
  114. package/dist/tools/modify/select-objects.js.map +1 -1
  115. package/dist/tools/modify/set-z-order.d.ts.map +1 -1
  116. package/dist/tools/modify/set-z-order.js +2 -1
  117. package/dist/tools/modify/set-z-order.js.map +1 -1
  118. package/dist/tools/modify/undo.d.ts.map +1 -1
  119. package/dist/tools/modify/undo.js +2 -1
  120. package/dist/tools/modify/undo.js.map +1 -1
  121. package/dist/tools/modify/ungroup-objects.d.ts.map +1 -1
  122. package/dist/tools/modify/ungroup-objects.js +2 -1
  123. package/dist/tools/modify/ungroup-objects.js.map +1 -1
  124. package/dist/tools/read/check-contrast.d.ts.map +1 -1
  125. package/dist/tools/read/check-contrast.js +14 -27
  126. package/dist/tools/read/check-contrast.js.map +1 -1
  127. package/dist/tools/read/convert-coordinate.d.ts.map +1 -1
  128. package/dist/tools/read/convert-coordinate.js +2 -1
  129. package/dist/tools/read/convert-coordinate.js.map +1 -1
  130. package/dist/tools/read/extract-design-tokens.d.ts.map +1 -1
  131. package/dist/tools/read/extract-design-tokens.js +2 -1
  132. package/dist/tools/read/extract-design-tokens.js.map +1 -1
  133. package/dist/tools/read/find-objects.d.ts.map +1 -1
  134. package/dist/tools/read/find-objects.js +3 -7
  135. package/dist/tools/read/find-objects.js.map +1 -1
  136. package/dist/tools/read/get-artboards.js +1 -1
  137. package/dist/tools/read/get-colors.d.ts.map +1 -1
  138. package/dist/tools/read/get-colors.js +2 -1
  139. package/dist/tools/read/get-colors.js.map +1 -1
  140. package/dist/tools/read/get-document-info.d.ts.map +1 -1
  141. package/dist/tools/read/get-document-info.js +2 -3
  142. package/dist/tools/read/get-document-info.js.map +1 -1
  143. package/dist/tools/read/get-document-structure.d.ts.map +1 -1
  144. package/dist/tools/read/get-document-structure.js +3 -7
  145. package/dist/tools/read/get-document-structure.js.map +1 -1
  146. package/dist/tools/read/get-effects.d.ts.map +1 -1
  147. package/dist/tools/read/get-effects.js +3 -7
  148. package/dist/tools/read/get-effects.js.map +1 -1
  149. package/dist/tools/read/get-groups.d.ts.map +1 -1
  150. package/dist/tools/read/get-groups.js +3 -7
  151. package/dist/tools/read/get-groups.js.map +1 -1
  152. package/dist/tools/read/get-guidelines.d.ts.map +1 -1
  153. package/dist/tools/read/get-guidelines.js +3 -7
  154. package/dist/tools/read/get-guidelines.js.map +1 -1
  155. package/dist/tools/read/get-images.d.ts.map +1 -1
  156. package/dist/tools/read/get-images.js +40 -13
  157. package/dist/tools/read/get-images.js.map +1 -1
  158. package/dist/tools/read/get-layers.js +1 -1
  159. package/dist/tools/read/get-overprint-info.d.ts.map +1 -1
  160. package/dist/tools/read/get-overprint-info.js +2 -3
  161. package/dist/tools/read/get-overprint-info.js.map +1 -1
  162. package/dist/tools/read/get-path-items.d.ts.map +1 -1
  163. package/dist/tools/read/get-path-items.js +11 -9
  164. package/dist/tools/read/get-path-items.js.map +1 -1
  165. package/dist/tools/read/get-separation-info.d.ts.map +1 -1
  166. package/dist/tools/read/get-separation-info.js +2 -3
  167. package/dist/tools/read/get-separation-info.js.map +1 -1
  168. package/dist/tools/read/get-symbols.d.ts.map +1 -1
  169. package/dist/tools/read/get-symbols.js +3 -7
  170. package/dist/tools/read/get-symbols.js.map +1 -1
  171. package/dist/tools/read/get-text-frame-detail.d.ts.map +1 -1
  172. package/dist/tools/read/get-text-frame-detail.js +2 -1
  173. package/dist/tools/read/get-text-frame-detail.js.map +1 -1
  174. package/dist/tools/read/list-fonts.d.ts.map +1 -1
  175. package/dist/tools/read/list-fonts.js +2 -1
  176. package/dist/tools/read/list-fonts.js.map +1 -1
  177. package/dist/tools/read/list-text-frames.d.ts.map +1 -1
  178. package/dist/tools/read/list-text-frames.js +3 -5
  179. package/dist/tools/read/list-text-frames.js.map +1 -1
  180. package/dist/tools/registry.d.ts.map +1 -1
  181. package/dist/tools/registry.js +2 -0
  182. package/dist/tools/registry.js.map +1 -1
  183. package/dist/tools/session.d.ts.map +1 -1
  184. package/dist/tools/session.js +5 -1
  185. package/dist/tools/session.js.map +1 -1
  186. package/dist/tools/utility/check-text-consistency.d.ts.map +1 -1
  187. package/dist/tools/utility/check-text-consistency.js +14 -20
  188. package/dist/tools/utility/check-text-consistency.js.map +1 -1
  189. package/dist/tools/utility/preflight-check.d.ts.map +1 -1
  190. package/dist/tools/utility/preflight-check.js +48 -20
  191. package/dist/tools/utility/preflight-check.js.map +1 -1
  192. package/dist/tools/utility/set-workflow.js +1 -1
  193. package/dist/tools/utility/set-workflow.js.map +1 -1
  194. package/package.json +1 -1
package/dist/bundle.cjs CHANGED
@@ -30279,8 +30279,8 @@ function createTempFiles() {
30279
30279
  async function writeParams(paramsPath, params) {
30280
30280
  await fs.writeFile(paramsPath, JSON.stringify(params ?? {}), "utf-8");
30281
30281
  }
30282
- async function writeJsx(scriptPath, jsxCode60) {
30283
- await fs.writeFile(scriptPath, BOM + jsxCode60, "utf-8");
30282
+ async function writeJsx(scriptPath, jsxCode61) {
30283
+ await fs.writeFile(scriptPath, BOM + jsxCode61, "utf-8");
30284
30284
  }
30285
30285
  async function writeAppleScript(scptPath, scriptPath, options) {
30286
30286
  const escaped = scriptPath.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -30313,11 +30313,17 @@ async function writePowerShellScript(ps1Path, scriptPath, options) {
30313
30313
  " Start-Sleep -Seconds 5",
30314
30314
  " }"
30315
30315
  ] : [];
30316
+ const activateLines = options?.activate ? [
30317
+ " try {",
30318
+ ' $wsh = New-Object -ComObject "WScript.Shell"',
30319
+ ' $wsh.AppActivate("Adobe Illustrator") | Out-Null',
30320
+ " } catch {}"
30321
+ ] : [];
30316
30322
  const lines = [
30317
30323
  "try {",
30318
30324
  ...launchLines,
30319
30325
  ' $ai = New-Object -ComObject "Illustrator.Application" -ErrorAction Stop',
30320
- ...options?.activate ? [" $ai.Visible = $true"] : [],
30326
+ ...activateLines,
30321
30327
  ` $ai.DoJavaScript("$.evalFile(new File('${jsxPathEscaped}'))")`,
30322
30328
  "} catch {",
30323
30329
  ' Write-Error "Illustrator COM automation failed: $_"',
@@ -30446,11 +30452,11 @@ function getExecFailureMessage(error48, stderr, timeout, transport = "osascript"
30446
30452
  if (transport === "powershell") return parsePowerShellError(stderr || error48.message);
30447
30453
  return parseOsascriptError(stderr || error48.message);
30448
30454
  }
30449
- async function executeViaOsascript(jsxCode60, params, timeout, activate) {
30455
+ async function executeViaOsascript(jsxCode61, params, timeout, activate) {
30450
30456
  const files = createTempFiles();
30451
30457
  try {
30452
30458
  await writeParams(files.paramsPath, params);
30453
- const fullJsx = await buildJsx(jsxCode60, files.paramsPath, files.resultPath);
30459
+ const fullJsx = await buildJsx(jsxCode61, files.paramsPath, files.resultPath);
30454
30460
  await writeJsx(files.scriptPath, fullJsx);
30455
30461
  await writeAppleScript(files.runnerPath, files.scriptPath, { activate, appPath: getAppPath() });
30456
30462
  await new Promise((resolve2, reject) => {
@@ -30467,11 +30473,11 @@ async function executeViaOsascript(jsxCode60, params, timeout, activate) {
30467
30473
  await cleanupTempFiles(files);
30468
30474
  }
30469
30475
  }
30470
- async function executeViaPowerShell(jsxCode60, params, timeout, activate) {
30476
+ async function executeViaPowerShell(jsxCode61, params, timeout, activate) {
30471
30477
  const files = createTempFiles();
30472
30478
  try {
30473
30479
  await writeParams(files.paramsPath, params);
30474
- const fullJsx = await buildJsx(jsxCode60, files.paramsPath, files.resultPath);
30480
+ const fullJsx = await buildJsx(jsxCode61, files.paramsPath, files.resultPath);
30475
30481
  await writeJsx(files.scriptPath, fullJsx);
30476
30482
  await writePowerShellScript(files.runnerPath, files.scriptPath, { activate, appPath: getAppPath() });
30477
30483
  await new Promise((resolve2, reject) => {
@@ -30510,24 +30516,24 @@ async function readAndValidateResult(resultPath) {
30510
30516
  }
30511
30517
  return result;
30512
30518
  }
30513
- async function executeJsxRaw(jsxCode60, params, timeout = TIMEOUT_NORMAL, activate = false) {
30519
+ async function executeJsxRaw(jsxCode61, params, timeout = TIMEOUT_NORMAL, activate = false) {
30514
30520
  const transport = getTransport();
30515
30521
  switch (transport) {
30516
30522
  case "osascript":
30517
- return await executeViaOsascript(jsxCode60, params, timeout, activate);
30523
+ return await executeViaOsascript(jsxCode61, params, timeout, activate);
30518
30524
  case "powershell":
30519
- return await executeViaPowerShell(jsxCode60, params, timeout, activate);
30525
+ return await executeViaPowerShell(jsxCode61, params, timeout, activate);
30520
30526
  default: {
30521
30527
  const _ = transport;
30522
30528
  throw new Error(`Unknown transport: ${_}`);
30523
30529
  }
30524
30530
  }
30525
30531
  }
30526
- async function executeJsx(jsxCode60, params, options) {
30532
+ async function executeJsx(jsxCode61, params, options) {
30527
30533
  pendingCount++;
30528
30534
  try {
30529
30535
  return await jsxLimit(() => executeJsxRaw(
30530
- jsxCode60,
30536
+ jsxCode61,
30531
30537
  params,
30532
30538
  options?.timeout ?? TIMEOUT_NORMAL,
30533
30539
  options?.activate ?? false
@@ -30539,8 +30545,8 @@ async function executeJsx(jsxCode60, params, options) {
30539
30545
  }
30540
30546
  }
30541
30547
  }
30542
- async function executeJsxHeavy(jsxCode60, params) {
30543
- return executeJsx(jsxCode60, params, { timeout: TIMEOUT_HEAVY, activate: true });
30548
+ async function executeJsxHeavy(jsxCode61, params) {
30549
+ return executeJsx(jsxCode61, params, { timeout: TIMEOUT_HEAVY, activate: true });
30544
30550
  }
30545
30551
 
30546
30552
  // src/tools/session.ts
@@ -30668,7 +30674,7 @@ async function resolveCoordinateSystem(explicit) {
30668
30674
  }
30669
30675
  }
30670
30676
  var coordinateSystemSchema = external_exports.enum(["artboard-web", "document"]).optional().describe(
30671
- "Coordinate system. Omit to auto-detect from document (CMYK\u2192document, RGB\u2192artboard-web). Override via set_workflow."
30677
+ "Coordinate system. Auto-detected from document by default (CMYK/print \u2192 document, RGB/web \u2192 artboard-web). artboard-web: origin at active artboard top-left, Y-down. document: Illustrator native coords, origin at bottom-left, Y-up. Call get_document_info to check which system is active."
30672
30678
  );
30673
30679
  function detectWorkflow(signals) {
30674
30680
  const { colorMode, rulerUnits, rasterEffectResolution, colorProfile } = signals;
@@ -30736,6 +30742,23 @@ function detectWorkflow(signals) {
30736
30742
  };
30737
30743
  }
30738
30744
 
30745
+ // src/tools/tool-executor.ts
30746
+ function ensureToolParams(params) {
30747
+ if (params && typeof params === "object" && !Array.isArray(params)) {
30748
+ return params;
30749
+ }
30750
+ return {};
30751
+ }
30752
+ function formatToolResult(result) {
30753
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
30754
+ }
30755
+ async function executeToolJsx(jsxCode61, params, options) {
30756
+ const baseParams = ensureToolParams(params);
30757
+ const resolvedParams = options?.resolveCoordinate ? { ...baseParams, coordinate_system: await resolveCoordinateSystem(baseParams.coordinate_system) } : baseParams;
30758
+ const result = options?.heavy ? await executeJsxHeavy(jsxCode61, resolvedParams) : await executeJsx(jsxCode61, resolvedParams, { activate: options?.activate ?? false });
30759
+ return formatToolResult(result);
30760
+ }
30761
+
30739
30762
  // src/tools/modify/shared.ts
30740
30763
  var coerceBoolean = external_exports.preprocess(
30741
30764
  (val) => {
@@ -31017,30 +31040,11 @@ function register(server) {
31017
31040
  });
31018
31041
  result.workflowHint = hint;
31019
31042
  }
31020
- return {
31021
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
31022
- };
31043
+ return formatToolResult(result);
31023
31044
  }
31024
31045
  );
31025
31046
  }
31026
31047
 
31027
- // src/tools/tool-executor.ts
31028
- function ensureToolParams(params) {
31029
- if (params && typeof params === "object" && !Array.isArray(params)) {
31030
- return params;
31031
- }
31032
- return {};
31033
- }
31034
- function formatToolResult(result) {
31035
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
31036
- }
31037
- async function executeToolJsx(jsxCode60, params, options) {
31038
- const baseParams = ensureToolParams(params);
31039
- const resolvedParams = options?.resolveCoordinate ? { ...baseParams, coordinate_system: await resolveCoordinateSystem(baseParams.coordinate_system) } : baseParams;
31040
- const result = options?.heavy ? await executeJsxHeavy(jsxCode60, resolvedParams) : await executeJsx(jsxCode60, resolvedParams, { activate: options?.activate ?? false });
31041
- return formatToolResult(result);
31042
- }
31043
-
31044
31048
  // src/tools/read/get-artboards.ts
31045
31049
  var jsxCode2 = `
31046
31050
  var preflight = preflightChecks();
@@ -31097,7 +31101,7 @@ if (preflight) {
31097
31101
  artboards.push(info);
31098
31102
  }
31099
31103
 
31100
- writeResultFile(RESULT_PATH, { artboards: artboards });
31104
+ writeResultFile(RESULT_PATH, { coordinateSystem: coordSystem, artboards: artboards });
31101
31105
  } // end if (!hasError)
31102
31106
  } catch (e) {
31103
31107
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to get artboard info: " + e.message, line: e.line });
@@ -31192,7 +31196,7 @@ if (preflight) {
31192
31196
  layers.push(traverseLayer(doc.layers[i]));
31193
31197
  }
31194
31198
 
31195
- writeResultFile(RESULT_PATH, { layers: layers });
31199
+ writeResultFile(RESULT_PATH, { coordinateSystem: coordSystem, layers: layers });
31196
31200
  } catch (e) {
31197
31201
  writeResultFile(RESULT_PATH, { error: true, message: "get_layers: " + e.message, line: e.line });
31198
31202
  }
@@ -31603,9 +31607,7 @@ function register5(server) {
31603
31607
  annotations: READ_ANNOTATIONS
31604
31608
  },
31605
31609
  async (params) => {
31606
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
31607
- const result = await executeJsx(jsxCode5, resolvedParams);
31608
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
31610
+ return executeToolJsx(jsxCode5, params, { resolveCoordinate: true });
31609
31611
  }
31610
31612
  );
31611
31613
  }
@@ -31834,7 +31836,7 @@ function register6(server) {
31834
31836
  const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
31835
31837
  const result = await executeJsx(jsxCode6, resolvedParams);
31836
31838
  if (result.error) {
31837
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
31839
+ return formatToolResult(result);
31838
31840
  }
31839
31841
  const runs = result.characterRuns ?? [];
31840
31842
  const kerningPairs = result.kerningPairs ?? [];
@@ -32216,7 +32218,7 @@ function register7(server) {
32216
32218
  },
32217
32219
  async (params) => {
32218
32220
  const result = await executeJsx(jsxCode7, params);
32219
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
32221
+ return formatToolResult(result);
32220
32222
  }
32221
32223
  );
32222
32224
  }
@@ -32328,14 +32330,20 @@ if (preflight) {
32328
32330
  try { info.closed = item.closed; } catch (e) {}
32329
32331
  try { info.opacity = item.opacity; } catch (e) {}
32330
32332
 
32331
- // Extract rotation from transformation matrix
32333
+ // Extract rotation from transformation matrix, fallback to note metadata
32332
32334
  try {
32333
32335
  var m = item.matrix;
32334
- if (m) {
32336
+ if (m && typeof m.mValueA === "number") {
32335
32337
  var rad = Math.atan2(m.mValueB, m.mValueA);
32336
32338
  info.transform.rotation = Math.round(rad * 180 / Math.PI * 100) / 100;
32337
32339
  }
32338
32340
  } catch (e) {}
32341
+ if (info.transform.rotation === null) {
32342
+ try {
32343
+ var notRot = getNoteMeta(item.note, "rot");
32344
+ if (notRot) info.transform.rotation = parseFloat(notRot);
32345
+ } catch (e) {}
32346
+ }
32339
32347
 
32340
32348
  // fill
32341
32349
  // Note: ExtendScript does not expose per-fill opacity on pathItems.
@@ -32455,11 +32463,7 @@ function register8(server) {
32455
32463
  annotations: READ_ANNOTATIONS
32456
32464
  },
32457
32465
  async (params) => {
32458
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
32459
- const result = await executeJsx(jsxCode8, resolvedParams);
32460
- return {
32461
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
32462
- };
32466
+ return executeToolJsx(jsxCode8, params, { resolveCoordinate: true });
32463
32467
  }
32464
32468
  );
32465
32469
  }
@@ -32550,11 +32554,7 @@ function register9(server) {
32550
32554
  annotations: READ_ANNOTATIONS
32551
32555
  },
32552
32556
  async (params) => {
32553
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
32554
- const result = await executeJsx(jsxCode9, resolvedParams);
32555
- return {
32556
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
32557
- };
32557
+ return executeToolJsx(jsxCode9, params, { resolveCoordinate: true });
32558
32558
  }
32559
32559
  );
32560
32560
  }
@@ -32716,11 +32716,7 @@ function register10(server) {
32716
32716
  annotations: READ_ANNOTATIONS
32717
32717
  },
32718
32718
  async (params) => {
32719
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
32720
- const result = await executeJsx(jsxCode10, resolvedParams);
32721
- return {
32722
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
32723
- };
32719
+ return executeToolJsx(jsxCode10, params, { resolveCoordinate: true });
32724
32720
  }
32725
32721
  );
32726
32722
  }
@@ -32887,11 +32883,7 @@ function register11(server) {
32887
32883
  annotations: READ_ANNOTATIONS
32888
32884
  },
32889
32885
  async (params) => {
32890
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
32891
- const result = await executeJsx(jsxCode11, resolvedParams);
32892
- return {
32893
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
32894
- };
32886
+ return executeToolJsx(jsxCode11, params, { resolveCoordinate: true });
32895
32887
  }
32896
32888
  );
32897
32889
  }
@@ -33154,7 +33146,19 @@ if (preflight) {
33154
33146
 
33155
33147
  try { info.name = item.name || ""; } catch(e) {}
33156
33148
 
33157
- // Store placed dimensions in points for Node.js-side DPI calculation
33149
+ // Store matrix scale factors for Node.js-side DPI calculation
33150
+ // Using matrix vector magnitude instead of geometricBounds to handle rotation correctly
33151
+ // (geometricBounds returns AABB which is larger when rotated, giving incorrect PPI)
33152
+ try {
33153
+ var pm = item.matrix;
33154
+ if (pm) {
33155
+ var psX = Math.sqrt(pm.mValueA * pm.mValueA + pm.mValueB * pm.mValueB);
33156
+ var psY = Math.sqrt(pm.mValueC * pm.mValueC + pm.mValueD * pm.mValueD);
33157
+ info.matrixScaleX = psX;
33158
+ info.matrixScaleY = psY;
33159
+ }
33160
+ } catch(e) {}
33161
+ // Fallback: also store geometricBounds dimensions
33158
33162
  try {
33159
33163
  var pBounds = item.geometricBounds;
33160
33164
  var pWidthPt = pBounds[2] - pBounds[0];
@@ -33286,16 +33290,27 @@ function register12(server) {
33286
33290
  if (img.type === "linked" && img.filePath && !img.linkBroken) {
33287
33291
  try {
33288
33292
  const dims = readImageDimensions(img.filePath);
33289
- if (dims && img.widthPt && img.heightPt) {
33293
+ if (dims) {
33290
33294
  img.pixelWidth = dims.width;
33291
33295
  img.pixelHeight = dims.height;
33292
- const widthInches = img.widthPt / 72;
33293
- const heightInches = img.heightPt / 72;
33294
- const ppiH = Math.round(dims.width / widthInches);
33295
- const ppiV = Math.round(dims.height / heightInches);
33296
- img.resolution = Math.min(ppiH, ppiV);
33297
- if (resolvedParams.include_print_info) {
33298
- img.scaleFactor = Math.round(img.widthPt / dims.width * 100);
33296
+ const matrixScaleX = img.matrixScaleX;
33297
+ const matrixScaleY = img.matrixScaleY;
33298
+ if (matrixScaleX && matrixScaleY && matrixScaleX > 0 && matrixScaleY > 0) {
33299
+ const ppiH = Math.round(72 / matrixScaleX);
33300
+ const ppiV = Math.round(72 / matrixScaleY);
33301
+ img.resolution = Math.min(ppiH, ppiV);
33302
+ if (resolvedParams.include_print_info) {
33303
+ img.scaleFactor = Math.round(matrixScaleX * 100);
33304
+ }
33305
+ } else if (img.widthPt && img.heightPt) {
33306
+ const widthInches = img.widthPt / 72;
33307
+ const heightInches = img.heightPt / 72;
33308
+ const ppiH = Math.round(dims.width / widthInches);
33309
+ const ppiV = Math.round(dims.height / heightInches);
33310
+ img.resolution = Math.min(ppiH, ppiV);
33311
+ if (resolvedParams.include_print_info) {
33312
+ img.scaleFactor = Math.round(img.widthPt / dims.width * 100);
33313
+ }
33299
33314
  }
33300
33315
  }
33301
33316
  } catch {
@@ -33303,11 +33318,11 @@ function register12(server) {
33303
33318
  }
33304
33319
  delete img.widthPt;
33305
33320
  delete img.heightPt;
33321
+ delete img.matrixScaleX;
33322
+ delete img.matrixScaleY;
33306
33323
  }
33307
33324
  }
33308
- return {
33309
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
33310
- };
33325
+ return formatToolResult(result);
33311
33326
  }
33312
33327
  );
33313
33328
  }
@@ -33397,11 +33412,7 @@ function register13(server) {
33397
33412
  annotations: READ_ANNOTATIONS
33398
33413
  },
33399
33414
  async (params) => {
33400
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
33401
- const result = await executeJsx(jsxCode13, resolvedParams);
33402
- return {
33403
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
33404
- };
33415
+ return executeToolJsx(jsxCode13, params, { resolveCoordinate: true });
33405
33416
  }
33406
33417
  );
33407
33418
  }
@@ -33503,11 +33514,7 @@ function register14(server) {
33503
33514
  annotations: READ_ANNOTATIONS
33504
33515
  },
33505
33516
  async (params) => {
33506
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
33507
- const result = await executeJsx(jsxCode14, resolvedParams);
33508
- return {
33509
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
33510
- };
33517
+ return executeToolJsx(jsxCode14, params, { resolveCoordinate: true });
33511
33518
  }
33512
33519
  );
33513
33520
  }
@@ -33693,11 +33700,7 @@ function register15(server) {
33693
33700
  annotations: READ_ANNOTATIONS
33694
33701
  },
33695
33702
  async (params) => {
33696
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
33697
- const result = await executeJsx(jsxCode15, resolvedParams);
33698
- return {
33699
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
33700
- };
33703
+ return executeToolJsx(jsxCode15, params, { resolveCoordinate: true });
33701
33704
  }
33702
33705
  );
33703
33706
  }
@@ -33841,34 +33844,23 @@ function register16(server) {
33841
33844
  const rgb1 = colorToRGB(params.color1);
33842
33845
  const rgb2 = colorToRGB(params.color2);
33843
33846
  if (!rgb1 || !rgb2) {
33844
- return { content: [{ type: "text", text: JSON.stringify({ error: true, message: "Could not convert colors to RGB" }) }] };
33847
+ return formatToolResult({ error: true, message: "Could not convert colors to RGB" });
33845
33848
  }
33846
33849
  const l1 = relativeLuminance(rgb1.r, rgb1.g, rgb1.b);
33847
33850
  const l2 = relativeLuminance(rgb2.r, rgb2.g, rgb2.b);
33848
33851
  const ratio = Math.round(contrastRatio(l1, l2) * 100) / 100;
33849
- return {
33850
- content: [
33851
- {
33852
- type: "text",
33853
- text: JSON.stringify(
33854
- {
33855
- contrastRatio: ratio,
33856
- wcagAA_normal: ratio >= 4.5,
33857
- wcagAA_large: ratio >= 3,
33858
- wcagAAA: ratio >= 7,
33859
- color1_rgb: rgb1,
33860
- color2_rgb: rgb2
33861
- },
33862
- null,
33863
- 2
33864
- )
33865
- }
33866
- ]
33867
- };
33852
+ return formatToolResult({
33853
+ contrastRatio: ratio,
33854
+ wcagAA_normal: ratio >= 4.5,
33855
+ wcagAA_large: ratio >= 3,
33856
+ wcagAAA: ratio >= 7,
33857
+ color1_rgb: rgb1,
33858
+ color2_rgb: rgb2
33859
+ });
33868
33860
  }
33869
33861
  const result = await executeJsx(jsxCode16, params);
33870
33862
  if (result.error) {
33871
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
33863
+ return formatToolResult(result);
33872
33864
  }
33873
33865
  const items = result.colorItems;
33874
33866
  const pairs = [];
@@ -33907,14 +33899,7 @@ function register16(server) {
33907
33899
  return true;
33908
33900
  });
33909
33901
  unique.sort((a, b) => a.contrastRatio - b.contrastRatio);
33910
- return {
33911
- content: [
33912
- {
33913
- type: "text",
33914
- text: JSON.stringify({ pairCount: unique.length, pairs: unique }, null, 2)
33915
- }
33916
- ]
33917
- };
33902
+ return formatToolResult({ pairCount: unique.length, pairs: unique });
33918
33903
  }
33919
33904
  );
33920
33905
  }
@@ -34092,7 +34077,7 @@ function register17(server) {
34092
34077
  async (params) => {
34093
34078
  const result = await executeJsx(jsxCode17, params);
34094
34079
  if (result.error) {
34095
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
34080
+ return formatToolResult(result);
34096
34081
  }
34097
34082
  const colorCounts = /* @__PURE__ */ new Map();
34098
34083
  for (const c of [...result.fillColors, ...result.strokeColors]) {
@@ -34163,6 +34148,8 @@ Saved to: ${params.output_path}` }]
34163
34148
  }
34164
34149
 
34165
34150
  // src/tools/export/export.ts
34151
+ var import_node_fs = require("node:fs");
34152
+ var import_node_path = require("node:path");
34166
34153
  var jsxCode18 = `
34167
34154
  var preflight = preflightChecks();
34168
34155
  if (preflight) {
@@ -34441,7 +34428,7 @@ function register18(server) {
34441
34428
  "export",
34442
34429
  {
34443
34430
  title: "Export",
34444
- description: "Export objects, groups, artboards, or selection. Note: Illustrator will be activated (brought to foreground) during execution.",
34431
+ description: "Export objects, groups, artboards, or selection. For PNG/JPG, the exported image is returned as base64 in the response \u2014 you can view it directly without reading the file from disk. Note: Illustrator will be activated (brought to foreground) during execution.",
34445
34432
  inputSchema: {
34446
34433
  target: external_exports.string().describe('UUID, "artboard:<index>", or "selection". When exporting a UUID target as PNG/JPG, a temporary document is created internally (selection state may change).'),
34447
34434
  // WebP is not supported by ExtendScript API
@@ -34465,8 +34452,43 @@ function register18(server) {
34465
34452
  annotations: WRITE_IDEMPOTENT_ANNOTATIONS
34466
34453
  },
34467
34454
  async (params) => {
34468
- const result = await executeJsxHeavy(jsxCode18, params);
34469
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
34455
+ const resolvedParams = { ...params };
34456
+ if (resolvedParams.output_path) {
34457
+ const dir = (0, import_node_path.dirname)(resolvedParams.output_path);
34458
+ if ((0, import_node_fs.existsSync)(dir)) {
34459
+ try {
34460
+ const realDir = (0, import_node_fs.realpathSync)(dir);
34461
+ resolvedParams.output_path = (0, import_node_path.join)(realDir, (0, import_node_path.basename)(resolvedParams.output_path));
34462
+ } catch (_) {
34463
+ }
34464
+ }
34465
+ }
34466
+ const result = await executeJsxHeavy(jsxCode18, resolvedParams);
34467
+ const textResult = formatToolResult(result);
34468
+ if (result && typeof result === "object" && result.success && result.output_path && (params.format === "png" || params.format === "jpg")) {
34469
+ const outputPath = result.output_path;
34470
+ try {
34471
+ if ((0, import_node_fs.existsSync)(outputPath)) {
34472
+ const imageData = (0, import_node_fs.readFileSync)(outputPath).toString("base64");
34473
+ const mimeType = params.format === "png" ? "image/png" : "image/jpeg";
34474
+ const visualCheckNote = {
34475
+ type: "text",
34476
+ text: JSON.stringify({
34477
+ visual_check_hint: "Now review the exported image visually \u2014 not just numerically. Text alignment can look off even when coordinates are mathematically correct, because bounding boxes include invisible padding. If text appears misaligned, adjust by visual impression rather than exact numbers."
34478
+ })
34479
+ };
34480
+ return {
34481
+ content: [
34482
+ ...textResult.content,
34483
+ visualCheckNote,
34484
+ { type: "image", data: imageData, mimeType }
34485
+ ]
34486
+ };
34487
+ }
34488
+ } catch {
34489
+ }
34490
+ }
34491
+ return textResult;
34470
34492
  }
34471
34493
  );
34472
34494
  }
@@ -34768,7 +34790,7 @@ function register19(server) {
34768
34790
  ...result,
34769
34791
  _note: "PDF exported. This file should be verified by a human before final print submission \u2014 automated checks cannot catch all print-critical issues."
34770
34792
  };
34771
- return { content: [{ type: "text", text: JSON.stringify(output, null, 2) }] };
34793
+ return formatToolResult(output);
34772
34794
  }
34773
34795
  );
34774
34796
  }
@@ -34883,9 +34905,7 @@ function register20(server) {
34883
34905
  },
34884
34906
  async (params) => {
34885
34907
  const result = await executeJsx(jsxCode20, params);
34886
- return {
34887
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
34888
- };
34908
+ return formatToolResult(result);
34889
34909
  }
34890
34910
  );
34891
34911
  }
@@ -34975,9 +34995,7 @@ function register21(server) {
34975
34995
  },
34976
34996
  async (params) => {
34977
34997
  const result = await executeJsx(jsxCode21, params);
34978
- return {
34979
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
34980
- };
34998
+ return formatToolResult(result);
34981
34999
  }
34982
35000
  );
34983
35001
  }
@@ -35014,8 +35032,8 @@ if (preflight) {
35014
35032
  } else if (color.typename === "RGBColor") {
35015
35033
  if (color.red === 255 && color.green === 255 && color.blue === 255) return true;
35016
35034
  } else if (color.typename === "GrayColor") {
35017
- // GrayColor.gray \u306F\u30A4\u30F3\u30AF\u91CF: 0=\u767D(\u30A4\u30F3\u30AF\u306A\u3057), 100=\u9ED2(\u30D5\u30EB\u30A4\u30F3\u30AF)
35018
- // E2E\u30C6\u30B9\u30C8\u3067\u78BA\u8A8D\u6E08\u307F\u3002\u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u306E "0=black, 100=white" \u8A18\u8F09\u306F\u8AA4\u308A\u3002
35035
+ // GrayColor.gray: 0=\u767D(\u30A4\u30F3\u30AF\u306A\u3057), 100=\u9ED2(\u30D5\u30EB\u30A4\u30F3\u30AF)
35036
+ // Adobe\u516C\u5F0F\u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u306E\u300C0=black, 100=white\u300D\u8A18\u8F09\u306F\u8AA4\u308A (Illustrator 2026 \u5B9F\u6A5F\u691C\u8A3C\u6E08\u307F)
35019
35037
  if (color.gray === 0) return true;
35020
35038
  }
35021
35039
  } catch(e) {}
@@ -35134,18 +35152,32 @@ if (preflight) {
35134
35152
  var pFile = pItem.file;
35135
35153
  if (pFile && pFile.exists) {
35136
35154
  var pUuid = ensureUUID(pItem);
35155
+ var pData = {
35156
+ uuid: pUuid,
35157
+ name: pItem.name || "",
35158
+ filePath: pFile.fsName,
35159
+ widthPt: 0,
35160
+ heightPt: 0,
35161
+ matrixScaleX: 0,
35162
+ matrixScaleY: 0
35163
+ };
35164
+ // Get matrix scale factors for rotation-safe PPI calculation
35165
+ try {
35166
+ var plm = pItem.matrix;
35167
+ if (plm) {
35168
+ pData.matrixScaleX = Math.sqrt(plm.mValueA * plm.mValueA + plm.mValueB * plm.mValueB);
35169
+ pData.matrixScaleY = Math.sqrt(plm.mValueC * plm.mValueC + plm.mValueD * plm.mValueD);
35170
+ }
35171
+ } catch(e2) {}
35172
+ // Fallback: geometricBounds
35137
35173
  var pBounds = pItem.geometricBounds;
35138
35174
  var pWPt = pBounds[2] - pBounds[0];
35139
35175
  var pHPt = -(pBounds[3] - pBounds[1]);
35140
35176
  if (pWPt < 0) pWPt = -pWPt;
35141
35177
  if (pHPt < 0) pHPt = -pHPt;
35142
- placedImageData.push({
35143
- uuid: pUuid,
35144
- name: pItem.name || "",
35145
- filePath: pFile.fsName,
35146
- widthPt: pWPt,
35147
- heightPt: pHPt
35148
- });
35178
+ pData.widthPt = pWPt;
35179
+ pData.heightPt = pHPt;
35180
+ placedImageData.push(pData);
35149
35181
  }
35150
35182
  } catch(e) {}
35151
35183
  }
@@ -35366,15 +35398,24 @@ function register22(server) {
35366
35398
  const minDpi = result?.minDPI ?? params.min_dpi ?? 300;
35367
35399
  if (result?.placedImageData) {
35368
35400
  for (const placed of result.placedImageData) {
35369
- if (!placed.filePath || placed.widthPt <= 0 || placed.heightPt <= 0) continue;
35401
+ if (!placed.filePath) continue;
35370
35402
  try {
35371
35403
  const dims = readImageDimensions(placed.filePath);
35372
35404
  if (dims) {
35373
- const widthInches = placed.widthPt / 72;
35374
- const heightInches = placed.heightPt / 72;
35375
- const ppiH = Math.round(dims.width / widthInches);
35376
- const ppiV = Math.round(dims.height / heightInches);
35377
- const effectivePPI = Math.min(ppiH, ppiV);
35405
+ let effectivePPI;
35406
+ if (placed.matrixScaleX > 0 && placed.matrixScaleY > 0) {
35407
+ const ppiH = Math.round(72 / placed.matrixScaleX);
35408
+ const ppiV = Math.round(72 / placed.matrixScaleY);
35409
+ effectivePPI = Math.min(ppiH, ppiV);
35410
+ } else if (placed.widthPt > 0 && placed.heightPt > 0) {
35411
+ const widthInches = placed.widthPt / 72;
35412
+ const heightInches = placed.heightPt / 72;
35413
+ const ppiH = Math.round(dims.width / widthInches);
35414
+ const ppiV = Math.round(dims.height / heightInches);
35415
+ effectivePPI = Math.min(ppiH, ppiV);
35416
+ } else {
35417
+ continue;
35418
+ }
35378
35419
  if (effectivePPI < minDpi) {
35379
35420
  result.results.push({
35380
35421
  level: "error",
@@ -35458,9 +35499,7 @@ function register22(server) {
35458
35499
  if (!hasIssues) {
35459
35500
  result._note = "No issues detected by these automated checks. This does not mean the document is free of problems \u2014 items outside the scope of automated checks (design intent, contextual spelling, regulatory requirements, print-shop-specific rules) still require human review.";
35460
35501
  }
35461
- return {
35462
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
35463
- };
35502
+ return formatToolResult(result);
35464
35503
  }
35465
35504
  );
35466
35505
  }
@@ -35713,32 +35752,21 @@ function register23(server) {
35713
35752
  const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
35714
35753
  const result = await executeJsx(jsxCode23, resolvedParams);
35715
35754
  if (result.error) {
35716
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
35755
+ return formatToolResult(result);
35717
35756
  }
35718
35757
  const analysis = analyzeTextConsistency(result.frames);
35719
- return {
35720
- content: [
35721
- {
35722
- type: "text",
35723
- text: JSON.stringify(
35724
- {
35725
- totalFrames: result.totalFrames,
35726
- mechanicalChecks: {
35727
- _reliability: "deterministic",
35728
- dummyTexts: analysis.dummyTexts,
35729
- knownVariations: analysis.knownVariations
35730
- },
35731
- llmAnalysis: {
35732
- _reliability: "ai-assisted \u2014 may miss errors or produce false positives. Clearly distinguish AI-based findings from mechanical checks when reporting to the user.",
35733
- allTexts: analysis.allTexts
35734
- }
35735
- },
35736
- null,
35737
- 2
35738
- )
35739
- }
35740
- ]
35741
- };
35758
+ return formatToolResult({
35759
+ totalFrames: result.totalFrames,
35760
+ mechanicalChecks: {
35761
+ _reliability: "deterministic",
35762
+ dummyTexts: analysis.dummyTexts,
35763
+ knownVariations: analysis.knownVariations
35764
+ },
35765
+ llmAnalysis: {
35766
+ _reliability: "ai-assisted \u2014 may miss errors or produce false positives. Clearly distinguish AI-based findings from mechanical checks when reporting to the user.",
35767
+ allTexts: analysis.allTexts
35768
+ }
35769
+ });
35742
35770
  }
35743
35771
  );
35744
35772
  }
@@ -35754,7 +35782,7 @@ function register24(server) {
35754
35782
  "set_workflow",
35755
35783
  {
35756
35784
  title: "Set Workflow",
35757
- description: "Set the session-level workflow and default coordinate system. Call this after confirming the user's intent (web, print, or video). Once set, all tools that omit coordinate_system will use the session default. Use clear: true to reset to the default behavior (artboard-web).",
35785
+ description: "Set the session-level workflow and default coordinate system. Call this after confirming the user's intent (web, print, or video). Once set, all tools that omit coordinate_system will use the session default. Use clear: true to reset to auto-detection from document (CMYK/print \u2192 document coords, RGB/web \u2192 artboard-web).",
35758
35786
  inputSchema: {
35759
35787
  workflow: external_exports.enum(["web", "print", "video"]).optional().describe("The workflow type. Determines the default coordinate system."),
35760
35788
  coordinate_system: external_exports.enum(["artboard-web", "document"]).optional().describe(
@@ -35914,7 +35942,7 @@ if (preflight) {
35914
35942
  }
35915
35943
 
35916
35944
  var uuid = ensureUUID(rect);
35917
- writeResultFile(RESULT_PATH, { uuid: uuid, verified: verifyItem(rect, coordSystem, abRect) });
35945
+ writeResultFile(RESULT_PATH, { uuid: uuid, coordinateSystem: coordSystem, verified: verifyItem(rect, coordSystem, abRect) });
35918
35946
  } catch (e) {
35919
35947
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to create rectangle: " + e.message, line: e.line });
35920
35948
  }
@@ -35980,7 +36008,7 @@ if (preflight) {
35980
36008
  }
35981
36009
 
35982
36010
  var uuid = ensureUUID(ellipse);
35983
- writeResultFile(RESULT_PATH, { uuid: uuid, verified: verifyItem(ellipse, coordSystem, abRect) });
36011
+ writeResultFile(RESULT_PATH, { uuid: uuid, coordinateSystem: coordSystem, verified: verifyItem(ellipse, coordSystem, abRect) });
35984
36012
  } catch (e) {
35985
36013
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to create ellipse: " + e.message, line: e.line });
35986
36014
  }
@@ -36059,7 +36087,7 @@ if (preflight) {
36059
36087
  }
36060
36088
 
36061
36089
  var uuid = ensureUUID(line);
36062
- writeResultFile(RESULT_PATH, { uuid: uuid, verified: verifyItem(line, coordSystem, abRect) });
36090
+ writeResultFile(RESULT_PATH, { uuid: uuid, coordinateSystem: coordSystem, verified: verifyItem(line, coordSystem, abRect) });
36063
36091
  } catch (e) {
36064
36092
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to create line: " + e.message, line: e.line });
36065
36093
  }
@@ -36167,7 +36195,7 @@ if (preflight) {
36167
36195
  }
36168
36196
 
36169
36197
  var uuid = ensureUUID(tf);
36170
- var resultData = { uuid: uuid, verified: verifyItem(tf, coordSystem, abRect) };
36198
+ var resultData = { uuid: uuid, coordinateSystem: coordSystem, verified: verifyItem(tf, coordSystem, abRect) };
36171
36199
  if (fontCandidates !== null) {
36172
36200
  resultData.font_warning = "Font '" + params.font_name + "' not found. Text frame created with default font.";
36173
36201
  resultData.font_candidates = fontCandidates;
@@ -36201,9 +36229,7 @@ function register29(server) {
36201
36229
  annotations: WRITE_ANNOTATIONS
36202
36230
  },
36203
36231
  async (params) => {
36204
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
36205
- const result = await executeJsx(jsxCode27, resolvedParams, { activate: true });
36206
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
36232
+ return executeToolJsx(jsxCode27, params, { activate: true, resolveCoordinate: true });
36207
36233
  }
36208
36234
  );
36209
36235
  }
@@ -36271,7 +36297,7 @@ if (preflight) {
36271
36297
  }
36272
36298
 
36273
36299
  var uuid = ensureUUID(path);
36274
- writeResultFile(RESULT_PATH, { uuid: uuid, verified: verifyItem(path, coordSystem, abRect) });
36300
+ writeResultFile(RESULT_PATH, { uuid: uuid, coordinateSystem: coordSystem, verified: verifyItem(path, coordSystem, abRect) });
36275
36301
  } catch (e) {
36276
36302
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to create path: " + e.message, line: e.line });
36277
36303
  }
@@ -36332,10 +36358,10 @@ if (preflight) {
36332
36358
  } else {
36333
36359
  var props = params.properties;
36334
36360
  var errors = [];
36361
+ var abRect = (coordSystem === "artboard-web") ? getActiveArtboardRect() : null;
36335
36362
 
36336
36363
  if (props.position) {
36337
36364
  try {
36338
- var abRect = (coordSystem === "artboard-web") ? getActiveArtboardRect() : null;
36339
36365
  var pos = webToAiPoint(props.position.x, props.position.y, coordSystem, abRect);
36340
36366
  item.position = pos;
36341
36367
  } catch(e) { errors.push("position: " + e.message); }
@@ -36371,18 +36397,25 @@ if (preflight) {
36371
36397
 
36372
36398
  if (typeof props.rotation === "number") {
36373
36399
  try {
36374
- if (props.rotation_mode === "absolute") {
36375
- // \u73FE\u5728\u306E\u56DE\u8EE2\u89D2\u3092 Matrix \u304B\u3089\u7B97\u51FA\u3057\u3001\u5DEE\u5206\u3092 rotate() \u306B\u6E21\u3059
36376
- var m = item.matrix;
36377
- var currentRad = Math.atan2(m.mValueB, m.mValueA);
36378
- var currentDeg = currentRad * 180 / Math.PI;
36400
+ var rotMode = props.rotation_mode || "delta";
36401
+ if (rotMode === "absolute") {
36402
+ // note \u30E1\u30BF\u30C7\u30FC\u30BF\u304B\u3089\u73FE\u5728\u306E\u7D2F\u7A4D\u56DE\u8EE2\u89D2\u5EA6\u3092\u8AAD\u307F\u53D6\u308A\u3001\u5DEE\u5206\u3092\u9069\u7528
36403
+ var noteStr = item.note || "";
36404
+ var currentDeg = parseFloat(getNoteMeta(noteStr, "rot")) || 0;
36379
36405
  var delta = props.rotation - currentDeg;
36380
- item.rotate(delta);
36406
+ if (Math.abs(delta) > 0.001) {
36407
+ item.rotate(delta);
36408
+ }
36409
+ setNoteMeta(item, "rot", String(Math.round(props.rotation * 1000) / 1000));
36381
36410
  } else {
36382
36411
  item.rotate(props.rotation);
36412
+ // delta \u56DE\u8EE2\u6642\u3082\u7D2F\u7A4D\u89D2\u5EA6\u3092\u66F4\u65B0
36413
+ var noteStr2 = item.note || "";
36414
+ var prevDeg = parseFloat(getNoteMeta(noteStr2, "rot")) || 0;
36415
+ setNoteMeta(item, "rot", String(Math.round((prevDeg + props.rotation) * 1000) / 1000));
36383
36416
  }
36384
36417
  }
36385
- catch(e) { errors.push("rotation: " + e.message); }
36418
+ catch(e) { errors.push("rotation: " + e.message + " (line: " + (e.line || "?") + ")"); }
36386
36419
  }
36387
36420
 
36388
36421
  if (typeof props.name === "string") {
@@ -36418,11 +36451,11 @@ if (preflight) {
36418
36451
 
36419
36452
  var verifiedState = verifyItem(item, coordSystem, abRect);
36420
36453
  if (errors.length > 0) {
36421
- var result = { success: false, uuid: params.uuid, errors: errors, verified: verifiedState };
36454
+ var result = { success: false, uuid: params.uuid, coordinateSystem: coordSystem, errors: errors, verified: verifiedState };
36422
36455
  if (fontCandidates !== null) { result.font_candidates = fontCandidates; }
36423
36456
  writeResultFile(RESULT_PATH, result);
36424
36457
  } else {
36425
- writeResultFile(RESULT_PATH, { success: true, uuid: params.uuid, verified: verifiedState });
36458
+ writeResultFile(RESULT_PATH, { success: true, uuid: params.uuid, coordinateSystem: coordSystem, verified: verifiedState });
36426
36459
  }
36427
36460
  }
36428
36461
  } catch (e) {
@@ -36462,9 +36495,7 @@ function register31(server) {
36462
36495
  annotations: DESTRUCTIVE_ANNOTATIONS
36463
36496
  },
36464
36497
  async (params) => {
36465
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
36466
- const result = await executeJsx(jsxCode29, resolvedParams, { activate: true });
36467
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
36498
+ return executeToolJsx(jsxCode29, params, { activate: true, resolveCoordinate: true });
36468
36499
  }
36469
36500
  );
36470
36501
  }
@@ -36540,7 +36571,7 @@ function register32(server) {
36540
36571
  },
36541
36572
  async (params) => {
36542
36573
  const result = await executeJsx(jsxCode30, params, { activate: true });
36543
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
36574
+ return formatToolResult(result);
36544
36575
  }
36545
36576
  );
36546
36577
  }
@@ -36606,7 +36637,7 @@ function register33(server) {
36606
36637
  },
36607
36638
  async (params) => {
36608
36639
  const result = await executeJsx(jsxCode31, params, { activate: true });
36609
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
36640
+ return formatToolResult(result);
36610
36641
  }
36611
36642
  );
36612
36643
  }
@@ -36626,11 +36657,26 @@ if (preflight) {
36626
36657
  var imgFile = new File(filePath);
36627
36658
  if (!imgFile.exists) {
36628
36659
  writeResultFile(RESULT_PATH, { error: true, message: "Image file not found: " + filePath });
36660
+ } else if (/\\.svgz?$/i.test(filePath)) {
36661
+ writeResultFile(RESULT_PATH, {
36662
+ error: true,
36663
+ message: "place_image does not support SVG files. SVG placed via PlacedItems becomes a non-editable linked artwork and often leaves broken link items in the document. Use import_svg_as_editable to bring SVG content in as editable Illustrator paths/text."
36664
+ });
36629
36665
  } else {
36630
36666
  var targetLayer = resolveTargetLayer(doc, params.layer_name);
36631
36667
 
36632
36668
  var placed = targetLayer.placedItems.add();
36633
- placed.file = imgFile;
36669
+ try {
36670
+ placed.file = imgFile;
36671
+ } catch (linkErr) {
36672
+ // Setting .file failed \u2014 remove the orphaned PlacedItem so no broken link remains
36673
+ try { placed.remove(); } catch (rmErr) {}
36674
+ writeResultFile(RESULT_PATH, {
36675
+ error: true,
36676
+ message: "Failed to link image file (likely unsupported or corrupt): " + linkErr.message + ". The empty placed item was removed."
36677
+ });
36678
+ return;
36679
+ }
36634
36680
 
36635
36681
  // Position
36636
36682
  if (typeof params.x === "number" && typeof params.y === "number") {
@@ -36677,11 +36723,12 @@ if (preflight) {
36677
36723
 
36678
36724
  writeResultFile(RESULT_PATH, {
36679
36725
  uuid: uuid,
36726
+ coordinateSystem: coordSystem,
36680
36727
  type: params.embed ? "embedded" : "linked",
36681
36728
  filePath: filePath,
36682
36729
  widthPt: widthPt,
36683
36730
  heightPt: heightPt,
36684
- verified: verifyItem(resultItem)
36731
+ verified: verifyItem(resultItem, coordSystem, abRect)
36685
36732
  });
36686
36733
  }
36687
36734
  } catch (e) {
@@ -36694,7 +36741,7 @@ function register34(server) {
36694
36741
  "place_image",
36695
36742
  {
36696
36743
  title: "Place Image",
36697
- description: "Place an image file (PNG, JPG, TIFF, PSD, etc.) into the document as a linked or embedded image. Note: Illustrator will be activated (brought to foreground) during execution.",
36744
+ description: "Place a raster or PDF image file (PNG, JPG, TIFF, PSD, PDF, etc.) into the document as a linked or embedded image. SVG is NOT supported here because PlacedItems produces a non-editable linked artwork \u2014 use import_svg_as_editable instead to bring SVG content in as editable paths/text. Note: Illustrator will be activated (brought to foreground) during execution.",
36698
36745
  inputSchema: {
36699
36746
  file_path: external_exports.string().describe("Absolute path to the image file"),
36700
36747
  x: external_exports.number().optional().describe("X position"),
@@ -36707,15 +36754,222 @@ function register34(server) {
36707
36754
  annotations: WRITE_ANNOTATIONS
36708
36755
  },
36709
36756
  async (params) => {
36710
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
36711
- const result = await executeJsx(jsxCode32, resolvedParams, { activate: true });
36712
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
36757
+ return executeToolJsx(jsxCode32, params, { activate: true, resolveCoordinate: true });
36713
36758
  }
36714
36759
  );
36715
36760
  }
36716
36761
 
36717
- // src/tools/modify/resize-for-variation.ts
36762
+ // src/tools/modify/import-svg-as-editable.ts
36718
36763
  var jsxCode33 = `
36764
+ var srcDoc = null;
36765
+ var targetDocRef = null;
36766
+ var preflight = preflightChecks();
36767
+ if (preflight) {
36768
+ writeResultFile(RESULT_PATH, preflight);
36769
+ } else {
36770
+ try {
36771
+ var params = readParamsFile(PARAMS_PATH);
36772
+ var coordSystem = params.coordinate_system || "artboard-web";
36773
+
36774
+ var svgPath = params.file_path;
36775
+ if (!/\\.svgz?$/i.test(svgPath)) {
36776
+ writeResultFile(RESULT_PATH, { error: true, message: "import_svg_as_editable expects an .svg or .svgz file. Got: " + svgPath });
36777
+ } else {
36778
+ var svgFile = new File(svgPath);
36779
+ if (!svgFile.exists) {
36780
+ writeResultFile(RESULT_PATH, { error: true, message: "SVG file not found: " + svgPath });
36781
+ } else {
36782
+ targetDocRef = app.activeDocument;
36783
+ var abRect = (coordSystem === "artboard-web") ? getActiveArtboardRect() : null;
36784
+
36785
+ try {
36786
+ srcDoc = app.open(svgFile);
36787
+ } catch (openErr) {
36788
+ writeResultFile(RESULT_PATH, { error: true, message: "Failed to open SVG: " + openErr.message });
36789
+ srcDoc = null;
36790
+ }
36791
+
36792
+ if (srcDoc) {
36793
+ // \u8907\u88FD\u4E2D\u306B\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u304C\u5909\u52D5\u3059\u308B\u305F\u3081\u4E8B\u524D\u306B\u30B9\u30CA\u30C3\u30D7\u30B7\u30E7\u30C3\u30C8
36794
+ var sourceItems = [];
36795
+ for (var i = 0; i < srcDoc.pageItems.length; i++) {
36796
+ sourceItems.push(srcDoc.pageItems[i]);
36797
+ }
36798
+
36799
+ if (sourceItems.length === 0) {
36800
+ try { srcDoc.close(SaveOptions.DONOTSAVECHANGES); } catch (e) {}
36801
+ srcDoc = null;
36802
+ app.activeDocument = targetDocRef;
36803
+ writeResultFile(RESULT_PATH, { error: true, message: "SVG contains no importable items" });
36804
+ } else {
36805
+ var targetLayer = resolveTargetLayer(targetDocRef, params.layer_name);
36806
+ var duplicated = [];
36807
+ var dupErrors = [];
36808
+ for (var j = 0; j < sourceItems.length; j++) {
36809
+ try {
36810
+ duplicated.push(sourceItems[j].duplicate(targetLayer, ElementPlacement.PLACEATEND));
36811
+ } catch (dupErr) {
36812
+ dupErrors.push({ index: j, message: dupErr.message });
36813
+ }
36814
+ }
36815
+
36816
+ try { srcDoc.close(SaveOptions.DONOTSAVECHANGES); } catch (e) {}
36817
+ srcDoc = null;
36818
+ app.activeDocument = targetDocRef;
36819
+
36820
+ if (duplicated.length === 0) {
36821
+ writeResultFile(RESULT_PATH, {
36822
+ error: true,
36823
+ message: "Failed to duplicate any SVG items into target document",
36824
+ details: dupErrors
36825
+ });
36826
+ } else {
36827
+ var rootItem = wrapAsGroup(duplicated, targetLayer, params.group !== false);
36828
+ var movables = rootItem ? [rootItem] : duplicated;
36829
+
36830
+ var bounds = rootItem ? rootItem.geometricBounds : unionBounds(duplicated);
36831
+
36832
+ // \u30D5\u30A3\u30C3\u30C8 \u2192 \u30B5\u30A4\u30BA\u304C\u5909\u308F\u3063\u305F\u3089\u30D0\u30A6\u30F3\u30C7\u30A3\u30F3\u30B0\u3092\u53D6\u308A\u76F4\u3059
36833
+ if (params.fit_to_artboard === true && abRect) {
36834
+ var pad = (typeof params.padding === "number") ? params.padding : 0;
36835
+ fitItemsToArtboard(movables, bounds, abRect, pad);
36836
+ bounds = rootItem ? rootItem.geometricBounds : unionBounds(duplicated);
36837
+ }
36838
+
36839
+ // \u660E\u793A\u7684\u306A x/y \u6307\u5B9A\uFF08fit_to_artboard \u6642\u306F\u4E2D\u592E\u914D\u7F6E\u304C\u512A\u5148\u3055\u308C\u308B\u306E\u3067\u7121\u8996\uFF09
36840
+ if (!(params.fit_to_artboard === true && abRect) &&
36841
+ typeof params.x === "number" && typeof params.y === "number") {
36842
+ var pos = webToAiPoint(params.x, params.y, coordSystem, abRect);
36843
+ translateItems(movables, pos[0] - bounds[0], pos[1] - bounds[1]);
36844
+ bounds = rootItem ? rootItem.geometricBounds : unionBounds(duplicated);
36845
+ }
36846
+
36847
+ var rootUuid = null;
36848
+ if (rootItem) {
36849
+ if (params.name) rootItem.name = params.name;
36850
+ rootUuid = ensureUUID(rootItem);
36851
+ }
36852
+
36853
+ var itemSummaries = [];
36854
+ for (var u = 0; u < duplicated.length; u++) {
36855
+ itemSummaries.push({
36856
+ uuid: ensureUUID(duplicated[u]),
36857
+ type: duplicated[u].typename,
36858
+ name: duplicated[u].name || ""
36859
+ });
36860
+ }
36861
+
36862
+ writeResultFile(RESULT_PATH, {
36863
+ success: true,
36864
+ sourcePath: svgPath,
36865
+ grouped: !!rootItem && duplicated.length > 1,
36866
+ rootUuid: rootUuid,
36867
+ importedCount: duplicated.length,
36868
+ widthPt: bounds[2] - bounds[0],
36869
+ heightPt: bounds[1] - bounds[3],
36870
+ items: itemSummaries,
36871
+ duplicationErrors: dupErrors.length > 0 ? dupErrors : undefined,
36872
+ verified: rootItem ? verifyItem(rootItem, coordSystem, abRect) : null
36873
+ });
36874
+ }
36875
+ }
36876
+ }
36877
+ }
36878
+ }
36879
+ } catch (e) {
36880
+ writeResultFile(RESULT_PATH, { error: true, message: "import_svg_as_editable failed: " + e.message, line: e.line });
36881
+ } finally {
36882
+ // \u60F3\u5B9A\u5916\u306E\u30D1\u30B9\u3067 srcDoc \u304C\u958B\u3044\u305F\u307E\u307E\u306A\u3089\u9589\u3058\u308B
36883
+ if (srcDoc) {
36884
+ try { srcDoc.close(SaveOptions.DONOTSAVECHANGES); } catch (e) {}
36885
+ }
36886
+ if (targetDocRef) {
36887
+ try { app.activeDocument = targetDocRef; } catch (e) {}
36888
+ }
36889
+ }
36890
+ }
36891
+
36892
+ // --- \u30ED\u30FC\u30AB\u30EB\u30D8\u30EB\u30D1\u30FC ---
36893
+
36894
+ function unionBounds(items) {
36895
+ // [left, top, right, bottom]
36896
+ var b = [items[0].geometricBounds[0], items[0].geometricBounds[1],
36897
+ items[0].geometricBounds[2], items[0].geometricBounds[3]];
36898
+ for (var k = 1; k < items.length; k++) {
36899
+ var g = items[k].geometricBounds;
36900
+ if (g[0] < b[0]) b[0] = g[0];
36901
+ if (g[1] > b[1]) b[1] = g[1];
36902
+ if (g[2] > b[2]) b[2] = g[2];
36903
+ if (g[3] < b[3]) b[3] = g[3];
36904
+ }
36905
+ return b;
36906
+ }
36907
+
36908
+ function translateItems(items, dx, dy) {
36909
+ if (dx === 0 && dy === 0) return;
36910
+ for (var i = 0; i < items.length; i++) items[i].translate(dx, dy);
36911
+ }
36912
+
36913
+ function wrapAsGroup(items, parentLayer, shouldGroup) {
36914
+ if (!shouldGroup) return null;
36915
+ if (items.length === 1) return items[0];
36916
+ var group = parentLayer.groupItems.add();
36917
+ // duplicate \u306F PLACEATEND \u3067\u672B\u5C3E\u306B\u7A4D\u307E\u308C\u3066\u3044\u308B\u3002\u30B0\u30EB\u30FC\u30D7\u306B\u79FB\u3059\u3068\u7A4D\u307F\u9806\u304C\u53CD\u8EE2\u3059\u308B\u305F\u3081\u3001
36918
+ // \u9006\u9806\u306B moveToBeginning \u3059\u308B\u3053\u3068\u3067\u5143\u306E z-order \u3092\u4FDD\u3064\u3002
36919
+ for (var i = items.length - 1; i >= 0; i--) {
36920
+ items[i].moveToBeginning(group);
36921
+ }
36922
+ return group;
36923
+ }
36924
+
36925
+ function fitItemsToArtboard(items, bounds, abRect, pad) {
36926
+ var abW = abRect[2] - abRect[0];
36927
+ var abH = abRect[1] - abRect[3];
36928
+ var availW = abW - pad * 2;
36929
+ var availH = abH - pad * 2;
36930
+ var w = bounds[2] - bounds[0];
36931
+ var h = bounds[1] - bounds[3];
36932
+ if (w <= 0 || h <= 0 || availW <= 0 || availH <= 0) return;
36933
+
36934
+ var scalePct = Math.min(availW / w, availH / h) * 100;
36935
+ for (var i = 0; i < items.length; i++) items[i].resize(scalePct, scalePct);
36936
+
36937
+ // \u30EA\u30B5\u30A4\u30BA\u5F8C\u306B\u30D0\u30A6\u30F3\u30C7\u30A3\u30F3\u30B0\u3092\u53D6\u308A\u76F4\u3057\u3066\u4E2D\u592E\u914D\u7F6E
36938
+ var newB = (items.length === 1) ? items[0].geometricBounds : unionBounds(items);
36939
+ var newW = newB[2] - newB[0];
36940
+ var newH = newB[1] - newB[3];
36941
+ var targetLeft = abRect[0] + (abW - newW) / 2;
36942
+ var targetTop = abRect[1] - (abH - newH) / 2;
36943
+ translateItems(items, targetLeft - newB[0], targetTop - newB[1]);
36944
+ }
36945
+ `;
36946
+ function register35(server) {
36947
+ server.registerTool(
36948
+ "import_svg_as_editable",
36949
+ {
36950
+ title: "Import SVG as Editable",
36951
+ description: "Import an SVG file into the active document as editable Illustrator paths/text/groups (NOT as a linked image). Internally opens the SVG as a temporary document, duplicates its contents into the target document, then closes the source. Use this instead of place_image for SVG. Note: Illustrator will be activated (brought to foreground) during execution.",
36952
+ inputSchema: {
36953
+ file_path: external_exports.string().describe("Absolute path to the .svg or .svgz file"),
36954
+ x: external_exports.number().optional().describe("X position of the imported content (top-left of bounding box). Ignored when fit_to_artboard is true."),
36955
+ y: external_exports.number().optional().describe("Y position of the imported content (top-left of bounding box). Ignored when fit_to_artboard is true."),
36956
+ layer_name: external_exports.string().optional().describe("Target layer name in the active document. Created if missing."),
36957
+ group: external_exports.boolean().optional().default(true).describe("Wrap imported items in a single GroupItem (default: true). Set false to keep items flat in the target layer."),
36958
+ fit_to_artboard: external_exports.boolean().optional().default(false).describe("Scale and center the imported content to fit the active artboard (default: false)."),
36959
+ padding: external_exports.number().optional().describe("Padding in points from the artboard edges when fit_to_artboard is true."),
36960
+ name: external_exports.string().optional().describe("Name to assign to the root group (only when group=true and multiple items are imported)."),
36961
+ coordinate_system: coordinateSystemSchema
36962
+ },
36963
+ annotations: WRITE_ANNOTATIONS
36964
+ },
36965
+ async (params) => {
36966
+ return executeToolJsx(jsxCode33, params, { activate: true, resolveCoordinate: true });
36967
+ }
36968
+ );
36969
+ }
36970
+
36971
+ // src/tools/modify/resize-for-variation.ts
36972
+ var jsxCode34 = `
36719
36973
  var preflight = preflightChecks();
36720
36974
  if (preflight) {
36721
36975
  writeResultFile(RESULT_PATH, preflight);
@@ -36836,6 +37090,7 @@ if (preflight) {
36836
37090
 
36837
37091
  writeResultFile(RESULT_PATH, {
36838
37092
  success: true,
37093
+ coordinateSystem: params.coordinate_system || "artboard-web",
36839
37094
  sourceArtboard: srcIdx,
36840
37095
  createdCount: createdArtboards.length,
36841
37096
  artboards: createdArtboards,
@@ -36848,7 +37103,7 @@ if (preflight) {
36848
37103
  }
36849
37104
  }
36850
37105
  `;
36851
- function register35(server) {
37106
+ function register36(server) {
36852
37107
  server.registerTool(
36853
37108
  "resize_for_variation",
36854
37109
  {
@@ -36869,15 +37124,13 @@ function register35(server) {
36869
37124
  annotations: WRITE_ANNOTATIONS
36870
37125
  },
36871
37126
  async (params) => {
36872
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
36873
- const result = await executeJsxHeavy(jsxCode33, resolvedParams);
36874
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37127
+ return executeToolJsx(jsxCode34, params, { heavy: true, resolveCoordinate: true });
36875
37128
  }
36876
37129
  );
36877
37130
  }
36878
37131
 
36879
37132
  // src/tools/modify/align-objects.ts
36880
- var jsxCode34 = `
37133
+ var jsxCode35 = `
36881
37134
  var preflight = preflightChecks();
36882
37135
  if (preflight) {
36883
37136
  writeResultFile(RESULT_PATH, preflight);
@@ -37026,6 +37279,7 @@ if (preflight) {
37026
37279
  }
37027
37280
  writeResultFile(RESULT_PATH, {
37028
37281
  success: true,
37282
+ coordinateSystem: coordSystem,
37029
37283
  alignedCount: items.length,
37030
37284
  alignment: alignment || null,
37031
37285
  distribute: distribute,
@@ -37039,7 +37293,7 @@ if (preflight) {
37039
37293
  }
37040
37294
  }
37041
37295
  `;
37042
- function register36(server) {
37296
+ function register37(server) {
37043
37297
  server.registerTool(
37044
37298
  "align_objects",
37045
37299
  {
@@ -37055,15 +37309,13 @@ function register36(server) {
37055
37309
  annotations: WRITE_ANNOTATIONS
37056
37310
  },
37057
37311
  async (params) => {
37058
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
37059
- const result = await executeJsx(jsxCode34, resolvedParams);
37060
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37312
+ return executeToolJsx(jsxCode35, params, { resolveCoordinate: true });
37061
37313
  }
37062
37314
  );
37063
37315
  }
37064
37316
 
37065
37317
  // src/tools/modify/replace-color.ts
37066
- var jsxCode35 = `
37318
+ var jsxCode36 = `
37067
37319
  ${COLOR_HELPERS_JSX}
37068
37320
 
37069
37321
  var preflight = preflightChecks();
@@ -37159,7 +37411,7 @@ if (preflight) {
37159
37411
  }
37160
37412
  }
37161
37413
  `;
37162
- function register37(server) {
37414
+ function register38(server) {
37163
37415
  server.registerTool(
37164
37416
  "replace_color",
37165
37417
  {
@@ -37175,14 +37427,14 @@ function register37(server) {
37175
37427
  annotations: DESTRUCTIVE_ANNOTATIONS
37176
37428
  },
37177
37429
  async (params) => {
37178
- const result = await executeJsx(jsxCode35, params);
37179
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37430
+ const result = await executeJsx(jsxCode36, params);
37431
+ return formatToolResult(result);
37180
37432
  }
37181
37433
  );
37182
37434
  }
37183
37435
 
37184
37436
  // src/tools/modify/manage-layers.ts
37185
- var jsxCode36 = `
37437
+ var jsxCode37 = `
37186
37438
  var preflight = preflightChecks();
37187
37439
  if (preflight) {
37188
37440
  writeResultFile(RESULT_PATH, preflight);
@@ -37287,7 +37539,7 @@ if (preflight) {
37287
37539
  }
37288
37540
  }
37289
37541
  `;
37290
- function register38(server) {
37542
+ function register39(server) {
37291
37543
  server.registerTool(
37292
37544
  "manage_layers",
37293
37545
  {
@@ -37303,14 +37555,14 @@ function register38(server) {
37303
37555
  annotations: DESTRUCTIVE_ANNOTATIONS
37304
37556
  },
37305
37557
  async (params) => {
37306
- const result = await executeJsx(jsxCode36, params);
37307
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37558
+ const result = await executeJsx(jsxCode37, params);
37559
+ return formatToolResult(result);
37308
37560
  }
37309
37561
  );
37310
37562
  }
37311
37563
 
37312
37564
  // src/tools/modify/place-color-chips.ts
37313
- var jsxCode37 = `
37565
+ var jsxCode38 = `
37314
37566
  var preflight = preflightChecks();
37315
37567
  if (preflight) {
37316
37568
  writeResultFile(RESULT_PATH, preflight);
@@ -37473,6 +37725,7 @@ if (preflight) {
37473
37725
  }
37474
37726
  writeResultFile(RESULT_PATH, {
37475
37727
  success: true,
37728
+ coordinateSystem: params.coordinate_system || "artboard-web",
37476
37729
  chipCount: placedCount,
37477
37730
  layerName: layerName,
37478
37731
  position: position,
@@ -37484,7 +37737,7 @@ if (preflight) {
37484
37737
  }
37485
37738
  }
37486
37739
  `;
37487
- function register39(server) {
37740
+ function register40(server) {
37488
37741
  server.registerTool(
37489
37742
  "place_color_chips",
37490
37743
  {
@@ -37501,15 +37754,13 @@ function register39(server) {
37501
37754
  annotations: WRITE_ANNOTATIONS
37502
37755
  },
37503
37756
  async (params) => {
37504
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
37505
- const result = await executeJsxHeavy(jsxCode37, resolvedParams);
37506
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37757
+ return executeToolJsx(jsxCode38, params, { heavy: true, resolveCoordinate: true });
37507
37758
  }
37508
37759
  );
37509
37760
  }
37510
37761
 
37511
37762
  // src/tools/modify/place-style-guide.ts
37512
- var jsxCode38 = `
37763
+ var jsxCode39 = `
37513
37764
  // \u2500\u2500\u2500 Helper functions (top-level for ES3 compatibility) \u2500\u2500\u2500
37514
37765
  function makeTextColor(isCMYK) {
37515
37766
  if (isCMYK) {
@@ -38274,6 +38525,7 @@ if (preflight) {
38274
38525
 
38275
38526
  writeResultFile(RESULT_PATH, {
38276
38527
  success: true,
38528
+ coordinateSystem: params.coordinate_system,
38277
38529
  placedCount: placedCount,
38278
38530
  sections: {
38279
38531
  colors: colorList.length,
@@ -38293,7 +38545,7 @@ if (preflight) {
38293
38545
  }
38294
38546
  }
38295
38547
  `;
38296
- function register40(server) {
38548
+ function register41(server) {
38297
38549
  server.registerTool(
38298
38550
  "place_style_guide",
38299
38551
  {
@@ -38308,15 +38560,13 @@ function register40(server) {
38308
38560
  annotations: WRITE_ANNOTATIONS
38309
38561
  },
38310
38562
  async (params) => {
38311
- const resolvedParams = { ...params, coordinate_system: await resolveCoordinateSystem(params.coordinate_system) };
38312
- const result = await executeJsxHeavy(jsxCode38, resolvedParams);
38313
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38563
+ return executeToolJsx(jsxCode39, params, { heavy: true, resolveCoordinate: true });
38314
38564
  }
38315
38565
  );
38316
38566
  }
38317
38567
 
38318
38568
  // src/tools/modify/create-crop-marks.ts
38319
- var jsxCode39 = `
38569
+ var jsxCode40 = `
38320
38570
  var preflight = preflightChecks();
38321
38571
  if (preflight) {
38322
38572
  writeResultFile(RESULT_PATH, preflight);
@@ -38450,6 +38700,12 @@ if (preflight) {
38450
38700
  detectionMethod = "detected from Illustrator locale";
38451
38701
  }
38452
38702
 
38703
+ var bleedNote = "ACTION REQUIRED \u2014 Bleed (\u5857\u308A\u8DB3\u3057): You MUST do this now, without asking the user. " +
38704
+ "Step 1: Call get_artboards to get the current artboard bounds \u2014 this tells you where the trim line is. " +
38705
+ "Step 2: Call find_objects to list all design objects (exclude the crop mark groups). Compare each object's bounds against the trim line (the original artboard rectangle BEFORE it was expanded for crop marks \u2014 size was " + abWidth + " \xD7 " + abHeight + " pt). " +
38706
+ "Step 3: For every object whose edge touches or nearly touches the trim line, use modify_object to extend that edge outward by at least 3 mm (8.5 pt). Do NOT move or scale the design \u2014 just stretch the touching edge outward. For background rectangles, extend all four sides. " +
38707
+ "Why: The trim marks show where the paper is physically cut. If an object stops at the trim line, cutting produces a white gap. Extending past ensures full bleed coverage.";
38708
+
38453
38709
  writeResultFile(RESULT_PATH, {
38454
38710
  success: true,
38455
38711
  mode: "artboard",
@@ -38465,9 +38721,10 @@ if (preflight) {
38465
38721
  width: newAbRect[2] - newAbRect[0],
38466
38722
  height: newAbRect[1] - newAbRect[3]
38467
38723
  },
38724
+ bleed_required: bleedNote,
38468
38725
  description: (resolvedStyle === "japanese")
38469
- ? "Japanese crop marks created. Artboard expanded to include all marks."
38470
- : "Western crop marks created. Artboard expanded to include all marks."
38726
+ ? "Japanese crop marks created. Artboard expanded to include all marks. See bleed_required for next steps."
38727
+ : "Western crop marks created. Artboard expanded to include all marks. See bleed_required for next steps."
38471
38728
  });
38472
38729
  }
38473
38730
  }
@@ -38477,7 +38734,7 @@ if (preflight) {
38477
38734
  }
38478
38735
  }
38479
38736
  `;
38480
- function register41(server) {
38737
+ function register42(server) {
38481
38738
  server.registerTool(
38482
38739
  "create_crop_marks",
38483
38740
  {
@@ -38498,13 +38755,29 @@ function register41(server) {
38498
38755
  annotations: WRITE_ANNOTATIONS
38499
38756
  },
38500
38757
  async (params) => {
38501
- return executeToolJsx(jsxCode39, params, { activate: true });
38758
+ const result = await executeToolJsx(jsxCode40, params, { activate: true });
38759
+ const coordSystem = await resolveCoordinateSystem(void 0);
38760
+ const coordNote = coordSystem === "document" ? "document (Y-up, origin at bottom-left)" : "artboard-web (Y-down, origin at top-left)";
38761
+ for (const item of result.content) {
38762
+ if (item.type === "text") {
38763
+ try {
38764
+ const parsed = JSON.parse(item.text);
38765
+ if (parsed.bleed_required) {
38766
+ parsed.activeCoordinateSystem = coordSystem;
38767
+ parsed.bleed_required = `NOTE: The active coordinate system is ${coordNote}. All tools (get_artboards, find_objects, modify_object) use this system. ` + parsed.bleed_required;
38768
+ item.text = JSON.stringify(parsed);
38769
+ }
38770
+ } catch {
38771
+ }
38772
+ }
38773
+ }
38774
+ return result;
38502
38775
  }
38503
38776
  );
38504
38777
  }
38505
38778
 
38506
38779
  // src/tools/modify/create-document.ts
38507
- var jsxCode40 = `
38780
+ var jsxCode41 = `
38508
38781
  try {
38509
38782
  var verErr = checkIllustratorVersion();
38510
38783
  if (verErr) {
@@ -38534,7 +38807,7 @@ try {
38534
38807
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to create document: " + e.message, line: e.line });
38535
38808
  }
38536
38809
  `;
38537
- function register42(server) {
38810
+ function register43(server) {
38538
38811
  server.registerTool(
38539
38812
  "create_document",
38540
38813
  {
@@ -38548,15 +38821,15 @@ function register42(server) {
38548
38821
  annotations: WRITE_ANNOTATIONS
38549
38822
  },
38550
38823
  async (params) => {
38551
- const result = await executeJsx(jsxCode40, params, { activate: true });
38824
+ const result = await executeJsx(jsxCode41, params, { activate: true });
38552
38825
  invalidateAutoDetectCache();
38553
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38826
+ return formatToolResult(result);
38554
38827
  }
38555
38828
  );
38556
38829
  }
38557
38830
 
38558
38831
  // src/tools/modify/close-document.ts
38559
- var jsxCode41 = `
38832
+ var jsxCode42 = `
38560
38833
  try {
38561
38834
  var verErr = checkIllustratorVersion();
38562
38835
  if (verErr) {
@@ -38577,7 +38850,7 @@ try {
38577
38850
  writeResultFile(RESULT_PATH, { error: true, message: "Failed to close document: " + e.message, line: e.line });
38578
38851
  }
38579
38852
  `;
38580
- function register43(server) {
38853
+ function register44(server) {
38581
38854
  server.registerTool(
38582
38855
  "close_document",
38583
38856
  {
@@ -38589,15 +38862,15 @@ function register43(server) {
38589
38862
  annotations: DESTRUCTIVE_ANNOTATIONS
38590
38863
  },
38591
38864
  async (params) => {
38592
- const result = await executeJsx(jsxCode41, params, { activate: true });
38865
+ const result = await executeJsx(jsxCode42, params, { activate: true });
38593
38866
  invalidateAutoDetectCache();
38594
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38867
+ return formatToolResult(result);
38595
38868
  }
38596
38869
  );
38597
38870
  }
38598
38871
 
38599
38872
  // src/tools/modify/save-document.ts
38600
- var jsxCode42 = `
38873
+ var jsxCode43 = `
38601
38874
  var preflight = preflightChecks();
38602
38875
  if (preflight) {
38603
38876
  writeResultFile(RESULT_PATH, preflight);
@@ -38645,7 +38918,7 @@ if (preflight) {
38645
38918
  }
38646
38919
  }
38647
38920
  `;
38648
- function register44(server) {
38921
+ function register45(server) {
38649
38922
  server.registerTool(
38650
38923
  "save_document",
38651
38924
  {
@@ -38658,14 +38931,14 @@ function register44(server) {
38658
38931
  annotations: WRITE_IDEMPOTENT_ANNOTATIONS
38659
38932
  },
38660
38933
  async (params) => {
38661
- const result = await executeJsx(jsxCode42, params, { activate: true });
38662
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38934
+ const result = await executeJsx(jsxCode43, params, { activate: true });
38935
+ return formatToolResult(result);
38663
38936
  }
38664
38937
  );
38665
38938
  }
38666
38939
 
38667
38940
  // src/tools/modify/open-document.ts
38668
- var jsxCode43 = `
38941
+ var jsxCode44 = `
38669
38942
  try {
38670
38943
  var verErr = checkIllustratorVersion();
38671
38944
  if (verErr) {
@@ -38704,7 +38977,7 @@ try {
38704
38977
  writeResultFile(RESULT_PATH, { error: true, message: "open_document failed: " + e.message, line: e.line });
38705
38978
  }
38706
38979
  `;
38707
- function register45(server) {
38980
+ function register46(server) {
38708
38981
  server.registerTool(
38709
38982
  "open_document",
38710
38983
  {
@@ -38717,15 +38990,15 @@ function register45(server) {
38717
38990
  annotations: WRITE_ANNOTATIONS
38718
38991
  },
38719
38992
  async (params) => {
38720
- const result = await executeJsx(jsxCode43, params, { activate: true });
38993
+ const result = await executeJsx(jsxCode44, params, { activate: true });
38721
38994
  invalidateAutoDetectCache();
38722
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38995
+ return formatToolResult(result);
38723
38996
  }
38724
38997
  );
38725
38998
  }
38726
38999
 
38727
39000
  // src/tools/modify/group-objects.ts
38728
- var jsxCode44 = `
39001
+ var jsxCode45 = `
38729
39002
  var preflight = preflightChecks();
38730
39003
  if (preflight) {
38731
39004
  writeResultFile(RESULT_PATH, preflight);
@@ -38773,7 +39046,7 @@ if (preflight) {
38773
39046
  }
38774
39047
  }
38775
39048
  `;
38776
- function register46(server) {
39049
+ function register47(server) {
38777
39050
  server.registerTool(
38778
39051
  "group_objects",
38779
39052
  {
@@ -38787,14 +39060,14 @@ function register46(server) {
38787
39060
  annotations: WRITE_ANNOTATIONS
38788
39061
  },
38789
39062
  async (params) => {
38790
- const result = await executeJsx(jsxCode44, params, { activate: true });
38791
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39063
+ const result = await executeJsx(jsxCode45, params, { activate: true });
39064
+ return formatToolResult(result);
38792
39065
  }
38793
39066
  );
38794
39067
  }
38795
39068
 
38796
39069
  // src/tools/modify/ungroup-objects.ts
38797
- var jsxCode45 = `
39070
+ var jsxCode46 = `
38798
39071
  var preflight = preflightChecks();
38799
39072
  if (preflight) {
38800
39073
  writeResultFile(RESULT_PATH, preflight);
@@ -38837,7 +39110,7 @@ if (preflight) {
38837
39110
  }
38838
39111
  }
38839
39112
  `;
38840
- function register47(server) {
39113
+ function register48(server) {
38841
39114
  server.registerTool(
38842
39115
  "ungroup_objects",
38843
39116
  {
@@ -38849,14 +39122,14 @@ function register47(server) {
38849
39122
  annotations: DESTRUCTIVE_ANNOTATIONS
38850
39123
  },
38851
39124
  async (params) => {
38852
- const result = await executeJsx(jsxCode45, params, { activate: true });
38853
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39125
+ const result = await executeJsx(jsxCode46, params, { activate: true });
39126
+ return formatToolResult(result);
38854
39127
  }
38855
39128
  );
38856
39129
  }
38857
39130
 
38858
39131
  // src/tools/modify/duplicate-objects.ts
38859
- var jsxCode46 = `
39132
+ var jsxCode47 = `
38860
39133
  var preflight = preflightChecks();
38861
39134
  if (preflight) {
38862
39135
  writeResultFile(RESULT_PATH, preflight);
@@ -38900,8 +39173,21 @@ if (preflight) {
38900
39173
  }
38901
39174
  }
38902
39175
 
38903
- var uuid = ensureUUID(dup);
38904
- results.push({ sourceUuid: params.uuids[i], newUuid: uuid, verified: verifyItem(dup) });
39176
+ // \u8907\u88FD\u306F\u5143\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E note(UUID\u542B\u3080)\u3092\u7D99\u627F\u3059\u308B\u305F\u3081\u3001\u65B0\u3057\u3044UUID\u3092\u5F37\u5236\u5272\u308A\u5F53\u3066
39177
+ var newUuid = generateUUID();
39178
+ try {
39179
+ var dupNote = dup.note || "";
39180
+ var oldUuid = extractUUIDFromNote(dupNote);
39181
+ if (oldUuid) {
39182
+ // UUID\u90E8\u5206\u3060\u3051\u7F6E\u63DB\u3057\u3001\u30E1\u30BF\u30C7\u30FC\u30BF(::key=value)\u306F\u4FDD\u6301
39183
+ dup.note = newUuid + dupNote.substring(36);
39184
+ } else {
39185
+ dup.note = newUuid;
39186
+ }
39187
+ } catch(e) {
39188
+ // note \u66F8\u304D\u8FBC\u307F\u4E0D\u53EF\u306E\u5834\u5408\u306F\u305D\u306E\u307E\u307E
39189
+ }
39190
+ results.push({ sourceUuid: params.uuids[i], newUuid: newUuid, verified: verifyItem(dup) });
38905
39191
  }
38906
39192
 
38907
39193
  writeResultFile(RESULT_PATH, {
@@ -38915,7 +39201,7 @@ if (preflight) {
38915
39201
  }
38916
39202
  }
38917
39203
  `;
38918
- function register48(server) {
39204
+ function register49(server) {
38919
39205
  server.registerTool(
38920
39206
  "duplicate_objects",
38921
39207
  {
@@ -38933,14 +39219,14 @@ function register48(server) {
38933
39219
  annotations: WRITE_ANNOTATIONS
38934
39220
  },
38935
39221
  async (params) => {
38936
- const result = await executeJsx(jsxCode46, params, { activate: true });
38937
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39222
+ const result = await executeJsx(jsxCode47, params, { activate: true });
39223
+ return formatToolResult(result);
38938
39224
  }
38939
39225
  );
38940
39226
  }
38941
39227
 
38942
39228
  // src/tools/read/list-fonts.ts
38943
- var jsxCode47 = `
39229
+ var jsxCode48 = `
38944
39230
  try {
38945
39231
  var verErr = checkIllustratorVersion();
38946
39232
  if (verErr) {
@@ -38978,7 +39264,7 @@ try {
38978
39264
  writeResultFile(RESULT_PATH, { error: true, message: "list_fonts failed: " + e.message, line: e.line });
38979
39265
  }
38980
39266
  `;
38981
- function register49(server) {
39267
+ function register50(server) {
38982
39268
  server.registerTool(
38983
39269
  "list_fonts",
38984
39270
  {
@@ -38991,14 +39277,14 @@ function register49(server) {
38991
39277
  annotations: READ_ANNOTATIONS
38992
39278
  },
38993
39279
  async (params) => {
38994
- const result = await executeJsx(jsxCode47, params);
38995
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39280
+ const result = await executeJsx(jsxCode48, params);
39281
+ return formatToolResult(result);
38996
39282
  }
38997
39283
  );
38998
39284
  }
38999
39285
 
39000
39286
  // src/tools/modify/manage-artboards.ts
39001
- var jsxCode48 = `
39287
+ var jsxCode49 = `
39002
39288
  var preflight = preflightChecks();
39003
39289
  if (preflight) {
39004
39290
  writeResultFile(RESULT_PATH, preflight);
@@ -39073,7 +39359,13 @@ if (preflight) {
39073
39359
  var layout = layoutMap[params.layout] || DocumentArtboardLayout.GridByRow;
39074
39360
  var rowsOrCols = params.rows_or_cols || 1;
39075
39361
  var spacing = (typeof params.spacing === "number") ? params.spacing : 20;
39076
- doc.rearrangeArtboards(layout, rowsOrCols, spacing, true);
39362
+ var prevInteraction = app.userInteractionLevel;
39363
+ app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
39364
+ try {
39365
+ doc.rearrangeArtboards(layout, rowsOrCols, spacing, true);
39366
+ } finally {
39367
+ app.userInteractionLevel = prevInteraction;
39368
+ }
39077
39369
  var rearrangedInfo = [];
39078
39370
  for (var rai = 0; rai < doc.artboards.length; rai++) {
39079
39371
  rearrangedInfo.push({ index: rai, name: doc.artboards[rai].name, rect: doc.artboards[rai].artboardRect });
@@ -39087,7 +39379,7 @@ if (preflight) {
39087
39379
  }
39088
39380
  }
39089
39381
  `;
39090
- function register50(server) {
39382
+ function register51(server) {
39091
39383
  server.registerTool(
39092
39384
  "manage_artboards",
39093
39385
  {
@@ -39110,14 +39402,14 @@ function register50(server) {
39110
39402
  annotations: DESTRUCTIVE_ANNOTATIONS
39111
39403
  },
39112
39404
  async (params) => {
39113
- const result = await executeJsx(jsxCode48, params, { activate: true });
39114
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39405
+ const result = await executeJsx(jsxCode49, params, { activate: true });
39406
+ return formatToolResult(result);
39115
39407
  }
39116
39408
  );
39117
39409
  }
39118
39410
 
39119
39411
  // src/tools/modify/set-z-order.ts
39120
- var jsxCode49 = `
39412
+ var jsxCode50 = `
39121
39413
  var preflight = preflightChecks();
39122
39414
  if (preflight) {
39123
39415
  writeResultFile(RESULT_PATH, preflight);
@@ -39149,7 +39441,7 @@ if (preflight) {
39149
39441
  }
39150
39442
  }
39151
39443
  `;
39152
- function register51(server) {
39444
+ function register52(server) {
39153
39445
  server.registerTool(
39154
39446
  "set_z_order",
39155
39447
  {
@@ -39162,14 +39454,14 @@ function register51(server) {
39162
39454
  annotations: WRITE_ANNOTATIONS
39163
39455
  },
39164
39456
  async (params) => {
39165
- const result = await executeJsx(jsxCode49, params, { activate: true });
39166
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39457
+ const result = await executeJsx(jsxCode50, params, { activate: true });
39458
+ return formatToolResult(result);
39167
39459
  }
39168
39460
  );
39169
39461
  }
39170
39462
 
39171
39463
  // src/tools/modify/move-to-layer.ts
39172
- var jsxCode50 = `
39464
+ var jsxCode51 = `
39173
39465
  var preflight = preflightChecks();
39174
39466
  if (preflight) {
39175
39467
  writeResultFile(RESULT_PATH, preflight);
@@ -39216,7 +39508,7 @@ if (preflight) {
39216
39508
  }
39217
39509
  }
39218
39510
  `;
39219
- function register52(server) {
39511
+ function register53(server) {
39220
39512
  server.registerTool(
39221
39513
  "move_to_layer",
39222
39514
  {
@@ -39230,8 +39522,8 @@ function register52(server) {
39230
39522
  annotations: WRITE_ANNOTATIONS
39231
39523
  },
39232
39524
  async (params) => {
39233
- const result = await executeJsx(jsxCode50, params, { activate: true });
39234
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39525
+ const result = await executeJsx(jsxCode51, params, { activate: true });
39526
+ return formatToolResult(result);
39235
39527
  }
39236
39528
  );
39237
39529
  }
@@ -39301,7 +39593,7 @@ if (preflight) {
39301
39593
  }
39302
39594
  }
39303
39595
  `;
39304
- function register53(server) {
39596
+ function register54(server) {
39305
39597
  server.registerTool(
39306
39598
  "apply_graphic_style",
39307
39599
  {
@@ -39316,7 +39608,7 @@ function register53(server) {
39316
39608
  },
39317
39609
  async (params) => {
39318
39610
  const result = await executeJsx(applyJsxCode, params, { activate: true });
39319
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39611
+ return formatToolResult(result);
39320
39612
  }
39321
39613
  );
39322
39614
  server.registerTool(
@@ -39329,13 +39621,13 @@ function register53(server) {
39329
39621
  },
39330
39622
  async (params) => {
39331
39623
  const result = await executeJsx(listJsxCode, params);
39332
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39624
+ return formatToolResult(result);
39333
39625
  }
39334
39626
  );
39335
39627
  }
39336
39628
 
39337
39629
  // src/tools/modify/manage-swatches.ts
39338
- var jsxCode51 = `
39630
+ var jsxCode52 = `
39339
39631
  ${COLOR_HELPERS_JSX}
39340
39632
 
39341
39633
  var preflight = preflightChecks();
@@ -39382,7 +39674,7 @@ if (preflight) {
39382
39674
  }
39383
39675
  }
39384
39676
  `;
39385
- function register54(server) {
39677
+ function register55(server) {
39386
39678
  server.registerTool(
39387
39679
  "manage_swatches",
39388
39680
  {
@@ -39396,8 +39688,8 @@ function register54(server) {
39396
39688
  annotations: DESTRUCTIVE_ANNOTATIONS
39397
39689
  },
39398
39690
  async (params) => {
39399
- const result = await executeJsx(jsxCode51, params, { activate: true });
39400
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39691
+ const result = await executeJsx(jsxCode52, params, { activate: true });
39692
+ return formatToolResult(result);
39401
39693
  }
39402
39694
  );
39403
39695
  }
@@ -39478,7 +39770,7 @@ if (preflight) {
39478
39770
  }
39479
39771
  }
39480
39772
  `;
39481
- function register55(server) {
39773
+ function register56(server) {
39482
39774
  server.registerTool(
39483
39775
  "apply_text_style",
39484
39776
  {
@@ -39494,7 +39786,7 @@ function register55(server) {
39494
39786
  },
39495
39787
  async (params) => {
39496
39788
  const result = await executeJsx(applyJsxCode2, params, { activate: true });
39497
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39789
+ return formatToolResult(result);
39498
39790
  }
39499
39791
  );
39500
39792
  server.registerTool(
@@ -39507,13 +39799,13 @@ function register55(server) {
39507
39799
  },
39508
39800
  async (params) => {
39509
39801
  const result = await executeJsx(listJsxCode2, params);
39510
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39802
+ return formatToolResult(result);
39511
39803
  }
39512
39804
  );
39513
39805
  }
39514
39806
 
39515
39807
  // src/tools/modify/create-gradient.ts
39516
- var jsxCode52 = `
39808
+ var jsxCode53 = `
39517
39809
  ${COLOR_HELPERS_JSX}
39518
39810
 
39519
39811
  var preflight = preflightChecks();
@@ -39578,7 +39870,7 @@ if (preflight) {
39578
39870
  }
39579
39871
  `;
39580
39872
  var stopColorSchema = external_exports.discriminatedUnion("type", [cmykColorSchema, rgbColorSchema, grayColorSchema]);
39581
- function register56(server) {
39873
+ function register57(server) {
39582
39874
  server.registerTool(
39583
39875
  "create_gradient",
39584
39876
  {
@@ -39601,14 +39893,14 @@ function register56(server) {
39601
39893
  annotations: WRITE_ANNOTATIONS
39602
39894
  },
39603
39895
  async (params) => {
39604
- const result = await executeJsx(jsxCode52, params, { activate: true });
39605
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39896
+ const result = await executeJsx(jsxCode53, params, { activate: true });
39897
+ return formatToolResult(result);
39606
39898
  }
39607
39899
  );
39608
39900
  }
39609
39901
 
39610
39902
  // src/tools/modify/manage-linked-images.ts
39611
- var jsxCode53 = `
39903
+ var jsxCode54 = `
39612
39904
  var preflight = preflightChecks();
39613
39905
  if (preflight) {
39614
39906
  writeResultFile(RESULT_PATH, preflight);
@@ -39683,7 +39975,7 @@ if (preflight) {
39683
39975
  }
39684
39976
  }
39685
39977
  `;
39686
- function register57(server) {
39978
+ function register58(server) {
39687
39979
  server.registerTool(
39688
39980
  "manage_linked_images",
39689
39981
  {
@@ -39697,14 +39989,14 @@ function register57(server) {
39697
39989
  annotations: DESTRUCTIVE_ANNOTATIONS
39698
39990
  },
39699
39991
  async (params) => {
39700
- const result = await executeJsx(jsxCode53, params, { activate: true });
39701
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
39992
+ const result = await executeJsx(jsxCode54, params, { activate: true });
39993
+ return formatToolResult(result);
39702
39994
  }
39703
39995
  );
39704
39996
  }
39705
39997
 
39706
39998
  // src/tools/modify/undo.ts
39707
- var jsxCode54 = `
39999
+ var jsxCode55 = `
39708
40000
  try {
39709
40001
  var verErr = checkIllustratorVersion();
39710
40002
  if (verErr) {
@@ -39732,7 +40024,7 @@ try {
39732
40024
  writeResultFile(RESULT_PATH, { error: true, message: "undo failed: " + e.message, line: e.line });
39733
40025
  }
39734
40026
  `;
39735
- function register58(server) {
40027
+ function register59(server) {
39736
40028
  server.registerTool(
39737
40029
  "undo",
39738
40030
  {
@@ -39745,14 +40037,14 @@ function register58(server) {
39745
40037
  annotations: DESTRUCTIVE_ANNOTATIONS
39746
40038
  },
39747
40039
  async (params) => {
39748
- const result = await executeJsx(jsxCode54, params, { activate: true });
39749
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40040
+ const result = await executeJsx(jsxCode55, params, { activate: true });
40041
+ return formatToolResult(result);
39750
40042
  }
39751
40043
  );
39752
40044
  }
39753
40045
 
39754
40046
  // src/tools/modify/manage-datasets.ts
39755
- var jsxCode55 = `
40047
+ var jsxCode56 = `
39756
40048
  function parseCsvLine(line) {
39757
40049
  var result = [];
39758
40050
  var current = "";
@@ -40035,7 +40327,7 @@ if (preflight) {
40035
40327
  }
40036
40328
  }
40037
40329
  `;
40038
- function register59(server) {
40330
+ function register60(server) {
40039
40331
  server.registerTool(
40040
40332
  "manage_datasets",
40041
40333
  {
@@ -40061,14 +40353,14 @@ function register59(server) {
40061
40353
  annotations: WRITE_ANNOTATIONS
40062
40354
  },
40063
40355
  async (params) => {
40064
- const result = await executeJsx(jsxCode55, params, { activate: true });
40065
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40356
+ const result = await executeJsx(jsxCode56, params, { activate: true });
40357
+ return formatToolResult(result);
40066
40358
  }
40067
40359
  );
40068
40360
  }
40069
40361
 
40070
40362
  // src/tools/modify/place-symbol.ts
40071
- var jsxCode56 = `
40363
+ var jsxCode57 = `
40072
40364
  var preflight = preflightChecks();
40073
40365
  if (preflight) {
40074
40366
  writeResultFile(RESULT_PATH, preflight);
@@ -40123,7 +40415,7 @@ if (preflight) {
40123
40415
  }
40124
40416
  }
40125
40417
  `;
40126
- function register60(server) {
40418
+ function register61(server) {
40127
40419
  server.registerTool(
40128
40420
  "place_symbol",
40129
40421
  {
@@ -40140,14 +40432,14 @@ function register60(server) {
40140
40432
  annotations: WRITE_ANNOTATIONS
40141
40433
  },
40142
40434
  async (params) => {
40143
- const result = await executeJsx(jsxCode56, params, { activate: true });
40144
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40435
+ const result = await executeJsx(jsxCode57, params, { activate: true });
40436
+ return formatToolResult(result);
40145
40437
  }
40146
40438
  );
40147
40439
  }
40148
40440
 
40149
40441
  // src/tools/modify/create-path-text.ts
40150
- var jsxCode57 = `
40442
+ var jsxCode58 = `
40151
40443
  var preflight = preflightChecks();
40152
40444
  if (preflight) {
40153
40445
  writeResultFile(RESULT_PATH, preflight);
@@ -40199,7 +40491,7 @@ if (preflight) {
40199
40491
  }
40200
40492
  }
40201
40493
  `;
40202
- function register61(server) {
40494
+ function register62(server) {
40203
40495
  server.registerTool(
40204
40496
  "create_path_text",
40205
40497
  {
@@ -40218,14 +40510,14 @@ function register61(server) {
40218
40510
  annotations: WRITE_ANNOTATIONS
40219
40511
  },
40220
40512
  async (params) => {
40221
- const result = await executeJsx(jsxCode57, params, { activate: true });
40222
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40513
+ const result = await executeJsx(jsxCode58, params, { activate: true });
40514
+ return formatToolResult(result);
40223
40515
  }
40224
40516
  );
40225
40517
  }
40226
40518
 
40227
40519
  // src/tools/modify/select-objects.ts
40228
- var jsxCode58 = `
40520
+ var jsxCode59 = `
40229
40521
  var preflight = preflightChecks();
40230
40522
  if (preflight) {
40231
40523
  writeResultFile(RESULT_PATH, preflight);
@@ -40275,7 +40567,7 @@ if (preflight) {
40275
40567
  }
40276
40568
  }
40277
40569
  `;
40278
- function register62(server) {
40570
+ function register63(server) {
40279
40571
  server.registerTool(
40280
40572
  "select_objects",
40281
40573
  {
@@ -40289,14 +40581,14 @@ function register62(server) {
40289
40581
  annotations: WRITE_IDEMPOTENT_ANNOTATIONS
40290
40582
  },
40291
40583
  async (params) => {
40292
- const result = await executeJsx(jsxCode58, params, { activate: true });
40293
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40584
+ const result = await executeJsx(jsxCode59, params, { activate: true });
40585
+ return formatToolResult(result);
40294
40586
  }
40295
40587
  );
40296
40588
  }
40297
40589
 
40298
40590
  // src/tools/read/convert-coordinate.ts
40299
- var jsxCode59 = `
40591
+ var jsxCode60 = `
40300
40592
  var preflight = preflightChecks();
40301
40593
  if (preflight) {
40302
40594
  writeResultFile(RESULT_PATH, preflight);
@@ -40333,7 +40625,7 @@ if (preflight) {
40333
40625
  }
40334
40626
  }
40335
40627
  `;
40336
- function register63(server) {
40628
+ function register64(server) {
40337
40629
  server.registerTool(
40338
40630
  "convert_coordinate",
40339
40631
  {
@@ -40350,8 +40642,8 @@ function register63(server) {
40350
40642
  annotations: READ_ANNOTATIONS
40351
40643
  },
40352
40644
  async (params) => {
40353
- const result = await executeJsx(jsxCode59, params);
40354
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
40645
+ const result = await executeJsx(jsxCode60, params);
40646
+ return formatToolResult(result);
40355
40647
  }
40356
40648
  );
40357
40649
  }
@@ -40421,10 +40713,11 @@ function registerAllTools(server) {
40421
40713
  register61(server);
40422
40714
  register62(server);
40423
40715
  register63(server);
40716
+ register64(server);
40424
40717
  }
40425
40718
 
40426
40719
  // src/prompts/quick-layout.ts
40427
- function register64(server) {
40720
+ function register65(server) {
40428
40721
  server.registerPrompt(
40429
40722
  "quick-layout",
40430
40723
  {
@@ -40467,7 +40760,7 @@ Always respond in the user's language.`
40467
40760
  }
40468
40761
 
40469
40762
  // src/prompts/print-preflight-workflow.ts
40470
- function register65(server) {
40763
+ function register66(server) {
40471
40764
  server.registerPrompt(
40472
40765
  "print-preflight-workflow",
40473
40766
  {
@@ -40520,8 +40813,8 @@ Always respond in the user's language.`
40520
40813
 
40521
40814
  // src/prompts/registry.ts
40522
40815
  function registerAllPrompts(server) {
40523
- register64(server);
40524
40816
  register65(server);
40817
+ register66(server);
40525
40818
  }
40526
40819
 
40527
40820
  // src/server.ts