iflow-run 1.0.0
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/LICENSE +21 -0
- package/README.md +274 -0
- package/bin/iflow-run.js +58 -0
- package/package.json +1 -0
- package/public/app.js +1629 -0
- package/public/index.html +290 -0
- package/public/styles.css +1501 -0
- package/public/test.html +46 -0
- package/server.js +252 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeWen-Du
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# iFlow-run
|
|
2
|
+
|
|
3
|
+
一个用于查看 iFlow CLI 会话轨迹和历史会话的 Web 应用程序。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 📁 **项目管理** - 浏览和查看 iFlow CLI 创建的所有项目
|
|
8
|
+
- 💬 **会话浏览** - 查看每个项目下的所有会话历史
|
|
9
|
+
- 🔍 **消息详情** - 查看完整的对话消息,包括用户消息、助手响应、工具调用和工具结果
|
|
10
|
+
- 👁️ **预览功能** - 快速预览会话的第一条消息内容
|
|
11
|
+
- 🎨 **现代 UI** - 采用暗色主题和玻璃拟态设计,提供优雅的用户体验
|
|
12
|
+
- 📱 **响应式设计** - 支持桌面端和移动端访问
|
|
13
|
+
|
|
14
|
+
## 技术栈
|
|
15
|
+
|
|
16
|
+
- **后端**: Node.js + Express
|
|
17
|
+
- **前端**: 纯 HTML5 + CSS3 + JavaScript (无框架)
|
|
18
|
+
- **样式**: 自定义 CSS,使用现代暗色主题
|
|
19
|
+
- **依赖**:
|
|
20
|
+
- express (^4.18.2)
|
|
21
|
+
- cors (^2.8.5)
|
|
22
|
+
|
|
23
|
+
## 快速开始
|
|
24
|
+
|
|
25
|
+
### 环境要求
|
|
26
|
+
|
|
27
|
+
- Node.js (v14 或更高版本)
|
|
28
|
+
- npm (随 Node.js 一起安装)
|
|
29
|
+
|
|
30
|
+
### 方式一:通过 npm 全局安装(推荐)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 全局安装
|
|
34
|
+
npm install -g iflow-run
|
|
35
|
+
|
|
36
|
+
# 启动服务
|
|
37
|
+
iflow-run
|
|
38
|
+
|
|
39
|
+
# 访问应用
|
|
40
|
+
# 打开浏览器访问 http://localhost:3000
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### 命令行参数
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 指定端口
|
|
47
|
+
iflow-run --port=8080
|
|
48
|
+
|
|
49
|
+
# 指定 iflow 数据目录
|
|
50
|
+
iflow-run --dir=/path/to/.iflow
|
|
51
|
+
|
|
52
|
+
# 使用环境变量
|
|
53
|
+
IFLOW_RUN_PORT=8080 iflow-run
|
|
54
|
+
IFLOW_RUN_DIR=/path/to/.iflow iflow-run
|
|
55
|
+
|
|
56
|
+
# 查看帮助
|
|
57
|
+
iflow-run --help
|
|
58
|
+
|
|
59
|
+
# 查看版本
|
|
60
|
+
iflow-run --version
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 方式二:本地运行
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 克隆或下载项目
|
|
67
|
+
cd iflow-run
|
|
68
|
+
|
|
69
|
+
# 安装依赖
|
|
70
|
+
npm install
|
|
71
|
+
|
|
72
|
+
# 启动服务器
|
|
73
|
+
npm start
|
|
74
|
+
|
|
75
|
+
# 或使用 npx 运行(如果已全局安装)
|
|
76
|
+
npx iflow-run
|
|
77
|
+
|
|
78
|
+
# 访问应用
|
|
79
|
+
# 打开浏览器访问 http://localhost:3000
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
应用会自动读取您系统中的 iFlow CLI 会话数据(默认路径为 `~/.iflow/projects`)。
|
|
83
|
+
|
|
84
|
+
## 项目结构
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
iflow-run/
|
|
88
|
+
├── server.js # Express 服务器
|
|
89
|
+
├── package.json # 项目配置
|
|
90
|
+
├── public/ # 前端静态文件
|
|
91
|
+
│ ├── index.html # 主页面
|
|
92
|
+
│ ├── app.js # 前端逻辑
|
|
93
|
+
│ ├── styles.css # 样式文件
|
|
94
|
+
│ └── test.html # 测试页面
|
|
95
|
+
└── test_screenshot.py # 自动化测试脚本
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## API 接口
|
|
99
|
+
|
|
100
|
+
### 获取所有项目
|
|
101
|
+
|
|
102
|
+
```http
|
|
103
|
+
GET /api/projects
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
返回所有项目和它们的会话列表。
|
|
107
|
+
|
|
108
|
+
### 获取会话详情
|
|
109
|
+
|
|
110
|
+
```http
|
|
111
|
+
GET /api/sessions/:projectId/:sessionId
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
返回指定会话的完整消息记录。
|
|
115
|
+
|
|
116
|
+
## 配置
|
|
117
|
+
|
|
118
|
+
### 通过命令行参数配置
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# 修改端口
|
|
122
|
+
iflow-run --port=8080
|
|
123
|
+
|
|
124
|
+
# 修改 iflow 数据目录
|
|
125
|
+
iflow-run --dir=/path/to/.iflow
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 通过环境变量配置
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Linux/Mac
|
|
132
|
+
export IFLOW_RUN_PORT=8080
|
|
133
|
+
export IFLOW_RUN_DIR=/path/to/.iflow
|
|
134
|
+
iflow-run
|
|
135
|
+
|
|
136
|
+
# Windows
|
|
137
|
+
set IFLOW_RUN_PORT=8080
|
|
138
|
+
set IFLOW_RUN_DIR=C:\path\to\.iflow
|
|
139
|
+
iflow-run
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 默认配置
|
|
143
|
+
|
|
144
|
+
- **端口**: 3000
|
|
145
|
+
- **数据目录**: `~/.iflow` (用户主目录下的 .iflow 文件夹)
|
|
146
|
+
- Windows: `C:\Users\{用户名}\.iflow`
|
|
147
|
+
- Linux/Mac: `/home/{用户名}/.iflow`
|
|
148
|
+
|
|
149
|
+
## 测试
|
|
150
|
+
|
|
151
|
+
项目包含一个基于 Selenium 的自动化测试脚本:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# 安装 Python 依赖
|
|
155
|
+
pip install selenium webdriver-manager
|
|
156
|
+
|
|
157
|
+
# 运行测试
|
|
158
|
+
python test_screenshot.py
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
测试会自动执行以下操作:
|
|
162
|
+
1. 加载首页并截图
|
|
163
|
+
2. 点击第一个项目并截图会话列表
|
|
164
|
+
3. 点击第一个会话并截图会话详情
|
|
165
|
+
4. 测试返回按钮功能
|
|
166
|
+
|
|
167
|
+
## 截图
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+

