@macroforge/mcp-server 0.1.33 → 0.1.34
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 +68 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/docs-loader.d.ts +133 -5
- package/dist/tools/docs-loader.d.ts.map +1 -1
- package/dist/tools/docs-loader.js +131 -15
- package/dist/tools/docs-loader.js.map +1 -1
- package/dist/tools/index.d.ts +48 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +163 -14
- package/dist/tools/index.js.map +1 -1
- package/docs/api/api-overview.md +24 -46
- package/docs/api/expand-sync.md +24 -51
- package/docs/api/native-plugin.md +24 -56
- package/docs/api/position-mapper.md +34 -76
- package/docs/api/transform-sync.md +27 -59
- package/docs/builtin-macros/clone.md +150 -68
- package/docs/builtin-macros/debug.md +216 -81
- package/docs/builtin-macros/default.md +234 -91
- package/docs/builtin-macros/deserialize.md +891 -166
- package/docs/builtin-macros/hash.md +238 -82
- package/docs/builtin-macros/macros-overview.md +42 -103
- package/docs/builtin-macros/ord.md +205 -92
- package/docs/builtin-macros/partial-eq.md +178 -97
- package/docs/builtin-macros/partial-ord.md +209 -98
- package/docs/builtin-macros/serialize.md +326 -137
- package/docs/concepts/architecture.md +40 -99
- package/docs/concepts/derive-system.md +132 -125
- package/docs/concepts/how-macros-work.md +52 -84
- package/docs/custom-macros/custom-overview.md +17 -39
- package/docs/custom-macros/rust-setup.md +22 -55
- package/docs/custom-macros/ts-macro-derive.md +43 -107
- package/docs/custom-macros/ts-quote.md +177 -507
- package/docs/getting-started/first-macro.md +108 -33
- package/docs/getting-started/installation.md +32 -73
- package/docs/integration/cli.md +70 -156
- package/docs/integration/configuration.md +32 -75
- package/docs/integration/integration-overview.md +16 -55
- package/docs/integration/mcp-server.md +30 -69
- package/docs/integration/svelte-preprocessor.md +60 -83
- package/docs/integration/typescript-plugin.md +32 -74
- package/docs/integration/vite-plugin.md +30 -79
- package/docs/language-servers/ls-overview.md +22 -46
- package/docs/language-servers/svelte.md +30 -69
- package/docs/language-servers/zed.md +34 -72
- package/docs/roadmap/roadmap.md +54 -130
- package/docs/sections.json +3 -262
- package/package.json +2 -2
|
@@ -1,51 +1,138 @@
|
|
|
1
1
|
# Debug
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
*The `Debug` macro generates a human-readable `toString()` method for TypeScript classes, interfaces, enums, and type aliases.*
|
|
3
|
+
## Basic Usage
|
|
4
|
+
**Before:**
|
|
5
|
+
```
|
|
6
|
+
/** @derive(Debug) */
|
|
7
|
+
class User {
|
|
8
|
+
name: string;
|
|
9
|
+
age: number;
|
|
10
|
+
|
|
11
|
+
constructor(name: string, age: number) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
this.age = age;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
**After:**
|
|
18
|
+
```
|
|
19
|
+
class User {
|
|
20
|
+
name: string;
|
|
21
|
+
age: number;
|
|
22
|
+
|
|
23
|
+
constructor(name: string, age: number) {
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.age = age;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString(): string {
|
|
29
|
+
const parts: string[] = [];
|
|
30
|
+
parts.push('name: ' + this.name);
|
|
31
|
+
parts.push('age: ' + this.age);
|
|
32
|
+
return 'User { ' + parts.join(', ') + ' }';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
``` ```
|
|
10
36
|
const user = new User("Alice", 30);
|
|
11
37
|
console.log(user.toString());
|
|
12
38
|
// Output: User { name: Alice, age: 30 }
|
|
39
|
+
``` ## Field Options
|
|
40
|
+
Use the `@debug` field decorator to customize behavior:
|
|
41
|
+
### Renaming Fields
|
|
42
|
+
**Before:**
|
|
13
43
|
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
44
|
+
/** @derive(Debug) */
|
|
45
|
+
class User {
|
|
46
|
+
/** @debug({ rename: "userId" }) */
|
|
47
|
+
id: number;
|
|
48
|
+
|
|
49
|
+
name: string;
|
|
50
|
+
|
|
51
|
+
constructor(id: number, name: string) {
|
|
52
|
+
this.id = id;
|
|
53
|
+
this.name = name;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
**After:**
|
|
58
|
+
```
|
|
59
|
+
class User {
|
|
60
|
+
id: number;
|
|
61
|
+
|
|
62
|
+
name: string;
|
|
63
|
+
|
|
64
|
+
constructor(id: number, name: string) {
|
|
65
|
+
this.id = id;
|
|
66
|
+
this.name = name;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toString(): string {
|
|
70
|
+
const parts: string[] = [];
|
|
71
|
+
parts.push('userId: ' + this.id);
|
|
72
|
+
parts.push('name: ' + this.name);
|
|
73
|
+
return 'User { ' + parts.join(', ') + ' }';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
``` ```
|
|
24
77
|
const user = new User(42, "Alice");
|
|
25
78
|
console.log(user.toString());
|
|
26
79
|
// Output: User { userId: 42, name: Alice }
|
|
80
|
+
``` ### Skipping Fields
|
|
81
|
+
Use `skip: true` to exclude sensitive fields from the output:
|
|
82
|
+
**Before:**
|
|
27
83
|
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
84
|
+
/** @derive(Debug) */
|
|
85
|
+
class User {
|
|
86
|
+
name: string;
|
|
87
|
+
email: string;
|
|
88
|
+
|
|
89
|
+
/** @debug({ skip: true }) */
|
|
90
|
+
password: string;
|
|
91
|
+
|
|
92
|
+
/** @debug({ skip: true }) */
|
|
93
|
+
authToken: string;
|
|
94
|
+
|
|
95
|
+
constructor(name: string, email: string, password: string, authToken: string) {
|
|
96
|
+
this.name = name;
|
|
97
|
+
this.email = email;
|
|
98
|
+
this.password = password;
|
|
99
|
+
this.authToken = authToken;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
**After:**
|
|
104
|
+
```
|
|
105
|
+
class User {
|
|
106
|
+
name: string;
|
|
107
|
+
email: string;
|
|
108
|
+
|
|
109
|
+
password: string;
|
|
110
|
+
|
|
111
|
+
authToken: string;
|
|
112
|
+
|
|
113
|
+
constructor(name: string, email: string, password: string, authToken: string) {
|
|
114
|
+
this.name = name;
|
|
115
|
+
this.email = email;
|
|
116
|
+
this.password = password;
|
|
117
|
+
this.authToken = authToken;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
toString(): string {
|
|
121
|
+
const parts: string[] = [];
|
|
122
|
+
parts.push('name: ' + this.name);
|
|
123
|
+
parts.push('email: ' + this.email);
|
|
124
|
+
return 'User { ' + parts.join(', ') + ' }';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
``` ```
|
|
36
128
|
const user = new User("Alice", "alice@example.com", "secret", "tok_xxx");
|
|
37
129
|
console.log(user.toString());
|
|
38
130
|
// Output: User { name: Alice, email: alice@example.com }
|
|
39
131
|
// Note: password and authToken are not included
|
|
132
|
+
``` **Security Always skip sensitive fields like passwords, tokens, and API keys to prevent accidental logging. ## Combining Options
|
|
133
|
+
****Source:**
|
|
40
134
|
```
|
|
41
|
-
|
|
42
|
-
<Alert type="tip" title="Security">
|
|
43
|
-
Always skip sensitive fields like passwords, tokens, and API keys to prevent accidental logging.
|
|
44
|
-
</Alert>
|
|
45
|
-
|
|
46
|
-
## Combining Options
|
|
47
|
-
|
|
48
|
-
<InteractiveMacro code={`/** @derive(Debug) */
|
|
135
|
+
/** @derive(Debug) */
|
|
49
136
|
class ApiResponse {
|
|
50
137
|
/** @debug({ rename: "statusCode" }) */
|
|
51
138
|
status: number;
|
|
@@ -54,70 +141,118 @@ class ApiResponse {
|
|
|
54
141
|
|
|
55
142
|
/** @debug({ skip: true }) */
|
|
56
143
|
internalMetadata: Record<string, unknown>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
| `rename`
|
|
62
|
-
| `
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
144
|
+
}
|
|
145
|
+
``` ## All Options
|
|
146
|
+
| Option | Type | Description |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| `rename` | `string` | Display a different name in the output |
|
|
149
|
+
| `skip` | `boolean` | Exclude this field from the output |
|
|
150
|
+
## Interface Support
|
|
151
|
+
Debug also works with interfaces. For interfaces, a namespace is generated with a `toString` function:
|
|
152
|
+
**Before:**
|
|
153
|
+
```
|
|
154
|
+
/** @derive(Debug) */
|
|
155
|
+
interface Status {
|
|
156
|
+
active: boolean;
|
|
157
|
+
message: string;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
**After:**
|
|
161
|
+
```
|
|
162
|
+
interface Status {
|
|
163
|
+
active: boolean;
|
|
164
|
+
message: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export namespace Status {
|
|
168
|
+
export function toString(self: Status): string {
|
|
169
|
+
const parts: string[] = [];
|
|
170
|
+
parts.push('active: ' + self.active);
|
|
171
|
+
parts.push('message: ' + self.message);
|
|
172
|
+
return 'Status { ' + parts.join(', ') + ' }';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
``` ```
|
|
76
176
|
const status: Status = { active: true, message: "OK" };
|
|
77
177
|
console.log(Status.toString(status));
|
|
78
178
|
// Output: Status { active: true, message: OK }
|
|
179
|
+
``` ## Enum Support
|
|
180
|
+
Debug also works with enums. For enums, a namespace is generated with a `toString` function that displays the enum name and variant:
|
|
181
|
+
**Before:**
|
|
79
182
|
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
183
|
+
/** @derive(Debug) */
|
|
184
|
+
enum Priority {
|
|
185
|
+
Low = 1,
|
|
186
|
+
Medium = 2,
|
|
187
|
+
High = 3
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
**After:**
|
|
191
|
+
```
|
|
192
|
+
enum Priority {
|
|
193
|
+
Low = 1,
|
|
194
|
+
Medium = 2,
|
|
195
|
+
High = 3
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export namespace Priority {
|
|
199
|
+
export function toString(value: Priority): string {
|
|
200
|
+
const key = Priority[value as unknown as keyof typeof Priority];
|
|
201
|
+
if (key !== undefined) {
|
|
202
|
+
return 'Priority.' + key;
|
|
203
|
+
}
|
|
204
|
+
return 'Priority(' + String(value) + ')';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
``` ```
|
|
88
208
|
console.log(Priority.toString(Priority.High));
|
|
89
209
|
// Output: Priority.High
|
|
90
210
|
|
|
91
211
|
console.log(Priority.toString(Priority.Low));
|
|
92
212
|
// Output: Priority.Low
|
|
213
|
+
``` Works with both numeric and string enums:
|
|
214
|
+
**Source:**
|
|
93
215
|
```
|
|
94
|
-
|
|
95
|
-
Works with both numeric and string enums:
|
|
96
|
-
|
|
97
|
-
<InteractiveMacro code={`/** @derive(Debug) */
|
|
216
|
+
/** @derive(Debug) */
|
|
98
217
|
enum Status {
|
|
99
218
|
Active = "active",
|
|
100
219
|
Inactive = "inactive",
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
220
|
+
}
|
|
221
|
+
``` ## Type Alias Support
|
|
222
|
+
Debug works with type aliases. For object types, fields are displayed similar to interfaces:
|
|
223
|
+
**Before:**
|
|
224
|
+
```
|
|
225
|
+
/** @derive(Debug) */
|
|
226
|
+
type Point = {
|
|
227
|
+
x: number;
|
|
228
|
+
y: number;
|
|
229
|
+
};
|
|
230
|
+
```
|
|
231
|
+
**After:**
|
|
232
|
+
```
|
|
233
|
+
type Point = {
|
|
234
|
+
x: number;
|
|
235
|
+
y: number;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export namespace Point {
|
|
239
|
+
export function toString(value: Point): string {
|
|
240
|
+
const parts: string[] = [];
|
|
241
|
+
parts.push('x: ' + value.x);
|
|
242
|
+
parts.push('y: ' + value.y);
|
|
243
|
+
return 'Point { ' + parts.join(', ') + ' }';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
``` ```
|
|
110
247
|
const point: Point = { x: 10, y: 20 };
|
|
111
248
|
console.log(Point.toString(point));
|
|
112
249
|
// Output: Point { x: 10, y: 20 }
|
|
250
|
+
``` For union types, the value is displayed using JSON.stringify:
|
|
251
|
+
**Source:**
|
|
113
252
|
```
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<InteractiveMacro code={`/** @derive(Debug) */
|
|
118
|
-
type ApiStatus = "loading" | "success" | "error";`} />
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
253
|
+
/** @derive(Debug) */
|
|
254
|
+
type ApiStatus = "loading" | "success" | "error";
|
|
255
|
+
``` ```
|
|
121
256
|
console.log(ApiStatus.toString("success"));
|
|
122
257
|
// Output: ApiStatus("success")
|
|
123
258
|
```
|