agentleFS
huangchenghuangcheng/Seelie/.claude/skills/seelie-server/SKILL.md

seelie-server

Skill4 starsChanged 8 months agoMITView on GitHub

Build, deploy and operate the Seelie generic UDP server. Covers the binary datagram protocol, CHECK/ANNOUNCE version-check flow, rebar3 builds, systemd deployment, and Aliyun firewall configuration. Use when the user wants to deploy the server, modify the protocol, test version checking, or manage the running daemon.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All datagrams share a fixed header, variable payload, and trailing CRC16.

    line 37
  2. Distinctive:

    If the client is already up-to-date or ahead:

    line 80
  3. Very specific:

    If CMakeLists.txt moves, update the absolute path in sys.config and redeploy.

    line 218
  4. Very specific:

    Add the platform binary to ?VALID_PLATFORMS in update_handler.erl

    line 222

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

The Seelie project includes a lightweight Erlang/OTP UDP server (server/). It currently handles version checking and can be extended for other UDP-based services. It lives on branch feature/update-server and is deployed to a public host at updates.example.com:9340 (the real host:port is configured at build time via the SEELIE_DEFAULT_UPDATE_ENDPOINT CMake cache variable — see CMakeLists.txt).

When to use

Triggers:

  • "deploy the server", "rebuild the server", "restart the daemon"
  • "how does the version check protocol work", "what is the datagram format"
  • "test the update server", "check if the server is running"
  • "open firewall port for updates", "change update server port"
  • modifying update_handler.erl, protocol.erl, or sys.config

Architecture

client (Qt/C++)          UDP            server (Erlang/OTP)
   |      CHECK  ------------------>  udp_server (gen_server)
   |     ANNOUNCE <------------------  protocol (codec)
   |                                   update_handler (manifest)
  • udp_server — opens UDP socket, dispatches packets to spawned handlers
  • protocol — binary encode/decode + CRC16-CCITT validation
  • update_handler — reads CMakeLists.txt version, compares with client's current version
  • systemd — seelie-server.service manages the release binary

Protocol

All datagrams share a fixed header, variable payload, and trailing CRC16.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Magic (4 bytes)                        |
|                     'H' 'C' 'H' 0x01                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version (1)   |  Command (1)  |           Seq (2)             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length (2)    |          Payload (*)          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                          Payload (cont.)                      ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           CRC16-CCITT (2)     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
FieldSizeValue
Magic4 B<<"HCH", 1>>
Version1 B1
Command1 B1=CHECK, 2=ANNOUNCE, 3=PULL, 4=PUSH, 5=ACK
Seq2 Buint16 big-endian, echo back in replies
PayloadLen2 Buint16 big-endian, max 1384
PayloadN BJSON (v1)
CRC162 BCRC16-CCITT (0xFFFF init, poly 0x1021) over all preceding bytes

v1 flow — check only

CHECK (client → server)

{"current_version":"1.0.0","platform":"windows"}

ANNOUNCE (server → client)

{"available":true,"latest_version":"1.2.0"}

If the client is already up-to-date or ahead:

{"available":false}

Supported platforms: windows, macos, linux.

Build

Requires Erlang/OTP 25+ and rebar3.

cd server
rebar3 compile          # dev build
rebar3 eunit            # run CRC + protocol tests
rebar3 as prod release  # production release under _build/prod/rel/server

Deploy

The production release is at /opt/seelie-server on the Aliyun host.

Push changes and rebuild

scp -r server/* aliyun:/opt/seelie-server/
ssh aliyun "cd /opt/seelie-server && rebar3 as prod release && systemctl restart seelie-server"

systemd service

File: /etc/systemd/system/seelie-server.service

[Unit]
Description=Seelie Generic UDP Server
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/seelie-server/_build/prod/rel/server
Environment=HOME=/root
ExecStart=/opt/seelie-server/_build/prod/rel/server/bin/server foreground
ExecStop=/opt/seelie-server/_build/prod/rel/server/bin/server stop
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Manage:

systemctl status seelie-server
systemctl restart seelie-server
systemctl stop seelie-server
journalctl -u seelie-server -f

Configuration

/opt/seelie-server/config/sys.config (rebuilt into the release):

[
    {server, [
        {udp_port, 9340},
        {udp_workers, 4},
        {version_file, "/opt/seelie-server/CMakeLists.txt"}
    ]}
].
  • udp_port — the port to open in Aliyun security group (UDP inbound)
  • version_file — absolute path to the root CMakeLists.txt the server reads for project(VERSION)

Test

A Python test script is included at test_udp.py:

python test_udp.py

Or manually with ncat / a small Python socket script:

import socket, struct, json

MAGIC = b'HCH\x01'
def crc16(data):
    crc = 0xFFFF
    for b in data:
        crc ^= b << 8
        for _ in range(8):
            crc = ((crc << 1) ^ 0x1021 if crc & 0x8000 else crc << 1) & 0xFFFF
    return crc

def encode(cmd, seq, payload=b''):
    body = struct.pack('>4sBBHH', MAGIC, 1, cmd, seq, len(payload)) + payload
    return body + struct.pack('>H', crc16(body))

payload = json.dumps({"current_version":"1.0.0","platform":"windows"}).encode()
packet = encode(1, 1, payload)

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(5)
sock.sendto(packet, ("updates.example.com", 9340))  # replace with your update host
data, _ = sock.recvfrom(2048)
print(data)

Files

PathPurpose
server/src/udp_server.erlUDP socket gen_server
server/src/protocol.erlDatagram codec + CRC16
server/src/update_handler.erlVersion comparison logic
server/src/server_app.erlOTP application callback
server/src/server_sup.erlSupervisor
server/config/sys.configRuntime config (port, version_file)
server/rebar.configBuild config + jsx dependency
test_udp.pyPython integration test

Common tasks

Change the listening port

  1. Edit server/config/sys.config
  2. Rebuild release: rebar3 as prod release
  3. Restart: systemctl restart seelie-server
  4. Open the new port in Aliyun security group (UDP inbound)

Update the version source

The server extracts project(Seelie VERSION X.Y.Z ...) from version_file. If CMakeLists.txt moves, update the absolute path in sys.config and redeploy.

Add a new platform

  1. Add the platform binary to ?VALID_PLATFORMS in update_handler.erl
  2. Rebuild and restart

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.