@biaoo/tiangong-wiki 0.2.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/LICENSE +21 -0
- package/README.md +167 -0
- package/README.zh-CN.md +167 -0
- package/SKILL.md +116 -0
- package/agents/openai.yaml +4 -0
- package/assets/config.example.env +18 -0
- package/assets/templates/achievement.md +32 -0
- package/assets/templates/bridge.md +33 -0
- package/assets/templates/concept.md +47 -0
- package/assets/templates/faq.md +31 -0
- package/assets/templates/lesson.md +31 -0
- package/assets/templates/method.md +31 -0
- package/assets/templates/misconception.md +35 -0
- package/assets/templates/person.md +31 -0
- package/assets/templates/research-note.md +34 -0
- package/assets/templates/resume.md +34 -0
- package/assets/templates/source-summary.md +35 -0
- package/assets/vllm/qwen3_5_openai_developer.jinja +182 -0
- package/assets/wiki.config.default.json +193 -0
- package/dist/commands/check-config.js +77 -0
- package/dist/commands/create.js +32 -0
- package/dist/commands/daemon.js +186 -0
- package/dist/commands/dashboard.js +112 -0
- package/dist/commands/doctor.js +22 -0
- package/dist/commands/export-graph.js +28 -0
- package/dist/commands/export-index.js +31 -0
- package/dist/commands/find.js +36 -0
- package/dist/commands/fts.js +32 -0
- package/dist/commands/graph.js +35 -0
- package/dist/commands/init.js +48 -0
- package/dist/commands/lint.js +35 -0
- package/dist/commands/list.js +28 -0
- package/dist/commands/page-info.js +24 -0
- package/dist/commands/search.js +32 -0
- package/dist/commands/setup.js +15 -0
- package/dist/commands/stat.js +20 -0
- package/dist/commands/sync.js +38 -0
- package/dist/commands/template.js +71 -0
- package/dist/commands/type.js +88 -0
- package/dist/commands/vault.js +64 -0
- package/dist/core/agent.js +201 -0
- package/dist/core/cli-env.js +129 -0
- package/dist/core/codex-workflow.js +233 -0
- package/dist/core/config.js +126 -0
- package/dist/core/db.js +292 -0
- package/dist/core/embedding.js +104 -0
- package/dist/core/frontmatter.js +287 -0
- package/dist/core/indexer.js +241 -0
- package/dist/core/onboarding.js +967 -0
- package/dist/core/page-files.js +91 -0
- package/dist/core/paths.js +161 -0
- package/dist/core/presenters.js +23 -0
- package/dist/core/query.js +58 -0
- package/dist/core/runtime.js +20 -0
- package/dist/core/sync.js +235 -0
- package/dist/core/synology.js +412 -0
- package/dist/core/template-evolution.js +38 -0
- package/dist/core/vault-processing.js +742 -0
- package/dist/core/vault.js +594 -0
- package/dist/core/workflow-context.js +188 -0
- package/dist/core/workflow-result.js +162 -0
- package/dist/core/workspace-bootstrap.js +30 -0
- package/dist/core/workspace-skills.js +220 -0
- package/dist/daemon/client.js +147 -0
- package/dist/daemon/server.js +807 -0
- package/dist/daemon/state.js +53 -0
- package/dist/dashboard/assets/index-1FgAUZ28.css +1 -0
- package/dist/dashboard/assets/index-6A0PWT4X.js +154 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-700-normal-BWTpRfYl.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-cyrillic-700-normal-CEoEElIJ.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-700-normal-C6CZE3T8.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-greek-700-normal-DEigVDxa.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-700-normal-CZipNAKV.woff2 +0 -0
- package/dist/dashboard/assets/jetbrains-mono-latin-ext-700-normal-CxPITLHs.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- package/dist/dashboard/assets/jetbrains-mono-vietnamese-700-normal-BDLVIk2r.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-400-normal-BnQMeOim.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-400-normal-CJ-V5oYT.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-500-normal-CNSSEhBt.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-500-normal-lFbtlQH6.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-700-normal-CwsQ-cCU.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-700-normal-RjhwGPKo.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-400-normal-CfP_5XZW.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-400-normal-DRPE3kg4.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-500-normal-3dgZTiw9.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-500-normal-DUe3BAxM.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-700-normal-BQnZhY3m.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-latin-ext-700-normal-HVCqSBdx.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-400-normal-B7xT_GF5.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-400-normal-BIWiOVfw.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-500-normal-BTqKIpxg.woff +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-500-normal-BmEvtly_.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-700-normal-DMty7AZE.woff2 +0 -0
- package/dist/dashboard/assets/space-grotesk-vietnamese-700-normal-Duxec5Rn.woff +0 -0
- package/dist/dashboard/index.html +18 -0
- package/dist/index.js +86 -0
- package/dist/operations/dashboard.js +1231 -0
- package/dist/operations/export.js +110 -0
- package/dist/operations/query.js +649 -0
- package/dist/operations/type-template.js +210 -0
- package/dist/operations/write.js +143 -0
- package/dist/types/config.js +1 -0
- package/dist/types/page.js +1 -0
- package/dist/utils/case.js +22 -0
- package/dist/utils/errors.js +26 -0
- package/dist/utils/fs.js +77 -0
- package/dist/utils/output.js +33 -0
- package/dist/utils/process.js +60 -0
- package/dist/utils/segmenter.js +24 -0
- package/dist/utils/slug.js +10 -0
- package/dist/utils/time.js +24 -0
- package/package.json +64 -0
- package/references/cli-interface.md +312 -0
- package/references/env.md +122 -0
- package/references/template-design-guide.md +271 -0
- package/references/vault-to-wiki-instruction.md +110 -0
- package/references/wiki-maintenance-instruction.md +190 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Template 设计指南
|
|
2
|
+
|
|
3
|
+
本文档定义如何为 wiki 设计新的 page type 和对应 template。适用于手动创建和 AI 自动演化(`ALLOW_TEMPLATE_EVOLUTION=true`)两种场景。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Template 是什么
|
|
8
|
+
|
|
9
|
+
一个 template 由两部分组成:
|
|
10
|
+
|
|
11
|
+
### 模板文件(`templates/<type>.md`)
|
|
12
|
+
|
|
13
|
+
定义页面的 frontmatter 字段和 body section 骨架:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
---
|
|
17
|
+
pageType: <type>
|
|
18
|
+
title: <Type Title>
|
|
19
|
+
nodeId: <type-slug>
|
|
20
|
+
status: draft
|
|
21
|
+
visibility: private
|
|
22
|
+
sourceRefs: []
|
|
23
|
+
relatedPages: []
|
|
24
|
+
tags: []
|
|
25
|
+
createdAt: 2026-04-06
|
|
26
|
+
updatedAt: 2026-04-06
|
|
27
|
+
# ... type-specific fields
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Section 1
|
|
31
|
+
|
|
32
|
+
引导性提示文本,告诉作者这一节该写什么。
|
|
33
|
+
|
|
34
|
+
## Section 2
|
|
35
|
+
|
|
36
|
+
...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 配置注册(`wiki.config.json` 的 `templates.<type>`)
|
|
40
|
+
|
|
41
|
+
定义该类型的索引行为:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"file": "templates/<type>.md",
|
|
46
|
+
"columns": { },
|
|
47
|
+
"edges": { },
|
|
48
|
+
"summaryFields": [ ]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
两者缺一不可。模板文件定义"写什么",配置注册定义"怎么索引"。
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 2. 何时需要新 Type
|
|
57
|
+
|
|
58
|
+
创建新 type 之前,先确认现有类型是否能覆盖:
|
|
59
|
+
|
|
60
|
+
- 这类知识的**结构**是否与现有类型有本质差异?(字段不同、section 不同)
|
|
61
|
+
- 还是仅仅是**主题**不同?(同样的结构,只是内容领域不同)
|
|
62
|
+
|
|
63
|
+
**主题差异用 tags 区分,结构差异才建新 type。**
|
|
64
|
+
|
|
65
|
+
示例判断:
|
|
66
|
+
- "环境领域的研究笔记" vs "教育领域的研究笔记" → 用 `research-note` + 不同 tags
|
|
67
|
+
- "会议纪要" vs "研究笔记" → 结构不同(参会人、决议、待办 vs 研究问题、文献、发现),需要新 type
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3. Frontmatter 字段设计
|
|
72
|
+
|
|
73
|
+
### 通用字段(不需要设计,自动继承)
|
|
74
|
+
|
|
75
|
+
所有 type 共享以下字段,模板中必须包含:
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
pageType, title, nodeId, status, visibility,
|
|
79
|
+
sourceRefs, relatedPages, tags, createdAt, updatedAt
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Type-specific 字段设计原则
|
|
83
|
+
|
|
84
|
+
1. **只加对查询或分类有意义的字段**。如果一个字段只在 body 中出现,不需要放进 frontmatter
|
|
85
|
+
2. **字段值应该是短文本或枚举**,不是长段落。长内容放 body section
|
|
86
|
+
3. **字段命名使用 camelCase**,系统会自动映射为 snake_case 列名
|
|
87
|
+
4. **不要重复通用字段的语义**。比如不要加 `category` 字段,用 `tags` 代替
|
|
88
|
+
|
|
89
|
+
### 字段放哪一层
|
|
90
|
+
|
|
91
|
+
| 问题 | 放在 | 原因 |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| 需要 `tiangong-wiki find --<field>` 过滤? | `columns` | 建 SQLite 索引列,支持结构化查询 |
|
|
94
|
+
| 需要出现在 `tiangong-wiki search` / `tiangong-wiki fts` 的摘要中? | `summaryFields` | 纳入 summary_text 用于检索 |
|
|
95
|
+
| 需要生成 edge(关联到其他页面/节点)? | `edges` | 写入 edges 表,支持 graph 遍历 |
|
|
96
|
+
| 只是页面内的补充信息? | 仅写在 frontmatter | 存入 `pages.extra` JSON,不建列 |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 4. Columns 设计
|
|
101
|
+
|
|
102
|
+
`columns` 中的字段会在 `pages` 表上建列和索引,支持 `tiangong-wiki find` 的结构化过滤。
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
"columns": {
|
|
106
|
+
"severity": "text",
|
|
107
|
+
"resolvedAt": "text"
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**设计要点**:
|
|
112
|
+
|
|
113
|
+
- 类型目前只支持 `"text"`
|
|
114
|
+
- 只有需要频繁按值过滤的字段才值得建列
|
|
115
|
+
- 不同 type 的 columns 共存于同一张 `pages` 表,非该类型的页面该列值为 NULL
|
|
116
|
+
- 列名全局唯一 — 如果两个 type 都有 `severity` 字段,它们共享同一个列
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 5. Edges 设计
|
|
121
|
+
|
|
122
|
+
`edges` 定义 frontmatter 中的数组字段如何生成 graph 边。
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
"edges": {
|
|
126
|
+
"prerequisites": {
|
|
127
|
+
"edgeType": "prerequisite",
|
|
128
|
+
"resolve": "nodeId"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**三个字段**:
|
|
134
|
+
|
|
135
|
+
| 字段 | 必填 | 说明 |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| `edgeType` | 是 | edge 类型标识,写入 `edges.edge_type` |
|
|
138
|
+
| `resolve` | 是 | 目标匹配方式:`"nodeId"` 匹配 `pages.node_id`;`"path"` 匹配 `pages.id` |
|
|
139
|
+
| `match` | 否 | 正则前置过滤,仅匹配的值参与 resolve |
|
|
140
|
+
|
|
141
|
+
**设计要点**:
|
|
142
|
+
|
|
143
|
+
- 只有**指向其他页面或节点**的数组字段才需要定义 edge
|
|
144
|
+
- `edgeType` 应该表达语义关系(`prerequisite`, `corrects`, `bridges_from`),不是字段名
|
|
145
|
+
- `resolve: "nodeId"` 适用于引用知识图谱中的概念节点
|
|
146
|
+
- `resolve: "path"` 适用于引用具体的页面文件路径
|
|
147
|
+
- `commonEdges`(`relatedPages`, `sourceRefs`)已全局生效,template 中不需要重复定义
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 6. SummaryFields 设计
|
|
152
|
+
|
|
153
|
+
`summaryFields` 中的字段值会拼接进 `pages.summary_text`,用于语义搜索和全文检索。
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
"summaryFields": ["confidence", "masteryLevel", "prerequisites"]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**设计要点**:
|
|
160
|
+
|
|
161
|
+
- 选择能帮助检索的字段 — 如果知道 `domain: "环境工程"` 能帮搜索找到这个页面,就加进去
|
|
162
|
+
- 不要放长文本字段,summary_text 应保持简洁
|
|
163
|
+
- `defaultSummaryFields`(`title`, `tags`)自动包含,不需要重复
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 7. Body Section 设计
|
|
168
|
+
|
|
169
|
+
Body section 是模板文件中 frontmatter 之后的 Markdown 骨架,引导作者(人或 AI)写出结构化内容。
|
|
170
|
+
|
|
171
|
+
**设计原则**:
|
|
172
|
+
|
|
173
|
+
1. **每个 section 用 `##` 标题** 开头
|
|
174
|
+
2. **写一句引导性提示**,告诉作者这一节的目的和期望内容,不是模板占位符
|
|
175
|
+
3. **提示语应该是具体的引导**,不是"在此处填写内容"这样的泛泛之词
|
|
176
|
+
4. **Section 数量控制在 3-6 个** — 太少缺乏结构,太多增加写作负担
|
|
177
|
+
5. **Section 之间应该有逻辑递进** — 比如从"是什么"到"为什么重要"到"如何使用"
|
|
178
|
+
|
|
179
|
+
**好的提示语示例**:
|
|
180
|
+
|
|
181
|
+
```markdown
|
|
182
|
+
## 核心理解
|
|
183
|
+
|
|
184
|
+
用两到四句话说明这个概念到底是什么,以及它为什么值得记住。
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**差的提示语示例**:
|
|
188
|
+
|
|
189
|
+
```markdown
|
|
190
|
+
## 内容
|
|
191
|
+
|
|
192
|
+
<!-- 在此处填写内容 -->
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 8. 完整示例
|
|
198
|
+
|
|
199
|
+
假设需要设计一个 `meeting-note` 类型:
|
|
200
|
+
|
|
201
|
+
### 模板文件 `templates/meeting-note.md`
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
---
|
|
205
|
+
pageType: meeting-note
|
|
206
|
+
title: Meeting Note Title
|
|
207
|
+
nodeId: meeting-note-slug
|
|
208
|
+
status: draft
|
|
209
|
+
visibility: private
|
|
210
|
+
sourceRefs: []
|
|
211
|
+
relatedPages: []
|
|
212
|
+
tags: []
|
|
213
|
+
createdAt: 2026-04-06
|
|
214
|
+
updatedAt: 2026-04-06
|
|
215
|
+
meetingDate:
|
|
216
|
+
participants: []
|
|
217
|
+
decisions: []
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 背景
|
|
221
|
+
|
|
222
|
+
简要说明这次会议的目的和上下文,让没参加的人能快速理解为什么开这个会。
|
|
223
|
+
|
|
224
|
+
## 关键讨论
|
|
225
|
+
|
|
226
|
+
记录会上最重要的讨论点和不同意见,重点是分歧和最终共识,不是流水账。
|
|
227
|
+
|
|
228
|
+
## 决议
|
|
229
|
+
|
|
230
|
+
列出会议达成的具体决定,每条决议应该是可执行的,不是模糊的方向。
|
|
231
|
+
|
|
232
|
+
## 后续待办
|
|
233
|
+
|
|
234
|
+
列出需要跟进的行动项,标注负责人和预期完成时间。
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 配置注册
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
"meeting-note": {
|
|
241
|
+
"file": "templates/meeting-note.md",
|
|
242
|
+
"columns": {
|
|
243
|
+
"meetingDate": "text"
|
|
244
|
+
},
|
|
245
|
+
"edges": {},
|
|
246
|
+
"summaryFields": ["meetingDate", "participants", "decisions"]
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**设计决策说明**:
|
|
251
|
+
|
|
252
|
+
- `meetingDate` 建列 — 需要按日期过滤查找
|
|
253
|
+
- `participants` 不建列 — 查参会人用 `tiangong-wiki fts` 搜索 summary_text 即可
|
|
254
|
+
- `participants` 和 `decisions` 放入 summaryFields — 帮助搜索命中
|
|
255
|
+
- `decisions` 不建 edge — 决议是文本,不是指向其他页面的引用
|
|
256
|
+
- Body 4 个 section — 背景 → 讨论 → 决议 → 待办,逻辑递进
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 9. 检查清单
|
|
261
|
+
|
|
262
|
+
设计完 template 后,用以下问题自检:
|
|
263
|
+
|
|
264
|
+
- [ ] 新 type 的结构是否与所有现有 type 都有本质差异?
|
|
265
|
+
- [ ] 每个 frontmatter 字段都有明确的查询或分类用途?
|
|
266
|
+
- [ ] 需要 `tiangong-wiki find` 过滤的字段都放进了 `columns`?
|
|
267
|
+
- [ ] 生成 graph 边的数组字段都定义了 `edges`?
|
|
268
|
+
- [ ] `summaryFields` 包含了有助于检索的关键字段?
|
|
269
|
+
- [ ] Body section 数量在 3-6 个之间,有逻辑递进?
|
|
270
|
+
- [ ] Section 提示语具体而非泛泛?
|
|
271
|
+
- [ ] 通过 `tiangong-wiki template create --type <type> --title <title>` 创建后,可以 `tiangong-wiki sync` + `tiangong-wiki lint` 无 error?
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Vault To Wiki Instruction
|
|
2
|
+
|
|
3
|
+
Use this instruction when a vault queue item must be processed into durable wiki knowledge.
|
|
4
|
+
|
|
5
|
+
## Goal
|
|
6
|
+
|
|
7
|
+
Turn one vault file into the smallest correct wiki knowledge update.
|
|
8
|
+
|
|
9
|
+
The output may be:
|
|
10
|
+
|
|
11
|
+
- no wiki change (`skip`)
|
|
12
|
+
- one or more page updates (`apply`)
|
|
13
|
+
- a type/template proposal without page writes (`propose_only`)
|
|
14
|
+
|
|
15
|
+
Do not assume any page type is the default destination.
|
|
16
|
+
|
|
17
|
+
## Core Rules
|
|
18
|
+
|
|
19
|
+
1. Discover the current ontology through the wiki CLI before deciding what to write.
|
|
20
|
+
2. Search for relevant existing pages before creating new ones.
|
|
21
|
+
3. Treat all page types equally. Choose the best fit from the current wiki, not a hardcoded fallback.
|
|
22
|
+
4. Skip transient, duplicate, or low-value files.
|
|
23
|
+
5. Preserve provenance with `sourceRefs` and any type-specific source fields already defined by the chosen template.
|
|
24
|
+
6. `sourceRefs` may only contain existing wiki page ids. Do not put raw vault file paths there; keep raw file provenance in the page body or a dedicated source field such as `vaultPath` when the chosen type supports it.
|
|
25
|
+
7. If the existing type system cannot represent the knowledge cleanly, prefer `propose_only` unless template evolution is explicitly allowed.
|
|
26
|
+
|
|
27
|
+
## Runtime Discovery
|
|
28
|
+
|
|
29
|
+
Use the CLI as the source of truth for the current ontology and page set.
|
|
30
|
+
|
|
31
|
+
Prefer:
|
|
32
|
+
|
|
33
|
+
- `tiangong-wiki type list --format json`
|
|
34
|
+
- `tiangong-wiki type show <type> --format json`
|
|
35
|
+
- `tiangong-wiki type recommend --text "<summary>" --keywords "a,b,c" --limit 5 --format json`
|
|
36
|
+
- `tiangong-wiki find`
|
|
37
|
+
- `tiangong-wiki fts`
|
|
38
|
+
- `tiangong-wiki page-info`
|
|
39
|
+
|
|
40
|
+
Notes:
|
|
41
|
+
|
|
42
|
+
- Do not use guessed subcommands such as `tiangong-wiki page find`.
|
|
43
|
+
- `tiangong-wiki find` and `tiangong-wiki list` already emit JSON; do not append `--format json`.
|
|
44
|
+
|
|
45
|
+
Do not rely on static prompt snapshots of types, templates, or pages.
|
|
46
|
+
|
|
47
|
+
## Decision Model
|
|
48
|
+
|
|
49
|
+
Choose exactly one decision:
|
|
50
|
+
|
|
51
|
+
- `skip`
|
|
52
|
+
The file is noise, duplicate, transient, unreadable, or already fully represented.
|
|
53
|
+
|
|
54
|
+
- `apply`
|
|
55
|
+
The file adds durable knowledge and you can express it with existing page types.
|
|
56
|
+
|
|
57
|
+
- `propose_only`
|
|
58
|
+
The file has durable value, but the current type system is not a clean fit and automatic template evolution is not allowed.
|
|
59
|
+
|
|
60
|
+
## Value Heuristics
|
|
61
|
+
|
|
62
|
+
Favors `apply`:
|
|
63
|
+
|
|
64
|
+
- durable documents with reusable knowledge
|
|
65
|
+
- files that materially strengthen or revise an existing page
|
|
66
|
+
- sources that introduce a clearly distinct knowledge object worth revisiting
|
|
67
|
+
|
|
68
|
+
Favors `skip`:
|
|
69
|
+
|
|
70
|
+
- temporary exports, dumps, or duplicates
|
|
71
|
+
- opaque binaries with no useful extractable content
|
|
72
|
+
- screenshots or images with no standalone evidence value
|
|
73
|
+
- files whose substance is already covered by current pages
|
|
74
|
+
|
|
75
|
+
Favors `propose_only`:
|
|
76
|
+
|
|
77
|
+
- the file is valuable
|
|
78
|
+
- existing types are clearly awkward or lossy
|
|
79
|
+
- creating a new type would materially improve ontology quality
|
|
80
|
+
|
|
81
|
+
## Page Update Rules
|
|
82
|
+
|
|
83
|
+
When applying changes:
|
|
84
|
+
|
|
85
|
+
1. Prefer updating an existing page if the source is a revision, appendix, or direct reinforcement of that page.
|
|
86
|
+
2. Create a new page only when the knowledge object is distinct and deserves its own identity.
|
|
87
|
+
3. Keep edits minimal, specific, and provenance-preserving.
|
|
88
|
+
4. For every changed page, run:
|
|
89
|
+
- `tiangong-wiki sync --path <page>`
|
|
90
|
+
- `tiangong-wiki lint --path <page> --format json`
|
|
91
|
+
|
|
92
|
+
## Manifest Contract
|
|
93
|
+
|
|
94
|
+
The workflow must write a valid `result.json` manifest.
|
|
95
|
+
|
|
96
|
+
Minimum expectations:
|
|
97
|
+
|
|
98
|
+
- `status`
|
|
99
|
+
- `decision`
|
|
100
|
+
- `reason`
|
|
101
|
+
- `threadId`
|
|
102
|
+
- `skillsUsed`
|
|
103
|
+
- `createdPageIds`
|
|
104
|
+
- `updatedPageIds`
|
|
105
|
+
- `appliedTypeNames`
|
|
106
|
+
- `proposedTypes`
|
|
107
|
+
- `actions`
|
|
108
|
+
- `lint`
|
|
109
|
+
|
|
110
|
+
The service layer trusts this manifest, not free-form prose.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Wiki Maintenance Instruction
|
|
2
|
+
|
|
3
|
+
Use this instruction when the agent is responsible for maintaining wiki knowledge pages, not only querying them.
|
|
4
|
+
|
|
5
|
+
The deterministic layer is the CLI and SQLite index.
|
|
6
|
+
The judgment layer is the agent: deciding whether knowledge is durable, which page type fits, and whether an existing page should be updated instead of creating a duplicate.
|
|
7
|
+
|
|
8
|
+
## Maintenance Goals
|
|
9
|
+
- Keep the wiki useful for future tasks, not bloated with one-off chatter.
|
|
10
|
+
- Prefer updating the best existing page before creating near-duplicates.
|
|
11
|
+
- Preserve provenance with `sourceRefs` and graph relations with `relatedPages` or page-type edge fields.
|
|
12
|
+
- Re-index every edited page immediately.
|
|
13
|
+
|
|
14
|
+
## Daily Maintenance Loop
|
|
15
|
+
1. Run `tiangong-wiki sync`.
|
|
16
|
+
2. Run `tiangong-wiki stat`.
|
|
17
|
+
3. Run `tiangong-wiki lint`.
|
|
18
|
+
4. Review `error` findings first.
|
|
19
|
+
5. Review `warning` findings that indicate stale, orphaned, or weakly connected knowledge.
|
|
20
|
+
6. Use `tiangong-wiki find`, `tiangong-wiki fts`, `tiangong-wiki search`, or `tiangong-wiki graph` to locate the best target page.
|
|
21
|
+
7. Edit Markdown in `wiki/pages/`.
|
|
22
|
+
8. Run `tiangong-wiki sync --path <page-id>`.
|
|
23
|
+
9. Re-run `tiangong-wiki lint --path <page-id>` when the change is localized.
|
|
24
|
+
|
|
25
|
+
## PageType Selection Table
|
|
26
|
+
| pageType | Use When | Typical Trigger | Notes |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| `concept` | A stable concept, model, or principle should be reusable later | New synthesis from multiple sources | Best for durable understanding |
|
|
29
|
+
| `misconception` | A wrong mental model was corrected | User or agent had a clear before/after correction | Record the failure mode and prevention cues |
|
|
30
|
+
| `bridge` | Knowledge transfers from one domain to another | Cross-project or cross-discipline analogy | Use when the value is the transfer itself |
|
|
31
|
+
| `source-summary` | The source itself deserves a reusable digest page | A source document should remain a first-class knowledge object | Preserve `vaultPath` and `sourceType`; this is not the default destination for every vault file |
|
|
32
|
+
| `lesson` | A specific incident produced a durable lesson | Failure, success, or surprise with actionable aftermath | Keep the event and future action linked |
|
|
33
|
+
| `method` | A repeatable process or recipe proved useful | Same process worked more than once | Capture applicability and evidence |
|
|
34
|
+
| `person` | Someone's role, preferences, or influence matters again later | Recurring collaborator or decision-maker | Keep factual and context-specific |
|
|
35
|
+
| `achievement` | A milestone, credential, or verifiable result matters | Award, publication, certification, milestone | Useful for profile and reporting reuse |
|
|
36
|
+
| `resume` | A reusable positioning page is needed for different audiences | Tailored summary for applications or intros | Keep it current and audience-aware |
|
|
37
|
+
| `research-note` | Investigation is ongoing and incomplete | Exploratory work with open questions | Prefer this over `concept` when not settled yet |
|
|
38
|
+
| `faq` | The same question recurs often | Third repeat or clear repeating pattern | Optimize for rapid reuse |
|
|
39
|
+
|
|
40
|
+
## Update Vs Create Decision Flow
|
|
41
|
+
1. Start with a retrieval pass.
|
|
42
|
+
2. If you know the target page type or node id, use `tiangong-wiki find`.
|
|
43
|
+
3. If you only know a phrase, use `tiangong-wiki fts`.
|
|
44
|
+
4. If the intent is fuzzy and embeddings are available, use `tiangong-wiki search`.
|
|
45
|
+
5. Inspect the top candidate with `tiangong-wiki page-info`.
|
|
46
|
+
6. When creating something new, inspect the ontology with `tiangong-wiki type list`, `tiangong-wiki type show`, or `tiangong-wiki type recommend`.
|
|
47
|
+
7. Update the existing page when one of these is true:
|
|
48
|
+
- The new material extends the same node or page intent.
|
|
49
|
+
- The existing page already answers at least 70% of the need.
|
|
50
|
+
- The new source mainly adds evidence, examples, or corrections.
|
|
51
|
+
8. Create a new page when one of these is true:
|
|
52
|
+
- The new knowledge has a distinct node id or clear separate title.
|
|
53
|
+
- The value is a new relation type, such as a new `bridge` or `misconception`.
|
|
54
|
+
- Updating the old page would mix two independent concepts.
|
|
55
|
+
|
|
56
|
+
## Create Workflow
|
|
57
|
+
1. Confirm no suitable active page exists.
|
|
58
|
+
2. Choose the page type from the table above.
|
|
59
|
+
3. Run `tiangong-wiki create --type <pageType> --title "<title>" [--node-id <nodeId>]`.
|
|
60
|
+
4. Open the created Markdown file and fill the frontmatter-specific fields.
|
|
61
|
+
5. Fill every body section in the template with concrete content, not placeholders.
|
|
62
|
+
6. Add `sourceRefs` and `relatedPages` where appropriate.
|
|
63
|
+
7. Run `tiangong-wiki sync --path <page-id>`.
|
|
64
|
+
8. Run `tiangong-wiki lint --path <page-id> --format json`.
|
|
65
|
+
|
|
66
|
+
## Update Workflow
|
|
67
|
+
1. Find the existing page.
|
|
68
|
+
2. Edit the Markdown file directly.
|
|
69
|
+
3. Update `updatedAt`.
|
|
70
|
+
4. Add or revise `sourceRefs`.
|
|
71
|
+
5. Add or revise `relatedPages` and page-type relation fields such as `prerequisites` or `correctedConcepts`.
|
|
72
|
+
6. Preserve existing durable content unless it is wrong or superseded.
|
|
73
|
+
7. Run `tiangong-wiki sync --path <page-id>`.
|
|
74
|
+
8. Run `tiangong-wiki lint --path <page-id>`.
|
|
75
|
+
|
|
76
|
+
## Archive Decision Rules
|
|
77
|
+
Archive by setting `status: archived` when at least one of these is true:
|
|
78
|
+
- The page has not been updated for more than 6 months and has no incoming links.
|
|
79
|
+
- A newer page fully supersedes it and the old one only remains for traceability.
|
|
80
|
+
- The project, context, or relationship it described has clearly ended and no longer transfers.
|
|
81
|
+
|
|
82
|
+
Do not delete archived pages just because they are old.
|
|
83
|
+
Archived pages remain valuable as provenance or historical context.
|
|
84
|
+
|
|
85
|
+
## Do Not Create A Wiki Page When
|
|
86
|
+
- The task is a one-off fact lookup with no likely future reuse.
|
|
87
|
+
- The note is only a transient debugging scratchpad or temporary execution log.
|
|
88
|
+
- The content is still too vague to classify and belongs in a short-lived working draft elsewhere.
|
|
89
|
+
|
|
90
|
+
## Query Command Selection During Maintenance
|
|
91
|
+
- Exact metadata filter: `tiangong-wiki find`
|
|
92
|
+
- Keyword hunt: `tiangong-wiki fts`
|
|
93
|
+
- Fuzzy intent: `tiangong-wiki search`
|
|
94
|
+
- One page inspection: `tiangong-wiki page-info`
|
|
95
|
+
- Network exploration: `tiangong-wiki graph`
|
|
96
|
+
- Workspace overview: `tiangong-wiki stat`
|
|
97
|
+
|
|
98
|
+
## Graph-Driven Exploration
|
|
99
|
+
Use graph traversal when you suspect there is existing context around a concept but a simple keyword search is too shallow.
|
|
100
|
+
|
|
101
|
+
Typical uses:
|
|
102
|
+
- Discover prerequisites before expanding a concept page.
|
|
103
|
+
- Find bridge pages that connect two contexts.
|
|
104
|
+
- Detect whether a new page would be orphaned.
|
|
105
|
+
- Inspect whether a correction should point to an existing concept through `correctedConcepts`.
|
|
106
|
+
|
|
107
|
+
Example flow:
|
|
108
|
+
```text
|
|
109
|
+
1. wiki graph bayesian-theorem --depth 2
|
|
110
|
+
2. Inspect prerequisite and bridge edges
|
|
111
|
+
3. If a required prerequisite page is missing, create or update it
|
|
112
|
+
4. If the new concept overlaps an existing subgraph, update the connected page instead of making an isolated duplicate
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Page-Type Specific Guidance
|
|
116
|
+
### concept
|
|
117
|
+
- Use for durable understanding, definitions, formulas, and reusable intuition.
|
|
118
|
+
- Fill prerequisites, examples, confusions, and open questions.
|
|
119
|
+
|
|
120
|
+
### misconception
|
|
121
|
+
- Use when the key value is the correction itself.
|
|
122
|
+
- Record the original wrong model, the turning point, and how to avoid relapse.
|
|
123
|
+
|
|
124
|
+
### bridge
|
|
125
|
+
- Use when the key value is transfer between source and target contexts.
|
|
126
|
+
- Keep `fromConcepts` and `toConcepts` accurate so graph traversal remains useful.
|
|
127
|
+
|
|
128
|
+
### source-summary
|
|
129
|
+
- Use when the source file itself should remain a reusable knowledge object with explicit provenance.
|
|
130
|
+
- Do not treat this as the automatic fallback for every vault file.
|
|
131
|
+
- Capture the relationship between the source and existing concept pages.
|
|
132
|
+
|
|
133
|
+
### lesson
|
|
134
|
+
- Use when a concrete event produced a durable rule or warning.
|
|
135
|
+
- Prefer `lesson` over `method` when the story of the event matters.
|
|
136
|
+
|
|
137
|
+
### method
|
|
138
|
+
- Use when steps, applicability, and evidence matter more than one incident.
|
|
139
|
+
- Update the page as new usage records accumulate.
|
|
140
|
+
|
|
141
|
+
### person
|
|
142
|
+
- Use factual, respectful, context-aware notes.
|
|
143
|
+
- Avoid speculative or irrelevant personal data.
|
|
144
|
+
|
|
145
|
+
### achievement
|
|
146
|
+
- Keep evidence and issuer information explicit.
|
|
147
|
+
- Reuse this page later from `resume` or reporting workflows.
|
|
148
|
+
|
|
149
|
+
### resume
|
|
150
|
+
- Keep audience and tailoring notes current.
|
|
151
|
+
- Update after new achievements, projects, or capability changes.
|
|
152
|
+
|
|
153
|
+
### research-note
|
|
154
|
+
- Prefer this when the work is ongoing and open-ended.
|
|
155
|
+
- Promote mature insights into `concept` or `method` pages later if needed.
|
|
156
|
+
|
|
157
|
+
### faq
|
|
158
|
+
- Optimize for fast reuse.
|
|
159
|
+
- Keep the short answer crisp, then elaborate underneath.
|
|
160
|
+
|
|
161
|
+
## Memory To Wiki
|
|
162
|
+
Use this flow when recurring memory entries have become reusable knowledge:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
1. Review the memory entry
|
|
166
|
+
2. Ask: is this still valuable after the current day or week?
|
|
167
|
+
3. tiangong-wiki find --type concept --node-id <candidate-node>
|
|
168
|
+
4. If a page exists, update it
|
|
169
|
+
5. If not, create the appropriate concept, lesson, method, or faq page
|
|
170
|
+
6. tiangong-wiki sync --path <page-id>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Profile To Wiki
|
|
174
|
+
Use this flow when structured profile data should appear in wiki pages:
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
1. Read the relevant profile data
|
|
178
|
+
2. Decide whether it belongs in achievement, resume, or person pages
|
|
179
|
+
3. Update frontmatter and body content with verifiable details
|
|
180
|
+
4. Preserve provenance through sourceRefs when appropriate
|
|
181
|
+
5. tiangong-wiki sync --path <page-id>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Quality Checklist Before Finishing
|
|
185
|
+
- Page type matches the actual reuse pattern.
|
|
186
|
+
- `updatedAt` changed if the page changed.
|
|
187
|
+
- `sourceRefs` is non-empty when knowledge came from sources.
|
|
188
|
+
- Graph-related fields are populated where relevant.
|
|
189
|
+
- The page is not an accidental orphan unless that is intentional.
|
|
190
|
+
- `tiangong-wiki lint` returns no errors for the changed page.
|