claude-web-ui 1.0.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_web_ui-1.0.0/.githooks/pre-commit +5 -0
- claude_web_ui-1.0.0/.gitignore +37 -0
- claude_web_ui-1.0.0/LICENSE +201 -0
- claude_web_ui-1.0.0/PKG-INFO +353 -0
- claude_web_ui-1.0.0/README.md +322 -0
- claude_web_ui-1.0.0/claude_web/__init__.py +3 -0
- claude_web_ui-1.0.0/claude_web/__main__.py +6 -0
- claude_web_ui-1.0.0/claude_web/server.py +1308 -0
- claude_web_ui-1.0.0/claude_web/static/index.html +3029 -0
- claude_web_ui-1.0.0/pyproject.toml +50 -0
- claude_web_ui-1.0.0/requirements.txt +5 -0
- claude_web_ui-1.0.0/screenshots/dark.png +0 -0
- claude_web_ui-1.0.0/screenshots/diff.png +0 -0
- claude_web_ui-1.0.0/screenshots/main.png +0 -0
- claude_web_ui-1.0.0/screenshots/stats.png +0 -0
- claude_web_ui-1.0.0/screenshots/stream.png +0 -0
- claude_web_ui-1.0.0/scripts/check_sensitive_info.py +285 -0
- claude_web_ui-1.0.0/server.py +1279 -0
- claude_web_ui-1.0.0/static/index.html +3029 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
|
|
15
|
+
# Build artifacts
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
*.whl
|
|
19
|
+
|
|
20
|
+
# Runtime data (user-specific, contains PII)
|
|
21
|
+
history/
|
|
22
|
+
uploads/
|
|
23
|
+
claude-web.db
|
|
24
|
+
claude-web.db-journal
|
|
25
|
+
claude-web.db-wal
|
|
26
|
+
claude-web.db-shm
|
|
27
|
+
|
|
28
|
+
# Editor / OS
|
|
29
|
+
.DS_Store
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
Thumbs.db
|
|
35
|
+
|
|
36
|
+
# Logs
|
|
37
|
+
*.log
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claude-web-ui
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Web UI for Claude Code CLI — token streaming, tool visualization, checkpoint rollback, multi-session management
|
|
5
|
+
Project-URL: Homepage, https://github.com/heng1234/claude-web
|
|
6
|
+
Project-URL: Repository, https://github.com/heng1234/claude-web
|
|
7
|
+
Project-URL: Issues, https://github.com/heng1234/claude-web/issues
|
|
8
|
+
Author: heng1234
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: anthropic,claude,claude-code,fastapi,llm,web-ui
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Web Environment
|
|
14
|
+
Classifier: Framework :: FastAPI
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Requires-Dist: fastapi>=0.110
|
|
26
|
+
Requires-Dist: pypdf>=4.0
|
|
27
|
+
Requires-Dist: python-docx>=1.0
|
|
28
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.27
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Claude Code Web
|
|
33
|
+
|
|
34
|
+
一个给 [Claude Code](https://docs.claude.com/claude-code) CLI 加可视化界面的 Web 应用。后端用 FastAPI 包装 `claude -p --output-format stream-json`,前端通过 SSE 流式渲染对话、工具调用、思考过程。
|
|
35
|
+
|
|
36
|
+
> 🔒 **隐私说明**:本工具只是 `claude` CLI 的本地 GUI 包装器,不上传任何数据到第三方服务。所有对话、图片、会话历史都存在本机 `history/` `uploads/` `claude-web.db` 中。认证沿用你本地 `claude` 的登录态(`~/.claude/`),本工具不接触任何 API Key。
|
|
37
|
+
|
|
38
|
+
## 📸 截图
|
|
39
|
+
|
|
40
|
+
### 主对话界面
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
### Token 级流式输出 & 工具调用可视化
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
### Edit 工具并排 Diff
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
### 使用统计面板
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
### 暗黑模式
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
## ✨ 特性
|
|
56
|
+
|
|
57
|
+
### 💬 对话
|
|
58
|
+
- **Token 级流式输出**(打字机效果)
|
|
59
|
+
- 多轮对话(基于 `claude --resume`)
|
|
60
|
+
- 停止正在运行的任务
|
|
61
|
+
- **跟进建议**:回答后自动生成 3 个「你可能想继续问」的追问按钮
|
|
62
|
+
- **会话分叉**:基于任意历史消息编辑 / 重新生成,原会话保留
|
|
63
|
+
- **思考动画**:等待响应时用跳动圆点 + 扫光文字提示
|
|
64
|
+
|
|
65
|
+
### 📝 输入
|
|
66
|
+
- 文本 + 图片(**文件选择 / 粘贴 / 拖拽**)
|
|
67
|
+
- **文档上传**:PDF / DOCX / CSV / TSV / TXT / MD / JSON / LOG 自动提取文本作为上下文
|
|
68
|
+
- **URL 自动检测**:输入框里粘贴链接,发送时自动抓取网页正文
|
|
69
|
+
- **联网搜索开关**:一键激活 WebSearch / WebFetch
|
|
70
|
+
- `@` 引用工作目录下的文件(↑↓ 选择)
|
|
71
|
+
- Token 估算 + 草稿自动保存
|
|
72
|
+
- 提示词模板库
|
|
73
|
+
|
|
74
|
+
### 🎨 渲染
|
|
75
|
+
- Markdown + 代码高亮(highlight.js)
|
|
76
|
+
- 工具调用图标化(Bash / Read / Write / Edit 等)
|
|
77
|
+
- **Edit 工具并排 diff**
|
|
78
|
+
- **Mermaid** 图表 + **LaTeX** 公式
|
|
79
|
+
- **代码块一键运行**:Python / JavaScript / Bash 现场执行,输出嵌在对话里
|
|
80
|
+
- 图片 Lightbox(点击放大)
|
|
81
|
+
- 代码块 / 全文一键复制
|
|
82
|
+
- **滚动控制**:流式输出中手动往上滚不被打断,右下角浮动「跳到最新 ↓」按钮带新内容计数
|
|
83
|
+
|
|
84
|
+
### 🗂 会话管理
|
|
85
|
+
- 📌 置顶 / 📥 归档 / 🏷 标签
|
|
86
|
+
- 🪄 AI 智能命名(让 Claude 给会话起标题)
|
|
87
|
+
- 双击标题重命名
|
|
88
|
+
- 搜索(标题 + 内容)
|
|
89
|
+
- 导出为 Markdown
|
|
90
|
+
|
|
91
|
+
### 🛡 安全 & 回滚
|
|
92
|
+
- **权限策略**:自由 / 允许编辑 / 计划 / 只读 / 自定义工具列表
|
|
93
|
+
- **工具权限重试**:当 Claude 因权限不足无法使用工具时,UI 弹出提示卡片,支持一键放行工具并重试本轮(无需切到 CLI)
|
|
94
|
+
- **Git Checkpoint**:每轮对话前自动 `git stash create` 快照,一键回滚文件
|
|
95
|
+
- **编辑 / 重新生成**:基于任意历史消息分叉新会话
|
|
96
|
+
- **SSRF 防护**:URL 抓取拒绝私网 / 本地主机
|
|
97
|
+
|
|
98
|
+
### 📋 TodoWrite 实时看板
|
|
99
|
+
- Claude 调用 TodoWrite 时右上角弹出任务面板
|
|
100
|
+
- 进度条 + 逐项状态(⬜ 待办 / ⏳ 进行中 / ✅ 完成)
|
|
101
|
+
- 多次 TodoWrite 调用自动队列回放,进度动画
|
|
102
|
+
- 面板可折叠 / 关闭
|
|
103
|
+
|
|
104
|
+
### 📊 其它
|
|
105
|
+
- 模型切换(Opus / Sonnet / Haiku)
|
|
106
|
+
- 使用统计(总成本 / 每日成本柱图 / 工具使用排行)
|
|
107
|
+
- Git 状态栏(branch / dirty 文件数)
|
|
108
|
+
- 系统提示词自定义
|
|
109
|
+
- 暗黑模式
|
|
110
|
+
- 快捷键:`⌘K` 搜索 · `⌘N` 新会话 · `Esc` 关闭弹窗
|
|
111
|
+
- 浏览器通知 + 完成提示音
|
|
112
|
+
- 移动端响应式(侧栏可收起)
|
|
113
|
+
- IME 输入法兼容(中文拼音回车不误发)
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🚀 快速开始
|
|
118
|
+
|
|
119
|
+
### 前置条件
|
|
120
|
+
|
|
121
|
+
1. **已安装 [Claude Code CLI](https://docs.claude.com/claude-code/quickstart)**:
|
|
122
|
+
```bash
|
|
123
|
+
npm install -g @anthropic-ai/claude-code
|
|
124
|
+
claude # 首次登录
|
|
125
|
+
```
|
|
126
|
+
2. **Python 3.9+**
|
|
127
|
+
|
|
128
|
+
### 安装
|
|
129
|
+
|
|
130
|
+
#### 方式一:pip 安装(推荐)
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install claude-web-ui
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
安装完成后一条命令启动:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
claude-web
|
|
140
|
+
# 浏览器打开 http://127.0.0.1:8765
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
更新到最新版:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pip install --upgrade claude-web-ui
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### 方式二:让 Claude Code 自己装 🎉
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
claude
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
进入交互模式后,把下面这段话丢给它:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
帮我安装 claude-web-ui:pip install claude-web-ui,然后运行 claude-web 启动服务
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> 💡 用 Claude Code 给 Claude Code 装一个 Web UI。
|
|
162
|
+
|
|
163
|
+
#### 方式三:从源码安装
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
git clone https://github.com/heng1234/claude-web.git
|
|
167
|
+
cd claude-web
|
|
168
|
+
pip install -e .
|
|
169
|
+
claude-web
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 运行
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
claude-web # 默认 127.0.0.1:8765
|
|
176
|
+
claude-web --port 9000 # 自定义端口
|
|
177
|
+
claude-web --open # 启动后自动打开浏览器
|
|
178
|
+
claude-web --host 0.0.0.0 # 局域网共享
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 局域网共享(可选)
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
claude-web --host 0.0.0.0
|
|
185
|
+
```
|
|
186
|
+
⚠️ 别暴露到公网,本工具**没有鉴权**。
|
|
187
|
+
|
|
188
|
+
### 自定义端口
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
PORT=9000 python server.py
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 多窗口并行对话
|
|
195
|
+
|
|
196
|
+
直接在新浏览器标签页 / 窗口打开 `http://127.0.0.1:8765`,点「+ 新会话」即可并行对话。每个标签页独立,互不干扰。
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 🔐 提交前敏感信息检查
|
|
201
|
+
|
|
202
|
+
仓库内置了 `.githooks/pre-commit`,会在 `git commit` 前扫描**已暂存文件**,重点拦截:
|
|
203
|
+
|
|
204
|
+
- 私钥块
|
|
205
|
+
- 常见平台 Token / API Key 模式
|
|
206
|
+
- 新增行里的 `api_key` / `token` / `password` / `secret` 这类疑似敏感赋值
|
|
207
|
+
|
|
208
|
+
首次 clone 后执行一次:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
git config core.hooksPath .githooks
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
手动检查当前文件也可以:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python3 scripts/check_sensitive_info.py --paths server.py static/index.html README.md
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
如果 hook 拦截了提交,先用 `git diff --cached` 看暂存内容,再决定是否移除或替换敏感信息。
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 🧩 技术栈
|
|
225
|
+
|
|
226
|
+
| 层 | 技术 |
|
|
227
|
+
|---|---|
|
|
228
|
+
| 后端 | Python 3.9+ · FastAPI · uvicorn · SQLite · pypdf · python-docx |
|
|
229
|
+
| 前端 | 原生 JS · TailwindCSS · marked.js · highlight.js · Mermaid · KaTeX · Chart.js |
|
|
230
|
+
| 协议 | Server-Sent Events(流式输出)· stream-json stdin(多模态图片输入) |
|
|
231
|
+
| 依赖 | `claude` CLI(透过 subprocess 调用) |
|
|
232
|
+
|
|
233
|
+
## 📐 架构
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
浏览器 ──POST /api/chat──> FastAPI
|
|
237
|
+
└─ subprocess: claude -p [message | --input-format stream-json] \
|
|
238
|
+
--output-format stream-json \
|
|
239
|
+
--include-partial-messages \
|
|
240
|
+
[--session-id | --resume] \
|
|
241
|
+
[--permission-mode | --allowed-tools]
|
|
242
|
+
└─ stdout JSON lines ──SSE──> 浏览器渲染
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- 会话 ID 首轮前端生成 UUID 通过 `--session-id` 传入,后续用 `--resume`
|
|
246
|
+
- `--include-partial-messages` 开启 token 级流式
|
|
247
|
+
- **图片输入**走 `--input-format stream-json` + stdin,base64 内联(跟 Anthropic API 多模态格式一致),而非通过 Read 工具间接读取,避免精度损失
|
|
248
|
+
- 每轮对话前若 cwd 是 git 仓库,执行 `git stash create` 创建 checkpoint
|
|
249
|
+
- 会话元数据存 SQLite(`claude-web.db`),事件流存 JSONL(`history/{session_id}.jsonl`)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## 📁 项目结构
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
claude-web/
|
|
257
|
+
├── server.py # FastAPI 主服务
|
|
258
|
+
├── static/
|
|
259
|
+
│ └── index.html # 单页前端
|
|
260
|
+
├── requirements.txt
|
|
261
|
+
├── screenshots/ # README 使用的截图
|
|
262
|
+
├── history/ # 会话事件 JSONL(运行时生成,gitignore)
|
|
263
|
+
├── uploads/ # 上传的图片/文档(运行时生成,gitignore)
|
|
264
|
+
├── claude-web.db # SQLite 会话元数据(运行时生成,gitignore)
|
|
265
|
+
└── .venv/ # 虚拟环境(gitignore)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 🧰 API 端点速查
|
|
271
|
+
|
|
272
|
+
| 端点 | 方法 | 说明 |
|
|
273
|
+
|------|------|------|
|
|
274
|
+
| `/api/chat` | POST | 主对话,SSE 流式返回 |
|
|
275
|
+
| `/api/chat/stop/{session_id}` | POST | 停止正在运行的会话 |
|
|
276
|
+
| `/api/upload` | POST | 上传图片 |
|
|
277
|
+
| `/api/upload-doc` | POST | 上传文档(PDF / DOCX / CSV / TSV / TXT / MD / JSON / LOG),自动提取文本 |
|
|
278
|
+
| `/api/exec-code` | POST | 运行代码块(Python/JS/Bash,15s 超时) |
|
|
279
|
+
| `/api/fetch-url` | POST | 抓取 URL 正文(带 SSRF 防护) |
|
|
280
|
+
| `/api/sessions` | GET | 列出所有会话(含搜索 / 归档 / 标签) |
|
|
281
|
+
| `/api/sessions/{id}` | GET/PATCH/DELETE | 查看 / 修改 / 删除会话 |
|
|
282
|
+
| `/api/sessions/{id}/export` | GET | 导出 Markdown |
|
|
283
|
+
| `/api/sessions/{id}/prepare-fork` | POST | 创建分叉会话 |
|
|
284
|
+
| `/api/sessions/{id}/prepare-inline-edit` | POST | 就地编辑历史消息并从该轮继续 |
|
|
285
|
+
| `/api/sessions/{id}/restore-checkpoint` | POST | Git 回滚 |
|
|
286
|
+
| `/api/sessions/{id}/suggest-title` | POST | AI 智能命名 |
|
|
287
|
+
| `/api/suggest-followups` | POST | 生成跟进建议 |
|
|
288
|
+
| `/api/prompts` | GET/POST/PUT/DELETE | 提示词模板 CRUD |
|
|
289
|
+
| `/api/stats` | GET | 使用统计(成本 / 工具 / 每日) |
|
|
290
|
+
| `/api/git` | GET | 当前目录 git 状态 |
|
|
291
|
+
| `/api/files` | GET | 当前目录文件列表(@ 引用用) |
|
|
292
|
+
| `/api/cwds` | GET | 最近用过的工作目录 |
|
|
293
|
+
| `/api/tags` | GET | 所有标签统计 |
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## ⚠️ 已知限制
|
|
298
|
+
|
|
299
|
+
- **权限审批是"失败后重试"模式**:不是 Cursor 那种执行中实时弹窗。当 Claude 因权限被拒时,UI 会显示琥珀色提示卡片,用户点击「允许 xxx 并重试」后系统自动把工具加入白名单并重发本轮。体验上多等一轮(20-30 秒),但功能完整。真正的实时交互审批需自建 MCP 权限服务器或双向 stream-json 通信。
|
|
300
|
+
- **Checkpoint 仅限 git 仓库**:非 git 目录跳过(后续可加 tar 快照)。
|
|
301
|
+
- **分叉会话会打包上下文**:编辑/重新生成时把历史作为前缀发给 Claude(可能多消耗 token)。
|
|
302
|
+
- **无鉴权**:仅供本地使用,不建议直接暴露公网。
|
|
303
|
+
- **代码块运行无沙盒**:Python/JS/Bash 直接在本机跑,点运行前会二次确认。
|
|
304
|
+
- **Claude CLI `-p` 模式流式局限**:CLI 在非交互模式下会整段缓冲后一次性吐事件,token 流式是"视觉动画模拟",非真实 token 速率。
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 🗺 Roadmap
|
|
309
|
+
|
|
310
|
+
### 当前实现情况
|
|
311
|
+
|
|
312
|
+
#### 已实现 ✅
|
|
313
|
+
- [x] 多轮对话、停止生成、图片输入、工具调用可视化、思考过程展示
|
|
314
|
+
- [x] 文档上传(PDF / DOCX / CSV / TSV / TXT / MD / JSON / LOG)和 URL 自动抓取上下文
|
|
315
|
+
- [x] 联网搜索开关、`@` 文件引用、Token 估算、草稿自动保存、提示词模板库
|
|
316
|
+
- [x] Mermaid / LaTeX 渲染、图片 Lightbox、代码块复制与本地运行
|
|
317
|
+
- [x] 会话置顶 / 归档 / 标签 / 搜索 / 导出 / 双击重命名 / AI 智能命名
|
|
318
|
+
- [x] 历史消息就地编辑继续、重新生成分叉、Git checkpoint 回滚
|
|
319
|
+
- [x] TodoWrite 实时看板、统计面板、Git 状态栏、暗黑模式、移动端侧栏
|
|
320
|
+
- [x] 权限策略(CLI 默认 / 允许编辑 / 计划 / 只读 / 自定义工具)和权限失败后的本会话临时放行重试
|
|
321
|
+
|
|
322
|
+
#### 部分实现 / 有限制 ⚠️
|
|
323
|
+
- [ ] 运行时交互式权限审批仍未实现;目前是预设策略 + 权限失败后重试
|
|
324
|
+
- [ ] 真正按模型原始速率的 token 级流式输出仍受 Claude CLI `-p` 模式限制
|
|
325
|
+
- [ ] Git checkpoint / 回滚仅适用于 git 仓库
|
|
326
|
+
- [ ] 代码块运行已实现,但无沙盒,只适合本机可信代码
|
|
327
|
+
|
|
328
|
+
### 待办
|
|
329
|
+
- [ ] Artifacts 侧边预览(HTML/React 实时渲染)
|
|
330
|
+
- [ ] MCP server 管理面板
|
|
331
|
+
- [ ] Slash 命令透传(`/compact` `/clear` `/init`)
|
|
332
|
+
- [ ] 导入 `~/.claude/projects/` 原生会话
|
|
333
|
+
- [ ] 基于 MCP 的真·交互审批
|
|
334
|
+
- [ ] 简单鉴权(Token / 密码)
|
|
335
|
+
- [ ] 内嵌终端(xterm.js)
|
|
336
|
+
- [ ] Projects 分组(跨会话共享上下文)
|
|
337
|
+
- [ ] 划选文字浮动工具栏
|
|
338
|
+
- [ ] 语音输入 / 朗读
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 🤝 贡献
|
|
343
|
+
|
|
344
|
+
欢迎 Issue / PR。
|
|
345
|
+
|
|
346
|
+
## 📄 License
|
|
347
|
+
|
|
348
|
+
Apache License 2.0 — 见 [LICENSE](LICENSE)
|
|
349
|
+
|
|
350
|
+
## 🙏 致谢
|
|
351
|
+
|
|
352
|
+
- [Claude Code](https://docs.claude.com/claude-code) — Anthropic
|
|
353
|
+
- [FastAPI](https://fastapi.tiangolo.com/) · [TailwindCSS](https://tailwindcss.com/) · [marked](https://github.com/markedjs/marked) · [pypdf](https://github.com/py-pdf/pypdf) · [python-docx](https://github.com/python-openxml/python-docx)
|