build: garden update 2026-04-15 03:13 — scripts/garden-session.sh
This commit is contained in:
parent
399cf5b03d
commit
51e4fac4db
1 changed files with 71 additions and 0 deletions
71
scripts/garden-session.sh
Executable file
71
scripts/garden-session.sh
Executable file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# garden-session.sh: Automate daily note → session log draft
|
||||||
|
# Usage: ./garden-session.sh [YYYY-MM-DD]
|
||||||
|
# Outputs to content/sessions/YYYY-MM-DD-session.md
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DATE=${1:-$(date +%Y-%m-%d)}
|
||||||
|
DAILY_PATH="~/.napkin/daily/${DATE}.md"
|
||||||
|
DRAFT_PATH="content/sessions/${DATE}-session.md"
|
||||||
|
|
||||||
|
echo "Generating session draft for ${DATE}..."
|
||||||
|
|
||||||
|
# Read daily note
|
||||||
|
napkin daily read --file "${DATE}" > /tmp/daily-${DATE}.md || {
|
||||||
|
echo "No daily note for ${DATE}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract YAML frontmatter (simple sed, assumes standard format)
|
||||||
|
FRONTMATTER=$(sed -n '/^---/,$p' /tmp/daily-${DATE}.md | sed '/^---/q' | tail -n +2)
|
||||||
|
SUMMARY=$(echo "${FRONTMATTER}" | grep '^summary:' | sed 's/^summary: //')
|
||||||
|
KEYWORDS=$(echo "${FRONTMATTER}" | grep '^keywords:' | sed 's/^keywords: \\[\\(.*\\)\\]/\\1/' | tr -d '[], "')
|
||||||
|
WORK=$(sed -n '/^**Work:**/,/^$/p' /tmp/daily-${DATE}.md | tail -n +2)
|
||||||
|
|
||||||
|
# Determine fragment types from keywords (simple mapping)
|
||||||
|
FRAGMENTS=()
|
||||||
|
if [[ "${KEYWORDS}" == *operational* || ${KEYWORDS} == *fix* ]]; then
|
||||||
|
FRAGMENTS+=("fix")
|
||||||
|
fi
|
||||||
|
if [[ "${KEYWORDS}" == *build* || ${KEYWORDS} == *protocol* ]]; then
|
||||||
|
FRAGMENTS+=("build")
|
||||||
|
fi
|
||||||
|
# Add more mappings...
|
||||||
|
|
||||||
|
# Generate draft MD
|
||||||
|
cat > "${DRAFT_PATH}" << EOF
|
||||||
|
---
|
||||||
|
title: "Vigilio Session Log: ${DATE}"
|
||||||
|
date: ${DATE}T00:00:00Z
|
||||||
|
tags: [session, ${KEYWORDS}]
|
||||||
|
draft: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Session ${DATE}
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
{{% fragment type="summary" %}}
|
||||||
|
${SUMMARY}
|
||||||
|
{{% /fragment %}}
|
||||||
|
|
||||||
|
## Work Highlights
|
||||||
|
{{% fragment type="work" %}}
|
||||||
|
${WORK}
|
||||||
|
{{% /fragment %}}
|
||||||
|
|
||||||
|
## Fragments
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Add dynamic fragments
|
||||||
|
for type in "${FRAGMENTS[@]}"; do
|
||||||
|
echo "
|
||||||
|
{{% fragment type=\"${type}\" %}}
|
||||||
|
[Details for ${type}]
|
||||||
|
{{% /fragment %}}" >> "${DRAFT_PATH}"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm /tmp/daily-${DATE}.md
|
||||||
|
|
||||||
|
echo "Draft generated: ${DRAFT_PATH}"
|
||||||
|
echo "Review, edit voice, set draft: false, hugo, commit."
|
||||||
Loading…
Add table
Add a link
Reference in a new issue