@cxmyu/ccglance 1.0.2 → 1.0.3

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 (3) hide show
  1. package/README.md +11 -122
  2. package/README.zh-CN.md +10 -101
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,72 +1,23 @@
1
+ <div align="center">
2
+
1
3
  # ccglance
2
4
 
3
- > A fast, zero-dependency, multi-line status line for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) — model, effort, context, cache, git and session, all at a glance.
5
+ **A fast, zero-dependency, multi-line status line for [Claude Code](https://docs.anthropic.com/en/docs/claude-code)**
6
+
7
+ model · effort · context · cache · git · session — all at a glance
4
8
 
5
9
  [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-3c873a)](https://nodejs.org/)
6
10
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
11
 
8
- English | [简体中文](./README.zh-CN.md)
9
-
10
- Repository: [github.com/CxMYu/CcGlanceLine](https://github.com/CxMYu/CcGlanceLine)
11
-
12
- `ccglance` uses the JSON that Claude Code pipes to its status-line command
13
- on stdin as its primary data source; the session `status` segment reads only
14
- the transcript tail when enabled. It's written in
15
- **TypeScript** and ships as compiled JavaScript with **zero runtime
16
- dependencies** (Node standard library only).
12
+ [English](./README.md) · [简体中文](./README.zh-CN.md) · [GitHub](https://github.com/CxMYu/CcGlanceLine)
17
13
 
18
- ## Documentation
19
-
20
- - [Segment & icon reference](./docs/segments.md) — every segment's data source, all icon meanings, rate-limit levels and color semantics
21
- - [Development](./docs/development.md) — build, test, source layout, contribution practices and git cache internals
14
+ ![ccglance preview](./docs/assets/preview.png)
22
15
 
23
- ## Preview
16
+ </div>
24
17
 
25
- ![ccglance preview](./docs/assets/preview.png)
18
+ > **stdin-first · zero runtime dependencies · fixed emoji style** — renders the JSON Claude Code pipes to its status-line command; only the `status` segment reads a bounded transcript tail. Written in TypeScript, shipped as compiled JavaScript; runs on Node.js ≥ 22 or Bun.
26
19
 
27
- Generated from `ccglance preview`.
28
-
29
- ## Features
30
-
31
- - **Compact multi-line layout** — runtime, quota and project/session state are
32
- separate logical rows; empty rows disappear.
33
- - **Zero runtime dependencies** — Node standard library only; TypeScript is a
34
- build-time tool, never shipped in the published package.
35
- - **stdin-first** — core segments consume the JSON Claude Code provides; status
36
- reads a bounded transcript tail only when used.
37
- - **Rich context block** — usage %, this-turn input/output tokens, tokens left.
38
- - **Prompt-cache block** — cache hit rate, read/write tokens.
39
- - **Git segment** — branch, clean/dirty/conflict glyph, ahead/behind counts,
40
- using one bounded `git status` call plus a short local cache.
41
- - **Session segment** — elapsed time plus lines added/removed.
42
- - **Claude Code version + update hint** — shows the `version` field from
43
- Claude Code stdin and appends `↑latest` when the 4h local cache reports a
44
- newer Claude Code release. Refresh runs after stdout and never blocks.
45
- - **Additional session context** — 5h/7d rate-limit quota, USD cost and
46
- worktree name next to the git branch when Claude Code provides it.
47
- - **Responsive multi-line layout** — probes the terminal width
48
- (`CCGLANCE_WIDTH` → `COLUMNS` → TTY → `tput`/`stty`) and wraps each row into
49
- as many lines as fit, down to a minimum of **one segment per line** so
50
- nothing gets hidden; display-width aware (CJK/emoji safe).
51
- - **Fixed built-in style** — no user config file and no external style file;
52
- the status line uses ccglance's own emoji-first style.
53
-
54
- ## Requirements
55
-
56
- - Node.js **>= 22**
57
- - `git` on `PATH` (optional — only for the git segment)
58
-
59
- Claude Code compatibility:
60
-
61
- | Claude Code CLI | ccglance behavior |
62
- |---|---|
63
- | >= 1.0.71 | Basic status-line stdin support |
64
- | >= 2.1.80 | Subscription quota row when official `rate_limits.five_hour` / `rate_limits.seven_day` fields are present |
65
- | >= 2.1.153 | Preferred terminal-width sizing through `COLUMNS` / `LINES`; older versions fall back to TTY width or 80 columns |
66
-
67
- The quota row is subscription-only. Claude.ai Pro/Max-style sessions can expose
68
- `rate_limits`; API-key, Bedrock, Vertex, and other usage-based sessions usually
69
- do not, so ccglance hides the quota row instead of inferring one.
20
+ **Docs:** [Overview](./docs/overview.md) · [Segments & icons](./docs/segments.md) · [Development](./docs/development.md)
70
21
 
71
22
  ## Install
72
23
 
@@ -76,6 +27,7 @@ do not, so ccglance hides the quota row instead of inferring one.
76
27
  npm install -g @cxmyu/ccglance # npm
77
28
  yarn global add @cxmyu/ccglance # or yarn
78
29
  pnpm add -g @cxmyu/ccglance # or pnpm
30
+ bun add -g @cxmyu/ccglance # or bun
79
31
  ```
80
32
 
81
33
  Behind a slow registry? Use a mirror:
@@ -150,69 +102,6 @@ On Windows use a full path, e.g. `node D:\\path\\to\\ccglance\\dist\\cli.js`.
150
102
  > command needs no path at all. `"padding": 0` drops Claude Code's default leading
151
103
  > indent so the row starts at the left edge.
152
104
 
153
- ## Status line at a glance
154
-
155
- Three logical rows; any row with no data disappears:
156
-
157
- 1. **Runtime** — 🤖 model · 🧠 effort · status · 🚀 fast · ⚡️ context · 💾 cache · 🎯 style
158
- 2. **Quota** *(subscription sessions only)* — 📊 Hour / Week rate-limit meters
159
- 3. **Project / session** — 📁 dir · 🌿 git · 🏷️ session name · ⏱️ session · 💰 cost · 💩 version
160
-
161
- **Full reference** — every segment's stdin source, all icon meanings, rate-limit
162
- moon-phase levels, session-status icons and color semantics — lives in
163
- **[docs/segments.md](./docs/segments.md)**.
164
-
165
- ## How it works
166
-
167
- On every redraw Claude Code runs your status-line `command` and pipes a JSON
168
- object to its **stdin** (model, effort, context window, cost, workspace,
169
- version, …). `ccglance` reads that once via `fs.readFileSync(0)`, formats its
170
- fixed rows, and **prints them first**. The `status` segment reads only a
171
- bounded transcript tail. The version segment synchronously
172
- reads only a tiny local cache; after stdout is written, ccglance refreshes the
173
- Claude Code latest-version cache in a detached background process when it is
174
- older than 4 hours. If the JSON can't be parsed it exits silently so it can never
175
- break the CLI. Text from stdin, transcript, and git is sanitized before being
176
- printed so terminal control sequences cannot escape the status line. The main
177
- external calls are local `git` (single bounded status call with a short cache),
178
- bounded transcript-tail reads, and the post-render detached npm registry check.
179
-
180
- ## Development
181
-
182
- Source build, tests, benchmark, source layout, contribution practices and git
183
- cache internals live in **[docs/development.md](./docs/development.md)**. Quick start:
184
-
185
- ```bash
186
- git clone https://github.com/CxMYu/CcGlanceLine.git
187
- cd CcGlanceLine
188
- npm install # devDeps + prepare build
189
- npm test # build + node:test
190
- ```
191
-
192
- ## Cache Files
193
-
194
- ccglance stores only disposable runtime caches: git status, transcript-derived
195
- status, and the Claude Code latest-version check. Files are grouped under
196
- `git/`, `transcript/`, and `version/`.
197
-
198
- Caches live under Claude Code's own config directory on every platform, so they
199
- travel with your Claude setup and are trivial to clear:
200
-
201
- ```text
202
- ~/.claude/ccglance/
203
- ├── git/ # git status snapshots (one per repo)
204
- ├── transcript/ # transcript-derived session status
205
- └── version/ # Claude Code latest-version check
206
- ```
207
-
208
- If you set `CLAUDE_CONFIG_DIR` to relocate Claude Code's config, ccglance places
209
- its caches under that directory instead. Deleting the whole `ccglance/` folder is
210
- safe — every file is regenerated on the next render.
211
-
212
- Git cache behavior (cache key, `HEAD` fallback, 20-minute TTL, detached refresh,
213
- atomic writes) is documented in
214
- [docs/development.md](./docs/development.md#git-cache-internals).
215
-
216
105
  ## Contributing
217
106
 
218
107
  Issues and pull requests are welcome. For code changes, run `npm run typecheck`,
package/README.zh-CN.md CHANGED
@@ -1,61 +1,23 @@
1
+ <div align="center">
2
+
1
3
  # ccglance
2
4
 
3
- > 面向 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) 的轻量多行状态栏 —— 模型、effort、上下文、缓存、git、会话,一眼尽览。TypeScript 编写、运行时零依赖。
5
+ **面向 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) 的快速、零依赖多行状态栏**
6
+
7
+ 模型 · effort · 上下文 · 缓存 · git · 会话 —— 一眼尽览
4
8
 
5
9
  [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-3c873a)](https://nodejs.org/)
6
10
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
11
 
8
- [English](./README.md) | 简体中文
9
-
10
- 仓库:[github.com/CxMYu/CcGlanceLine](https://github.com/CxMYu/CcGlanceLine)
11
-
12
- `ccglance` 以 Claude Code 通过 stdin 传入的 JSON 为主数据源;`status`
13
- 段只在启用时读取 transcript(会话记录)尾部。它用 **TypeScript** 编写,以编译后的
14
- JavaScript 发布,**运行时零依赖**(仅用 Node 标准库)。
15
-
16
- ## 文档
17
-
18
- - [字段与图标参考](./docs/segments.zh-CN.md) —— 每个段的数据来源、所有图标含义、配额档位与颜色语义
19
- - [开发](./docs/development.zh-CN.md) —— 构建、测试、代码结构、贡献范式与 git 缓存内部
20
-
21
- ## 预览
12
+ [English](./README.md) · [简体中文](./README.zh-CN.md) · [GitHub](https://github.com/CxMYu/CcGlanceLine)
22
13
 
23
14
  ![ccglance 预览](./docs/assets/preview.png)
24
15
 
25
- 截图由 `ccglance preview` 生成。
26
-
27
- ## 特性
16
+ </div>
28
17
 
29
- - **紧凑多行布局** —— 运行时、订阅配额、项目/会话分成逻辑行;无数据的行自动消失。
30
- - **运行时零依赖** —— 仅用 Node 标准库;TypeScript 仅为构建期工具,不进发布包。
31
- - **stdin 优先** —— 核心段消费 Claude Code 提供的 JSON;status 只读 transcript 尾部固定字节。
32
- - **上下文块** —— 占用百分比、本轮输入/输出 token、剩余 token。
33
- - **缓存块** —— 缓存命中率、读取/写入 token。
34
- - **git 段** —— 分支、干净/脏/冲突标记、领先/落后计数;只跑一次有界 `git status`,并带短缓存。
35
- - **会话段** —— 耗时 + 新增/删除行数。
36
- - **Claude Code 版本 + 更新提示** —— 显示 stdin 里的 Claude Code `version`;
37
- 本地 4 小时缓存发现新版时追加 `↑latest`。刷新在 stdout 写出后异步进行,不阻塞状态栏。
38
- - **额外会话信息** —— 5小时/7天配额、美元成本,以及 Claude Code 提供时显示在 git 分支右侧的 worktree 名。
39
- - **响应式多行布局** —— 读终端宽度(`COLUMNS`),把每行按能容纳的宽度自动折成多行;
40
- 正确处理 CJK/emoji 显示宽度。
41
- - **固定内置风格** —— 不读取用户配置文件,也不读取外部样式文件;状态栏使用 ccglance 自己的 emoji 优先风格。
18
+ > **stdin 优先 · 运行时零依赖 · 固定 emoji 风格** —— 渲染 Claude Code 经 stdin 传入的 JSON;仅 `status` 段读取 transcript 尾部固定字节。TypeScript 编写,以编译后的 JavaScript 发布,可在 Node.js ≥ 22 或 Bun 上运行。
42
19
 
43
- ## 环境要求
44
-
45
- - Node.js **>= 22**
46
- - `git`(可选,仅 git 段需要)
47
-
48
- Claude Code 兼容性:
49
-
50
- | Claude Code CLI | ccglance 行为 |
51
- |---|---|
52
- | >= 1.0.71 | 支持基础 statusline stdin |
53
- | >= 2.1.80 | 官方 `rate_limits.five_hour` / `rate_limits.seven_day` 字段存在时显示订阅配额行 |
54
- | >= 2.1.153 | 优先使用 `COLUMNS` / `LINES` 做终端宽度适配;更旧版本回退到 TTY 宽度或 80 列 |
55
-
56
- 配额行只面向订阅场景。Claude.ai Pro/Max 这类订阅会话可能提供 `rate_limits`;
57
- API key、Bedrock、Vertex 等按量/外部网关场景通常没有该字段,ccglance 会隐藏配额行,
58
- 不会自行推断或伪造。
20
+ **文档:** [概览](./docs/overview.zh-CN.md) · [字段与图标](./docs/segments.zh-CN.md) · [开发](./docs/development.zh-CN.md)
59
21
 
60
22
  ## 安装
61
23
 
@@ -65,6 +27,7 @@ API key、Bedrock、Vertex 等按量/外部网关场景通常没有该字段,c
65
27
  npm install -g @cxmyu/ccglance # npm
66
28
  yarn global add @cxmyu/ccglance # 或 yarn
67
29
  pnpm add -g @cxmyu/ccglance # 或 pnpm
30
+ bun add -g @cxmyu/ccglance # 或 bun
68
31
  ```
69
32
 
70
33
  registry 慢?用国内镜像:
@@ -134,60 +97,6 @@ Windows 用完整路径,例如 `node D:\\path\\to\\ccglance\\dist\\cli.js`。
134
97
  > 全局的 `ccglance` 命令则完全不需要写路径。`"padding": 0` 去掉 Claude Code 默认的左侧缩进,
135
98
  > 让状态栏从最左开始。
136
99
 
137
- ## 状态栏速览
138
-
139
- 三个逻辑行,任意一行无数据时自动消失:
140
-
141
- 1. **运行时** —— 🤖 模型 · 🧠 effort · 状态 · 🚀 fast · ⚡️ 上下文 · 💾 缓存 · 🎯 风格
142
- 2. **配额**(仅订阅会话)—— 📊 Hour / Week 配额仪表
143
- 3. **项目 / 会话** —— 📁 目录 · 🌿 git · 🏷️ 会话名 · ⏱️ 会话 · 💰 成本 · 💩 版本
144
-
145
- **完整参考** —— 每个段的 stdin 来源、所有图标含义、配额月相档位、会话状态图标与颜色语义 ——
146
- 见 **[docs/segments.zh-CN.md](./docs/segments.zh-CN.md)**。
147
-
148
- ## 原理
149
-
150
- 每次刷新时,Claude Code 会运行你配置的 `command`,并把一段 JSON(模型、effort、
151
- 上下文窗口、cost、workspace、版本……)从 **stdin** 传入。`ccglance` 用
152
- `fs.readFileSync(0)` 一次性读入、按固定行格式化并**先打印**;`status`
153
- 只会读取 transcript 尾部固定字节。版本段同步阶段只读本地小缓存;stdout 写出之后,如果
154
- Claude Code 最新版缓存超过 4 小时,才 detached 后台刷新 npm registry。若 JSON 解析失败则
155
- 静默退出,绝不影响 CLI。来自 stdin、transcript、git 的文本在输出前会清理终端控制序列,
156
- 避免逃逸到状态栏之外。主要外部调用是本地 `git`(单次有界 status 调用并带短缓存)、按需
157
- transcript 尾部读取,以及渲染后的后台版本检查。
158
-
159
- ## 开发
160
-
161
- 源码构建、测试、基准、代码结构、贡献范式与 git 缓存内部细节见
162
- **[docs/development.zh-CN.md](./docs/development.zh-CN.md)**。快速开始:
163
-
164
- ```bash
165
- git clone https://github.com/CxMYu/CcGlanceLine.git
166
- cd CcGlanceLine
167
- npm install # devDeps + prepare 构建
168
- npm test # 构建 + node:test
169
- ```
170
-
171
- ## 缓存文件
172
-
173
- `ccglance` 只落盘可丢弃的运行缓存:git 状态、transcript 派生状态、Claude Code 最新版本缓存。
174
- 文件按 `git/`、`transcript/`、`version/` 分组。
175
-
176
- 所有平台都统一落在 Claude Code 自己的配置目录下,随 Claude 配置一起走、清理也方便:
177
-
178
- ```text
179
- ~/.claude/ccglance/
180
- ├── git/ # git 状态快照(每个仓库一个)
181
- ├── transcript/ # transcript 派生的会话状态
182
- └── version/ # Claude Code 最新版本检查
183
- ```
184
-
185
- 若设置了 `CLAUDE_CONFIG_DIR` 改变 Claude Code 配置目录,ccglance 的缓存会跟着落到该目录下。
186
- 整个 `ccglance/` 目录随时可安全删除 —— 下次渲染会自动重建。
187
-
188
- git 缓存逻辑(缓存 key、`HEAD` 兜底、20 分钟 TTL、detached 刷新、原子写)见
189
- [docs/development.zh-CN.md](./docs/development.zh-CN.md#git-缓存内部细节)。
190
-
191
100
  ## 贡献
192
101
 
193
102
  欢迎提 issue 和 PR。改代码前请先跑 `npm run typecheck`、`npm run build`、`ccglance preview`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cxmyu/ccglance",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A fast, zero-dependency, multi-line status line for Claude Code — model, effort, context, cache, git and session, all at a glance.",
5
5
  "bin": {
6
6
  "ccglance": "dist/cli.js"