Implement the penpot_list_projects tool (teams and projects) with unit tests #190
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#190
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_list_projectstool: list the token user's teams (with each team's enabled features and the caller's permissions) and their projects. Projects are the container the extension later creates design files in, so this is the first read primitive and the preflight for every write path.Background
Depends on: #188
Read-only. Confirmed on Penpot 2.17 against a live instance:
get-teamstakes no parameters and returns the teams the caller belongs to, each carrying its enabledfeatures(e.g.layout/grid,design-tokens/v1) and the caller'spermissionson that team.get-projectsrequires ateamId— it errors without one. There is no "list all projects" call, so the tool must fan out over teams (or over a single team when the caller names one).The team
features/permissionsdata is directly useful later: the write path needs to know whether the caller can create files in a given team, and whether layout support is enabled.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 authoritative list of commands and parameters for this instance; confirmget-teams(no params) andget-projects(requiresteamId) before implementing.Authorization: Token <token>,/api/rpc/command/<command>).docs/reference/pi-coding-agent/pi.registerToolshape and how a tool returns text plus structureddetails.docs/reference/typebox/Type.Object,Type.Optional,Type.String, andType.Static<typeof T>for inferring the parameter type.Implementation Details
Create
extensions/penpot/src/tools/projects.tsexporting the tool definition, and register it inextensions/penpot/src/index.tsalongsidepenpot_whoami.Parameters:
team_id(string, optional) — when provided, skipget-teamsand list only that team's projects.Behaviour:
get-teams(no parameters) whenteam_idis absent; otherwise use the single given team id.GET get-projectswith the requiredteamIdquery/body parameter — exactly as the spec requires. UsePromise.allbut bound concurrency if the team count is large (a simple sequential loop is acceptable for a personal instance; do not fire an unbounded fan-out).features, the caller'spermissions, and each project name (id). Surface the team id prominently — the caller needs it to name a target project.detailscarries the structured shape:{ teams: [{ id, name, features, permissions, projects: [{ id, name }] }] }.get-projectscall fails must not abort the whole listing: record the error against that team and continue, reporting it in the text output.Keep the parameter schema permissive and additive (future steps may add filters) but do not add parameters that are not used.
Acceptance Criteria
penpot_list_projectsis registered and callable.team_id, it callsget-teamsand thenget-projectsfor every team, passing a realteamId.team_id, it callsget-projectsonce for that team and does not callget-teams.detailscontains the structured teams/projects shape.Test Plan
Live check (requires
PENPOT_URL/PENPOT_TOKEN):penpot_list_projectswith no arguments and confirm the teams/projects match the Penpot UI sidebar.team_ids and confirm only that team is listed.get-projects-without-teamIdfailure mode is avoided (no validation error from the server).pi-loop opened and merged a pull request for this issue: #223