89 Commits

Author SHA1 Message Date
nvaldez b68eaf7284 SPEC: add user configurable pricing files specification
Add section 6.2 to Configuration Files documenting:
- User-configurable pricing files in platform-specific directories
- Windows: %APPDATA%\agent-cost-estimator\price.json and custom-price.json
- Linux/macOS: /agent-cost-estimator/ or ~/.config/agent-cost-estimator/
- price.json initialized from repo version on first run
- custom-price.json created as blank template for user editing
- App reads both files with custom-price.json taking priority for duplicates
- Marked as Not Implemented

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-03 16:15:01 +01:00
nvaldez f2129b976d fix: backup _internal directory when patching VSCodium extension
The VSCodium extension's vibe-acp binary depends on Python 3.12 runtime
libraries in the _internal/ directory (specifically libpython3.12.so.1.0).
The previous patching logic only copied the vibe-acp binary to the backup
 directory, but not the _internal/ directory, causing the binary to fail
with 'cannot open shared object file' errors.

This change ensures the _internal/ directory is also backed up, allowing
the patched vibe-acp wrapper to successfully execute the original binary.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-03 16:13:44 +01:00
nvaldez 378b0ae3e1 fix: replace deprecated universal_newlines with text in VSCodium wrapper
The universal_newlines parameter is deprecated in Python 3.13, causing
exit code 255 errors in VSCodium extension when the wrapper tries to
start the patched vibe-acp binary.

This change fixes the VSCodium integration to work properly with
Python 3.13+ by using the recommended text=True parameter instead.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-03 16:04:40 +01:00
user e65575ab8e fix: Re-implement VSCodium integration with watchdog + stdin injection
The simple VIBE_HOME approach doesn't work because:
1. Vibe core in vibe-acp DOES auto-trigger hooks when VIBE_HOME is set
2. But hooks writing to stdout/err break the ACP protocol

Solution: Use a Python wrapper that:
- Sets VIBE_HOME (for hook configuration discovery)
- Monitors journal files for turn completions
- Runs hooks and injects their output into vibe-acp's stdin
- This way, hook output becomes part of the ACP communication

Hook changes:
- Output JSON to stdout (for stdin injection)
- Wrapper captures this and sends to vibe-acp stdin

This ensures costs are displayed in the VSCodium chat UI.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 18:42:51 +01:00
user f6614c8618 Revert cli.py to simple VIBE_HOME approach
The watchdog-based Python wrapper was causing issues. This reverts to the
simple approach from commit 434589e which just sets VIBE_HOME and lets
the Vibe core auto-trigger hooks.

The key fix is in the hook itself (commit 901dbca) which writes to stderr
instead of stdout to avoid breaking the ACP protocol.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 18:34:11 +01:00
user 901dbca119 fix: Make VSCodium hook write to stderr to avoid breaking ACP protocol
The Vibe core in vibe-acp (ACP mode) automatically triggers hooks when
VIBE_HOME is set. However, hooks that write to stdout will break the ACP
protocol that vibe-acp uses to communicate with VSCodium.

This fix modifies the VSCodium hook (mistral-vibe-code/post_turn.py) to:
- Write all output to stderr instead of stdout
- VSCodium will still display stderr output in the UI
- This avoids corrupting the ACP communication channel

The simpler approach:
1. Set VIBE_HOME environment variable (via shell wrapper)
2. Let Vibe core auto-trigger hooks
3. Hooks write to stderr (not stdout)

This is simpler and more reliable than the watchdog-based approach.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 18:33:04 +01:00
user eb8d85214f fix: Re-implement VSCodium hooks patch with watchdog-based monitoring
The previous commit (434589e) attempted to simplify the VSCodium integration
by just setting VIBE_HOME, assuming vibe-acp would automatically trigger hooks.
However, this approach doesn't work because:

1. The Vibe core in vibe-acp (ACP mode) does NOT automatically trigger hooks
2. Hooks write to stdout, which breaks the ACP protocol

This commit reverts to the watchdog-based approach from commit 89c615d but
improves it by:
- Using a Python wrapper instead of a shell script
- Monitoring journal files for turn completions
- Running hooks and writing output to vibe-acp's stdin (not stdout)
- Gracefully handling missing watchdog dependency
- Maintaining backward compatibility

The Python wrapper:
- Uses watchdog to monitor ~/.vibe/logs/session/unified/ for journal file changes
- When a journal file is created/modified, it identifies the session
- Runs all configured post_agent hooks for that session
- Writes hook output to vibe-acp's stdin to avoid breaking ACP protocol

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 18:11:57 +01:00
user 434589e1db fix: Simplify VSCodium hooks patch to use VIBE_HOME environment variable
The Vibe core in vibe-acp automatically loads hooks from $VIBE_HOME/hooks/
when VIBE_HOME is set. This is a much simpler approach than the previous
watchdog-based monitoring.

