logicstamp-context 0.1.0 → 0.2.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 (176) hide show
  1. package/LICENSE +21 -21
  2. package/LLM_CONTEXT.md +4 -3
  3. package/README.md +140 -21
  4. package/dist/cli/commands/compare.d.ts.map +1 -1
  5. package/dist/cli/commands/compare.js +17 -8
  6. package/dist/cli/commands/compare.js.map +1 -1
  7. package/dist/cli/commands/context/bundleFormatter.d.ts +20 -0
  8. package/dist/cli/commands/context/bundleFormatter.d.ts.map +1 -0
  9. package/dist/cli/commands/context/bundleFormatter.js +55 -0
  10. package/dist/cli/commands/context/bundleFormatter.js.map +1 -0
  11. package/dist/cli/commands/context/configManager.d.ts +23 -0
  12. package/dist/cli/commands/context/configManager.d.ts.map +1 -0
  13. package/dist/cli/commands/context/configManager.js +69 -0
  14. package/dist/cli/commands/context/configManager.js.map +1 -0
  15. package/dist/cli/commands/context/contractBuilder.d.ts +18 -0
  16. package/dist/cli/commands/context/contractBuilder.d.ts.map +1 -0
  17. package/dist/cli/commands/context/contractBuilder.js +72 -0
  18. package/dist/cli/commands/context/contractBuilder.js.map +1 -0
  19. package/dist/cli/commands/context/fileWriter.d.ts +38 -0
  20. package/dist/cli/commands/context/fileWriter.d.ts.map +1 -0
  21. package/dist/cli/commands/context/fileWriter.js +165 -0
  22. package/dist/cli/commands/context/fileWriter.js.map +1 -0
  23. package/dist/cli/commands/context/statsCalculator.d.ts +44 -0
  24. package/dist/cli/commands/context/statsCalculator.d.ts.map +1 -0
  25. package/dist/cli/commands/context/statsCalculator.js +150 -0
  26. package/dist/cli/commands/context/statsCalculator.js.map +1 -0
  27. package/dist/cli/commands/context/tokenEstimator.d.ts +76 -0
  28. package/dist/cli/commands/context/tokenEstimator.d.ts.map +1 -0
  29. package/dist/cli/commands/context/tokenEstimator.js +258 -0
  30. package/dist/cli/commands/context/tokenEstimator.js.map +1 -0
  31. package/dist/cli/commands/context.d.ts +2 -0
  32. package/dist/cli/commands/context.d.ts.map +1 -1
  33. package/dist/cli/commands/context.js +75 -405
  34. package/dist/cli/commands/context.js.map +1 -1
  35. package/dist/cli/commands/init.d.ts.map +1 -1
  36. package/dist/cli/commands/init.js +113 -24
  37. package/dist/cli/commands/init.js.map +1 -1
  38. package/dist/cli/commands/style.d.ts +11 -0
  39. package/dist/cli/commands/style.d.ts.map +1 -0
  40. package/dist/cli/commands/style.js +15 -0
  41. package/dist/cli/commands/style.js.map +1 -0
  42. package/dist/cli/handlers/cleanHandler.d.ts +5 -0
  43. package/dist/cli/handlers/cleanHandler.d.ts.map +1 -0
  44. package/dist/cli/handlers/cleanHandler.js +28 -0
  45. package/dist/cli/handlers/cleanHandler.js.map +1 -0
  46. package/dist/cli/handlers/compareHandler.d.ts +5 -0
  47. package/dist/cli/handlers/compareHandler.d.ts.map +1 -0
  48. package/dist/cli/handlers/compareHandler.js +332 -0
  49. package/dist/cli/handlers/compareHandler.js.map +1 -0
  50. package/dist/cli/handlers/contextHandler.d.ts +5 -0
  51. package/dist/cli/handlers/contextHandler.d.ts.map +1 -0
  52. package/dist/cli/handlers/contextHandler.js +24 -0
  53. package/dist/cli/handlers/contextHandler.js.map +1 -0
  54. package/dist/cli/handlers/initHandler.d.ts +6 -0
  55. package/dist/cli/handlers/initHandler.d.ts.map +1 -0
  56. package/dist/cli/handlers/initHandler.js +30 -0
  57. package/dist/cli/handlers/initHandler.js.map +1 -0
  58. package/dist/cli/handlers/styleHandler.d.ts +5 -0
  59. package/dist/cli/handlers/styleHandler.d.ts.map +1 -0
  60. package/dist/cli/handlers/styleHandler.js +30 -0
  61. package/dist/cli/handlers/styleHandler.js.map +1 -0
  62. package/dist/cli/handlers/validateHandler.d.ts +5 -0
  63. package/dist/cli/handlers/validateHandler.d.ts.map +1 -0
  64. package/dist/cli/handlers/validateHandler.js +23 -0
  65. package/dist/cli/handlers/validateHandler.js.map +1 -0
  66. package/dist/cli/index.js +5 -0
  67. package/dist/cli/index.js.map +1 -1
  68. package/dist/cli/parser/argumentParser.d.ts +44 -0
  69. package/dist/cli/parser/argumentParser.d.ts.map +1 -0
  70. package/dist/cli/parser/argumentParser.js +194 -0
  71. package/dist/cli/parser/argumentParser.js.map +1 -0
  72. package/dist/cli/parser/helpText.d.ts +11 -0
  73. package/dist/cli/parser/helpText.d.ts.map +1 -0
  74. package/dist/cli/parser/helpText.js +373 -0
  75. package/dist/cli/parser/helpText.js.map +1 -0
  76. package/dist/cli/stamp.js +14 -897
  77. package/dist/cli/stamp.js.map +1 -1
  78. package/dist/core/astParser/detectors.d.ts +24 -0
  79. package/dist/core/astParser/detectors.d.ts.map +1 -0
  80. package/dist/core/astParser/detectors.js +102 -0
  81. package/dist/core/astParser/detectors.js.map +1 -0
  82. package/dist/core/astParser/extractors/componentExtractor.d.ts +13 -0
  83. package/dist/core/astParser/extractors/componentExtractor.d.ts.map +1 -0
  84. package/dist/core/astParser/extractors/componentExtractor.js +41 -0
  85. package/dist/core/astParser/extractors/componentExtractor.js.map +1 -0
  86. package/dist/core/astParser/extractors/eventExtractor.d.ts +14 -0
  87. package/dist/core/astParser/extractors/eventExtractor.d.ts.map +1 -0
  88. package/dist/core/astParser/extractors/eventExtractor.js +49 -0
  89. package/dist/core/astParser/extractors/eventExtractor.js.map +1 -0
  90. package/dist/core/astParser/extractors/propExtractor.d.ts +14 -0
  91. package/dist/core/astParser/extractors/propExtractor.d.ts.map +1 -0
  92. package/dist/core/astParser/extractors/propExtractor.js +73 -0
  93. package/dist/core/astParser/extractors/propExtractor.js.map +1 -0
  94. package/dist/core/astParser/extractors/stateExtractor.d.ts +13 -0
  95. package/dist/core/astParser/extractors/stateExtractor.d.ts.map +1 -0
  96. package/dist/core/astParser/extractors/stateExtractor.js +66 -0
  97. package/dist/core/astParser/extractors/stateExtractor.js.map +1 -0
  98. package/dist/core/astParser.d.ts.map +1 -1
  99. package/dist/core/astParser.js +5 -307
  100. package/dist/core/astParser.js.map +1 -1
  101. package/dist/core/contractBuilder.d.ts +1 -0
  102. package/dist/core/contractBuilder.d.ts.map +1 -1
  103. package/dist/core/contractBuilder.js +1 -0
  104. package/dist/core/contractBuilder.js.map +1 -1
  105. package/dist/core/pack/builder.d.ts +35 -0
  106. package/dist/core/pack/builder.d.ts.map +1 -0
  107. package/dist/core/pack/builder.js +76 -0
  108. package/dist/core/pack/builder.js.map +1 -0
  109. package/dist/core/pack/collector.d.ts +20 -0
  110. package/dist/core/pack/collector.d.ts.map +1 -0
  111. package/dist/core/pack/collector.js +71 -0
  112. package/dist/core/pack/collector.js.map +1 -0
  113. package/dist/core/pack/loader.d.ts +23 -0
  114. package/dist/core/pack/loader.d.ts.map +1 -0
  115. package/dist/core/pack/loader.js +66 -0
  116. package/dist/core/pack/loader.js.map +1 -0
  117. package/dist/core/pack/resolver.d.ts +21 -0
  118. package/dist/core/pack/resolver.d.ts.map +1 -0
  119. package/dist/core/pack/resolver.js +79 -0
  120. package/dist/core/pack/resolver.js.map +1 -0
  121. package/dist/core/pack.d.ts +17 -27
  122. package/dist/core/pack.d.ts.map +1 -1
  123. package/dist/core/pack.js +18 -225
  124. package/dist/core/pack.js.map +1 -1
  125. package/dist/core/styleExtractor/index.d.ts +11 -0
  126. package/dist/core/styleExtractor/index.d.ts.map +1 -0
  127. package/dist/core/styleExtractor/index.js +11 -0
  128. package/dist/core/styleExtractor/index.js.map +1 -0
  129. package/dist/core/styleExtractor/layout.d.ts +14 -0
  130. package/dist/core/styleExtractor/layout.d.ts.map +1 -0
  131. package/dist/core/styleExtractor/layout.js +86 -0
  132. package/dist/core/styleExtractor/layout.js.map +1 -0
  133. package/dist/core/styleExtractor/motion.d.ts +20 -0
  134. package/dist/core/styleExtractor/motion.d.ts.map +1 -0
  135. package/dist/core/styleExtractor/motion.js +74 -0
  136. package/dist/core/styleExtractor/motion.js.map +1 -0
  137. package/dist/core/styleExtractor/scss.d.ts +30 -0
  138. package/dist/core/styleExtractor/scss.d.ts.map +1 -0
  139. package/dist/core/styleExtractor/scss.js +80 -0
  140. package/dist/core/styleExtractor/scss.js.map +1 -0
  141. package/dist/core/styleExtractor/styleExtractor.d.ts +11 -0
  142. package/dist/core/styleExtractor/styleExtractor.d.ts.map +1 -0
  143. package/dist/core/styleExtractor/styleExtractor.js +115 -0
  144. package/dist/core/styleExtractor/styleExtractor.js.map +1 -0
  145. package/dist/core/styleExtractor/styled.d.ts +13 -0
  146. package/dist/core/styleExtractor/styled.d.ts.map +1 -0
  147. package/dist/core/styleExtractor/styled.js +31 -0
  148. package/dist/core/styleExtractor/styled.js.map +1 -0
  149. package/dist/core/styleExtractor/tailwind.d.ts +16 -0
  150. package/dist/core/styleExtractor/tailwind.d.ts.map +1 -0
  151. package/dist/core/styleExtractor/tailwind.js +85 -0
  152. package/dist/core/styleExtractor/tailwind.js.map +1 -0
  153. package/dist/core/styleExtractor.d.ts +8 -0
  154. package/dist/core/styleExtractor.d.ts.map +1 -0
  155. package/dist/core/styleExtractor.js +8 -0
  156. package/dist/core/styleExtractor.js.map +1 -0
  157. package/dist/index.d.ts +4 -2
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js.map +1 -1
  160. package/dist/types/UIFContract.d.ts +71 -0
  161. package/dist/types/UIFContract.d.ts.map +1 -1
  162. package/dist/types/UIFContract.js.map +1 -1
  163. package/dist/utils/gitignore.d.ts +6 -5
  164. package/dist/utils/gitignore.d.ts.map +1 -1
  165. package/dist/utils/gitignore.js +11 -50
  166. package/dist/utils/gitignore.js.map +1 -1
  167. package/dist/utils/llmContext.d.ts +4 -6
  168. package/dist/utils/llmContext.d.ts.map +1 -1
  169. package/dist/utils/llmContext.js +8 -59
  170. package/dist/utils/llmContext.js.map +1 -1
  171. package/dist/utils/tokens.d.ts +18 -10
  172. package/dist/utils/tokens.d.ts.map +1 -1
  173. package/dist/utils/tokens.js +112 -10
  174. package/dist/utils/tokens.js.map +1 -1
  175. package/package.json +3 -1
  176. package/schema/logicstamp.context.schema.json +288 -0
