tidewave 0.3.0 → 0.5.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 +178 -93
- package/dist/cli/index.js +12019 -11664
- package/dist/core.d.ts +5 -0
- package/dist/evaluation/eval_worker.js +1 -30
- package/dist/index.d.ts +2 -2
- package/dist/logger/circular-buffer.d.ts +54 -0
- package/dist/logger/instrumentation.d.ts +2 -0
- package/dist/logger/tidewave-log-record-processor.d.ts +17 -0
- package/dist/logger/tidewave-span-processor.d.ts +26 -0
- package/dist/{next-js.d.ts → next-js/handler.d.ts} +2 -6
- package/dist/{http/index.js → next-js/handler.js} +33003 -32394
- package/dist/next-js/instrumentation.d.ts +7 -0
- package/dist/next-js/instrumentation.js +255 -0
- package/dist/tools.d.ts +18 -0
- package/dist/vite-plugin.d.ts +1 -0
- package/dist/vite-plugin.js +32264 -31750
- package/package.json +24 -9
- package/dist/core.js +0 -64
- package/dist/evaluation/code_executor.js +0 -104
- package/dist/http/security.js +0 -132
- package/dist/index.js +0 -906
- package/dist/mcp.js +0 -14174
- package/dist/next-js.js +0 -40304
- package/dist/resolution/formatters.js +0 -155
- package/dist/resolution/index.js +0 -829
- package/dist/resolution/module-resolver.js +0 -166
- package/dist/resolution/symbol-finder.js +0 -429
- package/dist/resolution/utils.js +0 -112
- package/dist/tools.js +0 -4099
package/README.md
CHANGED
|
@@ -1,129 +1,222 @@
|
|
|
1
1
|
# Tidewave
|
|
2
2
|
|
|
3
|
+
> Tidewave Web for Next.js and React+Vite 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
If you are using Next.js or you have a React + Vite frontend, talking either to
|
|
9
|
+
a backend as a service (such as Supabase) or a third-party framework, you are in
|
|
10
|
+
the right place!
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
If you are using React with Django, FastAPI, Flask, Phoenix, or Rails,
|
|
13
|
+
[follow the steps here instead](http://hexdocs.pm/tidewave/react.html).
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
This project can also be used through the CLI or as a standalone Model Context
|
|
16
|
+
Protocol (MCP) server for your editors.
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
documentation, type annotations, and source file locations of the packages being
|
|
16
|
-
currently used by your project, without relying on external systems.
|
|
18
|
+
## Installation
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
`package.json` as a STDIO MCP Server:
|
|
20
|
+
### Next.js
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
npx tidewave mcp
|
|
23
|
-
# or with Bun
|
|
24
|
-
bunx tidewave mcp
|
|
25
|
-
# or with Deno
|
|
26
|
-
deno run npm:tidewave mcp
|
|
27
|
-
```
|
|
22
|
+
If you are using Next.js, install Tidewave with:
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
```sh
|
|
25
|
+
$ npm install -D tidewave
|
|
26
|
+
# or
|
|
27
|
+
$ yarn add -D tidewave
|
|
28
|
+
# or
|
|
29
|
+
$ pnpm add --save-dev tidewave
|
|
30
|
+
# or
|
|
31
|
+
$ bun add --dev tidewave
|
|
32
|
+
```
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
development environments. Add the plugin to your `vite.config.js`:
|
|
34
|
+
Then create `pages/api/tidewave.ts` with:
|
|
37
35
|
|
|
38
|
-
```
|
|
39
|
-
import {
|
|
40
|
-
|
|
36
|
+
```typescript
|
|
37
|
+
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
38
|
+
|
|
39
|
+
export default async function handler(
|
|
40
|
+
req: NextApiRequest,
|
|
41
|
+
res: NextApiResponse,
|
|
42
|
+
) {
|
|
43
|
+
if (process.env.NODE_ENV === 'development') {
|
|
44
|
+
const { tidewaveHandler } = await import('tidewave/next-js/handler');
|
|
45
|
+
const handler = await tidewaveHandler();
|
|
46
|
+
return handler(req, res);
|
|
47
|
+
} else {
|
|
48
|
+
res.status(404).end();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
41
51
|
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
export const config = {
|
|
53
|
+
runtime: 'nodejs',
|
|
54
|
+
api: {
|
|
55
|
+
bodyParser: false, // Tidewave already parses the body internally
|
|
56
|
+
},
|
|
57
|
+
};
|
|
45
58
|
```
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
_Note: this uses the **Pages Router**, however it works regardless of the router
|
|
61
|
+
type you use in your application._
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
If you are using Next.js 16+, then create (or modify) `proxy.ts` with:
|
|
51
64
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
allowRemoteAccess: false, // Allow access from remote IPs
|
|
55
|
-
allowedOrigins: ['localhost'], // Allowed origins: defaults to the Vite's host+port
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### HTTP MCP via Next.js Integration
|
|
65
|
+
```typescript
|
|
66
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
export function proxy(req: NextRequest): NextResponse {
|
|
69
|
+
if (req.nextUrl.pathname.startsWith('/tidewave')) {
|
|
70
|
+
return NextResponse.rewrite(new URL('/api/tidewave', req.url));
|
|
71
|
+
}
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
// Here you could add your own logic or different middlewares.
|
|
74
|
+
return NextResponse.next();
|
|
75
|
+
}
|
|
76
|
+
```
|
|
67
77
|
|
|
68
|
-
|
|
78
|
+
For Next.js 15+ and earlier, create (or modify) `middleware.ts` with:
|
|
69
79
|
|
|
70
80
|
```typescript
|
|
71
|
-
import {
|
|
81
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
72
82
|
|
|
73
|
-
export
|
|
83
|
+
export function middleware(req: NextRequest): NextResponse {
|
|
84
|
+
if (req.nextUrl.pathname.startsWith('/tidewave')) {
|
|
85
|
+
return NextResponse.rewrite(new URL('/api/tidewave', req.url));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Here you could add your own logic or different middlewares.
|
|
89
|
+
return NextResponse.next();
|
|
90
|
+
}
|
|
74
91
|
|
|
75
|
-
// Next.js specific config
|
|
76
92
|
export const config = {
|
|
77
|
-
|
|
78
|
-
api: {
|
|
79
|
-
bodyParser: false, // tidewave already parses the body internally
|
|
80
|
-
},
|
|
93
|
+
matcher: ['/tidewave/:path*'],
|
|
81
94
|
};
|
|
82
95
|
```
|
|
83
96
|
|
|
84
|
-
|
|
97
|
+
Finally, we expose your application's spans, events, and logs to Tidewave MCP.
|
|
98
|
+
First install the NodeSDK:
|
|
85
99
|
|
|
86
|
-
|
|
100
|
+
```sh
|
|
101
|
+
npm install @opentelemetry/sdk-node
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
And then create (or modify) a custom `instrumentation.ts` file in the root
|
|
105
|
+
directory of the project (or inside `src` folder if using one):
|
|
87
106
|
|
|
88
107
|
```typescript
|
|
89
|
-
|
|
108
|
+
// instrumentation.ts
|
|
109
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
110
|
+
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
111
|
+
import type { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
112
|
+
|
|
113
|
+
export async function register() {
|
|
114
|
+
const runtime = process.env.NEXT_RUNTIME;
|
|
115
|
+
const env = process.env.NODE_ENV;
|
|
116
|
+
|
|
117
|
+
// Add your app own processes here existing configuration
|
|
118
|
+
const sdkConfig: {
|
|
119
|
+
spanProcessors: SpanProcessor[];
|
|
120
|
+
logRecordProcessors: LogRecordProcessor[];
|
|
121
|
+
} = {
|
|
122
|
+
spanProcessors: [],
|
|
123
|
+
logRecordProcessors: [],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// Conditionally add Tidewave processors in development
|
|
127
|
+
if (runtime === 'nodejs' && env === 'development') {
|
|
128
|
+
const { TidewaveSpanProcessor, TidewaveLogRecordProcessor } = await import(
|
|
129
|
+
'tidewave/next-js/instrumentation'
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
sdkConfig.spanProcessors.push(new TidewaveSpanProcessor());
|
|
133
|
+
sdkConfig.logRecordProcessors.push(new TidewaveLogRecordProcessor());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const sdk = new NodeSDK(sdkConfig);
|
|
137
|
+
sdk.start();
|
|
138
|
+
}
|
|
139
|
+
```
|
|
90
140
|
|
|
91
|
-
|
|
141
|
+
Now make sure
|
|
142
|
+
[Tidewave is installed](https://hexdocs.pm/tidewave/installation.html) and you
|
|
143
|
+
are ready to connect Tidewave to your app.
|
|
92
144
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
145
|
+
### React + Vite
|
|
146
|
+
|
|
147
|
+
If you are building a front-end application, using a backend as a service, such
|
|
148
|
+
as Supabase, or a non-officially supported web framework, we recommend using our
|
|
149
|
+
React + Vite integration.
|
|
150
|
+
|
|
151
|
+
Install it with:
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
$ npm install -D tidewave
|
|
155
|
+
# or
|
|
156
|
+
$ yarn add -D tidewave
|
|
157
|
+
# or
|
|
158
|
+
$ pnpm add --save-dev tidewave
|
|
159
|
+
# or
|
|
160
|
+
$ bun add --dev tidewave
|
|
96
161
|
```
|
|
97
162
|
|
|
98
|
-
|
|
163
|
+
Then configure your `vite.config.js` (also works for `.ts` and `.mjs`):
|
|
99
164
|
|
|
100
|
-
```
|
|
101
|
-
import {
|
|
102
|
-
|
|
103
|
-
const withTidewave = tidewaveMiddleware();
|
|
104
|
-
|
|
105
|
-
export function middleware(req: NextRequest): Promise<NextResponse> {
|
|
106
|
-
// This will return a unchanged NextResponse.next()
|
|
107
|
-
// if path doesn't match with `/tidewave`
|
|
108
|
-
// if does match it will rewrite to `/api/tidewave` instead
|
|
109
|
-
withTidewave(req, (req: NextRequest) => {
|
|
110
|
-
// your own logic
|
|
111
|
-
return NextResponse.json({ message: 'hello, world!' });
|
|
112
|
-
});
|
|
113
|
-
}
|
|
165
|
+
```javascript
|
|
166
|
+
import { defineConfig } from 'vite';
|
|
167
|
+
import tidewave from 'tidewave/vite-plugin';
|
|
114
168
|
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
169
|
+
export default defineConfig({
|
|
170
|
+
plugins: [tidewave()],
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Now make sure
|
|
175
|
+
[Tidewave is installed](https://hexdocs.pm/tidewave/installation.html) and you
|
|
176
|
+
are ready to connect Tidewave to your app.
|
|
177
|
+
|
|
178
|
+
If you are using Supabase or similar, you can prompt Tidewave to use the
|
|
179
|
+
`supabase` CLI so it has complete access to your database. For non-officially
|
|
180
|
+
supported web frameworks, our React + Vite integration allows Tidewave Web to
|
|
181
|
+
perform changes on the front-end, and the agent will be able to modify your
|
|
182
|
+
backend code as usual, but some functionality (such as accessing logs, doing
|
|
183
|
+
database calls, etc) won't be available.
|
|
184
|
+
|
|
185
|
+
### Configuration
|
|
186
|
+
|
|
187
|
+
Next.js' `tidewaveHandler` and Vite's `tidewave` accept the configuration
|
|
188
|
+
options below:
|
|
189
|
+
|
|
190
|
+
- `allow_remote_access:` allow remote connections when true (default false)
|
|
191
|
+
- `allowed_origins:` defaults to the current host/port
|
|
192
|
+
- `team`: enable Tidewave Web for teams
|
|
193
|
+
|
|
194
|
+
## CLI
|
|
195
|
+
|
|
196
|
+
Tidewave.js also comes with a CLI for developers who want to use it as a
|
|
197
|
+
standalone MCP or query its functionality directly. Note this functionality is
|
|
198
|
+
separate from Tidewave Web.
|
|
199
|
+
|
|
200
|
+
### STDIO MCP
|
|
201
|
+
|
|
202
|
+
Configure your editor to run `tidewave` in the same directory as your
|
|
203
|
+
`package.json` as a STDIO MCP Server:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npx tidewave mcp
|
|
207
|
+
# or with Bun
|
|
208
|
+
bunx tidewave mcp
|
|
209
|
+
# or with Deno
|
|
210
|
+
deno run npm:tidewave mcp
|
|
121
211
|
```
|
|
122
212
|
|
|
123
|
-
|
|
213
|
+
Available options:
|
|
214
|
+
|
|
215
|
+
- `--prefix path` - Specify the directory to find the `package.json` file
|
|
216
|
+
|
|
217
|
+
### Get docs / get source
|
|
124
218
|
|
|
125
|
-
|
|
126
|
-
npx/bunx/deno:
|
|
219
|
+
Fetch docs or retrieve the source location for classes, types, methods, etc:
|
|
127
220
|
|
|
128
221
|
```bash
|
|
129
222
|
# Extract documentation for a symbol
|
|
@@ -149,14 +242,6 @@ npx tidewave source ./src/utils:formatDate
|
|
|
149
242
|
npx tidewave source typescript:createProgram
|
|
150
243
|
```
|
|
151
244
|
|
|
152
|
-
### Runtime Support
|
|
153
|
-
|
|
154
|
-
Tidewave JavaScript supports multiple JavaScript runtimes:
|
|
155
|
-
|
|
156
|
-
- **Node.js** - Full support with npm/npx
|
|
157
|
-
- **Bun** - Native support with bunx
|
|
158
|
-
- **Deno** - Support via npm: protocol
|
|
159
|
-
|
|
160
245
|
## Contributing
|
|
161
246
|
|
|
162
247
|
```bash
|