fluffos_disassemble
Disassemble LPC files to display compiled bytecode for debugging and understanding code compilation processes.
Instructions
Disassemble an LPC file to show compiled bytecode using lpcc. Useful for debugging and understanding how code compiles.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Absolute path to the LPC file to disassemble |
Implementation Reference
- src/index.js:240-273 (handler)Core handler function that executes the disassembly by spawning the FluffOS lpcc binary on the normalized LPC file path, capturing and returning the output.async runLpcc(lpcFile) { return new Promise((resolve, reject) => { const normalizedPath = this.normalizePath(lpcFile) const lpccPath = path.join(this.binDir, "lpcc") const proc = spawn(lpccPath, [this.configFile, normalizedPath], { cwd: path.dirname(this.configFile), }) let stdout = "" let stderr = "" proc.stdout.on("data", data => { stdout += data.toString() }) proc.stderr.on("data", data => { stderr += data.toString() }) proc.on("close", code => { const output = (stdout + stderr).trim() if(code === 0) { resolve(output) } else { resolve(`Error (exit code: ${code}):\n\n${output}`) } }) proc.on("error", err => { reject(new Error(`Failed to run lpcc: ${err.message}`)) }) }) }
- src/index.js:107-121 (schema)Input schema and metadata definition for the fluffos_disassemble tool.{ name: "fluffos_disassemble", description: "Disassemble an LPC file to show compiled bytecode using lpcc. Returns detailed bytecode, function tables, strings, and disassembly. Useful for debugging and understanding how code compiles.", inputSchema: { type: "object", properties: { file: { type: "string", description: "Absolute path to the LPC file to disassemble", }, }, required: ["file"], }, },
- src/index.js:158-169 (registration)Tool call dispatch/registration in the CallToolRequestSchema handler switch statement.case "fluffos_disassemble": { const result = await this.runLpcc(args.file) return { content: [ { type: "text", text: result, }, ], } }
- src/index.js:72-85 (helper)Helper function to normalize LPC file paths relative to the mudlib directory.normalizePath(lpcFile) { // If we have a mudlib directory and the file path is absolute and starts with mudlib dir, // convert it to a relative path if(this.mudlibDir && path.isAbsolute(lpcFile) && lpcFile.startsWith(this.mudlibDir) ) { // Remove mudlib directory prefix and leading slash return lpcFile.substring(this.mudlibDir.length).replace(/^\/+/, "") } // Otherwise return as-is (already relative or not under mudlib) return lpcFile }