Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计提醒

nostr-relay-builder诺斯特继电器建设者

Agent Skill

nostr-relay-builder 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

218

周安装

9

GitHub Stars

4

下载量

71
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nostr-relay-builder(诺斯特继电器建设者)
来源仓库:https://github.com/accolver/skill-maker
仓库路径:skills/nostr-relay-builder
安装命令:
npx skills add https://github.com/accolver/skill-maker --skill nostr-relay-builder
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/accolver/skill-maker --skill nostr-relay-builder

简介

用于查找、检索和筛选相关信息,快速定位候选结果。

  • 适合在关键词搜索、任务场景或来源线索下使用,提升信息获取效率。
  • 可结合来源仓库和原始 README 核验具体用法,确保适用性。
  • 安装方式:通过 npx 从 GitHub 仓库添加,支持 Codex、Claude、Cursor、Gemini CLI。
  • 注意:安装前建议确认权限范围和维护状态,避免触发不必要的联网或文件操作。

SKILL.md

Nostr Relay Builder

Build a Nostr relay from scratch: WebSocket server, NIP-01 message protocol, event validation (id + signature), filter matching, subscription management, and progressive NIP support.

Overview

A Nostr relay is a WebSocket server that receives, validates, stores, and distributes events. This skill walks through building one step by step, starting with the mandatory NIP-01 protocol and progressively adding optional NIPs.

When to use

  • The task is implementing or extending a Nostr relay server.
  • The user needs relay-side handling for WebSocket messages, event validation, storage rules, subscriptions, or relay-supported NIPs.
  • The problem lives on the server side of the protocol, not in a client app.
  • The output should shape relay behavior, persistence, or message handling.

Do NOT use when:

  • The task is building a Nostr client.
  • The work is only constructing events or filters for client use.
  • The request is NIP-05 identity hosting rather than relay protocol behavior.

Response format

Always structure the final response with these top-level sections, in this order:

  1. Summary — state the task, scope, and main conclusion in 1-3 sentences.
  2. Decision / Approach — state the key classification, assumptions, or chosen path.
  3. Artifacts — provide the primary deliverable(s) for this skill. Use clear subheadings for multiple files, commands, JSON payloads, queries, or documents.
  4. Validation — state checks performed, important risks, caveats, or unresolved questions.
  5. Next steps — list concrete follow-up actions, or write None if nothing remains.

Rules:

  • Do not omit a section; write None when a section does not apply.
  • If files are produced, list each file path under Artifacts before its contents.
  • If commands, JSON, SQL, YAML, or code are produced, put each artifact in fenced code blocks with the correct language tag when possible.
  • Keep section names exactly as written above so output stays predictable across skills.

Workflow

1. Set up the WebSocket server

Create a WebSocket endpoint that accepts connections. The relay MUST:

  • Accept WebSocket upgrade requests on the root path
  • Handle multiple concurrent connections
  • Track per-connection state (subscriptions, auth status)
  • Implement ping/pong for connection health
  • Parse incoming messages as JSON arrays
// Bun example — minimal WebSocket server
Bun.serve({
  port: 3000,
  fetch(req, server) {
    // NIP-11: serve relay info on HTTP GET with Accept: application/nostr+json
    if (req.headers.get("Accept") === "application/nostr+json") {
      return Response.json(relayInfo, {
        headers: {
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "Accept",
          "Access-Control-Allow-Methods": "GET",
        },
      });
    }
    if (server.upgrade(req)) return;
    return new Response("Connect via WebSocket", { status: 400 });
  },
  websocket: {
    open(ws) {
      ws.data = { subscriptions: new Map() };
    },
    message(ws, raw) {
      handleMessage(ws, JSON.parse(raw));
    },
    close(ws) {/* cleanup subscriptions */},
  },
});

2. Implement the NIP-01 message protocol

Handle the three client message types and respond with the five relay message types. See references/message-protocol.md for the complete format reference.

function handleMessage(ws, msg: unknown[]) {
  const verb = msg[0];
  switch (verb) {
    case "EVENT":
      return handleEvent(ws, msg[1]);
    case "REQ":
      return handleReq(ws, msg[1], msg.slice(2));
    case "CLOSE":
      return handleClose(ws, msg[1]);
    default:
      return send(ws, ["NOTICE", `unknown message type: ${verb}`]);
  }
}

