Files
My-Brain-Is-Full-Crew/hooks/validate-frontmatter.sh
lh f66f4f6566 Add Hey CLI as alternative email backend for Postman (#14)
* Add Hey CLI support as alternative email backend

The Postman agent now supports two email backends:
- Hey (hey CLI) for Hey.com accounts with pre-sorted mailboxes
- GWS (gws CLI) for Gmail/Google Workspace accounts

Hey's mailbox model (Imbox, Feed, Paper Trail, Reply Later,
Set Aside, Bubble Up) is mapped to triage behaviours so the
agent leverages Hey's existing sorting. Calendar operations
remain on GWS.

All MCP function references replaced with CLI equivalents.
No user-specific details in the agent file.

* Update agents in postman.md by removing two roles

Removed descriptions for Food Coach and Wellness Guide agents from the postman documentation.

* Add Hey CLI as email backend across all docs, skills, and references

- Resolve all merge conflicts in postman.md keeping GWS + MCP + Hey
- Apply all 7 review comments from PR #14 (complete mailbox list,
  concrete email_backend setting, consistent template placeholders,
  Hey ID clarification, productivity features disclaimer, deadline
  body scanning, remove user-specific agent references)
- Add Hey CLI alongside GWS/MCP in: README, CLAUDE.md, TERMS_OF_USE,
  DISCLAIMERS, getting-started, gws-setup-guide (renamed sections),
  agents-registry, agents.md, onboarding skill, launchme.sh
- Update all 4 Postman-related skills (email-triage, deadline-radar,
  meeting-prep, weekly-agenda) with Hey CLI commands and backend
  detection
- Expand security section to cover Hey CLI injection vectors
- Keep MCP as read-only fallback for all backends

* Address Copilot review: fix typos, injection rules, platform compat, install hooks

- Fix hey imbox --json typo → hey box imbox --json
- Fix after:{{yesterday}} → newer_than:2d for consistent 48h scan
- Reconcile shell injection rules with hey reply/compose -m (user-approved
  text only, with safe quoting guidance)
- Separate email write ops (GWS/Hey) from calendar write ops (GWS only)
  in TERMS_OF_USE and DISCLAIMERS
- Replace grep -P with POSIX-compatible tab detection in validate-frontmatter
- Add hooks/ and settings.json installation to launchme.sh and updateme.sh
  so .claude/hooks/ paths in settings.json resolve correctly

---------

Co-authored-by: gnekt <dima9610@gmail.com>
2026-03-27 15:51:06 +01:00

65 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# =============================================================================
# Hook: Validate Frontmatter (PostToolUse on Write)
# =============================================================================
# After writing a .md file to the vault, checks that YAML frontmatter is
# properly formed. Obsidian relies on frontmatter for metadata, Dataview
# queries, tags, and search. Broken frontmatter silently breaks all of this.
#
# Checks:
# 1. If the file starts with ---, there must be a closing ---
# 2. No tabs in frontmatter (YAML uses spaces only)
# 3. Colons in values must be quoted
#
# Exit codes:
# 0 = all good
# 1 = warning (issue found, but operation is not blocked)
# =============================================================================
INPUT=$(cat)
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // ""' 2>/dev/null)
# Skip if we can't extract a path
[[ -z "$FILE" ]] && exit 0
# Only check .md files
[[ "$FILE" == *.md ]] || exit 0
# Skip system files (agents, skills, references)
[[ "$FILE" == *".claude/"* ]] && exit 0
# Skip if file doesn't exist (deleted or moved)
[[ -f "$FILE" ]] || exit 0
# ── Check 1: frontmatter delimiters ─────────────────────────────────────────
FIRST_LINE=$(head -1 "$FILE")
if [[ "$FIRST_LINE" == "---" ]]; then
# Count opening and closing delimiters (lines that are exactly ---)
DELIMITER_COUNT=$(grep -c "^---$" "$FILE" 2>/dev/null || echo "0")
if [[ "$DELIMITER_COUNT" -lt 2 ]]; then
echo "WARNING: Frontmatter in $(basename "$FILE") is missing the closing '---' delimiter. Obsidian will not parse metadata correctly."
exit 1
fi
# Extract frontmatter content (between first and second ---)
FRONTMATTER=$(sed -n '2,/^---$/p' "$FILE" | head -n -1)
# ── Check 2: tabs in frontmatter ────────────────────────────────────────
TAB_CHAR="$(printf '\t')"
if echo "$FRONTMATTER" | grep -q "$TAB_CHAR"; then
TAB_LINES=$(echo "$FRONTMATTER" | grep -n "$TAB_CHAR" | head -3)
echo "WARNING: Frontmatter in $(basename "$FILE") contains tabs. YAML requires spaces for indentation. Lines with tabs: $TAB_LINES"
exit 1
fi
# ── Check 3: common YAML errors ────────────────────────────────────────
# Unquoted values with colons (e.g., "title: My Note: Part 2" breaks YAML)
if echo "$FRONTMATTER" | grep -qE '^[a-zA-Z_-]+: .+: '; then
PROBLEM_LINES=$(echo "$FRONTMATTER" | grep -nE '^[a-zA-Z_-]+: .+: ' | head -3)
echo "WARNING: Frontmatter in $(basename "$FILE") may have unquoted colons in values. Wrap the value in quotes to avoid YAML parse errors. Problem lines: $PROBLEM_LINES"
exit 1
fi
fi
exit 0