@itradingai/aiwiki 0.2.5

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.
@@ -0,0 +1,194 @@
1
+ # Obsidian + Dataview Integration
2
+
3
+ ## Decision
4
+
5
+ AIWiki should treat Obsidian compatibility as a first-class product surface:
6
+
7
+ - Base layer: works with Obsidian native Markdown, Properties, Backlinks, Search, and Graph View.
8
+ - Enhanced layer: ships optional Dataview dashboards for users who install the Dataview community plugin.
9
+ - Boundary: AIWiki must not automatically install or modify Obsidian community plugins. Plugin installation stays a documented user action.
10
+
11
+ This keeps the knowledge base portable while making the Obsidian review workflow feel like a database when Dataview is available.
12
+
13
+ ## Implementation Status
14
+
15
+ Implemented in `0.2.0`:
16
+
17
+ - `setup` seeds dashboard, schema, and template files when missing.
18
+ - Generated Markdown includes database-oriented frontmatter relationship fields.
19
+ - CLI ingest output reports `dashboard` and `review_queue`.
20
+ - The bundled Agent skill tells host Agents to report Obsidian review entry points and not to install Dataview automatically.
21
+
22
+ ## Evidence From Current Code
23
+
24
+ - Workspace setup already creates `dashboards`, `_system/templates`, and `_system/schemas`, but only creates directories. No seeded dashboard/schema/template files exist yet. See `src/workspace.ts` lines 11-23 and 47-68.
25
+ - Ingest now writes Obsidian wikilinks and basic frontmatter fields. See `src/ingest.ts` lines 190-244 and 247-320.
26
+ - Generated relationship fields are currently mostly body links, not queryable frontmatter fields. See `src/ingest.ts` lines 203-206, 231-238, 258-259, 276-277, 294-295, and 312-313.
27
+ - Existing usage docs mention Dataview only as a possible filter surface, not as an optional database enhancement with setup instructions. See `docs/USAGE.md` lines 189-204.
28
+ - The Agent skill reports CLI output fields, but does not tell host Agents how to surface Obsidian dashboards or review queues to users. See `skill/SKILL.md` lines 30-39.
29
+
30
+ External grounding:
31
+
32
+ - Obsidian supports wikilinks and display aliases such as `[[note|label]]`: https://help.obsidian.md/Linking%20notes%20and%20files/Internal%20links
33
+ - Obsidian properties are YAML stored at the top of notes: https://help.obsidian.md/properties
34
+ - Dataview queries metadata fields from frontmatter/inline fields and implicit file metadata: https://blacksmithgu.github.io/obsidian-dataview/annotation/add-metadata/
35
+
36
+ ## Product Positioning
37
+
38
+ This should become one of AIWiki's selling points:
39
+
40
+ > AIWiki does not just save article Markdown. It turns every collected source into an Obsidian-ready review database: native Properties and Backlinks work out of the box, while optional Dataview dashboards provide source queues, claim queues, topic queues, and recent-run traceability.
41
+
42
+ The user flow should become:
43
+
44
+ 1. `aiwiki setup` creates the vault-like folder structure plus database assets.
45
+ 2. User optionally installs Dataview in Obsidian.
46
+ 3. User asks a host Agent: `入库 <url>`.
47
+ 4. AIWiki writes raw/source/claims/assets/topics/outlines/runs with stable metadata and wikilinks.
48
+ 5. User opens `dashboards/AIWiki Home.md` in Obsidian.
49
+ 6. Without Dataview: links and Properties still work.
50
+ 7. With Dataview: dashboards render tables for review queues and recent activity.
51
+
52
+ ## Target Database Schema
53
+
54
+ All generated Markdown notes should share these frontmatter fields:
55
+
56
+ ```yaml
57
+ aiwiki_id: "<stable slug or run-scoped id>"
58
+ type: "source_card | raw_article | claim_suggestions | asset_suggestions | topic_candidates | draft_outline | processing_summary"
59
+ status: "to-review | ready | draft | reviewed | archived | fetch-failed"
60
+ slug: "<article-slug>"
61
+ title: "<human title>"
62
+ source_url: "<original URL when available>"
63
+ source_type: "url | file | text"
64
+ source_card: "[[03-sources/article-cards/slug|资料卡]]"
65
+ raw_note: "[[02-raw/articles/slug|原文]]"
66
+ claims_note: "[[04-claims/_suggestions/slug-claims|Claim 建议]]"
67
+ assets_note: "[[06-assets/_suggestions/slug-assets|素材建议]]"
68
+ topics_note: "[[07-topics/ready/slug-topics|选题]]"
69
+ outline_note: "[[08-outputs/outlines/slug-outline|大纲]]"
70
+ run_summary: "[[09-runs/run-id/processing-summary|处理记录]]"
71
+ run_id: "<run-id>"
72
+ created_at: "<ISO timestamp>"
73
+ captured_at: "<ISO timestamp from host Agent>"
74
+ tags:
75
+ - aiwiki/source-card
76
+ ```
77
+
78
+ Rules:
79
+
80
+ - Use Obsidian-link strings in frontmatter for relationship fields, because Obsidian Properties can display internal links when they are quoted YAML strings.
81
+ - Keep body wikilinks as human navigation, but make frontmatter the database source of truth.
82
+ - Use lowercase snake_case field names to avoid Dataview field-name normalization surprises.
83
+ - Preserve existing `url` for compatibility, but prefer `source_url` going forward.
84
+
85
+ ## Dashboard Files To Generate
86
+
87
+ `aiwiki setup` should seed these files if missing:
88
+
89
+ - `dashboards/AIWiki Home.md`: entry point, review counts, recent sources, links to all queues.
90
+ - `dashboards/Review Queue.md`: sources and claims with `status = "to-review"`.
91
+ - `dashboards/Recent Runs.md`: processing summaries sorted by creation time.
92
+ - `dashboards/Topic Pipeline.md`: topic candidates and draft outlines.
93
+ - `_system/schemas/aiwiki-frontmatter.md`: schema reference and allowed values.
94
+ - `_system/templates/source-card.md`: source-card template.
95
+ - `_system/templates/review-note.md`: generic review template.
96
+
97
+ Dashboards should include:
98
+
99
+ - A short native fallback section with normal links.
100
+ - A Dataview section fenced as `dataview`, so users with the plugin get rendered tables.
101
+ - A clear note that installing Dataview is optional.
102
+
103
+ Example query:
104
+
105
+ ```dataview
106
+ TABLE status, source_url, captured_at, run_summary
107
+ FROM "03-sources/article-cards"
108
+ WHERE type = "source_card"
109
+ SORT captured_at DESC
110
+ ```
111
+
112
+ ## Implementation Plan
113
+
114
+ 1. Add workspace seed-file support in `src/workspace.ts`.
115
+ - Create a helper like `ensureSeedFile(root, relativePath, content)`.
116
+ - Only write files when missing, so user-edited dashboards/templates are not overwritten.
117
+ - Return seeded files in setup/init results so CLI can report them.
118
+
119
+ 2. Expand generated frontmatter in `src/ingest.ts`.
120
+ - Add stable relationship fields to raw, source card, claims, assets, topics, outline, and processing summary.
121
+ - Make `processing-summary.md` a first-class typed note with frontmatter.
122
+ - Keep existing body wikilinks for human navigation.
123
+
124
+ 3. Add dashboard content and schema docs.
125
+ - Seed `AIWiki Home.md`, `Review Queue.md`, `Recent Runs.md`, `Topic Pipeline.md`.
126
+ - Seed `_system/schemas/aiwiki-frontmatter.md`.
127
+ - Include optional Dataview installation instructions in docs, not automatic plugin writes.
128
+
129
+ 4. Update CLI output.
130
+ - After `setup`, print created/kept dashboard files.
131
+ - After successful ingest, print `dashboard: dashboards/AIWiki Home.md` or `review_queue: dashboards/Review Queue.md`.
132
+
133
+ 5. Update host Agent skill guidance.
134
+ - Tell Agents to report the Obsidian entry point after ingest.
135
+ - Tell Agents not to install Dataview or modify `.obsidian`.
136
+ - Tell Agents to say Dataview is optional and only enhances dashboard rendering.
137
+
138
+ 6. Update tests.
139
+ - Workspace tests assert seed files are created and preserved on rerun.
140
+ - Ingest tests assert all generated Markdown has the required frontmatter fields.
141
+ - CLI tests assert setup reports dashboard seed files and ingest reports the Obsidian entry point.
142
+ - Add collision tests to ensure relationship frontmatter points to the renamed long-term files.
143
+
144
+ 7. Update version.
145
+ - This is a user-visible workflow enhancement. Bump minor if implemented as a new feature, patch if only documentation/schema prep is merged.
146
+
147
+ ## Acceptance Criteria
148
+
149
+ - `aiwiki setup` creates dashboard/schema/template files when missing and preserves them when already edited.
150
+ - A fresh vault works in Obsidian without Dataview: links, backlinks, and Properties are usable.
151
+ - Installing Dataview renders dashboard tables without further file edits.
152
+ - Every generated Markdown note has `aiwiki_id`, `type`, `status`, `slug`, `created_at`, and relevant relationship fields.
153
+ - Dataview queries do not depend on body text parsing.
154
+ - Host Agent skill replies include the Obsidian review entry point.
155
+ - Tests cover setup seeding, ingest metadata, dashboard query presence, and rerun preservation.
156
+
157
+ ## Risks And Mitigations
158
+
159
+ - Risk: Auto-installing plugins can corrupt or surprise user vaults.
160
+ - Mitigation: Never edit `.obsidian/community-plugins.json`; document manual Dataview installation only.
161
+ - Risk: Dataview field names drift from generated frontmatter.
162
+ - Mitigation: Centralize field names in one generator/schema helper and test dashboard query field names.
163
+ - Risk: User customizes dashboards and setup overwrites them.
164
+ - Mitigation: Seed only when missing; future updates can write `.new` suggestions instead of overwriting.
165
+ - Risk: Obsidian links in YAML are parsed as strings, not link values, in some contexts.
166
+ - Mitigation: Quote all link strings and keep body wikilinks as fallback navigation.
167
+
168
+ ## Skill Optimization Needed
169
+
170
+ Yes, the AIWiki skill should be optimized after the database layer is implemented.
171
+
172
+ Required changes:
173
+
174
+ - Add an "Obsidian review workflow" section to `skill/SKILL.md`.
175
+ - Instruct host Agents to report `processing_summary`, `source_card`, and the dashboard/review queue path.
176
+ - Instruct host Agents not to install Dataview or edit Obsidian plugin files.
177
+ - Add wording for the final user reply, for example:
178
+
179
+ ```text
180
+ 已入库,并加入 Obsidian 审阅队列。
181
+ 资料卡:...
182
+ 处理记录:...
183
+ Obsidian 入口:dashboards/AIWiki Home.md
184
+ Dataview 是可选增强;未安装时仍可用 Properties、Backlinks 和普通链接审阅。
185
+ ```
186
+
187
+ ## Verification Plan
188
+
189
+ - Run `npm test`.
190
+ - Run `npm pack --dry-run` and confirm dashboard/schema/template assets are included.
191
+ - Generate a sample workspace, open generated Markdown, and inspect frontmatter/query blocks.
192
+ - Manually check one sample vault in Obsidian:
193
+ - Without Dataview: links and Properties work.
194
+ - With Dataview: dashboards render tables.
package/docs/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # AIWiki Docs
2
+
3
+ AIWiki 是一个 Agent-first 的本地知识库工具,用来把宿主 Agent 已经读取到的文章、网页正文或本地文本写入单知识库。
4
+
5
+ - 用户使用说明:[USAGE.md](USAGE.md)
6
+ - Agent 对接协议:[AGENT_HANDOFF.md](AGENT_HANDOFF.md)
7
+ - Obsidian + Dataview 方案:[OBSIDIAN_DATAVIEW_PLAN.md](OBSIDIAN_DATAVIEW_PLAN.md)
8
+ - 架构图:[architecture.svg](architecture.svg)
9
+
10
+ ## Quick Start
11
+
12
+ ```bash
13
+ npx @itradingai/aiwiki@latest setup
14
+ aiwiki agent list
15
+ aiwiki agent install
16
+ aiwiki prompt agent
17
+ aiwiki doctor
18
+ ```
19
+
20
+ 优先运行 `aiwiki agent install`,让 CLI 扫描本机 Codex、QClaw、OpenClaw、Claude Code 等宿主 Agent 并安装到所选目标。其他宿主 Agent 可使用 `aiwiki prompt agent` 输出通用协议,再安装成 skill 或粘贴到项目/会话说明里。之后把链接发给宿主 Agent:
21
+
22
+ ```text
23
+ 入库 https://example.com/article
24
+ ```
25
+
26
+ ## 重要边界
27
+
28
+ CLI 不保证网页抓取成功。网页读取属于宿主 Agent。
package/docs/USAGE.md ADDED
@@ -0,0 +1,329 @@
1
+ # AIWiki 使用说明
2
+
3
+ 目标体验:
4
+
5
+ ```text
6
+ 用户只做一次 setup -> 之后只把链接发给 Agent -> Agent 自动调用 AIWiki 入库
7
+ ```
8
+
9
+ AIWiki CLI 不负责网页抓取。Qclaw、Codex、Claude Code、Cursor、Gemini CLI 等都只是宿主 Agent 的例子;基础版面向的是通用宿主 Agent 协作。
10
+
11
+ ## 1. 一次性设置
12
+
13
+ 发布后直接运行交互式 setup:
14
+
15
+ ```bash
16
+ npx @itradingai/aiwiki@latest setup
17
+ ```
18
+
19
+ CLI 会询问知识库路径。直接回车会使用默认目录;输入 `y` 后会创建或补齐目录,并设置为默认知识库。
20
+
21
+ 如果你想一行命令完成,也可以运行:
22
+
23
+ ```bash
24
+ npx @itradingai/aiwiki@latest setup --path "F:\knowledge_data\aiwiki" --yes
25
+ ```
26
+
27
+ 本地仓库测试时:
28
+
29
+ ```bash
30
+ cd "<AIWiki 仓库路径>"
31
+ npm install
32
+ npm run build
33
+ npm link
34
+ aiwiki setup --path "F:\knowledge_data\aiwiki-test" --yes
35
+ ```
36
+
37
+ 验证:
38
+
39
+ ```bash
40
+ aiwiki doctor
41
+ aiwiki status
42
+ ```
43
+
44
+ `setup` 会做两件事:
45
+
46
+ - 创建或补齐知识库目录。
47
+ - 写入默认知识库配置到用户目录,例如 `%USERPROFILE%\.aiwiki\config.json`。
48
+
49
+ 之后大多数命令都可以省略 `--path`。
50
+
51
+ ## 2. 让宿主 Agent 学会 AIWiki
52
+
53
+ 初始化知识库之后,先让宿主 Agent 学会 AIWiki。推荐先扫描本机支持的宿主 Agent:
54
+
55
+ ```bash
56
+ aiwiki agent list
57
+ ```
58
+
59
+ 再启动安装向导:
60
+
61
+ ```bash
62
+ aiwiki agent install
63
+ ```
64
+
65
+ 也可以跳过选择,直接指定目标:
66
+
67
+ ```bash
68
+ aiwiki agent install --agent codex --yes
69
+ aiwiki agent install --agent qclaw --yes
70
+ aiwiki agent install --agent openclaw --yes
71
+ aiwiki agent install --agent claude --yes
72
+ ```
73
+
74
+ 当前自动复制范围:
75
+
76
+ - `codex`:复制到 Codex 用户 skills 目录。
77
+ - `qclaw`:复制到 QClaw skills 目录。
78
+ - `openclaw`:复制到 OpenClaw workspace skills 目录。
79
+ - `claude`:复制为 Claude Code slash-command 提示文件。
80
+
81
+ `opencode` 和 `hermes` 会被扫描出来,但基础版暂不自动写入它们的配置。确认官方用户提示/skill 目录后再开放自动安装。现在可先输出通用对接协议:
82
+
83
+ ```bash
84
+ aiwiki prompt agent
85
+ ```
86
+
87
+ 把输出内容安装成宿主 Agent 的 skill,或粘贴到宿主 Agent 的项目/会话说明里。不同 Agent 的安装入口不同,所以基础版提供自动安装向导和通用协议两条路径。
88
+
89
+ ## 3. 日常使用
90
+
91
+ 宿主 Agent 已经加载 AIWiki 协议后,把下面的话发给它,并替换链接:
92
+
93
+ ```text
94
+ 入库 https://example.com/article
95
+ ```
96
+
97
+ 宿主 Agent 应该自动完成:
98
+
99
+ 1. 读取网页正文。
100
+ 2. 生成 `aiwiki.agent_payload.v1`。
101
+ 3. 通过 stdin 调用 `aiwiki ingest-agent --stdin`。
102
+ 4. 把 AIWiki CLI 输出的入库结果摘要回复给用户。
103
+
104
+ 用户不需要保存 JSON,不需要手动运行 `ingest-agent`,也不需要每次输入知识库路径。
105
+
106
+ ## 4. 宿主 Agent 端应回复什么
107
+
108
+ AIWiki CLI 会输出 key-value 信息。成功入库时类似:
109
+
110
+ ```text
111
+ ingested: yes
112
+ recorded: yes
113
+ fetch_status: ok
114
+ fit_score: 90
115
+ fit_level: high
116
+ source_title: 文章标题
117
+ source_url: https://example.com/article
118
+ summary: 这里是文章前段摘要,方便 Agent 快速告诉用户文章大意。
119
+ run_id: 20260507-153012-abc123
120
+ run_dir: F:\knowledge_data\aiwiki\09-runs\20260507-153012-abc123
121
+ files: 13
122
+ processing_summary: 09-runs/20260507-153012-abc123/processing-summary.md
123
+ source_card: 03-sources/article-cards/article-slug.md
124
+ draft_outline: 09-runs/20260507-153012-abc123/draft-outline.md
125
+ dashboard: dashboards/AIWiki Home.md
126
+ review_queue: dashboards/Review Queue.md
127
+ warnings: 0
128
+ ```
129
+
130
+ 宿主 Agent 回复用户时建议展示:
131
+
132
+ ```text
133
+ 已加入 Obsidian 审阅队列。
134
+ 契合度:90 / high
135
+ 摘要:……
136
+ 资料卡:……
137
+ 处理记录:……
138
+ Obsidian 入口:dashboards/AIWiki Home.md
139
+ 待审队列:dashboards/Review Queue.md
140
+ ```
141
+
142
+ 网页读取失败但已记录原因时类似:
143
+
144
+ ```text
145
+ ingested: no
146
+ recorded: yes
147
+ fetch_status: failed
148
+ fit_score: 0
149
+ fit_level: fetch_failed
150
+ summary: 网页需要登录或宿主 Agent 无法访问正文。
151
+ run_id: 20260507-153012-abc123-fetch-failed
152
+ run_dir: F:\knowledge_data\aiwiki\09-runs\20260507-153012-abc123-fetch-failed
153
+ files: 2
154
+ processing_summary: 09-runs/20260507-153012-abc123-fetch-failed/processing-summary.md
155
+ dashboard: dashboards/AIWiki Home.md
156
+ review_queue: dashboards/Review Queue.md
157
+ warnings: 0
158
+ ```
159
+
160
+ 宿主 Agent 回复用户时建议展示:
161
+
162
+ ```text
163
+ 未成功入库正文,但已记录失败原因。
164
+ 原因:……
165
+ 记录目录:……
166
+ 处理记录:……
167
+ Obsidian 入口:dashboards/AIWiki Home.md
168
+ ```
169
+
170
+ ## 5. 成功后会生成什么
171
+
172
+ 每次 run 会写入:
173
+
174
+ ```text
175
+ 09-runs/<run-id>/payload.json
176
+ 09-runs/<run-id>/raw.md
177
+ 09-runs/<run-id>/source-card.md
178
+ 09-runs/<run-id>/creative-assets.md
179
+ 09-runs/<run-id>/topics.md
180
+ 09-runs/<run-id>/draft-outline.md
181
+ 09-runs/<run-id>/processing-summary.md
182
+ ```
183
+
184
+ 同时写入长期目录:
185
+
186
+ ```text
187
+ 02-raw/articles/
188
+ 03-sources/article-cards/
189
+ 04-claims/_suggestions/
190
+ 06-assets/_suggestions/
191
+ 07-topics/ready/
192
+ 08-outputs/outlines/
193
+ ```
194
+
195
+ Obsidian 主要审阅长期目录;`09-runs` 用于追溯每次处理。
196
+
197
+ ### Obsidian 链接规则
198
+
199
+ AIWiki 生成的 Markdown 按 Obsidian vault 内路径组织,文件正文会使用 wikilink:
200
+
201
+ ```text
202
+ [[03-sources/article-cards/article-slug|资料卡]]
203
+ [[02-raw/articles/article-slug|原文]]
204
+ [[09-runs/20260507-153012-abc123/processing-summary|处理记录]]
205
+ ```
206
+
207
+ 链接规则:
208
+ - wikilink 使用 vault 相对路径,统一为 `/`,并去掉 `.md` 后缀。
209
+ - `03-sources/article-cards` 是主要审阅入口,会链接到原文、Claim 建议、素材建议、选题、大纲和本次处理记录。
210
+ - `02-raw/articles`、`04-claims/_suggestions`、`06-assets/_suggestions`、`07-topics/ready`、`08-outputs/outlines` 会回链到资料卡,Obsidian 的 Backlinks/Graph View 可以串起同一篇资料。
211
+ - `09-runs/<run-id>/processing-summary.md` 会把本次生成的 Markdown 文件列成可点击 wikilink;`payload.json` 不是 Markdown,保留普通路径。
212
+ - frontmatter 会写入 `aiwiki_id`、`type`、`status`、`slug`、`source_url`、`created_at`、`captured_at`、`run_id`、`source_card`、`raw_note`、`claims_note`、`assets_note`、`topics_note`、`outline_note`、`run_summary`、`tags` 等字段,便于后续用 Obsidian Search / Properties / Dataview 做筛选。
213
+
214
+ ### Obsidian 数据库入口
215
+
216
+ `setup` 会创建或补齐 Obsidian 数据库资产:
217
+
218
+ ```text
219
+ dashboards/AIWiki Home.md
220
+ dashboards/Review Queue.md
221
+ dashboards/Recent Runs.md
222
+ dashboards/Topic Pipeline.md
223
+ _system/schemas/aiwiki-frontmatter.md
224
+ _system/templates/source-card.md
225
+ _system/templates/review-note.md
226
+ ```
227
+
228
+ 这些文件只在缺失时创建;如果你已经在 Obsidian 中改过 dashboard 或模板,重新运行 `aiwiki setup` 不会覆盖。
229
+
230
+ 不安装 Dataview 也可以使用:
231
+ - 用 `dashboards/AIWiki Home.md` 作为入口。
232
+ - 用 Obsidian Properties 查看字段。
233
+ - 用 Backlinks / Graph View 查看资料卡和原文、Claim、素材、选题、大纲之间的关系。
234
+
235
+ 安装 Dataview 后,dashboard 中的 `dataview` 代码块会渲染成表格,用来查看最近入库、待审队列、选题管线和处理记录。
236
+
237
+ Dataview 是可选增强,不是 AIWiki 的必需依赖。AIWiki 不会自动修改 `.obsidian` 或安装社区插件;需要时请在 Obsidian 的 Community plugins 中自行安装并启用 Dataview。
238
+
239
+ ## 6. Agent 对接协议
240
+
241
+ 给任意宿主 Agent 的详细协议见:
242
+
243
+ ```text
244
+ docs/AGENT_HANDOFF.md
245
+ ```
246
+
247
+ 核心要求:
248
+
249
+ - Agent 负责读取网页正文。
250
+ - Agent 不要让用户保存 payload。
251
+ - Agent 不要让用户手动运行 `ingest-agent`。
252
+ - Agent 生成 payload 后优先通过 stdin 调用 `aiwiki ingest-agent --stdin`。
253
+ - Agent 最后只向用户汇报入库状态、契合度、摘要、资料卡、处理记录和 Obsidian 审阅入口。
254
+
255
+ ## 7. 高级调试
256
+
257
+ 如果 Agent 只能输出 JSON,才需要手动保存 payload:
258
+
259
+ ```bash
260
+ aiwiki ingest-agent --payload "F:\knowledge_data\payload.json"
261
+ ```
262
+
263
+ 也可以用 stdin:
264
+
265
+ ```bash
266
+ type "F:\knowledge_data\payload.json" | aiwiki ingest-agent --stdin
267
+ ```
268
+
269
+ 本地 Markdown 文件:
270
+
271
+ ```bash
272
+ aiwiki ingest-file --file "F:\knowledge_data\article.md"
273
+ ```
274
+
275
+ 链接加正文文件:
276
+
277
+ ```bash
278
+ aiwiki ingest-url "https://example.com/article" --content-file "F:\knowledge_data\article.md"
279
+ ```
280
+
281
+ 注意:`ingest-url` 不会抓网页,只会读取 `--content-file`。
282
+
283
+ ## 8. 常见问题
284
+
285
+ ### 找不到 `aiwiki` 命令
286
+
287
+ 本地仓库测试时重新执行:
288
+
289
+ ```bash
290
+ cd "<AIWiki 仓库路径>"
291
+ npm run build
292
+ npm link
293
+ ```
294
+
295
+ ### `doctor` 提示没有默认知识库
296
+
297
+ 运行:
298
+
299
+ ```bash
300
+ aiwiki setup --path "F:\knowledge_data\aiwiki" --yes
301
+ ```
302
+
303
+ ### 宿主 Agent 抓不到网页
304
+
305
+ 这是宿主 Agent 的网页读取问题,不是 AIWiki CLI 的问题。让宿主 Agent 生成 `fetch_status=failed` 的 payload,AIWiki 会记录失败原因。
306
+
307
+ ### 想换默认知识库目录
308
+
309
+ 重新运行:
310
+
311
+ ```bash
312
+ aiwiki setup --path "新的知识库路径" --yes
313
+ ```
314
+
315
+ ## 9. 最小验收清单
316
+
317
+ 完成一次 Agent 入库测试后,检查:
318
+
319
+ ```bash
320
+ aiwiki status
321
+ ```
322
+
323
+ 验收标准:
324
+
325
+ - `run_count` 增加。
326
+ - `09-runs` 下出现新目录。
327
+ - `processing-summary.md` 存在。
328
+ - 成功读取时,`03-sources/article-cards` 下出现资料卡。
329
+ - 抓取失败时,`09-runs/<run-id>-fetch-failed` 下出现失败记录。
@@ -0,0 +1,103 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1280" height="820" viewBox="0 0 1280 820" role="img" aria-labelledby="title desc">
2
+ <title id="title">AIWiki Base Architecture</title>
3
+ <desc id="desc">AIWiki base edition architecture showing setup, host Agent installation, ingestion, CLI processing, and local knowledge base outputs.</desc>
4
+ <defs>
5
+ <style>
6
+ .bg { fill: #fbfaf7; }
7
+ .band { fill: #fff7ed; stroke: #d9a36a; stroke-width: 2; }
8
+ .panel { fill: #ffffff; stroke: #b9c2cc; stroke-width: 1.5; }
9
+ .core { fill: #eef6ff; stroke: #4e85bd; stroke-width: 2; }
10
+ .agent { fill: #f2fbf5; stroke: #4c9a67; stroke-width: 2; }
11
+ .store { fill: #fff4f0; stroke: #c8755a; stroke-width: 2; }
12
+ .note { fill: #f7f7f7; stroke: #c5c5c5; stroke-width: 1.2; }
13
+ .title { font: 700 30px Arial, "Microsoft YaHei", sans-serif; fill: #25313d; }
14
+ .h2 { font: 700 18px Arial, "Microsoft YaHei", sans-serif; fill: #25313d; }
15
+ .text { font: 15px Arial, "Microsoft YaHei", sans-serif; fill: #334155; }
16
+ .small { font: 13px Arial, "Microsoft YaHei", sans-serif; fill: #52606d; }
17
+ .mono { font: 14px Consolas, "SFMono-Regular", monospace; fill: #243b53; }
18
+ .arrow { stroke: #536471; stroke-width: 2.2; fill: none; marker-end: url(#arrow); }
19
+ .dash { stroke-dasharray: 7 6; }
20
+ .chip { fill: #eef2f7; stroke: #c9d2dd; }
21
+ </style>
22
+ <marker id="arrow" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto" markerUnits="strokeWidth">
23
+ <path d="M0,0 L0,6 L8,3 z" fill="#536471"/>
24
+ </marker>
25
+ </defs>
26
+
27
+ <rect class="bg" x="0" y="0" width="1280" height="820"/>
28
+ <text class="title" x="54" y="58">AIWiki 基础版架构图</text>
29
+ <text class="small" x="56" y="86">目标:宿主 Agent 负责读取与理解,AIWiki CLI 负责校验与本地确定性写入。</text>
30
+
31
+ <rect class="band" x="48" y="118" width="1184" height="118" rx="8"/>
32
+ <text class="h2" x="72" y="153">1. 一次性初始化与 Agent 安装</text>
33
+ <rect class="chip" x="72" y="174" width="172" height="34" rx="6"/>
34
+ <text class="mono" x="91" y="197">aiwiki setup</text>
35
+ <rect class="chip" x="292" y="174" width="172" height="34" rx="6"/>
36
+ <text class="mono" x="315" y="197">agent list</text>
37
+ <rect class="chip" x="512" y="174" width="212" height="34" rx="6"/>
38
+ <text class="mono" x="533" y="197">agent install</text>
39
+ <rect class="chip" x="772" y="174" width="210" height="34" rx="6"/>
40
+ <text class="mono" x="794" y="197">prompt agent</text>
41
+ <text class="small" x="1014" y="187">不自动乱写未知 Agent;</text>
42
+ <text class="small" x="1014" y="207">用户选择后才复制。</text>
43
+ <path class="arrow" d="M244 191 H292"/>
44
+ <path class="arrow" d="M464 191 H512"/>
45
+ <path class="arrow" d="M724 191 H772"/>
46
+
47
+ <rect class="panel" x="58" y="280" width="264" height="330" rx="8"/>
48
+ <text class="h2" x="84" y="318">用户 / 安装向导</text>
49
+ <text class="text" x="84" y="356">选择宿主 Agent:</text>
50
+ <text class="small" x="104" y="386">Codex</text>
51
+ <text class="small" x="104" y="414">QClaw / OpenClaw</text>
52
+ <text class="small" x="104" y="442">Claude Code</text>
53
+ <text class="small" x="104" y="470">opencode / Hermes</text>
54
+ <rect class="note" x="84" y="505" width="206" height="72" rx="6"/>
55
+ <text class="small" x="101" y="532">未知目录只给 prompt,</text>
56
+ <text class="small" x="101" y="555">不直接改配置。</text>
57
+
58
+ <rect class="agent" x="382" y="280" width="330" height="330" rx="8"/>
59
+ <text class="h2" x="414" y="318">宿主 Agent 层</text>
60
+ <text class="text" x="414" y="356">已加载 AIWiki skill / prompt</text>
61
+ <text class="small" x="434" y="386">读取 URL / 文件 / 正文</text>
62
+ <text class="small" x="434" y="414">提取标题、正文、来源信息</text>
63
+ <text class="small" x="434" y="442">生成 agent payload v1</text>
64
+ <text class="small" x="434" y="470">调用 stdin 交给 CLI</text>
65
+ <rect class="note" x="414" y="505" width="260" height="72" rx="6"/>
66
+ <text class="mono" x="434" y="533">aiwiki ingest-agent</text>
67
+ <text class="mono" x="434" y="555"> --stdin</text>
68
+
69
+ <rect class="core" x="772" y="280" width="210" height="330" rx="8"/>
70
+ <text class="h2" x="812" y="318">AIWiki CLI</text>
71
+ <text class="small" x="806" y="356">校验 payload</text>
72
+ <text class="small" x="806" y="386">拒绝越界路径</text>
73
+ <text class="small" x="806" y="416">生成 run_id</text>
74
+ <text class="small" x="806" y="446">写入运行产物</text>
75
+ <text class="small" x="806" y="476">写入长期目录</text>
76
+ <text class="small" x="806" y="506">输出 key-value 结果</text>
77
+
78
+ <rect class="store" x="1042" y="280" width="190" height="330" rx="8"/>
79
+ <text class="h2" x="1082" y="318">本地知识库</text>
80
+ <text class="mono" x="1064" y="356">aiwiki.yaml</text>
81
+ <text class="mono" x="1064" y="386">09-runs/</text>
82
+ <text class="mono" x="1064" y="416">02-raw/</text>
83
+ <text class="mono" x="1064" y="446">03-sources/</text>
84
+ <text class="mono" x="1064" y="476">04-claims/</text>
85
+ <text class="mono" x="1064" y="506">07-topics/</text>
86
+ <text class="mono" x="1064" y="536">08-outputs/</text>
87
+
88
+ <path class="arrow" d="M322 445 H382"/>
89
+ <path class="arrow" d="M712 445 H772"/>
90
+ <path class="arrow" d="M982 445 H1042"/>
91
+ <path class="arrow dash" d="M876 610 C876 688 544 688 544 610"/>
92
+ <text class="small" x="602" y="712">CLI 输出入库状态、契合度、摘要、run_dir,由宿主 Agent 回复用户</text>
93
+
94
+ <rect class="panel" x="58" y="650" width="452" height="102" rx="8"/>
95
+ <text class="h2" x="84" y="684">安装目标</text>
96
+ <text class="small" x="84" y="714">自动复制:Codex、QClaw、OpenClaw、Claude Code</text>
97
+ <text class="small" x="84" y="738">仅提示协议:opencode、Hermes(目录规范确认后再开放)</text>
98
+
99
+ <rect class="panel" x="772" y="650" width="460" height="102" rx="8"/>
100
+ <text class="h2" x="798" y="684">边界</text>
101
+ <text class="small" x="798" y="714">基础版不抓网页、不做多知识库、不做状态机、不做批量队列。</text>
102
+ <text class="small" x="798" y="738">所有写入必须限制在目标知识库根目录内。</text>
103
+ </svg>
Binary file