ouchbill 0.0.0-stage → 0.2.0

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 ADDED
@@ -0,0 +1,34 @@
1
+ Copyright (c) 2026 Drevan. All rights reserved.
2
+
3
+ OuchBill free-use licence, version 1 (2026-12-06)
4
+
5
+ This software, including its source code, its built bundles (dist/) and its data tables,
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.
23
+
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.
26
+
27
+ 4. Third-party components that are bundled into dist/ keep their own licences. Their notices
28
+ are in dist/THIRD_PARTY_NOTICES.txt.
29
+
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,3 +1,225 @@
1
- # Temporary Holding Version
1
+ # ouchbill
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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`.
package/action.yml ADDED
@@ -0,0 +1,96 @@
1
+ name: OuchBill check
2
+ description: >-
3
+ Fails the build when a key-shaped value is in the repo or the built bundle, or when a usage-billed
4
+ service the project uses has no cap declared in .ouchbill.json. Runs on the runner only: no network
5
+ calls, no telemetry, no secrets needed.
6
+ author: OuchBill
7
+ branding:
8
+ icon: shield
9
+ color: orange
10
+
11
+ inputs:
12
+ path:
13
+ description: Folder to check (detect services and scan for keys).
14
+ required: false
15
+ default: "."
16
+ scan:
17
+ description: Extra files or folders to scan for keys, one per line (e.g. build output outside `path`).
18
+ required: false
19
+ default: ""
20
+ exclude:
21
+ description: Paths to leave out of the model, version and service checks, relative to `path`, one per line. They are still scanned for keys, and every excluded path is printed.
22
+ required: false
23
+ default: ""
24
+ fail-on-uncapped:
25
+ description: '"true" fails the build when a detected service has no cap declared in .ouchbill.json.'
26
+ required: false
27
+ default: "true"
28
+ json-file:
29
+ description: If set, also write the JSON result (schemaVersion 1) to this file.
30
+ required: false
31
+ default: ""
32
+ fail-if-config-changed:
33
+ description: >-
34
+ "true" fails the check on a pull request that changes .ouchbill.json in the checked folder, so a pull request
35
+ cannot add its own excludes or cap declarations to pass. Needs the base commit: check out with fetch-depth 0.
36
+ required: false
37
+ default: "false"
38
+
39
+ outputs:
40
+ exit-code:
41
+ description: 0 nothing failing, 1 findings, 2 usage or config error.
42
+ value: ${{ steps.check.outputs.exit-code }}
43
+
44
+ runs:
45
+ using: composite
46
+ steps:
47
+ - id: check
48
+ shell: bash
49
+ # Inputs reach the script through env vars, never through ${{ }} inside the script (no injection).
50
+ env:
51
+ OUCHBILL_PATH: ${{ inputs.path }}
52
+ OUCHBILL_SCAN: ${{ inputs.scan }}
53
+ OUCHBILL_EXCLUDE: ${{ inputs.exclude }}
54
+ OUCHBILL_FAIL_ON_UNCAPPED: ${{ inputs.fail-on-uncapped }}
55
+ OUCHBILL_JSON_FILE: ${{ inputs.json-file }}
56
+ OUCHBILL_FAIL_IF_CONFIG_CHANGED: ${{ inputs.fail-if-config-changed }}
57
+ run: |
58
+ set -uo pipefail
59
+ major="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)"
60
+ if [ "$major" -lt 20 ]; then
61
+ echo "::error::ouchbill needs Node 20 or newer on the runner (found: $(node --version 2>/dev/null || echo none)). Add actions/setup-node before this step."
62
+ exit 2
63
+ fi
64
+ # Options first, then `--`, then the path: a path input such as "--help" stays a path.
65
+ opts=()
66
+ while IFS= read -r p; do [ -n "$p" ] && opts+=(--scan="$p"); done <<< "$OUCHBILL_SCAN"
67
+ while IFS= read -r p; do [ -n "$p" ] && opts+=(--exclude="$p"); done <<< "$OUCHBILL_EXCLUDE"
68
+ [ "$OUCHBILL_FAIL_ON_UNCAPPED" = "true" ] && opts+=(--fail-on-uncapped)
69
+ bin="$GITHUB_ACTION_PATH/dist/ouchbill.mjs"
70
+ # The report quotes text from the repo: workflow commands are off while it prints (one-time token, S-24).
71
+ token="ouchbill-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"
72
+ echo "::stop-commands::$token"
73
+ node "$bin" check "${opts[@]}" -- "$OUCHBILL_PATH"
74
+ code=$?
75
+ echo "::$token::"
76
+ # S-20: a pull request must not edit .ouchbill.json (excludes, cap declarations) to pass its own check.
77
+ if [ "$OUCHBILL_FAIL_IF_CONFIG_CHANGED" = "true" ]; then
78
+ case "${GITHUB_EVENT_NAME:-}" in
79
+ pull_request|pull_request_target)
80
+ base="$(node -e 'const e = require(process.env.GITHUB_EVENT_PATH); process.stdout.write(String((e.pull_request && e.pull_request.base && e.pull_request.base.sha) || ""))')"
81
+ if ! printf '%s' "$base" | grep -Eq '^[0-9a-f]{40}$'; then echo "::error::fail-if-config-changed could not read the pull request's base commit."; exit 2; fi
82
+ git cat-file -e "$base^{commit}" 2>/dev/null || git fetch --no-tags --depth=1 origin "$base" >/dev/null 2>&1 || true
83
+ if ! git cat-file -e "$base^{commit}" 2>/dev/null; then echo "::error::fail-if-config-changed needs the base commit. Use actions/checkout with fetch-depth: 0."; exit 2; fi
84
+ if ! git diff --quiet "$base" HEAD -- "${OUCHBILL_PATH%/}/.ouchbill.json"; then
85
+ echo "::error::This pull request changes .ouchbill.json (fail-if-config-changed is on). A maintainer must review that change; it can hide findings."
86
+ [ "$code" -eq 0 ] && code=1
87
+ fi
88
+ ;;
89
+ *) echo "fail-if-config-changed: not a pull request, nothing to compare." ;;
90
+ esac
91
+ fi
92
+ if [ -n "$OUCHBILL_JSON_FILE" ] && [ "$code" -ne 2 ]; then
93
+ node "$bin" check "${opts[@]}" --json -- "$OUCHBILL_PATH" > "$OUCHBILL_JSON_FILE" || true
94
+ fi
95
+ echo "exit-code=$code" >> "$GITHUB_OUTPUT"
96
+ exit "$code"
@@ -0,0 +1,3 @@
1
+ Third-party software bundled into ouchbill 0.2.0. Each keeps its own licence, reproduced below.
2
+
3
+ None: these bundles contain no third-party code.