Skip to main content

CLI tool for merging eo-protocol extensions and generating extended protocol XML

Project description

eo-proto-merge

Tests

A CLI tool for merging eo-protocol extensions and outputting extended protocol XML files ready to use with any eolib code generator.


Installation

pip install eo-proto-merge

Requires Python 3.9+.


Commands

Command Description
eo-proto-merge apply Fetch extensions, merge XML, and write extended protocol files
eo-proto-merge validate Dry-run merge to check for conflicts without writing any files

eo-proto-merge apply

Reads an extensions.xml config, fetches extension sources, merges the XML into the base eo-protocol files, and writes the result to an output directory.

eo-proto-merge apply --config=extensions.xml --output=./eo-protocol

Options:

Flag Default Description
--config extensions.xml Path to your extensions.xml file
--output ./eo-protocol Output directory for the merged protocol XML files

The output directory mirrors the structure of eo-protocol/xml/ and can be passed directly to any eolib code generator.


eo-proto-merge validate

Fetches the base eo-protocol and all extensions to the local cache, then performs a dry-run merge to check for conflicts — without writing any output files. Useful for catching merge errors during extension development or in CI.

eo-proto-merge validate --config=extensions.xml

extensions.xml format

Create an extensions.xml file in your project to declare which extensions to apply:

<extensions>
  <!-- Official registry extension (git, https://github.com/sorokya/eo-protocol-extensions) -->
  <extension type="git" name="deep"/>

  <!-- Extension from a custom repository -->
  <extension type="git"
             name="my-feature"
             repo="https://github.com/my-org/eo-protocol-extensions"/>

  <!-- Pin to a specific tag or commit -->
  <extension type="git" name="my-feature" ref="v2.0.0"
             repo="https://github.com/my-org/eo-protocol-extensions"/>

  <!-- Local file-based extension (good for development) -->
  <extension type="file" name="local-test" path="../my-extension"/>
</extensions>

Extensions are applied in the order they appear. Later extensions can append to or replace definitions introduced by earlier ones.

The path for type="file" can be relative (resolved from the extensions.xml location) or absolute.


Extension XML format

Extension protocol.xml files mirror the structure of the base eo-protocol XML files.

The extend attribute

extend can be used on top-level elements (<enum>, <struct>, <packet>) to control the merge behavior:

Value Behavior
(absent) New — definition must not already exist. Error if it does.
"append" Append — push child elements onto an existing definition.
"replace" Replace — completely swap out an existing definition.

extend="replace" can also be used on individual <value> children inside an extend="append" enum block to rename a specific existing value by its numeric position, without replacing the whole enum:

<!-- Rename Reserved7 to Spell while leaving all other values intact -->
<enum name="ItemType" extend="append">
    <value name="Spell" extend="replace">7</value>
</enum>

Appending switch cases

Use extend="append" on a <switch> child to add new <case> elements without replacing the whole definition. The merger locates the target <switch> by its field attribute, searching recursively — it works whether the switch is a direct child or nested inside a <chunked> block.

<struct name="AvatarChange" extend="append">
    <switch field="change_type" extend="append">
        <case value="Skin">
            <field name="skin" type="char"/>
        </case>
    </switch>
</struct>

Conflict rules

Situation Behavior
New definition with duplicate name Error — use extend="replace" to override
Append to nonexistent target Error — check name and extension order
Replace nonexistent target Error
Enum append with duplicate numeric value Error — numeric conflicts corrupt generated code
Enum value replace with nonexistent numeric value Error — check the numeric value
Switch append with no matching field Error — check the field name

Example

<?xml version="1.0" encoding="UTF-8"?>
<protocol>
    <!-- Add a brand-new enum -->
    <enum name="Rarity" type="char">
        <value name="Common">0</value>
        <value name="Rare">1</value>
    </enum>

    <!-- Add a new value to an existing enum -->
    <enum name="PacketFamily" extend="append">
        <value name="Rarity">200</value>
    </enum>

    <!-- Rename an existing reserved value by numeric position -->
    <enum name="ItemType" extend="append">
        <value name="Spell" extend="replace">7</value>
    </enum>

    <!-- Completely replace an existing struct -->
    <struct name="Coords" extend="replace">
        <field name="x" type="short"/>
        <field name="y" type="short"/>
        <field name="layer" type="char"/>
    </struct>

    <!-- Add new cases to a switch inside an existing struct -->
    <struct name="AvatarChange" extend="append">
        <switch field="change_type" extend="append">
            <case value="Skin">
                <field name="skin" type="char"/>
            </case>
        </switch>
    </struct>

    <!-- Add a new client-to-server packet -->
    <packet family="Rarity" action="Request">
        <field name="item_id" type="short"/>
    </packet>
</protocol>

Extension directory structure

An extension directory mirrors the layout of eo-protocol/xml/:

my-extension/
  protocol.xml              ← top-level definitions (enums, structs, misc packets)
  net/
    client/
      protocol.xml          ← client-to-server packets
    server/
      protocol.xml          ← server-to-client packets
  pub/
    protocol.xml            ← pub file type definitions (EIF, ENF, ESF, ECF)

Not all files are required — include only what your extension touches.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eo_proto_merge-0.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eo_proto_merge-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file eo_proto_merge-0.1.0.tar.gz.

File metadata

  • Download URL: eo_proto_merge-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eo_proto_merge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 532dfdc059faa9fb12d66255000f2e6d312c99ac593d303447a12092d12af00a
MD5 49e4ba0da6b62e84b156f773ba4f104a
BLAKE2b-256 db9d04e202758023018c74cb7ea5ddaec89dafdee3d95b97e34b1b5dd4ce2d63

See more details on using hashes here.

Provenance

The following attestation bundles were made for eo_proto_merge-0.1.0.tar.gz:

Publisher: publish.yml on sorokya/eo-proto-merge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eo_proto_merge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: eo_proto_merge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eo_proto_merge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b50b728402b38ff626c840b7ee5021630a02efc085a1b20173afb7fdcff1e909
MD5 eaad5fb1dc0118137021d44972e2a693
BLAKE2b-256 466d9ebe7deb02371a56f9eb26607190a0145941f255b2c353f0c9066953fb6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eo_proto_merge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on sorokya/eo-proto-merge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page