71 lines
2 KiB
Bash
Executable file
71 lines
2 KiB
Bash
Executable file
#!/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."
|