Repository navigation
v1.3.98
v1.3.98
Highlights
- Hooks system: Pre/post hooks for 5 lifecycle events (agent start/stop, stream start/stop, tool use) with command and HTTP types. Standardized JSON payload with HMAC signature support. Config validation with detailed error reporting.
- Context window indicator: Real-time visual indicator in the TUI composer showing context window usage with color-coded thresholds (green < 50%, orange 50–80%, red ≥ 80%).
- Friendly API error messages: Raw provider errors (401, 429, 5xx, network timeouts, context overflow) are now translated into human-readable messages with actionable advice.
- Cost tracking: New
/costslash command shows session token usage breakdown and estimated cost. Sidebar displays estimated cost or plan name for subscription users.
New Features
Hooks System
Five lifecycle events with command-based and HTTP-based hooks:
| Event | Trigger |
|---|---|
on_agent_start |
Before agent loop begins |
on_agent_stop |
After agent loop ends (success or failure) |
on_stream_start |
Before each streaming turn |
on_stream_stop |
After each streaming turn |
on_tool_use |
After any tool execution |
Each hook receives a standardized JSON payload via stdin with session info, event type, tool name, duration, and error details. HTTP hooks can verify authenticity via X-GGCode-Signature header (HMAC-SHA256).
Configuration in ggcode.yaml:
hooks:
on_agent_stop:
- type: command
command: ["notify-send", "ggcode agent finished"]
on_tool_use:
- type: http
url: https://hooks.example.com/ggcode
method: POST
secret: "${HOOK_SECRET}"See docs/guide/hooks.md for the complete guide.
Cost Tracking with Coding Plan Support
The /cost slash command shows session token usage with billing-type awareness:
- Per-token models: Shows estimated USD cost with input/output rates
- Subscription plans (GitHub Copilot, Z.ai Coding Plan, Kimi, Ark, Aliyun, MiniMax, Xiaomi MiMo): Shows "included in "
- Free models (e.g., GLM-4.5-Air): Shows "free tier"
- Unknown models: Honestly shows "no pricing data available" instead of fabricated prices
Coding plan detection works via endpoint name (IsCodingPlanEndpoint) and vendor type (IsSubscriptionVendor), matching the actual built-in endpoint configuration.
New Slash Commands
| Command | Description |
|---|---|
/cost |
Session token usage breakdown and estimated cost |
/diff |
View git diff in chat (supports --cached, --stat, <file>; 200-line truncation) |
/hooks |
View all configured hooks and validation status |
TUI Enhancements
- Context window indicator: Color-coded usage bar in the composer area
- Sidebar cost: Estimated cost (or plan name) displayed in the session usage panel
- Restructured
/help: Commands organized into 5 categories (Session & History, Model & Provider, Development, Integrations, System) with all new commands and shortcuts documented
Fixes
- Hooks config validation: Catches invalid hook configurations (empty commands, missing URLs, invalid events) at startup with detailed error messages
- HTTP context leak fix: HTTP hooks now properly cancel in-flight requests when the context is cancelled
- Pricing table non-deterministic match: Map iteration order could cause
gpt-4o-2024-08-06to matchgpt-4(rate $30/M) instead ofgpt-4o(rate $2.50/M). Fixed by selecting the longest matching prefix/suffix.
Internal
- Removed all hardcoded per-token prices from the pricing table (they were sourced from unreliable training data and contained outdated model names). The table now only contains billing-type information (subscription/per-token/free) verified from official pricing pages.
- Users can add custom per-token prices via
PricingTable.Merge(). ModelRatestruct extended withType(PricingType) andPlan(display name) fields.- New
IsMetered()andIsKnown()methods onModelRate. - 33 new tests for hooks dispatch, runner, validation, and payload serialization.
- 14 new tests for friendly error message pattern matching.
- 15 new tests for pricing table, subscription detection, and endpoint-based coding plan lookup.
Upgrade Notes
- Hooks are disabled by default. Configure them in
ggcode.yamlunder thehookskey. - Cost estimates for subscription plans show the plan name instead of dollar amounts.
- If you previously relied on per-token cost estimates for direct API models (Anthropic, OpenAI, etc.), you'll now see "no pricing data available". Configure custom rates via the pricing table API if needed.