create-lego-one 2.0.12 → 2.0.14

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 (78) hide show
  1. package/dist/index.cjs +150 -15
  2. package/dist/index.cjs.map +1 -1
  3. package/package.json +1 -1
  4. package/template/.cursor/rules/rules.mdc +639 -0
  5. package/template/.dockerignore +58 -0
  6. package/template/.env.example +18 -0
  7. package/template/.eslintignore +5 -0
  8. package/template/.eslintrc.js +28 -0
  9. package/template/.prettierignore +6 -0
  10. package/template/.prettierrc +11 -0
  11. package/template/CLAUDE.md +634 -0
  12. package/template/Dockerfile +67 -0
  13. package/template/PROMPT.md +457 -0
  14. package/template/README.md +325 -0
  15. package/template/docker-compose.yml +48 -0
  16. package/template/docker-entrypoint.sh +23 -0
  17. package/template/docs/checkpoints/.template.md +64 -0
  18. package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
  19. package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
  20. package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
  21. package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
  22. package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
  23. package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
  24. package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
  25. package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
  26. package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
  27. package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
  28. package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
  29. package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
  30. package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
  31. package/template/docs/framework/plans/00-index.md +164 -0
  32. package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
  33. package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
  34. package/template/docs/framework/plans/03-host-kernel.md +1518 -0
  35. package/template/docs/framework/plans/04-auth-system.md +1466 -0
  36. package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
  37. package/template/docs/framework/plans/06-ui-components.md +1478 -0
  38. package/template/docs/framework/plans/07-communication-system.md +1106 -0
  39. package/template/docs/framework/plans/08-plugin-system.md +1179 -0
  40. package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
  41. package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
  42. package/template/docs/framework/plans/11-testing.md +935 -0
  43. package/template/docs/framework/plans/12-deployment.md +896 -0
  44. package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
  45. package/template/docs/framework/research/00-modernjs-audit.md +488 -0
  46. package/template/docs/framework/research/01-system-blueprint.md +721 -0
  47. package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
  48. package/template/docs/framework/research/03-host-setup.md +714 -0
  49. package/template/docs/framework/research/04-plugin-architecture.md +645 -0
  50. package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
  51. package/template/docs/framework/research/06-cli-strategy.md +615 -0
  52. package/template/docs/framework/research/07-deployment.md +629 -0
  53. package/template/docs/framework/research/README.md +282 -0
  54. package/template/docs/framework/setup/00-index.md +210 -0
  55. package/template/docs/framework/setup/01-framework-structure.md +308 -0
  56. package/template/docs/framework/setup/02-development-workflow.md +405 -0
  57. package/template/docs/framework/setup/03-environment-setup.md +215 -0
  58. package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
  59. package/template/docs/framework/setup/05-plugin-system.md +620 -0
  60. package/template/docs/framework/setup/06-communication-patterns.md +451 -0
  61. package/template/docs/framework/setup/07-plugin-development.md +582 -0
  62. package/template/docs/framework/setup/08-component-library.md +658 -0
  63. package/template/docs/framework/setup/09-data-integration.md +609 -0
  64. package/template/docs/framework/setup/10-auth-rbac.md +497 -0
  65. package/template/docs/framework/setup/11-hooks-api.md +393 -0
  66. package/template/docs/framework/setup/12-components-api.md +665 -0
  67. package/template/docs/framework/setup/13-deployment-guide.md +566 -0
  68. package/template/docs/framework/setup/README.md +548 -0
  69. package/template/host/package.json +1 -1
  70. package/template/nginx.conf +72 -0
  71. package/template/package.json +1 -1
  72. package/template/packages/plugins/@lego/plugin-dashboard/package.json +1 -1
  73. package/template/packages/plugins/@lego/plugin-todo/package.json +1 -1
  74. package/template/pocketbase/CHANGELOG.md +911 -0
  75. package/template/pocketbase/LICENSE.md +17 -0
  76. package/template/scripts/create-plugin.js +221 -0
  77. package/template/scripts/deploy.sh +56 -0
  78. package/template/tsconfig.base.json +26 -0
