Implement MetricsStore for project-scoped agent metrics.

Add ADR-004 storage layer with append-only executions, summary
regeneration, idempotency keys, and retention pruning. Wire memory init
to scaffold .kaizen/metrics/ by default and add unit tests.
This commit is contained in:
2026-06-16 01:35:27 +02:00
parent bd74d7d122
commit 5cd3da3166
5 changed files with 331 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ from typing import List, Optional
from .registry import AgentRegistry, AgentCategory
from .installer import AgentInstaller, ProjectInitializer, InstallationConfig
from .metrics import MetricsStore
def safe_cli_wrapper():
@@ -781,7 +782,12 @@ def memory_show(agent_name: str, target: str):
@memory.command("init")
@click.argument("agent_name")
@click.option("--target", "-t", default=".", help="Project root (default: current)")
def memory_init(agent_name: str, target: str):
@click.option(
"--no-metrics",
is_flag=True,
help="Skip scaffolding .kaizen/metrics/<agent>/ (default: create metrics dir)",
)
def memory_init(agent_name: str, target: str, no_metrics: bool):
"""Scaffold an empty memory file for an agent."""
memory_path = _memory_path(target, agent_name)
@@ -820,6 +826,10 @@ session_count: 0
memory_path.write_text(content)
click.echo(f"Initialized memory for '{agent_name}': {memory_path}")
if not no_metrics:
metrics_dir = MetricsStore(Path(target), agent_name).scaffold()
click.echo(f"Initialized metrics for '{agent_name}': {metrics_dir}")
# For agents with protocols, note the protocol location
registry = _get_registry()
protocols_dir = registry.agents_dir / "protocols" / agent_name