clawculator 2.0.1 → 2.1.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/README.md +38 -0
- package/package.json +5 -12
- package/skills/clawculator/README.md +153 -0
- package/skills/clawculator/SKILL.md +57 -0
- package/skills/clawculator/analyzer.js +598 -0
- package/skills/clawculator/htmlReport.js +181 -0
- package/skills/clawculator/mdReport.js +147 -0
- package/skills/clawculator/reporter.js +139 -0
- package/skills/clawculator/run.js +102 -0
- package/logo.png +0 -0
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ AI cost forensics for OpenClaw and multi-model setups. One command. Full analysi
|
|
|
10
10
|
|
|
11
11
|
[](https://badge.fury.io/js/clawculator)
|
|
12
12
|
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
[](https://echoudhry.github.io/clawculator)
|
|
13
14
|
|
|
14
15
|
---
|
|
15
16
|
|
|
@@ -19,6 +20,15 @@ You set up OpenClaw. It runs great. Then your API bill arrives and you have no i
|
|
|
19
20
|
|
|
20
21
|
It could be any of these. Clawculator finds all of them — with zero AI, zero guesswork, and zero data leaving your machine.
|
|
21
22
|
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## [▶ Live Demo](https://echoudhry.github.io/clawculator)
|
|
28
|
+
|
|
29
|
+
See it run against a real config — findings, fix commands, cost exposure, session breakdown.
|
|
30
|
+
|
|
31
|
+
|
|
22
32
|
---
|
|
23
33
|
|
|
24
34
|
## One command
|
|
@@ -86,6 +96,34 @@ npx clawculator --json > cost-report.json
|
|
|
86
96
|
|
|
87
97
|
---
|
|
88
98
|
|
|
99
|
+
## Use as an OpenClaw skill (ClawHub)
|
|
100
|
+
|
|
101
|
+
Install clawculator as a skill so you can type `clawculator` in your OpenClaw webchat and get a full cost report inline.
|
|
102
|
+
|
|
103
|
+
**Install via ClawHub:**
|
|
104
|
+
```bash
|
|
105
|
+
npm i -g clawhub
|
|
106
|
+
clawhub install clawculator
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then start a new OpenClaw session and type:
|
|
110
|
+
```
|
|
111
|
+
clawculator
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Your agent runs the analysis and returns the full markdown report directly in chat.
|
|
115
|
+
|
|
116
|
+
**Or install manually** into your workspace:
|
|
117
|
+
```bash
|
|
118
|
+
mkdir -p ~/clawd/skills/clawculator
|
|
119
|
+
curl -o ~/clawd/skills/clawculator/SKILL.md \
|
|
120
|
+
https://raw.githubusercontent.com/echoudhry/clawculator/main/skills/clawculator/SKILL.md
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Start a new session to pick it up.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
89
127
|
## Why deterministic?
|
|
90
128
|
|
|
91
129
|
Every recommendation is a hardcoded switch/case — not generated by an AI. This means:
|
package/package.json
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawculator",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "AI cost forensics for OpenClaw and multi-model setups. Your friendly penny pincher. 100% offline. Zero AI. Pure deterministic logic.",
|
|
5
5
|
"main": "src/analyzer.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"clawculator": "bin/clawculator.js"
|
|
7
|
+
"clawculator": "./bin/clawculator.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node bin/clawculator.js",
|
|
11
11
|
"test": "node -e \"const {runAnalysis} = require('./src/analyzer'); runAnalysis({configPath:'~/.openclaw/openclaw.json',sessionsPath:'',logsDir:''}).then(r => console.log('OK:', r.summary))\""
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
|
-
"openclaw",
|
|
15
|
-
"
|
|
16
|
-
"anthropic",
|
|
17
|
-
"ai-cost",
|
|
18
|
-
"token-usage",
|
|
19
|
-
"cost-optimization",
|
|
20
|
-
"llm-cost",
|
|
21
|
-
"ai-forensics",
|
|
22
|
-
"multi-model"
|
|
14
|
+
"openclaw", "claude", "anthropic", "ai-cost", "token-usage",
|
|
15
|
+
"cost-optimization", "llm-cost", "ai-forensics", "multi-model"
|
|
23
16
|
],
|
|
24
17
|
"author": "Ed Choudhry",
|
|
25
18
|
"license": "MIT",
|
|
26
19
|
"repository": {
|
|
27
20
|
"type": "git",
|
|
28
|
-
"url": "
|
|
21
|
+
"url": "https://github.com/echoudhry/clawculator"
|
|
29
22
|
},
|
|
30
23
|
"engines": {
|
|
31
24
|
"node": ">=18.0.0"
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="logo.png" width="200" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Clawculator
|
|
6
|
+
|
|
7
|
+
> **Your friendly penny pincher.**
|
|
8
|
+
|
|
9
|
+
AI cost forensics for OpenClaw and multi-model setups. One command. Full analysis. 100% offline. Zero AI. Pure deterministic logic.
|
|
10
|
+
|
|
11
|
+
[](https://badge.fury.io/js/clawculator)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
[](https://echoudhry.github.io/clawculator)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## The problem
|
|
18
|
+
|
|
19
|
+
You set up OpenClaw. It runs great. Then your API bill arrives and you have no idea why it's $150. Was it the heartbeat? A skill running a polling loop? WhatsApp groups processing every message on Sonnet? Orphaned sessions? Hooks on the wrong model?
|
|
20
|
+
|
|
21
|
+
It could be any of these. Clawculator finds all of them — with zero AI, zero guesswork, and zero data leaving your machine.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## [▶ Live Demo](https://echoudhry.github.io/clawculator)
|
|
26
|
+
|
|
27
|
+
See it run against a real config — findings, fix commands, cost exposure, session breakdown.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## One command
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx clawculator
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
No install. No account. No config. Auto-detects your OpenClaw setup. Full deterministic report in seconds.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🔒 100% offline. Zero AI.
|
|
42
|
+
|
|
43
|
+
Clawculator uses **pure switch/case deterministic logic** — no LLM, no Ollama, no model of any kind. Every finding and recommendation is hardcoded. Results are 100% reproducible and non-negotiable.
|
|
44
|
+
|
|
45
|
+
Your `openclaw.json`, session logs, and API keys never leave your machine. There is no server. Disconnect your internet and run it — it works.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## What it finds
|
|
50
|
+
|
|
51
|
+
| Source | What it catches | Severity |
|
|
52
|
+
|--------|----------------|----------|
|
|
53
|
+
| 💓 Heartbeat | Running on paid model instead of Ollama | 🔴 Critical |
|
|
54
|
+
| 💓 Heartbeat | target not set to "none" (v2026.2.24+) | 🟠 High |
|
|
55
|
+
| 🔧 Skills | Polling/cron loops on paid model | 🔴 Critical |
|
|
56
|
+
| 📱 WhatsApp | Groups auto-joined on primary model | 🔴 Critical |
|
|
57
|
+
| 🪝 Hooks | boot-md, command-logger, session-memory on Sonnet | 🟠 High |
|
|
58
|
+
| 💬 Sessions | Orphaned sessions still holding tokens | 🟠 High |
|
|
59
|
+
| 🤖 Subagents | maxConcurrent too high — burst multiplier | 🟠 High |
|
|
60
|
+
| 📁 Workspace | Too many root .md files inflating context | 🟡 Medium |
|
|
61
|
+
| 🧠 Memory | memoryFlush on primary model | 🟡 Medium |
|
|
62
|
+
| ⚙️ Primary model | Cost awareness of chosen model tier | ℹ️ Info |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx clawculator # Terminal analysis (default)
|
|
70
|
+
npx clawculator --md # Markdown report (readable by your AI agent)
|
|
71
|
+
npx clawculator --report # Visual HTML dashboard
|
|
72
|
+
npx clawculator --json # JSON for piping into other tools
|
|
73
|
+
npx clawculator --md --out=~/cost.md # Custom output path
|
|
74
|
+
npx clawculator --config=/path/to/openclaw.json
|
|
75
|
+
npx clawculator --help
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Output formats
|
|
81
|
+
|
|
82
|
+
**Terminal** — color-coded findings by severity with cost estimates and exact fix commands. Session table includes token count, total cost, $/day burn rate, and last active time (relative + absolute).
|
|
83
|
+
|
|
84
|
+
**Markdown (`--md`)** — structured report your OpenClaw agent can read directly. Drop it in your workspace and ask your agent "what's my cost status?" Session table columns: Session · Model · Tokens · Total Cost · $/day · Last Active.
|
|
85
|
+
|
|
86
|
+
**HTML (`--report`)** — visual dashboard with full session breakdown table including age and daily burn rate, cost exposure banner, opens in browser locally. Available via `npx clawculator` only — not supported in the OpenClaw skill (agents don't need to open browsers).
|
|
87
|
+
|
|
88
|
+
**JSON (`--json`)** — machine-readable, pipeable:
|
|
89
|
+
```bash
|
|
90
|
+
npx clawculator --json | jq '.summary'
|
|
91
|
+
npx clawculator --json > cost-report.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> Session keys are truncated in all output formats (first 8 chars) to avoid exposing sensitive identifiers. Hover over the Last Active column in HTML for the exact timestamp.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Use as an OpenClaw skill (ClawHub)
|
|
99
|
+
|
|
100
|
+
Install clawculator as a skill so you can type `clawculator` in your OpenClaw webchat and get a full cost report inline.
|
|
101
|
+
|
|
102
|
+
**Install via ClawHub:**
|
|
103
|
+
```bash
|
|
104
|
+
npm i -g clawhub
|
|
105
|
+
clawhub install clawculator
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Then start a new OpenClaw session and type:
|
|
109
|
+
```
|
|
110
|
+
clawculator
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Your agent runs the analysis and returns the full markdown report directly in chat.
|
|
114
|
+
|
|
115
|
+
**Or install manually** into your workspace:
|
|
116
|
+
```bash
|
|
117
|
+
mkdir -p ~/clawd/skills/clawculator
|
|
118
|
+
|
|
119
|
+
BASE=https://raw.githubusercontent.com/echoudhry/clawculator/main/skills/clawculator
|
|
120
|
+
curl -o ~/clawd/skills/clawculator/SKILL.md $BASE/SKILL.md
|
|
121
|
+
curl -o ~/clawd/skills/clawculator/run.js $BASE/run.js
|
|
122
|
+
curl -o ~/clawd/skills/clawculator/analyzer.js $BASE/analyzer.js
|
|
123
|
+
curl -o ~/clawd/skills/clawculator/reporter.js $BASE/reporter.js
|
|
124
|
+
curl -o ~/clawd/skills/clawculator/mdReport.js $BASE/mdReport.js
|
|
125
|
+
curl -o ~/clawd/skills/clawculator/htmlReport.js $BASE/htmlReport.js
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Start a new session to pick it up.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Why deterministic?
|
|
133
|
+
|
|
134
|
+
Every recommendation is a hardcoded switch/case — not generated by an AI. This means:
|
|
135
|
+
|
|
136
|
+
- Results are identical every time for the same input
|
|
137
|
+
- No hallucinations, no surprises
|
|
138
|
+
- Works completely offline with no model dependency
|
|
139
|
+
- Fast — analysis runs in under a second
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Built by
|
|
144
|
+
|
|
145
|
+
[Ed Choudhry](https://github.com/echoudhry) — after personally losing hundreds of dollars to silent API cost bleed. Every cost source in this tool was discovered the hard way.
|
|
146
|
+
|
|
147
|
+
If this saved you money, star the repo and share it in the OpenClaw Discord.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT — free forever, open source, no telemetry, no accounts.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clawculator
|
|
3
|
+
description: Analyze OpenClaw costs and detect billing issues. Source code is fully bundled — nothing is fetched at runtime. Requires only the node binary.
|
|
4
|
+
homepage: https://github.com/echoudhry/clawculator
|
|
5
|
+
user-invocable: true
|
|
6
|
+
metadata: {"openclaw":{"emoji":"🦞","requires":{"bins":["node"]}}}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## clawculator
|
|
10
|
+
|
|
11
|
+
Cost forensics for OpenClaw. Finds billing issues in your config, sessions, and workspace. Pure deterministic logic — no AI, no network calls, no external dependencies.
|
|
12
|
+
|
|
13
|
+
**Source code is fully bundled in this skill folder.** Nothing is fetched at runtime. You can audit every file before running.
|
|
14
|
+
|
|
15
|
+
**Files this skill reads:**
|
|
16
|
+
- `~/.openclaw/openclaw.json` — your OpenClaw config
|
|
17
|
+
- `~/.openclaw/agents/main/sessions/sessions.json` — session token usage
|
|
18
|
+
- `~/clawd/` — workspace root file count only (no file contents read)
|
|
19
|
+
- `/tmp/openclaw` — log directory (read only, if present)
|
|
20
|
+
|
|
21
|
+
**Files this skill may write (only when `--md` is used):**
|
|
22
|
+
- `./clawculator-report.md` — markdown report
|
|
23
|
+
- Custom path via `--out=PATH`
|
|
24
|
+
|
|
25
|
+
**No network requests are made. No shell commands are spawned.**
|
|
26
|
+
|
|
27
|
+
**Session keys are truncated in all output** (first 8 chars + ellipsis) to avoid exposing sensitive identifiers.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
**Usage**
|
|
32
|
+
|
|
33
|
+
When the user types `clawculator`, `check my costs`, `analyze spend`, or `cost report`, run:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
node {baseDir}/run.js --md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Return the full markdown report to the user inline.
|
|
40
|
+
|
|
41
|
+
**Flags**
|
|
42
|
+
- `--md` — write markdown report and print to stdout
|
|
43
|
+
- `--json` — machine-readable JSON to stdout
|
|
44
|
+
- `--out=PATH` — custom output path for `--md`
|
|
45
|
+
- `node {baseDir}/run.js --help` — full usage
|
|
46
|
+
|
|
47
|
+
**What it catches**
|
|
48
|
+
- 💓 Heartbeat running on paid model instead of Ollama
|
|
49
|
+
- 🔧 Skill polling loops on paid model
|
|
50
|
+
- 📱 WhatsApp groups auto-joined on primary model
|
|
51
|
+
- 🪝 Hooks (boot-md, command-logger, session-memory) on Sonnet
|
|
52
|
+
- 💬 Orphaned sessions still holding tokens
|
|
53
|
+
- 🤖 maxConcurrent too high — burst cost multiplier
|
|
54
|
+
- 📁 Workspace root bloat inflating context
|
|
55
|
+
- ⚙️ Primary model cost awareness
|
|
56
|
+
|
|
57
|
+
All findings include exact fix commands.
|