@macroforge/mcp-server 0.1.17

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.
Files changed (46) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +47 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/tools/docs-loader.d.ts +30 -0
  6. package/dist/tools/docs-loader.d.ts.map +1 -0
  7. package/dist/tools/docs-loader.js +112 -0
  8. package/dist/tools/docs-loader.js.map +1 -0
  9. package/dist/tools/index.d.ts +6 -0
  10. package/dist/tools/index.d.ts.map +1 -0
  11. package/dist/tools/index.js +348 -0
  12. package/dist/tools/index.js.map +1 -0
  13. package/docs/api/api-overview.md +75 -0
  14. package/docs/api/expand-sync.md +121 -0
  15. package/docs/api/native-plugin.md +106 -0
  16. package/docs/api/position-mapper.md +127 -0
  17. package/docs/api/transform-sync.md +98 -0
  18. package/docs/builtin-macros/clone.md +180 -0
  19. package/docs/builtin-macros/debug.md +222 -0
  20. package/docs/builtin-macros/default.md +192 -0
  21. package/docs/builtin-macros/deserialize.md +662 -0
  22. package/docs/builtin-macros/hash.md +205 -0
  23. package/docs/builtin-macros/macros-overview.md +169 -0
  24. package/docs/builtin-macros/ord.md +258 -0
  25. package/docs/builtin-macros/partial-eq.md +306 -0
  26. package/docs/builtin-macros/partial-ord.md +268 -0
  27. package/docs/builtin-macros/serialize.md +321 -0
  28. package/docs/concepts/architecture.md +139 -0
  29. package/docs/concepts/derive-system.md +173 -0
  30. package/docs/concepts/how-macros-work.md +124 -0
  31. package/docs/custom-macros/custom-overview.md +84 -0
  32. package/docs/custom-macros/rust-setup.md +146 -0
  33. package/docs/custom-macros/ts-macro-derive.md +307 -0
  34. package/docs/custom-macros/ts-quote.md +696 -0
  35. package/docs/getting-started/first-macro.md +120 -0
  36. package/docs/getting-started/installation.md +110 -0
  37. package/docs/integration/cli.md +207 -0
  38. package/docs/integration/configuration.md +116 -0
  39. package/docs/integration/integration-overview.md +51 -0
  40. package/docs/integration/typescript-plugin.md +96 -0
  41. package/docs/integration/vite-plugin.md +126 -0
  42. package/docs/language-servers/ls-overview.md +47 -0
  43. package/docs/language-servers/svelte-ls.md +80 -0
  44. package/docs/language-servers/zed-extensions.md +84 -0
  45. package/docs/sections.json +258 -0
  46. package/package.json +48 -0
