Implement file-library linking and validate the export/import round trip #205
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills#205
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Validate the
.penpotexport/import round trip against the live instance and close the gap it exposes: an imported library file is not automatically connected to consuming files, so this step also implements and validates the library-linking tools (penpot_link_library,penpot_unlink_library,penpot_list_libraries) that make imported components reachable — a prerequisite for component instancing in the next milestone.Background
Depends on: #203, #204
The round trip was proven during design validation — a file was exported, downloaded, and re-imported into a fresh project with the same frame/rect/text and the same colour + typography assets. What was also discovered is the gap:
has-file-librariesreturnedfalseandget-file-librariesreturned[]for a file in the same project as the imported library, so an imported library is not usable by a consumer until it is explicitly linked vialink-file-to-library.That matters immediately: the next milestone instances components from the imported library, and
data.componentson the consuming file will not include them without a link. Rather than discovering this mid-instancing, this step implements the linking tools and proves the whole path — import → link → component visible on the consumer → available to stage.Required environment:
PENPOT_URL,PENPOT_TOKEN, the scratch project, and a fresh throwaway project for the re-import half.Documentation Required
A separate process downloads these into the listed folders before this issue is implemented. Check the folders for the actual reference material before starting.
docs/reference/penpot-api/<PENPOT_URL>/api/main/doc/openapi.json— the exact parameters oflink-file-to-library,unlink-file-from-library,get-file-libraries,has-file-libraries, andimport-binfile/export-binfileon this instance.docs/reference/pi-coding-agent/anddocs/reference/typebox/details, and returning a refusal/error as a normal result.Implementation Details
Build: the linking tools
Create
extensions/penpot/src/tools/libraries.tsexposing:penpot_list_libraries— paramsfile_id(required). Returns whether the file has libraries (has-file-libraries) and which ones (get-file-libraries): id, name, and any other fields the command returns. Must not error when the file has none.penpot_link_library— paramsfile_id(required),library_file_id(required). Callslink-file-to-library, then verifies by re-readingget-file-librariesand confirming the library appears (do not trust the mutation's response). Idempotent: linking an already-linked library reports that rather than failing.penpot_unlink_library— paramsfile_id(required),library_file_id(required). Unlinks and verifies by re-reading; idempotent when not linked.All three are writes on the consumer file, so
penpot_link_library/penpot_unlink_librarymust pass the designated-target guard forfile_idbefore sending anything. Register the tools insrc/index.ts.Validate: the round trip and the link
penpot_list_librariesand confirm it reports no libraries for a file in the same project as the imported library — reproducing the gap.penpot_link_librarywith the imported library's file id, then re-runpenpot_list_librariesand confirm the library is now listed; verify the same in the Penpot UI's library panel.penpot_get_file(orpenpot_list_library) and confirm the library's assets/components are now reachable.penpot_get_fileon the consumer must expose the component(s) with their ids, andpenpot_list_librarymust resolve the component names the instancing step will use. If the components are still not reachable after linking, record exactly why and stop — the next milestone is blocked on this.Record in
extensions/penpot/findings.mdunder "Library import/export and linking": the artifact's contents (entry list), what survived the round trip and what did not, the exacthas-file-libraries/get-file-librariesresults before and after linking, and the command responses observed (including whether linking needed any additional parameter).Clean up the throwaway project afterwards only if it contains nothing but the re-imported file.
Acceptance Criteria
penpot_list_libraries,penpot_link_libraryandpenpot_unlink_libraryare implemented, registered, and unit-tested with a stubbed client.penpot_link_libraryandpenpot_unlink_libraryverify the change by re-readingget-file-libraries, and are idempotent.file_idoutside the designated-target allow-list, before sending any request.penpot_link_library, the consumer file lists the library, the Penpot UI shows it, and the library's components are reachable via the extension's read tools.extensions/penpot/findings.mdrecords the round-trip and linking evidence, including anything that did not survive the round trip.Test Plan
Manual, against the live instance:
Then in the Penpot UI: open the imported file (confirm contents), open the consumer file's library panel (confirm the connected library and its components).
pi-loop opened and merged a pull request for this issue: #238