dsh-mc-compiler: Compiling ProgrammableFurnace .mc Scripts in DeepSeek Harness

Introduction

When developing agents in DeepSeek Harness, you will often encounter the need to invoke external tools or compile scripts. The ProgrammableFurnace mod uses .mc scripts as its embedded domain-specific language (DSL), and developers need to validate the syntax and semantics of these scripts to avoid runtime errors in-game. The traditional approach is either to test within the game or to use a dedicated editor (such as vscode-mc-compiler). The dsh-mc-compiler plugin integrates this capability into DSH’s sidebar and agent tools, enabling compile checks to be performed in the same context as code writing.

Plugin Positioning

dsh-mc-compiler is a DeepSeek Harness client plugin maintained by hjt458. It does not re-implement the language analysis logic of ProgrammableFurnace; instead, it directly runs the mod’s bundled dev.programmablefurnace.base.CompilerAnalyzer, packaged as compiler/mc-compiler.jar. This means the compilation results obtained in DSH are consistent with those produced in-game.

Core Features

1. Sidebar Compilation Panel

After installation, a “MC compiler” entry appears in the DSH sidebar (located below the Skill board). Clicking it to expand reveals:

  • A list of all .mc files under the currently configured scripts directory
  • A “Compile” and a “Compile all” button for each file
  • The compilation result’s ContentState (EXECUTABLE / DEPENDENCY / FAILED / BLANK / READONLY)
  • The module name
  • Diagnostic messages in the format code line:col message

2. Compiler Selector

The panel header contains a compiler selector for specifying which Java compiler to use. It supports two methods:

  • Directly specifying a jar file path
  • Placing a jar file into the compiler/jars/ directory (the plugin scans one level of depth). The selector displays the jar’s commit, build date, and size

The selection is persisted by default to <profile>/data/mc-compiler/selection.json and is retained even after DSH is restarted.

3. Agent Tool mc_compile

The plugin provides an agent tool mc_compile that allows agents to invoke it while editing scripts, retrieve compilation diagnostics, and feed them back to the model.

Compilation Process

The plugin selects a compiler in the following order:

  1. The jar specified in the configuration file
  2. The jar selected via the sidebar panel selector
  3. The built-in compiler/mc-compiler.jar (93 KB, sourced from the mod’s frontend and base analyzer)
  4. Fallback to javac to build the frontend from source (on first use)

Regardless of which method is used, a JVM is launched to run java -Dfile.encoding=UTF-8 -Dstdout.encoding=UTF-8 -cp <jar-or-classes> McCompileCli <files…>, and the JSON results are returned to the caller.

Installation & Activation

Run the following command in DSH (replace <absolute path to this directory> with the absolute path of the plugin’s directory):

plugin_manager: install_bundle, target: <absolute path to this directory>

After installation, the plugin is automatically injected into the current profile.

Configuration

The plugin reads its configuration from cordis.patch.yml. By default, it points to the maintainer’s source directory, which needs to be modified for local installation:

- id: mc-compiler
  name: dsh-mc-compiler
  config:
    # Root directory for recursive scanning of .mc files
    root: D:/MODS/ProgrammableFurnace/src/main/resources/programmablefurnace/scripts
    # Java source root directory containing dev/programmablefurnace/**
    sourceRoot: D:/MODS/ProgrammableFurnace/src/main/java
    # Directory to scan for additional jars (relative to the plugin directory)
    jars: [compiler/jars]

The runtime environment requires JDK 25 (for the javac fallback) or JRE 17+ (for running the built-in compiler only).

API Reference

The plugin exposes four HTTP routes (loopback access only):

Route Method Description
/api/mc-compiler/list GET Returns the file list { root, files: [{ name, rel, path, bytes, content, truncated }] }
/api/mc-compiler/compile POST Compiles a specified path or all files, returning { results: [...] }
/api/mc-compiler/compilers GET Lists available compilers, returning { selected, dirs, items: [{ path, name, role, known, commit, builtAt, release, bytes }] }
/api/mc-compiler/select POST Switches the selected compiler. Request body: { jar }. An empty string indicates using the built-in compiler

Notes

  • The plugin runs with the permissions of the current DSH process. Ensure that the configured scripts directory is accessible to the process.
  • If using the javac fallback, JDK 25 is required and the source directory must exist.
  • The client code uses the require pattern. Do not attempt to use module.exports within the plugin, as this will cause silent failures.
  • Java output requires explicit UTF-8 encoding (-Dstdout.encoding=UTF-8), otherwise Chinese identifiers and messages will be replaced with replacement characters.

Ecosystem & Maintenance

The philosophy behind DeepSeek Harness is “everything is a plugin.” Community directories (such as skillhub.cn) are independent third-party sites with no official affiliation with DeepSeek / High-Flyer. This plugin is released under the MIT license, permitting free use and modification.

References

  • Plugin directory: https://www.skillhub.cn/plugins/hjt458/dsh-mc-compiler
  • GitHub: https://github.com/hjt458/dsh-mc-compiler
  • Source compiler origin: https://github.com/hjt458/vscode-mc-compiler
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye