llm-wiki-stack 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/README.md +64 -0
- package/bin/setup.sh +36 -0
- package/package.json +25 -0
- package/skills/kb-init/SKILL.md +22 -0
- package/skills/kb-init/agents/openai.yaml +9 -0
- package/skills/llm-wiki-stack/SKILL.md +285 -0
- package/skills/llm-wiki-stack/agents/openai.yaml +8 -0
- package/skills/llm-wiki-stack/assets/AGENTS.template.md +93 -0
- package/skills/llm-wiki-stack/assets/concept.template.md +31 -0
- package/skills/llm-wiki-stack/assets/entity.template.md +22 -0
- package/skills/llm-wiki-stack/assets/health-report.template.md +32 -0
- package/skills/llm-wiki-stack/assets/log.template.md +18 -0
- package/skills/llm-wiki-stack/assets/output.template.md +28 -0
- package/skills/llm-wiki-stack/commands.md +35 -0
- package/skills/llm-wiki-stack/references/default-schema.md +273 -0
- package/skills/wiki-compile/SKILL.md +17 -0
- package/skills/wiki-lint/SKILL.md +19 -0
- package/skills/wiki-lint/agents/openai.yaml +9 -0
- package/skills/wiki-topic/SKILL.md +18 -0
- package/skills/wiki-topic/agents/openai.yaml +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# llm-wiki-stack
|
|
2
|
+
|
|
3
|
+
Obsidian-based knowledge base compiler. Turns fragmented source notes into an interconnected concept network, powered by LLM compilation.
|
|
4
|
+
|
|
5
|
+
## Philosophy
|
|
6
|
+
|
|
7
|
+
Most note systems are **warehouses** — you put things in. This is a **compiler** — it transforms raw material into structured, queryable knowledge.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
01 raw/ ──compile──> 02 wiki/ ──dialogue──> 03 outputs/
|
|
11
|
+
(source of truth) (concept network) (your opinions)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx llm-wiki-stack
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This copies the skills into `~/.claude/skills/`. Works in Claude Code.
|
|
21
|
+
|
|
22
|
+
Or clone manually:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/<your-username>/llm-wiki-stack.git
|
|
26
|
+
cp -R llm-wiki-stack/skills/* ~/.claude/skills/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
| Command | Action | When |
|
|
32
|
+
|---------|--------|------|
|
|
33
|
+
| `/kb-init` | Bootstrap a knowledge base from scratch | Once per vault |
|
|
34
|
+
| `/wiki-compile` | Compile new raw notes into wiki | After collecting source material |
|
|
35
|
+
| `/wiki-topic` | Question-driven opinion formation | When you have a research question |
|
|
36
|
+
| `/wiki-lint` | Health check + structured report | Monthly |
|
|
37
|
+
|
|
38
|
+
## How It Works
|
|
39
|
+
|
|
40
|
+
1. **Collect** — Save articles, thoughts, clippings into `01 raw/` with `status: inbox`
|
|
41
|
+
2. **Compile** — Run `/wiki-compile`; LLM extracts concepts, creates wiki pages, builds cross-references
|
|
42
|
+
3. **Think** — Run `/wiki-topic` with a question; LLM reveals structural relationships between concepts
|
|
43
|
+
4. **Maintain** — Run `/wiki-lint` monthly; LLM surfaces orphan nodes, fragile dependencies, concept evolution
|
|
44
|
+
|
|
45
|
+
## Key Mechanisms
|
|
46
|
+
|
|
47
|
+
**Concept Independence Test** — Before creating a new wiki page, every candidate concept must pass:
|
|
48
|
+
- Definability: can you clearly state what this concept *is* in 1-2 sentences?
|
|
49
|
+
- Single core: is it one concept, or "A and B" glued together?
|
|
50
|
+
- Multi-source verification: does it appear in at least two different source notes?
|
|
51
|
+
|
|
52
|
+
**Concept Evolution** — No overwrites. Understanding changes are tracked in a versioned timeline. Default behavior is *append*, not replace.
|
|
53
|
+
|
|
54
|
+
**Cross-Reference Integrity** — Every claim links to its raw source. Every wiki link is bidirectional. Linked counts are verified on each compile.
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
|
|
58
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) or compatible AI coding agent
|
|
59
|
+
- [Obsidian](https://obsidian.md/) (recommended, for graph visualization)
|
|
60
|
+
- Git (for version control)
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
package/bin/setup.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
SKILLS_SRC="$(cd "$(dirname "$0")/../skills" && pwd)"
|
|
5
|
+
SKILLS_DST="${HOME}/.claude/skills"
|
|
6
|
+
|
|
7
|
+
echo "llm-wiki-stack installer"
|
|
8
|
+
echo "========================"
|
|
9
|
+
echo ""
|
|
10
|
+
|
|
11
|
+
# Install each skill into ~/.claude/skills/
|
|
12
|
+
for skill_dir in "$SKILLS_SRC"/*/; do
|
|
13
|
+
skill_name=$(basename "$skill_dir")
|
|
14
|
+
target="$SKILLS_DST/$skill_name"
|
|
15
|
+
|
|
16
|
+
if [ -d "$target" ]; then
|
|
17
|
+
echo " updating: $skill_name (existing install, backing up)"
|
|
18
|
+
rm -rf "${target}.bak" 2>/dev/null
|
|
19
|
+
mv "$target" "${target}.bak"
|
|
20
|
+
else
|
|
21
|
+
echo " installing: $skill_name"
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
mkdir -p "$SKILLS_DST"
|
|
25
|
+
cp -R "$skill_dir" "$target"
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
echo ""
|
|
29
|
+
echo "Done. Available commands:"
|
|
30
|
+
echo " /kb-init — bootstrap a new knowledge base"
|
|
31
|
+
echo " /wiki-compile — compile raw sources into wiki"
|
|
32
|
+
echo " /wiki-topic — question-driven topic synthesis"
|
|
33
|
+
echo " /wiki-lint — health check and structured report"
|
|
34
|
+
echo ""
|
|
35
|
+
echo "Each command delegates to llm-wiki-stack, which reads"
|
|
36
|
+
echo "your repo-local AGENTS.md as the schema of truth."
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "llm-wiki-stack",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Obsidian knowledge base compiler — three-layer architecture (raw → wiki → outputs) with concept evolution, cross-reference integrity, and health checks. Command-driven, AI-maintained, plain Markdown.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"llm-wiki-stack": "bin/setup.sh"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"skills/"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"obsidian",
|
|
15
|
+
"knowledge-base",
|
|
16
|
+
"wiki",
|
|
17
|
+
"markdown",
|
|
18
|
+
"llm",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"compiler",
|
|
21
|
+
"concept-network",
|
|
22
|
+
"note-taking",
|
|
23
|
+
"personal-knowledge-management"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kb-init
|
|
3
|
+
description: Subcommand of the `llm-wiki-stack` knowledge-base management framework. Initialize an Obsidian knowledge base from a raw-only or partially initialized directory. Use when the user wants to bootstrap the wiki structure, generate repo-local AGENTS.md, initialize git, or run `/kb-init` directly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# KB Init
|
|
7
|
+
|
|
8
|
+
## Framework Binding
|
|
9
|
+
|
|
10
|
+
- This skill is one command adapter in the `llm-wiki-stack` framework.
|
|
11
|
+
- It does not define its own schema or workflow; it delegates to `../llm-wiki-stack/SKILL.md`.
|
|
12
|
+
- Repo-local `AGENTS.md` overrides both the core framework and this wrapper.
|
|
13
|
+
|
|
14
|
+
- This skill is a thin wrapper around `llm-wiki-stack`.
|
|
15
|
+
- First read `../llm-wiki-stack/SKILL.md` and follow the `/kb-init` command path only.
|
|
16
|
+
- Treat the user request as an explicit `/kb-init` invocation even if they do not mention `llm-wiki-stack`.
|
|
17
|
+
- Stay within bootstrap orchestration: create missing structure (including `03 outputs/`), generate local `AGENTS.md`, initialize git if needed, and keep the action idempotent.
|
|
18
|
+
- If `01 raw/` contains raw files, generate `03 outputs/初始化提案.md` listing suggested wiki concept pages and link relationships.
|
|
19
|
+
- Wait for user approval before batch compiling raw into wiki.
|
|
20
|
+
- After approval, reuse the core `/wiki-compile` pipeline with an explicit list of all eligible raw files. Do not invent a second compilation path inside this wrapper.
|
|
21
|
+
- Treat `/wiki-lint` mechanical checks as the completion gate for a full initialized knowledge base: uncompiled raw, broken links, frontmatter, raw_sources backfill, backlinks, and linked_count must be checked before writing `03 outputs/初始化完成报告.md`.
|
|
22
|
+
- Do not call `/wiki-topic` during initialization; initialization reports are system outputs, not question-driven topic pages.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "KB Init"
|
|
3
|
+
short_description: "Bootstrap an LLM wiki knowledge base."
|
|
4
|
+
brand_color: "#0F766E"
|
|
5
|
+
default_prompt: "Use $kb-init to initialize the current repo as an LLM wiki knowledge base."
|
|
6
|
+
|
|
7
|
+
policy:
|
|
8
|
+
allow_implicit_invocation: true
|
|
9
|
+
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: llm-wiki-stack
|
|
3
|
+
description: Core skill of the `llm-wiki-stack` knowledge-base management framework. 管理基于 Obsidian 的知识库,可用于从仅含 raw 的目录启动一个新的知识库,或维护已初始化的知识库。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# LLM Wiki Stack — 知识库编译器
|
|
7
|
+
|
|
8
|
+
## Role
|
|
9
|
+
|
|
10
|
+
你是三层知识库编译器的维护者。将 `01 raw/` 素材编译为 `02 wiki/` 概念网络,辅助用户在 `03 outputs/` 形成观点。
|
|
11
|
+
|
|
12
|
+
设计起点源自 Karpathy 的 [llm-wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) 思路,以及《知识库编译器系统规格书》的三层编译器架构。
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
01 raw/ ──编译──> 02 wiki/ ──对话──> 03 outputs/
|
|
18
|
+
(不可变源) (概念网络) (个人观点)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 权限模型
|
|
22
|
+
|
|
23
|
+
| 层 | LLM 权限 |
|
|
24
|
+
|----|---------|
|
|
25
|
+
| raw 正文 | **只读**,绝不修改 |
|
|
26
|
+
| raw YAML | **可写,分级**(自动字段/推断字段/手动字段) |
|
|
27
|
+
| raw 文件名 | **可建议**,不直接修改 |
|
|
28
|
+
| wiki | **可创建、更新、链接** |
|
|
29
|
+
| outputs 初始分析 | **可写** |
|
|
30
|
+
| outputs 对话区用户内容/综合判断 | **只读** |
|
|
31
|
+
|
|
32
|
+
### 页面类型
|
|
33
|
+
|
|
34
|
+
| type | 层 | 说明 |
|
|
35
|
+
|------|----|------|
|
|
36
|
+
| `source` | raw | 源笔记 |
|
|
37
|
+
| `entity` | wiki | 实体页——具体的人、组织、产品、岗位 |
|
|
38
|
+
| `concept` | wiki | 概念页——跨实体提炼的框架与原理 |
|
|
39
|
+
| `map` | wiki | 分区导航页 |
|
|
40
|
+
| `log` | wiki | 操作日志 |
|
|
41
|
+
| `output` | outputs | 观点主题页 |
|
|
42
|
+
| `health-report` | outputs | 体检报告 |
|
|
43
|
+
|
|
44
|
+
## Source Of Truth
|
|
45
|
+
|
|
46
|
+
1. repo-local `AGENTS.md`(最高优先级)
|
|
47
|
+
2. `references/default-schema.md`
|
|
48
|
+
3. `assets/*.template.md`
|
|
49
|
+
|
|
50
|
+
如果本地 `AGENTS.md` 存在,则视为当前知识库的唯一 schema 来源。如果不存在,只允许 `/kb-init` 继续执行。
|
|
51
|
+
|
|
52
|
+
## Operating Modes
|
|
53
|
+
|
|
54
|
+
### Bootstrap Mode
|
|
55
|
+
- 条件:repo 中不存在本地 `AGENTS.md`
|
|
56
|
+
- 允许:`/kb-init`
|
|
57
|
+
- 其他命令一律拒绝
|
|
58
|
+
|
|
59
|
+
### Managed Mode
|
|
60
|
+
- 条件:本地 `AGENTS.md` 已存在且可读
|
|
61
|
+
- 行为:所有命令优先遵循本地 `AGENTS.md`,仅在其缺失时回落 default-schema
|
|
62
|
+
|
|
63
|
+
## Command Router
|
|
64
|
+
|
|
65
|
+
4 个命令,对应规格书的日常操作:
|
|
66
|
+
|
|
67
|
+
| 命令 | 规格书动作 | 说明 |
|
|
68
|
+
|------|-----------|------|
|
|
69
|
+
| `/kb-init` | `🏗️ 初始化知识库` | 从零或 raw-only 目录启动知识库 |
|
|
70
|
+
| `/wiki-compile` | `🔄 编译新素材` | 编译指定或未编译 raw 进 wiki |
|
|
71
|
+
| `/wiki-topic` | `🧠 新建主题` | question-driven 观点形成 |
|
|
72
|
+
| `/wiki-lint` | `🏥 月度体检` | 健康检查 + 结构化报告 |
|
|
73
|
+
|
|
74
|
+
(`📄 新建源笔记` 由 Obsidian QuickAdd + 模板完成,非 LLM 命令)
|
|
75
|
+
|
|
76
|
+
### `/kb-init`
|
|
77
|
+
|
|
78
|
+
目标:将当前目录初始化为可管理的知识库。
|
|
79
|
+
|
|
80
|
+
执行要求:
|
|
81
|
+
- 读取 `references/default-schema.md`
|
|
82
|
+
- 执行 dependency doctor:检查 `git`、`rg`、基础 shell 工具、写权限;`git` 与写权限为必需项;`rg` 缺失时回退 `grep/find`
|
|
83
|
+
- 创建 `01 raw/`、`02 wiki/`、`03 outputs/`、`98 template/`
|
|
84
|
+
- 用 `assets/AGENTS.template.md` 生成本地 `AGENTS.md`
|
|
85
|
+
- 用模板生成 `02 wiki/log.md`
|
|
86
|
+
- 创建本地状态文件 `.wiki-kb/state.json`
|
|
87
|
+
- 若 `01 raw/` 下存在 raw 文件,扫描并生成 `03 outputs/初始化提案.md`(建议的 wiki 概念页、重要度、链接关系)
|
|
88
|
+
- **等待用户审阅确认**后,调用本文件的 `/wiki-compile` 核心流水线,并传入全部合格 raw 文件的显式列表;`/kb-init` 不另写轻量编译逻辑
|
|
89
|
+
- 编译后建立或补齐必要的全局索引页和分区 map 页,确保所有已生成概念页可从索引导航到达
|
|
90
|
+
- 将 `/wiki-lint` 的机械检查作为完成门禁:未编译 raw、断链、frontmatter、raw_sources 回填、双向回链、linked_count 一致性和孤立节点必须检查
|
|
91
|
+
- 输出 `03 outputs/初始化完成报告.md`,列出 raw 总数、已编译数、跳过项及原因、概念页数、map 页数和 lint 门禁结果
|
|
92
|
+
- 保持幂等;如果结构已基本存在,只补齐缺失项
|
|
93
|
+
|
|
94
|
+
### `/wiki-compile`
|
|
95
|
+
|
|
96
|
+
定义:将 raw 编译进 wiki 的唯一入口。`🔄 编译新素材`。
|
|
97
|
+
|
|
98
|
+
**文件选择**:
|
|
99
|
+
- 若用户在命令中指定了 raw 文件路径(可多个),直接编译这些文件
|
|
100
|
+
- 若由 `/kb-init` 调用,必须传入已扫描确认的全部合格 raw 文件列表;此时跳过交互式候选确认,但不能跳过文件名阻断、元数据补全、概念独立性测试和交叉引用完整性检查
|
|
101
|
+
- 若用户未指定文件,执行**未编译 raw 检测**:
|
|
102
|
+
1. 收集 `02 wiki/` 全部概念页 `raw_sources` 中已引用的 raw 路径,构建已编译集合
|
|
103
|
+
2. 扫描 `01 raw/` 全部 `.md` 文件,找出不在已编译集合中的文件
|
|
104
|
+
3. 排除 `README.md`、`.gitkeep` 等非笔记文件
|
|
105
|
+
4. 将候选列表呈现给用户,列出每个文件所属分区和标题,供用户勾选确认
|
|
106
|
+
5. 若候选列表为空,提示"当前无未编译 raw 文件"并退出
|
|
107
|
+
|
|
108
|
+
流程(对每个待编译文件):
|
|
109
|
+
1. **文件名阻断检查**:文件名含随机字符串或与内容明显不符时,停止处理该文件,写入 `title: 建议标题` 到 YAML,追加记录到 `03 outputs/待确认文件名.md`,提示用户处理后重新编译
|
|
110
|
+
2. **元数据补全**:补全缺失的 YAML 字段(type/created/source_url/title/tags)。若 `status` 缺失则设为 `processed`。正文永不修改
|
|
111
|
+
3. **实体与概念提取**:从 raw 提取关键实体和候选概念
|
|
112
|
+
4. **概念独立性测试**(创建新概念页前强制执行):
|
|
113
|
+
- **测试一(可定义性 + 单一核心)**:能否用一两句不含同义词循环的话清晰定义?拆解为"A 与 B"/"A 的 B"等形式后,各部分是否各自可独立定义?若可独立定义则为组合概念,不满足单一核心要求
|
|
114
|
+
- **测试二(多重验证)**:至少来自两个不同 raw 笔记的支撑,且有独立论述角度
|
|
115
|
+
- 不通过测试一的可定义性 → 不创建页,信息归入上位概念
|
|
116
|
+
- 不通过测试一的单一核心 → 拆分成独立概念分别创建
|
|
117
|
+
- 不通过测试二 → 不创建页,标记 `<!-- 潜在独立概念:XXX -->`
|
|
118
|
+
5. **wiki 页创建/更新**:
|
|
119
|
+
- 无对应 wiki 页则基于 concept 模板创建
|
|
120
|
+
- 已存在则默认**补充**至 `## 阐述`,不覆盖 `## 当前理解`
|
|
121
|
+
- **只有新信息明确纠正旧事实**时,触发版本归档:旧定义追加到 `## 概念演化`,更新 `## 当前理解`
|
|
122
|
+
- **观点冲突**:列入 `## 不同理解`,并列双方时间与出处,不判定对错
|
|
123
|
+
6. 每条关键陈述附 `[[01 raw/...]]` 出处
|
|
124
|
+
7. 建立 wiki 间 `[[02 wiki/...]]` 双向链接
|
|
125
|
+
8. **交叉引用完整性检查**(编译收尾强制执行):
|
|
126
|
+
- 出链回填:正文引用的 raw 路径全部回填到 `raw_sources`
|
|
127
|
+
- 入链保障:`## 相关概念` 列出的每个目标页必须包含回链,缺失时自动补入
|
|
128
|
+
- linked_count 准确性:等于全库指向该页的链接总数
|
|
129
|
+
- 孤立检测:linked_count 为 0 的页面显式提醒,向用户确认是否保留
|
|
130
|
+
9. 更新受影响 wiki 页的 `linked_count` 和 `updated`
|
|
131
|
+
|
|
132
|
+
### `/wiki-topic`
|
|
133
|
+
|
|
134
|
+
定义:围绕目标主题的 question-driven 观点形成流程,写入 `03 outputs/`。
|
|
135
|
+
|
|
136
|
+
流程:
|
|
137
|
+
1. 用户提出一个**问题**(非概念列表)
|
|
138
|
+
2. LLM 读取相关 map 页和概念页定位知识,生成 `🤖 初始分析`(含 `[[02 wiki/...]]` 来源标注),写入 `03 outputs/` 新页面
|
|
139
|
+
3. 用户主导后续对话,LLM 回应追问,提供多视角,不替用户做综合判断
|
|
140
|
+
4. 相关 wiki 链接自动建立,`linked_count` 增加
|
|
141
|
+
|
|
142
|
+
创建或更新 outputs 页面后,必须将正文中引用的所有 wiki 路径回填到 `raw_sources` 字段。
|
|
143
|
+
|
|
144
|
+
### `/wiki-lint`
|
|
145
|
+
|
|
146
|
+
定义:全库健康检查 + 结构化报告。`🏥 月度体检`。
|
|
147
|
+
|
|
148
|
+
执行要求:
|
|
149
|
+
- 机械检查:断链、孤儿页、空目录、frontmatter 完整性、linked_count 一致性、raw_sources 回填、未编译 raw、组合概念命名检测(A与B/A、B与C 模式)
|
|
150
|
+
- 当作为 `/kb-init` 完成门禁调用时,只执行机械检查和低风险自动修复;语义合并、主题创建和破坏性结构清理不得自动执行
|
|
151
|
+
- 语义检查:重复/可合并概念、raw 目录错放、合成缺口、交叉引用缺失(出链无回链)
|
|
152
|
+
- 生成 `03 outputs/月度体检-YYYY-MM.md`,使用 `- [ ]` 任务列表,包含:
|
|
153
|
+
- 概念演化一览
|
|
154
|
+
- 脆弱依赖(outputs 依赖低 linked_count 概念)
|
|
155
|
+
- 孤岛节点(linked_count 为 0 的概念页)
|
|
156
|
+
- 时间提示(引用已演化概念的 outputs)
|
|
157
|
+
- 输出分级清单:fix(可自动修复)/ consider(需确认)/ notice(仅提示)
|
|
158
|
+
- 只输出建议,绝不自动创建主题页
|
|
159
|
+
|
|
160
|
+
## Compilation Pipeline
|
|
161
|
+
|
|
162
|
+
编译是 `/wiki-compile` 的核心流水线:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
raw → 文件名阻断 → 元数据补全 → 实体提取 → 概念独立性测试 → wiki 创建/更新 → 交叉引用完整性检查
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**概念独立性测试**(创建新概念页前):可定义性 + 单一核心 + 多重验证。组合概念必须拆分,单一来源概念不创建独立页。
|
|
169
|
+
|
|
170
|
+
**默认追加原则**:新信息默认补充进 `## 阐述`,不覆盖 `## 当前理解`。只有明确纠正旧错误时才更新核心定义。
|
|
171
|
+
|
|
172
|
+
**交叉引用完整性检查**(编译收尾):出链回填 raw_sources + 入链保障(被链页面必须回链)+ linked_count 准确性 + 孤立节点显式提醒。
|
|
173
|
+
|
|
174
|
+
**信息时间偏见防范**:不因新信息时间更新就认为更好;除非明确纠正错误,否则不降低旧信息权重。
|
|
175
|
+
|
|
176
|
+
## Concept Independence Test
|
|
177
|
+
|
|
178
|
+
创建新概念页前的强制门禁,防止过泛化、过特异化和组合概念。
|
|
179
|
+
|
|
180
|
+
### 测试一:可定义性 + 单一核心
|
|
181
|
+
|
|
182
|
+
1. 能否用一两句不含同义词循环的话,清晰陈述"这个概念是什么"?
|
|
183
|
+
2. 该定义是否指向**单一核心**?检验:尝试拆解为"A 与 B"、"A 的 B"、"A 中的 B"。若 A 或 B 各自能独立通过可定义性测试,则为组合概念。
|
|
184
|
+
|
|
185
|
+
正面示例:"幸存者偏差"——拆解后各部分无法独立构成概念。
|
|
186
|
+
反面示例:"财富积累与人生算法"——可拆为"财富积累"和"人生算法",两者均可独立定义。
|
|
187
|
+
|
|
188
|
+
**不通过处理**:
|
|
189
|
+
- 不满足可定义性 → 不创建页,信息归入上位概念
|
|
190
|
+
- 不满足单一核心 → 拆分成独立概念分别创建或归入已有页
|
|
191
|
+
|
|
192
|
+
### 测试二:多重验证
|
|
193
|
+
|
|
194
|
+
该概念是否来自**至少两个不同 raw 笔记**的支撑,且有独立的论述角度(非同一篇文章重复剪藏)。
|
|
195
|
+
|
|
196
|
+
**不通过处理**:不创建页,在相关概念页中标记 `<!-- 潜在独立概念:XXX -->`。
|
|
197
|
+
|
|
198
|
+
## Concept Evolution
|
|
199
|
+
|
|
200
|
+
wiki 概念页的核心机制,追踪观念生长全程。
|
|
201
|
+
|
|
202
|
+
概念页标准结构:
|
|
203
|
+
```markdown
|
|
204
|
+
# {{概念名}}
|
|
205
|
+
## 当前理解
|
|
206
|
+
> 一句话核心定义
|
|
207
|
+
## 阐述
|
|
208
|
+
<!-- 整合自 raw 的理解,附 [[01 raw/...]] 出处 -->
|
|
209
|
+
## 不同理解
|
|
210
|
+
<!-- 冲突观点并列,附时间与出处 -->
|
|
211
|
+
## 概念演化
|
|
212
|
+
<!-- - (YYYY-MM) 旧理解摘要 [[01 raw/出处]] -->
|
|
213
|
+
## 相关概念
|
|
214
|
+
<!-- [[02 wiki/...]] 双向链接 -->
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
触发版本归档:新素材明确纠正旧事实错误 → 旧定义移入 `## 概念演化`,更新 `## 当前理解`。
|
|
218
|
+
触发冲突记录:不同来源有不同理解且无法判定对错 → 列入 `## 不同理解`,并列呈现。
|
|
219
|
+
|
|
220
|
+
## Metadata Completion
|
|
221
|
+
|
|
222
|
+
编译前自动补全 raw 的 YAML frontmatter:
|
|
223
|
+
|
|
224
|
+
| 字段 | 级别 | 规则 |
|
|
225
|
+
|------|------|------|
|
|
226
|
+
| `status` | 自动 | 缺失时设为 `processed`;已存在则不修改 |
|
|
227
|
+
| `type` | 自动 | 缺失补 `source` |
|
|
228
|
+
| `created` | 自动 | 缺失取文件系统创建时间 |
|
|
229
|
+
| `source_url` | 推断 | 从正文查找链接补入 |
|
|
230
|
+
| `title` | 推断 | 缺失则根据正文生成人类可读标题 |
|
|
231
|
+
| `tags` | 推断 | 提取 2-4 个主题标签 |
|
|
232
|
+
| 其他 | 手动 | 缺失不补 |
|
|
233
|
+
|
|
234
|
+
外部渠道(剪藏、抓取)的无 YAML 笔记,编译前自动生成最小 YAML 块。
|
|
235
|
+
|
|
236
|
+
## Filename Blocking
|
|
237
|
+
|
|
238
|
+
编译时检测不可读文件名,防止污染知识库。
|
|
239
|
+
|
|
240
|
+
触发条件:
|
|
241
|
+
- 文件名含随机字符串(如 `clip_20260506_1423.md`)
|
|
242
|
+
- 文件名与正文内容明显不符
|
|
243
|
+
- 与已有文件名冲突
|
|
244
|
+
|
|
245
|
+
阻断流程:停止处理 → YAML 写 `title: 建议标题` → 追加 `03 outputs/待确认文件名.md` → 提示用户 → 用户重命名后重新编译。
|
|
246
|
+
|
|
247
|
+
## Health Check
|
|
248
|
+
|
|
249
|
+
月度体检输出格式(`03 outputs/月度体检-YYYY-MM.md`):
|
|
250
|
+
|
|
251
|
+
```markdown
|
|
252
|
+
# 月度体检报告 — YYYY-MM
|
|
253
|
+
## 概念演化一览
|
|
254
|
+
## 脆弱依赖
|
|
255
|
+
## 孤岛节点
|
|
256
|
+
## 时间提示
|
|
257
|
+
## 建议行动
|
|
258
|
+
- [ ] ...
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
定性使用影响力信息(核心概念/边缘概念),不列具体 linked_count 数值。
|
|
262
|
+
|
|
263
|
+
## Context Discipline
|
|
264
|
+
|
|
265
|
+
- 只加载当前命令所需的最小文件集合
|
|
266
|
+
- 优先搜索再读取,不做全库全文装载
|
|
267
|
+
- 若本地 `AGENTS.md` 已覆盖规则,不在 skill 中创造第二套规则
|
|
268
|
+
- 输出简短、操作型,说明读取/更新了哪些文件
|
|
269
|
+
|
|
270
|
+
## Refusal Rules
|
|
271
|
+
|
|
272
|
+
- Bootstrap mode 下除 `/kb-init` 外拒绝所有命令
|
|
273
|
+
- 拒绝未指定 raw 的旧式 ingest 请求,引导使用 `/wiki-compile`
|
|
274
|
+
- 拒绝任何改写 raw 正文含义的请求
|
|
275
|
+
- 拒绝把 `00 daily memo/` 当作编译或主题输入
|
|
276
|
+
- `/wiki-topic` 若缺少合适主题且用户未明确要求新建,说明缺口并停止
|
|
277
|
+
- `/wiki-lint` 只输出建议,绝不自动创建主题页
|
|
278
|
+
|
|
279
|
+
## Context Loading Strategy
|
|
280
|
+
|
|
281
|
+
- 永远先读本地 `AGENTS.md`
|
|
282
|
+
- `/kb-init`:加载 default-schema + 模板文件
|
|
283
|
+
- `/wiki-compile`:加载指定或候选 raw + 相关 wiki 概念页 + map 页 + log.md
|
|
284
|
+
- `/wiki-topic`:加载对应 map 页 + 候选概念页 + 相关 raw(按需)
|
|
285
|
+
- `/wiki-lint`:先搜索定位问题,按需打开少量文件,不做全库全文读取
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "LLM Wiki Stack"
|
|
3
|
+
short_description: "Bootstrap and maintain an LLM-owned markdown wiki."
|
|
4
|
+
brand_color: "#0F766E"
|
|
5
|
+
default_prompt: "Use $llm-wiki-stack to initialize or maintain a raw-sources -> wiki -> schema knowledge base."
|
|
6
|
+
|
|
7
|
+
policy:
|
|
8
|
+
allow_implicit_invocation: true
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# LLM Wiki Schema
|
|
2
|
+
|
|
3
|
+
本仓库采用知识库编译器三层结构:
|
|
4
|
+
|
|
5
|
+
- `raw sources`:`01 raw`
|
|
6
|
+
- `wiki`:`02 wiki`
|
|
7
|
+
- `outputs`:`03 outputs`
|
|
8
|
+
- `schema`:本文件 `AGENTS.md`
|
|
9
|
+
|
|
10
|
+
完整规则集参见 skill 内置的 `references/default-schema.md`。
|
|
11
|
+
本文件仅定义项目特定配置和增量规则;通用 compile / topic / lint 工作流以 default-schema.md 为准。
|
|
12
|
+
|
|
13
|
+
## 项目路径
|
|
14
|
+
|
|
15
|
+
- `raw_root = 01 raw`
|
|
16
|
+
- `wiki_root = 02 wiki`
|
|
17
|
+
- `output_root = 03 outputs`
|
|
18
|
+
- `template_root = 98 template`
|
|
19
|
+
- `assets_root = _assets`
|
|
20
|
+
|
|
21
|
+
## 项目特定规则
|
|
22
|
+
|
|
23
|
+
以下规则是对 default-schema.md 的补充或覆盖,优先级高于 default-schema.md。
|
|
24
|
+
|
|
25
|
+
### Raw Asset Rules
|
|
26
|
+
|
|
27
|
+
带图片、截图、音频、附件等本地资源的 raw,统一使用库根 `_assets/` 作为资源根目录。
|
|
28
|
+
|
|
29
|
+
- 本地资源统一保存到 `_assets/<raw 文件名去扩展名>/`
|
|
30
|
+
- 禁止为 raw 新建同级 `*.assets/`、`assets/` 或 `_assets/` 子目录
|
|
31
|
+
- raw 内本地图片链接必须使用从当前 raw 文件到库根 `_assets` 的相对路径
|
|
32
|
+
- 编译收尾必须确认本次新增 raw 的本地图片链接全部解析到实际文件
|
|
33
|
+
|
|
34
|
+
### Daily Memo Boundary
|
|
35
|
+
|
|
36
|
+
`00 daily memo/**` 是独立模块,不属于 `raw sources`,也不属于 `wiki`。
|
|
37
|
+
|
|
38
|
+
- 不要将 `00 daily memo` 视为编译输入
|
|
39
|
+
- 不要在 `02 wiki` 中链接、引用或沉淀 `00 daily memo` 的内容
|
|
40
|
+
- 不要把 `00 daily memo` 的页面登记到 wiki 的任何导航或索引中
|
|
41
|
+
|
|
42
|
+
### Git Scope
|
|
43
|
+
|
|
44
|
+
- 纳入 git:`01 raw/**`、`02 wiki/**`、`03 outputs/**`、`98 template/**`、`AGENTS.md`、必要的共享资源文件
|
|
45
|
+
- 不纳入 git:`00 daily memo/**`、`.obsidian/**`、`.DS_Store`、`*.icloud`、`.wiki-kb/**`
|
|
46
|
+
|
|
47
|
+
### Git Sync 约定
|
|
48
|
+
|
|
49
|
+
实质变更后提交。commit message 格式:
|
|
50
|
+
|
|
51
|
+
- `compile: <分区或主题>`
|
|
52
|
+
- `topic: <主题名>`
|
|
53
|
+
- `refactor: <页面或结构>`
|
|
54
|
+
- `lint: <修复范围>`
|
|
55
|
+
- `fix: <具体问题>`
|
|
56
|
+
- `init: <初始化步骤>`
|
|
57
|
+
|
|
58
|
+
提交粒度:一次知识库动作对应一次 commit。不要求把 commit hash 回写进页面。
|
|
59
|
+
|
|
60
|
+
### 编译工作流(项目增量)
|
|
61
|
+
|
|
62
|
+
在 default-schema.md 的编译流程之上:
|
|
63
|
+
|
|
64
|
+
- 编译不在此阶段创建 outputs 页(那是 `/wiki-topic` 的职责)
|
|
65
|
+
- 仅当 raw 满足"枢纽来源"条件且用户明确要求时,才创建单篇来源页
|
|
66
|
+
- 若本次编译涉及本地图片或附件,先确认资源已保存到 `_assets/<raw 文件名去扩展名>/`
|
|
67
|
+
|
|
68
|
+
### 主题页写作规则
|
|
69
|
+
|
|
70
|
+
`02 wiki/` 下概念页默认按"可复用结论页"来写:
|
|
71
|
+
|
|
72
|
+
- 语言风格:简练、客观、清晰,避免口语化废话和 AI 式套话
|
|
73
|
+
- 优先输出压缩后的判断、优先级和取舍
|
|
74
|
+
- 如果 raw 已提供具体数字、动作、例子,正文中至少吸收一个具体细节
|
|
75
|
+
- 能明确判断时直接写结论,不默认做两边都讲的中性综述
|
|
76
|
+
- 结构服务于内容,不为结构而结构
|
|
77
|
+
|
|
78
|
+
### 单篇来源页例外条件
|
|
79
|
+
|
|
80
|
+
以下情况可创建单篇来源页(需用户明确要求):
|
|
81
|
+
|
|
82
|
+
- raw 本身非常长,内部已有多个可复用子结构
|
|
83
|
+
- 该 raw 预计会被高频反复引用
|
|
84
|
+
- 该 raw 属于会持续编译的系列内容
|
|
85
|
+
- 该 raw 能同时支撑多个概念页,具有"枢纽来源"角色
|
|
86
|
+
|
|
87
|
+
### Query Workflow
|
|
88
|
+
|
|
89
|
+
回答问题时优先使用 `02 wiki/` 概念页定位知识,再按需回读 raw。
|
|
90
|
+
|
|
91
|
+
- 若 wiki 层已经覆盖问题,优先基于 wiki 回答
|
|
92
|
+
- 若没有合适概念页,默认先停在 wiki 层;只有用户明确要求新建主题时,才通过 `/wiki-topic` 创建 outputs 页
|
|
93
|
+
- 只有在 wiki 缺失或需要核对原文时,才回读 raw
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: concept
|
|
3
|
+
status: active
|
|
4
|
+
created: {{DATE}}
|
|
5
|
+
updated: {{DATE}}
|
|
6
|
+
linked_count: 0
|
|
7
|
+
raw_sources: []
|
|
8
|
+
tags: []
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# {{概念名}}
|
|
12
|
+
|
|
13
|
+
## 当前理解
|
|
14
|
+
|
|
15
|
+
> 一句话核心定义,随认知演化更新
|
|
16
|
+
|
|
17
|
+
## 阐述
|
|
18
|
+
|
|
19
|
+
<!-- 整合来自不同 raw 的理解,每条关键陈述附 [[01 raw/...]] 出处 -->
|
|
20
|
+
|
|
21
|
+
## 不同理解
|
|
22
|
+
|
|
23
|
+
<!-- 若存在观点冲突,并列不同来源的视角与时间 -->
|
|
24
|
+
|
|
25
|
+
## 概念演化
|
|
26
|
+
|
|
27
|
+
<!-- 格式:- (YYYY-MM) 旧理解摘要 [[01 raw/出处]] -->
|
|
28
|
+
|
|
29
|
+
## 相关概念
|
|
30
|
+
|
|
31
|
+
<!-- [[02 wiki/...]] 双向链接 -->
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: entity
|
|
3
|
+
status: active
|
|
4
|
+
created: {{DATE}}
|
|
5
|
+
updated: {{DATE}}
|
|
6
|
+
raw_sources: []
|
|
7
|
+
tags: []
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# {{实体名}}
|
|
11
|
+
|
|
12
|
+
## 基本信息
|
|
13
|
+
|
|
14
|
+
<!-- 谁/什么、时间、关键属性 —— 事实性描述 -->
|
|
15
|
+
|
|
16
|
+
## 相关素材
|
|
17
|
+
|
|
18
|
+
<!-- [[01 raw/...]] 出处列表 -->
|
|
19
|
+
|
|
20
|
+
## 相关概念
|
|
21
|
+
|
|
22
|
+
<!-- [[02 wiki/...]] 链接到解释该实体的概念页 -->
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: health-report
|
|
3
|
+
created: {{DATE}}
|
|
4
|
+
tags:
|
|
5
|
+
- 月度体检
|
|
6
|
+
- 系统报告
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# 月度体检报告 — {{YYYY-MM}}
|
|
10
|
+
|
|
11
|
+
## 概念演化一览
|
|
12
|
+
|
|
13
|
+
<!-- 本月发生理解更新的概念 -->
|
|
14
|
+
|
|
15
|
+
## 脆弱依赖
|
|
16
|
+
|
|
17
|
+
<!-- 03 outputs 中观点依赖低 linked_count 概念的情况 -->
|
|
18
|
+
|
|
19
|
+
## 孤岛节点
|
|
20
|
+
|
|
21
|
+
<!-- linked_count 为 0 或长期未被引用的 02 wiki 页面 -->
|
|
22
|
+
|
|
23
|
+
## 时间提示
|
|
24
|
+
|
|
25
|
+
<!-- 引用了已演化概念的 03 outputs 笔记 -->
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 建议行动
|
|
30
|
+
|
|
31
|
+
- [ ] ...
|
|
32
|
+
- [ ] ...
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: log
|
|
3
|
+
status: active
|
|
4
|
+
created: {{DATE}}
|
|
5
|
+
updated: {{DATE}}
|
|
6
|
+
raw_sources: []
|
|
7
|
+
tags:
|
|
8
|
+
- llm-wiki-stack
|
|
9
|
+
- 日志
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# LLM Wiki Log
|
|
13
|
+
|
|
14
|
+
## [{{DATE}}] bootstrap | 初始化 wiki 骨架
|
|
15
|
+
|
|
16
|
+
- 建立 `02 wiki` 的分区目录、map 页与日志结构。
|
|
17
|
+
- 创建 `log.md` 与根目录 `AGENTS.md`。
|
|
18
|
+
- 初始化本地知识库管理规则,并准备后续 compile / topic / lint 工作流。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: output
|
|
3
|
+
status: in-progress
|
|
4
|
+
created: {{DATE}}
|
|
5
|
+
tags: []
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# {{主题名}}
|
|
9
|
+
|
|
10
|
+
## 我的问题
|
|
11
|
+
|
|
12
|
+
{{用户输入的研究问题}}
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
> 🤖 **初始分析**(LLM 基于 02 wiki 生成)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 对话
|
|
21
|
+
|
|
22
|
+
<!-- 用户与 LLM 持续交互,LLM 部分用 🤖 标记 -->
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ✍️ 我的综合判断
|
|
27
|
+
|
|
28
|
+
<!-- 思考成熟后写下最终观点 -->
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# llm-wiki-stack Command Manifest
|
|
2
|
+
|
|
3
|
+
Framework: `llm-wiki-stack`
|
|
4
|
+
|
|
5
|
+
## Spec Mapping
|
|
6
|
+
|
|
7
|
+
| 命令 | 规格书动作 |
|
|
8
|
+
|------|-----------|
|
|
9
|
+
| `/kb-init` | `🏗️ 初始化知识库` |
|
|
10
|
+
| `/wiki-compile` | `🔄 编译新素材` |
|
|
11
|
+
| `/wiki-topic` | `🧠 新建主题` |
|
|
12
|
+
| `/wiki-lint` | `🏥 月度体检` |
|
|
13
|
+
|
|
14
|
+
(`📄 新建源笔记` 由 Obsidian QuickAdd + 模板完成,非 LLM 命令)
|
|
15
|
+
|
|
16
|
+
## Command Adapters
|
|
17
|
+
|
|
18
|
+
- `kb-init` -> bootstrap workflow
|
|
19
|
+
- `wiki-compile` -> compilation pipeline
|
|
20
|
+
- `wiki-topic` -> topic workflow (outputs layer)
|
|
21
|
+
- `wiki-lint` -> lint + health check workflow
|
|
22
|
+
|
|
23
|
+
## Rule Hierarchy
|
|
24
|
+
|
|
25
|
+
1. repo-local `AGENTS.md`
|
|
26
|
+
2. `llm-wiki-stack/SKILL.md`
|
|
27
|
+
3. `llm-wiki-stack/references/default-schema.md`
|
|
28
|
+
|
|
29
|
+
## Interpretation Rules
|
|
30
|
+
|
|
31
|
+
- 这些 wrapper 属于同一个知识库管理框架,不是彼此独立的 skill。
|
|
32
|
+
- wrapper 不定义自己的 schema;它们只把用户请求映射到 core skill 的某一个命令入口。
|
|
33
|
+
- 若 wrapper 文案与 core skill 或 repo-local `AGENTS.md` 冲突,以更高层规则为准。
|
|
34
|
+
- `/wiki-compile` 是唯一将 raw 编译进 wiki 的入口,不再有独立的 lightweight ingest。
|
|
35
|
+
- `/kb-init` 是编排入口:初始化骨架后复用 core `/wiki-compile` 流水线编译全部合格 raw,并用 `/wiki-lint` 机械检查作为完成门禁;不得调用 `/wiki-topic` 生成初始化报告。
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Default Schema
|
|
2
|
+
|
|
3
|
+
本文件定义 `llm-wiki-stack` 在 bootstrap mode 下使用的默认知识库规则。
|
|
4
|
+
|
|
5
|
+
当 repo-local `AGENTS.md` 不存在时:
|
|
6
|
+
- `/kb-init` 以本文件作为默认 profile
|
|
7
|
+
- 其他日常动作不得继续执行,应提示先初始化
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
三层编译器架构:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
01 raw/ ──编译──> 02 wiki/ ──对话──> 03 outputs/
|
|
15
|
+
(不可变源) (概念网络) (个人观点)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **L1 raw**:源笔记,LLM 只读正文,可按权限规则修改 YAML frontmatter
|
|
19
|
+
- **L2 wiki**:概念页,LLM 维护,追踪概念演化
|
|
20
|
+
- **L3 outputs**:观点主题页 + 系统报告,用户主导,LLM 辅助
|
|
21
|
+
|
|
22
|
+
## Default Paths
|
|
23
|
+
|
|
24
|
+
- `raw_root = 01 raw`
|
|
25
|
+
- `wiki_root = 02 wiki`
|
|
26
|
+
- `output_root = 03 outputs`
|
|
27
|
+
- `template_root = 98 template`
|
|
28
|
+
- `assets_root = _assets`
|
|
29
|
+
|
|
30
|
+
## Bootstrap
|
|
31
|
+
|
|
32
|
+
`/kb-init` 假定用户只有大模型和一个目录,必须先做 dependency doctor:
|
|
33
|
+
|
|
34
|
+
- 检查 `git`、`rg`、基础 shell 工具和当前目录写权限
|
|
35
|
+
- `git` 与写权限为必需项;缺失时请求授权安装或提示用户处理
|
|
36
|
+
- `rg` 为推荐项;缺失时可回退到 `grep/find`
|
|
37
|
+
|
|
38
|
+
初始化流程:
|
|
39
|
+
|
|
40
|
+
1. 创建 `01 raw/`、`02 wiki/`、`03 outputs/`、`98 template/`
|
|
41
|
+
2. 用模板生成 `AGENTS.md`、`02 wiki/log.md`
|
|
42
|
+
3. 若 `01 raw/` 下存在 raw 文件,扫描并生成 `03 outputs/初始化提案.md`(列出建议创建的 wiki 概念页、重要度、链接关系)
|
|
43
|
+
4. **等待用户审阅确认**初始化提案
|
|
44
|
+
5. 用户确认后,调用 `/wiki-compile` 核心流水线,并传入全部合格 raw 文件的显式列表;`/kb-init` 不另写编译逻辑
|
|
45
|
+
6. 建立或补齐全局索引页和分区 map 页,确保概念页可从索引导航到达
|
|
46
|
+
7. 调用 `/wiki-lint` 机械检查作为完成门禁:未编译 raw、断链、frontmatter、raw_sources、双向回链、linked_count 和孤立节点必须检查
|
|
47
|
+
8. 输出 `03 outputs/初始化完成报告.md`,记录 raw 总数、已编译数、跳过项及原因、概念页数、map 页数和 lint 门禁结果
|
|
48
|
+
9. 初始化 git 和 `.gitignore`
|
|
49
|
+
|
|
50
|
+
## Page Types
|
|
51
|
+
|
|
52
|
+
wiki 和 outputs 页面统一使用最小 frontmatter:
|
|
53
|
+
|
|
54
|
+
| type | 所在层 | 说明 |
|
|
55
|
+
|------|--------|------|
|
|
56
|
+
| `source` | raw | 源笔记 |
|
|
57
|
+
| `entity` | wiki | 实体页——具体的人、组织、产品、岗位等可指名事物 |
|
|
58
|
+
| `concept` | wiki | 概念页——跨实体提炼的框架、原理、模式 |
|
|
59
|
+
| `map` | wiki | 分区导航页,簇识别与入口路由 |
|
|
60
|
+
| `log` | wiki | 追加式操作日志 |
|
|
61
|
+
| `output` | outputs | 观点主题页,question-driven 对话 |
|
|
62
|
+
| `health-report` | outputs | 月度体检报告 |
|
|
63
|
+
|
|
64
|
+
### concept 页 frontmatter
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
type: concept
|
|
68
|
+
status: active
|
|
69
|
+
created: YYYY-MM-DD
|
|
70
|
+
updated: YYYY-MM-DD
|
|
71
|
+
linked_count: 0
|
|
72
|
+
raw_sources: []
|
|
73
|
+
tags: []
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
linked_count 记录被其他 wiki 页和 outputs 页引用的次数,LLM 编译和创建主题时更新。
|
|
77
|
+
|
|
78
|
+
### entity 页 frontmatter
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
type: entity
|
|
82
|
+
status: active
|
|
83
|
+
created: YYYY-MM-DD
|
|
84
|
+
updated: YYYY-MM-DD
|
|
85
|
+
raw_sources: []
|
|
86
|
+
tags: []
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
实体页记录具体事物的事实信息(谁/什么、时间、关键属性),通过 `## 相关素材` 链接 raw 出处,`## 相关概念` 链接到解释该实体的概念页。实体页不包含 `## 当前理解` 和 `## 概念演化`——那是概念页的职责。
|
|
90
|
+
|
|
91
|
+
### output 页 frontmatter
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
type: output
|
|
95
|
+
status: in-progress
|
|
96
|
+
created: YYYY-MM-DD
|
|
97
|
+
tags: []
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Raw Boundary
|
|
101
|
+
|
|
102
|
+
- 允许:移动目录、重命名文件、按主题重组层级
|
|
103
|
+
- 禁止:修改正文、增删原文段落、改写原始摘录含义
|
|
104
|
+
- 如需补充结构化信息,只写到 `02 wiki`
|
|
105
|
+
|
|
106
|
+
## Permission Model
|
|
107
|
+
|
|
108
|
+
raw 笔记采用三级权限:
|
|
109
|
+
|
|
110
|
+
| 区域 | 权限 | 说明 |
|
|
111
|
+
|------|------|------|
|
|
112
|
+
| 正文(标题、`## 即时思考`、`## 原文`) | **只读** | LLM 绝不修改 |
|
|
113
|
+
| YAML frontmatter | **可写,分级** | 见下方字段表 |
|
|
114
|
+
| 文件名 | **可建议** | LLM 仅可建议,不直接修改 |
|
|
115
|
+
|
|
116
|
+
### YAML 字段处理规则
|
|
117
|
+
|
|
118
|
+
| 字段 | 类型 | 处理 |
|
|
119
|
+
|------|------|------|
|
|
120
|
+
| `status` | 自动 | 缺失时设为 `processed`;已存在则不修改 |
|
|
121
|
+
| `type` | 自动 | 缺失时填入 `source` |
|
|
122
|
+
| `created` | 自动 | 缺失时取文件系统创建时间 |
|
|
123
|
+
| `source_url` | 推断 | 从正文查找链接补入 |
|
|
124
|
+
| `title` | 推断 | 缺则根据正文生成人类可读标题 |
|
|
125
|
+
| `tags` | 推断 | 提取 2-4 个主题标签 |
|
|
126
|
+
| 其他 | 手动 | 缺失不补,不猜测 |
|
|
127
|
+
|
|
128
|
+
来自外部渠道(剪藏、抓取)的无 YAML 笔记,LLM 在编译开始前自动生成最小 YAML 块并补全上述字段。
|
|
129
|
+
|
|
130
|
+
## Compilation Workflow (`/wiki-compile`)
|
|
131
|
+
|
|
132
|
+
`🔄 编译新素材` 是唯一将 raw 编译进 wiki 的入口,替代旧的 lightweight ingest 模式。
|
|
133
|
+
|
|
134
|
+
流程:
|
|
135
|
+
|
|
136
|
+
**文件选择**:
|
|
137
|
+
- 若用户指定了 raw 文件路径,直接编译
|
|
138
|
+
- 若由 `/kb-init` 调用,使用初始化阶段扫描并经用户确认的全部合格 raw 文件显式列表;只跳过交互式候选选择,不跳过后续编译门禁
|
|
139
|
+
- 若未指定,检测未编译 raw:收集 wiki 概念页 raw_sources 中已引用的路径,扫描 `01 raw/` 全量,找出不在已编译集合中的文件,呈现候选列表供用户确认
|
|
140
|
+
- 若候选列表为空,提示"当前无未编译 raw 文件"并退出
|
|
141
|
+
|
|
142
|
+
流程(对每个待编译文件):
|
|
143
|
+
1. **文件名阻断检查**:文件名含随机字符串、与正文内容明显不符、或与已有文件冲突时,停止处理该文件,写入 `title: 建议标题` 到其 YAML,追加记录到 `03 outputs/待确认文件名.md`,提示用户处理后重新编译
|
|
144
|
+
2. **元数据补全**:按 Permission Model 规则补全缺失的 YAML 字段,正文永不修改
|
|
145
|
+
3. **实体提取**:从 raw 中提取关键实体和概念
|
|
146
|
+
4. **概念独立性测试**:创建新概念页前必须通过可定义性、单一核心和多重验证;单来源候选不创建独立页,只进入相关概念页或报告说明
|
|
147
|
+
5. **wiki 页创建/更新**,对每个实体/概念:
|
|
148
|
+
- 无对应 wiki 页则基于 `concept.template.md` 创建
|
|
149
|
+
- 已存在则默认**补充**新信息至 `## 阐述`,不覆盖 `## 当前理解`
|
|
150
|
+
- **只有新信息明确纠正旧事实错误**时,将旧定义追加到 `## 概念演化`:`- (YYYY-MM) 旧理解摘要 [[01 raw/出处]]`,再更新 `## 当前理解`
|
|
151
|
+
- **观点冲突**:列入 `## 不同理解`,并列双方时间与出处,不判定对错
|
|
152
|
+
6. 每条关键陈述附 `[[01 raw/...]]` 出处链接
|
|
153
|
+
7. 建立 wiki 间 `[[02 wiki/...]]` 双向链接
|
|
154
|
+
8. 交叉引用完整性检查:正文 raw 链接回填到 `raw_sources`,相关概念获得回链,`linked_count` 等于实际入链数
|
|
155
|
+
9. 更新受影响 wiki 页的 `linked_count`(=入链数)和 `updated`
|
|
156
|
+
|
|
157
|
+
编译完成后提交 git。
|
|
158
|
+
|
|
159
|
+
## Concept Evolution
|
|
160
|
+
|
|
161
|
+
wiki 概念页追踪观念生长全程,不覆盖历史。
|
|
162
|
+
|
|
163
|
+
**页面结构**:
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
# {{概念名}}
|
|
167
|
+
|
|
168
|
+
## 当前理解
|
|
169
|
+
> 一句话核心定义,随认知演化更新
|
|
170
|
+
|
|
171
|
+
## 阐述
|
|
172
|
+
<!-- 整合来自不同 raw 的理解,每条关键陈述附 [[01 raw/...]] 出处 -->
|
|
173
|
+
|
|
174
|
+
## 不同理解
|
|
175
|
+
<!-- 若存在观点冲突,并列不同来源的视角与时间 -->
|
|
176
|
+
|
|
177
|
+
## 概念演化
|
|
178
|
+
<!-- - (YYYY-MM) 旧理解摘要 [[01 raw/出处]] -->
|
|
179
|
+
|
|
180
|
+
## 相关概念
|
|
181
|
+
<!-- [[02 wiki/...]] 双向链接 -->
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**版本归档触发条件**:新素材明确纠正了旧事实错误。
|
|
185
|
+
**冲突记录触发条件**:不同来源对同一概念有不同理解,且无法判定对错。
|
|
186
|
+
|
|
187
|
+
默认假设新信息为补充,不因时间新就认为更好。
|
|
188
|
+
|
|
189
|
+
## Filename Blocking
|
|
190
|
+
|
|
191
|
+
防止随机 ID 文件名污染知识库。
|
|
192
|
+
|
|
193
|
+
触发条件(任一):
|
|
194
|
+
- 文件名含随机字符串(如 `clip_20260506_1423.md`)
|
|
195
|
+
- 文件名与正文内容明显不符
|
|
196
|
+
- 与已有文件名冲突
|
|
197
|
+
|
|
198
|
+
阻断流程:
|
|
199
|
+
1. `/wiki-compile` 发现此类文件,停止处理
|
|
200
|
+
2. 在该 raw 的 YAML 写入 `title: 建议标题`
|
|
201
|
+
3. 追加记录到 `03 outputs/待确认文件名.md`
|
|
202
|
+
4. 提示用户:"有 N 个文件待确认文件名,请处理后重新运行编译"
|
|
203
|
+
5. 用户处理完毕后再次触发编译,LLM 检查通过后继续
|
|
204
|
+
|
|
205
|
+
## Influence Weight
|
|
206
|
+
|
|
207
|
+
通过 `linked_count` 追踪概念被引用次数,定性区分核心与边缘。
|
|
208
|
+
|
|
209
|
+
- LLM 编译时更新受影响 wiki 页的 `linked_count`
|
|
210
|
+
- 在 outputs 对话和体检报告中定性使用:`被 outputs/ 引用` → 核心概念;`linked_count 低` → 边缘概念
|
|
211
|
+
- 默认不进行 PageRank 式递归计算,保持简单
|
|
212
|
+
|
|
213
|
+
## Health Check (`/wiki-lint`)
|
|
214
|
+
|
|
215
|
+
`🏥 月度体检` 目标:全库健康检查 + 结构化报告。
|
|
216
|
+
|
|
217
|
+
检查项:
|
|
218
|
+
- **断链**:所有 `[[...]]` 目标文件是否存在
|
|
219
|
+
- **孤儿页**:wiki 概念页是否被其他页面引用
|
|
220
|
+
- **空目录**:wiki、raw、outputs 下的空目录
|
|
221
|
+
- **frontmatter 完整性**:wiki/outputs 页面是否有 type/status/created/updated
|
|
222
|
+
- **linked_count 一致性**:声明的 linked_count vs 实际引用数
|
|
223
|
+
- **raw_sources 回填状态**:概念页正文引用了 raw 但 frontmatter raw_sources 为空
|
|
224
|
+
- **未编译 raw**:raw 文件未被任何 wiki 概念页的 raw_sources 引用
|
|
225
|
+
|
|
226
|
+
当 `/wiki-lint` 作为 `/kb-init` 完成门禁调用时,只执行机械检查和低风险自动修复;语义合并、主题创建和破坏性结构清理不得自动执行。
|
|
227
|
+
|
|
228
|
+
输出格式 `03 outputs/月度体检-YYYY-MM.md`,使用 `- [ ]` 任务列表:
|
|
229
|
+
|
|
230
|
+
- **概念演化一览**:本月发生理解更新的概念
|
|
231
|
+
- **脆弱依赖**:outputs 中观点依赖低 linked_count 概念的情况
|
|
232
|
+
- **孤岛节点**:linked_count 为 0 的 wiki 概念页
|
|
233
|
+
- **时间提示**:引用了已演化概念的 outputs 笔记
|
|
234
|
+
|
|
235
|
+
报告中定性使用影响力信息,不列具体数值。只输出建议,绝不自动创建主题页。
|
|
236
|
+
|
|
237
|
+
## Topic Workflow (`/wiki-topic`)
|
|
238
|
+
|
|
239
|
+
`🧠 新建主题` 是 question-driven 的观点形成流程,写入 `03 outputs/`。
|
|
240
|
+
|
|
241
|
+
流程:
|
|
242
|
+
1. 用户提出一个**问题**(非概念列表)
|
|
243
|
+
2. LLM 读取相关 wiki 概念,生成 `🤖 初始分析`(含来源标注)
|
|
244
|
+
3. 用户在 `对话` 区持续追问、质疑、引导,LLM 回应(均用 `🤖` 标记)
|
|
245
|
+
4. 用户自行在 `✍️ 我的综合判断` 写下结论
|
|
246
|
+
5. 相关 wiki 链接自动建立,`linked_count` 增加
|
|
247
|
+
|
|
248
|
+
LLM 权限:
|
|
249
|
+
- 可写入 `🤖 初始分析` 和对话区自己的回复
|
|
250
|
+
- 对话区用户内容、`✍️ 我的综合判断` 只读
|
|
251
|
+
- 不替用户做综合判断
|
|
252
|
+
|
|
253
|
+
## Git Sync
|
|
254
|
+
|
|
255
|
+
实质变更后提交,不再有 off/major/on 模式切换。
|
|
256
|
+
|
|
257
|
+
实质变更定义:
|
|
258
|
+
- 发生了文件或目录的创建、删除、移动、重命名
|
|
259
|
+
- 修改命中了 `01 raw/**` 或 `02 wiki/**` 或 `03 outputs/**` 下的内容
|
|
260
|
+
- 结构初始化或 schema 级改动
|
|
261
|
+
|
|
262
|
+
不算实质变更:
|
|
263
|
+
- 纯错字修复
|
|
264
|
+
- 单页轻微措辞调整
|
|
265
|
+
|
|
266
|
+
commit message 格式:`ingest: <分区>`, `compile: <主题>`, `refactor: <范围>`, `lint: <范围>`, `fix: <问题>`
|
|
267
|
+
|
|
268
|
+
## Linking Rules
|
|
269
|
+
|
|
270
|
+
- raw 与 wiki 的关联统一用 Obsidian 链接维护
|
|
271
|
+
- 概念页必须列出 `raw_sources`,并在正文中链接关键来源
|
|
272
|
+
- 命名使用中文优先;概念页不带时间戳
|
|
273
|
+
- wiki 概念页之间通过 `## 相关概念` 双向链接
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wiki-compile
|
|
3
|
+
description: Subcommand of the `llm-wiki-stack` knowledge-base management framework. Compile user-specified or uncompiled raw files into the wiki layer with concept evolution, metadata completion, and linked_count tracking. Use when the user wants to run `/wiki-compile` or `🔄 编译新素材`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wiki Compile
|
|
7
|
+
|
|
8
|
+
## Framework Binding
|
|
9
|
+
|
|
10
|
+
- This skill is one command adapter in the `llm-wiki-stack` framework.
|
|
11
|
+
- It does not define its own schema or workflow; it delegates to `../llm-wiki-stack/SKILL.md`.
|
|
12
|
+
- Repo-local `AGENTS.md` overrides both the core framework and this wrapper.
|
|
13
|
+
|
|
14
|
+
- This skill is a thin wrapper around `llm-wiki-stack`.
|
|
15
|
+
- First read `../llm-wiki-stack/SKILL.md` and follow the `/wiki-compile` command path only.
|
|
16
|
+
- Treat the user request as an explicit `/wiki-compile` invocation.
|
|
17
|
+
- Run the full compilation pipeline: determine target files (user-specified or auto-detect uncompiled) → filename check → metadata completion → entity extraction → concept independence test → wiki page creation/update with concept evolution → cross-reference integrity check → linked_count maintenance.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wiki-lint
|
|
3
|
+
description: Subcommand of the `llm-wiki-stack` knowledge-base management framework. Lint an Obsidian knowledge base for orphan pages, duplicate topics, missing backlinks, misplaced raw files, empty source-index entries, and similar structural issues. Use when the user wants to run `/wiki-lint` directly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wiki Lint
|
|
7
|
+
|
|
8
|
+
## Framework Binding
|
|
9
|
+
|
|
10
|
+
- This skill is one command adapter in the `llm-wiki-stack` framework.
|
|
11
|
+
- It does not define its own schema or workflow; it delegates to `../llm-wiki-stack/SKILL.md`.
|
|
12
|
+
- Repo-local `AGENTS.md` overrides both the core framework and this wrapper.
|
|
13
|
+
|
|
14
|
+
- This skill is a thin wrapper around `llm-wiki-stack`.
|
|
15
|
+
- First read `../llm-wiki-stack/SKILL.md` and follow the `/wiki-lint` command path only.
|
|
16
|
+
- Treat the user request as an explicit `/wiki-lint` invocation.
|
|
17
|
+
- Auto-fix low-risk mechanical issues (broken links, missing frontmatter); for semantic merges or destructive structural cleanup, follow the guardrails defined in the core skill.
|
|
18
|
+
- When user requests "月度体检" or "health check", generate a structured health report at `03 outputs/月度体检-YYYY-MM.md` with sections: concept evolution, fragile dependencies, orphan nodes, time hints, and suggested actions.
|
|
19
|
+
- Only output suggestions; never auto-create topic pages.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Wiki Lint"
|
|
3
|
+
short_description: "Lint wiki structure and fix low-risk issues."
|
|
4
|
+
brand_color: "#0F766E"
|
|
5
|
+
default_prompt: "Use $wiki-lint to lint the current LLM wiki and fix low-risk structural issues."
|
|
6
|
+
|
|
7
|
+
policy:
|
|
8
|
+
allow_implicit_invocation: true
|
|
9
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wiki-topic
|
|
3
|
+
description: Subcommand of the `llm-wiki-stack` knowledge-base management framework. Query, synthesize, create, or update a topic page inside an Obsidian knowledge base. Use when the user wants to run `/wiki-topic` directly to update a topic page, infer a topic target, or create a new reusable topic page when explicitly needed.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wiki Topic
|
|
7
|
+
|
|
8
|
+
## Framework Binding
|
|
9
|
+
|
|
10
|
+
- This skill is one command adapter in the `llm-wiki-stack` framework.
|
|
11
|
+
- It does not define its own schema or workflow; it delegates to `../llm-wiki-stack/SKILL.md`.
|
|
12
|
+
- Repo-local `AGENTS.md` overrides both the core framework and this wrapper.
|
|
13
|
+
|
|
14
|
+
- This skill is a thin wrapper around `llm-wiki-stack`.
|
|
15
|
+
- First read `../llm-wiki-stack/SKILL.md` and follow the `/wiki-topic` command path only.
|
|
16
|
+
- Treat the user request as an explicit `/wiki-topic` invocation.
|
|
17
|
+
- New topic pages go into `03 outputs/` with `type: output`. Use question-driven flow: user asks a question → LLM provides initial analysis → dialogue → user writes judgment.
|
|
18
|
+
- Resolve the target topic according to the core skill rules: prefer an explicit page, then an inferred reusable page, and only create a new page when an existing one cannot naturally absorb the content.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Wiki Topic"
|
|
3
|
+
short_description: "Update or create a reusable topic page."
|
|
4
|
+
brand_color: "#0F766E"
|
|
5
|
+
default_prompt: "Use $wiki-topic to update or create a topic page in the current LLM wiki."
|
|
6
|
+
|
|
7
|
+
policy:
|
|
8
|
+
allow_implicit_invocation: true
|
|
9
|
+
|