@tsa-group/claude-usage 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +17 -7
  2. package/package.json +17 -5
package/README.md CHANGED
@@ -45,12 +45,20 @@ claude-usage configure --server https://<你們的 ingest host>
45
45
  # 2) 一鍵安裝:enroll(取得身份)+ 註冊 SessionStart hook + 背景任務
46
46
  # 先加 --dry-run 可預覽會做什麼、不動任何系統設定
47
47
  claude-usage install --dry-run
48
- claude-usage install --enroll-secret <管理者給你的密語>
48
+ claude-usage install
49
49
 
50
50
  # 3) 確認狀態
51
51
  claude-usage status
52
52
  ```
53
53
 
54
+ **兩個可能讓你以為「裝壞了」的情況:**
55
+
56
+ - **server 開了人工核准** → `enroll` 會回 `status: pending`,你的資料要等管理者核准後才
57
+ 開始進來。`status` 會顯示已 enroll、心跳正常,但 server 端看不到你的用量。這是正常的。
58
+ - **server 要求 enroll 密語**(多數部署不需要)→ `install --enroll-secret <密語>`,或用
59
+ 環境變數 `CLAUDE_USAGE_ENROLL_SECRET`。⚠️ 寫在指令列會留在你的 shell history 裡,
60
+ 能用環境變數就用環境變數。
61
+
54
62
  安裝後會發生:
55
63
 
56
64
  - **hook**(開 session 時):抓一筆即時額度快照。註冊在 `~/.claude/settings.json` 的
@@ -107,19 +115,20 @@ npm rm -g @tsa-group/claude-usage
107
115
  | 指令 | 用途 |
108
116
  |---|---|
109
117
  | `configure --server <url>` | 設定 ingest server 位址 |
110
- | `install [--enroll-secret <s>] [--dry-run]` | enroll + hook + 背景任務 |
118
+ | `install [--dry-run]` | enroll + hook + 背景任務 |
111
119
  | `status` | 裝好了嗎?**採樣真的有在動嗎?** |
112
120
  | `uninstall` | 移除 hook 與背景任務 |
113
121
  | `show [--history]` | 看自己的額度水位 / 時間序 |
114
122
  | `sessions [--json]` | session 與 token 明細 |
115
123
  | `sample [--hook]` | 手動抓一筆額度快照 |
116
124
  | `daemon-tick [--explain]` | 背景排程器呼叫的單元;`--explain` 只印決策不採樣 |
117
- | `enroll [--enroll-secret <s>]` | 手動與 server 溝通取得身份 |
125
+ | `enroll` | 手動與 server 溝通取得身份 |
118
126
  | `report [--full] [--dry-run]` | 手動上報。`--full` 忽略游標整包重送(重送是安全的) |
119
127
  | `health` | 背景任務心跳;不健康時 **exit 1**(可接監控) |
120
128
 
121
- `--enroll-secret` **刻意不寫進設定檔**:enroll 是一次性動作,把密語落地在每台機器上只是
122
- 多開一個洩漏面。也可用環境變數 `CLAUDE_USAGE_ENROLL_SECRET`。
129
+ `install` / `enroll` 都接受 `--enroll-secret <s>`,但**只有在 server 要求時才需要**。
130
+ 它不會被寫進設定檔;若要避免留在 shell history,改用環境變數
131
+ `CLAUDE_USAGE_ENROLL_SECRET`。
123
132
 
124
133
  ---
125
134
 
@@ -199,8 +208,9 @@ Client 對 server 只用兩個端點,皆為 `application/json`:
199
208
  - **Linux 背景任務未實作**(systemd --user timer)。其餘指令可用。
200
209
  - **`session_id` 跨 compaction / resume 不穩定**:session **數**會高估。token 與成本不受影響
201
210
  (那是 per-event 去重的,與 session 身份無關)。
202
- - **enroll 是 client 自報身份**:可偽造 email / org,共享密語擋得住路過的人,擋不住內部人。
203
- 要真正的身份保證需要 server 端接 SSO 或人工核准流程。
211
+ - **enroll 是 client 自報身份**:profile client 自己打 Anthropic 取得後轉送,理論上可
212
+ 偽造 email / org。共享密語**不解決這件事**(知道密語的人一樣能冒充別人),它只擋路過的
213
+ 流量。要真正的身份保證需要 server 端接 SSO / OIDC,或用人工核准流程把關。
204
214
 
205
215
  ---
206
216
 
package/package.json CHANGED
@@ -1,18 +1,30 @@
1
1
  {
2
2
  "name": "@tsa-group/claude-usage",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Per-user Claude usage collector — measures Claude Code token detail and account-level rate-limit utilization locally, reports to your own ingest server.",
5
5
  "type": "module",
6
- "bin": { "claude-usage": "dist/cli.js" },
7
- "files": ["dist", "README.md"],
8
- "engines": { "node": ">=20" },
6
+ "bin": {
7
+ "claude-usage": "dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
9
16
  "scripts": {
10
17
  "build": "tsc -p tsconfig.json",
11
18
  "test": "node --test test/*.test.ts",
12
19
  "prepublishOnly": "npm run build && npm test",
13
20
  "check": "tsc -p tsconfig.json --noEmit"
14
21
  },
15
- "keywords": ["claude", "usage", "telemetry", "cli"],
22
+ "keywords": [
23
+ "claude",
24
+ "usage",
25
+ "telemetry",
26
+ "cli"
27
+ ],
16
28
  "license": "UNLICENSED",
17
29
  "private": false,
18
30
  "devDependencies": {