This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kb-skills/.planning/debug/zhihu-article-archive-format.resolved.md
T
starmen1265 2dce679cca
PR Test / lint (pull_request) Successful in 2s
fix(debug): resolve kb-pipeline import issue in skill directory
Root cause: ~/.openclaw/skills/kb-workflow/kb_workflow.py used old
import paths (kb_pipeline.*) after v1.1 refactor renamed package to
kb_workflow.pipeline

Fix applied to external skill directory:
- Updated imports from kb_pipeline.* to kb_workflow.pipeline.*
- Fixed project_root path calculation
- Updated SKILL.md documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 11:01:33 +08:00

139 lines
6.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
status: awaiting_human_verify
trigger: "知乎文章归档输出格式存在多个问题"
created: "2026-03-16T17:45:00+08:00"
updated: "2026-03-16T18:15:00+08:00"
---
## Current Focus
hypothesis: 修复完成,等待用户验证
test: 用户运行实际工作流验证
expecting: 知乎文章归档格式正确
next_action: 等待用户确认
## Symptoms
expected: |
1. 元数据 YAML 格式正确,Obsidian 可以正常解析
2. 文章归档模板应与视频不同:只要 300 字摘要 + 原文
3. 原文部分不应包含额外的元数据格式
4. 原文部分第一句应保持为正文,不应变成标题
actual: |
1. bvid 这一项空了一行导致 Obsidian 读取元数据错误
2. 文章归档使用了视频模板,显示了视频时间
3. 原文部分多了一段元数据格式
4. 原文部分第一句正文变成了标题
errors: 无显式错误,Obsidian 解析 YAML 元数据失败
reproduction: 运行一键 CLI 命令处理知乎文章链接,查看生成的归档 Markdown 文件
started: 刚发现,可能是模板或格式化逻辑问题
## Eliminated
## Evidence
- timestamp: "2026-03-16T17:45:00+08:00"
checked: zhihu_2003232153480226496_content.md 文件
found: |
1. frontmatter 中 author 字段后有空行(第4行 author 后有一个空行)
2. content.md 使用的是 zhihu.py 中的 _format_with_frontmatter,不是 deep_analyzer
3. 该文件是原始抓取的内容,不是最终分析报告
implication: 问题可能在两个地方 - zhihu.py 的 _format_with_frontmatter 和 deep_analyzer.py 的 generate_frontmatter
- timestamp: "2026-03-16T17:47:00+08:00"
checked: deep_analyzer.py 的 generate_frontmatter 函数(第436-470行)
found: |
1. 第455-459行:只有 content_type == "video" 时才添加 bvid
2. 这意味着对 answer/zhuanlan 类型不应该添加 bvid
3. 但代码中 bvid 只在 video 类型下插入
implication: generate_frontmatter 函数本身的逻辑是正确的,问题可能出在调用方或数据源
- timestamp: "2026-03-16T17:48:00+08:00"
checked: zhihu.py 的 _format_with_frontmatter 函数(第237-265行)
found: |
该函数用于 fetch_content,生成简单的 frontmatter:
- title, author, source_url, platform, content_type, fetched_at
- 没有 bvid 字段
implication: zhihu.py 生成的 content.md 是正确的,问题可能出在最终的分析报告
- timestamp: "2026-03-16T17:49:00+08:00"
checked: 用户报告的问题描述与实际 content.md 对比
found: |
实际 zhihu_2003232153480226496_content.md 文件中:
- author 字段后有换行符(author 的值包含换行)
- frontmatter 格式看起来正确,但 author 值 "啦啦啦啦​​" 后有不可见字符/换行
implication: 问题可能是 author 字段的值包含换行符,导致 YAML 解析失败
- timestamp: "2026-03-16T17:51:00+08:00"
checked: metadata.json 中的 author 字段
found: author 值为 '啦啦啦啦\u200b\n\u200b',包含零宽度空格(U+200B)和换行符
implication: zhihu_extractor 提取的 author 字段包含不可见字符,需要在生成 frontmatter 时清理
- timestamp: "2026-03-16T17:53:00+08:00"
checked: deep_analyzer.py 的 _build_prompt 函数(第193-196行)
found: |
if content_type == "article":
return self._build_article_prompt(...)
else:
return self._build_video_prompt(...)
只检查 "article",不检查 "answer" 或 "zhuanlan"
implication: 知乎 answer 类型走视频模板,导致生成了"时间轴"等视频专用内容
- timestamp: "2026-03-16T17:54:00+08:00"
checked: analysis.md 最终分析报告
found: |
1. 第4-5行 author 后有空行(零宽度空格+换行)
2. 第6行 platform: bilibili(应该是 zhihu)
3. 第41-67行有"时间轴"部分(视频模板,文章不需要)
4. 第69-212行"原文"部分追加了完整的 content.md(包含 frontmatter)
implication: 多个问题需要修复
- timestamp: "2026-03-16T17:55:00+08:00"
checked: analyze.py 的 _write_analysis_report 函数(第283-285行)
found: |
if content_type in ("article", "answer", "zhuanlan") and result.original_text:
full_analysis = full_analysis.rstrip() + "\n\n## 原文\n\n" + result.original_text
result.original_text 是从 content 的 text 字段提取的,应该只是正文
implication: 问题在 deep_analyzer.py 的 analyze 函数中,original_text 设置为完整的 text,但 text 来自 content.md 的全文
## Resolution
root_cause: |
问题1: author 字段包含零宽度空格(U+200B)和换行符
- 来源: zhihu_extractor 提取的 author 字段包含不可见字符
- 影响: YAML frontmatter 解析失败,Obsidian 无法读取元数据
问题2: _build_prompt 函数只检查 content_type == "article"
- 位置: deep_analyzer.py 第193-196行
- 影响: 知乎 answer/zhuanlan 类型走视频模板,生成"时间轴"等不需要的内容
问题3: 原文部分追加了完整的 content.md(包含 frontmatter)
- 位置: analyze.py 第103行读取整个 content.md 文件
- 影响: "原文"部分包含 YAML frontmatter,第一行变成标题
问题4: platform 字段默认为 bilibili
- 位置: deep_analyzer.py 第151行和第452行
- 影响: 知乎内容的 platform 显示为 bilibili
fix: |
1. deep_analyzer.py:
- _build_prompt: 扩展条件为 content_type in ("article", "answer", "zhuanlan")
- analyze: 清理 author 字段的零宽度空格和换行符
- generate_frontmatter: 清理 author 字段
- 根据 URL 或 content_type 推断 platform
2. analyze.py:
- 读取 content.md 时,去除 frontmatter 部分,只保留正文
verification: |
- 单元测试: 15/15 通过
- _clean_string 函数测试: 成功清理零宽度空格和换行符
- generate_frontmatter 测试: 正确推断 platform 为 zhihu
- _strip_frontmatter 测试: 成功去除 YAML frontmatter
files_changed:
- kb-deep-analyzer/deep_analyzer.py
- kb_pipeline/processors/analyze.py