ai-site-pilot 0.5.1 → 0.5.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.
- package/CLAUDE.md +77 -0
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -12,6 +12,83 @@ A drop-in AI chat widget that can **control and navigate websites**. The AI can
|
|
|
12
12
|
- Auto-generates system prompts from site content
|
|
13
13
|
- Streaming responses with tool execution
|
|
14
14
|
|
|
15
|
+
## IMPORTANT: Keeping Chatbot in Sync with Site Content
|
|
16
|
+
|
|
17
|
+
**The chatbot must always reflect the current site content.** To achieve this:
|
|
18
|
+
|
|
19
|
+
1. **Find where site data lives** - Look for constants files, data files, CMS exports, or API endpoints that contain the site's content (products, services, team, etc.)
|
|
20
|
+
|
|
21
|
+
2. **Import from the same source** - The API route should import from these existing data sources, NOT duplicate the data
|
|
22
|
+
|
|
23
|
+
3. **Maintain this pattern** - When updating site content, the chatbot automatically stays in sync
|
|
24
|
+
|
|
25
|
+
### Example Pattern
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// lib/data.ts - The site's single source of truth
|
|
29
|
+
export const CLASSES = [
|
|
30
|
+
{ id: 'ballet', name: 'Ballet', description: 'Classical ballet', price: '$80/mo' },
|
|
31
|
+
{ id: 'jazz', name: 'Jazz', description: 'High-energy jazz', price: '$75/mo' },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export const TEACHERS = [
|
|
35
|
+
{ id: 'sarah', name: 'Sarah Johnson', role: 'Owner', bio: '15 years experience' },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export const SITE_INFO = {
|
|
39
|
+
name: 'Dance Studio',
|
|
40
|
+
email: 'info@studio.com',
|
|
41
|
+
phone: '555-1234',
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// app/api/chat/route.ts - Imports from the SAME source
|
|
47
|
+
import { CLASSES, TEACHERS, SITE_INFO } from '@/lib/data';
|
|
48
|
+
import { createHandler } from 'ai-site-pilot/api';
|
|
49
|
+
|
|
50
|
+
export const POST = createHandler({
|
|
51
|
+
siteContent: {
|
|
52
|
+
name: SITE_INFO.name,
|
|
53
|
+
items: [
|
|
54
|
+
...CLASSES.map(c => ({ ...c, category: 'class' })),
|
|
55
|
+
...TEACHERS.map(t => ({ ...t, category: 'teacher' })),
|
|
56
|
+
],
|
|
57
|
+
contact: {
|
|
58
|
+
email: SITE_INFO.email,
|
|
59
|
+
phone: SITE_INFO.phone,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
tools,
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// components/ClassList.tsx - Also uses the same source
|
|
68
|
+
import { CLASSES } from '@/lib/data';
|
|
69
|
+
|
|
70
|
+
export function ClassList() {
|
|
71
|
+
return CLASSES.map(c => <ClassCard key={c.id} {...c} />);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Update `lib/data.ts` → Both site AND chatbot update automatically.**
|
|
76
|
+
|
|
77
|
+
### When Setting Up a New Project
|
|
78
|
+
|
|
79
|
+
As an AI assistant, you should:
|
|
80
|
+
|
|
81
|
+
1. **Scan the codebase** for existing data files:
|
|
82
|
+
- `constants.ts`, `data.ts`, `config.ts`
|
|
83
|
+
- `lib/`, `data/`, `content/` directories
|
|
84
|
+
- JSON files with site content
|
|
85
|
+
|
|
86
|
+
2. **Identify the data structure** - What does the site display? Products? Services? Team members?
|
|
87
|
+
|
|
88
|
+
3. **Create the API route** that imports from these existing sources
|
|
89
|
+
|
|
90
|
+
4. **Never duplicate data** - If you can't find existing data files, create ONE shared file that both the site and chatbot use
|
|
91
|
+
|
|
15
92
|
## Quick Setup (Recommended)
|
|
16
93
|
|
|
17
94
|
### 1. Install
|
package/package.json
CHANGED