canicode 0.8.5 → 0.8.6

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
@@ -108,7 +108,7 @@ Or with a Figma API token (no Figma MCP needed):
108
108
  claude mcp add canicode -e FIGMA_TOKEN=figd_xxxxxxxxxxxxx -- npx -y -p canicode canicode-mcp
109
109
  ```
110
110
 
111
- For Cursor / Claude Desktop config, see [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md).
111
+ For Cursor / Claude Desktop config, see [`docs/REFERENCE.md`](docs/REFERENCE.md).
112
112
 
113
113
  **Figma MCP Rate Limits**
114
114
 
@@ -160,7 +160,7 @@ Posts analysis as a PR comment. Fails if score is below threshold. See [**canico
160
160
 
161
161
  > Ask any LLM *"Write a canicode custom rule that checks X"* — it can generate the JSON for you.
162
162
 
163
- See [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZATION.md) for the full guide, examples, and all available options.
163
+ See [`docs/REFERENCE.md`](docs/REFERENCE.md) for the full guide, examples, and all available options.
164
164
 
165
165
  ---
166
166
 
package/dist/cli/index.js CHANGED
@@ -1105,7 +1105,7 @@ async function loadFromApi(fileKey, nodeId, token) {
1105
1105
  }
1106
1106
 
1107
1107
  // package.json
1108
- var version = "0.8.5";
1108
+ var version = "0.8.6";
1109
1109
  var AnalysisNodeTypeSchema = z.enum([
1110
1110
  "DOCUMENT",
1111
1111
  "CANVAS",
@@ -4267,7 +4267,7 @@ EXAMPLE
4267
4267
  USAGE
4268
4268
  canicode analyze <url> --custom-rules ./my-rules.json
4269
4269
 
4270
- Full guide: docs/CUSTOMIZATION.md
4270
+ Full guide: docs/REFERENCE.md
4271
4271
  Examples: examples/custom-rules.json
4272
4272
 
4273
4273
  TIP: Ask any LLM "Write a canicode custom rule that checks X" with the
@@ -4302,16 +4302,61 @@ EXAMPLE
4302
4302
  USAGE
4303
4303
  canicode analyze <url> --config ./my-config.json
4304
4304
 
4305
- Full guide: docs/CUSTOMIZATION.md
4305
+ Full guide: docs/REFERENCE.md
4306
4306
  Examples: examples/config.json
4307
4307
  `.trimStart());
4308
4308
  }
4309
+ function printDocsVisualCompare() {
4310
+ console.log(`
4311
+ VISUAL COMPARE \u2014 Pixel-level comparison between Figma and AI-generated code
4312
+
4313
+ USAGE
4314
+ canicode visual-compare ./index.html --figma-url 'https://www.figma.com/design/ABC/File?node-id=1-234'
4315
+
4316
+ OPTIONS
4317
+ --figma-url <url> Figma URL with node-id (required)
4318
+ --token <token> Figma API token (or FIGMA_TOKEN env var)
4319
+ --output <dir> Output directory (default: /tmp/canicode-visual-compare)
4320
+ --width <px> Viewport width override (default: match Figma screenshot)
4321
+ --height <px> Viewport height override (default: match Figma screenshot)
4322
+
4323
+ OUTPUT FILES
4324
+ /tmp/canicode-visual-compare/
4325
+ figma.png Figma screenshot (scale=2)
4326
+ code.png Playwright render of your HTML
4327
+ diff.png Pixel diff (red = different pixels)
4328
+
4329
+ JSON OUTPUT (stdout)
4330
+ {
4331
+ "similarity": 87, // 0-100%
4332
+ "diffPixels": 1340,
4333
+ "totalPixels": 102400,
4334
+ "width": 800,
4335
+ "height": 600,
4336
+ "figmaScreenshot": "/tmp/.../figma.png",
4337
+ "codeScreenshot": "/tmp/.../code.png",
4338
+ "diff": "/tmp/.../diff.png"
4339
+ }
4340
+
4341
+ HOW IT WORKS
4342
+ 1. Fetches Figma screenshot via REST API (scale=2)
4343
+ 2. Reads screenshot dimensions
4344
+ 3. Renders your HTML with Playwright at the same viewport size
4345
+ 4. Compares pixel-by-pixel with pixelmatch (threshold: 0.1)
4346
+ 5. Returns similarity % and diff image
4347
+
4348
+ REQUIREMENTS
4349
+ npx playwright install chromium
4350
+ Figma API token with read access
4351
+ `.trimStart());
4352
+ }
4309
4353
  var DOCS_TOPICS = {
4310
4354
  setup: printDocsSetup,
4311
4355
  install: printDocsSetup,
4312
4356
  // alias
4313
4357
  rules: printDocsRules,
4314
- config: printDocsConfig
4358
+ config: printDocsConfig,
4359
+ "visual-compare": printDocsVisualCompare
4315
4360
  };
4316
4361
  function handleDocs(topic) {
4317
4362
  if (!topic) {
@@ -4323,7 +4368,7 @@ function handleDocs(topic) {
4323
4368
  handler();
4324
4369
  } else {
4325
4370
  console.error(`Unknown docs topic: ${topic}`);
4326
- console.error(`Available topics: setup, rules, config`);
4371
+ console.error(`Available topics: setup, rules, config, visual-compare`);
4327
4372
  process.exit(1);
4328
4373
  }
4329
4374
  }
@@ -5034,7 +5079,7 @@ cli.command("list-rules", "List all analysis rules with scores and severity").op
5034
5079
  process.exit(1);
5035
5080
  }
5036
5081
  });
5037
- cli.command("docs [topic]", "Show documentation (topics: setup, rules, config)").action((topic) => {
5082
+ cli.command("docs [topic]", "Show documentation (topics: setup, rules, config, visual-compare)").action((topic) => {
5038
5083
  handleDocs(topic);
5039
5084
  });
5040
5085
  cli.help((sections) => {