refactor(lint): Improve link parsing and date command compatibility

This commit is contained in:
Matteo Cherubini 2026-05-09 17:03:16 +02:00
parent 3a2d69619c
commit b55084acc4

View file

@ -6,6 +6,9 @@
# Valid values for the 'type' frontmatter field.
# Must stay in sync with the type list in templates/agents-genome.md.
# Note: 'index' and 'log' are wiki-level singleton files (wiki/index.md, wiki/log.md).
# 'conflict' has no dedicated scaffold directory — it is a cross-cutting type
# that can live under any wiki/ subdirectory.
VALID_TYPES=("source" "entity" "concept" "query" "conflict" "private" "index" "log")
# ---------------------------------------------------------------------------
@ -121,7 +124,7 @@ check_knowledge_decay() {
# Parse date — handle both GNU date (Linux) and BSD date (macOS)
local updated_ts
if date --version &>/dev/null 2>&1; then
if date --version >/dev/null 2>&1; then
# GNU date
updated_ts=$(date -d "$last_updated" +%s 2>/dev/null)
else
@ -161,7 +164,7 @@ check_broken_links() {
# Extract link targets, stripping aliases: [[Link|Alias]] -> Link
local links
links=$(grep -oP '\[\[\K[^\]]+' "$file" 2>/dev/null | cut -d'|' -f1)
links=$(grep -oE '\[\[[^\]]+' "$file" 2>/dev/null | sed 's/^\[\[//' | cut -d'|' -f1)
for link in $links; do
local target="$link"