dominus-cli 0.5.7 → 0.5.9
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 +194 -6
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +199 -4
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -34,14 +34,23 @@ var CliMsg = {
|
|
|
34
34
|
INSERT_INSTANCE: "cli:insert",
|
|
35
35
|
DELETE_INSTANCE: "cli:delete",
|
|
36
36
|
GET_SELECTION: "cli:get:selection",
|
|
37
|
+
SELECT: "cli:select",
|
|
37
38
|
SEARCH_SCRIPTS: "cli:search:scripts",
|
|
38
39
|
GET_OUTPUT: "cli:get:output",
|
|
39
40
|
RUN_TESTS: "cli:run:tests",
|
|
40
41
|
EXECUTE_RUN_TEST: "cli:test:run",
|
|
41
42
|
EXECUTE_PLAY_TEST: "cli:test:play",
|
|
43
|
+
END_TEST: "cli:test:end",
|
|
42
44
|
BUILD_UI: "cli:build:ui",
|
|
43
45
|
GET_REFLECTION: "cli:get:reflection",
|
|
44
|
-
|
|
46
|
+
UPLOAD_ASSET: "cli:upload:asset",
|
|
47
|
+
SERIALIZE_UI: "cli:serialize:ui",
|
|
48
|
+
MOVE_INSTANCE: "cli:move:instance",
|
|
49
|
+
UNDO: "cli:undo",
|
|
50
|
+
REDO: "cli:redo",
|
|
51
|
+
BULK_SET_PROPERTIES: "cli:bulk:set:properties",
|
|
52
|
+
FIND_REPLACE_SCRIPTS: "cli:find:replace:scripts"
|
|
53
|
+
};
|
|
45
54
|
function createMessage(type, payload) {
|
|
46
55
|
return { id: nanoid(), type, payload, ts: Date.now() };
|
|
47
56
|
}
|
|
@@ -668,13 +677,20 @@ These are built-in lessons that ship with Dominus. Follow them exactly.
|
|
|
668
677
|
|
|
669
678
|
### NEVER use run_code for:
|
|
670
679
|
- Getting properties of an instance \u2192 use \`get_properties\` or \`serialize_ui\`
|
|
671
|
-
- Dumping selection info \u2192 use \`
|
|
680
|
+
- Dumping selection info \u2192 use \`inspect_selection\` (ONE call does it all)
|
|
681
|
+
- Inspecting an instance + its children \u2192 use \`inspect_instance\`
|
|
682
|
+
- Converting UI to Roact/React \u2192 use \`convert_ui_to_code\`
|
|
672
683
|
- Creating instances \u2192 use \`create_part\`, \`create_ui\`, \`insert_instance\`, \`build_multiple\`
|
|
673
684
|
- Modifying properties \u2192 use \`set_properties\` or \`bulk_set_properties\`
|
|
674
685
|
- Reading scripts \u2192 use \`read_script\`
|
|
675
686
|
- Browsing the explorer \u2192 use \`get_explorer\`
|
|
676
687
|
\`run_code\` is ONLY for procedural logic, terrain generation, raycasts, physics queries, or custom algorithms with no tool equivalent.
|
|
677
688
|
|
|
689
|
+
### Composite skill tools (prefer these over chaining)
|
|
690
|
+
- \`inspect_selection\` \u2014 Returns paths + compact properties for all selected instances in ONE call. Use when user says "my selection" or "what I selected".
|
|
691
|
+
- \`inspect_instance\` \u2014 Returns compact properties + children tree for a single instance in ONE call. Combines get_properties + get_explorer.
|
|
692
|
+
- \`convert_ui_to_code\` \u2014 Serializes a UI tree and generates a Roact/React component. Use when user says "turn this into a component" or "convert to React".
|
|
693
|
+
|
|
678
694
|
### Verification habits
|
|
679
695
|
- After a build, call \`get_explorer\` or \`get_selection\` to confirm the tree looks right.
|
|
680
696
|
- After editing a script, read it back.
|
|
@@ -715,7 +731,7 @@ async function startMcpServer() {
|
|
|
715
731
|
}
|
|
716
732
|
const mcp = new McpServer({
|
|
717
733
|
name: "dominus",
|
|
718
|
-
version: "0.5.
|
|
734
|
+
version: "0.5.8"
|
|
719
735
|
}, {
|
|
720
736
|
instructions: INTERNAL_MEMORY
|
|
721
737
|
});
|
|
@@ -728,6 +744,101 @@ async function startMcpServer() {
|
|
|
728
744
|
for (const p of parts) r += `[${luaStr(p)}]`;
|
|
729
745
|
return r;
|
|
730
746
|
}
|
|
747
|
+
function cleanNum(n) {
|
|
748
|
+
if (Number.isInteger(n)) return String(n);
|
|
749
|
+
const rounded = Math.round(n * 1e3) / 1e3;
|
|
750
|
+
return String(rounded);
|
|
751
|
+
}
|
|
752
|
+
function generateComponentCode(tree, componentName, framework) {
|
|
753
|
+
const isReact = framework === "react";
|
|
754
|
+
const lib = isReact ? "React" : "Roact";
|
|
755
|
+
const lines = [];
|
|
756
|
+
lines.push(`local ${lib} = require(game.ReplicatedStorage.Packages.${isReact ? "React" : "Roact"})`);
|
|
757
|
+
if (isReact) {
|
|
758
|
+
lines.push(`local e = React.createElement`);
|
|
759
|
+
} else {
|
|
760
|
+
lines.push(`local e = Roact.createElement`);
|
|
761
|
+
}
|
|
762
|
+
lines.push("");
|
|
763
|
+
lines.push(`local function ${componentName}()`);
|
|
764
|
+
lines.push(` return ${renderNode(tree, 1)}`);
|
|
765
|
+
lines.push("end");
|
|
766
|
+
lines.push("");
|
|
767
|
+
lines.push(`return ${componentName}`);
|
|
768
|
+
return lines.join("\n");
|
|
769
|
+
}
|
|
770
|
+
function renderNode(node, depth) {
|
|
771
|
+
const indent = " ".repeat(depth);
|
|
772
|
+
const indent2 = " ".repeat(depth + 1);
|
|
773
|
+
const className = node.ClassName || "Frame";
|
|
774
|
+
const children = node.Children || [];
|
|
775
|
+
node.Name;
|
|
776
|
+
const props = [];
|
|
777
|
+
const skipKeys = /* @__PURE__ */ new Set(["ClassName", "Name", "Children", "className", "name", "children"]);
|
|
778
|
+
for (const [key, val] of Object.entries(node)) {
|
|
779
|
+
if (skipKeys.has(key)) continue;
|
|
780
|
+
props.push(`${indent2}${key} = ${luaValue(val, depth + 1)},`);
|
|
781
|
+
}
|
|
782
|
+
const childEntries = [];
|
|
783
|
+
for (const child of children) {
|
|
784
|
+
const childName = child.Name || child.ClassName || "Child";
|
|
785
|
+
childEntries.push(`${indent2}${childName} = ${renderNode(child, depth + 1)},`);
|
|
786
|
+
}
|
|
787
|
+
const hasProps = props.length > 0;
|
|
788
|
+
const hasChildren = childEntries.length > 0;
|
|
789
|
+
if (!hasProps && !hasChildren) {
|
|
790
|
+
return `e("${className}", {})`;
|
|
791
|
+
}
|
|
792
|
+
const parts = [];
|
|
793
|
+
parts.push(`e("${className}", {`);
|
|
794
|
+
if (hasProps) {
|
|
795
|
+
parts.push(...props);
|
|
796
|
+
}
|
|
797
|
+
if (hasChildren) {
|
|
798
|
+
parts.push(`${indent2}}, {`);
|
|
799
|
+
parts.push(...childEntries);
|
|
800
|
+
parts.push(`${indent}})`);
|
|
801
|
+
} else {
|
|
802
|
+
parts.push(`${indent}})`);
|
|
803
|
+
}
|
|
804
|
+
return parts.join("\n");
|
|
805
|
+
}
|
|
806
|
+
function luaValue(val, _depth) {
|
|
807
|
+
if (val === null || val === void 0) return "nil";
|
|
808
|
+
if (typeof val === "boolean") return String(val);
|
|
809
|
+
if (typeof val === "number") return cleanNum(val);
|
|
810
|
+
if (typeof val === "string") {
|
|
811
|
+
if (val.startsWith("#") && val.length === 7) {
|
|
812
|
+
return `Color3.fromHex("${val}")`;
|
|
813
|
+
}
|
|
814
|
+
if (/^[A-Z][a-zA-Z]+$/.test(val)) {
|
|
815
|
+
return `"${val}"`;
|
|
816
|
+
}
|
|
817
|
+
return `"${val.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`;
|
|
818
|
+
}
|
|
819
|
+
if (Array.isArray(val)) {
|
|
820
|
+
if (val.length === 4 && val.every((v) => typeof v === "number")) {
|
|
821
|
+
return `UDim2.new(${val.map(cleanNum).join(", ")})`;
|
|
822
|
+
}
|
|
823
|
+
if (val.length === 2 && val.every((v) => typeof v === "number")) {
|
|
824
|
+
return `Vector2.new(${val.map(cleanNum).join(", ")})`;
|
|
825
|
+
}
|
|
826
|
+
if (val.length === 3 && val.every((v) => typeof v === "number")) {
|
|
827
|
+
const allSmall = val.every((v) => v <= 1);
|
|
828
|
+
if (allSmall) return `Color3.new(${val.map(cleanNum).join(", ")})`;
|
|
829
|
+
return `Color3.fromRGB(${val.map((v) => String(Math.round(v))).join(", ")})`;
|
|
830
|
+
}
|
|
831
|
+
return `{${val.map((v) => luaValue(v, _depth)).join(", ")}}`;
|
|
832
|
+
}
|
|
833
|
+
if (typeof val === "object") {
|
|
834
|
+
const entries = Object.entries(val);
|
|
835
|
+
if (entries.length === 0) return "{}";
|
|
836
|
+
return `{
|
|
837
|
+
${entries.map(([k, v]) => `${" ".repeat(_depth + 1)}${k} = ${luaValue(v, _depth + 1)}`).join(",\n")}
|
|
838
|
+
${" ".repeat(_depth)}}`;
|
|
839
|
+
}
|
|
840
|
+
return String(val);
|
|
841
|
+
}
|
|
731
842
|
mcp.tool(
|
|
732
843
|
"read_script",
|
|
733
844
|
"Read the source code of a script in Roblox Studio",
|
|
@@ -753,7 +864,7 @@ async function startMcpServer() {
|
|
|
753
864
|
);
|
|
754
865
|
mcp.tool(
|
|
755
866
|
"run_code",
|
|
756
|
-
"Execute arbitrary Luau code in Roblox Studio. LAST RESORT \u2014 only use when no dedicated tool exists. Do NOT use for: reading properties (use get_properties/
|
|
867
|
+
"Execute arbitrary Luau code in Roblox Studio. LAST RESORT \u2014 only use when no dedicated tool exists. Do NOT use for: reading properties (use get_properties/inspect_selection/serialize_ui), creating instances (use create_part/create_ui/insert_instance/build_multiple), modifying properties (use set_properties/bulk_set_properties), or inspecting the tree (use get_explorer). Valid uses: complex procedural generation, terrain algorithms, raycasting, physics queries, custom logic with no tool equivalent.",
|
|
757
868
|
{ code: z.string().describe("Luau code to execute") },
|
|
758
869
|
async ({ code }) => {
|
|
759
870
|
assertConnected();
|
|
@@ -1124,6 +1235,90 @@ async function startMcpServer() {
|
|
|
1124
1235
|
return { content: [{ type: "text", text: JSON.stringify(res.payload.tree, null, 2) }] };
|
|
1125
1236
|
}
|
|
1126
1237
|
);
|
|
1238
|
+
mcp.tool(
|
|
1239
|
+
"inspect_selection",
|
|
1240
|
+
`Inspect the user's current selection in Roblox Studio. Returns the selected instance paths AND their properties (compact) in a single call. Use this FIRST when the user says "my selection", "what I selected", or "the selected thing". Much better than calling get_selection + get_properties separately.`,
|
|
1241
|
+
{},
|
|
1242
|
+
async () => {
|
|
1243
|
+
assertConnected();
|
|
1244
|
+
const selRes = await bridge.sendRequest(CliMsg.GET_SELECTION, {});
|
|
1245
|
+
const paths = selRes.payload?.paths ?? [];
|
|
1246
|
+
if (paths.length === 0) {
|
|
1247
|
+
return { content: [{ type: "text", text: "No instances selected in Studio." }] };
|
|
1248
|
+
}
|
|
1249
|
+
const results = {};
|
|
1250
|
+
for (const p of paths.slice(0, 10)) {
|
|
1251
|
+
try {
|
|
1252
|
+
const propRes = await bridge.sendRequest(
|
|
1253
|
+
CliMsg.GET_PROPERTIES,
|
|
1254
|
+
{ path: p, compact: true }
|
|
1255
|
+
);
|
|
1256
|
+
results[p] = propRes.payload.properties ?? propRes.payload;
|
|
1257
|
+
} catch {
|
|
1258
|
+
results[p] = { error: "Failed to read properties" };
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if (paths.length > 10) {
|
|
1262
|
+
results["_truncated"] = `${paths.length - 10} more instances not shown`;
|
|
1263
|
+
}
|
|
1264
|
+
return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] };
|
|
1265
|
+
}
|
|
1266
|
+
);
|
|
1267
|
+
mcp.tool(
|
|
1268
|
+
"inspect_instance",
|
|
1269
|
+
"Inspect a single instance: returns its compact properties AND its children tree in one call. Combines get_properties + get_explorer into a single round-trip. Use when you need to understand an instance and its subtree.",
|
|
1270
|
+
{
|
|
1271
|
+
path: z.string().describe('Full instance path (e.g. "Workspace.MyModel")'),
|
|
1272
|
+
childDepth: z.number().optional().default(2).describe("How deep to show the children tree (default 2)")
|
|
1273
|
+
},
|
|
1274
|
+
async ({ path: path2, childDepth }) => {
|
|
1275
|
+
assertConnected();
|
|
1276
|
+
const [propRes, treeRes] = await Promise.all([
|
|
1277
|
+
bridge.sendRequest(
|
|
1278
|
+
CliMsg.GET_PROPERTIES,
|
|
1279
|
+
{ path: path2, compact: true }
|
|
1280
|
+
),
|
|
1281
|
+
bridge.sendRequest(
|
|
1282
|
+
CliMsg.GET_EXPLORER,
|
|
1283
|
+
{ rootPath: path2, maxDepth: childDepth ?? 2 }
|
|
1284
|
+
)
|
|
1285
|
+
]);
|
|
1286
|
+
return {
|
|
1287
|
+
content: [{
|
|
1288
|
+
type: "text",
|
|
1289
|
+
text: JSON.stringify({
|
|
1290
|
+
properties: propRes.payload.properties ?? propRes.payload,
|
|
1291
|
+
children: treeRes.payload.tree ?? treeRes.payload
|
|
1292
|
+
}, null, 2)
|
|
1293
|
+
}]
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
);
|
|
1297
|
+
mcp.tool(
|
|
1298
|
+
"convert_ui_to_code",
|
|
1299
|
+
'Convert an existing Roblox UI tree into Roact/React-lua component code. Serializes the UI at the given path, then generates a ready-to-use Luau component. Use when the user asks to "turn this into a component", "convert to React", or "make a Roact version".',
|
|
1300
|
+
{
|
|
1301
|
+
path: z.string().describe('Path to the UI instance to convert (e.g. "StarterGui.MyScreenGui.MainFrame")'),
|
|
1302
|
+
framework: z.enum(["roact", "react"]).optional().default("react").describe('Target framework: "roact" (legacy) or "react" (react-lua, default)'),
|
|
1303
|
+
componentName: z.string().optional().describe("Name for the generated component (defaults to instance Name)")
|
|
1304
|
+
},
|
|
1305
|
+
async ({ path: path2, framework, componentName }) => {
|
|
1306
|
+
assertConnected();
|
|
1307
|
+
const res = await bridge.sendRequest(
|
|
1308
|
+
CliMsg.SERIALIZE_UI,
|
|
1309
|
+
{ path: path2, maxDepth: 50 },
|
|
1310
|
+
1e3 * 60 * 2
|
|
1311
|
+
);
|
|
1312
|
+
if (!res.payload.success || !res.payload.tree) {
|
|
1313
|
+
return { content: [{ type: "text", text: `Error serializing UI: ${res.payload.error ?? "Unknown error"}` }] };
|
|
1314
|
+
}
|
|
1315
|
+
const tree = res.payload.tree;
|
|
1316
|
+
const name = componentName || tree.Name || "GeneratedComponent";
|
|
1317
|
+
const fw = framework || "react";
|
|
1318
|
+
const code = generateComponentCode(tree, name, fw);
|
|
1319
|
+
return { content: [{ type: "text", text: code }] };
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1127
1322
|
mcp.tool(
|
|
1128
1323
|
"recall_memory",
|
|
1129
1324
|
"Search persistent memory for facts about the current Roblox project",
|