@macroforge/mcp-server 0.1.42 → 0.1.50

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 (71) hide show
  1. package/LICENSE +22 -0
  2. package/docs/BOOK.md +165 -0
  3. package/docs/api/api-overview.md +67 -48
  4. package/docs/api/expand-sync.md +88 -53
  5. package/docs/api/native-plugin.md +121 -71
  6. package/docs/api/position-mapper.md +115 -55
  7. package/docs/api/transform-sync.md +86 -60
  8. package/docs/builtin-macros/clone.md +0 -20
  9. package/docs/builtin-macros/debug.md +0 -23
  10. package/docs/builtin-macros/default.md +1 -40
  11. package/docs/builtin-macros/deserialize/example.md +8 -1416
  12. package/docs/builtin-macros/deserialize.md +8 -1416
  13. package/docs/builtin-macros/hash.md +0 -42
  14. package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
  15. package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
  16. package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
  17. package/docs/builtin-macros/macros-overview/overview.md +36 -0
  18. package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
  19. package/docs/builtin-macros/macros-overview.md +171 -130
  20. package/docs/builtin-macros/ord.md +0 -25
  21. package/docs/builtin-macros/partial-eq.md +0 -84
  22. package/docs/builtin-macros/partial-ord.md +2 -32
  23. package/docs/builtin-macros/serialize.md +2 -62
  24. package/docs/concepts/architecture.md +125 -48
  25. package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
  26. package/docs/concepts/derive-system/overview.md +200 -0
  27. package/docs/concepts/derive-system.md +157 -104
  28. package/docs/concepts/how-macros-work.md +98 -47
  29. package/docs/custom-macros/custom-overview.md +79 -57
  30. package/docs/custom-macros/rust-setup.md +138 -99
  31. package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
  32. package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
  33. package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
  34. package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
  35. package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
  36. package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
  37. package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
  38. package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
  39. package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
  40. package/docs/custom-macros/ts-macro-derive.md +322 -228
  41. package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
  42. package/docs/custom-macros/ts-quote/comments-and.md +56 -22
  43. package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
  44. package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
  45. package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
  46. package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
  47. package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
  48. package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
  49. package/docs/custom-macros/ts-quote/overview.md +5 -10
  50. package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
  51. package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
  52. package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
  53. package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
  54. package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
  55. package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
  56. package/docs/custom-macros/ts-quote.md +800 -520
  57. package/docs/getting-started/first-macro.md +98 -71
  58. package/docs/getting-started/installation.md +109 -65
  59. package/docs/integration/cli.md +214 -105
  60. package/docs/integration/configuration.md +115 -72
  61. package/docs/integration/integration-overview.md +55 -18
  62. package/docs/integration/mcp-server.md +84 -43
  63. package/docs/integration/svelte-preprocessor.md +183 -126
  64. package/docs/integration/typescript-plugin.md +101 -53
  65. package/docs/integration/vite-plugin.md +116 -76
  66. package/docs/language-servers/ls-overview.md +37 -21
  67. package/docs/language-servers/svelte.md +69 -38
  68. package/docs/language-servers/zed.md +81 -44
  69. package/docs/roadmap/roadmap.md +75 -53
  70. package/docs/sections.json +1 -242
  71. package/package.json +27 -28
@@ -1,76 +1,156 @@
1
1
  # Command Line Interface
