ccus-cli 0.1.0 → 0.1.2

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  一个本地优先的 Claude Code statusline 使用率采集 CLI:
4
4
 
5
5
  - `ccus install`:自动把 statusLine 命令写进 Claude Code 的 `settings.json`,省去手动改配置。
6
- - `ccus statusline emit`:读取 Claude Code statusline 通过 `stdin` 传入的 JSON,输出 statusline 文本,并写入本地日志。
6
+ - `ccus statusline emit`:读取 Claude Code statusline 通过 `stdin` 传入的 JSON,输出 statusline 文本,并写入本地日志(加 `--no-store` / `--no-log` 则只输出、不落盘)。
7
7
  - `ccus dashboard serve`:直接启动本地 Web 页面,不用先手动生成 HTML 文件。
8
8
  - `ccus export`:默认导出当前周数据包,里面同时包含原始事件和按天维度的周汇总。
9
9
  - `ccus aggregate`:读取一个目录里的多人 export bundle json,输出明细、按天、按周三个 CSV。
@@ -21,12 +21,6 @@
21
21
  npm install -g ccus-cli
22
22
  ```
23
23
 
24
- 安装后 PATH 上即可使用 `ccus` 命令。一次性命令(如 `dashboard` / `export`)也可以用 `npx`:
25
-
26
- ```bash
27
- npx ccus-cli export
28
- ```
29
-
30
24
  要求 Node.js >= 20。
31
25
 
32
26
  ## 快速开始
@@ -88,6 +82,7 @@ ccus install
88
82
  ccus install
89
83
  ccus install --settings ~/.claude/settings.json
90
84
  ccus statusline emit
85
+ ccus statusline emit --no-store # 只渲染并输出状态行,不写本地日志(别名 --no-log)
91
86
  ccus dashboard build --range today --out ./ccus-dashboard.html
92
87
  ccus dashboard open --range today
93
88
  ccus dashboard serve --range today --open
package/dist/cli.js CHANGED
@@ -57,7 +57,7 @@ const storage_1 = require("./lib/storage");
57
57
  const time_1 = require("./lib/time");
58
58
  /** CLI 帮助信息保持简洁,方便直接挂到 README 或终端里查看。 */
59
59
  function printHelp() {
60
- process.stdout.write(`ccus\n\nCommands:\n ccus install [--settings PATH] [--command CMD] [--data-dir PATH]\n ccus statusline emit [--data-dir PATH] [--input FILE]\n ccus dashboard build [--range today|this-week|last-week|5h] [--out FILE] [--data-dir PATH]\n ccus dashboard open [--range today|this-week|last-week|5h] [--out FILE] [--data-dir PATH]\n ccus dashboard serve [--range today|this-week|last-week|5h] [--port 0] [--host 127.0.0.1] [--open] [--data-dir PATH]\n ccus export [RANGE] [--out FILE] [--data-dir PATH] (RANGE: this-week|tw, last-week|lw, today, 5h; e.g. ccus export lw)\n ccus aggregate --input-dir DIR [--out-dir DIR]\n ccus aggregate serve --input-dir DIR [--port 0] [--host 127.0.0.1]\n\nGlobal flags:\n --verbose | --debug | -v 输出详细调试日志到 stderr(等价于设置 CCUS_DEBUG=1),方便排查问题\n`);
60
+ process.stdout.write(`ccus\n\nCommands:\n ccus install [--settings PATH] [--command CMD] [--data-dir PATH]\n ccus statusline emit [--data-dir PATH] [--input FILE] [--no-store]\n ccus dashboard build [--range today|this-week|last-week|5h] [--out FILE] [--data-dir PATH]\n ccus dashboard open [--range today|this-week|last-week|5h] [--out FILE] [--data-dir PATH]\n ccus dashboard serve [--range today|this-week|last-week|5h] [--port 0] [--host 127.0.0.1] [--open] [--data-dir PATH]\n ccus export [RANGE] [--out FILE] [--data-dir PATH] (RANGE: this-week|tw, last-week|lw, today, 5h; e.g. ccus export lw)\n ccus aggregate --input-dir DIR [--out-dir DIR]\n ccus aggregate serve --input-dir DIR [--port 0] [--host 127.0.0.1]\n\nGlobal flags:\n --verbose | --debug | -v 输出详细调试日志到 stderr(等价于设置 CCUS_DEBUG=1),方便排查问题\n`);
61
61
  }
62
62
  /** 一个轻量的参数解析器,当前命令面不复杂,没必要引入额外依赖。 */
63
63
  function parseOptions(args) {
@@ -139,10 +139,14 @@ async function handleInstall(options) {
139
139
  * statusline 主路径:读 payload、归一化、落盘、输出单行状态文本。
140
140
  *
141
141
  * 这里即使异常也要优雅降级,不能因为采样失败把 statusline 弄挂。
142
+ *
143
+ * `--no-store`(别名 `--no-log`)只渲染并输出状态行,不把事件落盘,
144
+ * 适合预览 statusline 输出或临时禁用采集,stdout 单行契约保持不变。
142
145
  */
143
146
  async function handleStatuslineEmit(options) {
144
147
  const dataDir = getDataDir(options);
145
- (0, debug_1.debugLog)("statusline", "start", { dataDir });
148
+ const noStore = getBooleanOption(options, "no-store") || getBooleanOption(options, "no-log");
149
+ (0, debug_1.debugLog)("statusline", "start", { dataDir, noStore });
146
150
  try {
147
151
  const raw = await readInputPayload(options);
148
152
  (0, debug_1.debugLog)("statusline", "payload received", { length: raw.length });
@@ -152,7 +156,12 @@ async function handleStatuslineEmit(options) {
152
156
  record.gitUserName = gitIdentity.userName;
153
157
  record.gitUserEmail = gitIdentity.userEmail;
154
158
  record.gitUserAccount = (0, time_1.extractGitEmailAccount)(gitIdentity.userEmail);
155
- await (0, storage_1.appendEvent)(dataDir, record);
159
+ if (noStore) {
160
+ (0, debug_1.debugLog)("statusline", "no-store enabled, skipping appendEvent");
161
+ }
162
+ else {
163
+ await (0, storage_1.appendEvent)(dataDir, record);
164
+ }
156
165
  const event = (0, payload_1.computeStatuslineEvent)(record);
157
166
  (0, debug_1.debugLog)("statusline", "event computed", {
158
167
  sessionId: event.sessionId,
@@ -199,7 +199,7 @@ function renderDailyUserRequestChart(people, dailyIndex, dateAxis) {
199
199
  * 用横向条形图对比每个人的「周使用量(7 天额度)峰值」。
200
200
  *
201
201
  * 7 天额度是 Claude 给出的滚动周额度使用率,峰值代表这段时间里每个人最接近用满周额度的程度。
202
- * 条长按当前样本里的最大峰值做归一,方便在数值都偏小时也能横向比较;右侧仍标注绝对百分比。
202
+ * 条长按固定的 100% 满刻度归一,直接反映绝对使用率水平;右侧仍标注绝对百分比。
203
203
  */
204
204
  function renderSevenDayPeakChart(people) {
205
205
  const ranked = people
@@ -227,7 +227,7 @@ function renderSevenDayPeakChart(people) {
227
227
  const height = paddingTop + paddingBottom + ranked.length * rowHeight;
228
228
  const trackX = labelWidth;
229
229
  const trackWidth = width - labelWidth - valueWidth - 16;
230
- const maxValue = Math.max(...ranked.map((person) => person.sevenDayPeakUsagePct ?? 0), 1);
230
+ const maxValue = 100;
231
231
  const bars = ranked
232
232
  .map((person, index) => {
233
233
  const pct = person.sevenDayPeakUsagePct ?? 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccus-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Claude Code statusline usage logger and dashboard CLI",
5
5
  "type": "commonjs",
6
6
  "bin": {