Skip to content

The agent that turns websites into APIs!

release: v0.6.0 - Chrome DevTools MCP, sdist trim, tool-result streaming

kalil0321cc0c57d8cf80
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b94132..5945a4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.6.0] - 2026-04-01
+
+### Added
+- **Chrome DevTools MCP agent provider (`chrome-mcp`)**: Agent mode can drive the browser through [Chrome DevTools MCP](https://www.npmjs.com/package/chrome-devtools-mcp) (`--autoConnect`, optional `--no-usage-statistics`) with a dedicated system prompt and SDK wiring alongside the existing Playwright MCP path
+
+### Changed
+- **Agent provider selection**: CLI settings and mode flow distinguish **auto (Playwright MCP)** from **chrome-mcp (Chrome DevTools MCP)**
+- **Packaging**: Source distributions exclude local demo video, packed Chrome extension zip, store-asset screenshots, and per-machine `.claude/settings.local.json` files so PyPI artifacts stay small (wheel unchanged: `src/reverse_api` only)
+
+### Fixed
+- **Tool result blocks** (engineer / agent streaming): When `content` is empty, fall back to `result` or `output` on tool-result blocks so alternate SDK shapes still surface output in the UI and message store
+- **Process title**: Set when the CLI module loads so the terminal shows `reverse-api` earlier in startup
+- **Follow-up prompt**: Flush local sync before reading follow-up input so state is up to date
+- **Tests**: `ClaudeAutoEngineer` analyze tests now use real `claude_agent_sdk` message types (so `isinstance` checks in the streaming loop match) and stub `_prompt_follow_up` to avoid the interactive follow-up path
+
+### Documentation
+- **README**: Agent mode demo GIF
+
## [0.5.0] - 2026-03-17
### Added
diff --git a/pyproject.toml b/pyproject.toml
index f823156..c124996 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "reverse-api-engineer"
-version = "0.5.0"
+version = "0.6.0"
description = "A tool to capture browser traffic for API reverse engineering"
readme = "README.md"
requires-python = ">=3.11"
@@ -66,6 +66,15 @@ allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["src/reverse_api"]
+[tool.hatch.build.targets.sdist]
+exclude = [
+ "rae_autoscout.mp4",
+ "chrome-extension/packed/**",
+ "chrome-extension/store-assets/**",
+ ".claude/settings.local.json",
+ "chrome-extension/.claude/settings.local.json",
+]
+
[dependency-groups]
dev = [
"mypy>=1.19.1",
diff --git a/src/reverse_api/engineer.py b/src/reverse_api/engineer.py
index 022b625..b5f21d8 100644
--- a/src/reverse_api/engineer.py
+++ b/src/reverse_api/engineer.py
@@ -74,11 +74,11 @@ class ClaudeEngineer(BaseEngineer):
is_error = block.is_error if block.is_error else False
output = None
- if hasattr(block, "content"):
+ if getattr(block, "content", None) is not None:
output = block.content
- elif hasattr(block, "result"):
+ elif getattr(block, "result", None) is not None:
output = block.result
- elif hasattr(block, "output"):
+ elif getattr(block, "output", None) is not None:
output = block.output
tool_name = last_tool_name or "Tool"
diff --git a/tests/test_auto_engineer.py b/tests/test_auto_engineer.py
index 69a5d93..d7c6d2d 100644
--- a/tests/test_auto_engineer.py
+++ b/tests/test_auto_engineer.py
@@ -1,15 +1,49 @@
"""Tests for auto_engineer.py - Auto mode engineers."""
+from dataclasses import dataclass
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
import httpx
import pytest
+from claude_agent_sdk import (
+ AssistantMessage,
+ ResultMessage,
+ TextBlock,
+ ToolResultBlock,
+ ToolUseBlock,
+)
from reverse_api.auto_engineer import ClaudeAutoEngineer, OpenCodeAutoEngineer
+@dataclass
+class ToolResultWithResult(ToolResultBlock):
+ """Tool result with legacy ``result`` attribute (engineer.py fallback)."""
+
+ result: str | None = None
+
+
+@dataclass
+class ToolResultWithOutput(ToolResultBlock):
+ """Tool result with legacy ``output`` attribute (engineer.py fallback)."""
+
+ output: str | None = None
+
+
+def _sdk_result_message(*, is_error: bool = False, result: str | None = None) -> ResultMessage:
+ return ResultMessage(
+ subtype="test",
+ duration_ms=0,
+ duration_api_ms=0,
+ is_error=is_error,
+ num_turns=1,
+ session_id="test-session",
+ result=result,
+ )
+
+
class TestClaudeAutoEngineerInit:
"""Test ClaudeAutoEngineer initialization."""
@@ -386,10 +420,7 @@ class TestClaudeAutoEngineerAnalyze:
"""ResultMessage with success returns result dict."""
eng = self._make_engineer(tmp_path)
- from claude_agent_sdk import ResultMessage
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
- mock_result.result = "Success"
+ mock_result = _sdk_result_message(result="Success")
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -399,13 +430,14 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- assert result is not None
- assert "script_path" in result
+ result = await eng.analyze_and_generate()
+ assert result is not None
+ assert "script_path" in result
@pytest.mark.asyncio
async def test_result_with_usage(self, tmp_path):
@@ -418,9 +450,7 @@ class TestClaudeAutoEngineerAnalyze:
"cache_read_input_tokens": 50,
}
- from claude_agent_sdk import ResultMessage
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
+ mock_result = _sdk_result_message()
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -430,44 +460,30 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- if result is not None:
- assert "usage" in result
+ result = await eng.analyze_and_generate()
+ if result is not None:
+ assert "usage" in result
@pytest.mark.asyncio
async def test_assistant_message_with_tools(self, tmp_path):
"""AssistantMessage with ToolUseBlock, ToolResultBlock, TextBlock are processed."""
eng = self._make_engineer(tmp_path)
- from claude_agent_sdk import (
- AssistantMessage,
- ResultMessage,
- TextBlock,
- ToolResultBlock,
- ToolUseBlock,
+ mock_tool_use = ToolUseBlock(id="1", name="Read", input={"file_path": "/test.py"})
+ mock_tool_result = ToolResultBlock(
+ tool_use_id="1", content="file contents", is_error=False
)
-
- mock_tool_use = MagicMock(spec=ToolUseBlock)
- mock_tool_use.name = "Read"
- mock_tool_use.input = {"file_path": "/test.py"}
-
- mock_tool_result = MagicMock(spec=ToolResultBlock)
- mock_tool_result.is_error = False
- mock_tool_result.content = "file contents"
-
- mock_text = MagicMock(spec=TextBlock)
- mock_text.text = "Analyzing the file..."
-
- mock_assistant = MagicMock(spec=AssistantMessage)
- mock_assistant.content = [mock_tool_use, mock_tool_result, mock_text]
- del mock_assistant.usage
-
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
+ mock_text = TextBlock(text="Analyzing the file...")
+ mock_assistant = AssistantMessage(
+ content=[mock_tool_use, mock_tool_result, mock_text],
+ model="claude-sonnet-4-6",
+ )
+ mock_result = _sdk_result_message()
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -478,27 +494,24 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- assert result is not None
- assert "script_path" in result
+ result = await eng.analyze_and_generate()
+ assert result is not None
+ assert "script_path" in result
@pytest.mark.asyncio
async def test_assistant_message_with_usage(self, tmp_path):
"""AssistantMessage with usage metadata updates tracking."""
eng = self._make_engineer(tmp_path)
- from claude_agent_sdk import AssistantMessage, ResultMessage
-
- mock_assistant = MagicMock(spec=AssistantMessage)
- mock_assistant.content = []
+ mock_assistant = AssistantMessage(content=[], model="claude-sonnet-4-6")
mock_assistant.usage = {"input_tokens": 500, "output_tokens": 200}
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
+ mock_result = _sdk_result_message()
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -509,41 +522,29 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- assert result is not None
- assert eng.usage_metadata.get("input_tokens") == 500
+ result = await eng.analyze_and_generate()
+ assert result is not None
+ assert eng.usage_metadata.get("input_tokens") == 500
@pytest.mark.asyncio
async def test_tool_result_with_result_attr(self, tmp_path):
"""ToolResultBlock with result attribute (not content) is handled."""
eng = self._make_engineer(tmp_path)
- from claude_agent_sdk import (
- AssistantMessage,
- ResultMessage,
- ToolResultBlock,
- ToolUseBlock,
+ mock_tool_use = ToolUseBlock(id="u1", name="Bash", input={"command": "ls"})
+ mock_tool_result = ToolResultWithResult(
+ tool_use_id="u1", content=None, is_error=True, result="command not found"
)
-
- mock_tool_use = MagicMock(spec=ToolUseBlock)
- mock_tool_use.name = "Bash"
- mock_tool_use.input = {"command": "ls"}
-
- mock_tool_result = MagicMock(spec=ToolResultBlock)
- mock_tool_result.is_error = True
- del mock_tool_result.content
- mock_tool_result.result = "command not found"
-
- mock_assistant = MagicMock(spec=AssistantMessage)
- mock_assistant.content = [mock_tool_use, mock_tool_result]
- del mock_assistant.usage
-
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
+ mock_assistant = AssistantMessage(
+ content=[mock_tool_use, mock_tool_result],
+ model="claude-sonnet-4-6",
+ )
+ mock_result = _sdk_result_message()
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -554,41 +555,28 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- assert result is not None
+ result = await eng.analyze_and_generate()
+ assert result is not None
@pytest.mark.asyncio
async def test_tool_result_with_output_attr(self, tmp_path):
"""ToolResultBlock with output attribute (not content/result) is handled."""
eng = self._make_engineer(tmp_path)
- from claude_agent_sdk import (
- AssistantMessage,
- ResultMessage,
- ToolResultBlock,
- ToolUseBlock,
+ mock_tool_use = ToolUseBlock(id="u2", name="Grep", input={"pattern": "test"})
+ mock_tool_result = ToolResultWithOutput(
+ tool_use_id="u2", content=None, is_error=False, output="grep output here"
)
-
- mock_tool_use = MagicMock(spec=ToolUseBlock)
- mock_tool_use.name = "Grep"
- mock_tool_use.input = {"pattern": "test"}
-
- mock_tool_result = MagicMock(spec=ToolResultBlock)
- mock_tool_result.is_error = False
- del mock_tool_result.content
- del mock_tool_result.result
- mock_tool_result.output = "grep output here"
-
- mock_assistant = MagicMock(spec=AssistantMessage)
- mock_assistant.content = [mock_tool_use, mock_tool_result]
- del mock_assistant.usage
-
- mock_result = MagicMock(spec=ResultMessage)
- mock_result.is_error = False
+ mock_assistant = AssistantMessage(
+ content=[mock_tool_use, mock_tool_result],
+ model="claude-sonnet-4-6",
+ )
+ mock_result = _sdk_result_message()
mock_client = AsyncMock()
mock_client.query = AsyncMock()
@@ -599,12 +587,13 @@ class TestClaudeAutoEngineerAnalyze:
mock_client.receive_response = mock_receive
- with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
- mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
- mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
+ with patch.object(eng, "_prompt_follow_up", new=AsyncMock(return_value=None)):
+ with patch("reverse_api.auto_engineer.ClaudeSDKClient") as mock_sdk:
+ mock_sdk.return_value.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_sdk.return_value.__aexit__ = AsyncMock(return_value=False)
- result = await eng.analyze_and_generate()
- assert result is not None
+ result = await eng.analyze_and_generate()
+ assert result is not None
@pytest.mark.asyncio
async def test_no_result_message_returns_none(self, tmp_path):
diff --git a/uv.lock b/uv.lock
index 7e5f382..0f2d713 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2082,7 +2082,7 @@ wheels = [
[[package]]
name = "reverse-api-engineer"
-version = "0.5.0"
+version = "0.6.0"
source = { editable = "." }
dependencies = [
{ name = "claude-agent-sdk" },