@yungkei/geoplana 0.0.0-stage → 1.1.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 +201 -0
- package/README-zh.md +235 -0
- package/README.md +235 -3
- package/dist/adapters/opencode/index.d.ts +90 -0
- package/dist/adapters/opencode/index.js +260 -0
- package/dist/adapters/opencode/index.js.map +1 -0
- package/dist/chunk-3QZL6LY7.js +104 -0
- package/dist/chunk-3QZL6LY7.js.map +1 -0
- package/dist/chunk-6BJCPRH7.js +80 -0
- package/dist/chunk-6BJCPRH7.js.map +1 -0
- package/dist/chunk-6NY3OEIW.js +49 -0
- package/dist/chunk-6NY3OEIW.js.map +1 -0
- package/dist/chunk-IYTH6IE7.js +19 -0
- package/dist/chunk-IYTH6IE7.js.map +1 -0
- package/dist/chunk-J3S4NJ6B.js +2011 -0
- package/dist/chunk-J3S4NJ6B.js.map +1 -0
- package/dist/chunk-TGAZA6IU.js +46 -0
- package/dist/chunk-TGAZA6IU.js.map +1 -0
- package/dist/chunk-YGHYIQRK.js +46 -0
- package/dist/chunk-YGHYIQRK.js.map +1 -0
- package/dist/chunk-ZCE6KQO5.js +60 -0
- package/dist/chunk-ZCE6KQO5.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +577 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/events-KUYZEAKG.js +16 -0
- package/dist/events-KUYZEAKG.js.map +1 -0
- package/dist/handler-DAOFR5JH.js +142 -0
- package/dist/handler-DAOFR5JH.js.map +1 -0
- package/dist/index.d.ts +1021 -0
- package/dist/index.js +452 -0
- package/dist/index.js.map +1 -0
- package/dist/install-SLFDCAVQ.js +211 -0
- package/dist/install-SLFDCAVQ.js.map +1 -0
- package/dist/metrics-YMKFEUQK.js +11 -0
- package/dist/metrics-YMKFEUQK.js.map +1 -0
- package/dist/server-NPLFEU2Y.js +172 -0
- package/dist/server-NPLFEU2Y.js.map +1 -0
- package/dist/transfer-S5IMQ5JI.js +96 -0
- package/dist/transfer-S5IMQ5JI.js.map +1 -0
- package/package.json +73 -4
package/LICENSE
ADDED
|
@@ -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 use of permissions under the 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 yungkei
|
|
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.
|
package/README-zh.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Geoplana
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>通用 AI 外置记忆体</strong><br>
|
|
5
|
+
<em>双层存储 · 无损归档 · 压缩抢救 · 跨 agent 持久记忆</em>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="README.md">English</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/@yungkei/geoplana"><img src="https://img.shields.io/npm/v/%40yungkei%2Fgeoplana?style=flat&label=npm" alt="npm version"></a>
|
|
14
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat" alt="license">
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat&logo=node.js" alt="node version">
|
|
16
|
+
<img src="https://img.shields.io/badge/types-TypeScript-blue?style=flat&logo=typescript" alt="typescript">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
像涡虫(geoplana)一样:即使上下文被"切断"——上下文压缩、会话结束、模型切换——记忆也能完整再生。为 opencode、claude code 等 AI coding agent 提供本地持久记忆。
|
|
22
|
+
|
|
23
|
+
## 为什么选择 geoplana?
|
|
24
|
+
|
|
25
|
+
**你的 agent 的记忆有两个断点。**
|
|
26
|
+
一是**会话内**:上下文塞满时,agent 把历史压缩成 LLM 摘要——研究([Compact-Bench](https://arxiv.org/abs/2610.31710))表明,LLM 摘要最多只保留 **~16%** 的结构化细节(后续请求中还会再出现的那些)。二是**会话间**:会话一结束,没写下来的东西全部消失。geoplana 把两个断点都接上:
|
|
27
|
+
|
|
28
|
+
- **压缩前**,完整对话快照无损归档——没有任何内容被"摘要"掉。独立研究中,"纯文本日志 + 检索"方案的召回准确率达 **95–97%**,而有损基线最高只有 **21%**([GrepMem](https://arxiv.org/abs/2611.25123))
|
|
29
|
+
- **结构化提取**(确定性规则,而非 LLM 摘要)额外提炼值得保留的细节:同一基准中,纯机械提取保留了约 **79%** 的此类结构化细节——路径、提交 ID、错误类型、URL、配置项——而 LLM 摘要约 16%(约 **5 倍**)
|
|
30
|
+
- **跨会话、跨 agent**:同一份记忆跟着你从 opencode 到 claude code 到任何 MCP 兼容 agent,切换模型也不丢
|
|
31
|
+
|
|
32
|
+
**为承载多年记忆而建,值得信赖。**
|
|
33
|
+
|
|
34
|
+
- **本地优先、隐私可控**:单个 SQLite 文件,零云端依赖;`<private>` 内容永不落盘
|
|
35
|
+
- **任意语言可检索**:中、日、韩、泰、俄、阿拉伯等语言的全文检索真正可用
|
|
36
|
+
- **存储自管理**:热/温/冷三层(gzip 压缩后体积约为原来的 25%)、容量配额、遗忘曲线淘汰——常用的记忆永不衰减
|
|
37
|
+
- **你拍板,不是 AI 拍板**:冲突记忆只标注提醒,由你裁决(`memory_resolve`),绝不静默合并或删除
|
|
38
|
+
- **规则也留得住**:一项研究发现,第一次压缩摘要就会丢掉约 **1/3** 的任务约束,真实用户会话中"该如何工作、不该做什么"的规则被丢弃的频率约为"要做什么"规格的 **6 倍**([Salle et al., 2026](https://arxiv.org/abs/2610.31778))——geoplana 把这类规则作为 pinned 记忆跨会话保留
|
|
39
|
+
- **升级天然安全**:只增不毁的 schema 迁移、迁移前自动备份、旧版本会拒绝写入更新的数据库,避免损坏数据
|
|
40
|
+
|
|
41
|
+
**几分钟接入。** 一条命令接入 claude code(纯配置)或 opencode(薄 shim),也可以作为带类型的 npm 库嵌入你自己的 agent。
|
|
42
|
+
|
|
43
|
+
## 功能
|
|
44
|
+
|
|
45
|
+
- **双层存储**:提炼记忆(memories)+ 无损原始归档(episodes),SQLite + FTS5 多语言全文检索(中/日/韩/泰/俄/阿拉伯等),本地零依赖
|
|
46
|
+
- **本地查询扩展**:改写、跨语言、形态变体的查询同样能命中——内置中英概念表 + 意图相关词在匹配前扩展查询(不依赖模型、不联网);字面命中始终排在仅扩展命中之上
|
|
47
|
+
- **自动捕获**:决策、文件改动、命令、错误自动结构化提取;`<private>` 内容永不落盘
|
|
48
|
+
- **压缩抢救**:agent 上下文压缩前,完整对话快照自动归档
|
|
49
|
+
- **生命周期管理**:热/温/冷三层留存(gzip 压缩 + 归档导出),存储配额,遗忘曲线淘汰
|
|
50
|
+
- **使用保障**:`geoplana setup` 向 agent 指令文件(AGENTS.md / CLAUDE.md)写入记忆协议,告诉它何时检索、何时保存、冲突如何处理
|
|
51
|
+
- **冲突决策**:`memory_save` 发现相似记忆时返回 `conflicts` 而非静默覆盖;agent 向用户确认后调用 `memory_resolve`(keep-new / keep-old / keep-both)
|
|
52
|
+
- **MCP 工具**:`memory_save` / `memory_search` / `memory_get` / `memory_update` / `memory_delete` / `memory_list` / `memory_capture` / `memory_context` / `memory_resolve` / `memory_stats`
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/yungkei/geoplana.git
|
|
58
|
+
cd geoplana
|
|
59
|
+
npm install
|
|
60
|
+
npm run build
|
|
61
|
+
npm link # 使 geoplana 命令全局可用
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
数据存于 `~/.geoplana/geoplana.db`(环境变量 `GEOPLANA_HOME` 可覆盖)。
|
|
65
|
+
|
|
66
|
+
## 快速开始
|
|
67
|
+
|
|
68
|
+
### 接入 claude code(纯配置,零代码)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
geoplana setup claude-code
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
自动写入 `~/.claude/settings.json` hooks:会话开始注入记忆 → 每轮捕获 → 压缩前快照抢救。
|
|
75
|
+
|
|
76
|
+
### 接入 opencode(桥接 shim)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
geoplana setup opencode
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
复制 shim 插件到 `~/.config/opencode/plugins/`,并在 `opencode.json` 中注册 MCP 服务(其余设置保持不变):
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{ "mcp": { "geoplana": { "type": "local", "command": ["geoplana", "mcp"] } } }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
shim 是双代同体的 —— 同一个文件在加载时自动适配 opencode **V1**(≥1.16.2)与 **V2** 两套插件 API,无需按版本选择产物。`setup` 会检测本机安装的 opencode 世代并报告兼容性。
|
|
89
|
+
|
|
90
|
+
`setup` 还会把当前构建的指纹写入该服务条目。MCP 服务是长驻进程,升级后正在运行的那个仍会继续跑旧代码;指纹让 opencode 重启它、换上新构建。每次升级后重跑一次 `geoplana setup opencode`(在 opencode 里 `/reload` 也可以)。`geoplana doctor` 打印已安装的构建,`memory_stats` 报告运行中服务启动时的构建 —— 两者不一致就说明服务是旧的。
|
|
91
|
+
|
|
92
|
+
### 接入任意 MCP agent
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"geoplana": { "command": "geoplana", "args": ["mcp"] }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## CLI
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
geoplana save --namespace global --type decision --content "使用 Valkey 缓存" --importance 0.9
|
|
106
|
+
geoplana search "缓存方案" [--namespace a,b] [--limit 20]
|
|
107
|
+
geoplana list [--namespace a,b] [--type decision] # 别名: ls
|
|
108
|
+
geoplana get <id> / update <id> / delete <id> [--dry-run] # 别名: view / rm
|
|
109
|
+
geoplana resolve --new-id x --old-id y --action keep-new
|
|
110
|
+
geoplana context --namespace global,project:/repo
|
|
111
|
+
geoplana capture --namespace session:abc --kind message --content "..." --session-id abc
|
|
112
|
+
|
|
113
|
+
geoplana episodes list [--session s1] [--kind note] # 浏览无损归档层
|
|
114
|
+
geoplana episodes get <id> # 压缩记录读取时透明解压
|
|
115
|
+
geoplana export --output backup.jsonl.gz [--layer all] # 版本化备份
|
|
116
|
+
geoplana import backup.jsonl.gz [--dry-run] # 已存在的 id 自动跳过
|
|
117
|
+
|
|
118
|
+
geoplana stats # 存储用量、记忆类型分布、namespace 分布
|
|
119
|
+
geoplana stats --perf # 另附各事件的延迟分位数与结果计数器
|
|
120
|
+
geoplana stats --perf --event search,hook:recall:hits # 只看指定指标事件
|
|
121
|
+
geoplana gc [--dry-run] # 留存清理:压缩/导出/淘汰
|
|
122
|
+
geoplana migrate [--dry-run] # 把既有记忆重新归到共享 scope
|
|
123
|
+
geoplana doctor # schema 版本与完整性检查
|
|
124
|
+
geoplana mcp # 以 stdio 启动 MCP server
|
|
125
|
+
geoplana hook <event> # 通用 hook 处理器(agent 钩子调用)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 记忆的 scope
|
|
129
|
+
|
|
130
|
+
每条记忆都归属一个 scope,scope 决定谁读得到它。
|
|
131
|
+
|
|
132
|
+
| scope | namespace | 可见范围 | 内容 |
|
|
133
|
+
|---|---|---|---|
|
|
134
|
+
| global | `global` | 所有项目与会话 | 关于"怎么做"的规定 |
|
|
135
|
+
| project | `project:<path>` | 该仓库的所有会话 | 决策与偏好 |
|
|
136
|
+
| session | `session:<id>` | 仅该会话 | 执行过的命令、改过的文件、快照 |
|
|
137
|
+
|
|
138
|
+
一个会话读取 global + 自己所在的项目 + 自己。
|
|
139
|
+
|
|
140
|
+
自动抽取按"是否应当跨会话存活"来路由:
|
|
141
|
+
|
|
142
|
+
- 用户说出的**决策与偏好**进入 project scope
|
|
143
|
+
- **明确规定**(instruction)进入 global scope
|
|
144
|
+
- **事实、错误与上下文**留在 session scope —— 那是活动流水账,不是共享知识
|
|
145
|
+
|
|
146
|
+
两条规则保证共享 scope 不被污染:
|
|
147
|
+
|
|
148
|
+
- 只有**完整语句**才会被提升。半截话("改为复制 |")留在 session scope,因为共享 scope 会被之后每个会话读取
|
|
149
|
+
- 只有**用户自己的话**才会被提升。agent 复述自己的工作("改为路径无关:...")是在记录任务,不是在做决定
|
|
150
|
+
|
|
151
|
+
项目路径会做归一化(`D:\repo` 与 `D:/repo` 是同一个 namespace),每次捕获都会把项目目录记录到 episode 上。
|
|
152
|
+
|
|
153
|
+
`geoplana migrate` 把同样的规则应用到规则出现之前捕获的记忆:提升合格的语句、归一化 project namespace,并报告每一条被跳过的记忆及其原因。它不会删除任何东西。
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
geoplana migrate --dry-run # 预览
|
|
157
|
+
geoplana migrate # 执行
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`geoplana stats` 会输出 `durableScope`:
|
|
161
|
+
|
|
162
|
+
- `shared` —— 位于 global 或 project scope 的持久记忆,之后每个会话都读得到
|
|
163
|
+
- `locked` —— 符合共享条件却仍留在 session scope 的持久记忆,也就是 `geoplana migrate` 会搬走的那部分积压
|
|
164
|
+
- `sessionOnly` —— 仍留在 session scope 的全部持久记忆,含那些本就不该共享的片段
|
|
165
|
+
|
|
166
|
+
## 配置
|
|
167
|
+
|
|
168
|
+
`~/.geoplana/config.json`(全部可选,有默认值):
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"dbPath": "~/.geoplana/geoplana.db",
|
|
173
|
+
"embedding": { "provider": "none" },
|
|
174
|
+
"capture": { "maxExtractChars": 20000 },
|
|
175
|
+
"recall": { "intent": true, "expansion": true, "limit": 3 },
|
|
176
|
+
"retention": {
|
|
177
|
+
"hotDays": 30,
|
|
178
|
+
"snapshotHotDays": 90,
|
|
179
|
+
"coldDays": 365,
|
|
180
|
+
"evictThreshold": 0.02,
|
|
181
|
+
"protectRecentDays": 14,
|
|
182
|
+
"maxStorageMb": 500,
|
|
183
|
+
"autoGc": true
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
| 配置项 | 说明 |
|
|
189
|
+
| ----------------- | ------------------------------------------------------------------------------------- |
|
|
190
|
+
| `recall.intent` | 对召回提示做意图识别(关键词启发式,无 LLM),并对匹配的记忆类型做加权;`false` 关闭加权 |
|
|
191
|
+
| `recall.expansion` | 用概念同义词与意图相关词扩展检索查询(本地,无模型);`false` 关闭扩展 |
|
|
192
|
+
| `recall.limit` | 每次召回注入返回的记忆条数 |
|
|
193
|
+
| `hotDays` | episodes 原文可检索的热窗口天数 |
|
|
194
|
+
| `coldDays` | 压缩层保留天数,`-1` = 永久留存,`0` = 压缩后立即导出 |
|
|
195
|
+
| `maxStorageMb` | DB 体积配额,超限自动升级清理 |
|
|
196
|
+
| `evictThreshold` | 遗忘曲线淘汰阈值(pinned 记忆永不淘汰) |
|
|
197
|
+
| `autoGc` | MCP server 启动时自动执行 GC |
|
|
198
|
+
|
|
199
|
+
环境变量:`GEOPLANA_HOME`(数据目录)、`GEOPLANA_CMD`(agent shim 调用的命令路径)、`GEOPLANA_RECALL=1`(opencode 每轮自动召回)、`GEOPLANA_DEBUG=1`(调试日志)。
|
|
200
|
+
|
|
201
|
+
## 作为库使用
|
|
202
|
+
|
|
203
|
+
geoplana 也是 npm 包(`@yungkei/geoplana`),第三方程序可直接依赖调用:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npm install @yungkei/geoplana
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { Geoplana, createStorage, createMemoryStorage } from "@yungkei/geoplana"
|
|
211
|
+
|
|
212
|
+
const geoplana = new Geoplana(createStorage("/path/to/geoplana.db"))
|
|
213
|
+
|
|
214
|
+
geoplana.memories.save({ namespace: "global", type: "decision", content: "使用 Valkey 缓存" })
|
|
215
|
+
const hits = geoplana.search.search({ query: "缓存", includeEpisodes: false })
|
|
216
|
+
const bundle = geoplana.context.build({ namespaces: ["global"] })
|
|
217
|
+
|
|
218
|
+
geoplana.close()
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
全部核心服务均有类型导出:`memories` / `search` / `capture` / `context` / `retention`。如需自定义存储引擎,实现 `Storage` 接口并传入 `Geoplana` 构造函数即可。
|
|
222
|
+
|
|
223
|
+
## 开发
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm test # 单元测试
|
|
227
|
+
npm run typecheck # 类型检查
|
|
228
|
+
npm run lint # biome 规范检查
|
|
229
|
+
npm run check:i18n # 国际化守卫
|
|
230
|
+
npm run build # 构建到 dist/
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 许可协议
|
|
234
|
+
|
|
235
|
+
[Apache-2.0](LICENSE) © 2026 yungkei
|