canicode 0.10.5 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,6 +26,8 @@
26
26
 
27
27
  AI can turn Figma designs into code — but the quality depends heavily on **how the design is structured**. CanICode runs a **roundtrip** over your Figma file: analyze the design, surface the gotchas it can't answer on its own, apply fixes back to Figma, re-analyze until the design is clean, then hand off to Figma's `figma-implement-design` skill for code generation. canicode does the design augmentation; code generation lives downstream (see [ADR-013](.claude/docs/ADR.md) for the scope boundary).
28
28
 
29
+ ![Role diagram: gotchas (memo) vs roundtrip (canvas) vs code-gen](docs/images/roles.svg)
30
+
29
31
  ### How the analyzer knows what to fix
30
32
 
31
33
  - **16 rules** across 6 categories: Pixel Critical, Responsive Critical, Code Quality, Token Management, Interaction, Semantic
@@ -38,25 +40,30 @@ Rule scores aren't guesswork. The calibration pipeline converts real Figma desig
38
40
 
39
41
  ## The Roundtrip Workflow
40
42
 
41
- 1. **Analyze** run the 16 rules against the Figma design and grade it.
43
+ **Skills:** **`canicode-gotchas`** = survey answers saved **locally** in SKILL.md only (memo). **`canicode-roundtrip`** = same analysis path plus **writes to Figma** (annotations / properties). Pick gotchas for capture-only; pick roundtrip when the design file should change.
44
+
45
+ 1. **Analyze** — run the 16 rules against the Figma design (report includes grade).
42
46
  2. **Surface gotchas** — the analyzer emits questions for design information it can't infer (missing states, unclear variants, responsive intent).
43
47
  3. **Apply fixes to Figma** — the `/canicode-roundtrip` skill writes answers back via `use_figma`. Each write shows up in the summary with one of three outcome markers:
44
48
  - ✅ **scene write succeeded** — the property was written directly to the scene node or instance override.
45
49
  - 📝 **annotated the scene node** — the skill left a structured annotation instead of writing the property. This is the [ADR-012](.claude/docs/ADR.md) default for instance-child layout writes, because propagating a property to the component definition (and therefore every instance of it) is almost never what the user wants. **A summary full of 📝 markers is correct behavior, not failure.**
46
50
  - 🌐 **definition write propagated** — the property was written to the component definition and every instance inherited it. Only happens when the user opted in up front with `allowDefinitionWrite`.
47
- 4. **Re-analyze** — verify the gotchas were addressed (grade movement is a side-effect). Repeat step 2 if new gotchas surface.
51
+ 4. **Re-analyze** — verify gotchas were captured (annotations / acks); repeat step 2 if new gotchas surface.
48
52
  5. **Hand off** to `figma-implement-design` — canicode's scope ends here ([ADR-013](.claude/docs/ADR.md)). Figma's official code-generation skill takes the now-clean design and produces code.
49
53
 
50
54
  ---
51
55
 
52
56
  ## Getting Started
53
57
 
