@zosmaai/pi-llm-wiki 0.7.3 → 0.7.4
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.de.md +414 -0
- package/README.es.md +414 -0
- package/README.fr.md +414 -0
- package/README.hi.md +414 -0
- package/README.ja.md +414 -0
- package/README.ko.md +414 -0
- package/README.md +23 -0
- package/README.pt.md +414 -0
- package/README.ru.md +414 -0
- package/README.zh.md +414 -0
- package/assets/thank-you-for-the-star.png +0 -0
- package/extensions/llm-wiki/index.ts +20 -4
- package/extensions/llm-wiki/lib/observation.ts +310 -0
- package/extensions/llm-wiki/lib/recall.ts +277 -21
- package/package.json +1 -1
package/README.zh.md
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# @zosmaai/pi-llm-wiki
|
|
4
|
+
|
|
5
|
+
<a href="./README.md">English</a> | **中文** | <a href="./README.es.md">Español</a> | <a href="./README.ja.md">日本語</a> | <a href="./README.de.md">Deutsch</a> | <a href="./README.fr.md">Français</a> | <a href="./README.pt.md">Português</a> | <a href="./README.ru.md">Русский</a> | <a href="./README.ko.md">한국어</a> | <a href="./README.hi.md">हिंदी</a>
|
|
6
|
+
|
|
7
|
+
[](https://github.com/zosmaai/pi-llm-wiki/actions/workflows/ci.yml)
|
|
8
|
+
[](https://www.npmjs.com/package/@zosmaai/pi-llm-wiki)
|
|
9
|
+
[](https://www.npmjs.com/package/@zosmaai/pi-llm-wiki)
|
|
10
|
+
[](https://codecov.io/gh/zosmaai/pi-llm-wiki)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
[](https://github.com/zosmaai/pi-llm-wiki/actions/workflows/codeql.yml)
|
|
13
|
+
[](https://github.com/zosmaai/pi-llm-wiki/stargazers)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
<a href="https://github.com/zosmaai/pi-llm-wiki/stargazers">
|
|
21
|
+
<img src="./assets/thank-you-for-the-star.png" alt="Thank you for starring pi-llm-wiki!" width="100%" />
|
|
22
|
+
</a>
|
|
23
|
+
<br/>
|
|
24
|
+
<sub>
|
|
25
|
+
If you find pi-llm-wiki useful,
|
|
26
|
+
<a href="https://github.com/zosmaai/pi-llm-wiki">⭐ star the repo</a> —
|
|
27
|
+
it lets us know we're building something that matters.
|
|
28
|
+
</sub>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<br/>
|
|
32
|
+
|
|
33
|
+
**基于 [pi](https://pi.dev) 的自维护、兼容 Obsidian 的知识库。遵循 Andrej Karpathy 的 LLM Wiki 模式。**
|
|
34
|
+
Follows Andrej Karpathy's [LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f).
|
|
35
|
+
|
|
36
|
+
将原始来源(网址、PDF、Markdown、JSON、XML)转化为持久、互联、由 LLM 维护的 Wiki,并随时间不断积累。
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 快速开始
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pi install npm:@zosmaai/pi-llm-wiki
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The extension will proactively suggest creating a wiki on your first session. Alternatively:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
/wiki-init "AI Engineering"
|
|
50
|
+
/wiki-ingest
|
|
51
|
+
/wiki-query What are the key patterns?
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 为什么选择这个包?
|
|
57
|
+
|
|
58
|
+
大多数基于文件的 LLM 工作流如同一键式 RAG:每次提问时模型都会搜索原始文档。综合结果转瞬即逝。
|
|
59
|
+
|
|
60
|
+
**pi-llm-wiki** 创建了一个中间层:
|
|
61
|
+
|
|
62
|
+
- **原始来源包保留源头真实输入**
|
|
63
|
+
- **来源页面总结每个来源的内容**
|
|
64
|
+
- **规范 Wiki 页面追踪 Wiki 当前的知识状态**
|
|
65
|
+
- **生成的元数据使所有内容可搜索和可导航**
|
|
66
|
+
|
|
67
|
+
结果是一个不断累积的 Wiki——当你捕获来源、提问并归档持久分析时,知识会不断增长。
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 功能特性
|
|
72
|
+
|
|
73
|
+
| Capability | Description |
|
|
74
|
+
|------------|-------------|
|
|
75
|
+
| 🏠 **Personal fallback** | Always-on `~/.llm-wiki/` vault — knowledge compounds across projects even when no project wiki exists |
|
|
76
|
+
| 🔗 **Immutable source capture** | URLs, local files (PDF/md/txt/html/XML/JSON), or pasted text → structured source packets |
|
|
77
|
+
| 🧠 **Automated ingestion** | `wiki_ingest` batch-processes sources into concept, entity, synthesis & analysis pages |
|
|
78
|
+
| 🔍 **Full-text search** | Generated registry with keyword lookup across all pages and sources |
|
|
79
|
+
| 🩺 **Mechanical linting** | Orphans, broken links, duplicate aliases, coverage gaps, stale captures |
|
|
80
|
+
| 📊 **Dashboard** | `wiki_status` — counts, source states, recent activity |
|
|
81
|
+
| 🤖 **Auto-update watch** | `wiki_watch` — schedule periodic discovery + ingest |
|
|
82
|
+
| 🧠 **Layered recall** | Searches both personal (`~/.llm-wiki/`) and project (`.llm-wiki/`) vaults — personal knowledge follows you everywhere |
|
|
83
|
+
| 📝 **Auto-bootstrap** | Extension suggests creating a wiki when none exists in the current directory |
|
|
84
|
+
| 💾 **Lightweight capture** | `wiki_retro` — save atomic insights as a single markdown file; full 4-layer pipeline also available via `wiki_capture_source` |
|
|
85
|
+
| 🌐 **MCP Server** | Use with Claude Code, Cursor, Windsurf via stdio MCP transport |
|
|
86
|
+
| 📝 **Obsidian-friendly** | Folder-qualified wikilinks, stable source-ID citations, compatible vault |
|
|
87
|
+
| 🛡️ **Guardrails** | Blocks direct edits to raw sources and generated metadata |
|
|
88
|
+
| 🔧 **Configurable PDF extraction** | MarkItDown timeout via `WIKI_MARKITDOWN_TIMEOUT_MS` env var |
|
|
89
|
+
| 🧪 **38+ tests, CI, CodeQL** | TypeScript, Vitest, Biome, Codecov |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 工具
|
|
94
|
+
|
|
95
|
+
| Tool | Description |
|
|
96
|
+
|------|-------------|
|
|
97
|
+
| `wiki_bootstrap` | Initialize a new wiki vault with config, templates, schema, and metadata |
|
|
98
|
+
| `wiki_capture_source` | Capture a URL, local file, or pasted text into an immutable source packet |
|
|
99
|
+
| `wiki_recall` | Search wiki for task-relevant pages — searches both personal (`~/.llm-wiki/`) and project (`.llm-wiki/`) vaults, deduplicated |
|
|
100
|
+
| `wiki_retro` | Save atomic insights from completed tasks into the wiki |
|
|
101
|
+
| `wiki_ingest` | Process uningested source packets into wiki pages (batch) |
|
|
102
|
+
| `wiki_ensure_page` | Resolve or safely create entity / concept / synthesis / analysis pages |
|
|
103
|
+
| `wiki_search` | Search the generated wiki registry |
|
|
104
|
+
| `wiki_lint` | Deterministic health checks (orphans, gaps, contradictions, auto-fix) |
|
|
105
|
+
| `wiki_status` | Show counts, source states, and recent activity |
|
|
106
|
+
| `wiki_rebuild_meta` | Force a full metadata rebuild (registry, backlinks, index, log) |
|
|
107
|
+
| `wiki_log_event` | Append a structured event to the wiki activity log |
|
|
108
|
+
| `wiki_watch` | Schedule automatic wiki updates (daily / weekly / hourly) |
|
|
109
|
+
|
|
110
|
+
### 斜杠命令
|
|
111
|
+
|
|
112
|
+
| Command | Description |
|
|
113
|
+
|---------|-------------|
|
|
114
|
+
| `/wiki-init <topic>` | Initialize a new LLM Wiki vault |
|
|
115
|
+
| `/wiki-ingest [path]` | Process new source files and update the wiki |
|
|
116
|
+
| `/wiki-query <question>` | Ask questions against the wiki with citations |
|
|
117
|
+
| `/wiki-discover [--topic <topic>]` | Auto-discover new sources from the web |
|
|
118
|
+
| `/wiki-run [--schedule daily\|weekly]` | Full cycle: discover → ingest → lint |
|
|
119
|
+
| `/wiki-lint [--fix]` | Health check (orphans, contradictions, gaps) |
|
|
120
|
+
| `/wiki-status` | Show a concise operational summary |
|
|
121
|
+
| `/wiki-digest [--period daily\|weekly]` | Generate a digest of recent activity |
|
|
122
|
+
| `/wiki-retro` | Save atomic insights from completed tasks |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 分层 Vault 架构
|
|
127
|
+
|
|
128
|
+
Knowledge follows you everywhere. pi-llm-wiki uses a layered vault system:
|
|
129
|
+
|
|
130
|
+
| Layer | Location | Purpose |
|
|
131
|
+
|-------|----------|---------|
|
|
132
|
+
| 🏠 **Personal** | `~/.llm-wiki/` | Always active. Zero setup. Knowledge compounds across all your sessions — regardless of which project you're in. |
|
|
133
|
+
| 📁 **Project** | `{project}/.llm-wiki/` | Explicit opt-in. Dedicated wiki per project, sharing personal knowledge when relevant. |
|
|
134
|
+
| 🏢 **Company** (future) | git-tracked | Shared wiki across a team. `wiki_publish` promotes personal/project pages to the company wiki. |
|
|
135
|
+
|
|
136
|
+
**工作原理:**
|
|
137
|
+
|
|
138
|
+
1. `resolveVaultRoot()` checks: cwd → walk up for `.llm-wiki/` → `~/.llm-wiki/`
|
|
139
|
+
2. `wiki_recall` (layered) searches **both** personal and project vaults, merging results with vault labels
|
|
140
|
+
3. Personal results are shown first in recall output, tagged as "📓 personal"
|
|
141
|
+
4. `wiki_retro` writes to whichever vault is active (project takes priority)
|
|
142
|
+
5. Set `WIKI_HOME` env var to override the personal wiki location
|
|
143
|
+
|
|
144
|
+
This means: you can have a project wiki for team documentation **and** a personal wiki for your own notes, and recall searches both simultaneously.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 快速开始(详细)
|
|
149
|
+
|
|
150
|
+
### 1) 创建新 Wiki
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
mkdir my-wiki
|
|
154
|
+
cd my-wiki
|
|
155
|
+
pi
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
向 pi 提问:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Initialize an llm wiki here for AI research.
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This calls `wiki_bootstrap` and creates:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
.llm-wiki/
|
|
168
|
+
├── config.json
|
|
169
|
+
├── templates/
|
|
170
|
+
├── raw/
|
|
171
|
+
├── wiki/
|
|
172
|
+
├── meta/
|
|
173
|
+
└── WIKI_SCHEMA.md
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 2) 捕获来源
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
Capture this article into the wiki: https://example.com/some-article
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Capture this PDF into the wiki: ./papers/context-windows.pdf
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Capture these notes into the wiki: ...pasted text...
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 3) 整合来源
|
|
191
|
+
|
|
192
|
+
1. Capture the source
|
|
193
|
+
2. Read `.llm-wiki/wiki/sources/SRC-*.md`
|
|
194
|
+
3. Update that source page
|
|
195
|
+
4. Search for impacted canonical pages with `wiki_search`
|
|
196
|
+
5. Create missing pages with `wiki_ensure_page`
|
|
197
|
+
6. Update concept / entity / synthesis pages with citations
|
|
198
|
+
7. Mark the integration with `wiki_log_event kind=integrate`
|
|
199
|
+
|
|
200
|
+
### 4) 查询 Wiki
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Based on the wiki, what are the main tradeoffs between long-context models and RAG?
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
By default, query mode is **read-only**. To file a durable answer:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Answer the question and file the result as an analysis page.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Vault 布局
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
my-wiki/
|
|
218
|
+
└─ .llm-wiki/
|
|
219
|
+
├─ config.json # Vault config
|
|
220
|
+
├─ templates/ # Page templates
|
|
221
|
+
├─ raw/
|
|
222
|
+
│ └─ sources/
|
|
223
|
+
│ └─ SRC-2026-05-11-001/
|
|
224
|
+
│ ├─ manifest.json
|
|
225
|
+
│ ├─ original/ # Original artifact
|
|
226
|
+
│ ├─ extracted.md # Normalized text
|
|
227
|
+
│ └─ attachments/
|
|
228
|
+
├─ wiki/
|
|
229
|
+
│ ├─ sources/ # Source pages (what each source says)
|
|
230
|
+
│ ├─ concepts/ # Concepts and recurring ideas
|
|
231
|
+
│ ├─ entities/ # People, orgs, products, papers, systems
|
|
232
|
+
│ ├─ syntheses/ # Cross-source theses and tensions
|
|
233
|
+
│ └─ analyses/ # Durable filed answers from queries
|
|
234
|
+
├─ meta/
|
|
235
|
+
│ ├─ registry.json # Auto-generated search index
|
|
236
|
+
│ ├─ backlinks.json
|
|
237
|
+
│ ├─ index.md
|
|
238
|
+
│ ├─ events.jsonl # Append-only event log
|
|
239
|
+
│ ├─ log.md
|
|
240
|
+
│ └─ lint-report.md
|
|
241
|
+
└─ WIKI_SCHEMA.md # Operating manual
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 所有权模型
|
|
245
|
+
|
|
246
|
+
| Path | Owner | Rule |
|
|
247
|
+
|------|-------|------|
|
|
248
|
+
| Path | Owner | Rule |
|
|
249
|
+
|------|-------|------|
|
|
250
|
+
| `.llm-wiki/raw/**` | Extension tools | Immutable after capture |
|
|
251
|
+
| `.llm-wiki/wiki/**` | Model + user | Editable knowledge pages |
|
|
252
|
+
| `.llm-wiki/meta/registry.json` | Extension | Generated |
|
|
253
|
+
| `.llm-wiki/meta/backlinks.json` | Extension | Generated |
|
|
254
|
+
| `.llm-wiki/meta/index.md` | Extension | Generated |
|
|
255
|
+
| `.llm-wiki/meta/events.jsonl` | Extension / tool | Append-only |
|
|
256
|
+
| `.llm-wiki/meta/log.md` | Extension | Generated from events |
|
|
257
|
+
| `.llm-wiki/meta/lint-report.md` | Extension | Generated |
|
|
258
|
+
| `.llm-wiki/WIKI_SCHEMA.md` | Human + explicit request | Operating manual |
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 链接与引用风格
|
|
263
|
+
|
|
264
|
+
### 内部导航
|
|
265
|
+
|
|
266
|
+
```markdown
|
|
267
|
+
[[concepts/retrieval-augmented-generation]]
|
|
268
|
+
[[entities/openai|OpenAI]]
|
|
269
|
+
[[syntheses/long-context-vs-rag]]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 事实引用
|
|
273
|
+
|
|
274
|
+
```markdown
|
|
275
|
+
[[sources/SRC-2026-04-04-001|SRC-2026-04-04-001]]
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Stable source-page IDs keep provenance stable even if titles change.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 防护措施
|
|
283
|
+
|
|
284
|
+
The extension **blocks** direct tool-call edits to:
|
|
285
|
+
|
|
286
|
+
- `.llm-wiki/raw/**` — immutable source artifacts
|
|
287
|
+
- `.llm-wiki/meta/registry.json`
|
|
288
|
+
- `.llm-wiki/meta/backlinks.json`
|
|
289
|
+
- `.llm-wiki/meta/events.jsonl`
|
|
290
|
+
- `.llm-wiki/meta/index.md`
|
|
291
|
+
- `.llm-wiki/meta/log.md`
|
|
292
|
+
- `.llm-wiki/meta/lint-report.md`
|
|
293
|
+
|
|
294
|
+
If the model directly edits `.llm-wiki/wiki/**` using Pi's built-in `write` or `edit` tools, the extension **automatically rebuilds** generated metadata at the end of the agent turn.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 来源包格式
|
|
299
|
+
|
|
300
|
+
Each captured source is stored as a structured packet:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
.llm-wiki/raw/sources/SRC-YYYY-MM-DD-NNN/
|
|
304
|
+
├─ manifest.json # Capture metadata (title, URL, format, timestamp)
|
|
305
|
+
├─ original/ # Original artifact (preserved as-is)
|
|
306
|
+
├─ extracted.md # Normalized text (PDF→md, XML→md, JSON→md, etc.)
|
|
307
|
+
└─ attachments/ # Future attachment downloads
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
This preserves both the **original artifact** and a **normalized extracted view** for reading.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## MCP 服务器
|
|
315
|
+
|
|
316
|
+
Use the wiki from **any MCP-compatible tool** — Claude Code, Cursor, Windsurf, and others.
|
|
317
|
+
|
|
318
|
+
The package ships a standalone MCP server exposing 5 wiki tools over stdio:
|
|
319
|
+
|
|
320
|
+
| Tool | Description |
|
|
321
|
+
|------|-------------|
|
|
322
|
+
| `wiki_recall` | Search wiki for task-relevant pages |
|
|
323
|
+
| `wiki_search` | Full registry search |
|
|
324
|
+
| `wiki_status` | Wiki stats (page counts, type breakdown) |
|
|
325
|
+
| `wiki_retro` | Save atomic insights |
|
|
326
|
+
| `wiki_capture_source` | Capture text as a source packet |
|
|
327
|
+
|
|
328
|
+
### 使用方法
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# Auto-discovered by pi:
|
|
332
|
+
pi install npm:@zosmaai/pi-llm-wiki
|
|
333
|
+
|
|
334
|
+
# Standalone with any MCP client:
|
|
335
|
+
WIKI_ROOT=~/my-wiki node node_modules/@zosmaai/pi-llm-wiki/mcp/index.js
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Set `WIKI_ROOT` to your wiki vault directory. If unset, the server auto-detects from the current working directory.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 技能行为
|
|
343
|
+
|
|
344
|
+
The bundled `llm-wiki` skill teaches the model to:
|
|
345
|
+
|
|
346
|
+
- ❌ Never edit raw sources directly
|
|
347
|
+
- ❌ Never edit generated metadata files
|
|
348
|
+
- ✅ Capture first, integrate second
|
|
349
|
+
- ✅ Search before creating new canonical pages
|
|
350
|
+
- ✅ Cite facts using source-page IDs
|
|
351
|
+
- ✅ Keep query mode read-only by default
|
|
352
|
+
- ✅ Use "Tensions / caveats" and "Open questions" when evidence is mixed
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 架构
|
|
357
|
+
|
|
358
|
+
### Vault 层
|
|
359
|
+
|
|
360
|
+
See the [Layered Vault Architecture](#layered-vault-architecture) section above for the personal/project/company layering.
|
|
361
|
+
|
|
362
|
+
### 四层页面模型
|
|
363
|
+
|
|
364
|
+
Each wiki vault has four layers with clear ownership:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
.llm-wiki/raw/sources/SRC-*/ # Immutable source packets (extension-owned)
|
|
368
|
+
.llm-wiki/wiki/ # Editable knowledge pages (you + LLM)
|
|
369
|
+
.llm-wiki/meta/ # Auto-generated registry, backlinks, index, log
|
|
370
|
+
.llm-wiki/ # Config and templates
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Read [docs/architecture.md](docs/architecture.md) for the full design document.
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 文档
|
|
378
|
+
|
|
379
|
+
| Document | What it covers |
|
|
380
|
+
|----------|---------------|
|
|
381
|
+
| [Architecture](docs/architecture.md) | How the four layers work, ownership model |
|
|
382
|
+
| [Commands](docs/commands.md) | All slash commands and tool reference |
|
|
383
|
+
| [Obsidian Integration](docs/obsidian.md) | Vault setup and recommended plugins |
|
|
384
|
+
| [Configuration](docs/configuration.md) | Wiki modes, topics, environment variables |
|
|
385
|
+
| [API](docs/api.md) | Extension tool parameter reference |
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## 贡献
|
|
390
|
+
|
|
391
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, test patterns, and PR workflow.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## Star 历史
|
|
396
|
+
|
|
397
|
+
[](https://star-history.com/#zosmaai/pi-llm-wiki&Date)
|
|
398
|
+
|
|
399
|
+
## 贡献者
|
|
400
|
+
|
|
401
|
+
<a href="https://github.com/zosmaai/pi-llm-wiki/graphs/contributors">
|
|
402
|
+
<img src="https://contrib.rocks/image?repo=zosmaai/pi-llm-wiki" alt="Contributors" />
|
|
403
|
+
</a>
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
<div align="center">
|
|
408
|
+
<sub>Built with ❤️ by <a href="https://github.com/zosmaai">zosmaai</a> · </sub>
|
|
409
|
+
<a href="https://pi.dev">pi.dev</a> · <a href="https://github.com/zosmaai/pi-llm-wiki/issues">Issues</a>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
## 许可证
|
|
413
|
+
|
|
414
|
+
MIT
|
|
Binary file
|
|
@@ -2,6 +2,11 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
3
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
4
4
|
import { installGuardrails } from "./lib/guardrails.js";
|
|
5
|
+
import {
|
|
6
|
+
createReminderState,
|
|
7
|
+
registerObservationReminder,
|
|
8
|
+
registerWikiObserve,
|
|
9
|
+
} from "./lib/observation.js";
|
|
5
10
|
import { formatRecallContext, registerWikiRecall, searchWikiLayered } from "./lib/recall.js";
|
|
6
11
|
import { registerWikiRetro } from "./lib/retro.js";
|
|
7
12
|
import {
|
|
@@ -55,6 +60,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
55
60
|
registerWikiWatch(pi);
|
|
56
61
|
registerWikiRecall(pi);
|
|
57
62
|
registerWikiRetro(pi);
|
|
63
|
+
const reminderState = createReminderState();
|
|
64
|
+
registerWikiObserve(pi, reminderState);
|
|
65
|
+
registerObservationReminder(pi, reminderState);
|
|
58
66
|
|
|
59
67
|
installGuardrails(pi);
|
|
60
68
|
|
|
@@ -97,7 +105,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
97
105
|
return;
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
ctx.ui.setStatus("llm-wiki", "🧠 LLM Wiki (
|
|
108
|
+
ctx.ui.setStatus("llm-wiki", "🧠 LLM Wiki (13 tools, observe + recall active)");
|
|
101
109
|
});
|
|
102
110
|
|
|
103
111
|
// ─── Layered recall + topic inference hook ──────────
|
|
@@ -147,9 +155,17 @@ ${projectHints}
|
|
|
147
155
|
Then call wiki_bootstrap with the inferred topic and mode to finalize the setup. This is a one-time step.`;
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
//
|
|
158
|
+
// Auto-injection recall: search ONLY the project vault with a relevance
|
|
159
|
+
// threshold. Low-confidence matches are discarded to avoid context pollution.
|
|
160
|
+
// Personal vault is excluded — it contains cross-project pages that
|
|
161
|
+
// produce noise in unrelated sessions. Users can call wiki_recall
|
|
162
|
+
// explicitly for personal-vault searches.
|
|
151
163
|
if (prompt.trim()) {
|
|
152
|
-
|
|
164
|
+
// minScore=5: requires at least a title/heading/alias/trigger match,
|
|
165
|
+
// or multiple body matches. This eliminates accidental body-only
|
|
166
|
+
// substring matches (e.g. a Tally page matching on common words).
|
|
167
|
+
// includePersonal=false: personal vault is excluded from auto-injection.
|
|
168
|
+
const results = searchWikiLayered(paths, prompt, 3, 5, false);
|
|
153
169
|
if (results.length > 0) {
|
|
154
170
|
const recallContext = formatRecallContext(results);
|
|
155
171
|
if (recallContext) {
|
|
@@ -161,7 +177,7 @@ Then call wiki_bootstrap with the inferred topic and mode to finalize the setup.
|
|
|
161
177
|
// Always inject a visible wiki status footer, even when empty
|
|
162
178
|
// This ensures the model knows the wiki is active and can use it
|
|
163
179
|
injectedContext +=
|
|
164
|
-
"\n\n<wiki_status>LLM Wiki active — use wiki_recall for deeper search, wiki_retro to save
|
|
180
|
+
"\n\n<wiki_status>LLM Wiki active — use wiki_recall for deeper search, wiki_observe to record observations, wiki_retro to save insights.</wiki_status>";
|
|
165
181
|
|
|
166
182
|
if (injectedContext === event.systemPrompt) return;
|
|
167
183
|
return { systemPrompt: injectedContext };
|