Files
knowledge-base/scripts/kb-date-todos.py

48 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Append (YYYY-MM-DD) to undated '- [ ]' lines. One-off agent-loop fix."""
import re
from pathlib import Path
VAULT = Path(__file__).resolve().parent.parent
TODAY = "2026-04-18"
TARGETS = {
"projects/niikn/changelog.md": TODAY,
"projects/niikn/NIIKN-ChangeLog.md": TODAY,
"projects/niikn/matrix.md": TODAY,
"projects/dttb/nextcloud-talk-bot/README.md": TODAY,
"daily/2026-04-19.md": "2026-04-19",
"claude-memory/mas-niikn.md": TODAY,
"decisions/2026-04-16-unifi-migration-peredelki.md": "2026-04-16",
"projects/niikn/README.md": TODAY,
"decisions/2026-04-14-openclaw-claude-code-pipeline.md": "2026-04-14",
"projects/dttb/mailcow-dttb.md": TODAY,
"daily/2026-04-17.md": "2026-04-17",
"templates/daily-note.md": TODAY,
}
DATE_RE = re.compile(r"\d{4}-\d{2}-\d{2}")
TODO_RE = re.compile(r"^(\s*-\s*\[\s*\]\s*.*?)\s*$")
for rel, date in TARGETS.items():
p = VAULT / rel
if not p.is_file():
print(f"MISSING: {rel}")
continue
lines = p.read_text().splitlines()
fixed = 0
new_lines = []
for line in lines:
m = re.match(r"^\s*-\s*\[\s*\]\s+", line)
if m and not DATE_RE.search(line):
stripped = line.rstrip()
new_lines.append(f"{stripped} ({date})")
fixed += 1
elif re.match(r"^\s*-\s*\[\s*\]\s*$", line):
new_lines.append(f"{line.rstrip()} ({date})")
fixed += 1
else:
new_lines.append(line)
p.write_text("\n".join(new_lines) + ("\n" if lines and not lines[-1] == "" else ""))
print(f"{rel}: {fixed} fixed")