# falconsw/cost-info architecture

> Architecture diagram of the GitHub repository falconsw/cost-info, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/falconsw/cost-info
- Repository: https://github.com/falconsw/cost-info

## Overview

Cost Info is a Claude Code plugin that tracks session cost and token usage, displays a live meter, reports spending on `/spend`, and warns when a configured budget is crossed. Its main workflow is Claude Code events updating plugin-held meter state, followed by footer or pane rendering and an on-demand report. When Claude Code supplies no plan limits, the plugin polls MiniMax or Z.ai and parses their quota responses. The excerpts show the central hook and provider parsers; they do not expose every event registration or rendering detail.

Main entry points: [`cost-info/hooks/register.tsx`](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx) (Meter hooks), [`cost-info/types/index.d.ts`](https://github.com/falconsw/cost-info/blob/main/cost-info/types/index.d.ts) (Meter state types), [`cost-info/hooks/minimax.ts`](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/minimax.ts) (MiniMax quota parser), [`cost-info/hooks/glm.ts`](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/glm.ts) (GLM quota parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_meter["Meter and UI"]
  node_register["Meter hooks<br/>[register.tsx]"]
  node_state["Meter state types<br/>[index.d.ts]"]
  node_display["Footer and pane<br/>[register.tsx]"]
  node_spend["Spend report<br/>[register.tsx]"]
end

subgraph group_providers["Plan providers"]
  node_minimax["MiniMax quota parser<br/>[minimax.ts]"]
  node_glm["GLM quota parser<br/>[glm.ts]"]
end

node_claude(("Claude Code"))
node_minimax_api{{"MiniMax API"}}
node_glm_api{{"Z.ai API"}}

node_claude -->|"delivers events"| node_register
node_register -->|"uses state shape"| node_state
node_register -->|"renders meter"| node_display
node_register -->|"handles command"| node_spend
node_register -->|"parses response"| node_minimax
node_register -->|"parses response"| node_glm
node_register -->|"fetches quota"| node_minimax_api
node_register -->|"fetches quota"| node_glm_api

click node_register "https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx"
click node_state "https://github.com/falconsw/cost-info/blob/main/cost-info/types/index.d.ts"
click node_display "https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx"
click node_spend "https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx"
click node_minimax "https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/minimax.ts"
click node_glm "https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/glm.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_register,node_state,node_display,node_spend toneBlue
class node_minimax,node_glm toneAmber
class node_claude toneIndigo
class node_minimax_api,node_glm_api toneMint
```

## Components

### Meter and UI

- [Meter hooks](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx): `cost-info/hooks/register.tsx`
- [Meter state types](https://github.com/falconsw/cost-info/blob/main/cost-info/types/index.d.ts): `cost-info/types/index.d.ts`
- [Footer and pane](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx): `cost-info/hooks/register.tsx`
- [Spend report](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/register.tsx): `cost-info/hooks/register.tsx`

### Plan providers

- [MiniMax quota parser](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/minimax.ts): `cost-info/hooks/minimax.ts`
- [GLM quota parser](https://github.com/falconsw/cost-info/blob/main/cost-info/hooks/glm.ts): `cost-info/hooks/glm.ts`

### Other components

- **Claude Code**
- **MiniMax API**
- **Z.ai API**

## Connections

- Claude Code → Meter hooks: delivers events (evidence: `README.md`)
- Meter hooks → Meter state types: uses state shape (evidence: `cost-info/types/index.d.ts`)
- Meter hooks → Footer and pane: renders meter (evidence: `cost-info/hooks/register.tsx`)
- Meter hooks → Spend report: handles command (evidence: `cost-info/hooks/register.tsx`)
- Meter hooks → MiniMax quota parser: parses response (evidence: `cost-info/hooks/register.tsx`)
- Meter hooks → GLM quota parser: parses response (evidence: `cost-info/hooks/register.tsx`)
- Meter hooks → MiniMax API: fetches quota (evidence: `cost-info/hooks/register.tsx`)
- Meter hooks → Z.ai API: fetches quota (evidence: `cost-info/hooks/register.tsx`)