The wrapper now:
1. Sets VIBE_HOME to ~/.vibe
2. Executes the original vibe-acp binary

The original binary and its _internal directory are backed up to _backup/
to ensure PyInstaller runtime files are preserved.

The Vibe core will then automatically execute post_agent hooks after each
assistant turn, displaying the cost tracker.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 18:05:42 +01:00
nvaldez 8be245c2f9 Merge branch 'main' of https://gitea.nolivaldeziii.com/nvaldez/agent-cost-estimator 2026-10-25 16:59:41 +01:00
user 89c615d908 fix: send VSCodium hook output to vibe-acp stdin for proper integration
The VSCodium extension uses vibe-acp which communicates with the Vibe core via
stdin/stdout. The Vibe core in the extension does NOT automatically trigger
hhooks, so we need to monitor journal files and inject hook messages.

This fix:
- Uses subprocess.Popen to keep vibe-acp's stdin pipe open
- Writes hook output directly to vibe-acp's stdin
- Allows the Vibe core to process and display hook messages properly
- Avoids breaking the ACP protocol

The hook output format (system_message JSON) is recognized by the Vibe core,
which displays it as the last line in the chat after each assistant turn.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:58:41 +01:00
nvaldez 80a56ae26c fix: never silently drop the cost line + diagnosable publish path (0.4.4)
The 0.4.3 detached-thread publish could lose the line with no
trace: any failure inside _publish_notification (owner lookup
import error, session not live, missing event stream, publish
exception) returned quietly and the detached thread exited.

- every daemon-path failure now falls back to print() AND logs a
  WARNING/INFO tagged [cost], so a regression is diagnosable
  from the daemon's logs (grep '\[cost\]' in
  ~/.hermes/logs/errors.log) instead of a missing line
- session-not-live now falls back (was: silent skip)
- stream lookup is defensive (no event stream -> print + warn)
- success path logs INFO '[cost] published notification'
- 57/57 tests pass; version 0.4.4 (package + manifest)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
nvaldez 3f8eca4dd8 pricing: replace placeholder rates with official Mistral and Z.ai published rates
- Mistral: real per-model rates from docs.mistral.ai/inference/pricing
  (mistral-small-4 0.15/0.015/0.6, mistral-large-3 0.5/0.05/1.5,
  mistral-large-4 1.36/0.14/4.18, ministral-3 family, codestral,
  notes and sources normalized)
- Z.ai: GLM 5.3 real rates from docs.z.ai (zai-glm-5-3
  1.4/0.14/4.4 replacing the placeholder at Vibe default rates,
  glm-5.3-flash, glm-5.3-flashx, plus a zai default entry)
- pricing.json validates; 57/57 tests pass

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
nvaldez 846204d9fb fix: cost line ordering (publish after the response) + billing-route provider label
Ordering: post_llm_call fires in the agent worker thread before
the gateway settles the turn and publishes message.complete, so
an immediate notification.show lands ABOVE the response. The
publish now waits (bounded 60s, detached daemon thread so the
timeout-bounded hook returns instantly) until the session's
execution stamp clears - the settlement clears it strictly
after message.complete - making the cost line the LAST line of
every turn. Same hold pattern as the gateway's background-review
delivery.

Label: the line showed the pricing-table match (zai:zai-glm-5-3)
even when the session bills through a custom provider route.
The label now comes from the billing route: the config.yaml
custom_providers name matching the session's billing_base_url
(hermes_cli.config.load_config first, regex fallback for
standalone), else the stored billing_provider when not
generic, else the pricing key. A session served by the custom
provider 'mistral' now shows mistral:zai-glm-5-3.

Also: restore the zai provider in the bundled pricing.json
(dropped by an uncommitted local edit; plugin-local lookup made
the loss visible as default:default).

- tests: completion-stamp wait, billing-route label, execution
  stamp on the notification mock
- version 0.4.3 (package + plugin manifest)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
nvaldez 3817ca2118 fix: publish Hermes cost line via notification.show in the gateway daemon
CLI chat sessions run inside the long-lived hermes gateway
daemon, whose stdout is a socket - print() from the plugin never
reaches the user's terminal. The CLI client renders
notification.show events from the session's event stream (the
same seam the credits tracker and /login notices use), so:

- _publish_cost_line: resolve the daemon's session authority
  (gateway.session_cron.owner_for_home; same-process pid check
  makes this a no-op outside the daemon), publish a
  notification.show on the live session's event stream
  (text/level/kind/key payload, thread-safe publish)
