@claudetools/tools 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cli.js +9 -1
  2. package/dist/codedna/__tests__/examples/mongoose-example.d.ts +6 -0
  3. package/dist/codedna/__tests__/examples/mongoose-example.js +163 -0
  4. package/dist/codedna/__tests__/fixtures/typeorm-production-test.d.ts +1 -0
  5. package/dist/codedna/__tests__/fixtures/typeorm-production-test.js +231 -0
  6. package/dist/codedna/__tests__/fixtures/typeorm-test.d.ts +1 -0
  7. package/dist/codedna/__tests__/fixtures/typeorm-test.js +124 -0
  8. package/dist/codedna/__tests__/laravel-output-review.d.ts +1 -0
  9. package/dist/codedna/__tests__/laravel-output-review.js +249 -0
  10. package/dist/codedna/__tests__/mongoose-output-test.d.ts +1 -0
  11. package/dist/codedna/__tests__/mongoose-output-test.js +178 -0
  12. package/dist/codedna/examples/radix-example.d.ts +2 -0
  13. package/dist/codedna/examples/radix-example.js +259 -0
  14. package/dist/codedna/index.d.ts +5 -3
  15. package/dist/codedna/index.js +6 -3
  16. package/dist/codedna/kappa-ast.d.ts +143 -5
  17. package/dist/codedna/kappa-drizzle-generator.js +8 -5
  18. package/dist/codedna/kappa-gofiber-generator.d.ts +65 -0
  19. package/dist/codedna/kappa-gofiber-generator.js +587 -0
  20. package/dist/codedna/kappa-laravel-generator.d.ts +68 -0
  21. package/dist/codedna/kappa-laravel-generator.js +741 -0
  22. package/dist/codedna/kappa-lexer.d.ts +44 -0
  23. package/dist/codedna/kappa-lexer.js +124 -0
  24. package/dist/codedna/kappa-mantine-generator.d.ts +65 -0
  25. package/dist/codedna/kappa-mantine-generator.js +518 -0
  26. package/dist/codedna/kappa-mongoose-generator.d.ts +44 -0
  27. package/dist/codedna/kappa-mongoose-generator.js +442 -0
  28. package/dist/codedna/kappa-parser.d.ts +43 -1
  29. package/dist/codedna/kappa-parser.js +601 -0
  30. package/dist/codedna/kappa-radix-generator.d.ts +61 -0
  31. package/dist/codedna/kappa-radix-generator.js +566 -0
  32. package/dist/codedna/kappa-typeorm-generator.d.ts +59 -0
  33. package/dist/codedna/kappa-typeorm-generator.js +723 -0
  34. package/dist/codedna/kappa-vitest-generator.d.ts +85 -0
  35. package/dist/codedna/kappa-vitest-generator.js +739 -0
  36. package/dist/codedna/parser.js +26 -1
  37. package/dist/codegen/cloud-client.d.ts +160 -0
  38. package/dist/codegen/cloud-client.js +195 -0
  39. package/dist/codegen/codegen-tool.d.ts +35 -0
  40. package/dist/codegen/codegen-tool.js +312 -0
  41. package/dist/codegen/field-inference.d.ts +24 -0
  42. package/dist/codegen/field-inference.js +101 -0
  43. package/dist/codegen/form-parser.d.ts +13 -0
  44. package/dist/codegen/form-parser.js +186 -0
  45. package/dist/codegen/index.d.ts +2 -0
  46. package/dist/codegen/index.js +4 -0
  47. package/dist/codegen/natural-parser.d.ts +50 -0
  48. package/dist/codegen/natural-parser.js +769 -0
  49. package/dist/handlers/codedna-handlers.d.ts +1 -1
  50. package/dist/handlers/codegen-handlers.d.ts +20 -0
  51. package/dist/handlers/codegen-handlers.js +60 -0
  52. package/dist/handlers/kappa-handlers.d.ts +97 -0
  53. package/dist/handlers/kappa-handlers.js +408 -0
  54. package/dist/handlers/tool-handlers.js +124 -221
  55. package/dist/helpers/api-client.js +48 -3
  56. package/dist/helpers/compact-formatter.d.ts +9 -2
  57. package/dist/helpers/compact-formatter.js +26 -2
  58. package/dist/helpers/config.d.ts +7 -2
  59. package/dist/helpers/config.js +25 -10
  60. package/dist/helpers/session-validation.d.ts +1 -1
  61. package/dist/helpers/session-validation.js +2 -4
  62. package/dist/helpers/tasks.d.ts +21 -0
  63. package/dist/helpers/tasks.js +52 -0
  64. package/dist/helpers/workers.d.ts +1 -1
  65. package/dist/helpers/workers.js +19 -19
  66. package/dist/setup.d.ts +1 -0
  67. package/dist/setup.js +228 -3
  68. package/dist/templates/claude-md.d.ts +1 -1
  69. package/dist/templates/claude-md.js +37 -152
  70. package/dist/templates/orchestrator-prompt.d.ts +2 -2
  71. package/dist/templates/orchestrator-prompt.js +31 -38
  72. package/dist/templates/self-critique.d.ts +50 -0
  73. package/dist/templates/self-critique.js +209 -0
  74. package/dist/templates/worker-prompt.d.ts +3 -3
  75. package/dist/templates/worker-prompt.js +18 -18
  76. package/dist/tools.js +77 -413
  77. package/docs/codedna/generator-testing-summary.md +205 -0
  78. package/docs/codedna/radix-ui-generator.md +478 -0
  79. package/docs/kappa-gofiber-generator.md +274 -0
  80. package/docs/kappa-laravel-fixes.md +172 -0
  81. package/docs/kappa-mongoose-generator.md +322 -0
  82. package/docs/kappa-vitest-generator.md +337 -0
  83. package/package.json +1 -1
  84. package/dist/context/deduplication.test.d.ts +0 -6
  85. package/dist/context/deduplication.test.js +0 -84
