ouchbill 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,14 +1,34 @@
1
1
  Copyright (c) 2026 Drevan. All rights reserved.
2
2
 
3
+ OuchBill free-use licence, version 1 (2026-12-06)
4
+
3
5
  This software, including its source code, its built bundles (dist/) and its data tables,
4
- is proprietary to Drevan and is not open source.
6
+ is proprietary to Drevan and is not open source. Drevan gives you the rights below. Everything
7
+ not given here is reserved.
8
+
9
+ 1. What you may do, free of charge:
10
+ - install and run this software, on any number of machines, for any purpose, including
11
+ commercial work, client work and continuous integration (CI) systems;
12
+ - use, share and publish the output it produces (reports, findings, badges), including
13
+ inside your own products and documents.
14
+
15
+ 2. What you may not do without Drevan's written agreement:
16
+ - copy, modify, merge, translate or make works derived from the software;
17
+ - publish, redistribute, sublicense, sell or rent the software, in whole or in part, except
18
+ by pointing people to the official package;
19
+ - reverse engineer, decompile or de-minify it, or try to recover its source code, except
20
+ where the law allows this and cannot be limited by contract;
21
+ - extract its data tables to build or feed another product or service;
22
+ - remove or change this licence or the copyright notices.
5
23
 
6
- No licence is granted to copy, modify, merge, publish, distribute, sublicense or sell this
7
- software, in whole or in part, or to make works derived from it, except as Drevan agrees in
8
- writing. Running a copy that Drevan provided to you is permitted only on the terms under
9
- which Drevan provided it.
24
+ 3. Drevan may stop offering the software or change these terms for later versions. A version
25
+ you already received stays under the terms it came with.
10
26
 
