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

Options:

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

The output directory mirrors the structure of the upstream eo-protocol/xml/ repo 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.2.0.tar.gz (18.7 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.2.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eo_proto_merge-0.2.0.tar.gz
  • Upload date:
  • Size: 18.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 0c724d5fcf36deb6ae72f95089cbcb89286201fb6e56b9dc348a8fa7056fe75d
MD5 f9d0227445197e583e6732c2a40b4db3
BLAKE2b-256 8204918717160f162836583bf309c90ca203e5496efaae98ca0b33c8cd56b490

See more details on using hashes here.

Provenance

The following attestation bundles were made for eo_proto_merge-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: eo_proto_merge-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee3f16831febbe1bbf0c344a89615ac4c29167ade78acc6275f8b82c62767e09
MD5 54a71bed4652e894f87cd5cbe31f5a64
BLAKE2b-256 ecd56c8d9d0b53cd3d805c04ba8e591655c3d33a9607c6c18bd1a81aaaf24cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for eo_proto_merge-0.2.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