dominus-cli 0.5.1 → 0.5.3
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/dist/index.js +177 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +101 -4
- package/dist/mcp.js.map +1 -1
- package/package.json +17 -16
- package/plugin/Dominus.rbxm +0 -0
- package/plugin/src/Properties.lua +117 -8
- package/plugin/src/UIBuilder.lua +27 -9
- package/plugin/src/init.server.lua +5 -1
package/dist/mcp.js
CHANGED
|
@@ -40,7 +40,8 @@ var CliMsg = {
|
|
|
40
40
|
EXECUTE_RUN_TEST: "cli:test:run",
|
|
41
41
|
EXECUTE_PLAY_TEST: "cli:test:play",
|
|
42
42
|
BUILD_UI: "cli:build:ui",
|
|
43
|
-
GET_REFLECTION: "cli:get:reflection"
|
|
43
|
+
GET_REFLECTION: "cli:get:reflection",
|
|
44
|
+
SERIALIZE_UI: "cli:serialize:ui"};
|
|
44
45
|
function createMessage(type, payload) {
|
|
45
46
|
return { id: nanoid(), type, payload, ts: Date.now() };
|
|
46
47
|
}
|
|
@@ -612,6 +613,79 @@ function getScriptIndex(projectId) {
|
|
|
612
613
|
}));
|
|
613
614
|
}
|
|
614
615
|
|
|
616
|
+
// src/agent/internal-memory.ts
|
|
617
|
+
var INTERNAL_MEMORY = `## Internal Memory \u2014 Known Quirks & Lessons
|
|
618
|
+
|
|
619
|
+
These are built-in lessons that ship with Dominus. Follow them exactly.
|
|
620
|
+
|
|
621
|
+
### create_ui \u2014 property format
|
|
622
|
+
- Each node accepts properties in **either** of two shapes:
|
|
623
|
+
- **Flattened (preferred)**: props as top-level keys next to \`ClassName\`, \`Name\`, \`Children\`.
|
|
624
|
+
\`\`\`json
|
|
625
|
+
{ "ClassName": "TextButton", "Name": "Btn", "Text": "OK", "Size": [0, 100, 0, 40] }
|
|
626
|
+
\`\`\`
|
|
627
|
+
- **Nested bag**: props grouped under \`properties\` / \`Properties\` / \`props\` / \`Props\`.
|
|
628
|
+
\`\`\`json
|
|
629
|
+
{ "ClassName": "TextButton", "Name": "Btn",
|
|
630
|
+
"properties": { "Text": "OK", "Size": [0, 100, 0, 40] } }
|
|
631
|
+
\`\`\`
|
|
632
|
+
- Do NOT mix a nested \`properties\` bag with flattened props of the same name \u2014 the bag wins.
|
|
633
|
+
- Reserved keys (never treated as instance properties): \`ClassName\`, \`className\`, \`Name\`, \`name\`, \`Children\`, \`children\`, \`properties\`, \`Properties\`, \`props\`, \`Props\`.
|
|
634
|
+
|
|
635
|
+
### build_multiple \u2014 schema is strict
|
|
636
|
+
- Top-level keys only: \`name\`, \`className\`, \`position\`, \`size\`, \`color\`, \`material\`, \`anchored\`, \`shape\`, \`transparency\`, \`parent\`, \`canCollide\`.
|
|
637
|
+
- Does NOT accept a nested \`properties\` bag. For anything outside those fields use \`insert_instance\` + \`set_properties\`.
|
|
638
|
+
- \`shape\` values: \`Block\`, \`Ball\`, \`Cylinder\`, \`Wedge\`.
|
|
639
|
+
|
|
640
|
+
### Color formats (accepted everywhere)
|
|
641
|
+
- Hex: \`"#RRGGBB"\`
|
|
642
|
+
- RGB string: \`"rgb(255, 128, 0)"\`
|
|
643
|
+
- BrickColor name: \`"Bright red"\`, \`"Institutional white"\`, \`"Really black"\`, etc.
|
|
644
|
+
- Array: \`[r, g, b]\` (0\u20131 floats) or \`[255, 128, 0]\` (auto-detected if any value > 1)
|
|
645
|
+
|
|
646
|
+
### UDim2 / UDim / Vector2 / Color3 coercion (create_ui)
|
|
647
|
+
- UDim2: \`[xScale, xOffset, yScale, yOffset]\` or \`{XScale, XOffset, YScale, YOffset}\`.
|
|
648
|
+
- UDim: \`[scale, offset]\` or a plain number (treated as pixels).
|
|
649
|
+
- Vector2 (e.g. \`AnchorPoint\`): \`[x, y]\` or \`{x, y}\`.
|
|
650
|
+
- 2-element arrays are auto-disambiguated by property name (\`AnchorPoint\` \u2192 Vector2, \`CornerRadius\` \u2192 UDim).
|
|
651
|
+
|
|
652
|
+
### Common GUI property names
|
|
653
|
+
- GUI uses \`Size\`/\`Position\` as **UDim2** \u2014 never Vector3.
|
|
654
|
+
- \`BackgroundColor3\`, \`TextColor3\`, \`BorderColor3\`, \`ImageColor3\` \u2192 Color3.
|
|
655
|
+
- \`Font\` accepts a string enum name like \`"GothamBold"\`, \`"SourceSans"\`.
|
|
656
|
+
- Enum properties take the string name: \`"Center"\`, \`"Left"\`, \`"Fit"\`.
|
|
657
|
+
|
|
658
|
+
### Tool selection cheat-sheet
|
|
659
|
+
- Single 3D part \u2192 \`create_part\`
|
|
660
|
+
- Many 3D parts (tree, building, vehicle) \u2192 \`build_multiple\` with \`groupName\`
|
|
661
|
+
- Full UI tree \u2192 \`create_ui\` (one call, never loop \`insert_instance\` for UI)
|
|
662
|
+
- **Convert/export existing UI \u2192 \`serialize_ui\`** (NOT get_descendants_properties)
|
|
663
|
+
- Adjusting an existing instance \u2192 \`set_properties\` (not \`run_code\`)
|
|
664
|
+
- Anything exotic or procedural \u2192 \`run_code\` as last resort
|
|
665
|
+
|
|
666
|
+
### Verification habits
|
|
667
|
+
- After a build, call \`get_explorer\` or \`get_selection\` to confirm the tree looks right.
|
|
668
|
+
- After editing a script, read it back.
|
|
669
|
+
- After \`run_code\`, check \`get_output\` for errors.
|
|
670
|
+
|
|
671
|
+
### serialize_ui \u2014 the RIGHT tool for UI conversion
|
|
672
|
+
- **Use \`serialize_ui\` when converting existing UI to Roact/React/Fusion components.** It returns a minimal JSON tree with only non-default properties, already in JSON-friendly formats.
|
|
673
|
+
- **Do NOT use \`get_descendants_properties\` for UI conversion** \u2014 it returns a flat list with ~50+ properties per instance (including read-only, deprecated, nil, and default values), which bloats context and confuses conversion.
|
|
674
|
+
- \`serialize_ui\` output maps 1:1 to \`create_ui\` input \u2014 you can round-trip UI through it.
|
|
675
|
+
- The tree structure preserves parent-child hierarchy, so Roact/React children mapping is direct.
|
|
676
|
+
|
|
677
|
+
### UI \u2192 Roact/React conversion cheat-sheet
|
|
678
|
+
- \`serialize_ui\` path \u2192 JSON tree \u2192 map each node to \`Roact.createElement(ClassName, props, childrenDict)\`
|
|
679
|
+
- UDim2 arrays \`[xS, xO, yS, yO]\` \u2192 \`UDim2.new(xS, xO, yS, yO)\`
|
|
680
|
+
- Color3 hex strings \u2192 \`Color3.fromHex("#RRGGBB")\`
|
|
681
|
+
- Vector2 arrays \u2192 \`Vector2.new(x, y)\`
|
|
682
|
+
- UDim arrays \u2192 \`UDim.new(s, o)\`
|
|
683
|
+
- Enum strings like \`"Center"\` \u2192 \`Enum.TextXAlignment.Center\`
|
|
684
|
+
- FontFace \u2192 \`Font.new(family, weight, style)\`
|
|
685
|
+
- UI modifiers (UICorner, UIStroke, UIGradient, UIListLayout, UIPadding) are CHILDREN not props
|
|
686
|
+
- Use instance Name as dictionary key in children table
|
|
687
|
+
`;
|
|
688
|
+
|
|
615
689
|
// src/mcp/server.ts
|
|
616
690
|
var bridge;
|
|
617
691
|
async function startMcpServer() {
|
|
@@ -630,6 +704,8 @@ async function startMcpServer() {
|
|
|
630
704
|
const mcp = new McpServer({
|
|
631
705
|
name: "dominus",
|
|
632
706
|
version: "0.2.1"
|
|
707
|
+
}, {
|
|
708
|
+
instructions: INTERNAL_MEMORY
|
|
633
709
|
});
|
|
634
710
|
mcp.tool(
|
|
635
711
|
"read_script",
|
|
@@ -692,14 +768,15 @@ async function startMcpServer() {
|
|
|
692
768
|
);
|
|
693
769
|
mcp.tool(
|
|
694
770
|
"get_descendants_properties",
|
|
695
|
-
"Easily get all descendants of a UI instance (or any instance) and all of their properties.",
|
|
771
|
+
"Easily get all descendants of a UI instance (or any instance) and all of their properties. By default uses compact mode which strips read-only, nil, deprecated, and default-valued properties to keep responses small.",
|
|
696
772
|
{
|
|
697
773
|
path: z.string().describe('Full instance path (e.g., "Workspace.Part", "StarterGui.ScreenGui")'),
|
|
774
|
+
compact: z.boolean().optional().default(true).describe("Strip noisy/default properties (default true). Set false for full dump."),
|
|
698
775
|
outputFile: z.string().optional().describe("Optional file path to write to prevent limit errors/timeouts")
|
|
699
776
|
},
|
|
700
|
-
async ({ path: path2, outputFile }) => {
|
|
777
|
+
async ({ path: path2, compact, outputFile }) => {
|
|
701
778
|
assertConnected();
|
|
702
|
-
const res = await bridge.sendRequest(CliMsg.GET_DESCENDANTS_PROPERTIES, { path: path2, outputFile }, 1e3 * 60 * 5);
|
|
779
|
+
const res = await bridge.sendRequest(CliMsg.GET_DESCENDANTS_PROPERTIES, { path: path2, compact, outputFile }, 1e3 * 60 * 5);
|
|
703
780
|
return { content: [{ type: "text", text: JSON.stringify(res.payload, null, 2) }] };
|
|
704
781
|
}
|
|
705
782
|
);
|
|
@@ -1016,6 +1093,26 @@ async function startMcpServer() {
|
|
|
1016
1093
|
return { content: [{ type: "text", text: JSON.stringify(res.payload, null, 2) }] };
|
|
1017
1094
|
}
|
|
1018
1095
|
);
|
|
1096
|
+
mcp.tool(
|
|
1097
|
+
"serialize_ui",
|
|
1098
|
+
"Serialize an existing Roblox UI tree into a compact, create_ui-compatible JSON tree. This is the reverse of create_ui \u2014 reads any GUI instance and returns a declarative JSON tree with ClassName, Name, non-default properties (Color3 as hex, UDim2 as arrays, etc.), and Children. Perfect for: converting existing UI to Roact/React components, cloning/templating, understanding UI structure, or refactoring. Use this INSTEAD of get_descendants_properties when you need to recreate or convert UI.",
|
|
1099
|
+
{
|
|
1100
|
+
path: z.string().describe('Instance path to serialize (e.g. "StarterGui.MyScreenGui")'),
|
|
1101
|
+
maxDepth: z.number().optional().default(50).describe("Maximum tree depth (default 50)")
|
|
1102
|
+
},
|
|
1103
|
+
async ({ path: path2, maxDepth }) => {
|
|
1104
|
+
assertConnected();
|
|
1105
|
+
const res = await bridge.sendRequest(
|
|
1106
|
+
CliMsg.SERIALIZE_UI,
|
|
1107
|
+
{ path: path2, maxDepth },
|
|
1108
|
+
1e3 * 60 * 2
|
|
1109
|
+
);
|
|
1110
|
+
if (!res.payload.success) {
|
|
1111
|
+
return { content: [{ type: "text", text: `Error: ${res.payload.error ?? "Serialization failed"}` }] };
|
|
1112
|
+
}
|
|
1113
|
+
return { content: [{ type: "text", text: JSON.stringify(res.payload.tree, null, 2) }] };
|
|
1114
|
+
}
|
|
1115
|
+
);
|
|
1019
1116
|
mcp.tool(
|
|
1020
1117
|
"recall_memory",
|
|
1021
1118
|
"Search persistent memory for facts about the current Roblox project",
|