Critical rules:

  • EVENT → always respond with OK (true/false + message)
  • REQ → send matching stored events, then EOSE, then stream new matches
  • CLOSE → remove the subscription, no response required
  • Subscription IDs are per-connection, max 64 chars, non-empty strings
  • A new REQ with an existing subscription ID replaces the old subscription

3. Implement event validation

Every received event MUST be validated before storage. Follow the checklist in references/event-validation.md. The two critical checks:

ID verification — recompute and compare:

import { sha256 } from "@noble/hashes/sha256";
import { bytesToHex } from "@noble/hashes/utils";

function computeEventId(event): string {
  const serialized = JSON.stringify([
    0,
    event.pubkey,
    event.created_at,
    event.kind,
    event.tags,
    event.content,
  ]);
  return bytesToHex(sha256(new TextEncoder().encode(serialized)));
}

Signature verification — Schnorr over secp256k1:

import { schnorr } from "@noble/curves/secp256k1";

function verifySignature(event): boolean {
  return schnorr.verify(event.sig, event.id, event.pubkey);
}

If validation fails, respond with ["OK", event.id, false, "invalid: <reason>"].

4. Implement filter matching

Filters determine which events match a subscription. The logic is:

  • Within a single filter: all specified conditions must match (AND)
  • Across multiple filters in a REQ: any filter matching is sufficient (OR)
  • List fields (ids, authors, kinds, #tags): event value must be in the list (OR within field)
function matchesFilter(event, filter): boolean {
  if (filter.ids && !filter.ids.includes(event.id)) return false;
  if (filter.authors && !filter.authors.includes(event.pubkey)) return false;
  if (filter.kinds && !filter.kinds.includes(event.kind)) return false;
  if (filter.since && event.created_at < filter.since) return false;
  if (filter.until && event.created_at > filter.until) return false;

  // Tag filters: #e, #p, #a, etc.
  for (const [key, values] of Object.entries(filter)) {
    if (key.startsWith("#") && key.length === 2) {
      const tagName = key.slice(1);
      const eventTagValues = event.tags
        .filter((t) => t[0] === tagName)
        .map((t) => t[1]);
      if (!values.some((v) => eventTagValues.includes(v))) return false;
    }
  }
  return true;
}

limit handling: only applies to the initial query (not streaming). Return the newest limit events, ordered by created_at descending. On ties, lowest id (lexicographic) first.

5. Implement event storage with kind-based rules

Different kind ranges have different storage semantics:

Kind RangeTypeStorage Rule
1, 2, 4-44, 1000-9999RegularStore all events
0, 3, 10000-19999ReplaceableKeep only latest per pubkey + kind
20000-29999EphemeralDo NOT store; broadcast only
30000-39999AddressableKeep only latest per pubkey + kind + d tag

For replaceable/addressable events with the same created_at, keep the one with the lowest id (lexicographic order).

function getEventDTag(event): string {
  const dTag = event.tags.find((t) => t[0] === "d");
  return dTag ? dTag[1] : "";
}

function isReplaceable(kind: number): boolean {
  return kind === 0 || kind === 3 || (kind >= 10000 && kind < 20000);
}

function isAddressable(kind: number): boolean {
  return kind >= 30000 && kind < 40000;
}

function isEphemeral(kind: number): boolean {
  return kind >= 20000 && kind < 30000;
}

6. Implement subscription management

Track active subscriptions per connection:

function handleReq(ws, subId: string, filters: object[]) {
  if (!subId || subId.length > 64) {
    return send(ws, ["CLOSED", subId, "invalid: bad subscription id"]);
  }

  // Replace existing subscription with same ID
  ws.data.subscriptions.set(subId, filters);

  // Query stored events matching any filter
  const matches = queryEvents(filters);
  for (const event of matches) {
    send(ws, ["EVENT", subId, event]);
  }
  send(ws, ["EOSE", subId]);

  // New events will be checked against this subscription in real-time
}

function handleClose(ws, subId: string) {
  ws.data.subscriptions.delete(subId);
}

When a new event is stored, broadcast it to all connections with matching subscriptions (skip the limit check — it only applies to initial queries).

7. Add progressive NIP support

After NIP-01 is solid, add NIPs in this order:

NIP-11 — Relay information document: Serve JSON at the WebSocket URL when the HTTP request has Accept: application/nostr+json. Must include CORS headers. See the example in Step 1.

NIP-09 — Event deletion: Handle kind 5 events. Delete referenced events (by e and a tags) only if the deletion request's pubkey matches the referenced event's pubkey.

NIP-42 — Client authentication: Send ["AUTH", "<challenge>"] to clients. Accept ["AUTH", <signed-event>] responses. The auth event must be kind 22242 with relay and challenge tags. Verify created_at is within ~10 minutes. Use auth-required: prefix in OK/CLOSED messages when auth is needed.

NIP-45 — Event counting: Handle ["COUNT", subId,...filters] messages. Respond with ["COUNT", subId, {"count": N}].

NIP-50 — Search: Support a search field in filters. Implement full-text search over event content.

Checklist

  • WebSocket server accepts connections and parses JSON arrays
  • EVENT messages are validated (id + signature) and stored
  • OK responses sent for every EVENT (true/false + prefix message)
  • REQ creates subscriptions, returns matching events + EOSE
  • CLOSE removes subscriptions
  • Filter matching handles ids, authors, kinds, #tags, since, until, limit
  • Replaceable events (kind 0, 3, 10000-19999) keep only latest per pubkey+kind
  • Addressable events (kind 30000-39999) keep only latest per pubkey+kind+d-tag
  • Ephemeral events (kind 20000-29999) are broadcast but not stored
  • New events broadcast to connections with matching subscriptions
  • NIP-11 info document served on HTTP GET with correct Accept header

Common Mistakes

MistakeFix
Computing event ID with whitespace in JSONUse JSON.stringify with no spacer argument — zero whitespace
Forgetting to verify signature after ID checkBoth checks are mandatory; an event with valid ID but bad sig is invalid
Applying limit to streaming eventslimit only applies to the initial stored-event query, not real-time
Storing ephemeral events (kind 20000-29999)Ephemeral events must be broadcast only, never persisted
Using global subscription IDsSubscription IDs are scoped per WebSocket connection
Not replacing subscription on duplicate REQ IDA new REQ with the same sub ID must replace the old subscription
Missing CORS headers on NIP-11 responseNIP-11 requires Access-Control-Allow-Origin: * and related headers
Tag filter matching all tag elementsOnly the first value (index 1) of each tag is indexed/matched
Returning OK without the machine-readable prefixFailed OK messages must use prefixes: invalid:, duplicate:, error:, etc.
Not handling replaceable event timestamp tiesWhen created_at is equal, keep the event with the lowest id (lexicographic)

Quick Reference

MessageDirectionFormat
EVENT (client)Client → Relay["EVENT", <event>]
REQClient → Relay["REQ", <sub_id>, <filter1>,...]
CLOSEClient → Relay["CLOSE", <sub_id>]
EVENT (relay)Relay → Client["EVENT", <sub_id>, <event>]
OKRelay → Client["OK", <event_id>, <bool>, <message>]
EOSERelay → Client["EOSE", <sub_id>]
CLOSEDRelay → Client["CLOSED", <sub_id>, <message>]
NOTICERelay → Client["NOTICE", <message>]
AUTH (relay)Relay → Client["AUTH", <challenge>]
AUTH (client)Client → Relay["AUTH", <signed-event>]
OK PrefixMeaning
duplicate:Event already stored
invalid:Failed validation (bad id, bad sig, bad format)
blocked:Pubkey or IP is blocked
rate-limited:Too many events
restricted:Not authorized to write
pow:Proof-of-work related
error:Internal relay error
auth-required:Must authenticate first (NIP-42)

Key Principles

  1. Validate everything — Never store an event without verifying both the id (SHA-256 of canonical serialization) and the signature (Schnorr secp256k1). A relay that skips validation poisons the network.
  2. OK is mandatory — Every EVENT from a client MUST receive an OK response, whether accepted or rejected. Silent drops break client retry logic.
  3. Subscriptions are per-connection — Never share subscription state across WebSocket connections. Each connection maintains its own subscription map.
  4. Kind semantics are non-negotiable — Replaceable events (0, 3, 10000-19999) keep only the latest. Addressable events (30000-39999) key on pubkey+kind+d-tag. Ephemeral events (20000-29999) are never stored. Getting this wrong corrupts user data.
  5. Progressive enhancement — Start with NIP-01 only. Add NIPs one at a time, updating supported_nips in the NIP-11 info document as you go. A relay that does NIP-01 perfectly is more useful than one that does 10 NIPs poorly.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.44%
按下载量换算25

Claude

28.3%
按下载量换算20

Cursor

19.23%
按下载量换算14

Gemini CLI

8.74%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills