From 95893aa1f296d50bf0533db4abd6ce7efbae96bf Mon Sep 17 00:00:00 2001 From: Agent Date: Wed, 1 Apr 2026 13:06:40 +0000 Subject: [PATCH] fix: feat(20g): migrate all remaining agents to .profile + remove ops repo journal dirs (#90) --- AGENTS.md | 7 ++++--- bin/disinto | 2 ++ gardener/gardener-run.sh | 5 ++--- lib/formula-session.sh | 11 +++++++++++ planner/planner-run.sh | 22 ++++++++++------------ predictor/predictor-run.sh | 5 ++--- review/review-pr.sh | 4 ++-- supervisor/supervisor-run.sh | 5 ++--- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d31ec3c..d7e4822 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -68,16 +68,17 @@ load_formula_or_profile "agent-role" "formulas/agent-role.toml" At session start, agents load `knowledge/lessons-learned.md` from `.profile` and inject it into the prompt: ```bash -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +formula_prepare_profile_context ``` +This single function call replaces the previous boilerplate of `profile_load_lessons` + `LESSONS_INJECTION` assignments. + ### Journal writing After each session, agents write reflection journals to `.profile/journal/`: ```bash -profile_write_journal "$ISSUE" "$ISSUE_TITLE" "$outcome" "$FILES_CHANGED" +profile_write_journal "session-name" "Session title" "outcome" "files-changed" ``` Journals are automatically digested into `lessons-learned.md` when undigested count exceeds 10. diff --git a/bin/disinto b/bin/disinto index 5528f36..d7262ee 100755 --- a/bin/disinto +++ b/bin/disinto @@ -921,6 +921,8 @@ ${ops_name}/ └── RESOURCES.md # accounts, tokens (refs), infra inventory \`\`\` +> **Note:** Journal directories (journal/planner/ and journal/supervisor/) have been removed from the ops repo. Agent journals are now stored in each agent's .profile repo on Forgejo. + ## Branch protection - \`main\`: 2 reviewers required for vault items diff --git a/gardener/gardener-run.sh b/gardener/gardener-run.sh index 9a83fc9..942c86b 100755 --- a/gardener/gardener-run.sh +++ b/gardener/gardener-run.sh @@ -74,9 +74,8 @@ fi load_formula_or_profile "gardener" "$FACTORY_ROOT/formulas/run-gardener.toml" || exit 1 build_context_block AGENTS.md -# ── Load lessons from .profile repo (pre-session) ──────────────────────── -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +# ── Prepare .profile context (lessons injection) ───────────────────────── +formula_prepare_profile_context # ── Read scratch file (compaction survival) ─────────────────────────────── SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE") diff --git a/lib/formula-session.sh b/lib/formula-session.sh index 1675ea5..553b0de 100644 --- a/lib/formula-session.sh +++ b/lib/formula-session.sh @@ -350,6 +350,17 @@ ${lessons_content}" return 0 } +# formula_prepare_profile_context +# Pre-session: loads lessons from .profile repo and sets LESSONS_CONTEXT for prompt injection. +# Single shared function to avoid duplicate boilerplate across agent scripts. +# Requires: AGENT_IDENTITY, FORGE_TOKEN, FORGE_URL (via profile_load_lessons). +# Exports: LESSONS_CONTEXT (set by profile_load_lessons). +# Returns 0 on success, 1 if agent has no .profile repo (silent no-op). +formula_prepare_profile_context() { + profile_load_lessons || true + LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +} + # 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 31f5588..f7bb8a4 100755 --- a/planner/planner-run.sh +++ b/planner/planner-run.sh @@ -45,12 +45,6 @@ WORKTREE="/tmp/${PROJECT_NAME}-planner-run" log() { echo "[$(date -u +%Y-%m-%dT%H:%M:%S)Z] $*" >> "$LOG_FILE"; } -# Ensure AGENT_IDENTITY is set for profile functions -if [ -z "${AGENT_IDENTITY:-}" ] && [ -n "${FORGE_PLANNER_TOKEN:-}" ]; then - AGENT_IDENTITY=$(curl -sf -H "Authorization: token ${FORGE_PLANNER_TOKEN}" \ - "${FORGE_URL:-http://localhost:3000}/api/v1/user" 2>/dev/null | jq -r '.login // empty' 2>/dev/null || true) -fi - # ── Guards ──────────────────────────────────────────────────────────────── check_active planner acquire_cron_lock "/tmp/planner-run.lock" @@ -58,8 +52,14 @@ check_memory 2000 log "--- Planner run start ---" +# ── Resolve agent identity for .profile repo ──────────────────────────── +if [ -z "${AGENT_IDENTITY:-}" ] && [ -n "${FORGE_PLANNER_TOKEN:-}" ]; then + AGENT_IDENTITY=$(curl -sf -H "Authorization: token ${FORGE_PLANNER_TOKEN}" \ + "${FORGE_URL:-http://localhost:3000}/api/v1/user" 2>/dev/null | jq -r '.login // empty' 2>/dev/null || true) +fi + # ── Load formula + context ─────────────────────────────────────────────── -load_formula "$FACTORY_ROOT/formulas/run-planner.toml" +load_formula_or_profile "planner" "$FACTORY_ROOT/formulas/run-planner.toml" || exit 1 build_context_block VISION.md AGENTS.md ops:RESOURCES.md ops:prerequisites.md # ── Build structural analysis graph ────────────────────────────────────── @@ -78,9 +78,8 @@ $(cat "$MEMORY_FILE") " fi -# ── Load lessons from .profile repo (pre-session) ──────────────────────── -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +# ── Prepare .profile context (lessons injection) ───────────────────────── +formula_prepare_profile_context # ── Read scratch file (compaction survival) ─────────────────────────────── SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE") @@ -96,8 +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 +${CONTEXT_BLOCK}${MEMORY_BLOCK}${LESSONS_INJECTION:+## Lessons learned ${LESSONS_INJECTION} } diff --git a/predictor/predictor-run.sh b/predictor/predictor-run.sh index 943a630..e2e5c0e 100755 --- a/predictor/predictor-run.sh +++ b/predictor/predictor-run.sh @@ -66,9 +66,8 @@ build_context_block AGENTS.md ops:RESOURCES.md VISION.md ops:prerequisites.md # ── Build structural analysis graph ────────────────────────────────────── build_graph_section -# ── Load lessons from .profile repo (pre-session) ──────────────────────── -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +# ── Prepare .profile context (lessons injection) ───────────────────────── +formula_prepare_profile_context # ── Read scratch file (compaction survival) ─────────────────────────────── SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE") diff --git a/review/review-pr.sh b/review/review-pr.sh index e1fbeb4..036e1a8 100755 --- a/review/review-pr.sh +++ b/review/review-pr.sh @@ -27,6 +27,7 @@ source "$(dirname "$0")/../lib/env.sh" source "$(dirname "$0")/../lib/ci-helpers.sh" source "$(dirname "$0")/../lib/worktree.sh" source "$(dirname "$0")/../lib/agent-sdk.sh" +# shellcheck source=../lib/formula-session.sh source "$(dirname "$0")/../lib/formula-session.sh" # Auto-pull factory code to pick up merged fixes before any logic runs @@ -192,8 +193,7 @@ fi # ============================================================================= # LOAD LESSONS FROM .PROFILE REPO (PRE-SESSION) # ============================================================================= -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +formula_prepare_profile_context # ============================================================================= # BUILD PROMPT diff --git a/supervisor/supervisor-run.sh b/supervisor/supervisor-run.sh index 48e292e..67e893c 100755 --- a/supervisor/supervisor-run.sh +++ b/supervisor/supervisor-run.sh @@ -77,9 +77,8 @@ fi load_formula_or_profile "supervisor" "$FACTORY_ROOT/formulas/run-supervisor.toml" || exit 1 build_context_block AGENTS.md -# ── Load lessons from .profile repo (pre-session) ──────────────────────── -profile_load_lessons || true -LESSONS_INJECTION="${LESSONS_CONTEXT:-}" +# ── Prepare .profile context (lessons injection) ───────────────────────── +formula_prepare_profile_context # ── Read scratch file (compaction survival) ─────────────────────────────── SCRATCH_CONTEXT=$(read_scratch_context "$SCRATCH_FILE")