@xerg/cli 0.1.4 → 0.1.6

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.
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: xerg
3
+ description: Audit OpenClaw agent spend in dollars. Use for local or remote audits, before/after comparisons, CI threshold gates, and machine-readable recommendations.
4
+ ---
5
+
6
+ # Xerg
7
+
8
+ Use `xerg` if it is already installed. If not, use `npx @xerg/cli` with the same arguments.
9
+
10
+ Xerg audits OpenClaw spend in dollars and surfaces both confirmed waste and savings opportunities. It can analyze local files, pull remote sources over SSH or Railway, compare against prior local snapshots, and optionally push audit summaries to the Xerg API.
11
+
12
+ ## Inputs
13
+
14
+ Xerg needs one of these source inputs:
15
+
16
+ - Local OpenClaw data at the default paths:
17
+ - `/tmp/openclaw/openclaw-*.log`
18
+ - `~/.openclaw/agents/*/sessions/*.jsonl`
19
+ - Explicit paths via `--log-file` and/or `--sessions-dir`
20
+ - An SSH target via `--remote`
21
+ - A Railway target via `--railway`
22
+ - A multi-source config via `--remote-config`
23
+
24
+ Additional requirements:
25
+
26
+ - `--compare` needs at least one previously stored compatible local snapshot
27
+ - Pushing needs auth via `XERG_API_KEY`, `~/.xerg/config.json`, or `xerg login`
28
+ - SSH audits require `ssh` and `rsync` on your local `PATH`
29
+ - Railway audits require the `railway` CLI on your local `PATH`
30
+
31
+ ## Default Flow
32
+
33
+ 1. Detect sources first when paths or connectivity are uncertain:
34
+
35
+ ```bash
36
+ xerg doctor
37
+ xerg doctor --remote user@host
38
+ xerg doctor --railway
39
+ ```
40
+
41
+ 2. Run a baseline audit:
42
+
43
+ ```bash
44
+ xerg audit
45
+ ```
46
+
47
+ 3. Choose the right output mode for the task:
48
+
49
+ ```bash
50
+ xerg audit
51
+ xerg audit --json
52
+ xerg audit --markdown
53
+ ```
54
+
55
+ - Plain `xerg audit` is best for a human-readable summary
56
+ - `xerg audit --json` is best for automation and agents
57
+ - `xerg audit --markdown` is best for a shareable report
58
+
59
+ 4. After a workflow or model change, measure the delta:
60
+
61
+ ```bash
62
+ xerg audit --compare
63
+ xerg audit --compare --json
64
+ ```
65
+
66
+ 5. Export or push only when needed:
67
+
68
+ ```bash
69
+ xerg audit --markdown > xerg-audit.md
70
+ xerg audit --push
71
+ xerg push
72
+ ```
73
+
74
+ ## Source Selection
75
+
76
+ Local defaults:
77
+
78
+ ```bash
79
+ xerg audit
80
+ ```
81
+
82
+ Explicit local paths:
83
+
84
+ ```bash
85
+ xerg audit --log-file /path/to/openclaw.log
86
+ xerg audit --sessions-dir /path/to/sessions
87
+ ```
88
+
89
+ SSH remote:
90
+
91
+ ```bash
92
+ xerg audit --remote user@vps.example.com
93
+ xerg audit --remote user@vps.example.com \
94
+ --remote-log-file /opt/openclaw/logs/openclaw.log \
95
+ --remote-sessions-dir /opt/openclaw/sessions
96
+ ```
97
+
98
+ Railway:
99
+
100
+ ```bash
101
+ xerg audit --railway
102
+ xerg audit --railway --project <id> --environment <id> --service <id>
103
+ ```
104
+
105
+ Multiple remote sources:
106
+
107
+ ```bash
108
+ xerg audit --remote-config ~/.xerg/remotes.json
109
+ ```
110
+
111
+ Remote config files use this shape:
112
+
113
+ ```json
114
+ {
115
+ "remotes": [
116
+ {
117
+ "name": "prod",
118
+ "transport": "ssh",
119
+ "host": "deploy@prod.example.com"
120
+ },
121
+ {
122
+ "name": "railway-prod",
123
+ "transport": "railway",
124
+ "railway": {
125
+ "projectId": "...",
126
+ "environmentId": "...",
127
+ "serviceId": "..."
128
+ }
129
+ }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ ## CI And Automation
135
+
136
+ For CI gates, prefer a single command so the audit can still be pushed before threshold failure:
137
+
138
+ ```bash
139
+ xerg audit --push --fail-above-waste-rate 0.25 --fail-above-waste-usd 100
140
+ ```
141
+
142
+ Common variants:
143
+
144
+ ```bash
145
+ xerg audit --fail-above-waste-rate 0.30
146
+ xerg audit --fail-above-waste-usd 50
147
+ xerg audit --since 24h --fail-above-waste-rate 0.30
148
+ ```
149
+
150
+ Documented exit codes:
151
+
152
+ - `0` success
153
+ - `1` runtime error
154
+ - `2` no OpenClaw data found
155
+ - `3` threshold exceeded
156
+
157
+ Automation can branch on those codes instead of scraping terminal output.
158
+
159
+ ## Recommendations
160
+
161
+ When using `--json`, expect a `recommendations` array alongside the audit summary. Recommendation items include:
162
+
163
+ - `id`, `findingId`, `kind`, `title`, `description`
164
+ - `estimatedSavingsUsd`, `confidence`, `actionType`
165
+ - optional `suggestedChange`
166
+
167
+ Current recommendation kinds fall into two buckets:
168
+
169
+ - Confirmed waste: `retry-waste`, `loop-waste`
170
+ - Savings opportunities or directional findings: `context-outlier`, `idle-spend`, `candidate-downgrade`
171
+
172
+ Prefer reversible or high-confidence fixes first. Treat model downgrades and context reductions as A/B-test candidates, not guaranteed savings.
173
+
174
+ ## Checks
175
+
176
+ Before finalizing work that used Xerg:
177
+
178
+ - Say whether the audit was local, SSH, Railway, or multi-source
179
+ - Say whether the output was plain terminal text, JSON, or Markdown
180
+ - If `--compare` was used, confirm that it compared against a compatible stored snapshot
181
+ - If no data was found, run `xerg doctor` or use explicit source flags rather than guessing
182
+ - Say whether results were pushed to the Xerg API
183
+
184
+ ## Notes
185
+
186
+ - `--compare` and `--no-db` cannot be used together
187
+ - Xerg is local-first: it stores economic metadata and audit snapshots locally, not prompt or response content
188
+ - `XERG_API_KEY` is recommended for CI and non-interactive automation
189
+ - If browser auth is needed locally, use `xerg login`; remove stored credentials with `xerg logout`
190
+ - Pilot: [xerg.ai/pilot](https://xerg.ai/pilot)
191
+ - Support: `query@xerg.ai`