feat(agency): add coach meta-agent and complete memory brief command (WP-0002 T12-T14)

- Add agents/agent-coach.md: new meta-category coaching agent that reads
  all project agent memories, synthesises cross-agent briefs, and produces
  targeted orientation briefs for incoming agents
- Complete memory brief command: now reads all .kaizen/agents/*/memory.md,
  formats structured orientation output following coach agent spec, adds
  --raw flag for unformatted dump
- Coach validates and appears under kaizen-agentic list --category meta

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 23:41:17 +00:00
parent 260b9b27e9
commit 23345cc5fd
2 changed files with 226 additions and 26 deletions

View File

@@ -824,41 +824,78 @@ session_count: 0
@memory.command("brief")
@click.argument("agent_name")
@click.option("--target", "-t", default=".", help="Project root (default: current)")
def memory_brief(agent_name: str, target: str):
@click.option("--raw", is_flag=True, help="Dump raw memory files without synthesis header")
def memory_brief(agent_name: str, target: str, raw: bool):
"""Print a coach-synthesised orientation for an agent.
Reads this agent's memory and all other agent memories in the project.
Coach agent integration is pending (T13 — see KAIZEN-WP-0002).
Currently prints the agent's own memory as a starting orientation.
Reads all agent memories in the project and formats an orientation brief
for the specified agent, following the coach agent (agents/agent-coach.md)
output format. Pass to a Claude session with the coach agent loaded for
full LLM synthesis.
"""
memory_path = _memory_path(target, agent_name)
kaizen_dir = Path(target).resolve() / ".kaizen" / "agents"
project_root = Path(target).resolve()
kaizen_dir = project_root / ".kaizen" / "agents"
project_name = project_root.name
click.echo(f"=== Agent Brief: {agent_name} ===\n")
# Collect all agent memories
own_memory: Optional[str] = None
other_memories: dict = {}
# Show own memory
if memory_path.exists():
click.echo(f"--- Memory: {agent_name} ---")
click.echo(memory_path.read_text())
else:
click.echo(f"No memory file found for '{agent_name}'. Run: memory init {agent_name}")
# List other agents with memory in this project
other_agents = []
if kaizen_dir.exists():
for agent_dir in kaizen_dir.iterdir():
if agent_dir.is_dir() and agent_dir.name != agent_name:
mf = agent_dir / "memory.md"
if mf.exists():
other_agents.append(agent_dir.name)
for agent_dir in sorted(kaizen_dir.iterdir()):
if not agent_dir.is_dir():
continue
mf = agent_dir / "memory.md"
if not mf.exists():
continue
if agent_dir.name == agent_name:
own_memory = mf.read_text()
else:
other_memories[agent_dir.name] = mf.read_text()
if other_agents:
click.echo(f"\n--- Other agents with memory in this project: {', '.join(other_agents)} ---")
click.echo("(Coach synthesis not yet available — use 'memory show <agent>' to read each)")
if raw:
if own_memory:
click.echo(f"=== {agent_name} ===\n{own_memory}")
for name, content in other_memories.items():
click.echo(f"=== {name} ===\n{content}")
return
from datetime import date as _date
today = _date.today().isoformat()
sources = ([agent_name] if own_memory else []) + list(other_memories.keys())
click.echo(f"## Orientation Brief for: {agent_name}")
click.echo(f"Project: {project_name}")
click.echo(f"Generated: {today}")
click.echo(f"Sources: {', '.join(sources) if sources else 'none'}")
click.echo()
if not sources:
click.echo("No agent memory files found in this project.")
click.echo(f" Run: kaizen-agentic memory init {agent_name}")
click.echo(" Then load the coach agent (agents/agent-coach.md) for synthesis.")
return
# Own memory section
if own_memory:
click.echo("### Your Memory")
click.echo(own_memory)
else:
click.echo("\nNo other agent memories found in this project.")
click.echo(f"### Your Memory\n(none — run: kaizen-agentic memory init {agent_name})\n")
click.echo("\nNote: Full coach synthesis will be available once agent-coach is implemented (KAIZEN-WP-0002 T12-T13).")
# Cross-agent context
if other_memories:
click.echo("### Context From Other Agents")
click.echo("(Load coach agent for full synthesis. Raw content below.)\n")
for name, content in other_memories.items():
click.echo(f"--- {name} ---")
click.echo(content)
else:
click.echo("### Context From Other Agents\nNo other agent memories found in this project.\n")
click.echo("---")
click.echo("Tip: Load agents/agent-coach.md in your Claude session and pass this output")
click.echo(" for a full cross-agent synthesis and orientation brief.")
@memory.command("clear")