@aiyiran/myclaw 1.1.161 → 1.1.164

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/CLAUDE.md CHANGED
@@ -131,7 +131,9 @@ voice-output.js → voice-input.js → myclaw-tts.js
131
131
  │ │ 关闭预览时 POST {claw, workspace, entryFile, events...}
132
132
  ▼ ▼
133
133
  服务端(sync_workspace.py,本机 18800 / 远程经 nginx /sync)
134
- ├─ 按 workspace 自行算目录,写 {workspace}/debug/debug-record.{json,html}
134
+ ├─ 按 workspace 自行算目录,写两个文件:
135
+ │ debug-data.js ← 每次覆盖,window.__DEBUG_DATA__ = {规范化记录}(数据,喂渲染也给 AI 读)
136
+ │ debug-record.html ← 恒定壳,含 CSS + 前端渲染器,运行时加载 debug-data.js 渲染
135
137
 
136
138
  同步循环 → 上传 CDN → 可展示给学生
137
139
  ```
@@ -142,7 +144,8 @@ voice-output.js → voice-input.js → myclaw-tts.js
142
144
  |------|------|------|--------|
143
145
  | **probe**(采集侧) | `assets/debug-probe.js` | 在 iframe 内采集现场,`postMessage` 上报 | traceId、workspace、上传、判因 |
144
146
  | **collector**(接收侧) | `assets/debug-collector.js` | 父页面收事件、攒记录、关闭时提交 | probe 注入、AI 修复、HTML 模板 |
145
- | **server**(落库侧) | `server/debug_record.py` | 算目录、校验、渲染 HTML、原子写盘 | 采集、CDN 上传(交给同步循环) |
147
+ | **server**(落库侧) | `server/debug_record.py` | 算目录、校验、normalize、写 debug-data.js + 恒定 HTML | 采集、CDN 上传(交给同步循环) |
148
+ | **renderer**(渲染侧) | HTML 壳内联 JS(`render_shell_html()` 里) | 读 `window.__DEBUG_DATA__`,渲染小结/线索/回放 | 数据清洗(服务端做) |
146
149
 
147
150
  ### 关键设计约束(改之前先读)
148
151
 
@@ -157,7 +160,10 @@ voice-output.js → voice-input.js → myclaw-tts.js
157
160
 
158
161
  5. **前端不传文件路径**。前端只传逻辑字段(claw / workspace / entryFile),**服务端自己算目录**。`claw` 不是路径层级,只用于跟本机 `CLAW_NAME` 校验防串写;真实路径是 `{openclaw_root}/{workspace}/debug/`。
159
162
 
160
- 6. **落盘只留最新一份**:固定文件名 `debug-record.{json,html}`,每次覆盖。
163
+ 6. **数据/渲染分离,落盘两个文件**(固定文件名,每次覆盖):
164
+ - `debug-data.js`:`window.__DEBUG_DATA__ = {...}`,唯一数据源(喂前端渲染 + 给 AI 直接读)。
165
+ - `debug-record.html`:**恒定壳**,内容不随数据变(哈希不变 → 同步不会反复当成更新)。壳内联 CSS + 渲染器 JS,运行时用 `debug-data.js?t=<时间戳>` 动态加载绕 CDN 缓存。
166
+ - ⚠️ 渲染逻辑(事件转写 / 错误解释 / 线索提取)现在在**前端 JS**(`render_shell_html()` 里),不在 Python。改文案/样式改这里,且因为壳恒定,AI 修 bug 应读 `debug-data.js` 而非 HTML。
161
167
 
162
168
  ### 接口
163
169
 
@@ -555,14 +555,18 @@
555
555
  var rec = window.myclawLastDebugRecord;
556
556
  var lines = [];
557
557
 
558
+ // 调试数据现在落在 debug-data.js(window.__DEBUG_DATA__ = {...}),
559
+ // 与 debug-record.html 同目录。AI 直接读这个数据文件即可,不用读 HTML。
560
+ var dataFile = null;
558
561
  if (rec) {
559
562
  if (rec.debugRecordPath) {
560
- lines.push("调试记录文件:" + rec.debugRecordPath);
561
- } else if (rec.debugRecordUrl) {
562
- lines.push("调试记录:" + rec.debugRecordUrl);
563
+ dataFile = rec.debugRecordPath.replace(/debug-record\.html$/, "debug-data.js");
563
564
  } else if (rec.workspace) {
564
- lines.push("调试记录:" + rec.workspace + "/debug/debug-record.html");
565
+ dataFile = rec.workspace + "/debug/debug-data.js";
565
566
  }
567
+ }
568
+ if (dataFile) {
569
+ lines.push("调试数据文件:" + dataFile);
566
570
  lines.push("");
567
571
  }
568
572
 
@@ -570,12 +574,12 @@
570
574
  lines.push("");
571
575
  lines.push("请从学生描述里提取:我做了什么、发生了什么、我的预期是什么。");
572
576
  lines.push("");
573
- lines.push("如何阅读调试记录(不要通读整个 HTML,按下面抓重点):");
574
- lines.push("1. 调试记录是一个 HTML 文件,完整事件数据在 <script id=\"debug-data\" type=\"application/json\"> 这段 JSON 里——只读这段,别看页面样式。");
575
- lines.push("2. 先在事件里找 runtime-error / unhandledrejection / 以及 level 为 error 的 console 事件,它们是问题的起点。");
577
+ lines.push("如何阅读调试数据(按下面抓重点,别东翻西找):");
578
+ lines.push("1. 读上面的调试数据文件 debug-data.js,它是一行 `window.__DEBUG_DATA__ = {...}` 的赋值,里面的 events 数组就是完整运行现场。(不要去读同目录的 debug-record.html,那只是给人看的渲染壳。)");
579
+ lines.push("2. 先在 events 里找 runtime-error / unhandledrejection / 以及 payload.level 为 error 的 console 事件,它们是问题的起点。");
576
580
  lines.push("3. 抓住报错事件的 message、stack、filename、lineno——直接定位到源码里出错的那个函数/那几行,只看相关代码段,不要通读整个作品文件。");
577
581
  lines.push("4. 再倒着看报错之前的 page-enter / click / keydown / console,还原“做了什么 → 触发了什么”的因果链,确认重现路径。");
578
- lines.push("5. 如果没有任何报错(属于逻辑 bug),就对比【学生的预期】和事件里 console 输出 / 交互序列反映出的【实际行为】,差异处就是 bug。");
582
+ lines.push("5. 如果没有任何报错(属于逻辑 bug),就对比【学生的预期】和 events 里 console 输出 / 交互序列反映出的【实际行为】,差异处就是 bug。");
579
583
  lines.push("");
580
584
  lines.push("定位到根因后只做最小修复。修复后说明:问题原因、改了哪个文件的哪段代码、为什么这样改能解决。");
581
585
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.161",
3
+ "version": "1.1.164",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {