@enterstellar-ai/contracts-shadcn 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,196 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and derivative works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the
117
+ License.
118
+
119
+ You may add Your own license statement to Your modifications and
120
+ may provide additional grant of rights to use, copy, modify, merge,
121
+ publish, distribute, sublicense, and/or sell copies of the
122
+ Modifications or such Derivative Works, and to permit recipients
123
+ of the Modifications to such Derivative Works to do so, subject to
124
+ the terms of the License.
125
+
126
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
127
+ any Contribution intentionally submitted for inclusion in the Work
128
+ by You to the Licensor shall be under the terms and conditions of
129
+ this License, without any additional terms or conditions.
130
+ Notwithstanding the above, nothing herein shall supersede or modify
131
+ the terms of any separate license agreement you may have executed
132
+ with Licensor regarding such Contributions.
133
+
134
+ 6. Trademarks. This License does not grant permission to use the trade
135
+ names, trademarks, service marks, or product names of the Licensor,
136
+ except as required for reasonable and customary use in describing the
137
+ origin of the Work and reproducing the content of the NOTICE file.
138
+
139
+ 7. Disclaimer of Warranty. Unless required by applicable law or
140
+ agreed to in writing, Licensor provides the Work (and each
141
+ Contributor provides its Contributions) on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
143
+ implied, including, without limitation, any warranties or conditions
144
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
145
+ PARTICULAR PURPOSE. You are solely responsible for determining the
146
+ appropriateness of using or reproducing the Work and assume any
147
+ risks associated with Your exercise of permissions under this License.
148
+
149
+ 8. Limitation of Liability. In no event and under no legal theory,
150
+ whether in tort (including negligence), contract, or otherwise,
151
+ unless required by applicable law (such as deliberate and grossly
152
+ negligent acts) or agreed to in writing, shall any Contributor be
153
+ liable to You for damages, including any direct, indirect, special,
154
+ incidental, or exemplary damages of any character arising as a
155
+ result of this License or out of the use or inability to use the
156
+ Work (including but not limited to damages for loss of goodwill,
157
+ work stoppage, computer failure or malfunction, or all other
158
+ commercial damages or losses), even if such Contributor has been
159
+ advised of the possibility of such damages.
160
+
161
+ 9. Accepting Warranty or Additional Liability. While redistributing
162
+ the Work or Derivative Works thereof, You may choose to offer,
163
+ and charge a fee for, acceptance of support, warranty, indemnity,
164
+ or other liability obligations and/or rights consistent with this
165
+ License. However, in accepting such obligations, You may offer such
166
+ obligations only on Your own behalf and on Your sole responsibility,
167
+ not on behalf of any other Contributor, and only if You agree to
168
+ indemnify, defend, and hold each Contributor harmless for any
169
+ liability incurred by, or claims asserted against, such Contributor
170
+ by reason of your accepting any such warranty or additional liability.
171
+
172
+ END OF TERMS AND CONDITIONS
173
+
174
+ APPENDIX: How to apply the Apache License to your work.
175
+
176
+ To apply the Apache License to your work, attach the following
177
+ boilerplate notice, with the fields enclosed by brackets "[]"
178
+ replaced with your own identifying information. (Do not include
179
+ the brackets!) The text should be enclosed in the appropriate
180
+ comment syntax for the file format in question. Please also
181
+ make a list of the licenses used in the work and ask the
182
+ maintainers for clarification if needed.
183
+
184
+ Copyright 2026 LifeOS Frameworks, Inc. (DBA Enterstellar) and A. Yassin
185
+
186
+ Licensed under the Apache License, Version 2.0 (the "License");
187
+ you may not use this file except in compliance with the License.
188
+ You may obtain a copy of the License at
189
+
190
+ http://www.apache.org/licenses/LICENSE-2.0
191
+
192
+ Unless required by applicable law or agreed to in writing, software
193
+ distributed under the License is distributed on an "AS IS" BASIS,
194
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
195
+ See the License for the specific language governing permissions and
196
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ Enterstellar
2
+ Copyright 2026 LifeOS Frameworks, Inc. (DBA Enterstellar) and A. Yassin
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (the "License").
5
+ You may not use this product except in compliance with the License.
6
+ You may obtain a copy of the License at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed
11
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ specific language governing permissions and limitations under the License.
14
+
15
+ For licensing inquiries, contact: legal@enterstellar.dev
16
+ Homepage: https://enterstellar.dev
17
+ Repository: https://github.com/enterstellar-ai/enterstellar
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # @enterstellar-ai/contracts-shadcn
2
+
3
+ > Pre-converted Enterstellar ComponentContracts for [shadcn/ui](https://ui.shadcn.com/) — enabling one-line registration of shadcn components into the Enterstellar GenUI Compiler.
4
+
5
+ shadcn/ui uses a **code-copy distribution model** — components are copied into the developer's source tree, not installed from npm. This means there is no universal import path that this package can reference directly. Instead, developers provide their local component implementations via `registerShadcnContracts()`.
6
+
7
+ ## Current State
8
+
9
+ - **Registration logic:** Production-grade with 3-path validation.
10
+ - **Contracts:** Empty. Populated by the CI sync pipeline (`sync-contracts-shadcn.yml`).
11
+ - **Once contracts land**, `registerShadcnContracts()` will validate and pair them with local component implementations via `defineComponent()`.
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';
17
+ import { createRegistry } from '@enterstellar-ai/registry';
18
+
19
+ // Import your local shadcn component implementations.
20
+ import { Button } from '@/components/ui/button';
21
+ import { Card } from '@/components/ui/card';
22
+ import { Dialog } from '@/components/ui/dialog';
23
+
24
+ // Register: pairs your components with Enterstellar contracts.
25
+ const contracts = registerShadcnContracts({ Button, Card, Dialog });
26
+
27
+ // Include in your Enterstellar registry alongside your own contracts.
28
+ const registry = createRegistry({
29
+ components: [...myContracts, ...contracts],
30
+ });
31
+ ```
32
+
33
+ ## API Reference
34
+
35
+ ### `registerShadcnContracts(components)`
36
+
37
+ | Parameter | Type | Description |
38
+ | :----------- | :------------------- | :--------------------------------------------------------------------------- |
39
+ | `components` | `ShadcnComponentMap` | Map of contract names (PascalCase) to local React component implementations. |
40
+
41
+ **Returns:** `readonly ComponentContract[]` — validated contracts for `createRegistry()`.
42
+
43
+ **Throws:**
44
+
45
+ | Condition | Error Message |
46
+ | :----------------------- | :----------------------------------------------------------------------------------- |
47
+ | Unknown key (typo) | `'Buttn' is not a known shadcn contract. Did you mean 'Button'?` |
48
+ | `undefined`/`null` value | `Component 'Button' was not provided. Run 'npx shadcn@latest add button' to add it.` |
49
+
50
+ **Warn (console.warn):**
51
+
52
+ | Condition | Message |
53
+ | :------------------------- | :------------------------------------------------------------------------------------------ |
54
+ | Missing key (not provided) | `ShadcnButton: contract registered without renderer. <Zone> will use GenericCard fallback.` |
55
+
56
+ ### `ShadcnComponentMap`
57
+
58
+ ```ts
59
+ type ShadcnComponentMap = Partial<
60
+ Record<ShadcnContractName, ComponentType<Record<string, unknown>>>
61
+ >;
62
+ ```
63
+
64
+ Keys must match contract names in PascalCase. Missing keys are valid — contracts are registered without renderers, falling back to `GenericCard`. Unknown keys trigger an error with a Levenshtein-based suggestion (distance ≤ 3).
65
+
66
+ ### `SHADCN_CONTRACTS`
67
+
68
+ ```ts
69
+ export const SHADCN_CONTRACTS: Record<string, ComponentContractInput> = {};
70
+ ```
71
+
72
+ Master record of all shadcn/ui component contracts. Empty pre-CI — populated by the sync pipeline. Each key is a PascalCase component name, each value is a `defineComponent()`-compatible input.
73
+
74
+ ### Utilities
75
+
76
+ | Export | Description |
77
+ | :------------------------------------ | :----------------------------------------------------------- |
78
+ | `levenshteinDistance(a, b)` | Edit distance between two strings (O(m×n) time, O(n) space). |
79
+ | `findClosestMatch(input, candidates)` | Best match within distance ≤ 3, or `undefined`. |
80
+
81
+ ## Configuration
82
+
83
+ No configuration required. This package provides pre-built contracts — no build step, no code generation needed by the consumer.
84
+
85
+ ### Dependencies
86
+
87
+ | Package | Purpose |
88
+ | :--------------------------------- | :------------------------------------------------------------------------------- |
89
+ | `@enterstellar-ai/react` (peer) | Provides `defineComponent()` for contract validation and renderer registration. |
90
+ | `@enterstellar-ai/registry` (peer) | Provides `defineComponent()` and `ComponentContractInput` for contract creation. |
91
+ | `@enterstellar-ai/types` (peer) | Provides `ComponentContract` type definition. |
92
+ | `zod` (peer) | Runtime schema validation for contract prop types. |
93
+
94
+ > **Note:** There is no `shadcn` peer dependency — shadcn uses a code-copy model. The developer imports their own copied components directly.
95
+
96
+ ## CI Sync Pipeline
97
+
98
+ The `.github/workflows/sync-contracts-shadcn.yml` workflow defines the contract generation pipeline:
99
+
100
+ 1. `npx shadcn@latest add --all` — fetch latest component source.
101
+ 2. `enterstellar migrate` — generate contracts from source.
102
+ 3. Diff against published contracts.
103
+ 4. Classify changes (minor/major/deprecation).
104
+ 5. Open human-gated PR if changes detected.
105
+
106
+ Schedule: Weekly, Monday 06:00 UTC.
107
+
108
+ ## File Structure
109
+
110
+ ```
111
+ packages/contracts-shadcn/
112
+ ├── src/
113
+ │ ├── index.ts ← Barrel: public API surface
114
+ │ ├── register.ts ← registerShadcnContracts() implementation
115
+ │ ├── contracts/
116
+ │ │ └── index.ts ← SHADCN_CONTRACTS record (populated by CI)
117
+ │ └── utils/
118
+ │ └── levenshtein.ts ← Levenshtein distance + closest match
119
+ ├── __tests__/
120
+ │ ├── smoke.test.ts ← Barrel export smoke tests
121
+ │ ├── register.test.ts ← Registration validation path tests
122
+ │ └── levenshtein.test.ts ← Edit distance + closest match tests
123
+ ├── package.json
124
+ ├── tsconfig.json
125
+ ├── tsup.config.ts
126
+ └── vitest.config.ts
127
+ ```
128
+
129
+ ## See Also
130
+
131
+ - [Contract Packs Spec](../../archive/ADOPTION/migration/migration-05-contract-packs.md) — Correction 7: contract pack architecture.
132
+ - [Migration Pipeline](../../archive/ADOPTION/migration/migration-01-pipeline.md) — Corrections 1 & 2: the pipeline that generates contracts.
133
+ - [Coding Rules](../../agent/05-enterstellar-coding-rules.md) — naming conventions, strictness requirements.
package/dist/index.cjs ADDED
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ var Registry = require('@enterstellar-ai/registry');
4
+ var react = require('@enterstellar-ai/react');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var Registry__namespace = /*#__PURE__*/_interopNamespace(Registry);
25
+
26
+ // src/register.ts
27
+
28
+ // src/contracts/index.ts
29
+ var SHADCN_CONTRACTS = {
30
+ // -------------------------------------------------------------------------
31
+ // Populated by CI sync pipeline (sync-contracts-shadcn.yml).
32
+ // Each entry is a defineComponent()-compatible contract input.
33
+ //
34
+ // DO NOT add entries manually — they are auto-generated by running
35
+ // `enterstellar migrate` against upstream shadcn/ui source components.
36
+ // -------------------------------------------------------------------------
37
+ };
38
+
39
+ // src/utils/levenshtein.ts
40
+ var MATCH_THRESHOLD = 3;
41
+ function levenshteinDistance(a, b) {
42
+ if (a === b) {
43
+ return 0;
44
+ }
45
+ const m = a.length;
46
+ const n = b.length;
47
+ if (m === 0) {
48
+ return n;
49
+ }
50
+ if (n === 0) {
51
+ return m;
52
+ }
53
+ let prev = Array.from({ length: n + 1 }, (_, j) => j);
54
+ let curr = new Array(n + 1);
55
+ for (let i = 1; i <= m; i++) {
56
+ curr[0] = i;
57
+ for (let j = 1; j <= n; j++) {
58
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
59
+ const deletion = (prev[j] ?? 0) + 1;
60
+ const insertion = (curr[j - 1] ?? 0) + 1;
61
+ const substitution = (prev[j - 1] ?? 0) + cost;
62
+ curr[j] = Math.min(deletion, insertion, substitution);
63
+ }
64
+ [prev, curr] = [curr, prev];
65
+ }
66
+ return prev[n] ?? 0;
67
+ }
68
+ function findClosestMatch(input, candidates) {
69
+ let bestMatch;
70
+ let bestDistance = MATCH_THRESHOLD + 1;
71
+ for (const candidate of candidates) {
72
+ const distance = levenshteinDistance(input, candidate);
73
+ if (distance < bestDistance) {
74
+ bestDistance = distance;
75
+ bestMatch = candidate;
76
+ }
77
+ if (distance === 0) {
78
+ break;
79
+ }
80
+ }
81
+ return bestDistance <= MATCH_THRESHOLD ? bestMatch : void 0;
82
+ }
83
+
84
+ // src/register.ts
85
+ function registerShadcnContracts(components) {
86
+ const contracts = [];
87
+ const knownNames = Object.keys(SHADCN_CONTRACTS);
88
+ for (const key of Object.keys(components)) {
89
+ if (!(key in SHADCN_CONTRACTS)) {
90
+ const suggestion = findClosestMatch(key, knownNames);
91
+ const hint = suggestion !== void 0 ? ` Did you mean '${suggestion}'?` : "";
92
+ throw new Error(
93
+ `'${key}' is not a known shadcn contract.${hint}`
94
+ );
95
+ }
96
+ }
97
+ for (const [name, contractInput] of Object.entries(SHADCN_CONTRACTS)) {
98
+ const typedInput = contractInput;
99
+ const isProvided = name in components;
100
+ const component = components[name];
101
+ if (isProvided && component == null) {
102
+ throw new Error(
103
+ `Component '${name}' was not provided (received ${String(component)}). Run 'npx shadcn@latest add ${name.toLowerCase()}' to add it.`
104
+ );
105
+ }
106
+ if (component === void 0) {
107
+ console.warn(
108
+ `Shadcn${name}: contract registered without renderer. <Zone> will use GenericCard fallback. Pass ${name} to registerShadcnContracts() to enable full rendering.`
109
+ );
110
+ contracts.push(Registry__namespace.defineComponent(typedInput));
111
+ continue;
112
+ }
113
+ const { contract } = react.defineComponent({
114
+ contract: typedInput,
115
+ render: component
116
+ });
117
+ contracts.push(contract);
118
+ }
119
+ return contracts;
120
+ }
121
+
122
+ exports.SHADCN_CONTRACTS = SHADCN_CONTRACTS;
123
+ exports.findClosestMatch = findClosestMatch;
124
+ exports.levenshteinDistance = levenshteinDistance;
125
+ exports.registerShadcnContracts = registerShadcnContracts;
126
+ //# sourceMappingURL=index.cjs.map
127
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contracts/index.ts","../src/utils/levenshtein.ts","../src/register.ts"],"names":["Registry","defineComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,IAAM,gBAAA,GAA2D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQxE;;;AC1BA,IAAM,eAAA,GAAkB,CAAA;AA4BjB,SAAS,mBAAA,CAAoB,GAAW,CAAA,EAAmB;AAE9D,EAAA,IAAI,MAAM,CAAA,EAAG;AACT,IAAA,OAAO,CAAA;AAAA,EACX;AAEA,EAAA,MAAM,IAAI,CAAA,CAAE,MAAA;AACZ,EAAA,MAAM,IAAI,CAAA,CAAE,MAAA;AAGZ,EAAA,IAAI,MAAM,CAAA,EAAG;AACT,IAAA,OAAO,CAAA;AAAA,EACX;AACA,EAAA,IAAI,MAAM,CAAA,EAAG;AACT,IAAA,OAAO,CAAA;AAAA,EACX;AAIA,EAAA,IAAI,IAAA,GAAiB,KAAA,CAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAA,GAAI,CAAA,EAAE,EAAG,CAAC,CAAA,EAAG,CAAA,KAAM,CAAC,CAAA;AAC9D,EAAA,IAAI,IAAA,GAAiB,IAAI,KAAA,CAAc,CAAA,GAAI,CAAC,CAAA;AAE5C,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,IAAK,CAAA,EAAG,CAAA,EAAA,EAAK;AACzB,IAAA,IAAA,CAAK,CAAC,CAAA,GAAI,CAAA;AAEV,IAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,IAAK,CAAA,EAAG,CAAA,EAAA,EAAK;AAEzB,MAAA,MAAM,IAAA,GAAO,EAAE,CAAA,GAAI,CAAC,MAAM,CAAA,CAAE,CAAA,GAAI,CAAC,CAAA,GAAI,CAAA,GAAI,CAAA;AAMzC,MAAA,MAAM,QAAA,GAAA,CAAY,IAAA,CAAK,CAAC,CAAA,IAAK,CAAA,IAAK,CAAA;AAClC,MAAA,MAAM,SAAA,GAAA,CAAa,IAAA,CAAK,CAAA,GAAI,CAAC,KAAK,CAAA,IAAK,CAAA;AACvC,MAAA,MAAM,YAAA,GAAA,CAAgB,IAAA,CAAK,CAAA,GAAI,CAAC,KAAK,CAAA,IAAK,IAAA;AAE1C,MAAA,IAAA,CAAK,CAAC,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,QAAA,EAAU,WAAW,YAAY,CAAA;AAAA,IACxD;AAGA,IAAA,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,CAAC,MAAM,IAAI,CAAA;AAAA,EAC9B;AAIA,EAAA,OAAO,IAAA,CAAK,CAAC,CAAA,IAAK,CAAA;AACtB;AA+BO,SAAS,gBAAA,CACZ,OACA,UAAA,EACkB;AAClB,EAAA,IAAI,SAAA;AACJ,EAAA,IAAI,eAAe,eAAA,GAAkB,CAAA;AAErC,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAChC,IAAA,MAAM,QAAA,GAAW,mBAAA,CAAoB,KAAA,EAAO,SAAS,CAAA;AAErD,IAAA,IAAI,WAAW,YAAA,EAAc;AACzB,MAAA,YAAA,GAAe,QAAA;AACf,MAAA,SAAA,GAAY,SAAA;AAAA,IAChB;AAGA,IAAA,IAAI,aAAa,CAAA,EAAG;AAChB,MAAA;AAAA,IACJ;AAAA,EACJ;AAGA,EAAA,OAAO,YAAA,IAAgB,kBAAkB,SAAA,GAAY,MAAA;AACzD;;;AC9CO,SAAS,wBACZ,UAAA,EAC4B;AAC5B,EAAA,MAAM,YAAiC,EAAC;AACxC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,gBAAgB,CAAA;AAQ/C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA,EAAG;AACvC,IAAA,IAAI,EAAE,OAAO,gBAAA,CAAA,EAAmB;AAC5B,MAAA,MAAM,UAAA,GAAa,gBAAA,CAAiB,GAAA,EAAK,UAAU,CAAA;AACnD,MAAA,MAAM,IAAA,GAAO,UAAA,KAAe,MAAA,GACtB,CAAA,eAAA,EAAkB,UAAU,CAAA,EAAA,CAAA,GAC5B,EAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,CAAA,CAAA,EAAI,GAAG,CAAA,iCAAA,EAAoC,IAAI,CAAA;AAAA,OACnD;AAAA,IACJ;AAAA,EACJ;AAKA,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,aAAa,KAAK,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAA,EAAG;AAClE,IAAA,MAAM,UAAA,GAAqC,aAAA;AAG3C,IAAA,MAAM,aAAa,IAAA,IAAQ,UAAA;AAC3B,IAAA,MAAM,SAAA,GAAa,WAAkF,IAAI,CAAA;AAMzG,IAAA,IAAI,UAAA,IAAc,aAAa,IAAA,EAAM;AACjC,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,CAAA,WAAA,EAAc,IAAI,CAAA,6BAAA,EAAgC,MAAA,CAAO,SAAS,CAAC,CAAA,8BAAA,EACrC,IAAA,CAAK,WAAA,EAAa,CAAA,YAAA;AAAA,OACpD;AAAA,IACJ;AAMA,IAAA,IAAI,cAAc,MAAA,EAAW;AACzB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACJ,CAAA,MAAA,EAAS,IAAI,CAAA,mFAAA,EAEL,IAAI,CAAA,uDAAA;AAAA,OAChB;AACA,MAAA,SAAA,CAAU,IAAA,CAAcA,mBAAA,CAAA,eAAA,CAAgB,UAAU,CAAC,CAAA;AACnD,MAAA;AAAA,IACJ;AAMA,IAAA,MAAM,EAAE,QAAA,EAAS,GAAIC,qBAAAA,CAAgB;AAAA,MACjC,QAAA,EAAU,UAAA;AAAA,MACV,MAAA,EAAQ;AAAA,KACX,CAAA;AACD,IAAA,SAAA,CAAU,KAAK,QAAQ,CAAA;AAAA,EAC3B;AAEA,EAAA,OAAO,SAAA;AACX","file":"index.cjs","sourcesContent":["/**\n * @module @enterstellar-ai/contracts-shadcn/contracts\n * @description Barrel export for shadcn/ui component contracts.\n *\n * This directory is the target for the CI sync pipeline\n * (`sync-contracts-shadcn.yml`). The pipeline:\n *\n * 1. Scaffolds a temp Next.js project.\n * 2. Runs `npx shadcn@latest add --all` to install all components.\n * 3. Runs `enterstellar migrate` against the installed source files.\n * 4. Copies generated `*.contract.ts` files into this directory.\n * 5. Opens a human-gated PR with the updated contracts.\n *\n * **Pre-CI state:** `SHADCN_CONTRACTS` is an empty record. The type\n * infrastructure is in place so that `registerShadcnContracts()` can\n * operate against the record immediately when contracts arrive.\n *\n * **Post-CI state:** Each CI run adds/updates contract entries like:\n * ```ts\n * export const SHADCN_CONTRACTS = {\n * Button: { name: 'Button', description: '...', props: z.object({...}), ... },\n * Card: { name: 'Card', description: '...', props: z.object({...}), ... },\n * // ... ~50 components\n * } as const satisfies Record<string, ComponentContractInput>;\n * ```\n *\n * @see Correction 7 Decision 3 — CI Sync Pipeline\n * @see sync-contracts-shadcn.yml — workflow definition\n */\n\nimport type { ComponentContractInput } from '@enterstellar-ai/registry'; // Audit E1: from @enterstellar-ai/registry, NOT @enterstellar-ai/types\n\n// ---------------------------------------------------------------------------\n// Contract Record\n// ---------------------------------------------------------------------------\n\n/**\n * Master record of all shadcn/ui component contracts.\n *\n * **Current state:** Empty. Populated by the CI sync pipeline.\n *\n * Each key is a PascalCase component name (e.g., `'Button'`, `'Card'`).\n * Each value is a `ComponentContractInput` — the input to\n * `defineComponent()` from `@enterstellar-ai/registry`.\n *\n * When contracts exist, this record is used by:\n * - `registerShadcnContracts()` — to validate component maps and pair renderers.\n * - `ShadcnContractName` — derived literal union for type-safe keys.\n *\n * @see registerShadcnContracts — uses this record for validation + pairing\n * @see defineComponent — accepts each value as input\n */\nexport const SHADCN_CONTRACTS: Record<string, ComponentContractInput> = {\n // -------------------------------------------------------------------------\n // Populated by CI sync pipeline (sync-contracts-shadcn.yml).\n // Each entry is a defineComponent()-compatible contract input.\n //\n // DO NOT add entries manually — they are auto-generated by running\n // `enterstellar migrate` against upstream shadcn/ui source components.\n // -------------------------------------------------------------------------\n};\n\n// ---------------------------------------------------------------------------\n// Derived Types\n// ---------------------------------------------------------------------------\n\n/**\n * Union type of all known shadcn/ui contract names.\n *\n * **Pre-CI:** Resolves to `string` (empty record → `string` keys).\n * **Post-CI:** Resolves to a literal union (e.g., `'Button' | 'Card' | ...`)\n * when the record is populated and typed with `as const satisfies`.\n *\n * Used by `ShadcnComponentMap` to provide compile-time key validation.\n */\nexport type ShadcnContractName = keyof typeof SHADCN_CONTRACTS;\n","/**\n * @module @enterstellar-ai/contracts-shadcn/utils/levenshtein\n * @description Pure-function Levenshtein distance implementation for fuzzy\n * contract name validation.\n *\n * Used by {@link registerShadcnContracts} to provide actionable error\n * messages when a developer passes an unknown component name:\n *\n * ```\n * Error: 'Buttn' is not a known shadcn contract. Did you mean 'Button'?\n * ```\n *\n * **Zero dependencies. Zero framework imports. Pure functions only.**\n *\n * The threshold distance is **3** — any candidate with a distance ≤ 3\n * from the input is considered a viable suggestion. This covers:\n * - 1-char typos (distance 1): `Buttn` → `Button`\n * - Transpositions (distance 2): `Cadr` → `Card`\n * - Prefix/suffix errors (distance 2-3): `Dialg` → `Dialog`\n *\n * @see Correction 7 Decision 2 — fuzzy-validated registration\n */\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/**\n * Maximum Levenshtein distance to consider a candidate a valid suggestion.\n *\n * A threshold of 3 covers common typos (single-char, transposition,\n * prefix/suffix) while avoiding false positives on completely unrelated\n * names. Empirically validated against shadcn component names.\n */\nconst MATCH_THRESHOLD = 3;\n\n// ---------------------------------------------------------------------------\n// Levenshtein Distance\n// ---------------------------------------------------------------------------\n\n/**\n * Computes the Levenshtein distance between two strings.\n *\n * The Levenshtein distance is the minimum number of single-character\n * edits (insertions, deletions, or substitutions) required to change\n * one string into the other.\n *\n * Uses the standard O(m×n) dynamic programming algorithm with O(n)\n * space (two-row optimization).\n *\n * @param a - First string.\n * @param b - Second string.\n * @returns The edit distance between `a` and `b`. Always ≥ 0.\n *\n * @example\n * ```ts\n * levenshteinDistance('Button', 'Buttn'); // → 1\n * levenshteinDistance('Card', 'Cadr'); // → 2\n * levenshteinDistance('', 'Hello'); // → 5\n * levenshteinDistance('same', 'same'); // → 0\n * ```\n */\nexport function levenshteinDistance(a: string, b: string): number {\n // Early exit: identical strings.\n if (a === b) {\n return 0;\n }\n\n const m = a.length;\n const n = b.length;\n\n // Edge cases: one string is empty.\n if (m === 0) {\n return n;\n }\n if (n === 0) {\n return m;\n }\n\n // Two-row DP: prev = row (i-1), curr = row i.\n // Each row has (n + 1) entries.\n let prev: number[] = Array.from({ length: n + 1 }, (_, j) => j);\n let curr: number[] = new Array<number>(n + 1);\n\n for (let i = 1; i <= m; i++) {\n curr[0] = i;\n\n for (let j = 1; j <= n; j++) {\n // Cost is 0 if characters match, 1 otherwise.\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\n // Minimum of insertion, deletion, or substitution.\n // prev[j] + 1: deletion (remove from a)\n // (curr[j - 1] ?? 0) + 1: insertion (add to a)\n // (prev[j - 1] ?? 0) + cost: substitution\n const deletion = (prev[j] ?? 0) + 1;\n const insertion = (curr[j - 1] ?? 0) + 1;\n const substitution = (prev[j - 1] ?? 0) + cost;\n\n curr[j] = Math.min(deletion, insertion, substitution);\n }\n\n // Swap rows: curr becomes prev for next iteration.\n [prev, curr] = [curr, prev];\n }\n\n // After the loop, prev contains the last computed row.\n // The answer is in prev[n].\n return prev[n] ?? 0;\n}\n\n// ---------------------------------------------------------------------------\n// Closest Match Finder\n// ---------------------------------------------------------------------------\n\n/**\n * Finds the closest matching string from a list of candidates using\n * Levenshtein distance.\n *\n * Returns the candidate with the smallest distance to `input`, provided\n * that distance is ≤ {@link MATCH_THRESHOLD} (3). If no candidate is\n * within threshold, returns `undefined`.\n *\n * When multiple candidates share the minimum distance, the first one\n * encountered is returned (stable, deterministic ordering).\n *\n * @param input - The string to match against candidates.\n * @param candidates - The list of valid candidate strings.\n * @returns The closest matching candidate, or `undefined` if none\n * are within the threshold distance.\n *\n * @example\n * ```ts\n * const names = ['Button', 'Card', 'Dialog', 'Input'];\n *\n * findClosestMatch('Buttn', names); // → 'Button' (distance 1)\n * findClosestMatch('Crad', names); // → 'Card' (distance 2)\n * findClosestMatch('Xyz', names); // → undefined (no close match)\n * ```\n */\nexport function findClosestMatch(\n input: string,\n candidates: readonly string[],\n): string | undefined {\n let bestMatch: string | undefined;\n let bestDistance = MATCH_THRESHOLD + 1; // Start above threshold.\n\n for (const candidate of candidates) {\n const distance = levenshteinDistance(input, candidate);\n\n if (distance < bestDistance) {\n bestDistance = distance;\n bestMatch = candidate;\n }\n\n // Perfect match — can't do better.\n if (distance === 0) {\n break;\n }\n }\n\n // Only return if within threshold.\n return bestDistance <= MATCH_THRESHOLD ? bestMatch : undefined;\n}\n","/**\n * @module @enterstellar-ai/contracts-shadcn/register\n * @description Registration API for pairing shadcn/ui components with\n * Enterstellar ComponentContracts.\n *\n * shadcn/ui uses a **code-copy distribution model** — components are copied\n * into the developer's source tree (e.g., `@/components/ui/button`), not\n * installed from npm. This means there is no universal import path for\n * shadcn components that this package can reference directly.\n *\n * Instead, the developer provides their local component imports via\n * {@link registerShadcnContracts}:\n *\n * @example\n * ```ts\n * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';\n * import { Button } from '@/components/ui/button';\n * import { Card } from '@/components/ui/card';\n *\n * const contracts = registerShadcnContracts({ Button, Card });\n * const registry = createRegistry({ components: [...myContracts, ...contracts] });\n * ```\n *\n * ## Validation Rules\n *\n * 1. **Unknown keys** → throw with Levenshtein fuzzy suggestion.\n * 2. **`undefined`/`null` values** → throw with `npx shadcn add` hint.\n * 3. **Missing keys** → `console.warn` with GenericCard fallback message.\n * 4. **Valid components** → `defineComponent()` pairing.\n *\n * @see Correction 7 Decision 2 — Code-Copy Libraries\n * @see Correction 7 Decision 3 — CI Sync Pipeline\n */\n\nimport type { ComponentType } from 'react'; // type-only — erased at compile time (Audit N1)\n\nimport type { ComponentContract } from '@enterstellar-ai/types';\nimport * as Registry from '@enterstellar-ai/registry'; // Audit E2: explicit import\nimport type { ComponentContractInput } from '@enterstellar-ai/registry'; // Audit E1: from @enterstellar-ai/registry, NOT @enterstellar-ai/types\nimport { defineComponent } from '@enterstellar-ai/react';\n\nimport { SHADCN_CONTRACTS } from './contracts/index.js';\nimport type { ShadcnContractName } from './contracts/index.js';\nimport { findClosestMatch } from './utils/levenshtein.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Map of component names to React components provided by the developer.\n *\n * Keys must match contract names (PascalCase). Validation rules:\n * - **Unknown keys** throw an `Error` with a Levenshtein-based fuzzy\n * suggestion (e.g., \"Did you mean 'Button'?\" when given 'Buttn').\n * - **`undefined`/`null` values** throw an `Error` with a\n * `npx shadcn@latest add` hint for the missing component.\n * - **Missing keys** log `console.warn` — the contract is registered\n * without a renderer, which falls back to `GenericCard`.\n *\n * Uses `Record<string, unknown>` to match `defineComponent()`'s\n * `TProps extends Record<string, unknown>` constraint (Audit M7).\n *\n * @see Correction 7 Decision 2 — registerShadcnContracts() pairing pattern\n * @see defineComponent — TProps constraint\n */\nexport type ShadcnComponentMap = Partial<\n Record<ShadcnContractName, ComponentType<Record<string, unknown>>>\n>;\n\n// ---------------------------------------------------------------------------\n// Registration API\n// ---------------------------------------------------------------------------\n\n/**\n * Registers shadcn/ui contracts and pairs them with the developer's\n * local component implementations.\n *\n * **Validation sequence:**\n * 1. Iterate over all keys in the provided `components` map.\n * 2. For each key NOT in `SHADCN_CONTRACTS`, throw with a Levenshtein\n * fuzzy suggestion (if one exists within distance ≤ 3).\n * 3. Iterate over all entries in `SHADCN_CONTRACTS`:\n * - If the key was explicitly passed as `undefined` or `null`,\n * throw with `npx shadcn@latest add <name>` hint.\n * - If the key was not provided at all, `console.warn` that\n * GenericCard fallback will be used, and register the contract\n * without a renderer via `defineComponent()`.\n * - If the key was provided with a valid component, pair via\n * `defineComponent()` and collect the validated contract.\n *\n * @param components - Map of contract names to local React components.\n * Keys must be PascalCase and match known contract names.\n * @returns Readonly array of validated `ComponentContract` objects for\n * `createRegistry({ components: [...] })`.\n * @throws {Error} If a key doesn't match any known contract\n * (with Levenshtein-based fuzzy suggestion).\n * @throws {Error} If a component value is explicitly `undefined` or `null`\n * (with `npx shadcn@latest add` hint).\n *\n * @example\n * ```ts\n * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';\n * import { Button } from '@/components/ui/button';\n * import { Card } from '@/components/ui/card';\n * import { Dialog } from '@/components/ui/dialog';\n *\n * const contracts = registerShadcnContracts({ Button, Card, Dialog });\n *\n * const registry = createRegistry({\n * components: [...myContracts, ...contracts],\n * });\n * ```\n *\n * @see Correction 7 Decision 2 — Code-Copy Libraries\n * @see defineComponent — internal pairing mechanism\n */\nexport function registerShadcnContracts(\n components: ShadcnComponentMap,\n): readonly ComponentContract[] {\n const contracts: ComponentContract[] = [];\n const knownNames = Object.keys(SHADCN_CONTRACTS);\n\n // -------------------------------------------------------------------------\n // Phase 1: Validate unknown keys (throw with fuzzy suggestion)\n // -------------------------------------------------------------------------\n // Check every key the developer provided against the known contract names.\n // This runs first so the developer gets immediate feedback on typos before\n // any contracts are registered.\n for (const key of Object.keys(components)) {\n if (!(key in SHADCN_CONTRACTS)) {\n const suggestion = findClosestMatch(key, knownNames);\n const hint = suggestion !== undefined\n ? ` Did you mean '${suggestion}'?`\n : '';\n throw new Error(\n `'${key}' is not a known shadcn contract.${hint}`,\n );\n }\n }\n\n // -------------------------------------------------------------------------\n // Phase 2: Register each known contract\n // -------------------------------------------------------------------------\n for (const [name, contractInput] of Object.entries(SHADCN_CONTRACTS)) {\n const typedInput: ComponentContractInput = contractInput;\n\n // Check if the developer provided this key at all.\n const isProvided = name in components;\n const component = (components as Record<string, ComponentType<Record<string, unknown>> | undefined>)[name];\n\n // --- Case: explicitly passed undefined/null ---\n // The developer listed the key but didn't provide a component.\n // This is likely a mistake — they intended to provide it but forgot\n // to install/import it.\n if (isProvided && component == null) {\n throw new Error(\n `Component '${name}' was not provided (received ${String(component)}). ` +\n `Run 'npx shadcn@latest add ${name.toLowerCase()}' to add it.`,\n );\n }\n\n // --- Case: not provided at all ---\n // The developer didn't list this key in the map. This is intentional —\n // they don't have this component installed. Register the contract\n // without a renderer so GenericCard can fall back.\n if (component === undefined) {\n console.warn(\n `Shadcn${name}: contract registered without renderer. ` +\n `<Zone> will use GenericCard fallback. ` +\n `Pass ${name} to registerShadcnContracts() to enable full rendering.`,\n );\n contracts.push(Registry.defineComponent(typedInput));\n continue;\n }\n\n // --- Case: provided with a valid component ---\n // Pair the contract with the developer's local component implementation\n // via defineComponent(). This validates the contract, freezes it,\n // and registers the renderer in the module-level RendererRegistry.\n const { contract } = defineComponent({\n contract: typedInput,\n render: component,\n });\n contracts.push(contract);\n }\n\n return contracts;\n}\n"]}
@@ -0,0 +1,232 @@
1
+ import { ComponentType } from 'react';
2
+ import { ComponentContract } from '@enterstellar-ai/types';
3
+ import { ComponentContractInput } from '@enterstellar-ai/registry';
4
+
5
+ /**
6
+ * @module @enterstellar-ai/contracts-shadcn/contracts
7
+ * @description Barrel export for shadcn/ui component contracts.
8
+ *
9
+ * This directory is the target for the CI sync pipeline
10
+ * (`sync-contracts-shadcn.yml`). The pipeline:
11
+ *
12
+ * 1. Scaffolds a temp Next.js project.
13
+ * 2. Runs `npx shadcn@latest add --all` to install all components.
14
+ * 3. Runs `enterstellar migrate` against the installed source files.
15
+ * 4. Copies generated `*.contract.ts` files into this directory.
16
+ * 5. Opens a human-gated PR with the updated contracts.
17
+ *
18
+ * **Pre-CI state:** `SHADCN_CONTRACTS` is an empty record. The type
19
+ * infrastructure is in place so that `registerShadcnContracts()` can
20
+ * operate against the record immediately when contracts arrive.
21
+ *
22
+ * **Post-CI state:** Each CI run adds/updates contract entries like:
23
+ * ```ts
24
+ * export const SHADCN_CONTRACTS = {
25
+ * Button: { name: 'Button', description: '...', props: z.object({...}), ... },
26
+ * Card: { name: 'Card', description: '...', props: z.object({...}), ... },
27
+ * // ... ~50 components
28
+ * } as const satisfies Record<string, ComponentContractInput>;
29
+ * ```
30
+ *
31
+ * @see Correction 7 Decision 3 — CI Sync Pipeline
32
+ * @see sync-contracts-shadcn.yml — workflow definition
33
+ */
34
+
35
+ /**
36
+ * Master record of all shadcn/ui component contracts.
37
+ *
38
+ * **Current state:** Empty. Populated by the CI sync pipeline.
39
+ *
40
+ * Each key is a PascalCase component name (e.g., `'Button'`, `'Card'`).
41
+ * Each value is a `ComponentContractInput` — the input to
42
+ * `defineComponent()` from `@enterstellar-ai/registry`.
43
+ *
44
+ * When contracts exist, this record is used by:
45
+ * - `registerShadcnContracts()` — to validate component maps and pair renderers.
46
+ * - `ShadcnContractName` — derived literal union for type-safe keys.
47
+ *
48
+ * @see registerShadcnContracts — uses this record for validation + pairing
49
+ * @see defineComponent — accepts each value as input
50
+ */
51
+ declare const SHADCN_CONTRACTS: Record<string, ComponentContractInput>;
52
+ /**
53
+ * Union type of all known shadcn/ui contract names.
54
+ *
55
+ * **Pre-CI:** Resolves to `string` (empty record → `string` keys).
56
+ * **Post-CI:** Resolves to a literal union (e.g., `'Button' | 'Card' | ...`)
57
+ * when the record is populated and typed with `as const satisfies`.
58
+ *
59
+ * Used by `ShadcnComponentMap` to provide compile-time key validation.
60
+ */
61
+ type ShadcnContractName = keyof typeof SHADCN_CONTRACTS;
62
+
63
+ /**
64
+ * @module @enterstellar-ai/contracts-shadcn/register
65
+ * @description Registration API for pairing shadcn/ui components with
66
+ * Enterstellar ComponentContracts.
67
+ *
68
+ * shadcn/ui uses a **code-copy distribution model** — components are copied
69
+ * into the developer's source tree (e.g., `@/components/ui/button`), not
70
+ * installed from npm. This means there is no universal import path for
71
+ * shadcn components that this package can reference directly.
72
+ *
73
+ * Instead, the developer provides their local component imports via
74
+ * {@link registerShadcnContracts}:
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';
79
+ * import { Button } from '@/components/ui/button';
80
+ * import { Card } from '@/components/ui/card';
81
+ *
82
+ * const contracts = registerShadcnContracts({ Button, Card });
83
+ * const registry = createRegistry({ components: [...myContracts, ...contracts] });
84
+ * ```
85
+ *
86
+ * ## Validation Rules
87
+ *
88
+ * 1. **Unknown keys** → throw with Levenshtein fuzzy suggestion.
89
+ * 2. **`undefined`/`null` values** → throw with `npx shadcn add` hint.
90
+ * 3. **Missing keys** → `console.warn` with GenericCard fallback message.
91
+ * 4. **Valid components** → `defineComponent()` pairing.
92
+ *
93
+ * @see Correction 7 Decision 2 — Code-Copy Libraries
94
+ * @see Correction 7 Decision 3 — CI Sync Pipeline
95
+ */
96
+
97
+ /**
98
+ * Map of component names to React components provided by the developer.
99
+ *
100
+ * Keys must match contract names (PascalCase). Validation rules:
101
+ * - **Unknown keys** throw an `Error` with a Levenshtein-based fuzzy
102
+ * suggestion (e.g., "Did you mean 'Button'?" when given 'Buttn').
103
+ * - **`undefined`/`null` values** throw an `Error` with a
104
+ * `npx shadcn@latest add` hint for the missing component.
105
+ * - **Missing keys** log `console.warn` — the contract is registered
106
+ * without a renderer, which falls back to `GenericCard`.
107
+ *
108
+ * Uses `Record<string, unknown>` to match `defineComponent()`'s
109
+ * `TProps extends Record<string, unknown>` constraint (Audit M7).
110
+ *
111
+ * @see Correction 7 Decision 2 — registerShadcnContracts() pairing pattern
112
+ * @see defineComponent — TProps constraint
113
+ */
114
+ type ShadcnComponentMap = Partial<Record<ShadcnContractName, ComponentType<Record<string, unknown>>>>;
115
+ /**
116
+ * Registers shadcn/ui contracts and pairs them with the developer's
117
+ * local component implementations.
118
+ *
119
+ * **Validation sequence:**
120
+ * 1. Iterate over all keys in the provided `components` map.
121
+ * 2. For each key NOT in `SHADCN_CONTRACTS`, throw with a Levenshtein
122
+ * fuzzy suggestion (if one exists within distance ≤ 3).
123
+ * 3. Iterate over all entries in `SHADCN_CONTRACTS`:
124
+ * - If the key was explicitly passed as `undefined` or `null`,
125
+ * throw with `npx shadcn@latest add <name>` hint.
126
+ * - If the key was not provided at all, `console.warn` that
127
+ * GenericCard fallback will be used, and register the contract
128
+ * without a renderer via `defineComponent()`.
129
+ * - If the key was provided with a valid component, pair via
130
+ * `defineComponent()` and collect the validated contract.
131
+ *
132
+ * @param components - Map of contract names to local React components.
133
+ * Keys must be PascalCase and match known contract names.
134
+ * @returns Readonly array of validated `ComponentContract` objects for
135
+ * `createRegistry({ components: [...] })`.
136
+ * @throws {Error} If a key doesn't match any known contract
137
+ * (with Levenshtein-based fuzzy suggestion).
138
+ * @throws {Error} If a component value is explicitly `undefined` or `null`
139
+ * (with `npx shadcn@latest add` hint).
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';
144
+ * import { Button } from '@/components/ui/button';
145
+ * import { Card } from '@/components/ui/card';
146
+ * import { Dialog } from '@/components/ui/dialog';
147
+ *
148
+ * const contracts = registerShadcnContracts({ Button, Card, Dialog });
149
+ *
150
+ * const registry = createRegistry({
151
+ * components: [...myContracts, ...contracts],
152
+ * });
153
+ * ```
154
+ *
155
+ * @see Correction 7 Decision 2 — Code-Copy Libraries
156
+ * @see defineComponent — internal pairing mechanism
157
+ */
158
+ declare function registerShadcnContracts(components: ShadcnComponentMap): readonly ComponentContract[];
159
+
160
+ /**
161
+ * @module @enterstellar-ai/contracts-shadcn/utils/levenshtein
162
+ * @description Pure-function Levenshtein distance implementation for fuzzy
163
+ * contract name validation.
164
+ *
165
+ * Used by {@link registerShadcnContracts} to provide actionable error
166
+ * messages when a developer passes an unknown component name:
167
+ *
168
+ * ```
169
+ * Error: 'Buttn' is not a known shadcn contract. Did you mean 'Button'?
170
+ * ```
171
+ *
172
+ * **Zero dependencies. Zero framework imports. Pure functions only.**
173
+ *
174
+ * The threshold distance is **3** — any candidate with a distance ≤ 3
175
+ * from the input is considered a viable suggestion. This covers:
176
+ * - 1-char typos (distance 1): `Buttn` → `Button`
177
+ * - Transpositions (distance 2): `Cadr` → `Card`
178
+ * - Prefix/suffix errors (distance 2-3): `Dialg` → `Dialog`
179
+ *
180
+ * @see Correction 7 Decision 2 — fuzzy-validated registration
181
+ */
182
+ /**
183
+ * Computes the Levenshtein distance between two strings.
184
+ *
185
+ * The Levenshtein distance is the minimum number of single-character
186
+ * edits (insertions, deletions, or substitutions) required to change
187
+ * one string into the other.
188
+ *
189
+ * Uses the standard O(m×n) dynamic programming algorithm with O(n)
190
+ * space (two-row optimization).
191
+ *
192
+ * @param a - First string.
193
+ * @param b - Second string.
194
+ * @returns The edit distance between `a` and `b`. Always ≥ 0.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * levenshteinDistance('Button', 'Buttn'); // → 1
199
+ * levenshteinDistance('Card', 'Cadr'); // → 2
200
+ * levenshteinDistance('', 'Hello'); // → 5
201
+ * levenshteinDistance('same', 'same'); // → 0
202
+ * ```
203
+ */
204
+ declare function levenshteinDistance(a: string, b: string): number;
205
+ /**
206
+ * Finds the closest matching string from a list of candidates using
207
+ * Levenshtein distance.
208
+ *
209
+ * Returns the candidate with the smallest distance to `input`, provided
210
+ * that distance is ≤ {@link MATCH_THRESHOLD} (3). If no candidate is
211
+ * within threshold, returns `undefined`.
212
+ *
213
+ * When multiple candidates share the minimum distance, the first one
214
+ * encountered is returned (stable, deterministic ordering).
215
+ *
216
+ * @param input - The string to match against candidates.
217
+ * @param candidates - The list of valid candidate strings.
218
+ * @returns The closest matching candidate, or `undefined` if none
219
+ * are within the threshold distance.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * const names = ['Button', 'Card', 'Dialog', 'Input'];
224
+ *
225
+ * findClosestMatch('Buttn', names); // → 'Button' (distance 1)
226
+ * findClosestMatch('Crad', names); // → 'Card' (distance 2)
227
+ * findClosestMatch('Xyz', names); // → undefined (no close match)
228
+ * ```
229
+ */
230
+ declare function findClosestMatch(input: string, candidates: readonly string[]): string | undefined;
231
+
232
+ export { SHADCN_CONTRACTS, type ShadcnComponentMap, type ShadcnContractName, findClosestMatch, levenshteinDistance, registerShadcnContracts };
@@ -0,0 +1,232 @@
1
+ import { ComponentType } from 'react';
2
+ import { ComponentContract } from '@enterstellar-ai/types';
3
+ import { ComponentContractInput } from '@enterstellar-ai/registry';
4
+
5
+ /**
6
+ * @module @enterstellar-ai/contracts-shadcn/contracts
7
+ * @description Barrel export for shadcn/ui component contracts.
8
+ *
9
+ * This directory is the target for the CI sync pipeline
10
+ * (`sync-contracts-shadcn.yml`). The pipeline:
11
+ *
12
+ * 1. Scaffolds a temp Next.js project.
13
+ * 2. Runs `npx shadcn@latest add --all` to install all components.
14
+ * 3. Runs `enterstellar migrate` against the installed source files.
15
+ * 4. Copies generated `*.contract.ts` files into this directory.
16
+ * 5. Opens a human-gated PR with the updated contracts.
17
+ *
18
+ * **Pre-CI state:** `SHADCN_CONTRACTS` is an empty record. The type
19
+ * infrastructure is in place so that `registerShadcnContracts()` can
20
+ * operate against the record immediately when contracts arrive.
21
+ *
22
+ * **Post-CI state:** Each CI run adds/updates contract entries like:
23
+ * ```ts
24
+ * export const SHADCN_CONTRACTS = {
25
+ * Button: { name: 'Button', description: '...', props: z.object({...}), ... },
26
+ * Card: { name: 'Card', description: '...', props: z.object({...}), ... },
27
+ * // ... ~50 components
28
+ * } as const satisfies Record<string, ComponentContractInput>;
29
+ * ```
30
+ *
31
+ * @see Correction 7 Decision 3 — CI Sync Pipeline
32
+ * @see sync-contracts-shadcn.yml — workflow definition
33
+ */
34
+
35
+ /**
36
+ * Master record of all shadcn/ui component contracts.
37
+ *
38
+ * **Current state:** Empty. Populated by the CI sync pipeline.
39
+ *
40
+ * Each key is a PascalCase component name (e.g., `'Button'`, `'Card'`).
41
+ * Each value is a `ComponentContractInput` — the input to
42
+ * `defineComponent()` from `@enterstellar-ai/registry`.
43
+ *
44
+ * When contracts exist, this record is used by:
45
+ * - `registerShadcnContracts()` — to validate component maps and pair renderers.
46
+ * - `ShadcnContractName` — derived literal union for type-safe keys.
47
+ *
48
+ * @see registerShadcnContracts — uses this record for validation + pairing
49
+ * @see defineComponent — accepts each value as input
50
+ */
51
+ declare const SHADCN_CONTRACTS: Record<string, ComponentContractInput>;
52
+ /**
53
+ * Union type of all known shadcn/ui contract names.
54
+ *
55
+ * **Pre-CI:** Resolves to `string` (empty record → `string` keys).
56
+ * **Post-CI:** Resolves to a literal union (e.g., `'Button' | 'Card' | ...`)
57
+ * when the record is populated and typed with `as const satisfies`.
58
+ *
59
+ * Used by `ShadcnComponentMap` to provide compile-time key validation.
60
+ */
61
+ type ShadcnContractName = keyof typeof SHADCN_CONTRACTS;
62
+
63
+ /**
64
+ * @module @enterstellar-ai/contracts-shadcn/register
65
+ * @description Registration API for pairing shadcn/ui components with
66
+ * Enterstellar ComponentContracts.
67
+ *
68
+ * shadcn/ui uses a **code-copy distribution model** — components are copied
69
+ * into the developer's source tree (e.g., `@/components/ui/button`), not
70
+ * installed from npm. This means there is no universal import path for
71
+ * shadcn components that this package can reference directly.
72
+ *
73
+ * Instead, the developer provides their local component imports via
74
+ * {@link registerShadcnContracts}:
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';
79
+ * import { Button } from '@/components/ui/button';
80
+ * import { Card } from '@/components/ui/card';
81
+ *
82
+ * const contracts = registerShadcnContracts({ Button, Card });
83
+ * const registry = createRegistry({ components: [...myContracts, ...contracts] });
84
+ * ```
85
+ *
86
+ * ## Validation Rules
87
+ *
88
+ * 1. **Unknown keys** → throw with Levenshtein fuzzy suggestion.
89
+ * 2. **`undefined`/`null` values** → throw with `npx shadcn add` hint.
90
+ * 3. **Missing keys** → `console.warn` with GenericCard fallback message.
91
+ * 4. **Valid components** → `defineComponent()` pairing.
92
+ *
93
+ * @see Correction 7 Decision 2 — Code-Copy Libraries
94
+ * @see Correction 7 Decision 3 — CI Sync Pipeline
95
+ */
96
+
97
+ /**
98
+ * Map of component names to React components provided by the developer.
99
+ *
100
+ * Keys must match contract names (PascalCase). Validation rules:
101
+ * - **Unknown keys** throw an `Error` with a Levenshtein-based fuzzy
102
+ * suggestion (e.g., "Did you mean 'Button'?" when given 'Buttn').
103
+ * - **`undefined`/`null` values** throw an `Error` with a
104
+ * `npx shadcn@latest add` hint for the missing component.
105
+ * - **Missing keys** log `console.warn` — the contract is registered
106
+ * without a renderer, which falls back to `GenericCard`.
107
+ *
108
+ * Uses `Record<string, unknown>` to match `defineComponent()`'s
109
+ * `TProps extends Record<string, unknown>` constraint (Audit M7).
110
+ *
111
+ * @see Correction 7 Decision 2 — registerShadcnContracts() pairing pattern
112
+ * @see defineComponent — TProps constraint
113
+ */
114
+ type ShadcnComponentMap = Partial<Record<ShadcnContractName, ComponentType<Record<string, unknown>>>>;
115
+ /**
116
+ * Registers shadcn/ui contracts and pairs them with the developer's
117
+ * local component implementations.
118
+ *
119
+ * **Validation sequence:**
120
+ * 1. Iterate over all keys in the provided `components` map.
121
+ * 2. For each key NOT in `SHADCN_CONTRACTS`, throw with a Levenshtein
122
+ * fuzzy suggestion (if one exists within distance ≤ 3).
123
+ * 3. Iterate over all entries in `SHADCN_CONTRACTS`:
124
+ * - If the key was explicitly passed as `undefined` or `null`,
125
+ * throw with `npx shadcn@latest add <name>` hint.
126
+ * - If the key was not provided at all, `console.warn` that
127
+ * GenericCard fallback will be used, and register the contract
128
+ * without a renderer via `defineComponent()`.
129
+ * - If the key was provided with a valid component, pair via
130
+ * `defineComponent()` and collect the validated contract.
131
+ *
132
+ * @param components - Map of contract names to local React components.
133
+ * Keys must be PascalCase and match known contract names.
134
+ * @returns Readonly array of validated `ComponentContract` objects for
135
+ * `createRegistry({ components: [...] })`.
136
+ * @throws {Error} If a key doesn't match any known contract
137
+ * (with Levenshtein-based fuzzy suggestion).
138
+ * @throws {Error} If a component value is explicitly `undefined` or `null`
139
+ * (with `npx shadcn@latest add` hint).
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';
144
+ * import { Button } from '@/components/ui/button';
145
+ * import { Card } from '@/components/ui/card';
146
+ * import { Dialog } from '@/components/ui/dialog';
147
+ *
148
+ * const contracts = registerShadcnContracts({ Button, Card, Dialog });
149
+ *
150
+ * const registry = createRegistry({
151
+ * components: [...myContracts, ...contracts],
152
+ * });
153
+ * ```
154
+ *
155
+ * @see Correction 7 Decision 2 — Code-Copy Libraries
156
+ * @see defineComponent — internal pairing mechanism
157
+ */
158
+ declare function registerShadcnContracts(components: ShadcnComponentMap): readonly ComponentContract[];
159
+
160
+ /**
161
+ * @module @enterstellar-ai/contracts-shadcn/utils/levenshtein
162
+ * @description Pure-function Levenshtein distance implementation for fuzzy
163
+ * contract name validation.
164
+ *
165
+ * Used by {@link registerShadcnContracts} to provide actionable error
166
+ * messages when a developer passes an unknown component name:
167
+ *
168
+ * ```
169
+ * Error: 'Buttn' is not a known shadcn contract. Did you mean 'Button'?
170
+ * ```
171
+ *
172
+ * **Zero dependencies. Zero framework imports. Pure functions only.**
173
+ *
174
+ * The threshold distance is **3** — any candidate with a distance ≤ 3
175
+ * from the input is considered a viable suggestion. This covers:
176
+ * - 1-char typos (distance 1): `Buttn` → `Button`
177
+ * - Transpositions (distance 2): `Cadr` → `Card`
178
+ * - Prefix/suffix errors (distance 2-3): `Dialg` → `Dialog`
179
+ *
180
+ * @see Correction 7 Decision 2 — fuzzy-validated registration
181
+ */
182
+ /**
183
+ * Computes the Levenshtein distance between two strings.
184
+ *
185
+ * The Levenshtein distance is the minimum number of single-character
186
+ * edits (insertions, deletions, or substitutions) required to change
187
+ * one string into the other.
188
+ *
189
+ * Uses the standard O(m×n) dynamic programming algorithm with O(n)
190
+ * space (two-row optimization).
191
+ *
192
+ * @param a - First string.
193
+ * @param b - Second string.
194
+ * @returns The edit distance between `a` and `b`. Always ≥ 0.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * levenshteinDistance('Button', 'Buttn'); // → 1
199
+ * levenshteinDistance('Card', 'Cadr'); // → 2
200
+ * levenshteinDistance('', 'Hello'); // → 5
201
+ * levenshteinDistance('same', 'same'); // → 0
202
+ * ```
203
+ */
204
+ declare function levenshteinDistance(a: string, b: string): number;
205
+ /**
206
+ * Finds the closest matching string from a list of candidates using
207
+ * Levenshtein distance.
208
+ *
209
+ * Returns the candidate with the smallest distance to `input`, provided
210
+ * that distance is ≤ {@link MATCH_THRESHOLD} (3). If no candidate is
211
+ * within threshold, returns `undefined`.
212
+ *
213
+ * When multiple candidates share the minimum distance, the first one
214
+ * encountered is returned (stable, deterministic ordering).
215
+ *
216
+ * @param input - The string to match against candidates.
217
+ * @param candidates - The list of valid candidate strings.
218
+ * @returns The closest matching candidate, or `undefined` if none
219
+ * are within the threshold distance.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * const names = ['Button', 'Card', 'Dialog', 'Input'];
224
+ *
225
+ * findClosestMatch('Buttn', names); // → 'Button' (distance 1)
226
+ * findClosestMatch('Crad', names); // → 'Card' (distance 2)
227
+ * findClosestMatch('Xyz', names); // → undefined (no close match)
228
+ * ```
229
+ */
230
+ declare function findClosestMatch(input: string, candidates: readonly string[]): string | undefined;
231
+
232
+ export { SHADCN_CONTRACTS, type ShadcnComponentMap, type ShadcnContractName, findClosestMatch, levenshteinDistance, registerShadcnContracts };
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ import * as Registry from '@enterstellar-ai/registry';
2
+ import { defineComponent } from '@enterstellar-ai/react';
3
+
4
+ // src/register.ts
5
+
6
+ // src/contracts/index.ts
7
+ var SHADCN_CONTRACTS = {
8
+ // -------------------------------------------------------------------------
9
+ // Populated by CI sync pipeline (sync-contracts-shadcn.yml).
10
+ // Each entry is a defineComponent()-compatible contract input.
11
+ //
12
+ // DO NOT add entries manually — they are auto-generated by running
13
+ // `enterstellar migrate` against upstream shadcn/ui source components.
14
+ // -------------------------------------------------------------------------
15
+ };
16
+
17
+ // src/utils/levenshtein.ts
18
+ var MATCH_THRESHOLD = 3;
19
+ function levenshteinDistance(a, b) {
20
+ if (a === b) {
21
+ return 0;
22
+ }
23
+ const m = a.length;
24
+ const n = b.length;
25
+ if (m === 0) {
26
+ return n;
27
+ }
28
+ if (n === 0) {
29
+ return m;
30
+ }
31
+ let prev = Array.from({ length: n + 1 }, (_, j) => j);
32
+ let curr = new Array(n + 1);
33
+ for (let i = 1; i <= m; i++) {
34
+ curr[0] = i;
35
+ for (let j = 1; j <= n; j++) {
36
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
37
+ const deletion = (prev[j] ?? 0) + 1;
38
+ const insertion = (curr[j - 1] ?? 0) + 1;
39
+ const substitution = (prev[j - 1] ?? 0) + cost;
40
+ curr[j] = Math.min(deletion, insertion, substitution);
41
+ }
42
+ [prev, curr] = [curr, prev];
43
+ }
44
+ return prev[n] ?? 0;
45
+ }
46
+ function findClosestMatch(input, candidates) {
47
+ let bestMatch;
48
+ let bestDistance = MATCH_THRESHOLD + 1;
49
+ for (const candidate of candidates) {
50
+ const distance = levenshteinDistance(input, candidate);
51
+ if (distance < bestDistance) {
52
+ bestDistance = distance;
53
+ bestMatch = candidate;
54
+ }
55
+ if (distance === 0) {
56
+ break;
57
+ }
58
+ }
59
+ return bestDistance <= MATCH_THRESHOLD ? bestMatch : void 0;
60
+ }
61
+
62
+ // src/register.ts
63
+ function registerShadcnContracts(components) {
64
+ const contracts = [];
65
+ const knownNames = Object.keys(SHADCN_CONTRACTS);
66
+ for (const key of Object.keys(components)) {
67
+ if (!(key in SHADCN_CONTRACTS)) {
68
+ const suggestion = findClosestMatch(key, knownNames);
69
+ const hint = suggestion !== void 0 ? ` Did you mean '${suggestion}'?` : "";
70
+ throw new Error(
71
+ `'${key}' is not a known shadcn contract.${hint}`
72
+ );
73
+ }
74
+ }
75
+ for (const [name, contractInput] of Object.entries(SHADCN_CONTRACTS)) {
76
+ const typedInput = contractInput;
77
+ const isProvided = name in components;
78
+ const component = components[name];
79
+ if (isProvided && component == null) {
80
+ throw new Error(
81
+ `Component '${name}' was not provided (received ${String(component)}). Run 'npx shadcn@latest add ${name.toLowerCase()}' to add it.`
82
+ );
83
+ }
84
+ if (component === void 0) {
85
+ console.warn(
86
+ `Shadcn${name}: contract registered without renderer. <Zone> will use GenericCard fallback. Pass ${name} to registerShadcnContracts() to enable full rendering.`
87
+ );
88
+ contracts.push(Registry.defineComponent(typedInput));
89
+ continue;
90
+ }
91
+ const { contract } = defineComponent({
92
+ contract: typedInput,
93
+ render: component
94
+ });
95
+ contracts.push(contract);
96
+ }
97
+ return contracts;
98
+ }
99
+
100
+ export { SHADCN_CONTRACTS, findClosestMatch, levenshteinDistance, registerShadcnContracts };
101
+ //# sourceMappingURL=index.js.map
102
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contracts/index.ts","../src/utils/levenshtein.ts","../src/register.ts"],"names":["defineComponent"],"mappings":"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","file":"index.js","sourcesContent":["/**\n * @module @enterstellar-ai/contracts-shadcn/contracts\n * @description Barrel export for shadcn/ui component contracts.\n *\n * This directory is the target for the CI sync pipeline\n * (`sync-contracts-shadcn.yml`). The pipeline:\n *\n * 1. Scaffolds a temp Next.js project.\n * 2. Runs `npx shadcn@latest add --all` to install all components.\n * 3. Runs `enterstellar migrate` against the installed source files.\n * 4. Copies generated `*.contract.ts` files into this directory.\n * 5. Opens a human-gated PR with the updated contracts.\n *\n * **Pre-CI state:** `SHADCN_CONTRACTS` is an empty record. The type\n * infrastructure is in place so that `registerShadcnContracts()` can\n * operate against the record immediately when contracts arrive.\n *\n * **Post-CI state:** Each CI run adds/updates contract entries like:\n * ```ts\n * export const SHADCN_CONTRACTS = {\n * Button: { name: 'Button', description: '...', props: z.object({...}), ... },\n * Card: { name: 'Card', description: '...', props: z.object({...}), ... },\n * // ... ~50 components\n * } as const satisfies Record<string, ComponentContractInput>;\n * ```\n *\n * @see Correction 7 Decision 3 — CI Sync Pipeline\n * @see sync-contracts-shadcn.yml — workflow definition\n */\n\nimport type { ComponentContractInput } from '@enterstellar-ai/registry'; // Audit E1: from @enterstellar-ai/registry, NOT @enterstellar-ai/types\n\n// ---------------------------------------------------------------------------\n// Contract Record\n// ---------------------------------------------------------------------------\n\n/**\n * Master record of all shadcn/ui component contracts.\n *\n * **Current state:** Empty. Populated by the CI sync pipeline.\n *\n * Each key is a PascalCase component name (e.g., `'Button'`, `'Card'`).\n * Each value is a `ComponentContractInput` — the input to\n * `defineComponent()` from `@enterstellar-ai/registry`.\n *\n * When contracts exist, this record is used by:\n * - `registerShadcnContracts()` — to validate component maps and pair renderers.\n * - `ShadcnContractName` — derived literal union for type-safe keys.\n *\n * @see registerShadcnContracts — uses this record for validation + pairing\n * @see defineComponent — accepts each value as input\n */\nexport const SHADCN_CONTRACTS: Record<string, ComponentContractInput> = {\n // -------------------------------------------------------------------------\n // Populated by CI sync pipeline (sync-contracts-shadcn.yml).\n // Each entry is a defineComponent()-compatible contract input.\n //\n // DO NOT add entries manually — they are auto-generated by running\n // `enterstellar migrate` against upstream shadcn/ui source components.\n // -------------------------------------------------------------------------\n};\n\n// ---------------------------------------------------------------------------\n// Derived Types\n// ---------------------------------------------------------------------------\n\n/**\n * Union type of all known shadcn/ui contract names.\n *\n * **Pre-CI:** Resolves to `string` (empty record → `string` keys).\n * **Post-CI:** Resolves to a literal union (e.g., `'Button' | 'Card' | ...`)\n * when the record is populated and typed with `as const satisfies`.\n *\n * Used by `ShadcnComponentMap` to provide compile-time key validation.\n */\nexport type ShadcnContractName = keyof typeof SHADCN_CONTRACTS;\n","/**\n * @module @enterstellar-ai/contracts-shadcn/utils/levenshtein\n * @description Pure-function Levenshtein distance implementation for fuzzy\n * contract name validation.\n *\n * Used by {@link registerShadcnContracts} to provide actionable error\n * messages when a developer passes an unknown component name:\n *\n * ```\n * Error: 'Buttn' is not a known shadcn contract. Did you mean 'Button'?\n * ```\n *\n * **Zero dependencies. Zero framework imports. Pure functions only.**\n *\n * The threshold distance is **3** — any candidate with a distance ≤ 3\n * from the input is considered a viable suggestion. This covers:\n * - 1-char typos (distance 1): `Buttn` → `Button`\n * - Transpositions (distance 2): `Cadr` → `Card`\n * - Prefix/suffix errors (distance 2-3): `Dialg` → `Dialog`\n *\n * @see Correction 7 Decision 2 — fuzzy-validated registration\n */\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/**\n * Maximum Levenshtein distance to consider a candidate a valid suggestion.\n *\n * A threshold of 3 covers common typos (single-char, transposition,\n * prefix/suffix) while avoiding false positives on completely unrelated\n * names. Empirically validated against shadcn component names.\n */\nconst MATCH_THRESHOLD = 3;\n\n// ---------------------------------------------------------------------------\n// Levenshtein Distance\n// ---------------------------------------------------------------------------\n\n/**\n * Computes the Levenshtein distance between two strings.\n *\n * The Levenshtein distance is the minimum number of single-character\n * edits (insertions, deletions, or substitutions) required to change\n * one string into the other.\n *\n * Uses the standard O(m×n) dynamic programming algorithm with O(n)\n * space (two-row optimization).\n *\n * @param a - First string.\n * @param b - Second string.\n * @returns The edit distance between `a` and `b`. Always ≥ 0.\n *\n * @example\n * ```ts\n * levenshteinDistance('Button', 'Buttn'); // → 1\n * levenshteinDistance('Card', 'Cadr'); // → 2\n * levenshteinDistance('', 'Hello'); // → 5\n * levenshteinDistance('same', 'same'); // → 0\n * ```\n */\nexport function levenshteinDistance(a: string, b: string): number {\n // Early exit: identical strings.\n if (a === b) {\n return 0;\n }\n\n const m = a.length;\n const n = b.length;\n\n // Edge cases: one string is empty.\n if (m === 0) {\n return n;\n }\n if (n === 0) {\n return m;\n }\n\n // Two-row DP: prev = row (i-1), curr = row i.\n // Each row has (n + 1) entries.\n let prev: number[] = Array.from({ length: n + 1 }, (_, j) => j);\n let curr: number[] = new Array<number>(n + 1);\n\n for (let i = 1; i <= m; i++) {\n curr[0] = i;\n\n for (let j = 1; j <= n; j++) {\n // Cost is 0 if characters match, 1 otherwise.\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n\n // Minimum of insertion, deletion, or substitution.\n // prev[j] + 1: deletion (remove from a)\n // (curr[j - 1] ?? 0) + 1: insertion (add to a)\n // (prev[j - 1] ?? 0) + cost: substitution\n const deletion = (prev[j] ?? 0) + 1;\n const insertion = (curr[j - 1] ?? 0) + 1;\n const substitution = (prev[j - 1] ?? 0) + cost;\n\n curr[j] = Math.min(deletion, insertion, substitution);\n }\n\n // Swap rows: curr becomes prev for next iteration.\n [prev, curr] = [curr, prev];\n }\n\n // After the loop, prev contains the last computed row.\n // The answer is in prev[n].\n return prev[n] ?? 0;\n}\n\n// ---------------------------------------------------------------------------\n// Closest Match Finder\n// ---------------------------------------------------------------------------\n\n/**\n * Finds the closest matching string from a list of candidates using\n * Levenshtein distance.\n *\n * Returns the candidate with the smallest distance to `input`, provided\n * that distance is ≤ {@link MATCH_THRESHOLD} (3). If no candidate is\n * within threshold, returns `undefined`.\n *\n * When multiple candidates share the minimum distance, the first one\n * encountered is returned (stable, deterministic ordering).\n *\n * @param input - The string to match against candidates.\n * @param candidates - The list of valid candidate strings.\n * @returns The closest matching candidate, or `undefined` if none\n * are within the threshold distance.\n *\n * @example\n * ```ts\n * const names = ['Button', 'Card', 'Dialog', 'Input'];\n *\n * findClosestMatch('Buttn', names); // → 'Button' (distance 1)\n * findClosestMatch('Crad', names); // → 'Card' (distance 2)\n * findClosestMatch('Xyz', names); // → undefined (no close match)\n * ```\n */\nexport function findClosestMatch(\n input: string,\n candidates: readonly string[],\n): string | undefined {\n let bestMatch: string | undefined;\n let bestDistance = MATCH_THRESHOLD + 1; // Start above threshold.\n\n for (const candidate of candidates) {\n const distance = levenshteinDistance(input, candidate);\n\n if (distance < bestDistance) {\n bestDistance = distance;\n bestMatch = candidate;\n }\n\n // Perfect match — can't do better.\n if (distance === 0) {\n break;\n }\n }\n\n // Only return if within threshold.\n return bestDistance <= MATCH_THRESHOLD ? bestMatch : undefined;\n}\n","/**\n * @module @enterstellar-ai/contracts-shadcn/register\n * @description Registration API for pairing shadcn/ui components with\n * Enterstellar ComponentContracts.\n *\n * shadcn/ui uses a **code-copy distribution model** — components are copied\n * into the developer's source tree (e.g., `@/components/ui/button`), not\n * installed from npm. This means there is no universal import path for\n * shadcn components that this package can reference directly.\n *\n * Instead, the developer provides their local component imports via\n * {@link registerShadcnContracts}:\n *\n * @example\n * ```ts\n * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';\n * import { Button } from '@/components/ui/button';\n * import { Card } from '@/components/ui/card';\n *\n * const contracts = registerShadcnContracts({ Button, Card });\n * const registry = createRegistry({ components: [...myContracts, ...contracts] });\n * ```\n *\n * ## Validation Rules\n *\n * 1. **Unknown keys** → throw with Levenshtein fuzzy suggestion.\n * 2. **`undefined`/`null` values** → throw with `npx shadcn add` hint.\n * 3. **Missing keys** → `console.warn` with GenericCard fallback message.\n * 4. **Valid components** → `defineComponent()` pairing.\n *\n * @see Correction 7 Decision 2 — Code-Copy Libraries\n * @see Correction 7 Decision 3 — CI Sync Pipeline\n */\n\nimport type { ComponentType } from 'react'; // type-only — erased at compile time (Audit N1)\n\nimport type { ComponentContract } from '@enterstellar-ai/types';\nimport * as Registry from '@enterstellar-ai/registry'; // Audit E2: explicit import\nimport type { ComponentContractInput } from '@enterstellar-ai/registry'; // Audit E1: from @enterstellar-ai/registry, NOT @enterstellar-ai/types\nimport { defineComponent } from '@enterstellar-ai/react';\n\nimport { SHADCN_CONTRACTS } from './contracts/index.js';\nimport type { ShadcnContractName } from './contracts/index.js';\nimport { findClosestMatch } from './utils/levenshtein.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Map of component names to React components provided by the developer.\n *\n * Keys must match contract names (PascalCase). Validation rules:\n * - **Unknown keys** throw an `Error` with a Levenshtein-based fuzzy\n * suggestion (e.g., \"Did you mean 'Button'?\" when given 'Buttn').\n * - **`undefined`/`null` values** throw an `Error` with a\n * `npx shadcn@latest add` hint for the missing component.\n * - **Missing keys** log `console.warn` — the contract is registered\n * without a renderer, which falls back to `GenericCard`.\n *\n * Uses `Record<string, unknown>` to match `defineComponent()`'s\n * `TProps extends Record<string, unknown>` constraint (Audit M7).\n *\n * @see Correction 7 Decision 2 — registerShadcnContracts() pairing pattern\n * @see defineComponent — TProps constraint\n */\nexport type ShadcnComponentMap = Partial<\n Record<ShadcnContractName, ComponentType<Record<string, unknown>>>\n>;\n\n// ---------------------------------------------------------------------------\n// Registration API\n// ---------------------------------------------------------------------------\n\n/**\n * Registers shadcn/ui contracts and pairs them with the developer's\n * local component implementations.\n *\n * **Validation sequence:**\n * 1. Iterate over all keys in the provided `components` map.\n * 2. For each key NOT in `SHADCN_CONTRACTS`, throw with a Levenshtein\n * fuzzy suggestion (if one exists within distance ≤ 3).\n * 3. Iterate over all entries in `SHADCN_CONTRACTS`:\n * - If the key was explicitly passed as `undefined` or `null`,\n * throw with `npx shadcn@latest add <name>` hint.\n * - If the key was not provided at all, `console.warn` that\n * GenericCard fallback will be used, and register the contract\n * without a renderer via `defineComponent()`.\n * - If the key was provided with a valid component, pair via\n * `defineComponent()` and collect the validated contract.\n *\n * @param components - Map of contract names to local React components.\n * Keys must be PascalCase and match known contract names.\n * @returns Readonly array of validated `ComponentContract` objects for\n * `createRegistry({ components: [...] })`.\n * @throws {Error} If a key doesn't match any known contract\n * (with Levenshtein-based fuzzy suggestion).\n * @throws {Error} If a component value is explicitly `undefined` or `null`\n * (with `npx shadcn@latest add` hint).\n *\n * @example\n * ```ts\n * import { registerShadcnContracts } from '@enterstellar-ai/contracts-shadcn';\n * import { Button } from '@/components/ui/button';\n * import { Card } from '@/components/ui/card';\n * import { Dialog } from '@/components/ui/dialog';\n *\n * const contracts = registerShadcnContracts({ Button, Card, Dialog });\n *\n * const registry = createRegistry({\n * components: [...myContracts, ...contracts],\n * });\n * ```\n *\n * @see Correction 7 Decision 2 — Code-Copy Libraries\n * @see defineComponent — internal pairing mechanism\n */\nexport function registerShadcnContracts(\n components: ShadcnComponentMap,\n): readonly ComponentContract[] {\n const contracts: ComponentContract[] = [];\n const knownNames = Object.keys(SHADCN_CONTRACTS);\n\n // -------------------------------------------------------------------------\n // Phase 1: Validate unknown keys (throw with fuzzy suggestion)\n // -------------------------------------------------------------------------\n // Check every key the developer provided against the known contract names.\n // This runs first so the developer gets immediate feedback on typos before\n // any contracts are registered.\n for (const key of Object.keys(components)) {\n if (!(key in SHADCN_CONTRACTS)) {\n const suggestion = findClosestMatch(key, knownNames);\n const hint = suggestion !== undefined\n ? ` Did you mean '${suggestion}'?`\n : '';\n throw new Error(\n `'${key}' is not a known shadcn contract.${hint}`,\n );\n }\n }\n\n // -------------------------------------------------------------------------\n // Phase 2: Register each known contract\n // -------------------------------------------------------------------------\n for (const [name, contractInput] of Object.entries(SHADCN_CONTRACTS)) {\n const typedInput: ComponentContractInput = contractInput;\n\n // Check if the developer provided this key at all.\n const isProvided = name in components;\n const component = (components as Record<string, ComponentType<Record<string, unknown>> | undefined>)[name];\n\n // --- Case: explicitly passed undefined/null ---\n // The developer listed the key but didn't provide a component.\n // This is likely a mistake — they intended to provide it but forgot\n // to install/import it.\n if (isProvided && component == null) {\n throw new Error(\n `Component '${name}' was not provided (received ${String(component)}). ` +\n `Run 'npx shadcn@latest add ${name.toLowerCase()}' to add it.`,\n );\n }\n\n // --- Case: not provided at all ---\n // The developer didn't list this key in the map. This is intentional —\n // they don't have this component installed. Register the contract\n // without a renderer so GenericCard can fall back.\n if (component === undefined) {\n console.warn(\n `Shadcn${name}: contract registered without renderer. ` +\n `<Zone> will use GenericCard fallback. ` +\n `Pass ${name} to registerShadcnContracts() to enable full rendering.`,\n );\n contracts.push(Registry.defineComponent(typedInput));\n continue;\n }\n\n // --- Case: provided with a valid component ---\n // Pair the contract with the developer's local component implementation\n // via defineComponent(). This validates the contract, freezes it,\n // and registers the renderer in the module-level RendererRegistry.\n const { contract } = defineComponent({\n contract: typedInput,\n render: component,\n });\n contracts.push(contract);\n }\n\n return contracts;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@enterstellar-ai/contracts-shadcn",
3
+ "description": "shadcn/ui component contracts — pre-built ComponentContracts for shadcn/ui components.",
4
+ "version": "0.1.0",
5
+ "author": "Enterstellar",
6
+ "license": "Apache-2.0",
7
+ "homepage": "https://enterstellar.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/enterstellar-ai/enterstellar.git",
11
+ "directory": "packages/contracts-shadcn"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/enterstellar-ai/enterstellar/issues"
15
+ },
16
+ "keywords": [
17
+ "shadcn",
18
+ "contracts",
19
+ "components",
20
+ "generative-ui",
21
+ "enterstellar"
22
+ ],
23
+ "type": "module",
24
+ "private": false,
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "import": {
35
+ "types": "./dist/index.d.ts",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/index.d.cts",
40
+ "default": "./dist/index.cjs"
41
+ }
42
+ }
43
+ },
44
+ "files": [
45
+ "LICENSE",
46
+ "NOTICE",
47
+ "dist"
48
+ ],
49
+ "peerDependencies": {
50
+ "zod": "^4.3.6",
51
+ "@enterstellar-ai/react": "0.1.0",
52
+ "@enterstellar-ai/registry": "0.1.0",
53
+ "@enterstellar-ai/types": "0.1.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/react": "^19.2.14",
57
+ "zod": "^4.3.6",
58
+ "@enterstellar-ai/react": "0.1.0",
59
+ "@enterstellar-ai/registry": "0.1.0",
60
+ "@enterstellar-ai/types": "0.1.0"
61
+ },
62
+ "scripts": {
63
+ "build": "tsup",
64
+ "typecheck": "tsc --noEmit",
65
+ "lint": "eslint src/",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest"
68
+ }
69
+ }