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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { GetFileResponse, Node } from '@figma/rest-api-spec';
3
3
 
4
- var version = "0.10.5";
4
+ var version = "0.11.1";
5
5
 
6
6
  declare const SeveritySchema: z.ZodEnum<{
7
7
  blocking: "blocking";
@@ -13,17 +13,40 @@ type Severity = z.infer<typeof SeveritySchema>;
13
13
  declare const SEVERITY_WEIGHT: Record<Severity, number>;
14
14
  declare const SEVERITY_LABELS: Record<Severity, string>;
15
15
 
16
- declare const CategorySchema: z.ZodEnum<{
17
- "pixel-critical": "pixel-critical";
18
- "responsive-critical": "responsive-critical";
19
- "code-quality": "code-quality";
20
- "token-management": "token-management";
21
- semantic: "semantic";
22
- interaction: "interaction";
16
+ /**
17
+ * #402 shared output-channel vocabulary.
18
+ * Detection stays rule-based; output channel and persistence intent vary by
19
+ * consumer payload (score/transient vs annotation/durable).
20
+ */
21
+ declare const DetectionSchema: z.ZodLiteral<"rule-based">;
22
+ declare const OutputChannelSchema: z.ZodEnum<{
23
+ score: "score";
24
+ annotation: "annotation";
23
25
  }>;
24
- type Category = z.infer<typeof CategorySchema>;
25
- declare const CATEGORIES: ("pixel-critical" | "responsive-critical" | "code-quality" | "token-management" | "semantic" | "interaction")[];
26
- declare const CATEGORY_LABELS: Record<Category, string>;
26
+ declare const PersistenceIntentSchema: z.ZodEnum<{
27
+ transient: "transient";
28
+ durable: "durable";
29
+ }>;
30
+ type Detection = z.infer<typeof DetectionSchema>;
31
+ type OutputChannel = z.infer<typeof OutputChannelSchema>;
32
+ type PersistenceIntent = z.infer<typeof PersistenceIntentSchema>;
33
+ /**
34
+ * #406 rule purpose classification.
35
+ * - `violation`: score-primary. Node is violating a best-practice expectation;
36
+ * fixing the violation removes the rule fire. Gotcha question is secondary
37
+ * context about how to resolve the violation.
38
+ * - `info-collection`: annotation-primary. Node is not necessarily "wrong,"
39
+ * but implementation-critical context is absent from Figma (e.g. click
40
+ * target, interaction states). Gotcha question is the primary output;
41
+ * score impact is intentionally minimal (typically -1 or 0).
42
+ *
43
+ * Detection stays `rule-based` in both cases — see ADR-017.
44
+ */
45
+ declare const RulePurposeSchema: z.ZodEnum<{
46
+ violation: "violation";
47
+ "info-collection": "info-collection";
48
+ }>;
49
+ type RulePurpose = z.infer<typeof RulePurposeSchema>;
27
50
 
28
51
  /**
29
52
  * Figma node types required for analysis
@@ -308,6 +331,51 @@ declare const AnalysisFileSchema: z.ZodObject<{
308
331
  }, z.core.$strip>;
309
332
  type AnalysisFile = z.infer<typeof AnalysisFileSchema>;
310
333
 
334
+ /**
335
+ * #404: Analysis scope — what the user is asking canicode to reason about.
336
+ *
337
+ * - `page`: full screen / section / layout. Container frames are
338
+ * responsible for bounds; repetition detection is meaningful; rules
339
+ * that assume "this is a self-contained screen" apply.
340
+ * - `component`: standalone reusable UI unit (COMPONENT / COMPONENT_SET
341
+ * / INSTANCE analyzed in isolation). Root FILL is the design contract
342
+ * rather than a missing bound; repetition detection is generally a
343
+ * false signal because a component is itself the unit of reuse.
344
+ *
345
+ * The enum is intentionally two-valued; multi-scope analysis (analyzing
346
+ * a page and its inner components in one run) is explicitly out of scope
347
+ * per the issue. Each rule decides how (or whether) to switch on `scope`;
348
+ * this PR only carries the context. Rule-level consumption lands in
349
+ * follow-up PRs (e.g. #403 for `missing-size-constraint`).
350
+ */
351
+ declare const AnalysisScopeSchema: z.ZodEnum<{
352
+ page: "page";
353
+ component: "component";
354
+ }>;
355
+ type AnalysisScope = z.infer<typeof AnalysisScopeSchema>;
356
+ /**
357
+ * Deterministically detect analysis scope from the root node type. Returns
358
+ * `"component"` for `COMPONENT` / `COMPONENT_SET` / `INSTANCE` roots, and
359
+ * `"page"` for everything else.
360
+ *
361
+ * The CLI / MCP layer may override this with an explicit `scope` flag when
362
+ * the user knows the heuristic mis-detects (e.g. analyzing a FRAME that
363
+ * ships as a standalone design-system example rather than a screen).
364
+ */
365
+ declare function detectAnalysisScope(rootNode: AnalysisNode): AnalysisScope;
366
+
367
+ declare const CategorySchema: z.ZodEnum<{
368
+ "pixel-critical": "pixel-critical";
369
+ "responsive-critical": "responsive-critical";
370
+ "code-quality": "code-quality";
371
+ "token-management": "token-management";
372
+ semantic: "semantic";
373
+ interaction: "interaction";
374
+ }>;
375
+ type Category = z.infer<typeof CategorySchema>;
376
+ declare const CATEGORIES: ("pixel-critical" | "responsive-critical" | "code-quality" | "token-management" | "semantic" | "interaction")[];
377
+ declare const CATEGORY_LABELS: Record<Category, string>;
378
+
311
379
  /**
312
380
  * Rule definition - static metadata (does not change)
313
381
  */
@@ -359,6 +427,28 @@ interface RuleContext {
359
427
  siblings?: AnalysisNode[] | undefined;
360
428
  /** Per-analysis shared state. Created fresh for each analysis run, eliminating module-level mutable state. */
361
429
  analysisState: Map<string, unknown>;
430
+ /**
431
+ * #404: Scope of the analysis root (`page` vs `component`). Rules use
432
+ * this to decide whether expectations like "container must define
433
+ * bounds" or "repetition should become a component" apply. Constant for
434
+ * all nodes in a single analysis — whether the CURRENT node happens to
435
+ * be a `COMPONENT` descendant of a page root is already signalled by
436
+ * `componentDepth`, not by re-deriving scope per node.
437
+ */
438
+ scope: AnalysisScope;
439
+ /**
440
+ * #403: Figma node type of the analysis root, captured once in
441
+ * `RuleEngine.analyze`. This is an *axis orthogonal to* `scope`:
442
+ * `scope === "component"` does not tell a rule whether the root is a
443
+ * `COMPONENT`/`COMPONENT_SET` (component being audited) or an
444
+ * `INSTANCE` (component being used, possibly with overrides). The
445
+ * `missing-size-constraint` redesign needs that distinction so the
446
+ * gotcha question can ask the right thing — "intentionally
447
+ * non-responsive?" vs "override intended? original may be FILL". The
448
+ * value is the raw Figma node type string (no new enum) so it stays in
449
+ * sync with `AnalysisNode.type` without a translation layer.
450
+ */
451
+ rootNodeType: string;
362
452
  }
363
453
  /**
364
454
  * Get or initialize per-analysis state for a rule.
@@ -522,6 +612,10 @@ declare const McpAnalyzeResponseSchema: z.ZodObject<{
522
612
  fileName: z.ZodString;
523
613
  nodeCount: z.ZodNumber;
524
614
  maxDepth: z.ZodNumber;
615
+ scope: z.ZodEnum<{
616
+ page: "page";
617
+ component: "component";
618
+ }>;
525
619
  issueCount: z.ZodNumber;
526
620
  isReadyForCodeGen: z.ZodBoolean;
527
621
  blockingIssueCount: z.ZodNumber;
@@ -577,6 +671,17 @@ declare const McpAnalyzeResponseSchema: z.ZodObject<{
577
671
  issuesByRule: z.ZodRecord<z.ZodString, z.ZodNumber>;
578
672
  issues: z.ZodArray<z.ZodObject<{
579
673
  ruleId: z.ZodString;
674
+ detection: z.ZodLiteral<"rule-based">;
675
+ outputChannel: z.ZodEnum<{
676
+ score: "score";
677
+ }>;
678
+ persistenceIntent: z.ZodEnum<{
679
+ transient: "transient";
680
+ }>;
681
+ purpose: z.ZodEnum<{
682
+ violation: "violation";
683
+ "info-collection": "info-collection";
684
+ }>;
580
685
  subType: z.ZodOptional<z.ZodString>;
581
686
  severity: z.ZodEnum<{
582
687
  blocking: "blocking";
@@ -606,9 +711,9 @@ type InstanceContext = z.infer<typeof InstanceContextSchema>;
606
711
  * declared as a Zod enum here so MCP responses validate end-to-end.
607
712
  */
608
713
  declare const RuleApplyStrategySchema: z.ZodEnum<{
714
+ annotation: "annotation";
609
715
  "property-mod": "property-mod";
610
716
  "structural-mod": "structural-mod";
611
- annotation: "annotation";
612
717
  "auto-fix": "auto-fix";
613
718
  }>;
614
719
  type RuleApplyStrategy = z.infer<typeof RuleApplyStrategySchema>;
@@ -620,10 +725,33 @@ type RuleApplyStrategy = z.infer<typeof RuleApplyStrategySchema>;
620
725
  declare const AnnotationPropertySchema: z.ZodObject<{
621
726
  type: z.ZodString;
622
727
  }, z.core.$strip>;
728
+ /**
729
+ * #402: Gotcha output is generated by a rule-based detection pass but flows
730
+ * to the annotation channel (not the score channel). Answers are durable
731
+ * context intended to survive beyond a single re-analysis cycle.
732
+ */
733
+ declare const GotchaDetectionSchema: z.ZodLiteral<"rule-based">;
734
+ declare const GotchaOutputChannelSchema: z.ZodEnum<{
735
+ annotation: "annotation";
736
+ }>;
737
+ declare const GotchaPersistenceIntentSchema: z.ZodEnum<{
738
+ durable: "durable";
739
+ }>;
623
740
  declare const GotchaSurveyQuestionSchema: z.ZodObject<{
624
741
  nodeId: z.ZodString;
625
742
  nodeName: z.ZodString;
626
743
  ruleId: z.ZodString;
744
+ detection: z.ZodLiteral<"rule-based">;
745
+ outputChannel: z.ZodEnum<{
746
+ annotation: "annotation";
747
+ }>;
748
+ persistenceIntent: z.ZodEnum<{
749
+ durable: "durable";
750
+ }>;
751
+ purpose: z.ZodEnum<{
752
+ violation: "violation";
753
+ "info-collection": "info-collection";
754
+ }>;
627
755
  severity: z.ZodEnum<{
628
756
  blocking: "blocking";
629
757
  risk: "risk";
@@ -640,9 +768,9 @@ declare const GotchaSurveyQuestionSchema: z.ZodObject<{
640
768
  sourceComponentName: z.ZodOptional<z.ZodString>;
641
769
  }, z.core.$strip>>;
642
770
  applyStrategy: z.ZodEnum<{
771
+ annotation: "annotation";
643
772
  "property-mod": "property-mod";
644
773
  "structural-mod": "structural-mod";
645
- annotation: "annotation";
646
774
  "auto-fix": "auto-fix";
647
775
  }>;
648
776
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -675,6 +803,17 @@ declare const SurveyQuestionBatchSchema: z.ZodObject<{
675
803
  nodeId: z.ZodString;
676
804
  nodeName: z.ZodString;
677
805
  ruleId: z.ZodString;
806
+ detection: z.ZodLiteral<"rule-based">;
807
+ outputChannel: z.ZodEnum<{
808
+ annotation: "annotation";
809
+ }>;
810
+ persistenceIntent: z.ZodEnum<{
811
+ durable: "durable";
812
+ }>;
813
+ purpose: z.ZodEnum<{
814
+ violation: "violation";
815
+ "info-collection": "info-collection";
816
+ }>;
678
817
  severity: z.ZodEnum<{
679
818
  blocking: "blocking";
680
819
  risk: "risk";
@@ -691,9 +830,9 @@ declare const SurveyQuestionBatchSchema: z.ZodObject<{
691
830
  sourceComponentName: z.ZodOptional<z.ZodString>;
692
831
  }, z.core.$strip>>;
693
832
  applyStrategy: z.ZodEnum<{
833
+ annotation: "annotation";
694
834
  "property-mod": "property-mod";
695
835
  "structural-mod": "structural-mod";
696
- annotation: "annotation";
697
836
  "auto-fix": "auto-fix";
698
837
  }>;
699
838
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -723,6 +862,17 @@ declare const SurveyQuestionGroupSchema: z.ZodObject<{
723
862
  nodeId: z.ZodString;
724
863
  nodeName: z.ZodString;
725
864
  ruleId: z.ZodString;
865
+ detection: z.ZodLiteral<"rule-based">;
866
+ outputChannel: z.ZodEnum<{
867
+ annotation: "annotation";
868
+ }>;
869
+ persistenceIntent: z.ZodEnum<{
870
+ durable: "durable";
871
+ }>;
872
+ purpose: z.ZodEnum<{
873
+ violation: "violation";
874
+ "info-collection": "info-collection";
875
+ }>;
726
876
  severity: z.ZodEnum<{
727
877
  blocking: "blocking";
728
878
  risk: "risk";
@@ -739,9 +889,9 @@ declare const SurveyQuestionGroupSchema: z.ZodObject<{
739
889
  sourceComponentName: z.ZodOptional<z.ZodString>;
740
890
  }, z.core.$strip>>;
741
891
  applyStrategy: z.ZodEnum<{
892
+ annotation: "annotation";
742
893
  "property-mod": "property-mod";
743
894
  "structural-mod": "structural-mod";
744
- annotation: "annotation";
745
895
  "auto-fix": "auto-fix";
746
896
  }>;
747
897
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -773,6 +923,17 @@ declare const GroupedSurveySchema: z.ZodObject<{
773
923
  nodeId: z.ZodString;
774
924
  nodeName: z.ZodString;
775
925
  ruleId: z.ZodString;
926
+ detection: z.ZodLiteral<"rule-based">;
927
+ outputChannel: z.ZodEnum<{
928
+ annotation: "annotation";
929
+ }>;
930
+ persistenceIntent: z.ZodEnum<{
931
+ durable: "durable";
932
+ }>;
933
+ purpose: z.ZodEnum<{
934
+ violation: "violation";
935
+ "info-collection": "info-collection";
936
+ }>;
776
937
  severity: z.ZodEnum<{
777
938
  blocking: "blocking";
778
939
  risk: "risk";
@@ -789,9 +950,9 @@ declare const GroupedSurveySchema: z.ZodObject<{
789
950
  sourceComponentName: z.ZodOptional<z.ZodString>;
790
951
  }, z.core.$strip>>;
791
952
  applyStrategy: z.ZodEnum<{
953
+ annotation: "annotation";
792
954
  "property-mod": "property-mod";
793
955
  "structural-mod": "structural-mod";
794
- annotation: "annotation";
795
956
  "auto-fix": "auto-fix";
796
957
  }>;
797
958
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -826,6 +987,17 @@ declare const GotchaSurveySchema: z.ZodObject<{
826
987
  nodeId: z.ZodString;
827
988
  nodeName: z.ZodString;
828
989
  ruleId: z.ZodString;
990
+ detection: z.ZodLiteral<"rule-based">;
991
+ outputChannel: z.ZodEnum<{
992
+ annotation: "annotation";
993
+ }>;
994
+ persistenceIntent: z.ZodEnum<{
995
+ durable: "durable";
996
+ }>;
997
+ purpose: z.ZodEnum<{
998
+ violation: "violation";
999
+ "info-collection": "info-collection";
1000
+ }>;
829
1001
  severity: z.ZodEnum<{
830
1002
  blocking: "blocking";
831
1003
  risk: "risk";
@@ -842,9 +1014,9 @@ declare const GotchaSurveySchema: z.ZodObject<{
842
1014
  sourceComponentName: z.ZodOptional<z.ZodString>;
843
1015
  }, z.core.$strip>>;
844
1016
  applyStrategy: z.ZodEnum<{
1017
+ annotation: "annotation";
845
1018
  "property-mod": "property-mod";
846
1019
  "structural-mod": "structural-mod";
847
- annotation: "annotation";
848
1020
  "auto-fix": "auto-fix";
849
1021
  }>;
850
1022
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -872,6 +1044,17 @@ declare const GotchaSurveySchema: z.ZodObject<{
872
1044
  nodeId: z.ZodString;
873
1045
  nodeName: z.ZodString;
874
1046
  ruleId: z.ZodString;
1047
+ detection: z.ZodLiteral<"rule-based">;
1048
+ outputChannel: z.ZodEnum<{
1049
+ annotation: "annotation";
1050
+ }>;
1051
+ persistenceIntent: z.ZodEnum<{
1052
+ durable: "durable";
1053
+ }>;
1054
+ purpose: z.ZodEnum<{
1055
+ violation: "violation";
1056
+ "info-collection": "info-collection";
1057
+ }>;
875
1058
  severity: z.ZodEnum<{
876
1059
  blocking: "blocking";
877
1060
  risk: "risk";
@@ -888,9 +1071,9 @@ declare const GotchaSurveySchema: z.ZodObject<{
888
1071
  sourceComponentName: z.ZodOptional<z.ZodString>;
889
1072
  }, z.core.$strip>>;
890
1073
  applyStrategy: z.ZodEnum<{
1074
+ annotation: "annotation";
891
1075
  "property-mod": "property-mod";
892
1076
  "structural-mod": "structural-mod";
893
- annotation: "annotation";
894
1077
  "auto-fix": "auto-fix";
895
1078
  }>;
896
1079
  targetProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
@@ -911,25 +1094,28 @@ declare const GotchaSurveySchema: z.ZodObject<{
911
1094
  }, z.core.$strip>;
912
1095
  type GotchaSurvey = z.infer<typeof GotchaSurveySchema>;
913
1096
 
914
- /**
915
- * Acknowledgment marker — surfaced from a Figma Dev Mode annotation that
916
- * canicode itself wrote during a roundtrip. When the analysis pipeline
917
- * receives a list of acknowledgments, matching `(nodeId, ruleId)` issues are
918
- * flagged `acknowledged: true` and contribute half their normal weight to
919
- * the density score (#371).
920
- *
921
- * This contract is consumed by:
922
- * - The MCP `analyze` tool (`acknowledgments?: Acknowledgment[]` input)
923
- * - The CLI `analyze --acknowledgments <path>` flag
924
- * - `RuleEngineOptions.acknowledgments`
925
- *
926
- * It is produced by the Plugin-API helper
927
- * `extractAcknowledgmentsFromNode` / `readCanicodeAcknowledgments`
928
- * (see `src/core/roundtrip/read-acknowledgments.ts`).
929
- */
930
1097
  declare const AcknowledgmentSchema: z.ZodObject<{
931
1098
  nodeId: z.ZodString;
932
1099
  ruleId: z.ZodString;
1100
+ intent: z.ZodOptional<z.ZodObject<{
1101
+ field: z.ZodString;
1102
+ value: z.ZodUnknown;
1103
+ scope: z.ZodEnum<{
1104
+ instance: "instance";
1105
+ definition: "definition";
1106
+ }>;
1107
+ }, z.core.$strip>>;
1108
+ sceneWriteOutcome: z.ZodOptional<z.ZodObject<{
1109
+ result: z.ZodEnum<{
1110
+ unknown: "unknown";
1111
+ succeeded: "succeeded";
1112
+ "silent-ignored": "silent-ignored";
1113
+ "api-rejected": "api-rejected";
1114
+ "user-declined-propagation": "user-declined-propagation";
1115
+ }>;
1116
+ reason: z.ZodOptional<z.ZodString>;
1117
+ }, z.core.$strip>>;
1118
+ codegenDirective: z.ZodOptional<z.ZodString>;
933
1119
  }, z.core.$strip>;
934
1120
  type Acknowledgment = z.infer<typeof AcknowledgmentSchema>;
935
1121
 
@@ -972,6 +1158,13 @@ interface AnalysisResult {
972
1158
  maxDepth: number;
973
1159
  nodeCount: number;
974
1160
  analyzedAt: string;
1161
+ /**
1162
+ * #404: Resolved analysis scope (`page` vs `component`). Either detected
1163
+ * from the root node type or taken from the caller's explicit override.
1164
+ * Propagated to MCP / JSON output so downstream consumers (code-gen,
1165
+ * reports) can branch the same way rules do.
1166
+ */
1167
+ scope: AnalysisScope;
975
1168
  }
976
1169
  /**
977
1170
  * Options for the rule engine
@@ -991,6 +1184,15 @@ interface RuleEngineOptions {
991
1184
  * (`123-456`) or Plugin-API form (`123:456`) — both normalize to `:`.
992
1185
  */
993
1186
  acknowledgments?: Acknowledgment[];
1187
+ /**
1188
+ * #404: Explicit scope override. When omitted, the engine auto-detects
1189
+ * from the analysis root's node type via `detectAnalysisScope`. Supply
1190
+ * this when the caller knows the heuristic would mis-detect — e.g. a
1191
+ * FRAME that happens to be a design-system demo (component scope) or a
1192
+ * COMPONENT_SET being audited as part of a full page inventory (page
1193
+ * scope).
1194
+ */
1195
+ scope?: AnalysisScope;
994
1196
  }
995
1197
  /**
996
1198
  * Rule engine for analyzing Figma files
@@ -1003,6 +1205,7 @@ declare class RuleEngine {
1003
1205
  private excludeNamePattern;
1004
1206
  private excludeNodeTypes;
1005
1207
  private acknowledgments;
1208
+ private scopeOverride;
1006
1209
  constructor(options?: RuleEngineOptions);
1007
1210
  /**
1008
1211
  * Analyze a Figma file and return issues
@@ -1430,6 +1633,12 @@ declare class RuleRegistry {
1430
1633
  * Register a rule
1431
1634
  */
1432
1635
  register(rule: Rule): void;
1636
+ /**
1637
+ * Remove a rule by ID. Primarily used by tests that register a
1638
+ * throwaway rule and need to restore the registry afterwards. Returns
1639
+ * `true` if the rule was present.
1640
+ */
1641
+ unregister(id: RuleId): boolean;
1433
1642
  /**
1434
1643
  * Get a rule by ID
1435
1644
  */
@@ -1482,6 +1691,31 @@ interface AnnotationProperty {
1482
1691
  * - semantic: ΔV < 2%, negligible code difference — naming and semantic issues
1483
1692
  */
1484
1693
  declare const RULE_ID_CATEGORY: Record<RuleId, Category>;
1694
+ /**
1695
+ * #406: Classifies each rule by primary output channel.
1696
+ *
1697
+ * - `violation` (default): score-primary. Rule fires when a best-practice
1698
+ * expectation is broken; the score penalty is the main signal, gotcha
1699
+ * questions are secondary context on how to resolve the violation.
1700
+ * - `info-collection`: annotation-primary. Rule fires on nodes that need
1701
+ * implementation context Figma cannot encode natively (click target,
1702
+ * state variants). The gotcha annotation IS the output; score impact is
1703
+ * kept minimal (-1 range) so presence/absence of the annotation — not
1704
+ * the penalty — differentiates designs.
1705
+ *
1706
+ * Sibling map (mirrors `RULE_ID_CATEGORY`) so existing `RuleDefinition`
1707
+ * call sites don't need to be touched. Look up via `getRulePurpose`.
1708
+ */
1709
+ declare const RULE_PURPOSE: Record<RuleId, RulePurpose>;
1710
+ /**
1711
+ * Resolve a rule's purpose. Accepts `string` (not `RuleId`) because the
1712
+ * purpose concept must work for out-of-tree custom rules added via the
1713
+ * config loader — callers pass `issue.violation.ruleId` which is a plain
1714
+ * string. Defaults to `"violation"` for unknown ids. Keeping the cast
1715
+ * inside this helper (rather than forcing every caller to do `as RuleId`)
1716
+ * makes the fallback semantically honest.
1717
+ */
1718
+ declare function getRulePurpose(ruleId: string): RulePurpose;
1485
1719
  /**
1486
1720
  * Central configuration for all rules.
1487
1721
  * Scores based on ablation experiment + AI implementation interview (#200):
@@ -1718,6 +1952,10 @@ declare const CalibrationConfigSchema: z.ZodObject<{
1718
1952
  }>>;
1719
1953
  outputPath: z.ZodDefault<z.ZodString>;
1720
1954
  runDir: z.ZodOptional<z.ZodString>;
1955
+ scope: z.ZodOptional<z.ZodEnum<{
1956
+ page: "page";
1957
+ component: "component";
1958
+ }>>;
1721
1959
  }, z.core.$strip>;
1722
1960
  type CalibrationConfig = z.infer<typeof CalibrationConfigSchema>;
1723
1961
  type CalibrationConfigInput = z.input<typeof CalibrationConfigSchema>;
@@ -2107,4 +2345,4 @@ declare class ActivityLogger {
2107
2345
  getLogPath(): string;
2108
2346
  }
2109
2347
 
2110
- export { ALL_STRIP_TYPES, ActivityLogger, type AnalysisAgentInput, type AnalysisAgentOutput, type AnalysisFile, AnalysisFileSchema, type AnalysisIssue, type AnalysisNode, AnalysisNodeSchema, type AnalysisNodeType, AnalysisNodeTypeSchema, type AnalysisResult, AnnotationPropertySchema, CATEGORIES, CATEGORY_LABELS, type CalibrationConfig, type CalibrationConfigInput, CalibrationConfigSchema, type CalibrationRun, type CalibrationStatus, CalibrationStatusSchema, type Category, CategorySchema, type CategoryScore, type CategoryScoreResult, CategoryScoreSchema, type Confidence, ConfidenceSchema, type ConversionRecord, ConversionRecordSchema, DEPTH_WEIGHT_CATEGORIES, DESIGN_TREE_INFO_TYPES, type DesignTreeInfoType, type DesignTreeOptions, type DesignTreeResult, type DesignTreeStripType, type Difficulty, DifficultySchema, type EvaluationAgentInput, type EvaluationAgentOutput, FigmaClient, FigmaClientError, type FigmaClientOptions, FigmaFileLoadError, type FigmaUrlInfo, FigmaUrlInfoSchema, FigmaUrlParseError, type GapAnalyzerOutput, GapAnalyzerOutputSchema, type GapEntry, GapEntrySchema, type GetFileNodesResponse, type GotchaApplyResolution, type GotchaApplyStrategy, type GotchaSurvey, type GotchaSurveyQuestion, GotchaSurveyQuestionSchema, GotchaSurveySchema, type Grade, type GridChildAlign, GridChildAlignSchema, type GroupedSurvey, GroupedSurveySchema, type InstanceChildIdParts, type InstanceContext, InstanceContextSchema, type Issue, IssueSchema, type LayoutAlign, LayoutAlignSchema, type LayoutConstraint, LayoutConstraintSchema, type LayoutMode, LayoutModeSchema, type LayoutPositioning, LayoutPositioningSchema, type LayoutWrap, LayoutWrapSchema, type McpAnalyzeResponse, McpAnalyzeResponseSchema, type MismatchCase, MismatchCaseSchema, type MismatchType, MismatchTypeSchema, type NewRuleProposal, NewRuleProposalSchema, type NodeIssueDetail, type NodeIssueSummary, NodeIssueSummarySchema, type OverflowDirection, OverflowDirectionSchema, type Preset, RULE_ANNOTATION_PROPERTIES, RULE_CONFIGS, RULE_ID_CATEGORY, type Report, type ReportMetadata, ReportMetadataSchema, ReportSchema, type Rule, type RuleApplyStrategy, RuleApplyStrategySchema, type RuleCheckFn, type RuleConfig, RuleConfigSchema, type RuleContext, type RuleDefinition, RuleDefinitionSchema, RuleEngine, type RuleEngineOptions, type RuleFailure, type RuleId, RuleImpactAssessmentSchema, type RuleRelatedStruggle, RuleRelatedStruggleSchema, type RuleViolation, SEVERITY_LABELS, SEVERITY_WEIGHT, type SamplingStrategy, SamplingStrategySchema, type ScoreAdjustment, ScoreAdjustmentSchema, type ScoreReport, type Severity, SeveritySchema, type StripDeltaForEval, type StripDeltaResult, StripDeltaResultSchema, StripDeltasArraySchema, StripTypeEnum, type SurveyQuestionBatch, SurveyQuestionBatchSchema, type SurveyQuestionGroup, SurveyQuestionGroupSchema, type TuningAgentInput, type TuningAgentOutput, type UncoveredStruggle, UncoveredStruggleSchema, UncoveredStrugglesInputSchema, version as VERSION, type VisualCompareCliOptions, VisualCompareCliOptionsSchema, absolutePositionInAutoLayout, analyzeFile, buildFigmaDeepLink, buildResultJson, calculateScores, collectComponentIds, collectInteractionDestinationIds, createRuleEngine, deepNesting, defineRule, detachedInstance, extractRuleScores, fixedSizeInAutoLayout, formatScoreSummary, generateCalibrationReport, generateDesignTree, generateDesignTreeWithStats, getAnalysisState, getAnnotationProperties, getCategoryLabel, getConfigsWithPreset, getRuleOption, getSeverityLabel, gradeToClassName, inconsistentNamingConvention, irregularSpacing, isInstanceChildNodeId, isReadyForCodeGen, loadFigmaFileFromJson, missingComponent, missingInteractionState, missingPrototype, missingSizeConstraint, noAutoLayout, nonLayoutContainer, nonSemanticName, nonStandardNaming, parseFigmaJson, parseFigmaUrl, parseInstanceChildNodeId, rawValue, resolveComponentDefinitions, resolveGotchaApplyTarget, resolveInteractionDestinations, ruleRegistry, runAnalysisAgent, runCalibrationAnalyze, runCalibrationEvaluate, runEvaluationAgent, runTuningAgent, stripDeltaToDifficulty, stripDesignTree, supportsDepthWeight, toCommentableNodeId, tokenDeltaToDifficulty, transformComponentMasterNodes, transformFigmaResponse, transformFileNodesResponse, variantStructureMismatch };
2348
+ export { ALL_STRIP_TYPES, ActivityLogger, type AnalysisAgentInput, type AnalysisAgentOutput, type AnalysisFile, AnalysisFileSchema, type AnalysisIssue, type AnalysisNode, AnalysisNodeSchema, type AnalysisNodeType, AnalysisNodeTypeSchema, type AnalysisResult, type AnalysisScope, AnalysisScopeSchema, AnnotationPropertySchema, CATEGORIES, CATEGORY_LABELS, type CalibrationConfig, type CalibrationConfigInput, CalibrationConfigSchema, type CalibrationRun, type CalibrationStatus, CalibrationStatusSchema, type Category, CategorySchema, type CategoryScore, type CategoryScoreResult, CategoryScoreSchema, type Confidence, ConfidenceSchema, type ConversionRecord, ConversionRecordSchema, DEPTH_WEIGHT_CATEGORIES, DESIGN_TREE_INFO_TYPES, type DesignTreeInfoType, type DesignTreeOptions, type DesignTreeResult, type DesignTreeStripType, type Detection, DetectionSchema, type Difficulty, DifficultySchema, type EvaluationAgentInput, type EvaluationAgentOutput, FigmaClient, FigmaClientError, type FigmaClientOptions, FigmaFileLoadError, type FigmaUrlInfo, FigmaUrlInfoSchema, FigmaUrlParseError, type GapAnalyzerOutput, GapAnalyzerOutputSchema, type GapEntry, GapEntrySchema, type GetFileNodesResponse, type GotchaApplyResolution, type GotchaApplyStrategy, GotchaDetectionSchema, GotchaOutputChannelSchema, GotchaPersistenceIntentSchema, type GotchaSurvey, type GotchaSurveyQuestion, GotchaSurveyQuestionSchema, GotchaSurveySchema, type Grade, type GridChildAlign, GridChildAlignSchema, type GroupedSurvey, GroupedSurveySchema, type InstanceChildIdParts, type InstanceContext, InstanceContextSchema, type Issue, IssueSchema, type LayoutAlign, LayoutAlignSchema, type LayoutConstraint, LayoutConstraintSchema, type LayoutMode, LayoutModeSchema, type LayoutPositioning, LayoutPositioningSchema, type LayoutWrap, LayoutWrapSchema, type McpAnalyzeResponse, McpAnalyzeResponseSchema, type MismatchCase, MismatchCaseSchema, type MismatchType, MismatchTypeSchema, type NewRuleProposal, NewRuleProposalSchema, type NodeIssueDetail, type NodeIssueSummary, NodeIssueSummarySchema, type OutputChannel, OutputChannelSchema, type OverflowDirection, OverflowDirectionSchema, type PersistenceIntent, PersistenceIntentSchema, type Preset, RULE_ANNOTATION_PROPERTIES, RULE_CONFIGS, RULE_ID_CATEGORY, RULE_PURPOSE, type Report, type ReportMetadata, ReportMetadataSchema, ReportSchema, type Rule, type RuleApplyStrategy, RuleApplyStrategySchema, type RuleCheckFn, type RuleConfig, RuleConfigSchema, type RuleContext, type RuleDefinition, RuleDefinitionSchema, RuleEngine, type RuleEngineOptions, type RuleFailure, type RuleId, RuleImpactAssessmentSchema, type RulePurpose, RulePurposeSchema, type RuleRelatedStruggle, RuleRelatedStruggleSchema, type RuleViolation, SEVERITY_LABELS, SEVERITY_WEIGHT, type SamplingStrategy, SamplingStrategySchema, type ScoreAdjustment, ScoreAdjustmentSchema, type ScoreReport, type Severity, SeveritySchema, type StripDeltaForEval, type StripDeltaResult, StripDeltaResultSchema, StripDeltasArraySchema, StripTypeEnum, type SurveyQuestionBatch, SurveyQuestionBatchSchema, type SurveyQuestionGroup, SurveyQuestionGroupSchema, type TuningAgentInput, type TuningAgentOutput, type UncoveredStruggle, UncoveredStruggleSchema, UncoveredStrugglesInputSchema, version as VERSION, type VisualCompareCliOptions, VisualCompareCliOptionsSchema, absolutePositionInAutoLayout, analyzeFile, buildFigmaDeepLink, buildResultJson, calculateScores, collectComponentIds, collectInteractionDestinationIds, createRuleEngine, deepNesting, defineRule, detachedInstance, detectAnalysisScope, extractRuleScores, fixedSizeInAutoLayout, formatScoreSummary, generateCalibrationReport, generateDesignTree, generateDesignTreeWithStats, getAnalysisState, getAnnotationProperties, getCategoryLabel, getConfigsWithPreset, getRuleOption, getRulePurpose, getSeverityLabel, gradeToClassName, inconsistentNamingConvention, irregularSpacing, isInstanceChildNodeId, isReadyForCodeGen, loadFigmaFileFromJson, missingComponent, missingInteractionState, missingPrototype, missingSizeConstraint, noAutoLayout, nonLayoutContainer, nonSemanticName, nonStandardNaming, parseFigmaJson, parseFigmaUrl, parseInstanceChildNodeId, rawValue, resolveComponentDefinitions, resolveGotchaApplyTarget, resolveInteractionDestinations, ruleRegistry, runAnalysisAgent, runCalibrationAnalyze, runCalibrationEvaluate, runEvaluationAgent, runTuningAgent, stripDeltaToDifficulty, stripDesignTree, supportsDepthWeight, toCommentableNodeId, tokenDeltaToDifficulty, transformComponentMasterNodes, transformFigmaResponse, transformFileNodesResponse, variantStructureMismatch };