LLM-WIKI 测试 demo1

请在 D:\workspace\llm-wiki 初始化/补齐一个基于 Karpathy LLM Wiki 思路的个人知识库系统。

当前目录可能已有文件,请只创建缺失项;已有文件先读取、对比并汇报差异,未经我确认,不要覆盖、移动、删除或重命名。

重要约束:

  1. 当前根目录固定为:D:\workspace\llm-wiki
  2. 当前项目不是空目录,因此不要使用"覆盖式初始化"。
  3. 只创建缺失的目录和文件。
  4. 如果文件已存在,不要直接覆盖;先读取并对比,然后告诉我差异,等待确认。
  5. raw/ 目录由人类拥有,LLM 只能读取,绝不修改已有 raw 文件。
  6. wiki/ 目录由 LLM 维护,可创建和更新系统文件,但已有文件仍需先对比再确认。
  7. 不要移动、删除、重命名任何已有文件。
  8. 不要自动安装 qmd、npm 包、Python 包或其他依赖。
  9. 如果 qmd 不存在,只记录"qmd 未安装/不可用",不要自动安装,不要使用 npx。
  10. 在 Windows PowerShell 环境执行,目录树验证优先使用 PowerShell 命令,不要依赖 tree -L 3。

一、创建目录结构

在 D:\workspace\llm-wiki 下创建以下目录:

raw/articles/

raw/clippings/

raw/images/

raw/pdfs/

raw/notes/

raw/personal/

wiki/sources/

wiki/concepts/

wiki/entities/

wiki/synthesis/

wiki/templates/

wiki/outputs/

outputs/

scripts/

最终初始目录应为:

llm-wiki/

├── raw/

│ ├── articles/

│ ├── clippings/

│ ├── images/

│ ├── pdfs/

│ ├── notes/

│ └── personal/

├── wiki/

│ ├── sources/

│ ├── concepts/

│ ├── entities/

│ ├── synthesis/

│ ├── templates/

│ ├── outputs/

│ ├── index.md

│ ├── log.md

│ ├── overview.md

│ ├── QUESTIONS.md

│ └── schema.md

├── outputs/

├── scripts/

│ └── lint.py

├── OPENAI.md

└── USER_GUIDE.md

二、创建 wiki 系统文件

wiki/index.md

frontmatter:

type: system-index

date: 当前日期

graph-excluded: true

正文包含:

Knowledge Base Index

Sources

Processed

Unprocessed

Concepts

Entities

Recent Synthesis

Outputs

要求:

  • Sources 按日期倒序。
  • 不要引用系统文件。
  • wikilink 必须使用英文小写连字符 slug。

wiki/log.md

frontmatter:

type: system-log

date: 当前日期

graph-excluded: true

正文包含:

Operation Log

说明:

仅追加操作日志,不删除历史记录。

日志格式:

YYYY-MM-DD HH:MM | 操作类型 | 说明

示例:

2026-05-17 15:30 | init | initialized llm-wiki structure

wiki/overview.md

frontmatter:

type: system-overview

date: 当前日期

graph-excluded: true

正文包含:

Overview

Knowledge Base Health Dashboard

Metric Value Notes
总来源数 0 wiki/sources/ 中的来源页面数量
高置信度概念数 0 wiki/concepts/ 中 confidence: high 的页面数量
开放问题数 0 wiki/QUESTIONS.md 中未完成问题数量
Stale 页面数 0 超过 domain_volatility 时效阈值的概念页面数量

wiki/QUESTIONS.md

frontmatter:

type: system-questions

date: 当前日期

graph-excluded: true

正文包含:

Questions

Open Questions

Resolved Questions

wiki/schema.md

确认 schema.md 的位置为:

wiki/schema.md

原因:

schema.md 描述的是 wiki 层的数据契约,不是根目录级行为契约,因此放在 wiki/ 下最合理。

frontmatter:

type: system-schema

date: 当前日期

graph-excluded: true

正文包含:

Schema

Page Types