2
- *This binary provides command-line utilities for working with Macroforge TypeScript macros. It is designed for development workflows, enabling macro expansion and type checking without requiring Node.js integration.*
3
- ## Installation
4
- The CLI is a Rust binary. You can install it using Cargo:
5
- ```
6
- cargo install macroforge_ts
7
- ``` Or build from source:
8
- ```
9
- git clone https://github.com/rymskip/macroforge-ts.git
10
- cd macroforge-ts/crates
11
- cargo build --release --bin macroforge
12
-
13
- # The binary is at target/release/macroforge
14
- ``` ## Commands
15
- ### macroforge expand
16
- Expands macros in a TypeScript file and outputs the transformed code.
17
- ```
18
- macroforge expand <input> [options]
19
- ``` #### Arguments
20
- | Argument | Description |
21
- | --- | --- |
22
- | <input> | Path to the TypeScript or TSX file to expand |
23
- #### Options
24
- | Option | Description |
25
- | --- | --- |
26
- | --out <path> | Write the expanded JavaScript/TypeScript to a file |
27
- | --types-out <path> | Write the generated .d.ts declarations to a file |
28
- | --print | Print output to stdout even when --out is specified |
29
- | --builtin-only | Use only built-in Rust macros (faster, but no external macro support) |
30
- #### Examples
31
- Expand a file and print to stdout:
32
- ```
33
- macroforge&nbsp;expand&nbsp;src/user.ts
34
- ``` Expand and write to a file:
35
- ```
36
- macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--out&nbsp;dist/user.js
37
- ``` Expand with both runtime output and type declarations:
38
- ```
39
- macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--out&nbsp;dist/user.js&nbsp;--types-out&nbsp;dist/user.d.ts
40
- ``` Use fast built-in macros only (no external macro support):
41
- ```
42
- macroforge&nbsp;expand&nbsp;src/user.ts&nbsp;--builtin-only
43
- ``` > **Note:** By default, the CLI uses Node.js for full macro support (including external macros). It must be run from your project's root directory where macroforge and any external macro packages are installed in node_modules. ### macroforge tsc
44
- Runs TypeScript type checking with macro expansion. This wraps <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">tsc <span style="--shiki-dark:#F97583;--shiki-light:#D73A49">--<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">noEmit</code> and expands macros before type checking, so your generated methods are properly type-checked.
45
- ```
46
- macroforge&nbsp;tsc&nbsp;[options]
47
- ``` #### Options
48
- | Option | Description |
49
- | --- | --- |
50
- | -p, --project <path> | Path to tsconfig.json (defaults to tsconfig.json in current directory) |
51
- #### Examples
52
- Type check with default tsconfig.json:
53
- ```
54
- macroforge&nbsp;tsc
55
- ``` Type check with a specific config:
56
- ```
57
- macroforge&nbsp;tsc&nbsp;-p&nbsp;tsconfig.build.json
58
- ``` ## Output Format
59
- ### Expanded Code
60
- When expanding a file like this:
61
- ```
62
- /**&nbsp;@derive(Debug)&nbsp;*/
63
- class&nbsp;User&nbsp;&#123;
64
- &nbsp;&nbsp;name:&nbsp;string;
65
- &nbsp;&nbsp;age:&nbsp;number;
66
-
67
- &nbsp;&nbsp;constructor(name:&nbsp;string,&nbsp;age:&nbsp;number)&nbsp;&#123;
68
- &nbsp;&nbsp;&nbsp;&nbsp;this.name&nbsp;=&nbsp;name;
69
- &nbsp;&nbsp;&nbsp;&nbsp;this.age&nbsp;=&nbsp;age;
70
- &nbsp;&nbsp;&#125;
71
- &#125;
72
- ``` The CLI outputs the expanded code with the generated methods:
73
- ```
2
+
3
+ macroforge v0.1.48
4
+
5
+ This binary provides command-line utilities for working with Macroforge TypeScript macros. It is designed for development workflows, enabling macro expansion and type checking without requiring Node.js integration.
6
+
7
+ ## Installation
8
+
9
+ The CLI is a Rust binary. You can install it using Cargo:
10
+
11
+ Bash
12
+
13
+ ```
14
+ cargo install macroforge_ts
15
+ ```
16
+
17
+ Or build from source:
18
+
19
+ Bash
20
+
21
+ ```
22
+ git clone https://github.com/rymskip/macroforge-ts.git
23
+ cd macroforge-ts/crates
24
+ cargo build --release --bin macroforge
25
+
26
+ # The binary is at target/release/macroforge
27
+ ```
28
+
29
+ ## Commands
30
+
31
+ ### macroforge expand
32
+
33
+ Expands macros in a TypeScript file and outputs the transformed code.
34
+
35
+ Bash
36
+
37
+ ```
38
+ macroforge expand <input> [options]
39
+ ```
40
+
41
+ #### Arguments
42
+
43
+ | Argument | Description |
44
+ | --------- | -------------------------------------------- |
45
+ | `<input>` | Path to the TypeScript or TSX file to expand |
46
+
47
+ #### Options
48
+
49
+ | Option | Description |
50
+ | -------------------- | --------------------------------------------------------------------- |
51
+ | `--out <path>` | Write the expanded JavaScript/TypeScript to a file |
52
+ | `--types-out <path>` | Write the generated `.d.ts` declarations to a file |
53
+ | `--print` | Print output to stdout even when `--out` is specified |
54
+ | `--builtin-only` | Use only built-in Rust macros (faster, but no external macro support) |
55
+
56
+ #### Examples
57
+
58
+ Expand a file and print to stdout:
59
+
60
+ Bash
61
+
62
+ ```
63
+ macroforge expand src/user.ts
64
+ ```
65
+
66
+ Expand and write to a file:
67
+
68
+ Bash
69
+
70
+ ```
71
+ macroforge expand src/user.ts --out dist/user.js
72
+ ```
73
+
74
+ Expand with both runtime output and type declarations:
75
+
76
+ Bash
77
+
78
+ ```
79
+ macroforge expand src/user.ts --out dist/user.js --types-out dist/user.d.ts
80
+ ```
81
+
82
+ Use fast built-in macros only (no external macro support):
83
+
84
+ Bash
85
+
86
+ ```
87
+ macroforge expand src/user.ts --builtin-only
88
+ ```
89
+
90
+ Note
91
+
92
+ By default, the CLI uses Node.js for full macro support (including external macros). It must be run from your project's root directory where `macroforge` and any external macro packages are installed in `node_modules`.
93
+
94
+ ### macroforge tsc
95
+
96
+ Runs TypeScript type checking with macro expansion. This wraps `tsc --noEmit` and expands macros before type checking, so your generated methods are properly type-checked.
97
+
98
+ Bash
99
+
100
+ ```
101
+ macroforge tsc [options]
102
+ ```
103
+
104
+ #### Options
105
+
106
+ | Option | Description |
107
+ | ---------------------- | -------------------------------------------------------------------------- |
108
+ | `-p, --project <path>` | Path to `tsconfig.json` (defaults to `tsconfig.json` in current directory) |
109
+
110
+ #### Examples
111
+
112
+ Type check with default tsconfig.json:
113
+
114
+ Bash
115
+
116
+ ```
117
+ macroforge tsc
118
+ ```
119
+
120
+ Type check with a specific config:
121
+
122
+ Bash
123
+
124
+ ```
125
+ macroforge tsc -p tsconfig.build.json
126
+ ```
127
+
128
+ ## Output Format
129
+
130
+ ### Expanded Code
131
+
132
+ When expanding a file like this:
133
+
134
+ TypeScript
135
+
136
+ ```
137
+ /** @derive(Debug) */
138
+ class User {
139
+   name: string;
140
+   age: number;
141
+
142
+   constructor(name: string, age: number) {
143
+     this.name = name;
144
+     this.age = age;
145
+   }
146
+ }
147
+ ```
148
+
149
+ The CLI outputs the expanded code with the generated methods:
150
+
151
+ TypeScript
152
+
153
+ ```
74
154
  class User {
75
155
  name: string;
76
156
  age: number;
@@ -84,38 +164,67 @@ class User {
84
164
  return `User { name: ${this.name}, age: ${this.age} }`;
85
165
  }
86
166
  }
