feat: progressive disclosure + escalate everything to claude

- PROMPT.md references best-practices/ files instead of inlining all knowledge
- best-practices/{memory,disk,ci,dev-agent,git}.md — loaded on demand by claude
- All alerts go to claude -p. Claude decides what to fix and what to escalate.
- update-prompt.sh targets specific best-practices files for self-learning
This commit is contained in:
openhands 2026-03-12 13:04:50 +00:00
parent cb7dd398c7
commit 5eb17020d5
8 changed files with 222 additions and 117 deletions

View file

@ -1,34 +1,47 @@
#!/usr/bin/env bash
# update-prompt.sh — Append a lesson learned to PROMPT.md
# update-prompt.sh — Append a lesson to a best-practices file
#
# Usage:
# ./factory/update-prompt.sh "### Title" "Body text describing the lesson"
# ./factory/update-prompt.sh --from-file /tmp/lesson.md
# ./factory/update-prompt.sh "best-practices/memory.md" "### Title\nBody text"
# ./factory/update-prompt.sh --from-file "best-practices/memory.md" /tmp/lesson.md
#
# Called by claude -p when it learns something new during a fix.
# Called by claude -p when it learns something during a fix.
# Commits and pushes the update to the dark-factory repo.
source "$(dirname "$0")/../lib/env.sh"
PROMPT_FILE="${FACTORY_ROOT}/factory/PROMPT.md"
TARGET_FILE="${FACTORY_ROOT}/factory/$1"
shift
if [ "$1" = "--from-file" ] && [ -f "$2" ]; then
LESSON=$(cat "$2")
elif [ -n "$1" ] && [ -n "$2" ]; then
LESSON="$1
$2"
elif [ -n "$1" ]; then
LESSON="$1"
else
echo "Usage: update-prompt.sh 'Title' 'Body' OR update-prompt.sh --from-file path" >&2
echo "Usage: update-prompt.sh <relative-path> '<lesson text>'" >&2
echo " or: update-prompt.sh <relative-path> --from-file <path>" >&2
exit 1
fi
# Append to PROMPT.md under Best Practices
echo "" >> "$PROMPT_FILE"
echo "$LESSON" >> "$PROMPT_FILE"
if [ ! -f "$TARGET_FILE" ]; then
echo "Target file not found: $TARGET_FILE" >&2
exit 1
fi
# Append under "Lessons Learned" section if it exists, otherwise at end
if grep -q "## Lessons Learned" "$TARGET_FILE"; then
echo "" >> "$TARGET_FILE"
echo "$LESSON" >> "$TARGET_FILE"
else
echo "" >> "$TARGET_FILE"
echo "## Lessons Learned" >> "$TARGET_FILE"
echo "" >> "$TARGET_FILE"
echo "$LESSON" >> "$TARGET_FILE"
fi
cd "$FACTORY_ROOT"
git add factory/PROMPT.md
git commit -m "factory: update supervisor best practices" --no-verify 2>/dev/null
git add "factory/$1" 2>/dev/null || git add "$TARGET_FILE"
git commit -m "factory: learned — $(echo "$LESSON" | head -1 | sed 's/^#* *//')" --no-verify 2>/dev/null
git push origin main 2>/dev/null
log "PROMPT.md updated with new lesson"
log "Updated $(basename "$TARGET_FILE") with new lesson"