Skip to content

Commit 0ccbc7a

Browse files
committed
feedback
1 parent 8111672 commit 0ccbc7a

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

libs/core/kiln_ai/cli/commands/package_project.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,11 @@ def package_project(
864864
)
865865

866866
# 6. Export required skills
867-
export_skills(required_skill_ids, project, exported_project)
867+
try:
868+
export_skills(required_skill_ids, project, exported_project)
869+
except ValueError as e:
870+
console.print(f"[red]Error exporting skills: {e}")
871+
raise typer.Exit(code=1)
868872
if required_skill_ids:
869873
console.print(
870874
f"[green]✓[/green] Exported {len(required_skill_ids)} skill(s)"

libs/core/kiln_ai/cli/commands/test_package_project.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,17 @@ def test_no_skills_for_builtin_tools(self, temp_project_with_builtin_tool):
14681468

14691469
assert len(skill_ids) == 0
14701470

1471+
def test_skips_task_without_run_config(
1472+
self, temp_project_with_skill_tool: SkillToolProjectFixture
1473+
) -> None:
1474+
"""Test that tasks without a matching run config are skipped."""
1475+
task = Task.load_from_file(temp_project_with_skill_tool["task"].path)
1476+
1477+
assert task.id is not None
1478+
skill_ids = collect_required_skills([task], {})
1479+
1480+
assert len(skill_ids) == 0
1481+
14711482

14721483
class TestExportSkills:
14731484
def test_exports_skill(
@@ -1510,6 +1521,57 @@ def test_exports_no_skills_when_empty(self, temp_project):
15101521
finally:
15111522
shutil.rmtree(temp_dir, ignore_errors=True)
15121523

1524+
def test_raises_when_exported_project_path_is_none(
1525+
self, temp_project_with_skill_tool: SkillToolProjectFixture
1526+
) -> None:
1527+
"""Test that export_skills raises when exported project path is None."""
1528+
project = temp_project_with_skill_tool["project"]
1529+
skill = temp_project_with_skill_tool["skill"]
1530+
exported_project = Project(name="No Path Project", path=None)
1531+
1532+
assert skill.id is not None
1533+
with pytest.raises(ValueError, match="Exported project path is not set"):
1534+
export_skills({skill.id}, project, exported_project)
1535+
1536+
def test_raises_when_skill_id_not_found(
1537+
self, temp_project_with_skill_tool: SkillToolProjectFixture
1538+
) -> None:
1539+
"""Test that export_skills raises when a skill ID is not in the project."""
1540+
import shutil
1541+
1542+
project = temp_project_with_skill_tool["project"]
1543+
temp_dir, exported_project = create_export_directory(project)
1544+
1545+
try:
1546+
with pytest.raises(ValueError, match=r"Skill ID.*not found in the project"):
1547+
export_skills({"nonexistent_id"}, project, exported_project)
1548+
finally:
1549+
shutil.rmtree(temp_dir, ignore_errors=True)
1550+
1551+
def test_raises_when_skill_path_is_none(
1552+
self, temp_project_with_skill_tool: SkillToolProjectFixture
1553+
) -> None:
1554+
"""Test that export_skills raises when a skill's path is None."""
1555+
import shutil
1556+
from unittest.mock import MagicMock
1557+
1558+
project = temp_project_with_skill_tool["project"]
1559+
skill = temp_project_with_skill_tool["skill"]
1560+
temp_dir, exported_project = create_export_directory(project)
1561+
1562+
try:
1563+
assert skill.id is not None
1564+
fake_skill = MagicMock()
1565+
fake_skill.id = skill.id
1566+
fake_skill.name = skill.name
1567+
fake_skill.path = None
1568+
1569+
with patch.object(Project, "skills", return_value=[fake_skill]):
1570+
with pytest.raises(ValueError, match="path is not set"):
1571+
export_skills({skill.id}, project, exported_project)
1572+
finally:
1573+
shutil.rmtree(temp_dir, ignore_errors=True)
1574+
15131575

15141576
class TestExportToolServers:
15151577
def test_exports_tool_server(self, temp_project_with_mcp_remote_tool):

0 commit comments

Comments
 (0)