From 5cc234185a2a366fa65ddb92d92dec2dd070bd14 Mon Sep 17 00:00:00 2001 From: Carlos Bacelar Date: Sun, 8 Nov 2026 20:53:12 -0300 Subject: [PATCH] fix(agent-kiro-kit): collect kit tests again after the src to python rename conftest.py put the removed src/ directory on sys.path, so beddel_agent_kiro could not be imported, and test_kiro_cli.py imported make_context from a core test helper that kits no longer reach. Point conftest at python/, build the ExecutionContext with a module-local helper, and add a characterization test that the adapter passes no cwd to the subprocess (Story 7.0b, TD-19). --- kits/agent-kiro-kit/tests/conftest.py | 4 ++-- kits/agent-kiro-kit/tests/test_kiro_cli.py | 23 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/kits/agent-kiro-kit/tests/conftest.py b/kits/agent-kiro-kit/tests/conftest.py index cec39bc5..58785e71 100644 --- a/kits/agent-kiro-kit/tests/conftest.py +++ b/kits/agent-kiro-kit/tests/conftest.py @@ -1,6 +1,6 @@ """Configure sys.path for standalone kit test execution. -Adds the kit's ``src/`` to sys.path so ``import beddel_agent_kiro`` +Adds the kit's ``python/`` to sys.path so ``import beddel_agent_kiro`` resolves. The ``beddel`` SDK itself must be installed (``pip install beddel``). """ @@ -8,4 +8,4 @@ from pathlib import Path _KIT_ROOT = Path(__file__).resolve().parent.parent -sys.path.insert(0, str(_KIT_ROOT / "src")) +sys.path.insert(0, str(_KIT_ROOT / "python")) diff --git a/kits/agent-kiro-kit/tests/test_kiro_cli.py b/kits/agent-kiro-kit/tests/test_kiro_cli.py index 30fe5dc6..a83ed999 100644 --- a/kits/agent-kiro-kit/tests/test_kiro_cli.py +++ b/kits/agent-kiro-kit/tests/test_kiro_cli.py @@ -7,11 +7,10 @@ from unittest.mock import AsyncMock, MagicMock, patch import pytest -from _helpers import make_context from beddel_agent_kiro.adapter import _DEFAULT_CLI_PATH, KiroCLIAgentAdapter from beddel.domain.errors import AgentError -from beddel.domain.models import DefaultDependencies +from beddel.domain.models import DefaultDependencies, ExecutionContext from beddel.domain.ports import IAgentAdapter from beddel.error_codes import ( AGENT_EXECUTION_FAILED, @@ -29,6 +28,11 @@ _PATCH_WAIT = "beddel_agent_kiro.adapter.asyncio.wait_for" +def _make_context(workflow_id: str) -> ExecutionContext: + """Build the execution context required by the registry primitive.""" + return ExecutionContext(workflow_id=workflow_id, current_step_id="step-1") + + def _make_mock_process( *, stdout: bytes = b"Hello, world!", @@ -281,6 +285,17 @@ async def test_happy_path(self) -> None: "timeout": 600, } + @pytest.mark.asyncio + async def test_subprocess_receives_no_cwd(self) -> None: + """Characterize today's inherited cwd; Story 7.2a is expected to change it.""" + adapter = KiroCLIAgentAdapter() + mock_proc = _make_mock_process() + + with patch(_PATCH_EXEC, return_value=mock_proc) as mock_exec: + await adapter.execute(_PROMPT) + + assert "cwd" not in mock_exec.call_args.kwargs + @pytest.mark.asyncio async def test_non_zero_exit_code(self) -> None: adapter = KiroCLIAgentAdapter() @@ -376,7 +391,7 @@ async def test_adapter_registered_and_resolved_via_agent_exec(self) -> None: """Register adapter as 'kiro-cli', execute via AgentExecPrimitive.""" # Arrange adapter = KiroCLIAgentAdapter() - ctx = make_context(workflow_id="wf-registry-roundtrip") + ctx = _make_context(workflow_id="wf-registry-roundtrip") ctx.deps = DefaultDependencies(agent_registry={"kiro-cli": adapter}) mock_proc = _make_mock_process(stdout=b"hello", returncode=0) @@ -401,7 +416,7 @@ async def test_result_usage_contains_model_and_timeout(self) -> None: """Verify usage metadata includes default model and timeout.""" # Arrange adapter = KiroCLIAgentAdapter() - ctx = make_context(workflow_id="wf-registry-usage") + ctx = _make_context(workflow_id="wf-registry-usage") ctx.deps = DefaultDependencies(agent_registry={"kiro-cli": adapter}) mock_proc = _make_mock_process(stdout=b"hello", returncode=0)