@@ -1,23 +1,116 @@
1
1
  /**
2
2
  * Token estimation utilities for GPT and Claude models
3
- * Uses character-based approximations
3
+ * Uses character-based approximations by default
4
4
  *
5
- * For production use, consider installing:
6
- * - @dqbd/tiktoken for GPT models
7
- * - @anthropic-ai/tokenizer for Claude
5
+ * For accurate token counts, optionally install:
6
+ * - @dqbd/tiktoken for GPT models (gpt-4o encoding)
7
+ * - @anthropic-ai/tokenizer for Claude (claude-3-5-sonnet-20241022 encoding)
8
8
  */
9
+ // Lazy-loaded tokenizers (only loaded if available)
10
+ let tiktokenEncoder = null;
11
+ let anthropicTokenizer = null;
12
+ let tiktokenLoaded = false;
13
+ let anthropicLoaded = false;
9
14
  /**
10
- * Estimate GPT-4 tokens using character-based approximation
11
- * GPT-4 typically uses ~4 characters per token for code/JSON
15
+ * Try to load tiktoken encoder (lazy, only once)
12
16
  */
13
- export function estimateGPT4Tokens(text) {
17
+ async function loadTiktoken() {
18
+ if (tiktokenLoaded) {
19
+ return tiktokenEncoder !== null;
20
+ }
21
+ tiktokenLoaded = true;
22
+ try {
23
+ const tiktoken = await import('@dqbd/tiktoken');
24
+ // Try encoding_for_model first (preferred API)
25
+ if (typeof tiktoken.encoding_for_model === 'function') {
26
+ tiktokenEncoder = tiktoken.encoding_for_model('gpt-4o');
27
+ return true;
28
+ }
29
+ // Fallback to get_encoding if available
30
+ if (typeof tiktoken.get_encoding === 'function') {
31
+ tiktokenEncoder = tiktoken.get_encoding('cl100k_base');
32
+ return true;
33
+ }
34
+ // If neither method exists, tokenizer not usable
35
+ return false;
36
+ }
37
+ catch (error) {
38
+ // tiktoken not installed - use fallback
39
+ return false;
40
+ }
41
+ }
42
+ /**
43
+ * Try to load Anthropic tokenizer (lazy, only once)
44
+ */
45
+ async function loadAnthropicTokenizer() {
46
+ if (anthropicLoaded) {
47
+ return anthropicTokenizer !== null;
48
+ }
49
+ anthropicLoaded = true;
50
+ try {
51
+ const tokenizer = await import('@anthropic-ai/tokenizer');
52
+ // Check if it's a default export or named export
53
+ const tokenizerModule = tokenizer.default || tokenizer;
54
+ // Try to get tokenizer for claude-3-5-sonnet-20241022 (latest stable)
55
+ if (typeof tokenizerModule === 'function') {
56
+ anthropicTokenizer = tokenizerModule;
57
+ return true;
58
+ }
59
+ // Check for countTokens method directly
60
+ if (typeof tokenizerModule.countTokens === 'function') {
61
+ anthropicTokenizer = tokenizerModule;
62
+ return true;
63
+ }
64
+ // If no usable methods, tokenizer not usable
65
+ return false;
66
+ }
67
+ catch (error) {
68
+ // tokenizer not installed - use fallback
69
+ return false;
70
+ }
71
+ }
72
+ /**
73
+ * Estimate GPT-4 tokens
74
+ * Uses @dqbd/tiktoken if available, otherwise falls back to character-based approximation
75
+ */
76
+ export async function estimateGPT4Tokens(text) {
77
+ const hasTiktoken = await loadTiktoken();
78
+ if (hasTiktoken && tiktokenEncoder) {
79
+ try {
80
+ return tiktokenEncoder.encode(text).length;
81
+ }
82
+ catch (error) {
83
+ // Fall through to character-based estimation
84
+ }
85
+ }
86
+ // Fallback: character-based approximation
87
+ // GPT-4 typically uses ~4 characters per token for code/JSON
14
88
  return Math.ceil(text.length / 4);
15
89
  }
16
90
  /**
17
- * Estimate Claude tokens using character-based approximation
18
- * Claude typically uses ~4.5 characters per token for code/JSON
91
+ * Estimate Claude tokens
92
+ * Uses @anthropic-ai/tokenizer if available, otherwise falls back to character-based approximation
19
93
  */
20
- export function estimateClaudeTokens(text) {
94
+ export async function estimateClaudeTokens(text) {
95
+ const hasTokenizer = await loadAnthropicTokenizer();
96
+ if (hasTokenizer && anthropicTokenizer) {
97
+ try {
98
+ // Try countTokens method first (most common API)
99
+ if (typeof anthropicTokenizer.countTokens === 'function') {
100
+ return anthropicTokenizer.countTokens(text);
101
+ }
102
+ // Try as a function that takes text and returns count
103
+ if (typeof anthropicTokenizer === 'function') {
104
+ const result = anthropicTokenizer(text);
105
+ return typeof result === 'number' ? result : 0;
106
+ }
107
+ }
108
+ catch (error) {
109
+ // Fall through to character-based estimation
110
+ }
111
+ }
112
+ // Fallback: character-based approximation
113
+ // Claude typically uses ~4.5 characters per token for code/JSON
21
114
  return Math.ceil(text.length / 4.5);
22
115
  }
23
116
  /**
@@ -26,4 +119,13 @@ export function estimateClaudeTokens(text) {
26
119
  export function formatTokenCount(count) {
27
120
  return count.toLocaleString();
28
121
  }
122
+ /**
123
+ * Check if tokenizers are available
124
+ * Returns status for both GPT-4 and Claude tokenizers
125
+ */
126
+ export async function getTokenizerStatus() {
127
+ const gpt4 = await loadTiktoken();
128
+ const claude = await loadAnthropicTokenizer();
129
+ return { gpt4, claude };
130
+ }
29
131
  //# sourceMappingURL=tokens.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/utils/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,IAAI,eAAe,GAAQ,IAAI,CAAC;AAChC,IAAI,kBAAkB,GAAQ,IAAI,CAAC;AACnC,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,KAAK,UAAU,YAAY;IACzB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,eAAe,KAAK,IAAI,CAAC;IA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C,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,sBAAsB,EAAE,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logicstamp-context",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Generate AI-friendly context bundles from React codebases with LogicStamp contracts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -57,6 +57,8 @@
57
57
  "ts-morph": "^21.0.1"
58
58
  },
59
59
  "devDependencies": {
60
+ "@anthropic-ai/tokenizer": "^0.0.4",
61
+ "@dqbd/tiktoken": "^1.0.17",
60
62
  "@types/node": "^20.11.5",
61
63
  "@vitest/coverage-v8": "^4.0.8",
62
64
  "@vitest/ui": "^4.0.8",
@@ -195,6 +195,10 @@
195
195
  "links": {
196
196
  "$ref": "#/definitions/ContractLinks"
197
197
  },
198
+ "style": {
199
+ "$ref": "#/definitions/StyleMetadata",
200
+ "description": "Optional style metadata (only when --include-style is used)"
201
+ },
198
202
  "semanticHash": {
199
203
  "type": "string",
200
204
  "pattern": "^uif:[a-f0-9]{24}$",
@@ -425,6 +429,290 @@
425
429
  }
426
430
  },
427
431
  "additionalProperties": false
432
+ },
433
+ "StyleMetadata": {
434
+ "type": "object",
435
+ "properties": {
436
+ "styleSources": {
437
+ "$ref": "#/definitions/StyleSources"
438
+ },
439
+ "layout": {
440
+ "$ref": "#/definitions/LayoutMetadata"
441
+ },
442
+ "visual": {
443
+ "$ref": "#/definitions/VisualMetadata"
444
+ },
445
+ "animation": {
446
+ "$ref": "#/definitions/AnimationMetadata"
447
+ },
448
+ "pageLayout": {
449
+ "$ref": "#/definitions/PageLayoutMetadata"
450
+ }
451
+ },
452
+ "additionalProperties": false
453
+ },
454
+ "StyleSources": {
455
+ "type": "object",
456
+ "properties": {
457
+ "tailwind": {
458
+ "type": "object",
459
+ "properties": {
460
+ "categories": {
461
+ "type": "object",
462
+ "additionalProperties": {
463
+ "type": "array",
464
+ "items": {
465
+ "type": "string"
466
+ }
467
+ },
468
+ "description": "Tailwind classes categorized by type (layout, spacing, colors, typography, borders, effects)"
469
+ },
470
+ "breakpoints": {
471
+ "type": "array",
472
+ "items": {
473
+ "type": "string"
474
+ },
475
+ "description": "Responsive breakpoints used (sm, md, lg, xl, 2xl)"
476
+ },
477
+ "classCount": {
478
+ "type": "number",
479
+ "description": "Total number of Tailwind classes detected"
480
+ }
481
+ },
482
+ "additionalProperties": false
483
+ },
484
+ "scssModule": {
485
+ "type": "string",
486
+ "description": "Path to imported SCSS module file"
487
+ },
488
+ "scssDetails": {
489
+ "type": "object",
490
+ "properties": {
491
+ "selectors": {
492
+ "type": "array",
493
+ "items": {
494
+ "type": "string"
495
+ },
496
+ "description": "CSS selectors found in the SCSS file"
497
+ },
498
+ "properties": {
499
+ "type": "array",
500
+ "items": {
501
+ "type": "string"
502
+ },
503
+ "description": "CSS properties used"
504
+ },
505
+ "features": {
506
+ "type": "object",
507
+ "properties": {
508
+ "variables": {
509
+ "type": "boolean",
510
+ "description": "Uses SCSS variables"
511
+ },
512
+ "nesting": {
513
+ "type": "boolean",
514
+ "description": "Uses SCSS nesting"
515
+ },
516
+ "mixins": {
517
+ "type": "boolean",
518
+ "description": "Uses SCSS mixins"
519
+ }
520
+ },
521
+ "additionalProperties": false
522
+ }
523
+ },
524
+ "additionalProperties": false
525
+ },
526
+ "cssModule": {
527
+ "type": "string",
528
+ "description": "Path to imported CSS module file"
529
+ },
530
+ "cssDetails": {
531
+ "type": "object",
532
+ "properties": {
533
+ "selectors": {
534
+ "type": "array",
535
+ "items": {
536
+ "type": "string"
537
+ }
538
+ },
539
+ "properties": {
540
+ "type": "array",
541
+ "items": {
542
+ "type": "string"
543
+ }
544
+ }
545
+ },
546
+ "additionalProperties": false
547
+ },
548
+ "inlineStyles": {
549
+ "type": "boolean",
550
+ "description": "Uses inline styles (style={{...}})"
551
+ },
552
+ "styledComponents": {
553
+ "type": "object",
554
+ "properties": {
555
+ "components": {
556
+ "type": "array",
557
+ "items": {
558
+ "type": "string"
559
+ },
560
+ "description": "Styled component names (e.g., ['div', 'Button'])"
561
+ },
562
+ "usesTheme": {
563
+ "type": "boolean",
564
+ "description": "Uses theme"
565
+ },
566
+ "usesCssProp": {
567
+ "type": "boolean",
568
+ "description": "Uses css prop"
569
+ }
570
+ },
571
+ "additionalProperties": false
572
+ },
573
+ "motion": {
574
+ "type": "object",
575
+ "properties": {
576
+ "components": {
577
+ "type": "array",
578
+ "items": {
579
+ "type": "string"
580
+ },
581
+ "description": "Motion components (motion.div, motion.button, etc.)"
582
+ },
583
+ "variants": {
584
+ "type": "array",
585
+ "items": {
586
+ "type": "string"
587
+ },
588
+ "description": "Variant names used"
589
+ },
590
+ "features": {
591
+ "type": "object",
592
+ "properties": {
593
+ "gestures": {
594
+ "type": "boolean",
595
+ "description": "Uses gesture handlers (whileHover, whileTap, etc.)"
596
+ },
597
+ "layoutAnimations": {
598
+ "type": "boolean",
599
+ "description": "Uses layout animations (layout prop)"
600
+ },
601
+ "viewportAnimations": {
602
+ "type": "boolean",
603
+ "description": "Uses viewport-triggered animations (useInView, viewport)"
604
+ }
605
+ },
606
+ "required": ["gestures", "layoutAnimations", "viewportAnimations"],
607
+ "additionalProperties": false
608
+ }
609
+ },
610
+ "required": ["features"],
611
+ "additionalProperties": false
612
+ }
613
+ },
614
+ "additionalProperties": false
615
+ },
616
+ "LayoutMetadata": {
617
+ "type": "object",
618
+ "properties": {
619
+ "type": {
620
+ "type": "string",
621
+ "enum": ["flex", "grid", "relative", "absolute"],
622
+ "description": "Layout type"
623
+ },
624
+ "cols": {
625
+ "type": "string",
626
+ "description": "Grid column pattern (e.g., 'grid-cols-2 md:grid-cols-3')"
627
+ },
628
+ "hasHeroPattern": {
629
+ "type": "boolean",
630
+ "description": "Indicates hero section pattern (large text + CTA buttons)"
631
+ },
632
+ "hasFeatureCards": {
633
+ "type": "boolean",
634
+ "description": "Indicates feature card grid pattern"
635
+ },
636
+ "sections": {
637
+ "type": "array",
638
+ "items": {
639
+ "type": "string"
640
+ },
641
+ "description": "Identified page sections"
642
+ }
643
+ },
644
+ "additionalProperties": false
645
+ },
646
+ "VisualMetadata": {
647
+ "type": "object",
648
+ "properties": {
649
+ "colors": {
650
+ "type": "array",
651
+ "items": {
652
+ "type": "string"
653
+ },
654
+ "description": "Color utility classes (sorted, limited to top 10)"
655
+ },
656
+ "spacing": {
657
+ "type": "array",
658
+ "items": {
659
+ "type": "string"
660
+ },
661
+ "description": "Spacing utility classes (sorted, limited to top 10)"
662
+ },
663
+ "radius": {
664
+ "type": "string",
665
+ "description": "Most common border radius pattern"
666
+ },
667
+ "typography": {
668
+ "type": "array",
669
+ "items": {
670
+ "type": "string"
671
+ },
672
+ "description": "Typography classes (sorted, limited to top 10)"
673
+ }
674
+ },
675
+ "additionalProperties": false
676
+ },
677
+ "AnimationMetadata": {
678
+ "type": "object",
679
+ "properties": {
680
+ "type": {
681
+ "type": "string",
682
+ "description": "Animation type (e.g., 'fade-in', 'slide')"
683
+ },
684
+ "library": {
685
+ "type": "string",
686
+ "enum": ["framer-motion", "css"],
687
+ "description": "Animation library"
688
+ },
689
+ "trigger": {
690
+ "type": "string",
691
+ "description": "Trigger type (e.g., 'inView', 'hover', 'click')"
692
+ }
693
+ },
694
+ "additionalProperties": false
695
+ },
696
+ "PageLayoutMetadata": {
697
+ "type": "object",
698
+ "properties": {
699
+ "pageRole": {
700
+ "type": "string",
701
+ "description": "Page role (e.g., 'landing', 'dashboard')"
702
+ },
703
+ "sections": {
704
+ "type": "array",
705
+ "items": {
706
+ "type": "string"
707
+ },
708
+ "description": "Page sections"
709
+ },
710
+ "ctaCount": {
711
+ "type": "number",
712
+ "description": "Number of call-to-action elements"
713
+ }
714
+ },
715
+ "additionalProperties": false
428
716
  }
429
717
  }
430
718
  }