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 +141 -40
- package/dist/cli/index.js +11938 -11560
- package/dist/core.d.ts +11 -0
- package/dist/evaluation/eval_worker.js +1 -1
- package/dist/http/index.d.ts +3 -6
- package/dist/http/security.d.ts +2 -1
- 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/handler.d.ts +11 -0
- package/dist/{http/index.js → next-js/handler.js} +32978 -32329
- 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 +2 -1
- package/dist/vite-plugin.js +32924 -32366
- package/package.json +28 -5
- package/dist/core.js +0 -64
- package/dist/evaluation/code_executor.js +0 -81
- package/dist/http/security.js +0 -120
- package/dist/index.js +0 -883
- package/dist/mcp.js +0 -14151
- 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,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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
development.
|
|
138
|
+
### Configuration
|
|
49
139
|
|
|
50
|
-
|
|
140
|
+
Next.js' `tidewaveHandler` and Vite's `tidewave` accept the configuration options below:
|
|
51
141
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|