@macroforge/mcp-server 0.1.61 → 0.1.64
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## Identifier Concatenation: `
|
|
1
|
+
## Identifier Concatenation: ` content `
|
|
2
2
|
|
|
3
|
-
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block syntax. Everything inside `
|
|
3
|
+
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block syntax. Everything inside ` ` is concatenated without spaces:
|
|
4
4
|
|
|
5
5
|
Rust
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Rust
|
|
|
8
8
|
let field_name = "User";
|
|
9
9
|
|
|
10
10
|
let code = ts_template! {
|
|
11
|
-
function
|
|
11
|
+
function get@{field_name}() {
|
|
12
12
|
return this.@{field_name.to_lowercase()};
|
|
13
13
|
}
|
|
14
14
|
};
|
|
@@ -24,7 +24,7 @@ function getUser() {
|
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Without ident blocks, `@{}` always adds a space after for readability. Use `
|
|
27
|
+
Without ident blocks, `@{}` always adds a space after for readability. Use ` ` when you explicitly want concatenation:
|
|
28
28
|
|
|
29
29
|
Rust
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ let name = "Status";
|
|
|
35
35
|
ts_template! { namespace @{name} } // → "namespace Status"
|
|
36
36
|
|
|
37
37
|
// Without space (ident block)
|
|
38
|
-
ts_template! {
|
|
38
|
+
ts_template! { namespace@{name} } // → "namespaceStatus"
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Multiple interpolations can be combined:
|
|
@@ -46,5 +46,5 @@ Rust
|
|
|
46
46
|
let entity = "user";
|
|
47
47
|
let action = "create";
|
|
48
48
|
|
|
49
|
-
ts_template! { {
|
|
50
|
-
```
|
|
49
|
+
ts_template! { @{entity}_@{action} } // → "user_create"
|
|
50
|
+
```
|
|
@@ -17,7 +17,7 @@ let code = ts_template! {
|
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
19
|
User.prototype.toString = function () {
|
|
20
|
-
|
|
20
|
+
return "User instance";
|
|
21
21
|
};
|
|
22
22
|
```
|
|
23
23
|
|
|
@@ -31,7 +31,7 @@ When you need to build identifiers dynamically (like `getUser`, `setName`), use
|
|
|
31
31
|
let field_name = "User";
|
|
32
32
|
|
|
33
33
|
let code = ts_template! {
|
|
34
|
-
function
|
|
34
|
+
function get@{field_name}() {
|
|
35
35
|
return this.@{field_name.to_lowercase()};
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -41,7 +41,7 @@ let code = ts_template! {
|
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
function getUser() {
|
|
44
|
-
|
|
44
|
+
return this.user;
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -54,7 +54,7 @@ let name = "Status";
|
|
|
54
54
|
ts_template! { namespace @{name} } // → "namespace Status"
|
|
55
55
|
|
|
56
56
|
// Without space (ident block)
|
|
57
|
-
ts_template! {
|
|
57
|
+
ts_template! { namespace@{name} } // → "namespaceStatus"
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Multiple interpolations can be combined:
|
|
@@ -63,7 +63,7 @@ Multiple interpolations can be combined:
|
|
|
63
63
|
let entity = "user";
|
|
64
64
|
let action = "create";
|
|
65
65
|
|
|
66
|
-
ts_template! { {
|
|
66
|
+
ts_template! { @{entity}_@{action} } // → "user_create"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
<h2 id="comments">
|
|
@@ -346,4 +346,4 @@ let code = ts_template! {
|
|
|
346
346
|
console.log("many");
|
|
347
347
|
{/match}
|
|
348
348
|
};
|
|
349
|
-
```
|
|
349
|
+
```
|
|
@@ -11,27 +11,27 @@ The `macroforge_ts_quote` crate provides template-based code generation for Type
|
|
|
11
11
|
|
|
12
12
|
## Quick Reference
|
|
13
13
|
|
|
14
|
-
| Syntax | Description
|
|
15
|
-
| -------------------------------------------------------------- |
|
|
16
|
-
| `@{expr}` | Interpolate a Rust expression (adds space after)
|
|
14
|
+
| Syntax | Description |
|
|
15
|
+
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
16
|
+
| `@{expr}` | Interpolate a Rust expression (adds space after) |
|
|
17
17
|
| `{| content |}` | Ident block: concatenates without spaces (e.g., `{|get@{name}|}` → `getUser`) |
|
|
18
|
-
| `{> "comment" <}` | Block comment: outputs `/* comment */` (string preserves whitespace)
|
|
19
|
-
| `{>> "doc" <<}` | Doc comment: outputs `/** doc */` (string preserves whitespace)
|
|
20
|
-
| `@@{` | Escape for literal `@{` (e.g., `"@@{foo}"` → `@{foo}`)
|
|
21
|
-
| `"text @{expr}"` | String interpolation (auto-detected)
|
|
22
|
-
| `"'^template ${js}^'"` | JS backtick template literal (outputs `` `template ${js}` ``)
|
|
23
|
-
| `{#if cond}...{/if}` | Conditional block
|
|
24
|
-
| `{#if cond}...{:else}...{/if}` | Conditional with else
|
|
25
|
-
| `{#if a}...{:else if b}...{:else}...{/if}` | Full if/else-if/else chain
|
|
26
|
-
| `{#if let pattern = expr}...{/if}` | Pattern matching if-let
|
|
27
|
-
| `{#match expr}{:case pattern}...{/match}` | Match expression with case arms
|
|
28
|
-
| `{#for item in list}...{/for}` | Iterate over a collection
|
|
29
|
-
| `{#while cond}...{/while}` | While loop
|
|
30
|
-
| `{#while let pattern = expr}...{/while}` | While-let pattern matching loop
|
|
31
|
-
| `{$let name = expr}` | Define a local constant
|
|
32
|
-
| `{$let mut name = expr}` | Define a mutable local variable
|
|
33
|
-
| `{$do expr}` | Execute a side-effectful expression
|
|
34
|
-
| `{$typescript stream}` | Inject a TsStream, preserving its source and
|
|
18
|
+
| `{> "comment" <}` | Block comment: outputs `/* comment */` (string preserves whitespace) |
|
|
19
|
+
| `{>> "doc" <<}` | Doc comment: outputs `/** doc */` (string preserves whitespace) |
|
|
20
|
+
| `@@{` | Escape for literal `@{` (e.g., `"@@{foo}"` → `@{foo}`) |
|
|
21
|
+
| `"text @{expr}"` | String interpolation (auto-detected) |
|
|
22
|
+
| `"'^template ${js}^'"` | JS backtick template literal (outputs `` `template ${js}` ``) |
|
|
23
|
+
| `{#if cond}...{/if}` | Conditional block |
|
|
24
|
+
| `{#if cond}...{:else}...{/if}` | Conditional with else |
|
|
25
|
+
| `{#if a}...{:else if b}...{:else}...{/if}` | Full if/else-if/else chain |
|
|
26
|
+
| `{#if let pattern = expr}...{/if}` | Pattern matching if-let |
|
|
27
|
+
| `{#match expr}{:case pattern}...{/match}` | Match expression with case arms |
|
|
28
|
+
| `{#for item in list}...{/for}` | Iterate over a collection |
|
|
29
|
+
| `{#while cond}...{/while}` | While loop |
|
|
30
|
+
| `{#while let pattern = expr}...{/while}` | While-let pattern matching loop |
|
|
31
|
+
| `{$let name = expr}` | Define a local constant |
|
|
32
|
+
| `{$let mut name = expr}` | Define a mutable local variable |
|
|
33
|
+
| `{$do expr}` | Execute a side-effectful expression |
|
|
34
|
+
| `{$typescript stream}` | Inject a TsStream, preserving its source and runtime_patches (imports) |
|
|
35
35
|
|
|
36
36
|
**Note:** A single `@` not followed by `{` passes through unchanged (e.g., `email@domain.com` works as expected).
|
|
37
37
|
|
|
@@ -62,9 +62,9 @@ User.prototype.toString = function () {
|
|
|
62
62
|
};
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
## Identifier Concatenation: `
|
|
65
|
+
## Identifier Concatenation: ` content `
|
|
66
66
|
|
|
67
|
-
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block syntax. Everything inside `
|
|
67
|
+
When you need to build identifiers dynamically (like `getUser`, `setName`), use the ident block syntax. Everything inside ` ` is concatenated without spaces:
|
|
68
68
|
|
|
69
69
|
Rust
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ Rust
|
|
|
72
72
|
let field_name = "User";
|
|
73
73
|
|
|
74
74
|
let code = ts_template! {
|
|
75
|
-
function
|
|
75
|
+
function get@{field_name}() {
|
|
76
76
|
return this.@{field_name.to_lowercase()};
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -88,7 +88,7 @@ function getUser() {
|
|
|
88
88
|
}
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Without ident blocks, `@{}` always adds a space after for readability. Use `
|
|
91
|
+
Without ident blocks, `@{}` always adds a space after for readability. Use ` ` when you explicitly want concatenation:
|
|
92
92
|
|
|
93
93
|
Rust
|
|
94
94
|
|
|
@@ -99,7 +99,7 @@ let name = "Status";
|
|
|
99
99
|
ts_template! { namespace @{name} } // → "namespace Status"
|
|
100
100
|
|
|
101
101
|
// Without space (ident block)
|
|
102
|
-
ts_template! {
|
|
102
|
+
ts_template! { namespace@{name} } // → "namespaceStatus"
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
Multiple interpolations can be combined:
|
|
@@ -110,7 +110,7 @@ Rust
|
|
|
110
110
|
let entity = "user";
|
|
111
111
|
let action = "create";
|
|
112
112
|
|
|
113
|
-
ts_template! { {
|
|
113
|
+
ts_template! { @{entity}_@{action} } // → "user_create"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
## Comments: `{> "..." <}` and `{>> "..." <<}`
|
|
@@ -613,10 +613,10 @@ let code = ts_template! {
|
|
|
613
613
|
|
|
614
614
|
Common uses for `{$do}`:
|
|
615
615
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
616
|
+
- Incrementing counters: `{$do i += 1}`
|
|
617
|
+
- Building collections: `{$do vec.push(item)}`
|
|
618
|
+
- Setting flags: `{$do found = true}`
|
|
619
|
+
- Any mutating operation
|
|
620
620
|
|
|
621
621
|
## TsStream Injection: `{$typescript}`
|
|
622
622
|
|
|
@@ -727,7 +727,7 @@ pub fn derive_json_macro(input: TsStream) -> MacroResult {
|
|
|
727
727
|
}
|
|
728
728
|
```
|
|
729
729
|
|
|
730
|
-
### After (With
|
|
730
|
+
### After (With ts_template!)
|
|
731
731
|
|
|
732
732
|
Rust
|
|
733
733
|
|
|
@@ -782,8 +782,8 @@ This shows you exactly what was generated, making debugging easy!
|
|
|
782
782
|
|
|
783
783
|
You can mix template syntax with regular TypeScript. Braces `{}` are recognized as either:
|
|
784
784
|
|
|
785
|
-
|
|
786
|
-
|
|
785
|
+
- **Template tags** if they start with `#`, `$`, `:`, or `/`
|
|
786
|
+
- **Regular TypeScript blocks** otherwise
|
|
787
787
|
|
|
788
788
|
Rust
|
|
789
789
|
|
|
@@ -813,4 +813,4 @@ ts_template! {
|
|
|
813
813
|
1. Use `ts_template!` for complex code generation with loops/conditions
|
|
814
814
|
2. Use `ts_quote!` for simple, static statements
|
|
815
815
|
3. Keep templates readable - extract complex logic into variables
|
|
816
|
-
4. Don't nest templates too deeply - split into helper functions
|
|
816
|
+
4. Don't nest templates too deeply - split into helper functions
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"main": "dist/index.js",
|
|
26
26
|
"name": "@macroforge/mcp-server",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"macroforge": "0.1.
|
|
28
|
+
"macroforge": "0.1.64"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"macroforge": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"test": "node --test tests/**/*.test.js"
|
|
47
47
|
},
|
|
48
48
|
"type": "module",
|
|
49
|
-
"version": "0.1.
|
|
49
|
+
"version": "0.1.64"
|
|
50
50
|
}
|