@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,67 @@
1
+ import { Effect, Layer, Logger, McpServer } from '@livestore/utils/effect';
2
+ import { Cli, PlatformNode } from '@livestore/utils/node';
3
+ import { architectureContent } from "../mcp-content/architecture.js";
4
+ import { featuresContent } from "../mcp-content/features.js";
5
+ import { gettingStartedContent } from "../mcp-content/getting-started.js";
6
+ // Content imports
7
+ import { overviewContent } from "../mcp-content/overview.js";
8
+ import { blogSchemaContent } from "../mcp-content/schemas/blog.js";
9
+ import { ecommerceSchemaContent } from "../mcp-content/schemas/ecommerce.js";
10
+ import { socialSchemaContent } from "../mcp-content/schemas/social.js";
11
+ import { todoSchemaContent } from "../mcp-content/schemas/todo.js";
12
+ // Tools imports
13
+ import { livestoreToolkit, toolHandlers } from "./mcp-tools.js";
14
+ const LivestoreResources = Layer.mergeAll(McpServer.resource({
15
+ uri: 'livestore://overview',
16
+ name: 'LiveStore Overview',
17
+ description: 'Overview of LiveStore - the local-first data platform',
18
+ content: Effect.succeed(overviewContent),
19
+ }), McpServer.resource({
20
+ uri: 'livestore://features',
21
+ name: 'LiveStore Features',
22
+ description: 'Core features and capabilities of LiveStore',
23
+ content: Effect.succeed(featuresContent),
24
+ }), McpServer.resource({
25
+ uri: 'livestore://getting-started',
26
+ name: 'Getting Started with LiveStore',
27
+ description: 'Quick start guide for LiveStore development',
28
+ content: Effect.succeed(gettingStartedContent),
29
+ }), McpServer.resource({
30
+ uri: 'livestore://architecture',
31
+ name: 'LiveStore Architecture',
32
+ description: 'Technical architecture and design principles of LiveStore',
33
+ content: Effect.succeed(architectureContent),
34
+ }), McpServer.resource({
35
+ uri: 'livestore://schemas/todo',
36
+ name: 'Todo App Schema',
37
+ description: 'Complete LiveStore schema for a todo application with tags',
38
+ content: Effect.succeed(todoSchemaContent),
39
+ }), McpServer.resource({
40
+ uri: 'livestore://schemas/blog',
41
+ name: 'Blog Platform Schema',
42
+ description: 'LiveStore schema for a blog platform with posts and comments',
43
+ content: Effect.succeed(blogSchemaContent),
44
+ }), McpServer.resource({
45
+ uri: 'livestore://schemas/social',
46
+ name: 'Social Media Schema',
47
+ description: 'LiveStore schema for a social media platform with users, posts, and interactions',
48
+ content: Effect.succeed(socialSchemaContent),
49
+ }), McpServer.resource({
50
+ uri: 'livestore://schemas/ecommerce',
51
+ name: 'E-commerce Schema',
52
+ description: 'LiveStore schema for an e-commerce platform with products, orders, and categories',
53
+ content: Effect.succeed(ecommerceSchemaContent),
54
+ }));
55
+ const LivestoreTools = McpServer.toolkit(livestoreToolkit).pipe(Layer.provide(livestoreToolkit.toLayer(toolHandlers)));
56
+ const mcpServerCommand = Cli.Command.make('server', {}, Effect.fn(function* () {
57
+ yield* Effect.log('🚀 Starting LiveStore MCP Server...');
58
+ // Following Tim Smart's exact pattern from main.ts
59
+ return yield* McpServer.layerStdio({
60
+ name: 'livestore-mcp',
61
+ version: '0.1.0',
62
+ stdin: PlatformNode.NodeStream.stdin,
63
+ stdout: PlatformNode.NodeSink.stdout,
64
+ }).pipe(Layer.provide(LivestoreResources), Layer.provide(LivestoreTools), Layer.provide(Logger.add(Logger.prettyLogger({ stderr: true }))), Layer.launch);
65
+ }));
66
+ export const mcpCommand = Cli.Command.make('mcp').pipe(Cli.Command.withSubcommands([mcpServerCommand]));
67
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MA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B,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC,KAAK;QACpC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,MAAM;KACrC,CAAC,CAAC,IAAI,CACL,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EACjC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAC7B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAChE,KAAK,CAAC,MAAM,CACb,CAAA;AACH,CAAC,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { HttpClient, Option, Schema } from '@livestore/utils/effect';
2
+ import { Cli } from '@livestore/utils/node';
3
+ declare const ExampleNotFoundError_base: Schema.TaggedErrorClass<ExampleNotFoundError, "ExampleNotFoundError", {
4
+ readonly _tag: Schema.tag<"ExampleNotFoundError">;
5
+ } & {
6
+ exampleName: typeof Schema.String;
7
+ availableExamples: Schema.Array$<typeof Schema.String>;
8
+ message: typeof Schema.String;
9
+ }>;
10
+ export declare class ExampleNotFoundError extends ExampleNotFoundError_base {
11
+ }
12
+ declare const NetworkError_base: Schema.TaggedErrorClass<NetworkError, "NetworkError", {
13
+ readonly _tag: Schema.tag<"NetworkError">;
14
+ } & {
15
+ cause: typeof Schema.Unknown;
16
+ message: typeof Schema.String;
17
+ }>;
18
+ export declare class NetworkError extends NetworkError_base {
19
+ }
20
+ declare const DirectoryExistsError_base: Schema.TaggedErrorClass<DirectoryExistsError, "DirectoryExistsError", {
21
+ readonly _tag: Schema.tag<"DirectoryExistsError">;
22
+ } & {
23
+ path: typeof Schema.String;
24
+ message: typeof Schema.String;
25
+ }>;
26
+ export declare class DirectoryExistsError extends DirectoryExistsError_base {
27
+ }
28
+ export declare const newProjectCommand: Cli.Command.Command<"new-project", HttpClient.HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, {
29
+ readonly example: Option.Option<string>;
30
+ readonly branch: string;
31
+ readonly path: Option.Option<string>;
32
+ }>;
33
+ export {};
34
+ //# sourceMappingURL=new-project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-project.d.ts","sourceRoot":"","sources":["../../src/commands/new-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,UAAU,EAEV,MAAM,EACN,MAAM,EACP,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;;;;;;;;AAa3C,qBAAa,oBAAqB,SAAQ,yBAIxC;CAAG;;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAGhC;CAAG;;;;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAGxC;CAAG;AA2JL,eAAO,MAAM,iBAAiB;;;;EAoE7B,CAAA"}
@@ -0,0 +1,163 @@
1
+ import * as os from 'node:os';
2
+ import * as nodePath from 'node:path';
3
+ import { Command, Console, Effect, FileSystem, HttpClient, HttpClientRequest, Option, Schema, } from '@livestore/utils/effect';
4
+ import { Cli } from '@livestore/utils/node';
5
+ // Schema for GitHub API response
6
+ const GitHubContentSchema = Schema.Struct({
7
+ name: Schema.String,
8
+ type: Schema.Literal('dir', 'file'),
9
+ path: Schema.String,
10
+ download_url: Schema.NullOr(Schema.String),
11
+ });
12
+ const GitHubContentsResponseSchema = Schema.Array(GitHubContentSchema);
13
+ // Error types
14
+ export class ExampleNotFoundError extends Schema.TaggedError()('ExampleNotFoundError', {
15
+ exampleName: Schema.String,
16
+ availableExamples: Schema.Array(Schema.String),
17
+ message: Schema.String,
18
+ }) {
19
+ }
20
+ export class NetworkError extends Schema.TaggedError()('NetworkError', {
21
+ cause: Schema.Unknown,
22
+ message: Schema.String,
23
+ }) {
24
+ }
25
+ export class DirectoryExistsError extends Schema.TaggedError()('DirectoryExistsError', {
26
+ path: Schema.String,
27
+ message: Schema.String,
28
+ }) {
29
+ }
30
+ // Fetch available examples from GitHub
31
+ const fetchExamples = (branch) => Effect.gen(function* () {
32
+ const url = `https://api.github.com/repos/livestorejs/livestore/contents/examples?ref=${branch}`;
33
+ yield* Effect.log(`Fetching examples from branch: ${branch}`);
34
+ const request = HttpClientRequest.get(url);
35
+ const response = yield* HttpClient.execute(request).pipe(Effect.scoped, Effect.catchAll((error) => new NetworkError({
36
+ cause: error,
37
+ message: `Failed to fetch examples from GitHub: ${error}`,
38
+ })));
39
+ const responseText = yield* response.text;
40
+ const examples = yield* Schema.decodeUnknown(GitHubContentsResponseSchema)(JSON.parse(responseText)).pipe(Effect.catchAll((error) => new NetworkError({
41
+ cause: error,
42
+ message: `Failed to parse GitHub API response: ${error}`,
43
+ })));
44
+ const exampleNames = examples
45
+ .filter((item) => item.type === 'dir')
46
+ .map((item) => item.name)
47
+ .sort();
48
+ yield* Effect.log(`Found ${exampleNames.length} examples: ${exampleNames.join(', ')}`);
49
+ return exampleNames;
50
+ });
51
+ // Interactive example selection
52
+ const selectExample = (examples) => Effect.gen(function* () {
53
+ if (examples.length === 0) {
54
+ return yield* Effect.fail(new Error('No examples available'));
55
+ }
56
+ const prompt = Cli.Prompt.select({
57
+ message: '📦 Select a LiveStore example to create:',
58
+ choices: examples.map((example) => ({
59
+ title: example,
60
+ value: example,
61
+ description: `Create a new project using the ${example} example`,
62
+ })),
63
+ });
64
+ return yield* Cli.Prompt.run(prompt);
65
+ });
66
+ // Download and extract example using tiged approach
67
+ const downloadExample = (exampleName, branch, destinationPath) => Effect.gen(function* () {
68
+ yield* Console.log(`📥 Downloading example "${exampleName}" from branch "${branch}"...`);
69
+ const tempDir = yield* Effect.sync(() => os.tmpdir());
70
+ const tarballPath = nodePath.join(tempDir, `livestore-${branch}-${Date.now()}.tar.gz`);
71
+ const tarballUrl = `https://api.github.com/repos/livestorejs/livestore/tarball/${branch}`;
72
+ // Download tarball directly
73
+ const request = HttpClientRequest.get(tarballUrl);
74
+ const response = yield* HttpClient.execute(request).pipe(Effect.scoped, Effect.catchAll((error) => new NetworkError({
75
+ cause: error,
76
+ message: `Failed to download tarball: ${error}`,
77
+ })));
78
+ const fs = yield* FileSystem.FileSystem;
79
+ // Write tarball to temp file
80
+ const tarballBuffer = yield* response.arrayBuffer;
81
+ yield* fs.writeFile(tarballPath, new Uint8Array(tarballBuffer));
82
+ // Create destination directory
83
+ yield* fs.makeDirectory(destinationPath, { recursive: true });
84
+ // Extract the tarball to a temporary directory first
85
+ const extractDir = nodePath.join(tempDir, `extract-${Date.now()}`);
86
+ yield* fs.makeDirectory(extractDir, { recursive: true });
87
+ // Extract tarball using Effect Command
88
+ yield* Command.make('tar', '-xzf', tarballPath, '-C', extractDir).pipe(Command.exitCode, Effect.catchAll((error) => new NetworkError({
89
+ cause: error,
90
+ message: `Failed to extract tarball: ${error}`,
91
+ })));
92
+ // Find the extracted directory (it will be named like livestorejs-livestore-{hash})
93
+ const extractedDirs = yield* fs.readDirectory(extractDir);
94
+ if (extractedDirs.length === 0) {
95
+ return yield* new NetworkError({
96
+ cause: 'No extracted directory found',
97
+ message: 'Failed to find extracted repository directory',
98
+ });
99
+ }
100
+ const repoDir = nodePath.join(extractDir, extractedDirs[0]);
101
+ const exampleSourcePath = nodePath.join(repoDir, 'examples', exampleName);
102
+ // Check if the example exists
103
+ const exampleExists = yield* fs.exists(exampleSourcePath);
104
+ if (!exampleExists) {
105
+ return yield* new ExampleNotFoundError({
106
+ exampleName,
107
+ availableExamples: [],
108
+ message: `Example "${exampleName}" not found in the extracted repository`,
109
+ });
110
+ }
111
+ // Copy the example directory contents to the destination using Effect Command
112
+ yield* Command.make('cp', '-r', `${exampleSourcePath}/.`, destinationPath).pipe(Command.exitCode, Effect.catchAll((error) => new NetworkError({
113
+ cause: error,
114
+ message: `Failed to copy example files: ${error}`,
115
+ })));
116
+ // Clean up extract directory
117
+ yield* fs.remove(extractDir, { recursive: true }).pipe(Effect.catchAll(() => Effect.void));
118
+ // Clean up tarball
119
+ yield* fs.remove(tarballPath).pipe(Effect.catchAll(() => Effect.void));
120
+ yield* Console.log(`✅ Example "${exampleName}" created successfully at: ${destinationPath}`);
121
+ });
122
+ export const newProjectCommand = Cli.Command.make('new-project', {
123
+ example: Cli.Options.text('example').pipe(Cli.Options.optional, Cli.Options.withDescription('Example name to create (bypasses interactive selection)')),
124
+ branch: Cli.Options.text('branch').pipe(Cli.Options.withDefault('dev'), Cli.Options.withDescription('Branch to fetch examples from')),
125
+ path: Cli.Args.text({ name: 'path' }).pipe(Cli.Args.optional, Cli.Args.withDescription('Destination path for the new project')),
126
+ }, Effect.fn(function* ({ example, branch, path, }) {
127
+ yield* Effect.log('🚀 Creating new LiveStore project...');
128
+ // Fetch available examples
129
+ const examples = yield* fetchExamples(branch);
130
+ if (examples.length === 0) {
131
+ yield* Console.log('❌ No examples found in the repository');
132
+ return yield* new ExampleNotFoundError({
133
+ exampleName: '',
134
+ availableExamples: [],
135
+ message: 'No examples available',
136
+ });
137
+ }
138
+ // Select example (from CLI option or interactive prompt)
139
+ const selectedExample = Option.isSome(example) ? example.value : yield* selectExample(examples);
140
+ // Validate selected example exists
141
+ if (!examples.includes(selectedExample)) {
142
+ yield* Console.log(`❌ Example "${selectedExample}" not found`);
143
+ yield* Console.log(`Available examples: ${examples.join(', ')}`);
144
+ return yield* new ExampleNotFoundError({
145
+ exampleName: selectedExample,
146
+ availableExamples: examples,
147
+ message: `Example "${selectedExample}" not found`,
148
+ });
149
+ }
150
+ // Determine destination path
151
+ const destinationPath = Option.isSome(path) ? nodePath.resolve(path.value) : nodePath.resolve(selectedExample);
152
+ // Download and extract the example
153
+ yield* downloadExample(selectedExample, branch, destinationPath);
154
+ // Success message
155
+ yield* Console.log('\n🎉 Project created successfully!');
156
+ yield* Console.log(`📁 Location: ${destinationPath}`);
157
+ yield* Console.log('\n📋 Next steps:');
158
+ yield* Console.log(` cd ${nodePath.basename(destinationPath)}`);
159
+ yield* Console.log(' pnpm install # Install dependencies');
160
+ yield* Console.log(' pnpm dev # Start development server');
161
+ yield* Console.log('\n💡 Tip: Run `git init` if you want to initialize version control');
162
+ }));
163
+ //# sourceMappingURL=new-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-project.js","sourceRoot":"","sources":["../../src/commands/new-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AACrC,OAAO,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,MAAM,GACP,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAE3C,iCAAiC;AACjC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;CAC3C,CAAC,CAAA;AAEF,MAAM,4BAA4B,GAAG,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAEtE,cAAc;AACd,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC3G,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,iBAAiB,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,MAAM,CAAC,MAA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uBAAuB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,CAAC,IAAI,oBAAoB,CAAC;YACrC,WAAW,EAAE,eAAe;YAC5B,iBAAiB,EAAE,QAAQ;YAC3B,OAAO,EAAE,YAAY,eAAe,aAAa;SAClD,CAAC,CAAA;IACJ,CAAC;IAED,6BAA6B;IAC7B,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IAE9G,mCAAmC;IACnC,KAAK,CAAC,CAAC,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE,eAAe,CAAC,CAAA;IAEhE,kBAAkB;IAClB,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;IACxD,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,eAAe,EAAE,CAAC,CAAA;IACrD,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IACtC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA;IACjE,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAA;IAC/D,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;IACnE,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAA;AAC1F,CAAC,CAAC,CACH,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const architectureContent = "# LiveStore Architecture: Local-First Data Management\n\nLiveStore implements distributed systems principles from Martin Kleppmann's research on local-first software, ensuring data consistency, availability, and partition tolerance in collaborative applications.\n\n## Core Architectural Principles\n\n### 1. Local-First Data Storage\n- **Immediate Response**: All operations execute against local SQLite database first\n- **Offline Capability**: Full application functionality without network connectivity\n- **Data Ownership**: Users maintain complete control over their data\n- **Performance**: Sub-millisecond query responses from local storage\n\n### 2. Event Sourcing & CRDT-Inspired Conflict Resolution\n- **Immutable Event Log**: All changes recorded as immutable events\n- **Deterministic Replay**: State reconstruction from event sequence\n- **Conflict-Free Operations**: Events designed for commutative application\n- **Causal Ordering**: Lamport timestamps ensure causally consistent ordering\n\n### 3. Eventually Consistent Synchronization\n- **Asynchronous Replication**: Events sync when network available\n- **Convergence Guarantee**: All replicas converge to same state\n- **Conflict Resolution**: Last-write-wins with semantic merging strategies\n- **Incremental Sync**: Only transmit events since last synchronization\n\n## System Components\n\n### \uD83D\uDDC4\uFE0F State Layer (SQLite + Materializers)\n```typescript\n// Materialized views from event log\nconst materializers = State.SQLite.materializers(events, {\n 'TodoCreated': ({ id, text, createdAt }) => \n tables.todos.insert({ id, text, completed: false, createdAt }),\n 'TodoCompleted': ({ id }) => \n tables.todos.update({ completed: true }).where({ id })\n})\n```\n\n**Responsibilities:**\n- Maintain denormalized query-optimized state\n- Apply events to update materialized views\n- Support efficient reactive queries\n- Handle schema migrations\n\n### \uD83D\uDCDD Event System (Append-Only Log)\n```typescript\nconst events = {\n todoCompleted: Events.synced({\n name: 'v1.TodoCompleted',\n schema: Schema.Struct({ \n id: Schema.String,\n completedAt: Schema.Date // For conflict resolution\n })\n })\n}\n```\n\n**Characteristics:**\n- Immutable event log (append-only)\n- Cryptographically signed events for integrity\n- Causal dependencies tracked via vector clocks\n- Schema versioning for backward compatibility\n\n### \uD83D\uDD04 Synchronization Engine\n```typescript\n// Conflict resolution during sync\nconst mergeResult = SyncState.merge({\n syncState: currentState,\n payload: incomingEvents,\n isEqualEvent: (a, b) => a.id === b.id && a.type === b.type\n})\n```\n\n**Merge Strategies:**\n- **Advance**: New events extend current state\n- **Rebase**: Rollback conflicting events, apply remote, replay local\n- **Reject**: Ignore events that violate invariants\n\n### \uD83C\uDF10 Network Layer & Adapters\n```typescript\n// Platform-specific sync adapters\nexport const WebAdapter = {\n storage: OPFSSQLiteStorage, // Origin Private File System\n transport: WebSocketSync,\n worker: SharedWorker // Cross-tab synchronization\n}\n```\n\n**Adapter Implementations:**\n- **Web**: OPFS storage, SharedWorker coordination, WebSocket sync\n- **Node**: File system storage, cluster coordination, HTTP/WebSocket\n- **Mobile**: Native SQLite, background sync, push notifications\n\n## Distributed Systems Properties\n\n### CAP Theorem Considerations\n- **Consistency**: Eventually consistent (not strongly consistent)\n- **Availability**: Always available for reads/writes (local-first)\n- **Partition Tolerance**: Continues operation during network partitions\n\n*Trade-off: Chooses Availability + Partition Tolerance over strong Consistency*\n\n### ACID Properties (Local Transactions)\n- **Atomicity**: Event application is atomic within SQLite transaction\n- **Consistency**: Materializers maintain data integrity constraints\n- **Isolation**: Concurrent operations isolated via SQLite WAL mode\n- **Durability**: Events persisted to disk before acknowledgment\n\n### Conflict Resolution Strategies\n\n1. **Semantic Conflict Resolution**\n - Application-specific merge logic\n - E.g., text editing uses operational transforms\n\n2. **Last-Write-Wins (LWW)**\n - Timestamps determine winner\n - Simple but can lose data\n\n3. **Multi-Value Registers**\n - Preserve all conflicting values\n - User or application resolves\n\n4. **Commutative Operations**\n - Operations designed to commute\n - E.g., increment/decrement counters\n\n## Performance & Scalability\n\n### Query Performance\n- **Reactive Queries**: Automatically update UI on data changes\n- **Indexed Access**: SQLite B-tree indexes for fast lookups\n- **Prepared Statements**: Query compilation cached for reuse\n- **Batch Operations**: Multiple events applied in single transaction\n\n### Memory Management\n- **Incremental Loading**: Large datasets loaded on-demand\n- **Query Result Caching**: Expensive query results cached\n- **Event Log Compaction**: Periodic snapshotting and log truncation\n- **Connection Pooling**: Database connections reused across operations\n\n### Network Optimization\n- **Delta Synchronization**: Only sync events since last checkpoint\n- **Compression**: Event payloads compressed for network transfer\n- **Batching**: Multiple events transmitted in single round-trip\n- **Exponential Backoff**: Retry failed sync with increasing delays\n\n## Security Model\n\n### Data Integrity\n- **Event Signatures**: Cryptographic signatures prevent tampering\n- **Merkle Trees**: Efficient verification of event log integrity\n- **Schema Validation**: All events validated against defined schemas\n\n### Access Control\n- **Client-Side Authorization**: Fine-grained permissions in local database\n- **Sync Filtering**: Server filters events based on user permissions\n- **Encryption**: End-to-end encryption for sensitive data\n\n## Observability\n\n### Distributed Tracing\n- **Event Causality**: Trace event propagation across replicas\n- **Sync Performance**: Monitor replication lag and throughput\n- **Conflict Metrics**: Track merge conflicts and resolution strategies\n\n### Health Monitoring\n- **Storage Usage**: Local database size and growth rate\n- **Network Health**: Connection quality and sync success rates\n- **Error Tracking**: Failed operations and their root causes\n\nThis architecture enables applications that work seamlessly offline, sync reliably when online, and provide immediate feedback to users while maintaining data consistency across all replicas.";
2
+ //# sourceMappingURL=architecture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architecture.d.ts","sourceRoot":"","sources":["../../src/mcp-content/architecture.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,29MAyKgK,CAAA"}
@@ -0,0 +1,171 @@
1
+ export const architectureContent = `# LiveStore Architecture: Local-First Data Management
2
+
3
+ LiveStore implements distributed systems principles from Martin Kleppmann's research on local-first software, ensuring data consistency, availability, and partition tolerance in collaborative applications.
4
+
5
+ ## Core Architectural Principles
6
+
7
+ ### 1. Local-First Data Storage
8
+ - **Immediate Response**: All operations execute against local SQLite database first
9
+ - **Offline Capability**: Full application functionality without network connectivity
10
+ - **Data Ownership**: Users maintain complete control over their data
11
+ - **Performance**: Sub-millisecond query responses from local storage
12
+
13
+ ### 2. Event Sourcing & CRDT-Inspired Conflict Resolution
14
+ - **Immutable Event Log**: All changes recorded as immutable events
15
+ - **Deterministic Replay**: State reconstruction from event sequence
16
+ - **Conflict-Free Operations**: Events designed for commutative application
17
+ - **Causal Ordering**: Lamport timestamps ensure causally consistent ordering
18
+
19
+ ### 3. Eventually Consistent Synchronization
20
+ - **Asynchronous Replication**: Events sync when network available
21
+ - **Convergence Guarantee**: All replicas converge to same state
22
+ - **Conflict Resolution**: Last-write-wins with semantic merging strategies
23
+ - **Incremental Sync**: Only transmit events since last synchronization
24
+
25
+ ## System Components
26
+
27
+ ### 🗄️ State Layer (SQLite + Materializers)
28
+ \`\`\`typescript
29
+ // Materialized views from event log
30
+ const materializers = State.SQLite.materializers(events, {
31
+ 'TodoCreated': ({ id, text, createdAt }) =>
32
+ tables.todos.insert({ id, text, completed: false, createdAt }),
33
+ 'TodoCompleted': ({ id }) =>
34
+ tables.todos.update({ completed: true }).where({ id })
35
+ })
36
+ \`\`\`
37
+
38
+ **Responsibilities:**
39
+ - Maintain denormalized query-optimized state
40
+ - Apply events to update materialized views
41
+ - Support efficient reactive queries
42
+ - Handle schema migrations
43
+
44
+ ### 📝 Event System (Append-Only Log)
45
+ \`\`\`typescript
46
+ const events = {
47
+ todoCompleted: Events.synced({
48
+ name: 'v1.TodoCompleted',
49
+ schema: Schema.Struct({
50
+ id: Schema.String,
51
+ completedAt: Schema.Date // For conflict resolution
52
+ })
53
+ })
54
+ }
55
+ \`\`\`
56
+
57
+ **Characteristics:**
58
+ - Immutable event log (append-only)
59
+ - Cryptographically signed events for integrity
60
+ - Causal dependencies tracked via vector clocks
61
+ - Schema versioning for backward compatibility
62
+
63
+ ### 🔄 Synchronization Engine
64
+ \`\`\`typescript
65
+ // Conflict resolution during sync
66
+ const mergeResult = SyncState.merge({
67
+ syncState: currentState,
68
+ payload: incomingEvents,
69
+ isEqualEvent: (a, b) => a.id === b.id && a.type === b.type
70
+ })
71
+ \`\`\`
72
+
73
+ **Merge Strategies:**
74
+ - **Advance**: New events extend current state
75
+ - **Rebase**: Rollback conflicting events, apply remote, replay local
76
+ - **Reject**: Ignore events that violate invariants
77
+
78
+ ### 🌐 Network Layer & Adapters
79
+ \`\`\`typescript
80
+ // Platform-specific sync adapters
81
+ export const WebAdapter = {
82
+ storage: OPFSSQLiteStorage, // Origin Private File System
83
+ transport: WebSocketSync,
84
+ worker: SharedWorker // Cross-tab synchronization
85
+ }
86
+ \`\`\`
87
+
88
+ **Adapter Implementations:**
89
+ - **Web**: OPFS storage, SharedWorker coordination, WebSocket sync
90
+ - **Node**: File system storage, cluster coordination, HTTP/WebSocket
91
+ - **Mobile**: Native SQLite, background sync, push notifications
92
+
93
+ ## Distributed Systems Properties
94
+
95
+ ### CAP Theorem Considerations
96
+ - **Consistency**: Eventually consistent (not strongly consistent)
97
+ - **Availability**: Always available for reads/writes (local-first)
98
+ - **Partition Tolerance**: Continues operation during network partitions
99
+
100
+ *Trade-off: Chooses Availability + Partition Tolerance over strong Consistency*
101
+
102
+ ### ACID Properties (Local Transactions)
103
+ - **Atomicity**: Event application is atomic within SQLite transaction
104
+ - **Consistency**: Materializers maintain data integrity constraints
105
+ - **Isolation**: Concurrent operations isolated via SQLite WAL mode
106
+ - **Durability**: Events persisted to disk before acknowledgment
107
+
108
+ ### Conflict Resolution Strategies
109
+
110
+ 1. **Semantic Conflict Resolution**
111
+ - Application-specific merge logic
112
+ - E.g., text editing uses operational transforms
113
+
114
+ 2. **Last-Write-Wins (LWW)**
115
+ - Timestamps determine winner
116
+ - Simple but can lose data
117
+
118
+ 3. **Multi-Value Registers**
119
+ - Preserve all conflicting values
120
+ - User or application resolves
121
+
122
+ 4. **Commutative Operations**
123
+ - Operations designed to commute
124
+ - E.g., increment/decrement counters
125
+
126
+ ## Performance & Scalability
127
+
128
+ ### Query Performance
129
+ - **Reactive Queries**: Automatically update UI on data changes
130
+ - **Indexed Access**: SQLite B-tree indexes for fast lookups
131
+ - **Prepared Statements**: Query compilation cached for reuse
132
+ - **Batch Operations**: Multiple events applied in single transaction
133
+
134
+ ### Memory Management
135
+ - **Incremental Loading**: Large datasets loaded on-demand
136
+ - **Query Result Caching**: Expensive query results cached
137
+ - **Event Log Compaction**: Periodic snapshotting and log truncation
138
+ - **Connection Pooling**: Database connections reused across operations
139
+
140
+ ### Network Optimization
141
+ - **Delta Synchronization**: Only sync events since last checkpoint
142
+ - **Compression**: Event payloads compressed for network transfer
143
+ - **Batching**: Multiple events transmitted in single round-trip
144
+ - **Exponential Backoff**: Retry failed sync with increasing delays
145
+
146
+ ## Security Model
147
+
148
+ ### Data Integrity
149
+ - **Event Signatures**: Cryptographic signatures prevent tampering
150
+ - **Merkle Trees**: Efficient verification of event log integrity
151
+ - **Schema Validation**: All events validated against defined schemas
152
+
153
+ ### Access Control
154
+ - **Client-Side Authorization**: Fine-grained permissions in local database
155
+ - **Sync Filtering**: Server filters events based on user permissions
156
+ - **Encryption**: End-to-end encryption for sensitive data
157
+
158
+ ## Observability
159
+
160
+ ### Distributed Tracing
161
+ - **Event Causality**: Trace event propagation across replicas
162
+ - **Sync Performance**: Monitor replication lag and throughput
163
+ - **Conflict Metrics**: Track merge conflicts and resolution strategies
164
+
165
+ ### Health Monitoring
166
+ - **Storage Usage**: Local database size and growth rate
167
+ - **Network Health**: Connection quality and sync success rates
168
+ - **Error Tracking**: Failed operations and their root causes
169
+
170
+ This architecture enables applications that work seamlessly offline, sync reliably when online, and provide immediate feedback to users while maintaining data consistency across all replicas.`;
171
+ //# sourceMappingURL=architecture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architecture.js","sourceRoot":"","sources":["../../src/mcp-content/architecture.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gMAyK6J,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const featuresContent = "# LiveStore Features: Production-Ready Local-First Data\n\nLiveStore provides battle-tested primitives for building collaborative, offline-capable applications with the reliability and performance of modern distributed systems.\n\n## \uD83C\uDFE0 Local-First Architecture\n\n### Offline-First Operation\n- **Zero Latency**: All operations execute against local SQLite database\n- **Offline Capable**: Full application functionality without network connectivity\n- **Network Resilient**: Graceful degradation during connectivity issues\n- **Background Sync**: Automatic synchronization when network becomes available\n\n### Immediate Consistency\n- **Optimistic Updates**: UI updates immediately on user action\n- **Rollback on Conflict**: Automatic rollback and retry on merge conflicts\n- **Causal Consistency**: Operations maintain causal ordering across replicas\n\n## \uD83D\uDD04 Event-Driven Synchronization\n\n### Conflict-Free Event Model\n```typescript\n// Events designed for conflict-free merging\nconst events = {\n todoCreated: Events.synced({\n name: 'v1.TodoCreated',\n schema: Schema.Struct({\n id: Schema.String, // Deterministic ordering\n createdAt: Schema.Date, // Timestamp for LWW resolution\n position: Schema.Number // Fractional indexing for reordering\n })\n })\n}\n```\n\n### Sophisticated Merge Strategies\n- **Last-Write-Wins**: Timestamp-based conflict resolution\n- **Semantic Merging**: Application-specific merge logic\n- **Operational Transform**: Real-time collaborative text editing\n- **CRDT Integration**: Conflict-free replicated data types\n\n### Incremental Synchronization\n- **Delta Sync**: Only transmit changes since last synchronization\n- **Vector Clocks**: Efficient causal dependency tracking\n- **Merkle Trees**: Efficient integrity verification\n- **Batch Optimization**: Multiple events in single network round-trip\n\n## \uD83D\uDCCA Reactive Query Engine\n\n### Real-Time Reactivity\n```typescript\n// Queries automatically update when underlying data changes\nconst activeTodos$ = queryDb(\n tables.todos\n .select()\n .where({ completed: false, deletedAt: null })\n .orderBy('position'),\n { label: 'activeTodos' }\n)\n```\n\n### Advanced Query Capabilities\n- **Joins & Aggregations**: Full SQL expressiveness\n- **Reactive Subscriptions**: Automatic UI updates on data changes\n- **Query Optimization**: SQLite query planner with B-tree indexes\n- **Prepared Statements**: Cached query compilation for performance\n\n### Framework Integrations\n- **React**: `useLiveQuery()` hook for reactive components\n- **Vue**: Composables for reactive data binding\n- **Solid**: Reactive primitives integration\n- **Svelte**: Store-based reactive updates\n\n## \uD83D\uDD10 End-to-End Type Safety\n\n### Schema-First Development\n```typescript\n// Type safety from database to UI\nconst todoSchema = State.SQLite.table({\n name: 'todos',\n columns: {\n id: State.SQLite.text({ primaryKey: true }),\n title: State.SQLite.text(),\n completed: State.SQLite.boolean()\n }\n})\n\n// Fully typed queries\ntype Todo = typeof todoSchema.select.Type // { id: string, title: string, completed: boolean }\n```\n\n### Runtime Validation\n- **Schema Validation**: All events validated against Effect schemas\n- **Migration Safety**: Type-safe schema evolution\n- **Parse Don't Validate**: Schema types flow through entire application\n\n## \uD83C\uDF10 Multi-Platform Support\n\n### Web Platform\n- **Origin Private File System**: Persistent storage in modern browsers\n- **SharedWorker**: Cross-tab synchronization and resource sharing\n- **IndexedDB Fallback**: Compatibility with older browsers\n- **Service Worker**: Background synchronization\n\n### Node.js Platform\n- **File System Storage**: Native SQLite database files\n- **Cluster Coordination**: Multi-process synchronization\n- **HTTP/WebSocket Sync**: Flexible transport protocols\n- **Background Jobs**: Scheduled synchronization tasks\n\n### Mobile Platforms (Expo/React Native)\n- **Native SQLite**: Platform-optimized database performance\n- **Background Sync**: Synchronization during app backgrounding\n- **Push Notifications**: Real-time update notifications\n- **Secure Storage**: Encrypted local data storage\n\n## \uD83D\uDE80 Performance & Scalability\n\n### Query Performance\n- **Sub-millisecond Queries**: Local SQLite performance\n- **Efficient Indexing**: Automatic index recommendations\n- **Result Set Streaming**: Large datasets loaded incrementally\n- **Query Result Caching**: Expensive computations cached\n\n### Memory Management\n- **Lazy Loading**: Data loaded on-demand\n- **Connection Pooling**: Database connections efficiently reused\n- **Event Log Compaction**: Periodic snapshots prevent unbounded growth\n- **Garbage Collection**: Automatic cleanup of obsolete data\n\n### Network Optimization\n- **Compression**: Event payloads compressed for transmission\n- **Request Batching**: Multiple operations in single request\n- **Connection Pooling**: HTTP/WebSocket connections reused\n- **Exponential Backoff**: Intelligent retry strategies\n\n## \uD83C\uDFD7\uFE0F Developer Experience\n\n### Testing & Debugging\n```typescript\n// Built-in testing utilities\nconst testStore = createTestStore(schema)\n\n// Deterministic event replay for testing\nawait testStore.replay([\n events.todoCreated({ id: '1', title: 'Test todo' }),\n events.todoCompleted({ id: '1' })\n])\n```\n\n### Developer Tools\n- **Event Inspector**: Real-time event log visualization\n- **Query Profiler**: Performance analysis for slow queries \n- **Sync Monitor**: Network synchronization health dashboard\n- **Schema Explorer**: Interactive database schema browsing\n\n### Production Monitoring\n- **Distributed Tracing**: Event propagation across replicas\n- **Performance Metrics**: Query latency and throughput monitoring\n- **Error Tracking**: Comprehensive error reporting and alerting\n- **Health Checks**: Automated system health verification\n\n## \uD83D\uDD12 Security & Privacy\n\n### Data Protection\n- **End-to-End Encryption**: Client-side encryption before transmission\n- **Event Signatures**: Cryptographic integrity verification\n- **Access Control**: Fine-grained permission system\n- **Audit Logging**: Comprehensive security event logging\n\n### Privacy by Design\n- **Local Data Control**: Users maintain complete data ownership\n- **Selective Sync**: Fine-grained control over data sharing\n- **Data Minimization**: Only sync necessary data\n- **GDPR Compliance**: Built-in privacy compliance features\n\nLiveStore 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.";
2
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/mcp-content/features.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,grNA+KuN,CAAA"}