Skip to content
Public template

Repository files navigation

FSharpPluginTemplate

A minimal source-compiled F# plugin for the Hosihikari framework. The F# loader compiles main.fsx at load with FSharp.Compiler.Service and runs the assembly in a collectible ALC; there is no build step for the author.

Use it

  1. Keep this repository outside the server. Rename the plugin: change hosihikari.json name, rename MyFSharpPlugin.conf, and rename the type in main.fsx. The package directory name must equal the manifest name.

  2. Pack it with the framework packer, then copy dist/MyFSharpPlugin/ into the server as plugins/MyFSharpPlugin/. The packer needs a sibling PluginManager checkout, or HOSIHIKARI_PLUGINMANAGER pointing at one:

    pwsh ./pack.ps1
    bash ./pack.sh
  3. Install the carrier bundle and the F# loader with Seiko:

    sk init                                  # once per server root
    sk add hosihikari-hosting-levilamina     # LeviLamina
    # or: sk add hosihikari-hosting-endstone
    # or: sk add hosihikari-hosting-selfhosted
    sk add hosihikari-fsharp
  4. Restart the server. The log shows the plugin loading and enabling.

For the self-hosted carriers, sk add hosihikari-hosting-selfhosted selects Windows or Linux; start the server through hosihikari-server (hosihikari-server.exe on Windows). Loaders and plugins still live under plugins/.

Files

  • hosihikari.json — loader: fsharp, depends on hosihikari and hosihikari-fsharp. The packer writes the LeviLamina manifest.json envelope from it; that file is an output, not a source.
  • pack.ps1 / pack.sh — run the framework packer; dist/MyFSharpPlugin/ is the installable package. A project still on the 1.x manifest.json migrates in the same command (-MigrateOnly / --migrate-only rewrites just the metadata).
  • main.fsx — a parameterless type implementing IPlugin. It loads helper.fsx with #load.
  • helper.fsx — the second compilation unit, loaded into the entry script.
  • MyFSharpPlugin.conf — package defaults.

Configuration and data

  • Package defaults: plugins/<name>/<name>.conf.
  • Server override: config/hosihikari/<name>.conf.
  • Environment variables override the same keys.
  • Runtime data: data/hosihikari/<name>/.

Lifecycle

OnLoad runs after dependencies are ready. OnEnable opens the event/timer gate; a refusal keeps the plugin loaded and disabled. OnUnload releases what the plugin owns. An exception from a hook is a fault and the host unloads the plugin. Every hook is a ValueTask and receives a CancellationToken; honour it, and return before awaiting anything you cannot cancel.

See the F# loader for the compilation details.

Licence

MIT-0, see LICENSE.md.

Used by

Contributors

Languages