87
- ``` ### Diagnostics
88
- Errors and warnings are printed to stderr in a readable format:
89
- ```
90
- [macroforge]&nbsp;error&nbsp;at&nbsp;src/user.ts:5:1:&nbsp;Unknown&nbsp;derive&nbsp;macro:&nbsp;InvalidMacro
91
- [macroforge]&nbsp;warning&nbsp;at&nbsp;src/user.ts:10:3:&nbsp;Field&nbsp;'unused'&nbsp;is&nbsp;never&nbsp;used
92
- ``` ## Use Cases
93
- ### CI/CD Type Checking
94
- Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#B392F0;--shiki-light:#6F42C1">macroforge<span style="--shiki-dark:#9ECBFF;--shiki-light:#032F62"> tsc</code> in your CI pipeline to type-check with macro expansion:
95
- ```
96
- #&nbsp;package.json
97
- &#123;
98
- &nbsp;&nbsp;"scripts":&nbsp;&#123;
99
- &nbsp;&nbsp;&nbsp;&nbsp;"typecheck":&nbsp;"macroforge&nbsp;tsc"
100
- &nbsp;&nbsp;&#125;
101
- &#125;
102
- ``` ### Debugging Macro Output
103
- Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#B392F0;--shiki-light:#6F42C1">macroforge<span style="--shiki-dark:#9ECBFF;--shiki-light:#032F62"> expand</code> to inspect what code your macros generate:
104
- ```
105
- macroforge&nbsp;expand&nbsp;src/models/user.ts&nbsp;|&nbsp;less
106
- ``` ### Build Pipeline
107
- Generate expanded files as part of a custom build:
108
- ```
167
+ ```
168
+
169
+ ### Diagnostics
170
+
171
+ Errors and warnings are printed to stderr in a readable format:
172
+
173
+ Text
174
+
175
+ ```
176
+ [macroforge] error at src/user.ts:5:1: Unknown derive macro: InvalidMacro
177
+ [macroforge] warning at src/user.ts:10:3: Field 'unused' is never used
178
+ ```
179
+
180
+ ## Use Cases
181
+
182
+ ### CI/CD Type Checking
183
+
184
+ Use `macroforge tsc` in your CI pipeline to type-check with macro expansion:
185
+
186
+ JSON
187
+
188
+ ```
189
+ # package.json
190
+ {
191
+   "scripts": {
192
+     "typecheck": "macroforge tsc"
193
+   }
194
+ }
195
+ ```
196
+
197
+ ### Debugging Macro Output
198
+
199
+ Use `macroforge expand` to inspect what code your macros generate:
200
+
201
+ Bash
202
+
203
+ ```
204
+ macroforge expand src/models/user.ts | less
205
+ ```
206
+
207
+ ### Build Pipeline
208
+
209
+ Generate expanded files as part of a custom build:
210
+
211
+ Bash
212
+
213
+ ```
109
214
  #!/bin/bash
