Implement and run fetch-penpot-docs.mjs and commit the vendored Penpot reference #214
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#214
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
Implement
skills/penpot/scripts/fetch-penpot-docs.mjs: a one-command, version-pinned refresh of the skill's vendored Penpot reference — the instance's OpenAPI spec plus the relevantcommon/srcschemas — with deterministic output. Run it and commit the result underskills/penpot/docs/.Background
Depends on: #188
Penpot's RPC API is internal and unversioned and drifts between releases; the validated target is Penpot 2.17. Drift is real and already observed:
export-binfiletakesincludeLibraries/embedAssetsbooleans on 2.17 while later versions document atypeparameter. Vendoring heavily is the right call precisely because the version is controlled — refresh becomes a routine step of a Penpot upgrade instead of a re-learning exercise.Two sources, both needed:
<PENPOT_URL>/api/main/doc/openapi.json— ~1 MB, generated from Penpot's Clojure source, and the single highest-value artifact: it contains the command list, the change-type union, the shape variants and the layout enums. Note the URL carefully:/api/main/doc/openapi(without.json) serves a Swagger HTML page, so a wrong URL yields HTML that looks like a corrupted download.common/src/app/common/typesschemas from the Penpot repo at the tag matching the instance — the source of truth for field-level detail the spec only sketches:file,page,pages_list,shape,shape_tree,path,text,typography,typographies_list,color,component,components_list,fills,stroke,grid,token,tokens_lib,variant,library,objects_map.Determinism matters because the "re-run produces the committed bytes" check is how the vendored copy is kept honest: a diffable refresh means a Penpot upgrade produces a reviewable PR rather than an opaque blob dump.
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 spec this script downloads; open it once by hand to confirm the URL returns JSON (not the Swagger UI page) and to note the top-level structure that will be written to disk.PENPOT_URLhas no/apisuffix.Penpot source (pinned tag)
raw.githubusercontent.comURL shape the script should construct for each schema file.docs/reference/nodejs/mkdirSync/writeFileSync), plus reading a file back for the idempotency check.fetchused for both sources (no dependency).process.env, so the script fails loudly in a pipeline.scripts/local-install.test.mjsfollows, if a test is added for the script's pure helpers.Pi package conventions
docs/directory is packaged, so the vendored files ship with the skill.Implementation Details
Create
skills/penpot/scripts/fetch-penpot-docs.mjs(plain ESM.mjs, matchingscripts/local-install.mjs's style; no dependencies):Configuration
PENPOT_URL(normalise a trailing/or/api, reusing the same rule asextensions/penpot/src/env.ts— duplicate the small helper rather than importing TS from a.mjsscript, or import it if Node's type stripping makes that clean).PENPOT_TOKENoptional: send it when present (so a private instance works), and warn if absent.PENPOT_VERSIONenv override for the schema tag, defaulting to the pinned version recorded in the script (start at2.17.2, the newest 2.17 tag). Verify the tag exists with a HEAD/GET before downloading, and fail with a clear message naming the tag if not.--version <tag>/--out <dir>CLI flags.Fetch, in order, into
skills/penpot/docs/openapi.json— from the instance. If the response is HTML or the content type is not JSON, fail with the URL and a hint about the.jsonsuffix (this is the documented trap).schema/<file>.cljc— one file per schema in the list above, fromraw.githubusercontent.com/penpot/penpot/<tag>/common/src/app/common/types/<file>at the pinned tag.VERSION— a small text file recording: the Penpot version/tag, the instance host, the UTC date of the fetch, and the OpenAPI spec's own version/info fields if present.Determinism
openapi.json(write the parsed-and-re-serialised JSON with sorted keys if the raw bytes prove unstable, and document the choice). TheVERSIONfile is the only place a date appears, and it must be excluded from the byte-comparison check.Run it and commit the output, then add a short pointer index in
skills/penpot/SKILL.md— a "Reference" section listingdocs/openapi.json,docs/schema/*.cljcanddocs/VERSIONwith one line on what each is for. (The rest ofSKILL.mdis written in the next step; add only this section and keep the file valid.)Document the upgrade path: one short paragraph in the script's header comment and in
skills/penpot/docs/README.md— how to bump the pin on a Penpot upgrade (find the running version, update the pin, re-run, review the diff).Acceptance Criteria
skills/penpot/scripts/fetch-penpot-docs.mjsruns with no third-party dependency and writesskills/penpot/docs/openapi.json,skills/penpot/docs/schema/*.cljcandskills/penpot/docs/VERSION..json-suffix trap.docs/VERSION(proven by deletingdocs/, re-running, and diffing).skills/penpot/docs/README.mddocuments what the vendored files are and how to refresh them on a Penpot upgrade.skills/penpot/SKILL.mdhas a "Reference" section pointing at the vendored files, and the file remains valid skill frontmatter-wise.docs/VERSION.Test Plan
Then confirm in pi that
/skillsstill listspenpotand that the vendored files are present in the installed package.pi-loop opened and merged a pull request for this issue: #247