rekipedia 0.17.29 → 0.20.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 +17 -9
- package/README.md +117 -25
- package/README.zh-CN.md +361 -83
- package/README.zh-TW.md +362 -84
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2026 Eddie Chan (unrealandychan)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
("
|
|
7
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
mechanical methods, without the prior written permission of the Owner.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
**Turn any repo into an AI-ready knowledge base — wiki, RAG, and MCP server included.**
|
|
4
4
|
|
|
5
|
-
[](https://pypi.org/project/rekipedia/)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
[](https://www.python.org/)
|
|
5
|
+
[](https://pypi.org/project/rekipedia/) [](https://www.python.org/) [](LICENSE) [](https://modelcontextprotocol.io)
|
|
8
6
|
|
|
9
7
|
---
|
|
10
8
|
|
|
11
9
|
## Why rekipedia?
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
| Problem | rekipedia |
|
|
12
|
+
|---|---|
|
|
13
|
+
| "Where does the auth logic live?" | `reki ask "how does auth work?"` → `src/auth.py:42` |
|
|
14
|
+
| Onboarding new devs takes days | `reki onboard .` generates a guided walkthrough in seconds |
|
|
15
|
+
| AI agents hallucinate about your codebase | `reki mcp` gives agents a grounded knowledge base with citations |
|
|
16
|
+
| Refactor anxiety | `reki hotspots` surfaces hub nodes and bridge nodes before you touch anything |
|
|
17
|
+
| Wiki goes stale immediately | `reki watch .` auto-reindexes on every file save |
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
@@ -24,21 +25,6 @@ pip install rekipedia
|
|
|
24
25
|
# or: npx rekipedia
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
### Zero config — no API key needed
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
reki scan . --no-llm
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
✔ Scanned 312 files · 4,891 symbols indexed
|
|
35
|
-
✔ Wiki generated · .rekipedia/wiki/
|
|
36
|
-
✔ Knowledge store · .rekipedia/store.db
|
|
37
|
-
Done in 4.2s
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
That's it. Your codebase is now a portable knowledge base.
|
|
41
|
-
|
|
42
28
|
### With LLM (richer wiki + Q&A)
|
|
43
29
|
|
|
44
30
|
```bash
|
|
@@ -133,6 +119,34 @@ Claude Code and Cursor will automatically discover this config. The agent can th
|
|
|
133
119
|
- `get_relationships` — dependency graph queries
|
|
134
120
|
- `get_hub_nodes` — architectural hotspots
|
|
135
121
|
- `get_impact` — change impact analysis
|
|
122
|
+
- `list_wiki_pages` — enumerate all wiki pages
|
|
123
|
+
- `get_wiki_page` — read a specific wiki page by name
|
|
124
|
+
---
|
|
125
|
+
## AI CLI tool integration
|
|
126
|
+
|
|
127
|
+
rekipedia integrates natively with the major AI coding assistants via MCP (Model Context Protocol). After scanning your codebase, run:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
reki init --with-all-ai # configure Copilot + Codex + Cursor in one step
|
|
131
|
+
# or pick individually:
|
|
132
|
+
reki init --with-copilot # GitHub Copilot (VS Code) — writes .vscode/mcp.json
|
|
133
|
+
reki init --with-codex # Codex CLI — writes .codex/instructions.md + setup hint
|
|
134
|
+
reki init --with-cursor # Cursor — writes .cursor/mcp.json + rules
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Once configured, each tool automatically gets access to these rekipedia MCP tools:
|
|
138
|
+
|
|
139
|
+
| MCP Tool | What it does |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `ask` | Natural-language Q&A grounded in the scanned wiki |
|
|
142
|
+
| `search_nodes` | Fast symbol lookup by name |
|
|
143
|
+
| `get_context` | Symbols and relationships for a file |
|
|
144
|
+
| `get_relationships` | Callers and callees for a symbol |
|
|
145
|
+
| `get_hub_nodes` | Architectural chokepoints |
|
|
146
|
+
| `get_impact` | Blast-radius for a changed file |
|
|
147
|
+
| `get_knowledge_gaps` | Untested high-call-count symbols |
|
|
148
|
+
| `list_wiki_pages` | List all wiki pages |
|
|
149
|
+
| `get_wiki_page` | Read a specific wiki page by name |
|
|
136
150
|
|
|
137
151
|
---
|
|
138
152
|
|
|
@@ -165,7 +179,12 @@ export REKIPEDIA_MODEL=ollama/llama3
|
|
|
165
179
|
| `reki update . --impact-only` | Incremental update, affected pages only |
|
|
166
180
|
| `reki serve .` | Local web UI at `http://127.0.0.1:7070` |
|
|
167
181
|
| `reki embed .` | Build FAISS semantic index |
|
|
168
|
-
| `reki
|
|
182
|
+
| `reki publish . [--output-dir PATH]` | Publish wiki to a git-tracked directory for team sharing |
|
|
183
|
+
| `reki export . --format bundle` | Export a content-addressed wiki bundle for team sync |
|
|
184
|
+
| `reki merge <bundle-A> <bundle-B> [--base BASE]` | Three-way wiki merge — conflict-free team sync |
|
|
185
|
+
| `reki pull [URL]` | Fetch and merge a remote wiki bundle (HTTPS/S3/GCS) |
|
|
186
|
+
| `reki watch . --publish` | Auto-index + auto-publish wiki on every file save |
|
|
187
|
+
| `reki export . --format md\|zip\|json\|html\|bundle` | Export the wiki |
|
|
169
188
|
| `reki diff` | Show impact of uncommitted changes |
|
|
170
189
|
| `reki hotspots` | Hub & bridge node detection |
|
|
171
190
|
| `reki refactor . --dry-run` | Preview refactor suggestions |
|
|
@@ -174,14 +193,87 @@ export REKIPEDIA_MODEL=ollama/llama3
|
|
|
174
193
|
| `reki review` | LLM-powered PR review |
|
|
175
194
|
| `reki watch .` | Auto-index on file change |
|
|
176
195
|
| `reki hook install` | Install git post-commit hook |
|
|
196
|
+
| `reki init --with-all-ai` | Configure MCP for GitHub Copilot, Codex CLI, and Cursor in one step |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## FAQ
|
|
201
|
+
|
|
202
|
+
### Q: Why is `store.db` gitignored? How do teammates use rekipedia?
|
|
203
|
+
|
|
204
|
+
`store.db` is a binary SQLite file containing machine-specific absolute paths — committing it would cause path mismatches on other machines and create noisy binary diffs. Each developer runs `reki scan .` locally to build their own store. To share the human-readable output with your team, use `reki publish .`, which copies the generated wiki pages to `docs/wiki/` so they can be committed and browsed in your repo or docs site.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### Q: What is `store.db` for vs the FAISS index? Why do I need both?
|
|
209
|
+
|
|
210
|
+
They serve distinct purposes and are not interchangeable. `store.db` is a structured SQLite graph: it stores symbols, relationships, file manifests, and scan run history — the kind of data you query with precise filters ("find all callers of function X"). The FAISS index (built by `reki embed .`) stores dense embedding vectors for every chunk of your codebase, enabling fuzzy semantic search ("find code that handles authentication"). `reki ask` uses both together: BM25 keyword search over SQLite and vector similarity search over FAISS, then merges the results.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### Q: Can I use Postgres, MySQL, or another database instead of SQLite?
|
|
215
|
+
|
|
216
|
+
Not currently. SQLite is the only supported backend for the structured symbol/relationship store, and it is intentional — SQLite is zero-config, portable, and requires no running server, which keeps `reki scan` self-contained. The `reki export .` command produces JSON exports (`symbols.json`, `relationships.json`) you can load into any database. Postgres/MySQL support is not on the roadmap, but the JSON exports make integration with your own tooling straightforward.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
### Q: Does rekipedia support Qdrant or Chroma instead of FAISS?
|
|
221
|
+
|
|
222
|
+
Yes. FAISS is the default vector backend, but Qdrant and Chroma are both supported as optional backends. Qdrant and Chroma are useful when you want a persistent, server-hosted vector store shared across machines — unlike the local FAISS index, a running Qdrant or Chroma instance can be queried by your whole team without each person running `reki embed`. Install the relevant extras (`pip install rekipedia[qdrant]` or `rekipedia[chroma]`) and configure the backend in `.rekipedia/config.yml`.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### Q: Do I need an OpenAI API key?
|
|
227
|
+
|
|
228
|
+
No. rekipedia can run entirely without an LLM using the `--no-llm` flag — `reki scan . --no-llm` performs static analysis only, producing the symbol graph and wiki structure without AI-generated summaries. When you do want richer summaries and Q&A, rekipedia supports OpenAI, Anthropic, Ollama (local), Azure OpenAI, and any OpenAI-compatible endpoint. For fully offline usage, point it at a local [Ollama](https://ollama.com) instance — no internet required.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### Q: How do I share the wiki with my team without everyone running `reki scan`?
|
|
233
|
+
|
|
234
|
+
Use `reki publish .`. This command copies the generated `wiki/*.md` and `diagrams/*.md` files into `docs/wiki/` (not gitignored), which can be committed and browsed directly in GitHub, your docs site, or any Markdown viewer — no local scan required. The best setup is to automate publishing in CI so the wiki stays current whenever the main branch changes (see the GitHub Actions question below).
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### Q: How do I keep the wiki up to date automatically?
|
|
239
|
+
|
|
240
|
+
Run `reki init --with-ci` to scaffold a GitHub Actions workflow (`.github/workflows/rekipedia-wiki.yml`) that runs `reki scan`, then `reki publish` on every push to `main`. The workflow commits any changes to `docs/wiki/` back to the repo automatically. Set `REKIPEDIA_API_KEY` as a repository secret for LLM-enriched pages; omit it and the workflow falls back to `--no-llm` mode at zero cost.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### Q: How does team sync work for distributed teams?
|
|
245
|
+
|
|
246
|
+
rekipedia's team sync is a multi-layer system for conflict-free wiki collaboration:
|
|
247
|
+
|
|
248
|
+
1. **Bundle** — `reki export --format bundle` creates a deterministic, content-addressed snapshot with a stable `bundle_id` and per-page hash trailers.
|
|
249
|
+
2. **Merge** — `reki merge bundle-A bundle-B --base bundle-base` performs a three-way merge: pages changed by only one developer are accepted automatically; only genuinely divergent pages produce conflict markers.
|
|
250
|
+
3. **Git merge driver** — `reki init --with-merge-driver` registers a git merge driver so `git merge` and `git pull` automatically use rekipedia's merge logic — no `<<<<<<` conflicts in generated wiki files.
|
|
251
|
+
4. **Live sync** — `reki watch . --publish` publishes the wiki after every incremental update, keeping `docs/wiki/` in sync as you code. Set `team.sync_dir` in `.rekipedia/config.yml` for the default target.
|
|
252
|
+
5. **Remote pull** — `reki pull <url>` fetches a bundle from HTTPS, S3, or GCS and merges it locally. Combine with `reki init --with-ci --with-upload s3` to have CI upload a fresh bundle after every main-branch push.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### Q: How does `reki ask` actually work under the hood?
|
|
257
|
+
|
|
258
|
+
`reki ask "question"` runs a hybrid retrieval pipeline. First, it executes a BM25 keyword search against the SQLite store to find exact and near-exact symbol/token matches. In parallel, it encodes your question into an embedding vector and queries the FAISS (or Qdrant/Chroma) index for semantically similar chunks. The two result sets are merged and re-ranked by relevance score, then the top chunks are passed as context to your configured LLM, which synthesises a final answer with file:line citations. With `--no-llm`, retrieval results are returned directly without synthesis.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
### Q: How large does `store.db` / the FAISS index get on a large repo?
|
|
263
|
+
|
|
264
|
+
For a typical mid-size repo (50k–200k lines of code), `store.db` is usually 10–80 MB. The FAISS index in `.rekipedia/rag/` scales with the number of embedded chunks — expect 50–500 MB for the same size range, which is why `rag/` is gitignored by default. On very large monorepos (1M+ LOC), the FAISS index can exceed 1 GB; in that case, switching to a server-backed Qdrant instance is recommended so the index lives outside your working directory.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### Q: Can rekipedia scan private or fully offline repos?
|
|
269
|
+
|
|
270
|
+
Yes, fully. `reki scan` is pure static analysis — it never sends your source code anywhere. With `--no-llm`, the entire pipeline is offline and air-gap safe. When LLM features are enabled, only retrieved *chunks* (not your full source) are sent to the LLM provider as context; if you use Ollama, even that stays local. There are no telemetry calls, no license checks against a remote server, and no requirement for internet access beyond reaching your chosen LLM API endpoint.
|
|
177
271
|
|
|
178
272
|
---
|
|
179
273
|
|
|
180
274
|
## Coming Soon
|
|
181
275
|
|
|
182
276
|
- **Hosted wiki** — share your knowledge base with a link, no self-hosting required
|
|
183
|
-
- **Team sync** — collaborative wiki with conflict-free merge for distributed teams
|
|
184
|
-
- **GitHub Action** — auto-update wiki on every push
|
|
185
277
|
- **VS Code extension** — inline `reki ask` from your editor
|
|
186
278
|
|
|
187
279
|
---
|
package/README.zh-CN.md
CHANGED
|
@@ -2,158 +2,436 @@
|
|
|
2
2
|
|
|
3
3
|
**[English](README.md) | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)**
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> 您的 AI 技术负责人——随时在线,始终最新。
|
|
6
|
+
|
|
7
|
+
rekipedia 可扫描任意代码仓库,将其转化为便携的 SQLite 知识库,让团队中的每位开发者都拥有一个由 LLM 驱动的技术负责人,可以随时询问:_"认证流程是如何运作的?"、"添加一个新 API 端点最快的方式是什么?"、"上周是什么导致了支付服务故障?"_
|
|
8
|
+
|
|
9
|
+
零幻觉,零猜测——每个答案都基于您的真实代码库。
|
|
10
|
+
|
|
11
|
+
### 核心功能
|
|
12
|
+
- **关系置信度评分**:每个提取的关系均标记为 EXTRACTED/INFERRED/AMBIGUOUS,并附带置信度分数
|
|
13
|
+
- **设计意图提取**:`# NOTE:`、`# HACK:`、`# WHY:` 注释被提取为知识节点
|
|
14
|
+
- **God 节点**:度数最高的符号会在 index.md 中呈现,并在图形界面中高亮显示
|
|
15
|
+
- **交互式依赖关系图**:`rekipedia serve` 现已包含 `/graph` 路由,提供基于 D3.js 的力导向可视化
|
|
16
|
+
- **Git 钩子**:`rekipedia hook install` 可在每次提交时触发自动重建
|
|
17
|
+
- **智能 wiki 编排**:`PlannerAgent` 根据您的仓库动态设计 wiki 结构
|
|
18
|
+
- **页面重要性评分**:规划器为每个页面分配重要性分数(0–100),导航侧边栏按优先级排序
|
|
19
|
+
- **DeepWiki 风格分节**:页面按逻辑分节分组(`getting-started`、`architecture`、`core-components` 等)
|
|
20
|
+
- **Wiki 侧边栏分类**:`reki serve` 侧边栏按 `section` 字段分组,支持折叠标题
|
|
21
|
+
- **实时搜索**:在侧边栏搜索框中输入内容,可即时按标题或分类筛选 wiki 页面
|
|
22
|
+
- **重构分析**:`reki refactor` 检测代码异味(上帝类、循环依赖、死代码、高耦合),并提供 LLM 增强建议——输出 `REFACTOR.md` + `refactor_report.json`
|
|
23
|
+
- **上下文切片**:每个页面仅接收其所需的数据(相比固定布局方式减少约 40–60% 的 token 用量)
|
|
24
|
+
- **混合 RAG 问答**:FAISS 索引的代码块 + wiki 页面为 LLM 提供完整的代码库上下文以回答问题
|
|
25
|
+
- **嵌入模型提供商选择**:`--embed-provider openai|ollama|azure|...`——支持任何兼容 litellm 的嵌入模型
|
|
26
|
+
- **Wiki 导出**:打包为单个 Markdown 文件、ZIP 压缩包或结构化 JSON(`rekipedia export`)
|
|
27
|
+
- **增量更新**:首次扫描后仅重新处理已变更的文件
|
|
28
|
+
- **有据可查的问答**:答案引用真实的文件路径和行号——零幻觉
|
|
29
|
+
- **代码库树形索引**——每次扫描在 SQLite 中构建层级目录/文件树,支持结构化导航和未来基于推理的检索。
|
|
6
30
|
|
|
7
|
-
|
|
31
|
+
## 快速开始
|
|
8
32
|
|
|
9
|
-
|
|
33
|
+
### 通过 npm / npx(无需安装)
|
|
10
34
|
|
|
11
|
-
|
|
35
|
+
```bash
|
|
36
|
+
npx rekipedia init .
|
|
37
|
+
npx rekipedia scan .
|
|
38
|
+
```
|
|
12
39
|
|
|
13
|
-
|
|
40
|
+
### 通过 uv / uvx(无需安装)
|
|
14
41
|
|
|
15
42
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# 或
|
|
19
|
-
uvx rekipedia init . && uvx rekipedia scan .
|
|
43
|
+
uvx rekipedia init .
|
|
44
|
+
uvx rekipedia scan .
|
|
20
45
|
```
|
|
21
46
|
|
|
47
|
+
### 永久安装
|
|
48
|
+
|
|
22
49
|
```bash
|
|
23
|
-
#
|
|
24
|
-
pip install rekipedia
|
|
25
|
-
|
|
50
|
+
# Core (scan + serve + ask)
|
|
51
|
+
pip install rekipedia
|
|
52
|
+
# or
|
|
53
|
+
uv tool install rekipedia
|
|
54
|
+
|
|
55
|
+
# With RAG support (semantic embed + search — needs faiss-cpu + numpy ~100MB)
|
|
56
|
+
pip install "rekipedia[rag]"
|
|
57
|
+
|
|
58
|
+
# Homebrew (Go single binary — no Python needed)
|
|
59
|
+
brew tap unrealandychan/tap
|
|
60
|
+
brew install rekipedia
|
|
26
61
|
```
|
|
27
62
|
|
|
28
63
|
---
|
|
29
64
|
|
|
30
|
-
##
|
|
65
|
+
## 快速开始——无需 API 密钥
|
|
31
66
|
|
|
32
|
-
无需任何 LLM API
|
|
67
|
+
无需任何 LLM API 密钥即可执行完整静态分析:
|
|
33
68
|
|
|
34
69
|
```bash
|
|
35
70
|
pip install rekipedia
|
|
36
|
-
reki scan . --no-llm # ~5-
|
|
37
|
-
reki onboard . #
|
|
38
|
-
reki tour . #
|
|
39
|
-
reki domain . #
|
|
40
|
-
reki diff . #
|
|
41
|
-
reki export . --format md #
|
|
71
|
+
reki scan . --no-llm # ~5-10 秒,零 API 调用
|
|
72
|
+
reki onboard . # 架构总览
|
|
73
|
+
reki tour . # 依赖深度导览
|
|
74
|
+
reki domain . # 业务领域层次图
|
|
75
|
+
reki diff . # 变更影响分析
|
|
76
|
+
reki export . --format md # 导出完整 wiki 为 Markdown
|
|
42
77
|
```
|
|
43
78
|
|
|
44
|
-
> **注意:** `reki ask`(AI 问答)需要 LLM API
|
|
79
|
+
> **注意:** `reki ask`(AI 问答)需要 LLM API 密钥。请参阅下方 [LLM 配置](#llm-配置)。
|
|
45
80
|
|
|
46
81
|
---
|
|
47
82
|
|
|
48
|
-
##
|
|
83
|
+
## Python API
|
|
49
84
|
|
|
50
|
-
|
|
51
|
-
|---|---|
|
|
52
|
-
| `reki init .` | 初始化配置 |
|
|
53
|
-
| `reki scan .` | 完整分析 → wiki + 知识库 |
|
|
54
|
-
| `reki update .` | 增量刷新(仅处理变更文件) |
|
|
55
|
-
| `reki update . --impact-only` | 影响感知模式 —— 仅重新生成受影响模块的 wiki 页面 |
|
|
56
|
-
| `reki serve .` | 本地 Web UI —— 浏览、搜索、问 AI |
|
|
57
|
-
| `reki ask` | 交互式问答 REPL(流式输出) |
|
|
58
|
-
| `reki embed .` | 构建 FAISS 语义索引(混合 RAG) |
|
|
59
|
-
| `reki export .` | 打包 wiki → `--format md|zip|json|html` |
|
|
60
|
-
| `reki diff` | 未提交变更的影响分析 |
|
|
61
|
-
| `reki domain .` | 将代码库映射到业务层(API/Service/Data/UI) |
|
|
62
|
-
| `reki tour .` | 按依赖深度引导学习游览 |
|
|
63
|
-
| `reki onboard .` | 面向新开发者的静态入职指南 |
|
|
64
|
-
| `reki review` | 基于 wiki 上下文的 LLM PR 审查 |
|
|
65
|
-
| `reki refactor .` | 检测代码异味 → `REFACTOR.md` |
|
|
66
|
-
| `reki refactor . --dry-run` | 预览重构建议,不写入文件 |
|
|
67
|
-
| `reki refactor . --apply` | 自动应用安全修复(死代码标记、拆分建议) |
|
|
68
|
-
| `reki refactor . --apply --dry-run` | 预览 `--apply` 将执行的操作 |
|
|
69
|
-
| `reki watch .` | 文件变更时自动重建索引(OS 监听器) |
|
|
70
|
-
| `reki hook install` | Git post-commit 自动重建 |
|
|
71
|
-
| `reki mcp` | 面向 AI 编程助手的 MCP stdio 服务器 |
|
|
85
|
+
在 Jupyter Notebook、CI 流水线或任意 Python 应用中以编程方式使用 rekipedia:
|
|
72
86
|
|
|
73
|
-
|
|
87
|
+
```python
|
|
88
|
+
import rekipedia
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
# Scan a local repo
|
|
91
|
+
result = rekipedia.scan("/path/to/repo")
|
|
92
|
+
print(result.page_count) # number of wiki pages generated
|
|
93
|
+
print(result.symbol_count) # number of code symbols extracted
|
|
94
|
+
print(result.token_count) # estimated token count of the wiki
|
|
76
95
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
# Ask a question — grounded answer with file:line citations
|
|
97
|
+
answer = rekipedia.ask("/path/to/repo", "How does the auth flow work?")
|
|
98
|
+
print(answer.text)
|
|
99
|
+
for citation in answer.citations:
|
|
100
|
+
print(f" {citation.file}:{citation.line}")
|
|
80
101
|
|
|
81
|
-
#
|
|
82
|
-
|
|
102
|
+
# Async variants (Jupyter-friendly)
|
|
103
|
+
result = await rekipedia.scan_async("/path/to/repo")
|
|
104
|
+
answer = await rekipedia.ask_async("/path/to/repo", "What is the entry point?")
|
|
83
105
|
```
|
|
84
106
|
|
|
107
|
+
**返回类型:**
|
|
108
|
+
|
|
109
|
+
| Type | Key fields |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `ScanResult` | `page_count`, `symbol_count`, `token_count`, `wiki_pages`, `db_path`, `wiki_dir` |
|
|
112
|
+
| `AskResult` | `text`, `citations: list[Citation]`, `model_used` |
|
|
113
|
+
| `Citation` | `file`, `line`, `snippet` |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 命令
|
|
118
|
+
|
|
119
|
+
| Command | Description |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `rekipedia init [REPO]` | Scaffold `.rekipedia/` with `config.yml` and update `.gitignore` |
|
|
122
|
+
| `rekipedia scan [REPO]` | Full analysis — extracts symbols, synthesises wiki pages, exports JSON |
|
|
123
|
+
| `rekipedia update [REPO]` | Incremental refresh — re-extracts only changed files, keeps the rest |
|
|
124
|
+
| `rekipedia ask [QUESTION]` | Interactive Q&A REPL — streaming answers, Ctrl+C to quit |
|
|
125
|
+
| `rekipedia serve [REPO]` | Start a local web UI to browse wiki pages and ask questions |
|
|
126
|
+
| `rekipedia embed [REPO]` | Build (or rebuild) the FAISS semantic search index for hybrid RAG Q&A |
|
|
127
|
+
| `rekipedia export [REPO]` | Bundle the wiki to a single file (`--format md\|zip\|json`) |
|
|
128
|
+
| `rekipedia hook install/uninstall/status` | Manage git post-commit hook for auto wiki rebuild |
|
|
129
|
+
| `rekipedia diff [A] [B]` | Compare two graph snapshots (defaults to last two) |
|
|
130
|
+
| `rekipedia impact <file>` | Show blast-radius — all affected files, symbols, tests for a changed file |
|
|
131
|
+
| `rekipedia search <query>` | Search symbols (`--all-repos` for cross-repo parallel search) |
|
|
132
|
+
| `rekipedia export --format graphml\|cypher\|obsidian` | Export graph to GraphML / Neo4j Cypher / Obsidian wikilinks |
|
|
133
|
+
| `rekipedia mcp` | Start JSON-RPC 2.0 MCP stdio server (6 tools for AI coding assistants) |
|
|
134
|
+
| `rekipedia watch add\|start\|list\|remove` | Watch repos and auto-index on file change |
|
|
135
|
+
| `rekipedia refactor [REPO]` | Detect code smells + generate `REFACTOR.md` and `refactor_report.json` (use `--no-llm` for static only) |
|
|
136
|
+
| `rekipedia note add\|list\|remove\|edit\|import` | Manage persistent tech lead notes — injected into `reki ask` context automatically |
|
|
137
|
+
|
|
85
138
|
---
|
|
86
139
|
|
|
87
140
|
## LLM 配置
|
|
88
141
|
|
|
89
|
-
rekipedia 使用 [litellm](https://github.com/BerriAI/litellm)
|
|
142
|
+
rekipedia 使用 [litellm](https://github.com/BerriAI/litellm),支持任何提供商:
|
|
90
143
|
|
|
91
144
|
| 提供商 | 示例 |
|
|
92
145
|
|---|---|
|
|
93
|
-
| OpenAI | `OPENAI_API_KEY
|
|
94
|
-
| Anthropic Claude | `REKIPEDIA_MODEL=claude-3-5-sonnet-20241022 REKIPEDIA_API_KEY
|
|
95
|
-
| Google Gemini | `REKIPEDIA_MODEL=gemini/gemini-2.0-flash REKIPEDIA_API_KEY
|
|
96
|
-
| OpenRouter | `REKIPEDIA_MODEL=openrouter/anthropic/claude-3.5-sonnet REKIPEDIA_API_KEY
|
|
146
|
+
| OpenAI | `OPENAI_API_KEY=sk-... reki scan .` |
|
|
147
|
+
| Anthropic Claude | `REKIPEDIA_MODEL=claude-3-5-sonnet-20241022 REKIPEDIA_API_KEY=sk-ant-... reki scan .` |
|
|
148
|
+
| Google Gemini | `REKIPEDIA_MODEL=gemini/gemini-2.0-flash REKIPEDIA_API_KEY=AIza... reki scan .` |
|
|
149
|
+
| OpenRouter | `REKIPEDIA_MODEL=openrouter/anthropic/claude-3.5-sonnet REKIPEDIA_API_KEY=sk-or-... reki scan .` |
|
|
97
150
|
| 本地 Ollama(默认) | `REKIPEDIA_MODEL=ollama/llama4 reki scan .` |
|
|
98
|
-
| Azure OpenAI | `REKIPEDIA_MODEL=azure/gpt-4o REKIPEDIA_BASE_URL=https://your-resource.openai.azure.com REKIPEDIA_API_KEY
|
|
151
|
+
| Azure OpenAI | `REKIPEDIA_MODEL=azure/gpt-4o REKIPEDIA_BASE_URL=https://your-resource.openai.azure.com REKIPEDIA_API_KEY=... reki scan .` |
|
|
99
152
|
|
|
100
|
-
|
|
153
|
+
环境变量:
|
|
154
|
+
- `REKIPEDIA_MODEL` — litellm 模型字符串(默认:`ollama/llama4`)
|
|
155
|
+
- `REKIPEDIA_API_KEY` — 所选提供商的 API 密钥
|
|
156
|
+
- `REKIPEDIA_BASE_URL` — 自定义基础 URL(用于 Azure、Ollama、代理)
|
|
157
|
+
- `REKIPEDIA_TIMEOUT` — LLM 调用超时秒数(默认:180)
|
|
158
|
+
|
|
159
|
+
运行 `rekipedia init` 后,编辑 `.rekipedia/config.yml`:
|
|
101
160
|
|
|
102
161
|
```yaml
|
|
162
|
+
version: 1
|
|
163
|
+
ignore:
|
|
164
|
+
- .git
|
|
165
|
+
- node_modules
|
|
166
|
+
- __pycache__
|
|
167
|
+
- .rekipedia
|
|
168
|
+
languages:
|
|
169
|
+
- python
|
|
170
|
+
- typescript
|
|
103
171
|
llm:
|
|
104
|
-
model: ollama/llama4
|
|
105
|
-
api_key: ""
|
|
106
|
-
base_url: ""
|
|
172
|
+
model: ollama/llama4 # any litellm model string
|
|
173
|
+
api_key: "" # or set REKIPEDIA_API_KEY env var
|
|
174
|
+
base_url: "" # for local / self-hosted endpoints
|
|
107
175
|
temperature: 0.2
|
|
108
176
|
```
|
|
109
177
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
178
|
+
### 支持的提供商(通过 [litellm](https://docs.litellm.ai))
|
|
179
|
+
|
|
180
|
+
| Provider | Example model string |
|
|
181
|
+
|---|---|
|
|
182
|
+
| Ollama (local, free) | `ollama/llama4` |
|
|
183
|
+
| OpenAI | `gpt-5.5` |
|
|
184
|
+
| Anthropic | `claude-opus-4-6` |
|
|
185
|
+
| Google Gemini | `gemini/gemini-3.0-pro` |
|
|
186
|
+
| Any OpenAI-compatible | set `base_url` in config |
|
|
187
|
+
|
|
188
|
+
### 运行时覆盖(环境变量)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
export REKIPEDIA_MODEL=gpt-5.5
|
|
192
|
+
export REKIPEDIA_API_KEY=***
|
|
193
|
+
export REKIPEDIA_BASE_URL=https://my-proxy/v1
|
|
194
|
+
export REKIPEDIA_SHARD_TOKEN_BUDGET=***
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
| Variable | Description |
|
|
198
|
+
|---|---|
|
|
199
|
+
| `REKIPEDIA_MODEL` | LLM model name to use |
|
|
200
|
+
| `REKIPEDIA_API_KEY` | API key for the LLM provider |
|
|
201
|
+
| `REKIPEDIA_BASE_URL` | Base URL for OpenAI-compatible endpoints |
|
|
202
|
+
| `REKIPEDIA_SHARD_TOKEN_BUDGET` | Max tokens per shard group (default: 40000) |
|
|
203
|
+
| `REKIPEDIA_AGENT_ASK` | Set to `1` to enable agentic ReAct ask loop (default: `0` — single-shot) |
|
|
204
|
+
| `REKIPEDIA_ASK_MAX_ITER` | Max tool-call iterations for agentic ask (default: `5`) |
|
|
205
|
+
| `REKIPEDIA_AGENT_PLANNER` | Set to `1` to enable tool-calling wiki planner (default: `0`) |
|
|
115
206
|
|
|
116
207
|
---
|
|
117
208
|
|
|
118
|
-
##
|
|
209
|
+
## 输出
|
|
210
|
+
|
|
211
|
+
`rekipedia scan` 将所有内容写入仓库内的 `.rekipedia/` 目录:
|
|
119
212
|
|
|
120
213
|
```
|
|
121
214
|
.rekipedia/
|
|
122
|
-
├── config.yml
|
|
123
|
-
├── store.db
|
|
124
|
-
├──
|
|
125
|
-
├──
|
|
126
|
-
├──
|
|
127
|
-
|
|
215
|
+
├── config.yml # your settings (committed)
|
|
216
|
+
├── store.db # SQLite knowledge store (git-ignored)
|
|
217
|
+
├── scan_meta.json # last scan metadata (model, timestamp, file count)
|
|
218
|
+
├── wiki/ # generated Markdown pages (3–15 pages, dynamically planned)
|
|
219
|
+
│ ├── index.md
|
|
220
|
+
│ ├── architecture-overview.md
|
|
221
|
+
│ ├── repository-structure.md
|
|
222
|
+
│ └── ... (pages vary by repo)
|
|
223
|
+
├── rag/ # RAG index (git-ignored)
|
|
224
|
+
│ ├── index.faiss # FAISS flat L2 index
|
|
225
|
+
│ └── chunks.json # source code chunks + metadata
|
|
226
|
+
├── diagrams/ # Mermaid diagram files
|
|
227
|
+
│ ├── module-graph.md
|
|
228
|
+
│ └── class-hierarchy.md
|
|
229
|
+
└── exports/ # JSON exports
|
|
230
|
+
├── symbols.json
|
|
231
|
+
├── relationships.json
|
|
232
|
+
└── manifest.json # run summary + metadata + page importance scores
|
|
128
233
|
```
|
|
129
234
|
|
|
130
|
-
|
|
235
|
+
根据仓库复杂度动态生成 3–15 个 wiki 页面(由 PlannerAgent 驱动)。
|
|
131
236
|
|
|
132
|
-
|
|
237
|
+
wiki 结构由 `PlannerAgent` 根据仓库实际内容动态设计:
|
|
133
238
|
|
|
134
|
-
|
|
135
|
-
|
|
239
|
+
| Section | Example pages | When generated |
|
|
240
|
+
|---|---|---|
|
|
241
|
+
| Getting Started | index, installation, quick-start | Always |
|
|
242
|
+
| Architecture | architecture-overview, data-flow, repository-structure | ≥3 modules |
|
|
243
|
+
| Core Components | One page per major module | ≥2 modules |
|
|
244
|
+
| API Reference | cli-reference, python-api, rest-api | CLI/HTTP handlers found |
|
|
245
|
+
| Development | testing, contributing, ci-cd | Test files found |
|
|
246
|
+
| Ecosystem | integrations, deployment | ≥3 external deps |
|
|
136
247
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
248
|
+
### 扫描选项
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Use a specific LLM model
|
|
252
|
+
rekipedia scan . --model gpt-5.5
|
|
253
|
+
|
|
254
|
+
# Skip Docker (run extractors in-process)
|
|
255
|
+
rekipedia scan . --no-docker
|
|
256
|
+
|
|
257
|
+
# Write output to a custom directory
|
|
258
|
+
rekipedia scan . --output-dir /tmp/wiki-output
|
|
259
|
+
|
|
260
|
+
# Enable debug logging (litellm, HTTP, full tracebacks)
|
|
261
|
+
rekipedia scan . --verbose
|
|
262
|
+
|
|
263
|
+
# Auto-embed for RAG after scan
|
|
264
|
+
rekipedia scan . --embed-model text-embedding-3-small --embed-provider openai
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### RAG / 语义搜索
|
|
268
|
+
|
|
269
|
+
`rekipedia ask` 使用**混合检索**——wiki 页面 + FAISS 索引的代码块——在完整代码库上下文中回答问题。
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Build or rebuild the FAISS index
|
|
273
|
+
rekipedia embed .
|
|
274
|
+
|
|
275
|
+
# Custom embedding model + provider
|
|
276
|
+
rekipedia embed . --model text-embedding-3-small --provider openai
|
|
277
|
+
rekipedia embed . --model nomic-embed-text --provider ollama
|
|
278
|
+
|
|
279
|
+
# If your embed provider uses a DIFFERENT API key from your main LLM:
|
|
280
|
+
rekipedia embed . --model text-embedding-3-small --provider openai
|
|
281
|
+
# set embed_api_key in config.yml, or:
|
|
282
|
+
export REKIPEDIA_EMBED_API_KEY=***
|
|
283
|
+
|
|
284
|
+
# Or configure everything in .rekipedia/config.yml:
|
|
285
|
+
# llm:
|
|
286
|
+
# model: ollama/llama4 # main LLM (local)
|
|
287
|
+
# embed_model: text-embedding-3-small
|
|
288
|
+
# embed_provider: openai
|
|
289
|
+
# embed_api_key: sk-xxx # separate key for embed provider
|
|
290
|
+
# embed_base_url: "" # optional: custom endpoint
|
|
291
|
+
|
|
292
|
+
# Env var overrides (all optional):
|
|
293
|
+
export REKIPEDIA_EMBED_MODEL=nomic-embed-text
|
|
294
|
+
export REKIPEDIA_EMBED_PROVIDER=ollama
|
|
295
|
+
export REKIPEDIA_EMBED_API_KEY=***
|
|
296
|
+
export REKIPEDIA_EMBED_BASE_URL=https://my-proxy.example.com/v1
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
FAISS 索引保存至 `.rekipedia/rag/index.faiss`,分块后的源代码保存至 `.rekipedia/rag/chunks.json`。
|
|
300
|
+
|
|
301
|
+
### 导出 wiki
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Single combined Markdown file (default)
|
|
305
|
+
rekipedia export . --format md --output ./wiki-export.md
|
|
306
|
+
|
|
307
|
+
# ZIP archive (one .md per page + manifest.json)
|
|
308
|
+
rekipedia export . --format zip --output ./wiki.zip
|
|
309
|
+
|
|
310
|
+
# Structured JSON (all pages + metadata)
|
|
311
|
+
rekipedia export . --format json --output ./wiki.json
|
|
142
312
|
```
|
|
143
313
|
|
|
314
|
+
### 增量更新
|
|
315
|
+
|
|
316
|
+
首次扫描后,`rekipedia update` 仅重新处理 SHA-256 已发生变化的文件。未变更的符号和关系将从上次运行中延续——wiki 可在数秒内完成刷新。
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
rekipedia update . # auto-detect changed files
|
|
320
|
+
rekipedia update . --no-docker # skip Docker
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
若未找到之前的扫描记录,`update` 会自动回退至全量扫描。
|
|
324
|
+
|
|
325
|
+
### 询问 wiki
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# Start interactive Q&A session (streams answers, Ctrl+C to quit)
|
|
329
|
+
rekipedia ask
|
|
330
|
+
rekipedia ask --repo ./my-project
|
|
331
|
+
rekipedia ask --model gpt-4o
|
|
332
|
+
|
|
333
|
+
# Single-shot mode (backward compat)
|
|
334
|
+
rekipedia ask -q "How does the auth flow work?"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
答案**完全**基于您的 wiki 页面和符号索引——LLM 无法虚构扫描知识库中不存在的内容。答案以逐 token 流式方式输出,等待时显示进度指示器。
|
|
338
|
+
|
|
339
|
+
对某个生成页面不满意?请参阅 **[docs/customizing.md](docs/customizing.md)**——您可以固定页面、覆盖提示词、更改写作风格,或添加扫描永不触碰的自定义页面。
|
|
340
|
+
|
|
341
|
+
### 启动 wiki 服务
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
rekipedia serve . # opens browser at http://127.0.0.1:7070
|
|
345
|
+
rekipedia serve . --port 8080 # custom port
|
|
346
|
+
rekipedia serve . --no-browser # don't auto-open browser
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
- 在深色主题的 Web 界面中浏览生成的 wiki 页面
|
|
350
|
+
- 使用相同的有据可查问答功能提问(答案通过 Web 流式返回)
|
|
351
|
+
- 问答历史记录存储于 SQLite
|
|
352
|
+
|
|
144
353
|
---
|
|
145
354
|
|
|
355
|
+
## 前置要求
|
|
356
|
+
|
|
357
|
+
- **Python ≥ 3.11**(或使用 `uv`,它自行管理 Python 环境)
|
|
358
|
+
- **Docker**——可选;用于隔离提取。若 Docker 不可用,将自动回退至进程内运行模式(`--no-docker` 强制使用进程内模式)
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 与 AI 编程智能体配合使用
|
|
363
|
+
|
|
364
|
+
rekipedia 附带一个 **Hermes agent skill**(`rekipedia-agent-skill.md`),可教会 AI 助手(Copilot、Claude Code、Codex)将 rekipedia 作为其代码库智能层:
|
|
365
|
+
|
|
366
|
+
1. 将 `rekipedia-agent-skill.md` 复制到您的 Hermes skills 目录
|
|
367
|
+
2. 任何已加载该 skill 的智能体都将在深入源文件之前自动扫描并查询 rekipedia
|
|
368
|
+
3. 显著降低大型代码库的上下文窗口用量
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 智能体模式
|
|
373
|
+
|
|
374
|
+
rekipedia 支持实验性智能体模式,其中 LLM 调用使用工具调用(ReAct)而非单次大上下文输入。
|
|
375
|
+
|
|
376
|
+
### 智能体问答
|
|
377
|
+
|
|
378
|
+
设置 `REKIPEDIA_AGENT_ASK=1` 以启用:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
REKIPEDIA_AGENT_ASK=1 reki ask "How does authentication work?"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
LLM 按需发出工具调用以检索信息:
|
|
385
|
+
- `search_code(query)` — 对源代码进行语义搜索
|
|
386
|
+
- `get_symbol(name)` — 查找符号位置和签名
|
|
387
|
+
- `get_page(slug)` — 按需获取 wiki 页面
|
|
388
|
+
- `get_relationships(target)` — 获取符号/文件的依赖关系图
|
|
389
|
+
- `finish(answer)` — 提供最终答案
|
|
390
|
+
|
|
391
|
+
最大迭代次数可通过 `REKIPEDIA_ASK_MAX_ITER` 配置(默认值:5)。
|
|
392
|
+
|
|
393
|
+
### 智能体规划器
|
|
394
|
+
|
|
395
|
+
设置 `REKIPEDIA_AGENT_PLANNER=1` 以启用工具调用式 wiki 结构规划:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
REKIPEDIA_AGENT_PLANNER=1 reki scan .
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
规划器通过工具调用逐步构建 wiki 结构,而非生成单个大型 JSON 响应。
|
|
402
|
+
|
|
146
403
|
## 开发
|
|
147
404
|
|
|
148
405
|
```bash
|
|
406
|
+
# Install all deps
|
|
149
407
|
make dev
|
|
408
|
+
|
|
409
|
+
# Run tests
|
|
150
410
|
make test
|
|
411
|
+
|
|
412
|
+
# Lint
|
|
151
413
|
make lint
|
|
414
|
+
|
|
415
|
+
# Build wheel + npm tarball
|
|
152
416
|
make build
|
|
153
417
|
```
|
|
154
418
|
|
|
419
|
+
### 发布
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
PYPI_TOKEN=*** NPM_TOKEN=*** make release
|
|
423
|
+
|
|
424
|
+
# Full release: build + tag + push + PyPI + npm
|
|
425
|
+
make release-all PYPI_TOKEN=*** NPM_TOKEN=***
|
|
426
|
+
# With version bump
|
|
427
|
+
make release-all PYPI_TOKEN=*** NPM_TOKEN=*** VERSION=0.5.0
|
|
428
|
+
```
|
|
429
|
+
|
|
155
430
|
---
|
|
156
431
|
|
|
157
432
|
## 许可证
|
|
158
433
|
|
|
159
|
-
|
|
434
|
+
专有且保密——版权所有 © 2026 Eddie Chan。保留所有权利。
|
|
435
|
+
|
|
436
|
+
未经授权,严禁复制、分发或修改本软件。
|
|
437
|
+
详情请参阅 [LICENSE](LICENSE)。
|
package/README.zh-TW.md
CHANGED
|
@@ -2,158 +2,436 @@
|
|
|
2
2
|
|
|
3
3
|
**[English](README.md) | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)**
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> 您的 AI 技術領導——隨時待命,永遠最新。
|
|
6
|
+
|
|
7
|
+
rekipedia 能掃描任何程式碼庫,將其轉化為可攜式的 SQLite 知識庫,並為團隊中每位開發者提供一位由 LLM 驅動的技術領導,讓他們隨時提問:_「驗證流程是如何運作的?」、「新增 API 端點最快的方法是什麼?」、「上週付款服務是什麼出了問題?」_
|
|
8
|
+
|
|
9
|
+
不會產生幻覺,不靠猜測——每個答案都紮根於您實際的程式碼庫。
|
|
10
|
+
|
|
11
|
+
### 主要功能
|
|
12
|
+
- **關係可信度評分**:每個提取的關係都標記為 EXTRACTED/INFERRED/AMBIGUOUS,並附有可信度分數
|
|
13
|
+
- **設計原理提取**:`# NOTE:`、`# HACK:`、`# WHY:` 注釋會被提取為知識節點
|
|
14
|
+
- **核心節點(God nodes)**:連結度最高的符號會顯示於 index.md 並在圖表介面中高亮標示
|
|
15
|
+
- **互動式依賴關係圖**:`rekipedia serve` 現在包含一個使用 D3.js 力導向視覺化的 `/graph` 路由
|
|
16
|
+
- **Git hooks**:`rekipedia hook install` 會在每次提交時觸發自動重建
|
|
17
|
+
- **代理式 wiki 協作**:`PlannerAgent` 根據您的程式碼庫動態設計 wiki 結構
|
|
18
|
+
- **頁面重要性評分**:規劃器為每個頁面分配重要性分數(0–100);導航側邊欄依優先級排序
|
|
19
|
+
- **DeepWiki 式章節**:頁面分組至邏輯章節(`getting-started`、`architecture`、`core-components` 等)
|
|
20
|
+
- **Wiki 側邊欄分類**:`reki serve` 側邊欄依 `section` 欄位將頁面分組,並支援可折疊標頭
|
|
21
|
+
- **即時搜尋**:在側邊欄搜尋框中輸入,即可立即按標題或分類篩選 wiki 頁面
|
|
22
|
+
- **重構分析**:`reki refactor` 偵測程式碼異味(神類、循環依賴、死碼、高耦合),並提供 LLM 增強的建議——輸出 `REFACTOR.md` + `refactor_report.json`
|
|
23
|
+
- **上下文切片**:每個頁面只接收其所需的資料(相較固定佈局方式減少約 40–60% 的 token 用量)
|
|
24
|
+
- **混合式 RAG 問答**:FAISS 索引的程式碼片段 + wiki 頁面,讓 LLM 在回答問題時擁有完整的程式碼庫上下文
|
|
25
|
+
- **嵌入提供者選擇**:`--embed-provider openai|ollama|azure|...`——支援任何 litellm 相容的嵌入模型
|
|
26
|
+
- **Wiki 匯出**:打包為單一 Markdown 檔案、ZIP 壓縮包或結構化 JSON(`rekipedia export`)
|
|
27
|
+
- **增量更新**:初次掃描後僅重新處理已變更的檔案
|
|
28
|
+
- **有依據的問答**:答案引用真實的檔案路徑和行號——不產生幻覺
|
|
29
|
+
- **程式碼庫樹狀索引**——每次掃描都會在 SQLite 中建立階層式目錄/檔案樹,支援結構化導航與未來基於推理的檢索。
|
|
6
30
|
|
|
7
|
-
|
|
31
|
+
## 快速開始
|
|
8
32
|
|
|
9
|
-
|
|
33
|
+
### 透過 npm / npx(無需安裝)
|
|
10
34
|
|
|
11
|
-
|
|
35
|
+
```bash
|
|
36
|
+
npx rekipedia init .
|
|
37
|
+
npx rekipedia scan .
|
|
38
|
+
```
|
|
12
39
|
|
|
13
|
-
|
|
40
|
+
### 透過 uv / uvx(無需安裝)
|
|
14
41
|
|
|
15
42
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# 或
|
|
19
|
-
uvx rekipedia init . && uvx rekipedia scan .
|
|
43
|
+
uvx rekipedia init .
|
|
44
|
+
uvx rekipedia scan .
|
|
20
45
|
```
|
|
21
46
|
|
|
47
|
+
### 永久安裝
|
|
48
|
+
|
|
22
49
|
```bash
|
|
23
|
-
#
|
|
24
|
-
pip install rekipedia
|
|
25
|
-
|
|
50
|
+
# Core (scan + serve + ask)
|
|
51
|
+
pip install rekipedia
|
|
52
|
+
# or
|
|
53
|
+
uv tool install rekipedia
|
|
54
|
+
|
|
55
|
+
# With RAG support (semantic embed + search — needs faiss-cpu + numpy ~100MB)
|
|
56
|
+
pip install "rekipedia[rag]"
|
|
57
|
+
|
|
58
|
+
# Homebrew (Go single binary — no Python needed)
|
|
59
|
+
brew tap unrealandychan/tap
|
|
60
|
+
brew install rekipedia
|
|
26
61
|
```
|
|
27
62
|
|
|
28
63
|
---
|
|
29
64
|
|
|
30
|
-
##
|
|
65
|
+
## 快速開始——無需 API 金鑰
|
|
31
66
|
|
|
32
|
-
|
|
67
|
+
無需任何 LLM API 金鑰即可執行完整靜態分析:
|
|
33
68
|
|
|
34
69
|
```bash
|
|
35
70
|
pip install rekipedia
|
|
36
|
-
reki scan . --no-llm # ~5-
|
|
37
|
-
reki onboard . #
|
|
38
|
-
reki tour . #
|
|
39
|
-
reki domain . #
|
|
40
|
-
reki diff . #
|
|
41
|
-
reki export . --format md #
|
|
71
|
+
reki scan . --no-llm # ~5-10 秒,零 API 呼叫
|
|
72
|
+
reki onboard . # 架構總覽
|
|
73
|
+
reki tour . # 依賴深度導覽
|
|
74
|
+
reki domain . # 業務領域層次圖
|
|
75
|
+
reki diff . # 變更影響分析
|
|
76
|
+
reki export . --format md # 匯出完整 wiki 為 Markdown
|
|
42
77
|
```
|
|
43
78
|
|
|
44
|
-
> **注意:** `reki ask`(AI 問答)需要 LLM API
|
|
79
|
+
> **注意:** `reki ask`(AI 問答)需要 LLM API 金鑰。請參閱下方 [LLM 設定](#llm-設定)。
|
|
45
80
|
|
|
46
81
|
---
|
|
47
82
|
|
|
48
|
-
##
|
|
83
|
+
## Python API
|
|
49
84
|
|
|
50
|
-
|
|
51
|
-
|---|---|
|
|
52
|
-
| `reki init .` | 建立初始設定檔 |
|
|
53
|
-
| `reki scan .` | 完整分析 → wiki + 知識庫 |
|
|
54
|
-
| `reki update .` | 增量更新(僅處理變更的檔案) |
|
|
55
|
-
| `reki update . --impact-only` | 影響感知模式 — 僅重新產生受影響模組的 wiki 頁面 |
|
|
56
|
-
| `reki serve .` | 本地端 Web UI — 瀏覽、搜尋、詢問 AI |
|
|
57
|
-
| `reki ask` | 互動式問答 REPL(串流輸出) |
|
|
58
|
-
| `reki embed .` | 建立 FAISS 語意索引以支援 hybrid RAG |
|
|
59
|
-
| `reki export .` | 打包 wiki → `--format md|zip|json|html` |
|
|
60
|
-
| `reki diff` | 未提交變更的影響分析 |
|
|
61
|
-
| `reki domain .` | 將程式碼庫對應至業務層(API/Service/Data/UI) |
|
|
62
|
-
| `reki tour .` | 依相依深度的引導式學習流程 |
|
|
63
|
-
| `reki onboard .` | 給新開發者的靜態引導指南 |
|
|
64
|
-
| `reki review` | 以 wiki 為基礎的 LLM PR 審查 |
|
|
65
|
-
| `reki refactor .` | 偵測程式碼壞味道 → `REFACTOR.md` |
|
|
66
|
-
| `reki refactor . --dry-run` | 預覽重構建議,不實際寫入檔案 |
|
|
67
|
-
| `reki refactor . --apply` | 自動套用安全修正(死碼標記、拆分建議) |
|
|
68
|
-
| `reki refactor . --apply --dry-run` | 預覽 `--apply` 將會執行的內容 |
|
|
69
|
-
| `reki watch .` | 檔案變更時自動建立索引(OS watcher) |
|
|
70
|
-
| `reki hook install` | Git post-commit 自動重建 |
|
|
71
|
-
| `reki mcp` | 供 AI 程式碼助理使用的 MCP stdio 伺服器 |
|
|
85
|
+
在 Jupyter 筆記本、CI 流水線或任何 Python 應用程式中以程式化方式使用 rekipedia:
|
|
72
86
|
|
|
73
|
-
|
|
87
|
+
```python
|
|
88
|
+
import rekipedia
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
# Scan a local repo
|
|
91
|
+
result = rekipedia.scan("/path/to/repo")
|
|
92
|
+
print(result.page_count) # number of wiki pages generated
|
|
93
|
+
print(result.symbol_count) # number of code symbols extracted
|
|
94
|
+
print(result.token_count) # estimated token count of the wiki
|
|
76
95
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
# Ask a question — grounded answer with file:line citations
|
|
97
|
+
answer = rekipedia.ask("/path/to/repo", "How does the auth flow work?")
|
|
98
|
+
print(answer.text)
|
|
99
|
+
for citation in answer.citations:
|
|
100
|
+
print(f" {citation.file}:{citation.line}")
|
|
80
101
|
|
|
81
|
-
#
|
|
82
|
-
|
|
102
|
+
# Async variants (Jupyter-friendly)
|
|
103
|
+
result = await rekipedia.scan_async("/path/to/repo")
|
|
104
|
+
answer = await rekipedia.ask_async("/path/to/repo", "What is the entry point?")
|
|
83
105
|
```
|
|
84
106
|
|
|
107
|
+
**回傳型別:**
|
|
108
|
+
|
|
109
|
+
| Type | Key fields |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `ScanResult` | `page_count`, `symbol_count`, `token_count`, `wiki_pages`, `db_path`, `wiki_dir` |
|
|
112
|
+
| `AskResult` | `text`, `citations: list[Citation]`, `model_used` |
|
|
113
|
+
| `Citation` | `file`, `line`, `snippet` |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 指令
|
|
118
|
+
|
|
119
|
+
| Command | Description |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `rekipedia init [REPO]` | Scaffold `.rekipedia/` with `config.yml` and update `.gitignore` |
|
|
122
|
+
| `rekipedia scan [REPO]` | Full analysis — extracts symbols, synthesises wiki pages, exports JSON |
|
|
123
|
+
| `rekipedia update [REPO]` | Incremental refresh — re-extracts only changed files, keeps the rest |
|
|
124
|
+
| `rekipedia ask [QUESTION]` | Interactive Q&A REPL — streaming answers, Ctrl+C to quit |
|
|
125
|
+
| `rekipedia serve [REPO]` | Start a local web UI to browse wiki pages and ask questions |
|
|
126
|
+
| `rekipedia embed [REPO]` | Build (or rebuild) the FAISS semantic search index for hybrid RAG Q&A |
|
|
127
|
+
| `rekipedia export [REPO]` | Bundle the wiki to a single file (`--format md\|zip\|json`) |
|
|
128
|
+
| `rekipedia hook install/uninstall/status` | Manage git post-commit hook for auto wiki rebuild |
|
|
129
|
+
| `rekipedia diff [A] [B]` | Compare two graph snapshots (defaults to last two) |
|
|
130
|
+
| `rekipedia impact <file>` | Show blast-radius — all affected files, symbols, tests for a changed file |
|
|
131
|
+
| `rekipedia search <query>` | Search symbols (`--all-repos` for cross-repo parallel search) |
|
|
132
|
+
| `rekipedia export --format graphml\|cypher\|obsidian` | Export graph to GraphML / Neo4j Cypher / Obsidian wikilinks |
|
|
133
|
+
| `rekipedia mcp` | Start JSON-RPC 2.0 MCP stdio server (6 tools for AI coding assistants) |
|
|
134
|
+
| `rekipedia watch add\|start\|list\|remove` | Watch repos and auto-index on file change |
|
|
135
|
+
| `rekipedia refactor [REPO]` | Detect code smells + generate `REFACTOR.md` and `refactor_report.json` (use `--no-llm` for static only) |
|
|
136
|
+
| `rekipedia note add\|list\|remove\|edit\|import` | Manage persistent tech lead notes — injected into `reki ask` context automatically |
|
|
137
|
+
|
|
85
138
|
---
|
|
86
139
|
|
|
87
140
|
## LLM 設定
|
|
88
141
|
|
|
89
|
-
rekipedia 使用 [litellm](https://github.com/BerriAI/litellm)
|
|
142
|
+
rekipedia 使用 [litellm](https://github.com/BerriAI/litellm),支援任何提供者:
|
|
90
143
|
|
|
91
|
-
|
|
|
144
|
+
| 提供者 | 範例 |
|
|
92
145
|
|---|---|
|
|
93
|
-
| OpenAI | `OPENAI_API_KEY
|
|
94
|
-
| Anthropic Claude | `REKIPEDIA_MODEL=claude-3-5-sonnet-20241022 REKIPEDIA_API_KEY
|
|
95
|
-
| Google Gemini | `REKIPEDIA_MODEL=gemini/gemini-2.0-flash REKIPEDIA_API_KEY
|
|
96
|
-
| OpenRouter | `REKIPEDIA_MODEL=openrouter/anthropic/claude-3.5-sonnet REKIPEDIA_API_KEY
|
|
146
|
+
| OpenAI | `OPENAI_API_KEY=sk-... reki scan .` |
|
|
147
|
+
| Anthropic Claude | `REKIPEDIA_MODEL=claude-3-5-sonnet-20241022 REKIPEDIA_API_KEY=sk-ant-... reki scan .` |
|
|
148
|
+
| Google Gemini | `REKIPEDIA_MODEL=gemini/gemini-2.0-flash REKIPEDIA_API_KEY=AIza... reki scan .` |
|
|
149
|
+
| OpenRouter | `REKIPEDIA_MODEL=openrouter/anthropic/claude-3.5-sonnet REKIPEDIA_API_KEY=sk-or-... reki scan .` |
|
|
97
150
|
| 本地 Ollama(預設) | `REKIPEDIA_MODEL=ollama/llama4 reki scan .` |
|
|
98
|
-
| Azure OpenAI | `REKIPEDIA_MODEL=azure/gpt-4o REKIPEDIA_BASE_URL=https://your-resource.openai.azure.com REKIPEDIA_API_KEY
|
|
151
|
+
| Azure OpenAI | `REKIPEDIA_MODEL=azure/gpt-4o REKIPEDIA_BASE_URL=https://your-resource.openai.azure.com REKIPEDIA_API_KEY=... reki scan .` |
|
|
152
|
+
|
|
153
|
+
環境變數:
|
|
154
|
+
- `REKIPEDIA_MODEL` — litellm 模型字串(預設:`ollama/llama4`)
|
|
155
|
+
- `REKIPEDIA_API_KEY` — 所選提供者的 API 金鑰
|
|
156
|
+
- `REKIPEDIA_BASE_URL` — 自訂基礎 URL(用於 Azure、Ollama、代理)
|
|
157
|
+
- `REKIPEDIA_TIMEOUT` — LLM 呼叫逾時秒數(預設:180)
|
|
99
158
|
|
|
100
|
-
執行 `
|
|
159
|
+
執行 `rekipedia init` 後,編輯 `.rekipedia/config.yml`:
|
|
101
160
|
|
|
102
161
|
```yaml
|
|
162
|
+
version: 1
|
|
163
|
+
ignore:
|
|
164
|
+
- .git
|
|
165
|
+
- node_modules
|
|
166
|
+
- __pycache__
|
|
167
|
+
- .rekipedia
|
|
168
|
+
languages:
|
|
169
|
+
- python
|
|
170
|
+
- typescript
|
|
103
171
|
llm:
|
|
104
|
-
model: ollama/llama4
|
|
105
|
-
api_key: ""
|
|
106
|
-
base_url: ""
|
|
172
|
+
model: ollama/llama4 # any litellm model string
|
|
173
|
+
api_key: "" # or set REKIPEDIA_API_KEY env var
|
|
174
|
+
base_url: "" # for local / self-hosted endpoints
|
|
107
175
|
temperature: 0.2
|
|
108
176
|
```
|
|
109
177
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
178
|
+
### 支援的提供者(透過 [litellm](https://docs.litellm.ai))
|
|
179
|
+
|
|
180
|
+
| Provider | Example model string |
|
|
181
|
+
|---|---|
|
|
182
|
+
| Ollama (local, free) | `ollama/llama4` |
|
|
183
|
+
| OpenAI | `gpt-5.5` |
|
|
184
|
+
| Anthropic | `claude-opus-4-6` |
|
|
185
|
+
| Google Gemini | `gemini/gemini-3.0-pro` |
|
|
186
|
+
| Any OpenAI-compatible | set `base_url` in config |
|
|
187
|
+
|
|
188
|
+
### 執行時覆寫(環境變數)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
export REKIPEDIA_MODEL=gpt-5.5
|
|
192
|
+
export REKIPEDIA_API_KEY=***
|
|
193
|
+
export REKIPEDIA_BASE_URL=https://my-proxy/v1
|
|
194
|
+
export REKIPEDIA_SHARD_TOKEN_BUDGET=***
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
| Variable | Description |
|
|
198
|
+
|---|---|
|
|
199
|
+
| `REKIPEDIA_MODEL` | LLM model name to use |
|
|
200
|
+
| `REKIPEDIA_API_KEY` | API key for the LLM provider |
|
|
201
|
+
| `REKIPEDIA_BASE_URL` | Base URL for OpenAI-compatible endpoints |
|
|
202
|
+
| `REKIPEDIA_SHARD_TOKEN_BUDGET` | Max tokens per shard group (default: 40000) |
|
|
203
|
+
| `REKIPEDIA_AGENT_ASK` | Set to `1` to enable agentic ReAct ask loop (default: `0` — single-shot) |
|
|
204
|
+
| `REKIPEDIA_ASK_MAX_ITER` | Max tool-call iterations for agentic ask (default: `5`) |
|
|
205
|
+
| `REKIPEDIA_AGENT_PLANNER` | Set to `1` to enable tool-calling wiki planner (default: `0`) |
|
|
115
206
|
|
|
116
207
|
---
|
|
117
208
|
|
|
118
|
-
##
|
|
209
|
+
## 輸出
|
|
210
|
+
|
|
211
|
+
`rekipedia scan` 會將所有內容寫入您程式碼庫內的 `.rekipedia/`:
|
|
119
212
|
|
|
120
213
|
```
|
|
121
214
|
.rekipedia/
|
|
122
|
-
├── config.yml
|
|
123
|
-
├── store.db
|
|
124
|
-
├──
|
|
125
|
-
├──
|
|
126
|
-
├──
|
|
127
|
-
|
|
215
|
+
├── config.yml # your settings (committed)
|
|
216
|
+
├── store.db # SQLite knowledge store (git-ignored)
|
|
217
|
+
├── scan_meta.json # last scan metadata (model, timestamp, file count)
|
|
218
|
+
├── wiki/ # generated Markdown pages (3–15 pages, dynamically planned)
|
|
219
|
+
│ ├── index.md
|
|
220
|
+
│ ├── architecture-overview.md
|
|
221
|
+
│ ├── repository-structure.md
|
|
222
|
+
│ └── ... (pages vary by repo)
|
|
223
|
+
├── rag/ # RAG index (git-ignored)
|
|
224
|
+
│ ├── index.faiss # FAISS flat L2 index
|
|
225
|
+
│ └── chunks.json # source code chunks + metadata
|
|
226
|
+
├── diagrams/ # Mermaid diagram files
|
|
227
|
+
│ ├── module-graph.md
|
|
228
|
+
│ └── class-hierarchy.md
|
|
229
|
+
└── exports/ # JSON exports
|
|
230
|
+
├── symbols.json
|
|
231
|
+
├── relationships.json
|
|
232
|
+
└── manifest.json # run summary + metadata + page importance scores
|
|
128
233
|
```
|
|
129
234
|
|
|
130
|
-
|
|
235
|
+
根據程式碼庫複雜度動態生成 3–15 個 wiki 頁面(由 PlannerAgent 驅動)。
|
|
131
236
|
|
|
132
|
-
|
|
237
|
+
Wiki 結構由 `PlannerAgent` 根據您程式碼庫的實際內容動態設計:
|
|
133
238
|
|
|
134
|
-
|
|
135
|
-
|
|
239
|
+
| Section | Example pages | When generated |
|
|
240
|
+
|---|---|---|
|
|
241
|
+
| Getting Started | index, installation, quick-start | Always |
|
|
242
|
+
| Architecture | architecture-overview, data-flow, repository-structure | ≥3 modules |
|
|
243
|
+
| Core Components | One page per major module | ≥2 modules |
|
|
244
|
+
| API Reference | cli-reference, python-api, rest-api | CLI/HTTP handlers found |
|
|
245
|
+
| Development | testing, contributing, ci-cd | Test files found |
|
|
246
|
+
| Ecosystem | integrations, deployment | ≥3 external deps |
|
|
136
247
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
248
|
+
### 掃描選項
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Use a specific LLM model
|
|
252
|
+
rekipedia scan . --model gpt-5.5
|
|
253
|
+
|
|
254
|
+
# Skip Docker (run extractors in-process)
|
|
255
|
+
rekipedia scan . --no-docker
|
|
256
|
+
|
|
257
|
+
# Write output to a custom directory
|
|
258
|
+
rekipedia scan . --output-dir /tmp/wiki-output
|
|
259
|
+
|
|
260
|
+
# Enable debug logging (litellm, HTTP, full tracebacks)
|
|
261
|
+
rekipedia scan . --verbose
|
|
262
|
+
|
|
263
|
+
# Auto-embed for RAG after scan
|
|
264
|
+
rekipedia scan . --embed-model text-embedding-3-small --embed-provider openai
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### RAG / 語義搜尋
|
|
268
|
+
|
|
269
|
+
`rekipedia ask` 使用**混合式檢索**——wiki 頁面 + FAISS 索引的程式碼片段——以完整的程式碼庫上下文回答問題。
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Build or rebuild the FAISS index
|
|
273
|
+
rekipedia embed .
|
|
274
|
+
|
|
275
|
+
# Custom embedding model + provider
|
|
276
|
+
rekipedia embed . --model text-embedding-3-small --provider openai
|
|
277
|
+
rekipedia embed . --model nomic-embed-text --provider ollama
|
|
278
|
+
|
|
279
|
+
# If your embed provider uses a DIFFERENT API key from your main LLM:
|
|
280
|
+
rekipedia embed . --model text-embedding-3-small --provider openai
|
|
281
|
+
# set embed_api_key in config.yml, or:
|
|
282
|
+
export REKIPEDIA_EMBED_API_KEY=***
|
|
283
|
+
|
|
284
|
+
# Or configure everything in .rekipedia/config.yml:
|
|
285
|
+
# llm:
|
|
286
|
+
# model: ollama/llama4 # main LLM (local)
|
|
287
|
+
# embed_model: text-embedding-3-small
|
|
288
|
+
# embed_provider: openai
|
|
289
|
+
# embed_api_key: sk-xxx # separate key for embed provider
|
|
290
|
+
# embed_base_url: "" # optional: custom endpoint
|
|
291
|
+
|
|
292
|
+
# Env var overrides (all optional):
|
|
293
|
+
export REKIPEDIA_EMBED_MODEL=nomic-embed-text
|
|
294
|
+
export REKIPEDIA_EMBED_PROVIDER=ollama
|
|
295
|
+
export REKIPEDIA_EMBED_API_KEY=***
|
|
296
|
+
export REKIPEDIA_EMBED_BASE_URL=https://my-proxy.example.com/v1
|
|
142
297
|
```
|
|
143
298
|
|
|
299
|
+
FAISS 索引儲存於 `.rekipedia/rag/index.faiss`,分塊的原始碼儲存於 `.rekipedia/rag/chunks.json`。
|
|
300
|
+
|
|
301
|
+
### 匯出 wiki
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Single combined Markdown file (default)
|
|
305
|
+
rekipedia export . --format md --output ./wiki-export.md
|
|
306
|
+
|
|
307
|
+
# ZIP archive (one .md per page + manifest.json)
|
|
308
|
+
rekipedia export . --format zip --output ./wiki.zip
|
|
309
|
+
|
|
310
|
+
# Structured JSON (all pages + metadata)
|
|
311
|
+
rekipedia export . --format json --output ./wiki.json
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### 增量更新
|
|
315
|
+
|
|
316
|
+
初次掃描後,`rekipedia update` 只會重新處理 SHA-256 已變更的檔案。未變更的符號和關係會從上次執行中延續——wiki 可在幾秒內完成更新。
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
rekipedia update . # auto-detect changed files
|
|
320
|
+
rekipedia update . --no-docker # skip Docker
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
若找不到先前的掃描記錄,`update` 會自動回退至完整掃描。
|
|
324
|
+
|
|
325
|
+
### 向 wiki 提問
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# Start interactive Q&A session (streams answers, Ctrl+C to quit)
|
|
329
|
+
rekipedia ask
|
|
330
|
+
rekipedia ask --repo ./my-project
|
|
331
|
+
rekipedia ask --model gpt-4o
|
|
332
|
+
|
|
333
|
+
# Single-shot mode (backward compat)
|
|
334
|
+
rekipedia ask -q "How does the auth flow work?"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
答案**完全**以您的 wiki 頁面和符號索引為依據——LLM 無法捏造不存在於已掃描知識庫中的細節。答案以逐 token 串流方式輸出,等待時會顯示進度指示器。
|
|
338
|
+
|
|
339
|
+
對某個生成頁面不滿意?請參閱 **[docs/customizing.md](docs/customizing.md)**——您可以釘選頁面、覆寫提示詞、更改寫作風格,或新增掃描時永遠不會觸及的自訂頁面。
|
|
340
|
+
|
|
341
|
+
### 啟動 wiki 伺服器
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
rekipedia serve . # opens browser at http://127.0.0.1:7070
|
|
345
|
+
rekipedia serve . --port 8080 # custom port
|
|
346
|
+
rekipedia serve . --no-browser # don't auto-open browser
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
- 在深色主題的網頁介面中瀏覽生成的 wiki 頁面
|
|
350
|
+
- 使用相同的有依據問答功能提問(答案透過網頁串流)
|
|
351
|
+
- 問答歷史記錄儲存於 SQLite
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## 環境需求
|
|
356
|
+
|
|
357
|
+
- **Python ≥ 3.11**(或使用 `uv`,它自行管理 Python 版本)
|
|
358
|
+
- **Docker**——可選;用於隔離式提取。若 Docker 不可用,會自動回退至行程內執行模式(`--no-docker` 強制使用行程內模式)
|
|
359
|
+
|
|
144
360
|
---
|
|
145
361
|
|
|
362
|
+
## 搭配 AI 程式碼代理使用 rekipedia
|
|
363
|
+
|
|
364
|
+
rekipedia 附帶一個 **Hermes agent skill**(`rekipedia-agent-skill.md`),可教導 AI 助理(Copilot、Claude Code、Codex)將 rekipedia 作為其程式碼庫智慧層:
|
|
365
|
+
|
|
366
|
+
1. 將 `rekipedia-agent-skill.md` 複製到您的 Hermes skills 目錄
|
|
367
|
+
2. 任何已載入該技能的代理,都會在深入原始碼檔案前自動掃描並查詢 rekipedia
|
|
368
|
+
3. 大幅減少大型程式碼庫的上下文視窗用量
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 代理模式
|
|
373
|
+
|
|
374
|
+
rekipedia 支援實驗性的代理模式,其中 LLM 呼叫使用工具調用(ReAct)而非單次大型上下文傾倒。
|
|
375
|
+
|
|
376
|
+
### 代理式提問
|
|
377
|
+
|
|
378
|
+
設定 `REKIPEDIA_AGENT_ASK=1` 以啟用:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
REKIPEDIA_AGENT_ASK=1 reki ask "How does authentication work?"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
LLM 會發出工具調用以按需取得資訊:
|
|
385
|
+
- `search_code(query)` — 對原始碼進行語義搜尋
|
|
386
|
+
- `get_symbol(name)` — 查詢符號的位置和簽名
|
|
387
|
+
- `get_page(slug)` — 按需取得 wiki 頁面
|
|
388
|
+
- `get_relationships(target)` — 取得符號/檔案的依賴關係圖
|
|
389
|
+
- `finish(answer)` — 提供最終答案
|
|
390
|
+
|
|
391
|
+
最大迭代次數可透過 `REKIPEDIA_ASK_MAX_ITER` 設定(預設值:5)。
|
|
392
|
+
|
|
393
|
+
### 代理式規劃器
|
|
394
|
+
|
|
395
|
+
設定 `REKIPEDIA_AGENT_PLANNER=1` 以啟用工具調用式 wiki 結構規劃:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
REKIPEDIA_AGENT_PLANNER=1 reki scan .
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
規劃器使用工具調用增量建構 wiki 結構,而非生成單一大型 JSON 回應。
|
|
402
|
+
|
|
146
403
|
## 開發
|
|
147
404
|
|
|
148
405
|
```bash
|
|
406
|
+
# Install all deps
|
|
149
407
|
make dev
|
|
408
|
+
|
|
409
|
+
# Run tests
|
|
150
410
|
make test
|
|
411
|
+
|
|
412
|
+
# Lint
|
|
151
413
|
make lint
|
|
414
|
+
|
|
415
|
+
# Build wheel + npm tarball
|
|
152
416
|
make build
|
|
153
417
|
```
|
|
154
418
|
|
|
419
|
+
### 發佈
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
PYPI_TOKEN=*** NPM_TOKEN=*** make release
|
|
423
|
+
|
|
424
|
+
# Full release: build + tag + push + PyPI + npm
|
|
425
|
+
make release-all PYPI_TOKEN=*** NPM_TOKEN=***
|
|
426
|
+
# With version bump
|
|
427
|
+
make release-all PYPI_TOKEN=*** NPM_TOKEN=*** VERSION=0.5.0
|
|
428
|
+
```
|
|
429
|
+
|
|
155
430
|
---
|
|
156
431
|
|
|
157
432
|
## 授權條款
|
|
158
433
|
|
|
159
|
-
|
|
434
|
+
專有且機密——版權所有 © 2026 Eddie Chan。保留所有權利。
|
|
435
|
+
|
|
436
|
+
嚴禁未經授權複製、散布或修改本軟體。
|
|
437
|
+
詳情請參閱 [LICENSE](LICENSE)。
|
package/package.json
CHANGED