workbuddy-layered-psd-bridge 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # WorkBuddy Layered PSD Bridge 1.1.0
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Create a real layered Photoshop PSD from a **structured poster plan** in WorkBuddy. Ardot is optional. The primary path needs only WorkBuddy and Windows desktop Photoshop on the same PC; WorkBuddy prepares Node for the Connector.
4
+
5
+ ## What this does
6
+
7
+ WorkBuddy plans the poster as separate text, vector shapes, image assets, and groups. The Connector snapshots the assets, checks the plan, and asks local Photoshop to create a PSD and JPEG preview from one document. The user can inspect the preview in WorkBuddy, request changes by layer ID, and generate a revised PSD without reuploading unchanged assets.
8
+
9
+ A single ImageGen poster or a WorkBuddy image-edit result is a bitmap, not a recoverable layer tree. The Connector rejects a one-image poster when the user asks for a fully layered PSD. To keep layers editable, design the poster as layers from the beginning and generate photographs/illustrations as independent assets.
10
+
11
+ ## Requirements
12
+
13
+ - Windows WorkBuddy 5.0+ and Adobe Photoshop 2020 (v21) or newer. Photoshop **26.8.1** is the version tested for RGB and CMYK builds. Other versions are checked on the target PC but require a local trial export.
14
+ - Node 20+ when running outside WorkBuddy. WorkBuddy's Connector `runtime.type: "node"` can provide it automatically.
15
+ - Enough RAM and disk for the chosen canvas. The backend checks dimensions, layer/asset counts, decoded image sizes, memory and disk estimates, and asset hashes before building. There is no single hardware minimum for every poster.
16
+ - Fonts used by editable text should be installed on the target PC. Substitution is reported; text overflow fails rather than silently shifting the design.
17
+
18
+ ## MCP workflow
19
+
20
+ 1. `photoshop_status` checks the target installation. Optional `progId` selects a particular registered Photoshop version, such as `Photoshop.Application.27`.
21
+ 2. `prepare_workbuddy_poster` receives `canvas`, bottom-to-top `layers`, and separate `imageAssets`; it returns a preparation ID immediately. It also supports `baseDraftId` plus restricted layer `edits` for later revisions.
22
+ 3. `get_poster_preparation` polls for a frozen `draftId` and SHA-256.
23
+ 4. `start_psd_export` creates a durable local Photoshop job; `get_psd_job` polls for a PSD/JPEG result and warnings.
24
+ 5. `get_poster_draft` provides bounded layer information for a revision without exposing local asset paths.
25
+
26
+ The older `prepare_ardot_canvas` and `get_ardot_preparation` route remains available for users who already have an accessible Ardot MCP node tree. It is not part of the default installation path.
27
+
28
+ ## Storage and recovery
29
+
30
+ Default drafts and final files are under `~/Documents/WorkBuddyLayeredPSD/work` and `~/Documents/WorkBuddyLayeredPSD/deliveries`. Use absolute `WORKBUDDY_PSD_DATA_DIR` and `WORKBUDDY_PSD_OUTPUT_DIR` environment variables to change them. The earlier `ZAOJIAN_PSD_DATA_DIR` and `ZAOJIAN_PSD_OUTPUT_DIR` names remain accepted for existing setups. The package does not assume any particular drive letter or creator workstation configuration.
31
+
32
+ Assets are copied into immutable snapshots. The bridge serializes Photoshop jobs so concurrent requests do not manipulate the same Photoshop instance. After a script timeout, it leaves `photoshop.lock` in the data directory because Photoshop might still be running the script. Close Photoshop and WorkBuddy, remove that lock, then restart. Incomplete drafts are cleared; completed draft caches are pruned after 30 days if no active job uses them. PSD/JPEG deliverables are not pruned.
33
+
34
+ HTTPS image imports are restricted to trusted hosts; local paths and MCP image bytes are supported. For a WorkBuddy generated image, use the local image file path or image data rather than assuming an undocumented remote URL is trusted.
35
+
36
+ ## Distribution
37
+
38
+ Publish `workbuddy-layered-psd-bridge@1.1.0` to npm **before** uploading the matching WorkBuddy Connector ZIP. The market ZIP contains metadata, `mcp.json`, icon, and a Skill; it does not itself contain this executable package. WorkBuddy's managed Node runtime allows other users to connect without installing Node manually.
39
+
40
+ The public WorkBuddy docs describe the built-in “设计创意” Ardot canvas but do not document a way for a third-party Connector to read its internal node tree directly. The direct WorkBuddy route therefore builds its **own explicit layer plan**. The Ardot route requires real MCP node data and has not been validated against a live account in this release.
41
+
42
+ References: [WorkBuddy Connector format](https://open.workbuddy.cn/docs/connector) · [WorkBuddy design mode](https://www.workbuddy.cn/docs/workbuddy/From-Beginner-to-Expert-Guide/Function-Description/Design-Idea) · [Ardot MCP](https://docs.ardot.tencent.com/ardot-mcp/features.html)
@@ -0,0 +1,41 @@
1
+ # Ardot snapshot adapter
2
+
3
+ `index.mjs` is a dependency-free Node ESM module. It converts an Ardot-like node tree into `zaojian.psd.manifest.v1` for the Photoshop backend. It never infers missing geometry, stack order, or editable text formatting.
4
+
5
+ ```js
6
+ import { normalizeArdotSnapshot } from './ardot_adapter/index.mjs';
7
+
8
+ const { manifest, warnings, statistics } = normalizeArdotSnapshot(snapshot, {
9
+ rootNodeId: 'canvas-id',
10
+ sourceOrder: 'bottom-to-top',
11
+ coordinateSpace: 'parent',
12
+ exportedAssets: {
13
+ 'image-node-id': { path: '/absolute/staging/photo.png', mediaType: 'image/png' },
14
+ 'complex-node-id': {
15
+ dataBase64: '...', mediaType: 'image/png', renderedNode: true,
16
+ },
17
+ },
18
+ assetDir: '/absolute/staging',
19
+ allowedAssetRoots: ['/absolute/staging'],
20
+ });
21
+ ```
22
+
23
+ The sample paths above are placeholders. The caller chooses a writable staging directory on the user's machine and passes that absolute path to the adapter and Photoshop backend.
24
+
25
+ ## Input
26
+
27
+ Accepted envelopes: one node object, `{node}`, `{root}`, `{nodes:[...]}`, or a single JSON text block in an MCP `content` result. `structuredContent`, `result`, and `data` wrappers are unwrapped. The synthetic fixture in `fixtures/synthetic-poster.json` is a **documented adapter example**, not a claim that Ardot always returns these exact fields.
28
+
29
+ Select one canvas/frame/group root. Each node needs a stable `id`, `type`, and bounds. `absoluteBoundingBox`, `absoluteBounds`, or `absoluteBox` is treated as document absolute. Otherwise specify `coordinateSpace:'parent'` or `'absolute'` for `bounds` or `x/y/width/height`. Canvas bounds determine PSD dimensions, and layer bounds become canvas absolute pixels. If all siblings have numeric `zIndex`, `stackIndex`, or `order`, those values determine bottom-to-top order; otherwise specify `sourceOrder:'bottom-to-top'` or `'top-to-bottom'`.
30
+
31
+ `exportedAssets` is keyed by Ardot **node ID**, not a separate asset ID. A value may contain a local absolute `path` or `dataBase64`; use PNG or JPEG. Local paths require `allowedAssetRoots`; base64 staging requires `assetDir`. Remote URLs are rejected until the connector downloads and validates them. `options.assets` is an alias for `options.exportedAssets`.
32
+
33
+ An unsupported node or style can use a **rendered export of that individual node** with `renderedNode:true`. The resulting PSD layer is an image and a `NODE_RASTERIZED` warning explains the loss of interior editability. Source image files must not be marked as rendered node exports. A single image covering the design is rejected as a flattened source.
34
+
35
+ Editable text needs font family, size, weight, alignment, line height, color, and real visible line breaks. For auto-wrapped text, provide `visibleLines`/`textLines` if the source value has no explicit newline. The backend uses those lines to form Photoshop line breaks. Without them the adapter rejects the node unless a rendered per-node export is provided. `allowApproximateText:true` is a deliberate opt-in for a potentially different wrap; public connector flows should leave it off.
36
+
37
+ Rotation requires unrotated design-frame bounds. The adapter accepts rotated leaf nodes only with `rotationBoundsUntransformed:true`, an explicit caller assertion. Rotated groups require a rendered per-node export and visual absolute bounds. Unsupported effects, masks, clipping, image crops, unequal corner radii, rich text runs, and other unrepresented style fields are rejected or rasterized per node.
38
+
39
+ Ardot's public MCP docs name `batch_read`, `capture_layout`, and `export_nodes` but do not provide a complete response JSON schema: https://docs.ardot.tencent.com/ardot-mcp/features.html. Once a real response is available, adapt its fields explicitly and add a fixture. Do not assume the synthetic field names are a stable Ardot API.
40
+
41
+ Run the adapter tests with `node --test ardot_adapter/test.mjs`. The tests stage tiny assets beside this module and clean them up.
@@ -0,0 +1,64 @@
1
+ {
2
+ "fileId": "synthetic-demo",
3
+ "nodes": [
4
+ {
5
+ "id": "canvas",
6
+ "name": "Sample poster",
7
+ "type": "CANVAS",
8
+ "absoluteBoundingBox": { "x": 200, "y": 300, "width": 1080, "height": 1350 },
9
+ "fill": "#FAF7F1",
10
+ "children": [
11
+ {
12
+ "id": "accent",
13
+ "name": "Accent",
14
+ "type": "RECTANGLE",
15
+ "zIndex": 0,
16
+ "absoluteBoundingBox": { "x": 280, "y": 380, "width": 920, "height": 150 },
17
+ "fill": { "type": "SOLID", "color": "#E6584B" },
18
+ "cornerRadius": 20
19
+ },
20
+ {
21
+ "id": "message",
22
+ "name": "Message group",
23
+ "type": "GROUP",
24
+ "zIndex": 1,
25
+ "absoluteBoundingBox": { "x": 280, "y": 650, "width": 900, "height": 500 },
26
+ "children": [
27
+ {
28
+ "id": "headline",
29
+ "name": "Headline",
30
+ "type": "TEXT",
31
+ "zIndex": 0,
32
+ "absoluteBoundingBox": { "x": 300, "y": 690, "width": 800, "height": 200 },
33
+ "text": "First line Second line",
34
+ "visibleLines": ["First line ", "Second line"],
35
+ "wrap": true,
36
+ "fontFamily": "Arial",
37
+ "fontSize": 64,
38
+ "fontWeight": 700,
39
+ "align": "center",
40
+ "lineHeightPx": 72,
41
+ "fill": "#121212"
42
+ },
43
+ {
44
+ "id": "dot",
45
+ "name": "Dot",
46
+ "type": "ELLIPSE",
47
+ "zIndex": 1,
48
+ "absoluteBoundingBox": { "x": 700, "y": 970, "width": 100, "height": 100 },
49
+ "fill": "#4466CC"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "id": "photo",
55
+ "name": "Photo",
56
+ "type": "IMAGE",
57
+ "zIndex": 2,
58
+ "absoluteBoundingBox": { "x": 350, "y": 1200, "width": 700, "height": 300 },
59
+ "fit": "cover"
60
+ }
61
+ ]
62
+ }
63
+ ]
64
+ }