@macroforge/mcp-server 0.1.40 → 0.1.49

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 +65 -46
  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 +114 -54
  7. package/docs/api/transform-sync.md +85 -59
  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 +11 -43
  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 +171 -97
  28. package/docs/concepts/how-macros-work.md +89 -37
  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 +799 -519
  57. package/docs/getting-started/first-macro.md +61 -32
  58. package/docs/getting-started/installation.md +109 -66
  59. package/docs/integration/cli.md +212 -103
  60. package/docs/integration/configuration.md +114 -71
  61. package/docs/integration/integration-overview.md +54 -17
  62. package/docs/integration/mcp-server.md +83 -42
  63. package/docs/integration/svelte-preprocessor.md +183 -126
  64. package/docs/integration/typescript-plugin.md +101 -54
  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 -39
  68. package/docs/language-servers/zed.md +81 -45
  69. package/docs/roadmap/roadmap.md +75 -53
  70. package/docs/sections.json +333 -44
  71. package/package.json +27 -28
@@ -1,73 +1,116 @@
1
1
  # Configuration
2
- *Macroforge can be configured with a `macroforge.json` file in your project root.*
3
- ## Configuration File
4
- Create a `macroforge.json` file:
5
- ```
6
- {
7
- "allowNativeMacros": true,
8
- "macroPackages": [],
9
- "keepDecorators": false,
10
- "limits": {
11
- "maxExecutionTimeMs": 5000,
12
- "maxMemoryBytes": 104857600,
13
- "maxOutputSize": 10485760,
14
- "maxDiagnostics": 100
15
- }
16
- }
17
- ``` ## Options Reference
18
- ### allowNativeMacros
19
- | Type | `boolean` |
20
- | Default | `true` |
21
- Enable or disable native (Rust) macro packages. Set to `false` 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
- {
28
- "macroPackages": [
29
- "@my-org/custom-macros",
30
- "community-macros"
31
- ]
32
- }
33
- ``` ### keepDecorators
34
- | Type | `boolean` |
35
- | Default | `false` |
36
- Keep `@derive` decorators in the output. Useful for debugging.
37
- ### limits
38
- Configure resource limits for macro expansion:
39
- ```
40
- {
41
- "limits": {
42
- // Maximum time for a single macro expansion (ms)
43
- "maxExecutionTimeMs": 5000,
44
-
45
- // Maximum memory usage (bytes)
46
- "maxMemoryBytes": 104857600, // 100MB
47
-
48
- // Maximum size of generated code (bytes)
49
- "maxOutputSize": 10485760, // 10MB
50
-
51
- // Maximum number of diagnostics per file
52
- "maxDiagnostics": 100
53
- }
54
- }
55
- ``` ## Macro Runtime Overrides
56
- Override settings for specific macros:
57
- ```
58
- {
59
- "macroRuntimeOverrides": {
60
- "@my-org/macros": {
61
- "maxExecutionTimeMs": 10000
62
- }
63
- }
64
- }
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 |
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 |
70
110
  | `MACROFORGE_LOG_FILE` | Write logs to a file |
71
- ```
72
- MACROFORGE_DEBUG=1 npm run dev
73
- ```**
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
- | --- | --- | --- |
2
+
3
+ Macroforge integrates with your development workflow through IDE plugins and build tool integration.
4
+
5
+ ## Overview
6
+
7
+ | Integration | Purpose | Package |
8
+ | ----------------- | --------------------------------- | ------------------------------- |
6
9
  | 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
- # Install both plugins
14
- npm install -D @macroforge/typescript-plugin @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)
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)
@@ -1,45 +1,86 @@
1
1
  # MCP Server
