tidewave 0.2.4 → 0.4.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/README.md CHANGED
@@ -1,39 +1,130 @@
1
1
  # Tidewave
2
2
 
3
+ > Tidewave Web for Next.js is currently in alpha testing!
4
+
3
5
  Tidewave is the coding agent for full-stack web app development.
4
6
  [See our website](https://tidewave.ai) for more information.
5
7
 
6
- Our current release connects your editor's assistant to your web framework
7
- runtime via [MCP](https://modelcontextprotocol.io/). Support for Tidewave Web
8
- will come in future releases.
8
+ This package is recommended for JavaScript-powered backends as well as
9
+ JavaScript libraries/applications using a backend as a service (such as
10
+ Supabase). If you are using React with Phoenix, Rails, Django, or another
11
+ server-side framework, [follow the steps here instead](http://hexdocs.pm/tidewave/react.html).
9
12
 
10
- ## Usage
13
+ This project can also be used as a standalone Model Context Protocol (MCP)
14
+ server for your editors.
11
15
 
12
- ### Standalone MCP
16
+ ## Installation
13
17
 
14
- Tidewave's MCP server gives your editor and coding agents access to the
15
- documentation, type annotations, and source file locations of the packages being
16
- currently used by your project, without relying on external systems.
18
+ ### Next.js
17
19
 
18
- Simply configure your editor to run `tidewave` in the same directory as your
19
- `package.json` as a STDIO MCP Server:
20
+ Install it with:
20
21
 
21
- ```bash
22
- npx tidewave mcp
23
- # or with Bun
24
- bunx tidewave mcp
25
- # or with Deno
26
- deno run npm:tidewave mcp
22
+ ```sh
23
+ $ npm install -D tidewave
24
+ # or
25
+ $ yarn add -D tidewave
26
+ # or
27
+ $ pnpm add --save-dev tidewave
28
+ # or
29
+ $ bun add --dev tidewave
27
30
  ```
28
31
 
29
- Available MCP options:
32
+ Then create `pages/api/tidewave.ts` with:
33
+
34
+ ```typescript
35
+ import type { NextApiRequest, NextApiResponse } from 'next';
36
+
37
+ export default async function handler(
38
+ req: NextApiRequest,
39
+ res: NextApiResponse,
40
+ ) {
41
+ if (process.env.NODE_ENV === 'development') {
42
+ const { tidewaveHandler } = await import('tidewave/next-js');
43
+ const handler = await tidewaveHandler();
44
+ return handler(req, res);
45
+ } else {
46
+ res.status(404).end();
47
+ }
48
+ }
49
+
50
+ export const config = {
51
+ runtime: 'nodejs',
52
+ api: {
53
+ bodyParser: false, // Tidewave already parses the body internally
54
+ },
55
+ };
56
+ ```
30
57
 
31
- - `--prefix path` - Specify the directory to find the `package.json` file
58
+ _Note: this uses the **Pages Router**, however it works regardless of the router
59
+ type you use in your application._
60
+
61
+ Then create (or modify) `middleware.ts` with:
32
62
 
33
- ### HTTP MCP via Vite Plugin
63
+ ```typescript
64
+ import { NextRequest, NextResponse } from 'next/server';
65
+
66
+ export function middleware(req: NextRequest): NextResponse {
67
+ if (req.nextUrl.pathname.startsWith('/tidewave')) {
68
+ return NextResponse.rewrite(new URL(`/api/tidewave`, req.url));
69
+ }
70
+
71
+ // Here you could add your own logic or different middlewares.
72
+ return NextResponse.next();
73
+ }
74
+
75
+ export const config = {
76
+ matcher: ['/tidewave/:path*'],
77
+ };
78
+ ```
79
+
80
+ Finally, we recommend creating the `instrumentation.ts` file below,
81
+ to expose your application's spans, events, and logs to Tidewave/MCP:
82
+
83
+ ```typescript
84
+ // instrumentation.ts
85
+ import { NodeSDK } from '@opentelemetry/sdk-node';
86
+ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';
87
+
88
+ export async function register() {
89
+ const runtime = process.env.NEXT_RUNTIME;
90
+ const env = process.env.NODE_ENV;
91
+
92
+ // Add your app own processes here existing configuration
93
+ const sdkConfig = {
94
+ spanProcessors: [],
95
+ logRecordProcessors: [],
96
+ };
97
+
98
+ // Conditionally add Tidewave processors in development
99
+ if (runtime === 'nodejs' && env === 'development') {
100
+ const { TidewaveSpanProcessor, TidewaveLogRecordProcessor } = await import(
101
+ 'tidewave/next-js/instrumentation'
102
+ );
103
+
104
+ sdkConfig.spanProcessors.push(new TidewaveSpanProcessor());
105
+ sdkConfig.logRecordProcessors.push(new TidewaveLogRecordProcessor());
106
+ }
107
+
108
+ const sdk = new NodeSDK(sdkConfig);
109
+ sdk.start();
110
+ }
111
+ ```
112
+
113
+ ### React + Vite
114
+
115
+ Install it with:
116
+
117
+ ```sh
118
+ $ npm install -D tidewave
119
+ # or
120
+ $ yarn add -D tidewave
121
+ # or
122
+ $ pnpm add --save-dev tidewave
123
+ # or
124
+ $ bun add --dev tidewave
125
+ ```
34
126
 
35
- Tidewave also provides HTTP-based MCP access through a Vite plugin for
36
- development environments. Add the plugin to your `vite.config.js`:
127
+ Then configure your `vite.config.js` (also works for `.ts` and `.mjs`):
37
128
 
38
129
  ```javascript
39
130
  import { defineConfig } from 'vite';
@@ -44,22 +135,40 @@ export default defineConfig({
44
135
  });
45
136
  ```
46
137
 
47
- This exposes MCP endpoints at `/tidewave/mcp` and `/tidewave/shell` during
48
- development.
138
+ ### Configuration
49
139
 
50
- Configuration options:
140
+ Next.js' `tidewaveHandler` and Vite's `tidewave` accept the configuration options below:
51
141
 
52
- ```javascript
53
- tidewave({
54
- allowRemoteAccess: false, // Allow access from remote IPs
55
- allowedOrigins: ['localhost'], // Allowed origins: defaults to the Vite's host+port
56
- });
142
+ - `allow_remote_access:` allow remote connections when true (default false)
143
+ - `allowed_origins:` defaults to the current host/port
144
+ - `team`: enable Tidewave Web for teams
145
+
146
+ ## CLI
147
+
148
+ Tidewave.js also comes with a CLI for developers who want to use it
149
+ as a standalone MCP or query its functionality directly. Note this
150
+ functionality is separate from Tidewave Web.
151
+
152
+ ### STDIO MCP
153
+
154
+ Configure your editor to run `tidewave` in the same directory as your
155
+ `package.json` as a STDIO MCP Server:
156
+
157
+ ```bash
158
+ npx tidewave mcp
159
+ # or with Bun
160
+ bunx tidewave mcp
161
+ # or with Deno
162
+ deno run npm:tidewave mcp
57
163
  ```
58
164
 
59
- ### CLI Usage
165
+ Available options:
166
+
167
+ - `--prefix path` - Specify the directory to find the `package.json` file
168
+
169
+ ### Get docs / get source
60
170
 
61
- Tidewave also provides the MCP features over a CLI tool. Use it directly via
62
- npx/bunx/deno:
171
+ Fetch docs or retrieve the source location for classes, types, methods, etc:
63
172
 
64
173
  ```bash
65
174
  # Extract documentation for a symbol
@@ -85,14 +194,6 @@ npx tidewave source ./src/utils:formatDate
85
194
  npx tidewave source typescript:createProgram
86
195
  ```
87
196
 
88
- ### Runtime Support
89
-
90
- Tidewave JavaScript supports multiple JavaScript runtimes:
91
-
92
- - **Node.js** - Full support with npm/npx
93
- - **Bun** - Native support with bunx
94
- - **Deno** - Support via npm: protocol
95
-
96
197
  ## Contributing
97
198
 
98
199
  ```bash