kb-memory 2.1.0__tar.gz

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.
Files changed (90) hide show
  1. kb_memory-2.1.0/LICENSE +201 -0
  2. kb_memory-2.1.0/PKG-INFO +415 -0
  3. kb_memory-2.1.0/README.md +365 -0
  4. kb_memory-2.1.0/kb/__init__.py +2 -0
  5. kb_memory-2.1.0/kb/__main__.py +4 -0
  6. kb_memory-2.1.0/kb/api.py +975 -0
  7. kb_memory-2.1.0/kb/audit.py +263 -0
  8. kb_memory-2.1.0/kb/bm25.py +144 -0
  9. kb_memory-2.1.0/kb/cli.py +788 -0
  10. kb_memory-2.1.0/kb/config.py +136 -0
  11. kb_memory-2.1.0/kb/consolidation.py +228 -0
  12. kb_memory-2.1.0/kb/discovery.py +264 -0
  13. kb_memory-2.1.0/kb/embedder.py +134 -0
  14. kb_memory-2.1.0/kb/eval.py +136 -0
  15. kb_memory-2.1.0/kb/governance.py +188 -0
  16. kb_memory-2.1.0/kb/i18n.py +257 -0
  17. kb_memory-2.1.0/kb/ingest.py +122 -0
  18. kb_memory-2.1.0/kb/llm.py +155 -0
  19. kb_memory-2.1.0/kb/logging_setup.py +75 -0
  20. kb_memory-2.1.0/kb/mcp.py +300 -0
  21. kb_memory-2.1.0/kb/models.py +102 -0
  22. kb_memory-2.1.0/kb/monitor.py +421 -0
  23. kb_memory-2.1.0/kb/reranker.py +61 -0
  24. kb_memory-2.1.0/kb/retriever.py +281 -0
  25. kb_memory-2.1.0/kb/scopes.py +197 -0
  26. kb_memory-2.1.0/kb/service.py +947 -0
  27. kb_memory-2.1.0/kb/sparse.py +238 -0
  28. kb_memory-2.1.0/kb/storage.py +204 -0
  29. kb_memory-2.1.0/kb/watcher.py +171 -0
  30. kb_memory-2.1.0/kb_memory.egg-info/PKG-INFO +415 -0
  31. kb_memory-2.1.0/kb_memory.egg-info/SOURCES.txt +88 -0
  32. kb_memory-2.1.0/kb_memory.egg-info/dependency_links.txt +1 -0
  33. kb_memory-2.1.0/kb_memory.egg-info/entry_points.txt +2 -0
  34. kb_memory-2.1.0/kb_memory.egg-info/requires.txt +33 -0
  35. kb_memory-2.1.0/kb_memory.egg-info/top_level.txt +1 -0
  36. kb_memory-2.1.0/pyproject.toml +70 -0
  37. kb_memory-2.1.0/setup.cfg +4 -0
  38. kb_memory-2.1.0/tests/test_agent_isolation.py +370 -0
  39. kb_memory-2.1.0/tests/test_api_auth.py +99 -0
  40. kb_memory-2.1.0/tests/test_charset_json.py +120 -0
  41. kb_memory-2.1.0/tests/test_consolidation.py +238 -0
  42. kb_memory-2.1.0/tests/test_embed_model_resolution.py +108 -0
  43. kb_memory-2.1.0/tests/test_hotfix_validation.py +87 -0
  44. kb_memory-2.1.0/tests/test_improvements_bm25_batch.py +27 -0
  45. kb_memory-2.1.0/tests/test_improvements_concurrency.py +55 -0
  46. kb_memory-2.1.0/tests/test_improvements_isolation_recall.py +52 -0
  47. kb_memory-2.1.0/tests/test_n01_config.py +44 -0
  48. kb_memory-2.1.0/tests/test_n02_models.py +20 -0
  49. kb_memory-2.1.0/tests/test_n03_embedder.py +35 -0
  50. kb_memory-2.1.0/tests/test_n04_storage.py +55 -0
  51. kb_memory-2.1.0/tests/test_n05_bm25.py +32 -0
  52. kb_memory-2.1.0/tests/test_n06_retriever_service.py +62 -0
  53. kb_memory-2.1.0/tests/test_n07_api.py +43 -0
  54. kb_memory-2.1.0/tests/test_n08_api_ext.py +92 -0
  55. kb_memory-2.1.0/tests/test_n09_llm.py +65 -0
  56. kb_memory-2.1.0/tests/test_n10_ask.py +54 -0
  57. kb_memory-2.1.0/tests/test_n11_routing.py +81 -0
  58. kb_memory-2.1.0/tests/test_n12_mcp.py +74 -0
  59. kb_memory-2.1.0/tests/test_n13_ingest.py +45 -0
  60. kb_memory-2.1.0/tests/test_n13_ingest_extra.py +106 -0
  61. kb_memory-2.1.0/tests/test_n14_web.py +35 -0
  62. kb_memory-2.1.0/tests/test_n15_watcher.py +41 -0
  63. kb_memory-2.1.0/tests/test_n16_regression.py +29 -0
  64. kb_memory-2.1.0/tests/test_n17_logging.py +143 -0
  65. kb_memory-2.1.0/tests/test_n18_logs_api.py +177 -0
  66. kb_memory-2.1.0/tests/test_n18_logs_doc.py +24 -0
  67. kb_memory-2.1.0/tests/test_n18_monitor.py +508 -0
  68. kb_memory-2.1.0/tests/test_n19_nav.py +34 -0
  69. kb_memory-2.1.0/tests/test_n21_decay.py +264 -0
  70. kb_memory-2.1.0/tests/test_n21_metadata.py +138 -0
  71. kb_memory-2.1.0/tests/test_n22_dedup.py +167 -0
  72. kb_memory-2.1.0/tests/test_n22_governance.py +290 -0
  73. kb_memory-2.1.0/tests/test_n23_audit.py +277 -0
  74. kb_memory-2.1.0/tests/test_n23_cli.py +152 -0
  75. kb_memory-2.1.0/tests/test_n24_reranker.py +168 -0
  76. kb_memory-2.1.0/tests/test_n25_sparse.py +471 -0
  77. kb_memory-2.1.0/tests/test_n26_eval.py +211 -0
  78. kb_memory-2.1.0/tests/test_n27_perf.py +125 -0
  79. kb_memory-2.1.0/tests/test_n28_cli.py +200 -0
  80. kb_memory-2.1.0/tests/test_n29_security.py +69 -0
  81. kb_memory-2.1.0/tests/test_n30_mcp_stdio.py +143 -0
  82. kb_memory-2.1.0/tests/test_n31_serve_probe.py +173 -0
  83. kb_memory-2.1.0/tests/test_n32_hybrid_fusion_recall.py +97 -0
  84. kb_memory-2.1.0/tests/test_skill_package.py +116 -0
  85. kb_memory-2.1.0/tests/test_user_experience_fixes.py +160 -0
  86. kb_memory-2.1.0/tests/test_v21_bootstrap.py +98 -0
  87. kb_memory-2.1.0/tests/test_v21_i18n.py +75 -0
  88. kb_memory-2.1.0/tests/test_v21_packaging.py +73 -0
  89. kb_memory-2.1.0/tests/test_v21_runtime.py +110 -0
  90. kb_memory-2.1.0/tests/test_watcher_missing_dir.py +60 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 little-fishy
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,415 @@
1
+ Metadata-Version: 2.4
2
+ Name: kb-memory
3
+ Version: 2.1.0
4
+ Summary: Local-first agent memory & knowledge service: hybrid retrieval + memory governance (decay / dedup / freshness), REST + MCP dual protocol, fully usable offline without an LLM
5
+ Author: fish827-08
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/fish827-08/rag-kb
8
+ Project-URL: Repository, https://github.com/fish827-08/rag-kb
9
+ Keywords: mcp,memory,agent,rag,knowledge-base,local-first
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: fastapi<1.0,>=0.110
20
+ Requires-Dist: uvicorn[standard]<1.0,>=0.29
21
+ Requires-Dist: mcp<3.0,>=2.0
22
+ Requires-Dist: chromadb<2.0,>=1.5
23
+ Requires-Dist: rank_bm25<0.3,>=0.2.2
24
+ Requires-Dist: jieba<0.43,>=0.42
25
+ Requires-Dist: sentence-transformers<7.0,>=3.0
26
+ Requires-Dist: transformers<6,>=4.40
27
+ Requires-Dist: httpx<1.0,>=0.27
28
+ Requires-Dist: langchain-text-splitters<2.0,>=0.3
29
+ Requires-Dist: pydantic-settings<3.0,>=2.0
30
+ Requires-Dist: typer<1.0,>=0.12
31
+ Requires-Dist: rich<16.0,>=13.0
32
+ Provides-Extra: ingest
33
+ Requires-Dist: pypdf<7.0,>=4.0; extra == "ingest"
34
+ Requires-Dist: python-docx<2.0,>=1.1; extra == "ingest"
35
+ Requires-Dist: markitdown<0.2,>=0.1; extra == "ingest"
36
+ Requires-Dist: trafilatura<3.0,>=1.8; extra == "ingest"
37
+ Requires-Dist: lxml_html_clean<1.0,>=0.4; extra == "ingest"
38
+ Requires-Dist: watchdog<7.0,>=4.0; extra == "ingest"
39
+ Provides-Extra: llm
40
+ Requires-Dist: openai<4.0,>=1.0; extra == "llm"
41
+ Provides-Extra: full
42
+ Requires-Dist: pypdf<7.0,>=4.0; extra == "full"
43
+ Requires-Dist: python-docx<2.0,>=1.1; extra == "full"
44
+ Requires-Dist: markitdown<0.2,>=0.1; extra == "full"
45
+ Requires-Dist: trafilatura<3.0,>=1.8; extra == "full"
46
+ Requires-Dist: lxml_html_clean<1.0,>=0.4; extra == "full"
47
+ Requires-Dist: watchdog<7.0,>=4.0; extra == "full"
48
+ Requires-Dist: openai<4.0,>=1.0; extra == "full"
49
+ Dynamic: license-file
50
+
51
+ # rag-kb — 本地 Agent 记忆与知识服务
52
+
53
+ <!-- mcp-name: io.github.fish827-08/kb-memory -->
54
+
55
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
56
+ [![Glama MCP score](https://glama.ai/mcp/servers/fish827-08/rag-kb/badges/score.svg)](https://glama.ai/mcp/servers/fish827-08/rag-kb)
57
+ [English](README_EN.md) | 中文
58
+
59
+ **本地优先、完全离线可用的 Agent 记忆与知识服务**——REST + MCP 双协议,混合检索(向量 + BM25 归一化加权融合),文档/网页入库与 RAG 问答;无 LLM 时存取与检索完整可用。
60
+
61
+ <!-- GitHub Topics: mcp, memory-service, rag, ai-agent, knowledge-base, local-first, llm, claude-code, hybrid-search, embedding -->
62
+
63
+ **kb** 是本地优先、完全免费的 Agent 记忆与知识服务(v2.1.0 · 自动化回归全绿,待人工验收)。
64
+
65
+ > 开源协议:[Apache-2.0](LICENSE)(含专利授权,可商用)。
66
+
67
+ ## kb — 本地优先的 Agent 记忆与知识服务
68
+
69
+ Windows 单进程常驻(`python -m kb serve`),REST + MCP 双协议,向 Claude Code /
70
+ Cursor / TraeWork / 自建 Agent 提供记忆写入、文档与网页入库、混合检索
71
+ (向量 + BM25 归一化加权融合)与 RAG 问答。
72
+
73
+ **无 LLM 时存取与检索完整可用**——记忆写入、文档入库、混合检索不依赖任何大模型;
74
+ 配置本地 Ollama 或云端 API 后,`/ask` 问答能力自动启用。
75
+
76
+ ## 核心特性
77
+
78
+ - **单进程常驻**:一个 `python -m kb serve` 同时提供 REST API 与 MCP 端点,无需额外组件
79
+ - **混合检索**:向量检索 + BM25 关键词检索,归一化加权融合排序(每路 min-max 归一化后按生效路数均权,N32/N33),中文分词友好
80
+ - 嵌入模型:**默认 `BAAI/bge-small-zh-v1.5`(轻量,约 92 MB / 512 维)**——开箱成本低、CPU 上也快;需要更强语义理解可换 `BAAI/bge-m3`(约 2.2 GB / 1024 维),见「[嵌入模型怎么选](#嵌入模型怎么选)」
81
+ - 可选精排:`KB_RERANK_ENABLED=true` 启用 bge-reranker-v2-m3 交叉重排(默认关)
82
+ - 可选三路:`KB_SPARSE_ENABLED=true` 启用 BGE-M3 稀疏向量第三路(默认关,失败自动降级双路;需 bge-m3)
83
+ - **记忆管理**:写入 / 更新 / 删除 / 列表,支持 namespace、tags、type 过滤
84
+ - **记忆全共享**:所有记忆/知识与任何客户端、任务、AI 全共享——本地单用户定位,跨 agent、跨任务读到同一份用户记忆;client 仅用于审计归类与元数据;主键服务端生成
85
+ - **全局 + 分项目记忆(v2.1)**:不传 `project` 写入全局库;传 `project` 写入独立子库 `kb_data/projects/<project>/`(物理隔离,删目录即删项目记忆);带项目检索 = 项目子库 + 全局库加权合并(`KB_PROJECT_BOOST`)
86
+ - **PyPI 安装与依赖瘦身(v2.1)**:`pip install "kb-memory[ingest]"`,摄取/LLM 拆为可选 extras;Linux 可先装 CPU 版 torch,总下载量显著下降
87
+ - **Skill 自动安装与发现(v2.1)**:skill 内置 `bootstrap.py`,**询问用户同意后**才建独立环境安装;`kb where` 告诉你装在哪,`kb autostart enable` 开机自启
88
+ - **空闲卸载(v2.1)**:`KB_IDLE_UNLOAD_SECONDS` 到期自动卸载嵌入模型并释放显存,后台占用趋零
89
+ - **记忆语言与自定义规则(v2.1)**:`KB_MEMORY_LANG=auto` 跟随操作系统语言存储记忆;`~/.kb/rules.md` 自定义"什么时候该存记忆"
90
+ - **存取审计**:每次写/读/改/删/检索/问答记 JSON 到 `logs/agent-audit/<客户端>__<项目>.log`(按 client+project 分文件);用户可查:REST `GET /api/v1/audit?client=<客户端>[&project=<项目>]` 或 CLI `kb audit --client <客户端>`
91
+ - **知识入库**:本地文档(txt/md/pdf/docx 等)上传或路径导入,网页正文抓取入库
92
+ - **目录监听**:指定目录内新增/删除文件自动入库/清理(`KB_WATCH_DIR`)
93
+ - **CLI 工具**:`kb add/search/stats/ask/eval/forget/dedup`——终端直接完成写入、检索、统计与 RAG 问答
94
+ - **隐私护栏**:敏感 namespace 强制本地回答不出网;`/ask` 智能路由(本地优先,难题可选云端)
95
+ - **断网可用**:模型与数据全部落本地,无网络时存取与检索功能完整
96
+
97
+ ## 快速开始(Windows / Linux / macOS)
98
+
99
+ **从 PyPI 安装(推荐):**
100
+
101
+ ```bash
102
+ pip install "kb-memory[ingest]" # 核心 + 文档/网页摄取;[llm]=云端问答,[full]=全部
103
+ python -m kb serve
104
+ ```
105
+
106
+ **Linux 无显卡机器先装 CPU 版 torch**(PyPI 默认拉 CUDA 轮子,体积大得多):
107
+
108
+ ```bash
109
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
110
+ pip install "kb-memory[ingest]"
111
+ python -m kb serve
112
+ ```
113
+
114
+ **源码开发安装:**
115
+
116
+ ```powershell
117
+ python -m venv venv
118
+ .\venv\Scripts\Activate.ps1 # Linux/macOS: source venv/bin/activate
119
+ pip install -r requirements.txt
120
+ pip install -e ".[full]" # 开发/测试需要摄取、监听与 LLM 可选依赖
121
+ python -m kb serve
122
+ ```
123
+
124
+ > **首次安装要下载什么、大概多久**(先看一眼,避免以为卡死了):
125
+ > - 核心 Python 依赖约 **400–600 MB**(Windows CPU 版 `torch` 约 124 MB 为最大单体;
126
+ > Linux 先装 CPU 轮子可避免默认 CUDA 轮子带来的数 GB 下载);
127
+ > - 可选 `[ingest]` 额外约几十 MB(PDF/DOCX/Office 解析、网页提取、目录监听);
128
+ > - **首次写入/检索时**才加载并下载嵌入模型(懒加载,启动本身很轻),**默认 `bge-small-zh-v1.5` 约 92 MB**(若显式配了 `KB_EMBED_MODEL=BAAI/bge-m3`,则约 2.2 GB);
129
+ > - 国内网络建议加 pip 镜像(实测阿里云可用、清华可能 403):
130
+ > `pip install "kb-memory[ingest]" -i https://mirrors.aliyun.com/pypi/simple/`
131
+ > - 模型下载走 HuggingFace 镜像:`$env:HF_ENDPOINT='https://hf-mirror.com'`(Windows)/ `export HF_ENDPOINT=https://hf-mirror.com`(Linux、macOS)。
132
+ >
133
+ > 重要:用源码 venv 安装时 `kb` 命令只装在虚拟环境内。**每个新终端都要先激活虚拟环境**
134
+ > (Windows `.\venv\Scripts\Activate.ps1`,Linux/macOS `source venv/bin/activate`),
135
+ > 否则会提示 `kb:未找到命令`。改用 `python -m kb <子命令>` 可绕过激活。
136
+ > 不知道自己的 kb 装在哪里、怎么启动:`kb where`,或运行 skill 包里的
137
+ > `python bootstrap.py --status` / `--start-only`。
138
+
139
+ 启动后健康检查:
140
+
141
+ ```powershell
142
+ curl http://127.0.0.1:8000/api/v1/healthz
143
+ ```
144
+
145
+ > 嵌入模型采用懒加载:启动后空闲时几乎不占内存,**首次写入或检索**才加载
146
+ > `BAAI/bge-small-zh-v1.5`(约 92 MB,自动下载并缓存,之后断网可用);
147
+ > 未配置 LLM 时服务照常启动,`/ask` 返回 503 与配置指引。
148
+ > `/healthz` 的 `embedder` 字段会显示 `unloaded/loading/ok/error`,模型加载失败时
149
+ > 写/查请求返回 **503 `EMBED_MODEL_UNAVAILABLE`**(含模型名与修复建议),不再裸 500。
150
+ >
151
+ > **CPU 即可运行,不占显卡**:全新安装默认拿到 CPU 版 torch(`device=cpu`),
152
+ > 不占用 GPU 显存,无独立显卡的机器也能完整使用。有显卡想加速(大库、批量入库)
153
+ > 可另装 CUDA 版 torch,见 [AGENTS.md](AGENTS.md) 第 7 节;也可显式 `KB_DEVICE=cuda`。
154
+ >
155
+ > **LLM 默认关闭(`KB_LLM_MODE=off`)**:服务启动不会探测/加载/调用任何大模型,
156
+ > 零显存、零成本、纯离线;记忆写入、文档入库、混合检索完整可用。
157
+ > 需要 RAG 问答(`/ask`)时再按下面方式配置本地或云端 LLM。
158
+
159
+ ### 嵌入模型怎么选
160
+
161
+ 默认用轻量模型,是为了让"先试试"的成本足够低;模型不强绑定,可随时按需切换:
162
+
163
+ | 模型 | 体积 | 维度 | 加载后常驻内存 | 适用 |
164
+ |---|---|---|---|---|
165
+ | **`BAAI/bge-small-zh-v1.5`(默认)** | **约 92 MB** | 512 | 约 100 MB 量级 | 日常偏好/决策/笔记类记忆;CPU 上也快 |
166
+ | `BAAI/bge-m3` | 约 2.2 GB | 1024 | 约 2 GB | 长文档、跨语言、语义更微妙的内容,需要更强语义召回 |
167
+
168
+ > 本项目在自带 50 题中文评测集上的实测(`kb eval`):轻量模型 Recall@1 **0.760** / MRR **0.847** /
169
+ > 平均延迟 **28.6 ms**;bge-m3 为 0.740 / 0.841 / 105.6 ms。小样本下二者基本持平,轻量模型更快更省。
170
+ > 但 **bge-m3 在长文档与跨语言场景预期更强**,两个模型定位不同,按自己数据选。
171
+
172
+ **换模型前必读**:向量维度不同(512 vs 1024),ChromaDB 集合维度由首次写入的向量决定,
173
+ **换了模型后旧数据无法直接检索**。所以:
174
+
175
+ - **新库**(还没写过数据):直接设 `KB_EMBED_MODEL=BAAI/bge-m3` 即可;
176
+ - **已有数据的库**:kb 会自动**沿用建库时使用的模型**(记录在 `kb_data/runtime.json`),
177
+ 不会因默认值变化而破坏你的数据,启动日志会记录实际沿用的模型;
178
+ 若能识别的配置与库不一致(你显式改了 `KB_EMBED_MODEL`),还会给出 WARNING 说明如何迁移。
179
+ 确要换模型,请先备份,再清空 `kb_data/chroma` 后重新入库。
180
+
181
+ ### 配置 LLM(可选,`/ask` 问答需要)
182
+
183
+ `KB_LLM_MODE` 默认 `off`(不加载不调用);四个档位:
184
+
185
+ | 档位 | 行为 |
186
+ |---|---|
187
+ | `off`(默认) | 完全不加载/不调用 LLM;记忆存取与检索完整可用 |
188
+ | `local` | 仅本地 Ollama(完全离线,隐私零出网) |
189
+ | `auto` | **本地优先,云端降级**:本地 Ollama 可用走本地,无本地但有云端 Key 走云端 |
190
+ | `cloud` | 全部走云端(本地仅做压缩与隐私隔离) |
191
+
192
+ **本地 LLM(Ollama):**
193
+
194
+ ```powershell
195
+ # 1. 安装并启动 Ollama(Windows 从开始菜单/托盘启动,不要从 AI 沙箱终端拉起)
196
+ # 2. 拉取一个适合你电脑的模型(按显存/内存选择,如 qwen3:4b 约 3.2GB、
197
+ # qwen3:1.7b 约 1.8GB;国内可用魔搭加速,拉完 ollama cp 改成短名)
198
+ ollama pull <你的模型名>
199
+ # 3. 在 .env 配置后重启服务:
200
+ # KB_LLM_MODE=local # 仅本地
201
+ # KB_LLM_MODEL=<你的模型名> # 以 `ollama list` 输出的名称为准
202
+ # KB_OLLAMA_BASE_URL=http://localhost:11434
203
+ ```
204
+
205
+ **云端 LLM(任意 OpenAI 兼容服务商,不绑定 DeepSeek):**
206
+ DeepSeek / OpenAI / 通义千问 / 硅基流动 / Moonshot 等均可,通用三键:
207
+
208
+ ```ini
209
+ # .env
210
+ KB_LLM_MODE=auto # 本地优先、云端降级;或 cloud 全云端
211
+ KB_LLM_API_KEY=sk-xxx # 服务商 API Key
212
+ KB_LLM_BASE_URL=https://api.deepseek.com # 换成你所用服务商的 OpenAI 兼容端点
213
+ KB_LLM_CLOUD_MODEL=deepseek-v4-flash # 云端模型名
214
+ ```
215
+
216
+ 验证:`GET /api/v1/healthz` 的 `llm` 字段——`local`/`cloud` 表示 LLM 已就绪,`disabled` 表示未启用。
217
+
218
+ ### 常见问题:嵌入模型下载失败
219
+
220
+ - **中国大陆直连 `huggingface.co` 会超时**。设置 HF 镜像后重启即可:
221
+ ```bash
222
+ export HF_ENDPOINT=https://hf-mirror.com # 或写入 ~/.bashrc 永久生效
223
+ python -m kb serve
224
+ ```
225
+ 模型会自动从镜像下载并缓存到 `~/.cache/huggingface/hub/`,之后断网也能离线加载。
226
+ - **模型已在本机缓存,但无外网**:`kb` 采用离线优先(先命中本地缓存,失败才联网),
227
+ 只要缓存目录完整即可完全离线运行。
228
+
229
+ ## 让 Agent 接入 kb(客户端无关)
230
+
231
+ 把 kb 的接入规约交给 AI 客户端(TraeWork / Claude Code / Cursor / 自建 Agent),
232
+ 让它们知道怎么读写记忆、按什么身份规约、怎么查审计。**两种方式,任选其一**:
233
+
234
+ 1. **skill(推荐,能自动触发)——可选的独立步骤**:仓库内
235
+ [`skills/kb-memory/SKILL.md`](skills/kb-memory/SKILL.md)
236
+ 是客户端无关的 Anthropic 开格式 skill。把它安装到你所用客户端的用户级 skills 目录后,
237
+ 该客户端的任何项目会话都会在读写记忆/RAG 问答/审计查询时**自动识别并触发**。
238
+ 安装 = 把 `skills/kb-memory` 目录复制过去即可(有脚本,也可手动复制,无需任何依赖);
239
+ 更新(重新覆盖)、卸载、以及装好后的使用说明见
240
+ [`scripts/README.md`](scripts/README.md)。
241
+
242
+ > **不装也不影响 kb 服务**:skill 只是给 AI 客户端的「提示词包装」,与服务的安装、
243
+ > 启动无关——跳过这一步,服务照常运行,你随时可用方法 2 的纯文本提示词接入;
244
+ > skill 安装是**一次性、按需、独立执行**的,不会随 `kb serve` 自动触发,
245
+ > 也不会写入你的任何客户端目录以外的文件。
246
+ 2. **纯文本提示词(兜底,任何客户端通用)**:整段复制
247
+ [`docs/AGENT_PROMPT.md`](docs/AGENT_PROMPT.md) 粘贴给 Agent 即可,不依赖 skill 机制。
248
+
249
+ > **`.trae-cn/skills` / `.claude/skills` / `.cursor/skills` 是任何客户端都认的「标准」吗?——不是。**
250
+ > 这些只是各家客户端各自的**用户级约定目录**:`SKILL.md` 本身是统一的 Anthropic 开格式,
251
+ > 但「装到哪个目录、能否自动触发」由各客户端自行决定,支持程度不一:
252
+
253
+ | 客户端 | 用户级 skills 目录 | 自动加载 |
254
+ |---|---|---|
255
+ | TraeWork | `~/.trae-cn/skills/` | 自动发现 |
256
+ | Claude Code | `~/.claude/skills/` | 高版本支持 |
257
+ | Cursor | `~/.cursor/skills/` | 逐步跟进 |
258
+ | 其他 / 自建 Agent | 无统一约定 | 需手动加载或不支持 |
259
+
260
+ > 不存在「所有客户端都遵循」的统一目录;你的客户端若不支持 skill,**永远有方法 2 兜底**
261
+ > (粘贴 `AGENT_PROMPT.md`,纯文本任何客户端可用)。安装方法、各客户端目录差异与加载机制、
262
+ > 相互引用关系:详细见 [`scripts/README.md`](scripts/README.md)(此处不重复)。
263
+
264
+ ### 打包为独立 skill(Agensi / marketplace)
265
+
266
+ `skills/kb-memory/` 是 **kb 的独立交付单元**,只依赖 kb 服务本身:
267
+ 包含标准 front matter 的 `SKILL.md`(包根)、MCP 配置模板 `mcp.json`、配置模板
268
+ `env.example`、独立 README 与 LICENSE,覆盖「安装 → 启动 → 配置 → 验证 → 排障」全流程。
269
+
270
+ ```powershell
271
+ python scripts/build_skill_package.py # 产物:dist/kb-memory-skill-<版本>.zip
272
+ ```
273
+
274
+ zip 内 `SKILL.md` 位于**包根目录**,不含测试、运行数据或任何密钥;
275
+ 构建脚本会校验 front matter、自包含说明与敏感信息。可直接提交到 Agensi 这类
276
+ skill marketplace,用户拿到包后按 `SKILL.md` 即可把本机 kb 接入自己的 Agent。
277
+
278
+ ## MCP 挂载
279
+
280
+ MCP 端点(streamable HTTP):`http://127.0.0.1:8000/mcp/`
281
+
282
+ **Claude Code**:本仓库已内置项目级 `.mcp.json`,在本目录启动 Claude Code 即自动挂载;
283
+ 也可全局添加:
284
+
285
+ ```powershell
286
+ claude mcp add --transport http kb http://127.0.0.1:8000/mcp/
287
+ ```
288
+
289
+ **Cursor / TraeWork 及其他支持 MCP 的客户端**:在 MCP 配置中加入以下 JSON
290
+ (Cursor 放 `~/.cursor/mcp.json` 或项目 `.cursor/mcp.json`;TraeWork 在设置中添加 MCP 服务器):
291
+
292
+ ```json
293
+ {
294
+ "mcpServers": {
295
+ "kb": {
296
+ "type": "http",
297
+ "url": "http://127.0.0.1:8000/mcp/"
298
+ }
299
+ }
300
+ }
301
+ ```
302
+
303
+ 挂载后可用的 MCP 工具:`write_memory` / `search_memory` / `read_memory` /
304
+ `update_memory` / `delete_memory` / `add_document` / `add_webpage` / `ask_kb`。
305
+
306
+ > 启用 `KB_API_KEY` 鉴权后,MCP 客户端需在连接配置加 `headers`(`Authorization: Bearer <key>`);
307
+ > 仓库内 `.mcp.json` 模板不含真实 key(JSON 不支持注释),配法见 [USER_GUIDE §5.2](docs/USER_GUIDE.md#52-客户端适配n20启用鉴权后各客户端如何带-key)。
308
+
309
+ ## REST 端点速查
310
+
311
+ | 方法 | 路径 | 说明 |
312
+ |---|---|---|
313
+ | POST | `/api/v1/memories` | 写入记忆 `{content, tags?, source?, namespace?}` |
314
+ | GET | `/api/v1/memories` | 记忆列表,支持 `type/tag/source/q/limit/offset` 过滤 |
315
+ | GET | `/api/v1/memories/{id}` | 读取单条记忆 |
316
+ | PATCH | `/api/v1/memories/{id}` | 更新内容或标签 |
317
+ | DELETE | `/api/v1/memories/{id}` | 删除单条记忆 |
318
+ | POST | `/api/v1/search` | 混合检索 `{query, top_k?, mode?, type?, tag?}`,mode: `hybrid/vector/keyword` |
319
+ | POST | `/api/v1/documents` | 文档入库:multipart `file` 字段或 JSON `{"path": "本地路径"}` |
320
+ | GET | `/api/v1/documents` | 已入库文档列表(按 source 聚合) |
321
+ | DELETE | `/api/v1/documents/{source}` | 按 source 删除该文档全部记录(本地文件名等简单 source) |
322
+ | DELETE | `/api/v1/documents?source=<urlencoded>` | 按查询参数删除(**URL 等含斜杠的 source 必须用这个**) |
323
+ | POST | `/api/v1/ingest/web` | 网页入库 `{url}`,抓取正文切分入库;同 URL 重复入库自动替换旧记录 |
324
+ | POST | `/api/v1/ask` | RAG 问答 `{question}`;未配置 LLM 返回 503 |
325
+ | GET | `/api/v1/healthz` | 健康检查与服务统计(含 `embedder` 状态) |
326
+ | GET | `/api/v1/governance/stats` | 记忆治理统计:`total_count`/`avg_access_count`/`stale_90d_count`(只读) |
327
+ | GET | `/api/v1/governance/config` | 治理配置:衰减+新鲜度开关与参数(只读) |
328
+ | POST | `/api/v1/memories` → **409** | 启用语义去重(`KB_DEDUP_ENABLED=true`)后写入命中重复返回 409:`{"error":"DUPLICATE","duplicate_of":"<已有记录id>","similarity":<相似度>}`(不写入) |
329
+
330
+ > 记忆治理(去重/衰减/新鲜度)均默认关闭、零行为变化;用法见 [USER_GUIDE §3.5](docs/USER_GUIDE.md#35-记忆治理a3语义去重--衰减--新鲜度)。
331
+
332
+ 示例(Windows PowerShell 可直接复制;中文必须按 UTF-8 字节发送):
333
+
334
+ ```powershell
335
+ function Invoke-KbJson($Uri, $Body) {
336
+ Invoke-RestMethod -Uri $Uri -Method Post -ContentType 'application/json; charset=utf-8' `
337
+ -Body ([System.Text.Encoding]::UTF8.GetBytes(($Body | ConvertTo-Json -Depth 5)))
338
+ }
339
+
340
+ # 写入一条记忆
341
+ Invoke-KbJson http://127.0.0.1:8000/api/v1/memories @{ content = "用户偏好深色主题"; tags = @("偏好") }
342
+
343
+ # 混合检索
344
+ Invoke-KbJson http://127.0.0.1:8000/api/v1/search @{ query = "用户界面偏好"; top_k = 5 }
345
+
346
+ # 按 URL 删除网页文档(source 需 URL 编码;PowerShell 用 [uri]::EscapeDataString)
347
+ $src = [uri]::EscapeDataString("https://example.com/page")
348
+ Invoke-RestMethod -Uri "http://127.0.0.1:8000/api/v1/documents?source=$src" -Method Delete
349
+ ```
350
+
351
+ Linux / macOS 用 `curl`(`curl` 在这里是原生命令,不是 PowerShell 别名):
352
+
353
+ ```bash
354
+ curl -X POST http://127.0.0.1:8000/api/v1/memories \
355
+ -H "Content-Type: application/json" \
356
+ -d '{"content": "用户偏好深色主题", "tags": ["偏好"]}'
357
+ ```
358
+
359
+ ## 配置项简表
360
+
361
+ 全部配置以 `KB_` 前缀的环境变量或 `.env` 文件提供;完整键名见 [`.env.example`](.env.example)
362
+ (复制为 `.env` 后填写,`.env` 已被 gitignore,真实密钥只放本机,严禁入库)。
363
+
364
+ | 配置项 | 默认值 | 说明 |
365
+ |---|---|---|
366
+ | `KB_LLM_MODE` | `off` | LLM 模式:`off`(默认,不加载/不调用 LLM,零显存零成本)/ `local`(仅本地 Ollama)/ `auto`(本地优先,云端降级)/ `cloud` |
367
+ | `KB_DEVICE` | 空 | 嵌入模型设备:空=自动检测,可显式设 `cpu` / `cuda` |
368
+ | `KB_WATCH_DIR` | `data` | serve 模式监听目录,文件变动自动入库;空串或 `.` = 不启动 |
369
+ | `KB_DATA_DIR` | `kb_data` | 运行数据根目录(ChromaDB、运行时状态等) |
370
+ | `KB_API_HOST` / `KB_API_PORT` | `127.0.0.1` / `8000` | REST 与 MCP 监听地址 |
371
+ | `KB_EMBED_MODEL` | `BAAI/bge-small-zh-v1.5` | 嵌入模型(轻量默认,约 92 MB);可换 `BAAI/bge-m3`(约 2.2 GB,更强),见「嵌入模型怎么选」 |
372
+ | `KB_LLM_MODEL` | 空 | 本地 Ollama 模型名(默认空=不配;配 `KB_LLM_MODE=local/auto` 时须按自己电脑选模型,以 `ollama list` 为准) |
373
+ | `KB_OLLAMA_BASE_URL` | `http://localhost:11434` | Ollama 端点 |
374
+ | `KB_LLM_API_KEY` / `KB_LLM_BASE_URL` / `KB_LLM_CLOUD_MODEL` | 空 | 云端 LLM(可选):**任意 OpenAI 兼容服务商**(DeepSeek / OpenAI / 通义 / 硅基流动等),仅填在本机 `.env` |
375
+ | `KB_CHUNK_SIZE` / `KB_CHUNK_OVERLAP` | `500` / `100` | 文档切分参数 |
376
+ | `KB_SENSITIVE_NAMESPACES` | 空 | 逗号分隔的敏感 namespace,命中强制本地回答不出网 |
377
+ | `KB_API_KEY` | 空 | 空=不鉴权(本地回环零摩擦);非空=启用 Bearer/X-API-Key 鉴权 |
378
+ | `KB_RERANK_ENABLED` / `KB_RERANK_MODEL` / `KB_RERANK_TOP_N` | `false` / `BAAI/bge-reranker-v2-m3` / `20` | 检索精排(A3.5):融合候选送 CrossEncoder 重排,默认关 |
379
+ | `KB_SPARSE_ENABLED` | `false` | 稀疏第三路(A3.5):BGE-M3 稀疏向量 + 倒排索引参与归一化加权融合,默认关 |
380
+
381
+ ## CLI 速查(无需启动服务)
382
+
383
+ ```powershell
384
+ python -m kb add "记忆内容" --tags 偏好 --client TraeWork # 写入(project 缺省自动取当前目录名)
385
+ python -m kb search "查询词" --client TraeWork # 混合检索(v2.1:不传 project 查全局;传 project 合并子库)
386
+ python -m kb stats # 统计:类型分布 / 访问热度 / 陈旧分布
387
+ python -m kb ask "问题" --client TraeWork # 终端 RAG 问答(LLM 不可用时输出检索命中)
388
+ python -m kb audit --client TraeWork --days 7 # 查某客户端/项目存过/读过什么
389
+ python -m kb eval --file tests/eval_zh_50.jsonl # 检索质量评测(Recall@1/@5 + MRR)
390
+ python -m kb forget --stale --days 90 # 清理超期未命中记忆
391
+ python -m kb dedup --threshold 0.92 # 语义去重
392
+ ```
393
+
394
+ > `kb ask` 直连本地服务逻辑(不经 HTTP);建议 `serve` 停止时使用,避免双进程写库竞争。
395
+
396
+ ## 目录结构
397
+
398
+ ```
399
+ kb/ kb 服务源码(config / models / embedder / storage / bm25 / retriever /
400
+ service / llm / ingest / watcher / api / mcp / cli + reranker / sparse / eval)
401
+ tests/ kb 验收测试(417 项通过 / 1 跳过,含 eval_zh_50.jsonl 检索评测数据集)
402
+ docs/ 核心文档、当前设计(历史 spec/plan 已归档本地,不上传)
403
+ kb_data/ kb 运行数据(gitignore)
404
+ _archive/ 旧学习项目 + 历史 spec/plan 归档(仅本地保留,禁止参考)
405
+ ```
406
+
407
+ ## 更多文档
408
+
409
+ - **用户使用手册(人类用户入口)**:[docs/USER_GUIDE.md](docs/USER_GUIDE.md)
410
+ - **AI 接力文档(AI 助手入口)**:[PROJECT.md](PROJECT.md)(项目状态 / 进度看板 / 接手指南)
411
+ - 设计文档(需求、架构、API、里程碑):`docs/superpowers/specs/2026-08-23-kb-memory-service-design.md`
412
+ - **v2.1 设计(当前)**:`docs/superpowers/specs/2026-10-20-kb-v2.1-design.md`
413
+ - 开发者维护手册:`docs/DEV_HANDBOOK.md`
414
+ - AI 协作规范:`AGENTS.md`
415
+ - 历史 spec / 节点计划已归档到本地 `_archive/docs/`(不上传,不再作为开发依据)