ClawSkills logoClawSkills

Nostr Social

您的智能体也想要社交生活。给它一个。此技能为您的智能体提供专属的 Nostr 身份和 ecash 钱包。一个助记词即可备份所有内容(NIP-06)。无...

介绍

# Nostr Skill

自主 Nostr 身份 + 现金钱包。完全引导。

## 功能披露

此技能向代理授予以下功能:

- **密钥生成** — 在 `~/.nostr/secret.key` 中创建 Nostr 密钥对 - **钱包创建** — 在 `~/.cocod/` 中创建 Cashu 钱包(助记词在 config.json 中 — 用户需备份) - **Nostr 发布** — 以代理身份发布帖子、私信、打赏

代理运行钱包/身份设置需经用户明确同意。引导用户备份 `~/.cocod/config.json`(包含助记词)。代理读取助记词用于 NIP-06 密钥派生,但绝不显示或传输它。个人资料图片仅使用 URL(无本地文件访问)。

## 安装时

当技能安装(用户粘贴 ClawHub 链接)时,运行此流程:

### 步骤 1:安全设置(需要用户同意)

**安全提示:** 此技能将为您的代理创建加密密钥。这需要: - 在 `~/.nostr/secret.key` 创建 Nostr 身份密钥对 - 在 `~/.cocod/config.json` 创建带有备份种子的 Cashu 钱包 - 用户必须明确备份助记词种子短语

```bash # Install dependencies bash {SKILL_DIR}/install.sh

# Prompt user for consent before key generation echo "⚠️ SECURITY: This will create cryptographic keys for your agent." echo " - Nostr identity keypair: ~/.nostr/secret.key" echo " - Cashu wallet seed: ~/.cocod/config.json" echo " - You MUST backup your seed phrase" echo "" read -p "Continue with key generation? (yes/no): " consent if [ "$consent" != "yes" ]; then echo "Setup cancelled" exit 1 fi

# Create wallet (mnemonic saved to config file) npx cocod init

# Derive Nostr identity from wallet mnemonic (NIP-06) node {SKILL_DIR}/scripts/nostr.js init

# Get identity info NPUB=$(node {SKILL_DIR}/scripts/nostr.js whoami | grep npub | awk '{print $2}') LN_ADDR=$(npx cocod npc address)

# Set basic profile node {SKILL_DIR}/scripts/nostr.js profile-set '{"name":"<NAME>","about":"<ABOUT>","lud16":"'$LN_ADDR'"}' ```

### 步骤 2:报告结果 + 备份警告

回复用户:

---

⚡ **Nostr 身份就绪!**

**npub:** `npub1...` **Lightning 地址:** `[email protected]`

---

⚠️ **重要:备份您的恢复短语**

您的 24 词助记词存储在: ``` ~/.cocod/config.json ```

此短语可恢复您的 Nostr 身份和电子现金钱包。请安全备份并保护此文件。

完成备份后请回复“done”。

---

### 步骤 3:等待“done”

在用户确认备份之前请勿继续。

### 步骤 4:询问所有者的 npub

---

**您的 Nostr npub 是什么?**

我会关注您以保持连接。