58
+ > **Token safety:** Do **not** paste your Figma token into Claude, Cursor, or other agent chats — session logs can retain it. Use `FIGMA_TOKEN=figd_… npx canicode init`, or run `npx canicode init` and enter the token **only** at the CLI prompt.
59
+
54
60
  **Quickest way:** **[Open the web app](https://let-sunny.github.io/canicode/)** — paste a Figma URL, get a report.
55
61
 
56
62
  **Design-to-code in Claude Code (recommended):**
57
63
 
58
64
  ```bash
59
65
  # 1. Save your Figma token AND install the /canicode-roundtrip skill
66
+ # (never paste the token into chat — env var or CLI prompt only)
60
67
  npx canicode init --token figd_xxxxxxxxxxxxx
61
68
 
62
69
  # 2. Run the roundtrip on a Figma URL
@@ -65,6 +72,12 @@ npx canicode init --token figd_xxxxxxxxxxxxx
65
72
 
66
73
  > **Prerequisite:** the roundtrip skill calls the Figma MCP server to read and write the design. Install it once with `claude mcp add -s project -t http figma https://mcp.figma.com/mcp` — see the **MCP Server** install section below.
67
74
 
75
+ **CanICode in Cursor (no Claude Code required):**
76
+
77
+ 1. Add **canicode** and **Figma** MCPs — [Cursor MCP](docs/CUSTOMIZATION.md#cursor-mcp-canicode) for `npx` → `canicode-mcp` (use **`.cursor/mcp.json`** or **`~/.cursor/mcp.json`** in Cursor, not repo-root `.mcp.json`; [why](docs/CUSTOMIZATION.md#which-mcp-file-affects-which-host)); Figma MCP is required for **`use_figma`** if you run **roundtrip** (design writes), not for analyze-only.
78
+ 2. `npx canicode init --token figd_xxxxxxxxxxxxx --cursor-skills` (use `FIGMA_TOKEN=…` or the CLI prompt — not chat) — installs the same three skills as Claude under `.cursor/skills/` (`canicode`, `canicode-gotchas`, `canicode-roundtrip` + `helpers.js`) plus the shared `.claude/skills/canicode-gotchas/SKILL.md` answer file when needed.
79
+ 3. In Agent chat, @-mention **canicode-gotchas** (survey) or **canicode-roundtrip** (full roundtrip) and pass a Figma URL — same tool names and JSON as Claude Code (`gotcha-survey`, `analyze`, etc.).
80
+
68
81
  **If you only want analysis (no writes back to Figma):**
69
82
 
70
83
  ```bash
@@ -75,6 +88,8 @@ npx canicode analyze "https://www.figma.com/design/ABC123/MyDesign?node-id=1-234
75
88
  claude mcp add canicode -- npx --yes --package=canicode canicode-mcp
76
89
  ```
77
90
 
91
+ Restart Claude Code or reload MCP (Cursor) so canicode tools (`analyze`, `gotcha-survey`, …) load — same cold-session requirement as the Figma MCP (#433).
92
+
78
93
  <details>
79
94
  <summary><strong>All channels</strong></summary>
80
95
 
@@ -114,7 +129,7 @@ Each row below is a **complete** install. Don't run more than one — they cover
114
129
  | If you use… | Install |
115
130
  |-------------|---------|
116
131
  | **Claude Code** (recommended for the roundtrip workflow) | `npx canicode init --token figd_xxxxxxxxxxxxx` — saves the token AND drops `/canicode`, `/canicode-gotchas`, `/canicode-roundtrip` skills into `./.claude/skills/`. The skills already know how to call canicode via `npx canicode …`, no MCP install needed. |
117
- | **Cursor / Claude Desktop / other MCP host** | `claude mcp add canicode -- npx --yes --package=canicode canicode-mcp` registers the MCP server. |
132
+ | **Cursor / Claude Desktop / other MCP host** | Add canicode to the host’s MCP config — see [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md#cursor-mcp-canicode). Example (Cursor project file): `npx` + `canicode-mcp` via `--package=canicode`. |
118
133
  | **Just the CLI** (CI, scripts) | Nothing. `npx canicode analyze "<figma-url>"` works directly. Run `canicode init --token …` once if you want the token persisted to `~/.canicode/config.json`. |
119
134
 
120
135
  > **Get your token:** Figma → Settings → Security → Personal access tokens → Generate new token
@@ -125,6 +140,7 @@ Each row below is a **complete** install. Don't run more than one — they cover
125
140
  <summary><strong>Claude Code Skills</strong> — install details</summary>
126
141
 
127
142
  ```bash
143
+ # Token: env or CLI prompt only — do not paste into agent chat
128
144
  npx canicode init --token figd_xxxxxxxxxxxxx
129
145
  ```
130
146
 
@@ -147,13 +163,15 @@ Flags: `--global` installs into `~/.claude/skills/` instead. `--no-skills` skips
147
163
  claude mcp add canicode -- npx --yes --package=canicode canicode-mcp
148
164
  ```
149
165
 
166
+ Restart Claude Code or reload MCP (Cursor) so canicode MCP tools appear in a fresh session (#433).
167
+
150
168
  Then ask: *"Analyze this Figma design: https://www.figma.com/design/..."*
151
169
 
152
170
  canicode's rule engine analyzes the design data — the AI assistant just orchestrates the calls. The MCP server reads `FIGMA_TOKEN` from `~/.canicode/config.json` (set via `canicode init --token …`) or from the host's environment, so passing `-e FIGMA_TOKEN=…` to `claude mcp add` is **not** required and the current parser rejects it anyway (#364).
153
171
 
154
172
  If you genuinely need a per-server token without using `canicode init`, export it on the calling shell instead: `export FIGMA_TOKEN=figd_xxxxxxxxxxxxx`.
155
173
 
156
- For Cursor / Claude Desktop config, see [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md).
174
+ For Cursor / Claude Desktop config, see [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md) — especially [Cursor MCP (canicode)](docs/CUSTOMIZATION.md#cursor-mcp-canicode) and the **Manual test checklist (#407)** for verifying `gotcha-survey` end-to-end.
157
175
 
158
176
  </details>
159
177
 
@@ -200,6 +218,7 @@ Posts analysis as a PR comment. Fails if score is below threshold. See [**canico
200
218
  |------|-----|
201
219
  | **Presets** | `--preset relaxed \| dev-friendly \| ai-ready \| strict` |
202
220
  | **Config overrides** | `--config ./config.json` — adjust scores, severity, exclude nodes |
221
+ | **Analysis scope** | `--scope page \| component` — override auto-detection when a `COMPONENT`-rooted design should be analyzed as a page (or vice versa) |
203
222
 
204
223
  See [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md) for the full guide, examples, and all available options.
205
224