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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: uv sync --all-groups

- name: Run type checker
run: uv run mypy src
run: uv run ty check src

test:
runs-on: ubuntu-latest
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ venv.bak/
# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

Expand Down
11 changes: 7 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ repos:
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
- repo: local
hooks:
- id: mypy
- id: ty
name: ty
entry: uv run ty check src
language: system
types: [python]
pass_filenames: false
stages: [pre-push]
additional_dependencies: [textual, claude-agent-sdk, pydantic, types-PyYAML]
8 changes: 1 addition & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
"editor.tabSize": 4,
"editor.insertSpaces": true,
"files.exclude": {
"**/.mypy_cache": true,
"**/.ruff_cache": true,
"**/.venv": true,
"**/__pycache__": true,
"**/agent_chat_cli.egg-info": true,
},
"mypy.dmypyExecutable": "${workspaceFolder}/.venv/bin/dmypy",
"mypy.runUsingActiveInterpreter": true,
"ruff.enable": true,
"ruff.lint.enable": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "basic",
"python.analysis.inlayHints.functionReturnTypes": false,
"python.analysis.inlayHints.variableTypes": false,
"python.languageServer": "None",

"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Rules

- Read `docs/architecture.md` for an architectural overview of the project. Refactors should always start here first.
- The project uses `uv`, `ruff` and `mypy`
- The project uses `uv`, `ruff` and `ty`
- Run commands should be prefixed with `uv`: `uv run ...`
- Use `asyncio` features, if such is needed
- Prefer early returns
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ test:
uv run pytest

type-check:
uv run mypy src
uv run ty check src
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Additional MCP servers are configured in `agent-chat-cli.config.yaml` and prompt

- Install pre-commit hooks via [pre-commit](https://pre-commit.com/)
- `uv run pre-commit install`
- Type-checking is via [MyPy](https://github.com/python/mypy):
- Type-checking is via [ty](https://github.com/astral-sh/ty):
- `make type-check`
- Linting and formatting is via [Ruff](https://docs.astral.sh/ruff/)
- `make lint`
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ requires-python = ">=3.14"
dependencies = [
"asyncio>=4.0.0",
"claude-agent-sdk>=0.1.10",
"mypy>=1.19.0",
"pydantic>=2.12.5",
"python-dotenv>=1.2.1",
"pyyaml>=6.0.3",
Expand All @@ -17,14 +16,13 @@ dependencies = [

[dependency-groups]
dev = [
"mypy>=1.19.0",
"pre-commit>=4.3.0",
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
"pytest-textual-snapshot>=1.0.0",
"ruff>=0.14.7",
"textual-dev>=1.8.0",
"types-pyyaml>=6.0.12.20250915",
"ty>=0.0.2",
]

[project.scripts]
Expand Down
5 changes: 3 additions & 2 deletions src/agent_chat_cli/core/agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from claude_agent_sdk.types import (
AssistantMessage,
Message,
StreamEvent,
SystemMessage,
TextBlock,
ToolUseBlock,
Expand Down Expand Up @@ -124,8 +125,8 @@ async def _handle_message(self, message: Message) -> None:
MCPServerStatus.update(message.data["mcp_servers"])

# Handle streaming messages
if hasattr(message, "event"):
event = message.event # type: ignore[attr-defined]
if isinstance(message, StreamEvent):
event = message.event

if event.get("type") == ContentType.CONTENT_BLOCK_DELTA.value:
delta = event.get("delta", {})
Expand Down
35 changes: 21 additions & 14 deletions tests/core/test_agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from claude_agent_sdk.types import (
AssistantMessage,
StreamEvent,
SystemMessage,
TextBlock,
ToolUseBlock,
Expand Down Expand Up @@ -141,14 +142,17 @@ class TestHandleMessageStreamEvent:
async def test_handles_text_delta_stream_event(self, mock_app, mock_config):
agent_loop = AgentLoop(app=mock_app)

message = MagicMock()
message.event = {
"type": ContentType.CONTENT_BLOCK_DELTA.value,
"delta": {
"type": ContentType.TEXT_DELTA.value,
"text": "Hello world",
message = StreamEvent(
uuid="test-uuid",
session_id="test-session",
event={
"type": ContentType.CONTENT_BLOCK_DELTA.value,
"delta": {
"type": ContentType.TEXT_DELTA.value,
"text": "Hello world",
},
},
}
)

await agent_loop._handle_message(message)

Expand All @@ -160,14 +164,17 @@ async def test_handles_text_delta_stream_event(self, mock_app, mock_config):
async def test_ignores_empty_text_delta(self, mock_app, mock_config):
agent_loop = AgentLoop(app=mock_app)

message = MagicMock()
message.event = {
"type": ContentType.CONTENT_BLOCK_DELTA.value,
"delta": {
"type": ContentType.TEXT_DELTA.value,
"text": "",
message = StreamEvent(
uuid="test-uuid",
session_id="test-session",
event={
"type": ContentType.CONTENT_BLOCK_DELTA.value,
"delta": {
"type": ContentType.TEXT_DELTA.value,
"text": "",
},
},
}
)

await agent_loop._handle_message(message)

Expand Down
Loading