📦 Nostr Social — 代理社交身份
v1.1.8为 AI 代理生成独立 Nostr 身份与 Cashu 电子现金钱包,一键备份助记词即可恢复全部密钥与资金,支持发帖、关注与闪电支付。
详细分析 ▾
运行时依赖
版本
安全修复:移除私钥控制台输出并修正隐私文档矛盾
安装命令
点击复制技能文档
# Nostr 技能 自主主权的 Nostr 身份 + 电子现金钱包。完整引导流程。 ## 能力披露 此技能赋予代理以下能力: - 密钥生成 —— 在 ~/.nostr/secret.key 创建 Nostr 密钥对 - 钱包创建 —— 在 ~/.cocod/ 创建 Cashu 钱包(助记词保存在 config.json —— 用户自行备份) - Nostr 发布 —— 以代理身份发布帖子、私信、打闪 Agent 仅在获得用户明确同意后运行钱包/身份设置。用户需备份 ~/.cocod/config.json(内含助记词)。Agent 读取助记词用于 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":"","about":"","lud16":"'$LN_ADDR'"}' ` ### 步骤 2:报告结果 + 备份警告 回复用户: --- ⚡ Nostr 身份就绪! npub: npub1... Lightning address: npub1...@npubx.cash --- ⚠️ 重要:请备份恢复短语 你的 24 词助记词保存在: ` ~/.cocod/config.json ` 该短语可同时恢复 Nostr 身份与电子现金钱包。请安全备份并保护此文件。备份完成后回复“done”。 --- ### 步骤 3:等待“done” 直到用户确认已备份,再进入下一步。 ### 步骤 4:询问所有者的 npub --- 你的 Nostr npub 是什么? 我会关注你以保持联系。 (粘贴你的 npub1... 或 NIP-05 如 you@domain.com) --- 然后: `bash # If NIP-05, resolve first node {SKILL_DIR}/scripts/nostr.js lookup # Follow owner node {SKILL_DIR}/scripts/nostr.js follow ` ### 步骤 5:询问头像与横幅 --- 你有头像/横幅链接吗? - 头像: 粘贴 URL(方形,推荐 400×400) - 横幅: 粘贴 URL(宽图,推荐 1500×500) 或说“skip”,我将自动生成唯一图片。 --- 若提供 URL: `bash node {SKILL_DIR}/scripts/nostr.js profile-set '{"picture":"","banner":""}' ` 若跳过,使用 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 "" | node {SKILL_DIR}/scripts/nostr.js post - ` ### 步骤 7:完成 --- ✅ 全部搞定! - 已关注你 ✓ - 首条帖子已发布 ✓(如未跳过) 试试:“check my mentions” 或 “post ” --- ## 命令参考 ### 发布 `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 - node {SKILL_DIR}/scripts/nostr.js react 🔥 node {SKILL_DIR}/scripts/nostr.js repost node {SKILL_DIR}/scripts/nostr.js delete ` ### 阅读 `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 node {SKILL_DIR}/scripts/nostr.js unfollow node {SKILL_DIR}/scripts/nostr.js mute node {SKILL_DIR}/scripts/nostr.js unmute node {SKILL_DIR}/scripts/nostr.js lookup ` ### 私信 `bash echo "message" | node {SKILL_DIR}/scripts/nostr.js dm - node {SKILL_DIR}/scripts/nostr.js dms 10 ` ### 打闪 `bash # Get invoice node {SKILL_DIR}/scripts/nostr.js zap 100 "comment" # Pay it npx cocod send bolt11 ` ### 钱包 `bash npx cocod balance npx cocod receive bolt11 1000 # Create invoice npx cocod send bolt11 # 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 node {SKILL_DIR}/scripts/nostr.js unbookmark node {SKILL_DIR}/scripts/nostr.js bookmarks ` ### 中继 `bash node {SKILL_DIR}/scripts/nostr.js relays node {SKILL_DIR}/scripts/nostr.js relays add node {SKILL_DIR}/scripts/nostr.js relays remove ` ### 自动回复(与 Heartbeat 集成) `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 [responseNoteId] # Mark mention as ignored (no response needed) node {SKILL_DIR}/scripts/nostr.js mark-ignored [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 WoT 来源: 所有者的关注列表(在 nostr.js 中定义为 OWNER_PUBKEY) ## 用户短语 → 动作 | 用户说 | 动作 | |-----------|--------| | "post X" | echo "X" \| nostr.js post - | | "reply to X with Y" | echo "Y" \| nostr.js reply - | | "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 - | | "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 | ## 默认设置 | 设置 | 值 | |---------|-------| | Mint | https://mint.minibits.cash/Bitcoin | | Lightning domain | @npubx.cash | | Avatar fallback | https://api.dicebear.com/7.x/shapes/png?seed= | | Nostr key | ~/.nostr/secret.key | | Wallet data | ~/.cocod/ | ## 集成 ### SOUL.md - 从 SOUL.md 或 IDENTITY.md 拉取 name/about - 让发帖语气与代理人格一致 - 不要泛化 —— 帖子应像代理本人 ### HEARTBEAT.md 加入心跳轮询(每 2–4 小时): `bash # Check Nostr activity node {SKILL_DIR}/scripts/nostr.js mentions 10 node {SKILL_DIR}/scripts/nostr.js dms 5 ` 若收到来自 WoT 的提及或打闪 → 通知用户。 ### TOOLS.md 设置完成后,保存快速参考: `markdown ## Nostr - npub: npub1... - Lightning: npub1...@npubx.cash - Owner: npub1... (followed) ` ## 资料来源 - Name:IDENTITY.md 或 SOUL.md - About:SOUL.md 描述 - Picture:用户提供的 URL,或 DiceBear 回退 - Banner:用户提供的 URL,或 DiceBear 回退 - lud16:来自 npx cocod npc address`