bar-fmt: lua codemod, workspace integration, LLM type-triage (rollup) - #57
bar-fmt: lua codemod, workspace integration, LLM type-triage (rollup)#57keithharvey wants to merge 11 commits into
Conversation
2110efe to
a542849
Compare
| @@ -0,0 +1,185 @@ | |||
| # Type Triage Worker Prompt (OpenAI variant) | |||
There was a problem hiding this comment.
I do think this file is good to include, mostly as a blueprint for how to do this sort of subagent/orchestrator script in the future. This PR does new things so having the some sub-agent stuff in claude/ provides helpful rails for future folks trying the same thing.
| @@ -0,0 +1,1084 @@ | |||
| --- | |||
There was a problem hiding this comment.
This is the skill file so subagents bail if they don't hit a known rule while walking through EmmyLua errors.
a542849 to
64d3fb4
Compare
a9c3a03 to
d6bf9f9
Compare
91d8d48 to
4ff79bf
Compare
| LuaParser, LuaStringToken, LuaSyntaxKind, LuaSyntaxNode, LuaSyntaxToken, LuaSyntaxTree, | ||
| LuaTokenKind, ParserConfig, | ||
| }; | ||
| use std::collections::HashMap; |
There was a problem hiding this comment.
CST is "Concrete Syntax Tree" as in we don't throw away whitespace, comments, or exact token positions.
bar-lua-codemod parses BAR Lua with emmylua_parser (the same front-end family as emmylua_check/emmylua_ls) at Lua51, doc-comment analysis off. Transforms collect byte-range edits over the rowan CST and splice them into the original source, so untouched bytes are untouched by construction. cst.rs carries the shared helpers: parse gate on SyntaxError-kind diagnostics only, bracketed-string-key extraction that tolerates trivia, and the function-declaration-name exclusion. codemod-cargo.sh runs cargo inside bar-dev, where the toolchain lives.
x["y"] -> x.y and ["y"] = -> y = for string keys that are valid, non-reserved identifiers. Raw quoted content only — escapes and long strings never convert. Injects a space when ] abutted a word character so .identifier doesn't merge with what follows.
Spring.GetMyTeamID / GetMyAllyTeamID / GetMyPlayerID -> the canonical GetLocal* names, wherever the prefix is the bare Spring global. Bracket access and non-Spring prefixes are left alone.
Spring.I18N / Utilities / Debug / Lava / GetModOptionsCopy — BAR's own helpers riding the Spring table — move to the BAR namespace. Handles the _G.Spring.Module spelling too; function-declaration names stay put.
0.24.0 is what the current tangzx.emmylua VS Code extension bundles as its language server, so `just bar::check` and the editor run the same analyzer instead of sitting two minor versions apart. Upstream renamed the aarch64 release assets from arm64 to aarch64 between 0.22.0 and 0.24.0; x86_64 names are unchanged, so the version bump alone would 404 an ARM build. BAR's CI workflows do not pin emmylua, so there is no lockstep constraint here.
bar::check / bar::check-errors run emmylua_check inside bar-dev against BAR's .emmyrc.json; check-errors re-derives its exit code from the error count so warnings and hints stay local instead of failing CI. Adds the devtools .emmyrc.json, points the VS Code template at the exported emmylua wrappers, and makes distrobox a hard setup requirement — the whole toolchain lives in the container. bar::setup-hooks installs a pre-commit hook that checks the staged blobs instead of rewriting the working tree. What git records is what gets checked; staged content is always LF, so .gitattributes eol and stylua's line_endings can disagree without breaking the gate. It refuses rather than reformatting — a hook that edits the tree mid-commit changes what you are committing.
bar::codemod-build / codemod-test wrap codemod-cargo.sh. Migrations get
their own bar::migrate:: namespace — adoption-dated entries listed in
order, retired to [private] ~6 months after adoption. The 2026-07
stylua-cleanup entry replays the transform set (bracket-to-dot,
rename-aliases, detach-bar-modules) plus stylua onto the local BAR
checkout — the idempotent "transform your branch, then merge" path the
README callout documents.
Codemod runs carry the .styluaignore skip set explicitly: common/luaUtilities,
.lux, recoil-lua-library, mapgenerator. mapgenerator/mapinfo_template.lua
is a ${} placeholder template, not parseable Lua.
CODEMOD_BIN reads the environment. `set export` puts every variable into
the environment of every recipe, so a recipe shelling out to
bar::migrate::* would otherwise override the binary its own caller named
— sending CI back to a cargo build instead of the one baked into the
migration image, and still going green.
lua-doc-extractor also walks rts/Sim/Units/Scripts, so the generated library covers the unit-script API that emmylua_check needs to resolve. clean_dir removes the directory itself, so it has to run before the mkdir, not after it.
llm-type-triage.sh chunks emmylua_check errors and dispatches parallel LLM workers (claude --print, or the openai worker via BACKEND=openai — hence python3-pip in bar-dev) that fix annotations per file. The codemod-prereq SKILL.md is the categorization rulebook: error pattern -> idempotent fix recipe, first match wins. claude/claude.md carries the cross-repo agent context. The type-fixes-preserve-behavior skill is the standing rule for that work: a type fix may change types and names, never behavior. It encodes the gui_chat.lua regression that shipped a widget which would not load. Git dir resolves via rev-parse — a worktree's .git is a file, not a directory.
4ff79bf to
88ff67d
Compare
generate-branches.sh deterministically rebuilds fmt, the mig-* leaves, the mig rollup, and the fmt-llm capstone (env layer + gen(llm) commit), with PR-body generation, the museum table, and stacked-PR base overrides. bar::migrate::stylua-cleanup-generate fronts it ([private] — generation stays out of the listing), wrapping execution in $CREDENTIALS_RUNNER so the triage workers inherit LLM-backend credentials; the tracking-issue template ties the PR stack together. Every pipeline branch and PR hosts on the canonical repo. GitHub's native stacks reject fork-headed PRs and lock --base edits, so PR edits omit --base when it already matches, and the museum links, the tracking checklist and the Bulk Migrations doc link all point at the same-repo PRs (#8395-#8410). --push and --update-prs are one transaction in both directions: museum SHAs and branches move together or not at all. A branch that sits on its PR base is never pushed. Blame-ignore revs are read off the branch rather than the build loop. stylua runs on the host, where git writes. The script re-execs itself from its file path with stdin on /dev/null once inside the container: enter_distrobox otherwise feeds the script itself on stdin, and any child that reads stdin eats the remainder and the run ends silently at exit 0. Maintainers can run the catch-up for contributors — the Bulk Migration action replays every migration still listed under bar::migrate, oldest first, skipping the ones a branch already has.
Builds and publishes docker/dev.Containerfile to ghcr, and adds docker/migration.Containerfile with the codemod binary baked in, so the Bulk Migration action runs the same toolchain developers run locally instead of rebuilding it per job. Adds gh to the dev image for the pipeline's stack linking.
88ff67d to
e36306c
Compare
|
@NortySpock @thvl3 Ok this one is ready to go. The codemod changes are now in BAR master so the deterministic part of this has been validated against the real repo. This one is definitely better reviewed as the individual commits, best I could do without upstream access to stack this PR. |
The bar-fmt migration as one PR (19 commits at the stack tip): bar-lua-codemod tooling and tests, workspace integration (check recipes, editor wiring,
migrate::stylua-cleanup, the genericbar::restackstack rebaser), the LLM type-triage layer with the generation capstone, and the migrate:: moves that host every pipeline branch and PR on the canonical repo (#8395–#8410).