- fall back to print() when no authority (in-process CLI runs)
- tests: daemon publish (mocked authority) + in-process fallback
- version 0.4.2 (package + plugin manifest)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
nvaldez e3c9c54844 fix: print cost line for gateway local sessions (platform=local)
Interactive CLI chat in current Hermes builds runs through the
gateway's local adapter, so post_llm_call receives
platform == 'local', not 'cli'. The print gate now accepts both
(ledger records confirmed the plugin loaded and recorded; only
the print was gated off).

- PRINT_PLATFORMS = {'cli', 'local'} in the plugin
- regression test: test_plugin_prints_for_local_platform
- SPEC.md print-gating section updated
- version 0.4.1 (package + plugin manifest)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
nvaldez 9cc95dc793 feat: add Hermes Agent support (harness adapter, plugin, installer)
- harnesses/hermes.py: Hermes adapter reading state.db
  (session_model_usage cumulative counters) for authoritative
  session totals plus the plugin's JSONL ledger for per-turn
  breakdowns; Hermes's disjoint CanonicalUsage buckets are folded
  into the tool's inclusive (Vibe-style) contract
- integration/hermes/plugin: Hermes plugin (plugin.yaml +
  register(ctx)) wiring pre_llm_call (turn labels),
  post_api_request + post_auxiliary_call (per-call ledger,
  queue + drainer, no hook-path I/O), post_llm_call
  (cost line after every interactive CLI turn; silent for
  subagents/cron/one-shot)
- integration/hermes/install.py: standalone idempotent installer
  (validates the home, copies the plugin + pricing.json, runs
  hermes plugins enable); also wired as
  agent-cost-estimator --integrate hermes / --rm-integrate hermes
- pricing: plugin-local pricing.json first (stdlib-only reader),
  then the package table, then default rates
- tests: 22 new (52 total) covering adapter, plugin, installer
- docs: SPEC.md 1.1.0 (sections 5.2.1, 7.3), SKILL.md, wiki entity

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:40 +01:00
user 7500045acd fix: send VSCodium hook output to vibe-acp stdin to integrate with Vibe core
The VSCodium extension uses vibe-acp which communicates with the Vibe core via
stdin/stdout. Hook messages need to be sent to vibe-acp's stdin so the Vibe core
can process and display them properly.

This fix uses subprocess.Popen to keep the stdin pipe open and writes hook
output directly to vibe-acp's stdin, allowing the Vibe core to handle system
messages without breaking the ACP protocol.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:57:30 +01:00
user 68bd0c57f1 fix: send VSCodium hook output to stderr to avoid ACP protocol interference
The VSCodium extension uses JSON-RPC over stdout for ACP communication with
vibe-acp. Printing hook output to stdout corrupts this protocol, causing
the extension to fail during initialization.

This change sends hook output to stderr instead, allowing the Vibe core to
receive clean ACP messages on stdout while the extension can still display
hook messages to the user.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-25 16:50:51 +01:00
nvaldez 1e85c9b895 feat: add Vibe VSCodium extension support with modular hooks
- Add support for Mistral Vibe VSCodium extension (mistral-vibe-code)
- Restructure hooks into modular directories (mistral-vibe-cli/, mistral-vibe-code/)
- Enhance model detection with fallback to global config.toml
- Add --rm-integrate command to remove hooks integration
- Add VSCodium extension patching for hooks support
- Add hooks/README.md documentation
- Update SPEC.md with VSCodium configuration details
- Bump version to 0.3.0

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 13:59:31 +02:00
user d9816be4a4 Update AGENTS.md: require version bump for any code change
- Clarify that version MUST be bumped for ANY code change
- Specify semantic versioning guidelines
- Emphasize bumping BEFORE committing

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 03:07:07 +02:00
user 1924f4dcc3 Add source and date fields to pricing.json models
- Each model now includes:
  - source: Where the pricing data came from
  - date: When the pricing was last updated