110
- for&nbsp;file&nbsp;in&nbsp;src/**/*.ts;&nbsp;do
111
- &nbsp;&nbsp;outfile="dist/$(basename&nbsp;"$file"&nbsp;.ts).js"
112
- &nbsp;&nbsp;macroforge&nbsp;expand&nbsp;"$file"&nbsp;--out&nbsp;"$outfile"
215
+ for file in src/**/*.ts; do
216
+   outfile="dist/$(basename "$file" .ts).js"
217
+   macroforge expand "$file" --out "$outfile"
113
218
  done
114
- ``` ## Built-in vs Full Mode
115
- By default, the CLI uses Node.js for full macro support including external macros. Use <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#F97583;--shiki-light:#D73A49">--<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">builtin<span style="--shiki-dark:#F97583;--shiki-light:#D73A49">-<span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">only</code> for faster expansion when you only need built-in macros:
116
- | Feature | Default (Node.js) | --builtin-only (Rust) |
117
- | --- | --- | --- |
118
- | Built-in macros | Yes | Yes |
119
- | External macros | Yes | No |
120
- | Performance | Standard | Faster |
121
- | Dependencies | Requires macroforge in node_modules | None |
219
+ ```
220
+
221
+ ## Built-in vs Full Mode
222
+
223
+ By default, the CLI uses Node.js for full macro support including external macros. Use `--builtin-only` for faster expansion when you only need built-in macros:
224
+
225
+ | Feature | Default (Node.js) | `--builtin-only` (Rust) |
226
+ | --------------- | -------------------------------------- | ----------------------- |
227
+ | Built-in macros | Yes | Yes |
228
+ | External macros | Yes | No |
229
+ | Performance | Standard | Faster |
230
+ | Dependencies | Requires `macroforge` in node\_modules | None |
@@ -1,73 +1,116 @@
1
1
  # Configuration
