@livestore/cli 0.0.0-snapshot-2ac5fd340c97c9e07fe4c5dc6d31d5132aa6557c.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.
Files changed (80) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/LICENSE +201 -0
  3. package/dist/cli +0 -0
  4. package/dist/cli.d.ts +15 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +22 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/mcp-coach.d.ts +15 -0
  9. package/dist/commands/mcp-coach.d.ts.map +1 -0
  10. package/dist/commands/mcp-coach.js +87 -0
  11. package/dist/commands/mcp-coach.js.map +1 -0
  12. package/dist/commands/mcp-tools.d.ts +41 -0
  13. package/dist/commands/mcp-tools.d.ts.map +1 -0
  14. package/dist/commands/mcp-tools.js +148 -0
  15. package/dist/commands/mcp-tools.js.map +1 -0
  16. package/dist/commands/mcp.d.ts +5 -0
  17. package/dist/commands/mcp.d.ts.map +1 -0
  18. package/dist/commands/mcp.js +67 -0
  19. package/dist/commands/mcp.js.map +1 -0
  20. package/dist/commands/new-project.d.ts +34 -0
  21. package/dist/commands/new-project.d.ts.map +1 -0
  22. package/dist/commands/new-project.js +163 -0
  23. package/dist/commands/new-project.js.map +1 -0
  24. package/dist/mcp-content/architecture.d.ts +2 -0
  25. package/dist/mcp-content/architecture.d.ts.map +1 -0
  26. package/dist/mcp-content/architecture.js +171 -0
  27. package/dist/mcp-content/architecture.js.map +1 -0
  28. package/dist/mcp-content/features.d.ts +2 -0
  29. package/dist/mcp-content/features.d.ts.map +1 -0
  30. package/dist/mcp-content/features.js +177 -0
  31. package/dist/mcp-content/features.js.map +1 -0
  32. package/dist/mcp-content/getting-started.d.ts +2 -0
  33. package/dist/mcp-content/getting-started.d.ts.map +1 -0
  34. package/dist/mcp-content/getting-started.js +405 -0
  35. package/dist/mcp-content/getting-started.js.map +1 -0
  36. package/dist/mcp-content/overview.d.ts +2 -0
  37. package/dist/mcp-content/overview.d.ts.map +1 -0
  38. package/dist/mcp-content/overview.js +120 -0
  39. package/dist/mcp-content/overview.js.map +1 -0
  40. package/dist/mcp-content/schemas/blog.d.ts +2 -0
  41. package/dist/mcp-content/schemas/blog.d.ts.map +1 -0
  42. package/dist/mcp-content/schemas/blog.js +223 -0
  43. package/dist/mcp-content/schemas/blog.js.map +1 -0
  44. package/dist/mcp-content/schemas/ecommerce.d.ts +2 -0
  45. package/dist/mcp-content/schemas/ecommerce.d.ts.map +1 -0
  46. package/dist/mcp-content/schemas/ecommerce.js +436 -0
  47. package/dist/mcp-content/schemas/ecommerce.js.map +1 -0
  48. package/dist/mcp-content/schemas/social.d.ts +2 -0
  49. package/dist/mcp-content/schemas/social.d.ts.map +1 -0
  50. package/dist/mcp-content/schemas/social.js +339 -0
  51. package/dist/mcp-content/schemas/social.js.map +1 -0
  52. package/dist/mcp-content/schemas/todo.d.ts +2 -0
  53. package/dist/mcp-content/schemas/todo.d.ts.map +1 -0
  54. package/dist/mcp-content/schemas/todo.js +172 -0
  55. package/dist/mcp-content/schemas/todo.js.map +1 -0
  56. package/dist/mod.d.ts +2 -0
  57. package/dist/mod.d.ts.map +1 -0
  58. package/dist/mod.js +2 -0
  59. package/dist/mod.js.map +1 -0
  60. package/dist/test-tool.d.ts +2 -0
  61. package/dist/test-tool.d.ts.map +1 -0
  62. package/dist/test-tool.js +57 -0
  63. package/dist/test-tool.js.map +1 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -0
  65. package/package.json +27 -0
  66. package/src/cli.ts +35 -0
  67. package/src/commands/mcp-coach.ts +121 -0
  68. package/src/commands/mcp-tools.ts +169 -0
  69. package/src/commands/mcp.ts +97 -0
  70. package/src/commands/new-project.ts +263 -0
  71. package/src/mcp-content/architecture.ts +170 -0
  72. package/src/mcp-content/features.ts +176 -0
  73. package/src/mcp-content/getting-started.ts +404 -0
  74. package/src/mcp-content/overview.ts +119 -0
  75. package/src/mcp-content/schemas/blog.ts +222 -0
  76. package/src/mcp-content/schemas/ecommerce.ts +435 -0
  77. package/src/mcp-content/schemas/social.ts +338 -0
  78. package/src/mcp-content/schemas/todo.ts +171 -0
  79. package/src/mod.ts +1 -0
  80. package/tsconfig.json +9 -0