@@ -0,0 +1,457 @@
1
+ # PROMPT.md
2
+
3
+ **Lego-One Vibe Coding Session Template**
4
+
5
+ > Use this template to provide complete context for AI-assisted development sessions. Fill out all sections before starting.
6
+
7
+ ---
8
+
9
+ ## Session Information
10
+
11
+ **Date:** `{YYYY-MM-DD}`
12
+ **Session ID:** `{optional: for tracking related work}`
13
+ **Related Checkpoint:** `{optional: link to /docs/checkpoints/ file}`
14
+
15
+ ---
16
+
17
+ ## Task Description
18
+
19
+ **What needs to be done?**
20
+
21
+ <!-- Provide a detailed explanation of the feature, bugfix, or enhancement -->
22
+
23
+
24
+ **Success Criteria:**
25
+
26
+ <!-- Define what "done" looks like. What should work? What should be tested? -->
27
+
28
+ - [ ] Criterion 1
29
+ - [ ] Criterion 2
30
+ - [ ] Criterion 3
31
+
32
+ ---
33
+
34
+ ## Target Scope
35
+
36
+ **Is this for:**
37
+
38
+ - [ ] **Host/Framework (Kernel)** - Core system changes (auth, RBAC, shared state, etc.)
39
+ - [ ] **Application Plugin** - New or modified plugin for this application
40
+
41
+ **Clarification:**
42
+
43
+ <!-- If Framework: Explain why core changes are needed -->
44
+ <!-- If Application: Describe which plugin or what new plugin to create -->
45
+
46
+ ---
47
+
48
+ ## Type & Classification
49
+
50
+ **What type of work is this?**
51
+
52
+ - [ ] **New Plugin** - Creating a brand new plugin
53
+ - [ ] **Plugin Enhancement** - Adding features to existing plugin
54
+ - [ ] **Bug Fix** - Fixing an issue
55
+ - [ ] **Refactoring** - Code improvement without behavior change
56
+ - [ ] **Documentation** - Updating docs or creating new docs
57
+
58
+ **Plugin Name (if applicable):**
59
+
60
+ <!-- e.g., @lego/plugin-calculator, @lego/plugin-inventory, etc. -->
61
+
62
+ ---
63
+
64
+ ## Dependencies
65
+
66
+ **Required Services:**
67
+
68
+ - [ ] PocketBase (database)
69
+ - [ ] Authentication (user login required)
70
+ - [ ] Authorization (RBAC/permissions)
71
+ - [ ] Organization context (multi-tenancy)
72
+ - [ ] External API (specify which)
73
+
74
+ **Database Collections (if new data needed):**
75
+
76
+ <!-- List PocketBase collections that need to be created -->
77
+
78
+ | Collection Name | Purpose | Multi-Tenancy Required? |
79
+ |----------------|---------|------------------------|
80
+ | `example_items` | Stores example data | Yes (organizationId, ownerId) |
81
+
82
+ **npm Packages (if needed):**
83
+
84
+ <!-- List any additional dependencies -->
85
+
86
+ ```bash
87
+ pnpm add <package-name>
88
+ ```
89
+
90
+ ---
91
+
92
+ ## UI/UX Requirements
93
+
94
+ **Pages/Routes:**
95
+
96
+ <!-- Does this plugin need dedicated pages? List them here -->
97
+
98
+ | Route Path | Page Name | Protected? | Required Permissions |
99
+ |------------|-----------|-----------|---------------------|
100
+ | `/my-plugin` | MyPluginPage | Yes | `myplugin.read` |
101
+ | `/my-plugin/:id` | ItemDetailPage | Yes | `myplugin.read` |
102
+
103
+ **Slot Injections:**
104
+
105
+ <!-- Should this plugin inject UI into existing slots? -->
106
+
107
+ | Slot Location | Component | Purpose | Order |
108
+ |---------------|-----------|---------|-------|
109
+ | `sidebar:nav` | NavigationLink | Add to sidebar navigation | 100 |
110
+
111
+ **UI Components Needed:**
112
+
113
+ <!-- List UI components required (use existing from kernel when possible) -->
114
+
115
+ - [ ] Forms (use existing: Button, Input, Select, etc.)
116
+ - [ ] Tables/Lists
117
+ - [ ] Dialogs/Modals
118
+ - [ ] Toasts/Notifications
119
+ - [ ] Custom components (describe)
120
+
121
+ **Wireframe/Mockup (Optional):**
122
+
123
+ <!-- Link to design or describe layout -->
124
+
125
+ ```
126
+ ┌─────────────────────────────────────┐
127
+ │ Page Header │
128
+ │ [Button] [Filter] [Search] │
129
+ ├─────────────────────────────────────┤
130
+ │ Table/List View │
131
+ │ - Item 1 │
132
+ │ - Item 2 │
133
+ └─────────────────────────────────────┘
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Logic Flow
139
+
140
+ **How should the feature work?**
141
+
142
+ <!-- Step-by-step description of the feature behavior -->
143
+
144
+ 1. **User Action:** User clicks "Create Item" button
145
+ 2. **System Response:** Opens dialog with form
146
+ 3. **Validation:** Form validates using Zod schema
147
+ 4. **Backend:** Creates record in PocketBase with organizationId
148
+ 5. **UI Update:** Refreshes list, shows success toast
149
+ 6. **Error Handling:** Displays error message if creation fails
150
+
151
+ **Data Flow Diagram (Optional):**
152
+
153
+ ```
154
+ ┌─────────┐ ┌─────────────┐ ┌──────────────┐
155
+ │ Plugin │────>│ Window Bridge│────>│ Kernel/Host │
156
+ │ Component│ │ (publish) │ │ Services │
157
+ └─────────┘ └─────────────┘ └──────────────┘
158
+
159
+ v
160
+ ┌──────────────┐
161
+ │ PocketBase │
162
+ │ (API) │
163
+ └──────────────┘
164
+ ```
165
+
166
+ **State Management:**
167
+
168
+ <!-- How is state managed? -->
169
+
170
+ - [ ] Local component state (useState)
171
+ - [ ] TanStack Query (server state)
172
+ - [ ] Kernel state (useGlobalKernelState)
173
+ - [ ] Channel bus (events)
174
+
175
+ ---
176
+
177
+ ## API & Data Requirements
178
+
179
+ **PocketBase Collections (if creating new):**
180
+
181
+ ```javascript
182
+ {
183
+ name: 'my_collection',
184
+ type: 'base',
185
+ fields: [
186
+ // Multi-tenancy required fields
187
+ { name: 'organizationId', type: 'relation', required: true },
188
+ { name: 'ownerId', type: 'relation', required: true },
189
+
190
+ // Your fields here
191
+ { name: 'title', type: 'text', required: true },
192
+ { name: 'description', type: 'text' },
193
+ { name: 'status', type: 'select', options: ['active', 'inactive'] },
194
+ ],
195
+
196
+ // Multi-tenancy API rules
197
+ listRule: '@request.auth.id != "" && organizationId = @request.auth.membership.organizations',
198
+ viewRule: '@request.auth.id != "" && organizationId = @request.auth.membership.organizations',
199
+ createRule: '@request.auth.id != "" && organizationId = @request.auth.membership.organizations',
200
+ updateRule: '@request.auth.id != "" && organizationId = @request.auth.membership.organizations && ownerId = @request.auth.id',
201
+ deleteRule: '@request.auth.id != "" && organizationId = @request.auth.membership.organizations && ownerId = @request.auth.id',
202
+ }
203
+ ```
204
+
205
+ **Custom Hooks to Create:**
206
+
207
+ <!-- List data fetching and mutation hooks needed -->
208
+
209
+ - `useMyItems()` - Fetch items for current organization
210
+ - `useCreateMyItem()` - Create new item
211
+ - `useUpdateMyItem()` - Update existing item
212
+ - `useDeleteMyItem()` - Delete item
213
+
214
+ ---
215
+
216
+ ## Permissions & Security
217
+
218
+ **Required Permissions (RBAC):**
219
+
220
+ <!-- Define permissions needed for this feature -->
221
+
222
+ | Permission | Resource | Action | Description |
223
+ |------------|----------|--------|-------------|
224
+ | `myplugin.read` | myplugin | read | View items |
225
+ | `myplugin.write` | myplugin | write | Create/edit items |
226
+ | `myplugin.delete` | myplugin | delete | Delete items |
227
+
228
+ **Access Control:**
229
+
230
+ - [ ] All pages require authentication
231
+ - [ ] Certain actions require specific permissions
232
+ - [ ] Data scoped to organization
233
+ - [ ] Ownership verification (users can only edit their own items)
234
+
235
+ ---
236
+
237
+ ## Testing Strategy
238
+
239
+ **Test Cases:**
240
+
241
+ <!-- List scenarios that must be tested -->
242
+
243
+ - [ ] User can view list of items
244
+ - [ ] User can create new item
245
+ - [ ] User can edit own item
246
+ - [ ] User cannot edit others' items
247
+ - [ ] User can delete own item
248
+ - [ ] Form validation works
249
+ - [ ] Toast notifications display
250
+ - [ ] Organization isolation works (users only see their org's data)
251
+
252
+ **Testing Commands:**
253
+
254
+ ```bash
255
+ # Run tests
256
+ pnpm test
257
+
258
+ # E2E tests
259
+ pnpm test:e2e
260
+
261
+ # Type checking
262
+ pnpm run typecheck
263
+ ```
264
+
265
+ ---
266
+
267
+ ## AI Instructions
268
+
269
+ **IMPORTANT:** Read these instructions before starting work:
270
+
271
+ ### 1. DOCUMENTATION FIRST
272
+
273
+ You **MUST** read the relevant documentation files before writing any code:
274
+
275
+ 1. **ALWAYS read** `/docs/framework/setup/00-index.md` first
276
+ 2. **Read files based on task type:**
277
+ - Creating plugin → Read `07-plugin-development.md`
278
+ - Adding UI components → Read `12-components-api.md`
279
+ - Working with hooks → Read `11-hooks-api.md`
280
+ - Deployment → Read `13-deployment-guide.md`
281
+ 3. **Follow established patterns** from Dashboard/Todo plugins
282
+
283
+ ### 2. MICROKERNEL ARCHITECTURE RULES
284
+
285
+ **STRICT SEPARATION:**
286
+
287
+ - **Framework (Kernel)** = Core services in `host/src/kernel/`
288
+ - **Application Plugins** = Features in `packages/plugins/@lego/`
289
+
290
+ **YOU CANNOT:**
291
+ - Modify kernel code when working on application plugins
292
+ - Create circular dependencies between host and plugins
293
+ - Import directly from host kernel in plugins (use window bridge)
294
+
295
+ **YOU MUST:**
296
+ - Implement all features within plugin scope
297
+ - Use window bridge for host communication: `window.__LEGO_CHANNEL_BUS__`
298
+ - Read kernel state via: `window.__LEGO_KERNEL_STATE__`
299
+ - Follow existing plugin structure exactly
300
+
301
+ **IF KERNEL MODIFICATION IS NEEDED:**
302
+ 1. **STOP IMMEDIATELY**
303
+ 2. **Inform the user:** "This task requires Framework/Kernel changes"
304
+ 3. **Request permission** before proceeding
305
+ 4. **If approved:** Make kernel changes first, then plugin changes
306
+
307
+ ### 3. CODE ORGANIZATION
308
+
309
+ **File Structure for New Plugin:**
310
+
311
+ ```
312
+ packages/plugins/@lego/plugin-<name>/
313
+ ├── src/
314
+ │ ├── components/ # React components
315
+ │ ├── hooks/ # Data fetching hooks
316
+ │ ├── pages/ # Page components
317
+ │ ├── plugin.config.ts # Plugin configuration
318
+ │ ├── plugin.ts # Entry point
319
+ │ ├── types.ts # TypeScript types
320
+ │ ├── schemas.ts # Zod validation schemas
321
+ │ └── global.css # Plugin styles
322
+ ├── package.json
323
+ ├── tsconfig.json
324
+ ├── modern.config.ts
325
+ └── tailwind.config.ts
326
+ ```
327
+
328
+ **Naming Conventions:**
329
+ - Components: PascalCase (`MyComponent.tsx`)
330
+ - Hooks: camelCase with 'use' prefix (`useMyData.ts`)
331
+ - Types: PascalCase (`MyType`, `MyInterface`)
332
+ - Files: kebab-case for non-TS (`my-file.css`)
333
+
334
+ ### 4. MULTI-TENANCY REQUIREMENTS
335
+
336
+ **ALL data MUST be scoped to organization:**
337
+
338
+ ```typescript
339
+ // ✅ CORRECT - Filter by organization
340
+ const result = await pb.collection('items').getList(1, 50, {
341
+ filter: `organizationId = "${orgId}"`
342
+ });
343
+
344
+ // ❌ WRONG - No organization filter
345
+ const result = await pb.collection('items').getList(1, 50);
346
+ ```
347
+
348
+ **PocketBase collections MUST include:**
349
+ - `organizationId` field (relation to organizations)
350
+ - `ownerId` field (relation to users)
351
+ - API rules with organization filtering
352
+
353
+ ### 5. TYPE SAFETY
354
+
355
+ - **TypeScript strict mode** is required
356
+ - Define all types in `types.ts`
357
+ - Use Zod schemas for validation
358
+ - No `any` types without justification
359
+
360
+ ### 6. ERROR HANDLING
361
+
362
+ - **Always handle loading states** (show spinners/skeletons)
363
+ - **Always handle error states** (show error messages)
364
+ - **Use toast notifications** for user feedback
365
+ - **Log errors** for debugging
366
+
367
+ ### 7. TESTING
368
+
369
+ - Write unit tests for hooks and utilities
370
+ - Write component tests for UI
371
+ - Test multi-tenancy (org isolation)
372
+ - Test permission checks
373
+
374
+ ### 8. CHECKPOINT DOCUMENTATION
375
+
376
+ **You MUST create a checkpoint file for all work:**
377
+
378
+ - Bugfixes → `/docs/checkpoints/bugfixes/<title>.md`
379
+ - Features → `/docs/checkpoints/features/<title>.md`
380
+ - Enhancements → `/docs/checkpoints/enhancements/<title>.md`
381
+
382
+ Use the template from `/docs/checkpoints/.template.md`
383
+
384
+ ---
385
+
386
+ ## Additional Notes
387
+
388
+ <!-- Any other context, constraints, or preferences -->
389
+
390
+ - Preferred design style: (minimal, detailed, etc.)
391
+ - Performance considerations:
392
+ - Accessibility requirements:
393
+ - Browser compatibility:
394
+ - Other requirements:
395
+
396
+ ---
397
+
398
+ ## Session Checklist
399
+
400
+ **Before starting work:**
401
+
402
+ - [ ] All sections above are filled out
403
+ - [ ] AI has read relevant documentation
404
+ - [ ] Target scope is clear (Framework vs Application)
405
+ - [ ] Dependencies are identified
406
+ - [ ] UI/UX requirements are defined
407
+
408
+ **During work:**
409
+
410
+ - [ ] Following microkernel architecture rules
411
+ - [ ] Using existing components and patterns
412
+ - [ ] Writing tests as code is developed
413
+ - [ ] Handling errors and loading states
414
+ - [ ] Maintaining type safety
415
+
416
+ **After completion:**
417
+
418
+ - [ ] All acceptance criteria met
419
+ - [ ] Tests passing
420
+ - [ ] Checkpoint documentation created
421
+ - [ ] Code follows framework patterns
422
+ - [ ] Ready for review
423
+
424
+ ---
425
+
426
+ ## Quick Reference
427
+
428
+ **Essential Files:**
429
+ - Documentation Index: `/docs/framework/setup/00-index.md`
430
+ - Plugin Development: `/docs/framework/setup/07-plugin-development.md`
431
+ - Components API: `/docs/framework/setup/12-components-api.md`
432
+ - Hooks API: `/docs/framework/setup/11-hooks-api.md`
433
+ - Checkpoint Template: `/docs/checkpoints/.template.md`
434
+
435
+ **Key Commands:**
436
+ ```bash
437
+ # Development
438
+ pnpm run dev:all # Start all services
439
+ pnpm run dev:host # Start host only
440
+ pnpm --filter './packages/plugins/@lego/plugin-<name>' dev
441
+
442
+ # Building
443
+ pnpm run build # Build all
444
+ pnpm --filter './packages/plugins/@lego/plugin-<name>' build
445
+
446
+ # Testing
447
+ pnpm test # Run all tests
448
+ pnpm test:e2e # E2E tests
449
+ pnpm test:coverage # Coverage report
450
+
451
+ # Type Checking
452
+ pnpm run typecheck # TypeScript validation
453
+ ```
454
+
455
+ ---
456
+
457
+ **READY TO START:** When all sections are complete, share this file with the AI and begin the vibe coding session!