Nereid

From bnomei/nereid · View interactive version

Nereid is an AI agent skill from the GitHub repository bnomei/nereid. Collaborate in Nereid Mermaid sessions via MCP using AST-first, probe-refine workflows for sequence, flowchart, class, entity-relationship, and Gantt diagrams, plus xrefs, routes, and walkthroughs. Use when exploring or editing diagrams with a human watching live in TUI, and when coordinating attent

How to use this skill

Skill file

Nereid MCP Collaboration

Collaborate on Mermaid-backed diagrams in a live, shared TUI/MCP session. Keep context small, edits structured, and attention explicit.

Collaboration Contract

Assume co-presence by default:

Drive collaboration with this state model:

Treat these as separate concerns:

Core Principles

Supported category pairs are seq/participant, seq/message, seq/block, seq/section,

flow/node, flow/edge, class/class, class/relation, er/entity, er/relationship,

gantt/section, gantt/task, and gantt/lane.

Diagram Kind Boundaries

| Kind | Mermaid header | Canonical object categories | Mutation path |

|---|---|---|---|

| Sequence | sequenceDiagram | seq/participant, seq/message, seq/block, seq/section | structured seq_* ops or Mermaid replace |

| Flowchart | flowchart / graph | flow/node, flow/edge | structured flow_* ops or Mermaid replace |

| Class | classDiagram | class/class, class/relation | Mermaid replace |

| ER | erDiagram | er/entity, er/relationship | Mermaid replace |

| Gantt | gantt | gantt/section, gantt/task, gantt/lane | Mermaid replace |

Creation, raw Mermaid reads, text rendering, xrefs, selection, and attention work for all five

kinds. diagram_get_ast and object_read return kind-specific fields, including class members,

typed ER cardinalities, and Gantt sections, starts, durations, and dependencies. Typed mutation ops

and dedicated query helpers remain sequence/flow-specific, so edit class, ER, and Gantt diagrams

with Mermaid replace. gantt/lane refs identify rendered time headers; prefer task or section refs

for structural probing.

Execution Discipline

Tool Groups

Default Operating Loop

  1. Resolve target:
  1. Read live collab state:
  1. Probe local context:
  1. Steer visual attention:
  1. Propose and apply minimal edits:
  1. Refresh with deltas:

Live Co-Presence Rules

attention_agent_set); avoid extra diagram_stat, diagram_render_text, or flow_* probes

unless the user asks for inspection/debugging.

Tool Contracts (Input/Output)

`diagram_create_from_mermaid`

Input:

{
  "mermaid": "flowchart TD\n  A --> B",
  "diagram_id": "d-my-flow",
  "name": "My Flow",
  "make_active": true
}

Output:

{
  "diagram": {
    "diagram_id": "d-my-flow",
    "name": "My Flow",
    "kind": "flowchart",
    "rev": 0
  },
  "active_diagram_id": "d-my-flow"
}

`diagram_delete`

Input:

{
  "diagram_id": "d-my-flow"
}

Output:

{
  "deleted_diagram_id": "d-my-flow",
  "active_diagram_id": "d-next"
}

`diagram_get_slice`

Input:

{
  "diagram_id": "d-flow",
  "center_ref": "d:d-flow/flow/node/n:a",
  "radius": 1,
  "depth": 1,
  "filters": {
    "include_categories": ["flow/node", "flow/edge"],
    "exclude_categories": []
  }
}

Output:

{
  "objects": ["d:d-flow/flow/node/n:a", "d:d-flow/flow/node/n:b"],
  "edges": ["d:d-flow/flow/edge/e:ab"]
}

`diagram_apply_ops`

Input:

{
  "diagram_id": "d-seq",
  "base_rev": 3,
  "ops": []
}

Output:

{
  "new_rev": 4,
  "applied": 1,
  "delta": { "added": [], "removed": [], "updated": [] }
}

`walkthrough_apply_ops`

Input:

{
  "walkthrough_id": "w:1",
  "base_rev": 0,
  "ops": []
}

Output:

{
  "new_rev": 1,
  "applied": 1,
  "delta": { "added": [], "removed": [], "updated": [] }
}

`object_read`

Input:

{ "object_ref": "d:d-seq/seq/block/b:0000" }

Output:

{
  "objects": [
    {
      "object_ref": "d:d-seq/seq/block/b:0000",
      "object": {
        "type": "seq_block",
        "kind": "alt",
        "header": "guard",
        "section_ids": ["sec:0000:00", "sec:0000:01"],
        "child_block_ids": []
      }
    },
    {
      "object_ref": "d:d-seq/seq/section/sec:0000:00",
      "object": {
        "type": "seq_section",
        "kind": "main",
        "header": "ok",
        "message_ids": ["m:0000"]
      }
    }
  ],
  "context": {}
}

