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

applesauce-common苹果酱常见

Agent Skill

applesauce-common 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

490

周安装

20

GitHub Stars

30

下载量

158
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:applesauce-common(苹果酱常见)
来源仓库:https://github.com/purrgrammer/grimoire
仓库路径:skills/applesauce-common
安装命令:
npx skills add https://github.com/purrgrammer/grimoire --skill applesauce-common
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/purrgrammer/grimoire --skill applesauce-common

简介

提供 applesauce v5 中社交/NIP 相关工具、事件蓝图和操作系统的使用知识。

  • 适用于 Nostr 应用中处理文章、高亮、线程、反应及类型化事件访问。
  • 结合 casting system 创建或修改事件,使用 blueprints 和 operations 实现业务逻辑。
  • 注意该包为 v5 新增,部分旧版 helpers 已迁移至此,需核对版本兼容性。
  • applesauce-common 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

applesauce-common Skill (v5)

This skill provides comprehensive knowledge for working with applesauce-common, a new package in applesauce v5 that contains social/NIP-specific utilities, the casting system, blueprints, and operations.

Note: applesauce-common was introduced in v5. Many helpers that were previously in applesauce-core/helpers have moved here.

When to Use This Skill

Use this skill when:

  • Working with article, highlight, threading, zap, or reaction helpers
  • Using the casting system for typed event access
  • Creating events with blueprints
  • Modifying events with operations
  • Working with NIP-specific social features

Package Structure

applesauce-common/
├── helpers/          # Social/NIP-specific helpers
│   ├── article.js    # NIP-23 article helpers
│   ├── highlight.js  # NIP-84 highlight helpers
│   ├── threading.js  # NIP-10 thread helpers
│   ├── comment.js    # NIP-22 comment helpers
│   ├── zap.js        # NIP-57 zap helpers
│   ├── reaction.js   # NIP-25 reaction helpers
│   ├── lists.js      # NIP-51 list helpers
│   └── ...
├── casts/            # Typed event classes
│   ├── Note.js
│   ├── User.js
│   ├── Profile.js
│   ├── Article.js
│   └── ...
├── blueprints/       # Event creation blueprints
└── operations/       # Event modification operations

Helpers (Migrated from applesauce-core)

Article Helpers (NIP-23)

import {
  getArticleTitle,
  getArticleSummary,
  getArticleImage,
  getArticlePublished
} from 'applesauce-common/helpers/article';

// All helpers cache internally - no useMemo needed
const title = getArticleTitle(event);
const summary = getArticleSummary(event);
const image = getArticleImage(event);
const publishedAt = getArticlePublished(event);

Highlight Helpers (NIP-84)

import {
  getHighlightText,
  getHighlightSourceUrl,
  getHighlightSourceEventPointer,
  getHighlightSourceAddressPointer,
  getHighlightContext,
  getHighlightComment
} from 'applesauce-common/helpers/highlight';

const text = getHighlightText(event);
const sourceUrl = getHighlightSourceUrl(event);
const eventPointer = getHighlightSourceEventPointer(event);
const addressPointer = getHighlightSourceAddressPointer(event);
const context = getHighlightContext(event);
const comment = getHighlightComment(event);

Threading Helpers (NIP-10)

import { getNip10References } from 'applesauce-common/helpers/threading';

// Parse NIP-10 thread structure
const refs = getNip10References(event);

if (refs.root) {
  console.log('Root event:', refs.root.e);
  console.log('Root address:', refs.root.a);
}

if (refs.reply) {
  console.log('Reply to:', refs.reply.e);
}

Comment Helpers (NIP-22)

import { getCommentReplyPointer } from 'applesauce-common/helpers/comment';

const pointer = getCommentReplyPointer(event);
if (pointer) {
  // Handle reply target
}

Zap Helpers (NIP-57)

import {
  getZapAmount,
  getZapSender,
  getZapRecipient,
  getZapComment
} from 'applesauce-common/helpers/zap';

const amount = getZapAmount(event);     // In millisats
const sender = getZapSender(event);     // Pubkey
const recipient = getZapRecipient(event);
const comment = getZapComment(event);

List Helpers (NIP-51)

import { getRelaysFromList } from 'applesauce-common/helpers/lists';

const relays = getRelaysFromList(event);

Casting System

The casting system transforms raw Nostr events into typed classes with both synchronous properties and reactive observables.

Basic Usage

import { castEvent, Note, User, Profile } from 'applesauce-common/casts';

// Cast an event to a typed class
const note = castEvent(event, Note, eventStore);

// Access synchronous properties
console.log(note.id);
console.log(note.createdAt);
console.log(note.isReply);

// Subscribe to reactive observables
note.author.profile$.subscribe(profile => {
  console.log('Author name:', profile?.name);
});