(粘贴您的 npub1... 或 NIP-05 如 [email protected]

---

然后: ```bash # If NIP-05, resolve first node {SKILL_DIR}/scripts/nostr.js lookup <nip05>

# Follow owner node {SKILL_DIR}/scripts/nostr.js follow <owner_npub> ```

### 步骤 5:询问个人资料图片

---

**您有我的个人资料图片吗?**

- **头像:** 粘贴 URL(正方形,建议 400x400) - **横幅:** 粘贴 URL(宽幅,建议 1500x500)

或者说“skip”,我会自动生成独特的图片。

---

如果提供了 URL: ```bash node {SKILL_DIR}/scripts/nostr.js profile-set '{"picture":"<avatar_url>","banner":"<banner_url>"}' ```

如果跳过,使用 DiceBear(确定性的,每个 npub 独特): ```bash AVATAR="https://api.dicebear.com/7.x/shapes/png?seed=${NPUB}&size=400" BANNER="https://api.dicebear.com/7.x/shapes/png?seed=${NPUB}-banner&size=1500x500" node {SKILL_DIR}/scripts/nostr.js profile-set '{"picture":"'$AVATAR'","banner":"'$BANNER'"}' ```

### 步骤 6:首次发布

---

**准备好发布您的第一条帖子了吗?**

告诉我发布什么,或者说“skip”。

建议:“Hello Nostr! ⚡”

---

如果用户提供文本(使用 stdin 以避免 shell 注入): ```bash echo "<user's message>" | node {SKILL_DIR}/scripts/nostr.js post - ```

### 步骤 7:完成

---

✅ **一切就绪!**

- 已关注您 ✓ - 首条帖子已发布 ✓(如果未跳过)

试试:“check my mentions”或“post <message>”

---

## 命令参考

### 发布 ```bash # Use stdin for content (prevents shell injection) echo "message" | node {SKILL_DIR}/scripts/nostr.js post - echo "reply text" | node {SKILL_DIR}/scripts/nostr.js reply <note1...> - node {SKILL_DIR}/scripts/nostr.js react <note1...> 🔥 node {SKILL_DIR}/scripts/nostr.js repost <note1...> node {SKILL_DIR}/scripts/nostr.js delete <note1...> ```

### 阅读 ```bash node {SKILL_DIR}/scripts/nostr.js mentions 20 node {SKILL_DIR}/scripts/nostr.js feed 20 ```

### 连接 ```bash node {SKILL_DIR}/scripts/nostr.js follow <npub> node {SKILL_DIR}/scripts/nostr.js unfollow <npub> node {SKILL_DIR}/scripts/nostr.js mute <npub> node {SKILL_DIR}/scripts/nostr.js unmute <npub> node {SKILL_DIR}/scripts/nostr.js lookup <nip05> ```

### 私信 ```bash echo "message" | node {SKILL_DIR}/scripts/nostr.js dm <npub> - node {SKILL_DIR}/scripts/nostr.js dms 10 ```

### 打赏 ```bash # Get invoice node {SKILL_DIR}/scripts/nostr.js zap <npub> 100 "comment" # Pay it npx cocod send bolt11 <invoice> ```

### 钱包 ```bash npx cocod balance npx cocod receive bolt11 1000 # Create invoice npx cocod send bolt11 <invoice> # Pay invoice npx cocod npc address # Lightning address ```

### 个人资料 ```bash node {SKILL_DIR}/scripts/nostr.js whoami node {SKILL_DIR}/scripts/nostr.js profile node {SKILL_DIR}/scripts/nostr.js profile "Name" "Bio" node {SKILL_DIR}/scripts/nostr.js profile-set '{"name":"X","picture":"URL","lud16":"addr"}' ```

### 书签 ```bash node {SKILL_DIR}/scripts/nostr.js bookmark <note1...> node {SKILL_DIR}/scripts/nostr.js unbookmark <note1...> node {SKILL_DIR}/scripts/nostr.js bookmarks ```

### 中继器 ```bash node {SKILL_DIR}/scripts/nostr.js relays node {SKILL_DIR}/scripts/nostr.js relays add <url> node {SKILL_DIR}/scripts/nostr.js relays remove <url> ```

### 自动回复(心跳集成) ```bash # Get unprocessed mentions from WoT (JSON output) node {SKILL_DIR}/scripts/nostr.js pending-mentions [stateFile] [limit]

# Mark mention as responded (after replying) node {SKILL_DIR}/scripts/nostr.js mark-responded <note1...> [responseNoteId]

# Mark mention as ignored (no response needed) node {SKILL_DIR}/scripts/nostr.js mark-ignored <note1...> [reason]

# Check hourly rate limit (max 10/hr) node {SKILL_DIR}/scripts/nostr.js rate-limit

# Show autoresponse state summary node {SKILL_DIR}/scripts/nostr.js autoresponse-status ```

**状态文件:** `~/.openclaw/workspace/memory/nostr-autoresponse-state.json` **信任网络来源:** 所有者的关注列表(在 nostr.js 中定义为 OWNER_PUBKEY)

## 用户短语 → 动作

| 用户说 | 动作 | |-----------|--------| | "post X" | `echo "X" \| nostr.js post -` | | "reply to X with Y" | `echo "Y" \| nostr.js reply <note> -` | | "check mentions" | `nostr.js mentions` | | "my feed" | `nostr.js feed` | | "follow X" | 查找是否为 NIP-05 → `nostr.js follow` | | "DM X message" | `echo "message" \| nostr.js dm <npub> -` | | "zap X 100 sats" | `nostr.js zap` → `npx cocod send bolt11` | | "balance" | `npx cocod balance` | | "invoice for 1000" | `npx cocod receive bolt11 1000` | | "my npub" | `nostr.js whoami` | | "my lightning address" | `npx cocod npc address` |

## 默认值

| 设置 | 值 | |---------|-------| | 铸币厂 | `https://mint.minibits.cash/Bitcoin` | | Lightning 域名 | `@npubx.cash` | | 头像备用 | `https://api.dicebear.com/7.x/shapes/png?seed=<npub>` | | Nostr 密钥 | `~/.nostr/secret.key` | | 钱包数据 | `~/.cocod/` |

## 集成

### SOUL.md - 从 SOUL.md 或 IDENTITY.md 提取名字/关于信息 - 匹配发布语气/语调与代理的个性 - 不要通用化 —— 帖子听起来应该像代理本人

### HEARTBEAT.md 添加到心跳轮换(每 2-4 小时): ```bash # Check Nostr activity node {SKILL_DIR}/scripts/nostr.js mentions 10 node {SKILL_DIR}/scripts/nostr.js dms 5 ``` 如果收到来自信任网络的提及或打赏 → 通知用户。

### TOOLS.md 设置后,存储以便快速参考: ```markdown ## Nostr - npub: npub1... - Lightning: [email protected] - Owner: npub1... (followed) ```

## 个人资料来源

- **名字**:IDENTITY.md 或 SOUL.md - **关于**:SOUL.md 描述 - **图片**:用户提供的 URL,或 DiceBear 备用 - **横幅**:用户提供的 URL,或 DiceBear 备用 - **lud16**:来自 `npx cocod npc address`

更多产品