Implemented the next missing parity slice around agent configurations.

This commit is contained in:
Abdelrahman Abdallah
2026-04-17 05:15:17 +02:00
parent 02674ba594
commit 872f4f89b5
11 changed files with 770 additions and 6 deletions
+52 -1
View File
@@ -6,7 +6,14 @@ import unittest
from pathlib import Path
from unittest.mock import patch
from src.agent_registry import load_agent_registry, render_agent_detail, render_agents_report
from src.agent_registry import (
create_agent_definition,
delete_agent_definition,
load_agent_registry,
render_agent_detail,
render_agents_report,
update_agent_definition,
)
def _write_agent(path: Path, *, name: str, description: str, body: str, extra: str = '') -> None:
@@ -22,6 +29,50 @@ def _write_agent(path: Path, *, name: str, description: str, body: str, extra: s
class AgentRegistryTests(unittest.TestCase):
def test_create_update_delete_agent_definition_roundtrip(self) -> None:
with tempfile.TemporaryDirectory() as home_dir, tempfile.TemporaryDirectory() as tmp_dir:
workspace = Path(tmp_dir)
with patch.dict(os.environ, {'HOME': home_dir}):
created = create_agent_definition(
workspace,
agent_type='reviewer',
description='Review implementation changes.',
system_prompt='Inspect diffs and summarize risks.',
source='project',
tools=('read_file', 'grep_search'),
model='demo-model',
initial_prompt='Start with changed files.',
)
self.assertEqual(created.action, 'created')
self.assertTrue(Path(created.file_path).exists())
snapshot = load_agent_registry(workspace)
detail = render_agent_detail(snapshot, 'reviewer')
self.assertIn('demo-model', detail)
self.assertIn('Start with changed files.', detail)
updated = update_agent_definition(
workspace,
agent_type='reviewer',
description='Review code and tests carefully.',
system_prompt='Focus on regressions and missing coverage.',
source='project',
)
self.assertEqual(updated.action, 'updated')
snapshot = load_agent_registry(workspace)
detail = render_agent_detail(snapshot, 'reviewer')
self.assertIn('Review code and tests carefully.', detail)
self.assertIn('Focus on regressions and missing coverage.', detail)
deleted = delete_agent_definition(
workspace,
agent_type='reviewer',
source='project',
)
self.assertEqual(deleted.action, 'deleted')
self.assertFalse(Path(deleted.file_path).exists())
def test_project_agent_overrides_built_in_agent(self) -> None:
with tempfile.TemporaryDirectory() as home_dir, tempfile.TemporaryDirectory() as tmp_dir:
workspace = Path(tmp_dir)