|
|
171
|
+

|
|
172
|
+
|
|
173
|
+
## 开发
|
|
174
|
+
|
|
175
|
+
### 代码规范
|
|
176
|
+
|
|
177
|
+
- **前端**: 使用模块化函数组织代码,采用事件委托处理动态元素
|
|
178
|
+
- **后端**: RESTful API 风格,包含完善的错误处理
|
|
179
|
+
- **样式**: 使用 CSS 变量定义设计令牌,支持主题定制
|
|
180
|
+
|
|
181
|
+
### 自定义主题
|
|
182
|
+
|
|
183
|
+
编辑 `public/styles.css` 文件中的 CSS 变量:
|
|
184
|
+
|
|
185
|
+
```css
|
|
186
|
+
:root {
|
|
187
|
+
--bg-primary: #0a0a0f;
|
|
188
|
+
--accent-primary: #6366f1;
|
|
189
|
+
/* 更多颜色变量... */
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 常见问题
|
|
194
|
+
|
|
195
|
+
### 无法读取项目数据?
|
|
196
|
+
|
|
197
|
+
请确认:
|
|
198
|
+
1. `.iflow` 目录路径是否正确
|
|
199
|
+
2. 目录下是否有 `projects` 子目录
|
|
200
|
+
3. 项目目录中是否有 `session-*.jsonl` 文件
|
|
201
|
+
|
|
202
|
+
### 消息显示为空?
|
|
203
|
+
|
|
204
|
+
可能原因:
|
|
205
|
+
- 会话文件格式不正确
|
|
206
|
+
- 消息内容不包含可显示的文本
|
|
207
|
+
- 消息格式不符合预期
|
|
208
|
+
|
|
209
|
+
## 贡献
|
|
210
|
+
|
|
211
|
+
欢迎提交 Issue 和 Pull Request!
|
|
212
|
+
|
|
213
|
+
## 许可证
|
|
214
|
+
|
|
215
|
+
MIT License
|
|
216
|
+
|
|
217
|
+
## 致谢
|
|
218
|
+
|
|
219
|
+
- [Express](https://expressjs.com/) - Web 框架
|
|
220
|
+
- [Inter Font](https://rsms.me/inter/) - 字体
|
|
221
|
+
- [Selenium](https://www.selenium.dev/) - 自动化测试
|
|
222
|
+
|
|
223
|
+
## 发布到 npm
|
|
224
|
+
|
|
225
|
+
如果您是项目维护者,需要将包发布到 npm,请按照以下步骤操作:
|
|
226
|
+
|
|
227
|
+
### 1. 登录 npm
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npm login
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 2. 检查包名是否可用
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm view iflow-run
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
如果返回错误,说明包名可用。
|
|
240
|
+
|
|
241
|
+
### 3. 更新版本号
|
|
242
|
+
|
|
243
|
+
在 `package.json` 中更新版本号(遵循语义化版本规范):
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# 小版本更新(新功能,向后兼容)
|
|
247
|
+
npm version minor
|
|
248
|
+
|
|
249
|
+
# 补丁更新(bug 修复)
|
|
250
|
+
npm version patch
|
|
251
|
+
|
|
252
|
+
# 主版本更新(破坏性更改)
|
|
253
|
+
npm version major
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 4. 发布包
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npm publish
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 5. 验证发布
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npm view iflow-run
|
|
266
|
+
npm install -g iflow-run
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 注意事项
|
|
270
|
+
|
|
271
|
+
- 确保在发布前已经通过测试
|
|
272
|
+
- 检查 `.npmignore` 文件,排除不需要发布的文件
|
|
273
|
+
- 发布后无法删除,只能弃用或更新
|
|
274
|
+
- 建议先发布到 `npm publish --dry-run` 进行预检查
|
package/bin/iflow-run.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
// 解析命令行参数
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
|
|
9
|
+
// 显示帮助信息
|
|
10
|
+
function showHelp() {
|
|
11
|
+
console.log(`
|
|
12
|
+
iflow-run - iFlow CLI 会话轨迹查看器
|
|
13
|
+
|
|
14
|
+
用法:
|
|
15
|
+
iflow-run [选项]
|
|
16
|
+
|
|
17
|
+
选项:
|
|
18
|
+
--port=<端口> 指定服务器端口 (默认: 3000)
|
|
19
|
+
--dir=<目录> 指定 iflow 数据目录 (默认: ~/.iflow)
|
|
20
|
+
-h, --help 显示帮助信息
|
|
21
|
+
-v, --version 显示版本号
|
|
22
|
+
|
|
23
|
+
环境变量:
|
|
24
|
+
IFLOW_RUN_PORT 指定服务器端口
|
|
25
|
+
IFLOW_RUN_DIR 指定 iflow 数据目录
|
|
26
|
+
|
|
27
|
+
示例:
|
|
28
|
+
iflow-run # 使用默认配置启动
|
|
29
|
+
iflow-run --port=8080 # 指定端口 8080
|
|
30
|
+
iflow-run --dir=/path/to/iflow # 指定 iflow 目录
|
|
31
|
+
IFLOW_RUN_PORT=8080 iflow-run # 使用环境变量指定端口
|
|
32
|
+
|
|
33
|
+
访问:
|
|
34
|
+
启动后访问 http://localhost:<端口> 查看会话轨迹
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 显示版本信息
|
|
39
|
+
function showVersion() {
|
|
40
|
+
const packagePath = path.join(__dirname, '..', 'package.json');
|
|
41
|
+
const pkg = require(packagePath);
|
|
42
|
+
console.log(`iflow-run v${pkg.version}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 处理参数
|
|
46
|
+
for (const arg of args) {
|
|
47
|
+
if (arg === '-h' || arg === '--help') {
|
|
48
|
+
showHelp();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
if (arg === '-v' || arg === '--version') {
|
|
52
|
+
showVersion();
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 启动服务器
|
|
58
|
+
require('../server.js');
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "iflow-run", "version": "1.0.0", "description": "查看 iflow-cli 会话轨迹和历史会话的 Web 应用", "main": "server.js", "bin": {"iflow-run": "./bin/iflow-run.js"}, "scripts": {"start": "node server.js", "dev": "node server.js"}, "keywords": ["iflow", "session", "history", "cli", "viewer", "dashboard"], "author": "dukewen <dukewen666@gmail.com>", "license": "MIT", "files": ["bin/", "public/", "server.js", "package.json", "README.md"], "dependencies": {"express": "^4.18.2", "cors": "^2.8.5"}, "engines": {"node": ">=14.0.0"}}
|