@macroforge/mcp-server 0.1.64 → 0.1.66
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 +7 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/docs-loader.d.ts.map +1 -1
- package/dist/tools/docs-loader.js +1 -1
- package/dist/tools/docs-loader.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +84 -85
- package/dist/tools/index.js.map +1 -1
- package/docs/BOOK.md +8 -33
- package/docs/api/api-overview.md +4 -4
- package/docs/api/expand-sync.md +3 -2
- package/docs/api/native-plugin.md +5 -2
- package/docs/api/position-mapper.md +7 -4
- package/docs/api/transform-sync.md +7 -5
- package/docs/builtin-macros/deserialize/all-options.md +7 -21
- package/docs/builtin-macros/deserialize/combining-with-serialize.md +7 -5
- package/docs/builtin-macros/deserialize/enum-support.md +8 -6
- package/docs/builtin-macros/deserialize/error-handling.md +10 -9
- package/docs/builtin-macros/deserialize/interface-support.md +9 -4
- package/docs/builtin-macros/deserialize/runtime-validation.md +10 -21
- package/docs/builtin-macros/deserialize/serde-options.md +19 -31
- package/docs/builtin-macros/deserialize/type-alias-support.md +7 -6
- package/docs/builtin-macros/macros-overview/detailed-documentation.md +9 -9
- package/docs/builtin-macros/macros-overview/enum-support.md +3 -2
- package/docs/builtin-macros/macros-overview/interface-support.md +3 -2
- package/docs/builtin-macros/macros-overview/overview.md +13 -12
- package/docs/builtin-macros/macros-overview/type-alias-support.md +3 -2
- package/docs/builtin-macros/macros-overview.md +27 -23
- package/docs/builtin-macros/partial-eq/example.md +188 -232
- package/docs/builtin-macros/partial-eq/overview.md +18 -18
- package/docs/builtin-macros/serialize/example.md +11 -3
- package/docs/builtin-macros/serialize/overview.md +12 -11
- package/docs/builtin-macros/serialize/type-specific-serialization.md +12 -12
- package/docs/concepts/architecture.md +23 -22
- package/docs/concepts/derive-system/built-in-vs-custom-macros.md +4 -3
- package/docs/concepts/derive-system/overview.md +27 -24
- package/docs/concepts/derive-system.md +31 -27
- package/docs/concepts/how-macros-work.md +23 -21
- package/docs/custom-macros/custom-overview.md +9 -8
- package/docs/custom-macros/rust-setup.md +11 -10
- package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +2 -1
- package/docs/custom-macros/ts-macro-derive/adding-imports.md +2 -1
- package/docs/custom-macros/ts-macro-derive/attribute-options.md +1 -1
- package/docs/custom-macros/ts-macro-derive/complete-example.md +1 -1
- package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +1 -1
- package/docs/custom-macros/ts-macro-derive/function-signature.md +1 -1
- package/docs/custom-macros/ts-macro-derive/overview.md +3 -2
- package/docs/custom-macros/ts-macro-derive/parsing-input.md +1 -1
- package/docs/custom-macros/ts-macro-derive/returning-errors.md +1 -1
- package/docs/custom-macros/ts-macro-derive.md +7 -4
- package/docs/custom-macros/ts-quote/backtick-template-literals.md +5 -3
- package/docs/custom-macros/ts-quote/comments-and.md +3 -2
- package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +12 -11
- package/docs/custom-macros/ts-quote/conditionals-ifif.md +1 -1
- package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +5 -3
- package/docs/custom-macros/ts-quote/interpolation-expr.md +18 -11
- package/docs/custom-macros/ts-quote/iteration-for.md +1 -1
- package/docs/custom-macros/ts-quote/local-constants-let.md +1 -1
- package/docs/custom-macros/ts-quote/match-expressions-match.md +1 -1
- package/docs/custom-macros/ts-quote/overview.md +4 -2
- package/docs/custom-macros/ts-quote/pattern-matching-if-let.md +2 -2
- package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +1 -1
- package/docs/custom-macros/ts-quote/quick-reference.md +24 -23
- package/docs/custom-macros/ts-quote/side-effects-do.md +6 -5
- package/docs/custom-macros/ts-quote/string-interpolation-text-expr.md +3 -3
- package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +1 -1
- package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +3 -2
- package/docs/custom-macros/ts-quote/while-loops-while.md +1 -1
- package/docs/custom-macros/ts-quote.md +30 -19
- package/docs/getting-started/first-macro.md +5 -4
- package/docs/getting-started/installation.md +20 -17
- package/docs/integration/cli.md +11 -5
- package/docs/integration/configuration.md +7 -9
- package/docs/integration/integration-overview.md +5 -5
- package/docs/integration/mcp-server.md +17 -8
- package/docs/integration/svelte-preprocessor.md +18 -14
- package/docs/integration/typescript-plugin.md +14 -12
- package/docs/integration/vite-plugin.md +13 -11
- package/docs/language-servers/ls-overview.md +18 -12
- package/docs/language-servers/svelte-ls.md +9 -11
- package/docs/language-servers/svelte.md +18 -17
- package/docs/language-servers/zed-extensions.md +14 -11
- package/docs/language-servers/zed.md +19 -13
- package/docs/roadmap/roadmap.md +8 -6
- package/package.json +4 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Template Syntax
|
|
2
2
|
|
|
3
|
-
The `macroforge_ts_quote` crate provides template-based code generation for TypeScript. The
|
|
3
|
+
The `macroforge_ts_quote` crate provides template-based code generation for TypeScript. The
|
|
4
|
+
`ts_template!` macro uses Svelte + Rust-inspired syntax for control flow and interpolation, making
|
|
5
|
+
it easy to generate complex TypeScript code.
|
|
4
6
|
|
|
5
7
|
## Available Macros
|
|
6
8
|
|
|
@@ -33,7 +35,8 @@ The `macroforge_ts_quote` crate provides template-based code generation for Type
|
|
|
33
35
|
| `{$do expr}` | Execute a side-effectful expression |
|
|
34
36
|
| `{$typescript stream}` | Inject a TsStream, preserving its source and runtime_patches (imports) |
|
|
35
37
|
|
|
36
|
-
**Note:** A single `@` not followed by `{` passes through unchanged (e.g., `email@domain.com` works
|
|
38
|
+
**Note:** A single `@` not followed by `{` passes through unchanged (e.g., `email@domain.com` works
|
|
39
|
+
as expected).
|
|
37
40
|
|
|
38
41
|
## Interpolation: `@{expr}`
|
|
39
42
|
|
|
@@ -62,9 +65,10 @@ User.prototype.toString = function () {
|
|
|
62
65
|
};
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
## Identifier Concatenation: `
|
|
68
|
+
## Identifier Concatenation: `content`
|
|
66
69
|
|
|
67
|
-
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block
|
|
70
|
+
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block
|
|
71
|
+
syntax. Everything inside `` is concatenated without spaces:
|
|
68
72
|
|
|
69
73
|
Rust
|
|
70
74
|
|
|
@@ -88,7 +92,8 @@ function getUser() {
|
|
|
88
92
|
}
|
|
89
93
|
```
|
|
90
94
|
|
|
91
|
-
Without ident blocks, `@{}` always adds a space after for readability. Use
|
|
95
|
+
Without ident blocks, `@{}` always adds a space after for readability. Use `` when you explicitly
|
|
96
|
+
want concatenation:
|
|
92
97
|
|
|
93
98
|
Rust
|
|
94
99
|
|
|
@@ -115,7 +120,8 @@ ts_template! { @{entity}_@{action} } // → "user_create"
|
|
|
115
120
|
|
|
116
121
|
## Comments: `{> "..." <}` and `{>> "..." <<}`
|
|
117
122
|
|
|
118
|
-
Since Rust's tokenizer strips whitespace before macros see them, use string literals to preserve
|
|
123
|
+
Since Rust's tokenizer strips whitespace before macros see them, use string literals to preserve
|
|
124
|
+
exact spacing in comments:
|
|
119
125
|
|
|
120
126
|
### Block Comments
|
|
121
127
|
|
|
@@ -232,7 +238,8 @@ let code = ts_template! {
|
|
|
232
238
|
|
|
233
239
|
## Backtick Template Literals: `"'^...^'"`
|
|
234
240
|
|
|
235
|
-
For JavaScript template literals (backtick strings), use the `'^...^'` syntax. This outputs actual
|
|
241
|
+
For JavaScript template literals (backtick strings), use the `'^...^'` syntax. This outputs actual
|
|
242
|
+
backticks and passes through `${"${}"}` for JS interpolation:
|
|
236
243
|
|
|
237
244
|
Rust
|
|
238
245
|
|
|
@@ -252,7 +259,8 @@ TypeScript
|
|
|
252
259
|
const html = `<div>${content}</div>`;
|
|
253
260
|
```
|
|
254
261
|
|
|
255
|
-
You can mix Rust `@{}` interpolation (evaluated at macro expansion time) with JS `${"${}"}`
|
|
262
|
+
You can mix Rust `@{}` interpolation (evaluated at macro expansion time) with JS `${"${}"}`
|
|
263
|
+
interpolation (evaluated at runtime):
|
|
256
264
|
|
|
257
265
|
Rust
|
|
258
266
|
|
|
@@ -597,7 +605,8 @@ let code = ts_template! {
|
|
|
597
605
|
|
|
598
606
|
## Side Effects: `{$do}`
|
|
599
607
|
|
|
600
|
-
Execute an expression for its side effects without producing output. This is commonly used with
|
|
608
|
+
Execute an expression for its side effects without producing output. This is commonly used with
|
|
609
|
+
mutable variables:
|
|
601
610
|
|
|
602
611
|
Rust
|
|
603
612
|
|
|
@@ -620,7 +629,8 @@ Common uses for `{$do}`:
|
|
|
620
629
|
|
|
621
630
|
## TsStream Injection: `{$typescript}`
|
|
622
631
|
|
|
623
|
-
Inject another TsStream into your template, preserving both its source code and runtime patches
|
|
632
|
+
Inject another TsStream into your template, preserving both its source code and runtime patches
|
|
633
|
+
(like imports added via `add_import()`):
|
|
624
634
|
|
|
625
635
|
Rust
|
|
626
636
|
|
|
@@ -758,14 +768,15 @@ pub fn derive_json_macro(input: TsStream) -> MacroResult {
|
|
|
758
768
|
|
|
759
769
|
## How It Works
|
|
760
770
|
|
|
761
|
-
1.
|
|
762
|
-
2.
|
|
763
|
-
3.
|
|
764
|
-
4.
|
|
771
|
+
1. **Compile-Time:** The template is parsed during macro expansion
|
|
772
|
+
2. **String Building:** Generates Rust code that builds a TypeScript string at runtime
|
|
773
|
+
3. **SWC Parsing:** The generated string is parsed with SWC to produce a typed AST
|
|
774
|
+
4. **Result:** Returns `Stmt` that can be used in `MacroResult` patches
|
|
765
775
|
|
|
766
776
|
## Return Type
|
|
767
777
|
|
|
768
|
-
`ts_template!` returns a `Result<Stmt, TsSynError>` by default. The macro automatically unwraps and
|
|
778
|
+
`ts_template!` returns a `Result<Stmt, TsSynError>` by default. The macro automatically unwraps and
|
|
779
|
+
provides helpful error messages showing the generated TypeScript code if parsing fails:
|
|
769
780
|
|
|
770
781
|
Text
|
|
771
782
|
|
|
@@ -810,7 +821,7 @@ ts_template! {
|
|
|
810
821
|
|
|
811
822
|
## Best Practices
|
|
812
823
|
|
|
813
|
-
1.
|
|
814
|
-
2.
|
|
815
|
-
3.
|
|
816
|
-
4.
|
|
824
|
+
1. Use `ts_template!` for complex code generation with loops/conditions
|
|
825
|
+
2. Use `ts_quote!` for simple, static statements
|
|
826
|
+
3. Keep templates readable - extract complex logic into variables
|
|
827
|
+
4. Don't nest templates too deeply - split into helper functions
|
|
@@ -4,7 +4,8 @@ Let's create a class that uses Macroforge's derive macros to automatically gener
|
|
|
4
4
|
|
|
5
5
|
## Creating a Class with Derive Macros
|
|
6
6
|
|
|
7
|
-
Start by creating a simple `User` class. We'll use the `@derive` decorator to automatically generate
|
|
7
|
+
Start by creating a simple `User` class. We'll use the `@derive` decorator to automatically generate
|
|
8
|
+
methods.
|
|
8
9
|
|
|
9
10
|
Before (Your Code)
|
|
10
11
|
|
|
@@ -163,6 +164,6 @@ Field-level decorators let you control exactly how each field is handled by the
|
|
|
163
164
|
|
|
164
165
|
## Next Steps
|
|
165
166
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
- [Learn how macros work under the hood](../../docs/concepts)
|
|
168
|
+
- [Explore all Debug options](../../docs/builtin-macros/debug)
|
|
169
|
+
- [Create your own custom macros](../../docs/custom-macros)
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
# Installation
|
|
2
2
|
|
|
3
|
-
Get started with Macroforge in just a few minutes. Install the package and configure your project to
|
|
3
|
+
Get started with Macroforge in just a few minutes. Install the package and configure your project to
|
|
4
|
+
start using TypeScript macros.
|
|
4
5
|
|
|
5
6
|
## Requirements
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
- Node.js 24.0 or later
|
|
9
|
+
- TypeScript 5.9 or later
|
|
9
10
|
|
|
10
11
|
## Install the Package
|
|
11
12
|
|
|
12
13
|
Install Macroforge using your preferred package manager:
|
|
13
14
|
|
|
14
|
-
npm
|
|
15
|
+
npm
|
|
15
16
|
|
|
16
17
|
```
|
|
17
18
|
npm install macroforge
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
bun
|
|
21
|
+
bun
|
|
21
22
|
|
|
22
23
|
```
|
|
23
24
|
bun add macroforge
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
pnpm
|
|
27
|
+
pnpm
|
|
27
28
|
|
|
28
29
|
```
|
|
29
30
|
pnpm add macroforge
|
|
@@ -31,13 +32,15 @@ pnpm add macroforge
|
|
|
31
32
|
|
|
32
33
|
Info
|
|
33
34
|
|
|
34
|
-
Macroforge includes pre-built native binaries for macOS (x64, arm64), Linux (x64, arm64), and
|
|
35
|
+
Macroforge includes pre-built native binaries for macOS (x64, arm64), Linux (x64, arm64), and
|
|
36
|
+
Windows (x64, arm64).
|
|
35
37
|
|
|
36
38
|
## Basic Usage
|
|
37
39
|
|
|
38
|
-
The simplest way to use Macroforge is with the built-in derive macros. Add a `@derive` comment
|
|
40
|
+
The simplest way to use Macroforge is with the built-in derive macros. Add a `@derive` comment
|
|
41
|
+
decorator to your class:
|
|
39
42
|
|
|
40
|
-
user.ts
|
|
43
|
+
user.ts
|
|
41
44
|
|
|
42
45
|
```
|
|
43
46
|
/** @derive(Debug, Clone, PartialEq) */
|
|
@@ -61,7 +64,7 @@ class User {
|
|
|
61
64
|
|
|
62
65
|
For the best development experience, add the TypeScript plugin to your `tsconfig.json`:
|
|
63
66
|
|
|
64
|
-
tsconfig.json
|
|
67
|
+
tsconfig.json
|
|
65
68
|
|
|
66
69
|
```
|
|
67
70
|
{
|
|
@@ -77,15 +80,15 @@ tsconfig.json
|
|
|
77
80
|
|
|
78
81
|
This enables features like:
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
- Accurate error positions in your source code
|
|
84
|
+
- Autocompletion for generated methods
|
|
85
|
+
- Type checking for expanded code
|
|
83
86
|
|
|
84
87
|
## Build Integration (Vite)
|
|
85
88
|
|
|
86
89
|
If you're using Vite, add the plugin to your config for automatic macro expansion during build:
|
|
87
90
|
|
|
88
|
-
vite.config.ts
|
|
91
|
+
vite.config.ts
|
|
89
92
|
|
|
90
93
|
```
|
|
91
94
|
import macroforge from "@macroforge/vite-plugin";
|
|
@@ -105,6 +108,6 @@ export default defineConfig({
|
|
|
105
108
|
|
|
106
109
|
Now that you have Macroforge installed, learn how to use it:
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
- [Create your first macro](../docs/getting-started/first-macro)
|
|
112
|
+
- [Understand how macros work](../docs/concepts)
|
|
113
|
+
- [Explore built-in macros](../docs/builtin-macros)
|
package/docs/integration/cli.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
macroforge v0.1.48
|
|
4
4
|
|
|
5
|
-
This binary provides command-line utilities for working with Macroforge TypeScript macros. It is
|
|
5
|
+
This binary provides command-line utilities for working with Macroforge TypeScript macros. It is
|
|
6
|
+
designed for development workflows, enabling macro expansion and type checking without requiring
|
|
7
|
+
Node.js integration.
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -89,11 +91,14 @@ macroforge expand src/user.ts --builtin-only
|
|
|
89
91
|
|
|
90
92
|
Note
|
|
91
93
|
|
|
92
|
-
By default, the CLI uses Node.js for full macro support (including external macros). It must be run
|
|
94
|
+
By default, the CLI uses Node.js for full macro support (including external macros). It must be run
|
|
95
|
+
from your project's root directory where `macroforge` and any external macro packages are installed
|
|
96
|
+
in `node_modules`.
|
|
93
97
|
|
|
94
98
|
### macroforge tsc
|
|
95
99
|
|
|
96
|
-
Runs TypeScript type checking with macro expansion. This wraps `tsc --noEmit` and expands macros
|
|
100
|
+
Runs TypeScript type checking with macro expansion. This wraps `tsc --noEmit` and expands macros
|
|
101
|
+
before type checking, so your generated methods are properly type-checked.
|
|
97
102
|
|
|
98
103
|
Bash
|
|
99
104
|
|
|
@@ -220,11 +225,12 @@ done
|
|
|
220
225
|
|
|
221
226
|
## Built-in vs Full Mode
|
|
222
227
|
|
|
223
|
-
By default, the CLI uses Node.js for full macro support including external macros. Use
|
|
228
|
+
By default, the CLI uses Node.js for full macro support including external macros. Use
|
|
229
|
+
`--builtin-only` for faster expansion when you only need built-in macros:
|
|
224
230
|
|
|
225
231
|
| Feature | Default (Node.js) | `--builtin-only` (Rust) |
|
|
226
232
|
| --------------- | -------------------------------------- | ----------------------- |
|
|
227
233
|
| Built-in macros | Yes | Yes |
|
|
228
234
|
| External macros | Yes | No |
|
|
229
235
|
| Performance | Standard | Faster |
|
|
230
|
-
| Dependencies | Requires `macroforge` in node\_modules | None |
|
|
236
|
+
| Dependencies | Requires `macroforge` in node\_modules | None |
|
|
@@ -6,7 +6,7 @@ Macroforge can be configured with a `macroforge.json` file in your project root.
|
|
|
6
6
|
|
|
7
7
|
Create a `macroforge.json` file:
|
|
8
8
|
|
|
9
|
-
macroforge.json
|
|
9
|
+
macroforge.json
|
|
10
10
|
|
|
11
11
|
```
|
|
12
12
|
{
|
|
@@ -26,15 +26,13 @@ macroforge.json
|
|
|
26
26
|
|
|
27
27
|
### allowNativeMacros
|
|
28
28
|
|
|
29
|
-
| Type
|
|
30
|
-
| Default | `true` |
|
|
29
|
+
| Type | `boolean` | | Default | `true` |
|
|
31
30
|
|
|
32
31
|
Enable or disable native (Rust) macro packages. Set to `false` to only allow built-in macros.
|
|
33
32
|
|
|
34
33
|
### macroPackages
|
|
35
34
|
|
|
36
|
-
| Type
|
|
37
|
-
| Default | `[]` |
|
|
35
|
+
| Type | `string[]` | | Default | `[]` |
|
|
38
36
|
|
|
39
37
|
List of npm packages that provide macros. Macroforge will look for macros in these packages.
|
|
40
38
|
|
|
@@ -51,8 +49,7 @@ JSON
|
|
|
51
49
|
|
|
52
50
|
### keepDecorators
|
|
53
51
|
|
|
54
|
-
| Type
|
|
55
|
-
| Default | `false` |
|
|
52
|
+
| Type | `boolean` | | Default | `false` |
|
|
56
53
|
|
|
57
54
|
Keep `@derive` decorators in the output. Useful for debugging.
|
|
58
55
|
|
|
@@ -98,7 +95,8 @@ JSON
|
|
|
98
95
|
|
|
99
96
|
Warning
|
|
100
97
|
|
|
101
|
-
Be careful when increasing limits, as this could allow malicious macros to consume excessive
|
|
98
|
+
Be careful when increasing limits, as this could allow malicious macros to consume excessive
|
|
99
|
+
resources.
|
|
102
100
|
|
|
103
101
|
## Environment Variables
|
|
104
102
|
|
|
@@ -113,4 +111,4 @@ Bash
|
|
|
113
111
|
|
|
114
112
|
```
|
|
115
113
|
MACROFORGE_DEBUG=1 npm run dev
|
|
116
|
-
```
|
|
114
|
+
```
|
|
@@ -13,8 +13,8 @@ Macroforge integrates with your development workflow through IDE plugins and bui
|
|
|
13
13
|
|
|
14
14
|
For the best development experience, use both integrations:
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
2.
|
|
16
|
+
1. **TypeScript Plugin**: Provides real-time feedback in your IDE
|
|
17
|
+
2. **Vite Plugin**: Expands macros during development and production builds
|
|
18
18
|
|
|
19
19
|
Bash
|
|
20
20
|
|
|
@@ -51,6 +51,6 @@ Optimized output
|
|
|
51
51
|
|
|
52
52
|
## Detailed Guides
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
- [TypeScript Plugin setup](../docs/integration/typescript-plugin)
|
|
55
|
+
- [Vite Plugin configuration](../docs/integration/vite-plugin)
|
|
56
|
+
- [Configuration options](../docs/integration/configuration)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# MCP Server
|
|
2
2
|
|
|
3
|
-
The MCP (Model Context Protocol) server enables AI assistants to understand and work with Macroforge
|
|
3
|
+
The MCP (Model Context Protocol) server enables AI assistants to understand and work with Macroforge
|
|
4
|
+
macros, providing documentation lookup, code validation, and macro expansion.
|
|
4
5
|
|
|
5
|
-
The local (stdio) version of the MCP server is available via the
|
|
6
|
+
The local (stdio) version of the MCP server is available via the
|
|
7
|
+
[`@macroforge/mcp-server`](https://www.npmjs.com/package/@macroforge/mcp-server) npm package. You
|
|
8
|
+
can either install it globally and then reference it in your configuration or run it with `npx`:
|
|
6
9
|
|
|
7
10
|
Bash
|
|
8
11
|
|
|
@@ -26,9 +29,10 @@ The `[scope]` must be `user`, `project` or `local`.
|
|
|
26
29
|
|
|
27
30
|
## Claude Desktop
|
|
28
31
|
|
|
29
|
-
In the Settings > Developer section, click on Edit Config. It will open the folder with a
|
|
32
|
+
In the Settings > Developer section, click on Edit Config. It will open the folder with a
|
|
33
|
+
`claude_desktop_config.json` file in it. Edit the file to include the following configuration:
|
|
30
34
|
|
|
31
|
-
claude\_desktop\_config.json
|
|
35
|
+
claude\_desktop\_config.json
|
|
32
36
|
|
|
33
37
|
```
|
|
34
38
|
{
|
|
@@ -43,9 +47,11 @@ claude\_desktop\_config.json
|
|
|
43
47
|
|
|
44
48
|
## Codex CLI
|
|
45
49
|
|
|
46
|
-
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to
|
|
50
|
+
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to
|
|
51
|
+
[the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more
|
|
52
|
+
advanced setups):
|
|
47
53
|
|
|
48
|
-
config.toml
|
|
54
|
+
config.toml
|
|
49
55
|
|
|
50
56
|
```
|
|
51
57
|
[mcp_servers.macroforge]
|
|
@@ -67,7 +73,8 @@ The `[scope]` must be `user`, `project` or `local`.
|
|
|
67
73
|
|
|
68
74
|
## Other Clients
|
|
69
75
|
|
|
70
|
-
If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers
|
|
76
|
+
If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers
|
|
77
|
+
and use `npx` as the command and `-y @macroforge/mcp-server` as the arguments.
|
|
71
78
|
|
|
72
79
|
## Available Tools
|
|
73
80
|
|
|
@@ -83,4 +90,6 @@ The MCP server provides five tools for AI assistants:
|
|
|
83
90
|
|
|
84
91
|
Note
|
|
85
92
|
|
|
86
|
-
For code validation and expansion features (`macroforge-autofixer`, `expand-code`,
|
|
93
|
+
For code validation and expansion features (`macroforge-autofixer`, `expand-code`,
|
|
94
|
+
`get-macro-info`), the MCP server requires `macroforge` as a peer dependency. Install it in your
|
|
95
|
+
project with `npm install macroforge`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Svelte Preprocessor
|
|
2
2
|
|
|
3
|
-
The Svelte preprocessor expands Macroforge macros in `<script>` blocks before Svelte compilation,
|
|
3
|
+
The Svelte preprocessor expands Macroforge macros in `<script>` blocks before Svelte compilation,
|
|
4
|
+
enabling seamless macro usage in Svelte components.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ npm install -D @macroforge/svelte-preprocessor
|
|
|
14
15
|
|
|
15
16
|
Add the preprocessor to your `svelte.config.js`:
|
|
16
17
|
|
|
17
|
-
svelte.config.js
|
|
18
|
+
svelte.config.js
|
|
18
19
|
|
|
19
20
|
```
|
|
20
21
|
import adapter from '@sveltejs/adapter-auto';
|
|
@@ -38,13 +39,14 @@ export default config;
|
|
|
38
39
|
|
|
39
40
|
Warning
|
|
40
41
|
|
|
41
|
-
Always place `macroforgePreprocess()` **before** other preprocessors like `vitePreprocess()`. This
|
|
42
|
+
Always place `macroforgePreprocess()` **before** other preprocessors like `vitePreprocess()`. This
|
|
43
|
+
ensures macros are expanded before TypeScript compilation.
|
|
42
44
|
|
|
43
45
|
## Usage
|
|
44
46
|
|
|
45
47
|
Use `@derive` decorators directly in your Svelte component scripts:
|
|
46
48
|
|
|
47
|
-
UserCard.svelte
|
|
49
|
+
UserCard.svelte
|
|
48
50
|
|
|
49
51
|
```
|
|
50
52
|
<script lang="ts">
|
|
@@ -91,10 +93,10 @@ macroforgePreprocess({
|
|
|
91
93
|
|
|
92
94
|
The preprocessor:
|
|
93
95
|
|
|
94
|
-
1.
|
|
95
|
-
2.
|
|
96
|
-
3.
|
|
97
|
-
4.
|
|
96
|
+
1. Intercepts `<script lang="ts">` blocks in `.svelte` files
|
|
97
|
+
2. Checks for `@derive` decorators (skips files without them)
|
|
98
|
+
3. Expands macros using the native Macroforge binary
|
|
99
|
+
4. Returns the transformed code for Svelte compilation
|
|
98
100
|
|
|
99
101
|
Tip
|
|
100
102
|
|
|
@@ -102,9 +104,10 @@ Files without `@derive` decorators are passed through unchanged with zero overhe
|
|
|
102
104
|
|
|
103
105
|
## SvelteKit Integration
|
|
104
106
|
|
|
105
|
-
For SvelteKit projects, you can use both the preprocessor (for `.svelte` files) and the Vite plugin
|
|
107
|
+
For SvelteKit projects, you can use both the preprocessor (for `.svelte` files) and the Vite plugin
|
|
108
|
+
(for standalone `.ts` files):
|
|
106
109
|
|
|
107
|
-
svelte.config.js
|
|
110
|
+
svelte.config.js
|
|
108
111
|
|
|
109
112
|
```
|
|
110
113
|
// svelte.config.js
|
|
@@ -119,7 +122,7 @@ export default {
|
|
|
119
122
|
};
|
|
120
123
|
```
|
|
121
124
|
|
|
122
|
-
vite.config.ts
|
|
125
|
+
vite.config.ts
|
|
123
126
|
|
|
124
127
|
```
|
|
125
128
|
// vite.config.ts
|
|
@@ -139,7 +142,7 @@ export default defineConfig({
|
|
|
139
142
|
|
|
140
143
|
The preprocessor works seamlessly with Vitest for testing Svelte components:
|
|
141
144
|
|
|
142
|
-
vitest.config.ts
|
|
145
|
+
vitest.config.ts
|
|
143
146
|
|
|
144
147
|
```
|
|
145
148
|
// vitest.config.ts
|
|
@@ -163,7 +166,8 @@ export default defineConfig({
|
|
|
163
166
|
|
|
164
167
|
## Svelte 5 Runes Compatibility
|
|
165
168
|
|
|
166
|
-
The preprocessor is fully compatible with Svelte 5 runes (`$state`, `$derived`, `$props`, etc.).
|
|
169
|
+
The preprocessor is fully compatible with Svelte 5 runes (`$state`, `$derived`, `$props`, etc.).
|
|
170
|
+
Files using runes but without `@derive` decorators are skipped entirely.
|
|
167
171
|
|
|
168
172
|
Svelte
|
|
169
173
|
|
|
@@ -182,4 +186,4 @@ Svelte
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
</script>
|
|
185
|
-
```
|
|
189
|
+
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# TypeScript Plugin
|
|
2
2
|
|
|
3
|
-
The TypeScript plugin provides IDE integration for Macroforge, including error reporting,
|
|
3
|
+
The TypeScript plugin provides IDE integration for Macroforge, including error reporting,
|
|
4
|
+
completions, and type checking for generated code.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ npm install -D @macroforge/typescript-plugin
|
|
|
14
15
|
|
|
15
16
|
Add the plugin to your `tsconfig.json`:
|
|
16
17
|
|
|
17
|
-
tsconfig.json
|
|
18
|
+
tsconfig.json
|
|
18
19
|
|
|
19
20
|
```
|
|
20
21
|
{
|
|
@@ -30,17 +31,18 @@ tsconfig.json
|
|
|
30
31
|
|
|
31
32
|
## VS Code Setup
|
|
32
33
|
|
|
33
|
-
VS Code uses its own TypeScript version by default. To use the workspace version (which includes
|
|
34
|
+
VS Code uses its own TypeScript version by default. To use the workspace version (which includes
|
|
35
|
+
plugins):
|
|
34
36
|
|
|
35
|
-
1.
|
|
36
|
-
2.
|
|
37
|
-
3.
|
|
37
|
+
1. Open the Command Palette (`Cmd/Ctrl + Shift + P`)
|
|
38
|
+
2. Search for "TypeScript: Select TypeScript Version"
|
|
39
|
+
3. Choose "Use Workspace Version"
|
|
38
40
|
|
|
39
41
|
Tip
|
|
40
42
|
|
|
41
43
|
Add this setting to your `.vscode/settings.json` to make it permanent:
|
|
42
44
|
|
|
43
|
-
.vscode/settings.json
|
|
45
|
+
.vscode/settings.json
|
|
44
46
|
|
|
45
47
|
```
|
|
46
48
|
{
|
|
@@ -90,13 +92,13 @@ const copy = user.clone();
|
|
|
90
92
|
|
|
91
93
|
### Plugin Not Loading
|
|
92
94
|
|
|
93
|
-
1.
|
|
94
|
-
2.
|
|
95
|
-
3.
|
|
95
|
+
1. Ensure you're using the workspace TypeScript version
|
|
96
|
+
2. Restart the TypeScript server (Command Palette → "TypeScript: Restart TS Server")
|
|
97
|
+
3. Check that the plugin is listed in `tsconfig.json`
|
|
96
98
|
|
|
97
99
|
### Errors Not Showing
|
|
98
100
|
|
|
99
101
|
If errors from macros aren't appearing:
|
|
100
102
|
|
|
101
|
-
1.
|
|
102
|
-
2.
|
|
103
|
+
1. Make sure the Vite plugin is also installed (for source file watching)
|
|
104
|
+
2. Check that your file is saved (plugins process on save)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Vite Plugin
|
|
2
2
|
|
|
3
|
-
The Vite plugin provides build-time macro expansion, transforming your code during development and
|
|
3
|
+
The Vite plugin provides build-time macro expansion, transforming your code during development and
|
|
4
|
+
production builds.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ npm install -D @macroforge/vite-plugin
|
|
|
14
15
|
|
|
15
16
|
Add the plugin to your `vite.config.ts`:
|
|
16
17
|
|
|
17
|
-
vite.config.ts
|
|
18
|
+
vite.config.ts
|
|
18
19
|
|
|
19
20
|
```
|
|
20
21
|
import macroforge from "@macroforge/vite-plugin";
|
|
@@ -64,7 +65,7 @@ macroforge({
|
|
|
64
65
|
|
|
65
66
|
### React (Vite)
|
|
66
67
|
|
|
67
|
-
vite.config.ts
|
|
68
|
+
vite.config.ts
|
|
68
69
|
|
|
69
70
|
```
|
|
70
71
|
import macroforge from "@macroforge/vite-plugin";
|
|
@@ -81,7 +82,7 @@ export default defineConfig({
|
|
|
81
82
|
|
|
82
83
|
### SvelteKit
|
|
83
84
|
|
|
84
|
-
vite.config.ts
|
|
85
|
+
vite.config.ts
|
|
85
86
|
|
|
86
87
|
```
|
|
87
88
|
import macroforge from "@macroforge/vite-plugin";
|
|
@@ -98,20 +99,21 @@ export default defineConfig({
|
|
|
98
99
|
|
|
99
100
|
Note
|
|
100
101
|
|
|
101
|
-
Always place the Macroforge plugin before other framework plugins to ensure macros are expanded
|
|
102
|
+
Always place the Macroforge plugin before other framework plugins to ensure macros are expanded
|
|
103
|
+
first.
|
|
102
104
|
|
|
103
105
|
## Development Server
|
|
104
106
|
|
|
105
107
|
During development, the plugin:
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
- Watches for file changes
|
|
110
|
+
- Expands macros on save
|
|
111
|
+
- Provides HMR support for expanded code
|
|
110
112
|
|
|
111
113
|
## Production Build
|
|
112
114
|
|
|
113
115
|
During production builds, the plugin:
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
- Expands all macros in the source files
|
|
118
|
+
- Generates type declaration files
|
|
119
|
+
- Strips `@derive` decorators from output
|