tidewave 0.3.0 → 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 +131 -94
- package/dist/cli/index.js +12024 -11669
- 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 +32255 -31741
- package/package.json +22 -7
- 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,174 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
+
This project can also be used as a standalone Model Context Protocol (MCP)
|
|
14
|
+
server for your editors.
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
## Installation
|
|
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
|
+
### Next.js
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
`package.json` as a STDIO MCP Server:
|
|
20
|
+
Install it with:
|
|
20
21
|
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
# or
|
|
24
|
-
|
|
25
|
-
# or
|
|
26
|
-
|
|
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
|
-
|
|
32
|
+
Then create `pages/api/tidewave.ts` with:
|
|
30
33
|
|
|
31
|
-
|
|
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
|
+
}
|
|
32
49
|
|
|
33
|
-
|
|
50
|
+
export const config = {
|
|
51
|
+
runtime: 'nodejs',
|
|
52
|
+
api: {
|
|
53
|
+
bodyParser: false, // Tidewave already parses the body internally
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
```
|
|
34
57
|
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
_Note: this uses the **Pages Router**, however it works regardless of the router
|
|
59
|
+
type you use in your application._
|
|
37
60
|
|
|
38
|
-
|
|
39
|
-
import { defineConfig } from 'vite';
|
|
40
|
-
import tidewave from 'tidewave/vite-plugin';
|
|
61
|
+
Then create (or modify) `middleware.ts` with:
|
|
41
62
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
```
|
|
63
|
+
```typescript
|
|
64
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
}
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
// Here you could add your own logic or different middlewares.
|
|
72
|
+
return NextResponse.next();
|
|
73
|
+
}
|
|
51
74
|
|
|
52
|
-
|
|
53
|
-
tidewave
|
|
54
|
-
|
|
55
|
-
allowedOrigins: ['localhost'], // Allowed origins: defaults to the Vite's host+port
|
|
56
|
-
});
|
|
75
|
+
export const config = {
|
|
76
|
+
matcher: ['/tidewave/:path*'],
|
|
77
|
+
};
|
|
57
78
|
```
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
Finally, we recommend creating the `instrumentation.ts` file below,
|
|
81
|
+
to expose your application's spans, events, and logs to Tidewave/MCP:
|
|
60
82
|
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
```
|
|
63
112
|
|
|
64
|
-
|
|
65
|
-
> mode `NODE_ENV === 'development'` if the validation fails, an Error will be
|
|
66
|
-
> thrown
|
|
113
|
+
### React + Vite
|
|
67
114
|
|
|
68
|
-
|
|
115
|
+
Install it with:
|
|
69
116
|
|
|
70
|
-
```
|
|
71
|
-
|
|
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
|
+
```
|
|
72
126
|
|
|
73
|
-
|
|
127
|
+
Then configure your `vite.config.js` (also works for `.ts` and `.mjs`):
|
|
74
128
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
129
|
+
```javascript
|
|
130
|
+
import { defineConfig } from 'vite';
|
|
131
|
+
import tidewave from 'tidewave/vite-plugin';
|
|
132
|
+
|
|
133
|
+
export default defineConfig({
|
|
134
|
+
plugins: [tidewave()],
|
|
135
|
+
});
|
|
82
136
|
```
|
|
83
137
|
|
|
84
|
-
|
|
138
|
+
### Configuration
|
|
85
139
|
|
|
86
|
-
|
|
140
|
+
Next.js' `tidewaveHandler` and Vite's `tidewave` accept the configuration options below:
|
|
87
141
|
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
90
145
|
|
|
91
|
-
|
|
146
|
+
## CLI
|
|
92
147
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```
|
|
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.
|
|
97
151
|
|
|
98
|
-
|
|
152
|
+
### STDIO MCP
|
|
99
153
|
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
}
|
|
154
|
+
Configure your editor to run `tidewave` in the same directory as your
|
|
155
|
+
`package.json` as a STDIO MCP Server:
|
|
114
156
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
```bash
|
|
158
|
+
npx tidewave mcp
|
|
159
|
+
# or with Bun
|
|
160
|
+
bunx tidewave mcp
|
|
161
|
+
# or with Deno
|
|
162
|
+
deno run npm:tidewave mcp
|
|
121
163
|
```
|
|
122
164
|
|
|
123
|
-
|
|
165
|
+
Available options:
|
|
166
|
+
|
|
167
|
+
- `--prefix path` - Specify the directory to find the `package.json` file
|
|
168
|
+
|
|
169
|
+
### Get docs / get source
|
|
124
170
|
|
|
125
|
-
|
|
126
|
-
npx/bunx/deno:
|
|
171
|
+
Fetch docs or retrieve the source location for classes, types, methods, etc:
|
|
127
172
|
|
|
128
173
|
```bash
|
|
129
174
|
# Extract documentation for a symbol
|
|
@@ -149,14 +194,6 @@ npx tidewave source ./src/utils:formatDate
|
|
|
149
194
|
npx tidewave source typescript:createProgram
|
|
150
195
|
```
|
|
151
196
|
|
|
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
197
|
## Contributing
|
|
161
198
|
|
|
162
199
|
```bash
|