feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
#!/usr/bin/env bash
|
2026-03-12 13:04:50 +00:00
|
|
|
# update-prompt.sh — Append a lesson to a best-practices file
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
#
|
|
|
|
|
# Usage:
|
2026-03-12 13:04:50 +00:00
|
|
|
# ./factory/update-prompt.sh "best-practices/memory.md" "### Title\nBody text"
|
|
|
|
|
# ./factory/update-prompt.sh --from-file "best-practices/memory.md" /tmp/lesson.md
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
#
|
2026-03-12 13:04:50 +00:00
|
|
|
# Called by claude -p when it learns something during a fix.
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
# Commits and pushes the update to the dark-factory repo.
|
|
|
|
|
|
|
|
|
|
source "$(dirname "$0")/../lib/env.sh"
|
|
|
|
|
|
2026-03-12 13:04:50 +00:00
|
|
|
TARGET_FILE="${FACTORY_ROOT}/factory/$1"
|
|
|
|
|
shift
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
|
|
|
|
|
if [ "$1" = "--from-file" ] && [ -f "$2" ]; then
|
|
|
|
|
LESSON=$(cat "$2")
|
2026-03-12 13:04:50 +00:00
|
|
|
elif [ -n "$1" ]; then
|
|
|
|
|
LESSON="$1"
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
else
|
2026-03-12 13:04:50 +00:00
|
|
|
echo "Usage: update-prompt.sh <relative-path> '<lesson text>'" >&2
|
|
|
|
|
echo " or: update-prompt.sh <relative-path> --from-file <path>" >&2
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-12 13:04:50 +00:00
|
|
|
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
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
|
|
|
|
|
cd "$FACTORY_ROOT"
|
2026-03-12 13:04:50 +00:00
|
|
|
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
|
feat: factory supervisor with priorities, auto-fix, and claude -p escalation
- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)
Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
2026-03-12 13:00:17 +00:00
|
|
|
git push origin main 2>/dev/null
|
|
|
|
|
|
2026-03-12 13:04:50 +00:00
|
|
|
log "Updated $(basename "$TARGET_FILE") with new lesson"
|