claude-code-dashboard 0.1.0__tar.gz
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.
- claude_code_dashboard-0.1.0/.github/pull_request_template.md +14 -0
- claude_code_dashboard-0.1.0/.github/workflows/publish.yml +115 -0
- claude_code_dashboard-0.1.0/.gitignore +24 -0
- claude_code_dashboard-0.1.0/CONTRIBUTING.md +138 -0
- claude_code_dashboard-0.1.0/LICENSE +21 -0
- claude_code_dashboard-0.1.0/PKG-INFO +296 -0
- claude_code_dashboard-0.1.0/README.md +273 -0
- claude_code_dashboard-0.1.0/claude-dash-demo.gif +0 -0
- claude_code_dashboard-0.1.0/pyproject.toml +39 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/__init__.py +7 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/__main__.py +9 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/agent_panel.py +286 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/agent_parser.py +380 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/agent_scanner.py +142 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/app.py +143 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/cli.py +103 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/constants.py +140 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/sprites.py +278 -0
- claude_code_dashboard-0.1.0/src/claude_code_dashboard/token_panel.py +63 -0
- claude_code_dashboard-0.1.0/uv.lock +671 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# PyPI 發佈工作流程
|
|
2
|
+
#
|
|
3
|
+
# 觸發方式(二擇一):
|
|
4
|
+
# A. 推送 v* tag → 自動發佈到 PyPI(正式版)
|
|
5
|
+
# B. 手動觸發 → 可選擇發佈到 TestPyPI 或 PyPI
|
|
6
|
+
#
|
|
7
|
+
# 使用前需設定 GitHub Secrets:
|
|
8
|
+
# - PYPI_API_TOKEN : PyPI 的 API Token
|
|
9
|
+
# - TEST_PYPI_API_TOKEN : TestPyPI 的 API Token
|
|
10
|
+
#
|
|
11
|
+
# 發版流程:
|
|
12
|
+
# 1. 修改 pyproject.toml 中的 version(例如 "0.2.0")
|
|
13
|
+
# 2. git commit -m "release: v0.2.0"
|
|
14
|
+
# 3. git tag v0.2.0 && git push origin main --tags
|
|
15
|
+
# 4. GitHub Actions 自動觸發發佈到 PyPI
|
|
16
|
+
#
|
|
17
|
+
# 測試發佈:到 Actions 頁面手動觸發,選擇 testpypi。
|
|
18
|
+
|
|
19
|
+
name: Publish to PyPI
|
|
20
|
+
|
|
21
|
+
on:
|
|
22
|
+
push:
|
|
23
|
+
tags:
|
|
24
|
+
- "v*"
|
|
25
|
+
|
|
26
|
+
workflow_dispatch:
|
|
27
|
+
inputs:
|
|
28
|
+
target:
|
|
29
|
+
description: "發佈目標"
|
|
30
|
+
required: true
|
|
31
|
+
type: choice
|
|
32
|
+
options:
|
|
33
|
+
- testpypi
|
|
34
|
+
- pypi
|
|
35
|
+
default: testpypi
|
|
36
|
+
|
|
37
|
+
jobs:
|
|
38
|
+
publish:
|
|
39
|
+
name: Build & Publish
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
permissions:
|
|
42
|
+
contents: read
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout
|
|
46
|
+
uses: actions/checkout@v4
|
|
47
|
+
|
|
48
|
+
- name: Install uv
|
|
49
|
+
uses: astral-sh/setup-uv@v4
|
|
50
|
+
|
|
51
|
+
- name: Set up Python
|
|
52
|
+
run: uv python install 3.12
|
|
53
|
+
|
|
54
|
+
# 取得版本號供後續步驟使用
|
|
55
|
+
- name: Get version
|
|
56
|
+
id: version
|
|
57
|
+
run: |
|
|
58
|
+
VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
|
|
59
|
+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
60
|
+
|
|
61
|
+
# 驗證 tag 版號與 pyproject.toml 一致(僅 tag 觸發時檢查)
|
|
62
|
+
- name: Verify tag matches version
|
|
63
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
64
|
+
run: |
|
|
65
|
+
TAG="${GITHUB_REF#refs/tags/v}"
|
|
66
|
+
TOML="${{ steps.version.outputs.version }}"
|
|
67
|
+
if [ "${TAG}" != "${TOML}" ]; then
|
|
68
|
+
echo "::error::Tag v${TAG} does not match pyproject.toml version ${TOML}"
|
|
69
|
+
echo "Please ensure the tag matches: git tag v${TOML}"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
echo "Version check passed: v${TAG} == ${TOML}"
|
|
73
|
+
|
|
74
|
+
- name: Build package
|
|
75
|
+
run: uv build
|
|
76
|
+
|
|
77
|
+
# Tag 觸發 → 發佈到 PyPI
|
|
78
|
+
- name: Publish to PyPI (tag)
|
|
79
|
+
if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
|
|
80
|
+
run: uv publish
|
|
81
|
+
env:
|
|
82
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
83
|
+
|
|
84
|
+
# 手動觸發 → TestPyPI
|
|
85
|
+
- name: Publish to TestPyPI (manual)
|
|
86
|
+
if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
|
|
87
|
+
run: uv publish --publish-url https://test.pypi.org/legacy/
|
|
88
|
+
env:
|
|
89
|
+
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
90
|
+
|
|
91
|
+
# 手動觸發 → PyPI
|
|
92
|
+
- name: Publish to PyPI (manual)
|
|
93
|
+
if: github.event_name == 'workflow_dispatch' && inputs.target == 'pypi'
|
|
94
|
+
run: uv publish
|
|
95
|
+
env:
|
|
96
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
97
|
+
|
|
98
|
+
- name: Summary
|
|
99
|
+
run: |
|
|
100
|
+
V="${{ steps.version.outputs.version }}"
|
|
101
|
+
if [ "${{ github.event_name }}" = "push" ]; then
|
|
102
|
+
TARGET="pypi"
|
|
103
|
+
else
|
|
104
|
+
TARGET="${{ inputs.target }}"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
if [ "${TARGET}" = "testpypi" ]; then
|
|
108
|
+
echo "### ✅ Published v${V} to TestPyPI" >> $GITHUB_STEP_SUMMARY
|
|
109
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
110
|
+
echo "Install: \`pip install -i https://test.pypi.org/simple/ claude-code-dashboard==${V}\`" >> $GITHUB_STEP_SUMMARY
|
|
111
|
+
else
|
|
112
|
+
echo "### ✅ Published v${V} to PyPI" >> $GITHUB_STEP_SUMMARY
|
|
113
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
echo "Install: \`pip install claude-code-dashboard==${V}\`" >> $GITHUB_STEP_SUMMARY
|
|
115
|
+
fi
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
|
|
13
|
+
# IDE
|
|
14
|
+
.idea/
|
|
15
|
+
.vscode/
|
|
16
|
+
*.swp
|
|
17
|
+
*.swo
|
|
18
|
+
|
|
19
|
+
# OS
|
|
20
|
+
.DS_Store
|
|
21
|
+
Thumbs.db
|
|
22
|
+
|
|
23
|
+
# uv
|
|
24
|
+
.python-version
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
感謝你有興趣貢獻 Claude Dashboard!
|
|
4
|
+
|
|
5
|
+
<br>
|
|
6
|
+
|
|
7
|
+
## 開發流程
|
|
8
|
+
|
|
9
|
+
### 分支規範
|
|
10
|
+
|
|
11
|
+
| 分支 | 用途 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `main` | 穩定版本,所有發版從此分支進行 |
|
|
14
|
+
| `feature/*` | 新功能開發(例如 `feature/dark-mode`) |
|
|
15
|
+
| `fix/*` | Bug 修復(例如 `fix/card-truncation`) |
|
|
16
|
+
|
|
17
|
+
### 提交 Pull Request
|
|
18
|
+
|
|
19
|
+
1. 從 `main` 建立功能分支
|
|
20
|
+
2. 完成開發後發起 PR 到 `main`
|
|
21
|
+
3. PR 標題簡潔描述變更內容(例如「Add dark mode support」)
|
|
22
|
+
4. PR 描述中說明:
|
|
23
|
+
- **做了什麼**:變更摘要
|
|
24
|
+
- **為什麼**:動機或對應的 Issue
|
|
25
|
+
- **如何測試**:驗證方式
|
|
26
|
+
|
|
27
|
+
> **發版權限**:僅專案維護者可以打 tag 與觸發 PyPI 發佈。
|
|
28
|
+
|
|
29
|
+
<br>
|
|
30
|
+
|
|
31
|
+
## 開發環境
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd claude-code-dashboard
|
|
35
|
+
uv sync # 建立 .venv 並安裝相依套件
|
|
36
|
+
uv run claude-dash --plan max5 # 直接執行
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
## 新增 Agent 狀態
|
|
42
|
+
|
|
43
|
+
1. 在 `constants.py` 新增 `STATE_XXX` 常數與 `STATE_DISPLAY` 項目
|
|
44
|
+
2. 在 `sprites.py` 新增對應的像素網格(2 幀)與 `SPRITE_FRAMES` 項目
|
|
45
|
+
3. 在 `agent_parser.py` 的 `parse_agent_state()` 中新增判斷邏輯
|
|
46
|
+
|
|
47
|
+
<br>
|
|
48
|
+
|
|
49
|
+
## 新增工具顯示格式
|
|
50
|
+
|
|
51
|
+
在 `constants.py` 的 `TOOL_DISPLAY` 字典中新增項目,
|
|
52
|
+
並在 `agent_parser.py` 的 `_format_tool_status()` 中新增對應的參數萃取邏輯。
|
|
53
|
+
|
|
54
|
+
<br>
|
|
55
|
+
|
|
56
|
+
## GitHub 設定(維護者)
|
|
57
|
+
|
|
58
|
+
### GitHub Secrets
|
|
59
|
+
|
|
60
|
+
Repository → Settings → **Secrets and variables** → Actions。
|
|
61
|
+
|
|
62
|
+
| Secret 名稱 | 用途 |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `TEST_PYPI_API_TOKEN` | [TestPyPI](https://test.pypi.org/manage/account/#api-tokens) 的 API Token |
|
|
65
|
+
| `PYPI_API_TOKEN` | [PyPI](https://pypi.org/manage/account/#api-tokens) 的 API Token |
|
|
66
|
+
|
|
67
|
+
### Repository 保護規則
|
|
68
|
+
|
|
69
|
+
Repository → Settings → **Rules** → Rulesets → New ruleset。
|
|
70
|
+
|
|
71
|
+
**1. Branch 保護 (`main`)**
|
|
72
|
+
|
|
73
|
+
- **Target**:
|
|
74
|
+
- Branches matching `main`
|
|
75
|
+
- **Bypass list**:
|
|
76
|
+
- Maintain
|
|
77
|
+
- Repository admin (Always allow)
|
|
78
|
+
- **Rules**:
|
|
79
|
+
- **Require a pull request before merging**
|
|
80
|
+
- **Block force pushes**
|
|
81
|
+
- **Restrict deletions**
|
|
82
|
+
|
|
83
|
+
**2. Tag 保護 (`v*`)**
|
|
84
|
+
|
|
85
|
+
- **Target**:
|
|
86
|
+
- Tags → Tag targeting criteria 填 `v*`
|
|
87
|
+
- **Bypass list**:
|
|
88
|
+
- Maintain
|
|
89
|
+
- Repository admin (Always allow)
|
|
90
|
+
- **Rules**:
|
|
91
|
+
- **Restrict creations**
|
|
92
|
+
- **Restrict deletions**
|
|
93
|
+
- **Block force pushes**
|
|
94
|
+
|
|
95
|
+
> `workflow_dispatch`(手動觸發 Actions)預設僅 write 權限以上的人可操作,無需額外設定。
|
|
96
|
+
|
|
97
|
+
<br>
|
|
98
|
+
|
|
99
|
+
## 發佈到 PyPI
|
|
100
|
+
|
|
101
|
+
### 發版流程
|
|
102
|
+
|
|
103
|
+
所有發版操作在 `main` 分支上進行。
|
|
104
|
+
|
|
105
|
+
### 測試發佈(TestPyPI)
|
|
106
|
+
|
|
107
|
+
先透過手動觸發 GitHub Actions 發到 TestPyPI 驗證:
|
|
108
|
+
|
|
109
|
+
1. 修改 `pyproject.toml` 中的 `version`(遵循 [Semantic Versioning](#版本號規則semantic-versioning))
|
|
110
|
+
2. Commit & Push 到 `main`
|
|
111
|
+
3. 到 GitHub Actions 頁面 → "Publish to PyPI" → **Run workflow** → 選擇 `testpypi`
|
|
112
|
+
4. 驗證安裝:
|
|
113
|
+
```bash
|
|
114
|
+
pip install -i https://test.pypi.org/simple/ claude-code-dashboard==0.2.0
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 正式發佈(PyPI)
|
|
118
|
+
|
|
119
|
+
確認 TestPyPI 沒問題後,打 tag 觸發正式發佈:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git tag v0.2.0
|
|
123
|
+
git push origin v0.2.0
|
|
124
|
+
# GitHub Actions 偵測到 v* tag 後自動發佈到 PyPI
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> **注意**:CI 會驗證 tag 版號與 `pyproject.toml` 中的 `version` 是否一致,不一致時發佈會失敗。
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### 版本號規則(Semantic Versioning)
|
|
131
|
+
|
|
132
|
+
| 變更類型 | 版本號 | 範例 |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| Bug 修復、微調 | Patch `x.y.Z` | `0.1.0` → `0.1.1` |
|
|
135
|
+
| 新功能、不影響既有 API | Minor `x.Y.0` | `0.1.1` → `0.2.0` |
|
|
136
|
+
| 重大變更、不相容修改 | Major `X.0.0` | `0.9.0` → `1.0.0` |
|
|
137
|
+
|
|
138
|
+
> **注意**:PyPI 不允許重新上傳相同版本號。發佈出錯時必須遞增版本號。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Claude Dashboard Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claude-code-dashboard
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terminal dashboard for Claude Code: token usage + agent status with pixel sprites
|
|
5
|
+
Project-URL: Homepage, https://github.com/linziyou0601/claude-code-dashboard
|
|
6
|
+
Project-URL: Repository, https://github.com/linziyou0601/claude-code-dashboard
|
|
7
|
+
Author-email: linziyou0601 <qqq23939889@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Requires-Dist: claude-monitor<4,>=3.1.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Claude Code Dashboard
|
|
25
|
+
|
|
26
|
+
Claude Code Dashboard 是一個終端介面(TUI)工具,整合兩大功能於同一畫面:
|
|
27
|
+
|
|
28
|
+
1. **Token 用量面板** — 直接延用 [claude-monitor (ccm)](https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor) 的即時用量介面,顯示費用、Token 消耗量、燃燒率、預測等
|
|
29
|
+
2. **Agent 狀態面板** — 受 [Pixel Agents](https://github.com/pablodelucca/pixel-agents) 啟發,以像素精靈動畫顯示每個 Claude Code 工作階段的即時狀態
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
<br>
|
|
34
|
+
|
|
35
|
+
## 功能特色
|
|
36
|
+
|
|
37
|
+
- **即時刷新** — 畫面以 2 Hz 更新,資料依指定間隔掃描
|
|
38
|
+
- **像素精靈動畫** — 5 種狀態各有兩幀動畫,使用 Unicode Braille 字元渲染(無需圖片協議支援)
|
|
39
|
+
- **多工作階段偵測** — 同一專案可同時顯示多個 Agent(自動編號 #1, #2, ...)
|
|
40
|
+
- **檔案式偵測** — 以 JSONL mtime 判斷工作階段存活,支援 macOS / Linux / Windows
|
|
41
|
+
- **ccm 原生整合** — Token 面板直接呼叫 ccm 的 `DisplayController`,顯示效果完全一致
|
|
42
|
+
- **跨終端相容** — 純 Unicode 文字輸出,VS Code 終端、iTerm2、Terminal.app 皆可使用
|
|
43
|
+
|
|
44
|
+
<br>
|
|
45
|
+
|
|
46
|
+
## 專案架構
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
claude-code-dashboard/
|
|
50
|
+
├── pyproject.toml
|
|
51
|
+
├── README.md
|
|
52
|
+
├── LICENSE
|
|
53
|
+
├── .gitignore
|
|
54
|
+
└── src/
|
|
55
|
+
└── claude_code_dashboard/
|
|
56
|
+
├── __init__.py
|
|
57
|
+
├── __main__.py
|
|
58
|
+
├── cli.py # CLI 引數解析(argparse)
|
|
59
|
+
├── constants.py # 全域常數(門檻值、預設值、顯示設定)
|
|
60
|
+
├── app.py # 主迴圈(Rich Live 即時刷新)
|
|
61
|
+
├── token_panel.py # Token 面板(封裝 ccm DisplayController)
|
|
62
|
+
├── agent_scanner.py # 工作階段掃描(JSONL mtime 偵測)
|
|
63
|
+
├── agent_parser.py # JSONL 解析(推斷 Agent 狀態)
|
|
64
|
+
├── agent_panel.py # Agent 面板(精靈卡片渲染)
|
|
65
|
+
└── sprites.py # 像素精靈定義與 Braille 渲染引擎
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 模組依賴關係
|
|
69
|
+
|
|
70
|
+
```mermaid
|
|
71
|
+
graph TD
|
|
72
|
+
CLI["cli.py<br/><i>CLI 引數解析</i>"] --> APP["app.py<br/><i>Rich Live 主迴圈</i>"]
|
|
73
|
+
APP --> TP["token_panel.py<br/><i>Token 面板</i>"]
|
|
74
|
+
APP --> AP["agent_panel.py<br/><i>Agent 面板</i>"]
|
|
75
|
+
TP --> CCM["claude_monitor<br/><i>外部套件</i>"]
|
|
76
|
+
AP --> PARSE["agent_parser.py<br/><i>JSONL 解析</i>"]
|
|
77
|
+
AP --> SCAN["agent_scanner.py<br/><i>工作階段掃描</i>"]
|
|
78
|
+
AP --> SPRITE["sprites.py<br/><i>Braille 渲染</i>"]
|
|
79
|
+
PARSE --> CONST["constants.py<br/><i>全域常數</i>"]
|
|
80
|
+
AP --> CONST
|
|
81
|
+
SCAN --> CONST
|
|
82
|
+
|
|
83
|
+
style CCM stroke:#999,stroke-dasharray: 5 5
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Agent 偵測流程
|
|
87
|
+
|
|
88
|
+
```mermaid
|
|
89
|
+
flowchart TD
|
|
90
|
+
A["掃描 ~/.claude/projects/\*/\*.jsonl"] --> B{"mtime 在時限內?"}
|
|
91
|
+
B -- 否 --> Z["跳過"]
|
|
92
|
+
B -- 是 --> C{"mtime < 30 秒?"}
|
|
93
|
+
C -- 是 --> D["✅ 視為存活"]
|
|
94
|
+
C -- 否 --> E["❌ 視為非活躍"]
|
|
95
|
+
D --> J["讀取 JSONL 尾端 32KB"]
|
|
96
|
+
E --> J
|
|
97
|
+
J --> K{"有 tool_use<br/>無 tool_result?"}
|
|
98
|
+
K -- 是 --> L{"非豁免工具<br/>且超過 7 秒?"}
|
|
99
|
+
L -- 是 --> M["⏳ 等待授權"]
|
|
100
|
+
L -- 否 --> N["✍ 工作中"]
|
|
101
|
+
K -- 否 --> O{"最後為純文字?"}
|
|
102
|
+
O -- 是 --> P{"超過 5 秒?"}
|
|
103
|
+
P -- 是 --> Q["💬 等待輸入"]
|
|
104
|
+
P -- 否 --> R["🧠 思考中"]
|
|
105
|
+
O -- 否 --> S["💤 閒置"]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 各模組職責
|
|
109
|
+
|
|
110
|
+
| 模組 | 職責 |
|
|
111
|
+
|------|------|
|
|
112
|
+
| `cli.py` | 定義 CLI 參數、進入點 |
|
|
113
|
+
| `app.py` | Rich Live 主迴圈,組合所有面板 |
|
|
114
|
+
| `token_panel.py` | 封裝 ccm 的 `DisplayController`,產生 Token 用量面板 |
|
|
115
|
+
| `agent_scanner.py` | 掃描 `~/.claude/projects/` 的 JSONL 檔案,以 mtime 判斷存活 |
|
|
116
|
+
| `agent_parser.py` | 讀取 JSONL 尾端 32KB,推斷工具使用狀態與 Agent 狀態 |
|
|
117
|
+
| `agent_panel.py` | 將工作階段與狀態組合為 Rich Panel 卡片 |
|
|
118
|
+
| `sprites.py` | 定義 14×12 像素網格,轉換為 Unicode Braille 字元 |
|
|
119
|
+
| `constants.py` | 所有門檻值、計時器、顏色、預設值的集中管理 |
|
|
120
|
+
|
|
121
|
+
<br>
|
|
122
|
+
|
|
123
|
+
## 安裝方式
|
|
124
|
+
|
|
125
|
+
### 前置需求
|
|
126
|
+
|
|
127
|
+
- **macOS / Linux / Windows**(需先安裝 [Claude Code](https://code.claude.com/docs/en/setup))
|
|
128
|
+
- **Python 3.9+**
|
|
129
|
+
- **[uv](https://docs.astral.sh/uv/)** — 新一代 Python 套件管理器(以 Rust 實作,速度極快)
|
|
130
|
+
- **[claude-monitor](https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor)** (ccm) — Token 用量追蹤(安裝時自動安裝)
|
|
131
|
+
|
|
132
|
+
> **什麼是 uv?**
|
|
133
|
+
>
|
|
134
|
+
> [uv](https://docs.astral.sh/uv/) 是 Astral 開發的 Python 套件管理器,用來取代 `pip`、`venv`、`pipx` 等工具。
|
|
135
|
+
> 它會自動管理虛擬環境與相依套件,安裝速度比 pip 快 10–100 倍。
|
|
136
|
+
>
|
|
137
|
+
> - `uv tool install <pkg>` — 將套件安裝為全域命令列工具(類似 `npm install -g`)
|
|
138
|
+
> - `uv run <cmd>` — 在專案的虛擬環境中執行命令(類似 `npx`)
|
|
139
|
+
> - `uv pip install <pkg>` — 傳統 pip 的加速替代方案
|
|
140
|
+
>
|
|
141
|
+
> 安裝 uv:`curl -LsSf https://astral.sh/uv/install.sh | sh`
|
|
142
|
+
|
|
143
|
+
### 方法一:uv tool install(推薦)
|
|
144
|
+
|
|
145
|
+
將 `claude-code-dashboard` 安裝為全域命令列工具,自動建立隔離的虛擬環境
|
|
146
|
+
|
|
147
|
+
從 PyPI 安裝(推薦):
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
uv tool install claude-code-dashboard
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
或從本機原始碼安裝:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
cd claude-code-dashboard
|
|
157
|
+
uv tool install .
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
安裝完成後,在任何目錄都可直接執行(全名或縮寫皆可):
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
claude-dash --plan max5
|
|
164
|
+
# 或
|
|
165
|
+
ccd --plan max5
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
更新到最新版:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
uv tool upgrade claude-code-dashboard
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 方法二:uv run(開發用途)
|
|
175
|
+
|
|
176
|
+
不安裝,直接在專案目錄中執行。uv 會自動建立 `.venv` 並安裝相依套件
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
cd claude-code-dashboard
|
|
180
|
+
uv run claude-dash --plan max5
|
|
181
|
+
# 或 uv run ccd --plan max5
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 方法三:pip install(傳統方式)
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
cd claude-code-dashboard
|
|
188
|
+
python -m venv .venv && source .venv/bin/activate
|
|
189
|
+
pip install .
|
|
190
|
+
claude-dash --plan max5
|
|
191
|
+
# 或 ccd --plan max5
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
<br>
|
|
195
|
+
|
|
196
|
+
## 使用方式
|
|
197
|
+
|
|
198
|
+
**名稱對照**:本專案使用三個名稱,語境不同請對應使用。
|
|
199
|
+
|
|
200
|
+
| 語境 | 名稱 | 範例 |
|
|
201
|
+
|------|------|------|
|
|
202
|
+
| PyPI 套件 / 專案目錄 | **claude-code-dashboard** | `pip install claude-code-dashboard`、`cd claude-code-dashboard` |
|
|
203
|
+
| 指令(全名) | **claude-dash** | `claude-dash --plan max5` |
|
|
204
|
+
| 指令(縮寫) | **ccd** | `ccd --plan max5` |
|
|
205
|
+
|
|
206
|
+
### 基本使用
|
|
207
|
+
|
|
208
|
+
以下範例以 `claude-dash` 為例,亦可改用縮寫 `ccd`:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# 顯示所有面板(Token + Agent),使用 max5 方案
|
|
212
|
+
claude-dash --plan max5
|
|
213
|
+
|
|
214
|
+
# 僅顯示 Agent 面板
|
|
215
|
+
claude-dash --view agents
|
|
216
|
+
|
|
217
|
+
# 僅顯示 Token 面板
|
|
218
|
+
claude-dash --view tokens
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### CLI 參數一覽
|
|
222
|
+
|
|
223
|
+
| 參數 | 預設值 | 說明 |
|
|
224
|
+
|------|--------|------|
|
|
225
|
+
| `--plan` | `max5` | Token 方案等級:`pro` / `max5` / `max20` / `custom` |
|
|
226
|
+
| `--timezone` | `Asia/Taipei` | IANA 時區名稱 |
|
|
227
|
+
| `--view` | `all` | 顯示面板:`all` / `tokens` / `agents` |
|
|
228
|
+
| `--refresh` | `10` | 資料刷新間隔(秒) |
|
|
229
|
+
| `--idle-timeout` | `10` | 隱藏閒置超過 N 分鐘的 Agent |
|
|
230
|
+
| `--max-agents` | `0` | 最多顯示的 Agent 卡片數量(0=不限) |
|
|
231
|
+
| `--show-all` | `false` | 顯示 30 分鐘內的所有工作階段 |
|
|
232
|
+
| `--no-sprites` | `false` | 停用像素精靈,改用純文字模式 |
|
|
233
|
+
| `--version` | — | 顯示版本號 |
|
|
234
|
+
|
|
235
|
+
### 使用範例
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# 快速刷新,顯示所有工作階段
|
|
239
|
+
claude-dash --plan max5 --refresh 5 --show-all
|
|
240
|
+
|
|
241
|
+
# 純文字模式(適合螢幕閱讀器或低解析度終端)
|
|
242
|
+
claude-dash --view agents --no-sprites
|
|
243
|
+
|
|
244
|
+
# 僅顯示最多 4 個 Agent
|
|
245
|
+
claude-dash --max-agents 4
|
|
246
|
+
|
|
247
|
+
# 使用不同時區
|
|
248
|
+
claude-dash --timezone America/New_York
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
<br>
|
|
252
|
+
|
|
253
|
+
## 運作原理
|
|
254
|
+
|
|
255
|
+
### Token 面板
|
|
256
|
+
|
|
257
|
+
直接匯入 ccm 的 `DisplayController.create_data_display()` 方法,該方法回傳一個 Rich `Group` 可渲染物件。這表示 Token 面板的顯示效果與 `ccm --view realtime` **完全相同**,無需重新實作任何邏輯。
|
|
258
|
+
|
|
259
|
+
### 像素精靈渲染
|
|
260
|
+
|
|
261
|
+
使用 **Unicode Braille 字元**(U+2800–U+28FF)實現終端機中的「像素級」繪圖:
|
|
262
|
+
|
|
263
|
+
- 每個 Braille 字元編碼 2×4 的點陣矩陣(8 個像素點)
|
|
264
|
+
- 比一般方塊字元精細 **8 倍**
|
|
265
|
+
- 14×12 像素的精靈網格渲染為 7 字元寬 × 3 行高
|
|
266
|
+
- 每個 2×4 區塊以「多數決」選出代表顏色
|
|
267
|
+
- 支援 7 種顏色(膚色、頭髮、上衣、褲子、強調色、家具、特效)
|
|
268
|
+
- 每種狀態有 2 幀動畫,以 0.5 秒間隔交替
|
|
269
|
+
|
|
270
|
+
> **為什麼不用 Sixel / Kitty 圖片協議?**
|
|
271
|
+
> 因為 VS Code 內建終端不支援任何圖片協議。Braille 字元是純 Unicode 文字,在所有終端都能正確顯示。
|
|
272
|
+
|
|
273
|
+
<br>
|
|
274
|
+
|
|
275
|
+
## 開發與發佈
|
|
276
|
+
|
|
277
|
+
詳見 [CONTRIBUTING.md](CONTRIBUTING.md)。
|
|
278
|
+
|
|
279
|
+
<br>
|
|
280
|
+
|
|
281
|
+
## 致謝
|
|
282
|
+
|
|
283
|
+
本專案的靈感與技術基礎來自以下開源專案:
|
|
284
|
+
|
|
285
|
+
- **[claude-monitor (ccm)](https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor)** — Token 用量面板直接呼叫 ccm 的 API,感謝 Maciej 提供優秀的 Token 追蹤工具(MIT License)
|
|
286
|
+
- **[Pixel Agents](https://github.com/pablodelucca/pixel-agents)** — Agent 狀態偵測的啟發式邏輯與像素精靈概念源自此 VS Code 擴充套件,感謝 Pablo De Lucca 的創意(MIT License)
|
|
287
|
+
|
|
288
|
+
<br>
|
|
289
|
+
|
|
290
|
+
## 授權條款
|
|
291
|
+
|
|
292
|
+
本專案採用 [MIT License](LICENSE) 授權。
|
|
293
|
+
|
|
294
|
+

|
|
295
|
+

|
|
296
|
+

|