canicode 0.11.0 → 0.11.2

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.11.0";
4
+ var version = "0.11.2";
5
5
 
6
6
  declare const SeveritySchema: z.ZodEnum<{
7
7
  blocking: "blocking";
@@ -798,7 +798,11 @@ type GotchaSurveyQuestion = z.infer<typeof GotchaSurveyQuestionSchema>;
798
798
  */
799
799
  declare const SurveyQuestionBatchSchema: z.ZodObject<{
800
800
  ruleId: z.ZodString;
801
- batchable: z.ZodBoolean;
801
+ batchMode: z.ZodEnum<{
802
+ safe: "safe";
803
+ "opt-in": "opt-in";
804
+ none: "none";
805
+ }>;
802
806
  questions: z.ZodArray<z.ZodObject<{
803
807
  nodeId: z.ZodString;
804
808
  nodeName: z.ZodString;
@@ -857,7 +861,11 @@ declare const SurveyQuestionGroupSchema: z.ZodObject<{
857
861
  }, z.core.$strip>>;
858
862
  batches: z.ZodArray<z.ZodObject<{
859
863
  ruleId: z.ZodString;
860
- batchable: z.ZodBoolean;
864
+ batchMode: z.ZodEnum<{
865
+ safe: "safe";
866
+ "opt-in": "opt-in";
867
+ none: "none";
868
+ }>;
861
869
  questions: z.ZodArray<z.ZodObject<{
862
870
  nodeId: z.ZodString;
863
871
  nodeName: z.ZodString;
@@ -918,7 +926,11 @@ declare const GroupedSurveySchema: z.ZodObject<{
918
926
  }, z.core.$strip>>;
919
927
  batches: z.ZodArray<z.ZodObject<{
920
928
  ruleId: z.ZodString;
921
- batchable: z.ZodBoolean;
929
+ batchMode: z.ZodEnum<{
930
+ safe: "safe";
931
+ "opt-in": "opt-in";
932
+ none: "none";
933
+ }>;
922
934
  questions: z.ZodArray<z.ZodObject<{
923
935
  nodeId: z.ZodString;
924
936
  nodeName: z.ZodString;
@@ -1039,7 +1051,11 @@ declare const GotchaSurveySchema: z.ZodObject<{
1039
1051
  }, z.core.$strip>>;
1040
1052
  batches: z.ZodArray<z.ZodObject<{
1041
1053
  ruleId: z.ZodString;
1042
- batchable: z.ZodBoolean;
1054
+ batchMode: z.ZodEnum<{
1055
+ safe: "safe";
1056
+ "opt-in": "opt-in";
1057
+ none: "none";
1058
+ }>;
1043
1059
  questions: z.ZodArray<z.ZodObject<{
1044
1060
  nodeId: z.ZodString;
1045
1061
  nodeName: z.ZodString;
@@ -1091,28 +1107,32 @@ declare const GotchaSurveySchema: z.ZodObject<{
1091
1107
  }, z.core.$strip>>;
1092
1108
  }, z.core.$strip>;
1093
1109
  designKey: z.ZodString;
1110
+ suggestedDefaultApply: z.ZodBoolean;
1094
1111
  }, z.core.$strip>;
1095
1112
  type GotchaSurvey = z.infer<typeof GotchaSurveySchema>;
1096
1113
 
1097
- /**
1098
- * Acknowledgment marker — surfaced from a Figma Dev Mode annotation that
1099
- * canicode itself wrote during a roundtrip. When the analysis pipeline
1100
- * receives a list of acknowledgments, matching `(nodeId, ruleId)` issues are
1101
- * flagged `acknowledged: true` and contribute half their normal weight to
1102
- * the density score (#371).
1103
- *
1104
- * This contract is consumed by:
1105
- * - The MCP `analyze` tool (`acknowledgments?: Acknowledgment[]` input)
1106
- * - The CLI `analyze --acknowledgments <path>` flag
1107
- * - `RuleEngineOptions.acknowledgments`
1108
- *
1109
- * It is produced by the Plugin-API helper
1110
- * `extractAcknowledgmentsFromNode` / `readCanicodeAcknowledgments`
1111
- * (see `src/core/roundtrip/read-acknowledgments.ts`).
1112
- */
1113
1114
  declare const AcknowledgmentSchema: z.ZodObject<{
1114
1115
  nodeId: z.ZodString;
1115
1116
  ruleId: z.ZodString;
1117
+ intent: z.ZodOptional<z.ZodObject<{
1118
+ field: z.ZodString;
1119
+ value: z.ZodUnknown;
1120
+ scope: z.ZodEnum<{
1121
+ instance: "instance";
1122
+ definition: "definition";
1123
+ }>;
1124
+ }, z.core.$strip>>;
1125
+ sceneWriteOutcome: z.ZodOptional<z.ZodObject<{
1126
+ result: z.ZodEnum<{
1127
+ unknown: "unknown";
1128
+ succeeded: "succeeded";
1129
+ "silent-ignored": "silent-ignored";
1130
+ "api-rejected": "api-rejected";
1131
+ "user-declined-propagation": "user-declined-propagation";
1132
+ }>;
1133
+ reason: z.ZodOptional<z.ZodString>;
1134
+ }, z.core.$strip>>;
1135
+ codegenDirective: z.ZodOptional<z.ZodString>;
1116
1136
  }, z.core.$strip>;
1117
1137
  type Acknowledgment = z.infer<typeof AcknowledgmentSchema>;
1118
1138
 
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import 'crypto';
6
6
  import { homedir } from 'os';
7
7
 
8
8
  // package.json
9
- var version = "0.11.0";
9
+ var version = "0.11.2";
10
10
  var SeveritySchema = z.enum([
11
11
  "blocking",
12
12
  "risk",
@@ -411,13 +411,17 @@ var GotchaSurveyQuestionSchema = z.object({
411
411
  var SurveyQuestionBatchSchema = z.object({
412
412
  ruleId: z.string(),
413
413
  /**
414
- * `true` when every member shares an answer-shape uniformly applicable to
415
- * all of them (e.g. one `min-width` value covers all FILL children).
416
- * The SKILL renders one shared prompt for `batchable: true` batches with
417
- * `questions.length >= 2`; everything else falls through to the
418
- * single-question template.
414
+ * Rendering mode for this batch (see `BatchMode` in
415
+ * `src/core/gotcha/group-and-batch-questions.ts` the authoritative
416
+ * whitelists `BATCHABLE_RULE_IDS` and `OPT_IN_BATCHABLE_RULE_IDS` live
417
+ * there):
418
+ * - `"safe"` — one answer uniformly applies to every member (#369).
419
+ * - `"opt-in"` — one shared answer is a suggested default; the user may
420
+ * reply `split` for per-node override (#426).
421
+ * - `"none"` — single-member batch, renders the standard per-question
422
+ * template.
419
423
  */
420
- batchable: z.boolean(),
424
+ batchMode: z.enum(["safe", "opt-in", "none"]),
421
425
  questions: z.array(GotchaSurveyQuestionSchema),
422
426
  /**
423
427
  * Sum of `max(question.replicas, 1)` across `questions`. Counts the
@@ -451,7 +455,21 @@ var GotchaSurveySchema = z.object({
451
455
  * this directly when upserting the per-design section, so the SKILL.md
452
456
  * prose no longer parses URLs (per ADR-016).
453
457
  */
454
- designKey: z.string()
458
+ designKey: z.string(),
459
+ /**
460
+ * #428 — threshold hint for the `allowDefinitionWrite` picker in the
461
+ * `canicode-roundtrip` skill. `true` when `propagationCandidates >= 3`
462
+ * (i.e. three or more questions target instance children that could
463
+ * benefit from definition-level writes). When `false`, the skill silently
464
+ * uses the annotation default (ADR-012) without surfacing the picker —
465
+ * the opt-in flow is over-engineered for tiny surveys.
466
+ *
467
+ * Computed server-side from `questions` so the skill doesn't have to
468
+ * count `isInstanceChild` manually; the skill may still override this
469
+ * hint when it has additional context (e.g. all candidates are
470
+ * read-only per probe result).
471
+ */
472
+ suggestedDefaultApply: z.boolean()
455
473
  });
456
474
 
457
475
  // src/core/rules/rule-config.ts
@@ -791,9 +809,27 @@ function defineRule(rule) {
791
809
  ruleRegistry.register(rule);
792
810
  return rule;
793
811
  }
812
+ var AcknowledgmentIntentSchema = z.object({
813
+ field: z.string(),
814
+ value: z.unknown(),
815
+ scope: z.enum(["instance", "definition"])
816
+ });
817
+ var AcknowledgmentSceneWriteOutcomeSchema = z.object({
818
+ result: z.enum([
819
+ "succeeded",
820
+ "silent-ignored",
821
+ "api-rejected",
822
+ "user-declined-propagation",
823
+ "unknown"
824
+ ]),
825
+ reason: z.string().optional()
826
+ });
794
827
  var AcknowledgmentSchema = z.object({
795
828
  nodeId: z.string(),
796
- ruleId: z.string()
829
+ ruleId: z.string(),
830
+ intent: AcknowledgmentIntentSchema.optional(),
831
+ sceneWriteOutcome: AcknowledgmentSceneWriteOutcomeSchema.optional(),
832
+ codegenDirective: z.string().optional()
797
833
  });
798
834
  z.array(AcknowledgmentSchema);
799
835
  function normalizeNodeId(id) {