`attention_human_read`

Input:

{}

Output:

{
  "object_ref": "d:d-auth-flow/flow/node/n:authorize",
  "diagram_id": "d-auth-flow"
}

`attention_agent_read`

Input:

{}

Output:

{
  "object_ref": "d:d-auth-flow/flow/node/n:authorize",
  "diagram_id": "d-auth-flow"
}

`attention_agent_set`

Input:

{
  "object_ref": "d:d-auth-flow/flow/node/n:authorize"
}

Output:

{
  "object_ref": "d:d-auth-flow/flow/node/n:authorize",
  "diagram_id": "d-auth-flow"
}

`attention_agent_clear`

Input:

{}

Output:

{
  "cleared": 1
}

`follow_ai_read`

Input:

{}

Output:

{
  "enabled": true
}

`follow_ai_set`

Input:

{
  "enabled": true
}

Output:

{
  "enabled": true
}

`selection_update`

Input:

{
  "object_refs": [
    "d:d-auth-flow/flow/node/n:start",
    "d:d-auth-flow/flow/node/n:authorize"
  ],
  "mode": "replace"
}

Output:

{
  "applied": [
    "d:d-auth-flow/flow/node/n:authorize",
    "d:d-auth-flow/flow/node/n:start"
  ],
  "ignored": []
}

Probe-and-Refine on Charts

Use a shallow, typed exploration loop:

  1. Anchor on one object (attention_human_read or explicit object_ref).
  2. Pull local structure with diagram_get_slice.
  3. Ask one typed question (seq_*, flow_*, xref_*, route_find).
  4. Shift agent spotlight to next object if needed.
  5. Repeat until ambiguity is resolved.

Escalate to global reads (diagram_read, diagram_get_ast, diagram_render_text) only when local probes are insufficient.

Mutation Discipline

Sequence structure ops

Prefer structured ops over rewriting Mermaid when editing alt / opt / loop / par:

| Op type | Purpose |

|---|---|

| seq_add_block | Create block + main section (kind: alt/opt/loop/par) |

| seq_update_block | Patch block header |

| seq_remove_block | Remove block tree; messages remain |

| seq_add_section | Add else (under alt) or and (under par) |

| seq_update_section | Patch section header |

| seq_remove_section | Remove empty non-main section |

| seq_set_message_section | Attach/move/detach message membership (section_id: null detaches) |

| seq_add_message | Optional section_id to place message on create |

Rules agents must follow:

Example batch (add alt/else with two messages):

{
  "diagram_id": "d-seq",
  "base_rev": 0,
  "ops": [
    {
      "type": "seq_add_block",
      "block_id": "b:cache",
      "kind": "alt",
      "header": "cache",
      "main_section_id": "sec:cache:main"
    },
    {
      "type": "seq_add_section",
      "section_id": "sec:cache:else",
      "block_id": "b:cache",
      "kind": "else",
      "header": "miss"
    },
    {
      "type": "seq_add_message",
      "message_id": "m:hit",
      "from_participant_id": "p:A",
      "to_participant_id": "p:B",
      "kind": "sync",
      "text": "hit",
      "order_key": 1000,
      "section_id": "sec:cache:main"
    },
    {
      "type": "seq_add_message",
      "message_id": "m:miss",
      "from_participant_id": "p:A",
      "to_participant_id": "p:B",
      "kind": "sync",
      "text": "miss",
      "order_key": 2000,
      "section_id": "sec:cache:else"
    }
  ]
}

Walkthrough and Evidence Artifacts

Build walkthroughs as resumable breadcrumbs:

Use xrefs to preserve cross-diagram semantics:

Conflict Recovery

When mutation fails due to stale base_rev:

  1. call diagram_diff or walkthrough_diff from last known rev,
  2. rebase ops on current_rev,
  3. retry with updated base_rev.

If diff history window is exhausted, fetch a fresh snapshot (diagram_read or walkthrough_read) and resume delta-first flow.

Bulk Mermaid replace

Use diagram_replace_from_mermaid when a bulk rewrite is easier than structure ops:

{
  "diagram_id": "d-seq",
  "base_rev": 3,
  "mermaid": "sequenceDiagram\n  A->>B: Hello\n"
}

Behavior:

Reporting Discipline

Report only what the user needs:

MCP Playbook Companion

Use references/mcp-playbooks.md for extra payload templates. Keep this file as the primary protocol and behavior contract.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.