RamMAC / mac /services /kernel_registry.py
Aaryan17's picture
feat: upload full MAC source (mac/, frontend/, alembic/, tests/)
9c0b225 verified
"""
Kernel Registry β€” Language definitions for the MAC Notebook execution engine.
Each entry describes how to compile/run code for a given language,
including Docker image names (pre-built, offline-ready) and subprocess fallbacks.
"""
KERNEL_REGISTRY: dict[str, dict] = {
# ──── Interpreted Languages ────────────────────────────
"python": {
"display_name": "Python 3",
"file_extension": ".py",
"mime_type": "text/x-python",
"binary": "python",
"run_cmd": ["python", "-u", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-python",
"icon": "🐍",
"color": "#3776AB",
},
"javascript": {
"display_name": "JavaScript (Node.js)",
"file_extension": ".js",
"mime_type": "text/javascript",
"binary": "node",
"run_cmd": ["node", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-node",
"icon": "🟨",
"color": "#F7DF1E",
},
"typescript": {
"display_name": "TypeScript",
"file_extension": ".ts",
"mime_type": "text/typescript",
"binary": "npx",
"run_cmd": ["npx", "tsx", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-node",
"icon": "πŸ”·",
"color": "#3178C6",
},
"r": {
"display_name": "R",
"file_extension": ".R",
"mime_type": "text/x-r",
"binary": "Rscript",
"run_cmd": ["Rscript", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-r",
"icon": "πŸ“Š",
"color": "#276DC3",
},
"julia": {
"display_name": "Julia",
"file_extension": ".jl",
"mime_type": "text/x-julia",
"binary": "julia",
"run_cmd": ["julia", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-julia",
"icon": "🟣",
"color": "#9558B2",
},
"ruby": {
"display_name": "Ruby",
"file_extension": ".rb",
"mime_type": "text/x-ruby",
"binary": "ruby",
"run_cmd": ["ruby", "{file}"],
"exec_mode": "subprocess",
"icon": "πŸ’Ž",
"color": "#CC342D",
},
"php": {
"display_name": "PHP",
"file_extension": ".php",
"mime_type": "text/x-php",
"binary": "php",
"run_cmd": ["php", "{file}"],
"exec_mode": "subprocess",
"icon": "🐘",
"color": "#777BB4",
},
"perl": {
"display_name": "Perl",
"file_extension": ".pl",
"mime_type": "text/x-perl",
"binary": "perl",
"run_cmd": ["perl", "{file}"],
"exec_mode": "subprocess",
"icon": "πŸͺ",
"color": "#39457E",
},
"lua": {
"display_name": "Lua",
"file_extension": ".lua",
"mime_type": "text/x-lua",
"binary": "lua",
"run_cmd": ["lua", "{file}"],
"exec_mode": "subprocess",
"icon": "πŸŒ™",
"color": "#000080",
},
"bash": {
"display_name": "Bash / Shell",
"file_extension": ".sh",
"mime_type": "text/x-sh",
"binary": "bash",
"run_cmd": ["bash", "{file}"],
"exec_mode": "subprocess",
"icon": "🐚",
"color": "#4EAA25",
},
"powershell": {
"display_name": "PowerShell",
"file_extension": ".ps1",
"mime_type": "text/x-powershell",
"binary": "pwsh",
"run_cmd": ["pwsh", "-File", "{file}"],
"exec_mode": "subprocess",
"icon": "⚑",
"color": "#012456",
},
# ──── Compiled Languages ───────────────────────────────
"c": {
"display_name": "C (GCC)",
"file_extension": ".c",
"mime_type": "text/x-csrc",
"binary": "gcc",
"compile_cmd": ["gcc", "-o", "{output}", "{file}", "-lm"],
"run_cmd": ["{output}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-cpp",
"icon": "πŸ”΅",
"color": "#A8B9CC",
},
"cpp": {
"display_name": "C++ (G++)",
"file_extension": ".cpp",
"mime_type": "text/x-c++src",
"binary": "g++",
"compile_cmd": ["g++", "-std=c++20", "-o", "{output}", "{file}"],
"run_cmd": ["{output}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-cpp",
"icon": "πŸ”΅",
"color": "#00599C",
},
"java": {
"display_name": "Java",
"file_extension": ".java",
"mime_type": "text/x-java",
"binary": "javac",
"compile_cmd": ["javac", "{file}"],
"run_cmd": ["java", "-cp", "{file_dir}", "{class_name}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-java",
"icon": "β˜•",
"color": "#ED8B00",
},
"csharp": {
"display_name": "C# (.NET)",
"file_extension": ".cs",
"mime_type": "text/x-csharp",
"binary": "dotnet-script",
"run_cmd": ["dotnet-script", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-dotnet",
"icon": "πŸŸͺ",
"color": "#239120",
},
"go": {
"display_name": "Go",
"file_extension": ".go",
"mime_type": "text/x-go",
"binary": "go",
"run_cmd": ["go", "run", "{file}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-go",
"icon": "🐹",
"color": "#00ADD8",
},
"rust": {
"display_name": "Rust",
"file_extension": ".rs",
"mime_type": "text/x-rust",
"binary": "rustc",
"compile_cmd": ["rustc", "-o", "{output}", "{file}"],
"run_cmd": ["{output}"],
"exec_mode": "subprocess",
"docker_image": "mac-kernel-rust",
"icon": "πŸ¦€",
"color": "#DEA584",
},
"kotlin": {
"display_name": "Kotlin",
"file_extension": ".kts",
"mime_type": "text/x-kotlin",
"binary": "kotlinc",
"run_cmd": ["kotlinc", "-script", "{file}"],
"exec_mode": "subprocess",
"icon": "🟠",
"color": "#7F52FF",
},
"scala": {
"display_name": "Scala",
"file_extension": ".scala",
"mime_type": "text/x-scala",
"binary": "scala",
"run_cmd": ["scala", "{file}"],
"exec_mode": "subprocess",
"icon": "πŸ”΄",
"color": "#DC322F",
},
"swift": {
"display_name": "Swift",
"file_extension": ".swift",
"mime_type": "text/x-swift",
"binary": "swift",
"run_cmd": ["swift", "{file}"],
"exec_mode": "subprocess",
"icon": "🍎",
"color": "#F05138",
},
"haskell": {
"display_name": "Haskell",
"file_extension": ".hs",
"mime_type": "text/x-haskell",
"binary": "runhaskell",
"run_cmd": ["runhaskell", "{file}"],
"exec_mode": "subprocess",
"icon": "🟀",
"color": "#5D4F85",
},
# ──── Data & Scientific ────────────────────────────────
"sql": {
"display_name": "SQL (SQLite)",
"file_extension": ".sql",
"mime_type": "text/x-sql",
"binary": "sqlite3",
"run_cmd": ["sqlite3", ":memory:", ".read {file}"],
"exec_mode": "subprocess",
"icon": "πŸ—ƒοΈ",
"color": "#003B57",
},
"octave": {
"display_name": "Octave (MATLAB-compatible)",
"file_extension": ".m",
"mime_type": "text/x-octave",
"binary": "octave",
"run_cmd": ["octave", "--no-gui", "{file}"],
"exec_mode": "subprocess",
"icon": "πŸ“",
"color": "#0790C0",
},
# ──── Systems / Low-level ──────────────────────────────
"zig": {
"display_name": "Zig",
"file_extension": ".zig",
"mime_type": "text/x-zig",
"binary": "zig",
"run_cmd": ["zig", "run", "{file}"],
"exec_mode": "subprocess",
"icon": "⚑",
"color": "#F7A41D",
},
# ──── Markup (render-only) ─────────────────────────────
"markdown": {
"display_name": "Markdown",
"file_extension": ".md",
"mime_type": "text/markdown",
"exec_mode": "render",
"icon": "πŸ“",
"color": "#083FA1",
},
"html": {
"display_name": "HTML",
"file_extension": ".html",
"mime_type": "text/html",
"exec_mode": "render",
"icon": "🌐",
"color": "#E34F26",
},
}