ArcherArcher
Home
Quick Start
Project Introduction
  • 简体中文
  • English
Home
Quick Start
Project Introduction
  • 简体中文
  • English
  • Home
  • Basic Configuration

    • Project Introduction
    • Quick Start
    • FAQ
    • Contact Us
  • Advanced Development

    • Basic Knowledge
    • Basic Framework
    • Script Migration
    • Majsoul Development

      • Tile Names

        • Basic
      • Game Interfaces

        • Basic
      • LQ

        • Basic
      • Action Types

        • Basic
      • Game State

        • Basic
      • Login Event

        • Login Event
        • Advanced - Mahjong Event Login
      • Discard Actions

        • Basics
        • Advanced
      • Chii (Eat)
      • Pon
      • Kong
      • Cancel, Skip
  • Auto Review

    • Automatic Review
  • Tenhou Room

    • Playing in Tenhou Private Room with Mortal Bot
  • RiichiCity

    • Basic

Script Package Path Migration

Who this is for: developers who push remote yaegi scripts through the /auto endpoint, and anyone maintaining local scripts/*.majsoul samples.

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 with unable 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 the utils split (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.
  • utils was split into 4 packages (drop .Inst(), call package-level functions instead — see B1). (The merged countdown / playerinfo UI-state packages have since been removed in the Unity migration — see the notice above.)
  • Method names never change. The config path is unchanged. The engine packages github.com/moxcomic/lq and github.com/moxcomic/engine/tenhou_client are 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 importNew import
github.com/moxcomic/Archer/gamestategithub.com/moxcomic/Archer/internal/domain/gamestate
github.com/moxcomic/Archer/userinfogithub.com/moxcomic/Archer/internal/infra/userinfo
github.com/moxcomic/Archer/variablegithub.com/moxcomic/Archer/internal/infra/variable
github.com/moxcomic/Archer/actionsgithub.com/moxcomic/Archer/internal/platform/actions
github.com/moxcomic/Archer/pushergithub.com/moxcomic/Archer/internal/notify/pusher
github.com/moxcomic/Archer/audiogithub.com/moxcomic/Archer/internal/ui/audio
github.com/moxcomic/Archer/discordgithub.com/moxcomic/Archer/internal/notify/discord
github.com/moxcomic/Archer/telegramgithub.com/moxcomic/Archer/internal/notify/telegram
github.com/moxcomic/Archer/wechatgithub.com/moxcomic/Archer/internal/notify/wechat

github.com/moxcomic/Archer/config is unchanged (still a top-level public package).

⚠️ The userinfo method IsVaild was renamed to IsValid (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 callNew importNew call
utils.Inst().ChangeEngine(...)
utils.Inst().ChangeMainIndex(...)
github.com/moxcomic/Archer/internal/platformutil/engineswitchengineswitch.ChangeEngine(...)
engineswitch.ChangeMainIndex(...)
utils.Inst().DispatchBot(...)
utils.Inst().DispatchBotGateway(...)
github.com/moxcomic/Archer/internal/platformutil/botdispatchbotdispatch.DispatchBot(...)
botdispatch.DispatchBotGateway(...)
utils.Inst().MouseMove(...) / MouseClick() / Screenshot(...) / SetMarker(...) / SetMarkerForPage(...) / SetMouseMarker(...)github.com/moxcomic/Archer/internal/platformutil/pagecontrolpagecontrol.MouseMove(...) etc. (drop Inst().)
utils.Inst().Polarity(...)github.com/moxcomic/Archer/internal/platformutil/extensionextension.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 / otherplayerinfomgr are 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

  1. Replace every github.com/moxcomic/Archer/<X> import in your script with the internal/... path from table A.
  2. utils.Inst().X() → per B1, change to the package-level function in engineswitch / botdispatch / pagecontrol / extension (drop Inst().).
  3. winmgr / huleshowmgr / scorechangemgr / playerinfomgr / otherplayerinfomgr and other UI-state query packages → removed in the Unity migration; delete those calls and derive state from the in-game event stream instead.
  4. config, github.com/moxcomic/lq, and github.com/moxcomic/engine/tenhou_client stay unchanged.
  5. If you used userinfo.Inst().IsVaild(), change it to IsValid().
  6. Redeploy to the /auto push side. The local sample scripts/auto.majsoul has 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 /auto are yours to update per this guide.

Last Updated: 5/31/26, 8:14 AM
Contributors: moxcomic
Prev
Basic Framework