nostr-nak
General purpose skill for using the Nostr Army Knife (nak) CLI tool.
Critical Technical Note (PTY Requirement)
nak hangs in non-interactive environments due to stdout buffering.
Always wrap
nak commands in
script to force a pseudo-TTY:
INLINECODE3
Relay Logic
By default, use discovery relays if no relay is specified:
- - INLINECODE4
- INLINECODE5
- INLINECODE6
If the user specifies a relay, override these defaults.
Identity Handling
- - Querying: Use
npub... or hex pubkey with the -a flag. - Posting: Use
nsec... or hex private key with the --sec flag.
Usage Examples
Fetch last 5 notes:
INLINECODE11
nostr-nak
使用Nostr瑞士军刀(nak)CLI工具的多功能技能。
关键技术说明(PTY要求)
由于标准输出缓冲问题,nak在非交互式环境中会挂起。
务必使用script包装nak命令以强制使用伪终端:
script -q -c nak req ... /dev/null | cat
中继逻辑
默认情况下,若未指定中继,则使用发现中继:
- - wss://relay.damus.io
- wss://relay.primal.net
- wss://relay.nostr.band
如果用户指定了中继,则覆盖这些默认设置。
身份处理
- - 查询:使用npub...或十六进制公钥,配合-a标志。
- 发布:使用nsec...或十六进制私钥,配合--sec标志。
使用示例
获取最近5条笔记:
script -q -c nak req -k 1 -a
-l 5 /dev/null | cat