- Helps track pricing provenance and currency
- All tests still pass

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 03:03:13 +02:00
user e6fd268db6 Add AGENTS.md and ai-usage-cost.md for cost tracking
- AGENTS.md: Instructions for AI agents working on this project
- .vibe/ai-usage-cost.md: Template for tracking AI usage costs per commit
- Includes workflow, architecture principles, and cost tracking requirements

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 03:00:21 +02:00
user 156f488716 Restructure SPEC.md: separate harness-specific configs from general configs
- Moved Vibe CLI specific hook files (post_turn.py, hooks.toml) to new Section 7
- Created Section 7: Harness-Specific Configurations
- Updated TOC to reflect new structure
- Section 6 now only contains general configuration (pricing.json)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:50:44 +02:00
user 17239e26b3 Add comprehensive SPEC.md for project recreation
- Document architecture, data flow, and module structure
- Define harness adapter interface contract
- Specify pricing table format (provider-based)
- Document hook integration requirements
- List all feature requirements and configuration files
- Include glossary, examples, and file index

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:45:45 +02:00
user d6f37c3be5 Bump version to 0.2.1
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:33:53 +02:00
user b726ca28dd Prioritize active_model over model_name for pricing lookup
- Swapped parameter order in effective_rates() to pass alias (active_model) as model_name
- This ensures the actual running model is displayed in hook output
- Updated docstring to clarify the new priority order
- All 30 tests still pass

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:31:13 +02:00
user fb2ceaedf0 Bump version to 0.2.0
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:24:07 +02:00
user 4d13fa08fd Make --integrate command require explicit harness argument
- Changed --integrate from flag to argument that requires a harness name
- Currently supports 'mistral' harness (Vibe CLI)
- Renamed integrate_vibe_hooks() to integrate_hooks() for modularity
- Added validation for supported harnesses
- Added tests for --integrate command validation
- Modular design allows adding more harnesses in the future

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:17:12 +02:00
user 974aea129e Add warning when model price is not available in pricing.json
- Modified get_model_prices() in pricing.py to return is_default flag
- Updated CLI to display warning in all output modes (default, details, JSON)
- Warning format: '**model price not available**' on new line
- Updated all tests to handle 4-tuple return value
- Works with refactored provider-based pricing structure

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:14:59 +02:00
user 27a7200bc3 Update documentation for --integrate command
- Updated README.md with --integrate usage
- Updated SKILL.md with --integrate documentation

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:05:18 +02:00
user 6feecdaa12 Add --integrate command for automatic Vibe hook installation
- New command: agent-cost-estimator --integrate
- Installs post_turn.py hook script to ~/.vibe/hooks/
- Creates/updates ~/.vibe/hooks.toml with hook configuration
- Adds agent-cost-estimator to Vibe's bash allowlist in config.toml
- Hook script bundled in agent_cost_estimator/hooks/ package
- Works on all machines (portable installation)
- Added hooks package to pyproject.toml

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:04:29 +02:00
user ecafb961c1 Update CLI output to show provider:model in all display modes
- Default output: provider:model | session:$X | turn:$Y
- Details (-d): shows provider:model as 'model' field
- JSON (--json): adds 'provider' and 'provider_model' fields
- Updated test to expect new default output format

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:03:06 +02:00
user 443f88a32b Clean up pricing.json to provider-only structure
- Remove root-level currency and models (flat structure)
- Keep only providers dictionary with nested currency and models
- Add default provider as fallback
- Add mistral-vibe-cli-latest model to mistral provider
- Simplify pricing.py to remove backward compatibility code
- Update tests to use provider-based structure

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 02:00:20 +02:00
user 79300bdb13 Refactor pricing.json to support multiple providers
- Add 'providers' top-level dictionary with provider-specific configurations
- Each provider has its own 'currency' and 'models' dictionary
- Model-level currency can override provider currency
- Maintain backward compatibility with flat structure (currency + models at root)
- Update pricing.py to handle both structures with provider-aware lookup
- Update get_model_prices() to return (rates, key, currency) tuple
- Update CLI to display currency and provider-prefixed model keys
- Update tests to handle new return signature

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-24 01:52:20 +02:00
nvaldez 27fb34dd78 Fix pyproject.toml: replace invalid package-data syntax with include-package-data
The original package-data configuration used invalid TOML syntax with
empty string and wildcard keys that are not supported by setuptools.
This caused pip install to fail with TOMLDecodeError.

Changed to use include-package-data = true which automatically includes
all non-Python files in the package directories (pricing.json, SKILL.md).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-23 23:03:47 +02:00
nvaldez c38579fb1e Add --local and --no-env options to bootstrap scripts
- Add --no-env flag to skip virtual environment creation
- Add --local flag to install with --user (user-local installation)
- Update both bash and PowerShell scripts

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-21 23:55:53 +02:00
nvaldez 59c7fd73da Add bootstrap scripts for local pip install
- Add bash bootstrap script for Linux/macOS
- Add PowerShell bootstrap.ps1 for Windows
- Update pyproject.toml with dev dependencies (pytest, pytest-cov)
- Update license to GPL-3.0-only
- Add pytest configuration

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-21 23:53:29 +02:00
nvaldez a3b12291cb Change license from MIT to GNU GPL v3
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-21 23:18:37 +02:00
nvaldez b3d581d21a Initial commit: agent-cost-estimator 0.1.0
- Python CLI tool to report token usage and estimated USD cost
- Supports Mistral Vibe harness with pluggable adapter interface
- Includes SKILL.md in skill/ directory for LLM consumption via --skill flag
- Full test suite (28 tests)
- Typical Python project structure with .gitignore, .gitattributes, LICENSE, README.md
- Build script for PyPI distribution

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-10-21 23:12:07 +02:00