Skip to content

Commit 6bb9e38

Browse files
committed
fix: exclude unneeded filed from sdist build
- LInt and fix examples/* - Switch to pdm.backend - Exclude .uv-cache and .github from sdist build Signed-off-by: Frost Ming <[email protected]>
1 parent 8556f0d commit 6bb9e38

File tree

10 files changed

+36
-39
lines changed

10 files changed

+36
-39
lines changed

examples/agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from typing import Any
44

55
from acp import (
6+
PROTOCOL_VERSION,
67
Agent,
7-
AgentSideConnection,
88
AuthenticateResponse,
99
InitializeResponse,
1010
LoadSessionResponse,
@@ -14,7 +14,6 @@
1414
run_agent,
1515
text_block,
1616
update_agent_message,
17-
PROTOCOL_VERSION,
1817
)
1918
from acp.interfaces import Client
2019
from acp.schema import (

examples/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
from typing import Any
99

1010
from acp import (
11+
PROTOCOL_VERSION,
1112
Client,
12-
connect_to_agent,
1313
RequestError,
14+
connect_to_agent,
1415
text_block,
15-
PROTOCOL_VERSION,
1616
)
1717
from acp.core import ClientSideConnection
1818
from acp.schema import (
@@ -154,8 +154,8 @@ async def interactive_loop(conn: ClientSideConnection, session_id: str) -> None:
154154
session_id=session_id,
155155
prompt=[text_block(line)],
156156
)
157-
except Exception as exc: # noqa: BLE001
158-
logging.error("Prompt failed: %s", exc)
157+
except Exception:
158+
logging.exception("Prompt failed")
159159

160160

161161
async def main(argv: list[str]) -> int:

examples/duet.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import sys
55
from pathlib import Path
66

7+
from acp import PROTOCOL_VERSION, spawn_agent_process
8+
79

810
def _load_client_module(path: Path):
911
spec = importlib.util.spec_from_file_location("examples_client", path)
@@ -15,10 +17,6 @@ def _load_client_module(path: Path):
1517
return module
1618

1719

18-
from acp import PROTOCOL_VERSION, spawn_agent_process
19-
from acp.schema import InitializeRequest, NewSessionRequest
20-
21-
2220
async def main() -> int:
2321
root = Path(__file__).resolve().parent
2422
agent_path = root / "agent.py"

examples/echo_agent.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from acp import (
66
Agent,
7-
AgentSideConnection,
87
InitializeResponse,
98
NewSessionResponse,
109
PromptResponse,

examples/gemini.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import os
99
import shutil
1010
import sys
11+
from collections.abc import Iterable
1112
from pathlib import Path
12-
from typing import Any, Iterable
13+
from typing import Any
1314

1415
from acp import (
15-
Client,
16-
connect_to_agent,
1716
PROTOCOL_VERSION,
17+
Client,
1818
RequestError,
19+
connect_to_agent,
1920
text_block,
2021
)
2122
from acp.core import ClientSideConnection
@@ -25,26 +26,22 @@
2526
AgentThoughtChunk,
2627
AllowedOutcome,
2728
AvailableCommandsUpdate,
28-
CancelNotification,
2929
ClientCapabilities,
30+
CreateTerminalResponse,
3031
CurrentModeUpdate,
32+
DeniedOutcome,
33+
EmbeddedResourceContentBlock,
3134
EnvVariable,
3235
FileEditToolCallContent,
3336
FileSystemCapability,
34-
CreateTerminalResponse,
35-
DeniedOutcome,
36-
EmbeddedResourceContentBlock,
3737
KillTerminalCommandResponse,
38-
InitializeRequest,
39-
NewSessionRequest,
4038
PermissionOption,
41-
PromptRequest,
4239
ReadTextFileResponse,
40+
ReleaseTerminalResponse,
4341
RequestPermissionResponse,
4442
ResourceContentBlock,
45-
ReleaseTerminalResponse,
46-
TerminalToolCallContent,
4743
TerminalOutputResponse,
44+
TerminalToolCallContent,
4845
TextContentBlock,
4946
ToolCall,
5047
ToolCallProgress,
@@ -115,7 +112,7 @@ async def read_text_file(
115112
text = _slice_text(text, line, limit)
116113
return ReadTextFileResponse(content=text)
117114

118-
async def session_update(
115+
async def session_update( # noqa: C901
119116
self,
120117
session_id: str,
121118
update: UserMessageChunk
@@ -259,7 +256,7 @@ async def interactive_loop(conn: ClientSideConnection, session_id: str) -> None:
259256
)
260257
except RequestError as err:
261258
_print_request_error("prompt", err)
262-
except Exception as exc: # noqa: BLE001
259+
except Exception as exc:
263260
print(f"Prompt failed: {exc}", file=sys.stderr)
264261

265262

@@ -275,7 +272,7 @@ def _resolve_gemini_cli(binary: str | None) -> str:
275272
raise FileNotFoundError("Unable to locate `gemini` CLI, provide --gemini path")
276273

277274

278-
async def run(argv: list[str]) -> int:
275+
async def run(argv: list[str]) -> int: # noqa: C901
279276
parser = argparse.ArgumentParser(description="Interact with the Gemini CLI over ACP.")
280277
parser.add_argument("--gemini", help="Path to the Gemini CLI binary")
281278
parser.add_argument("--model", help="Model identifier to pass to Gemini")
@@ -331,7 +328,7 @@ async def run(argv: list[str]) -> int:
331328
_print_request_error("initialize", err)
332329
await _shutdown(proc, conn)
333330
return 1
334-
except Exception as exc: # noqa: BLE001
331+
except Exception as exc:
335332
print(f"initialize error: {exc}", file=sys.stderr)
336333
await _shutdown(proc, conn)
337334
return 1
@@ -347,7 +344,7 @@ async def run(argv: list[str]) -> int:
347344
_print_request_error("new_session", err)
348345
await _shutdown(proc, conn)
349346
return 1
350-
except Exception as exc: # noqa: BLE001
347+
except Exception as exc:
351348
print(f"new_session error: {exc}", file=sys.stderr)
352349
await _shutdown(proc, conn)
353350
return 1

pyproject.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
name = "agent-client-protocol"
33
version = "0.6.3"
44
description = "A Python implement of Agent Client Protocol (ACP, by Zed Industries)"
5-
authors = [{ name = "Chojan Shang", email = "[email protected]" }]
5+
authors = [
6+
{ name = "Chojan Shang", email = "[email protected]" },
7+
{ name = "Frost Ming", email = "[email protected]" },
8+
]
69
readme = "README.md"
710
keywords = ['python']
811
requires-python = ">=3.10,<3.15"
@@ -18,7 +21,7 @@ classifiers = [
1821
"Topic :: Software Development :: Libraries :: Python Modules",
1922
]
2023
dependencies = [
21-
"pydantic>=2.7",
24+
"pydantic>=2.7",
2225
]
2326

2427

@@ -47,11 +50,11 @@ dev = [
4750
logfire = ["logfire>=0.14", "opentelemetry-sdk>=1.28.0"]
4851

4952
[build-system]
50-
requires = ["hatchling"]
51-
build-backend = "hatchling.build"
53+
requires = ["pdm-backend"]
54+
build-backend = "pdm.backend"
5255

53-
[tool.hatch.build.targets.wheel]
54-
packages = ["src/acp"]
56+
[tool.pdm.build]
57+
source-includes = ["examples/", "tests/"]
5558

5659
[tool.ty.environment]
5760
python = "./.venv"
@@ -103,11 +106,12 @@ ignore = [
103106
"E501",
104107
# DoNotAssignLambda
105108
"E731",
109+
# Long exception message
110+
"TRY003",
106111
]
107112

108113
[tool.ruff.lint.per-file-ignores]
109114
"tests/*" = ["S101"]
110-
"examples/*" = ["ALL"]
111115
"src/acp/meta.py" = ["ALL"]
112116
"src/acp/schema.py" = ["ALL"]
113117

scripts/gen_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def fetch_json(url: str) -> dict:
129129
with urllib.request.urlopen(url) as response: # noqa: S310 - trusted source configured by repo
130130
return json.loads(response.read().decode("utf-8"))
131131
except urllib.error.URLError as exc:
132-
raise RuntimeError(f"Failed to fetch {url}: {exc}") from exc # noqa: TRY003
132+
raise RuntimeError(f"Failed to fetch {url}: {exc}") from exc
133133

134134

135135
def _cached_ref() -> str | None:

scripts/gen_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def generate_meta() -> None:
1717
meta_json = SCHEMA_DIR / "meta.json"
1818
out_py = ROOT / "src" / "acp" / "meta.py"
1919
if not meta_json.exists():
20-
raise SystemExit("schema/meta.json not found. Run gen_schema.py first.") # noqa: TRY003
20+
raise SystemExit("schema/meta.json not found. Run gen_schema.py first.")
2121

2222
data = json.loads(meta_json.read_text("utf-8"))
2323
agent_methods = data.get("agentMethods", {})

scripts/gen_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def generate_schema() -> None:
164164

165165
def postprocess_generated_schema(output_path: Path) -> list[str]:
166166
if not output_path.exists():
167-
raise RuntimeError(f"Generated schema not found at {output_path}") # noqa: TRY003
167+
raise RuntimeError(f"Generated schema not found at {output_path}")
168168

169169
raw_content = output_path.read_text(encoding="utf-8")
170170
header_block = _build_header_block()

src/acp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ def __getattr__(name: str) -> Any:
178178
module_name, attr_name = new_path.split(":")
179179
module = import_module(module_name)
180180
return getattr(module, attr_name)
181-
raise AttributeError(f"module {__name__} has no attribute {name}") # noqa: TRY003
181+
raise AttributeError(f"module {__name__} has no attribute {name}")

0 commit comments

Comments
 (0)