2
- *The MCP (Model Context Protocol) server enables AI assistants to understand and work with Macroforge macros, providing documentation lookup, code validation, and macro expansion.*
3
- The local (stdio) version of the MCP server is available via the [`@macroforge/mcp-server`](https://www.npmjs.com/package/@macroforge/mcp-server) npm package. You can either install it globally and then reference it in your configuration or run it with `npx`:
4
- ```
5
- npx -y @macroforge/mcp-server
6
- ``` Here's how to set it up in some common MCP clients:
7
- ## Claude Code
8
- To include the local MCP version in Claude Code, simply run the following command:
9
- ```
10
- claude mcp add -t stdio -s [scope] macroforge -- npx -y @macroforge/mcp-server
11
- ``` The `[scope]` must be `user`, `project` or `local`.
12
- ## Claude Desktop
13
- In the Settings > Developer section, click on Edit Config. It will open the folder with a `claude_desktop_config.json` file in it. Edit the file to include the following configuration:
14
- ```
15
- &#123;
16
- "mcpServers": &#123;
17
- "macroforge": &#123;
18
- "command": "npx",
19
- "args": ["-y", "@macroforge/mcp-server"]
20
- &#125;
21
- &#125;
22
- &#125;
23
- ``` ## Codex CLI
24
- Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
25
- ```
2
+
3
+ The MCP (Model Context Protocol) server enables AI assistants to understand and work with Macroforge macros, providing documentation lookup, code validation, and macro expansion.
4
+
5
+ The local (stdio) version of the MCP server is available via the [`@macroforge/mcp-server`](https://www.npmjs.com/package/@macroforge/mcp-server) npm package. You can either install it globally and then reference it in your configuration or run it with `npx`:
6
+
7
+ Bash
8
+
9
+ ```
10
+ npx -y @macroforge/mcp-server
11
+ ```
12
+
13
+ Here's how to set it up in some common MCP clients:
14
+
15
+ ## Claude Code
16
+
17
+ To include the local MCP version in Claude Code, simply run the following command:
18
+
19
+ Bash
20
+
21
+ ```
22
+ claude mcp add -t stdio -s [scope] macroforge -- npx -y @macroforge/mcp-server
23
+ ```
24
+
25
+ The `[scope]` must be `user`, `project` or `local`.
26
+
27
+ ## Claude Desktop
28
+
29
+ In the Settings > Developer section, click on Edit Config. It will open the folder with a `claude_desktop_config.json` file in it. Edit the file to include the following configuration:
30
+
31
+ claude\_desktop\_config.json
32
+
33
+ ```
34
+ {
35
+     "mcpServers": {
36
+         "macroforge": {
37
+             "command": "npx",
38
+             "args": ["-y", "@macroforge/mcp-server"]
39
+         }
40
+     }
41
+ }
42
+ ```
43
+
44
+ ## Codex CLI
45
+
46
+ Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
47
+
48
+ config.toml
49
+
50
+ ```
26
51
  [mcp_servers.macroforge]
27
- command = "npx"
28
- args = ["-y", "@macroforge/mcp-server"]
29
- ``` ## Gemini CLI
30
- To include the local MCP version in Gemini CLI, simply run the following command:
31
- ```
32
- gemini mcp add -t stdio -s [scope] macroforge npx -y @macroforge/mcp-server
33
- ``` The `[scope]` must be `user`, `project` or `local`.
34
- ## Other Clients
35
- If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers and use `npx` as the command and `-y @macroforge/mcp-server` as the arguments.
36
- ## Available Tools
37
- The MCP server provides five tools for AI assistants:
38
- | Tool | Description |
39
- | --- | --- |
40
- | `list-sections` | Lists all available Macroforge documentation sections |
41
- | `get-documentation` | Retrieves full documentation for one or more sections |
52
+ command = "npx"
53
+ args = ["-y", "@macroforge/mcp-server"]
54
+ ```
55
+
56
+ ## Gemini CLI
57
+
58
+ To include the local MCP version in Gemini CLI, simply run the following command:
59
+
60
+ Bash
61
+
62
+ ```
63
+ gemini mcp add -t stdio -s [scope] macroforge npx -y @macroforge/mcp-server
64
+ ```
65
+
66
+ The `[scope]` must be `user`, `project` or `local`.
67
+
68
+ ## Other Clients
69
+
70
+ If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers and use `npx` as the command and `-y @macroforge/mcp-server` as the arguments.
71
+
72
+ ## Available Tools
73
+
74
+ The MCP server provides five tools for AI assistants:
75
+
76
+ | Tool | Description |
77
+ | ---------------------- | ---------------------------------------------------------------- |
78
+ | `list-sections` | Lists all available Macroforge documentation sections |
79
+ | `get-documentation` | Retrieves full documentation for one or more sections |
42
80
  | `macroforge-autofixer` | Validates code with `@derive` decorators and returns diagnostics |
43
- | `expand-code` | Expands macros and returns the transformed TypeScript code |
44
- | `get-macro-info` | Retrieves documentation for macros and field decorators |
45
- > **Note:** For code validation and expansion features (macroforge-autofixer, expand-code, get-macro-info), the MCP server requires macroforge as a peer dependency. Install it in your project with npm install macroforge.
81
+ | `expand-code` | Expands macros and returns the transformed TypeScript code |
82
+ | `get-macro-info` | Retrieves documentation for macros and field decorators |
83
+
84
+ Note
85
+
86
+ For code validation and expansion features (`macroforge-autofixer`, `expand-code`, `get-macro-info`), the MCP server requires `macroforge` as a peer dependency. Install it in your project with `npm install macroforge`.