So a few months ago I said I had an idea that would help multiple mods to apply changes to the same files without overriding one another.
The idea basically boils down to; we would need a new raw file type, kinda like creature variations. You would use this format not to define new objects but to apply edits to objects that have been defined elsewhere. Say I wanted to edit dwarves, I would create a new file, for this example I decided to call them "mod" files, with their own headers;
mod_spellcrafts_standard
[MODIFICATION]
then select the dwarf object. probably a good idea for it to filter by object type like;
[MODIFY_OBJECT:CREATURE:DWARF]
Then since what I want to add to them is a CDI, I would add something like this:
[GO_TO_END]
[MD_NEW_TAG:CAN_DO_INTERACTION:SPELL_POWERS_RANDOM_CASTEBASED]
[MD_NEW_TAG:CDI:ADV_NAME:Unlock Racial Abilities]
[MD_NEW_TAG:CDI:USAGE_HINT:GREETING]
[MD_NEW_TAG:CDI:BP_REQUIRED:BY_CATEGORY:HEART]
[MD_NEW_TAG:CDI:TARGET:A:LINE_OF_SIGHT:SELF_ALLOWED]
[MD_NEW_TAG:CDI:VERB:practice your innate magic:practices their innate magic:NA]
[MD_NEW_TAG:CDI:TARGET_RANGE:A:10]
[MD_NEW_TAG:CDI:MAX_TARGET_NUMBER:A:5]
[MD_NEW_TAG:CDI:WAIT_PERIOD:200]
This will be applied to the end of the dwarf raws after the mod file is read and applied. Multiple such files from different mods could thus apply effects to dwarves without overriding one-another or having to be merged/patched, except when theyre both trying to change the same strings. This would have to, ideally, be robust enough to add and remove tissue layers, materials, body parts, castes, and any other aspects of a creature (and every other type of object) besides its object ID.
Ideally, these modification files would be loaded after all object definition files in the load order, then themselves are loaded and apply changes in the order in which the mods theyre part of are loaded. If the object youre trying to modify doesnt exist, it would be ideal if it didnt print a bunch of errors to the errorlog.txt but would instead just pass over it. That would let mods modify objects from other mods, if the other mod is present, but be ignored and not cause issues if they are absent, which helps work around another modding issue you run into trying to mod many games; having to create a third patch mod to make two other mods compatible with one-another. Of course if two mods do modify the same tags/variables in a file then whichever came last in the load order should overwrite the former.
This wasnt every single thought that went through my head as ive been pondering how best this work, but this is the basic gist of what I think is the bare minimum to get multiple mods to not overwrite each other while trying to change the same object, or worse, one mod trying to change dwarves and another trying to change dragons, which are both in creature_standard.txt, so traditionally overwriting one would mean the other mod would simply be ignored. This method would target only a single object definition at a time from a "third-party" file, so creature_standard.txt itself isnt overwritten and only the object in it that you wanted to change is affected.
Will probably have to reload the raw files after changes have been made? I dont know how it works behind the scenes, but possibly it will have to load all the vanilla + mods' object definitions, then load and apply modification files, then reload the now-modified object definitions for play? That would be weird.