2
- *Macroforge can be configured with a <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">macroforge.json</code> file in your project root.*
3
- ## Configuration File
4
- Create a <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">macroforge.json</code> file:
5
- ```
6
- &#123;
7
- &nbsp;&nbsp;"allowNativeMacros":&nbsp;true,
8
- &nbsp;&nbsp;"macroPackages":&nbsp;[],
9
- &nbsp;&nbsp;"keepDecorators":&nbsp;false,
10
- &nbsp;&nbsp;"limits":&nbsp;&#123;
11
- &nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;5000,
12
- &nbsp;&nbsp;&nbsp;&nbsp;"maxMemoryBytes":&nbsp;104857600,
13
- &nbsp;&nbsp;&nbsp;&nbsp;"maxOutputSize":&nbsp;10485760,
14
- &nbsp;&nbsp;&nbsp;&nbsp;"maxDiagnostics":&nbsp;100
15
- &nbsp;&nbsp;&#125;
16
- &#125;
17
- ``` ## Options Reference
18
- ### allowNativeMacros
19
- | Type | boolean |
20
- | Default | true |
21
- Enable or disable native (Rust) macro packages. Set to <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#79B8FF;--shiki-light:#005CC5">false</code> to only allow built-in macros.
22
- ### macroPackages
23
- | Type | string[] |
24
- | Default | [] |
25
- List of npm packages that provide macros. Macroforge will look for macros in these packages.
26
- ```
27
- &#123;
28
- &nbsp;&nbsp;"macroPackages":&nbsp;[
29
- &nbsp;&nbsp;&nbsp;&nbsp;"@my-org/custom-macros",
30
- &nbsp;&nbsp;&nbsp;&nbsp;"community-macros"
31
- &nbsp;&nbsp;]
32
- &#125;
33
- ``` ### keepDecorators
34
- | Type | boolean |
35
- | Default | false |
36
- Keep <code class="shiki-inline"><span class="line"><span style="--shiki-dark:#E1E4E8;--shiki-light:#24292E">@derive</code> decorators in the output. Useful for debugging.
37
- ### limits
38
- Configure resource limits for macro expansion:
39
- ```
40
- &#123;
41
- &nbsp;&nbsp;"limits":&nbsp;&#123;
42
- &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;time&nbsp;for&nbsp;a&nbsp;single&nbsp;macro&nbsp;expansion&nbsp;(ms)
43
- &nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;5000,
44
-
45
- &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;memory&nbsp;usage&nbsp;(bytes)
46
- &nbsp;&nbsp;&nbsp;&nbsp;"maxMemoryBytes":&nbsp;104857600,&nbsp;&nbsp;//&nbsp;100MB
47
-
48
- &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;size&nbsp;of&nbsp;generated&nbsp;code&nbsp;(bytes)
49
- &nbsp;&nbsp;&nbsp;&nbsp;"maxOutputSize":&nbsp;10485760,&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;10MB
50
-
51
- &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Maximum&nbsp;number&nbsp;of&nbsp;diagnostics&nbsp;per&nbsp;file
52
- &nbsp;&nbsp;&nbsp;&nbsp;"maxDiagnostics":&nbsp;100
53
- &nbsp;&nbsp;&#125;
54
- &#125;
55
- ``` ## Macro Runtime Overrides
56
- Override settings for specific macros:
57
- ```
58
- &#123;
59
- &nbsp;&nbsp;"macroRuntimeOverrides":&nbsp;&#123;
60
- &nbsp;&nbsp;&nbsp;&nbsp;"@my-org/macros":&nbsp;&#123;
61
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"maxExecutionTimeMs":&nbsp;10000
62
- &nbsp;&nbsp;&nbsp;&nbsp;&#125;
63
- &nbsp;&nbsp;&#125;
64
- &#125;
65
- ``` **Warning Be careful when increasing limits, as this could allow malicious macros to consume excessive resources. ## Environment Variables
66
- Some settings can be overridden with environment variables:
67
- | Variable | Description |
68
- | --- | --- |
69
- | MACROFORGE_DEBUG | Enable debug logging |
70
- | MACROFORGE_LOG_FILE | Write logs to a file |
71
- ```
72
- MACROFORGE_DEBUG=1&nbsp;npm&nbsp;run&nbsp;dev
73
- ```**
2
+
3
+ Macroforge can be configured with a `macroforge.json` file in your project root.
4
+
5
+ ## Configuration File
6
+
7
+ Create a `macroforge.json` file:
8
+
9
+ macroforge.json
10
+
11
+ ```
12
+ {
13
+   "allowNativeMacros": true,
14
+   "macroPackages": [],
15
+   "keepDecorators": false,
16
+   "limits": {
17
+     "maxExecutionTimeMs": 5000,
18
+     "maxMemoryBytes": 104857600,
19
+     "maxOutputSize": 10485760,
20
+     "maxDiagnostics": 100
21
+   }
22
+ }
23
+ ```
24
+
25
+ ## Options Reference
26
+
27
+ ### allowNativeMacros
28
+
29
+ | Type | `boolean` |
30
+ | Default | `true` |
31
+
32
+ Enable or disable native (Rust) macro packages. Set to `false` to only allow built-in macros.
33
+
34
+ ### macroPackages
35
+
36
+ | Type | `string[]` |
37
+ | Default | `[]` |
38
+
39
+ List of npm packages that provide macros. Macroforge will look for macros in these packages.
40
+
41
+ JSON
42
+
43
+ ```
44
+ {
45
+   "macroPackages": [
46
+     "@my-org/custom-macros",
47
+     "community-macros"
48
+   ]
49
+ }
50
+ ```
51
+
52
+ ### keepDecorators
53
+
54
+ | Type | `boolean` |
55
+ | Default | `false` |
56
+
57
+ Keep `@derive` decorators in the output. Useful for debugging.
58
+
59
+ ### limits
60
+
61
+ Configure resource limits for macro expansion:
62
+
63
+ JSON
64
+
65
+ ```
66
+ {
67
+   "limits": {
68
+     // Maximum time for a single macro expansion (ms)
69
+     "maxExecutionTimeMs": 5000,
70
+
71
+     // Maximum memory usage (bytes)
72
+     "maxMemoryBytes": 104857600,  // 100MB
73
+
74
+     // Maximum size of generated code (bytes)
75
+     "maxOutputSize": 10485760,    // 10MB
76
+
77
+     // Maximum number of diagnostics per file
78
+     "maxDiagnostics": 100
79
+   }
80
+ }
81
+ ```
82
+
83
+ ## Macro Runtime Overrides
84
+
85
+ Override settings for specific macros:
86
+
87
+ JSON
88
+
89
+ ```
90
+ {
91
+   "macroRuntimeOverrides": {
92
+     "@my-org/macros": {
93
+       "maxExecutionTimeMs": 10000
94
+     }
95
+   }
96
+ }
97
+ ```
98
+
99
+ Warning
100
+
101
+ Be careful when increasing limits, as this could allow malicious macros to consume excessive resources.
102
+
103
+ ## Environment Variables
104
+
105
+ Some settings can be overridden with environment variables:
106
+
107
+ | Variable | Description |
108
+ | --------------------- | -------------------- |
109
+ | `MACROFORGE_DEBUG` | Enable debug logging |
110
+ | `MACROFORGE_LOG_FILE` | Write logs to a file |
111
+
112
+ Bash
113
+
114
+ ```
115
+ MACROFORGE_DEBUG=1 npm run dev
116
+ ```
@@ -1,19 +1,56 @@
1
1
  # Integration
