Script Package Path Migration
Who this is for: developers who push remote yaegi scripts through the
/autoendpoint, and anyone maintaining localscripts/*.majsoulsamples.This refactor moved the script-visible Go packages into the layered
internal/directory. The import paths in your scripts need updating, otherwise yaegi will fail at load/runtime withunable to find source/undefined symbol.
⚠️ 2026 update (Majsoul Unity migration): After Majsoul's web client moved to Unity + WASM, all the UI-state “manager” packages have been removed entirely:
lobbymgr,desktopmgr,infomgr,gameendmgr,activitymgr,activitysignmgr,monthlymgr,countdown,playerinfo. They relied on LayaBox engine JS globals that no longer exist under Unity. The widget rows in table A below, and sections B2 / B3, are obsolete — do not use them; derive game state from the in-game protobuf event stream instead. The other packages (gamestate/userinfo/variable/actions/pusher, etc.) and theutilssplit (B1) are unaffected.
TL;DR
- For the vast majority of packages: only the import path changes. The
pkg.Inst().Method()call style is completely unchanged. utilswas split into 4 packages (drop.Inst(), call package-level functions instead — see B1). (The mergedcountdown/playerinfoUI-state packages have since been removed in the Unity migration — see the notice above.)- Method names never change. The
configpath is unchanged. The engine packagesgithub.com/moxcomic/lqandgithub.com/moxcomic/engine/tenhou_clientare unaffected.
Why it changed
The yaegi interpreter uses a symbols table to map the import paths in your script to the real Go packages. After the refactor these packages physically moved (new import paths), and the symbols table was updated to match. But the import paths hard-coded in your scripts must be changed by you — if a path doesn't match, yaegi can't resolve the symbol and errors out at load or runtime.
A. Import path only (call style unchanged)
| Old import | New import |
|---|---|
github.com/moxcomic/Archer/gamestate | github.com/moxcomic/Archer/internal/domain/gamestate |
github.com/moxcomic/Archer/userinfo | github.com/moxcomic/Archer/internal/infra/userinfo |
github.com/moxcomic/Archer/variable | github.com/moxcomic/Archer/internal/infra/variable |
github.com/moxcomic/Archer/actions | github.com/moxcomic/Archer/internal/platform/actions |
github.com/moxcomic/Archer/pusher | github.com/moxcomic/Archer/internal/notify/pusher |
github.com/moxcomic/Archer/audio | github.com/moxcomic/Archer/internal/ui/audio |
github.com/moxcomic/Archer/discord | github.com/moxcomic/Archer/internal/notify/discord |
github.com/moxcomic/Archer/telegram | github.com/moxcomic/Archer/internal/notify/telegram |
github.com/moxcomic/Archer/wechat | github.com/moxcomic/Archer/internal/notify/wechat |
github.com/moxcomic/Archer/configis unchanged (still a top-level public package).⚠️ The
userinfomethodIsVaildwas renamed toIsValid(typo fix). If your script called.IsVaild(), change it to.IsValid(); every other method name is unchanged.
Call style is unchanged, for example:
// Only the import line above changes; the calls below stay exactly the same
gamestate.Inst().GetHandTile()
variable.Inst().GetInt("ju")
actions.NewMajsoulActions()
pusher.Inst().SendMasterText("...")
B. Call style also changed (split / merge)
B1. utils split into 4 packages (drop .Inst())
The old utils.Inst().X(...) now becomes the matching package's package-level function pkg.X(...):
| Old call | New import | New call |
|---|---|---|
utils.Inst().ChangeEngine(...)utils.Inst().ChangeMainIndex(...) | github.com/moxcomic/Archer/internal/platformutil/engineswitch | engineswitch.ChangeEngine(...)engineswitch.ChangeMainIndex(...) |
utils.Inst().DispatchBot(...)utils.Inst().DispatchBotGateway(...) | github.com/moxcomic/Archer/internal/platformutil/botdispatch | botdispatch.DispatchBot(...)botdispatch.DispatchBotGateway(...) |
utils.Inst().MouseMove(...) / MouseClick() / Screenshot(...) / SetMarker(...) / SetMarkerForPage(...) / SetMouseMarker(...) | github.com/moxcomic/Archer/internal/platformutil/pagecontrol | pagecontrol.MouseMove(...) etc. (drop Inst().) |
utils.Inst().Polarity(...) | github.com/moxcomic/Archer/internal/platformutil/extension | extension.Polarity(...) |
B2 / B3. Countdown (countdown) and player info (playerinfo) — removed
⚠️ These two UI-state query packages were removed in the Majsoul Unity migration (see the notice at the top) and are no longer provided. The former
winmgr/huleshowmgr/scorechangemgr/playerinfomgr/otherplayerinfomgrare all gone. Derive the corresponding state from the in-game protobuf event stream instead.
Full example: a Tenhou room script before and after
Before (old paths + old utils call):
import (
"github.com/moxcomic/Archer/utils"
"github.com/moxcomic/Archer/gamestate"
"github.com/moxcomic/Archer/userinfo"
"github.com/moxcomic/Archer/variable"
tenhouclient "github.com/moxcomic/engine/tenhou_client"
"github.com/moxcomic/lq"
)
func dispatch() error {
return utils.Inst().DispatchBot(1000, 20, strconv.Itoa(ROOM_ID), "high", "4.1b", "4.1b", "4.1b")
}
After:
import (
"github.com/moxcomic/Archer/internal/platformutil/botdispatch"
"github.com/moxcomic/Archer/internal/domain/gamestate"
"github.com/moxcomic/Archer/internal/infra/userinfo"
"github.com/moxcomic/Archer/internal/infra/variable"
tenhouclient "github.com/moxcomic/engine/tenhou_client"
"github.com/moxcomic/lq"
)
func dispatch() error {
return botdispatch.DispatchBot(1000, 20, strconv.Itoa(ROOM_ID), "high", "4.1b", "4.1b", "4.1b")
}
The gamestate.Inst() / userinfo.Inst() / variable.Inst() / tenhouclient.Inst() calls are untouched — only the import lines and the single utils.Inst().DispatchBot call changed.
Migration checklist
- Replace every
github.com/moxcomic/Archer/<X>import in your script with theinternal/...path from table A. utils.Inst().X()→ per B1, change to the package-level function inengineswitch/botdispatch/pagecontrol/extension(dropInst().).winmgr/huleshowmgr/scorechangemgr/playerinfomgr/otherplayerinfomgrand other UI-state query packages → removed in the Unity migration; delete those calls and derive state from the in-game event stream instead.config,github.com/moxcomic/lq, andgithub.com/moxcomic/engine/tenhou_clientstay unchanged.- If you used
userinfo.Inst().IsVaild(), change it toIsValid(). - Redeploy to the
/autopush side. The local samplescripts/auto.majsoulhas been updated and can be used as a reference.
The script actually loaded locally,
scripts/auto.go, was updated alongside the refactor and passes the yaegi tests. The scripts you push via/autoare yours to update per this guide.