@@ -0,0 +1,177 @@
1
+ export const featuresContent = `# LiveStore Features: Production-Ready Local-First Data
2
+
3
+ LiveStore provides battle-tested primitives for building collaborative, offline-capable applications with the reliability and performance of modern distributed systems.
4
+
5
+ ## 🏠 Local-First Architecture
6
+
7
+ ### Offline-First Operation
8
+ - **Zero Latency**: All operations execute against local SQLite database
9
+ - **Offline Capable**: Full application functionality without network connectivity
10
+ - **Network Resilient**: Graceful degradation during connectivity issues
11
+ - **Background Sync**: Automatic synchronization when network becomes available
12
+
13
+ ### Immediate Consistency
14
+ - **Optimistic Updates**: UI updates immediately on user action
15
+ - **Rollback on Conflict**: Automatic rollback and retry on merge conflicts
16
+ - **Causal Consistency**: Operations maintain causal ordering across replicas
17
+
18
+ ## 🔄 Event-Driven Synchronization
19
+
20
+ ### Conflict-Free Event Model
21
+ \`\`\`typescript
22
+ // Events designed for conflict-free merging
23
+ const events = {
24
+ todoCreated: Events.synced({
25
+ name: 'v1.TodoCreated',
26
+ schema: Schema.Struct({
27
+ id: Schema.String, // Deterministic ordering
28
+ createdAt: Schema.Date, // Timestamp for LWW resolution
29
+ position: Schema.Number // Fractional indexing for reordering
30
+ })
31
+ })
32
+ }
33
+ \`\`\`
34
+
35
+ ### Sophisticated Merge Strategies
36
+ - **Last-Write-Wins**: Timestamp-based conflict resolution
37
+ - **Semantic Merging**: Application-specific merge logic
38
+ - **Operational Transform**: Real-time collaborative text editing
39
+ - **CRDT Integration**: Conflict-free replicated data types
40
+
41
+ ### Incremental Synchronization
42
+ - **Delta Sync**: Only transmit changes since last synchronization
43
+ - **Vector Clocks**: Efficient causal dependency tracking
44
+ - **Merkle Trees**: Efficient integrity verification
45
+ - **Batch Optimization**: Multiple events in single network round-trip
46
+
47
+ ## 📊 Reactive Query Engine
48
+
49
+ ### Real-Time Reactivity
50
+ \`\`\`typescript
51
+ // Queries automatically update when underlying data changes
52
+ const activeTodos$ = queryDb(
53
+ tables.todos
54
+ .select()
55
+ .where({ completed: false, deletedAt: null })
56
+ .orderBy('position'),
57
+ { label: 'activeTodos' }
58
+ )
59
+ \`\`\`
60
+
61
+ ### Advanced Query Capabilities
62
+ - **Joins & Aggregations**: Full SQL expressiveness
63
+ - **Reactive Subscriptions**: Automatic UI updates on data changes
64
+ - **Query Optimization**: SQLite query planner with B-tree indexes
65
+ - **Prepared Statements**: Cached query compilation for performance
66
+
67
+ ### Framework Integrations
68
+ - **React**: \`useLiveQuery()\` hook for reactive components
69
+ - **Vue**: Composables for reactive data binding
70
+ - **Solid**: Reactive primitives integration
71
+ - **Svelte**: Store-based reactive updates
72
+
73
+ ## 🔐 End-to-End Type Safety
74
+
75
+ ### Schema-First Development
76
+ \`\`\`typescript
77
+ // Type safety from database to UI
78
+ const todoSchema = State.SQLite.table({
79
+ name: 'todos',
80
+ columns: {
81
+ id: State.SQLite.text({ primaryKey: true }),
82
+ title: State.SQLite.text(),
83
+ completed: State.SQLite.boolean()
84
+ }
85
+ })
86
+
87
+ // Fully typed queries
88
+ type Todo = typeof todoSchema.select.Type // { id: string, title: string, completed: boolean }
89
+ \`\`\`
90
+
91
+ ### Runtime Validation
92
+ - **Schema Validation**: All events validated against Effect schemas
93
+ - **Migration Safety**: Type-safe schema evolution
94
+ - **Parse Don't Validate**: Schema types flow through entire application
95
+
96
+ ## 🌐 Multi-Platform Support
97
+
98
+ ### Web Platform
99
+ - **Origin Private File System**: Persistent storage in modern browsers
100
+ - **SharedWorker**: Cross-tab synchronization and resource sharing
101
+ - **IndexedDB Fallback**: Compatibility with older browsers
102
+ - **Service Worker**: Background synchronization
103
+
104
+ ### Node.js Platform
105
+ - **File System Storage**: Native SQLite database files
106
+ - **Cluster Coordination**: Multi-process synchronization
107
+ - **HTTP/WebSocket Sync**: Flexible transport protocols
108
+ - **Background Jobs**: Scheduled synchronization tasks
109
+
110
+ ### Mobile Platforms (Expo/React Native)
111
+ - **Native SQLite**: Platform-optimized database performance
112
+ - **Background Sync**: Synchronization during app backgrounding
113
+ - **Push Notifications**: Real-time update notifications
114
+ - **Secure Storage**: Encrypted local data storage
115
+
116
+ ## 🚀 Performance & Scalability
117
+
118
+ ### Query Performance
119
+ - **Sub-millisecond Queries**: Local SQLite performance
120
+ - **Efficient Indexing**: Automatic index recommendations
121
+ - **Result Set Streaming**: Large datasets loaded incrementally
122
+ - **Query Result Caching**: Expensive computations cached
123
+
124
+ ### Memory Management
125
+ - **Lazy Loading**: Data loaded on-demand
126
+ - **Connection Pooling**: Database connections efficiently reused
127
+ - **Event Log Compaction**: Periodic snapshots prevent unbounded growth
128
+ - **Garbage Collection**: Automatic cleanup of obsolete data
129
+
130
+ ### Network Optimization
131
+ - **Compression**: Event payloads compressed for transmission
132
+ - **Request Batching**: Multiple operations in single request
133
+ - **Connection Pooling**: HTTP/WebSocket connections reused
134
+ - **Exponential Backoff**: Intelligent retry strategies
135
+
136
+ ## 🏗️ Developer Experience
137
+
138
+ ### Testing & Debugging
139
+ \`\`\`typescript
140
+ // Built-in testing utilities
141
+ const testStore = createTestStore(schema)
142
+
143
+ // Deterministic event replay for testing
144
+ await testStore.replay([
145
+ events.todoCreated({ id: '1', title: 'Test todo' }),
146
+ events.todoCompleted({ id: '1' })
147
+ ])
148
+ \`\`\`
149
+
150
+ ### Developer Tools
151
+ - **Event Inspector**: Real-time event log visualization
152
+ - **Query Profiler**: Performance analysis for slow queries
153
+ - **Sync Monitor**: Network synchronization health dashboard
154
+ - **Schema Explorer**: Interactive database schema browsing
155
+
156
+ ### Production Monitoring
157
+ - **Distributed Tracing**: Event propagation across replicas
158
+ - **Performance Metrics**: Query latency and throughput monitoring
159
+ - **Error Tracking**: Comprehensive error reporting and alerting
160
+ - **Health Checks**: Automated system health verification
161
+
162
+ ## 🔒 Security & Privacy
163
+
164
+ ### Data Protection
165
+ - **End-to-End Encryption**: Client-side encryption before transmission
166
+ - **Event Signatures**: Cryptographic integrity verification
167
+ - **Access Control**: Fine-grained permission system
168
+ - **Audit Logging**: Comprehensive security event logging
169
+
170
+ ### Privacy by Design
171
+ - **Local Data Control**: Users maintain complete data ownership
172
+ - **Selective Sync**: Fine-grained control over data sharing
173
+ - **Data Minimization**: Only sync necessary data
174
+ - **GDPR Compliance**: Built-in privacy compliance features
175
+
176
+ LiveStore combines the reliability of traditional databases with the performance and user experience of local-first applications, enabling you to build applications that users love while maintaining the technical rigor of distributed systems.`;
177
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/mcp-content/features.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mPA+KoN,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const gettingStartedContent = "# Getting Started with LiveStore\n\nBuild your first local-first application with LiveStore in minutes. This guide walks through creating a real-time collaborative todo app that works offline and syncs when online.\n\n## Quick Start\n\n### 1. Installation\n\n```bash\n# Install LiveStore core\nnpm install @livestore/livestore\n\n# Choose your platform adapter\nnpm install @livestore/adapter-web # For web applications\nnpm install @livestore/adapter-node # For Node.js applications\nnpm install @livestore/adapter-expo # For React Native/Expo apps\n```\n\n### 2. Define Your Schema\n\nLiveStore uses an event-driven architecture where all changes are recorded as immutable events and applied to materialized SQLite tables.\n\n```typescript\n// schema.ts\nimport { Events, makeSchema, Schema, SessionIdSymbol, State } from '@livestore/livestore'\n\n// Define your state as SQLite tables\nexport const tables = {\n todos: State.SQLite.table({\n name: 'todos',\n columns: {\n id: State.SQLite.text({ primaryKey: true }),\n text: State.SQLite.text({ default: '' }),\n completed: State.SQLite.boolean({ default: false }),\n deletedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),\n createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),\n },\n }),\n \n // Client-only state (not synced)\n uiState: State.SQLite.clientDocument({\n name: 'uiState',\n schema: Schema.Struct({ \n newTodoText: Schema.String, \n filter: Schema.Literal('all', 'active', 'completed') \n }),\n default: { id: SessionIdSymbol, value: { newTodoText: '', filter: 'all' } },\n }),\n}\n\n// Define events that represent state changes\nexport const events = {\n todoCreated: Events.synced({\n name: 'v1.TodoCreated',\n schema: Schema.Struct({ \n id: Schema.String, \n text: Schema.String,\n createdAt: Schema.Date \n }),\n }),\n todoCompleted: Events.synced({\n name: 'v1.TodoCompleted',\n schema: Schema.Struct({ id: Schema.String }),\n }),\n todoUncompleted: Events.synced({\n name: 'v1.TodoUncompleted',\n schema: Schema.Struct({ id: Schema.String }),\n }),\n todoDeleted: Events.synced({\n name: 'v1.TodoDeleted',\n schema: Schema.Struct({ id: Schema.String, deletedAt: Schema.Date }),\n }),\n \n // UI state events (local only)\n uiStateSet: tables.uiState.set,\n}\n\n// Materializers map events to state changes\nconst materializers = State.SQLite.materializers(events, {\n 'v1.TodoCreated': ({ id, text, createdAt }) => \n tables.todos.insert({ id, text, completed: false, createdAt }),\n \n 'v1.TodoCompleted': ({ id }) => \n tables.todos.update({ completed: true }).where({ id }),\n \n 'v1.TodoUncompleted': ({ id }) => \n tables.todos.update({ completed: false }).where({ id }),\n \n 'v1.TodoDeleted': ({ id, deletedAt }) => \n tables.todos.update({ deletedAt }).where({ id }),\n})\n\nconst state = State.SQLite.makeState({ tables, materializers })\n\nexport const schema = makeSchema({ events, state })\n```\n\n### 3. Create Reactive Queries\n\nLiveStore queries automatically update your UI when underlying data changes.\n\n```typescript\n// queries.ts\nimport { queryDb } from '@livestore/livestore'\nimport { tables } from './schema.js'\n\n// Reactive query for all active todos\nexport const activeTodos$ = queryDb(\n tables.todos\n .select()\n .where({ deletedAt: null, completed: false })\n .orderBy('createdAt'),\n { label: 'activeTodos' }\n)\n\n// Reactive query for completed todos\nexport const completedTodos$ = queryDb(\n tables.todos\n .select()\n .where({ deletedAt: null, completed: true })\n .orderBy('createdAt'),\n { label: 'completedTodos' }\n)\n\n// UI state query\nexport const uiState$ = queryDb(\n tables.uiState.get(),\n { label: 'uiState' }\n)\n```\n\n### 4. Connect to Your UI Framework\n\n#### React Integration\n\n```typescript\n// TodoApp.tsx\nimport React from 'react'\nimport { useLiveQuery, dispatchEvent } from '@livestore/react'\nimport { activeTodos$, completedTodos$, uiState$ } from './queries.js'\nimport { events } from './schema.js'\n\nconst TodoApp: React.FC = () => {\n const activeTodos = useLiveQuery(activeTodos$)\n const completedTodos = useLiveQuery(completedTodos$)\n const uiState = useLiveQuery(uiState$)\n \n const createTodo = (text: string) => {\n const id = crypto.randomUUID()\n dispatchEvent(events.todoCreated({ id, text, createdAt: new Date() }))\n }\n \n const toggleTodo = (id: string, completed: boolean) => {\n dispatchEvent(\n completed \n ? events.todoCompleted({ id })\n : events.todoUncompleted({ id })\n )\n }\n \n const deleteTodo = (id: string) => {\n dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))\n }\n \n return (\n <div className=\"todo-app\">\n <h1>Local-First Todos</h1>\n \n {/* Add todo form */}\n <form onSubmit={(e) => {\n e.preventDefault()\n const form = e.target as HTMLFormElement\n const input = form.elements.namedItem('todo') as HTMLInputElement\n if (input.value.trim()) {\n createTodo(input.value.trim())\n input.value = ''\n }\n }}>\n <input name=\"todo\" placeholder=\"What needs to be done?\" />\n <button type=\"submit\">Add Todo</button>\n </form>\n \n {/* Active todos */}\n <div className=\"todo-list\">\n <h2>Active ({activeTodos.length})</h2>\n {activeTodos.map(todo => (\n <div key={todo.id} className=\"todo-item\">\n <input \n type=\"checkbox\"\n checked={false}\n onChange={() => toggleTodo(todo.id, true)}\n />\n <span>{todo.text}</span>\n <button onClick={() => deleteTodo(todo.id)}>Delete</button>\n </div>\n ))}\n </div>\n \n {/* Completed todos */}\n <div className=\"todo-list\">\n <h2>Completed ({completedTodos.length})</h2>\n {completedTodos.map(todo => (\n <div key={todo.id} className=\"todo-item completed\">\n <input \n type=\"checkbox\"\n checked={true}\n onChange={() => toggleTodo(todo.id, false)}\n />\n <span>{todo.text}</span>\n <button onClick={() => deleteTodo(todo.id)}>Delete</button>\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nexport default TodoApp\n```\n\n#### Vue Integration\n\n```vue\n<!-- TodoApp.vue -->\n<template>\n <div class=\"todo-app\">\n <h1>Local-First Todos</h1>\n \n <form @submit.prevent=\"createTodo\">\n <input v-model=\"newTodoText\" placeholder=\"What needs to be done?\" />\n <button type=\"submit\">Add Todo</button>\n </form>\n \n <div class=\"todo-list\">\n <h2>Active ({{ activeTodos.length }})</h2>\n <div v-for=\"todo in activeTodos\" :key=\"todo.id\" class=\"todo-item\">\n <input \n type=\"checkbox\"\n :checked=\"false\"\n @change=\"toggleTodo(todo.id, true)\"\n />\n <span>{{ todo.text }}</span>\n <button @click=\"deleteTodo(todo.id)\">Delete</button>\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport { useLiveQuery, dispatchEvent } from '@livestore/vue'\nimport { activeTodos$ } from './queries.js'\nimport { events } from './schema.js'\n\nconst activeTodos = useLiveQuery(activeTodos$)\nconst newTodoText = ref('')\n\nconst createTodo = () => {\n if (newTodoText.value.trim()) {\n const id = crypto.randomUUID()\n dispatchEvent(events.todoCreated({ \n id, \n text: newTodoText.value.trim(), \n createdAt: new Date() \n }))\n newTodoText.value = ''\n }\n}\n\nconst toggleTodo = (id: string, completed: boolean) => {\n dispatchEvent(\n completed \n ? events.todoCompleted({ id })\n : events.todoUncompleted({ id })\n )\n}\n\nconst deleteTodo = (id: string) => {\n dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))\n}\n</script>\n```\n\n### 5. Initialize Your Application\n\n```typescript\n// main.ts\nimport { LiveStore } from '@livestore/livestore'\nimport { WebAdapter } from '@livestore/adapter-web'\nimport { schema } from './schema.js'\n\n// Initialize LiveStore with your schema\nconst liveStore = LiveStore.create({\n schema,\n adapter: WebAdapter({\n databaseName: 'todo-app',\n // Optional: Add sync configuration\n sync: {\n url: 'wss://your-sync-server.com',\n auth: { token: 'your-auth-token' }\n }\n })\n})\n\n// Start your application\nconst app = document.getElementById('app')\nif (app) {\n // Your framework-specific initialization\n // React: createRoot(app).render(<TodoApp />)\n // Vue: createApp(TodoApp).mount(app)\n}\n```\n\n## Advanced Features\n\n### Offline Support\n\nYour app automatically works offline. All operations execute against the local database, and changes sync when connectivity returns.\n\n```typescript\n// Check online status\nconst isOnline$ = queryDb(\n LiveStore.connectionStatus(),\n { label: 'connectionStatus' }\n)\n```\n\n### Real-Time Collaboration\n\nMultiple users can collaborate in real-time. Conflicts are automatically resolved using last-write-wins or custom merge strategies.\n\n```typescript\n// Custom conflict resolution\nconst materializers = State.SQLite.materializers(events, {\n 'v1.TodoTextChanged': ({ id, text, editedAt }) => \n // Use timestamp for conflict resolution\n tables.todos\n .update({ text, editedAt })\n .where({ id })\n .and(tables.todos.column('editedAt').lt(editedAt))\n})\n```\n\n### Testing\n\n```typescript\n// todo.test.ts\nimport { createTestStore } from '@livestore/testing'\nimport { schema, events } from './schema.js'\n\ntest('creating and completing todos', async () => {\n const store = createTestStore(schema)\n \n // Dispatch events\n await store.dispatch([\n events.todoCreated({ id: '1', text: 'Test todo', createdAt: new Date() }),\n events.todoCompleted({ id: '1' })\n ])\n \n // Query final state\n const completedTodos = await store.query(\n tables.todos.select().where({ completed: true })\n )\n \n expect(completedTodos).toHaveLength(1)\n expect(completedTodos[0].text).toBe('Test todo')\n})\n```\n\n## Next Steps\n\n### Production Deployment\n1. **Set up sync server**: Deploy LiveStore sync server for real-time collaboration\n2. **Configure authentication**: Add user authentication and authorization\n3. **Add monitoring**: Set up distributed tracing and performance monitoring\n4. **Optimize performance**: Add indexes and query optimization\n\n### Advanced Patterns\n- **Multi-user collaboration**: User permissions and access control\n- **Rich text editing**: Operational transforms for collaborative editing\n- **File synchronization**: Binary data and file attachment handling\n- **Schema migrations**: Evolving your data model over time\n\n### Platform-Specific Guides\n- **Web deployment**: Service workers, PWA configuration, OPFS optimization\n- **Mobile apps**: Background sync, push notifications, native storage\n- **Desktop apps**: Electron integration, native file system access\n\n## Examples Repository\n\nExplore complete working examples:\n- **TodoMVC**: Classic todo app with real-time sync\n- **Collaborative Editor**: Rich text editing with operational transforms\n- **Chat Application**: Real-time messaging with presence indicators\n- **E-commerce**: Product catalog with shopping cart and orders\n\n```bash\n# Clone examples repository\ngit clone https://github.com/livestorejs/examples.git\ncd examples/web-todomvc\nnpm install && npm run dev\n```\n\nVisit [docs.livestore.dev](https://docs.livestore.dev) for comprehensive documentation, API reference, and advanced patterns.";
2
+ //# sourceMappingURL=getting-started.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.d.ts","sourceRoot":"","sources":["../../src/mcp-content/getting-started.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,4oXAmZ4F,CAAA"}
@@ -0,0 +1,405 @@
1
+ export const gettingStartedContent = `# Getting Started with LiveStore
2
+
3
+ Build your first local-first application with LiveStore in minutes. This guide walks through creating a real-time collaborative todo app that works offline and syncs when online.
4
+
5
+ ## Quick Start
6
+
7
+ ### 1. Installation
8
+
9
+ \`\`\`bash
10
+ # Install LiveStore core
11
+ npm install @livestore/livestore
12
+
13
+ # Choose your platform adapter
14
+ npm install @livestore/adapter-web # For web applications
15
+ npm install @livestore/adapter-node # For Node.js applications
16
+ npm install @livestore/adapter-expo # For React Native/Expo apps
17
+ \`\`\`
18
+
19
+ ### 2. Define Your Schema
20
+
21
+ LiveStore uses an event-driven architecture where all changes are recorded as immutable events and applied to materialized SQLite tables.
22
+
23
+ \`\`\`typescript
24
+ // schema.ts
25
+ import { Events, makeSchema, Schema, SessionIdSymbol, State } from '@livestore/livestore'
26
+
27
+ // Define your state as SQLite tables
28
+ export const tables = {
29
+ todos: State.SQLite.table({
30
+ name: 'todos',
31
+ columns: {
32
+ id: State.SQLite.text({ primaryKey: true }),
33
+ text: State.SQLite.text({ default: '' }),
34
+ completed: State.SQLite.boolean({ default: false }),
35
+ deletedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),
36
+ createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),
37
+ },
38
+ }),
39
+
40
+ // Client-only state (not synced)
41
+ uiState: State.SQLite.clientDocument({
42
+ name: 'uiState',
43
+ schema: Schema.Struct({
44
+ newTodoText: Schema.String,
45
+ filter: Schema.Literal('all', 'active', 'completed')
46
+ }),
47
+ default: { id: SessionIdSymbol, value: { newTodoText: '', filter: 'all' } },
48
+ }),
49
+ }
50
+
51
+ // Define events that represent state changes
52
+ export const events = {
53
+ todoCreated: Events.synced({
54
+ name: 'v1.TodoCreated',
55
+ schema: Schema.Struct({
56
+ id: Schema.String,
57
+ text: Schema.String,
58
+ createdAt: Schema.Date
59
+ }),
60
+ }),
61
+ todoCompleted: Events.synced({
62
+ name: 'v1.TodoCompleted',
63
+ schema: Schema.Struct({ id: Schema.String }),
64
+ }),
65
+ todoUncompleted: Events.synced({
66
+ name: 'v1.TodoUncompleted',
67
+ schema: Schema.Struct({ id: Schema.String }),
68
+ }),
69
+ todoDeleted: Events.synced({
70
+ name: 'v1.TodoDeleted',
71
+ schema: Schema.Struct({ id: Schema.String, deletedAt: Schema.Date }),
72
+ }),
73
+
74
+ // UI state events (local only)
75
+ uiStateSet: tables.uiState.set,
76
+ }
77
+
78
+ // Materializers map events to state changes
79
+ const materializers = State.SQLite.materializers(events, {
80
+ 'v1.TodoCreated': ({ id, text, createdAt }) =>
81
+ tables.todos.insert({ id, text, completed: false, createdAt }),
82
+
83
+ 'v1.TodoCompleted': ({ id }) =>
84
+ tables.todos.update({ completed: true }).where({ id }),
85
+
86
+ 'v1.TodoUncompleted': ({ id }) =>
87
+ tables.todos.update({ completed: false }).where({ id }),
88
+
89
+ 'v1.TodoDeleted': ({ id, deletedAt }) =>
90
+ tables.todos.update({ deletedAt }).where({ id }),
91
+ })
92
+
93
+ const state = State.SQLite.makeState({ tables, materializers })
94
+
95
+ export const schema = makeSchema({ events, state })
96
+ \`\`\`
97
+
98
+ ### 3. Create Reactive Queries
99
+
100
+ LiveStore queries automatically update your UI when underlying data changes.
101
+
102
+ \`\`\`typescript
103
+ // queries.ts
104
+ import { queryDb } from '@livestore/livestore'
105
+ import { tables } from './schema.js'
106
+
107
+ // Reactive query for all active todos
108
+ export const activeTodos$ = queryDb(
109
+ tables.todos
110
+ .select()
111
+ .where({ deletedAt: null, completed: false })
112
+ .orderBy('createdAt'),
113
+ { label: 'activeTodos' }
114
+ )
115
+
116
+ // Reactive query for completed todos
117
+ export const completedTodos$ = queryDb(
118
+ tables.todos
119
+ .select()
120
+ .where({ deletedAt: null, completed: true })
121
+ .orderBy('createdAt'),
122
+ { label: 'completedTodos' }
123
+ )
124
+
125
+ // UI state query
126
+ export const uiState$ = queryDb(
127
+ tables.uiState.get(),
128
+ { label: 'uiState' }
129
+ )
130
+ \`\`\`
131
+
132
+ ### 4. Connect to Your UI Framework
133
+
134
+ #### React Integration
135
+
136
+ \`\`\`typescript
137
+ // TodoApp.tsx
138
+ import React from 'react'
139
+ import { useLiveQuery, dispatchEvent } from '@livestore/react'
140
+ import { activeTodos$, completedTodos$, uiState$ } from './queries.js'
141
+ import { events } from './schema.js'
142
+
143
+ const TodoApp: React.FC = () => {
144
+ const activeTodos = useLiveQuery(activeTodos$)
145
+ const completedTodos = useLiveQuery(completedTodos$)
146
+ const uiState = useLiveQuery(uiState$)
147
+
148
+ const createTodo = (text: string) => {
149
+ const id = crypto.randomUUID()
150
+ dispatchEvent(events.todoCreated({ id, text, createdAt: new Date() }))
151
+ }
152
+
153
+ const toggleTodo = (id: string, completed: boolean) => {
154
+ dispatchEvent(
155
+ completed
156
+ ? events.todoCompleted({ id })
157
+ : events.todoUncompleted({ id })
158
+ )
159
+ }
160
+
161
+ const deleteTodo = (id: string) => {
162
+ dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))
163
+ }
164
+
165
+ return (
166
+ <div className="todo-app">
167
+ <h1>Local-First Todos</h1>
168
+
169
+ {/* Add todo form */}
170
+ <form onSubmit={(e) => {
171
+ e.preventDefault()
172
+ const form = e.target as HTMLFormElement
173
+ const input = form.elements.namedItem('todo') as HTMLInputElement
174
+ if (input.value.trim()) {
175
+ createTodo(input.value.trim())
176
+ input.value = ''
177
+ }
178
+ }}>
179
+ <input name="todo" placeholder="What needs to be done?" />
180
+ <button type="submit">Add Todo</button>
181
+ </form>
182
+
183
+ {/* Active todos */}
184
+ <div className="todo-list">
185
+ <h2>Active ({activeTodos.length})</h2>
186
+ {activeTodos.map(todo => (
187
+ <div key={todo.id} className="todo-item">
188
+ <input
189
+ type="checkbox"
190
+ checked={false}
191
+ onChange={() => toggleTodo(todo.id, true)}
192
+ />
193
+ <span>{todo.text}</span>
194
+ <button onClick={() => deleteTodo(todo.id)}>Delete</button>
195
+ </div>
196
+ ))}
197
+ </div>
198
+
199
+ {/* Completed todos */}
200
+ <div className="todo-list">
201
+ <h2>Completed ({completedTodos.length})</h2>
202
+ {completedTodos.map(todo => (
203
+ <div key={todo.id} className="todo-item completed">
204
+ <input
205
+ type="checkbox"
206
+ checked={true}
207
+ onChange={() => toggleTodo(todo.id, false)}
208
+ />
209
+ <span>{todo.text}</span>
210
+ <button onClick={() => deleteTodo(todo.id)}>Delete</button>
211
+ </div>
212
+ ))}
213
+ </div>
214
+ </div>
215
+ )
216
+ }
217
+
218
+ export default TodoApp
219
+ \`\`\`
220
+
221
+ #### Vue Integration
222
+
223
+ \`\`\`vue
224
+ <!-- TodoApp.vue -->
225
+ <template>
226
+ <div class="todo-app">
227
+ <h1>Local-First Todos</h1>
228
+
229
+ <form @submit.prevent="createTodo">
230
+ <input v-model="newTodoText" placeholder="What needs to be done?" />
231
+ <button type="submit">Add Todo</button>
232
+ </form>
233
+
234
+ <div class="todo-list">
235
+ <h2>Active ({{ activeTodos.length }})</h2>
236
+ <div v-for="todo in activeTodos" :key="todo.id" class="todo-item">
237
+ <input
238
+ type="checkbox"
239
+ :checked="false"
240
+ @change="toggleTodo(todo.id, true)"
241
+ />
242
+ <span>{{ todo.text }}</span>
243
+ <button @click="deleteTodo(todo.id)">Delete</button>
244
+ </div>
245
+ </div>
246
+ </div>
247
+ </template>
248
+
249
+ <script setup lang="ts">
250
+ import { ref } from 'vue'
251
+ import { useLiveQuery, dispatchEvent } from '@livestore/vue'
252
+ import { activeTodos$ } from './queries.js'
253
+ import { events } from './schema.js'
254
+
255
+ const activeTodos = useLiveQuery(activeTodos$)
256
+ const newTodoText = ref('')
257
+
258
+ const createTodo = () => {
259
+ if (newTodoText.value.trim()) {
260
+ const id = crypto.randomUUID()
261
+ dispatchEvent(events.todoCreated({
262
+ id,
263
+ text: newTodoText.value.trim(),
264
+ createdAt: new Date()
265
+ }))
266
+ newTodoText.value = ''
267
+ }
268
+ }
269
+
270
+ const toggleTodo = (id: string, completed: boolean) => {
271
+ dispatchEvent(
272
+ completed
273
+ ? events.todoCompleted({ id })
274
+ : events.todoUncompleted({ id })
275
+ )
276
+ }
277
+
278
+ const deleteTodo = (id: string) => {
279
+ dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))
280
+ }
281
+ </script>
282
+ \`\`\`
283
+
284
+ ### 5. Initialize Your Application
285
+
286
+ \`\`\`typescript
287
+ // main.ts
288
+ import { LiveStore } from '@livestore/livestore'
289
+ import { WebAdapter } from '@livestore/adapter-web'
290
+ import { schema } from './schema.js'
291
+
292
+ // Initialize LiveStore with your schema
293
+ const liveStore = LiveStore.create({
294
+ schema,
295
+ adapter: WebAdapter({
296
+ databaseName: 'todo-app',
297
+ // Optional: Add sync configuration
298
+ sync: {
299
+ url: 'wss://your-sync-server.com',
300
+ auth: { token: 'your-auth-token' }
301
+ }
302
+ })
303
+ })
304
+
305
+ // Start your application
306
+ const app = document.getElementById('app')
307
+ if (app) {
308
+ // Your framework-specific initialization
309
+ // React: createRoot(app).render(<TodoApp />)
310
+ // Vue: createApp(TodoApp).mount(app)
311
+ }
312
+ \`\`\`
313
+
314
+ ## Advanced Features
315
+
316
+ ### Offline Support
317
+
318
+ Your app automatically works offline. All operations execute against the local database, and changes sync when connectivity returns.
319
+
320
+ \`\`\`typescript
321
+ // Check online status
322
+ const isOnline$ = queryDb(
323
+ LiveStore.connectionStatus(),
324
+ { label: 'connectionStatus' }
325
+ )
326
+ \`\`\`
327
+
328
+ ### Real-Time Collaboration
329
+
330
+ Multiple users can collaborate in real-time. Conflicts are automatically resolved using last-write-wins or custom merge strategies.
331
+
332
+ \`\`\`typescript
333
+ // Custom conflict resolution
334
+ const materializers = State.SQLite.materializers(events, {
335
+ 'v1.TodoTextChanged': ({ id, text, editedAt }) =>
336
+ // Use timestamp for conflict resolution
337
+ tables.todos
338
+ .update({ text, editedAt })
339
+ .where({ id })
340
+ .and(tables.todos.column('editedAt').lt(editedAt))
341
+ })
342
+ \`\`\`
343
+
344
+ ### Testing
345
+
346
+ \`\`\`typescript
347
+ // todo.test.ts
348
+ import { createTestStore } from '@livestore/testing'
349
+ import { schema, events } from './schema.js'
350
+
351
+ test('creating and completing todos', async () => {
352
+ const store = createTestStore(schema)
353
+
354
+ // Dispatch events
355
+ await store.dispatch([
356
+ events.todoCreated({ id: '1', text: 'Test todo', createdAt: new Date() }),
357
+ events.todoCompleted({ id: '1' })
358
+ ])
359
+
360
+ // Query final state
361
+ const completedTodos = await store.query(
362
+ tables.todos.select().where({ completed: true })
363
+ )
364
+
365
+ expect(completedTodos).toHaveLength(1)
366
+ expect(completedTodos[0].text).toBe('Test todo')
367
+ })
368
+ \`\`\`
369
+
370
+ ## Next Steps
371
+
372
+ ### Production Deployment
373
+ 1. **Set up sync server**: Deploy LiveStore sync server for real-time collaboration
374
+ 2. **Configure authentication**: Add user authentication and authorization
375
+ 3. **Add monitoring**: Set up distributed tracing and performance monitoring
376
+ 4. **Optimize performance**: Add indexes and query optimization
377
+
378
+ ### Advanced Patterns
379
+ - **Multi-user collaboration**: User permissions and access control
380
+ - **Rich text editing**: Operational transforms for collaborative editing
381
+ - **File synchronization**: Binary data and file attachment handling
382
+ - **Schema migrations**: Evolving your data model over time
383
+
384
+ ### Platform-Specific Guides
385
+ - **Web deployment**: Service workers, PWA configuration, OPFS optimization
386
+ - **Mobile apps**: Background sync, push notifications, native storage
387
+ - **Desktop apps**: Electron integration, native file system access
388
+
389
+ ## Examples Repository
390
+
391
+ Explore complete working examples:
392
+ - **TodoMVC**: Classic todo app with real-time sync
393
+ - **Collaborative Editor**: Rich text editing with operational transforms
394
+ - **Chat Application**: Real-time messaging with presence indicators
395
+ - **E-commerce**: Product catalog with shopping cart and orders
396
+
397
+ \`\`\`bash
398
+ # Clone examples repository
399
+ git clone https://github.com/livestorejs/examples.git
400
+ cd examples/web-todomvc
401
+ npm install && npm run dev
402
+ \`\`\`
403
+
404
+ Visit [docs.livestore.dev](https://docs.livestore.dev) for comprehensive documentation, API reference, and advanced patterns.`;
405
+ //# sourceMappingURL=getting-started.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.js","sourceRoot":"","sources":["../../src/mcp-content/getting-started.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8HAmZyF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const overviewContent = "# LiveStore: Local-First Data Platform\n\nLiveStore is a production-ready local-first data platform that combines the immediate responsiveness of local SQLite databases with the collaborative power of real-time synchronization. Built on distributed systems principles from Martin Kleppmann's research, LiveStore enables applications that work seamlessly offline and sync reliably when online.\n\n## Core Philosophy\n\n**Local-First Principles**: Your data lives primarily on your device, not in the cloud. Applications respond immediately to user actions without network round-trips, providing the smooth experience users expect from native applications.\n\n**Collaborative by Design**: Real-time collaboration isn't an afterthought \u2013 it's built into the foundation. Multiple users can work together seamlessly with automatic conflict resolution and eventual consistency guarantees.\n\n**Reliability Through Event Sourcing**: All changes are captured as immutable events, providing a complete audit trail and enabling powerful features like undo/redo, time travel debugging, and deterministic testing.\n\n## What Makes LiveStore Different\n\n### \uD83D\uDCBE Local SQLite Performance\n- **Sub-millisecond queries** from local SQLite database\n- **Complex joins and aggregations** with full SQL expressiveness\n- **Reactive queries** that automatically update your UI\n- **ACID transactions** for data integrity\n\n### \uD83C\uDF10 Distributed Systems Reliability\n- **Conflict-free synchronization** using CRDT-inspired merge strategies\n- **Causal consistency** with vector clocks and event ordering\n- **Network partition tolerance** \u2013 works offline, syncs when online\n- **Eventually consistent** convergence across all replicas\n\n### \uD83D\uDD10 End-to-End Type Safety\n- **Schema-first development** with Effect-based validation\n- **Compile-time query validation** prevents runtime errors \n- **Automatic TypeScript generation** from schema definitions\n- **Runtime safety** with comprehensive input validation\n\n### \uD83C\uDFD7\uFE0F Framework Agnostic\n- **React, Vue, Solid, Svelte** \u2013 use with any frontend framework\n- **Web, Node.js, React Native** \u2013 deploy anywhere JavaScript runs\n- **Consistent API** across all platforms and frameworks\n\n## Real-World Use Cases\n\n### \uD83D\uDCDD Collaborative Applications\n- **Document editors** with real-time collaboration (Google Docs-style)\n- **Project management** tools with team coordination\n- **Design tools** with multiplayer editing capabilities\n- **Chat applications** with offline message queuing\n\n### \uD83D\uDCF1 Mobile-First Applications \n- **Field service apps** that work in areas with poor connectivity\n- **Healthcare applications** with sensitive data that must stay local\n- **Educational apps** for students in low-connectivity environments\n- **Financial apps** requiring immediate transaction feedback\n\n### \uD83C\uDFEE Enterprise Applications\n- **CRM systems** with offline sales capability\n- **Inventory management** with real-time stock updates\n- **Customer service** tools with offline case management\n- **Analytics dashboards** with local data caching\n\n## Architecture at a Glance\n\n```mermaid\ngraph TB\n UI[UI Framework] --> Queries[Reactive Queries]\n UI --> Events[Event Dispatch]\n \n Events --> EventLog[Event Log]\n EventLog --> Materializers[Materializers]\n Materializers --> SQLite[SQLite Database]\n Queries --> SQLite\n \n EventLog --> Sync[Sync Engine]\n Sync --> Network[Network Layer]\n Network --> Server[Sync Server]\n \n Server --> OtherClients[Other Clients]\n OtherClients --> Server\n Server --> Network\n```\n\n1. **UI Layer**: Framework-specific bindings (React, Vue, etc.)\n2. **Query Layer**: Reactive SQL queries with automatic UI updates\n3. **Event Layer**: Immutable event log with schema validation\n4. **Materialization**: Events applied to SQLite tables via materializers\n5. **Synchronization**: Conflict-free replication across devices/users\n6. **Storage**: Local SQLite database for immediate data access\n\n## Key Technical Innovations\n\n### Event-Driven State Management\nUnlike traditional ORMs that hide change tracking, LiveStore makes all state changes explicit through events. This provides:\n- **Deterministic state updates** that can be tested and debugged\n- **Conflict resolution** through event reordering and semantic merging\n- **Time travel** capabilities for debugging and feature development\n- **Audit trails** for compliance and data governance\n\n### Sophisticated Conflict Resolution\nLiveStore handles conflicts intelligently using multiple strategies:\n- **Last-Write-Wins**: Simple timestamp-based resolution\n- **Semantic Merging**: Application-specific conflict resolution logic \n- **Operational Transforms**: For real-time collaborative text editing\n- **CRDT Integration**: Conflict-free data types for specific use cases\n\n### Performance Optimization\n- **Query compilation caching** for repeated queries\n- **Reactive dependency tracking** to minimize unnecessary updates\n- **Incremental synchronization** to reduce network overhead\n- **Background processing** to keep the UI thread responsive\n\n## Production Ready\n\nLiveStore is designed for production applications with enterprise-grade requirements:\n\n- **Security**: End-to-end encryption, event signatures, access control\n- **Observability**: Distributed tracing, performance monitoring, health checks\n- **Scalability**: Horizontal scaling, connection pooling, data partitioning\n- **Reliability**: Automatic retries, circuit breakers, graceful degradation\n\nWhether you're building a simple todo app or a complex collaborative platform, LiveStore provides the foundation for applications that users love \u2013 fast, reliable, and always available.\n\n**Ready to get started?** Check out our [Getting Started Guide](./getting-started) or explore our [Example Applications](https://github.com/livestorejs/examples).";
2
+ //# sourceMappingURL=overview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../src/mcp-content/overview.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,y4LAsHuI,CAAA"}