@contentful/experience-design-system-cli 2.6.2-dev-build-864e323.0 → 2.7.1-dev-build-02830eb.0

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.
Files changed (45) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/analyze/command.js +1 -1
  3. package/dist/src/analyze/extract/scoring.d.ts +3 -2
  4. package/dist/src/analyze/extract/scoring.js +39 -22
  5. package/dist/src/analyze/select/tui/App.js +54 -474
  6. package/dist/src/analyze/select/tui/components/ComponentDetail.d.ts +3 -5
  7. package/dist/src/analyze/select/tui/components/ComponentDetail.js +9 -10
  8. package/dist/src/analyze/select/tui/components/FinalizeDialog.d.ts +1 -1
  9. package/dist/src/analyze/select/tui/components/FinalizeDialog.js +2 -10
  10. package/dist/src/analyze/select/tui/components/HelpOverlay.d.ts +1 -1
  11. package/dist/src/analyze/select/tui/components/HelpOverlay.js +2 -7
  12. package/dist/src/analyze/select/tui/components/JsonEditor.d.ts +7 -5
  13. package/dist/src/analyze/select/tui/components/JsonEditor.js +15 -146
  14. package/dist/src/analyze/select/tui/components/QuitDialog.d.ts +1 -1
  15. package/dist/src/analyze/select/tui/components/QuitDialog.js +2 -10
  16. package/dist/src/analyze/select/tui/components/Sidebar.d.ts +0 -2
  17. package/dist/src/analyze/select/tui/components/StatusBar.d.ts +0 -2
  18. package/dist/src/analyze/select/tui/hooks/useImmediateInput.d.ts +5 -0
  19. package/dist/src/analyze/select/tui/hooks/useImmediateInput.js +7 -4
  20. package/dist/src/analyze/select/tui/hooks/useKeymap.d.ts +0 -23
  21. package/dist/src/analyze/select/tui/hooks/useKeymap.js +1 -67
  22. package/dist/src/analyze/select/tui/hooks/useRawMode.d.ts +6 -0
  23. package/dist/src/analyze/select/tui/hooks/useRawMode.js +16 -0
  24. package/dist/src/analyze/select/tui/hooks/useSideEffects.d.ts +17 -0
  25. package/dist/src/analyze/select/tui/hooks/useSideEffects.js +226 -0
  26. package/dist/src/analyze/select/tui/hooks/useUndo.js +15 -21
  27. package/dist/src/analyze/select/tui/inputToAction.d.ts +13 -0
  28. package/dist/src/analyze/select/tui/inputToAction.js +68 -0
  29. package/dist/src/analyze/select/tui/state.d.ts +136 -0
  30. package/dist/src/analyze/select/tui/state.js +385 -0
  31. package/dist/src/analyze/select/tui/utils.d.ts +5 -0
  32. package/dist/src/analyze/select/tui/utils.js +11 -0
  33. package/dist/src/analyze/select/types.d.ts +1 -1
  34. package/dist/src/analyze/select/types.js +1 -1
  35. package/dist/src/analyze/tui/AnalyzeView.d.ts +1 -1
  36. package/dist/src/analyze/tui/AnalyzeView.js +5 -3
  37. package/dist/src/generate/agent-runner.js +7 -2
  38. package/dist/src/import/tui/WizardApp.js +2 -0
  39. package/dist/src/import/tui/steps/GenerateReviewStep.js +5 -12
  40. package/dist/src/print/validate/tui/ValidateView.js +2 -0
  41. package/dist/src/session/db.js +4 -4
  42. package/dist/src/types.d.ts +3 -1
  43. package/dist/src/types.js +4 -1
  44. package/package.json +2 -2
  45. package/skills/select-components.md +8 -3
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.6.2-dev-build-864e323.0",
3
+ "version": "2.7.1-dev-build-02830eb.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -153,7 +153,7 @@ export function registerAnalyzeCommand(program) {
153
153
  propCount: c.props.length,
154
154
  slotCount: c.slots.length,
155
155
  warnings: allWarnings.filter((w) => w.startsWith(c.name + ':')),
156
- extractionConfidence: c.extractionConfidence ?? 100,
156
+ extractionConfidence: c.extractionConfidence ?? null,
157
157
  needsReview: c.needsReview ?? false,
158
158
  })),
159
159
  totalWarnings: allWarnings.length,
