Skip to content

Commit 002bca2

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: deduplicate CLAUDE_BINARY constant across _agent and _console_emitter
Both modules defined the same _CLAUDE_BINARY = "claude" constant independently. Promote to a single public CLAUDE_BINARY in _agent.py (the natural owner) and import it in _console_emitter.py. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent b29adc5 commit 002bca2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

β€Žsrc/ralphify/_agent.pyβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
_STDERR: OutputStream = "stderr"
5555

5656
# Agent binary name that supports --output-format stream-json.
57-
_CLAUDE_BINARY = "claude"
57+
# Public because _console_emitter also needs this for display logic.
58+
CLAUDE_BINARY = "claude"
5859

5960
# CLI flags appended when streaming mode is used.
6061
_OUTPUT_FORMAT_FLAG = "--output-format"
@@ -269,7 +270,7 @@ def _supports_stream_json(cmd: list[str]) -> bool:
269270
if not cmd:
270271
return False
271272
binary = Path(cmd[0]).stem
272-
return binary == _CLAUDE_BINARY
273+
return binary == CLAUDE_BINARY
273274

274275

275276
def _readline_pump(

β€Žsrc/ralphify/_console_emitter.pyβ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
RunStoppedData,
4141
)
4242
from ralphify import _brand
43+
from ralphify._agent import CLAUDE_BINARY
4344
from ralphify._output import format_duration
4445

4546
_ICON_SUCCESS = "βœ“"
@@ -94,8 +95,6 @@
9495

9596
# ── Claude binary detection ───────────────────────────────────────────
9697

97-
_CLAUDE_BINARY = "claude"
98-
9998

10099
def _is_claude_command(agent: str) -> bool:
101100
"""Return True if *agent* is a Claude Code command."""
@@ -105,7 +104,7 @@ def _is_claude_command(agent: str) -> bool:
105104
return False
106105
if not parts:
107106
return False
108-
return Path(parts[0]).stem == _CLAUDE_BINARY
107+
return Path(parts[0]).stem == CLAUDE_BINARY
109108

110109

111110
# ── Tool argument abbreviation ────────────────────────────────────────

0 commit comments

Comments
Β (0)