@@ -0,0 +1,222 @@
1
+ # Debug
2
+
3
+ *The `Debug` macro generates a `toString()` method that produces a human-readable string representation of your class.*
4
+
5
+ ## Basic Usage
6
+
7
+ ```typescript
8
+ /** @derive(Debug) */
9
+ class User {
10
+ name: string;
11
+ age: number;
12
+
13
+ constructor(name: string, age: number) {
14
+ this.name = name;
15
+ this.age = age;
16
+ }
17
+ }
18
+
19
+ const user = new User("Alice", 30);
20
+ console.log(user.toString());
21
+ // Output: User { name: Alice, age: 30 }
22
+ ```
23
+
24
+ ## Generated Code
25
+
26
+ ```typescript
27
+ toString(): string {
28
+ const parts: string[] = [];
29
+ parts.push("name: " + this.name);
30
+ parts.push("age: " + this.age);
31
+ return "User { " + parts.join(", ") + " }";
32
+ }
33
+ ```
34
+
35
+ ## Field Options
36
+
37
+ Use the `@debug` field decorator to customize behavior:
38
+
39
+ ### Renaming Fields
40
+
41
+ ```typescript
42
+ /** @derive(Debug) */
43
+ class User {
44
+ /** @debug({ rename: "userId" }) */
45
+ id: number;
46
+
47
+ name: string;
48
+
49
+ constructor(id: number, name: string) {
50
+ this.id = id;
51
+ this.name = name;
52
+ }
53
+ }
54
+
55
+ const user = new User(42, "Alice");
56
+ console.log(user.toString());
57
+ // Output: User { userId: 42, name: Alice }
58
+ ```
59
+
60
+ ### Skipping Fields
61
+
62
+ Use `skip: true` to exclude sensitive fields from the output:
63
+
64
+ ```typescript
65
+ /** @derive(Debug) */
66
+ class User {
67
+ name: string;
68
+ email: string;
69
+
70
+ /** @debug({ skip: true }) */
71
+ password: string;
72
+
73
+ /** @debug({ skip: true }) */
74
+ authToken: string;
75
+
76
+ constructor(name: string, email: string, password: string, authToken: string) {
77
+ this.name = name;
78
+ this.email = email;
79
+ this.password = password;
80
+ this.authToken = authToken;
81
+ }
82
+ }
83
+
84
+ const user = new User("Alice", "alice@example.com", "secret", "tok_xxx");
85
+ console.log(user.toString());
86
+ // Output: User { name: Alice, email: alice@example.com }
87
+ // Note: password and authToken are not included
88
+ ```
89
+
90
+ <Alert type="tip" title="Security">
91
+ Always skip sensitive fields like passwords, tokens, and API keys to prevent accidental logging.
92
+ </Alert>
93
+
94
+ ## Combining Options
95
+
96
+ ```typescript
97
+ /** @derive(Debug) */
98
+ class ApiResponse {
99
+ /** @debug({ rename: "statusCode" }) */
100
+ status: number;
101
+
102
+ data: unknown;
103
+
104
+ /** @debug({ skip: true }) */
105
+ internalMetadata: Record<string, unknown>;
106
+ }
107
+ ```
108
+
109
+ ## All Options
110
+
111
+ | `rename`
112
+ | `string`
113
+ | Display a different name in the output
114
+
115
+ | `skip`
116
+ | `boolean`
117
+ | Exclude this field from the output
118
+
119
+ ## Interface Support
120
+
121
+ Debug also works with interfaces. For interfaces, a namespace is generated with a `toString` function:
122
+
123
+ ```typescript
124
+ /** @derive(Debug) */
125
+ interface Status {
126
+ active: boolean;
127
+ message: string;
128
+ }
129
+
130
+ // Generated:
131
+ // export namespace Status {
132
+ // export function toString(self: Status): string {
133
+ // const parts: string[] = [];
134
+ // parts.push("active: " + self.active);
135
+ // parts.push("message: " + self.message);
136
+ // return "Status { " + parts.join(", ") + " }";
137
+ // }
138
+ // }
139
+
140
+ const status: Status = { active: true, message: "OK" };
141
+ console.log(Status.toString(status));
142
+ // Output: Status { active: true, message: OK }
143
+ ```
144
+
145
+ ## Enum Support
146
+
147
+ Debug also works with enums. For enums, a namespace is generated with a `toString` function that displays the enum name and variant:
148
+
149
+ ```typescript
150
+ /** @derive(Debug) */
151
+ enum Priority {
152
+ Low = 1,
153
+ Medium = 2,
154
+ High = 3,
155
+ }
156
+
157
+ // Generated:
158
+ // export namespace Priority {
159
+ // export function toString(value: Priority): string {
160
+ // const key = Priority[value as unknown as keyof typeof Priority];
161
+ // if (key !== undefined) {
162
+ // return "Priority." + key;
163
+ // }
164
+ // return "Priority(" + String(value) + ")";
165
+ // }
166
+ // }
167
+
168
+ console.log(Priority.toString(Priority.High));
169
+ // Output: Priority.High
170
+
171
+ console.log(Priority.toString(Priority.Low));
172
+ // Output: Priority.Low
173
+ ```
174
+
175
+ Works with both numeric and string enums:
176
+
177
+ ```typescript
178
+ /** @derive(Debug) */
179
+ enum Status {
180
+ Active = "active",
181
+ Inactive = "inactive",
182
+ }
183
+
184
+ console.log(Status.toString(Status.Active));
185
+ // Output: Status.Active
186
+ ```
187
+
188
+ ## Type Alias Support
189
+
190
+ Debug works with type aliases. For object types, fields are displayed similar to interfaces:
191
+
192
+ ```typescript
193
+ /** @derive(Debug) */
194
+ type Point = {
195
+ x: number;
196
+ y: number;
197
+ };
198
+
199
+ // Generated:
200
+ // export namespace Point {
201
+ // export function toString(value: Point): string {
202
+ // const parts: string[] = [];
203
+ // parts.push("x: " + value.x);
204
+ // parts.push("y: " + value.y);
205
+ // return "Point { " + parts.join(", ") + " }";
206
+ // }
207
+ // }
208
+
209
+ const point: Point = { x: 10, y: 20 };
210
+ console.log(Point.toString(point));
211
+ // Output: Point { x: 10, y: 20 }
212
+ ```
213
+
214
+ For union types, the value is displayed using JSON.stringify:
215
+
216
+ ```typescript
217
+ /** @derive(Debug) */
218
+ type ApiStatus = "loading" | "success" | "error";
219
+
220
+ console.log(ApiStatus.toString("success"));
221
+ // Output: ApiStatus("success")
222
+ ```
@@ -0,0 +1,192 @@
1
+ # Default
2
+
3
+ *The `Default` macro generates a static `default()` factory method that creates instances with default field values.*
4
+
5
+ ## Basic Usage
6
+
7
+ ```typescript
8
+ /** @derive(Default) */
9
+ class Config {
10
+ host: string;
11
+ port: number;
12
+ enabled: boolean;
13
+
14
+ constructor(host: string, port: number, enabled: boolean) {
15
+ this.host = host;
16
+ this.port = port;
17
+ this.enabled = enabled;
18
+ }
19
+ }
20
+
21
+ const config = Config.default();
22
+ console.log(config.host); // ""
23
+ console.log(config.port); // 0
24
+ console.log(config.enabled); // false
25
+ ```
26
+
27
+ ## Generated Code
28
+
29
+ The Default macro generates a static factory method:
30
+
31
+ ```typescript
32
+ static default(): Config {
33
+ const instance = new Config();
34
+ instance.host = "";
35
+ instance.port = 0;
36
+ instance.enabled = false;
37
+ return instance;
38
+ }
39
+ ```
40
+
41
+ ## Automatic Default Values
42
+
43
+ The Default macro automatically determines default values based on field types:
44
+
45
+ - `string` → `""` (empty string)
46
+
47
+ - `number` → `0`
48
+
49
+ - `boolean` → `false`
50
+
51
+ - `bigint` → `0n`
52
+
53
+ - `Array<T>` or `T[]` → `[]` (empty array)
54
+
55
+ - `Map<K, V>` → `new Map()`
56
+
57
+ - `Set<T>` → `new Set()`
58
+
59
+ - `Date` → `new Date()`
60
+
61
+ - Custom types → `null as any`
62
+
63
+ ## Custom Default Values
64
+
65
+ Use the `@defaultValue()` decorator to specify custom default values for fields:
66
+
67
+ ```typescript
68
+ /** @derive(Default) */
69
+ class ServerConfig {
70
+ /** @defaultValue("localhost") */
71
+ host: string;
72
+
73
+ /** @defaultValue(8080) */
74
+ port: number;
75
+
76
+ /** @defaultValue(true) */
77
+ enabled: boolean;
78
+
79
+ /** @defaultValue(["info", "error"]) */
80
+ logLevels: string[];
81
+
82
+ constructor(host: string, port: number, enabled: boolean, logLevels: string[]) {
83
+ this.host = host;
84
+ this.port = port;
85
+ this.enabled = enabled;
86
+ this.logLevels = logLevels;
87
+ }
88
+ }
89
+
90
+ const config = ServerConfig.default();
91
+ console.log(config.host); // "localhost"
92
+ console.log(config.port); // 8080
93
+ console.log(config.enabled); // true
94
+ console.log(config.logLevels); // ["info", "error"]
95
+ ```
96
+
97
+ ## Interface Support
98
+
99
+ Default also works with interfaces. For interfaces, a namespace is generated with a `default_()` function (note the underscore to avoid conflicts with the reserved word):
100
+
101
+ ```typescript
102
+ /** @derive(Default) */
103
+ interface Point {
104
+ x: number;
105
+ y: number;
106
+ }
107
+
108
+ // Generated:
109
+ // export namespace Point {
110
+ // export function default_(): Point {
111
+ // return {
112
+ // x: 0,
113
+ // y: 0
114
+ // } as Point;
115
+ // }
116
+ // }
117
+
118
+ const origin = Point.default_();
119
+ console.log(origin); // { x: 0, y: 0 }
120
+ ```
121
+
122
+ ## Enum Support
123
+
124
+ Default works with enums. For enums, it returns the first variant as the default value:
125
+
126
+ ```typescript
127
+ /** @derive(Default) */
128
+ enum Status {
129
+ Pending = "pending",
130
+ Active = "active",
131
+ Completed = "completed",
132
+ }
133
+
134
+ // Generated:
135
+ // export namespace Status {
136
+ // export function default_(): Status {
137
+ // return Status.Pending;
138
+ // }
139
+ // }
140
+
141
+ const defaultStatus = Status.default_();
142
+ console.log(defaultStatus); // "pending"
143
+ ```
144
+
145
+ ## Type Alias Support
146
+
147
+ Default works with type aliases. For object types, it creates an object with default field values:
148
+
149
+ ```typescript
150
+ /** @derive(Default) */
151
+ type Dimensions = {
152
+ width: number;
153
+ height: number;
154
+ };
155
+
156
+ // Generated:
157
+ // export namespace Dimensions {
158
+ // export function default_(): Dimensions {
159
+ // return {
160
+ // width: 0,
161
+ // height: 0
162
+ // } as Dimensions;
163
+ // }
164
+ // }
165
+
166
+ const dims = Dimensions.default_();
167
+ console.log(dims); // { width: 0, height: 0 }
168
+ ```
169
+
170
+ ## Combining with Other Macros
171
+
172
+ ```typescript
173
+ /** @derive(Default, Debug, Clone, PartialEq) */
174
+ class User {
175
+ /** @defaultValue("Anonymous") */
176
+ name: string;
177
+
178
+ /** @defaultValue(0) */
179
+ age: number;
180
+
181
+ constructor(name: string, age: number) {
182
+ this.name = name;
183
+ this.age = age;
184
+ }
185
+ }
186
+
187
+ const user1 = User.default();
188
+ const user2 = user1.clone();
189
+
190
+ console.log(user1.toString()); // User { name: "Anonymous", age: 0 }
191
+ console.log(user1.equals(user2)); // true
192
+ ```