Goal
Make the GGPK data exporter runnable as one CLI command instead of a GUI-only flow, so a patch export becomes <command> --ggpk <path> --run-all on the maintainer's machine. This is the prerequisite for ever automating exports further.
⚠️ Constraint for AI agents
The exporter needs a local PoE2 install and the Windows-only bun_extract_file.exe — neither exists in CI or agent sessions. An agent CAN do the refactor and verify the new entry point loads, parses arguments, and fails gracefully without game files; final verification against a real GGPK must be done by a human (@jay9297). Say so explicitly in the PR.
Background (read first)
- Read
CLAUDE.md and CONTRIBUTING.md (exporter setup section, ~lines 246–287).
- Current flow:
src/Export/Launch.lua boots a SimpleGraphic GUI ("Dat View", src/Export/Main.lua); the user clicks "Edit Sources…" to set the GGPK path, then "Run All" to execute the 16 scripts in src/Export/Scripts/ (statdesc.lua always first — see Main.lua:186-198).
- The repo already has the pattern for running GUI code headlessly:
src/HeadlessWrapper.lua stubs all rendering callbacks so the main app runs under plain LuaJIT (it's what the test suite boots through). The exporter needs the same treatment.
What to build
-
Audit GUI coupling in the export path. Grep src/Export/Main.lua, src/Export/Classes/*.lua, and src/Export/Scripts/*.lua for rendering/UI calls (Draw*, SetDrawColor, controls, IsKeyDown, popup/dialog functions). The export scripts are mostly pure data processing; the coupling is concentrated in Main.lua (script list UI, console rendering) and possibly progress output.
-
Create src/Export/HeadlessExport.lua modeled on src/HeadlessWrapper.lua:
- Stubs the SimpleGraphic callbacks exactly as
HeadlessWrapper.lua does (copy its stub set; print ConPrintf output to stdout).
- Accepts CLI args:
--ggpk <path-to-Content.ggpk-or-game-dir> (required), --script <name> (repeatable), --run-all.
- Initializes the same state
Main.lua:Init() builds (GGPK reader via src/Export/Classes/GGPKData.lua, DAT specs from src/Export/spec.lua), without constructing UI controls. Refactor Main.lua so the logic (source setup, script execution order incl. statdesc-first, error collection) lives in functions callable from both the GUI and the headless entry — do not duplicate the logic.
- Exit code 0 only if all requested scripts ran without errors; print per-script pass/fail summary.
-
Document it in CONTRIBUTING.md next to the existing GUI instructions: luajit src/Export/HeadlessExport.lua --ggpk "C:\...\Content.ggpk" --run-all (note it still requires the ggpk/ extractor binaries).
Acceptance criteria
luajit src/Export/HeadlessExport.lua (no args) prints usage and exits non-zero — verifiable in the test container.
- With a bogus
--ggpk /nonexistent it fails with a clear error, not a nil-reference crash — verifiable in the test container.
- The GUI exporter still works: no behavior change to
Launch.lua flow beyond the refactor (this is hard to test headlessly — keep the refactor mechanical: extract functions, don't rewrite them).
- Full test suite passes:
docker compose run --rm busted-tests (exporter code isn't covered by tests, but the suite guards against accidental damage elsewhere).
- PR explicitly lists what was verified headlessly vs. what needs the maintainer's real-GGPK run.
Out of scope
- Cross-platform extraction (replacing
bun_extract_file.exe).
- Scheduled/CI exports.
- Changing what any export script outputs.
Goal
Make the GGPK data exporter runnable as one CLI command instead of a GUI-only flow, so a patch export becomes
<command> --ggpk <path> --run-allon the maintainer's machine. This is the prerequisite for ever automating exports further.The exporter needs a local PoE2 install and the Windows-only
bun_extract_file.exe— neither exists in CI or agent sessions. An agent CAN do the refactor and verify the new entry point loads, parses arguments, and fails gracefully without game files; final verification against a real GGPK must be done by a human (@jay9297). Say so explicitly in the PR.Background (read first)
CLAUDE.mdandCONTRIBUTING.md(exporter setup section, ~lines 246–287).src/Export/Launch.luaboots a SimpleGraphic GUI ("Dat View",src/Export/Main.lua); the user clicks "Edit Sources…" to set the GGPK path, then "Run All" to execute the 16 scripts insrc/Export/Scripts/(statdesc.luaalways first — seeMain.lua:186-198).src/HeadlessWrapper.luastubs all rendering callbacks so the main app runs under plain LuaJIT (it's what the test suite boots through). The exporter needs the same treatment.What to build
Audit GUI coupling in the export path. Grep
src/Export/Main.lua,src/Export/Classes/*.lua, andsrc/Export/Scripts/*.luafor rendering/UI calls (Draw*,SetDrawColor, controls,IsKeyDown, popup/dialog functions). The export scripts are mostly pure data processing; the coupling is concentrated inMain.lua(script list UI, console rendering) and possibly progress output.Create
src/Export/HeadlessExport.luamodeled onsrc/HeadlessWrapper.lua:HeadlessWrapper.luadoes (copy its stub set; printConPrintfoutput to stdout).--ggpk <path-to-Content.ggpk-or-game-dir>(required),--script <name>(repeatable),--run-all.Main.lua:Init()builds (GGPK reader viasrc/Export/Classes/GGPKData.lua, DAT specs fromsrc/Export/spec.lua), without constructing UI controls. RefactorMain.luaso the logic (source setup, script execution order incl. statdesc-first, error collection) lives in functions callable from both the GUI and the headless entry — do not duplicate the logic.Document it in
CONTRIBUTING.mdnext to the existing GUI instructions:luajit src/Export/HeadlessExport.lua --ggpk "C:\...\Content.ggpk" --run-all(note it still requires theggpk/extractor binaries).Acceptance criteria
luajit src/Export/HeadlessExport.lua(no args) prints usage and exits non-zero — verifiable in the test container.--ggpk /nonexistentit fails with a clear error, not a nil-reference crash — verifiable in the test container.Launch.luaflow beyond the refactor (this is hard to test headlessly — keep the refactor mechanical: extract functions, don't rewrite them).docker compose run --rm busted-tests(exporter code isn't covered by tests, but the suite guards against accidental damage elsewhere).Out of scope
bun_extract_file.exe).