margin-cli 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
margin_cli/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """CLI application for margin."""
2
2
 
3
- __version__ = "0.1.2"
3
+ __version__ = "0.1.3"
margin_cli/main.py CHANGED
@@ -1,4 +1,4 @@
1
- """The ``agents`` command: list, inspect and run installed agents.
1
+ """The ``margin`` command: list, inspect and run installed agents.
2
2
 
3
3
  Output conventions: the report (or the ``--json`` listing) goes to stdout and nothing else
4
4
  does, so ``margin run ... --format json > report.json`` always produces valid JSON. Progress,
@@ -19,6 +19,7 @@ Exit codes:
19
19
  from __future__ import annotations
20
20
 
21
21
  import asyncio
22
+ import contextlib
22
23
  import json
23
24
  import logging
24
25
  import sys
@@ -190,6 +191,27 @@ def _render(result: AgentResult, fmt: ReportFormat) -> str:
190
191
  return to_json(result) + "\n" if fmt is ReportFormat.json else to_markdown(result)
191
192
 
192
193
 
194
+ def _write_stdout(text: str) -> None:
195
+ """Write ``text`` to stdout as UTF-8, even when redirected with cp1252 on Windows."""
196
+ stream = sys.stdout
197
+ if stream is None:
198
+ return
199
+ reconfigure = getattr(stream, "reconfigure", None)
200
+ if callable(reconfigure):
201
+ with contextlib.suppress(OSError, ValueError, AttributeError):
202
+ reconfigure(encoding="utf-8", errors="replace")
203
+ try:
204
+ stream.write(text)
205
+ stream.flush()
206
+ except UnicodeEncodeError:
207
+ buffer = getattr(stream, "buffer", None)
208
+ if buffer is None:
209
+ raise
210
+ stream.flush()
211
+ buffer.write(text.encode("utf-8", errors="replace"))
212
+ buffer.flush()
213
+
214
+
193
215
  def _exit_code(result: AgentResult | None, cancelled: bool, strict: bool) -> ExitCode:
194
216
  if cancelled or result is None:
195
217
  return ExitCode.CANCELLED
@@ -278,7 +300,7 @@ def run_agent(
278
300
  out.write_text(report, encoding="utf-8")
279
301
  stderr.print(f"Report written to {out}", highlight=False)
280
302
  else:
281
- typer.echo(report, nl=False)
303
+ _write_stdout(report)
282
304
  for warning in result.warnings:
283
305
  stderr.print(f"[yellow]Warning:[/] {escape(warning)}", highlight=False)
284
306
  if result.status == "error":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: margin-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: The `margin` command: list, inspect and run margin agents from the terminal.
5
5
  Project-URL: Homepage, https://github.com/Waddah0-0/margin
6
6
  Project-URL: Source, https://github.com/Waddah0-0/margin/tree/main/packages/cli
@@ -0,0 +1,10 @@
1
+ margin_cli/__init__.py,sha256=JAUDeYXTxvlQhwTHdVuavgg4QVgEQ0xdTPuTi5VPrsw,57
2
+ margin_cli/execution.py,sha256=0grI8Yu6n0BMx7N6mmekQg-aL0KN4kdcjPp71DqO8F8,10524
3
+ margin_cli/main.py,sha256=Mfk6Yr81CfdVFh0703HrKJlodMrOIN4DTbtelIR3IWM,10818
4
+ margin_cli/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
5
+ margin_cli/render.py,sha256=Ufd2zUwhR_TMDUsMfz7yv5VTfz96Ox4noVmKHp3ZmJw,2697
6
+ margin_cli-0.1.3.dist-info/METADATA,sha256=Umtqy3oYX2unZZ7CLEjYDvxN5-_2DTh0xA0huY1TT9Y,4092
7
+ margin_cli-0.1.3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
8
+ margin_cli-0.1.3.dist-info/entry_points.txt,sha256=cVKA3g5oAcVLuozKqPrhzxsTQI3v0eNoA_lAIUbpnNA,47
9
+ margin_cli-0.1.3.dist-info/licenses/LICENSE,sha256=7dCPJ4m91LD52BnTk6tiuMOiQU5i6aoIfpSzGgb9mVY,1076
10
+ margin_cli-0.1.3.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- margin_cli/__init__.py,sha256=7uBnHZScIUiEZtPduIeUmYTZxTTEEzVwRREF2cRF7LY,57
2
- margin_cli/execution.py,sha256=0grI8Yu6n0BMx7N6mmekQg-aL0KN4kdcjPp71DqO8F8,10524
3
- margin_cli/main.py,sha256=e9jaoXvTgeiMoyn8tqv_4eCqGFJd7Th24neXprbzbwk,10108
4
- margin_cli/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
5
- margin_cli/render.py,sha256=Ufd2zUwhR_TMDUsMfz7yv5VTfz96Ox4noVmKHp3ZmJw,2697
6
- margin_cli-0.1.2.dist-info/METADATA,sha256=9g50LSOFxCAobowTNNl7qDK1fizuMwoIvTTmMcPSi6w,4092
7
- margin_cli-0.1.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
8
- margin_cli-0.1.2.dist-info/entry_points.txt,sha256=cVKA3g5oAcVLuozKqPrhzxsTQI3v0eNoA_lAIUbpnNA,47
9
- margin_cli-0.1.2.dist-info/licenses/LICENSE,sha256=7dCPJ4m91LD52BnTk6tiuMOiQU5i6aoIfpSzGgb9mVY,1076
10
- margin_cli-0.1.2.dist-info/RECORD,,