Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/apm_cli/compilation/agents_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,9 @@ def _generate_placement_summary(self, distributed_result) -> str:

for placement in distributed_result.placements:
try:
rel_path = placement.agents_path.relative_to(self.base_dir.resolve())
rel_path = placement.agents_path.relative_to(self.base_dir.resolve()).as_posix()
except ValueError:
rel_path = placement.agents_path
rel_path = str(placement.agents_path)
lines.append(f"{rel_path}")
lines.append(f" Instructions: {len(placement.instructions)}")
lines.append(f" Patterns: {', '.join(sorted(placement.coverage_patterns))}")
Expand Down Expand Up @@ -868,9 +868,9 @@ def _generate_distributed_summary(self, distributed_result, config: CompilationC

for placement in distributed_result.placements:
try:
rel_path = placement.agents_path.relative_to(self.base_dir.resolve())
rel_path = placement.agents_path.relative_to(self.base_dir.resolve()).as_posix()
except ValueError:
rel_path = placement.agents_path
rel_path = str(placement.agents_path)
lines.append(f"- {rel_path} ({len(placement.instructions)} instructions)")

lines.extend([
Expand Down
127 changes: 71 additions & 56 deletions tests/unit/test_config_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,53 +29,62 @@ def test_config_show_outside_project(self):
"""Show config when not in an APM project directory."""
with tempfile.TemporaryDirectory() as tmp_dir:
os.chdir(tmp_dir)
with patch("apm_cli.commands.config.get_version", return_value="1.2.3"):
result = self.runner.invoke(config, [])
try:
with patch("apm_cli.commands.config.get_version", return_value="1.2.3"):
result = self.runner.invoke(config, [])
finally:
os.chdir(self.original_dir)
assert result.exit_code == 0

def test_config_show_inside_project(self):
"""Show config when apm.yml is present."""
with tempfile.TemporaryDirectory() as tmp_dir:
os.chdir(tmp_dir)
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: myproject\nversion: '0.1'\n")
with (
patch("apm_cli.commands.config.get_version", return_value="1.2.3"),
patch(
"apm_cli.commands.config._load_apm_config",
return_value={
"name": "myproject",
"version": "0.1",
"entrypoint": "main.md",
},
),
):
result = self.runner.invoke(config, [])
try:
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: myproject\nversion: '0.1'\n")
with (
patch("apm_cli.commands.config.get_version", return_value="1.2.3"),
patch(
"apm_cli.commands.config._load_apm_config",
return_value={
"name": "myproject",
"version": "0.1",
"entrypoint": "main.md",
},
),
):
result = self.runner.invoke(config, [])
finally:
os.chdir(self.original_dir)
assert result.exit_code == 0

def test_config_show_inside_project_with_compilation(self):
"""Show config when apm.yml has compilation settings."""
with tempfile.TemporaryDirectory() as tmp_dir:
os.chdir(tmp_dir)
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: myproject\ncompilation:\n output: AGENTS.md\n")
apm_config = {
"name": "myproject",
"version": "0.1",
"compilation": {
"output": "AGENTS.md",
"chatmode": "copilot",
"resolve_links": False,
},
"dependencies": {"mcp": ["server1", "server2"]},
}
with (
patch("apm_cli.commands.config.get_version", return_value="1.2.3"),
patch(
"apm_cli.commands.config._load_apm_config", return_value=apm_config
),
):
result = self.runner.invoke(config, [])
try:
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: myproject\ncompilation:\n output: AGENTS.md\n")
apm_config = {
"name": "myproject",
"version": "0.1",
"compilation": {
"output": "AGENTS.md",
"chatmode": "copilot",
"resolve_links": False,
},
"dependencies": {"mcp": ["server1", "server2"]},
}
with (
patch("apm_cli.commands.config.get_version", return_value="1.2.3"),
patch(
"apm_cli.commands.config._load_apm_config", return_value=apm_config
),
):
result = self.runner.invoke(config, [])
finally:
os.chdir(self.original_dir)
assert result.exit_code == 0

def test_config_show_rich_import_error_fallback(self):
Expand All @@ -85,11 +94,14 @@ def test_config_show_rich_import_error_fallback(self):
mock_table_cls = MagicMock(side_effect=ImportError("no rich"))
with tempfile.TemporaryDirectory() as tmp_dir:
os.chdir(tmp_dir)
with (
patch("apm_cli.commands.config.get_version", return_value="0.9.0"),
patch.object(rich.table, "Table", side_effect=ImportError("no rich")),
):
result = self.runner.invoke(config, [])
try:
with (
patch("apm_cli.commands.config.get_version", return_value="0.9.0"),
patch.object(rich.table, "Table", side_effect=ImportError("no rich")),
):
result = self.runner.invoke(config, [])
finally:
os.chdir(self.original_dir)
assert result.exit_code == 0

def test_config_show_fallback_inside_project(self):
Expand All @@ -98,22 +110,25 @@ def test_config_show_fallback_inside_project(self):

with tempfile.TemporaryDirectory() as tmp_dir:
os.chdir(tmp_dir)
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: proj\n")
apm_config = {
"name": "proj",
"version": "1.0",
"entrypoint": None,
"dependencies": {"mcp": []},
}
with (
patch("apm_cli.commands.config.get_version", return_value="0.9.0"),
patch(
"apm_cli.commands.config._load_apm_config", return_value=apm_config
),
patch.object(rich.table, "Table", side_effect=ImportError("no rich")),
):
result = self.runner.invoke(config, [])
try:
apm_yml = Path(tmp_dir) / "apm.yml"
apm_yml.write_text("name: proj\n")
apm_config = {
"name": "proj",
"version": "1.0",
"entrypoint": None,
"dependencies": {"mcp": []},
}
with (
patch("apm_cli.commands.config.get_version", return_value="0.9.0"),
patch(
"apm_cli.commands.config._load_apm_config", return_value=apm_config
),
patch.object(rich.table, "Table", side_effect=ImportError("no rich")),
):
result = self.runner.invoke(config, [])
finally:
os.chdir(self.original_dir)
assert result.exit_code == 0


Expand Down
Loading