@stelis/say-ur-intent 0.0.5 → 0.0.6
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.
|
@@ -28,15 +28,31 @@ const NAME_BY_ADDRESS = new Map(CONTRACT_NAME_REGISTRY.flatMap((entry) => {
|
|
|
28
28
|
* Replace every registered package address in PTB Mermaid label text with its
|
|
29
29
|
* registered name. Only exact normalized-address matches are replaced; unknown
|
|
30
30
|
* addresses are left unchanged. Mermaid node ids are synthetic (`command0`,
|
|
31
|
-
* `input0`, ...) and the
|
|
32
|
-
*
|
|
31
|
+
* `input0`, ...) and the address only appears inside quoted label text.
|
|
32
|
+
*
|
|
33
|
+
* Registered names are Move Registry names like `@deepbook/core`. Mermaid v11
|
|
34
|
+
* reads a literal `@` as node/edge metadata syntax even inside a quoted label
|
|
35
|
+
* and crashes the renderer, so the inserted name's `@` is written as the Mermaid
|
|
36
|
+
* decimal entity `#64;`, which renders as `@` without a literal `@` in the
|
|
37
|
+
* source. The copyable Mermaid source keeps raw addresses (it is built from the
|
|
38
|
+
* unmodified text), so this only affects the named, rendered graph.
|
|
33
39
|
*/
|
|
34
40
|
export function applyContractNamesToMermaid(mermaidText) {
|
|
35
41
|
let text = mermaidText;
|
|
36
42
|
for (const [address, name] of NAME_BY_ADDRESS) {
|
|
37
43
|
if (text.includes(address)) {
|
|
38
|
-
text = text.split(address).join(name);
|
|
44
|
+
text = text.split(address).join(mermaidSafeName(name));
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
return text;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Escape characters that break Mermaid label parsing. A literal `@` triggers
|
|
51
|
+
* Mermaid v11 node/edge metadata syntax (even inside quotes) and throws, so it
|
|
52
|
+
* is written as the `#64;` decimal entity, which renders as `@`. Other Move
|
|
53
|
+
* Registry name characters (letters, `/`, `-`, `_`, `.`, `:`) are valid in
|
|
54
|
+
* Mermaid label text.
|
|
55
|
+
*/
|
|
56
|
+
function mermaidSafeName(name) {
|
|
57
|
+
return name.replace(/@/g, "#64;");
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stelis/say-ur-intent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"mcpName": "io.github.stelis-dev/say-ur-intent",
|
|
5
5
|
"description": "Say Ur Intent is a local-first toolkit for helping AI applications and users inspect Sui DeFi actions before execution.",
|
|
6
6
|
"license": "MIT",
|