@macroforge/mcp-server 0.1.42 → 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.
- package/LICENSE +22 -0
- package/docs/BOOK.md +165 -0
- package/docs/api/api-overview.md +67 -48
- package/docs/api/expand-sync.md +88 -53
- package/docs/api/native-plugin.md +121 -71
- package/docs/api/position-mapper.md +115 -55
- package/docs/api/transform-sync.md +86 -60
- package/docs/builtin-macros/clone.md +0 -20
- package/docs/builtin-macros/debug.md +0 -23
- package/docs/builtin-macros/default.md +1 -40
- package/docs/builtin-macros/deserialize/example.md +8 -1416
- package/docs/builtin-macros/deserialize.md +8 -1416
- package/docs/builtin-macros/hash.md +0 -42
- package/docs/builtin-macros/macros-overview/detailed-documentation.md +13 -0
- package/docs/builtin-macros/macros-overview/enum-support.md +30 -0
- package/docs/builtin-macros/macros-overview/interface-support.md +28 -0
- package/docs/builtin-macros/macros-overview/overview.md +36 -0
- package/docs/builtin-macros/macros-overview/type-alias-support.md +62 -0
- package/docs/builtin-macros/macros-overview.md +171 -130
- package/docs/builtin-macros/ord.md +0 -25
- package/docs/builtin-macros/partial-eq.md +0 -84
- package/docs/builtin-macros/partial-ord.md +2 -32
- package/docs/builtin-macros/serialize.md +2 -62
- package/docs/concepts/architecture.md +125 -48
- package/docs/concepts/derive-system/built-in-vs-custom-macros.md +13 -0
- package/docs/concepts/derive-system/overview.md +200 -0
- package/docs/concepts/derive-system.md +157 -104
- package/docs/concepts/how-macros-work.md +98 -47
- package/docs/custom-macros/custom-overview.md +79 -57
- package/docs/custom-macros/rust-setup.md +138 -99
- package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +40 -31
- package/docs/custom-macros/ts-macro-derive/adding-imports.md +14 -11
- package/docs/custom-macros/ts-macro-derive/attribute-options.md +20 -25
- package/docs/custom-macros/ts-macro-derive/complete-example.md +40 -38
- package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +49 -47
- package/docs/custom-macros/ts-macro-derive/function-signature.md +12 -0
- package/docs/custom-macros/ts-macro-derive/overview.md +9 -7
- package/docs/custom-macros/ts-macro-derive/parsing-input.md +20 -18
- package/docs/custom-macros/ts-macro-derive/returning-errors.md +15 -13
- package/docs/custom-macros/ts-macro-derive.md +322 -228
- package/docs/custom-macros/ts-quote/backtick-template-literals.md +19 -7
- package/docs/custom-macros/ts-quote/comments-and.md +56 -22
- package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +89 -98
- package/docs/custom-macros/ts-quote/conditionals-ifif.md +35 -29
- package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +30 -22
- package/docs/custom-macros/ts-quote/iteration-for.md +48 -40
- package/docs/custom-macros/ts-quote/local-constants-let.md +23 -21
- package/docs/custom-macros/ts-quote/match-expressions-match.md +46 -38
- package/docs/custom-macros/ts-quote/overview.md +5 -10
- package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +39 -0
- package/docs/custom-macros/ts-quote/quick-reference.md +50 -129
- package/docs/custom-macros/ts-quote/side-effects-do.md +13 -78
- package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +36 -0
- package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +43 -35
- package/docs/custom-macros/ts-quote/while-loops-while.md +31 -23
- package/docs/custom-macros/ts-quote.md +800 -520
- package/docs/getting-started/first-macro.md +98 -71
- package/docs/getting-started/installation.md +109 -65
- package/docs/integration/cli.md +214 -105
- package/docs/integration/configuration.md +115 -72
- package/docs/integration/integration-overview.md +55 -18
- package/docs/integration/mcp-server.md +84 -43
- package/docs/integration/svelte-preprocessor.md +183 -126
- package/docs/integration/typescript-plugin.md +101 -53
- package/docs/integration/vite-plugin.md +116 -76
- package/docs/language-servers/ls-overview.md +37 -21
- package/docs/language-servers/svelte.md +69 -38
- package/docs/language-servers/zed.md +81 -44
- package/docs/roadmap/roadmap.md +75 -53
- package/docs/sections.json +333 -44
- package/package.json +27 -28
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
## DeriveInput Structure
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
Rust
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
struct DeriveInput {
|
|
7
|
+
pub ident: Ident, // The type name
|
|
8
|
+
pub span: SpanIR, // Span of the type definition
|
|
9
|
+
pub attrs: Vec<Attribute>, // Decorators (excluding @derive)
|
|
10
|
+
pub data: Data, // The parsed type data
|
|
11
|
+
pub context: MacroContextIR, // Macro context with spans
|
|
12
|
+
|
|
13
|
+
// Helper methods
|
|
14
|
+
fn name(&self) -> &str; // Get the type name
|
|
15
|
+
fn decorator_span(&self) -> SpanIR; // Span of @derive decorator
|
|
16
|
+
fn as_class(&self) -> Option<&DataClass>;
|
|
17
|
+
fn as_interface(&self) -> Option<&DataInterface>;
|
|
18
|
+
fn as_enum(&self) -> Option<&DataEnum>;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
enum
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
enum Data {
|
|
22
|
+
Class(DataClass),
|
|
23
|
+
Interface(DataInterface),
|
|
24
|
+
Enum(DataEnum),
|
|
25
|
+
TypeAlias(DataTypeAlias),
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
impl
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
impl DataClass {
|
|
29
|
+
fn fields(&self) -> &[FieldIR];
|
|
30
|
+
fn methods(&self) -> &[MethodSigIR];
|
|
31
|
+
fn field_names(&self) -> impl Iterator<Item = &str>;
|
|
32
|
+
fn field(&self, name: &str) -> Option<&FieldIR>;
|
|
33
|
+
fn body_span(&self) -> SpanIR; // For inserting code into class body
|
|
34
|
+
fn type_params(&self) -> &[String]; // Generic type parameters
|
|
35
|
+
fn heritage(&self) -> &[String]; // extends/implements clauses
|
|
36
|
+
fn is_abstract(&self) -> bool;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
impl
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
impl DataInterface {
|
|
40
|
+
fn fields(&self) -> &[InterfaceFieldIR];
|
|
41
|
+
fn methods(&self) -> &[InterfaceMethodIR];
|
|
42
|
+
fn field_names(&self) -> impl Iterator<Item = &str>;
|
|
43
|
+
fn field(&self, name: &str) -> Option<&InterfaceFieldIR>;
|
|
44
|
+
fn body_span(&self) -> SpanIR;
|
|
45
|
+
fn type_params(&self) -> &[String];
|
|
46
|
+
fn heritage(&self) -> &[String]; // extends clauses
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
impl
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
impl DataEnum {
|
|
50
|
+
fn variants(&self) -> &[EnumVariantIR];
|
|
51
|
+
fn variant_names(&self) -> impl Iterator<Item = &str>;
|
|
52
|
+
fn variant(&self, name: &str) -> Option<&EnumVariantIR>;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
impl
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
impl DataTypeAlias {
|
|
56
|
+
fn body(&self) -> &TypeBody;
|
|
57
|
+
fn type_params(&self) -> &[String];
|
|
58
|
+
fn is_union(&self) -> bool;
|
|
59
|
+
fn is_object(&self) -> bool;
|
|
60
|
+
fn as_union(&self) -> Option<&[TypeMember]>;
|
|
61
|
+
fn as_object(&self) -> Option<&[InterfaceFieldIR]>;
|
|
60
62
|
}
|
|
61
63
|
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## Function Signature
|
|
2
|
+
|
|
3
|
+
Rust
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError>
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Parameter | Description |
|
|
10
|
+
| ----------------------------------- | ------------------------------------------------------- |
|
|
11
|
+
| `input: TsStream` | Token stream containing the class/interface AST |
|
|
12
|
+
| `Result<TsStream, MacroforgeError>` | Returns generated code or an error with source location |
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ts\_macro\_derive
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `#[ts_macro_derive]` attribute is a Rust procedural macro that registers your function as a Macroforge derive macro.
|
|
4
4
|
|
|
5
5
|
## Basic Syntax
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Rust
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
use macroforge_ts::macros::ts_macro_derive;
|
|
11
|
+
use macroforge_ts::ts_syn::{TsStream, MacroforgeError};
|
|
10
12
|
|
|
11
13
|
#[ts_macro_derive(MacroName)]
|
|
12
|
-
pub
|
|
13
|
-
|
|
14
|
+
pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
|
|
15
|
+
// Macro implementation
|
|
14
16
|
}
|
|
15
17
|
```
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Use `parse_ts_macro_input!` to convert the token stream:
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Rust
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
use macroforge_ts::ts_syn::{Data, DeriveInput, parse_ts_macro_input};
|
|
7
9
|
|
|
8
10
|
#[ts_macro_derive(MyMacro)]
|
|
9
|
-
pub
|
|
10
|
-
|
|
11
|
+
pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
|
|
12
|
+
let input = parse_ts_macro_input!(input as DeriveInput);
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
// Access class data
|
|
15
|
+
match &input.data {
|
|
16
|
+
Data::Class(class) => {
|
|
17
|
+
let class_name = input.name();
|
|
18
|
+
let fields = class.fields();
|
|
19
|
+
// ...
|
|
20
|
+
}
|
|
21
|
+
Data::Interface(interface) => {
|
|
22
|
+
// Handle interfaces
|
|
23
|
+
}
|
|
24
|
+
Data::Enum(_) => {
|
|
25
|
+
// Handle enums (if supported)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
```
|
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Use `MacroforgeError` to report errors with source locations:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Rust
|
|
6
|
+
|
|
7
|
+
```
|
|
6
8
|
#[ts_macro_derive(ClassOnly)]
|
|
7
|
-
pub
|
|
8
|
-
|
|
9
|
+
pub fn class_only(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
|
|
10
|
+
let input = parse_ts_macro_input!(input as DeriveInput);
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
match &input.data {
|
|
13
|
+
Data::Class(_) => {
|
|
14
|
+
// Generate code...
|
|
15
|
+
Ok(body! { /* ... */ })
|
|
16
|
+
}
|
|
17
|
+
_ => Err(MacroforgeError::new(
|
|
18
|
+
input.decorator_span(),
|
|
19
|
+
"@derive(ClassOnly) can only be used on classes",
|
|
20
|
+
)),
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
```
|