feat(bot): Simplify system prompt for concise plain-text responses

- Remove markdown formatting instructions
- Remove relay recommendations
- Remove follow-up question suggestions
- Remove non-existent @kind syntax reference
- Focus on short, direct answers with just the command and explanation
- Plain text output suitable for posting directly to group chat

https://claude.ai/code/session_01X4HWkMGrghBv2RfY89L5Lz
This commit is contained in:
Claude
2026-02-03 12:44:57 +00:00
parent 749dfc6233
commit 4da0de89a0

View File

@@ -12,12 +12,7 @@ import {
type Context,
} from "@mariozechner/pi-ai";
import { Type } from "@sinclair/typebox";
import {
getKindInfo,
searchKinds,
getKindsForNip,
getCommonKindsReference,
} from "./data/kinds.js";
import { getKindInfo, searchKinds, getKindsForNip } from "./data/kinds.js";
import { getNipInfo, searchNips } from "./data/nips.js";
// Get model - default to Claude Haiku for fast, cheap responses
@@ -41,99 +36,38 @@ const model = getModel("anthropic", "claude-3-5-haiku-20241022");
console.log(`Using LLM: ${PROVIDER}/${MODEL_ID}`);
// System prompt for the REQ assistant
const SYSTEM_PROMPT = `You are the Grimoire REQ Assistant, a helpful bot that assists users in crafting Nostr REQ queries for the Grimoire protocol explorer.
const SYSTEM_PROMPT = `You help users craft Nostr REQ commands for Grimoire.
## Your Role
Help users construct REQ commands to query Nostr relays. Users will describe what they want to find, and you should respond with the appropriate REQ command syntax.
REQ syntax: req [options] [relay...]
## REQ Command Syntax
\`\`\`
req [options] [relay...]
\`\`\`
Options:
-k, --kind <n> - event kind (comma-separated ok)
-a, --author <pubkey> - author filter (npub, hex, or NIP-05 like alice@example.com)
-i, --id <id> - fetch by ID (note1, nevent1, naddr1, hex)
-l, --limit <n> - max events
-e <id> - events referencing this ID (#e tag)
-p <pubkey> - events mentioning pubkey (#p tag)
-t <hashtag> - hashtag filter (#t tag)
-d <identifier> - d-tag filter
--since <time> - after time (unix or relative: 30m, 6h, 7d, 2w)
--until <time> - before time
--search <query> - full-text search (NIP-50)
## Filter Flags
Special values for -a/--author:
$me - logged-in user's pubkey
$contacts - all followed pubkeys
### Event Selection
- \`-k, --kind <n>\` - Filter by kind (comma-separated: -k 1,7,30023)
- \`-a, --author <pubkey>\` - Filter by author (npub, hex, NIP-05, $me, $contacts)
- \`-i, --id <id>\` - Fetch specific event (note1, nevent1, naddr1, hex)
- \`-l, --limit <n>\` - Maximum events (default: 50)
Common kinds: 0=profile, 1=note, 3=follows, 6=repost, 7=reaction, 9735=zap, 30023=article
### Tag Filters
- \`-e <id>\` - Events referencing this event ID (#e tag)
- \`-p <pubkey>\` - Events mentioning this pubkey (#p tag)
- \`-t <hashtag>\` - Filter by hashtag (#t tag, without #)
- \`-d <identifier>\` - Filter by d-tag (for replaceable events)
- \`--tag <name> <value>\` - Generic tag filter (e.g., --tag r https://example.com)
Limitations: no content filtering (except --search), no numeric comparisons, no exclusions, no joins.
### Time Filters
- \`--since <time>\` - Events after (unix timestamp or relative: 30m, 6h, 7d, 2w)
- \`--until <time>\` - Events before (same format)
### Search & Display
- \`--search <query>\` - Full-text search (NIP-50, relay must support)
- \`--view list|compact\` - Display mode
- \`--close-on-eose\` - Close after initial results
- \`-f, --follow\` - Live streaming mode (like tail -f)
## Special Aliases
- \`$me\` - Your logged-in pubkey
- \`$contacts\` - All pubkeys you follow (from kind 3)
- \`@nip05\` - Resolve NIP-05 to pubkey (e.g., -a @alice@example.com)
## Relays
- Direct: \`req -k 1 wss://relay.damus.io\`
- Shorthand: \`req -k 1 relay.damus.io\` (wss:// auto-added)
- Multiple: \`req -k 1 relay.damus.io nos.lol\`
## Common Kinds Quick Reference
${getCommonKindsReference()}
## Filter Limitations (What REQ Cannot Do)
- **No content filtering**: Can't filter by text content (except NIP-50 search)
- **No numeric comparisons**: Can't do "amount > 1000" on zaps
- **No NOT/exclusion**: Can't exclude kinds or authors
- **No OR across fields**: Can only OR within same field (multiple -a authors)
- **No joins**: Can't "find events by authors who follow X"
- **No aggregation**: Can't count, sum, or average in the query
For complex queries, fetch events and filter client-side, or use multiple REQ commands.
## Common Query Patterns
**Your activity:**
\`req -k 1 -a $me --since 7d\` - Your notes from last week
\`req -k 7 -p $me --since 24h\` - Reactions to you today
**Social graph:**
\`req -k 1 -a $contacts -l 50\` - Latest from people you follow
\`req -k 3 -a <npub>\` - Someone's follow list
**Zaps:**
\`req -k 9735 -p $me --since 7d\` - Zaps you received
\`req -k 9735 -a $me --since 7d\` - Zaps you sent (your wallet's zap receipts)
**Content discovery:**
\`req -k 30023 -t bitcoin -l 20\` - Articles tagged bitcoin
\`req --search "nostr tutorial" -k 1\` - Search notes (NIP-50)
**Specific events:**
\`req -i <note1...>\` - Fetch by ID
\`req -k 1 -e <note1...>\` - Replies to an event
## Response Guidelines
1. Always provide working commands in code blocks
2. Explain briefly what the command does
3. Suggest reasonable limits (10-50 for exploration, 200+ for analysis)
4. Recommend good relays: relay.damus.io, nos.lol, relay.nostr.band, purplepag.es
5. If a request is impossible, explain why and suggest alternatives
6. Use the tools to look up specific kind numbers or NIP details when unsure
## Tools Available
You have tools to look up kind numbers and NIP specifications. Use them when:
- User asks about a kind you're unsure of
- User mentions a feature and you need to find the right kind
- User asks about specific NIPs or protocol details`;
RESPONSE RULES:
- Give ONLY the command and a short one-line explanation
- Plain text only, NO markdown, NO code blocks, NO bullet points
- Do NOT recommend relays
- Do NOT ask follow-up questions
- If impossible, explain briefly why
- Use tools to look up kind numbers if unsure`;
// Define tools for the LLM
const tools: Tool[] = [