type directory purpose
source wiki/sources/ 外部来源整理页
personal-writing wiki/sources/ 个人写作来源页
concept wiki/concepts/ 概念页
entity wiki/entities/ 实体页
synthesis wiki/synthesis/ 综合分析页
system-index wiki/index.md 系统索引
system-log wiki/log.md 操作日志
system-overview wiki/overview.md 健康仪表盘
system-questions wiki/QUESTIONS.md 问题池
system-schema wiki/schema.md 数据契约
lint-report wiki/outputs/ 健康检查报告
query-output wiki/outputs/ 查询输出
gap-report wiki/outputs/ 知识空白报告

Required Frontmatter Fields

source

字段:

type, title, date, source_url, domain, author, tags, processed, raw_file, raw_sha256, last_verified, possibly_outdated, language, canonical_source

personal-writing

字段:

type, title, date, status, topic_tags, confidence_at_writing, superseded_by, raw_file, raw_sha256, last_verified, tags, processed

允许值:

status: draft / published / deprecated

confidence_at_writing: low / medium / high

concept

字段:

type, title, date, updated, tags, source_count, confidence, domain_volatility, last_reviewed, aliases

允许值:

confidence: low / medium / high

domain_volatility: low / medium / high

entity

字段:

type, title, date, tags, entity_type, aliases

允许值:

entity_type: person / tool / institution / paper / product / service / framework

synthesis

字段:

type, title, date, tags, source_count, confidence

允许值:

confidence: low / medium / high

Slug Rules

所有页面文件名和 wikilink 目标必须使用英文小写连字符格式。

正确:

  • mse-microservice-governance
  • full-link-canary
  • traffic-control

错误:

  • 微服务治理
  • FullLinkCanary
  • traffic_control

Graph Exclusion Rules

以下文件必须包含 graph-excluded: true:

  • wiki/index.md
  • wiki/log.md
  • wiki/overview.md
  • wiki/QUESTIONS.md
  • wiki/schema.md
  • wiki/outputs/ 下所有文件

三、创建页面模板

wiki/templates/source-template.md

frontmatter 字段:

type: source

title

date

source_url

domain

author

tags

processed

raw_file

raw_sha256

last_verified

possibly_outdated

language

canonical_source

正文结构:

Source Template

Summary

Key Points

Concepts Extracted

Entities Extracted

Contradictions

与其他来源的分歧。

My Notes

wiki/templates/personal-writing-template.md

frontmatter 字段:

type: personal-writing

title

date

status: draft

topic_tags

confidence_at_writing: medium

superseded_by

raw_file

raw_sha256

last_verified

tags

processed

正文结构:

Personal Writing Template

Core Argument

Key Claims

Evidence Referenced

Limitations

wiki/templates/concept-template.md

frontmatter 字段:

type: concept

title: 中文主名称

date

updated

tags

source_count

confidence

domain_volatility

last_reviewed

aliases

正文结构:

中文主名称

Definition

中文主名称(English Name)

Key Points

My Position

Contradictions

Sources

仅 wikilinks 列表。

Evolution Log

每次更新追加一条。

格式:

  • YYYY-MM-DD(N sources):本次认知变化的一句话描述

wiki/templates/entity-template.md

frontmatter 字段:

type: entity

title

date

tags

entity_type

aliases

正文结构:

Entity Template

Description

Key Contributions

Sources

wiki/templates/synthesis-template.md

frontmatter 字段:

type: synthesis

title

date

tags

source_count

confidence

正文结构:

Synthesis Template

Thesis

Evidence

Counter-evidence

Stage 0 反向检验结果。

Synthesis

Confidence Notes

Limitations

Sources

四、创建 scripts/lint.py

创建 scripts/lint.py。

