kb-rss-cleanup
Safely prune generated RSS watcher raw cache after weekly digest retention, without touching manual raw ingests or the RSS seen ledger.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safely prune generated RSS watcher raw cache after weekly digest retention, without touching manual raw ingests or the RSS seen ledger.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Poll trusted Multiple Sclerosis RSS feeds, score credibility, save raw items, filter low-quality material, and promote high-value items into citation-grounded KB processing.
Save a URL, file path, pasted text, DOI, or PMID into the knowledgebase at $KB_ROOT/raw/manual/YYYY/MM/DD/. Enriches via the relevant MCP (pubmed/crossref) when input is a DOI or PMID. NON-DESTRUCTIVE — write-only into raw/, never into pages/.
Append a single timestamped bullet to today's $KB_ROOT/journals/YYYY/MM/YYYY_MM_DD.md describing what the agent just did. Logseq-compatible and date-partitioned. Call this at the end of every meaningful action (page write, ingest, query answered).
Self-heal the MS knowledgebase layout after RSS watch or weekly digest. Migrates legacy flat files into the V2 date/type structure, refreshes Start Here and Index pages, checks links/frontmatter, and journals the maintenance summary.
Answer a research question by searching the kb first, then PubMed → CrossRef → SearXNG, writing a citation-grounded content page under $KB_ROOT/content/<type>/YYYY/MM/. Every claim cites a DOI/PMID/URL or is dropped. This is the heart of the agent.
Resolve any check, save, attack, or world-roll using the dice-roller MCP — never compute dice results from LLM memory.
| name | kb-rss-cleanup |
| description | Safely prune generated RSS watcher raw cache after weekly digest retention, without touching manual raw ingests or the RSS seen ledger. |
| version | 0.1.0 |
| author | dobry-ops |
| license | MIT |
| metadata | {"hermes":{"tags":["kb","rss","cleanup","retention","ms-research"],"category":"ms-knowledgebase","related_skills":["kb-rss-watch","kb-journal"]}} |
Safely delete old generated RSS watcher raw cache. This skill must be boring, conservative, and auditable.
rss-raw-cleanup every Monday at 10:00 Europe/Sofia.$KB_ROOT/raw/rss/YYYY/MM/DD/.$KB_ROOT/raw/rss/YYYY_MM_DD/ may also be cleaned with the same date/retention safeguards until the KB is fully migrated.$KB_ROOT/raw/ outside raw/rss/$KB_ROOT/raw/rss/seen_urls.txtraw/rss/Use Python stdlib with the same guards as this pattern. The implementation must
handle both V2 raw/rss/YYYY/MM/DD/ leaf directories and legacy
raw/rss/YYYY_MM_DD/ directories during migration. Do not use broad rm -rf
globs.
python3 - <<'PY'
import datetime as dt
import re
import shutil
from pathlib import Path
from zoneinfo import ZoneInfo
kb = Path(__import__('os').environ['KB_ROOT']).resolve()
rss = (kb / 'raw' / 'rss').resolve()
assert str(rss).startswith(str(kb / 'raw')), f"refusing unsafe rss path: {rss}"
now = dt.datetime.now(ZoneInfo('Europe/Sofia'))
today = now.date()
cutoff = today - dt.timedelta(days=14)
pattern = re.compile(r'^\d{4}_\d{2}_\d{2}$')
deleted = []
kept = []
skipped = []
bytes_deleted = 0
if not rss.exists():
rss.mkdir(parents=True, exist_ok=True)
for child in sorted(rss.iterdir()):
if child.name == 'seen_urls.txt':
skipped.append((child.name, 'seen ledger'))
continue
if not child.is_dir():
skipped.append((child.name, 'not a directory'))
continue
if not pattern.match(child.name):
skipped.append((child.name, 'not YYYY_MM_DD'))
continue
try:
d = dt.datetime.strptime(child.name, '%Y_%m_%d').date()
except ValueError:
skipped.append((child.name, 'invalid date'))
continue
if d >= cutoff:
kept.append(child.name)
continue
size = sum(p.stat().st_size for p in child.rglob('*') if p.is_file())
shutil.rmtree(child)
deleted.append(child.name)
bytes_deleted += size
report_dir = kb / 'content' / 'queries' / now.strftime('%Y') / now.strftime('%m')
report_dir.mkdir(parents=True, exist_ok=True)
stamp = now.strftime('%Y_%m_%d_%H%M')
report = report_dir / f'rss_raw_cleanup_{stamp}.md'
report.write_text(
'---\n'
'type: query\n'
'source: rss-raw-cleanup\n'
f'generated: {now.strftime("%Y-%m-%d %H:%M Europe/Sofia")}\n'
f'retention_days: 14\n'
f'deleted_dirs: {len(deleted)}\n'
f'bytes_deleted: {bytes_deleted}\n'
'---\n\n'
f'# RSS raw cleanup {now.strftime("%Y-%m-%d %H:%M")}\n\n'
f'Cutoff: delete generated `$KB_ROOT/raw/rss/YYYY/MM/DD/` directories older than {cutoff.isoformat()}. Legacy `$KB_ROOT/raw/rss/YYYY_MM_DD/` directories may also be cleaned during migration.\n\n'
'## Deleted\n'
+ ''.join(f'- `{name}`\n' for name in deleted) + ('' if deleted else '- none\n')
+ '\n## Kept within retention\n'
+ ''.join(f'- `{name}`\n' for name in kept) + ('' if kept else '- none\n')
+ '\n## Skipped / protected\n'
+ ''.join(f'- `{name}` — {why}\n' for name, why in skipped) + ('' if skipped else '- none\n')
)
print(f'RSS cleanup report: {report}')
print(f'deleted_dirs={len(deleted)} bytes_deleted={bytes_deleted}')
PY
Call kb-journal with:
event: rss-cleanup deleted=<N>, bytes=<N>
Reference the cleanup report in the journal when possible:
Refs: [[rss_raw_cleanup_YYYY_MM_DD_HHMM]]
$KB_ROOT is missing or unsafe, stop and report the error.seen_urls.txt; it prevents duplicate feed processing.raw/ top-level files.$KB_ROOT/raw/rss/YYYY/MM/DD/; migrate legacy flat date directories with kb-maintain rather than creating new ones.