ccus-cli 0.1.1 → 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 +2 -1
- package/dist/cli.js +12 -3
- package/package.json +1 -1
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。
|
|
@@ -82,6 +82,7 @@ ccus install
|
|
|
82
82
|
ccus install
|
|
83
83
|
ccus install --settings ~/.claude/settings.json
|
|
84
84
|
ccus statusline emit
|
|
85
|
+
ccus statusline emit --no-store # 只渲染并输出状态行,不写本地日志(别名 --no-log)
|
|
85
86
|
ccus dashboard build --range today --out ./ccus-dashboard.html
|
|
86
87
|
ccus dashboard open --range today
|
|
87
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
|
-
(
|
|
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
|
-
|
|
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,
|