oneie 3.0.3 → 3.3.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/CLAUDE.md +173 -19
- package/README.md +53 -0
- package/dist/commands/init.d.ts +18 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +155 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/file-resolver.d.ts +83 -0
- package/dist/utils/file-resolver.d.ts.map +1 -0
- package/dist/utils/file-resolver.js +196 -0
- package/dist/utils/file-resolver.js.map +1 -0
- package/dist/utils/installation-setup.d.ts +50 -0
- package/dist/utils/installation-setup.d.ts.map +1 -0
- package/dist/utils/installation-setup.js +253 -0
- package/dist/utils/installation-setup.js.map +1 -0
- package/folders.yaml +1 -1
- package/one/.obsidian/workspace.json +15 -15
- package/one/events/deployment-installation-folders.md +160 -0
- package/one/events/deployment-ops-summary.md +368 -0
- package/one/events/deployment-verification.md +348 -0
- package/one/events/installation-folders-workflow-integration.md +440 -0
- package/one/events/legal-assessment-2025-10-16.md +1899 -0
- package/one/knowledge/installation-folders.md +304 -0
- package/one/knowledge/typescript-patterns.md +303 -0
- package/one/things/agents/agent-lawyer.md +1266 -0
- package/one/things/legal/README.md +190 -0
- package/one/things/legal/privacy-policy.md +1064 -0
- package/one/things/legal/terms-of-service.md +1271 -0
- package/one/things/plans/group-folder-multi-tenancy.md +830 -0
- package/package.json +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Installation Folders Guide
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0.0
|
|
4
|
+
**Status:** Production Ready
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
Installation folders enable filesystem-based customization where each ONE installation gets a top-level folder with ontology-structured subdirectories that override global templates.
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
|
|
12
|
+
### Conceptual Model
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Installation Folder ≠ Database Group
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **One installation** can serve **many database groups**
|
|
19
|
+
- Installation folder = Documentation/config per organization
|
|
20
|
+
- Database groups = Runtime data per group (via `groupId`)
|
|
21
|
+
|
|
22
|
+
### Folder Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
/
|
|
26
|
+
├── one/ # GLOBAL templates (always fallback)
|
|
27
|
+
├── <installation-name>/ # INSTALLATION-SPECIFIC
|
|
28
|
+
│ ├── README.md
|
|
29
|
+
│ ├── groups/ # Hierarchical group documentation
|
|
30
|
+
│ │ ├── engineering/
|
|
31
|
+
│ │ │ ├── frontend/
|
|
32
|
+
│ │ │ ├── backend/
|
|
33
|
+
│ │ │ └── practices.md
|
|
34
|
+
│ │ └── marketing/
|
|
35
|
+
│ ├── people/
|
|
36
|
+
│ ├── things/
|
|
37
|
+
│ ├── connections/
|
|
38
|
+
│ ├── events/
|
|
39
|
+
│ └── knowledge/
|
|
40
|
+
├── web/
|
|
41
|
+
├── backend/
|
|
42
|
+
└── .claude/
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## File Resolution
|
|
46
|
+
|
|
47
|
+
### Resolution Algorithm
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Given: relativePath = "sprint-guide.md", groupId = frontend
|
|
51
|
+
|
|
52
|
+
1. Check group-specific:
|
|
53
|
+
/<installation>/groups/engineering/frontend/sprint-guide.md
|
|
54
|
+
|
|
55
|
+
2. Walk up parents:
|
|
56
|
+
/<installation>/groups/engineering/sprint-guide.md
|
|
57
|
+
|
|
58
|
+
3. Check installation root:
|
|
59
|
+
/<installation>/sprint-guide.md
|
|
60
|
+
|
|
61
|
+
4. Global fallback:
|
|
62
|
+
/one/sprint-guide.md
|
|
63
|
+
|
|
64
|
+
5. Not found: throw error
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Implementation
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { resolveFile } from '@/lib/utils/file-resolver';
|
|
71
|
+
|
|
72
|
+
const filePath = await resolveFile('things/vision.md', {
|
|
73
|
+
installationName: 'acme',
|
|
74
|
+
groupId: frontendGroupId,
|
|
75
|
+
fallbackToGlobal: true,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Use Cases
|
|
80
|
+
|
|
81
|
+
### 1. Private Documentation
|
|
82
|
+
|
|
83
|
+
Store customer-specific documentation that shouldn't be in the global templates:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
echo "# Acme Engineering Handbook" > /acme/groups/engineering/handbook.md
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. Custom Agent Prompts
|
|
90
|
+
|
|
91
|
+
Override global AI agent prompts with organization-specific instructions:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
echo "# Custom Agent Rules" > /acme/.claude/rules.md
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Group-Specific Workflows
|
|
98
|
+
|
|
99
|
+
Document workflows unique to specific groups:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
echo "# Frontend Sprint Process" > /acme/groups/engineering/frontend/sprint-guide.md
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 4. Installation-Wide Overrides
|
|
106
|
+
|
|
107
|
+
Replace global vision or rules for entire installation:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
echo "# Our Vision" > /acme/things/vision.md
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## CLI Usage
|
|
114
|
+
|
|
115
|
+
### Initialize Installation
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
$ npx oneie init
|
|
119
|
+
? What is your organization name? Acme Corp
|
|
120
|
+
? Installation identifier: acme
|
|
121
|
+
|
|
122
|
+
✅ Creating installation folder: /acme
|
|
123
|
+
✅ Mirroring ontology structure...
|
|
124
|
+
✅ Creating README.md
|
|
125
|
+
✅ Creating .env.local with INSTALLATION_NAME=acme
|
|
126
|
+
|
|
127
|
+
🎉 Installation initialized!
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Environment Configuration
|
|
131
|
+
|
|
132
|
+
The installation name is stored in `.env.local`:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
INSTALLATION_NAME=acme
|
|
136
|
+
PUBLIC_INSTALLATION_NAME=acme # Exposed to frontend
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Security
|
|
140
|
+
|
|
141
|
+
### Path Validation
|
|
142
|
+
|
|
143
|
+
All file paths are validated to prevent traversal attacks:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// ✅ Valid
|
|
147
|
+
/acme/things/vision.md
|
|
148
|
+
|
|
149
|
+
// ❌ Invalid (path traversal)
|
|
150
|
+
/acme/../../../etc/passwd
|
|
151
|
+
|
|
152
|
+
// ❌ Invalid (symlink outside allowed dirs)
|
|
153
|
+
/acme/things/../../secrets.txt
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Sensitive Data
|
|
157
|
+
|
|
158
|
+
**NEVER** store secrets or credentials in installation folders:
|
|
159
|
+
|
|
160
|
+
- ❌ API keys
|
|
161
|
+
- ❌ Database passwords
|
|
162
|
+
- ❌ OAuth secrets
|
|
163
|
+
- ❌ Private keys
|
|
164
|
+
|
|
165
|
+
Use `.env.local` for sensitive configuration.
|
|
166
|
+
|
|
167
|
+
### Access Control
|
|
168
|
+
|
|
169
|
+
Installation folders use filesystem-level isolation:
|
|
170
|
+
|
|
171
|
+
- Local installations: Standard filesystem permissions
|
|
172
|
+
- SaaS deployments: Separate repository per customer
|
|
173
|
+
- Git: Exclude installation folders by default (`.gitignore`)
|
|
174
|
+
|
|
175
|
+
## Deployment
|
|
176
|
+
|
|
177
|
+
### Cloudflare Pages
|
|
178
|
+
|
|
179
|
+
**Build Integration:**
|
|
180
|
+
|
|
181
|
+
Installation folder is copied to `dist/_installation` during build:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
INSTALLATION_NAME=acme npm run build
|
|
185
|
+
# Copies /acme/ → dist/_installation/
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Runtime Resolution:**
|
|
189
|
+
|
|
190
|
+
Files are served from `dist/_installation/` on Cloudflare Pages.
|
|
191
|
+
|
|
192
|
+
### Environment-Specific
|
|
193
|
+
|
|
194
|
+
Support different docs per environment:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Development
|
|
198
|
+
INSTALLATION_NAME=acme INSTALLATION_ENV=dev npm run dev
|
|
199
|
+
|
|
200
|
+
# Production
|
|
201
|
+
INSTALLATION_NAME=acme INSTALLATION_ENV=prod npm run build
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Resolution checks:
|
|
205
|
+
1. `/acme-prod/` (environment-specific)
|
|
206
|
+
2. `/acme/` (installation default)
|
|
207
|
+
3. `/one/` (global fallback)
|
|
208
|
+
|
|
209
|
+
## Database vs Filesystem
|
|
210
|
+
|
|
211
|
+
### Example Scenario
|
|
212
|
+
|
|
213
|
+
**Installation:** Acme Corp (`/acme/`)
|
|
214
|
+
|
|
215
|
+
**Database groups:**
|
|
216
|
+
- `acme-engineering` (groupId: g1, parentGroupId: null)
|
|
217
|
+
- `acme-frontend` (groupId: g2, parentGroupId: g1)
|
|
218
|
+
- `acme-backend` (groupId: g3, parentGroupId: g1)
|
|
219
|
+
- `acme-marketing` (groupId: g4, parentGroupId: null)
|
|
220
|
+
|
|
221
|
+
**Filesystem docs:**
|
|
222
|
+
- `/acme/groups/engineering/practices.md` - Applies to g1, g2, g3
|
|
223
|
+
- `/acme/groups/engineering/frontend/sprint-guide.md` - Applies to g2 only
|
|
224
|
+
- `/acme/groups/marketing/campaigns.md` - Applies to g4 only
|
|
225
|
+
|
|
226
|
+
**Key Insight:** Filesystem hierarchy mirrors database `parentGroupId` structure.
|
|
227
|
+
|
|
228
|
+
## Best Practices
|
|
229
|
+
|
|
230
|
+
### 1. Start with Global Templates
|
|
231
|
+
|
|
232
|
+
Don't override files unless you have a specific reason:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# ✅ Good: Override when needed
|
|
236
|
+
/acme/things/vision.md # Custom vision
|
|
237
|
+
|
|
238
|
+
# ❌ Bad: Unnecessary duplication
|
|
239
|
+
/acme/things/architecture.md # Same as /one/things/architecture.md
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 2. Use Hierarchical Groups
|
|
243
|
+
|
|
244
|
+
Leverage parent groups for shared documentation:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Shared by all engineering subgroups
|
|
248
|
+
/acme/groups/engineering/practices.md
|
|
249
|
+
|
|
250
|
+
# Frontend-specific
|
|
251
|
+
/acme/groups/engineering/frontend/sprint-guide.md
|
|
252
|
+
|
|
253
|
+
# Backend-specific
|
|
254
|
+
/acme/groups/engineering/backend/deployment-guide.md
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 3. Version Control
|
|
258
|
+
|
|
259
|
+
Decide if installation folder should be in git:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Option 1: Exclude (default)
|
|
263
|
+
echo "/acme/" >> .gitignore
|
|
264
|
+
|
|
265
|
+
# Option 2: Track in separate repo
|
|
266
|
+
cd /acme && git init
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 4. Documentation Hygiene
|
|
270
|
+
|
|
271
|
+
Keep installation folders clean and organized:
|
|
272
|
+
|
|
273
|
+
- Use descriptive filenames
|
|
274
|
+
- Follow ontology structure
|
|
275
|
+
- Delete unused files
|
|
276
|
+
- Update README.md with context
|
|
277
|
+
|
|
278
|
+
## FAQ
|
|
279
|
+
|
|
280
|
+
**Q: Do I need an installation folder?**
|
|
281
|
+
A: No, it's optional. The system falls back to `/one/` if no installation folder exists.
|
|
282
|
+
|
|
283
|
+
**Q: Can I have multiple installation folders?**
|
|
284
|
+
A: Phase 2 feature. Currently, one installation per deployment.
|
|
285
|
+
|
|
286
|
+
**Q: What if I delete my installation folder?**
|
|
287
|
+
A: The system falls back to global `/one/` templates. No data loss (database is separate).
|
|
288
|
+
|
|
289
|
+
**Q: Can installation folders access each other?**
|
|
290
|
+
A: No, strict isolation. Each installation only sees its own folder and `/one/`.
|
|
291
|
+
|
|
292
|
+
**Q: How do I sync installation folder to production?**
|
|
293
|
+
A: Use git, CI/CD, or (future) `npx oneie sync --upload`.
|
|
294
|
+
|
|
295
|
+
## Learn More
|
|
296
|
+
|
|
297
|
+
- Complete implementation plan: `/one/things/plans/group-folder-multi-tenancy.md`
|
|
298
|
+
- 6-Dimension Ontology: `/one/knowledge/ontology.md`
|
|
299
|
+
- Development workflow: `/one/connections/workflow.md`
|
|
300
|
+
- CLI reference: `/one/knowledge/cli.md` (TODO)
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
**Simple enough for individuals. Powerful enough for enterprises.**
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# TypeScript Patterns & Best Practices
|
|
2
|
+
|
|
3
|
+
## Common Type Issues & Fixes
|
|
4
|
+
|
|
5
|
+
### 1. Lucide React Icon Types
|
|
6
|
+
|
|
7
|
+
**Problem:** Icon type definitions using function signatures fail with React 19 + Lucide React.
|
|
8
|
+
|
|
9
|
+
**Error:**
|
|
10
|
+
```
|
|
11
|
+
error ts(2322): Type 'ForwardRefExoticComponent<Omit<LucideProps, "ref"> & RefAttributes<SVGSVGElement>>'
|
|
12
|
+
is not assignable to type '(props: SVGProps<SVGSVGElement>) => Element'.
|
|
13
|
+
Type 'ReactNode' is not assignable to type 'Element'.
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Bad Pattern:**
|
|
17
|
+
```typescript
|
|
18
|
+
import { Sparkles, Code2 } from 'lucide-react';
|
|
19
|
+
|
|
20
|
+
type Tool = {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
// ❌ WRONG: Function signature
|
|
24
|
+
icon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const TOOLS: Tool[] = [
|
|
28
|
+
{
|
|
29
|
+
id: "claude",
|
|
30
|
+
label: "Claude Code",
|
|
31
|
+
icon: Sparkles, // Type error!
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Good Pattern:**
|
|
37
|
+
```typescript
|
|
38
|
+
import { Sparkles, Code2 } from 'lucide-react';
|
|
39
|
+
|
|
40
|
+
type Tool = {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
// ✅ CORRECT: Component type
|
|
44
|
+
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const TOOLS: Tool[] = [
|
|
48
|
+
{
|
|
49
|
+
id: "claude",
|
|
50
|
+
label: "Claude Code",
|
|
51
|
+
icon: Sparkles, // Works!
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Why:** Lucide icons are `ForwardRefExoticComponent`, not regular functions. Use `ComponentType` for component references.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### 2. React 19 Component Props
|
|
61
|
+
|
|
62
|
+
**Problem:** Props types not compatible with React 19's stricter typing.
|
|
63
|
+
|
|
64
|
+
**Bad Pattern:**
|
|
65
|
+
```typescript
|
|
66
|
+
// ❌ Old React patterns
|
|
67
|
+
interface ButtonProps {
|
|
68
|
+
children: React.ReactNode;
|
|
69
|
+
onClick: () => void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const Button = ({ children, onClick }: ButtonProps) => {
|
|
73
|
+
return <button onClick={onClick}>{children}</button>;
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Good Pattern:**
|
|
78
|
+
```typescript
|
|
79
|
+
// ✅ React 19 recommended
|
|
80
|
+
import { type ReactNode } from 'react';
|
|
81
|
+
|
|
82
|
+
interface ButtonProps {
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
onClick: () => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function Button({ children, onClick }: ButtonProps) {
|
|
88
|
+
return <button onClick={onClick}>{children}</button>;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Why:** React 19 prefers named exports and direct ReactNode imports for cleaner types.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### 3. SVG Component Types
|
|
97
|
+
|
|
98
|
+
**Bad Pattern:**
|
|
99
|
+
```typescript
|
|
100
|
+
// ❌ Inconsistent with Lucide
|
|
101
|
+
type CustomIcon = (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Good Pattern:**
|
|
105
|
+
```typescript
|
|
106
|
+
// ✅ Matches Lucide pattern
|
|
107
|
+
type IconProps = React.SVGProps<SVGSVGElement>;
|
|
108
|
+
type CustomIcon = React.ComponentType<IconProps>;
|
|
109
|
+
|
|
110
|
+
// Usage
|
|
111
|
+
const MyIcon: CustomIcon = (props) => (
|
|
112
|
+
<svg {...props}>
|
|
113
|
+
<path d="..." />
|
|
114
|
+
</svg>
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Why:** Consistency with library patterns makes code more maintainable.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### 4. Astro + React Integration
|
|
123
|
+
|
|
124
|
+
**Problem:** Type mismatches between Astro and React components.
|
|
125
|
+
|
|
126
|
+
**Bad Pattern:**
|
|
127
|
+
```astro
|
|
128
|
+
---
|
|
129
|
+
// ❌ No type safety
|
|
130
|
+
import Button from '@/components/Button';
|
|
131
|
+
const data = await fetch('...').then(r => r.json());
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
<Button onClick={() => console.log(data)} />
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Good Pattern:**
|
|
138
|
+
```astro
|
|
139
|
+
---
|
|
140
|
+
// ✅ Type-safe props
|
|
141
|
+
import Button from '@/components/ui/button';
|
|
142
|
+
import type { ApiResponse } from '@/types';
|
|
143
|
+
|
|
144
|
+
const data: ApiResponse = await fetch('...')
|
|
145
|
+
.then(r => r.json());
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
<Button client:load onClick={() => console.log(data)}>
|
|
149
|
+
Click me
|
|
150
|
+
</Button>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Why:** Explicit types catch errors at build time, not runtime.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### 5. Generic Component Props
|
|
158
|
+
|
|
159
|
+
**Bad Pattern:**
|
|
160
|
+
```typescript
|
|
161
|
+
// ❌ Any destroys type safety
|
|
162
|
+
interface FormProps {
|
|
163
|
+
onSubmit: (data: any) => void;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Good Pattern:**
|
|
168
|
+
```typescript
|
|
169
|
+
// ✅ Generic for type safety
|
|
170
|
+
interface FormProps<T> {
|
|
171
|
+
onSubmit: (data: T) => void;
|
|
172
|
+
initialData?: T;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function Form<T>({ onSubmit, initialData }: FormProps<T>) {
|
|
176
|
+
// Type-safe implementation
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Usage
|
|
180
|
+
interface LoginData {
|
|
181
|
+
email: string;
|
|
182
|
+
password: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
<Form<LoginData>
|
|
186
|
+
onSubmit={(data) => {
|
|
187
|
+
// data is typed as LoginData!
|
|
188
|
+
console.log(data.email);
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Why:** Generics preserve type information through component boundaries.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Diagnostic Commands
|
|
198
|
+
|
|
199
|
+
### Find Type Errors
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Full type check (Astro + TypeScript)
|
|
203
|
+
bunx astro check
|
|
204
|
+
|
|
205
|
+
# Filter errors only
|
|
206
|
+
bunx astro check 2>&1 | grep "error"
|
|
207
|
+
|
|
208
|
+
# Filter by file
|
|
209
|
+
bunx astro check 2>&1 | grep "SendToTools"
|
|
210
|
+
|
|
211
|
+
# Count errors
|
|
212
|
+
bunx astro check 2>&1 | grep -c "error"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Regenerate Types
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Regenerate Astro content types
|
|
219
|
+
bunx astro sync
|
|
220
|
+
|
|
221
|
+
# Full rebuild
|
|
222
|
+
bunx astro build
|
|
223
|
+
|
|
224
|
+
# Type check without building
|
|
225
|
+
bunx astro check --minimumSeverity error
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## React 19 + Astro Compatibility
|
|
231
|
+
|
|
232
|
+
### Key Changes in React 19
|
|
233
|
+
|
|
234
|
+
1. **Server Components** - Use `'use client'` directive when needed
|
|
235
|
+
2. **Stricter Types** - More precise type inference
|
|
236
|
+
3. **New Hooks** - `useFormStatus`, `useFormState`, `useOptimistic`
|
|
237
|
+
4. **Async Components** - Server components can be async
|
|
238
|
+
|
|
239
|
+
### Astro Integration Best Practices
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
// ✅ GOOD: Client directive for interactivity
|
|
243
|
+
<Button client:load onClick={handler}>Click</Button>
|
|
244
|
+
|
|
245
|
+
// ❌ BAD: Missing client directive
|
|
246
|
+
<Button onClick={handler}>Click</Button>
|
|
247
|
+
|
|
248
|
+
// ✅ GOOD: Server-side data fetching
|
|
249
|
+
---
|
|
250
|
+
const data = await fetch('https://api.example.com/data')
|
|
251
|
+
.then(r => r.json());
|
|
252
|
+
---
|
|
253
|
+
<DataDisplay data={data} />
|
|
254
|
+
|
|
255
|
+
// ✅ GOOD: Client component with hydration
|
|
256
|
+
<InteractiveChart client:load data={data} />
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Common Fixes Checklist
|
|
262
|
+
|
|
263
|
+
When encountering type errors:
|
|
264
|
+
|
|
265
|
+
- [ ] Check if using `React.ComponentType` for component references
|
|
266
|
+
- [ ] Verify `client:load` on interactive React components
|
|
267
|
+
- [ ] Run `bunx astro sync` to regenerate content types
|
|
268
|
+
- [ ] Check import statements (named vs default exports)
|
|
269
|
+
- [ ] Verify React 19 compatibility
|
|
270
|
+
- [ ] Look for `any` types - replace with proper types
|
|
271
|
+
- [ ] Check prop spreading (`{...props}`) types
|
|
272
|
+
- [ ] Verify generic constraints are met
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Testing Type Safety
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
// Create a type test file
|
|
280
|
+
// types.test.ts
|
|
281
|
+
|
|
282
|
+
import { expectType } from 'tsd';
|
|
283
|
+
import type { Tool } from './Tool';
|
|
284
|
+
|
|
285
|
+
// Test icon type
|
|
286
|
+
expectType<React.ComponentType<React.SVGProps<SVGSVGElement>>>(
|
|
287
|
+
tool.icon
|
|
288
|
+
);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Documentation References
|
|
294
|
+
|
|
295
|
+
- **React 19 Types:** https://react.dev/blog/2024/04/25/react-19-upgrade-guide
|
|
296
|
+
- **Astro TypeScript:** https://docs.astro.build/en/guides/typescript/
|
|
297
|
+
- **Lucide React:** https://lucide.dev/guide/packages/lucide-react
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
**Last Updated:** v3.0.3 (Icon type fixes)
|
|
302
|
+
**Category:** Knowledge / TypeScript
|
|
303
|
+
**Ontology Dimension:** Knowledge (technical patterns)
|