Available Casts

  • Note - Kind 1 short text notes
  • User - User with profile and social graph
  • Profile - Kind 0 profile metadata
  • Article - Kind 30023 long-form articles
  • Reaction - Kind 7 reactions
  • Zap - Kind 9735 zap receipts
  • Comment - NIP-22 comments
  • Share - Reposts/quotes
  • Bookmarks - NIP-51 bookmarks
  • Mutes - NIP-51 mute lists

With React

import { use$ } from 'applesauce-react/hooks';
import { castEvent, Note } from 'applesauce-common/casts';

function NoteComponent({ event }) {
  const note = castEvent(event, Note, eventStore);

  // Subscribe to author's profile
  const profile = use$(note.author.profile$);

  // Subscribe to replies
  const replies = use$(note.replies$);

  return (
    <div>
      <span>{profile?.name}</span>
      <p>{note.content}</p>
      <span>{replies?.length} replies</span>
    </div>
  );
}

Blueprints

Blueprints are factory functions that create Nostr events with automatic tag extraction and proper NIP compliance. They eliminate manual tag building and reduce boilerplate code significantly.

Key Benefits

  1. Automatic Tag Extraction: Blueprints automatically extract hashtags (#word), mentions (nostr:npub), and event quotes (nostr:note/nevent) from text content
  2. NIP Compliance: Each blueprint follows the correct NIP specifications for its event type
  3. Less Code: Replace 50-100 lines of manual tag building with 5-10 lines
  4. Type Safety: Full TypeScript support with proper types for all options
  5. Maintainable: Centralized event building logic that's easier to update

Using Blueprints

import { EventFactory } from 'applesauce-core/event-factory';
import { NoteBlueprint } from 'applesauce-common/blueprints';

const factory = new EventFactory();
factory.setSigner(signer);

// Create event from blueprint
const draft = await factory.create(NoteBlueprint, content, options);
const event = await factory.sign(draft);

NoteBlueprint (Kind 1)

Creates short text notes with automatic hashtag, mention, and quote extraction.

What it handles automatically:

  • Extracts #hashtags from content → t tags
  • Extracts nostr:npub... mentions → p tags
  • Extracts nostr:note... and nostr:nevent... quotes → q tags (NIP-18)
  • Adds custom emoji tags (NIP-30)
import { NoteBlueprint } from 'applesauce-common/blueprints';

// Simple note
const draft = await factory.create(
  NoteBlueprint,
  'Hello #nostr! Check out nostr:npub1abc...',
  {}
);

// With custom emojis
const draft = await factory.create(
  NoteBlueprint,
  'Hello :rocket:!',
  {
    emojis: [{ shortcode: 'rocket', url: 'https://example.com/rocket.png' }]
  }
);

// The blueprint automatically adds:
// - ["t", "nostr"] for #nostr
// - ["p", "decoded-pubkey"] for the npub mention
// - ["emoji", "rocket", "https://example.com/rocket.png"] for custom emoji

Options:

  • emojis?: Array<{shortcode: string; url: string}> - Custom emojis (NIP-30)
  • contentWarning?: boolean | string - Content warning tag

Before/After Example:

// ❌ BEFORE: Manual tag building (~70 lines)
const hashtags = content.match(/#(\w+)/g)?.map(tag => tag.slice(1)) || [];
const mentionRegex = /nostr:(npub1[a-z0-9]+)/g;
const mentions = [];
let match;
while ((match = mentionRegex.exec(content)) !== null) {
  try {
    const { data } = nip19.decode(match[1]);
    mentions.push(data);
  } catch (e) { /* ignore */ }
}
// ... more extraction logic ...
draft.tags = [
  ...hashtags.map(t => ['t', t]),
  ...mentions.map(p => ['p', p]),
  // ... more tags ...
];

// ✅ AFTER: Blueprint handles everything
const draft = await factory.create(NoteBlueprint, content, { emojis });

NoteReplyBlueprint (Kind 1 Reply)

Creates threaded note replies following NIP-10 conventions.

What it handles automatically:

  • Extracts root event from parent's tags (NIP-10)
  • Adds proper e tags with markers (root, reply)
  • Copies p tags from parent for notifications
  • Extracts hashtags, mentions, and quotes from content
  • Uses q tags for quotes instead of e tags (correct semantic)
import { NoteReplyBlueprint } from 'applesauce-common/blueprints';

// Reply to a note
const parentEvent = await eventStore.event(parentId).toPromise();

const draft = await factory.create(
  NoteReplyBlueprint,
  parentEvent,
  'Great point! #bitcoin',
  {
    emojis: [{ shortcode: 'fire', url: 'https://example.com/fire.png' }]
  }
);

// The blueprint automatically:
// 1. Finds root from parent's tags (if parent is also a reply)
// 2. Adds ["e", rootId, relay, "root"]
// 3. Adds ["e", parentId, relay, "reply"]
// 4. Copies all ["p", ...] tags from parent
// 5. Extracts #bitcoin → ["t", "bitcoin"]
// 6. Adds emoji tag

Options:

  • emojis?: Array<{shortcode: string; url: string}> - Custom emojis
  • contentWarning?: boolean | string - Content warning

Before/After Example:

// ❌ BEFORE: Manual NIP-10 threading (~95 lines)
const parentRefs = getNip10References(parentEvent);
const rootId = parentRefs.root?.e || parentEvent.id;
const rootRelay = parentRefs.root?.relay || '';

draft.tags = [
  ['e', rootId, rootRelay, 'root'],
  ['e', parentEvent.id, '', 'reply'],
];

// Copy p-tags from parent
const parentPTags = parentEvent.tags.filter(t => t[0] === 'p');
draft.tags.push(...parentPTags);
if (!parentPTags.some(t => t[1] === parentEvent.pubkey)) {
  draft.tags.push(['p', parentEvent.pubkey]);
}
// ... hashtag extraction ...
// ... mention extraction ...

// ✅ AFTER: Blueprint handles NIP-10 threading
const draft = await factory.create(
  NoteReplyBlueprint,
  parentEvent,
  content,
  { emojis }
);

ReactionBlueprint (Kind 7)

Creates reactions to events (likes, custom emoji reactions).

What it handles automatically:

  • Adds e tag pointing to reacted event
  • Adds k tag for event kind
  • Adds p tag for event author
  • Handles custom emoji reactions (:shortcode: format)
  • Supports both string emoji and Emoji objects
import { ReactionBlueprint } from 'applesauce-common/blueprints';

// Simple like (+ emoji)
const draft = await factory.create(ReactionBlueprint, messageEvent, '+');

// Custom emoji reaction
const draft = await factory.create(
  ReactionBlueprint,
  messageEvent,
  {
    shortcode: 'rocket',
    url: 'https://example.com/rocket.png'
  }
);

// String emoji
const draft = await factory.create(ReactionBlueprint, messageEvent, '🚀');

// The blueprint automatically adds:
// - ["e", messageEvent.id]
// - ["k", messageEvent.kind.toString()]
// - ["p", messageEvent.pubkey]
// For custom emoji: ["emoji", "rocket", "url"]

Options:

  • Second parameter: emoji?: string | {shortcode: string; url: string}

Before/After Example:

// ❌ BEFORE: Manual reaction building (~15 lines per adapter)
draft.kind = 7;
draft.content = typeof emoji === 'string' ? emoji : `:${emoji.shortcode}:`;
draft.tags = [
  ['e', messageEvent.id],
  ['k', messageEvent.kind.toString()],
  ['p', messageEvent.pubkey],
];
if (typeof emoji === 'object') {
  draft.tags.push(['emoji', emoji.shortcode, emoji.url]);
}

// ✅ AFTER: Blueprint handles reactions
const draft = await factory.create(ReactionBlueprint, messageEvent, emoji);

GroupMessageBlueprint (Kind 9 - NIP-29)

Creates NIP-29 group chat messages.

What it handles automatically:

  • Adds h tag with group ID
  • Extracts hashtags, mentions, and quotes from content
  • Adds custom emoji tags
  • Handles message threading with previous field
import { GroupMessageBlueprint } from 'applesauce-common/blueprints';

// Send message to NIP-29 group
const draft = await factory.create(
  GroupMessageBlueprint,
  { id: groupId, relay: relayUrl },
  'Hello group! #welcome',
  {
    previous: [], // Array of previous message events for threading
    emojis: [{ shortcode: 'wave', url: 'https://example.com/wave.png' }]
  }
);

// The blueprint automatically adds:
// - ["h", groupId]
// - ["t", "welcome"] for #welcome hashtag
// - ["emoji", "wave", "url"] for custom emoji

Options:

  • previous?: NostrEvent[] - Previous messages for threading (required, use [] if no threading)
  • emojis?: Array<{shortcode: string; url: string}> - Custom emojis

Note: The previous field is required by the type, but can be an empty array if you don't need threading.

DeleteBlueprint (Kind 5 - NIP-09)

Creates event deletion requests.

What it handles automatically:

  • Adds e tags for each event to delete
  • Sets proper kind and content format
  • Adds optional reason in content
import { DeleteBlueprint } from 'applesauce-common/blueprints';

// Delete single event
const draft = await factory.create(
  DeleteBlueprint,
  [eventToDelete],
  'Accidental post'
);

// Delete multiple events
const draft = await factory.create(
  DeleteBlueprint,
  [event1, event2, event3],
  'Cleaning up old posts'
);

// Without reason
const draft = await factory.create(DeleteBlueprint, [event], '');

// The blueprint automatically:
// - Sets kind to 5
// - Adds ["e", eventId] for each event
// - Sets content to reason (or empty)

Parameters:

  • events: (string | NostrEvent)[] - Events to delete (IDs or full events)
  • reason?: string - Optional deletion reason

Adding Custom Tags

Blueprints handle common tags automatically, but you can add custom tags afterward:

// Create with blueprint
const draft = await factory.create(NoteBlueprint, content, { emojis });

// Add custom tags not handled by blueprint
draft.tags.push(['client', 'grimoire', '31990:...']);
draft.tags.push(['a', `${kind}:${pubkey}:${identifier}`]);

// Add NIP-92 imeta tags for blob attachments
for (const blob of blobAttachments) {
  draft.tags.push(['imeta', `url ${blob.url}`, `x ${blob.sha256}`, ...]);
}

// Sign the modified draft
const event = await factory.sign(draft);

Protocol-Specific Tag Additions

Some protocols require additional tags beyond what blueprints provide:

// NIP-29: Add q-tag for replies (not in blueprint yet)
const draft = await factory.create(GroupMessageBlueprint, group, content, options);
if (replyToId) {
  draft.tags.push(['q', replyToId]);
}

// NIP-53: Add a-tag for live activity context
const draft = await factory.create(ReactionBlueprint, messageEvent, emoji);
draft.tags.push(['a', liveActivityATag, relay]);

Available Blueprints

All blueprints from applesauce-common/blueprints:

  • NoteBlueprint - Kind 1 short text notes
  • NoteReplyBlueprint - Kind 1 threaded replies (NIP-10)
  • ReactionBlueprint - Kind 7 reactions (NIP-25)
  • GroupMessageBlueprint - Kind 9 group messages (NIP-29)
  • DeleteBlueprint - Kind 5 deletion requests (NIP-09)
  • MetadataBlueprint - Kind 0 profile metadata
  • ContactsBlueprint - Kind 3 contact lists
  • ArticleBlueprint - Kind 30023 long-form articles (NIP-23)
  • HighlightBlueprint - Kind 9802 highlights (NIP-84)
  • ZapRequestBlueprint - Kind 9734 zap requests (NIP-57)
  • And more - check node_modules/applesauce-common/dist/blueprints/

Best Practices

  1. Always use blueprints when creating standard event types - they handle NIPs correctly
  2. Add custom tags after blueprint creation for app-specific metadata
  3. Don't extract tags manually - let blueprints handle hashtags, mentions, quotes
  4. Use proper emoji format - blueprints expect {shortcode, url} objects
  5. Check blueprint source - when in doubt, read the blueprint code for exact behavior

Operations

Operations modify existing events.

import { addTag, removeTag } from 'applesauce-common/operations';

// Add a tag to an event
const modified = addTag(event, ['t', 'bitcoin']);

// Remove a tag
const updated = removeTag(event, 'client');

Migration from v4

Helper Import Changes

// ❌ Old (v4)
import { getArticleTitle } from 'applesauce-core/helpers';
import { getNip10References } from 'applesauce-core/helpers/threading';
import { getZapAmount } from 'applesauce-core/helpers/zap';

// ✅ New (v5)
import { getArticleTitle } from 'applesauce-common/helpers/article';
import { getNip10References } from 'applesauce-common/helpers/threading';
import { getZapAmount } from 'applesauce-common/helpers/zap';

Helpers that stayed in applesauce-core

These protocol-level helpers remain in applesauce-core/helpers:

  • getTagValue, hasNameValueTag
  • getProfileContent
  • parseCoordinate, getEventPointerFromETag, getAddressPointerFromATag
  • isFilterEqual, matchFilter, mergeFilters
  • getSeenRelays, mergeRelaySets
  • getInboxes, getOutboxes
  • normalizeURL

Best Practices

Helper Caching

All helpers in applesauce-common cache internally using symbols:

// ❌ Don't memoize helper calls
const title = useMemo(() => getArticleTitle(event), [event]);

// ✅ Call helpers directly
const title = getArticleTitle(event);

Casting vs Helpers

Use helpers when you need specific fields:

const title = getArticleTitle(event);
const amount = getZapAmount(event);

Use casts when you need reactive data or multiple related properties:

const note = castEvent(event, Note, eventStore);
const profile$ = note.author.profile$;
const replies$ = note.replies$;

Related Skills

  • applesauce-core - Protocol-level helpers and event store
  • applesauce-signers - Event signing abstractions
  • nostr - Nostr protocol fundamentals

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.55%
按下载量换算56

Claude

29.95%
按下载量换算47

Cursor

22.1%
按下载量换算35

Gemini CLI

9.11%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills