diff --git a/dev/dev-agent.sh b/dev/dev-agent.sh index 93acf17..ee1bfef 100755 --- a/dev/dev-agent.sh +++ b/dev/dev-agent.sh @@ -299,6 +299,12 @@ else done fi +# Track files changed for journal entry (will be populated after agent work) +FILES_CHANGED="" +if [ -n "$REMOTE_SHA" ]; then + FILES_CHANGED=$(git -C "$WORKTREE" diff "${FORGE_REMOTE}/${PRIMARY_BRANCH}..HEAD" --name-only 2>/dev/null | tr '\n' ',' | sed 's/,$//') || true +fi + # ============================================================================= # BUILD PROMPT # ============================================================================= @@ -548,9 +554,6 @@ if [ "$rc" -eq 0 ]; then log "PR #${PR_NUMBER} merged" issue_close "$ISSUE" - # Capture files changed for journal entry (after agent work) - FILES_CHANGED=$(git -C "$WORKTREE" diff "${FORGE_REMOTE}/${PRIMARY_BRANCH}..HEAD" --name-only 2>/dev/null | tr '\n' ',' | sed 's/,$//') || FILES_CHANGED="" - # Write journal entry post-session (before cleanup) profile_write_journal "$ISSUE" "$ISSUE_TITLE" "merged" "$FILES_CHANGED" || true @@ -568,9 +571,6 @@ else log "PR walk failed: ${_PR_WALK_EXIT_REASON:-unknown}" issue_block "$ISSUE" "${_PR_WALK_EXIT_REASON:-agent_failed}" - # Capture files changed for journal entry (after agent work) - FILES_CHANGED=$(git -C "$WORKTREE" diff "${FORGE_REMOTE}/${PRIMARY_BRANCH}..HEAD" --name-only 2>/dev/null | tr '\n' ',' | sed 's/,$//') || FILES_CHANGED="" - # Write journal entry post-session (before cleanup) outcome="blocked_${_PR_WALK_EXIT_REASON:-agent_failed}" profile_write_journal "$ISSUE" "$ISSUE_TITLE" "$outcome" "$FILES_CHANGED" || true diff --git a/lib/formula-session.sh b/lib/formula-session.sh index 1675ea5..917d623 100644 --- a/lib/formula-session.sh +++ b/lib/formula-session.sh @@ -242,7 +242,7 @@ Write the complete, rewritten lessons-learned.md content below. No preamble, no # Extract content from JSON response local lessons_content - lessons_content=$(printf '%s' "$output" | jq -r '.result // empty' 2>/dev/null || echo "") + lessons_content=$(printf '%s' "$output" | jq -r '.choices?[0].message?.content // empty' 2>/dev/null || echo "") if [ -z "$lessons_content" ]; then log "profile: failed to digest journals" @@ -258,7 +258,6 @@ Write the complete, rewritten lessons-learned.md content below. No preamble, no # Move digested journals to archive (if any were processed) if [ -d "$journal_dir" ]; then - mkdir -p "${journal_dir}/archive" local archived=0 for jf in "$journal_dir"/*.md; do [ -f "$jf" ] || continue @@ -415,7 +414,7 @@ Write the journal entry below. Use markdown format." # Extract content from JSON response local journal_content - journal_content=$(printf '%s' "$output" | jq -r '.result // empty' 2>/dev/null || echo "") + journal_content=$(printf '%s' "$output" | jq -r '.choices?[0].message?.content // empty' 2>/dev/null || echo "") if [ -z "$journal_content" ]; then log "profile: failed to write journal entry" diff --git a/planner/planner-run.sh b/planner/planner-run.sh index 31f5588..b406f18 100755 --- a/planner/planner-run.sh +++ b/planner/planner-run.sh @@ -120,8 +120,5 @@ export CLAUDE_MODEL="opus" agent_run --worktree "$WORKTREE" "$PROMPT" log "agent_run complete" -# Write journal entry post-session -profile_write_journal "planner-run" "Planner run $(date -u +%Y-%m-%d)" "complete" "" || true - rm -f "$SCRATCH_FILE" log "--- Planner run done ---"