@aiyiran/myclaw 1.1.205 → 1.1.207

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.205",
3
+ "version": "1.1.207",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -21,7 +21,7 @@ python3 scripts/extract_chat.py <my-workspace> "<urls>"
21
21
 
22
22
  **两步执行逻辑**:
23
23
  1. **始终先扫描**所有 agent → 生成 `作品扫描_<时间>.html`
24
- 2. 如果传了 `<urls>` → 再提取指定会话 → 生成 `index.js` + `index.html`
24
+ 2. 如果传了 `<urls>` → 再提取指定会话,并按 Workspace 合并 → 生成 `index.js` + `index.html`
25
25
 
26
26
  ## 输出文件
27
27
 
@@ -29,34 +29,39 @@ python3 scripts/extract_chat.py <my-workspace> "<urls>"
29
29
 
30
30
  | 文件 | 说明 |
31
31
  |---|---|
32
- | `index.js` | 唯一数据产物:`chatIndex`(会话元数据列表)+ `chatAll`(每个会话的完整对话) |
33
- | `index.html` | 查看器,复制自 `assets/chat-history-template.html`,只加载 `index.js` |
32
+ | `index.js` | 数据产物:Workspace 索引、合并时间线,以及原始 Session 数据 |
33
+ | `index.html` | 查看器;可按 Session 筛选、辨认来源并下载当前视图为 Markdown |
34
34
 
35
35
  `index.js` 结构:
36
36
 
37
37
  ```javascript
38
- // chatIndex:用于会话切换下拉框的元数据
38
+ // chatIndex:用于 Workspace 切换下拉框的元数据
39
39
  const chatIndex = [
40
- { "session_id": "agent:xxx:main", "workspace_name": "xxx", "session_name": "main",
41
- "total_pairs": 10, "first_time": "...", "last_time": "...", "work_url": "" },
40
+ { "workspace_name": "xxx", "workspace_label": "作品名称", "session_count": 2,
41
+ "total_pairs": 10, "first_time": "...", "last_time": "..." },
42
42
  ...
43
43
  ];
44
44
 
45
- // chatAll:按 session_id 索引的完整会话数据(HTML 渲染的真正数据源)
46
- const chatAll = {
47
- "agent:xxx:main": {
48
- "workspace_name": "xxx", "session_name": "main", "session_id": "agent:xxx:main",
49
- "total_pairs": 10, "first_time": "...", "last_time": "...", "work_url": "",
45
+ // chatWorkspaces:按 workspace_name 索引的合并时间线(HTML 的主要数据源)
46
+ const chatWorkspaces = {
47
+ "xxx": {
48
+ "workspace_name": "xxx", "workspace_label": "作品名称", "session_count": 2,
49
+ "total_pairs": 10, "first_time": "...", "last_time": "...",
50
50
  "conversations": [
51
- { "user": "...", "user_time": "...", "ai": "...", "ai_time": "..." },
51
+ { "user": "...", "user_time": "...", "user_timestamp": "...",
52
+ "ai": "...", "ai_time": "...", "ai_timestamp": "...",
53
+ "workspace_turn_index": 1, "source_session_id": "agent:xxx:main",
54
+ "source_session_label": "程序", "source_turn_index": 1 },
52
55
  ...
53
56
  ]
54
57
  },
55
58
  ...
56
59
  };
60
+
61
+ // chatSessionIndex / chatAll:保留原始 Session 索引和原始 Session 数据,兼容旧用途。
57
62
  ```
58
63
 
59
- > 单会话和批量模式产物一致,区别只是 `chatIndex` / `chatAll` 里的会话数量。
64
+ 同一 Workspace 下的多个 Session 会按**用户原始时间戳**稳定合并;展示时间只用于阅读,不参与排序。每轮仍保留来源 Session、来源标签和原轮次,便于追溯。
60
65
 
61
66
  ## 工作流
62
67
 
@@ -80,24 +85,36 @@ URL 示例:`https://claw1.kekouen.cn/chat?session=agent%3Ac108-v1-1811%3Amain`
80
85
  ### Step 3: 解析 JSONL,构建对话对
81
86
 
82
87
  1. 筛选 `type == "message"` 的事件
83
- 2. 每条用户消息与后续**所有连续的** AI 消息配对
84
- 3. 多条 AI 回复合并为一条
85
- 4. 跳过 `toolResult` 事件和空文本消息
88
+ 2. 高置信度识别模型切换时瞬间重新注入的历史回放块,整块过滤,避免重复对话
89
+ 3. 每条用户消息与后续**所有连续的** AI 消息配对
90
+ 4. 多条 AI 回复合并为一条
91
+ 5. 跳过 `toolResult` 事件和空文本消息
86
92
 
87
- ### Step 4: 生成 index.js
93
+ ### Step 4: 按 Workspace 合并并生成 index.js
88
94
 
89
- 所有会话的数据在内存中汇总,一次性写入唯一的 `index.js`(`chatIndex` + `chatAll`),不为单个会话单独落文件。
95
+ 所有 Session 先按 Workspace 分组,再按用户原始时间戳合并。一次性写入唯一的 `index.js`(`chatIndex` + `chatWorkspaces` + `chatSessionIndex` + `chatAll`),不为单个会话单独落文件。
90
96
 
91
97
  ### Step 5: 渲染
92
98
 
93
99
  将模板 `assets/chat-history-template.html` 复制到输出目录为 `index.html`。
94
- 模板只加载 `index.js`,通过 `chatIndex` 渲染会话切换下拉框、从 `chatAll` 取完整对话。
100
+ 模板只加载 `index.js`,通过 `chatIndex` 切换 Workspace、从 `chatWorkspaces` 读取合并时间线。页面以稳定的背景色和来源标签区分 Session,也可点击 Session 标签筛选当前视图。
95
101
 
96
102
  模板展示三种时间指标:
97
103
  - **课程流逝** — 距首条消息的时间
98
104
  - **回复耗时** — AI 响应时间
99
105
  - **间隔耗时** — 到下一条用户消息的间隔
100
106
 
107
+ ### Step 6: 下载当前视图为 Markdown
108
+
109
+ 页面顶部的“下载当前视图 MD”按钮会在浏览器本地即时生成文件,不需要服务端接口:
110
+
111
+ - 当前选择“全部会话”:导出整个 Workspace 的合并时间线
112
+ - 当前筛选某个 Session:只导出该 Session
113
+ - 文件顶部包含总体汇总、会话概览、每日对话分布、响应时间和内容规模
114
+ - 正文保留合并轮次、原 Session 轮次、Session 标签/ID、显示时间和原始时间戳
115
+ - 用户与 AI 原文使用 Markdown 引用块封装,适合直接交给 AI 分析
116
+ - 文件使用 UTF-8 BOM,降低中文在本地软件中打开时出现乱码的概率
117
+
101
118
  ## Agent 手动流程
102
119
 
103
120
  如果不使用脚本(如当前 agent 直接操作):