Fix #18: populate layers and add execute_jsx tool#67
Open
lcdzyj wants to merge 1 commit into
Open
Conversation
…tool - Fix loonghao#18: get_active_document_info now returns layers, layer_sets, and channels by reading from PhotoshopApp document object instead of leaving them as empty arrays. - Add execute_jsx MCP tool for universal Photoshop JSX script execution, unlocking the full Photoshop API beyond the predefined tools. - Fix doJavaScript COM dispatch: comtypes requires all 3 arguments (script, None, 1) to work correctly. Single-argument calls trigger COM error -2147352567 on Photoshop CC2017+. - Add JSON.stringify polyfill for ExtendScript (ES3) since Photoshop's scripting engine lacks a native JSON object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three issues discovered during real-world testing:
1. Fix #18:
get_active_document_inforeturns empty layersThe original code had a TODO comment and never populated
layers,layer_sets, orchannels. Now reads them from the PhotoshopApp document object (artLayers, layerSets, channels).2. Add
execute_jsxuniversal toolNew MCP tool that executes arbitrary JSX scripts via
doJavaScript, unlocking the full Photoshop API beyond the 8 predefined tools. Follows the MCP + script + COM architecture pattern.3. Fix
doJavaScriptCOM dispatch errorcomtypesrequires all 3 arguments(script, None, 1)fordoJavaScript. Single-argument calls trigger COM error-2147352567on Photoshop CC2017+. Also injects aJSON.stringifypolyfill since Photoshop's ExtendScript (ES3) lacks a native JSON object.Changes
ps_adapter/action_manager.py— populate layers/layer_sets/channelsps_adapter/application.py— fix 3-arg doJavaScript + JSON polyfilltools/script_tools.py— new execute_jsx MCP toolTest plan
get_active_document_inforeturns layer names, visibility, opacityexecute_jsxruns simple scripts:'hello';,app.activeDocument.name;execute_jsxruns complex scripts withJSON.stringifyexecute_jsxcan create shapes, modify layers via JSX