Implement the penpot_whoami tool and wire the extension entry point #189
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#189
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 the
penpot_whoamitool and wire it into the extension entry point — the first callable penpot tool. It returns the authenticated user's profile, proves the auth path end to end, and gives a clean, actionable failure whenPENPOT_URL/PENPOT_TOKENare missing or wrong.Background
Depends on: #188
This is the milestone's proof-of-life step: a single no-parameter command (
get-profile) called through the shared client. On Penpot 2.17,get-profileandget-teamsneed no parameters — calling them is the cheapest way to confirm the token, the base URL and the header scheme all work.This step also establishes the tool-registration pattern every later penpot tool copies:
pi.registerTool({...})call per tool, kept in a module that exports the tool definition, withextensions/penpot/src/index.tsdoing the registration (seeextensions/victorialogs/index.tsfor the exact shape);additionalProperties: falseif the API supports it);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/pi-coding-agent/pi.registerToolsignature: thename,description,parametersandexecutefields, and how tool results are returned to the model.docs/reference/typebox/Type.Object/Type.Optionaland static type inference; the parameter schema for this tool is empty, but the pattern must match the sibling extensions.docs/reference/penpot-api/get-profilecurl example: confirms the command name, theGETverb and theAuthorization: Token <token>header.<PENPOT_URL>/api/main/doc/openapi.json— confirmget-profiletakes no required parameters on this instance before finalising the empty schema.Implementation Details
extensions/penpot/src/tools/whoami.ts(create asrc/tools/directory — later milestones addframe.ts,rect.ts,text.ts,svg.ts,library.ts,commit.ts, etc. there):penpotRequest("get-profile")through the shared client.detailsobject with the raw profile fields — do not dump the entire profile blob into the text channel.src/errors.ts. For aconfigerror, the message must tell the user exactly what to set (PENPOT_URLwithout/api,PENPOT_TOKENfrom Penpot account settings).extensions/penpot/src/index.ts— register the tool:Keep everything lazy: no
resolveConfig()call and no network access at load time.extensions/penpot/README.md— add a short "Tools" section listingpenpot_whoamiand a "Configuration" section documentingPENPOT_URL(base URL, no/api) andPENPOT_TOKEN. The full reference (all tools, safety model) is completed in a later milestone; do not write placeholder tables for tools that do not exist yet.Write a co-located unit test for the tool's success and failure formatting with a stubbed client.
Acceptance Criteria
penpot_whoamiis registered byextensions/penpot/src/index.tsand callable in pi.get-profilecommand throughsrc/client.ts.PENPOT_URLorPENPOT_TOKEN, the tool returns an actionable config message naming the variable and its expected value — no stack trace.extensions/penpot/README.mddocuments both environment variables.Test Plan
Unit tests (stubbed client, no credentials):
Live validation against the scratch project's instance (requires
PENPOT_URL/PENPOT_TOKEN):/reload, then callpenpot_whoami→ expect the token owner's name/email.PENPOT_TOKENand call again → expect an actionable config message, not a crash.PENPOT_TOKENto a deliberately invalid value and call again → expect a readable auth error containing no raw Transit payload.Record the outcome (pass/fail per case) in the milestone validation issue — this milestone does not advance on an unvalidated auth path.
pi-loop opened and merged a pull request for this issue: #222