lint.py 必须执行以下 9 项检查:

  1. YAML frontmatter 合法性

    检查所有 wiki/ 下 .md 文件是否有合法 YAML frontmatter,并包含 type 和 date。

  2. Broken Wikilinks

    检查 [[xxx]] 是否引用了不存在的页面。

  3. Index 一致性

    检查 wiki/index.md 中标记或引用的文件是否实际存在。

  4. Stub 页面

    检查正文少于 100 字的空壳页面。系统文件、模板文件、outputs 可排除。

  5. 近重复概念名称

    检查 wiki/concepts/ 下 slug 名称 Jaccard 相似度是否 > 0.7。

  6. SHA-256 完整性

    检查 source 页中的 raw_file 和 raw_sha256。

    如果 raw 文件当前哈希与记录不一致,报告:⚠ SOURCE MODIFIED。

  7. Stale 页面

    根据 concept 页 domain_volatility 检查过期:

    • high = 90 天
    • medium = 180 天
    • low = 365 天
  8. 跨语言重复

    检查:

    • source URL 相似度
    • 不同 concept 页 aliases 字段是否重叠
  9. Wikilink 格式规范

    检查:

    • wikilink 是否为英文小写连字符格式
    • 是否存在中文 wikilink,如 [[价值投资]]
    • 是否存在驼峰、下划线等非法格式
    • 是否存在别名断链

lint.py 完成后将报告写入:

wiki/outputs/lint-YYYY-MM-DD.md

报告 frontmatter 必须包含:

type: lint-report

date: 当前日期

graph-excluded: true

五、创建 OPENAI.md

创建根目录文件:

OPENAI.md

frontmatter:

type: behavior-contract

date: 当前日期

graph-excluded: true

OPENAI.md 必须包含以下章节:

  1. 系统概述
  2. INGEST 操作规范
  3. QUERY 操作规范
  4. LINT 操作规范
  5. REFLECT 操作规范
  6. MERGE 操作规范
  7. ADD-QUESTION 操作规范
  8. Wikilink 使用规范
  9. Wiki 语言规范
  10. Confidence 更新规则
  11. Source Integrity Rules
  12. 系统文件隔离规则
  13. 文档维护规则

核心原则必须写清楚:

  • 三层架构:Raw / Wiki / Outputs
  • raw/ 由人类拥有,LLM 只能读取,绝不修改
  • wiki/ 由 LLM 维护,可读取和写入
  • outputs/ 保存输出结果
  • 所有知识结论必须可追溯到 source 页,再追溯到 raw 文件

六、创建 USER_GUIDE.md

创建根目录文件:

USER_GUIDE.md

frontmatter:

type: user-guide

date: 当前日期

graph-excluded: true

必须包含:

  1. 快速开始
  2. 三层目录说明
  3. 常用触发词
  4. 如何放入 raw 材料
  5. 如何执行 ingest
  6. 如何执行 query
  7. 如何执行 lint
  8. 如何执行 reflect
  9. Wikilink 规范
  10. Confidence 规则
  11. 维护规则

要求:

OPENAI.md 规则变化时,USER_GUIDE.md 对应章节必须同步更新。

七、初始化 qmd 索引

先检查 qmd 是否存在:

qmd --version

如果 qmd 可用,执行:

qmd add wiki/

qmd status

如果 qmd 不可用:

  • 不要安装
  • 不要使用 npx
  • 在最终报告中写明:qmd 当前不可用,索引初始化未执行

八、执行 lint

执行:

python scripts/lint.py

如果 Python 不可用,尝试:

py scripts/lint.py

如果都不可用,在最终报告中说明。

九、执行完成后的验证报告

完成后输出以下验证报告:

  1. 当前工作目录
  2. 目录结构树,最多 3 层
  3. OPENAI.md 包含的章节列表
  4. wiki/schema.md 是否存在,以及包含的 Page Types
  5. wiki/templates/ 下的模板文件列表
  6. scripts/lint.py 包含的 9 项检查列表
  7. qmd status 输出;如果 qmd 不可用,说明未执行
  8. lint 报告路径
  9. 是否存在未覆盖的已有文件
  10. 下一步建议:放入第一篇 raw 材料,例如 MSE 微服务治理 FAQ

参考:https://www.bilibili.com/video/BV1Ki5C6BEEL/?spm_id_from=333.337.search-card.all.click\&vd_source=4d02563e0aa06f2983dd90aefb4bd1f1