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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `--strict` flag on `agentcost analyze`: log parse failures exit non-zero instead of being reported as zero usage (#83)

### Fixed
- `budget set --quiet` (and `-q`) now suppresses per-period budget output while still saving the configured thresholds (#188)
- `ClaudeCodeParser`, `CodexParser`, `OpenCodeParser` and `HermesParser` no longer crash on UTF-16 or other non-UTF-8 logs: all five parsers now share one encoding-fallback reader, so one such file cannot abort a directory scan (#182)
- BOM-less UTF-16 logs (`utf-16-le` / `utf-16-be`) are now decoded by the shared encoding-fallback reader instead of being read as NUL-filled UTF-8 and silently yielding zero usages (#185)
- CI failure on Python 3.10 due to missing `tomllib` stdlib module (#26)
Expand Down
12 changes: 6 additions & 6 deletions src/agentcost/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,12 @@ def budget(action, daily, weekly, monthly, as_sarif, quiet=False):
save_budget_config(daily, weekly, monthly)
if not quiet:
console.print("[green]Budget thresholds saved to ~/.agentcost/config.toml[/green]")
if daily:
console.print(f" Daily: ${daily:.2f}")
if weekly:
console.print(f" Weekly: ${weekly:.2f}")
if monthly:
console.print(f" Monthly: ${monthly:.2f}")
if daily:
console.print(f" Daily: ${daily:.2f}")
if weekly:
console.print(f" Weekly: ${weekly:.2f}")
if monthly:
console.print(f" Monthly: ${monthly:.2f}")
elif action == "show":
config = load_budget_config()
if not config:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_quiet_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest

from agentcost.cli import cli
from agentcost.budget import load_budget_config


@pytest.fixture
Expand Down Expand Up @@ -106,3 +107,32 @@ def test_compare_quiet(sample_claude_log: Path):
data = json.loads(result.output)
assert isinstance(data, list)
assert len(data) > 0


@pytest.mark.parametrize("quiet_flag", ["--quiet", "-q"])
@pytest.mark.parametrize("thresholds", [
{"daily": 5.0},
{"daily": 5.0, "weekly": 25.0, "monthly": 100.0},
])
def test_budget_set_quiet(tmp_path, monkeypatch, quiet_flag, thresholds):
monkeypatch.setattr("agentcost.budget.CONFIG_DIR", tmp_path)
monkeypatch.setattr("agentcost.budget.CONFIG_FILE", tmp_path / "config.toml")
monkeypatch.chdir(tmp_path)
runner = CliRunner()
args = ["budget", "set"]
for period, amount in thresholds.items():
args.extend([f"--{period}", str(amount)])

normal = runner.invoke(cli, args)
assert normal.exit_code == 0
assert "Budget thresholds saved" in normal.output
for period, amount in thresholds.items():
assert f"{period.title()}: ${amount:.2f}" in normal.output
expected_config = (tmp_path / "config.toml").read_bytes()
(tmp_path / "config.toml").unlink()

quiet = runner.invoke(cli, args + [quiet_flag])
assert quiet.exit_code == normal.exit_code
assert quiet.output == ""
assert (tmp_path / "config.toml").read_bytes() == expected_config
assert load_budget_config() == thresholds
Loading