Repository navigation
feat: read comment threads with figma-cli comments (opt-in REST, the Plugin API can't) - #1
Closed
Konstantinos019 wants to merge 1 commit into
Closed
Konstantinos019 wants to merge 1 commit into
Konstantinos019 wants to merge 1 commit into
Conversation
The Plugin API cannot see comments, so `comments list` reads them from the REST API (GET /v1/files/:key/comments) with a personal access token, then asks the plugin to resolve each pin: the REST pin is usually the outermost frame plus an offset, so the offset is walked down to the deepest visible layer under it and shown as "screen › layer". - `comments list [--file <key|url>] [--node <id>] [--all] [--json]` - `comments token set|clear|status`: the token comes from FIGMA_ACCESS_TOKEN / FIGMA_TOKEN or the OS credential store, and is never printed. - plugin manifest: `enablePrivatePluginApi`, so `figma.fileKey` is readable and --file is only needed when it is not. Works in any connection mode; without a connection it still lists the threads (node ids instead of layer names) when --file is given. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
Superseded by silships#55. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Sil, thanks for figma-cli. We use it every day in Safe Mode to build and audit screens from code, and it has held up really well.
The problem
Design review on our side happens in Figma comments. An agent driving figma-cli had no way to see them: the Plugin API exposes annotations, stickies and layers, but not comment threads, and that is true in every connection mode (Yolo, Browser and Safe). We checked the offline
figma-cli apiindex (no comment interface), the command list, and this repo's issues and PRs (nothing on comments), so as far as we can tell the CLI can't reach them today.The only way to read comments is Figma's REST API, which is why this PR uses a personal access token. We know "no token needed" is a core point of figma-cli, so the change is strictly opt-in: nothing else in the CLI touches the token, and without one nothing is sent anywhere.
What it adds
--fileis given: it still lists the threads, with node ids instead of layer names.Security
credentials.jshelpers (saveKey/getKey/promptKeySecure/maskKey), the same way plugin keys are handled.FIGMA_ACCESS_TOKENin the environment also works.api.figma.com, only whencomments listruns, and the only scopes needed are File content: Read and Comments: Read.SECURITY.md's "No Figma API key is involved" line is updated to describe this one exception honestly, and the README gets a short "The one exception: reading comments" section next to the MCP comparison.One thing to check with you
plugin/manifest.jsongets"enablePrivatePluginApi": trueso thatfigma.fileKeyis readable in Safe Mode, andcomments listcan find the open file on its own. If you'd rather not add that flag, it can go:--filecovers the same case.Tests
tests/comments.test.jscovers the pure helpers (file-key parsing, threading, pins, labels, the generated plugin code).npm test: 555 passing. Also tried end to end in Safe Mode against a real file with ten comment threads.If you'd prefer this outside core (say, as an optional plugin under
plugins/), or with different naming, I'm happy to rework it.🤖 Generated with Claude Code