From 221afe94d982c5438ef479a68fb60559779afe4f Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sun, 22 Feb 2026 17:44:36 -0600 Subject: [PATCH] feat: inject active mission context into agent system prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The session-start hook approach didn't work — Claude Code's TUI overwrites stdout before the agent sees it, and the hook only fires when the agent calls it as a tool. Instead, inject mission context directly into the composed system prompt via build_runtime_prompt(). When mission.json is active in CWD, the agent gets mission name, ID, milestone progress, and mandatory first-action instructions in its initial context. Co-Authored-By: Claude Opus 4.6 --- bin/mosaic | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bin/mosaic b/bin/mosaic index a86c948..771cc3d 100755 --- a/bin/mosaic +++ b/bin/mosaic @@ -169,6 +169,40 @@ EOF printf '\n\n# Runtime-Specific Contract\n\n' cat "$runtime_file" + + # Inject active mission context if present in CWD + local mission_file=".mosaic/orchestrator/mission.json" + if [[ -f "$mission_file" ]] && command -v jq &>/dev/null; then + local status + status="$(jq -r '.status // "inactive"' "$mission_file" 2>/dev/null)" + if [[ "$status" == "active" || "$status" == "paused" ]]; then + local m_name m_id m_count m_completed + m_name="$(jq -r '.name // "unnamed"' "$mission_file")" + m_id="$(jq -r '.mission_id // ""' "$mission_file")" + m_count="$(jq '.milestones | length' "$mission_file")" + m_completed="$(jq '[.milestones[] | select(.status == "completed")] | length' "$mission_file")" + + printf '\n\n# Active Mission Context\n\n' + cat <