diff --git a/gardener/gardener-run.sh b/gardener/gardener-run.sh index 942c86b..62e9eb1 100755 --- a/gardener/gardener-run.sh +++ b/gardener/gardener-run.sh @@ -114,10 +114,7 @@ You have full shell access and --dangerously-skip-permissions. Fix what you can. File vault items for what you cannot. Do NOT ask permission — act first, report after. ## Project context -${CONTEXT_BLOCK}${LESSONS_INJECTION:+## Lessons learned -${LESSONS_INJECTION} - -} +${CONTEXT_BLOCK}$(formula_lessons_block) ${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT} } ## Result file diff --git a/lib/formula-session.sh b/lib/formula-session.sh index 64ca724..e6c6aae 100644 --- a/lib/formula-session.sh +++ b/lib/formula-session.sh @@ -362,6 +362,17 @@ formula_prepare_profile_context() { LESSONS_INJECTION="${LESSONS_CONTEXT:-}" } +# formula_lessons_block +# Returns a formatted lessons block for prompt injection. +# Usage: LESSONS_BLOCK=$(formula_lessons_block) +# Expects: LESSONS_INJECTION to be set by formula_prepare_profile_context. +# Returns: formatted block or empty string. +formula_lessons_block() { + if [ -n "${LESSONS_INJECTION:-}" ]; then + printf '\n## Lessons learned (from .profile/knowledge/lessons-learned.md)\n%s' "$LESSONS_INJECTION" + fi +} + # profile_write_journal ISSUE_NUM ISSUE_TITLE OUTCOME [FILES_CHANGED] # Post-session: writes a reflection journal entry after work completes. # Returns 0 on success, 1 on failure. diff --git a/planner/planner-run.sh b/planner/planner-run.sh index f7bb8a4..663703c 100755 --- a/planner/planner-run.sh +++ b/planner/planner-run.sh @@ -95,10 +95,7 @@ build_sdk_prompt_footer " PROMPT="You are the strategic planner for ${FORGE_REPO}. Work through the formula below. ## Project context -${CONTEXT_BLOCK}${MEMORY_BLOCK}${LESSONS_INJECTION:+## Lessons learned -${LESSONS_INJECTION} - -} +${CONTEXT_BLOCK}${MEMORY_BLOCK}$(formula_lessons_block) ${GRAPH_SECTION} ${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT} } diff --git a/predictor/predictor-run.sh b/predictor/predictor-run.sh index e2e5c0e..266829c 100755 --- a/predictor/predictor-run.sh +++ b/predictor/predictor-run.sh @@ -91,10 +91,7 @@ Use WebSearch for external signal scanning — be targeted (project dependencies and tools only, not general news). Limit to 3 web searches per run. ## Project context -${CONTEXT_BLOCK}${LESSONS_INJECTION:+## Lessons learned -${LESSONS_INJECTION} - -} +${CONTEXT_BLOCK}$(formula_lessons_block) ${GRAPH_SECTION} ${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT} } diff --git a/review/review-pr.sh b/review/review-pr.sh index 036e1a8..8a9a29d 100755 --- a/review/review-pr.sh +++ b/review/review-pr.sh @@ -208,7 +208,7 @@ FORMULA=$(cat "${FACTORY_ROOT}/formulas/review-pr.toml") "$PR_BODY" "$FILES" "$DNOTE" "$DIFF" [ -n "$PREV_CONTEXT" ] && printf '%s\n' "$PREV_CONTEXT" [ -n "$GRAPH_SECTION" ] && printf '%s\n' "$GRAPH_SECTION" - [ -n "$LESSONS_INJECTION" ] && printf '\n## Lessons learned\n%s\n\n' "$LESSONS_INJECTION" + formula_lessons_block printf '\n## Formula\n%s\n\n## Environment\nREVIEW_OUTPUT_FILE=%s\nFORGE_API=%s\nPR_NUMBER=%s\nFACTORY_ROOT=%s\n' \ "$FORMULA" "$OUTPUT_FILE" "$API" "$PR_NUMBER" "$FACTORY_ROOT" printf 'NEVER echo the actual token — always reference ${FORGE_TOKEN} or ${FORGE_REVIEW_TOKEN}.\n' diff --git a/supervisor/supervisor-run.sh b/supervisor/supervisor-run.sh index 67e893c..4ba6ec3 100755 --- a/supervisor/supervisor-run.sh +++ b/supervisor/supervisor-run.sh @@ -100,10 +100,7 @@ Fix what you can. File vault items for what you cannot. Do NOT ask permission ${PREFLIGHT_OUTPUT} ## Project context -${CONTEXT_BLOCK}${LESSONS_INJECTION:+## Lessons learned -${LESSONS_INJECTION} - -} +${CONTEXT_BLOCK}$(formula_lessons_block) ${SCRATCH_CONTEXT:+${SCRATCH_CONTEXT} } Priority order: P0 memory > P1 disk > P2 stopped > P3 degraded > P4 housekeeping