2
- *Macroforge integrates with your development workflow through IDE plugins and build tool integration.*
3
- ## Overview
4
- | Integration | Purpose | Package |
5
- | --- | --- | --- |
6
- | TypeScript Plugin | IDE support (errors, completions) | @macroforge/typescript-plugin |
7
- | Vite Plugin | Build-time macro expansion | @macroforge/vite-plugin |
8
- ## Recommended Setup
9
- For the best development experience, use both integrations:
10
- 1. **TypeScript Plugin**: Provides real-time feedback in your IDE
11
- 2. **Vite Plugin**: Expands macros during development and production builds
12
- ```
13
- #&nbsp;Install&nbsp;both&nbsp;plugins
14
- npm&nbsp;install&nbsp;-D&nbsp;@macroforge/typescript-plugin&nbsp;@macroforge/vite-plugin
15
- ``` ## How They Work Together
16
- <div class="flex justify-center"><div class="border-2 border-primary bg-primary/10 rounded-lg px-6 py-3 text-center"><div class="font-semibold text-primary">Your Code TypeScript with @derive decorators <div class="absolute top-0 h-px bg-border" style="width: 50%; left: 25%;"> <div class="flex flex-col items-center"> <div class="border border-border bg-card rounded-lg px-4 py-3 text-center w-full mt-1"><div class="font-medium text-foreground">TypeScript Plugin Language service integration <div class="border border-success/30 bg-success/10 rounded-md px-3 py-2 text-center"><div class="text-sm font-medium text-success-foreground">IDE Feedback Errors & completions <div class="border border-border bg-card rounded-lg px-4 py-3 text-center w-full mt-1"><div class="font-medium text-foreground">Vite Plugin Build-time transformation <div class="border border-success/30 bg-success/10 rounded-md px-3 py-2 text-center"><div class="text-sm font-medium text-success-foreground">Dev Server Hot reload<div class="text-sm font-medium text-success-foreground">Production Build Optimized output ## Detailed Guides
17
- - [TypeScript Plugin setup](../docs/integration/typescript-plugin)
18
- - [Vite Plugin configuration](../docs/integration/vite-plugin)
19
- - [Configuration options](../docs/integration/configuration)
2
+
3
+ Macroforge integrates with your development workflow through IDE plugins and build tool integration.
4
+
5
+ ## Overview
6
+
7
+ | Integration | Purpose | Package |
8
+ | ----------------- | --------------------------------- | ------------------------------- |
9
+ | TypeScript Plugin | IDE support (errors, completions) | `@macroforge/typescript-plugin` |
10
+ | Vite Plugin | Build-time macro expansion | `@macroforge/vite-plugin` |
11
+
12
+ ## Recommended Setup
13
+
14
+ For the best development experience, use both integrations:
15
+
16
+ 1. **TypeScript Plugin**: Provides real-time feedback in your IDE
17
+ 2. **Vite Plugin**: Expands macros during development and production builds
18
+
19
+ Bash
20
+
21
+ ```
22
+ # Install both plugins
23
+ npm install -D @macroforge/typescript-plugin @macroforge/vite-plugin
24
+ ```
25
+
26
+ ## How They Work Together
27
+
28
+ Your Code
29
+
30
+ TypeScript with @derive decorators
31
+
32
+ TypeScript Plugin
33
+
34
+ Language service integration
35
+
36
+ IDE Feedback
37
+
38
+ Errors & completions
39
+
40
+ Vite Plugin
41
+
42
+ Build-time transformation
43
+
44
+ Dev Server
45
+
46
+ Hot reload
47
+
48
+ Production Build
49
+
50
+ Optimized output
51
+
52
+ ## Detailed Guides
53
+
54
+ * [TypeScript Plugin setup](../docs/integration/typescript-plugin)
55
+ * [Vite Plugin configuration](../docs/integration/vite-plugin)
56
+ * [Configuration options](../docs/integration/configuration)