@@ -1,7 +1,8 @@
1
1
  import type { RawComponentDefinition } from '../../types.js';
2
+ export type ExtractionConfidence = 1 | 2 | 3 | 4 | 5;
2
3
  export type ExtractionScore = {
3
- confidence: number;
4
+ confidence: ExtractionConfidence;
4
5
  reasons: string[];
5
6
  };
6
7
  export declare function computeExtractionScore(component: RawComponentDefinition): ExtractionScore;
7
- export declare function deriveNeedsReview(confidence: number): boolean;
8
+ export declare function deriveNeedsReview(confidence: ExtractionConfidence): boolean;
@@ -41,47 +41,64 @@ function isWidePrimitiveUnion(type) {
41
41
  const nullability = new Set(['null', 'undefined']);
42
42
  const baseCount = parts.filter((p) => basePrimitives.has(p)).length;
43
43
  const nullabilityCount = parts.filter((p) => nullability.has(p)).length;
44
- // Wide only when there are 3+ base primitives, or 2+ base primitives combined with nullability modifiers
45
44
  return baseCount >= 3 || (baseCount >= 2 && nullabilityCount > 0 && baseCount + nullabilityCount >= 3);
46
45
  }
47
- export function computeExtractionScore(component) {
48
- let confidence = 100;
46
+ // Count the number of issues found for scoring
47
+ function countIssues(component) {
48
+ let count = 0;
49
49
  const reasons = [];
50
- // No props and no slots — extractor likely missed something or component is a wrapper
51
50
  if (component.props.length === 0 && component.slots.length === 0) {
52
- confidence -= 15;
51
+ count++;
53
52
  reasons.push('no-props-or-slots');
54
53
  }
54
+ if (component.props.length > 50) {
55
+ count++;
56
+ reasons.push(`high-prop-count:${component.props.length}`);
57
+ }
55
58
  for (const prop of component.props) {
56
- // Opaque types — extractor couldn't resolve the real type
57
59
  if (OPAQUE_TYPES.has(prop.type.trim())) {
58
- confidence -= 20;
60
+ count++;
59
61
  reasons.push(`opaque-type:${prop.name}`);
60
- break; // only penalise once per component
62
+ break;
61
63
  }
62
- // Wide primitive union — hard for the AI agent to classify meaningfully
63
64
  if (isWidePrimitiveUnion(prop.type)) {
64
- confidence -= 10;
65
+ count++;
65
66
  reasons.push(`wide-union:${prop.name}`);
66
- break; // only penalise once
67
+ break;
67
68
  }
68
- // Non-obvious prop name with no description
69
69
  if (!prop.description && !OBVIOUS_PROP_NAMES.has(prop.name)) {
70
- confidence -= 10;
70
+ count++;
71
71
  reasons.push('props-missing-description');
72
- break; // only penalise once
72
+ break;
73
73
  }
74
74
  }
75
- // High prop count possible DOM inflation near-miss or overly broad extraction
76
- if (component.props.length > 50) {
77
- confidence -= 20;
78
- reasons.push(`high-prop-count:${component.props.length}`);
79
- }
75
+ return { count, reasons: [...new Set(reasons)] };
76
+ }
77
+ // Maps issue count to a 1–5 confidence scale:
78
+ // 0 issues → 5 (clean)
79
+ // 1 issue → 4 (minor concern)
80
+ // 2 issues → 3 (moderate concern)
81
+ // 3 issues → 2 (significant concern)
82
+ // 4+ issues → 1 (likely wrong)
83
+ function issueCountToConfidence(count) {
84
+ if (count === 0)
85
+ return 5;
86
+ if (count === 1)
87
+ return 4;
88
+ if (count === 2)
89
+ return 3;
90
+ if (count === 3)
91
+ return 2;
92
+ return 1;
93
+ }
94
+ export function computeExtractionScore(component) {
95
+ const { count, reasons } = countIssues(component);
80
96
  return {
81
- confidence: Math.max(0, Math.min(100, confidence)),
82
- reasons: [...new Set(reasons)], // deduplicate
97
+ confidence: issueCountToConfidence(count),
98
+ reasons,
83
99
  };
84
100
  }
101
+ // Flag components scoring 2 or below for human review
85
102
  export function deriveNeedsReview(confidence) {
86
- return confidence < 70;
103
+ return confidence <= 2;
87
104
  }