This commit is contained in:
2026-06-07 00:13:03 -05:00
parent 342501d670
commit 7e181cafc6
3 changed files with 7 additions and 5 deletions
@@ -270,7 +270,7 @@ After substantive activity, write a one-line entry to today's daily note's `## A
1. Try to GET `journal/daily/YYYY-MM-DD.md`.
2. If 404 — PUT a fresh daily note from the template, then PATCH.
3. If 200 but `## Agent Log` is missing — POST `\n\n## Agent Log\n` to the file to add the heading, then PATCH.
3. If 200 but `## Agent Log` is missing — POST `\n\n## Agent Log\n` to the file to add the heading, then PATCH. **Detect the heading by grepping the raw markdown for an anchored `^## Agent Log` line — do NOT grep the document-map JSON, whose headings are full `::`-delimited paths (e.g. `"2026-06-07::Agent Log"`); a bare `"Agent Log"` match fails there and a duplicate heading gets appended.**
4. PATCH-append the entry under the target `<YYYY-MM-DD>::Agent Log` (the H1 of a daily note is the date, so that's the full target path).
```bash
@@ -286,9 +286,11 @@ if [ "$HTTP" = "404" ]; then
| curl -s -X PUT -H "$AUTH" -H "Content-Type: text/markdown" --data-binary @- "$DAILY"
fi
# 3: ensure the `## Agent Log` heading exists
MAP=$(curl -s -H "$AUTH" -H "Accept: application/vnd.olrapi.document-map+json" "$DAILY")
if ! printf '%s' "$MAP" | grep -q '"Agent Log"'; then
# 3: ensure the `## Agent Log` heading exists.
# Grep the RAW markdown for an anchored heading line. Do NOT grep the document-map
# JSON: its headings are full "::"-delimited paths (e.g. "2026-06-07::Agent Log"), so a
# bare '"Agent Log"' match never matches and a DUPLICATE heading gets appended each time.
if ! curl -s -H "$AUTH" "$DAILY" | grep -q '^## Agent Log'; then
printf '\n\n## Agent Log\n' | curl -s -X POST -H "$AUTH" -H "Content-Type: text/markdown" --data-binary @- "$DAILY"
fi