Skip to content

Commit 0491902

Browse files
chore: 默认 README 改为中文 + 版本 1.4.2
- README.md 改为中文(原英文移至 README.en.md),交叉链接同步 - 版本号 1.4.1 → 1.4.2(package.json + package-lock.json)
1 parent a6af647 commit 0491902

5 files changed

Lines changed: 577 additions & 577 deletions

File tree

README.en.md

Lines changed: 396 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,396 @@
1+
<div align="center">
2+
<img src="doc/banner-en.png" alt="LumenCode" width="100%">
3+
</div>
4+
5+
6+
<p align="center">
7+
<a href="https://www.npmjs.com/package/lumencode"><img src="https://img.shields.io/npm/v/lumencode.svg?style=flat-square&color=cb3837" alt="npm version"></a>
8+
<a href="https://www.npmjs.com/package/lumencode"><img src="https://img.shields.io/npm/dm/lumencode.svg?style=flat-square&color=cb3837" alt="npm downloads"></a>
9+
<a href="https://github.com/yaowen51888-rich/lumencode"><img src="https://img.shields.io/github/stars/yaowen51888-rich/lumencode.svg?style=flat-square&color=yellow" alt="GitHub stars"></a>
10+
<a href="LICENSE"><img src="https://img.shields.io/npm/l/lumencode.svg?style=flat-square&color=blue" alt="license"></a>
11+
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen.svg?style=flat-square" alt="Node.js"></a>
12+
</p>
13+
14+
<p align="center">
15+
<b>AI Coding Assistant Analytics</b> — One command to see exactly how much code AI wrote for you
16+
</p>
17+
18+
<p align="center">
19+
15-Tool Unified · Line-Level AI Attribution · 600+ Model Cost Estimation · One-Click Weekly Report
20+
</p>
21+
22+
<p align="center">
23+
<a href="README.md">中文版</a> · <a href="#cli-usage">CLI</a> · <a href="#mcp-server">MCP</a> · <a href="#faq">FAQ</a> · <a href="#whats-new">Changelog</a>
24+
</p>
25+
<div align="center">
26+
<img src="doc/数据分析页面.png" alt="LumenCode Dashboard" width="800">
27+
</div>
28+
29+
---
30+
31+
32+
## What problem does it solve?
33+
34+
> "How much code did AI write?" "Are these AI subscriptions worth it?" — Stop calculating manually. One command does it all.
35+
36+
| Scenario | Solved by LumenCode |
37+
|----------|--------------------------|
38+
| **Precise AI Contribution** | Not vague “AI helped a lot” — report AI-added and AI-deleted lines separately; contribution uses total changed lines (added + deleted). **Every line accounted for.** |
39+
| **Proving AI ROI** | Auto-generated weekly report: “This week AI assisted 12 commits, added 3,180 lines, deleted 420 lines, cost $18.50.” **Every number is traceable.** |
40+
| **Weekly reports in 3 seconds** | Pick period → click "Work Summary → Copy" → paste into Lark/DingTalk. **Done in 3 seconds.** |
41+
| **Per-project reporting** | Configure multiple projects, then select one to generate an independent report for each project lead |
42+
| **Sprint cycle alignment** | Beyond daily/weekly/monthly — pick any start/end date, no longer limited to fixed periods |
43+
| **Tracking AI costs** | Built-in **600+ model pricing** (incl. GLM, Kimi, Qwen, DeepSeek), auto-calculates equivalent API cost |
44+
45+
---
46+
47+
## How does it compare to `ccusage`?
48+
49+
Both LumenCode and [`ccusage`](https://github.com/ccusage/ccusage) read the same local logs from the same 15 agent CLIs. The difference is *what you can do with the data* — LumenCode adds a Web UI, an MCP server, and line-level AI attribution on top.
50+
51+
| | **ccusage** | **LumenCode** |
52+
|---|:---:|:---:|
53+
| **Interface** | CLI | **CLI + Web UI + MCP** |
54+
| **Line-level AI attribution** || ✅ "this line was written by AI" |
55+
| **Publishable report** | terminal / JSON | **Markdown / Lark / DingTalk** · Detailed / Brief |
56+
| **AI-generated smart report** || ✅ calls local agent for insights |
57+
| **Drill-down dashboard** || ✅ click chart → session / commit |
58+
| **Tools supported** | 15 | 15 (same set) |
59+
| **Cost & pricing** | ✅ offline + custom overrides |**600+ models** bundled (GLM / Kimi / Qwen / DeepSeek) |
60+
61+
> ccusage is a great, fast CLI — we draw inspiration from it. LumenCode reads the same `~/.claude` logs, so both run side by side with no conflict.
62+
63+
---
64+
65+
## Requirements
66+
67+
- Node.js >= 20.0.0
68+
- Native SQLite dependency (`better-sqlite3`, auto-built during `npm install`)
69+
- At least one of the [supported tools](#supported-tools--data-directories) installed with existing session logs
70+
71+
---
72+
73+
## Supported Tools & Data Directories
74+
75+
15 AI coding tools, all ✅ Fully Supported (session-level / token-level / model-level statistics).
76+
77+
| Tool | Default Log Directory | Env Var (Optional) |
78+
|------|---------------------|-------------------|
79+
| **Claude Code** | `~/.claude` | `CLAUDE_DIR` |
80+
| **OpenAI Codex** | `~/.codex` | `CODEX_DIR` |
81+
| **OpenCode** | `~/.opencode` | `OPENCODE_DIR` |
82+
| **Gemini CLI** | `~/.gemini` | `GEMINI_DIR` |
83+
| **Qwen Code** | `~/.qwen` | `QWEN_DIR` |
84+
| **Goose** | `~/.local/share/goose` | `GOOSE_DIR` |
85+
| **Amp** | `~/.local/share/amp` | `AMP_DIR` |
86+
| **Hermes Agent** | `~/.hermes` | `HERMES_DIR` |
87+
| **OpenClaw** | `~/.openclaw` | `OPENCLAW_DIR` |
88+
| **Kimi CLI** | `~/.kimi` | `KIMI_DIR` |
89+
| **Codebuff** | `~/.config/manicode` | `CODEBUFF_DIR` |
90+
| **Droid** | `~/.factory/sessions` | `DROID_DIR` |
91+
| **Pi Agent** | `~/.pi/agent/sessions` | `PI_AGENT_DIR` |
92+
| **Kilo** | `~/.local/share/kilo` | `KILO_DATA_DIR` |
93+
| **GitHub Copilot CLI** | `~/.copilot/otel` | `COPILOT_OTEL_FILE_EXPORTER_PATH` / `COPILOT_DATA_DIR` |
94+
95+
> Without env vars set, the default directory is auto-detected. Multiple accounts can be comma-separated.
96+
97+
---
98+
99+
## Get Started in 3 Seconds
100+
101+
```bash
102+
# Global install (pin to latest)
103+
npm install -g lumencode@latest
104+
lumencode serve # Start Web server, auto-opens browser
105+
106+
# Verify version (ensure ≥ 1.4.0)
107+
lumencode --version
108+
109+
# Or run without installing
110+
npx lumencode@latest serve
111+
```
112+
113+
> ⚠️ **Stuck on an old version?** Run `npm cache clean --force && npm install -g lumencode@latest` to flush the cache and reinstall.
114+
115+
**Zero-config out of the box** — First run auto-detects all 15 tools' log directories above and derives project paths from session metadata. No manual setup needed.
116+
117+
---
118+
119+
## Highlights
120+
121+
> Core: **line-level attribution × fifteen-tool unified × precise cost × one-click reports** — accounting for AI coding's ROI down to every line, every cent.
122+
123+
| Highlight | Description |
124+
|-----------|-------------|
125+
| 🎯 **Line-Level AI Attribution** | Not "AI helped with this commit" — "This line was written by AI." Hook-based step tracking + step evidence, precise down to every line |
126+
| 🔎 **Attribution Evidence Drill-Down** | Drill into any commit for per-line evidence: matched lines, source tool / session / step, confidence — every number traceable to the source |
127+
| 🌐 **Fifteen-Tool Unified** | Claude Code / Codex / Copilot and 12 more — all data auto-aggregated, one-click switch, cross-tool comparison |
128+
| 🩺 **Data Health Transparency** | `doctor` runs a one-shot health check on each tool's log parsing (success rate, last success, errors) — catch data issues early |
129+
| 📝 **One-Click Publishable Report** | Detailed / Brief reports in seconds; Markdown / Lark / DingTalk formats, copy-paste ready, each section with insights |
130+
| 🤖 **AI Smart Report** | Calls one of local Claude Code / Codex / OpenCode for AI analysis (highlights, insights, risks, recommendations); supports Default and leadership-oriented "Workhorse" styles |
131+
| 💰 **Precise Cost Estimation** | 600+ model pricing library (incl. GLM/Kimi/Qwen/DeepSeek) + Portkey API fallback; unknown models counted at $0 — real numbers only, no guessing |
132+
| 📂 **Per-Project Reports** | Multiple projects in parallel, each gets an independent report (commits + AI interaction + hotspot files) |
133+
| 📅 **Sprint Cycle Alignment** | Beyond daily/weekly/monthly — custom start/end dates to fit your iteration rhythm |
134+
| 🔍 **Trend Insights** | Peak days, active streaks, 5-category tool usage at a glance; click any chart to drill into session / commit |
135+
| 📦 **Zero-Config Out of the Box** | Auto-detects tool directories and derives project paths on first run — install and go |
136+
| 🌙 **Light / Dark Theme** | Dark mode default, all charts auto-adapt |
137+
138+
---
139+
140+
## Screenshots
141+
142+
### Data Analysis Overview
143+
144+
> Switch tools from the left sidebar. Main area shows Token usage, cost, model distribution, and AI contribution attribution.
145+
146+
<table>
147+
<tr>
148+
<td><img src="doc/数据分析页面.png" alt="Summary & Trends" width="400"></td>
149+
<td><img src="doc/数据分析页面2.png" alt="Project & Hourly Distribution" width="400"></td>
150+
</tr>
151+
<tr>
152+
<td align="center">Summary + Token Trends</td>
153+
<td align="center">Project Distribution + Hourly Activity + Session List</td>
154+
</tr>
155+
</table>
156+
157+
![AI Contribution & Commit Analysis](doc/数据分析页面3.png)
158+
159+
### Multi-Tool Dimension
160+
161+
> Switch to "All Tools" view for cross-tool aggregate data and comparative analysis.
162+
163+
![Multi-Tool Dimension](doc/多工具维度.png)
164+
165+
### Project Distribution & Sessions
166+
167+
> Per-project Token, cost, and session count stats. Click to drill down into individual session details.
168+
169+
![Project Distribution & Sessions](doc/项目分布-会话记录.png)
170+
171+
### Scenario Analysis
172+
173+
> Categorize by work type (coding / testing / debugging / docs / review / planning), with matched keyword examples.
174+
175+
![Scenario Analysis](doc/工作类型分布_匹配示例.png)
176+
177+
### Work Report · One-Click Publishable Weekly Report
178+
179+
> Natural-language paragraph reports covering Token / cost / AI contribution / project highlights / code output, each section with insight commentary.
180+
181+
- **Detailed** — Full data + insights + numbered sections, ideal for weekly/monthly reports
182+
- **Brief** — 3-5 sentence core summary, ideal for daily reports or group chat
183+
- **Smart Report** — Calls one of the local Claude Code / Codex / OpenCode agents from the page to generate AI analysis with data summary, work highlights, key insights, risks, and recommendations
184+
- **Style Selection** — Choose Default style, or "Workhorse" for a leadership-reporting tone before generation
185+
- **Persistence & Freshness Hints** — Smart reports are saved by period, project, report level, and style; stale source data prompts regeneration
186+
- **Multi-Platform Format** — Standard Markdown / Lark / DingTalk, one-click toggle
187+
- **Per-Project** — Select a project from the right panel to generate a project-specific report
188+
189+
<table>
190+
<tr>
191+
<td><img src="doc/工作汇报_详报.png" alt="Work Report - Detailed" width="400"></td>
192+
<td><img src="doc/工作汇报_简报.png" alt="Work Report - Brief" width="400"></td>
193+
</tr>
194+
<tr>
195+
<td align="center"><b>Detailed</b></td>
196+
<td align="center"><b>Brief</b></td>
197+
</tr>
198+
</table>
199+
200+
### Light / Dark Theme
201+
202+
> All chart colors auto-adapt for comfortable long sessions.
203+
204+
![Light Mode](doc/浅色模式.png)
205+
206+
> Dark mode is the default theme — the screenshots above were taken in dark mode.
207+
208+
### Settings
209+
210+
> Configure data sources (15 tool directories), enabled tools, cost mode, step-tracking attribution, scenario keywords, and appearance — all from the sidebar Settings page, organized into cards.
211+
212+
![Settings Page](doc/设置页面.png)
213+
214+
---
215+
216+
## CLI Usage
217+
218+
```bash
219+
lumencode <command> [period] [date] [options]
220+
```
221+
222+
| Command | Description |
223+
|---------|-------------|
224+
| `serve` | Start Web server (default port 4567) |
225+
| `report` | Generate CLI report (default command) |
226+
| `doctor` | Check parsing health of each tool's logs |
227+
| `init` | Initialize config file |
228+
| `hooks` | Enable/disable line-level attribution hooks (see [Line-Level AI Attribution](#line-level-ai-attribution-optional)) |
229+
| `mcp` | Start MCP Server for Claude Code / Cursor etc. (see [MCP Server](#mcp-server)) |
230+
231+
| Period | Description |
232+
|--------|-------------|
233+
| `daily` | Daily report (default) |
234+
| `weekly` | Weekly report (auto-calculates week range) |
235+
| `monthly` | Monthly report (auto-calculates month range) |
236+
237+
### Examples
238+
239+
```bash
240+
# Web mode (recommended)
241+
lumencode serve
242+
243+
# CLI daily report
244+
lumencode report daily
245+
lumencode report daily 2026-05-15
246+
247+
# Weekly / Monthly
248+
lumencode report weekly
249+
lumencode report monthly 2026-05-01
250+
251+
# Specific projects only
252+
lumencode report daily --projects D:/fzwork,E:/play/idea
253+
254+
# One-click publishable work summary
255+
lumencode report daily --work # Detailed
256+
lumencode report daily --work --brief # Brief
257+
lumencode report weekly --work
258+
```
259+
260+
---
261+
262+
## MCP Server
263+
264+
LumenCode ships with a built-in MCP Server that exposes its AI coding analytics as 7 tools, callable directly from **Claude Code / Cursor / Windsurf** and other MCP-compatible clients — query usage, generate weekly reports, and analyze code contribution right in the conversation, no need to switch to the Web UI.
265+
266+
### Tools
267+
268+
| Tool | Description |
269+
|------|-------------|
270+
| `usage_summary` | AI usage overview: token consumption, cost, session count, model distribution |
271+
| `daily_report` | Generate a usage report for a given date (Markdown) |
272+
| `work_report` | Work summary (weekly/monthly), supports normal / brief / boss styles |
273+
| `session_list` | List AI coding sessions within a time range |
274+
| `trend_analysis` | Usage trends: daily token, cost, and request volume |
275+
| `ai_contribution` | AI code contribution for a repo: contribution rate, commit attribution, hotspot files |
276+
| `cost_breakdown` | Cost breakdown: per-model / per-project spend and cache hit rate |
277+
278+
### Configuration
279+
280+
**Option 1: After global install (recommended)**
281+
282+
```bash
283+
npm install -g lumencode@latest
284+
```
285+
286+
Add to your client's MCP config (Claude Code `settings.json` shown):
287+
288+
```json
289+
{
290+
"mcpServers": {
291+
"lumencode": {
292+
"command": "lumencode-mcp"
293+
}
294+
}
295+
}
296+
```
297+
298+
**Option 2: Source / dev mode**
299+
300+
```json
301+
{
302+
"mcpServers": {
303+
"lumencode": {
304+
"command": "node",
305+
"args": ["src/mcp/server.js"]
306+
}
307+
}
308+
}
309+
```
310+
311+
Cursor / Windsurf and other clients use the same `mcpServers` field — enter it via their respective settings. You can also run `npm run mcp` or `lumencode-mcp` directly in the foreground for debugging.
312+
313+
### Highlights
314+
315+
- **Zero-config** — Auto-detects all supported tools' log directories and derives project paths from sessions
316+
- **stdio transport** — Standard MCP stdio protocol; scans and caches logs on first call, reuses thereafter
317+
- **Consistent results** — All tools share the same `lib/` stats and attribution implementations as the Web UI and CLI
318+
319+
Once configured, ask your AI assistant directly, e.g. "How much did AI coding cost me this week?", "Analyze AI contribution for the idea repo", or "Generate this week's work summary".
320+
321+
---
322+
323+
## Configuration
324+
325+
**First run auto-detects** installed tools' log directories and project paths. For customization, open the **Settings** page from the left sidebar rail. Settings are organized into cards: Data Sources, Repositories, Cost & Billing, Attribution & Tracking, Scenario Keywords, and Appearance.
326+
327+
| Setting | Description |
328+
|---------|-------------|
329+
| Each tool's log directory | Data directories for the 15 tools, auto-detected by default per the table above; overridable in Settings or `config.json` |
330+
| Enabled Tools | Specify which tools to enable, defaults to all detected |
331+
| Local Project Paths | Git repo paths for code commit stats and AI attribution |
332+
| Excluded Projects | Project names to exclude |
333+
| Scenario Keywords | Work type classification keyword JSON |
334+
| Cost Mode | Cost calculation source: `auto` (prefer log cost, fall back to pricing) · `calculate` (always recompute from token pricing) · `display` (raw log values only) |
335+
| Step Tracking | Toggle step-level recording for line attribution (see [Line-Level AI Attribution](#line-level-ai-attribution-optional)) |
336+
| AI Attribution Params | Expert thresholds/weights for attribution scoring — read-only preview in UI; edit `config.json` directly to change |
337+
338+
### Line-Level AI Attribution (Optional)
339+
340+
Line-level attribution uses AI coding tool hooks to record file-edit steps, refining AI contribution from commit/file level down to line level. Claude Code uses `PostToolBatch`, Codex uses `PostToolUse`, OpenCode uses a project-level plugin. The feature is opt-in: without an initialized database, the hook silently skips and normal usage is unaffected. In the Web UI, every attributed commit drills down to line-level evidence — which lines were matched, and which tool / session / step they came from.
341+
342+
```bash
343+
# Run in the Git project root you want to track
344+
node index.js hooks status
345+
node index.js hooks enable # Interactive tool selection, steps init, auto config backup
346+
```
347+
348+
Enabling only modifies the current project's local config (`.claude/settings.local.json`, `.codex/config.toml`, `.opencode/plugins/lumencode-step-tracker.js`) — global config and other projects are untouched. To disable:
349+
350+
```bash
351+
node index.js hooks disable
352+
```
353+
354+
Data is written to `.lumencode/steps.db` in the current project. Existing `.ccusage/steps.db` files from older versions are copied to the new path on first use and kept as rollback-safe legacy backups.
355+
356+
### Model Pricing Data
357+
358+
- **Local table** — 590 models pre-synced from [Portkey-AI/models](https://github.com/Portkey-AI/models) with vendor canonical names
359+
- **Alias mapping** — 28 authoritative overrides mapping aggregator aliases (`glm-5.1`, `kimi-for-coding`) to correct pricing
360+
- **API fallback** — Unknown models auto-queried via Portkey's free API, results cached to `data/pricing-cache.json`; local + fallback covers 600+ models
361+
- **Graceful degradation** — When API is unavailable, the model is counted at $0 (won't be guessed), other models unaffected
362+
363+
---
364+
365+
## FAQ
366+
367+
| Issue | Solution |
368+
|-------|----------|
369+
| Browser shows "No Data" | First run will guide you through config; if skipped, open the Settings page (left sidebar) |
370+
| Log directory not found on Windows | Default path is `C:\Users\<username>\.claude`, ensure `projects/` subdirectory exists |
371+
| Port 4567 in use | Set env variable: `set LUMENCODE_PORT=8080 && lumencode serve` |
372+
| Git stats not found | Project path is auto-derived from session `cwd`; if still unrecognized, set it manually in Settings |
373+
| Cost showing $0 | Model not in pricing table — try with network connection to let API fallback resolve, or add an `aliasOf` entry in `data/pricing.json` overrides |
374+
| Smart report unavailable | Smart reports require one of local Claude Code / Codex / OpenCode — ensure the corresponding command is in your PATH |
375+
376+
---
377+
378+
## What's New
379+
380+
📖 [Full changelog → Releases](https://github.com/yaowen51888-rich/lumencode/releases)
381+
382+
---
383+
384+
## Support This Project
385+
386+
If this tool helps you:
387+
388+
- **Star this repo** — Help others discover it
389+
- **File an issue** — Report bugs or request features
390+
- **Open a PR** — Contributions welcome for model pricing, scenario keywords, or new tool adapters
391+
392+
---
393+
394+
## License
395+
396+
[MIT](LICENSE) © [zhangyaowen](https://github.com/yaowen51888-rich)

0 commit comments

Comments
 (0)