Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions hooks/scripts/session-orient.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,25 @@ fi

# Methodology staleness check (Rule Zero)
if [ -d ops/methodology ] && [ -f ops/config.yaml ]; then
CONFIG_MTIME=$(stat -f %m ops/config.yaml 2>/dev/null || stat -c %Y ops/config.yaml 2>/dev/null || echo 0)
# Detect platform for stat syntax: Linux uses -c %Y, macOS uses -f %m.
# Must try Linux first — on Linux, stat -f means "filesystem stats" and
# succeeds with wrong output instead of failing, breaking the || fallback.
if stat -c %Y ops/config.yaml &>/dev/null 2>&1; then
_STAT_FMT() { stat -c %Y "$1" 2>/dev/null || echo 0; }
elif stat -f %m ops/config.yaml &>/dev/null 2>&1; then
_STAT_FMT() { stat -f %m "$1" 2>/dev/null || echo 0; }
else
_STAT_FMT() { echo 0; }
fi

CONFIG_MTIME=$(_STAT_FMT ops/config.yaml)
NEWEST_METH=$(ls -t ops/methodology/*.md 2>/dev/null | head -1)
if [ -n "$NEWEST_METH" ]; then
METH_MTIME=$(stat -f %m "$NEWEST_METH" 2>/dev/null || stat -c %Y "$NEWEST_METH" 2>/dev/null || echo 0)
METH_MTIME=$(_STAT_FMT "$NEWEST_METH")
DAYS_STALE=$(( (CONFIG_MTIME - METH_MTIME) / 86400 ))
if [ "$DAYS_STALE" -ge 30 ]; then
echo "CONDITION: Methodology notes are ${DAYS_STALE}+ days behind config changes. Consider /rethink drift."
fi
fi
unset -f _STAT_FMT
fi
5 changes: 3 additions & 2 deletions skill-sources/rethink/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ Read:

```bash
# Compare config.yaml modification time vs newest methodology note
CONFIG_MTIME=$(stat -f %m ops/config.yaml 2>/dev/null || stat -c %Y ops/config.yaml 2>/dev/null || echo 0)
# Linux stat -f means filesystem stats (not file), so try -c first
CONFIG_MTIME=$(stat -c %Y ops/config.yaml 2>/dev/null || stat -f %m ops/config.yaml 2>/dev/null || echo 0)
NEWEST_METH=$(ls -t ops/methodology/*.md 2>/dev/null | head -1)
METH_MTIME=$(stat -f %m "$NEWEST_METH" 2>/dev/null || stat -c %Y "$NEWEST_METH" 2>/dev/null || echo 0)
METH_MTIME=$(stat -c %Y "$NEWEST_METH" 2>/dev/null || stat -f %m "$NEWEST_METH" 2>/dev/null || echo 0)
```

If `CONFIG_MTIME > METH_MTIME`: config has changed since methodology was last updated. Flag as staleness drift.
Expand Down
3 changes: 2 additions & 1 deletion skills/health/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ for f in {vocabulary.notes}/*.md; do
basename=$(basename "$f" .md)

# Last modified (days ago)
mod_days=$(( ($(date +%s) - $(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null)) / 86400 ))
# Linux stat -f means filesystem stats (not file), so try -c first
mod_days=$(( ($(date +%s) - $(stat -c %Y "$f" 2>/dev/null || stat -f %m "$f" 2>/dev/null || echo 0)) / 86400 ))

# Incoming link count
incoming=$(rg -l "\[\[$basename\]\]" --glob '*.md' | grep -v "$f" | wc -l | tr -d ' ')
Expand Down