11
- Third-party components that are bundled into dist/ keep their own licences. Their notices
12
- are in dist/THIRD_PARTY_NOTICES.txt.
27
+ 4. Third-party components that are bundled into dist/ keep their own licences. Their notices
28
+ are in dist/THIRD_PARTY_NOTICES.txt.
13
29
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
30
+ 5. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ IMPLIED, INCLUDING FITNESS FOR A PARTICULAR PURPOSE. To the extent the law allows, Drevan
32
+ is not liable for any damages arising from its use, including costs from API keys,
33
+ provider bills or missed deadlines the software did or did not report. Checking your
34
+ providers' own dashboards remains your responsibility.
package/README.md CHANGED
@@ -1,253 +1,225 @@
1
- # ouchbill
2
-
3
- A local check you run before you ship. It tells you what in a project will break, and what could
4
- cost you money:
5
-
6
- 1. **What will break, and when.** AI model ids in your code that the provider retires, with file,
7
- line, date, days left, the provider's suggested replacement and its source page. The same check
8
- covers runtimes, frameworks, databases, serverless runtimes and GitHub Actions versions that reach
9
- end of life.
10
- 2. **Is a key sitting in the repo or the build output?** The same key patterns as the
11
- OuchBill site scanner, with masked output.
12
- 3. **Which usage-billed services does this project use, and does each provider offer a hard
13
- spending cap?** Read from dependency manifests, env var *names* and infrastructure files.
14
-
15
- Findings are ranked critical, high, medium, low or unknown, and each has fix steps. The default run
16
- makes no network calls.
17
-
18
- It exits 1 when it finds a key, or (with `--fail-on-uncapped`) when the project uses a service with
19
- no cap declared, so it can fail a CI build.
20
-
21
- ```
22
- npx ouchbill check [dir] # services + cap status + key scan
23
- npx ouchbill scan [path] # key scan only (files or build output)
24
- npx ouchbill providers # provider ids the catalog knows
25
- ```
26
-
27
- ## Privacy: no network by default
28
-
29
- - **No network calls by default.** ouchbill reads files on disk and prints a result. Without
30
- `--fresh` or `--online` it does not call any provider, any OuchBill server or any analytics
31
- service. A test replaces every way Node can reach the network (fetch, http, https, http2, net,
32
- tls, dns, dgram) and every way to start a process, runs every command on every fixture, and fails
33
- on a single call. Another test checks that `dist/ouchbill.mjs` imports only `node:fs`, `node:path`
34
- and, behind those two flags, the separate `dist/ouchbill-online.mjs`. A third puts a booby-trapped
35
- copy of that file next to the bundle and proves default commands never load it.
36
- - **`--fresh` contacts ouchbill.com only.** It requests the signed date tables and sends no code,
37
- paths or file names. The host sees your IP address and a `User-Agent` of `ouchbill/<version>`.
38
- It needs a free data feed key in the `OUCHBILL_TABLE_KEY` environment variable (ouchbill.com, Settings),
39
- sent only as `Authorization: Bearer` to `https://ouchbill.com/api/table`, never read from repo files and
40
- never printed. Without a key no request is made and the bundled tables are used, with a line saying how
41
- to get one; a refused key (401/403) also falls back. Watermark rows in the served table are dropped
42
- before scanning. Verified tables are cached in your OS user cache folder under `ouchbill`. **Until the production
43
- signing key and site are live, `--fresh` uses the bundled data** and says so.
44
- - **`--online` contacts the listed hosts and rdap.org.** It prints every hostname before connecting,
45
- does a TLS handshake on port 443 with up to 10 production hostnames found in the repo, and looks up
46
- their domains through rdap.org, which redirects to the domain's registry. Those parties learn that
47
- this machine asked about those names. IP addresses, localhost, private names and names that resolve
48
- to a private address are refused.
49
- - **No telemetry.** None, opt-in or otherwise.
50
- - **Env var names only.** ouchbill reads the part before `=` in `.env.example` and similar files,
51
- and names like `process.env.OPENAI_API_KEY` in code. It never opens `.env`, `.env.local`,
52
- `.envrc` or any other local env file: they hold real values by design. The report lists them so
53
- you can check they are git-ignored. From your shell it only checks whether `ANTHROPIC_API_KEY` is
54
- set (see below), never what it is.
55
- - **Masked keys only.** A found key is printed as its prefix and last four characters
56
- (`sk-proj-…a1B2`). The full value is never printed, logged or written to JSON. ouchbill never tests a found key against its provider.
57
-
58
- ## What it prints
59
-
60
- ```
61
- SERVICE DETECTED BY HARD CAP OFFERED (catalog) YOUR CAP WHERE TO SET IT
62
- OpenAI API env OPENAI_API_KEY, npm openai yes (verified 2026-11-03) not declared https://platform.openai.com/settings/organization/limits
63
- Microsoft Azure terraform provider "azurerm" no (verified 2026-11-03) not declared https://portal.azure.com/
64
- Cloudflare npm wrangler unknown: no confirmed cap not declared https://dash.cloudflare.com/
65
- ```
66
-
67
- - **Hard cap offered** comes from the OuchBill provider catalog, with the date the fact was read on
68
- the provider's own docs. `unknown` means nobody has confirmed the provider's limit stops spending.
69
- It is shown as "no confirmed cap", never as "fine", and it never counts as capped.
70
- - **Your cap** is what your project has declared in `.ouchbill.json`. ouchbill cannot see your
71
- provider consoles, so "offered" never means "on".
72
- - ouchbill never says your bill is safe. It tells you what is declared on, what has no cap, what
73
- is unknown and where to fix it.
74
-
75
- ## Declaring your caps: `.ouchbill.json`
76
-
77
- ```json
78
- {
79
- "caps": {
80
- "openai": { "status": "on", "checkedOn": "2026-11-15", "note": "org limit + project limits" },
81
- "azure": { "status": "accepted", "reason": "PAYG has no hard cap; budget alerts at 50/80/100%" }
82
- },
83
- "exclude": ["test/fixtures"]
84
- }
85
- ```
86
-
87
- - `"on"` needs `checkedOn`: the date someone looked at the provider's setting.
88
- - `"accepted"` needs a `reason`: you know there is no hard cap and chose to run without one.
89
- - `"on"` counts only where the catalog confirms the provider has a stop (`yes` or `partial`).
90
- Where the catalog says **no** hard cap, or the cap is **unknown**, `"on"` is reported as
91
- "declared, not counted" and still fails `--fail-on-uncapped`. Budgets that only send alerts are
92
- not caps. If you accept running without a confirmed cap, say so with `"accepted"` and a reason.
93
- - Provider ids come from `ouchbill providers`. An unknown id is an error, so a typo can't pass CI.
94
- - A config file that contains anything key-shaped is refused (exit 2).
95
-
96
- ## Exit codes
97
-
98
- | Code | Meaning |
99
- |---|---|
100
- | 0 | Nothing failing found |
101
- | 1 | A key-shaped value was found, or `--fail-on-uncapped` is set and a detected service has no confirmed cap declared (unknown never counts) and no accepted reason |
102
- | 2 | Bad arguments, a missing path, or an invalid `.ouchbill.json` |
103
-
104
- ## Options
105
-
106
- | Option | |
107
- |---|---|
108
- | `--json` | Print the result as JSON (`schemaVersion: 1`). The test suite holds the shape to a strict schema. |
109
- | `--fail-on-uncapped` | Exit 1 when a detected service has no cap declared on or accepted. |
110
- | `--fresh` | `check` only. Use the latest signed date tables (contacts ouchbill.com only). Output states the source (live, cache or bundled), data date and any warning. A failed refresh falls back and never changes the exit code by itself. |
111
- | `--online` | `check` only. Add TLS certificate and domain expiry for up to 10 repo hostnames (contacts those hosts and rdap.org). Uses the same severity dates. A failed check is shown as unknown, never as fine. |
112
- | `--fail-on-severity=L` | `check` only. Exit 1 when a security pack finding (key, browser-exposed key, agent or MCP config, GitHub Actions, prompt-injection sink) is at severity L or above: `critical`, `high`, or `none` (default: pack findings never fail the run). |
113
- | `--fail-on-expiry[=N]` | With `--online`, exit 1 when a known certificate or domain date is within N days (default 30) or past. An unknown result does not fail the run. |
114
- | `--scan <path>` | Also scan this file or folder, e.g. build output outside `dir`. Repeatable. |
115
- | `--exclude <path>` | Leave a path (relative to `dir`) out of the model, version and service checks. Repeatable. Excluded paths are always listed in the report and are still scanned for key-shaped values. |
116
- | `--badge` | `check` only. Print a link that makes a README badge: a date and counts (services, caps declared, gaps, keys found), no provider names. The link opens a page that signs it and gives the README line. Still makes no network call. |
117
- | `--badge-breaks` | `check` only. Print a markdown badge, `breaks in 90 days: N`, linking to ouchbill.com/retirements. It counts dated retirements and end-of-life dates within 90 days (green at 0, orange for some, red `N now` when any is already critical). Counts only: no model ids, paths or provider names. A plain shields.io link; no network call is made. Cannot be combined with `--json` or `--badge`. |
118
- | `--badge-providers` | With `--badge`, also list the detected service ids on the badge's page. Off by default. |
119
- | `--report <file.html>` | `check` only. Also write one self-contained HTML report: headline first ("2 critical, 3 high: fix these before you ship"), a severity bar, a fix-first list, then every finding grouped by severity and category with file:line, why, numbered fix steps, source and checked date. Filters by severity and category, light and dark, prints well. Inline CSS, no script at all, and a Content-Security-Policy that blocks every request: it works offline. |
120
- | `--sarif <file.sarif>` | Also write SARIF 2.1.0 (validated against the OASIS schema in the tests) for GitHub code scanning. One rule per finding id, one result per place, `security-severity` set. |
121
-
122
- ## AI-stack security pack
123
-
124
- `ouchbill check` also runs these rules, in-process: no network, no external binary, nothing uploaded. Every finding
125
- uses the same id in text, `--json` (`ranked` and the raw `security` hits), `--report`, `--sarif` and the MCP server.
126
- Titles, reasons and fix steps are our own words; a repo path appears only in `where`.
127
-
128
- | Id | Severity | What |
129
- |---|---|---|
130
- | `secret:<provider>` | critical | A key-shaped value in the repo or build output (now also Perplexity, Fireworks, Hugging Face org tokens, OuchBill data feed keys (`obt_`), and Mistral, Cohere, Together, DeepSeek, ElevenLabs keys written next to their env var name). Masked, never tested. Also read: committed env files (keys only), text with NUL bytes and UTF-16 without a byte-order mark. |
131
- | `exposed:public-env-llm-key` | critical | An LLM key name with a browser-public prefix: `NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `REACT_APP_`. |
132
- | `exposed:llm-sdk-in-client` | critical | An LLM SDK imported in browser code (`"use client"` files, `*.client.*`, Vue/Svelte components, `public/`, browser bundles), or `dangerouslyAllowBrowser: true`. |
133
- | `exposed:key-in-client-code` | critical | A key-shaped value in browser code or a browser bundle (also reported as `secret:`). |
134
- | `agent:pipe-to-shell` | critical | A hook, status line or MCP start command that pipes `curl`/`wget` into a shell or interpreter, by program name (`sh`, `/bin/sh`, `env bash`, `sudo bash`, `python`, `node` …), or gives one `$(curl …)`. |
135
- | `actions:pr-target-checkout` | critical | `pull_request_target` with a checkout of the pull request head. |
136
- | `agent:mcp-plaintext-secret` | high | A literal secret in an MCP server's `env` or `headers`. |
137
- | `agent:bypass-permissions` | high | `bypassPermissions`, `--dangerously-skip-permissions` or a `dangerously…: true` key. |
138
- | `agent:wildcard-allow` | high | An allow rule of `Bash`, `Bash(*)`, `Bash(:*)` or `*`, or one that allows a shell, an interpreter with inline code or a wrapper with any arguments (`Bash(sh:*)`, `Bash(bash -c:*)`, `Bash(node:*)`, `Bash(env:*)`). |
139
- | `agent:auto-approve-mcp` | high | `enableAllProjectMcpServers: true`: every server in the project's `.mcp.json` starts without a prompt. |
140
- | `agent:mcp-plain-http` | high | A remote MCP server on `http://` (loopback is fine). |
141
- | `actions:template-injection` | high | `${{ github.event.* }}` or `github.head_ref` inside `run:` (numbers, SHAs and maintainer-set fields excepted), in block or flow style, quoted keys and multi-line values. |
142
- | `actions:write-all` | high | `permissions: write-all`. |
143
- | `agent:mcp-unpinned-package` | medium | An MCP server started with `npx`/`bunx`/`pnpm dlx`/`uvx` and no exact version, or `@latest`. |
144
- | `actions:unpinned-third-party` | medium | A third-party action (or `docker://` image) not pinned to a full SHA (digest). |
145
- | `actions:no-permissions` | medium | A workflow with no `permissions:` block (reusable `workflow_call`-only workflows excepted). |
146
- | `injection:input-in-prompt` | medium, to check | Request input joined into a prompt string in a file that calls an LLM. |
147
- | `injection:output-to-sink` | medium, to check | Model output on the same line as `eval`, a shell call, raw SQL or raw HTML. |
148
- | `actions:unpinned-first-party` | low | `actions/*` or `github/*` not pinned to a full SHA. |
149
- | `actions:persist-credentials` | low | `actions/checkout` without `persist-credentials: false`. |
150
-
151
- Files read: `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.claude/settings.json`, `.claude/settings.local.json`,
152
- `claude_desktop_config.json` (JSON with comments allowed), `.github/workflows/*.yml` and `action.yml`, and code files.
153
- Tests, docs and installed packages are skipped by the code rules. Folders of installed packages and caches
154
- (`node_modules`, a virtualenv with its full layout, a Go `vendor/` with `modules.txt` and `go.mod`, `.cache` …) are not
155
- entered, but each is listed in the output, and the files in them that git tracks are still scanned for keys and agent
156
- and Actions configs. An exclude never hides the root workflows, `action.yml` or the root agent configs. "To check" findings are heuristics
157
- (`confirmed: false`) and are never critical. The pack does not change exit codes: keys still exit 1 as before.
158
-
159
- Every rule reads text in linear time (1 MB hostile files under 1 s each, in `test/redos.test.ts` and
160
- `test/security-pack.test.ts`). Sources for each rule are in `src/pack.ts`; the key prefixes and where each was
161
- confirmed on 2026-12-01 are in `src/llm-keys.ts`.
162
-
163
- ## GitHub Action
164
-
165
- The Action runs the same bundle on the runner. It fails the build on a key in the repo or the
166
- built bundle, and on a used service with no declared cap. It does not send spend alerts; other free
167
- tools already do that hourly. This one checks whether a cap exists at all.
168
-
169
- ```yaml
170
- # .github/workflows/ouchbill.yml
171
- name: ouchbill
172
- on: [pull_request]
173
- permissions:
174
- contents: read
175
- jobs:
176
- caps-and-keys:
177
- runs-on: ubuntu-24.04
178
- steps:
179
- - uses: actions/checkout@v4
180
- - uses: actions/setup-node@v4
181
- with:
182
- node-version: 22
183
- - run: npm ci && npm run build # scan what you actually ship
184
- - uses: OWNER/REPO/packages/cli@COMMIT_SHA # pin a full SHA once the repo is public
185
- with:
186
- scan: |
187
- dist
188
- exclude: |
189
- test/fixtures # still scanned for keys; only model, version and service checks skip it
190
- fail-on-uncapped: "true"
191
- ```
192
-
193
- Inputs: `path` (default `.`), `scan` and `exclude` (one per line), `fail-on-uncapped` (default
194
- `"true"`), `json-file` (also write the JSON result), `fail-if-config-changed` (default `"false"`; on a pull
195
- request, fail when it changes `.ouchbill.json`; needs `fetch-depth: 0`). Output: `exit-code`. The Action needs no
196
- secrets and no token. It needs Node 20 or newer on the runner; GitHub-hosted runners have it.
197
-
198
- A full example is in [`examples/ouchbill.yml`](examples/ouchbill.yml).
199
-
200
- ## How detection works
201
-
202
- | Signal | Read from |
203
- |---|---|
204
- | Dependencies | `package.json` (all dependency sections), `requirements*.txt`, `pyproject.toml` (PEP 621, Poetry), `Pipfile`, `go.mod` |
205
- | Env var names | `.env.example` / `.env.sample` / `.env.template`, CI and deploy config (workflows, compose files, `fly.toml` …), and `process.env.X`-style references in code |
206
- | Infrastructure | Terraform `provider` blocks and `required_providers`, `wrangler.toml`, `vercel.json`, `netlify.toml`, `fly.toml`, `render.yaml`, `firebase.json`, `supabase/config.toml`, `cdk.json`, SAM/CloudFormation templates, Bicep files |
207
-
208
- Only unambiguous signals count: an official SDK, the provider's own config file, an env var name
209
- the provider documents, or an IaC provider. Generic clients that also reach self-hosted software
210
- (`pg`, `mongodb`, `redis`) are left out, so a self-hosted database is not reported as a cloud bill.
211
- If nothing is detected, ouchbill says so and says that is not proof there is nothing.
212
-
213
- `node_modules`, `.git`, virtualenvs and build caches (`.next/cache`) are skipped. Build output
214
- (`dist`, `build`, `.next`, `out`) is scanned, because that is what ships to browsers. Files over
215
- 20 MB and binary files are skipped and counted in the report.
216
-
217
- ### Claude Code and `ANTHROPIC_API_KEY`
218
-
219
- If `ANTHROPIC_API_KEY` is set in the shell that runs `ouchbill check`, it prints a note: on a
220
- Claude Pro/Max plan, Claude Code can bill that API key per token instead of your plan. Only the
221
- variable's name is checked.
222
-
223
- ## Where the data comes from
224
-
225
- The provider catalog (cap status, source link, verified date, where to set the cap) and the key
226
- patterns are not copied into this package. They are imported from the OuchBill web app's sources
227
- (`apps/web/src/data/providers.ts`, `apps/web/src/lib/patterns.ts`) and bundled into
228
- `dist/ouchbill.mjs` at build time, so the CLI, the website and the site scanner never disagree. A
229
- test fails when the committed bundle no longer matches those sources.
230
-
231
- ## Develop
232
-
233
- ```
234
- cd packages/cli
235
- npm ci
236
- npm test # typecheck + vitest
237
- npm run build # rebuild dist/ouchbill.mjs after changing src or the shared catalog
238
- ```
239
-
240
- Test fixtures contain no keys. Tests plant obviously fake keys (`…OUCHBILLFAKE…`) in temp folders
241
- at runtime.
242
-
243
- ## Licence
244
-
245
- Proprietary. Copyright (c) 2026 Drevan. All rights reserved. See [LICENSE](LICENSE). Bundled third-party
246
- components keep their own licences: `dist/THIRD_PARTY_NOTICES.txt`.
247
-
248
- ## `usage` and `detect` (local, offline)
249
-
250
- - `ouchbill usage` reads Claude Code (`~/.claude/projects/**/*.jsonl`, or `CLAUDE_CONFIG_DIR`), Codex CLI (`~/.codex/sessions`, or `CODEX_HOME`) and Gemini CLI (`~/.gemini/tmp/*/chats`) logs on this machine and prints tokens per model for today, this week (from Monday) and this month. Any money shown is an **estimate at list price** from a bundled table with a source URL and checked date (`src/pricing.ts`), in integer micro-dollars. A model not in the table has an unknown cost, never zero. It is not your bill.
251
- - `ouchbill detect` reports which logins already exist: AWS CLI profile names, whether gcloud has an active account, whether a Vercel login file exists, and the Claude, Codex and Gemini CLIs. It never opens credentials or token files and prints no secret or account value.
252
-
253
- Neither command makes a network call, and neither accepts `--fresh` or `--online`.
1
+ # ouchbill
2
+
3
+ **What in your project will break or bill you next.** One command finds AI models your provider is retiring,
4
+ runtimes reaching end of life, API keys committed to the repo, and paid services with no spending cap. A second
5
+ command tells you which API keys in your `.env` still work and how much each has left.
6
+
7
+ ```bash
8
+ npx ouchbill check . # what breaks, what leaks, what can bill you, most urgent first
9
+ npx ouchbill keys . # which API keys in .env work, and how much credit each has left
10
+ ```
11
+
12
+ Node 20+. No install, no sign-up, no account, no telemetry. Zero runtime dependencies.
13
+
14
+ ---
15
+
16
+ ## What you see
17
+
18
+ ```
19
+ OUCHBILL 0.2.0 · my-app · 5934 files read
20
+ AI model dates checked 6 Dec (today)
21
+
22
+ 6 NOW 10 PLAN 1 LATER
23
+ 2 things already failing; 10 key-shaped values to rotate.
24
+ Since your last run (2 days ago): ✔ 2 fixed
25
+
26
+ BREAKING already failing or within 30 days
27
+ ✖ NOW claude-sonnet-4-20250514 stopped working 174 days ago 15 Jun
28
+ llm/claude_provider.py:22
29
+ → Switch to claude-sonnet-5-5
30
+
31
+ LEAKED KEYS AND SECURITY 4 issues
32
+ ✖ NOW 2 OpenAI key-shaped values in the repo
33
+ .env.example:23, .env.example:57
34
+ → Rotate this key at the provider now, then load it from an environment variable
35
+
36
+ SPEND 3 pay-per-use services in this project
37
+ OpenAI API ▲ no cap set · hard cap available
38
+ ...
39
+
40
+ Start here: Switch to claude-sonnet-5-5
41
+ Next date to watch: gpt-4o-mini-2024-07-18 on 14 Jan 2027. Run ouchbill again before then.
42
+ ```
43
+
44
+ In a terminal it is in colour. In CI, pipes and AI agents it prints plain text, or JSON with `--json`.
45
+
46
+ ## What it checks
47
+
48
+ | | What | Example |
49
+ |---|---|---|
50
+ | **Breaks** | AI model ids in your code that the provider retires, with date, days left and the replacement | `gpt-4o-mini-2024-07-18` stops working 14 Jan |
51
+ | **Breaks** | Runtimes, frameworks, databases and GitHub Actions versions reaching end of life | Node.js 18, Python 3.9, `actions/checkout@v3` |
52
+ | **Leaks** | API keys in the repo or the build output (shown masked, never tested) | `sk-proj-…a1B2` in `src/config.ts:4` |
53
+ | **Leaks** | AI-stack mistakes: LLM keys exposed to the browser, risky agent and MCP configs, unsafe GitHub Actions, prompt-injection sinks | `NEXT_PUBLIC_OPENAI_API_KEY` |
54
+ | **Bills** | Pay-per-use services the project uses, and whether each provider offers a hard spending cap | OpenAI: hard cap available, none declared |
55
+ | **Balance** | `ouchbill keys`: whether each key in `.env` works and how much credit or quota it has left | OpenRouter: $1.50 left of $10 |
56
+
57
+ ## Commands
58
+
59
+ | Command | What it does | Network |
60
+ |---|---|---|
61
+ | `ouchbill check [dir]` | The full check, most urgent first | Reads the latest provider dates (below). `--offline` for none |
62
+ | `ouchbill keys [dir]` | Checks the keys in your `.env` files, after asking you | Each key to its own provider only |
63
+ | `ouchbill usage` | Your AI coding tokens today, this week, this month (Claude Code, Codex, Gemini CLI) | None |
64
+ | `ouchbill detect` | Which cloud and AI logins exist on this machine; never reads a secret | None |
65
+ | `ouchbill scan [path]` | Only the key scan, e.g. on build output | None |
66
+ | `ouchbill statusline` | Claude Code status line: your 5-hour and 7-day limits and when they reset | None |
67
+
68
+ ## Safety: what it sends, and to whom
69
+
70
+ ouchbill was built for people who don't want their keys or code to leave their machine. Every point below is
71
+ enforced by an automated test, not only written down.
72
+
73
+ **`check`, `scan`, `usage`, `detect`, `statusline`**
74
+ - Never upload your code, file names, paths or findings anywhere.
75
+ - `check` downloads one signed file of provider dates from the public npm registry (package `ouchbill-data`).
76
+ The request carries nothing about your project (npm sees your IP address, as with any download). The file is verified with an Ed25519 signature built
77
+ into ouchbill; a file that fails the check, has expired, or is older than the dates already bundled is refused,
78
+ and the bundled dates are used. A failed download never changes the result or the exit code.
79
+ - `--offline` or `OUCHBILL_OFFLINE=1` makes no network request at all. A test proves the network code is never
80
+ even loaded in that case.
81
+ - `check` reads env var **names** only. It never opens `.env` files.
82
+
83
+ **`keys`** (the only command that reads `.env` values)
84
+ - Lists every key it found, **masked**, and **asks before sending anything**. Without a terminal it needs `--yes`.
85
+ - Each key goes **only to its own provider**, over https, to a fixed address built into ouchbill:
86
+ `api.openai.com`, `api.anthropic.com`, `openrouter.ai`, `api.deepseek.com`, `api.elevenlabs.io`,
87
+ `api.groq.com`, `api.mistral.ai`, `generativelanguage.googleapis.com`, `api.deepgram.com`, `api.x.ai`,
88
+ `api.together.xyz`, `api.twilio.com`. Any other address is refused before the request is made.
89
+ - Redirects are refused. Only free, read-only calls: list models, or read the key's own limit or balance.
90
+ Nothing that generates text, spends credit or changes your account. Admin keys are not used.
91
+ - A key whose provider is unclear (for example a bare `sk-…` under `API_KEY`) is **never sent**.
92
+ - Never sends a key to OuchBill, never stores it, never writes it to disk, never prints it. Output shows the
93
+ masked form only, and from the provider's reply only numbers, currency codes, dates and fixed words.
94
+ - Refuses to run if TLS certificate checks are switched off (`NODE_TLS_REJECT_UNAUTHORIZED=0`).
95
+ - Skips `.env` files that are links, so a repo cannot point it at files outside the project.
96
+ - Not available through the MCP server, so an AI assistant cannot send your keys anywhere through it.
97
+
98
+ **Always**
99
+ - No telemetry, no analytics, no account.
100
+ - Zero runtime dependencies: the package is two self-contained files, so there is no dependency tree to poison.
101
+
102
+ ## For AI coding agents
103
+
104
+ ouchbill is safe for an agent to run on a user's project without asking:
105
+
106
+ ```bash
107
+ npx ouchbill@0.2.0 check . --json # structured result, schemaVersion 1
108
+ npx ouchbill@0.2.0 check . --json --offline # same, with no network request at all
109
+ ```
110
+
111
+ - It only reads files. It never runs code from the repo and never changes a file (unless you pass `--report` or
112
+ `--sarif`, which write only the file you name, inside the project or the current folder).
113
+ - Text from the repo (paths, names) is quoted and marked as data in the output, so a planted file cannot pass
114
+ instructions to you through ouchbill.
115
+ - `--json` gives `ranked`: one entry per problem, with `severity`, `title`, `where` (file and line), `why`,
116
+ numbered `fix` steps, `replacement` and `source`.
117
+ - Exit codes: `0` nothing failing, `1` a key in the repo or a `--fail-on-*` threshold met, `2` bad input.
118
+
119
+ **Do not run `ouchbill keys` for the user without asking them first, and never with `--yes` on their behalf.**
120
+ It sends the user's keys to their providers. Suggest the command and let the user run it.
121
+
122
+ ## In CI
123
+
124
+ ```yaml
125
+ - run: npx ouchbill@0.2.0 check . --fail-on-retiring=30 --fail-on-eol=30 --sarif ouchbill.sarif
126
+ ```
127
+
128
+ Fails the build when a model in the code retires within 30 days, a runtime reaches end of life, or a key is
129
+ committed. Upload the SARIF file to GitHub code scanning to see findings inline on pull requests.
130
+
131
+ ## Options
132
+
133
+ | Option | |
134
+ |---|---|
135
+ | `--json` | Machine-readable output (`schemaVersion: 1`) |
136
+ | `--offline` | `check`: no network request; use the bundled dates (also `OUCHBILL_OFFLINE=1`) |
137
+ | `--plain` | No colour, even in a terminal. Colour also follows `NO_COLOR` and `FORCE_COLOR` |
138
+ | `--yes` | `keys`: check without the prompt (scripts only) |
139
+ | `--report <file.html>` | A self-contained HTML report with fix steps for every item. No scripts, works offline |
140
+ | `--sarif <file.sarif>` | SARIF 2.1.0 for GitHub code scanning |
141
+ | `--fail-on-retiring[=N]` | Exit 1 when a model in the code stops working within N days (default 30) |
142
+ | `--fail-on-eol[=N]` | Exit 1 when a pinned runtime, action, framework or database ends within N days (default 30) |
143
+ | `--fail-on-severity=L` | Exit 1 on a security finding at `critical` or `high` or above |
144
+ | `--fail-on-uncapped` | Exit 1 when a pay-per-use service has no cap declared in `.ouchbill.json` |
145
+ | `--online` | Also check TLS certificate and domain expiry for up to 10 production hosts in the repo. Prints every host before connecting |
146
+ | `--fail-on-expiry[=N]` | With `--online`: exit 1 when a certificate or domain expires within N days |
147
+ | `--scan <path>` / `--exclude <path>` | Add or skip a path. Excluded paths are still scanned for keys |
148
+ | `--badge-breaks` | A "breaks in 90 days: N" badge for your README (counts only) |
149
+
150
+ ## Which providers `keys` can read
151
+
152
+ | Provider | What you see |
153
+ |---|---|
154
+ | OpenRouter | Credit left of the key's limit, and usage |
155
+ | DeepSeek | Account balance |
156
+ | ElevenLabs | Characters left this period, and the reset date |
157
+ | Twilio | Account balance (needs `TWILIO_ACCOUNT_SID` next to the token) |
158
+ | Deepgram | Credit left (only with an owner or admin key; otherwise "works") |
159
+ | OpenAI, Anthropic, Groq, Mistral, Gemini, Together, xAI | Whether the key works, and a link to the billing page. These providers don't let an ordinary key read the balance |
160
+
161
+ ---
162
+
163
+ ## Details
164
+
165
+ ### Declaring your caps: `.ouchbill.json`
166
+
167
+ ouchbill cannot see your provider dashboards, so "cap available" never means "cap on". Say what you set:
168
+
169
+ ```json
170
+ {
171
+ "caps": {
172
+ "openai": { "status": "on", "checkedOn": "2026-11-15", "note": "org limit + project limits" },
173
+ "azure": { "status": "accepted", "reason": "PAYG has no hard cap; budget alerts at 50/80/100%" }
174
+ },
175
+ "exclude": ["test/fixtures"]
176
+ }
177
+ ```
178
+
179
+ - `"on"` needs `checkedOn`: the date someone looked at the provider's setting.
180
+ - `"accepted"` needs a `reason`: you know there is no hard cap and chose to run without one.
181
+ - `"on"` counts only where the catalog confirms the provider has a stop (`yes` or `partial`).
182
+ Where the catalog says **no** hard cap, or the cap is **unknown**, `"on"` is reported as
183
+ "declared, not counted" and still fails `--fail-on-uncapped`. Budgets that only send alerts are
184
+ not caps. If you accept running without a confirmed cap, say so with `"accepted"` and a reason.
185
+ - Provider ids come from `ouchbill providers`. An unknown id is an error, so a typo can't pass CI.
186
+ - A config file that contains anything key-shaped is refused (exit 2).
187
+
188
+ ### AI-stack security rules
189
+
190
+ | Id | Severity | What |
191
+ |---|---|---|
192
+ | `secret:<provider>` | critical | A key-shaped value in the repo or build output (now also Perplexity, Fireworks, Hugging Face org tokens, OuchBill data feed keys (`obt_`), and Mistral, Cohere, Together, DeepSeek, ElevenLabs keys written next to their env var name). Masked, never tested. Also read: committed env files (keys only), text with NUL bytes and UTF-16 without a byte-order mark. |
193
+ | `exposed:public-env-llm-key` | critical | An LLM key name with a browser-public prefix: `NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `REACT_APP_`. |
194
+ | `exposed:llm-sdk-in-client` | critical | An LLM SDK imported in browser code (`"use client"` files, `*.client.*`, Vue/Svelte components, `public/`, browser bundles), or `dangerouslyAllowBrowser: true`. |
195
+ | `exposed:key-in-client-code` | critical | A key-shaped value in browser code or a browser bundle (also reported as `secret:`). |
196
+ | `agent:pipe-to-shell` | critical | A hook, status line or MCP start command that pipes `curl`/`wget` into a shell or interpreter, by program name (`sh`, `/bin/sh`, `env bash`, `sudo bash`, `python`, `node` …), or gives one `$(curl …)`. |
197
+ | `actions:pr-target-checkout` | critical | `pull_request_target` with a checkout of the pull request head. |
198
+ | `agent:mcp-plaintext-secret` | high | A literal secret in an MCP server's `env` or `headers`. |
199
+ | `agent:bypass-permissions` | high | `bypassPermissions`, `--dangerously-skip-permissions` or a `dangerously…: true` key. |
200
+ | `agent:wildcard-allow` | high | An allow rule of `Bash`, `Bash(*)`, `Bash(:*)` or `*`, or one that allows a shell, an interpreter with inline code or a wrapper with any arguments (`Bash(sh:*)`, `Bash(bash -c:*)`, `Bash(node:*)`, `Bash(env:*)`). |
201
+ | `agent:auto-approve-mcp` | high | `enableAllProjectMcpServers: true`: every server in the project's `.mcp.json` starts without a prompt. |
202
+ | `agent:mcp-plain-http` | high | A remote MCP server on `http://` (loopback is fine). |
203
+ | `actions:template-injection` | high | `${{ github.event.* }}` or `github.head_ref` inside `run:` (numbers, SHAs and maintainer-set fields excepted), in block or flow style, quoted keys and multi-line values. |
204
+ | `actions:write-all` | high | `permissions: write-all`. |
205
+ | `agent:mcp-unpinned-package` | medium | An MCP server started with `npx`/`bunx`/`pnpm dlx`/`uvx` and no exact version, or `@latest`. |
206
+ | `actions:unpinned-third-party` | medium | A third-party action (or `docker://` image) not pinned to a full SHA (digest). |
207
+ | `actions:no-permissions` | medium | A workflow with no `permissions:` block (reusable `workflow_call`-only workflows excepted). |
208
+ | `injection:input-in-prompt` | medium, to check | Request input joined into a prompt string in a file that calls an LLM. |
209
+ | `injection:output-to-sink` | medium, to check | Model output on the same line as `eval`, a shell call, raw SQL or raw HTML. |
210
+ | `actions:unpinned-first-party` | low | `actions/*` or `github/*` not pinned to a full SHA. |
211
+ | `actions:persist-credentials` | low | `actions/checkout` without `persist-credentials: false`. |
212
+
213
+ "To check" findings are heuristics and are never critical. Every rule reads text in linear time.
214
+
215
+ ### Where the dates come from
216
+
217
+ Each model retirement and end-of-life date is copied from the provider's own page (OpenAI, Anthropic and Google
218
+ deprecation pages, endoflife.date and others). Every finding carries its source link and the date it was checked.
219
+ "Unknown" is never shown as "fine", and ouchbill never says your bill is safe.
220
+
221
+ ## Licence
222
+
223
+ Free to use, including for commercial work and in CI. Not open source: copying, modifying, redistributing or
224
+ reverse engineering it is not allowed. Copyright (c) 2026 Drevan. See [LICENSE](LICENSE). Bundled third-party
225
+ components keep their own licences: `dist/THIRD_PARTY_NOTICES.txt`.
@@ -1,3 +1,3 @@
1
- Third-party software bundled into ouchbill 0.1.0. Each keeps its own licence, reproduced below.
1
+ Third-party software bundled into ouchbill 0.2.1. Each keeps its own licence, reproduced below.
2
2
 
3
3
  None: these bundles contain no third-party code.