chore: hook scripts lint-clean (0.9.2)
Leftover working-tree edits from the 48e9242 session, committed
unchanged: BLE001 noqa with fail-soft comments, I001 import
order, explicit check=False on the estimator subprocess.run,
{e!s}. Behavior identical; both Vibe hook scripts now pass ruff
clean. PATCH bump to 0.9.2, plugin.yaml pin kept in lockstep.
130 tests pass.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -270,6 +270,21 @@ And add the cost information to this file for the current session.
|
||||
|
||||
---
|
||||
|
||||
#### (pending) - chore: hook scripts lint-clean; 0.9.2
|
||||
- **Date**: 2026-11-11
|
||||
- **Model**: mistral-vibe:zai-glm-5-3
|
||||
- **Session Cost**: $4.28 (running total at commit time)
|
||||
- **Turn Cost**: $0.07
|
||||
- **Total for commit**: $4.28
|
||||
- **Notes**: leftover working-tree edits from the 48e9242 session
|
||||
committed as-is: BLE001 noqa with fail-soft comments, I001 import
|
||||
order, explicit check=False on the estimator subprocess.run,
|
||||
{e!s} - behavior unchanged, both mistral-vibe-cli and
|
||||
mistral-vibe-code post_turn.py now pass ruff clean. PATCH bump
|
||||
to 0.9.2 (plugin.yaml pin kept in lockstep); 130 tests pass.
|
||||
|
||||
---
|
||||
|
||||
## Instructions for Contributors
|
||||
|
||||
1. Before committing, run `agent-cost-estimator` for your current session
|
||||
|
||||
Regular → Executable
+13
-8
@@ -46,11 +46,11 @@ multiple concurrent sessions.
|
||||
This hook is designed for: Mistral Vibe CLI (mistral-vibe)
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import subprocess
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Configure logging
|
||||
@@ -96,7 +96,9 @@ def get_session_dir() -> Path:
|
||||
|
||||
except json.JSONDecodeError as e:
|
||||
LOG.debug(f"No valid JSON payload: {e}")
|
||||
except Exception as e:
|
||||
# Fail soft by design: a payload-reading hiccup must never break
|
||||
# the turn; fall through to the default session directory.
|
||||
except Exception as e: # noqa: BLE001
|
||||
LOG.warning(f"Error reading payload: {e}")
|
||||
|
||||
# Default fallback
|
||||
@@ -129,12 +131,13 @@ def main():
|
||||
"--display-lines"
|
||||
]
|
||||
|
||||
# Run agent-cost-estimator
|
||||
# Run agent-cost-estimator; a nonzero exit is handled below
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30
|
||||
timeout=30,
|
||||
check=False,
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
@@ -156,10 +159,12 @@ def main():
|
||||
print(json.dumps({
|
||||
"system_message": "-- [cost: timeout]"
|
||||
}))
|
||||
except Exception as e:
|
||||
# Fail soft by design: any unexpected error still yields a
|
||||
# machine-readable system_message, never a broken turn.
|
||||
except Exception as e: # noqa: BLE001
|
||||
LOG.error(f"Unexpected error: {e}")
|
||||
print(json.dumps({
|
||||
"system_message": f"-- [cost: error - {str(e)}]"
|
||||
"system_message": f"-- [cost: error - {e!s}]"
|
||||
}))
|
||||
|
||||
|
||||
|
||||
Regular → Executable
+13
-8
@@ -49,11 +49,11 @@ multiple concurrent sessions.
|
||||
This hook is designed for: Mistral Vibe VSCodium Extension (mistralai.mistral-vibe-code)
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import subprocess
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Configure logging to stderr
|
||||
@@ -103,7 +103,9 @@ def get_session_dir() -> Path:
|
||||
|
||||
except json.JSONDecodeError as e:
|
||||
LOG.debug(f"No valid JSON payload: {e}")
|
||||
except Exception as e:
|
||||
# Fail soft by design: a payload-reading hiccup must never break
|
||||
# the turn; fall through to the default session directory.
|
||||
except Exception as e: # noqa: BLE001
|
||||
LOG.warning(f"Error reading payload: {e}")
|
||||
|
||||
# Default fallback
|
||||
@@ -136,12 +138,13 @@ def main():
|
||||
"--display-lines"
|
||||
]
|
||||
|
||||
# Run agent-cost-estimator
|
||||
# Run agent-cost-estimator; a nonzero exit is handled below
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30
|
||||
timeout=30,
|
||||
check=False,
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
@@ -163,11 +166,13 @@ def main():
|
||||
print(json.dumps({
|
||||
"system_message": "-- [cost: timeout]"
|
||||
}))
|
||||
except Exception as e:
|
||||
# Fail soft by design: any unexpected error still yields a
|
||||
# machine-readable system_message, never a broken turn.
|
||||
except Exception as e: # noqa: BLE001
|
||||
LOG.error(f"Unexpected error: {e}")
|
||||
# Return JSON to stdout (will be sent to vibe-acp stdin by wrapper)
|
||||
print(json.dumps({
|
||||
"system_message": f"-- [cost: error - {str(e)}]"
|
||||
"system_message": f"-- [cost: error - {e!s}]"
|
||||
}))
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: agent-cost-estimator
|
||||
version: 0.9.1
|
||||
version: 0.9.2
|
||||
description: "Print an estimated cost line plus session token line (provider:model | session:$X | turn:$Y, then -- I:X O:Y C:Z) after every assistant turn, recorded from Hermes session usage. Rendered through the shared display module for display parity with the CLI, GUI, and Vibe hooks."
|
||||
author: "nvaldez"
|
||||
provides_hooks:
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "agent-cost-estimator"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
description = "Report token usage and estimated USD cost of AI agent sessions from local harness logs"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
|
||||
Reference in New Issue
Block a user