diff --git a/scripts/curate_brief.js b/scripts/curate_brief.js new file mode 100644 index 0000000..5101e61 --- /dev/null +++ b/scripts/curate_brief.js @@ -0,0 +1,70 @@ +// The curation brief: agents take whole classes over into src/ as idiomatic C++ (see README, Reconstruction). +// Per round: copy to /wf.js, replace __ROUND__ with the round folder (reports of earlier rounds sit beside it as +// ../cN/reports.md) and __TASKS__ with one `ASSIGNMENT (agent i): ...` string per agent, then run it with Workflow. +export const meta = { + name: 'decomp-curate', + description: 'Curation round: whole classes taken over as idiomatic C++ in src/', + phases: [{ title: 'Curate' }], +} +const R = '__ROUND__' +const common = `Repo: /home/anon/sda/Personal/Repos/isaac-decomp. It holds a decompilation of The Binding of Isaac: Repentance+ (isaac-ng.exe v1.9.7.17, 32-bit MSVC) that is being reconstructed as a readable C++20 game for native 64-bit Linux. + +Read these before starting: +- README.md, sections "Reconstruction" and "Quick use". +- The user's coding rules in CLAUDE.md. They are binding. +- The style reference: the user's own game at /home/anon/sda/Personal/Repos/smack-a-brother, especially src/fighter.h, src/fighter.cpp, src/common.h, src/renderer.cpp, src/audio.cpp and src/anm2.cpp. Read-only. +- What is already in src/: rng.cpp, log.h, data.h/.cpp and gl.h/.cpp are the house style. + - Round 1 files (anm2.cpp, item_config.cpp, entity_config.cpp, font.cpp, string_table.cpp, formatted_text.cpp, rich_text.cpp, options_config.cpp, challenge_param.cpp, mod_manager.cpp, msvc.h and their .h) are CORRECT BUT NOT IN THE TARGET STYLE: they still follow the original 32-bit MSVC layouts. + - Their reports are in ${R}/../c1/reports.md (round 1) and ${R}/../c2/reports.md (wave A of this round, which already rewrote anm2, text, config and the SDL3 platform: read their new headers in src/ and use those APIs). Treat them as a verified reference for behaviour. + + +Conventions added since wave A, which every agent this wave follows: +- Manager is being taken over in this same wave by agent 3. Refer to its members by the generated name without the leading underscore: g_manager->stringTable, g_manager->optionsConfig, g_manager->itemConfig, g_manager->entityConfig, g_manager->modManager, g_manager->musicManager ... Until agent 3 lands, those lines will not compile against your private header. That is expected, so check everything else. +- A taken-over class gets no generated stubs. Every method your header declares but you do not write yet gets a one-line definition calling reconstruction_missing("Class::Method 00xxxxxx") from src/log.h, so the build keeps linking and stops there with a clear message. +- Comments: a comment starting with an address takes that function over. So does every address in a parenthesised list on a comment, like "(0040b000, 0040b1d0, 00a1a5c0 to 00a1a630)" (ranges included). +- src/data.h has resource_path(path) (lowercased, under resources/) for any non-JSON resource, and data_path(path) for converted XML. .anm2 files are Anm2Ed JSON documents, already handled by src/anm2.h. + +How the build works: +- generated-src/classes.h is generated and declares every class with the original 32-bit layout. +- generated-src/stubs.cpp defines every function src/ has not taken over as a stub that prints "Reached X, not reconstructed yet" and exits. +- CMake builds src/*.cpp + stubs.cpp into build/isaac. Only curated code ever runs. +- When src/.h defines a struct or class itself, the generator (scripts/source_tree.py) drops that class from classes.h, keeping only a forward declaration, and writes no stubs for it. That is a CLASS TAKEOVER, and this round is about class takeovers. + +How to take over a class: +- Write src/.h with the class definition and src/.cpp with its methods. Include "classes.h" for everything else. +- Make it idiomatic C++20 in the smack-a-brother style: + - std::string, std::vector, std::map, std::unordered_map, std::array, std::unique_ptr members instead of the MSVC layouts; + - real enums, preferably enum class or plain enums as smack-a-brother does, for modes and flags; + - constexpr SCREAMING_SNAKE_CASE constants; + - default member initializers; + - no raw offsets, no sized operator_delete, no hand-built MSVC trees, no GHIDRA_* helpers, no msvc:: types in your classes. + - The original layout no longer binds the class, because only curated code touches it. +- Names: keep Rebirth's names for the class and for methods the game has (ANM2::Play, StringTable::GetString, ItemConfig::Load ...). Name fields in camelCase without a leading underscore (_spriteSheetPath becomes spriteSheetPath). Use REPENTOGON's names (repentogon/libzhl/functions/*.zhl) where they exist. Everything else follows CLAUDE.md: noun_verb snake_case free functions, camelCase locals, "is" booleans. +- Method signatures may become idiomatic (std::string_view instead of std_string*, references instead of pointers, enums instead of ints) when that is clearer. Keep the meaning. +- Each method the original has gets a comment directly above it that starts with its address (or addresses, if you merged several), then one short sentence: "// 0040bd50 Loads the .anm2 at path, sharing parsed files through the cache." The generator stops emitting a function once src/ carries its address. +- Take over the WHOLE class you are assigned: every method the class has in the original that the game needs (see generated-src/classes.h for the list and generated-src/.cpp, ./decompile.sh
, ./decompile.sh --asm
N for bodies). + - Collapse compiler-generated ones (copy constructors, operator_assign, destructors that only free members) into the language defaults where std members make them unnecessary, and still list their addresses in a comment above the class so the generator drops them: "// Copies, assignment and destruction (0040b000, 0040b1d0, 0040ae70) are the defaults." +- Behaviour must match the original exactly: same results, same order of effects, same edge cases. Where the original crashes or has undefined behaviour, pick a safe behaviour and say so in one comment line. +- Data: XML is converted by the import tool into JSON under resources/ (lowercase paths, ".json" appended). Read it through src/data.h: data_load, node_children, node_tag, node_attr, node_text. Element order is preserved and attribute values are the original strings. A file with several roots becomes {"tag":"#document","children":[...]}. Convert values exactly as the original did. resources/ holds the real converted game files: look at them. +- Other classes: call whatever classes.h declares for classes nobody has taken over (they are stubs for now). Do NOT edit src/ files other than your own: other agents are rewriting other classes at the same time. If a round 1 file outside your assignment calls something you changed, list the needed call-site change in your report. +- Every file you write must compile with no warnings: clang++ -std=c++20 -fsyntax-only -Wall -Wextra -I src -isystem ${R}/gen_\${i} -isystem external/simdjson/singleheader -isystem external/sdl/include src/.cpp + - First regenerate your private header with python3 -I scripts/source_tree.py ${R}/gen_\${i} classes.tsv dump zhl_vtables.tsv. Rerun it after creating your .h, because the generator drops the classes your header defines. + - Round 1 files that depend on your old API may stop compiling. That is expected, so only check your own files. +- Style details from CLAUDE.md: + - Allman braces; a one-line body stays on one line without braces. + - One declaration per line, with members sorted logically and same types grouped. + - Case labels indented. + - One short comment above each struct and function, with no semicolons inside comments. + - Blank lines between logical blocks. + - Few parameters: pass a struct reference rather than many arguments. + - Short, elegant code, the fewest lines that stay clear. +Final message: +- per method: taken over, merged into a default, or why not, with addresses; +- the public API of your classes (one line each); +- call-site changes other src/ files need; +- anything in the original you found wrong or surprising.` +const tasks = [ +__TASKS__ +] +await parallel(tasks.map((task, i) => () => agent(common.replaceAll('${i}', String(i)) + '\n\n' + task, { label: `curate2a ${i}`, phase: 'Curate' }))) +return 'done'