@@ -0,0 +1,249 @@
1
+ // Temporary test file to review Laravel generator output
2
+ import { generateLaravel } from '../kappa-laravel-generator.js';
3
+ // Comprehensive entity with all field types
4
+ const entities = [
5
+ {
6
+ kind: 'EntityBlock',
7
+ loc: { line: 1, column: 1 },
8
+ name: 'User',
9
+ fields: [
10
+ {
11
+ kind: 'EntityField',
12
+ loc: { line: 2, column: 1 },
13
+ name: 'id',
14
+ type: { kind: 'primitive', type: 'uuid' },
15
+ modifiers: ['primary'],
16
+ },
17
+ {
18
+ kind: 'EntityField',
19
+ loc: { line: 3, column: 1 },
20
+ name: 'email',
21
+ type: { kind: 'primitive', type: 'email' },
22
+ modifiers: ['unique', 'required'],
23
+ },
24
+ {
25
+ kind: 'EntityField',
26
+ loc: { line: 4, column: 1 },
27
+ name: 'password',
28
+ type: { kind: 'primitive', type: 'string' },
29
+ modifiers: ['hashed', 'required'],
30
+ },
31
+ {
32
+ kind: 'EntityField',
33
+ loc: { line: 5, column: 1 },
34
+ name: 'name',
35
+ type: { kind: 'primitive', type: 'string' },
36
+ modifiers: ['required'],
37
+ },
38
+ {
39
+ kind: 'EntityField',
40
+ loc: { line: 6, column: 1 },
41
+ name: 'age',
42
+ type: { kind: 'primitive', type: 'int' },
43
+ modifiers: ['optional'],
44
+ validators: [{ name: 'min', args: [18] }],
45
+ },
46
+ {
47
+ kind: 'EntityField',
48
+ loc: { line: 7, column: 1 },
49
+ name: 'bio',
50
+ type: { kind: 'primitive', type: 'markdown' },
51
+ modifiers: ['optional'],
52
+ },
53
+ {
54
+ kind: 'EntityField',
55
+ loc: { line: 8, column: 1 },
56
+ name: 'isActive',
57
+ type: { kind: 'primitive', type: 'bool' },
58
+ modifiers: [],
59
+ defaultValue: 'true',
60
+ },
61
+ {
62
+ kind: 'EntityField',
63
+ loc: { line: 9, column: 1 },
64
+ name: 'metadata',
65
+ type: { kind: 'primitive', type: 'json' },
66
+ modifiers: ['optional'],
67
+ },
68
+ {
69
+ kind: 'EntityField',
70
+ loc: { line: 10, column: 1 },
71
+ name: 'createdAt',
72
+ type: { kind: 'primitive', type: 'timestamp' },
73
+ modifiers: ['auto'],
74
+ },
75
+ ],
76
+ relationships: [],
77
+ capabilities: [],
78
+ lifecycleHooks: [],
79
+ },
80
+ {
81
+ kind: 'EntityBlock',
82
+ loc: { line: 11, column: 1 },
83
+ name: 'Post',
84
+ fields: [
85
+ {
86
+ kind: 'EntityField',
87
+ loc: { line: 12, column: 1 },
88
+ name: 'id',
89
+ type: { kind: 'primitive', type: 'uuid' },
90
+ modifiers: ['primary'],
91
+ },
92
+ {
93
+ kind: 'EntityField',
94
+ loc: { line: 13, column: 1 },
95
+ name: 'title',
96
+ type: { kind: 'primitive', type: 'string' },
97
+ modifiers: ['required'],
98
+ },
99
+ {
100
+ kind: 'EntityField',
101
+ loc: { line: 14, column: 1 },
102
+ name: 'slug',
103
+ type: { kind: 'primitive', type: 'slug' },
104
+ modifiers: ['unique', 'required'],
105
+ },
106
+ {
107
+ kind: 'EntityField',
108
+ loc: { line: 15, column: 1 },
109
+ name: 'content',
110
+ type: { kind: 'primitive', type: 'markdown' },
111
+ modifiers: [],
112
+ },
113
+ {
114
+ kind: 'EntityField',
115
+ loc: { line: 16, column: 1 },
116
+ name: 'status',
117
+ type: { kind: 'enum', values: ['draft', 'published', 'archived'] },
118
+ modifiers: [],
119
+ },
120
+ {
121
+ kind: 'EntityField',
122
+ loc: { line: 17, column: 1 },
123
+ name: 'userId',
124
+ type: { kind: 'reference', entity: 'User' },
125
+ modifiers: ['required'],
126
+ },
127
+ {
128
+ kind: 'EntityField',
129
+ loc: { line: 18, column: 1 },
130
+ name: 'publishedAt',
131
+ type: { kind: 'primitive', type: 'timestamp' },
132
+ modifiers: ['optional'],
133
+ },
134
+ ],
135
+ relationships: [],
136
+ capabilities: [],
137
+ lifecycleHooks: [],
138
+ },
139
+ ];
140
+ // API with CRUD and custom operations
141
+ const apis = [
142
+ {
143
+ kind: 'APIBlock',
144
+ loc: { line: 1, column: 1 },
145
+ name: 'User',
146
+ operations: [
147
+ {
148
+ kind: 'APIOperation',
149
+ loc: { line: 2, column: 1 },
150
+ name: 'register',
151
+ parameters: [],
152
+ effects: [],
153
+ returnType: { kind: 'single', entity: 'User' },
154
+ },
155
+ {
156
+ kind: 'APIOperation',
157
+ loc: { line: 3, column: 1 },
158
+ name: 'login',
159
+ parameters: [],
160
+ effects: [],
161
+ returnType: { kind: 'void' },
162
+ },
163
+ {
164
+ kind: 'APIOperation',
165
+ loc: { line: 4, column: 1 },
166
+ name: 'getProfile',
167
+ parameters: [],
168
+ effects: ['Auth'],
169
+ returnType: { kind: 'single', entity: 'User' },
170
+ },
171
+ ],
172
+ crud: [],
173
+ },
174
+ {
175
+ kind: 'APIBlock',
176
+ loc: { line: 5, column: 1 },
177
+ name: 'Post',
178
+ operations: [],
179
+ crud: [
180
+ {
181
+ entity: 'Post',
182
+ actions: [
183
+ { action: 'list', effects: [] },
184
+ { action: 'create', effects: ['Auth'] },
185
+ { action: 'read', effects: [] },
186
+ { action: 'update', effects: ['Auth'] },
187
+ { action: 'delete', effects: ['Auth'] },
188
+ ],
189
+ },
190
+ ],
191
+ },
192
+ ];
193
+ // Generate all Laravel files
194
+ const result = generateLaravel(apis, entities);
195
+ // Output each file type
196
+ console.log('='.repeat(80));
197
+ console.log('ROUTES (routes/api.php)');
198
+ console.log('='.repeat(80));
199
+ console.log(result.routes);
200
+ console.log('\n');
201
+ console.log('='.repeat(80));
202
+ console.log('USER CONTROLLER (app/Http/Controllers/UserController.php)');
203
+ console.log('='.repeat(80));
204
+ console.log(result.controllers['UserController']);
205
+ console.log('\n');
206
+ console.log('='.repeat(80));
207
+ console.log('POST CONTROLLER (app/Http/Controllers/PostController.php)');
208
+ console.log('='.repeat(80));
209
+ console.log(result.controllers['PostController']);
210
+ console.log('\n');
211
+ console.log('='.repeat(80));
212
+ console.log('USER MODEL (app/Models/User.php)');
213
+ console.log('='.repeat(80));
214
+ console.log(result.models['User']);
215
+ console.log('\n');
216
+ console.log('='.repeat(80));
217
+ console.log('POST MODEL (app/Models/Post.php)');
218
+ console.log('='.repeat(80));
219
+ console.log(result.models['Post']);
220
+ console.log('\n');
221
+ console.log('='.repeat(80));
222
+ console.log('USER MIGRATION (database/migrations/xxxx_create_users_table.php)');
223
+ console.log('='.repeat(80));
224
+ console.log(result.migrations['create_users_table']);
225
+ console.log('\n');
226
+ console.log('='.repeat(80));
227
+ console.log('POST MIGRATION (database/migrations/xxxx_create_posts_table.php)');
228
+ console.log('='.repeat(80));
229
+ console.log(result.migrations['create_posts_table']);
230
+ console.log('\n');
231
+ console.log('='.repeat(80));
232
+ console.log('USER RESOURCE (app/Http/Resources/UserResource.php)');
233
+ console.log('='.repeat(80));
234
+ console.log(result.resources['UserResource']);
235
+ console.log('\n');
236
+ console.log('='.repeat(80));
237
+ console.log('POST RESOURCE (app/Http/Resources/PostResource.php)');
238
+ console.log('='.repeat(80));
239
+ console.log(result.resources['PostResource']);
240
+ console.log('\n');
241
+ if (result.formRequests) {
242
+ console.log('='.repeat(80));
243
+ console.log('FORM REQUESTS');
244
+ console.log('='.repeat(80));
245
+ for (const [name, content] of Object.entries(result.formRequests)) {
246
+ console.log(`\n--- ${name} ---`);
247
+ console.log(content);
248
+ }
249
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,178 @@
1
+ import { describe, it } from 'vitest';
2
+ import { generateMongooseSchema } from '../kappa-mongoose-generator.js';
3
+ const loc = {
4
+ startLine: 1,
5
+ startColumn: 1,
6
+ endLine: 1,
7
+ endColumn: 1,
8
+ startOffset: 0,
9
+ endOffset: 0,
10
+ };
11
+ describe('Mongoose Output Inspection', () => {
12
+ it('generates production-ready User and Post schemas', () => {
13
+ const entities = [
14
+ {
15
+ kind: 'EntityBlock',
16
+ name: 'User',
17
+ loc,
18
+ fields: [
19
+ {
20
+ kind: 'EntityField',
21
+ name: 'id',
22
+ loc,
23
+ type: { kind: 'primitive', type: 'uuid' },
24
+ modifiers: ['primary', 'auto'],
25
+ },
26
+ {
27
+ kind: 'EntityField',
28
+ name: 'email',
29
+ loc,
30
+ type: { kind: 'primitive', type: 'email' },
31
+ modifiers: ['unique'],
32
+ },
33
+ {
34
+ kind: 'EntityField',
35
+ name: 'name',
36
+ loc,
37
+ type: { kind: 'primitive', type: 'string', range: { min: 2, max: 100 } },
38
+ modifiers: [],
39
+ },
40
+ {
41
+ kind: 'EntityField',
42
+ name: 'age',
43
+ loc,
44
+ type: { kind: 'primitive', type: 'int', range: { min: 0, max: 120 } },
45
+ modifiers: ['optional'],
46
+ },
47
+ {
48
+ kind: 'EntityField',
49
+ name: 'tags',
50
+ loc,
51
+ type: {
52
+ kind: 'array',
53
+ itemType: { kind: 'primitive', type: 'string' },
54
+ },
55
+ modifiers: [],
56
+ },
57
+ {
58
+ kind: 'EntityField',
59
+ name: 'role',
60
+ loc,
61
+ type: { kind: 'enum', values: ['admin', 'user', 'guest'] },
62
+ modifiers: [],
63
+ defaultValue: 'user',
64
+ },
65
+ ],
66
+ relationships: [
67
+ {
68
+ kind: 'EntityRelationship',
69
+ type: 'has_many',
70
+ entity: 'Post',
71
+ loc,
72
+ },
73
+ ],
74
+ capabilities: [],
75
+ lifecycleHooks: [],
76
+ indexes: [
77
+ {
78
+ kind: 'EntityIndex',
79
+ fields: ['email'],
80
+ unique: true,
81
+ loc,
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ kind: 'EntityBlock',
87
+ name: 'Post',
88
+ loc,
89
+ fields: [
90
+ {
91
+ kind: 'EntityField',
92
+ name: 'title',
93
+ loc,
94
+ type: { kind: 'primitive', type: 'string' },
95
+ modifiers: [],
96
+ },
97
+ {
98
+ kind: 'EntityField',
99
+ name: 'content',
100
+ loc,
101
+ type: { kind: 'primitive', type: 'markdown' },
102
+ modifiers: [],
103
+ },
104
+ {
105
+ kind: 'EntityField',
106
+ name: 'published',
107
+ loc,
108
+ type: { kind: 'primitive', type: 'bool' },
109
+ modifiers: [],
110
+ defaultValue: false,
111
+ },
112
+ {
113
+ kind: 'EntityField',
114
+ name: 'tags',
115
+ loc,
116
+ type: {
117
+ kind: 'array',
118
+ itemType: { kind: 'reference', entity: 'Tag', optional: false },
119
+ },
120
+ modifiers: [],
121
+ },
122
+ ],
123
+ relationships: [
124
+ {
125
+ kind: 'EntityRelationship',
126
+ type: 'belongs_to',
127
+ entity: 'User',
128
+ as: 'author',
129
+ loc,
130
+ },
131
+ ],
132
+ capabilities: [],
133
+ lifecycleHooks: [],
134
+ indexes: [
135
+ {
136
+ kind: 'EntityIndex',
137
+ fields: ['title', 'published'],
138
+ loc,
139
+ },
140
+ ],
141
+ },
142
+ {
143
+ kind: 'EntityBlock',
144
+ name: 'Tag',
145
+ loc,
146
+ fields: [
147
+ {
148
+ kind: 'EntityField',
149
+ name: 'name',
150
+ loc,
151
+ type: { kind: 'primitive', type: 'string' },
152
+ modifiers: ['unique'],
153
+ },
154
+ {
155
+ kind: 'EntityField',
156
+ name: 'slug',
157
+ loc,
158
+ type: { kind: 'primitive', type: 'slug' },
159
+ modifiers: ['unique'],
160
+ },
161
+ ],
162
+ relationships: [],
163
+ capabilities: [],
164
+ lifecycleHooks: [],
165
+ indexes: [],
166
+ },
167
+ ];
168
+ const result = generateMongooseSchema(entities);
169
+ console.log('\n========================================');
170
+ console.log('GENERATED SCHEMA FILE');
171
+ console.log('========================================\n');
172
+ console.log(result.schema);
173
+ console.log('\n========================================');
174
+ console.log('GENERATED TYPES FILE');
175
+ console.log('========================================\n');
176
+ console.log(result.types);
177
+ });
178
+ });
@@ -0,0 +1,2 @@
1
+ declare function runExamples(): void;
2
+ export { runExamples };
@@ -0,0 +1,259 @@
1
+ // =============================================================================
2
+ // Kappa Radix UI Generator - Example Usage
3
+ // =============================================================================
4
+ //
5
+ // This example demonstrates how to use the Radix UI generator to create
6
+ // accessible, compound components based on Radix UI primitives.
7
+ //
8
+ import { generateRadixComponents } from '../kappa-radix-generator.js';
9
+ // =============================================================================
10
+ // Example 1: Simple Dialog Component
11
+ // =============================================================================
12
+ const confirmDialogSpec = {
13
+ kind: 'ComponentBlock',
14
+ name: 'ConfirmDialog',
15
+ props: [
16
+ {
17
+ kind: 'ComponentProp',
18
+ name: 'title',
19
+ type: 'string',
20
+ optional: false,
21
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
22
+ },
23
+ {
24
+ kind: 'ComponentProp',
25
+ name: 'message',
26
+ type: 'string',
27
+ optional: false,
28
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
29
+ },
30
+ {
31
+ kind: 'ComponentProp',
32
+ name: 'onConfirm',
33
+ type: 'func',
34
+ optional: false,
35
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
36
+ },
37
+ ],
38
+ structure: undefined,
39
+ variants: [],
40
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
41
+ };
42
+ // =============================================================================
43
+ // Example 2: Compound Dialog Component
44
+ // =============================================================================
45
+ const compoundDialogSpec = {
46
+ kind: 'ComponentBlock',
47
+ name: 'CustomDialog',
48
+ props: [
49
+ {
50
+ kind: 'ComponentProp',
51
+ name: 'open',
52
+ type: 'boolean',
53
+ optional: true,
54
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
55
+ },
56
+ {
57
+ kind: 'ComponentProp',
58
+ name: 'onOpenChange',
59
+ type: 'func',
60
+ optional: true,
61
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
62
+ },
63
+ ],
64
+ structure: undefined,
65
+ variants: [],
66
+ compound: [
67
+ {
68
+ kind: 'CompoundPart',
69
+ name: 'Trigger',
70
+ element: 'button',
71
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
72
+ },
73
+ {
74
+ kind: 'CompoundPart',
75
+ name: 'Overlay',
76
+ element: 'div',
77
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
78
+ },
79
+ {
80
+ kind: 'CompoundPart',
81
+ name: 'Content',
82
+ element: 'div',
83
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
84
+ },
85
+ {
86
+ kind: 'CompoundPart',
87
+ name: 'Title',
88
+ element: 'h2',
89
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
90
+ },
91
+ {
92
+ kind: 'CompoundPart',
93
+ name: 'Description',
94
+ element: 'p',
95
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
96
+ },
97
+ {
98
+ kind: 'CompoundPart',
99
+ name: 'Close',
100
+ element: 'button',
101
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
102
+ },
103
+ ],
104
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
105
+ };
106
+ // =============================================================================
107
+ // Example 3: Popover Component
108
+ // =============================================================================
109
+ const userPopoverSpec = {
110
+ kind: 'ComponentBlock',
111
+ name: 'UserPopover',
112
+ props: [
113
+ {
114
+ kind: 'ComponentProp',
115
+ name: 'user',
116
+ type: 'object',
117
+ optional: false,
118
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
119
+ },
120
+ ],
121
+ structure: undefined,
122
+ variants: [],
123
+ compound: [
124
+ {
125
+ kind: 'CompoundPart',
126
+ name: 'Trigger',
127
+ element: 'button',
128
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
129
+ },
130
+ {
131
+ kind: 'CompoundPart',
132
+ name: 'Content',
133
+ element: 'div',
134
+ props: ['side', 'align'],
135
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
136
+ },
137
+ ],
138
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
139
+ };
140
+ // =============================================================================
141
+ // Example 4: Tabs Component
142
+ // =============================================================================
143
+ const settingsTabsSpec = {
144
+ kind: 'ComponentBlock',
145
+ name: 'SettingsTabs',
146
+ props: [
147
+ {
148
+ kind: 'ComponentProp',
149
+ name: 'defaultValue',
150
+ type: 'string',
151
+ optional: true,
152
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
153
+ },
154
+ ],
155
+ structure: undefined,
156
+ variants: [],
157
+ compound: [
158
+ {
159
+ kind: 'CompoundPart',
160
+ name: 'List',
161
+ element: 'div',
162
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
163
+ },
164
+ {
165
+ kind: 'CompoundPart',
166
+ name: 'Trigger',
167
+ element: 'button',
168
+ props: ['value'],
169
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
170
+ },
171
+ {
172
+ kind: 'CompoundPart',
173
+ name: 'Content',
174
+ element: 'div',
175
+ props: ['value'],
176
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
177
+ },
178
+ ],
179
+ loc: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startOffset: 0, endOffset: 0 },
180
+ };
181
+ // =============================================================================
182
+ // Generate All Examples
183
+ // =============================================================================
184
+ function runExamples() {
185
+ console.log('='.repeat(80));
186
+ console.log('Kappa Radix UI Generator Examples');
187
+ console.log('='.repeat(80));
188
+ console.log();
189
+ // Generate all components
190
+ const result = generateRadixComponents([confirmDialogSpec, compoundDialogSpec, userPopoverSpec, settingsTabsSpec], {
191
+ provenance: true,
192
+ typescript: true,
193
+ a11yDocs: true,
194
+ basePath: 'components/ui',
195
+ });
196
+ // Print results
197
+ console.log(`Generated ${result.components.length} components:`);
198
+ console.log();
199
+ for (const component of result.components) {
200
+ console.log(`Component: ${component.path}`);
201
+ console.log(`Primitive: ${component.primitive}`);
202
+ console.log(`Content preview (first 500 chars):`);
203
+ console.log(component.content.slice(0, 500));
204
+ console.log();
205
+ console.log('-'.repeat(80));
206
+ console.log();
207
+ }
208
+ console.log('Required dependencies:');
209
+ for (const dep of result.dependencies) {
210
+ console.log(` - ${dep}`);
211
+ }
212
+ console.log();
213
+ // Show full example of compound dialog
214
+ console.log('='.repeat(80));
215
+ console.log('Full Example: Compound Dialog Component');
216
+ console.log('='.repeat(80));
217
+ console.log();
218
+ const compoundDialog = result.components.find((c) => c.path.includes('custom-dialog'));
219
+ if (compoundDialog) {
220
+ console.log(compoundDialog.content);
221
+ }
222
+ console.log();
223
+ // Show usage example
224
+ console.log('='.repeat(80));
225
+ console.log('Usage Example:');
226
+ console.log('='.repeat(80));
227
+ console.log();
228
+ console.log(`
229
+ import { CustomDialog } from '@/components/ui/custom-dialog';
230
+
231
+ function App() {
232
+ const [open, setOpen] = useState(false);
233
+
234
+ return (
235
+ <CustomDialog open={open} onOpenChange={setOpen}>
236
+ <CustomDialog.Trigger>Open Dialog</CustomDialog.Trigger>
237
+ <CustomDialog.Overlay />
238
+ <CustomDialog.Content>
239
+ <CustomDialog.Title>Confirm Action</CustomDialog.Title>
240
+ <CustomDialog.Description>
241
+ Are you sure you want to proceed?
242
+ </CustomDialog.Description>
243
+ <div className="flex gap-2">
244
+ <button onClick={() => setOpen(false)}>Cancel</button>
245
+ <button onClick={() => handleConfirm()}>Confirm</button>
246
+ </div>
247
+ <CustomDialog.Close />
248
+ </CustomDialog.Content>
249
+ </CustomDialog>
250
+ );
251
+ }
252
+ `.trim());
253
+ console.log();
254
+ }
255
+ // Run examples if this file is executed directly
256
+ if (import.meta.url === `file://${process.argv[1]}`) {
257
+ runExamples();
258
+ }
259
+ export { runExamples };