MUSH Format is an intelligent, AI-powered build tool and pre-processor for MUSHcode (TinyMUSH, PennMUSH, MUX, RhostMUSH, etc.). Write clean, modern, readable code โ and let the agentic system autonomously analyze, format, and heal your code into production-ready MUSH scripts.
Write code like a developer. Let AI handle the rest.
MUSH Format doesn't just compile code โ it understands it. Our agentic workflow powered by LangGraph and Google Gemini provides:
- Automatically discovers your project structure
- Identifies entry points and dependencies
- Supports
mform.config.ts/jsfor custom configuration
- Processes
#include,@define, templates, and all directives - Handles multi-file projects with automatic bundling
- Preserves source mapping for debugging
- Heuristic healing for common errors (unterminated strings, etc.)
- LLM-powered healing for complex syntax issues using RAG with MUX documentation
- Detects and fixes:
- Unbalanced brackets
[]and parentheses() - @ commands inside function calls
- Complex nested expression errors
- Unbalanced brackets
- Parallel batch processing (30 concurrent fixes) for speed
- Validates formatted output
- Reports remaining errors with detailed diagnostics
- Provides confidence in your build
npm install -g @digibear/mush-format-
Initialize a new project:
mform init my-game cd my-game -
Write clean code (
src/index.mush):// Define a hello command &CMD_HELLO #123=$hello *: @pemit %#=Hello, %0! @pemit %#=Welcome to the game. -
Build with agentic mode (default):
mform run . -o build.txtThe agent will:
- โ Analyze your project
- โ Parse and bundle files
- โ Compress and optimize
- โ Detect and heal syntax errors
- โ Verify the output
-
Output (
build.txt):&CMD_HELLO #123=$hello *:@pemit %#=Hello, %0!;@pemit %#=Welcome to the game.
- LLM Self-Healing: Automatically fixes complex syntax errors using Google Gemini 2.5 Flash
- RAG Integration: Leverages MUX documentation for context-aware fixes
- Parallel Processing: Heals up to 30 errors simultaneously for speed
- Write indented, commented, readable code
- Use
//comments (removed) and@@MUSH comments (preserved) - Block comments
/* */supported
mform initto scaffold new projectsmform install github:user/repofor dependencies- Configuration via
mform.config.ts/jsor legacymush.json
- Imports:
#include ./file.mushor from URLs - Macros:
@define MACRO(args) { body }for code reuse - Templates:
#for,#iffor code generation - Testing:
@testframework for unit tests - Documentation: Auto-generate help from JSDoc comments
- Minification and compression
- Installer script generation (
-iflag) - Watch mode (
-w) for development - Diff mode (
-d) for incremental updates
Create .env.local in your project root:
GOOGLE_API_KEY=your_api_key_hereOr set globally:
mform run . --google-api-key=your_keyWithout an API key, complex errors are detected but not automatically healed.
mform.config.ts (recommended):
export default {
mform: {
main: "./src/index.mush",
},
include: ["src/**/*.mush", "lib/**/*.mu"],
dependencies: {
"utils": "github:mushcoder/mush-utils",
},
};Legacy mush.json:
{
"main": "./src/index.mush",
"dependencies": {
"utils": "github:mushcoder/mush-utils"
}
}// Import from local files
#include ./utils/helpers.mush
// Import from URLs
#include https://raw.githubusercontent.com/user/repo/main/lib.mu
// Include file content as MUSH comments
#file ./LICENSE
Define reusable code patterns:
@define EMIT_TO_ROOM(msg) {
@remit %l=msg
}
@define SET_ATTR(obj, attr, val) {
&attr obj=val
}
EMIT_TO_ROOM(The room shakes!)
SET_ATTR(%#, HEALTH, 100)
Generate code programmatically:
// Loops
#for i in range(1, 5) {
&STAT_%i #123=%i
}
// Conditionals
#if (ENV == "dev") {
@debug Development mode active
}
@test "Math functions" {
add(2, 2)
} expect {
4
}
@test "String ops" {
cat(Hello, World)
} expect {
HelloWorld
}
Run tests (when implemented):
mform testGenerate @help entries from comments:
@help_object #123
@help_pre &HELP_
/**
* +attack <target>
*
* Initiates combat with the specified target.
* Requires you to be in the same room.
*/
&CMD_ATTACK #123=$+attack *:
// Implementation
Generates:
&HELP_ATTACK #123=+attack <target>%r%rInitiates combat with the specified target.%rRequires you to be in the same room.
| Command | Alias | Description |
|---|---|---|
mform run <path> |
r |
Build project with agentic mode (default) |
mform init <name> |
i |
Create new project scaffold |
mform install <pkg> |
add |
Install dependency from GitHub |
mform github <url> |
git |
Format remote file from GitHub |
mform purge <file> |
p |
Clear diff caches |
mform run <path> [options]
Options:
-o, --output <file> Save output to file
-d, --diff Show only changes from previous build
-w, --watch Watch mode - rebuild on file changes
-i, --install-script Generate installer script format
--no-agent Disable agentic mode (classic formatter)
--google-api-key <key> Set Google API key for LLM healing# Build with agentic healing
mform run . -o build.txt
# Watch mode for development
mform run . -w
# Generate installer script
mform run . -i -o installer.txt
# Classic mode (no AI)
mform run . --no-agent -o output.txt
# Install a dependency
mform install github:mushcoder/combat-systemMUSH Format features a beautiful, accessible CLI with:
- ๐จ Vibrant colors for different message types
- โ Semantic icons (success, error, warning, info)
- ๐ Progress indicators during healing
- ๐ฏ Clear sections for workflow stages
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
AGENTIC MODE ACTIVATED
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Analyzing Project: /path/to/project
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Config loaded from: mform.config.ts
โธ Found 45 potential source files
โ
Entry Point: index.mush
[=============================] 100% | โ Batch 1-30 complete
โ Successfully healed all errors!
โ Parsing Complete: 1,234 lines
โ Successfully formatted 1,234 lines
MUSH Format uses LangGraph for workflow orchestration:
START โ Analyzer โ Parser โ Compressor โ Linter โฒ Verifier โ END
โ โ
โโโโโโโโโ
Self-Healing Loop
(max 3 iterations)
- Analyzer: Discovers files, entry points, and configuration
- Parser: Processes all directives and generates formatted output
- Compressor: Strips comments, joins lines, optimizes
- Linter: Detects errors and initiates healing
- Verifier: Validates final output
- Simple errors โ Heuristic fixes (instant)
- Complex errors โ LLM healing with RAG context
- Batch processing โ 30 parallel API calls for speed
- Re-verification โ Ensures fixes are correct
Exciting features on the roadmap to make MUSH development even better:
- VSCode Extension - Syntax highlighting, IntelliSense, live preview, and one-click builds
- Language Server Protocol (LSP) - Full IDE support with autocomplete, go-to-definition, and refactoring
- Interactive Playground - Web-based editor to experiment with mform syntax and see instant results
- Live Reload - Hot module replacement for instant feedback during development
- GitHub Actions Integration - Automated builds and deployments on every commit
- Pre-commit Hooks - Automatic formatting and linting before commits
- Deployment Pipelines - Push directly to MUSH game servers from CI/CD
- Version Tagging - Semantic versioning for MUSH packages
- Incremental Builds - Only reprocess changed files for faster rebuilds
- Smart Caching - Persistent cache for includes and dependencies
- Build Profiles - Optimize for development vs. production builds
- Parallel Processing - Multi-threaded parsing for massive projects
- Enhanced Test Runner - Execute
@testblocks with detailed reports and coverage - Agentic Testing -
mform testcommand that runs tests against live MUSH server - Test Generation - AI-powered test case generation from code
- Integration Testing - Test against live MUSH server instances
- Code Coverage Reports - Track which code is tested
- Performance Profiling - Identify slow commands and bottlenecks
- Snapshot Testing - Track and verify command output over time
- Visual Debugger - Step through code execution with breakpoints
- Dependency Graph Viewer - Visualize project structure and imports
- Refactoring Tools - Automated code transformations and modernization
- Code Metrics Dashboard - Complexity analysis, duplication detection, and quality scores
- Cloud-Based Healing - No API key required - healing as a service
- Package Registry - Discover, share, and install community packages
- Collaborative Editing - Real-time multiplayer coding sessions
- Version Control Integration - Git workflow optimized for MUSH code
- Agentic Create -
mform create <description>to generate new code from natural language - Agentic Modify -
mform modify <file> <instruction>to edit code via AI - AI Code Suggestions - Context-aware autocomplete powered by LLM
- Automatic Refactoring - AI-suggested improvements and modernizations
- Code Review Assistant - Automated best practice recommendations
- Natural Language Commands - "Create a combat system" โ Generated scaffold
- Intent-Based Healing - AI understands what you're trying to do and fixes accordingly
- Direct Server Upload - Deploy code directly to your game server
- Live Data Sync - Two-way sync between code and server
- Remote Debugging - Debug code running on the server
- Server Health Monitoring - Track performance and errors in real-time
- Interactive Tutorials - Learn mform with hands-on examples
- Recipe Library - Pre-built templates for common patterns
- Best Practices Guide - Advanced techniques and optimization tips
- Video Courses - Comprehensive learning materials
Contributions welcome! This project is actively developed.
- Clone:
git clone https://github.com/digibear-io/mush-format.git - Install:
npm install - Build:
npm run build - Test:
npm test
MIT ยฉ Digibear
- GitHub: digibear-io/mush-format
- npm: @digibear/mush-format
- Issues: Report a bug
Made with โค๏ธ for the MUSH community
