improve: Ur

This commit is contained in:
daniel
2026-02-23 02:47:34 +00:00
parent e7d5941a75
commit 456d7ae21c
6 changed files with 53 additions and 5 deletions

View File

@@ -154,12 +154,37 @@ bash_cleanup() {
has_open=$(grep -c '^\- \[ \] `@q\[' "$file" 2>/dev/null) || true
if [[ "$has_open" -eq 0 ]]; then
sed -i '/^## Review Queue$/d; /^<!-- factbase:review -->$/d' "$file"
# Clean up trailing blank lines and stray --- at end of file
sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$file"
changed=true
fi
fi
# Remove answered review Q&A lines (- [x] `@q[...]` and their > answer lines)
if grep -qP '^\- \[x\] `@q\[' "$file" 2>/dev/null; then
local has_open
has_open=$(grep -c '^\- \[ \] `@q\[' "$file" 2>/dev/null) || true
if [[ "$has_open" -eq 0 ]]; then
# Remove - [x] `@q[...] lines and the > answer line that follows each
awk '
/^\- \[x\] `@q\[/ { skip=1; next }
skip && /^>/ { skip=0; next }
{ skip=0; print }
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
changed=true
fi
fi
# Remove duplicate H1 headings (keep first, remove subsequent)
local h1_count
h1_count=$(grep -c '^# ' "$file" 2>/dev/null) || true
if [[ "$h1_count" -gt 1 ]]; then
# Keep the first H1, delete all others
awk '/^# / { if (++count > 1) next } { print }' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
changed=true
fi
# Clean up trailing blank lines
sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$file"
[[ "$changed" == true ]]
}
@@ -335,6 +360,11 @@ RULES:
- The document content is already provided above — do NOT call get_entity to re-read it
unless you just called apply_review_answers and need to verify the result
- Use update_document to edit — be surgical, change only what needs changing
- When calling update_document, do NOT include the <!-- factbase:XXXXXX --> comment or the
# Title heading in the content — factbase adds those automatically. Start content with
the first section (e.g. ## Overview). Including them causes duplicate headings.
- If the document has answered review questions (- [x] `@q[...] lines with > answer lines),
ALWAYS remove them from the content — they are stale artifacts, not part of the document.
- Do NOT run git add, git commit, or git push — the wrapper script handles all git operations
- If nothing needs changing, say so and move on
@@ -390,7 +420,10 @@ process_entity() {
# Phase 2: Decide if agent is needed
local needs_agent=true
if [[ "${incomplete_name:-0}" -eq 1 ]]; then
if [[ "$SKIP_UNCHANGED" == true && "$last_processed" -gt 0 && "$mtime" -le "$last_processed" ]]; then
needs_agent=false
log " ⏭️ Not modified since last pass → skipping (--skip-unchanged)"
elif [[ "${incomplete_name:-0}" -eq 1 ]]; then
log " 👤 Incomplete name (ruler doc) → agent needed to resolve identity"
elif [[ "$review_count" -gt 0 ]]; then
log " 📋 $review_count review questions → agent needed"