Files
kb/scripts/inbox.sh
T

61 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# KB Inbox — list all raw files with status: inbox
# Usage: ./scripts/inbox.sh [--count] [--recent N]
KB_DIR="$(cd "$(dirname "$0")/.." && pwd)"
COUNT_ONLY=false
RECENT=0
for arg in "$@"; do
case $arg in
--count) COUNT_ONLY=true ;;
--recent) RECENT=1 ;;
esac
done
cd "$KB_DIR"
if $COUNT_ONLY; then
count=$(rg -l "status: inbox" raw/ 2>/dev/null | wc -l)
echo "📥 Inbox: $count items pending"
exit 0
fi
echo "📥 KB Inbox — pending review"
echo "============================"
echo ""
if [ "$RECENT" -gt 0 ]; then
# Show most recent first
items=$(rg -l "status: inbox" raw/ 2>/dev/null | sort -r | head -"$RECENT")
else
items=$(rg -l "status: inbox" raw/ 2>/dev/null | sort -r)
fi
count=0
for f in $items; do
title=$(grep "^title:" "$f" 2>/dev/null | head -1 | sed 's/title: *"//;s/"$//')
url=$(grep "^source_url:" "$f" 2>/dev/null | head -1 | sed 's/source_url: *"//;s/"$//')
ingested=$(grep "^ingested:" "$f" 2>/dev/null | head -1 | sed 's/ingested: *//')
if [ -z "$title" ]; then
title=$(basename "$f" .md | sed 's/^[0-9-]*//' | tr '-' ' ')
fi
echo "[$ingested] 📄 ${title:0:80}"
if [ -n "$url" ]; then
echo " 🔗 ${url:0:100}"
fi
echo " 📁 $f"
echo ""
count=$((count + 1))
done
if [ "$count" -eq 0 ]; then
echo "✅ No inbox items — all caught up!"
else
echo "---"
echo "Total: $count inbox items"
fi