create-lego-one 2.0.12 → 2.0.13
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/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
- package/template/.cursor/rules/rules.mdc +639 -0
- package/template/.dockerignore +58 -0
- package/template/.env.example +18 -0
- package/template/.eslintignore +5 -0
- package/template/.eslintrc.js +28 -0
- package/template/.prettierignore +6 -0
- package/template/.prettierrc +11 -0
- package/template/CLAUDE.md +634 -0
- package/template/Dockerfile +67 -0
- package/template/PROMPT.md +457 -0
- package/template/README.md +325 -0
- package/template/docker-compose.yml +48 -0
- package/template/docker-entrypoint.sh +23 -0
- package/template/docs/checkpoints/.template.md +64 -0
- package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
- package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
- package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
- package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
- package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
- package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
- package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
- package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
- package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
- package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
- package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
- package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
- package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
- package/template/docs/framework/plans/00-index.md +164 -0
- package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
- package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
- package/template/docs/framework/plans/03-host-kernel.md +1518 -0
- package/template/docs/framework/plans/04-auth-system.md +1466 -0
- package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
- package/template/docs/framework/plans/06-ui-components.md +1478 -0
- package/template/docs/framework/plans/07-communication-system.md +1106 -0
- package/template/docs/framework/plans/08-plugin-system.md +1179 -0
- package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
- package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
- package/template/docs/framework/plans/11-testing.md +935 -0
- package/template/docs/framework/plans/12-deployment.md +896 -0
- package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
- package/template/docs/framework/research/00-modernjs-audit.md +488 -0
- package/template/docs/framework/research/01-system-blueprint.md +721 -0
- package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
- package/template/docs/framework/research/03-host-setup.md +714 -0
- package/template/docs/framework/research/04-plugin-architecture.md +645 -0
- package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
- package/template/docs/framework/research/06-cli-strategy.md +615 -0
- package/template/docs/framework/research/07-deployment.md +629 -0
- package/template/docs/framework/research/README.md +282 -0
- package/template/docs/framework/setup/00-index.md +210 -0
- package/template/docs/framework/setup/01-framework-structure.md +308 -0
- package/template/docs/framework/setup/02-development-workflow.md +405 -0
- package/template/docs/framework/setup/03-environment-setup.md +215 -0
- package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
- package/template/docs/framework/setup/05-plugin-system.md +620 -0
- package/template/docs/framework/setup/06-communication-patterns.md +451 -0
- package/template/docs/framework/setup/07-plugin-development.md +582 -0
- package/template/docs/framework/setup/08-component-library.md +658 -0
- package/template/docs/framework/setup/09-data-integration.md +609 -0
- package/template/docs/framework/setup/10-auth-rbac.md +497 -0
- package/template/docs/framework/setup/11-hooks-api.md +393 -0
- package/template/docs/framework/setup/12-components-api.md +665 -0
- package/template/docs/framework/setup/13-deployment-guide.md +566 -0
- package/template/docs/framework/setup/README.md +548 -0
- package/template/host/package.json +1 -1
- package/template/nginx.conf +72 -0
- package/template/package.json +1 -1
- package/template/packages/plugins/@lego/plugin-dashboard/package.json +1 -1
- package/template/packages/plugins/@lego/plugin-todo/package.json +1 -1
- package/template/pocketbase/CHANGELOG.md +911 -0
- package/template/pocketbase/LICENSE.md +17 -0
- package/template/scripts/create-plugin.js +221 -0
- package/template/scripts/deploy.sh +56 -0
- package/template/tsconfig.base.json +26 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# Lego-One Research Documentation
|
|
2
|
+
|
|
3
|
+
**Project:** Lego-One (Modern.js SaaS OS)
|
|
4
|
+
**Status:** Research & Implementation Complete
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
This directory contains comprehensive architectural research for building a **Microkernel SaaS Boilerplate** using Modern.js, Garfish (micro-frontends), PocketBase, and modern React tooling.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Document Index
|
|
13
|
+
|
|
14
|
+
### Phase 0: Architecture & Research
|
|
15
|
+
|
|
16
|
+
| Document | Description | Status |
|
|
17
|
+
|----------|-------------|--------|
|
|
18
|
+
| [`00-modernjs-audit.md`](./00-modernjs-audit.md) | Modern.js + Garfish configuration, shared dependencies, externals | ✅ |
|
|
19
|
+
| [`01-system-blueprint.md`](./01-system-blueprint.md) | High-level Host/Consumer architecture, communication patterns | ✅ |
|
|
20
|
+
| [`02-data-migration-protocol.md`](./02-data-migration-protocol.md) | PocketBase auto-schema synchronization on startup | ✅ |
|
|
21
|
+
|
|
22
|
+
### Phase 1: Implementation Plan
|
|
23
|
+
|
|
24
|
+
| Document | Description | Status |
|
|
25
|
+
|----------|-------------|--------|
|
|
26
|
+
| [`03-host-setup.md`](./03-host-setup.md) | Initialize Modern.js host with Tailwind + Shadcn UI | ✅ |
|
|
27
|
+
| [`04-plugin-architecture.md`](./04-plugin-architecture.md) | Create "Hello World" plugin and register with host | ✅ |
|
|
28
|
+
| [`05-slot-injection-pattern.md`](./05-slot-injection-pattern.md) | UI extension system for plugins to inject into host layout | ✅ |
|
|
29
|
+
|
|
30
|
+
### Phase 2: DevOps
|
|
31
|
+
|
|
32
|
+
| Document | Description | Status |
|
|
33
|
+
|----------|-------------|--------|
|
|
34
|
+
| [`06-cli-strategy.md`](./06-cli-strategy.md) | `pnpm create lego-one` CLI tool implementation | ✅ |
|
|
35
|
+
| [`07-deployment.md`](./07-deployment.md) | Deploy host and plugins (Monorepo vs Polyrepo) | ✅ |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Key Architectural Decisions
|
|
40
|
+
|
|
41
|
+
| Decision | Choice | Rationale |
|
|
42
|
+
|----------|--------|-----------|
|
|
43
|
+
| **Framework** | Modern.js | Native Garfish support, Rspack performance |
|
|
44
|
+
| **Micro-Frontends** | Garfish | Built into Modern.js, mature ecosystem |
|
|
45
|
+
| **State Management** | Zustand | Lightweight, works across MFE boundaries |
|
|
46
|
+
| **Backend** | PocketBase | Single binary, multi-tenancy via API Rules |
|
|
47
|
+
| **Distribution** | npm CLI + Git Template | Easy project creation, user control over updates |
|
|
48
|
+
| **Repo Structure** | Monorepo | Shared deps, coordinated changes, easier onboarding |
|
|
49
|
+
| **Dev Deployment** | Separate servers per plugin | Independent plugin development |
|
|
50
|
+
| **Prod Deployment** | Single server (plugins bundled) | One app, one deployment, simpler operations |
|
|
51
|
+
| **Version Management** | Automated semantic versioning | Patch/minor/major releases with git tags |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Technology Stack
|
|
56
|
+
|
|
57
|
+
| Layer | Technology |
|
|
58
|
+
|-------|-----------|
|
|
59
|
+
| **Framework** | Modern.js + Rspack |
|
|
60
|
+
| **MFE Engine** | Garfish |
|
|
61
|
+
| **UI** | React 18 + Tailwind CSS + Shadcn UI + Radix Primitives |
|
|
62
|
+
| **State** | Zustand + TanStack Query v5 |
|
|
63
|
+
| **Backend** | PocketBase |
|
|
64
|
+
| **Language** | TypeScript (strict) |
|
|
65
|
+
| **CLI** | Commander + Prompts + Chalk |
|
|
66
|
+
| **Distribution** | npm registry |
|
|
67
|
+
| **Versioning** | Automated scripts (patch/minor/major) |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Distribution & Publishing
|
|
72
|
+
|
|
73
|
+
### CLI Distribution
|
|
74
|
+
|
|
75
|
+
Lego-One is distributed via npm as a create CLI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Create a new Lego-One application
|
|
79
|
+
pnpm create lego-one my-saas-app
|
|
80
|
+
|
|
81
|
+
# Or using npx
|
|
82
|
+
npx create-lego-one my-saas-app
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**CLI Package:** `create-lego-one`
|
|
86
|
+
- **Location:** `packages/create-lego-one/`
|
|
87
|
+
- **Entry Point:** `dist/index.js` (built from `src/index.ts`)
|
|
88
|
+
- **Template:** Copied from monorepo root during CLI execution
|
|
89
|
+
- **Dependencies:** prompts, commander, chalk, ora, fs-extra, validate-npm-package-name
|
|
90
|
+
|
|
91
|
+
### Version Management
|
|
92
|
+
|
|
93
|
+
Automated version bumping scripts:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Patch release (bug fixes)
|
|
97
|
+
pnpm run version:patch
|
|
98
|
+
|
|
99
|
+
# Minor release (new features)
|
|
100
|
+
pnpm run version:minor
|
|
101
|
+
|
|
102
|
+
# Major release (breaking changes)
|
|
103
|
+
pnpm run version:major
|
|
104
|
+
|
|
105
|
+
# Pre-release (beta/alpha)
|
|
106
|
+
pnpm run version:pre
|
|
107
|
+
|
|
108
|
+
# Full release workflow (build, test, version, publish, push)
|
|
109
|
+
pnpm run release
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Script:** `scripts/version.js`
|
|
113
|
+
- Updates root `package.json`
|
|
114
|
+
- Updates `host/package.json`
|
|
115
|
+
- Updates all plugin `package.json` files
|
|
116
|
+
- Creates git tag automatically
|
|
117
|
+
- Follows semantic versioning
|
|
118
|
+
|
|
119
|
+
### Publishing to npm
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Build CLI package
|
|
123
|
+
cd packages/create-lego-one
|
|
124
|
+
pnpm run build
|
|
125
|
+
|
|
126
|
+
# Publish to npm (from root)
|
|
127
|
+
pnpm run publish:cli
|
|
128
|
+
|
|
129
|
+
# Or manually
|
|
130
|
+
cd packages/create-lego-one
|
|
131
|
+
npm publish --access public
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Configuration:** `.npmrc`
|
|
135
|
+
- `access=public` - Public scope packages
|
|
136
|
+
- `provenance=true` - Cryptographic proof of publisher identity
|
|
137
|
+
- `engine-strict=true` - Enforce Node.js version requirements
|
|
138
|
+
|
|
139
|
+
### Update Strategy for Users
|
|
140
|
+
|
|
141
|
+
Users of Lego-One can update their framework installation:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Update Lego-One to latest version
|
|
145
|
+
pnpm update lego-one
|
|
146
|
+
|
|
147
|
+
# Or update create-lego-one CLI
|
|
148
|
+
pnpm update create-lego-one
|
|
149
|
+
|
|
150
|
+
# Or specific version
|
|
151
|
+
pnpm update lego-one@latest
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Plugin Isolation:**
|
|
155
|
+
- Custom plugins in `packages/plugins/@custom/` are never overwritten
|
|
156
|
+
- Framework updates only affect `@lego/*` packages
|
|
157
|
+
- Users maintain full control over custom code
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Architecture Summary
|
|
162
|
+
|
|
163
|
+
### Microkernel Pattern
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
┌─────────────────────────────────────────────────────────┐
|
|
167
|
+
│ Host (Kernel) │
|
|
168
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
169
|
+
│ │ Auth │ │ RBAC │ │ State │ │
|
|
170
|
+
│ │ System │ │ System │ │ Management │ │
|
|
171
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
172
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
173
|
+
│ │ UI │ │ Channels │ │ Slot │ │
|
|
174
|
+
│ │ Layout │ │ Bus │ │ Injection │ │
|
|
175
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
176
|
+
└─────────────────────────────────────────────────────────┘
|
|
177
|
+
│
|
|
178
|
+
│ via Garfish + Window Bridge
|
|
179
|
+
│
|
|
180
|
+
┌──────────────────┼──────────────────┐
|
|
181
|
+
│ │ │
|
|
182
|
+
┌───────▼────────┐ ┌───────▼────────┐ ┌───────▼────────┐
|
|
183
|
+
│ Dashboard │ │ Todo │ │ Custom │
|
|
184
|
+
│ Plugin │ │ Plugin │ │ Plugins │
|
|
185
|
+
└────────────────┘ └────────────────┘ └────────────────┘
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Communication Patterns
|
|
189
|
+
|
|
190
|
+
**Host → Plugin:**
|
|
191
|
+
- Window bridge state (`window.__LEGO_KERNEL_STATE__`)
|
|
192
|
+
- Channel bus for events (`window.__LEGO_CHANNEL_BUS__`)
|
|
193
|
+
- Slot injection for UI components
|
|
194
|
+
|
|
195
|
+
**Plugin → Host:**
|
|
196
|
+
- Read kernel state via window bridge
|
|
197
|
+
- Publish events via channel bus
|
|
198
|
+
- Inject UI into predefined slots
|
|
199
|
+
|
|
200
|
+
**Plugin ↔ Plugin:**
|
|
201
|
+
- Via channel bus events
|
|
202
|
+
- No direct dependencies
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Development Workflow
|
|
207
|
+
|
|
208
|
+
### For Framework Maintainers
|
|
209
|
+
|
|
210
|
+
1. **Make changes** to host, kernel, or built-in plugins
|
|
211
|
+
2. **Bump version** using `pnpm run version:patch/minor/major`
|
|
212
|
+
3. **Build and test** using `pnpm run build && pnpm test`
|
|
213
|
+
4. **Publish CLI** using `pnpm run publish:cli`
|
|
214
|
+
5. **Push to git** with tag for version tracking
|
|
215
|
+
|
|
216
|
+
### For End Users
|
|
217
|
+
|
|
218
|
+
1. **Create new project:** `pnpm create lego-one my-app`
|
|
219
|
+
2. **Develop custom plugins** in `packages/plugins/@custom/`
|
|
220
|
+
3. **Update framework:** `pnpm update lego-one` (custom plugins preserved)
|
|
221
|
+
4. **Build for production:** `pnpm run build`
|
|
222
|
+
5. **Deploy:** Use provided Dockerfile or custom deployment
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## File Structure
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
lego-one/
|
|
230
|
+
├── host/ # Kernel application
|
|
231
|
+
│ ├── src/
|
|
232
|
+
│ │ ├── kernel/ # Core systems
|
|
233
|
+
│ │ ├── layout/ # UI layout
|
|
234
|
+
│ │ ├── routes/ # Page routes
|
|
235
|
+
│ │ └── providers/ # Context providers
|
|
236
|
+
│ └── package.json
|
|
237
|
+
│
|
|
238
|
+
├── packages/
|
|
239
|
+
│ ├── plugins/
|
|
240
|
+
│ │ └── @lego/
|
|
241
|
+
│ │ ├── plugin-dashboard/ # Built-in plugins
|
|
242
|
+
│ │ └── plugin-todo/
|
|
243
|
+
│ │
|
|
244
|
+
│ └── create-lego-one/ # CLI for `pnpm create`
|
|
245
|
+
│ ├── src/ # CLI source
|
|
246
|
+
│ ├── template/ # (Optional) bundled template
|
|
247
|
+
│ └── package.json
|
|
248
|
+
│
|
|
249
|
+
├── scripts/
|
|
250
|
+
│ ├── version.js # Version management
|
|
251
|
+
│ └── create-plugin.js # Plugin scaffolding
|
|
252
|
+
│
|
|
253
|
+
├── docs/
|
|
254
|
+
│ ├── framework/ # Architecture docs
|
|
255
|
+
│ ├── api/ # API references
|
|
256
|
+
│ ├── guides/ # User guides
|
|
257
|
+
│ └── checkpoints/ # Phase completion tracking
|
|
258
|
+
│
|
|
259
|
+
├── .npmrc # npm publishing config
|
|
260
|
+
├── pnpm-workspace.yaml # Monorepo config
|
|
261
|
+
└── package.json # Root package config
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Next Steps
|
|
267
|
+
|
|
268
|
+
1. **Review:** Review all research documents
|
|
269
|
+
2. **Setup:** Follow the setup guide in `/docs/framework/setup/README.md`
|
|
270
|
+
3. **Develop:** Create custom plugins using AI instructions
|
|
271
|
+
4. **Deploy:** Use the deployment guide for production
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Sources
|
|
276
|
+
|
|
277
|
+
- [Modern.js Documentation](https://modernjs.dev/)
|
|
278
|
+
- [Garfish Documentation](https://www.garfishjs.org/)
|
|
279
|
+
- [PocketBase Documentation](https://pocketbase.io/docs/)
|
|
280
|
+
- [npm Publishing](https://docs.npmjs.com/cli/v9/commands/npm-publish)
|
|
281
|
+
- [Semantic Versioning](https://semver.org/)
|
|
282
|
+
- [pnpm Workspaces](https://pnpm.io/workspaces)
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# AI Development Documentation
|
|
2
|
+
|
|
3
|
+
**Lego-One Framework - AI "Vibe Coding" Reference**
|
|
4
|
+
|
|
5
|
+
> This documentation is optimized for AI agents working on the Lego-One framework. Read sequentially for complete context.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Documentation Index
|
|
10
|
+
|
|
11
|
+
Read these files in order for complete framework understanding:
|
|
12
|
+
|
|
13
|
+
### Getting Started
|
|
14
|
+
|
|
15
|
+
| # | File | Description |
|
|
16
|
+
|---|------|-------------|
|
|
17
|
+
| 01 | [`01-framework-structure.md`](./01-framework-structure.md) | Project structure, architecture, file locations |
|
|
18
|
+
| 02 | [`02-development-workflow.md`](./02-development-workflow.md) | How to work on this framework (dev, build, test) |
|
|
19
|
+
| 03 | [`03-environment-setup.md`](./03-environment-setup.md) | Environment variables, dependencies, prerequisites |
|
|
20
|
+
|
|
21
|
+
### Core Concepts
|
|
22
|
+
|
|
23
|
+
| # | File | Description |
|
|
24
|
+
|---|------|-------------|
|
|
25
|
+
| 04 | [`04-kernel-architecture.md`](./04-kernel-architecture.md) | Host/Kernel system, core infrastructure |
|
|
26
|
+
| 05 | [`05-plugin-system.md`](./05-plugin-system.md) | Plugin architecture, Garfish, micro-frontends |
|
|
27
|
+
| 06 | [`06-communication-patterns.md`](./06-communication-patterns.md) | Window bridge, channel bus, plugin-host communication |
|
|
28
|
+
|
|
29
|
+
### Development Patterns
|
|
30
|
+
|
|
31
|
+
| # | File | Description |
|
|
32
|
+
|---|------|-------------|
|
|
33
|
+
| 07 | [`07-plugin-development.md`](./07-plugin-development.md) | Complete guide to creating plugins |
|
|
34
|
+
| 08 | `08-component-library.md` | UI components, styling, design system *(TODO)* |
|
|
35
|
+
| 09 | `09-data-integration.md` | PocketBase, multi-tenancy, data fetching *(TODO)* |
|
|
36
|
+
| 10 | `10-auth-rbac.md` | Authentication, authorization, permissions *(TODO)* |
|
|
37
|
+
|
|
38
|
+
### API Reference
|
|
39
|
+
|
|
40
|
+
| # | File | Description |
|
|
41
|
+
|---|------|-------------|
|
|
42
|
+
| 11 | [`11-hooks-api.md`](./11-hooks-api.md) | All kernel hooks (auth, RBAC, state, channels) |
|
|
43
|
+
| 12 | [`12-components-api.md`](./12-components-api.md) | UI component library reference |
|
|
44
|
+
| 13 | [`13-deployment-guide.md`](./13-deployment-guide.md) | Production deployment instructions |
|
|
45
|
+
|
|
46
|
+
### Core Concepts (TODO)
|
|
47
|
+
|
|
48
|
+
| # | File | Description |
|
|
49
|
+
|---|------|-------------|
|
|
50
|
+
| 04 | `04-kernel-architecture.md` | Host/Kernel system, core infrastructure |
|
|
51
|
+
| 05 | `05-plugin-system.md` | Plugin architecture, Garfish, micro-frontends |
|
|
52
|
+
| 06 | `06-communication-patterns.md` | Window bridge, channel bus, plugin-host communication |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Quick Reference for AI Agents
|
|
57
|
+
|
|
58
|
+
### When Starting Any Task
|
|
59
|
+
|
|
60
|
+
1. **ALWAYS read `/docs/framework/setup/00-index.md` first** (this file)
|
|
61
|
+
2. **Read relevant files** from the index above based on your task
|
|
62
|
+
3. **Follow established patterns** - consistency is critical
|
|
63
|
+
4. **Write checkpoints** for every task/bugfix/feature in `/docs/checkpoints/`
|
|
64
|
+
|
|
65
|
+
### Task → Documentation Mapping
|
|
66
|
+
|
|
67
|
+
| Task Type | Read First | Reference |
|
|
68
|
+
|-----------|-----------|----------|
|
|
69
|
+
| Create new plugin | `07-plugin-development.md` | Dashboard/Todo plugins |
|
|
70
|
+
| Add UI components | `08-component-library.md` | Existing components |
|
|
71
|
+
| Fix auth issues | `10-auth-rbac.md` | Kernel auth system |
|
|
72
|
+
| Add data features | `09-data-integration.md` | Todo plugin patterns |
|
|
73
|
+
| Debug issues | `02-development-workflow.md` | Troubleshooting section |
|
|
74
|
+
|
|
75
|
+
### Critical Constraints
|
|
76
|
+
|
|
77
|
+
**DO NOT:**
|
|
78
|
+
- Skip reading documentation before coding
|
|
79
|
+
- Create circular dependencies between host and plugins
|
|
80
|
+
- Import directly from host kernel in plugins (use window bridge)
|
|
81
|
+
- Skip TypeScript strict mode compliance
|
|
82
|
+
- Forget to write checkpoints for your work
|
|
83
|
+
|
|
84
|
+
**ALWAYS:**
|
|
85
|
+
- Read relevant documentation first
|
|
86
|
+
- Follow existing file structures and naming conventions
|
|
87
|
+
- Use window bridge for host-plugin communication
|
|
88
|
+
- Implement proper error handling
|
|
89
|
+
- Test in both dev and production modes
|
|
90
|
+
- Document your work in checkpoints
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## File Location Conventions
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
lego-one/
|
|
98
|
+
├── host/src/kernel/ # Core systems (auth, RBAC, state, channels)
|
|
99
|
+
├── host/src/layout/ # Layout components (Sidebar, Topbar, Shell)
|
|
100
|
+
├── host/src/routes/ # Page routes
|
|
101
|
+
├── host/src/providers/ # Context providers
|
|
102
|
+
└── packages/plugins/@lego/ # Feature modules
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Kernel Structure
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
host/src/kernel/
|
|
109
|
+
├── shared-state/ # Zustand store + window bridge
|
|
110
|
+
├── providers/ # PocketBase, Query, Theme providers
|
|
111
|
+
├── plugins/ # Plugin system, slot injection
|
|
112
|
+
├── channels/ # Garfish channel bus
|
|
113
|
+
├── auth/ # Authentication logic
|
|
114
|
+
├── rbac/ # Multitenancy, permissions
|
|
115
|
+
├── lib/ # Utilities (cn, formatDate)
|
|
116
|
+
└── components/ # Shared UI components
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Plugin Structure
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
packages/plugins/@lego/plugin-<name>/
|
|
123
|
+
├── src/
|
|
124
|
+
│ ├── components/ # Plugin components
|
|
125
|
+
│ ├── hooks/ # Data fetching hooks
|
|
126
|
+
│ ├── pages/ # Plugin pages
|
|
127
|
+
│ ├── plugin.config.ts # Plugin configuration
|
|
128
|
+
│ └── plugin.ts # Entry point
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Key Hooks and APIs
|
|
134
|
+
|
|
135
|
+
| Hook/Api | Purpose | Location |
|
|
136
|
+
|----------|---------|----------|
|
|
137
|
+
| `usePocketBase()` | Access PocketBase client | `host/src/kernel/providers/` |
|
|
138
|
+
| `useCurrentOrganization()` | Get current organization context | `host/src/kernel/hooks/` |
|
|
139
|
+
| `useUserPermissions()` | Get user permissions | `host/src/kernel/hooks/` |
|
|
140
|
+
| `useGlobalKernelState()` | Access kernel state | `host/src/kernel/shared-state/` |
|
|
141
|
+
| `window.__LEGO_KERNEL_STATE__` | Read-only kernel state access | Global window object |
|
|
142
|
+
| `window.__LEGO_CHANNEL_BUS__` | Event publishing/subscribing | Global window object |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Import Path Conventions
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// From host kernel
|
|
150
|
+
import { usePocketBase } from '@/kernel/providers/PocketBaseProvider';
|
|
151
|
+
import { useCurrentOrganization } from '@/kernel/hooks/useCurrentOrganization';
|
|
152
|
+
import { Button } from '@/kernel/components/ui/Button';
|
|
153
|
+
|
|
154
|
+
// Window bridge (in plugins)
|
|
155
|
+
const kernelState = window.__LEGO_KERNEL_STATE__;
|
|
156
|
+
const channelBus = window.__LEGO_CHANNEL_BUS__;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Testing Commands
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Unit and component tests
|
|
165
|
+
pnpm --filter './host' test
|
|
166
|
+
|
|
167
|
+
# E2E tests (requires dev server running)
|
|
168
|
+
pnpm test:e2e
|
|
169
|
+
|
|
170
|
+
# Coverage report
|
|
171
|
+
pnpm test:coverage
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Build Commands
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Build all
|
|
178
|
+
pnpm run build
|
|
179
|
+
|
|
180
|
+
# Build host only
|
|
181
|
+
pnpm --filter './host' build
|
|
182
|
+
|
|
183
|
+
# Build specific plugin
|
|
184
|
+
pnpm --filter './packages/plugins/@lego/plugin-dashboard' build
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Before You Code
|
|
190
|
+
|
|
191
|
+
Use this decision tree:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
Task: Create a new feature
|
|
195
|
+
├─ Is it a CRUD feature? → Follow Todo Plugin pattern (file 07)
|
|
196
|
+
├─ Is it display only? → Follow Dashboard Plugin pattern (file 07)
|
|
197
|
+
├─ Does it need backend storage? → Read file 09 (Data Integration)
|
|
198
|
+
├─ Does it need authentication? → Read file 10 (Auth/RBAC)
|
|
199
|
+
└─ Is it a calculation? → Create hook with pure functions
|
|
200
|
+
|
|
201
|
+
Task: Fix a bug
|
|
202
|
+
├─ In host kernel? → Edit files in host/src/kernel/
|
|
203
|
+
├─ In plugin? → Edit files in packages/plugins/@lego/plugin-<name>/
|
|
204
|
+
├─ UI related? → Check components and layout (file 08)
|
|
205
|
+
└─ Data related? → Check hooks and PocketBase queries (file 09)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
**Next:** Read [`01-framework-structure.md`](./01-framework-structure.md) to understand the project layout.
|