refactor: update multi-agent rules to TMUX & refactor MAM skills scripts

- Update .agents/MULTI_AGENT_RULES.md & .ko.md to align with TMUX concepts
- Add .agents/INSTALL.md guide for MAM setup and workflows
- Clean up legacy markdown reports under .agents/reports/
- Refactor MAM scripts in .agents/skills/ (rename resolve_herdr_session to resolve_herdr_workspace)
- Improve workspace pane splitting/re-use logic in lib.sh
- Reduce paste safety sleep in send_keys_safe and support linking ~/.claude.json
This commit is contained in:
2026-07-22 06:57:32 +09:00
parent e4b1fb3329
commit 36a087af58
49 changed files with 258 additions and 4361 deletions
@@ -102,6 +102,10 @@ if [ "$ALL_REVIEWERS" = true ] && [ -n "$REVIEWER_LIST" ]; then
log_warn "--all-reviewer takes precedence; ignoring --reviewer list ('$REVIEWER_LIST')."
fi
if [ "$PLAN_TALK_TURNS" -gt 0 ] && [ "$PLAN_MODE" = false ]; then
log_warn "--plan-talk was specified but --plan mode is not enabled. Discussion turns will be ignored."
fi
# Verdict must occupy the report's last non-blank line — a standalone token
# quoted mid-report (e.g. as a formatting example) never matches (P0-2).
has_verdict() {
@@ -159,7 +163,7 @@ import os, json
d = json.loads(os.environ.get('MAM_STATE_JSON', '{}'))
target_agent = os.environ.get('TARGET_AGENT')
reviewers = [s.get('name') for s in d.get('herdr_sessions', [])
if 'reviewer' in s.get('role', '').lower() and s.get('name') != target_agent]
if 'reviewer' in (s.get('role') or '').lower() and s.get('status') == 'running' and s.get('name') != target_agent]
print(','.join(reviewers))
"
}
@@ -199,7 +203,7 @@ import os, json
d = json.loads(os.environ.get('MAM_STATE_JSON', '{}'))
planner = ''
for s in d.get('herdr_sessions', []):
if 'planner' in s.get('role', '').lower():
if 'planner' in (s.get('role') or '').lower() and s.get('status') == 'running':
planner = s.get('name')
break
print(planner)
@@ -220,8 +224,37 @@ log_info "Initializing multi-agent-mux-loop controller..."
log_info "Target Agent: $TARGET_AGENT"
log_info "Task Goal: $TASK"
# Validate that Target Agent is registered and running
TARGET_STATUS=$(MAM_STATE_JSON="$(load_state_json)" TARGET="$TARGET_AGENT" python3 -c "
import os, json
d = json.loads(os.environ.get('MAM_STATE_JSON', '{}'))
target = os.environ.get('TARGET')
status = ''
for s in d.get('herdr_sessions', []):
if s.get('name') == target:
status = s.get('status')
break
print(status)
")
if [ -z "$TARGET_STATUS" ]; then
log_error "Target agent session '$TARGET_AGENT' is not registered in the session registry."
exit 1
elif [ "$TARGET_STATUS" != "running" ]; then
log_error "Target agent session '$TARGET_AGENT' is not running (current status: '$TARGET_STATUS'). Please start it first."
exit 1
fi
PLANNER_SESSION=$(resolve_planner_session)
log_info "Resolved Planner session: $PLANNER_SESSION"
if [ "$PLAN_MODE" = true ]; then
if [ -z "$PLANNER_SESSION" ]; then
log_error "Planner mode enabled (--plan) but no running session with a 'planner' role was found."
exit 1
fi
fi
CURRENT_PLAN=""
CREATED_JOBS=()
@@ -329,7 +362,9 @@ else
log_info "=== Phase 1: Self-Planning Mode (Direct Execution) ==="
EXISTING_PLAN_FILE=""
if [ -n "$PLANNER_SESSION" ]; then
EXISTING_PLAN_FILE=".agents/reports/$PLANNER_SESSION/report-final.md"
# Promoted plans are saved as plan-<job-id>.md by the Phase 3 promotion
# step below, not report-final.md; pick the most recently promoted one.
EXISTING_PLAN_FILE=$(ls -t ".agents/reports/$PLANNER_SESSION"/plan-*.md 2>/dev/null | head -n 1 || true)
fi
if [ -n "$EXISTING_PLAN_FILE" ] && [ -f "$EXISTING_PLAN_FILE" ]; then
log_info "Found existing promoted plan at '$EXISTING_PLAN_FILE'. Loading plan..."
@@ -385,8 +420,14 @@ if [ "$ALL_REVIEWERS" = true ]; then
if [ -n "$RESOLVED_REVS" ]; then
IFS=' ,' read -r -a REVIEWERS <<< "$RESOLVED_REVS"
fi
if [ "${#REVIEWERS[@]}" -eq 0 ]; then
log_error "--all-reviewer was specified, but no running reviewer sessions were found."
exit 1
fi
elif [ -n "$REVIEWER_LIST" ]; then
IFS=' ,' read -r -a REVIEWERS <<< "$REVIEWER_LIST"
# Strip whitespaces first to prevent empty array elements from trailing spaces
CLEAN_REVS=$(echo "$REVIEWER_LIST" | tr -d '[:space:]')
IFS=',' read -r -a REVIEWERS <<< "$CLEAN_REVS"
fi
loop_count=1